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

Commit d82e4add authored by Julia Reynolds's avatar Julia Reynolds Committed by android-build-merger
Browse files

Merge changes I36636687,I4c45f787 into oc-mr1-dev

am: 54ff7e75

Change-Id: I6f368c79acfc92c4ed62e7808ae5c744959069c7
parents bb143baf 54ff7e75
Loading
Loading
Loading
Loading
+7 −3
Original line number Original line Diff line number Diff line
@@ -1164,7 +1164,8 @@ public class Notification implements Parcelable
     * Constant for {@link Builder#setGroupAlertBehavior(int)}, meaning that all children
     * Constant for {@link Builder#setGroupAlertBehavior(int)}, meaning that all children
     * notification in a group should be silenced (no sound or vibration) even if they are posted
     * notification in a group should be silenced (no sound or vibration) even if they are posted
     * to a {@link NotificationChannel} that has sound and/or vibration. Use this constant to
     * to a {@link NotificationChannel} that has sound and/or vibration. Use this constant to
     * mute this notification if this notification is a group child.
     * mute this notification if this notification is a group child. This must be applied to all
     * children notifications you want to mute.
     *
     *
     * <p> For example, you might want to use this constant if you post a number of children
     * <p> For example, you might want to use this constant if you post a number of children
     * notifications at once (say, after a periodic sync), and only need to notify the user
     * notifications at once (say, after a periodic sync), and only need to notify the user
@@ -1179,7 +1180,8 @@ public class Notification implements Parcelable
     * to mute this notification if this notification is a group summary.
     * to mute this notification if this notification is a group summary.
     *
     *
     * <p>For example, you might want to use this constant if only the children notifications
     * <p>For example, you might want to use this constant if only the children notifications
     * in your group have content and the summary is only used to visually group notifications.
     * in your group have content and the summary is only used to visually group notifications
     * rather than to alert the user that new information is available.
     */
     */
    public static final int GROUP_ALERT_CHILDREN = 2;
    public static final int GROUP_ALERT_CHILDREN = 2;


@@ -2914,7 +2916,9 @@ public class Notification implements Parcelable
         * Sets the group alert behavior for this notification. Use this method to mute this
         * Sets the group alert behavior for this notification. Use this method to mute this
         * notification if alerts for this notification's group should be handled by a different
         * notification if alerts for this notification's group should be handled by a different
         * notification. This is only applicable for notifications that belong to a
         * notification. This is only applicable for notifications that belong to a
         * {@link #setGroup(String) group}.
         * {@link #setGroup(String) group}. This must be called on all notifications you want to
         * mute. For example, if you want only the summary of your group to make noise, all
         * children in the group should have the group alert behavior {@link #GROUP_ALERT_SUMMARY}.
         *
         *
         * <p> The default value is {@link #GROUP_ALERT_ALL}.</p>
         * <p> The default value is {@link #GROUP_ALERT_ALL}.</p>
         */
         */
+1 −9
Original line number Original line Diff line number Diff line
@@ -15,24 +15,18 @@
 */
 */
package android.app;
package android.app;


import android.annotation.StringRes;
import android.annotation.SystemApi;
import android.annotation.SystemApi;
import android.content.Intent;
import android.content.Intent;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable;
import android.service.notification.NotificationListenerService;
import android.text.TextUtils;
import android.text.TextUtils;
import android.util.Slog;


import org.json.JSONException;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONObject;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlSerializer;
import org.xmlpull.v1.XmlSerializer;


import java.io.IOException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.List;


/**
/**
@@ -115,10 +109,8 @@ public final class NotificationChannelGroup implements Parcelable {
        return mName;
        return mName;
    }
    }


    /*
    /**
     * Returns the list of channels that belong to this group
     * Returns the list of channels that belong to this group
     *
     * @hide
     */
     */
    public List<NotificationChannel> getChannels() {
    public List<NotificationChannel> getChannels() {
        return mChannels;
        return mChannels;
+1 −0
Original line number Original line Diff line number Diff line
@@ -804,6 +804,7 @@ public class NotificationManagerService extends SystemService {
        public void onReceive(Context context, Intent intent) {
        public void onReceive(Context context, Intent intent) {
            if (Intent.ACTION_LOCALE_CHANGED.equals(intent.getAction())) {
            if (Intent.ACTION_LOCALE_CHANGED.equals(intent.getAction())) {
                mZenModeHelper.updateDefaultZenRules();
                mZenModeHelper.updateDefaultZenRules();
                mRankingHelper.onLocaleChanged(context, ActivityManager.getCurrentUser());
            }
            }
        }
        }
    };
    };
+16 −0
Original line number Original line Diff line number Diff line
@@ -1073,6 +1073,22 @@ public class RankingHelper implements RankingConfig {
        }
        }
    }
    }


    protected void onLocaleChanged(Context context, int userId) {
        synchronized (mRecords) {
            int N = mRecords.size();
            for (int i = 0; i < N; i++) {
                Record record = mRecords.valueAt(i);
                if (UserHandle.getUserId(record.uid) == userId) {
                    if (record.channels.containsKey(NotificationChannel.DEFAULT_CHANNEL_ID)) {
                        record.channels.get(NotificationChannel.DEFAULT_CHANNEL_ID).setName(
                                context.getResources().getString(
                                        R.string.default_notification_channel_label));
                    }
                }
            }
        }
    }

    public void onPackagesChanged(boolean removingPackage, int changeUserId, String[] pkgList,
    public void onPackagesChanged(boolean removingPackage, int changeUserId, String[] pkgList,
            int[] uidList) {
            int[] uidList) {
        if (pkgList == null || pkgList.length == 0) {
        if (pkgList == null || pkgList.length == 0) {
+22 −0
Original line number Original line Diff line number Diff line
@@ -46,6 +46,7 @@ import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.NotificationManager;
import android.content.pm.ApplicationInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Color;
import android.media.AudioAttributes;
import android.media.AudioAttributes;
import android.net.Uri;
import android.net.Uri;
@@ -78,6 +79,7 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verify;
@@ -127,6 +129,8 @@ public class RankingHelperTest extends NotificationTestCase {
        when(mPm.getPackageUidAsUser(eq(UPDATED_PKG), anyInt())).thenReturn(UID2);
        when(mPm.getPackageUidAsUser(eq(UPDATED_PKG), anyInt())).thenReturn(UID2);
        when(mContext.getResources()).thenReturn(
        when(mContext.getResources()).thenReturn(
                InstrumentationRegistry.getContext().getResources());
                InstrumentationRegistry.getContext().getResources());
        when(mContext.getContentResolver()).thenReturn(
                InstrumentationRegistry.getContext().getContentResolver());
        when(mContext.getPackageManager()).thenReturn(mPm);
        when(mContext.getPackageManager()).thenReturn(mPm);
        when(mContext.getApplicationInfo()).thenReturn(legacy);
        when(mContext.getApplicationInfo()).thenReturn(legacy);
        // most tests assume badging is enabled
        // most tests assume badging is enabled
@@ -1366,4 +1370,22 @@ public class RankingHelperTest extends NotificationTestCase {
        assertFalse(mHelper.badgingEnabled(USER));
        assertFalse(mHelper.badgingEnabled(USER));
        assertTrue(mHelper.badgingEnabled(USER2));
        assertTrue(mHelper.badgingEnabled(USER2));
    }
    }

    @Test
    public void testOnLocaleChanged_updatesDefaultChannels() throws Exception {
        String newLabel = "bananas!";
        final NotificationChannel defaultChannel = mHelper.getNotificationChannel(PKG, UID,
                NotificationChannel.DEFAULT_CHANNEL_ID, false);
        assertFalse(newLabel.equals(defaultChannel.getName()));

        Resources res = mock(Resources.class);
        when(mContext.getResources()).thenReturn(res);
        when(res.getString(com.android.internal.R.string.default_notification_channel_label))
                .thenReturn(newLabel);

        mHelper.onLocaleChanged(mContext, USER.getIdentifier());

        assertEquals(newLabel, mHelper.getNotificationChannel(PKG, UID,
                NotificationChannel.DEFAULT_CHANNEL_ID, false).getName());
    }
}
}