Add support for cross-activity scenes and transitions
* Add theme attributes for specifying a top-level TransitionManager
for an activity window.
* Add window feature for automatic content transitions. This
automatically assigns/creates a Scene for setContentView calls.
* Add named transitions. This allows apps to define APIs for
handshake-agreements about which exit/entrance transitions to play.
* Add new transition type for ActivityOptions. This lets the system
use ActivityOptions to communicate transition specifics and
arguments to the called activity.
* Have ActivityManager pass appropriate ActivityOptions through to the
called Activity. Have the called activity call back into the caller
to let it know which transition of a possible requested set was
chosen.
Still to do:
* Define and pass arguments for transitions. This will require
defining a Parcelable version of TransitionValues and deciding how
much leeway apps should have for these things.
* Determine how to appropriately filter the ActivityOptions bundle so
that only appropriate data reaches the target.
* Determine if generalizing the auto-Scenes functionality to
ViewGroups is appropriate.
Change-Id: I10684b926129ab2fbc1adec9ef31767237acae79
diff --git a/services/java/com/android/server/am/ActivityRecord.java b/services/java/com/android/server/am/ActivityRecord.java
index 5776181..8e85914 100644
--- a/services/java/com/android/server/am/ActivityRecord.java
+++ b/services/java/com/android/server/am/ActivityRecord.java
@@ -723,6 +723,10 @@
}
}
+ ActivityOptions getOptionsForTargetActivityLocked() {
+ return pendingOptions != null ? pendingOptions.forTargetActivity() : null;
+ }
+
void clearOptionsLocked() {
if (pendingOptions != null) {
pendingOptions.abort();
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index cd2cb331..2e914aa 100644
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -36,6 +36,8 @@
import static com.android.server.am.ActivityStackSupervisor.DEBUG_STATES;
import static com.android.server.am.ActivityStackSupervisor.HOME_STACK_ID;
+import android.os.Trace;
+import android.util.Log;
import com.android.internal.os.BatteryStatsImpl;
import com.android.internal.util.Objects;
import com.android.server.Watchdog;
@@ -1078,7 +1080,7 @@
mWindowManager.setAppVisibility(r.appToken, true);
}
if (r != starting) {
- mStackSupervisor.startSpecificActivityLocked(r, false, false);
+ mStackSupervisor.startSpecificActivityLocked(r, false, false, null);
}
}
@@ -1511,7 +1513,13 @@
mWindowManager.prepareAppTransition(AppTransition.TRANSIT_ACTIVITY_OPEN, false);
}
}
+
+ Bundle resumeAnimOptions = null;
if (anim) {
+ ActivityOptions opts = next.getOptionsForTargetActivityLocked();
+ if (opts != null) {
+ resumeAnimOptions = opts.toBundle();
+ }
next.applyOptionsLocked();
} else {
next.clearOptionsLocked();
@@ -1604,7 +1612,7 @@
next.app.pendingUiClean = true;
next.app.forceProcessStateUpTo(ActivityManager.PROCESS_STATE_TOP);
next.app.thread.scheduleResumeActivity(next.appToken, next.app.repProcState,
- mService.isNextTransitionForward());
+ mService.isNextTransitionForward(), resumeAnimOptions);
mStackSupervisor.checkReadyForSleepLocked();
@@ -1628,7 +1636,7 @@
next.nonLocalizedLabel, next.labelRes, next.icon, next.logo,
next.windowFlags, null, true);
}
- mStackSupervisor.startSpecificActivityLocked(next, true, false);
+ mStackSupervisor.startSpecificActivityLocked(next, true, false, resumeAnimOptions);
if (DEBUG_STACK) mStackSupervisor.validateTopActivitiesLocked();
return true;
}
@@ -1666,7 +1674,7 @@
if (DEBUG_SWITCH) Slog.v(TAG, "Restarting: " + next);
}
if (DEBUG_STATES) Slog.d(TAG, "resumeTopActivityLocked: Restarting " + next);
- mStackSupervisor.startSpecificActivityLocked(next, true, true);
+ mStackSupervisor.startSpecificActivityLocked(next, true, true, resumeAnimOptions);
}
if (DEBUG_STACK) mStackSupervisor.validateTopActivitiesLocked();
diff --git a/services/java/com/android/server/am/ActivityStackSupervisor.java b/services/java/com/android/server/am/ActivityStackSupervisor.java
index f4ca324..04617af 100644
--- a/services/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/java/com/android/server/am/ActivityStackSupervisor.java
@@ -379,7 +379,7 @@
if (hr.app == null && app.uid == hr.info.applicationInfo.uid
&& processName.equals(hr.processName)) {
try {
- if (realStartActivityLocked(hr, app, true, true)) {
+ if (realStartActivityLocked(hr, app, true, true, null)) {
didSomething = true;
}
} catch (Exception e) {
@@ -868,7 +868,7 @@
}
final boolean realStartActivityLocked(ActivityRecord r,
- ProcessRecord app, boolean andResume, boolean checkConfig)
+ ProcessRecord app, boolean andResume, boolean checkConfig, Bundle resumeArgs)
throws RemoteException {
r.startFreezingScreenLocked(app, 0);
@@ -960,13 +960,14 @@
}
}
}
+
app.forceProcessStateUpTo(ActivityManager.PROCESS_STATE_TOP);
app.thread.scheduleLaunchActivity(new Intent(r.intent), r.appToken,
System.identityHashCode(r), r.info,
new Configuration(mService.mConfiguration), r.compat,
app.repProcState, r.icicle, results, newIntents, !andResume,
mService.isNextTransitionForward(), profileFile, profileFd,
- profileAutoStop);
+ profileAutoStop, resumeArgs);
if ((app.info.flags&ApplicationInfo.FLAG_CANT_SAVE_STATE) != 0) {
// This may be a heavy-weight process! Note that the package
@@ -1040,7 +1041,7 @@
}
void startSpecificActivityLocked(ActivityRecord r,
- boolean andResume, boolean checkConfig) {
+ boolean andResume, boolean checkConfig, Bundle resumeArgs) {
// Is this activity's application already running?
ProcessRecord app = mService.getProcessRecordLocked(r.processName,
r.info.applicationInfo.uid, true);
@@ -1057,7 +1058,7 @@
// separate apk in the process.
app.addPackage(r.info.packageName, mService.mProcessStats);
}
- realStartActivityLocked(r, app, andResume, checkConfig);
+ realStartActivityLocked(r, app, andResume, checkConfig, resumeArgs);
return;
} catch (RemoteException e) {
Slog.w(TAG, "Exception when starting activity "