Merge "Only migrate 2-button setting if set" into qt-dev
This commit is contained in:
@@ -20,12 +20,7 @@ import static android.os.Process.INVALID_UID;
|
|||||||
import static android.os.Process.ROOT_UID;
|
import static android.os.Process.ROOT_UID;
|
||||||
import static android.os.Process.SHELL_UID;
|
import static android.os.Process.SHELL_UID;
|
||||||
import static android.os.Process.SYSTEM_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_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.Manifest;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
@@ -41,7 +36,6 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.om.IOverlayManager;
|
import android.content.om.IOverlayManager;
|
||||||
import android.content.om.OverlayInfo;
|
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.IPackageManager;
|
import android.content.pm.IPackageManager;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
@@ -4321,50 +4315,19 @@ public class SettingsProvider extends ContentProvider {
|
|||||||
|
|
||||||
if (currentVersion == 176) {
|
if (currentVersion == 176) {
|
||||||
// Version 176: Migrate the existing swipe up setting into the resource overlay
|
// Version 176: Migrate the existing swipe up setting into the resource overlay
|
||||||
// for the navigation bar interaction mode.
|
// for the navigation bar interaction mode. We do so only if the
|
||||||
|
// setting is set.
|
||||||
|
|
||||||
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 SettingsState secureSettings = getSecureSettingsLocked(userId);
|
||||||
final Setting swipeUpSetting = secureSettings.getSettingLocked(
|
final Setting swipeUpSetting = secureSettings.getSettingLocked(
|
||||||
"swipe_up_to_switch_apps_enabled");
|
"swipe_up_to_switch_apps_enabled");
|
||||||
if (swipeUpSetting != null && !swipeUpSetting.isNull()) {
|
if (swipeUpSetting != null && !swipeUpSetting.isNull()
|
||||||
navBarMode = swipeUpSetting.getValue().equals("1")
|
&& swipeUpSetting.getValue().equals("1")) {
|
||||||
? NAV_BAR_MODE_2BUTTON
|
final IOverlayManager overlayManager = IOverlayManager.Stub.asInterface(
|
||||||
: NAV_BAR_MODE_3BUTTON;
|
ServiceManager.getService(Context.OVERLAY_SERVICE));
|
||||||
}
|
|
||||||
|
|
||||||
// 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) {
|
|
||||||
String overlayPackage = "";
|
|
||||||
try {
|
try {
|
||||||
switch (navBarMode) {
|
overlayManager.setEnabledExclusiveInCategory(
|
||||||
case NAV_BAR_MODE_3BUTTON:
|
NAV_BAR_MODE_2BUTTON_OVERLAY, UserHandle.USER_CURRENT);
|
||||||
overlayPackage = NAV_BAR_MODE_3BUTTON_OVERLAY;
|
|
||||||
break;
|
|
||||||
case NAV_BAR_MODE_2BUTTON:
|
|
||||||
overlayPackage = NAV_BAR_MODE_2BUTTON_OVERLAY;
|
|
||||||
break;
|
|
||||||
case NAV_BAR_MODE_GESTURAL:
|
|
||||||
overlayPackage = NAV_BAR_MODE_GESTURAL_OVERLAY;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
overlayManager.setEnabledExclusiveInCategory(overlayPackage,
|
|
||||||
UserHandle.USER_CURRENT);
|
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"Failed to set nav bar interaction mode overlay");
|
"Failed to set nav bar interaction mode overlay");
|
||||||
|
|||||||
Reference in New Issue
Block a user