Settings: Only show gesture navigation if device has a software nav bar

Change-Id: Ic90c8a194a736807c2e101ffd5f7e90c86a55381
This commit is contained in:
Rashed Abdel-Tawab 2018-09-03 10:18:08 -07:00 committed by LuK1337
parent 2e10956562
commit 71b30e4772
No known key found for this signature in database

View file

@ -23,6 +23,10 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.RemoteException;
import android.view.Display;
import android.view.IWindowManager;
import android.view.WindowManagerGlobal;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
@ -54,9 +58,20 @@ public class SystemNavigationPreferenceController extends BasePreferenceControll
/** Returns {@code true} if gesture is available. */
public static boolean isGestureAvailable(Context context) {
boolean hasNavigationBar = false;
final boolean configEnabled = context.getResources().getBoolean(
com.android.internal.R.bool.config_swipe_up_gesture_setting_available);
try {
IWindowManager windowManager = WindowManagerGlobal.getWindowManagerService();
hasNavigationBar = windowManager.hasNavigationBar(Display.DEFAULT_DISPLAY);
} catch (RemoteException ex) {
// no window manager? good luck with that
}
// Skip if the swipe up settings are not available
if (!context.getResources().getBoolean(
com.android.internal.R.bool.config_swipe_up_gesture_setting_available)) {
// or if on-screen navbar is disabled (for devices with hardware keys)
if (!configEnabled || !hasNavigationBar) {
return false;
}