From 95ab5221395be15d35f28a851a76e5f881797341 Mon Sep 17 00:00:00 2001 From: Ariel Gertzenstein Date: Fri, 2 Sep 2016 17:00:16 -0400 Subject: [PATCH] Add api to WearableExtender for setting and getting the bridge tag. Make a change in the comment of setDismissalId. Bug:31181351 Change-Id: I2fa080cd171c24d753529304ca16e4023cfb2c15 --- api/current.txt | 2 ++ api/system-current.txt | 2 ++ api/test-current.txt | 2 ++ core/java/android/app/Notification.java | 37 +++++++++++++++++++++---- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/api/current.txt b/api/current.txt index 0a7607056cd9a..e16fbda1c6520 100644 --- a/api/current.txt +++ b/api/current.txt @@ -5259,6 +5259,7 @@ package android.app { method public android.app.Notification.Builder extend(android.app.Notification.Builder); method public java.util.List getActions(); method public android.graphics.Bitmap getBackground(); + method public java.lang.String getBridgeTag(); method public int getContentAction(); method public int getContentIcon(); method public int getContentIconGravity(); @@ -5277,6 +5278,7 @@ package android.app { method public java.util.List getPages(); method public boolean getStartScrollBottom(); method public android.app.Notification.WearableExtender setBackground(android.graphics.Bitmap); + method public android.app.Notification.WearableExtender setBridgeTag(java.lang.String); method public android.app.Notification.WearableExtender setContentAction(int); method public android.app.Notification.WearableExtender setContentIcon(int); method public android.app.Notification.WearableExtender setContentIconGravity(int); diff --git a/api/system-current.txt b/api/system-current.txt index 83cb79af60b17..cc7ae969ff998 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -5406,6 +5406,7 @@ package android.app { method public android.app.Notification.Builder extend(android.app.Notification.Builder); method public java.util.List getActions(); method public android.graphics.Bitmap getBackground(); + method public java.lang.String getBridgeTag(); method public int getContentAction(); method public int getContentIcon(); method public int getContentIconGravity(); @@ -5424,6 +5425,7 @@ package android.app { method public java.util.List getPages(); method public boolean getStartScrollBottom(); method public android.app.Notification.WearableExtender setBackground(android.graphics.Bitmap); + method public android.app.Notification.WearableExtender setBridgeTag(java.lang.String); method public android.app.Notification.WearableExtender setContentAction(int); method public android.app.Notification.WearableExtender setContentIcon(int); method public android.app.Notification.WearableExtender setContentIconGravity(int); diff --git a/api/test-current.txt b/api/test-current.txt index f974393c62075..2cb0291c5abcd 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -5262,6 +5262,7 @@ package android.app { method public android.app.Notification.Builder extend(android.app.Notification.Builder); method public java.util.List getActions(); method public android.graphics.Bitmap getBackground(); + method public java.lang.String getBridgeTag(); method public int getContentAction(); method public int getContentIcon(); method public int getContentIconGravity(); @@ -5280,6 +5281,7 @@ package android.app { method public java.util.List getPages(); method public boolean getStartScrollBottom(); method public android.app.Notification.WearableExtender setBackground(android.graphics.Bitmap); + method public android.app.Notification.WearableExtender setBridgeTag(java.lang.String); method public android.app.Notification.WearableExtender setContentAction(int); method public android.app.Notification.WearableExtender setContentIcon(int); method public android.app.Notification.WearableExtender setContentIconGravity(int); diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 2028572505a31..26c8670c50c5f 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -5834,6 +5834,7 @@ public class Notification implements Parcelable private static final String KEY_GRAVITY = "gravity"; private static final String KEY_HINT_SCREEN_TIMEOUT = "hintScreenTimeout"; private static final String KEY_DISMISSAL_ID = "dismissalId"; + private static final String KEY_BRIDGE_TAG = "bridgeTag"; // Flags bitwise-ored to mFlags private static final int FLAG_CONTENT_INTENT_AVAILABLE_OFFLINE = 0x1; @@ -5863,6 +5864,7 @@ public class Notification implements Parcelable private int mGravity = DEFAULT_GRAVITY; private int mHintScreenTimeout; private String mDismissalId; + private String mBridgeTag; /** * Create a {@link android.app.Notification.WearableExtender} with default @@ -5900,6 +5902,7 @@ public class Notification implements Parcelable mGravity = wearableBundle.getInt(KEY_GRAVITY, DEFAULT_GRAVITY); mHintScreenTimeout = wearableBundle.getInt(KEY_HINT_SCREEN_TIMEOUT); mDismissalId = wearableBundle.getString(KEY_DISMISSAL_ID); + mBridgeTag = wearableBundle.getString(KEY_BRIDGE_TAG); } } @@ -5953,6 +5956,9 @@ public class Notification implements Parcelable if (mDismissalId != null) { wearableBundle.putString(KEY_DISMISSAL_ID, mDismissalId); } + if (mBridgeTag != null) { + wearableBundle.putString(KEY_BRIDGE_TAG, mBridgeTag); + } builder.getExtras().putBundle(EXTRA_WEARABLE_EXTENSIONS, wearableBundle); return builder; @@ -5974,6 +5980,7 @@ public class Notification implements Parcelable that.mGravity = this.mGravity; that.mHintScreenTimeout = this.mHintScreenTimeout; that.mDismissalId = this.mDismissalId; + that.mBridgeTag = this.mBridgeTag; return that; } @@ -6462,12 +6469,11 @@ public class Notification implements Parcelable } /** - * When you post a notification, if you set the dismissal id field, then when that - * notification is canceled, notifications on other wearables and the paired Android phone - * having that same dismissal id will also be canceled. Note that this only works if you - * have notification bridge mode set to NO_BRIDGING in your Wear app manifest. See + * Sets the dismissal id for this notification. If a notification is posted with a + * dismissal id, then when that notification is canceled, notifications on other wearables + * and the paired Android phone having that same dismissal id will also be canceled. See * Adding Wearable Features to - * Notifications for more information on how to use the bridge mode feature. + * Notifications for more information. * @param dismissalId the dismissal id of the notification. * @return this object for method chaining */ @@ -6484,6 +6490,27 @@ public class Notification implements Parcelable return mDismissalId; } + /** + * Sets a bridge tag for this notification. A bridge tag can be set for notifications + * posted from a phone to provide finer-grained control on what notifications are bridged + * to wearables. See Adding Wearable + * Features to Notifications for more information. + * @param bridgeTag the bridge tag of the notification. + * @return this object for method chaining + */ + public WearableExtender setBridgeTag(String bridgeTag) { + mBridgeTag = bridgeTag; + return this; + } + + /** + * Returns the bridge tag of the notification. + * @return the bridge tag or null if not present. + */ + public String getBridgeTag() { + return mBridgeTag; + } + private void setFlag(int mask, boolean value) { if (value) { mFlags |= mask;