VIBRATE permission as optional
Asked Answered
P

2

7

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

Place answered 17/7, 2017 at 10:39 Comment(0)
P
1

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" />
Place answered 7/9, 2021 at 18:42 Comment(0)
J
0

This permission is not explicitely requested during install, so i assume it's not mandatory at least on sdk 26

from adb there won't be any change of state for it

adb shell pm grant com.pixeemedical.kneeplus android.permission.VIBRATE

Operation not allowed: java.lang.SecurityException: Permission android.permission.VIBRATE is not a changeable permission type

I hope this can help give more insight about your inquiry

Jonellejones answered 10/1, 2023 at 21:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.