Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0e496551 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Respect feature flag when providing OHM controller"

parents 2bfca138 d8cb9140
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -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.
     */
+33 −45
Original line number Diff line number Diff line
@@ -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,18 +192,6 @@ 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;
@@ -223,7 +217,6 @@ public class OneHandedController implements OneHanded {
        setupGesturalOverlay();
        updateSettings();
    }
    }

    /**
     * Set one handed enabled or disabled when user update settings
@@ -248,11 +241,6 @@ public class OneHandedController implements OneHanded {
        updateOneHandedEnabled();
    }

    @Override
    public boolean hasOneHandedFeature() {
        return mHasOneHandedFeature;
    }

    @Override
    public boolean isOneHandedEnabled() {
        return mIsOneHandedEnabled;
+0 −4
Original line number Diff line number Diff line
@@ -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);
+9 −2
Original line number Diff line number Diff line
@@ -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));
    }
}
+0 −9
Original line number Diff line number Diff line
@@ -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);
    }
}
Loading