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

Commit 7ced3637 authored by Hongwei Wang's avatar Hongwei Wang
Browse files

[PiP2] Respond to AppOps change in PiP2

Integrate the PipAppOpsListener into PiP2 and make it independent from
PipTouchHandler / PipMotionHelper.

Flag: com.android.wm.shell.enable_pip2
Bug: 381190353
Video: http://recall/-/aaaaaabFQoRHlzixHdtY/eHQTWNTeGScZpJYzI4liOM
Test: Turn off app ops settings, verify pip vanishes, see video
Test: atest WMShellUnitTests:PipAppOpsListenerTest
Change-Id: Iafbd43e403b07d9ca9d22b54bd665ec2ec70efcd
parent 6d794e85
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import com.android.wm.shell.common.ShellExecutor

class PipAppOpsListener(
    private val mContext: Context,
    private val mCallback: Callback,
    private val mMainExecutor: ShellExecutor
) {
    private val mAppOpsManager: AppOpsManager = checkNotNull(
@@ -46,7 +45,9 @@ class PipAppOpsListener(
                    packageName
                ) != AppOpsManager.MODE_ALLOWED
            ) {
                mMainExecutor.execute { mCallback.dismissPip() }
                mCallback?.let {
                    mMainExecutor.execute { it.dismissPip() }
                }
            }
        } catch (e: PackageManager.NameNotFoundException) {
            // Unregister the listener if the package can't be found
@@ -54,6 +55,12 @@ class PipAppOpsListener(
        }
    }

    private var mCallback: Callback? = null

    fun setCallback(callback: Callback) {
        mCallback = callback
    }

    fun onActivityPinned(packageName: String) {
        // Register for changes to the app ops setting for this package while it is in PiP
        registerAppOpsListener(packageName)
+8 −0
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ import com.android.wm.shell.common.TabletopModeController;
import com.android.wm.shell.common.TaskStackListenerImpl;
import com.android.wm.shell.common.pip.PhonePipKeepClearAlgorithm;
import com.android.wm.shell.common.pip.PhoneSizeSpecSource;
import com.android.wm.shell.common.pip.PipAppOpsListener;
import com.android.wm.shell.common.pip.PipBoundsAlgorithm;
import com.android.wm.shell.common.pip.PipBoundsState;
import com.android.wm.shell.common.pip.PipDisplayLayoutState;
@@ -531,6 +532,13 @@ public abstract class WMShellBaseModule {
                pipKeepClearAlgorithm, pipDisplayLayoutState, sizeSpecSource);
    }

    @WMSingleton
    @Provides
    static PipAppOpsListener providePipAppOpsListener(Context context,
            @ShellMainThread ShellExecutor mainExecutor) {
        return new PipAppOpsListener(context, mainExecutor);
    }

    //
    // Bubbles (optional feature)
    //
+0 −8
Original line number Diff line number Diff line
@@ -201,14 +201,6 @@ public abstract class Pip1Module {
                homeTransitionObserver, splitScreenOptional);
    }

    @WMSingleton
    @Provides
    static PipAppOpsListener providePipAppOpsListener(Context context,
            PipTouchHandler pipTouchHandler,
            @ShellMainThread ShellExecutor mainExecutor) {
        return new PipAppOpsListener(context, pipTouchHandler.getMotionHelper(), mainExecutor);
    }

    @WMSingleton
    @Provides
    static PipMotionHelper providePipMotionHelper(Context context,
+3 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import com.android.wm.shell.common.FloatingContentCoordinator;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.SystemWindows;
import com.android.wm.shell.common.TaskStackListenerImpl;
import com.android.wm.shell.common.pip.PipAppOpsListener;
import com.android.wm.shell.common.pip.PipBoundsAlgorithm;
import com.android.wm.shell.common.pip.PipBoundsState;
import com.android.wm.shell.common.pip.PipDisplayLayoutState;
@@ -113,6 +114,7 @@ public abstract class Pip2Module {
            ShellTaskOrganizer shellTaskOrganizer,
            PipTransitionState pipTransitionState,
            PipTouchHandler pipTouchHandler,
            PipAppOpsListener pipAppOpsListener,
            @ShellMainThread ShellExecutor mainExecutor) {
        if (!PipUtils.isPip2ExperimentEnabled()) {
            return Optional.empty();
@@ -121,7 +123,7 @@ public abstract class Pip2Module {
                    context, shellInit, shellCommandHandler, shellController, displayController,
                    displayInsetsController, pipBoundsState, pipBoundsAlgorithm,
                    pipDisplayLayoutState, pipScheduler, taskStackListener, shellTaskOrganizer,
                    pipTransitionState, pipTouchHandler, mainExecutor));
                    pipTransitionState, pipTouchHandler, pipAppOpsListener, mainExecutor));
        }
    }

+0 −8
Original line number Diff line number Diff line
@@ -233,12 +233,4 @@ public abstract class TvPipModule {
    static PipParamsChangedForwarder providePipParamsChangedForwarder() {
        return new PipParamsChangedForwarder();
    }

    @WMSingleton
    @Provides
    static PipAppOpsListener providePipAppOpsListener(Context context,
            PipTaskOrganizer pipTaskOrganizer,
            @ShellMainThread ShellExecutor mainExecutor) {
        return new PipAppOpsListener(context, pipTaskOrganizer::removePip, mainExecutor);
    }
}
Loading