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

Commit 67a55fdb authored by Adrian Roos's avatar Adrian Roos Committed by Android (Google) Code Review
Browse files

Merge "Prevent crash and ANR dialogs in VR mode"

parents cac707dc c3064773
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -536,6 +536,7 @@ public final class ActivityManagerService extends ActivityManagerNative
    // default actuion automatically.  Important for devices without direct input
    // devices.
    private boolean mShowDialogs = true;
    private boolean mInVrMode = false;
    BroadcastQueue mFgBroadcastQueue;
    BroadcastQueue mBgBroadcastQueue;
@@ -2204,7 +2205,15 @@ public final class ActivityManagerService extends ActivityManagerNative
            } break;
            case VR_MODE_CHANGE_MSG: {
                VrManagerInternal vrService = LocalServices.getService(VrManagerInternal.class);
                vrService.setVrMode(msg.arg1 != 0);
                final boolean vrMode = msg.arg1 != 0;
                vrService.setVrMode(vrMode);
                if (mInVrMode != vrMode) {
                    synchronized (ActivityManagerService.this) {
                        mInVrMode = vrMode;
                        mShowDialogs = shouldShowDialogs(mConfiguration, mInVrMode);
                    }
                }
            } break;
            }
        }
@@ -18439,7 +18448,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                // TODO: If our config changes, should we auto dismiss any currently
                // showing dialogs?
                mShowDialogs = shouldShowDialogs(newConfig);
                mShowDialogs = shouldShowDialogs(newConfig, mInVrMode);
                AttributeCache ac = AttributeCache.instance();
                if (ac != null) {
@@ -18528,13 +18537,13 @@ public final class ActivityManagerService extends ActivityManagerNative
     * A thought: SystemUI might also want to get told about this, the Power
     * dialog / global actions also might want different behaviors.
     */
    private static final boolean shouldShowDialogs(Configuration config) {
    private static final boolean shouldShowDialogs(Configuration config, boolean inVrMode) {
        final boolean inputMethodExists = !(config.keyboard == Configuration.KEYBOARD_NOKEYS
                                   && config.touchscreen == Configuration.TOUCHSCREEN_NOTOUCH
                                   && config.navigation == Configuration.NAVIGATION_NONAV);
        final boolean uiIsNotCarType = !((config.uiMode & Configuration.UI_MODE_TYPE_MASK)
                                    == Configuration.UI_MODE_TYPE_CAR);
        return inputMethodExists && uiIsNotCarType;
        return inputMethodExists && uiIsNotCarType && !inVrMode;
    }
    @Override