diff options
author | 2019-03-05 11:10:12 -0800 | |
---|---|---|
committer | 2019-03-22 11:33:52 -0700 | |
commit | d9f2fb36ceb4719bd2351e46241a93fcf68ac01e (patch) | |
tree | e8cb0ad1286604c3e79926ed68fcfc4fb4f30134 | |
parent | 8f8deb20b33725742a38e3bab5234b00d7ca34f7 (diff) |
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
17 files changed, 393 insertions, 2 deletions
diff --git a/core/java/android/view/WindowManagerPolicyConstants.java b/core/java/android/view/WindowManagerPolicyConstants.java index 35ed7bfa2ce6..46a59f09eca7 100644 --- a/core/java/android/view/WindowManagerPolicyConstants.java +++ b/core/java/android/view/WindowManagerPolicyConstants.java @@ -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. */ diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 14edf6fe1aa3..14202f2d48d4 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -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> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 4ab9edb8bbaa..d7f4a6c3be25 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -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. --> diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java index 9e46ad6061eb..7337cdb81ebf 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java @@ -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) { diff --git a/packages/overlays/Android.mk b/packages/overlays/Android.mk index a15e89c8bcdb..b5223445d127 100644 --- a/packages/overlays/Android.mk +++ b/packages/overlays/Android.mk @@ -39,7 +39,10 @@ LOCAL_REQUIRED_MODULES := \ IconShapeRoundedRectOverlay \ IconShapeSquareOverlay \ IconShapeSquircleOverlay \ - IconShapeTeardropOverlay + IconShapeTeardropOverlay \ + NavigationBarMode3ButtonOverlay \ + NavigationBarMode2ButtonOverlay \ + NavigationBarModeGesturalOverlay include $(BUILD_PHONY_PACKAGE) include $(CLEAR_VARS) diff --git a/packages/overlays/NavigationBarMode2ButtonOverlay/Android.mk b/packages/overlays/NavigationBarMode2ButtonOverlay/Android.mk new file mode 100644 index 000000000000..410d6d87c61d --- /dev/null +++ b/packages/overlays/NavigationBarMode2ButtonOverlay/Android.mk @@ -0,0 +1,30 @@ +# +# Copyright 2018, The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_RRO_THEME := NavigationBarMode2Button +LOCAL_CERTIFICATE := platform + +LOCAL_SRC_FILES := $(call all-subdir-java-files) + +LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res + +LOCAL_PACKAGE_NAME := NavigationBarMode2ButtonOverlay +LOCAL_SDK_VERSION := current + +include $(BUILD_RRO_PACKAGE)
\ No newline at end of file diff --git a/packages/overlays/NavigationBarMode2ButtonOverlay/AndroidManifest.xml b/packages/overlays/NavigationBarMode2ButtonOverlay/AndroidManifest.xml new file mode 100644 index 000000000000..970380f070e9 --- /dev/null +++ b/packages/overlays/NavigationBarMode2ButtonOverlay/AndroidManifest.xml @@ -0,0 +1,27 @@ +<!-- +/** + * Copyright (c) 2018, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +--> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.internal.systemui.navbar.twobutton" + android:versionCode="1" + android:versionName="1.0"> + <overlay android:targetPackage="android" + android:category="com.android.internal.navigation_bar_mode" + android:priority="1"/> + + <application android:label="@string/navigation_bar_mode_title" android:hasCode="false"/> +</manifest>
\ No newline at end of file diff --git a/packages/overlays/NavigationBarMode2ButtonOverlay/res/values/config.xml b/packages/overlays/NavigationBarMode2ButtonOverlay/res/values/config.xml new file mode 100644 index 000000000000..b353322aed9c --- /dev/null +++ b/packages/overlays/NavigationBarMode2ButtonOverlay/res/values/config.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright (c) 2019, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +--> +<resources> + <!-- 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">1</integer> +</resources>
\ No newline at end of file diff --git a/packages/overlays/NavigationBarMode2ButtonOverlay/res/values/strings.xml b/packages/overlays/NavigationBarMode2ButtonOverlay/res/values/strings.xml new file mode 100644 index 000000000000..1696ecfea4e4 --- /dev/null +++ b/packages/overlays/NavigationBarMode2ButtonOverlay/res/values/strings.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright (c) 2018, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +--> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <!-- Name of overlay [CHAR LIMIT=64] --> + <string name="navigation_bar_mode_title" translatable="false">2 Button Navigation Bar</string> +</resources>
\ No newline at end of file diff --git a/packages/overlays/NavigationBarMode3ButtonOverlay/Android.mk b/packages/overlays/NavigationBarMode3ButtonOverlay/Android.mk new file mode 100644 index 000000000000..2bc9a6aea9eb --- /dev/null +++ b/packages/overlays/NavigationBarMode3ButtonOverlay/Android.mk @@ -0,0 +1,30 @@ +# +# Copyright 2018, The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_RRO_THEME := NavigationBarMode3Button +LOCAL_CERTIFICATE := platform + +LOCAL_SRC_FILES := $(call all-subdir-java-files) + +LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res + +LOCAL_PACKAGE_NAME := NavigationBarMode3ButtonOverlay +LOCAL_SDK_VERSION := current + +include $(BUILD_RRO_PACKAGE)
\ No newline at end of file diff --git a/packages/overlays/NavigationBarMode3ButtonOverlay/AndroidManifest.xml b/packages/overlays/NavigationBarMode3ButtonOverlay/AndroidManifest.xml new file mode 100644 index 000000000000..628fc1dd3aa7 --- /dev/null +++ b/packages/overlays/NavigationBarMode3ButtonOverlay/AndroidManifest.xml @@ -0,0 +1,27 @@ +<!-- +/** + * Copyright (c) 2018, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +--> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.internal.systemui.navbar.threebutton" + android:versionCode="1" + android:versionName="1.0"> + <overlay android:targetPackage="android" + android:category="com.android.internal.navigation_bar_mode" + android:priority="1"/> + + <application android:label="@string/navigation_bar_mode_title" android:hasCode="false"/> +</manifest>
\ No newline at end of file diff --git a/packages/overlays/NavigationBarMode3ButtonOverlay/res/values/config.xml b/packages/overlays/NavigationBarMode3ButtonOverlay/res/values/config.xml new file mode 100644 index 000000000000..7bd0a140bb1c --- /dev/null +++ b/packages/overlays/NavigationBarMode3ButtonOverlay/res/values/config.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright (c) 2019, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +--> +<resources> + <!-- 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> +</resources>
\ No newline at end of file diff --git a/packages/overlays/NavigationBarMode3ButtonOverlay/res/values/strings.xml b/packages/overlays/NavigationBarMode3ButtonOverlay/res/values/strings.xml new file mode 100644 index 000000000000..201b9e94cfbc --- /dev/null +++ b/packages/overlays/NavigationBarMode3ButtonOverlay/res/values/strings.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright (c) 2018, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +--> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <!-- Name of overlay [CHAR LIMIT=64] --> + <string name="navigation_bar_mode_title" translatable="false">3 Button Navigation Bar</string> +</resources>
\ No newline at end of file diff --git a/packages/overlays/NavigationBarModeGesturalOverlay/Android.mk b/packages/overlays/NavigationBarModeGesturalOverlay/Android.mk new file mode 100644 index 000000000000..5f7e0eb62a46 --- /dev/null +++ b/packages/overlays/NavigationBarModeGesturalOverlay/Android.mk @@ -0,0 +1,30 @@ +# +# Copyright 2018, The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_RRO_THEME := NavigationBarModeGestural +LOCAL_CERTIFICATE := platform + +LOCAL_SRC_FILES := $(call all-subdir-java-files) + +LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res + +LOCAL_PACKAGE_NAME := NavigationBarModeGesturalOverlay +LOCAL_SDK_VERSION := current + +include $(BUILD_RRO_PACKAGE)
\ No newline at end of file diff --git a/packages/overlays/NavigationBarModeGesturalOverlay/AndroidManifest.xml b/packages/overlays/NavigationBarModeGesturalOverlay/AndroidManifest.xml new file mode 100644 index 000000000000..aff82d836ae5 --- /dev/null +++ b/packages/overlays/NavigationBarModeGesturalOverlay/AndroidManifest.xml @@ -0,0 +1,27 @@ +<!-- +/** + * Copyright (c) 2018, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +--> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.internal.systemui.navbar.gestural" + android:versionCode="1" + android:versionName="1.0"> + <overlay android:targetPackage="android" + android:category="com.android.internal.navigation_bar_mode" + android:priority="1"/> + + <application android:label="@string/navigation_bar_mode_title" android:hasCode="false"/> +</manifest>
\ No newline at end of file diff --git a/packages/overlays/NavigationBarModeGesturalOverlay/res/values/config.xml b/packages/overlays/NavigationBarModeGesturalOverlay/res/values/config.xml new file mode 100644 index 000000000000..48c37695d4a1 --- /dev/null +++ b/packages/overlays/NavigationBarModeGesturalOverlay/res/values/config.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright (c) 2019, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +--> +<resources> + <!-- 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">2</integer> +</resources>
\ No newline at end of file diff --git a/packages/overlays/NavigationBarModeGesturalOverlay/res/values/strings.xml b/packages/overlays/NavigationBarModeGesturalOverlay/res/values/strings.xml new file mode 100644 index 000000000000..8d38916a0541 --- /dev/null +++ b/packages/overlays/NavigationBarModeGesturalOverlay/res/values/strings.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright (c) 2018, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +--> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <!-- Name of overlay [CHAR LIMIT=64] --> + <string name="navigation_bar_mode_title" translatable="false">Gestural Navigation Bar</string> +</resources>
\ No newline at end of file |