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

Commit d9f2fb36 authored by Winson Chung's avatar Winson Chung
Browse files

Add overlays for nav bar interaction mode.

- Add config for nav bar interaction mode
- Add overlay packages for overriding the nav bar interaction mode
- Migrate existing swipe up setting into the resource overlay
  P2 P->Q:
    def/off -> 3 button overlay enabled (from default)
    set on  -> 2 button overlay enabled (from setting)
  P3 (default on):
    def (setting not exposed) -> 2 button overlay enabled (from default)

Bug: 127366543
Test: adb shell cmd overlay dump

Change-Id: I75590f81d9dd6a017776e0a34c295575bfe1bf2a
parent 8f8deb20
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -54,6 +54,16 @@ public interface WindowManagerPolicyConstants {
    int NAV_BAR_RIGHT = 1 << 1;
    int NAV_BAR_BOTTOM = 1 << 2;

    // Navigation bar interaction modes
    int NAV_BAR_MODE_3BUTTON = 0;
    int NAV_BAR_MODE_2BUTTON = 1;
    int NAV_BAR_MODE_GESTURAL = 2;

    // Associated overlays for each nav bar mode
    String NAV_BAR_MODE_3BUTTON_OVERLAY = "com.android.internal.systemui.navbar.threebutton";
    String NAV_BAR_MODE_2BUTTON_OVERLAY = "com.android.internal.systemui.navbar.twobutton";
    String NAV_BAR_MODE_GESTURAL_OVERLAY = "com.android.internal.systemui.navbar.gestural";

    /**
     * Broadcast sent when a user activity is detected.
     */
+6 −0
Original line number Diff line number Diff line
@@ -3222,6 +3222,12 @@
         -->
    <integer name="config_navBarOpacityMode">0</integer>

    <!-- Controls the navigation bar interaction mode:
         0: 3 button mode (back, home, overview buttons)
         1: 2 button mode (back, home buttons + swipe up for overview)
         2: gestures only for back, home and overview -->
    <integer name="config_navBarInteractionMode">0</integer>

    <!-- Default insets [LEFT/RIGHTxTOP/BOTTOM] from the screen edge for picture-in-picture windows.
         These values are in DPs and will be converted to pixel sizes internally. -->
    <string translatable="false" name="config_defaultPictureInPictureScreenEdgeInsets">16x16</string>
+1 −0
Original line number Diff line number Diff line
@@ -2831,6 +2831,7 @@
  <java-symbol type="string" name="config_packagedKeyboardName" />
  <java-symbol type="bool" name="config_forceWindowDrawsStatusBarBackground" />
  <java-symbol type="integer" name="config_navBarOpacityMode" />
  <java-symbol type="integer" name="config_navBarInteractionMode" />
  <java-symbol type="color" name="system_bar_background_semi_transparent" />

  <!-- EditText suggestion popup. -->
+60 −1
Original line number Diff line number Diff line
@@ -19,6 +19,12 @@ package com.android.providers.settings;
import static android.os.Process.ROOT_UID;
import static android.os.Process.SHELL_UID;
import static android.os.Process.SYSTEM_UID;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON_OVERLAY;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY;

import android.Manifest;
import android.annotation.NonNull;
@@ -33,6 +39,8 @@ import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.om.IOverlayManager;
import android.content.om.OverlayInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.pm.PackageInfo;
@@ -3235,7 +3243,7 @@ public class SettingsProvider extends ContentProvider {
        }

        private final class UpgradeController {
            private static final int SETTINGS_VERSION = 176;
            private static final int SETTINGS_VERSION = 177;

            private final int mUserId;

@@ -4311,6 +4319,57 @@ public class SettingsProvider extends ContentProvider {
                    currentVersion = 176;
                }

                if (currentVersion == 176) {
                    // Version 176: Migrate the existing swipe up setting into the resource overlay
                    //              for the navigation bar interaction mode.

                    final IOverlayManager overlayManager = IOverlayManager.Stub.asInterface(
                            ServiceManager.getService(Context.OVERLAY_SERVICE));
                    int navBarMode = -1;

                    // Migrate the swipe up setting only if it is set
                    final SettingsState secureSettings = getSecureSettingsLocked(userId);
                    final Setting swipeUpSetting = secureSettings.getSettingLocked(
                            Secure.SWIPE_UP_TO_SWITCH_APPS_ENABLED);
                    if (swipeUpSetting != null && !swipeUpSetting.isNull()) {
                        navBarMode = swipeUpSetting.getValue().equals("1")
                                ? NAV_BAR_MODE_2BUTTON
                                : NAV_BAR_MODE_3BUTTON;
                    }

                    // Temporary: Only for migration for dogfooders, to be removed
                    try {
                        final OverlayInfo info = overlayManager.getOverlayInfo(
                                "com.android.internal.experiment.navbar.type.inset",
                                UserHandle.USER_CURRENT);
                        if (info != null && info.isEnabled()) {
                            navBarMode = NAV_BAR_MODE_GESTURAL;
                        }
                    } catch (RemoteException e) {
                        // Ingore, fall through
                    }

                    if (navBarMode != -1) {
                        try {
                            overlayManager.setEnabled(NAV_BAR_MODE_3BUTTON_OVERLAY,
                                    navBarMode == NAV_BAR_MODE_3BUTTON,
                                    UserHandle.USER_CURRENT);
                            overlayManager.setEnabled(NAV_BAR_MODE_2BUTTON_OVERLAY,
                                    navBarMode == NAV_BAR_MODE_2BUTTON,
                                    UserHandle.USER_CURRENT);
                            overlayManager.setEnabled(NAV_BAR_MODE_GESTURAL_OVERLAY,
                                    navBarMode == NAV_BAR_MODE_GESTURAL,
                                    UserHandle.USER_CURRENT);
                        } catch (RemoteException e) {
                            throw new IllegalStateException(
                                    "Failed to set nav bar interaction mode overlay");
                        }
                    }

                    currentVersion = 177;
                }


                // vXXX: Add new settings above this point.

                if (currentVersion != newVersion) {
+4 −1
Original line number Diff line number Diff line
@@ -39,7 +39,10 @@ LOCAL_REQUIRED_MODULES := \
	IconShapeRoundedRectOverlay \
	IconShapeSquareOverlay \
	IconShapeSquircleOverlay \
	IconShapeTeardropOverlay
	IconShapeTeardropOverlay \
	NavigationBarMode3ButtonOverlay \
	NavigationBarMode2ButtonOverlay \
	NavigationBarModeGesturalOverlay

include $(BUILD_PHONY_PACKAGE)
include $(CLEAR_VARS)
Loading