Merge "Respect feature flag when providing OHM controller"
This commit is contained in:
committed by
Android (Google) Code Review
commit
0e4965517e
@@ -26,11 +26,6 @@ import java.io.PrintWriter;
|
||||
* Interface to engage one handed feature.
|
||||
*/
|
||||
public interface OneHanded {
|
||||
/**
|
||||
* Return whether the device has one handed feature or not.
|
||||
*/
|
||||
boolean hasOneHandedFeature();
|
||||
|
||||
/**
|
||||
* Return one handed settings enabled or not.
|
||||
*/
|
||||
|
||||
@@ -30,9 +30,10 @@ import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.SystemProperties;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.wm.shell.common.DisplayChangeController;
|
||||
@@ -54,7 +55,6 @@ public class OneHandedController implements OneHanded {
|
||||
|
||||
static final String SUPPORT_ONE_HANDED_MODE = "ro.support_one_handed_mode";
|
||||
|
||||
private final boolean mHasOneHandedFeature;
|
||||
private boolean mIsOneHandedEnabled;
|
||||
private boolean mIsSwipeToNotificationEnabled;
|
||||
private boolean mTaskChangeToExit;
|
||||
@@ -160,10 +160,16 @@ public class OneHandedController implements OneHanded {
|
||||
};
|
||||
|
||||
/**
|
||||
* The static constructor method to create OneHnadedController.
|
||||
* Creates {@link OneHandedController}, returns {@code null} if the feature is not supported.
|
||||
*/
|
||||
@Nullable
|
||||
public static OneHandedController create(
|
||||
Context context, DisplayController displayController) {
|
||||
if (!SystemProperties.getBoolean(SUPPORT_ONE_HANDED_MODE, false)) {
|
||||
Slog.w(TAG, "Device doesn't support OneHanded feature");
|
||||
return null;
|
||||
}
|
||||
|
||||
OneHandedTutorialHandler tutorialHandler = new OneHandedTutorialHandler(context);
|
||||
OneHandedAnimationController animationController =
|
||||
new OneHandedAnimationController(context);
|
||||
@@ -186,43 +192,30 @@ public class OneHandedController implements OneHanded {
|
||||
OneHandedTutorialHandler tutorialHandler,
|
||||
OneHandedGestureHandler gestureHandler,
|
||||
IOverlayManager overlayManager) {
|
||||
mHasOneHandedFeature = SystemProperties.getBoolean(SUPPORT_ONE_HANDED_MODE, false);
|
||||
if (!mHasOneHandedFeature) {
|
||||
Log.i(TAG, "Device config SUPPORT_ONE_HANDED_MODE off");
|
||||
mContext = null;
|
||||
mDisplayAreaOrganizer = null;
|
||||
mDisplayController = null;
|
||||
mTouchHandler = null;
|
||||
mTutorialHandler = null;
|
||||
mGestureHandler = null;
|
||||
mTimeoutHandler = null;
|
||||
mOverlayManager = null;
|
||||
} else {
|
||||
mContext = context;
|
||||
mDisplayAreaOrganizer = displayAreaOrganizer;
|
||||
mDisplayController = displayController;
|
||||
mTouchHandler = touchHandler;
|
||||
mTutorialHandler = tutorialHandler;
|
||||
mGestureHandler = gestureHandler;
|
||||
mOverlayManager = overlayManager;
|
||||
mContext = context;
|
||||
mDisplayAreaOrganizer = displayAreaOrganizer;
|
||||
mDisplayController = displayController;
|
||||
mTouchHandler = touchHandler;
|
||||
mTutorialHandler = tutorialHandler;
|
||||
mGestureHandler = gestureHandler;
|
||||
mOverlayManager = overlayManager;
|
||||
|
||||
mOffSetFraction = SystemProperties.getInt(ONE_HANDED_MODE_OFFSET_PERCENTAGE, 50)
|
||||
/ 100.0f;
|
||||
mIsOneHandedEnabled = OneHandedSettingsUtil.getSettingsOneHandedModeEnabled(
|
||||
context.getContentResolver());
|
||||
mIsSwipeToNotificationEnabled =
|
||||
OneHandedSettingsUtil.getSettingsSwipeToNotificationEnabled(
|
||||
context.getContentResolver());
|
||||
mTimeoutHandler = OneHandedTimeoutHandler.get();
|
||||
mOffSetFraction = SystemProperties.getInt(ONE_HANDED_MODE_OFFSET_PERCENTAGE, 50)
|
||||
/ 100.0f;
|
||||
mIsOneHandedEnabled = OneHandedSettingsUtil.getSettingsOneHandedModeEnabled(
|
||||
context.getContentResolver());
|
||||
mIsSwipeToNotificationEnabled =
|
||||
OneHandedSettingsUtil.getSettingsSwipeToNotificationEnabled(
|
||||
context.getContentResolver());
|
||||
mTimeoutHandler = OneHandedTimeoutHandler.get();
|
||||
|
||||
mDisplayController.addDisplayChangingController(mRotationController);
|
||||
mDisplayController.addDisplayChangingController(mRotationController);
|
||||
|
||||
setupCallback();
|
||||
setupSettingObservers();
|
||||
setupTimeoutListener();
|
||||
setupGesturalOverlay();
|
||||
updateSettings();
|
||||
}
|
||||
setupCallback();
|
||||
setupSettingObservers();
|
||||
setupTimeoutListener();
|
||||
setupGesturalOverlay();
|
||||
updateSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,11 +241,6 @@ public class OneHandedController implements OneHanded {
|
||||
updateOneHandedEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOneHandedFeature() {
|
||||
return mHasOneHandedFeature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOneHandedEnabled() {
|
||||
return mIsOneHandedEnabled;
|
||||
|
||||
@@ -312,10 +312,6 @@ public final class WMShell extends SystemUI
|
||||
|
||||
@VisibleForTesting
|
||||
void initOneHanded(OneHanded oneHanded) {
|
||||
if (!oneHanded.hasOneHandedFeature()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int currentMode = mNavigationModeController.addListener(mode ->
|
||||
oneHanded.setThreeButtonModeEnabled(mode == NAV_BAR_MODE_3BUTTON));
|
||||
oneHanded.setThreeButtonModeEnabled(currentMode == NAV_BAR_MODE_3BUTTON);
|
||||
|
||||
@@ -40,6 +40,7 @@ import com.android.wm.shell.common.SyncTransactionQueue;
|
||||
import com.android.wm.shell.common.SystemWindows;
|
||||
import com.android.wm.shell.common.TransactionPool;
|
||||
import com.android.wm.shell.onehanded.OneHanded;
|
||||
import com.android.wm.shell.onehanded.OneHandedController;
|
||||
import com.android.wm.shell.pip.Pip;
|
||||
import com.android.wm.shell.pip.PipSurfaceTransactionHelper;
|
||||
import com.android.wm.shell.pip.PipUiEventLogger;
|
||||
@@ -48,6 +49,8 @@ import com.android.wm.shell.pip.phone.PipMediaController;
|
||||
import com.android.wm.shell.pip.phone.PipTouchHandler;
|
||||
import com.android.wm.shell.splitscreen.SplitScreen;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import dagger.BindsOptionalOf;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
@@ -164,6 +167,10 @@ public abstract class WMShellBaseModule {
|
||||
@BindsOptionalOf
|
||||
abstract Bubbles optionalBubbles();
|
||||
|
||||
@BindsOptionalOf
|
||||
abstract OneHanded optionalOneHanded();
|
||||
@SysUISingleton
|
||||
@Provides
|
||||
static Optional<OneHanded> provideOneHandedController(Context context,
|
||||
DisplayController displayController) {
|
||||
return Optional.ofNullable(OneHandedController.create(context, displayController));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,8 +30,6 @@ import com.android.wm.shell.common.FloatingContentCoordinator;
|
||||
import com.android.wm.shell.common.SyncTransactionQueue;
|
||||
import com.android.wm.shell.common.SystemWindows;
|
||||
import com.android.wm.shell.common.TransactionPool;
|
||||
import com.android.wm.shell.onehanded.OneHanded;
|
||||
import com.android.wm.shell.onehanded.OneHandedController;
|
||||
import com.android.wm.shell.pip.Pip;
|
||||
import com.android.wm.shell.pip.PipBoundsHandler;
|
||||
import com.android.wm.shell.pip.PipSurfaceTransactionHelper;
|
||||
@@ -129,11 +127,4 @@ public class WMShellModule {
|
||||
pipSurfaceTransactionHelper, splitScreenOptional, displayController,
|
||||
pipUiEventLogger, shellTaskOrganizer);
|
||||
}
|
||||
|
||||
@SysUISingleton
|
||||
@Provides
|
||||
static OneHanded provideOneHandedController(Context context,
|
||||
DisplayController displayController) {
|
||||
return OneHandedController.create(context, displayController);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,6 @@ public class WMShellTest extends SysuiTestCase {
|
||||
|
||||
@Test
|
||||
public void initOneHanded_registersCallbacks() {
|
||||
when(mOneHanded.hasOneHandedFeature()).thenReturn(true);
|
||||
mWMShell.initOneHanded(mOneHanded);
|
||||
|
||||
verify(mKeyguardUpdateMonitor).registerCallback(any(KeyguardUpdateMonitorCallback.class));
|
||||
|
||||
Reference in New Issue
Block a user