Reading and Writing System Settings (settings)¶
You can use FIRERPA's Settings-related interfaces to configure some Android system parameters or read system settings. This feature can accomplish many specific tasks, for example, setting screen brightness, toggling developer mode, or even adjusting ringtone volume. Here, we will only provide some simple examples.
Calling Interfaces¶
If you are still confused, don't worry; we will explain everything in detail later. Before you start, you need to get a Settings instance. You can call it like this:
settings = d.stub("Settings")
Then, you can execute the following code to set the system screen brightness to manual mode. This way, your device's screen brightness will not change with the ambient light, allowing you to set a fixed brightness level.
settings.put_system("screen_brightness_mode", "0")
You can use the following two interfaces to get the current screen brightness and then set the screen brightness to 5.
settings.get_system("screen_brightness")
settings.put_system("screen_brightness", "5")
You can also use the following two interfaces to check if developer mode is enabled, and then disable it.
settings.get_global("development_settings_enabled")
settings.put_global("development_settings_enabled", "0")
You can also use the following two interfaces to check if the screensaver is enabled, and then disable it.
settings.get_secure("screensaver_enabled")
settings.put_secure("screensaver_enabled", "0)
Alright, that concludes the introduction. The examples above are just to guide you on how to use these features. You can continue reading to unlock their full potential.
Available Parameters¶
If you are wondering about strings like screen_brightness, this section is for you. The available parameters for this interface depend entirely on what the system supports. You should be aware that some constants may not be compatible across different Android versions, and some manufacturers may have custom variables. You can find the relevant available parameters in the official Android documentation linked below. You can use the fields from these documents with the interfaces described above to configure system settings.
https://developer.android.com/reference/android/provider/Settings.System https://developer.android.com/reference/android/provider/Settings.Secure https://developer.android.com/reference/android/provider/Settings.Global