summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCraig Mautner <cmautner@google.com>2014-02-07 15:30:03 -0800
committerCraig Mautner <cmautner@google.com>2014-02-07 15:30:03 -0800
commit4e5b67e69560ca443d5fb4b78abf56ae948f578c (patch)
tree834def21b262209e8e6a553c4008edc14c132627
parent9ef471f7f2f59de032d7cb9c3c7241486109979e (diff)
downloadframeworks_base-4e5b67e69560ca443d5fb4b78abf56ae948f578c.zip
frameworks_base-4e5b67e69560ca443d5fb4b78abf56ae948f578c.tar.gz
frameworks_base-4e5b67e69560ca443d5fb4b78abf56ae948f578c.tar.bz2
Queue startActivity params if not yet ready.
If the ActivityView is not ready when the startActivity method is called we now save the Intent until the ActivityView is ready. Fixes bug 12821638. Change-Id: I30ebb2699963f174cc2d5a3fb77a99ed33a4252b
-rw-r--r--core/java/android/app/ActivityView.java47
1 files changed, 35 insertions, 12 deletions
diff --git a/core/java/android/app/ActivityView.java b/core/java/android/app/ActivityView.java
index df4ec78..ad38489 100644
--- a/core/java/android/app/ActivityView.java
+++ b/core/java/android/app/ActivityView.java
@@ -18,6 +18,7 @@ package android.app;
import android.content.Context;
import android.content.ContextWrapper;
+import android.content.IIntentSender;
import android.content.Intent;
import android.content.IntentSender;
import android.graphics.SurfaceTexture;
@@ -43,6 +44,10 @@ public class ActivityView extends ViewGroup {
private int mHeight;
private Surface mSurface;
+ // Only one IIntentSender or Intent may be queued at a time. Most recent one wins.
+ IIntentSender mQueuedPendingIntent;
+ Intent mQueuedIntent;
+
public ActivityView(Context context) {
this(context, null);
}
@@ -118,28 +123,38 @@ public class ActivityView extends ViewGroup {
} catch (RemoteException e) {
throw new IllegalStateException("ActivityView: Unable to startActivity. " + e);
}
+ } else {
+ mQueuedIntent = intent;
+ mQueuedPendingIntent = null;
+ }
+ }
+
+ private void startActivityIntentSender(IIntentSender iIntentSender) {
+ try {
+ mActivityContainer.startActivityIntentSender(iIntentSender);
+ } catch (RemoteException e) {
+ throw new IllegalStateException(
+ "ActivityView: Unable to startActivity from IntentSender. " + e);
}
}
public void startActivity(IntentSender intentSender) {
+ final IIntentSender iIntentSender = intentSender.getTarget();
if (mSurface != null) {
- try {
- mActivityContainer.startActivityIntentSender(intentSender.getTarget());
- } catch (RemoteException e) {
- throw new IllegalStateException(
- "ActivityView: Unable to startActivity from IntentSender. " + e);
- }
+ startActivityIntentSender(iIntentSender);
+ } else {
+ mQueuedPendingIntent = iIntentSender;
+ mQueuedIntent = null;
}
}
public void startActivity(PendingIntent pendingIntent) {
+ final IIntentSender iIntentSender = pendingIntent.getTarget();
if (mSurface != null) {
- try {
- mActivityContainer.startActivityIntentSender(pendingIntent.getTarget());
- } catch (RemoteException e) {
- throw new IllegalStateException(
- "ActivityView: Unable to startActivity from PendingIntent. " + e);
- }
+ startActivityIntentSender(iIntentSender);
+ } else {
+ mQueuedPendingIntent = iIntentSender;
+ mQueuedIntent = null;
}
}
@@ -163,6 +178,14 @@ public class ActivityView extends ViewGroup {
throw new IllegalStateException(
"ActivityView: Unable to create ActivityContainer. " + e);
}
+
+ if (mQueuedIntent != null) {
+ startActivity(mQueuedIntent);
+ mQueuedIntent = null;
+ } else if (mQueuedPendingIntent != null) {
+ startActivityIntentSender(mQueuedPendingIntent);
+ mQueuedPendingIntent = null;
+ }
}
private void detach() {