0

I am trying to write values using putInt. The settings I am trying to write into are -

"android.settings.CAMERA_COVER_STATUS"

"android.settings.MIC_SWITCH_STATUS"

I am not sure if the above-mentioned settings are proper or not. But when I try to write values on them I get the following errors -

2021-09-25 22:48:04.371 WARNING  logcat: System.err(4223): java.lang.IllegalArgumentException: You cannot keep your settings in the secure settings.
2021-09-25 22:48:04.371 WARNING  logcat: System.err(4223):  at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:165)
2021-09-25 22:48:04.371 WARNING  logcat: System.err(4223):  at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
2021-09-25 22:48:04.371 WARNING  logcat: System.err(4223):  at android.content.ContentProviderProxy.call(ContentProviderNative.java:651)
2021-09-25 22:48:04.371 INFO     logcat: LYNC PAL(6468): findClass java/net/Inet6Address loader 0x23c6
2021-09-25 22:48:04.371 WARNING  logcat: System.err(4223):  at android.provider.Settings$NameValueCache.putStringForUser(Settings.java:1851)
2021-09-25 22:48:04.371 WARNING  logcat: System.err(4223):  at android.provider.Settings$System.putStringForUser(Settings.java:2275)
2021-09-25 22:48:04.371 WARNING  logcat: System.err(4223):  at android.provider.Settings$System.putIntForUser(Settings.java:2380)
2021-09-25 22:48:04.372 INFO     logcat: LYNC PAL(6468): findClass java/net/Inet4Address loader 0x23c6
2021-09-25 22:48:04.372 WARNING  logcat: System.err(4223):  at android.provider.Settings$System.putInt(Settings.java:2374)
2021-09-25 22:48:04.372 WARNING  logcat: System.err(4223):  at 
2021-09-25 22:48:04.372 WARNING  logcat: System.err(4223):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
2021-09-25 22:48:04.372 WARNING  logcat: System.err(4223):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
2021-09-25 22:48:04.372 WARNING  logcat: System.err(4223):  at java.lang.Thread.run(Thread.java:764)

Any kind of suggestion and help will greatly appreciated.

Naseef Chowdhury
  • 2,357
  • 3
  • 28
  • 52
  • 1
    https://stackoverflow.com/questions/32266425/android-6-0-permission-denial-requires-permission-android-permission-write-sett/35285034#35285034 This might answer your question – MoonLight Sep 27 '21 at 08:35
  • @MoonLight not actually. I am not quite sure if the properties are right. – Naseef Chowdhury Sep 27 '21 at 15:03

1 Answers1

0

Fixed. Had to use the System Settings prefix to solve the issue. Added prefix "settings://system/" before the settings key. Now the keys become as following -

"settings://system/android.settings.CAMERA_COVER_STATUS"

"settings://system/android.settings.MIC_SWITCH_STATUS"

Also tested the values using the following code -

cameraStatus = Settings.System.getInt(this.getContentResolver(),"android.settings.CAMERA_COVER_STATUS",1);
micStatus =Settings.System.getInt(this.getContentResolver(),"android.settings.MIC_SWITCH_STATUS", 1);

They seems to be working fine.

Note: Added the answer myself so that if anyone faces similar issue, it might help.

Naseef Chowdhury
  • 2,357
  • 3
  • 28
  • 52