Merge "Loading boost: use the existing GAME_LOADING power mode, and deactivate it on a timer." into tm-dev
This commit is contained in:
@@ -121,7 +121,10 @@ public final class GameManagerService extends IGameManagerService.Stub {
|
|||||||
static final int REMOVE_SETTINGS = 2;
|
static final int REMOVE_SETTINGS = 2;
|
||||||
static final int POPULATE_GAME_MODE_SETTINGS = 3;
|
static final int POPULATE_GAME_MODE_SETTINGS = 3;
|
||||||
static final int SET_GAME_STATE = 4;
|
static final int SET_GAME_STATE = 4;
|
||||||
|
static final int CANCEL_GAME_LOADING_MODE = 5;
|
||||||
static final int WRITE_SETTINGS_DELAY = 10 * 1000; // 10 seconds
|
static final int WRITE_SETTINGS_DELAY = 10 * 1000; // 10 seconds
|
||||||
|
static final int LOADING_BOOST_MAX_DURATION = 5 * 1000; // 5 seconds
|
||||||
|
|
||||||
static final PackageOverride COMPAT_ENABLED = new PackageOverride.Builder().setEnabled(true)
|
static final PackageOverride COMPAT_ENABLED = new PackageOverride.Builder().setEnabled(true)
|
||||||
.build();
|
.build();
|
||||||
static final PackageOverride COMPAT_DISABLED = new PackageOverride.Builder().setEnabled(false)
|
static final PackageOverride COMPAT_DISABLED = new PackageOverride.Builder().setEnabled(false)
|
||||||
@@ -299,6 +302,10 @@ public final class GameManagerService extends IGameManagerService.Stub {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case CANCEL_GAME_LOADING_MODE: {
|
||||||
|
mPowerManagerInternal.setPowerMode(Mode.GAME_LOADING, false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1028,9 +1035,22 @@ public final class GameManagerService extends IGameManagerService.Stub {
|
|||||||
if (gameMode == GameManager.GAME_MODE_UNSUPPORTED) {
|
if (gameMode == GameManager.GAME_MODE_UNSUPPORTED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final int loadingBoostDuration = getLoadingBoostDuration(packageName, userId);
|
int loadingBoostDuration = getLoadingBoostDuration(packageName, userId);
|
||||||
if (loadingBoostDuration != -1) {
|
if (loadingBoostDuration != -1) {
|
||||||
mPowerManagerInternal.setPowerBoost(Mode.GAME_LOADING, loadingBoostDuration);
|
if (loadingBoostDuration == 0 || loadingBoostDuration > LOADING_BOOST_MAX_DURATION) {
|
||||||
|
loadingBoostDuration = LOADING_BOOST_MAX_DURATION;
|
||||||
|
}
|
||||||
|
if (mHandler.hasMessages(CANCEL_GAME_LOADING_MODE)) {
|
||||||
|
// The loading mode has already been set and is waiting to be unset. It is not
|
||||||
|
// required to set the mode again and we should replace the queued cancel
|
||||||
|
// instruction.
|
||||||
|
mHandler.removeMessages(CANCEL_GAME_LOADING_MODE);
|
||||||
|
} else {
|
||||||
|
mPowerManagerInternal.setPowerMode(Mode.GAME_LOADING, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
mHandler.sendMessageDelayed(
|
||||||
|
mHandler.obtainMessage(CANCEL_GAME_LOADING_MODE), loadingBoostDuration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user