Loading core/java/com/android/internal/statusbar/IStatusBarService.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,8 @@ interface IStatusBarService in NotificationVisibility[] noLongerVisibleKeys); void onNotificationExpansionChanged(in String key, in boolean userAction, in boolean expanded); void onNotificationDirectReplied(String key); void onNotificationSmartRepliesAdded(in String key, in int replyCount); void onNotificationSmartReplySent(in String key, in int replyIndex); void onNotificationSettingsViewed(String key); void setSystemUiVisibility(int vis, int mask, String cause); Loading packages/SystemUI/src/com/android/systemui/SystemUIFactory.java +2 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import com.android.systemui.statusbar.NotificationMediaManager; import com.android.systemui.statusbar.NotificationRemoteInputManager; import com.android.systemui.statusbar.NotificationViewHierarchyManager; import com.android.systemui.statusbar.ScrimView; import com.android.systemui.statusbar.SmartReplyLogger; import com.android.systemui.statusbar.notification.VisualStabilityManager; import com.android.systemui.statusbar.phone.DozeParameters; import com.android.systemui.statusbar.phone.KeyguardBouncer; Loading Loading @@ -146,5 +147,6 @@ public class SystemUIFactory { () -> new NotificationViewHierarchyManager(context)); providers.put(NotificationEntryManager.class, () -> new NotificationEntryManager(context)); providers.put(KeyguardDismissUtil.class, KeyguardDismissUtil::new); providers.put(SmartReplyLogger.class, () -> new SmartReplyLogger(context)); } } packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java +17 −7 Original line number Diff line number Diff line Loading @@ -80,7 +80,7 @@ public class NotificationContentView extends FrameLayout { private RemoteInputView mHeadsUpRemoteInput; private SmartReplyConstants mSmartReplyConstants; private SmartReplyView mExpandedSmartReplyView; private SmartReplyLogger mSmartReplyLogger; private NotificationViewWrapper mContractedWrapper; private NotificationViewWrapper mExpandedWrapper; Loading Loading @@ -153,6 +153,7 @@ public class NotificationContentView extends FrameLayout { super(context, attrs); mHybridGroupManager = new HybridGroupManager(getContext(), this); mSmartReplyConstants = Dependency.get(SmartReplyConstants.class); mSmartReplyLogger = Dependency.get(SmartReplyLogger.class); initView(); } Loading Loading @@ -1243,7 +1244,7 @@ public class NotificationContentView extends FrameLayout { } applyRemoteInput(entry, hasRemoteInput); applySmartReplyView(remoteInputWithChoices, pendingIntentWithChoices); applySmartReplyView(remoteInputWithChoices, pendingIntentWithChoices, entry); } private void applyRemoteInput(NotificationData.Entry entry, boolean hasRemoteInput) { Loading Loading @@ -1344,13 +1345,21 @@ public class NotificationContentView extends FrameLayout { return null; } private void applySmartReplyView(RemoteInput remoteInput, PendingIntent pendingIntent) { mExpandedSmartReplyView = mExpandedChild == null ? null : applySmartReplyView(mExpandedChild, remoteInput, pendingIntent); private void applySmartReplyView(RemoteInput remoteInput, PendingIntent pendingIntent, NotificationData.Entry entry) { if (mExpandedChild != null) { SmartReplyView view = applySmartReplyView(mExpandedChild, remoteInput, pendingIntent, entry); if (view != null && remoteInput != null && remoteInput.getChoices() != null && remoteInput.getChoices().length > 0) { mSmartReplyLogger.smartRepliesAdded(entry, remoteInput.getChoices().length); } } } private SmartReplyView applySmartReplyView( View view, RemoteInput remoteInput, PendingIntent pendingIntent) { View view, RemoteInput remoteInput, PendingIntent pendingIntent, NotificationData.Entry entry) { View smartReplyContainerCandidate = view.findViewById( com.android.internal.R.id.smart_reply_container); if (!(smartReplyContainerCandidate instanceof LinearLayout)) { Loading @@ -1372,7 +1381,8 @@ public class NotificationContentView extends FrameLayout { } } if (smartReplyView != null) { smartReplyView.setRepliesFromRemoteInput(remoteInput, pendingIntent); smartReplyView.setRepliesFromRemoteInput(remoteInput, pendingIntent, mSmartReplyLogger, entry); smartReplyContainer.setVisibility(View.VISIBLE); } return smartReplyView; Loading packages/SystemUI/src/com/android/systemui/statusbar/SmartReplyLogger.java 0 → 100644 +52 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package com.android.systemui.statusbar; import android.content.Context; import android.os.RemoteException; import android.os.ServiceManager; import com.android.internal.statusbar.IStatusBarService; /** * Handles reporting when smart replies are added to a notification * and clicked upon. */ public class SmartReplyLogger { protected IStatusBarService mBarService; public SmartReplyLogger(Context context) { mBarService = IStatusBarService.Stub.asInterface( ServiceManager.getService(Context.STATUS_BAR_SERVICE)); } public void smartReplySent(NotificationData.Entry entry, int replyIndex) { try { mBarService.onNotificationSmartReplySent(entry.notification.getKey(), replyIndex); } catch (RemoteException e) { // Nothing to do, system going down } } public void smartRepliesAdded(final NotificationData.Entry entry, int replyCount) { try { mBarService.onNotificationSmartRepliesAdded(entry.notification.getKey(), replyCount); } catch (RemoteException e) { // Nothing to do, system going down } } } packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java +11 −5 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.keyguard.KeyguardHostView.OnDismissAction; import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.statusbar.NotificationData; import com.android.systemui.statusbar.SmartReplyLogger; import com.android.systemui.statusbar.phone.KeyguardDismissUtil; import java.text.BreakIterator; Loading Loading @@ -109,14 +111,16 @@ public class SmartReplyView extends ViewGroup { Math.max(getChildCount(), 1), DECREASING_MEASURED_WIDTH_WITHOUT_PADDING_COMPARATOR); } public void setRepliesFromRemoteInput(RemoteInput remoteInput, PendingIntent pendingIntent) { public void setRepliesFromRemoteInput(RemoteInput remoteInput, PendingIntent pendingIntent, SmartReplyLogger smartReplyLogger, NotificationData.Entry entry) { removeAllViews(); if (remoteInput != null && pendingIntent != null) { CharSequence[] choices = remoteInput.getChoices(); if (choices != null) { for (CharSequence choice : choices) { for (int i = 0; i < choices.length; ++i) { Button replyButton = inflateReplyButton( getContext(), this, choice, remoteInput, pendingIntent); getContext(), this, i, choices[i], remoteInput, pendingIntent, smartReplyLogger, entry); addView(replyButton); } } Loading @@ -130,8 +134,9 @@ public class SmartReplyView extends ViewGroup { } @VisibleForTesting Button inflateReplyButton(Context context, ViewGroup root, CharSequence choice, RemoteInput remoteInput, PendingIntent pendingIntent) { Button inflateReplyButton(Context context, ViewGroup root, int replyIndex, CharSequence choice, RemoteInput remoteInput, PendingIntent pendingIntent, SmartReplyLogger smartReplyLogger, NotificationData.Entry entry) { Button b = (Button) LayoutInflater.from(context).inflate( R.layout.smart_reply_button, root, false); b.setText(choice); Loading @@ -147,6 +152,7 @@ public class SmartReplyView extends ViewGroup { } catch (PendingIntent.CanceledException e) { Log.w(TAG, "Unable to send smart reply", e); } smartReplyLogger.smartReplySent(entry, replyIndex); return false; // do not defer }; Loading Loading
core/java/com/android/internal/statusbar/IStatusBarService.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,8 @@ interface IStatusBarService in NotificationVisibility[] noLongerVisibleKeys); void onNotificationExpansionChanged(in String key, in boolean userAction, in boolean expanded); void onNotificationDirectReplied(String key); void onNotificationSmartRepliesAdded(in String key, in int replyCount); void onNotificationSmartReplySent(in String key, in int replyIndex); void onNotificationSettingsViewed(String key); void setSystemUiVisibility(int vis, int mask, String cause); Loading
packages/SystemUI/src/com/android/systemui/SystemUIFactory.java +2 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import com.android.systemui.statusbar.NotificationMediaManager; import com.android.systemui.statusbar.NotificationRemoteInputManager; import com.android.systemui.statusbar.NotificationViewHierarchyManager; import com.android.systemui.statusbar.ScrimView; import com.android.systemui.statusbar.SmartReplyLogger; import com.android.systemui.statusbar.notification.VisualStabilityManager; import com.android.systemui.statusbar.phone.DozeParameters; import com.android.systemui.statusbar.phone.KeyguardBouncer; Loading Loading @@ -146,5 +147,6 @@ public class SystemUIFactory { () -> new NotificationViewHierarchyManager(context)); providers.put(NotificationEntryManager.class, () -> new NotificationEntryManager(context)); providers.put(KeyguardDismissUtil.class, KeyguardDismissUtil::new); providers.put(SmartReplyLogger.class, () -> new SmartReplyLogger(context)); } }
packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java +17 −7 Original line number Diff line number Diff line Loading @@ -80,7 +80,7 @@ public class NotificationContentView extends FrameLayout { private RemoteInputView mHeadsUpRemoteInput; private SmartReplyConstants mSmartReplyConstants; private SmartReplyView mExpandedSmartReplyView; private SmartReplyLogger mSmartReplyLogger; private NotificationViewWrapper mContractedWrapper; private NotificationViewWrapper mExpandedWrapper; Loading Loading @@ -153,6 +153,7 @@ public class NotificationContentView extends FrameLayout { super(context, attrs); mHybridGroupManager = new HybridGroupManager(getContext(), this); mSmartReplyConstants = Dependency.get(SmartReplyConstants.class); mSmartReplyLogger = Dependency.get(SmartReplyLogger.class); initView(); } Loading Loading @@ -1243,7 +1244,7 @@ public class NotificationContentView extends FrameLayout { } applyRemoteInput(entry, hasRemoteInput); applySmartReplyView(remoteInputWithChoices, pendingIntentWithChoices); applySmartReplyView(remoteInputWithChoices, pendingIntentWithChoices, entry); } private void applyRemoteInput(NotificationData.Entry entry, boolean hasRemoteInput) { Loading Loading @@ -1344,13 +1345,21 @@ public class NotificationContentView extends FrameLayout { return null; } private void applySmartReplyView(RemoteInput remoteInput, PendingIntent pendingIntent) { mExpandedSmartReplyView = mExpandedChild == null ? null : applySmartReplyView(mExpandedChild, remoteInput, pendingIntent); private void applySmartReplyView(RemoteInput remoteInput, PendingIntent pendingIntent, NotificationData.Entry entry) { if (mExpandedChild != null) { SmartReplyView view = applySmartReplyView(mExpandedChild, remoteInput, pendingIntent, entry); if (view != null && remoteInput != null && remoteInput.getChoices() != null && remoteInput.getChoices().length > 0) { mSmartReplyLogger.smartRepliesAdded(entry, remoteInput.getChoices().length); } } } private SmartReplyView applySmartReplyView( View view, RemoteInput remoteInput, PendingIntent pendingIntent) { View view, RemoteInput remoteInput, PendingIntent pendingIntent, NotificationData.Entry entry) { View smartReplyContainerCandidate = view.findViewById( com.android.internal.R.id.smart_reply_container); if (!(smartReplyContainerCandidate instanceof LinearLayout)) { Loading @@ -1372,7 +1381,8 @@ public class NotificationContentView extends FrameLayout { } } if (smartReplyView != null) { smartReplyView.setRepliesFromRemoteInput(remoteInput, pendingIntent); smartReplyView.setRepliesFromRemoteInput(remoteInput, pendingIntent, mSmartReplyLogger, entry); smartReplyContainer.setVisibility(View.VISIBLE); } return smartReplyView; Loading
packages/SystemUI/src/com/android/systemui/statusbar/SmartReplyLogger.java 0 → 100644 +52 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package com.android.systemui.statusbar; import android.content.Context; import android.os.RemoteException; import android.os.ServiceManager; import com.android.internal.statusbar.IStatusBarService; /** * Handles reporting when smart replies are added to a notification * and clicked upon. */ public class SmartReplyLogger { protected IStatusBarService mBarService; public SmartReplyLogger(Context context) { mBarService = IStatusBarService.Stub.asInterface( ServiceManager.getService(Context.STATUS_BAR_SERVICE)); } public void smartReplySent(NotificationData.Entry entry, int replyIndex) { try { mBarService.onNotificationSmartReplySent(entry.notification.getKey(), replyIndex); } catch (RemoteException e) { // Nothing to do, system going down } } public void smartRepliesAdded(final NotificationData.Entry entry, int replyCount) { try { mBarService.onNotificationSmartRepliesAdded(entry.notification.getKey(), replyCount); } catch (RemoteException e) { // Nothing to do, system going down } } }
packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java +11 −5 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.keyguard.KeyguardHostView.OnDismissAction; import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.statusbar.NotificationData; import com.android.systemui.statusbar.SmartReplyLogger; import com.android.systemui.statusbar.phone.KeyguardDismissUtil; import java.text.BreakIterator; Loading Loading @@ -109,14 +111,16 @@ public class SmartReplyView extends ViewGroup { Math.max(getChildCount(), 1), DECREASING_MEASURED_WIDTH_WITHOUT_PADDING_COMPARATOR); } public void setRepliesFromRemoteInput(RemoteInput remoteInput, PendingIntent pendingIntent) { public void setRepliesFromRemoteInput(RemoteInput remoteInput, PendingIntent pendingIntent, SmartReplyLogger smartReplyLogger, NotificationData.Entry entry) { removeAllViews(); if (remoteInput != null && pendingIntent != null) { CharSequence[] choices = remoteInput.getChoices(); if (choices != null) { for (CharSequence choice : choices) { for (int i = 0; i < choices.length; ++i) { Button replyButton = inflateReplyButton( getContext(), this, choice, remoteInput, pendingIntent); getContext(), this, i, choices[i], remoteInput, pendingIntent, smartReplyLogger, entry); addView(replyButton); } } Loading @@ -130,8 +134,9 @@ public class SmartReplyView extends ViewGroup { } @VisibleForTesting Button inflateReplyButton(Context context, ViewGroup root, CharSequence choice, RemoteInput remoteInput, PendingIntent pendingIntent) { Button inflateReplyButton(Context context, ViewGroup root, int replyIndex, CharSequence choice, RemoteInput remoteInput, PendingIntent pendingIntent, SmartReplyLogger smartReplyLogger, NotificationData.Entry entry) { Button b = (Button) LayoutInflater.from(context).inflate( R.layout.smart_reply_button, root, false); b.setText(choice); Loading @@ -147,6 +152,7 @@ public class SmartReplyView extends ViewGroup { } catch (PendingIntent.CanceledException e) { Log.w(TAG, "Unable to send smart reply", e); } smartReplyLogger.smartReplySent(entry, replyIndex); return false; // do not defer }; Loading