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

Commit 293d86e3 authored by Eliot Courtney's avatar Eliot Courtney
Browse files

Remove dependency from PipAppsOpsListener to PipMotionHelper.

Bug: 122503380
Test: compiles
Test: Open YouTube and put it into PIP. Accessing the settings and
disabling PIP correctly closes PIP.

Change-Id: I2903ad37802e4dfab9e3f145483da658c0fdbb5e
parent 917173f5
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -36,8 +36,7 @@ public class PipAppOpsListener {
    private Handler mHandler;
    private IActivityManager mActivityManager;
    private AppOpsManager mAppOpsManager;

    private PipMotionHelper mMotionHelper;
    private Callback mCallback;

    private AppOpsManager.OnOpChangedListener mAppOpsChangedListener = new OnOpChangedListener() {
        @Override
@@ -52,7 +51,7 @@ public class PipAppOpsListener {
                    if (appInfo.packageName.equals(topPipActivityInfo.first.getPackageName()) &&
                            mAppOpsManager.checkOpNoThrow(OP_PICTURE_IN_PICTURE, appInfo.uid,
                                    packageName) != MODE_ALLOWED) {
                        mHandler.post(() -> mMotionHelper.dismissPip());
                        mHandler.post(() -> mCallback.dismissPip());
                    }
                }
            } catch (NameNotFoundException e) {
@@ -63,12 +62,12 @@ public class PipAppOpsListener {
    };

    public PipAppOpsListener(Context context, IActivityManager activityManager,
            PipMotionHelper motionHelper) {
            Callback callback) {
        mContext = context;
        mHandler = new Handler(mContext.getMainLooper());
        mActivityManager = activityManager;
        mAppOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
        mMotionHelper = motionHelper;
        mCallback = callback;
    }

    public void onActivityPinned(String packageName) {
@@ -89,4 +88,10 @@ public class PipAppOpsListener {
    private void unregisterAppOpsListener() {
        mAppOpsManager.stopWatchingMode(mAppOpsChangedListener);
    }

    /** Callback for PipAppOpsListener to request changes to the PIP window. */
    public interface Callback {
        /** Dismisses the PIP window. */
        void dismissPip();
    }
}
+3 −2
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ import java.io.PrintWriter;
/**
 * A helper to animate and manipulate the PiP.
 */
public class PipMotionHelper implements Handler.Callback {
public class PipMotionHelper implements Handler.Callback, PipAppOpsListener.Callback {

    private static final String TAG = "PipMotionHelper";
    private static final boolean DEBUG = false;
@@ -172,7 +172,8 @@ public class PipMotionHelper implements Handler.Callback {
    /**
     * Dismisses the pinned stack.
     */
    void dismissPip() {
    @Override
    public void dismissPip() {
        if (DEBUG) {
            Log.d(TAG, "dismissPip: callers=\n" + Debug.getCallers(5, "    "));
        }