2

I am making a flash light app. So naturally most devices now a days have a built in flash for the camera but when a flash is not present I want to use the screen as the flash light. To make this functionality work I want to adjust the screen brightness so it can act as the flashlight. To change the brightness I used code from this post. The code works fine and I can change the brightness without issue. As a side note this code I used works on Physical android 8.1, 10 and 11 devices.

My first question comes from a lint warning I get when adding the <uses-permission android:name="android.permission.WRITE_SETTINGS"/> permission. The warning says "Permission is only granted to system apps". Now I can obviously just suppress this warning, but my worry is when I upload the app to the app store Google will either reject the AAB or the app will no longer be a "System app" once its downloaded from the app store. Will suppressing the error do anything?

My second question is is this a false positive? Looking at the manifest permission docs WRITE_SETTINGS has no special permission besides for having to get the users consent buuuut WRITE_SECURE_SETTINGS definitely does. As per the docs for WRITE_SECURE_SETTINGS "Allows an application to read or write the secure system settings. Not for use by third-party applications." So could this be lint thinking WRITE_SETTINGS is WRITE_SECURE_SETTINGS?

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • As an addendum to my question I can obviously just have the user adjust the brightness manually but If possible I would like to avoid this. – Alexander Robinson Jun 23 '21 at 11:22
  • Why can't you use Window manager for brightness – Usama Altaf Jun 23 '21 at 11:27
  • I tried using Window manager and it didn't work. I only managed to get the brightness to change after getting user permission and using 'Settings.System.putInt( mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, brightness );' – Alexander Robinson Jun 23 '21 at 11:39
  • Does this answer your question? [Is android.permission.WRITE\_SETTINGS only granted to system apps?](https://stackoverflow.com/questions/63192108/is-android-permission-write-settings-only-granted-to-system-apps) – javdromero Jun 23 '21 at 14:02
  • Hi @javdromero. It does not. Pretty much left with the same questions as before. What I'm going to do is leave the permission in and see what Google does when I try to upload it to the app store. If Google doesn't complain il try implementing the functionality and see what happens then. Will update my question with the outcome once the app goes live and I can download it. – Alexander Robinson Jun 23 '21 at 14:41

0 Answers0