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

Commit 9bc1411d authored by Jim Blackler's avatar Jim Blackler Committed by Automerger Merge Worker
Browse files

Merge "Loading boost: use the existing GAME_LOADING power mode, and deactivate...

Merge "Loading boost: use the existing GAME_LOADING power mode, and deactivate it on a timer." into tm-dev am: 70853212 am: d01e773c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17745929



Change-Id: I428847733a46433f2bc6e526aaa123ed8d6d6802
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 1185e831 d01e773c
Loading
Loading
Loading
Loading
+22 −2
Original line number Diff line number Diff line
@@ -121,7 +121,10 @@ public final class GameManagerService extends IGameManagerService.Stub {
    static final int REMOVE_SETTINGS = 2;
    static final int POPULATE_GAME_MODE_SETTINGS = 3;
    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 LOADING_BOOST_MAX_DURATION = 5 * 1000;  // 5 seconds

    static final PackageOverride COMPAT_ENABLED = new PackageOverride.Builder().setEnabled(true)
            .build();
    static final PackageOverride COMPAT_DISABLED = new PackageOverride.Builder().setEnabled(false)
@@ -299,6 +302,10 @@ public final class GameManagerService extends IGameManagerService.Stub {
                    }
                    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) {
            return;
        }
        final int loadingBoostDuration = getLoadingBoostDuration(packageName, userId);
        int loadingBoostDuration = getLoadingBoostDuration(packageName, userId);
        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);
        }
    }