summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Bill Lin <lbill@google.com> 2020-09-02 00:56:18 +0800
committer Bill Lin <lbill@google.com> 2020-09-02 01:28:55 +0800
commite78dd5f06870cdf98b1627345efe8ed69950105c (patch)
tree8ad8ac0fd0659595fdc9bb154f25c123dd4e9e1d
parent8f36c6e55ace1f08c447de7dd7c9f11562dcada1 (diff)
Fix NPE when device do NOT has FEATURE_PICTURE_IN_PICTURE
Some project may be config FEATURE_PICTURE_IN_PICTURE = false If device not support PIP, components in PipController won't initialized, but OverviewProxyService PipController APIs will lead NPE Solution: Check if device has system PIP feature before calling Bug: 161118569 Fixes: 167390795 Test: make SystemUI Test: make ArcSystemUI Test: lunch aosp_tv_arm-userdebug & make Test: atest WindowManagerShellTests Test: atest SystemUITests Test: adb shell input keyevent 171(KEYCODE_WINDOW) Test: manual test Pip demo AP Change-Id: I0ac17901f31623f04ad5e6787be0f4f25e6066c5
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/phone/PipController.java1
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java15
2 files changed, 13 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipController.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipController.java
index 1a805daef77e..6998e90b3a7c 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipController.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipController.java
@@ -280,6 +280,7 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac
PackageManager pm = context.getPackageManager();
boolean supportsPip = pm.hasSystemFeature(FEATURE_PICTURE_IN_PICTURE);
if (!supportsPip) {
+ Log.w(TAG, "Device not support PIP feature");
return;
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java
index 62b35f9f5e2d..56f010d7e866 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java
@@ -16,6 +16,7 @@
package com.android.systemui.recents;
+import static android.content.pm.PackageManager.FEATURE_PICTURE_IN_PICTURE;
import static android.content.pm.PackageManager.MATCH_SYSTEM_ONLY;
import static android.view.MotionEvent.ACTION_CANCEL;
import static android.view.MotionEvent.ACTION_DOWN;
@@ -143,6 +144,7 @@ public class OverviewProxyService extends CurrentUserTracker implements
private int mConnectionBackoffAttempts;
private boolean mBound;
private boolean mIsEnabled;
+ private boolean mHasPipFeature;
private int mCurrentBoundedUserId = -1;
private float mNavBarButtonAlpha;
private boolean mInputFocusTransferStarted;
@@ -383,7 +385,9 @@ public class OverviewProxyService extends CurrentUserTracker implements
@Override
public void setShelfHeight(boolean visible, int shelfHeight) {
- if (!verifyCaller("setShelfHeight")) {
+ if (!verifyCaller("setShelfHeight") || !mHasPipFeature) {
+ Log.w(TAG_OPS,
+ "ByPass setShelfHeight, FEATURE_PICTURE_IN_PICTURE:" + mHasPipFeature);
return;
}
long token = Binder.clearCallingIdentity();
@@ -409,7 +413,9 @@ public class OverviewProxyService extends CurrentUserTracker implements
@Override
public void notifySwipeToHomeFinished() {
- if (!verifyCaller("notifySwipeToHomeFinished")) {
+ if (!verifyCaller("notifySwipeToHomeFinished") || !mHasPipFeature) {
+ Log.w(TAG_OPS, "ByPass notifySwipeToHomeFinished, FEATURE_PICTURE_IN_PICTURE:"
+ + mHasPipFeature);
return;
}
long token = Binder.clearCallingIdentity();
@@ -424,7 +430,9 @@ public class OverviewProxyService extends CurrentUserTracker implements
@Override
public void setPinnedStackAnimationListener(IPinnedStackAnimationListener listener) {
- if (!verifyCaller("setPinnedStackAnimationListener")) {
+ if (!verifyCaller("setPinnedStackAnimationListener") || !mHasPipFeature) {
+ Log.w(TAG_OPS, "ByPass setPinnedStackAnimationListener, FEATURE_PICTURE_IN_PICTURE:"
+ + mHasPipFeature);
return;
}
long token = Binder.clearCallingIdentity();
@@ -617,6 +625,7 @@ public class OverviewProxyService extends CurrentUserTracker implements
super(broadcastDispatcher);
mContext = context;
mPipOptional = pipOptional;
+ mHasPipFeature = mContext.getPackageManager().hasSystemFeature(FEATURE_PICTURE_IN_PICTURE);
mStatusBarOptionalLazy = statusBarOptionalLazy;
mHandler = new Handler();
mNavBarControllerLazy = navBarControllerLazy;