Game Driver: Fix EnableForAllApps switch and test

Bug: 123707483
Bug: 119221883
Test: Build, flash, boot and make RunSettingsRoboTests
Change-Id: Iffbe3355b37763d4fa71b96271c1ba448fb6cdc5
This commit is contained in:
Yiwei Zhang
2019-01-31 18:25:00 -08:00
parent 374495a865
commit ccc81a83cc
3 changed files with 29 additions and 13 deletions

View File

@@ -79,19 +79,21 @@ public class GameDriverGlobalSwitchBarController
@Override
public boolean onSwitchToggled(boolean isChecked) {
if (!isChecked) {
Settings.Global.putInt(
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_OFF);
final int gameDriver = Settings.Global.getInt(
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
if (isChecked
&& (gameDriver == GAME_DRIVER_DEFAULT || gameDriver == GAME_DRIVER_ALL_APPS)) {
return true;
}
if (Settings.Global.getInt(
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
!= GAME_DRIVER_ALL_APPS) {
Settings.Global.putInt(
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
if (!isChecked && gameDriver == GAME_DRIVER_OFF) {
return true;
}
Settings.Global.putInt(mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS,
isChecked ? GAME_DRIVER_DEFAULT : GAME_DRIVER_OFF);
return true;
}