summaryrefslogtreecommitdiff
path: root/packages/SystemUI/src/com/android/keyguard/KeyguardSliceView.java
diff options
context:
space:
mode:
authorLucas Dupin <dupin@google.com>2018-08-15 11:29:32 -0700
committerLucas Dupin <dupin@google.com>2018-08-15 11:37:07 -0700
commita0d5119c38e2dedd2bc1d00554c26a5bd3925614 (patch)
tree68722f1b7de4727f2f860b4dafed24ec222c5389 /packages/SystemUI/src/com/android/keyguard/KeyguardSliceView.java
parent07d2da8e7697c2f099bad0b51ebbe2329a29de43 (diff)
Avoid binder call when binding Slice
The ContentProvider will make unecessary binder calls when trying to bind the Slice. We can call directly into the provider and grab the slice in these cases. Bug: 112563822 Test: systrace Change-Id: Ia761afccd7d28cf5e41b7c1420715fd9446ac8e8
Diffstat (limited to 'packages/SystemUI/src/com/android/keyguard/KeyguardSliceView.java')
-rw-r--r--packages/SystemUI/src/com/android/keyguard/KeyguardSliceView.java20
1 files changed, 19 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSliceView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSliceView.java
index 6517a9dd4f71..9603562c0d4a 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSliceView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSliceView.java
@@ -27,6 +27,7 @@ import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.net.Uri;
+import android.os.Trace;
import android.provider.Settings;
import android.text.Layout;
import android.text.TextUtils;
@@ -148,6 +149,7 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe
}
private void showSlice() {
+ Trace.beginSection("KeyguardSliceView#showSlice");
if (mPulsing || mSlice == null) {
mTitle.setVisibility(GONE);
mRow.setVisibility(GONE);
@@ -236,6 +238,7 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe
if (mContentChangeListener != null) {
mContentChangeListener.run();
}
+ Trace.endSection();
}
public void setPulsing(boolean pulsing, boolean animate) {
@@ -383,8 +386,23 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe
}
public void refresh() {
- Slice slice = SliceViewManager.getInstance(getContext()).bindSlice(mKeyguardSliceUri);
+ Slice slice;
+ Trace.beginSection("KeyguardSliceView#refresh");
+ // We can optimize performance and avoid binder calls when we know that we're bound
+ // to a Slice on the same process.
+ if (KeyguardSliceProvider.KEYGUARD_SLICE_URI.equals(mKeyguardSliceUri.toString())) {
+ KeyguardSliceProvider instance = KeyguardSliceProvider.getAttachedInstance();
+ if (instance != null) {
+ slice = instance.onBindSlice(mKeyguardSliceUri);
+ } else {
+ Log.w(TAG, "Keyguard slice not bound yet?");
+ slice = null;
+ }
+ } else {
+ slice = SliceViewManager.getInstance(getContext()).bindSlice(mKeyguardSliceUri);
+ }
onChanged(slice);
+ Trace.endSection();
}
public static class Row extends LinearLayout {