Loading api/current.txt +4 −0 Original line number Original line Diff line number Diff line Loading @@ -5266,6 +5266,7 @@ package android.app { method public String getGroup(); method public String getGroup(); method public int getGroupAlertBehavior(); method public int getGroupAlertBehavior(); method public android.graphics.drawable.Icon getLargeIcon(); method public android.graphics.drawable.Icon getLargeIcon(); method @Nullable public android.content.LocusId getLocusId(); method public CharSequence getSettingsText(); method public CharSequence getSettingsText(); method public String getShortcutId(); method public String getShortcutId(); method public android.graphics.drawable.Icon getSmallIcon(); method public android.graphics.drawable.Icon getSmallIcon(); Loading Loading @@ -5545,6 +5546,7 @@ package android.app { method @NonNull public android.app.Notification.Builder setLargeIcon(android.graphics.drawable.Icon); method @NonNull public android.app.Notification.Builder setLargeIcon(android.graphics.drawable.Icon); method @Deprecated public android.app.Notification.Builder setLights(@ColorInt int, int, int); method @Deprecated public android.app.Notification.Builder setLights(@ColorInt int, int, int); method @NonNull public android.app.Notification.Builder setLocalOnly(boolean); method @NonNull public android.app.Notification.Builder setLocalOnly(boolean); method @NonNull public android.app.Notification.Builder setLocusId(@Nullable android.content.LocusId); method @NonNull public android.app.Notification.Builder setNumber(int); method @NonNull public android.app.Notification.Builder setNumber(int); method @NonNull public android.app.Notification.Builder setOngoing(boolean); method @NonNull public android.app.Notification.Builder setOngoing(boolean); method @NonNull public android.app.Notification.Builder setOnlyAlertOnce(boolean); method @NonNull public android.app.Notification.Builder setOnlyAlertOnce(boolean); Loading Loading @@ -11974,6 +11976,7 @@ package android.content.pm { method @Nullable public android.content.Intent getIntent(); method @Nullable public android.content.Intent getIntent(); method @Nullable public android.content.Intent[] getIntents(); method @Nullable public android.content.Intent[] getIntents(); method public long getLastChangedTimestamp(); method public long getLastChangedTimestamp(); method @Nullable public android.content.LocusId getLocusId(); method @Nullable public CharSequence getLongLabel(); method @Nullable public CharSequence getLongLabel(); method @NonNull public String getPackage(); method @NonNull public String getPackage(); method public int getRank(); method public int getRank(); Loading Loading @@ -12008,6 +12011,7 @@ package android.content.pm { method @NonNull public android.content.pm.ShortcutInfo.Builder setIcon(android.graphics.drawable.Icon); method @NonNull public android.content.pm.ShortcutInfo.Builder setIcon(android.graphics.drawable.Icon); method @NonNull public android.content.pm.ShortcutInfo.Builder setIntent(@NonNull android.content.Intent); method @NonNull public android.content.pm.ShortcutInfo.Builder setIntent(@NonNull android.content.Intent); method @NonNull public android.content.pm.ShortcutInfo.Builder setIntents(@NonNull android.content.Intent[]); method @NonNull public android.content.pm.ShortcutInfo.Builder setIntents(@NonNull android.content.Intent[]); method @NonNull public android.content.pm.ShortcutInfo.Builder setLocusId(@NonNull android.content.LocusId); method @NonNull public android.content.pm.ShortcutInfo.Builder setLongLabel(@NonNull CharSequence); method @NonNull public android.content.pm.ShortcutInfo.Builder setLongLabel(@NonNull CharSequence); method @NonNull public android.content.pm.ShortcutInfo.Builder setLongLived(); method @NonNull public android.content.pm.ShortcutInfo.Builder setLongLived(); method @NonNull public android.content.pm.ShortcutInfo.Builder setPerson(@NonNull android.app.Person); method @NonNull public android.content.pm.ShortcutInfo.Builder setPerson(@NonNull android.app.Person); core/java/android/app/Notification.java +42 −0 Original line number Original line Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.annotation.SystemApi; import android.annotation.UnsupportedAppUsage; import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.LocusId; import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManager.NameNotFoundException; Loading Loading @@ -77,6 +78,7 @@ import android.view.Gravity; import android.view.NotificationHeaderView; import android.view.NotificationHeaderView; import android.view.View; import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup; import android.view.contentcapture.ContentCaptureContext; import android.widget.ProgressBar; import android.widget.ProgressBar; import android.widget.RemoteViews; import android.widget.RemoteViews; Loading Loading @@ -1271,6 +1273,7 @@ public class Notification implements Parcelable private long mTimeout; private long mTimeout; private String mShortcutId; private String mShortcutId; private LocusId mLocusId; private CharSequence mSettingsText; private CharSequence mSettingsText; private BubbleMetadata mBubbleMetadata; private BubbleMetadata mBubbleMetadata; Loading Loading @@ -2274,6 +2277,10 @@ public class Notification implements Parcelable mShortcutId = parcel.readString(); mShortcutId = parcel.readString(); } } if (parcel.readInt() != 0) { mLocusId = LocusId.CREATOR.createFromParcel(parcel); } mBadgeIcon = parcel.readInt(); mBadgeIcon = parcel.readInt(); if (parcel.readInt() != 0) { if (parcel.readInt() != 0) { Loading Loading @@ -2397,6 +2404,7 @@ public class Notification implements Parcelable that.mChannelId = this.mChannelId; that.mChannelId = this.mChannelId; that.mTimeout = this.mTimeout; that.mTimeout = this.mTimeout; that.mShortcutId = this.mShortcutId; that.mShortcutId = this.mShortcutId; that.mLocusId = this.mLocusId; that.mBadgeIcon = this.mBadgeIcon; that.mBadgeIcon = this.mBadgeIcon; that.mSettingsText = this.mSettingsText; that.mSettingsText = this.mSettingsText; that.mGroupAlertBehavior = this.mGroupAlertBehavior; that.mGroupAlertBehavior = this.mGroupAlertBehavior; Loading Loading @@ -2712,6 +2720,13 @@ public class Notification implements Parcelable parcel.writeInt(0); parcel.writeInt(0); } } if (mLocusId != null) { parcel.writeInt(1); mLocusId.writeToParcel(parcel, 0); } else { parcel.writeInt(0); } parcel.writeInt(mBadgeIcon); parcel.writeInt(mBadgeIcon); if (mSettingsText != null) { if (mSettingsText != null) { Loading Loading @@ -3025,6 +3040,10 @@ public class Notification implements Parcelable sb.append(" publicVersion="); sb.append(" publicVersion="); sb.append(publicVersion.toString()); sb.append(publicVersion.toString()); } } if (this.mLocusId != null) { sb.append(" locusId="); sb.append(this.mLocusId); // LocusId.toString() is PII safe. } sb.append(")"); sb.append(")"); return sb.toString(); return sb.toString(); } } Loading Loading @@ -3127,6 +3146,16 @@ public class Notification implements Parcelable return mShortcutId; return mShortcutId; } } /** * Gets the {@link LocusId} associated with this notification. * * <p>Used by the device's intelligence services to correlate objects (such as * {@link ShortcutInfo} and {@link ContentCaptureContext}) that are correlated. */ @Nullable public LocusId getLocusId() { return mLocusId; } /** /** * Returns the settings text provided to {@link Builder#setSettingsText(CharSequence)}. * Returns the settings text provided to {@link Builder#setSettingsText(CharSequence)}. Loading Loading @@ -3484,6 +3513,19 @@ public class Notification implements Parcelable return this; return this; } } /** * Sets the {@link LocusId} associated with this notification. * * <p>This method should be called when the {@link LocusId} is used in other places (such * as {@link ShortcutInfo} and {@link ContentCaptureContext}) so the device's intelligence * services can correlate them. */ @NonNull public Builder setLocusId(@Nullable LocusId locusId) { mN.mLocusId = locusId; return this; } /** /** * Sets which icon to display as a badge for this notification. * Sets which icon to display as a badge for this notification. * * Loading core/java/android/content/pm/ShortcutInfo.java +47 −1 Original line number Original line Diff line number Diff line Loading @@ -22,11 +22,13 @@ import android.annotation.SystemApi; import android.annotation.TestApi; import android.annotation.TestApi; import android.annotation.UnsupportedAppUsage; import android.annotation.UnsupportedAppUsage; import android.annotation.UserIdInt; import android.annotation.UserIdInt; import android.app.Notification; import android.app.Person; import android.app.Person; import android.app.TaskStackBuilder; import android.app.TaskStackBuilder; import android.content.ComponentName; import android.content.ComponentName; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.LocusId; import android.content.pm.LauncherApps.ShortcutQuery; import android.content.pm.LauncherApps.ShortcutQuery; import android.content.res.Resources; import android.content.res.Resources; import android.content.res.Resources.NotFoundException; import android.content.res.Resources.NotFoundException; Loading @@ -41,6 +43,7 @@ import android.os.UserHandle; import android.text.TextUtils; import android.text.TextUtils; import android.util.ArraySet; import android.util.ArraySet; import android.util.Log; import android.util.Log; import android.view.contentcapture.ContentCaptureContext; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.Preconditions; import com.android.internal.util.Preconditions; Loading Loading @@ -354,6 +357,9 @@ public final class ShortcutInfo implements Parcelable { @Nullable @Nullable private Person[] mPersons; private Person[] mPersons; @Nullable private LocusId mLocusId; private int mRank; private int mRank; /** /** Loading Loading @@ -415,6 +421,8 @@ public final class ShortcutInfo implements Parcelable { } } mRank = b.mRank; mRank = b.mRank; mExtras = b.mExtras; mExtras = b.mExtras; mLocusId = b.mLocusId; updateTimestamp(); updateTimestamp(); } } Loading Loading @@ -521,6 +529,7 @@ public final class ShortcutInfo implements Parcelable { mFlags = source.mFlags; mFlags = source.mFlags; mLastChangedTimestamp = source.mLastChangedTimestamp; mLastChangedTimestamp = source.mLastChangedTimestamp; mDisabledReason = source.mDisabledReason; mDisabledReason = source.mDisabledReason; mLocusId = source.mLocusId; // Just always keep it since it's cheep. // Just always keep it since it's cheep. mIconResId = source.mIconResId; mIconResId = source.mIconResId; Loading Loading @@ -876,6 +885,10 @@ public final class ShortcutInfo implements Parcelable { if (source.mExtras != null) { if (source.mExtras != null) { mExtras = source.mExtras; mExtras = source.mExtras; } } if (source.mLocusId != null) { mLocusId = source.mLocusId; } } } /** /** Loading Loading @@ -941,6 +954,8 @@ public final class ShortcutInfo implements Parcelable { private PersistableBundle mExtras; private PersistableBundle mExtras; private LocusId mLocusId; /** /** * Old style constructor. * Old style constructor. * @hide * @hide Loading Loading @@ -972,6 +987,19 @@ public final class ShortcutInfo implements Parcelable { mId = Preconditions.checkStringNotEmpty(id, "id cannot be empty"); mId = Preconditions.checkStringNotEmpty(id, "id cannot be empty"); } } /** * Sets the {@link LocusId} associated with this shortcut. * * <p>This method should be called when the {@link LocusId} is used in other places (such * as {@link Notification} and {@link ContentCaptureContext}) so the device's intelligence * services can correlate them. */ @NonNull public Builder setLocusId(@NonNull LocusId locusId) { mLocusId = Preconditions.checkNotNull(locusId, "locusId cannot be null"); return this; } /** /** * Sets the target activity. A shortcut will be shown along with this activity's icon * Sets the target activity. A shortcut will be shown along with this activity's icon * on the launcher. * on the launcher. Loading Loading @@ -1294,6 +1322,17 @@ public final class ShortcutInfo implements Parcelable { return mId; return mId; } } /** * Gets the {@link LocusId} associated with this shortcut. * * <p>Used by the device's intelligence services to correlate objects (such as * {@link Notification} and {@link ContentCaptureContext}) that are correlated. */ @Nullable public LocusId getLocusId() { return mLocusId; } /** /** * Return the package name of the publisher app. * Return the package name of the publisher app. */ */ Loading Loading @@ -1999,6 +2038,7 @@ public final class ShortcutInfo implements Parcelable { } } mPersons = source.readParcelableArray(cl, Person.class); mPersons = source.readParcelableArray(cl, Person.class); mLocusId = source.readParcelable(cl); } } @Override @Override Loading Loading @@ -2048,6 +2088,7 @@ public final class ShortcutInfo implements Parcelable { } } dest.writeParcelableArray(mPersons, flags); dest.writeParcelableArray(mPersons, flags); dest.writeParcelable(mLocusId, flags); } } public static final @android.annotation.NonNull Creator<ShortcutInfo> CREATOR = public static final @android.annotation.NonNull Creator<ShortcutInfo> CREATOR = Loading Loading @@ -2263,6 +2304,10 @@ public final class ShortcutInfo implements Parcelable { sb.append(mBitmapPath); sb.append(mBitmapPath); } } if (mLocusId != null) { sb.append("locusId="); sb.append(mLocusId); // LocusId.toString() is PII-safe. } sb.append("}"); sb.append("}"); return sb.toString(); return sb.toString(); } } Loading @@ -2276,7 +2321,7 @@ public final class ShortcutInfo implements Parcelable { Set<String> categories, Intent[] intentsWithExtras, int rank, PersistableBundle extras, Set<String> categories, Intent[] intentsWithExtras, int rank, PersistableBundle extras, long lastChangedTimestamp, long lastChangedTimestamp, int flags, int iconResId, String iconResName, String bitmapPath, int disabledReason, int flags, int iconResId, String iconResName, String bitmapPath, int disabledReason, Person[] persons) { Person[] persons, LocusId locusId) { mUserId = userId; mUserId = userId; mId = id; mId = id; mPackageName = packageName; mPackageName = packageName; Loading @@ -2303,5 +2348,6 @@ public final class ShortcutInfo implements Parcelable { mBitmapPath = bitmapPath; mBitmapPath = bitmapPath; mDisabledReason = disabledReason; mDisabledReason = disabledReason; mPersons = persons; mPersons = persons; mLocusId = locusId; } } } } core/tests/coretests/src/android/app/NotificationTest.java +23 −0 Original line number Original line Diff line number Diff line Loading @@ -21,12 +21,14 @@ import static com.android.internal.util.ContrastColorUtil.satisfiesTextContrast; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue; import android.annotation.Nullable; import android.annotation.Nullable; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.LocusId; import android.graphics.BitmapFactory; import android.graphics.BitmapFactory; import android.graphics.drawable.Icon; import android.graphics.drawable.Icon; import android.media.session.MediaSession; import android.media.session.MediaSession; Loading Loading @@ -320,6 +322,27 @@ public class NotificationTest { action.clone().getSemanticAction()); action.clone().getSemanticAction()); } } @Test public void testBuilder_setLocusId() { LocusId locusId = new LocusId("4815162342"); Notification notification = new Notification.Builder(mContext, "whatever") .setLocusId(locusId).build(); assertEquals(locusId, notification.getLocusId()); Notification clone = writeAndReadParcelable(notification); assertEquals(locusId, clone.getLocusId()); } @Test public void testBuilder_setLocusId_null() { Notification notification = new Notification.Builder(mContext, "whatever") .setLocusId(null).build(); assertNull(notification.getLocusId()); Notification clone = writeAndReadParcelable(notification); assertNull(clone.getLocusId()); } private Notification.Builder getMediaNotification() { private Notification.Builder getMediaNotification() { MediaSession session = new MediaSession(mContext, "test"); MediaSession session = new MediaSession(mContext, "test"); return new Notification.Builder(mContext, "color") return new Notification.Builder(mContext, "color") Loading services/core/java/com/android/server/pm/ShortcutPackage.java +5 −2 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.app.Person; import android.content.ComponentName; import android.content.ComponentName; import android.content.Intent; import android.content.Intent; import android.content.IntentFilter; import android.content.IntentFilter; import android.content.LocusId; import android.content.pm.PackageInfo; import android.content.pm.PackageInfo; import android.content.pm.ShortcutInfo; import android.content.pm.ShortcutInfo; import android.content.pm.ShortcutManager; import android.content.pm.ShortcutManager; Loading Loading @@ -1702,6 +1703,8 @@ class ShortcutPackage extends ShortcutPackageItem { flags |= ShortcutInfo.FLAG_SHADOW; flags |= ShortcutInfo.FLAG_SHADOW; } } LocusId locusId = null; // LocusId is not set on XML. return new ShortcutInfo( return new ShortcutInfo( userId, id, packageName, activityComponent, /* icon= */ null, userId, id, packageName, activityComponent, /* icon= */ null, title, titleResId, titleResName, text, textResId, textResName, title, titleResId, titleResName, text, textResId, textResName, Loading @@ -1710,7 +1713,7 @@ class ShortcutPackage extends ShortcutPackageItem { intents.toArray(new Intent[intents.size()]), intents.toArray(new Intent[intents.size()]), rank, extras, lastChangedTimestamp, flags, rank, extras, lastChangedTimestamp, flags, iconResId, iconResName, bitmapPath, disabledReason, iconResId, iconResName, bitmapPath, disabledReason, persons.toArray(new Person[persons.size()])); persons.toArray(new Person[persons.size()]), locusId); } } private static Intent parseIntent(XmlPullParser parser) private static Intent parseIntent(XmlPullParser parser) Loading Loading
api/current.txt +4 −0 Original line number Original line Diff line number Diff line Loading @@ -5266,6 +5266,7 @@ package android.app { method public String getGroup(); method public String getGroup(); method public int getGroupAlertBehavior(); method public int getGroupAlertBehavior(); method public android.graphics.drawable.Icon getLargeIcon(); method public android.graphics.drawable.Icon getLargeIcon(); method @Nullable public android.content.LocusId getLocusId(); method public CharSequence getSettingsText(); method public CharSequence getSettingsText(); method public String getShortcutId(); method public String getShortcutId(); method public android.graphics.drawable.Icon getSmallIcon(); method public android.graphics.drawable.Icon getSmallIcon(); Loading Loading @@ -5545,6 +5546,7 @@ package android.app { method @NonNull public android.app.Notification.Builder setLargeIcon(android.graphics.drawable.Icon); method @NonNull public android.app.Notification.Builder setLargeIcon(android.graphics.drawable.Icon); method @Deprecated public android.app.Notification.Builder setLights(@ColorInt int, int, int); method @Deprecated public android.app.Notification.Builder setLights(@ColorInt int, int, int); method @NonNull public android.app.Notification.Builder setLocalOnly(boolean); method @NonNull public android.app.Notification.Builder setLocalOnly(boolean); method @NonNull public android.app.Notification.Builder setLocusId(@Nullable android.content.LocusId); method @NonNull public android.app.Notification.Builder setNumber(int); method @NonNull public android.app.Notification.Builder setNumber(int); method @NonNull public android.app.Notification.Builder setOngoing(boolean); method @NonNull public android.app.Notification.Builder setOngoing(boolean); method @NonNull public android.app.Notification.Builder setOnlyAlertOnce(boolean); method @NonNull public android.app.Notification.Builder setOnlyAlertOnce(boolean); Loading Loading @@ -11974,6 +11976,7 @@ package android.content.pm { method @Nullable public android.content.Intent getIntent(); method @Nullable public android.content.Intent getIntent(); method @Nullable public android.content.Intent[] getIntents(); method @Nullable public android.content.Intent[] getIntents(); method public long getLastChangedTimestamp(); method public long getLastChangedTimestamp(); method @Nullable public android.content.LocusId getLocusId(); method @Nullable public CharSequence getLongLabel(); method @Nullable public CharSequence getLongLabel(); method @NonNull public String getPackage(); method @NonNull public String getPackage(); method public int getRank(); method public int getRank(); Loading Loading @@ -12008,6 +12011,7 @@ package android.content.pm { method @NonNull public android.content.pm.ShortcutInfo.Builder setIcon(android.graphics.drawable.Icon); method @NonNull public android.content.pm.ShortcutInfo.Builder setIcon(android.graphics.drawable.Icon); method @NonNull public android.content.pm.ShortcutInfo.Builder setIntent(@NonNull android.content.Intent); method @NonNull public android.content.pm.ShortcutInfo.Builder setIntent(@NonNull android.content.Intent); method @NonNull public android.content.pm.ShortcutInfo.Builder setIntents(@NonNull android.content.Intent[]); method @NonNull public android.content.pm.ShortcutInfo.Builder setIntents(@NonNull android.content.Intent[]); method @NonNull public android.content.pm.ShortcutInfo.Builder setLocusId(@NonNull android.content.LocusId); method @NonNull public android.content.pm.ShortcutInfo.Builder setLongLabel(@NonNull CharSequence); method @NonNull public android.content.pm.ShortcutInfo.Builder setLongLabel(@NonNull CharSequence); method @NonNull public android.content.pm.ShortcutInfo.Builder setLongLived(); method @NonNull public android.content.pm.ShortcutInfo.Builder setLongLived(); method @NonNull public android.content.pm.ShortcutInfo.Builder setPerson(@NonNull android.app.Person); method @NonNull public android.content.pm.ShortcutInfo.Builder setPerson(@NonNull android.app.Person);
core/java/android/app/Notification.java +42 −0 Original line number Original line Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.annotation.SystemApi; import android.annotation.UnsupportedAppUsage; import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.LocusId; import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManager.NameNotFoundException; Loading Loading @@ -77,6 +78,7 @@ import android.view.Gravity; import android.view.NotificationHeaderView; import android.view.NotificationHeaderView; import android.view.View; import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup; import android.view.contentcapture.ContentCaptureContext; import android.widget.ProgressBar; import android.widget.ProgressBar; import android.widget.RemoteViews; import android.widget.RemoteViews; Loading Loading @@ -1271,6 +1273,7 @@ public class Notification implements Parcelable private long mTimeout; private long mTimeout; private String mShortcutId; private String mShortcutId; private LocusId mLocusId; private CharSequence mSettingsText; private CharSequence mSettingsText; private BubbleMetadata mBubbleMetadata; private BubbleMetadata mBubbleMetadata; Loading Loading @@ -2274,6 +2277,10 @@ public class Notification implements Parcelable mShortcutId = parcel.readString(); mShortcutId = parcel.readString(); } } if (parcel.readInt() != 0) { mLocusId = LocusId.CREATOR.createFromParcel(parcel); } mBadgeIcon = parcel.readInt(); mBadgeIcon = parcel.readInt(); if (parcel.readInt() != 0) { if (parcel.readInt() != 0) { Loading Loading @@ -2397,6 +2404,7 @@ public class Notification implements Parcelable that.mChannelId = this.mChannelId; that.mChannelId = this.mChannelId; that.mTimeout = this.mTimeout; that.mTimeout = this.mTimeout; that.mShortcutId = this.mShortcutId; that.mShortcutId = this.mShortcutId; that.mLocusId = this.mLocusId; that.mBadgeIcon = this.mBadgeIcon; that.mBadgeIcon = this.mBadgeIcon; that.mSettingsText = this.mSettingsText; that.mSettingsText = this.mSettingsText; that.mGroupAlertBehavior = this.mGroupAlertBehavior; that.mGroupAlertBehavior = this.mGroupAlertBehavior; Loading Loading @@ -2712,6 +2720,13 @@ public class Notification implements Parcelable parcel.writeInt(0); parcel.writeInt(0); } } if (mLocusId != null) { parcel.writeInt(1); mLocusId.writeToParcel(parcel, 0); } else { parcel.writeInt(0); } parcel.writeInt(mBadgeIcon); parcel.writeInt(mBadgeIcon); if (mSettingsText != null) { if (mSettingsText != null) { Loading Loading @@ -3025,6 +3040,10 @@ public class Notification implements Parcelable sb.append(" publicVersion="); sb.append(" publicVersion="); sb.append(publicVersion.toString()); sb.append(publicVersion.toString()); } } if (this.mLocusId != null) { sb.append(" locusId="); sb.append(this.mLocusId); // LocusId.toString() is PII safe. } sb.append(")"); sb.append(")"); return sb.toString(); return sb.toString(); } } Loading Loading @@ -3127,6 +3146,16 @@ public class Notification implements Parcelable return mShortcutId; return mShortcutId; } } /** * Gets the {@link LocusId} associated with this notification. * * <p>Used by the device's intelligence services to correlate objects (such as * {@link ShortcutInfo} and {@link ContentCaptureContext}) that are correlated. */ @Nullable public LocusId getLocusId() { return mLocusId; } /** /** * Returns the settings text provided to {@link Builder#setSettingsText(CharSequence)}. * Returns the settings text provided to {@link Builder#setSettingsText(CharSequence)}. Loading Loading @@ -3484,6 +3513,19 @@ public class Notification implements Parcelable return this; return this; } } /** * Sets the {@link LocusId} associated with this notification. * * <p>This method should be called when the {@link LocusId} is used in other places (such * as {@link ShortcutInfo} and {@link ContentCaptureContext}) so the device's intelligence * services can correlate them. */ @NonNull public Builder setLocusId(@Nullable LocusId locusId) { mN.mLocusId = locusId; return this; } /** /** * Sets which icon to display as a badge for this notification. * Sets which icon to display as a badge for this notification. * * Loading
core/java/android/content/pm/ShortcutInfo.java +47 −1 Original line number Original line Diff line number Diff line Loading @@ -22,11 +22,13 @@ import android.annotation.SystemApi; import android.annotation.TestApi; import android.annotation.TestApi; import android.annotation.UnsupportedAppUsage; import android.annotation.UnsupportedAppUsage; import android.annotation.UserIdInt; import android.annotation.UserIdInt; import android.app.Notification; import android.app.Person; import android.app.Person; import android.app.TaskStackBuilder; import android.app.TaskStackBuilder; import android.content.ComponentName; import android.content.ComponentName; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.LocusId; import android.content.pm.LauncherApps.ShortcutQuery; import android.content.pm.LauncherApps.ShortcutQuery; import android.content.res.Resources; import android.content.res.Resources; import android.content.res.Resources.NotFoundException; import android.content.res.Resources.NotFoundException; Loading @@ -41,6 +43,7 @@ import android.os.UserHandle; import android.text.TextUtils; import android.text.TextUtils; import android.util.ArraySet; import android.util.ArraySet; import android.util.Log; import android.util.Log; import android.view.contentcapture.ContentCaptureContext; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.Preconditions; import com.android.internal.util.Preconditions; Loading Loading @@ -354,6 +357,9 @@ public final class ShortcutInfo implements Parcelable { @Nullable @Nullable private Person[] mPersons; private Person[] mPersons; @Nullable private LocusId mLocusId; private int mRank; private int mRank; /** /** Loading Loading @@ -415,6 +421,8 @@ public final class ShortcutInfo implements Parcelable { } } mRank = b.mRank; mRank = b.mRank; mExtras = b.mExtras; mExtras = b.mExtras; mLocusId = b.mLocusId; updateTimestamp(); updateTimestamp(); } } Loading Loading @@ -521,6 +529,7 @@ public final class ShortcutInfo implements Parcelable { mFlags = source.mFlags; mFlags = source.mFlags; mLastChangedTimestamp = source.mLastChangedTimestamp; mLastChangedTimestamp = source.mLastChangedTimestamp; mDisabledReason = source.mDisabledReason; mDisabledReason = source.mDisabledReason; mLocusId = source.mLocusId; // Just always keep it since it's cheep. // Just always keep it since it's cheep. mIconResId = source.mIconResId; mIconResId = source.mIconResId; Loading Loading @@ -876,6 +885,10 @@ public final class ShortcutInfo implements Parcelable { if (source.mExtras != null) { if (source.mExtras != null) { mExtras = source.mExtras; mExtras = source.mExtras; } } if (source.mLocusId != null) { mLocusId = source.mLocusId; } } } /** /** Loading Loading @@ -941,6 +954,8 @@ public final class ShortcutInfo implements Parcelable { private PersistableBundle mExtras; private PersistableBundle mExtras; private LocusId mLocusId; /** /** * Old style constructor. * Old style constructor. * @hide * @hide Loading Loading @@ -972,6 +987,19 @@ public final class ShortcutInfo implements Parcelable { mId = Preconditions.checkStringNotEmpty(id, "id cannot be empty"); mId = Preconditions.checkStringNotEmpty(id, "id cannot be empty"); } } /** * Sets the {@link LocusId} associated with this shortcut. * * <p>This method should be called when the {@link LocusId} is used in other places (such * as {@link Notification} and {@link ContentCaptureContext}) so the device's intelligence * services can correlate them. */ @NonNull public Builder setLocusId(@NonNull LocusId locusId) { mLocusId = Preconditions.checkNotNull(locusId, "locusId cannot be null"); return this; } /** /** * Sets the target activity. A shortcut will be shown along with this activity's icon * Sets the target activity. A shortcut will be shown along with this activity's icon * on the launcher. * on the launcher. Loading Loading @@ -1294,6 +1322,17 @@ public final class ShortcutInfo implements Parcelable { return mId; return mId; } } /** * Gets the {@link LocusId} associated with this shortcut. * * <p>Used by the device's intelligence services to correlate objects (such as * {@link Notification} and {@link ContentCaptureContext}) that are correlated. */ @Nullable public LocusId getLocusId() { return mLocusId; } /** /** * Return the package name of the publisher app. * Return the package name of the publisher app. */ */ Loading Loading @@ -1999,6 +2038,7 @@ public final class ShortcutInfo implements Parcelable { } } mPersons = source.readParcelableArray(cl, Person.class); mPersons = source.readParcelableArray(cl, Person.class); mLocusId = source.readParcelable(cl); } } @Override @Override Loading Loading @@ -2048,6 +2088,7 @@ public final class ShortcutInfo implements Parcelable { } } dest.writeParcelableArray(mPersons, flags); dest.writeParcelableArray(mPersons, flags); dest.writeParcelable(mLocusId, flags); } } public static final @android.annotation.NonNull Creator<ShortcutInfo> CREATOR = public static final @android.annotation.NonNull Creator<ShortcutInfo> CREATOR = Loading Loading @@ -2263,6 +2304,10 @@ public final class ShortcutInfo implements Parcelable { sb.append(mBitmapPath); sb.append(mBitmapPath); } } if (mLocusId != null) { sb.append("locusId="); sb.append(mLocusId); // LocusId.toString() is PII-safe. } sb.append("}"); sb.append("}"); return sb.toString(); return sb.toString(); } } Loading @@ -2276,7 +2321,7 @@ public final class ShortcutInfo implements Parcelable { Set<String> categories, Intent[] intentsWithExtras, int rank, PersistableBundle extras, Set<String> categories, Intent[] intentsWithExtras, int rank, PersistableBundle extras, long lastChangedTimestamp, long lastChangedTimestamp, int flags, int iconResId, String iconResName, String bitmapPath, int disabledReason, int flags, int iconResId, String iconResName, String bitmapPath, int disabledReason, Person[] persons) { Person[] persons, LocusId locusId) { mUserId = userId; mUserId = userId; mId = id; mId = id; mPackageName = packageName; mPackageName = packageName; Loading @@ -2303,5 +2348,6 @@ public final class ShortcutInfo implements Parcelable { mBitmapPath = bitmapPath; mBitmapPath = bitmapPath; mDisabledReason = disabledReason; mDisabledReason = disabledReason; mPersons = persons; mPersons = persons; mLocusId = locusId; } } } }
core/tests/coretests/src/android/app/NotificationTest.java +23 −0 Original line number Original line Diff line number Diff line Loading @@ -21,12 +21,14 @@ import static com.android.internal.util.ContrastColorUtil.satisfiesTextContrast; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue; import android.annotation.Nullable; import android.annotation.Nullable; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.LocusId; import android.graphics.BitmapFactory; import android.graphics.BitmapFactory; import android.graphics.drawable.Icon; import android.graphics.drawable.Icon; import android.media.session.MediaSession; import android.media.session.MediaSession; Loading Loading @@ -320,6 +322,27 @@ public class NotificationTest { action.clone().getSemanticAction()); action.clone().getSemanticAction()); } } @Test public void testBuilder_setLocusId() { LocusId locusId = new LocusId("4815162342"); Notification notification = new Notification.Builder(mContext, "whatever") .setLocusId(locusId).build(); assertEquals(locusId, notification.getLocusId()); Notification clone = writeAndReadParcelable(notification); assertEquals(locusId, clone.getLocusId()); } @Test public void testBuilder_setLocusId_null() { Notification notification = new Notification.Builder(mContext, "whatever") .setLocusId(null).build(); assertNull(notification.getLocusId()); Notification clone = writeAndReadParcelable(notification); assertNull(clone.getLocusId()); } private Notification.Builder getMediaNotification() { private Notification.Builder getMediaNotification() { MediaSession session = new MediaSession(mContext, "test"); MediaSession session = new MediaSession(mContext, "test"); return new Notification.Builder(mContext, "color") return new Notification.Builder(mContext, "color") Loading
services/core/java/com/android/server/pm/ShortcutPackage.java +5 −2 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.app.Person; import android.content.ComponentName; import android.content.ComponentName; import android.content.Intent; import android.content.Intent; import android.content.IntentFilter; import android.content.IntentFilter; import android.content.LocusId; import android.content.pm.PackageInfo; import android.content.pm.PackageInfo; import android.content.pm.ShortcutInfo; import android.content.pm.ShortcutInfo; import android.content.pm.ShortcutManager; import android.content.pm.ShortcutManager; Loading Loading @@ -1702,6 +1703,8 @@ class ShortcutPackage extends ShortcutPackageItem { flags |= ShortcutInfo.FLAG_SHADOW; flags |= ShortcutInfo.FLAG_SHADOW; } } LocusId locusId = null; // LocusId is not set on XML. return new ShortcutInfo( return new ShortcutInfo( userId, id, packageName, activityComponent, /* icon= */ null, userId, id, packageName, activityComponent, /* icon= */ null, title, titleResId, titleResName, text, textResId, textResName, title, titleResId, titleResName, text, textResId, textResName, Loading @@ -1710,7 +1713,7 @@ class ShortcutPackage extends ShortcutPackageItem { intents.toArray(new Intent[intents.size()]), intents.toArray(new Intent[intents.size()]), rank, extras, lastChangedTimestamp, flags, rank, extras, lastChangedTimestamp, flags, iconResId, iconResName, bitmapPath, disabledReason, iconResId, iconResName, bitmapPath, disabledReason, persons.toArray(new Person[persons.size()])); persons.toArray(new Person[persons.size()]), locusId); } } private static Intent parseIntent(XmlPullParser parser) private static Intent parseIntent(XmlPullParser parser) Loading