(2/n) Stop user from enabling OHM setting if user is using 3-button
mode
Return One-Handed mode getAvailabilityStatus to UNSUPPORTED_ON_DEVICE
when SystemNavigationMode is 3-button.
Bug: 184903678
Test: manual
Test: manual verified on Settings > System > Gesture page
Test: make RunSettingsRoboTests ROBOTEST_FILTER=
"com.android.settings.gestures
.OneHandedEnablePreferenceControllerTest"
Test: make RunSettingsRoboTests ROBOTEST_FILTER=
"com.android.settings.gestures
.SwipeBottomToNotificationPreferenceControllerTest"
Change-Id: I454dabb5cc267d544732fa5079f3146154d0568c
This commit is contained in:
@@ -19,7 +19,6 @@ package com.android.settings.gestures;
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.widget.SettingsMainSwitchPreferenceController;
|
||||
|
||||
/**
|
||||
@@ -33,9 +32,8 @@ public class OneHandedEnablePreferenceController extends SettingsMainSwitchPrefe
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return OneHandedSettingsUtils.isSupportOneHandedMode()
|
||||
? BasePreferenceController.AVAILABLE
|
||||
: BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
return OneHandedSettingsUtils.isFeatureAvailable(mContext)
|
||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -176,6 +176,28 @@ public class OneHandedSettingsUtils {
|
||||
sCurrentUserId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get NavigationBar mode flag from Settings provider.
|
||||
* @param context App context
|
||||
* @return Navigation bar mode:
|
||||
* 0 = 3 button
|
||||
* 1 = 2 button
|
||||
* 2 = fully gestural
|
||||
*/
|
||||
public static int getNavigationBarMode(Context context) {
|
||||
return Settings.Secure.getIntForUser(context.getContentResolver(),
|
||||
Settings.Secure.NAVIGATION_MODE, 2 /* fully gestural */, sCurrentUserId);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param context App context
|
||||
* @return Support One-Handed mode feature or not.
|
||||
*/
|
||||
public static boolean isFeatureAvailable(Context context) {
|
||||
return isSupportOneHandedMode() && getNavigationBarMode(context) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers callback for observing Settings.Secure.ONE_HANDED_MODE_ENABLED state.
|
||||
* @param callback for state changes
|
||||
|
||||
@@ -33,7 +33,8 @@ public class SwipeBottomToNotificationPreferenceController extends TogglePrefere
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return OneHandedSettingsUtils.isSupportOneHandedMode() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
return OneHandedSettingsUtils.isFeatureAvailable(mContext)
|
||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user