Merge "Fixing error calculating the top pinned activity."
This commit is contained in:
committed by
Android (Google) Code Review
commit
2bf3b1b2cf
@@ -86,9 +86,12 @@ public class PipManager {
|
||||
// another package than the top activity in the stack
|
||||
boolean expandPipToFullscreen = true;
|
||||
if (sourceComponent != null) {
|
||||
ComponentName topActivity = PipUtils.getTopPinnedActivity(mActivityManager);
|
||||
expandPipToFullscreen = topActivity != null && topActivity.getPackageName().equals(
|
||||
sourceComponent.getPackageName());
|
||||
ComponentName topActivity = PipUtils.getTopPinnedActivity(mContext,
|
||||
mActivityManager);
|
||||
if (topActivity != null && topActivity.getPackageName().equals(
|
||||
sourceComponent.getPackageName())) {
|
||||
expandPipToFullscreen = false;
|
||||
}
|
||||
}
|
||||
if (expandPipToFullscreen) {
|
||||
mTouchHandler.expandPinnedStackToFullscreen();
|
||||
|
||||
@@ -148,7 +148,8 @@ public class PipMediaController {
|
||||
*/
|
||||
private void resolveActiveMediaController(List<MediaController> controllers) {
|
||||
if (controllers != null) {
|
||||
final ComponentName topActivity = PipUtils.getTopPinnedActivity(mActivityManager);
|
||||
final ComponentName topActivity = PipUtils.getTopPinnedActivity(mContext,
|
||||
mActivityManager);
|
||||
if (topActivity != null) {
|
||||
for (int i = 0; i < controllers.size(); i++) {
|
||||
final MediaController controller = controllers.get(i);
|
||||
|
||||
@@ -21,6 +21,7 @@ import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
|
||||
import android.app.ActivityManager.StackInfo;
|
||||
import android.app.IActivityManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -29,14 +30,23 @@ public class PipUtils {
|
||||
private static final String TAG = "PipUtils";
|
||||
|
||||
/**
|
||||
* @return the ComponentName of the top activity in the pinned stack, or null if none exists.
|
||||
* @return the ComponentName of the top non-SystemUI activity in the pinned stack, or null if
|
||||
* none exists.
|
||||
*/
|
||||
public static ComponentName getTopPinnedActivity(IActivityManager activityManager) {
|
||||
public static ComponentName getTopPinnedActivity(Context context,
|
||||
IActivityManager activityManager) {
|
||||
try {
|
||||
StackInfo pinnedStackInfo = activityManager.getStackInfo(PINNED_STACK_ID);
|
||||
final String sysUiPackageName = context.getPackageName();
|
||||
final StackInfo pinnedStackInfo = activityManager.getStackInfo(PINNED_STACK_ID);
|
||||
if (pinnedStackInfo != null && pinnedStackInfo.taskIds != null &&
|
||||
pinnedStackInfo.taskIds.length > 0) {
|
||||
return pinnedStackInfo.topActivity;
|
||||
for (int i = pinnedStackInfo.taskNames.length - 1; i >= 0; i--) {
|
||||
ComponentName cn = ComponentName.unflattenFromString(
|
||||
pinnedStackInfo.taskNames[i]);
|
||||
if (cn != null && !cn.getPackageName().equals(sysUiPackageName)) {
|
||||
return cn;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Unable to get pinned stack.");
|
||||
|
||||
Reference in New Issue
Block a user