Disable Play auto-update during tests
For devices using Play services, disable auto-update during tests, as it may interfere with them. For example, Webview may be killed if it is opened while the update is applied. Bug: 263665773 Test: atest Change-Id: I9613d739ad0763c882a1971879aa743f4541a75c
This commit is contained in:
parent
e2b5213774
commit
90edff826a
1 changed files with 20 additions and 1 deletions
|
|
@ -48,6 +48,11 @@ open class ConnectivityTestTargetPreparer : BaseTargetPreparer() {
|
|||
|
||||
override fun setUp(testInformation: TestInformation) {
|
||||
if (isDisabled) return
|
||||
disableGmsUpdate(testInformation)
|
||||
runPreparerApk(testInformation)
|
||||
}
|
||||
|
||||
private fun runPreparerApk(testInformation: TestInformation) {
|
||||
installer.setCleanApk(true)
|
||||
installer.addTestFileName(CONNECTIVITY_CHECKER_APK)
|
||||
installer.setShouldGrantPermission(true)
|
||||
|
|
@ -90,8 +95,22 @@ open class ConnectivityTestTargetPreparer : BaseTargetPreparer() {
|
|||
testInformation.device.deviceDescriptor)
|
||||
}
|
||||
|
||||
override fun tearDown(testInformation: TestInformation?, e: Throwable?) {
|
||||
private fun disableGmsUpdate(testInformation: TestInformation) {
|
||||
// This will be a no-op on devices without root (su) or not using gservices, but that's OK.
|
||||
testInformation.device.executeShellCommand("su 0 am broadcast " +
|
||||
"-a com.google.gservices.intent.action.GSERVICES_OVERRIDE " +
|
||||
"-e finsky.play_services_auto_update_enabled false")
|
||||
}
|
||||
|
||||
private fun clearGmsUpdateOverride(testInformation: TestInformation) {
|
||||
testInformation.device.executeShellCommand("su 0 am broadcast " +
|
||||
"-a com.google.gservices.intent.action.GSERVICES_OVERRIDE " +
|
||||
"--esn finsky.play_services_auto_update_enabled")
|
||||
}
|
||||
|
||||
override fun tearDown(testInformation: TestInformation, e: Throwable?) {
|
||||
if (isTearDownDisabled) return
|
||||
installer.tearDown(testInformation, e)
|
||||
clearGmsUpdateOverride(testInformation)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue