Do not allow moveToFront() and moveTaskToFront() when app is in background
Bug: 129063631 Test: Unable to start activity / move task in background Change-Id: Icb5ebad3567b911719341f221483df1a1512109b
This commit is contained in:
@@ -2001,7 +2001,10 @@ public class ActivityManager {
|
||||
@RequiresPermission(android.Manifest.permission.REORDER_TASKS)
|
||||
public void moveTaskToFront(int taskId, @MoveTaskFlags int flags, Bundle options) {
|
||||
try {
|
||||
getTaskService().moveTaskToFront(taskId, flags, options);
|
||||
ActivityThread thread = ActivityThread.currentActivityThread();
|
||||
IApplicationThread appThread = thread.getApplicationThread();
|
||||
String packageName = mContext.getPackageName();
|
||||
getTaskService().moveTaskToFront(appThread, packageName, taskId, flags, options);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -4212,7 +4215,10 @@ public class ActivityManager {
|
||||
*/
|
||||
public void moveToFront() {
|
||||
try {
|
||||
mAppTaskImpl.moveToFront();
|
||||
ActivityThread thread = ActivityThread.currentActivityThread();
|
||||
IApplicationThread appThread = thread.getApplicationThread();
|
||||
String packageName = ActivityThread.currentPackageName();
|
||||
mAppTaskImpl.moveToFront(appThread, packageName);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
|
||||
@@ -130,7 +130,8 @@ interface IActivityManager {
|
||||
List<ActivityManager.RunningTaskInfo> getFilteredTasks(int maxNum, int ignoreActivityType,
|
||||
int ignoreWindowingMode);
|
||||
@UnsupportedAppUsage
|
||||
void moveTaskToFront(int task, int flags, in Bundle options);
|
||||
void moveTaskToFront(in IApplicationThread caller, in String callingPackage, int task,
|
||||
int flags, in Bundle options);
|
||||
@UnsupportedAppUsage
|
||||
int getTaskForActivity(in IBinder token, in boolean onlyRoot);
|
||||
ContentProviderHolder getContentProvider(in IApplicationThread caller, in String callingPackage,
|
||||
|
||||
@@ -149,7 +149,8 @@ interface IActivityTaskManager {
|
||||
boolean shouldUpRecreateTask(in IBinder token, in String destAffinity);
|
||||
boolean navigateUpTo(in IBinder token, in Intent target, int resultCode,
|
||||
in Intent resultData);
|
||||
void moveTaskToFront(int task, int flags, in Bundle options);
|
||||
void moveTaskToFront(in IApplicationThread app, in String callingPackage, int task,
|
||||
int flags, in Bundle options);
|
||||
int getTaskForActivity(in IBinder token, in boolean onlyRoot);
|
||||
void finishSubActivity(in IBinder token, in String resultWho, int requestCode);
|
||||
ParceledListSlice getRecentTasks(int maxNum, int flags, int userId);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package android.app;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.IApplicationThread;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
@@ -25,7 +26,7 @@ interface IAppTask {
|
||||
void finishAndRemoveTask();
|
||||
@UnsupportedAppUsage
|
||||
ActivityManager.RecentTaskInfo getTaskInfo();
|
||||
void moveToFront();
|
||||
void moveToFront(in IApplicationThread appThread, in String callingPackage);
|
||||
int startActivity(IBinder whoThread, String callingPackage,
|
||||
in Intent intent, String resolvedType, in Bundle options);
|
||||
void setExcludeFromRecents(boolean exclude);
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
package com.android.internal.app;
|
||||
|
||||
import com.android.internal.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityTaskManager;
|
||||
import android.app.ActivityThread;
|
||||
import android.app.IApplicationThread;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentSender;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
@@ -29,13 +29,14 @@ import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.Window;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.internal.R;
|
||||
|
||||
/**
|
||||
* This activity is displayed when the system attempts to start an Intent for
|
||||
* which there is more than one matching activity, allowing the user to decide
|
||||
@@ -127,7 +128,10 @@ public class HeavyWeightSwitcherActivity extends Activity {
|
||||
private OnClickListener mSwitchOldListener = new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
try {
|
||||
ActivityTaskManager.getService().moveTaskToFront(mCurTask, 0, null);
|
||||
ActivityThread thread = ActivityThread.currentActivityThread();
|
||||
IApplicationThread appThread = thread.getApplicationThread();
|
||||
ActivityTaskManager.getService().moveTaskToFront(appThread, getPackageName(),
|
||||
mCurTask, 0, null);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
finish();
|
||||
|
||||
Reference in New Issue
Block a user