Loading core/java/android/app/Activity.java +2 −3 Original line number Diff line number Diff line Loading @@ -54,7 +54,6 @@ import android.graphics.Canvas; import android.graphics.drawable.Drawable; import android.media.AudioManager; import android.media.session.MediaController; import android.media.session.MediaSession; import android.net.Uri; import android.os.Build; import android.os.Bundle; Loading Loading @@ -5641,8 +5640,8 @@ public class Activity extends ContextThemeWrapper if (info.taskAffinity == null) { return false; } return !ActivityManagerNative.getDefault() .targetTaskAffinityMatchesActivity(mToken, info.taskAffinity); return ActivityManagerNative.getDefault() .shouldUpRecreateTask(mToken, info.taskAffinity); } catch (RemoteException e) { return false; } catch (NameNotFoundException e) { Loading core/java/android/app/ActivityManagerNative.java +4 −4 Original line number Diff line number Diff line Loading @@ -1997,11 +1997,11 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM return true; } case TARGET_TASK_AFFINITY_MATCHES_ACTIVITY_TRANSACTION: { case SHOULD_UP_RECREATE_TASK_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); IBinder token = data.readStrongBinder(); String destAffinity = data.readString(); boolean res = targetTaskAffinityMatchesActivity(token, destAffinity); boolean res = shouldUpRecreateTask(token, destAffinity); reply.writeNoException(); reply.writeInt(res ? 1 : 0); return true; Loading Loading @@ -4858,14 +4858,14 @@ class ActivityManagerProxy implements IActivityManager reply.recycle(); } public boolean targetTaskAffinityMatchesActivity(IBinder token, String destAffinity) public boolean shouldUpRecreateTask(IBinder token, String destAffinity) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeStrongBinder(token); data.writeString(destAffinity); mRemote.transact(TARGET_TASK_AFFINITY_MATCHES_ACTIVITY_TRANSACTION, data, reply, 0); mRemote.transact(SHOULD_UP_RECREATE_TASK_TRANSACTION, data, reply, 0); reply.readException(); boolean result = reply.readInt() != 0; data.recycle(); Loading core/java/android/app/IActivityManager.java +2 −2 Original line number Diff line number Diff line Loading @@ -393,7 +393,7 @@ public interface IActivityManager extends IInterface { public void keyguardWaitingForActivityDrawn() throws RemoteException; public boolean targetTaskAffinityMatchesActivity(IBinder token, String destAffinity) public boolean shouldUpRecreateTask(IBinder token, String destAffinity) throws RemoteException; public boolean navigateUpTo(IBinder token, Intent target, int resultCode, Intent resultData) Loading Loading @@ -702,7 +702,7 @@ public interface IActivityManager extends IInterface { int GET_MY_MEMORY_STATE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+142; int KILL_PROCESSES_BELOW_FOREGROUND_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+143; int GET_CURRENT_USER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+144; int TARGET_TASK_AFFINITY_MATCHES_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+145; int SHOULD_UP_RECREATE_TASK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+145; int NAVIGATE_UP_TO_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+146; int SET_LOCK_SCREEN_SHOWN_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+147; int FINISH_ACTIVITY_AFFINITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+148; Loading services/core/java/com/android/server/am/ActivityManagerService.java +8 −4 Original line number Diff line number Diff line Loading @@ -15566,10 +15566,14 @@ public final class ActivityManagerService extends ActivityManagerNative } @Override public boolean targetTaskAffinityMatchesActivity(IBinder token, String destAffinity) { public boolean shouldUpRecreateTask(IBinder token, String destAffinity) { synchronized (this) { ActivityRecord srec = ActivityRecord.forToken(token); return srec != null && srec.task.affinity != null && srec.task.affinity.equals(destAffinity); if (srec.task != null && srec.task.stack != null) { return srec.task.stack.shouldUpRecreateTaskLocked(srec, destAffinity); } } return false; } public boolean navigateUpTo(IBinder token, Intent destIntent, int resultCode, services/core/java/com/android/server/am/ActivityStack.java +36 −0 Original line number Diff line number Diff line Loading @@ -2806,6 +2806,42 @@ final class ActivityStack { } } final boolean shouldUpRecreateTaskLocked(ActivityRecord srec, String destAffinity) { // Basic case: for simple app-centric recents, we need to recreate // the task if the affinity has changed. if (srec == null || srec.task.affinity == null || !srec.task.affinity.equals(destAffinity)) { return true; } // Document-centric case: an app may be split in to multiple documents; // they need to re-create their task if this current activity is the root // of a document, unless simply finishing it will return them to the the // correct app behind. if (srec.frontOfTask && srec.task != null) { // Okay, this activity is at the root of its task. What to do, what to do... if (srec.task.getTaskToReturnTo() != ActivityRecord.APPLICATION_ACTIVITY_TYPE) { // Finishing won't return to an application, so we need to recreate. return true; } // We now need to get the task below it to determine what to do. int taskIdx = mTaskHistory.indexOf(srec.task); if (taskIdx <= 0) { Slog.w(TAG, "shouldUpRecreateTask: task not in history for " + srec); return false; } if (taskIdx == 0) { // At the bottom of the stack, nothing to go back to. return true; } TaskRecord prevTask = mTaskHistory.get(taskIdx); if (!srec.task.affinity.equals(prevTask.affinity)) { // These are different apps, so need to recreate. return true; } } return false; } final boolean navigateUpToLocked(IBinder token, Intent destIntent, int resultCode, Intent resultData) { final ActivityRecord srec = ActivityRecord.forToken(token); Loading Loading
core/java/android/app/Activity.java +2 −3 Original line number Diff line number Diff line Loading @@ -54,7 +54,6 @@ import android.graphics.Canvas; import android.graphics.drawable.Drawable; import android.media.AudioManager; import android.media.session.MediaController; import android.media.session.MediaSession; import android.net.Uri; import android.os.Build; import android.os.Bundle; Loading Loading @@ -5641,8 +5640,8 @@ public class Activity extends ContextThemeWrapper if (info.taskAffinity == null) { return false; } return !ActivityManagerNative.getDefault() .targetTaskAffinityMatchesActivity(mToken, info.taskAffinity); return ActivityManagerNative.getDefault() .shouldUpRecreateTask(mToken, info.taskAffinity); } catch (RemoteException e) { return false; } catch (NameNotFoundException e) { Loading
core/java/android/app/ActivityManagerNative.java +4 −4 Original line number Diff line number Diff line Loading @@ -1997,11 +1997,11 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM return true; } case TARGET_TASK_AFFINITY_MATCHES_ACTIVITY_TRANSACTION: { case SHOULD_UP_RECREATE_TASK_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); IBinder token = data.readStrongBinder(); String destAffinity = data.readString(); boolean res = targetTaskAffinityMatchesActivity(token, destAffinity); boolean res = shouldUpRecreateTask(token, destAffinity); reply.writeNoException(); reply.writeInt(res ? 1 : 0); return true; Loading Loading @@ -4858,14 +4858,14 @@ class ActivityManagerProxy implements IActivityManager reply.recycle(); } public boolean targetTaskAffinityMatchesActivity(IBinder token, String destAffinity) public boolean shouldUpRecreateTask(IBinder token, String destAffinity) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeStrongBinder(token); data.writeString(destAffinity); mRemote.transact(TARGET_TASK_AFFINITY_MATCHES_ACTIVITY_TRANSACTION, data, reply, 0); mRemote.transact(SHOULD_UP_RECREATE_TASK_TRANSACTION, data, reply, 0); reply.readException(); boolean result = reply.readInt() != 0; data.recycle(); Loading
core/java/android/app/IActivityManager.java +2 −2 Original line number Diff line number Diff line Loading @@ -393,7 +393,7 @@ public interface IActivityManager extends IInterface { public void keyguardWaitingForActivityDrawn() throws RemoteException; public boolean targetTaskAffinityMatchesActivity(IBinder token, String destAffinity) public boolean shouldUpRecreateTask(IBinder token, String destAffinity) throws RemoteException; public boolean navigateUpTo(IBinder token, Intent target, int resultCode, Intent resultData) Loading Loading @@ -702,7 +702,7 @@ public interface IActivityManager extends IInterface { int GET_MY_MEMORY_STATE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+142; int KILL_PROCESSES_BELOW_FOREGROUND_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+143; int GET_CURRENT_USER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+144; int TARGET_TASK_AFFINITY_MATCHES_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+145; int SHOULD_UP_RECREATE_TASK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+145; int NAVIGATE_UP_TO_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+146; int SET_LOCK_SCREEN_SHOWN_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+147; int FINISH_ACTIVITY_AFFINITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+148; Loading
services/core/java/com/android/server/am/ActivityManagerService.java +8 −4 Original line number Diff line number Diff line Loading @@ -15566,10 +15566,14 @@ public final class ActivityManagerService extends ActivityManagerNative } @Override public boolean targetTaskAffinityMatchesActivity(IBinder token, String destAffinity) { public boolean shouldUpRecreateTask(IBinder token, String destAffinity) { synchronized (this) { ActivityRecord srec = ActivityRecord.forToken(token); return srec != null && srec.task.affinity != null && srec.task.affinity.equals(destAffinity); if (srec.task != null && srec.task.stack != null) { return srec.task.stack.shouldUpRecreateTaskLocked(srec, destAffinity); } } return false; } public boolean navigateUpTo(IBinder token, Intent destIntent, int resultCode,
services/core/java/com/android/server/am/ActivityStack.java +36 −0 Original line number Diff line number Diff line Loading @@ -2806,6 +2806,42 @@ final class ActivityStack { } } final boolean shouldUpRecreateTaskLocked(ActivityRecord srec, String destAffinity) { // Basic case: for simple app-centric recents, we need to recreate // the task if the affinity has changed. if (srec == null || srec.task.affinity == null || !srec.task.affinity.equals(destAffinity)) { return true; } // Document-centric case: an app may be split in to multiple documents; // they need to re-create their task if this current activity is the root // of a document, unless simply finishing it will return them to the the // correct app behind. if (srec.frontOfTask && srec.task != null) { // Okay, this activity is at the root of its task. What to do, what to do... if (srec.task.getTaskToReturnTo() != ActivityRecord.APPLICATION_ACTIVITY_TYPE) { // Finishing won't return to an application, so we need to recreate. return true; } // We now need to get the task below it to determine what to do. int taskIdx = mTaskHistory.indexOf(srec.task); if (taskIdx <= 0) { Slog.w(TAG, "shouldUpRecreateTask: task not in history for " + srec); return false; } if (taskIdx == 0) { // At the bottom of the stack, nothing to go back to. return true; } TaskRecord prevTask = mTaskHistory.get(taskIdx); if (!srec.task.affinity.equals(prevTask.affinity)) { // These are different apps, so need to recreate. return true; } } return false; } final boolean navigateUpToLocked(IBinder token, Intent destIntent, int resultCode, Intent resultData) { final ActivityRecord srec = ActivityRecord.forToken(token); Loading