RIM posts higher-than-expected earnings