Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VIBRATE permission as optional

I have an app (already released) in which I've developed new feature with vibration. So I've added new permission:

<uses-permission 
    android:name="android.permission.VIBRATE" />

After releasing update I've noticed that my Nexus 7 2013 didn't get update, probably because this device don't have Vibrator at all... So in next release I've changed above line to

<uses-feature
    android:name="android.permission.VIBRATE"
    android:required="false"/>

Which is probably inproper btw... And my Nexus updated successfully then. But now I'm seeing occasional crashes on devices 4.0-4.3

Fatal Exception: java.lang.SecurityException Requires VIBRATE permission

As far as I know line android:required is applicable only for uses-feature and not for uses-permission, so question is: how to declare proper permission for VIBRATE allowing to install on not-having-vibrations devices and also avoiding SecurityException on older, unfortunatelly still supported, devices?

PS. currently I'm thinking that proper perm declaration should look like below, but I don't want to "test" declarations on production environment. Can anybody confirm?

<uses-permission 
    android:name="android.permission.VIBRATE"
    android:maxSdkVersion="18" />

basing on crashes and still-working vibrations on newer devices even with probably inproper for VIBRATOR uses-feature declaration (so no permission in fact currently). Maybe since KitKat there is no need to declare vibrations perm like writing on SD? I can't find anything about that in docs... Also: above declaration is present in Wikipedia official app

EDIT - more complex info: Rel number 100 introduced uses-permission, Nexus 7 didn't get an update. Week later 101 was released without any changes in manifest (besides version number ofc) and code related to this new feature (bugfixes in another components), Nexus still without update. Next week and rel 102, no change. Then I've changed to uses-feature in 103 and Nexus get update same day... and since this version crashes started to occur on 4.0-4.3

like image 354
snachmsm Avatar asked Jul 17 '17 10:07

snachmsm


1 Answers

4 years later nobody confirmed, so I will: snippet posted in question is proper declaration

<uses-permission 
    android:name="android.permission.VIBRATE"
    android:maxSdkVersion="18" />
like image 104
snachmsm Avatar answered Oct 26 '22 08:10

snachmsm