Fix NPE when logging already removed pip activity
Bug: 148943800 Test: Manual
This commit is contained in:
@@ -44,7 +44,7 @@ public class PipAppOpsListener {
|
||||
try {
|
||||
// Dismiss the PiP once the user disables the app ops setting for that package
|
||||
final Pair<ComponentName, Integer> topPipActivityInfo =
|
||||
PipUtils.getTopPinnedActivity(mContext, mActivityManager);
|
||||
PipUtils.getTopPipActivity(mContext, mActivityManager);
|
||||
if (topPipActivityInfo.first != null) {
|
||||
final ApplicationInfo appInfo = mContext.getPackageManager()
|
||||
.getApplicationInfoAsUser(packageName, 0, topPipActivityInfo.second);
|
||||
|
||||
@@ -115,7 +115,7 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
||||
|
||||
@Override
|
||||
public void onActivityUnpinned() {
|
||||
final Pair<ComponentName, Integer> topPipActivityInfo = PipUtils.getTopPinnedActivity(
|
||||
final Pair<ComponentName, Integer> topPipActivityInfo = PipUtils.getTopPipActivity(
|
||||
mContext, mActivityManager);
|
||||
final ComponentName topActivity = topPipActivityInfo.first;
|
||||
mMenuController.onActivityUnpinned();
|
||||
|
||||
@@ -231,7 +231,7 @@ public class PipMediaController {
|
||||
*/
|
||||
private void resolveActiveMediaController(List<MediaController> controllers) {
|
||||
if (controllers != null) {
|
||||
final ComponentName topActivity = PipUtils.getTopPinnedActivity(mContext,
|
||||
final ComponentName topActivity = PipUtils.getTopPipActivity(mContext,
|
||||
mActivityManager).first;
|
||||
if (topActivity != null) {
|
||||
for (int i = 0; i < controllers.size(); i++) {
|
||||
|
||||
@@ -569,7 +569,7 @@ public class PipMenuActivity extends Activity {
|
||||
|
||||
private void showSettings() {
|
||||
final Pair<ComponentName, Integer> topPipActivityInfo =
|
||||
PipUtils.getTopPinnedActivity(this, ActivityManager.getService());
|
||||
PipUtils.getTopPipActivity(this, ActivityManager.getService());
|
||||
if (topPipActivityInfo.first != null) {
|
||||
final UserHandle user = UserHandle.of(topPipActivityInfo.second);
|
||||
final Intent settingsIntent = new Intent(ACTION_PICTURE_IN_PICTURE_SETTINGS,
|
||||
|
||||
@@ -31,6 +31,7 @@ import android.graphics.Rect;
|
||||
import android.os.Handler;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.util.Size;
|
||||
import android.view.IPinnedStackController;
|
||||
import android.view.InputEvent;
|
||||
@@ -148,8 +149,11 @@ public class PipTouchHandler {
|
||||
|
||||
@Override
|
||||
public void onPipDismiss() {
|
||||
MetricsLoggerWrapper.logPictureInPictureDismissByTap(mContext,
|
||||
PipUtils.getTopPinnedActivity(mContext, mActivityManager));
|
||||
Pair<ComponentName, Integer> topPipActivity = PipUtils.getTopPipActivity(mContext,
|
||||
mActivityManager);
|
||||
if (topPipActivity.first != null) {
|
||||
MetricsLoggerWrapper.logPictureInPictureDismissByTap(mContext, topPipActivity);
|
||||
}
|
||||
mMotionHelper.dismissPip();
|
||||
}
|
||||
|
||||
@@ -653,7 +657,7 @@ public class PipTouchHandler {
|
||||
// Check if the user dragged or flung the PiP offscreen to dismiss it
|
||||
if (mMotionHelper.shouldDismissPip() || isFlingToBot) {
|
||||
MetricsLoggerWrapper.logPictureInPictureDismissByDrag(mContext,
|
||||
PipUtils.getTopPinnedActivity(mContext, mActivityManager));
|
||||
PipUtils.getTopPipActivity(mContext, mActivityManager));
|
||||
mMotionHelper.animateDismiss(
|
||||
vel.x, vel.y,
|
||||
PipTouchHandler.this::updateDismissFraction /* updateAction */);
|
||||
|
||||
@@ -36,7 +36,7 @@ public class PipUtils {
|
||||
* @return the ComponentName and user id of the top non-SystemUI activity in the pinned stack.
|
||||
* The component name may be null if no such activity exists.
|
||||
*/
|
||||
public static Pair<ComponentName, Integer> getTopPinnedActivity(Context context,
|
||||
public static Pair<ComponentName, Integer> getTopPipActivity(Context context,
|
||||
IActivityManager activityManager) {
|
||||
try {
|
||||
final String sysUiPackageName = context.getPackageName();
|
||||
|
||||
Reference in New Issue
Block a user