Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java +151 −117 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.RemoteViews; import com.android.app.tracing.TraceUtils; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.widget.ImageMessageConsumer; import com.android.systemui.dagger.SysUISingleton; Loading Loading @@ -369,12 +370,14 @@ public class NotificationContentInflater implements NotificationRowContentBinder ExpandableNotificationRow row, NotifLayoutInflaterFactory.Provider notifLayoutInflaterFactoryProvider, NotificationContentInflaterLogger logger) { return TraceUtils.trace("NotificationContentInflater.createRemoteViews", () -> { InflationProgress result = new InflationProgress(); final NotificationEntry entryForLogging = row.getEntry(); if ((reInflateFlags & FLAG_CONTENT_VIEW_CONTRACTED) != 0) { logger.logAsyncTaskProgress(entryForLogging, "creating contracted remote view"); result.newContentView = createContentView(builder, isLowPriority, usesIncreasedHeight); result.newContentView = createContentView(builder, isLowPriority, usesIncreasedHeight); } if ((reInflateFlags & FLAG_CONTENT_VIEW_EXPANDED) != 0) { Loading @@ -384,7 +387,8 @@ public class NotificationContentInflater implements NotificationRowContentBinder if ((reInflateFlags & FLAG_CONTENT_VIEW_HEADS_UP) != 0) { logger.logAsyncTaskProgress(entryForLogging, "creating heads up remote view"); result.newHeadsUpView = builder.createHeadsUpContentView(usesIncreasedHeadsUpHeight); result.newHeadsUpView = builder.createHeadsUpContentView( usesIncreasedHeadsUpHeight); } if ((reInflateFlags & FLAG_CONTENT_VIEW_PUBLIC) != 0) { Loading @@ -408,10 +412,13 @@ public class NotificationContentInflater implements NotificationRowContentBinder } setNotifsViewsInflaterFactory(result, row, notifLayoutInflaterFactoryProvider); result.packageContext = packageContext; result.headsUpStatusBarText = builder.getHeadsUpStatusBarText(false /* showingPublic */); result.headsUpStatusBarText = builder.getHeadsUpStatusBarText( false /* showingPublic */); result.headsUpStatusBarTextPublic = builder.getHeadsUpStatusBarText( true /* showingPublic */); return result; }); } private static void setNotifsViewsInflaterFactory(InflationProgress result, Loading Loading @@ -445,6 +452,8 @@ public class NotificationContentInflater implements NotificationRowContentBinder RemoteViews.InteractionHandler remoteViewClickHandler, @Nullable InflationCallback callback, NotificationContentInflaterLogger logger) { Trace.beginAsyncSection(APPLY_TRACE_METHOD, System.identityHashCode(row)); NotificationContentView privateLayout = row.getPrivateLayout(); NotificationContentView publicLayout = row.getPublicLayout(); final HashMap<Integer, CancellationSignal> runningInflations = new HashMap<>(); Loading Loading @@ -621,6 +630,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder cancellationSignal.setOnCancelListener( () -> { logger.logAsyncTaskProgress(entry, "apply cancelled"); Trace.endAsyncSection(APPLY_TRACE_METHOD, System.identityHashCode(row)); runningInflations.values().forEach(CancellationSignal::cancel); }); Loading Loading @@ -769,17 +779,17 @@ public class NotificationContentInflater implements NotificationRowContentBinder if (!requiresHeightCheck(entry)) { return true; } Trace.beginSection("NotificationContentInflater#satisfiesMinHeightRequirement"); return TraceUtils.trace("NotificationContentInflater#satisfiesMinHeightRequirement", () -> { int heightSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); int referenceWidth = resources.getDimensionPixelSize( R.dimen.notification_validation_reference_width); int widthSpec = View.MeasureSpec.makeMeasureSpec(referenceWidth, View.MeasureSpec.EXACTLY); int widthSpec = View.MeasureSpec.makeMeasureSpec(referenceWidth, View.MeasureSpec.EXACTLY); view.measure(widthSpec, heightSpec); int minHeight = resources.getDimensionPixelSize( R.dimen.notification_validation_minimum_allowed_height); boolean result = view.getMeasuredHeight() >= minHeight; Trace.endSection(); return result; return view.getMeasuredHeight() >= minHeight; }); } /** Loading Loading @@ -966,6 +976,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder entry.headsUpStatusBarText = result.headsUpStatusBarText; entry.headsUpStatusBarTextPublic = result.headsUpStatusBarTextPublic; Trace.endAsyncSection(APPLY_TRACE_METHOD, System.identityHashCode(row)); if (endListener != null) { endListener.onAsyncInflationFinished(entry); } Loading Loading @@ -1101,15 +1112,31 @@ public class NotificationContentInflater implements NotificationRowContentBinder Notification.addFieldsFromContext(appInfo, sbn.getNotification()); } @Override protected void onPreExecute() { Trace.beginAsyncSection(ASYNC_TASK_TRACE_METHOD, System.identityHashCode(this)); } @Override protected InflationProgress doInBackground(Void... params) { return TraceUtils.trace("NotificationContentInflater.AsyncInflationTask#doInBackground", () -> { try { return doInBackgroundInternal(); } catch (Exception e) { mError = e; mLogger.logAsyncTaskException(mEntry, "inflating", e); return null; } }); } private InflationProgress doInBackgroundInternal() { final StatusBarNotification sbn = mEntry.getSbn(); // Ensure the ApplicationInfo is updated before a builder is recovered. updateApplicationInfo(sbn); final Notification.Builder recoveredBuilder = Notification.Builder.recoverBuilder(mContext, sbn.getNotification()); final Notification.Builder recoveredBuilder = Notification.Builder.recoverBuilder( mContext, sbn.getNotification()); Context packageContext = sbn.getPackageContext(mContext); if (recoveredBuilder.usesTemplate()) { Loading @@ -1129,7 +1156,8 @@ public class NotificationContentInflater implements NotificationRowContentBinder mLogger.logAsyncTaskProgress(mEntry, "getting existing smart reply state (on wrong thread!)"); InflatedSmartReplyState previousSmartReplyState = mRow.getExistingSmartReplyState(); InflatedSmartReplyState previousSmartReplyState = mRow.getExistingSmartReplyState(); mLogger.logAsyncTaskProgress(mEntry, "inflating smart reply views"); InflationProgress result = inflateSmartReplyViews( /* result = */ inflationProgress, Loading Loading @@ -1170,15 +1198,12 @@ public class NotificationContentInflater implements NotificationRowContentBinder imageResolver.waitForPreloadedImages(IMG_PRELOAD_TIMEOUT_MS); return result; } catch (Exception e) { mError = e; mLogger.logAsyncTaskException(mEntry, "inflating", e); return null; } } @Override protected void onPostExecute(InflationProgress result) { Trace.endAsyncSection(ASYNC_TASK_TRACE_METHOD, System.identityHashCode(this)); if (mError == null) { // Logged in detail in apply. mCancellationSignal = apply( Loading @@ -1197,6 +1222,11 @@ public class NotificationContentInflater implements NotificationRowContentBinder } } @Override protected void onCancelled(InflationProgress result) { Trace.endAsyncSection(ASYNC_TASK_TRACE_METHOD, System.identityHashCode(this)); } private void handleError(Exception e) { mEntry.onInflationTaskFinished(); StatusBarNotification sbn = mEntry.getSbn(); Loading Loading @@ -1294,4 +1324,8 @@ public class NotificationContentInflater implements NotificationRowContentBinder public abstract void setResultView(View v); public abstract RemoteViews getRemoteView(); } private static final String ASYNC_TASK_TRACE_METHOD = "NotificationContentInflater.AsyncInflationTask"; private static final String APPLY_TRACE_METHOD = "NotificationContentInflater#apply"; } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java +151 −117 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.RemoteViews; import com.android.app.tracing.TraceUtils; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.widget.ImageMessageConsumer; import com.android.systemui.dagger.SysUISingleton; Loading Loading @@ -369,12 +370,14 @@ public class NotificationContentInflater implements NotificationRowContentBinder ExpandableNotificationRow row, NotifLayoutInflaterFactory.Provider notifLayoutInflaterFactoryProvider, NotificationContentInflaterLogger logger) { return TraceUtils.trace("NotificationContentInflater.createRemoteViews", () -> { InflationProgress result = new InflationProgress(); final NotificationEntry entryForLogging = row.getEntry(); if ((reInflateFlags & FLAG_CONTENT_VIEW_CONTRACTED) != 0) { logger.logAsyncTaskProgress(entryForLogging, "creating contracted remote view"); result.newContentView = createContentView(builder, isLowPriority, usesIncreasedHeight); result.newContentView = createContentView(builder, isLowPriority, usesIncreasedHeight); } if ((reInflateFlags & FLAG_CONTENT_VIEW_EXPANDED) != 0) { Loading @@ -384,7 +387,8 @@ public class NotificationContentInflater implements NotificationRowContentBinder if ((reInflateFlags & FLAG_CONTENT_VIEW_HEADS_UP) != 0) { logger.logAsyncTaskProgress(entryForLogging, "creating heads up remote view"); result.newHeadsUpView = builder.createHeadsUpContentView(usesIncreasedHeadsUpHeight); result.newHeadsUpView = builder.createHeadsUpContentView( usesIncreasedHeadsUpHeight); } if ((reInflateFlags & FLAG_CONTENT_VIEW_PUBLIC) != 0) { Loading @@ -408,10 +412,13 @@ public class NotificationContentInflater implements NotificationRowContentBinder } setNotifsViewsInflaterFactory(result, row, notifLayoutInflaterFactoryProvider); result.packageContext = packageContext; result.headsUpStatusBarText = builder.getHeadsUpStatusBarText(false /* showingPublic */); result.headsUpStatusBarText = builder.getHeadsUpStatusBarText( false /* showingPublic */); result.headsUpStatusBarTextPublic = builder.getHeadsUpStatusBarText( true /* showingPublic */); return result; }); } private static void setNotifsViewsInflaterFactory(InflationProgress result, Loading Loading @@ -445,6 +452,8 @@ public class NotificationContentInflater implements NotificationRowContentBinder RemoteViews.InteractionHandler remoteViewClickHandler, @Nullable InflationCallback callback, NotificationContentInflaterLogger logger) { Trace.beginAsyncSection(APPLY_TRACE_METHOD, System.identityHashCode(row)); NotificationContentView privateLayout = row.getPrivateLayout(); NotificationContentView publicLayout = row.getPublicLayout(); final HashMap<Integer, CancellationSignal> runningInflations = new HashMap<>(); Loading Loading @@ -621,6 +630,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder cancellationSignal.setOnCancelListener( () -> { logger.logAsyncTaskProgress(entry, "apply cancelled"); Trace.endAsyncSection(APPLY_TRACE_METHOD, System.identityHashCode(row)); runningInflations.values().forEach(CancellationSignal::cancel); }); Loading Loading @@ -769,17 +779,17 @@ public class NotificationContentInflater implements NotificationRowContentBinder if (!requiresHeightCheck(entry)) { return true; } Trace.beginSection("NotificationContentInflater#satisfiesMinHeightRequirement"); return TraceUtils.trace("NotificationContentInflater#satisfiesMinHeightRequirement", () -> { int heightSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); int referenceWidth = resources.getDimensionPixelSize( R.dimen.notification_validation_reference_width); int widthSpec = View.MeasureSpec.makeMeasureSpec(referenceWidth, View.MeasureSpec.EXACTLY); int widthSpec = View.MeasureSpec.makeMeasureSpec(referenceWidth, View.MeasureSpec.EXACTLY); view.measure(widthSpec, heightSpec); int minHeight = resources.getDimensionPixelSize( R.dimen.notification_validation_minimum_allowed_height); boolean result = view.getMeasuredHeight() >= minHeight; Trace.endSection(); return result; return view.getMeasuredHeight() >= minHeight; }); } /** Loading Loading @@ -966,6 +976,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder entry.headsUpStatusBarText = result.headsUpStatusBarText; entry.headsUpStatusBarTextPublic = result.headsUpStatusBarTextPublic; Trace.endAsyncSection(APPLY_TRACE_METHOD, System.identityHashCode(row)); if (endListener != null) { endListener.onAsyncInflationFinished(entry); } Loading Loading @@ -1101,15 +1112,31 @@ public class NotificationContentInflater implements NotificationRowContentBinder Notification.addFieldsFromContext(appInfo, sbn.getNotification()); } @Override protected void onPreExecute() { Trace.beginAsyncSection(ASYNC_TASK_TRACE_METHOD, System.identityHashCode(this)); } @Override protected InflationProgress doInBackground(Void... params) { return TraceUtils.trace("NotificationContentInflater.AsyncInflationTask#doInBackground", () -> { try { return doInBackgroundInternal(); } catch (Exception e) { mError = e; mLogger.logAsyncTaskException(mEntry, "inflating", e); return null; } }); } private InflationProgress doInBackgroundInternal() { final StatusBarNotification sbn = mEntry.getSbn(); // Ensure the ApplicationInfo is updated before a builder is recovered. updateApplicationInfo(sbn); final Notification.Builder recoveredBuilder = Notification.Builder.recoverBuilder(mContext, sbn.getNotification()); final Notification.Builder recoveredBuilder = Notification.Builder.recoverBuilder( mContext, sbn.getNotification()); Context packageContext = sbn.getPackageContext(mContext); if (recoveredBuilder.usesTemplate()) { Loading @@ -1129,7 +1156,8 @@ public class NotificationContentInflater implements NotificationRowContentBinder mLogger.logAsyncTaskProgress(mEntry, "getting existing smart reply state (on wrong thread!)"); InflatedSmartReplyState previousSmartReplyState = mRow.getExistingSmartReplyState(); InflatedSmartReplyState previousSmartReplyState = mRow.getExistingSmartReplyState(); mLogger.logAsyncTaskProgress(mEntry, "inflating smart reply views"); InflationProgress result = inflateSmartReplyViews( /* result = */ inflationProgress, Loading Loading @@ -1170,15 +1198,12 @@ public class NotificationContentInflater implements NotificationRowContentBinder imageResolver.waitForPreloadedImages(IMG_PRELOAD_TIMEOUT_MS); return result; } catch (Exception e) { mError = e; mLogger.logAsyncTaskException(mEntry, "inflating", e); return null; } } @Override protected void onPostExecute(InflationProgress result) { Trace.endAsyncSection(ASYNC_TASK_TRACE_METHOD, System.identityHashCode(this)); if (mError == null) { // Logged in detail in apply. mCancellationSignal = apply( Loading @@ -1197,6 +1222,11 @@ public class NotificationContentInflater implements NotificationRowContentBinder } } @Override protected void onCancelled(InflationProgress result) { Trace.endAsyncSection(ASYNC_TASK_TRACE_METHOD, System.identityHashCode(this)); } private void handleError(Exception e) { mEntry.onInflationTaskFinished(); StatusBarNotification sbn = mEntry.getSbn(); Loading Loading @@ -1294,4 +1324,8 @@ public class NotificationContentInflater implements NotificationRowContentBinder public abstract void setResultView(View v); public abstract RemoteViews getRemoteView(); } private static final String ASYNC_TASK_TRACE_METHOD = "NotificationContentInflater.AsyncInflationTask"; private static final String APPLY_TRACE_METHOD = "NotificationContentInflater#apply"; }