summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android/systemui/recents
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2014-09-06 17:07:51 +0200
committerWinson Chung <winsonc@google.com>2014-09-07 20:08:55 +0000
commit4e8dd649b4c72122cdf15da9cfabc45aac789365 (patch)
tree91a8628e185ec67be455edfbc60dd0b491260fb2 /packages/SystemUI/src/com/android/systemui/recents
parent2e7f3bdcc9ec0b3e95b565b943ecee2210f4b937 (diff)
downloadframeworks_base-4e8dd649b4c72122cdf15da9cfabc45aac789365.zip
frameworks_base-4e8dd649b4c72122cdf15da9cfabc45aac789365.tar.gz
frameworks_base-4e8dd649b4c72122cdf15da9cfabc45aac789365.tar.bz2
Ensuring that we retry if the callback for animation started comes before the Recents activity starts. (Bug 17316671)
Change-Id: I8e50e2cd9ba6a47dda21f21afbe14bb9d3eda979
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/recents')
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java29
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java3
2 files changed, 30 insertions, 2 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
index 64617bf..5fa9fa4 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
@@ -16,10 +16,12 @@
package com.android.systemui.recents;
+import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityOptions;
import android.appwidget.AppWidgetProviderInfo;
import android.content.ActivityNotFoundException;
+import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -563,11 +565,34 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
public void onAnimationStarted() {
// Notify recents to start the enter animation
if (!mStartAnimationTriggered) {
+ // There can be a race condition between the start animation callback and
+ // the start of the new activity (where we register the receiver that listens
+ // to this broadcast, so we add our own receiver and if that gets called, then
+ // we know the activity has not yet started and we can retry sending the broadcast.
+ BroadcastReceiver fallbackReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (getResultCode() == Activity.RESULT_OK) {
+ mStartAnimationTriggered = true;
+ return;
+ }
+
+ // Schedule for the broadcast to be sent again after some time
+ mHandler.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ onAnimationStarted();
+ }
+ }, 75);
+ }
+ };
+
+ // Send the broadcast to notify Recents that the animation has started
Intent intent = new Intent(ACTION_START_ENTER_ANIMATION);
intent.setPackage(mContext.getPackageName());
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
- mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT);
- mStartAnimationTriggered = true;
+ mContext.sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT, null,
+ fallbackReceiver, null, Activity.RESULT_CANCELED, null, null);
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
index ec7799a..8f92027 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
@@ -146,6 +146,9 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
ReferenceCountedTrigger t = new ReferenceCountedTrigger(context, null, null, null);
mRecentsView.startEnterRecentsAnimation(new ViewAnimation.TaskViewEnterContext(t));
onEnterAnimationTriggered();
+ // Notify the fallback receiver that we have successfully got the broadcast
+ // See AlternateRecentsComponent.onAnimationStarted()
+ setResultCode(Activity.RESULT_OK);
}
}
};