Merge "Fix unknown tag @throw" into lmp-dev
diff --git a/api/current.txt b/api/current.txt
index 4a96399..025c778 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -4588,6 +4588,7 @@
field public static final int DEFAULT_SOUND = 1; // 0x1
field public static final int DEFAULT_VIBRATE = 2; // 0x2
field public static final java.lang.String EXTRA_BACKGROUND_IMAGE_URI = "android.backgroundImageUri";
+ field public static final java.lang.String EXTRA_COMPACT_ACTIONS = "android.compactActions";
field public static final java.lang.String EXTRA_INFO_TEXT = "android.infoText";
field public static final java.lang.String EXTRA_LARGE_ICON = "android.largeIcon";
field public static final java.lang.String EXTRA_LARGE_ICON_BIG = "android.largeIcon.big";
@@ -27277,6 +27278,7 @@
ctor public StatusBarNotification(android.os.Parcel);
method public android.service.notification.StatusBarNotification clone();
method public int describeContents();
+ method public java.lang.String getGroupKey();
method public int getId();
method public java.lang.String getKey();
method public android.app.Notification getNotification();
@@ -28690,15 +28692,15 @@
}
public class PhoneAccount implements android.os.Parcelable {
- ctor public PhoneAccount(android.telecomm.PhoneAccountHandle, android.net.Uri, java.lang.String, int, int, java.lang.String, java.lang.String, boolean);
+ ctor public PhoneAccount(android.telecomm.PhoneAccountHandle, android.net.Uri, java.lang.String, int, int, java.lang.CharSequence, java.lang.CharSequence, boolean);
method public int describeContents();
method public android.telecomm.PhoneAccountHandle getAccountHandle();
method public int getCapabilities();
method public android.net.Uri getHandle();
method public android.graphics.drawable.Drawable getIcon(android.content.Context);
method public int getIconResId();
- method public java.lang.String getLabel();
- method public java.lang.String getShortDescription();
+ method public java.lang.CharSequence getLabel();
+ method public java.lang.CharSequence getShortDescription();
method public java.lang.String getSubscriptionNumber();
method public boolean isVideoCallingSupported();
method public void writeToParcel(android.os.Parcel, int);
@@ -28792,13 +28794,13 @@
}
public final class StatusHints implements android.os.Parcelable {
- ctor public StatusHints(android.content.ComponentName, java.lang.String, int, android.os.Bundle);
+ ctor public StatusHints(android.content.ComponentName, java.lang.CharSequence, int, android.os.Bundle);
method public int describeContents();
method public android.content.ComponentName getComponentName();
method public android.os.Bundle getExtras();
method public android.graphics.drawable.Drawable getIcon(android.content.Context);
method public int getIconId();
- method public java.lang.String getLabel();
+ method public java.lang.CharSequence getLabel();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator CREATOR;
}
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index da59a03..5782edc 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -799,6 +799,12 @@
public static final String EXTRA_MEDIA_SESSION = "android.mediaSession";
/**
+ * {@link #extras} key: the indices of actions to be shown in the compact view,
+ * as supplied to (e.g.) {@link MediaStyle#setShowActionsInCompactView(int...)}.
+ */
+ public static final String EXTRA_COMPACT_ACTIONS = "android.compactActions";
+
+ /**
* Value for {@link #EXTRA_AS_HEADS_UP} that indicates this notification should not be
* displayed in the heads up space.
*
@@ -3362,6 +3368,9 @@
if (mToken != null) {
extras.putParcelable(EXTRA_MEDIA_SESSION, mToken);
}
+ if (mActionsToShowInCompact != null) {
+ extras.putIntArray(EXTRA_COMPACT_ACTIONS, mActionsToShowInCompact);
+ }
}
private RemoteViews generateMediaActionButton(Action action) {
diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java
index 38ddede..5face69 100644
--- a/core/java/android/content/res/Resources.java
+++ b/core/java/android/content/res/Resources.java
@@ -1824,15 +1824,7 @@
remainder = languageTag.substring(separator);
}
- if ("id".equals(language)) {
- return "in" + remainder;
- } else if ("yi".equals(language)) {
- return "ji" + remainder;
- } else if ("he".equals(language)) {
- return "iw" + remainder;
- } else {
- return languageTag;
- }
+ return Locale.adjustLanguageCode(language) + remainder;
}
/**
diff --git a/core/java/android/service/notification/StatusBarNotification.java b/core/java/android/service/notification/StatusBarNotification.java
index e7cdc4e..e5a5292 100644
--- a/core/java/android/service/notification/StatusBarNotification.java
+++ b/core/java/android/service/notification/StatusBarNotification.java
@@ -30,6 +30,7 @@
private final int id;
private final String tag;
private final String key;
+ private final String groupKey;
private final int uid;
private final String opPkg;
@@ -65,6 +66,7 @@
this.notification.setUser(user);
this.postTime = postTime;
this.key = key();
+ this.groupKey = groupKey();
}
public StatusBarNotification(Parcel in) {
@@ -84,12 +86,26 @@
this.notification.setUser(this.user);
this.postTime = in.readLong();
this.key = key();
+ this.groupKey = groupKey();
}
private String key() {
return user.getIdentifier() + "|" + pkg + "|" + id + "|" + tag + "|" + uid;
}
+ private String groupKey() {
+ final String group = getNotification().getGroup();
+ final String sortKey = getNotification().getSortKey();
+ if (group == null && sortKey == null) {
+ // a group of one
+ return key;
+ }
+ return user.getIdentifier() + "|" + pkg + "|" +
+ (group == null
+ ? "p:" + notification.priority
+ : "g:" + group);
+ }
+
public void writeToParcel(Parcel out, int flags) {
out.writeString(this.pkg);
out.writeString(this.opPkg);
@@ -240,4 +256,11 @@
public String getKey() {
return key;
}
+
+ /**
+ * A key that indicates the group with which this message ranks.
+ */
+ public String getGroupKey() {
+ return groupKey;
+ }
}
diff --git a/core/java/com/android/internal/app/LocalePicker.java b/core/java/com/android/internal/app/LocalePicker.java
index a866ca7..229df8f 100644
--- a/core/java/com/android/internal/app/LocalePicker.java
+++ b/core/java/com/android/internal/app/LocalePicker.java
@@ -36,7 +36,6 @@
import android.widget.TextView;
import java.text.Collator;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
@@ -106,22 +105,21 @@
return constructAdapter(context, layoutId, fieldId, false /* disable pseudolocales */);
}
- public static ArrayAdapter<LocaleInfo> constructAdapter(Context context,
- final int layoutId, final int fieldId, final boolean isInDeveloperMode) {
+ public static List<LocaleInfo> getAllAssetLocales(Context context, boolean isInDeveloperMode) {
final Resources resources = context.getResources();
- String[] locales = Resources.getSystem().getAssets().getLocales();
+ final String[] locales = Resources.getSystem().getAssets().getLocales();
List<String> localeList = new ArrayList<String>(locales.length);
Collections.addAll(localeList, locales);
if (isInDeveloperMode) {
if (!localeList.contains("zz_ZZ")) {
localeList.add("zz_ZZ");
}
- /** - TODO: Enable when zz_ZY Pseudolocale is complete
- * if (!localeList.contains("zz_ZY")) {
- * localeList.add("zz_ZY");
- * }
- */
+ /** - TODO: Enable when zz_ZY Pseudolocale is complete
+ * if (!localeList.contains("zz_ZY")) {
+ * localeList.add("zz_ZY");
+ * }
+ */
}
Collections.sort(localeList);
@@ -179,6 +177,13 @@
}
Collections.sort(localeInfos);
+ return localeInfos;
+ }
+
+ public static ArrayAdapter<LocaleInfo> constructAdapter(Context context,
+ final int layoutId, final int fieldId, final boolean isInDeveloperMode) {
+ final List<LocaleInfo> localeInfos = getAllAssetLocales(context, isInDeveloperMode);
+
final LayoutInflater inflater =
(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
return new ArrayAdapter<LocaleInfo>(context, layoutId, fieldId, localeInfos) {
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 2d6d09b..dcb4f18 100755
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -8060,8 +8060,8 @@
boolean checkedGrants = false;
if (checkUser) {
// Looking for cross-user grants before enforcing the typical cross-users permissions
- int tmpTargetUserId = unsafeConvertIncomingUser(UserHandle.getUserId(callingUid));
- if (tmpTargetUserId != userId) {
+ int tmpTargetUserId = unsafeConvertIncomingUser(userId);
+ if (tmpTargetUserId != UserHandle.getUserId(callingUid)) {
if (checkAuthorityGrants(callingUid, cpi, tmpTargetUserId, checkUser)) {
return null;
}
diff --git a/services/core/java/com/android/server/notification/GroupedNotificationComparator.java b/services/core/java/com/android/server/notification/GroupedNotificationComparator.java
new file mode 100644
index 0000000..608d55c
--- /dev/null
+++ b/services/core/java/com/android/server/notification/GroupedNotificationComparator.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2014 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.server.notification;
+
+import android.text.TextUtils;
+import android.util.Log;
+
+/**
+ * Sorts notifications, accounting for groups and sort keys.
+ */
+public class GroupedNotificationComparator extends NotificationComparator {
+ private static final String TAG = "GroupedNotificationComparator";
+
+ @Override
+ public int compare(NotificationRecord left, NotificationRecord right) {
+ // "recently intrusive" is an ad hoc group that temporarily claims noisy notifications
+ if (left.isRecentlyIntrusive() != right.isRecentlyIntrusive()) {
+ return left.isRecentlyIntrusive() ? -1 : 1;
+ }
+
+ final NotificationRecord leftProxy = left.getRankingProxy();
+ if (leftProxy == null) {
+ throw new RuntimeException("left proxy cannot be null: " + left.getKey());
+ }
+ final NotificationRecord rightProxy = right.getRankingProxy();
+ if (rightProxy == null) {
+ throw new RuntimeException("right proxy cannot be null: " + right.getKey());
+ }
+ final String leftSortKey = left.getNotification().getSortKey();
+ final String rightSortKey = right.getNotification().getSortKey();
+ if (leftProxy != rightProxy) {
+ // between groups, compare proxies
+ return Integer.compare(leftProxy.getAuthoritativeRank(),
+ rightProxy.getAuthoritativeRank());
+ } else if (TextUtils.isEmpty(leftSortKey) || TextUtils.isEmpty(rightSortKey)) {
+ // missing sort keys, use prior rank
+ return Integer.compare(left.getAuthoritativeRank(),
+ right.getAuthoritativeRank());
+ } else {
+ // use sort keys within group
+ return leftSortKey.compareTo(rightSortKey);
+ }
+ }
+}
diff --git a/services/core/java/com/android/server/notification/NotificationComparator.java b/services/core/java/com/android/server/notification/NotificationComparator.java
index 0546a55..ec81fd2 100644
--- a/services/core/java/com/android/server/notification/NotificationComparator.java
+++ b/services/core/java/com/android/server/notification/NotificationComparator.java
@@ -18,35 +18,35 @@
import java.util.Comparator;
/**
- * Sorts notificaitons into attention-relelvant order.
+ * Sorts notifications individually into attention-relelvant order.
*/
public class NotificationComparator
implements Comparator<NotificationRecord> {
@Override
- public int compare(NotificationRecord lhs, NotificationRecord rhs) {
- if (lhs.isRecentlyIntrusive() != rhs.isRecentlyIntrusive()) {
- return lhs.isRecentlyIntrusive() ? -1 : 1;
- }
- final int leftPackagePriority = lhs.getPackagePriority();
- final int rightPackagePriority = rhs.getPackagePriority();
+ public int compare(NotificationRecord left, NotificationRecord right) {
+ final int leftPackagePriority = left.getPackagePriority();
+ final int rightPackagePriority = right.getPackagePriority();
if (leftPackagePriority != rightPackagePriority) {
// by priority, high to low
return -1 * Integer.compare(leftPackagePriority, rightPackagePriority);
}
- final int leftScore = lhs.sbn.getScore();
- final int rightScore = rhs.sbn.getScore();
+
+ final int leftScore = left.sbn.getScore();
+ final int rightScore = right.sbn.getScore();
if (leftScore != rightScore) {
// by priority, high to low
return -1 * Integer.compare(leftScore, rightScore);
}
- final float leftPeple = lhs.getContactAffinity();
- final float rightPeople = rhs.getContactAffinity();
- if (leftPeple != rightPeople) {
+
+ final float leftPeople = left.getContactAffinity();
+ final float rightPeople = right.getContactAffinity();
+ if (leftPeople != rightPeople) {
// by contact proximity, close to far
- return -1 * Float.compare(leftPeple, rightPeople);
+ return -1 * Float.compare(leftPeople, rightPeople);
}
+
// then break ties by time, most recent first
- return -1 * Long.compare(lhs.getRankingTimeMs(), rhs.getRankingTimeMs());
+ return -1 * Long.compare(left.getRankingTimeMs(), right.getRankingTimeMs());
}
}
diff --git a/services/core/java/com/android/server/notification/NotificationRecord.java b/services/core/java/com/android/server/notification/NotificationRecord.java
index 088b813..57f3e2d 100644
--- a/services/core/java/com/android/server/notification/NotificationRecord.java
+++ b/services/core/java/com/android/server/notification/NotificationRecord.java
@@ -21,6 +21,7 @@
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.service.notification.StatusBarNotification;
+import com.android.internal.annotations.VisibleForTesting;
import java.io.PrintWriter;
import java.lang.reflect.Array;
@@ -60,7 +61,12 @@
public boolean isUpdate;
private int mPackagePriority;
- NotificationRecord(StatusBarNotification sbn, int score)
+ // The record that ranking should use for comparisons outside the group.
+ private NotificationRecord mRankingProxy;
+ private int mAuthoritativeRank;
+
+ @VisibleForTesting
+ public NotificationRecord(StatusBarNotification sbn, int score)
{
this.sbn = sbn;
this.score = score;
@@ -73,7 +79,9 @@
mRecentlyIntrusive = previous.mRecentlyIntrusive;
mPackagePriority = previous.mPackagePriority;
mIntercept = previous.mIntercept;
+ mRankingProxy = previous.mRankingProxy;
mRankingTimeMs = calculateRankingTimeMs(previous.getRankingTimeMs());
+ // Don't copy mGroupKey, recompute it, in case it has changed
}
public Notification getNotification() { return sbn.getNotification(); }
@@ -89,6 +97,7 @@
+ " / " + idDebugString(baseContext, sbn.getPackageName(), notification.icon));
pw.println(prefix + " pri=" + notification.priority + " score=" + sbn.getScore());
pw.println(prefix + " key=" + sbn.getKey());
+ pw.println(prefix + " groupKey=" + getGroupKey());
pw.println(prefix + " contentIntent=" + notification.contentIntent);
pw.println(prefix + " deleteIntent=" + notification.deleteIntent);
pw.println(prefix + " tickerText=" + notification.tickerText);
@@ -145,6 +154,7 @@
pw.println(prefix + " mRecentlyIntrusive=" + mRecentlyIntrusive);
pw.println(prefix + " mPackagePriority=" + mPackagePriority);
pw.println(prefix + " mIntercept=" + mIntercept);
+ pw.println(prefix + " mRankingProxy=" + getRankingProxy().getKey());
pw.println(prefix + " mRankingTimeMs=" + mRankingTimeMs);
}
@@ -241,4 +251,24 @@
}
return sbn.getPostTime();
}
+
+ public NotificationRecord getRankingProxy() {
+ return mRankingProxy;
+ }
+
+ public void setRankingProxy(NotificationRecord proxy) {
+ mRankingProxy = proxy;
+ }
+
+ public void setAuthoritativeRank(int authoritativeRank) {
+ mAuthoritativeRank = authoritativeRank;
+ }
+
+ public int getAuthoritativeRank() {
+ return mAuthoritativeRank;
+ }
+
+ public String getGroupKey() {
+ return sbn.getGroupKey();
+ }
}
diff --git a/services/core/java/com/android/server/notification/RankingHelper.java b/services/core/java/com/android/server/notification/RankingHelper.java
index fc03c17..d59e17b 100644
--- a/services/core/java/com/android/server/notification/RankingHelper.java
+++ b/services/core/java/com/android/server/notification/RankingHelper.java
@@ -17,12 +17,12 @@
import android.app.Notification;
import android.content.Context;
+import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import android.os.UserHandle;
import android.text.TextUtils;
import android.util.ArrayMap;
-import android.util.Log;
import android.util.Slog;
import android.util.SparseIntArray;
import org.xmlpull.v1.XmlPullParser;
@@ -49,13 +49,13 @@
private static final String ATT_UID = "uid";
private static final String ATT_PRIORITY = "priority";
- private static final String VALUE_HIGH = "high";
-
private final NotificationSignalExtractor[] mSignalExtractors;
- private final NotificationComparator mRankingComparator = new NotificationComparator();
+ private final NotificationComparator mPreliminaryComparator = new NotificationComparator();
+ private final NotificationComparator mFinalComparator = new GroupedNotificationComparator();
// Package name to uid, to priority. Would be better as Table<String, Int, Int>
private final ArrayMap<String, SparseIntArray> mPackagePriorities;
+ private final ArrayMap<String, NotificationRecord> mProxyByGroupTmp;
private final Context mContext;
private final Handler mRankingHandler;
@@ -83,6 +83,7 @@
Slog.w(TAG, "Problem accessing extractor " + extractorNames[i] + ".", e);
}
}
+ mProxyByGroupTmp = new ArrayMap<String, NotificationRecord>();
}
public void extractSignals(NotificationRecord r) {
@@ -166,11 +167,39 @@
}
public void sort(ArrayList<NotificationRecord> notificationList) {
- Collections.sort(notificationList, mRankingComparator);
+ final int N = notificationList.size();
+ // clear group proxies
+ for (int i = N - 1; i >= 0; i--) {
+ notificationList.get(i).setRankingProxy(null);
+ }
+
+ // rank each record individually
+ Collections.sort(notificationList, mPreliminaryComparator);
+
+ // record inidivdual ranking result and nominate proxies for each group
+ for (int i = N - 1; i >= 0; i--) {
+ final NotificationRecord record = notificationList.get(i);
+ record.setAuthoritativeRank(i);
+ final String groupKey = record.getGroupKey();
+ boolean isGroupSummary = record.getNotification().getGroup() != null
+ && (record.getNotification().flags & Notification.FLAG_GROUP_SUMMARY) != 0;
+ if (isGroupSummary || mProxyByGroupTmp.get(groupKey) == null) {
+ mProxyByGroupTmp.put(groupKey, record);
+ }
+ }
+ // assign nominated proxies to each notification
+ for (int i = 0; i < N; i++) {
+ final NotificationRecord record = notificationList.get(i);
+ record.setRankingProxy(mProxyByGroupTmp.get(record.getGroupKey()));
+ }
+ // Do a second ranking pass, using group proxies
+ Collections.sort(notificationList, mFinalComparator);
+
+ mProxyByGroupTmp.clear();
}
public int indexOf(ArrayList<NotificationRecord> notificationList, NotificationRecord target) {
- return Collections.binarySearch(notificationList, target, mRankingComparator);
+ return Collections.binarySearch(notificationList, target, mFinalComparator);
}
private static int safeInt(XmlPullParser parser, String att, int defValue) {
diff --git a/services/tests/servicestests/src/com/android/server/notification/RankingHelperTest.java b/services/tests/servicestests/src/com/android/server/notification/RankingHelperTest.java
new file mode 100644
index 0000000..3cc04e8
--- /dev/null
+++ b/services/tests/servicestests/src/com/android/server/notification/RankingHelperTest.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2014 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.server.notification;
+
+import android.app.Notification;
+import android.os.UserHandle;
+import android.service.notification.StatusBarNotification;
+import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import java.util.ArrayList;
+
+public class RankingHelperTest extends AndroidTestCase {
+
+ private Notification mNotiGroupGSortA;
+ private Notification mNotiGroupGSortB;
+ private Notification mNotiNoGroup;
+ private Notification mNotiNoGroup2;
+ private Notification mNotiNoGroupSortA;
+ private NotificationRecord mRecordGroupGSortA;
+ private NotificationRecord mRecordGroupGSortB;
+ private NotificationRecord mRecordNoGroup;
+ private NotificationRecord mRecordNoGroup2;
+ private NotificationRecord mRecordNoGroupSortA;
+ private RankingHelper mHelper;
+
+ @Override
+ public void setUp() {
+ UserHandle user = UserHandle.ALL;
+
+ mHelper = new RankingHelper(getContext(), null, new String[0]);
+
+ mNotiGroupGSortA = new Notification.Builder(getContext())
+ .setContentTitle("A")
+ .setGroup("G")
+ .setSortKey("A")
+ .setWhen(1205)
+ .build();
+ mRecordGroupGSortA = new NotificationRecord(new StatusBarNotification(
+ "package", "package", 1, null, 0, 0, 0, mNotiGroupGSortA, user), 0);
+
+ mNotiGroupGSortB = new Notification.Builder(getContext())
+ .setContentTitle("B")
+ .setGroup("G")
+ .setSortKey("B")
+ .setWhen(1200)
+ .build();
+ mRecordGroupGSortB = new NotificationRecord(new StatusBarNotification(
+ "package", "package", 1, null, 0, 0, 0, mNotiGroupGSortB, user), 0);
+
+ mNotiNoGroup = new Notification.Builder(getContext())
+ .setContentTitle("C")
+ .setWhen(1201)
+ .build();
+ mRecordNoGroup = new NotificationRecord(new StatusBarNotification(
+ "package", "package", 1, null, 0, 0, 0, mNotiNoGroup, user), 0);
+
+ mNotiNoGroup2 = new Notification.Builder(getContext())
+ .setContentTitle("D")
+ .setWhen(1202)
+ .build();
+ mRecordNoGroup2 = new NotificationRecord(new StatusBarNotification(
+ "package", "package", 1, null, 0, 0, 0, mNotiNoGroup2, user), 0);
+
+ mNotiNoGroupSortA = new Notification.Builder(getContext())
+ .setContentTitle("E")
+ .setWhen(1201)
+ .setSortKey("A")
+ .build();
+ mRecordNoGroupSortA = new NotificationRecord(new StatusBarNotification(
+ "package", "package", 1, null, 0, 0, 0, mNotiNoGroupSortA, user), 0);
+ }
+
+ @SmallTest
+ public void testFindAfterRankingWithASplitGroup() throws Exception {
+ ArrayList<NotificationRecord> notificationList = new ArrayList<NotificationRecord>(3);
+ notificationList.add(mRecordGroupGSortA);
+ notificationList.add(mRecordGroupGSortB);
+ notificationList.add(mRecordNoGroup);
+ notificationList.add(mRecordNoGroupSortA);
+ mHelper.sort(notificationList);
+ assertTrue(mHelper.indexOf(notificationList, mRecordGroupGSortA) >= 0);
+ assertTrue(mHelper.indexOf(notificationList, mRecordGroupGSortB) >= 0);
+ assertTrue(mHelper.indexOf(notificationList, mRecordNoGroup) >= 0);
+ assertTrue(mHelper.indexOf(notificationList, mRecordNoGroupSortA) >= 0);
+ }
+
+ @SmallTest
+ public void testSortShouldNotThrowWithPlainNotifications() throws Exception {
+ ArrayList<NotificationRecord> notificationList = new ArrayList<NotificationRecord>(2);
+ notificationList.add(mRecordNoGroup);
+ notificationList.add(mRecordNoGroup2);
+ mHelper.sort(notificationList);
+ }
+
+ @SmallTest
+ public void testSortShouldNotThrowOneSorted() throws Exception {
+ ArrayList<NotificationRecord> notificationList = new ArrayList<NotificationRecord>(2);
+ notificationList.add(mRecordNoGroup);
+ notificationList.add(mRecordNoGroupSortA);
+ mHelper.sort(notificationList);
+ }
+
+ @SmallTest
+ public void testSortShouldNotThrowOneNotification() throws Exception {
+ ArrayList<NotificationRecord> notificationList = new ArrayList<NotificationRecord>(1);
+ notificationList.add(mRecordNoGroup);
+ mHelper.sort(notificationList);
+ }
+
+ @SmallTest
+ public void testSortShouldNotThrowOneSortKey() throws Exception {
+ ArrayList<NotificationRecord> notificationList = new ArrayList<NotificationRecord>(1);
+ notificationList.add(mRecordGroupGSortB);
+ mHelper.sort(notificationList);
+ }
+
+ @SmallTest
+ public void testSortShouldNotThrowOnEmptyList() throws Exception {
+ ArrayList<NotificationRecord> notificationList = new ArrayList<NotificationRecord>();
+ mHelper.sort(notificationList);
+ }
+}
diff --git a/telecomm/java/android/telecomm/PhoneAccount.java b/telecomm/java/android/telecomm/PhoneAccount.java
index 5a7753c..1f9071e 100644
--- a/telecomm/java/android/telecomm/PhoneAccount.java
+++ b/telecomm/java/android/telecomm/PhoneAccount.java
@@ -71,8 +71,8 @@
private final String mSubscriptionNumber;
private final int mCapabilities;
private final int mIconResId;
- private final String mLabel;
- private final String mShortDescription;
+ private final CharSequence mLabel;
+ private final CharSequence mShortDescription;
private boolean mVideoCallingSupported;
public PhoneAccount(
@@ -81,8 +81,8 @@
String subscriptionNumber,
int capabilities,
int iconResId,
- String label,
- String shortDescription,
+ CharSequence label,
+ CharSequence shortDescription,
boolean supportsVideoCalling) {
mAccountHandle = account;
mHandle = handle;
@@ -136,11 +136,11 @@
}
/**
- * A short string label describing a {@code PhoneAccount}.
+ * A short label describing a {@code PhoneAccount}.
*
* @return A label for this {@code PhoneAccount}.
*/
- public String getLabel() {
+ public CharSequence getLabel() {
return mLabel;
}
@@ -149,7 +149,7 @@
*
* @return A description for this {@code PhoneAccount}.
*/
- public String getShortDescription() {
+ public CharSequence getShortDescription() {
return mShortDescription;
}
@@ -214,8 +214,8 @@
out.writeString(mSubscriptionNumber);
out.writeInt(mCapabilities);
out.writeInt(mIconResId);
- out.writeString(mLabel);
- out.writeString(mShortDescription);
+ out.writeCharSequence(mLabel);
+ out.writeCharSequence(mShortDescription);
out.writeInt(mVideoCallingSupported ? 1 : 0);
}
@@ -238,8 +238,8 @@
mSubscriptionNumber = in.readString();
mCapabilities = in.readInt();
mIconResId = in.readInt();
- mLabel = in.readString();
- mShortDescription = in.readString();
+ mLabel = in.readCharSequence();
+ mShortDescription = in.readCharSequence();
mVideoCallingSupported = in.readInt() == 1;
}
}
diff --git a/telecomm/java/android/telecomm/StatusHints.java b/telecomm/java/android/telecomm/StatusHints.java
index 5e64bff..50f525a 100644
--- a/telecomm/java/android/telecomm/StatusHints.java
+++ b/telecomm/java/android/telecomm/StatusHints.java
@@ -34,11 +34,11 @@
public final class StatusHints implements Parcelable {
private final ComponentName mComponentName;
- private final String mLabel;
+ private final CharSequence mLabel;
private final int mIconId;
private final Bundle mExtras;
- public StatusHints(ComponentName componentName, String label, int iconId, Bundle extras) {
+ public StatusHints(ComponentName componentName, CharSequence label, int iconId, Bundle extras) {
mComponentName = componentName;
mLabel = label;
mIconId = iconId;
@@ -55,7 +55,7 @@
/**
* @return The label displayed in the in-call UI.
*/
- public String getLabel() {
+ public CharSequence getLabel() {
return mLabel;
}
@@ -88,7 +88,7 @@
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeParcelable(mComponentName, flags);
- out.writeString(mLabel);
+ out.writeCharSequence(mLabel);
out.writeInt(mIconId);
out.writeParcelable(mExtras, 0);
}
@@ -106,7 +106,7 @@
private StatusHints(Parcel in) {
mComponentName = in.readParcelable(getClass().getClassLoader());
- mLabel = in.readString();
+ mLabel = in.readCharSequence();
mIconId = in.readInt();
mExtras = (Bundle) in.readParcelable(getClass().getClassLoader());
}