summaryrefslogtreecommitdiff
path: root/InCallUI/src/com/android/incallui/InCallPresenter.java
diff options
context:
space:
mode:
authorSantos Cordon <santoscordon@google.com>2013-09-13 18:56:45 -0700
committerSantos Cordon <santoscordon@google.com>2013-09-13 23:46:31 -0700
commit49ff6571403695e81dbbd83e4f61790ce9c75f6d (patch)
tree6ae7141e11e5866b5dda8ce8cf84b20ea6b7068a /InCallUI/src/com/android/incallui/InCallPresenter.java
parentb5346c68a29e128fed4d1e72b3501599ee9663bb (diff)
Fix UI lag when calling a contact with a photo.
Related fixes unrelated to latency problem: a. Update StatusBarNotifier with new changes to CallerInfoCache. b. Outgoing JANK fix in notifier needed to know if the activity was previously started, not just if it was finished. (b/10734874) c. Consolidate places where we use the Intent. Several improvements to speed up startUp time from most egregious to least: 1. In InCallPresenter, statusBarNotifier wasn't unlistening to incoming call changes which kept orphaned instances still listening and calling into contactInfoCache. ContactInfoCache was subsequently calling into many notifiers which did heavy image parcelling work. - Clear incomingCallListeners on tear down. 2. StatusBarNotifier was getting called directly from InCallPresenter & onIncomingCall() callbacks. onIncomingCall callback was unnecessary and caused extra work. - Fix is to stop listening to incoming calls. Status bar notifier gets called directly by InCallPresenter in startAndFinish() so listening to incoming was redundant. 3. Make ContactInfoCache listeners list a Set to avoid duplicate entries and reduce callback execution. bug:10712670 bug:10734874 Change-Id: Ic8d50b1d9ce336ffe3a5191abe1c9db32365eee6
Diffstat (limited to 'InCallUI/src/com/android/incallui/InCallPresenter.java')
-rw-r--r--InCallUI/src/com/android/incallui/InCallPresenter.java30
1 files changed, 26 insertions, 4 deletions
diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java
index 0f8d4071a..47b0871ae 100644
--- a/InCallUI/src/com/android/incallui/InCallPresenter.java
+++ b/InCallUI/src/com/android/incallui/InCallPresenter.java
@@ -50,9 +50,17 @@ public class InCallPresenter implements CallList.Listener {
private Context mContext;
private CallList mCallList;
private InCallActivity mInCallActivity;
- private boolean mServiceConnected = false;
private InCallState mInCallState = InCallState.NO_CALLS;
private ProximitySensor mProximitySensor;
+ private boolean mServiceConnected = false;
+
+ /**
+ * Is true when the activity has been previously started. Some code needs to know not just if
+ * the activity is currently up, but if it had been previously shown in foreground for this
+ * in-call session (e.g., StatusBarNotifier). This gets reset when the session ends in the
+ * tear-down method.
+ */
+ private boolean mActivityPreviouslyStarted = false;
public static synchronized InCallPresenter getInstance() {
if (sInCallPresenter == null) {
@@ -78,7 +86,6 @@ public class InCallPresenter implements CallList.Listener {
mStatusBarNotifier = new StatusBarNotifier(context, mContactInfoCache, mCallList);
addListener(mStatusBarNotifier);
- addIncomingCallListener(mStatusBarNotifier);
mAudioModeProvider = audioModeProvider;
@@ -218,6 +225,11 @@ public class InCallPresenter implements CallList.Listener {
mIncomingCallListeners.add(listener);
}
+ public void removeIncomingCallListener(IncomingCallListener listener) {
+ Preconditions.checkNotNull(listener);
+ mIncomingCallListeners.remove(listener);
+ }
+
public void addListener(InCallStateListener listener) {
Preconditions.checkNotNull(listener);
mListeners.add(listener);
@@ -272,8 +284,12 @@ public class InCallPresenter implements CallList.Listener {
!mInCallActivity.isFinishing());
}
+ public boolean isActivityPreviouslyStarted() {
+ return mActivityPreviouslyStarted;
+ }
+
/**
- * Called when the activity goes out of the foreground.
+ * Called when the activity goes in/out of the foreground.
*/
public void onUiShowing(boolean showing) {
// We need to update the notification bar when we leave the UI because that
@@ -285,6 +301,10 @@ public class InCallPresenter implements CallList.Listener {
if (mProximitySensor != null) {
mProximitySensor.onInCallShowing(showing);
}
+
+ if (showing) {
+ mActivityPreviouslyStarted = true;
+ }
}
/**
@@ -397,6 +417,7 @@ public class InCallPresenter implements CallList.Listener {
Log.i(this, "attemptCleanup? " + shouldCleanup);
if (shouldCleanup) {
+ mActivityPreviouslyStarted = false;
// blow away stale contact info so that we get fresh data on
// the next set of calls
@@ -417,6 +438,7 @@ public class InCallPresenter implements CallList.Listener {
mInCallActivity = null;
mListeners.clear();
+ mIncomingCallListeners.clear();
Log.d(this, "Finished InCallPresenter.CleanUp");
}
@@ -426,7 +448,7 @@ public class InCallPresenter implements CallList.Listener {
mContext.startActivity(getInCallIntent());
}
- private Intent getInCallIntent() {
+ public Intent getInCallIntent() {
final Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS