Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit af41d5f7 authored by Nadia Benbernou's avatar Nadia Benbernou Committed by Android (Google) Code Review
Browse files

Merge "Make sure notifications from the default sms app do not get filtered to...

Merge "Make sure notifications from the default sms app do not get filtered to the non-interruptive section."
parents f2bfd385 1ee91a3c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4409,7 +4409,7 @@
        {@link android.provider.Telephony.Intents#ACTION_DEFAULT_SMS_PACKAGE_CHANGED_INTERNAL}
        broadcast -->
    <permission android:name="android.permission.MONITOR_DEFAULT_SMS_PACKAGE"
        android:protectionLevel="signature" />
        android:protectionLevel="signature|privileged" />

    <!-- A subclass of {@link android.app.SmsAppService} must be protected with this permission. -->
    <permission android:name="android.permission.BIND_SMS_APP_SERVICE"
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ applications that come with the platform
<permissions>
    <privapp-permissions package="android.ext.services">
        <permission name="android.permission.PROVIDE_RESOLVER_RANKER_SERVICE" />
        <permission name="android.permission.MONITOR_DEFAULT_SMS_PACKAGE" />
    </privapp-permissions>

    <privapp-permissions package="com.android.apps.tag">
+2 −0
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@
    <uses-permission android:name="android.permission.PROVIDE_RESOLVER_RANKER_SERVICE" />
    <uses-permission android:name="android.permission.READ_DEVICE_CONFIG" />

    <uses-permission android:name="android.permission.MONITOR_DEFAULT_SMS_PACKAGE" />

    <application android:label="@string/app_name"
        android:defaultToDeviceProtectedStorage="true"
        android:directBootAware="true">
+5 −2
Original line number Diff line number Diff line
@@ -214,7 +214,8 @@ public class Assistant extends NotificationAssistantService {
        if (!isForCurrentUser(sbn)) {
            return null;
        }
        NotificationEntry entry = new NotificationEntry(mPackageManager, sbn, channel);
        NotificationEntry entry =
                new NotificationEntry(mPackageManager, sbn, channel, SmsHelper.getInstance(this));
        SmartActionsHelper.SmartSuggestions suggestions = mSmartActionsHelper.suggest(entry);
        return createEnqueuedNotificationAdjustment(
                entry, suggestions.actions, suggestions.replies);
@@ -261,7 +262,7 @@ public class Assistant extends NotificationAssistantService {
            Ranking ranking = getRanking(sbn.getKey(), rankingMap);
            if (ranking != null && ranking.getChannel() != null) {
                NotificationEntry entry = new NotificationEntry(mPackageManager,
                        sbn, ranking.getChannel());
                        sbn, ranking.getChannel(), SmsHelper.getInstance(this));
                String key = getKey(
                        sbn.getPackageName(), sbn.getUserId(), ranking.getChannel().getId());
                ChannelImpressions ci = mkeyToImpressions.getOrDefault(key,
@@ -397,6 +398,7 @@ public class Assistant extends NotificationAssistantService {
    @Override
    public void onListenerConnected() {
        if (DEBUG) Log.i(TAG, "CONNECTED");
        SmsHelper.getInstance(this).initialize();
        try {
            mFile = new AtomicFile(new File(new File(
                    Environment.getDataUserCePackageDirectory(
@@ -413,6 +415,7 @@ public class Assistant extends NotificationAssistantService {

    @Override
    public void onListenerDisconnected() {
        SmsHelper.getInstance(this).destroy();
        if (mAgingHelper != null) {
            mAgingHelper.onDestroy();
        }
+14 −2
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.app.Notification;
import android.app.NotificationChannel;
import android.app.Person;
import android.app.RemoteInput;
import android.content.ComponentName;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
@@ -56,15 +57,17 @@ public class NotificationEntry {
    private boolean mSeen;
    private boolean mExpanded;
    private boolean mIsShowActionEventLogged;
    private SmsHelper mSmsHelper;

    public NotificationEntry(IPackageManager packageManager, StatusBarNotification sbn,
            NotificationChannel channel) {
            NotificationChannel channel, SmsHelper smsHelper) {
        mSbn = sbn;
        mChannel = channel;
        mPackageManager = packageManager;
        mPreChannelsNotification = isPreChannelsNotification();
        mAttributes = calculateAudioAttributes();
        mImportance = calculateInitialImportance();
        mSmsHelper = smsHelper;
    }

    private boolean isPreChannelsNotification() {
@@ -192,7 +195,16 @@ public class NotificationEntry {
    protected boolean involvesPeople() {
        return isMessaging()
                || hasStyle(Notification.InboxStyle.class)
                || hasPerson();
                || hasPerson()
                || isDefaultSmsApp();
    }

    private boolean isDefaultSmsApp() {
        ComponentName defaultSmsApp = mSmsHelper.getDefaultSmsApplication();
        if (defaultSmsApp == null) {
            return false;
        }
        return mSbn.getPackageName().equals(defaultSmsApp.getPackageName());
    }

    protected boolean isMessaging() {
Loading