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

Commit 0f6525db authored by Tracy Zhou's avatar Tracy Zhou
Browse files

Dismiss PIP window when PIP is disabled from settings.

The app ops call comes in on a binder thread so we need to post dismissPip() to the main thread.

Bug: 73625696
Test: atest
CtsActivityManagerDeviceTestCases:ActivityManagerPinnedStackTests

Change-Id: I365947934155d0d29ac67ebedc0b35b6d377cb84
parent 57be73d6
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -26,12 +26,14 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Handler;
import android.util.Pair;

public class PipAppOpsListener {
    private static final String TAG = PipAppOpsListener.class.getSimpleName();

    private Context mContext;
    private Handler mHandler;
    private IActivityManager mActivityManager;
    private AppOpsManager mAppOpsManager;

@@ -50,7 +52,7 @@ public class PipAppOpsListener {
                    if (appInfo.packageName.equals(topPipActivityInfo.first.getPackageName()) &&
                            mAppOpsManager.checkOpNoThrow(OP_PICTURE_IN_PICTURE, appInfo.uid,
                                    packageName) != MODE_ALLOWED) {
                        mMotionHelper.dismissPip();
                        mHandler.post(() -> mMotionHelper.dismissPip());
                    }
                }
            } catch (NameNotFoundException e) {
@@ -63,6 +65,7 @@ public class PipAppOpsListener {
    public PipAppOpsListener(Context context, IActivityManager activityManager,
            PipMotionHelper motionHelper) {
        mContext = context;
        mHandler = new Handler(mContext.getMainLooper());
        mActivityManager = activityManager;
        mAppOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
        mMotionHelper = motionHelper;