LineageParts: switch to 3-button navigation when disabling navbar
If gesture navigation is enabled when disabling on-screen navigation
bar, the hardware keys don't work properly.
Change-Id: I9b5ad6516515f72483f061686e3f95e47445341b
diff --git a/src/org/lineageos/lineageparts/input/ButtonSettings.java b/src/org/lineageos/lineageparts/input/ButtonSettings.java
index 613e847..0bbded0 100644
--- a/src/org/lineageos/lineageparts/input/ButtonSettings.java
+++ b/src/org/lineageos/lineageparts/input/ButtonSettings.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2016 The CyanogenMod project
- * 2017-2021 The LineageOS project
+ * 2017-2022 The LineageOS project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,11 +17,14 @@
package org.lineageos.lineageparts.input;
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY;
+
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
+import android.content.om.IOverlayManager;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
@@ -29,6 +32,7 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.RemoteException;
+import android.os.ServiceManager;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.ArraySet;
@@ -820,6 +824,16 @@
} else if (preference == mDisableNavigationKeys) {
mDisableNavigationKeys.setEnabled(false);
mNavigationPreferencesCat.setEnabled(false);
+ if (!mDisableNavigationKeys.isChecked()) {
+ IOverlayManager overlayManager = IOverlayManager.Stub.asInterface(
+ ServiceManager.getService(Context.OVERLAY_SERVICE));
+ try {
+ overlayManager.setEnabledExclusiveInCategory(NAV_BAR_MODE_3BUTTON_OVERLAY,
+ UserHandle.USER_CURRENT);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
writeDisableNavkeysOption(getActivity(), mDisableNavigationKeys.isChecked());
updateDisableNavkeysOption();
updateDisableNavkeysCategories(true, false);