Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 77c687eb authored by Ben Reich's avatar Ben Reich
Browse files

Log the initial screen off and sleep timeout values

There appears to be an emerging cluster of errors that seem to find both
the initialScreenOffTimeoutValue and initialSleepTimeoutValue values as
null. This is puzzling as the values should be retrieved in the setUp
then restored in the tearDown. Let's log these values as warnings to we
can inspect logcat to see if they're being retrieved during setup. My
initial hunch is that either the value being returned is null OR the
setup is failing and the teardown is always being run. This should shed
some more light though.

This also removes the unused resetStorage which stopped being used in
http://ag/32833099.

Bug: 409044744
Bug: 408942389
Test: m DocumentsUIGoogle
Flag: EXEMPT test only change
Change-Id: I3772544b8a62bf5621b0034cd08d3a4cff9d8ae8
parent 30139568
Loading
Loading
Loading
Loading
+7 −5
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.Context
import android.content.Intent
import android.content.Intent
import android.os.RemoteException
import android.os.RemoteException
import android.provider.DocumentsContract
import android.provider.DocumentsContract
import android.util.Log
import android.view.KeyEvent
import android.view.KeyEvent
import android.view.MotionEvent
import android.view.MotionEvent
import androidx.test.core.app.ActivityScenario
import androidx.test.core.app.ActivityScenario
@@ -152,11 +153,6 @@ abstract class ActivityTestJunit4<T : Activity?> {
        mActivityScenario = ActivityScenario.launch(intent)
        mActivityScenario = ActivityScenario.launch(intent)
    }
    }


    @Throws(RemoteException::class)
    protected fun resetStorage() {
        device!!.waitForIdle()
    }

    @Throws(IOException::class)
    @Throws(IOException::class)
    private fun disableScreenOffAndSleepTimeouts() {
    private fun disableScreenOffAndSleepTimeouts() {
        initialScreenOffTimeoutValue = device!!.executeShellCommand(
        initialScreenOffTimeoutValue = device!!.executeShellCommand(
@@ -165,6 +161,11 @@ abstract class ActivityTestJunit4<T : Activity?> {
        initialSleepTimeoutValue = device!!.executeShellCommand(
        initialSleepTimeoutValue = device!!.executeShellCommand(
            "settings get secure sleep_timeout"
            "settings get secure sleep_timeout"
        )
        )
        Log.w(
            TAG,
            """initialScreenOffTimeoutValue = '$initialScreenOffTimeoutValue'
                |initialSleepTimeoutValue = '$initialSleepTimeoutValue'""".trimMargin()
        )
        device!!.executeShellCommand("settings put system screen_off_timeout -1")
        device!!.executeShellCommand("settings put system screen_off_timeout -1")
        device!!.executeShellCommand("settings put secure sleep_timeout -1")
        device!!.executeShellCommand("settings put secure sleep_timeout -1")
    }
    }
@@ -192,5 +193,6 @@ abstract class ActivityTestJunit4<T : Activity?> {


    companion object {
    companion object {
        const val TIMEOUT = 5000
        const val TIMEOUT = 5000
        const val TAG = "ActivityTestJunit4"
    }
    }
}
}