0

I am using a custom AOSP build with an system application, with single activity, where the user can enable or disable screen time off.

The lock screen is disables from :

<bool name="def_lockscreen_disabled">true</bool> 

at frameworks/base/packages/SettingsProvider/res/values/defaults.xml

I tired by following approached but it didn't worked.

Settings.System.putInt(
                context.contentResolver,
                Settings.System.SCREEN_OFF_TIMEOUT,
                timeOut
            )

So I tried the following approach and it almost worked.

/**
     * This function enables the auto-dim,
     * The screen will turn off after 10 minutes
     * */
    private fun enableAutoDim() {
        window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
        setTurnScreenOn(false)
    }

/**
     * This disables the auto-dim feature.
     * The screen will always remain on
     * */
    private fun disableAutoDim() {
        window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
        //setTurnScreenOn(true)
    }

The only issue is, once the screen is turned off and user touched, the screen is not only turning on it is also passing the touch event to the application.

I want the screen to turn up only, on first touch and then the user touch to be passed to the window. How can I disable touch once the screen is off.

-    <bool name="def_dim_screen">true</bool>
-    <integer name="def_screen_off_timeout">60000</integer>
+    <bool name="def_dim_screen">false</bool>
+    <integer name="def_screen_off_timeout">600000</integer>
     <integer name="def_sleep_timeout">-1</integer>

The CPU should always be on so I had aquired the PARTIAL_WAKE_LOCK. As I am using a particular chip, it doesn't support double-tap to wake up.

0 Answers0