You need to ask if you want an Android to vibrate

I posted a few days ago about a new little app I stuck in the Android Market. An error report appeared from the app in the Market last night that I thought was interesting.

The app does some stuff in the background then when it’s finished, it sticks a notification in the top status bar. In my code, I just use the default notification settings – LED flash, vibrate, etc. And on every Android I’ve tested it on, it’s been fine.

But for one user, it caused the app to crash:

Exception class java.lang.SecurityException

Source method Parcel.readException()

java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:200)
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
at java.lang.Thread.run(Thread.java:1102)
Caused by: java.lang.SecurityException: Requires VIBRATE permission
at android.os.Parcel.readException(Parcel.java:1247)
at android.os.Parcel.readException(Parcel.java:1235)
at android.app.INotificationManager$Stub$Proxy.enqueueNotificationWithTag(INotificationManager.java:368)
at android.app.NotificationManager.notify(NotificationManager.java:110)
at android.app.NotificationManager.notify(NotificationManager.java:90)
at com.dalelane.lovefilm.data.ImageProcessService.publishUpdateNotification(ImageProcessService.java:281)
at com.dalelane.lovefilm.data.ImageProcessService.access$0(ImageProcessService.java:234)
at com.dalelane.lovefilm.data.ImageProcessService$ImageProcesser.doInBackground(ImageProcessService.java:215)
at com.dalelane.lovefilm.data.ImageProcessService$ImageProcesser.doInBackground(ImageProcessService.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:185)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
... 4 more

It’s pretty obvious what the bug is – “java.lang.SecurityException: Requires VIBRATE permission” is a bit of a giveaway!

I didn’t include android.permission.VIBRATE in the list of permissions that the app explicitly asks for on install. And on every Android I’ve tried that’s not caused a problem.

But for one user, their phone kicked the app out for trying to use vibrate without permission.

Thanks to them (whoever they are!) for clicking the “Report…” button and letting me know. They even added “HTC Desire Froyo” to the user comments, so I know which device this caused a problem on, too.

I’ve talked about the Android Market developer site before but it’s worth mentioning again – it’s very cool that it’s so easy for a user to let me know when there is a problem, and that I can push out a quick fix within 24 hours. And for users with devices running Android 2.2, it can even be updated automatically too.

Moral of the story: don’t rely on testing to show you which permissions your app needs. Go through the list of possible permissions yourself, and include anything that you think your app uses.

Tags: ,

Comments are closed.