Deprecate notification fields

And move references to the deprecated fields to
NotificationRecord for testability.

Test: runtest systemui-notification
Change-Id: If3910dc78297ad66679b1efa380315127261a018
diff --git a/api/current.txt b/api/current.txt
index 2be6183..0ec22fa 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -5088,26 +5088,26 @@
     field public static final int FLAG_NO_CLEAR = 32; // 0x20
     field public static final int FLAG_ONGOING_EVENT = 2; // 0x2
     field public static final int FLAG_ONLY_ALERT_ONCE = 8; // 0x8
-    field public static final int FLAG_SHOW_LIGHTS = 1; // 0x1
+    field public static final deprecated int FLAG_SHOW_LIGHTS = 1; // 0x1
     field public static final java.lang.String INTENT_CATEGORY_NOTIFICATION_PREFERENCES = "android.intent.category.NOTIFICATION_PREFERENCES";
-    field public static final int PRIORITY_DEFAULT = 0; // 0x0
-    field public static final int PRIORITY_HIGH = 1; // 0x1
-    field public static final int PRIORITY_LOW = -1; // 0xffffffff
-    field public static final int PRIORITY_MAX = 2; // 0x2
-    field public static final int PRIORITY_MIN = -2; // 0xfffffffe
+    field public static final deprecated int PRIORITY_DEFAULT = 0; // 0x0
+    field public static final deprecated int PRIORITY_HIGH = 1; // 0x1
+    field public static final deprecated int PRIORITY_LOW = -1; // 0xffffffff
+    field public static final deprecated int PRIORITY_MAX = 2; // 0x2
+    field public static final deprecated int PRIORITY_MIN = -2; // 0xfffffffe
     field public static final deprecated int STREAM_DEFAULT = -1; // 0xffffffff
     field public static final int VISIBILITY_PRIVATE = 0; // 0x0
     field public static final int VISIBILITY_PUBLIC = 1; // 0x1
     field public static final int VISIBILITY_SECRET = -1; // 0xffffffff
     field public android.app.Notification.Action[] actions;
-    field public android.media.AudioAttributes audioAttributes;
+    field public deprecated android.media.AudioAttributes audioAttributes;
     field public deprecated int audioStreamType;
     field public deprecated android.widget.RemoteViews bigContentView;
     field public java.lang.String category;
     field public int color;
     field public android.app.PendingIntent contentIntent;
     field public deprecated android.widget.RemoteViews contentView;
-    field public int defaults;
+    field public deprecated int defaults;
     field public android.app.PendingIntent deleteIntent;
     field public android.os.Bundle extras;
     field public int flags;
@@ -5116,16 +5116,16 @@
     field public deprecated int icon;
     field public int iconLevel;
     field public deprecated android.graphics.Bitmap largeIcon;
-    field public int ledARGB;
-    field public int ledOffMS;
-    field public int ledOnMS;
+    field public deprecated int ledARGB;
+    field public deprecated int ledOffMS;
+    field public deprecated int ledOnMS;
     field public deprecated int number;
-    field public int priority;
+    field public deprecated int priority;
     field public android.app.Notification publicVersion;
-    field public android.net.Uri sound;
+    field public deprecated android.net.Uri sound;
     field public java.lang.CharSequence tickerText;
     field public deprecated android.widget.RemoteViews tickerView;
-    field public long[] vibrate;
+    field public deprecated long[] vibrate;
     field public int visibility;
     field public long when;
   }
@@ -5229,7 +5229,7 @@
     method public android.app.Notification.Builder setCustomBigContentView(android.widget.RemoteViews);
     method public android.app.Notification.Builder setCustomContentView(android.widget.RemoteViews);
     method public android.app.Notification.Builder setCustomHeadsUpContentView(android.widget.RemoteViews);
-    method public android.app.Notification.Builder setDefaults(int);
+    method public deprecated android.app.Notification.Builder setDefaults(int);
     method public android.app.Notification.Builder setDeleteIntent(android.app.PendingIntent);
     method public android.app.Notification.Builder setExtras(android.os.Bundle);
     method public android.app.Notification.Builder setFullScreenIntent(android.app.PendingIntent, boolean);
@@ -5237,12 +5237,12 @@
     method public android.app.Notification.Builder setGroupSummary(boolean);
     method public android.app.Notification.Builder setLargeIcon(android.graphics.Bitmap);
     method public android.app.Notification.Builder setLargeIcon(android.graphics.drawable.Icon);
-    method public android.app.Notification.Builder setLights(int, int, int);
+    method public deprecated android.app.Notification.Builder setLights(int, int, int);
     method public android.app.Notification.Builder setLocalOnly(boolean);
     method public deprecated android.app.Notification.Builder setNumber(int);
     method public android.app.Notification.Builder setOngoing(boolean);
     method public android.app.Notification.Builder setOnlyAlertOnce(boolean);
-    method public android.app.Notification.Builder setPriority(int);
+    method public deprecated android.app.Notification.Builder setPriority(int);
     method public android.app.Notification.Builder setProgress(int, int, boolean);
     method public android.app.Notification.Builder setPublicVersion(android.app.Notification);
     method public android.app.Notification.Builder setRemoteInputHistory(java.lang.CharSequence[]);
@@ -5251,16 +5251,16 @@
     method public android.app.Notification.Builder setSmallIcon(int, int);
     method public android.app.Notification.Builder setSmallIcon(android.graphics.drawable.Icon);
     method public android.app.Notification.Builder setSortKey(java.lang.String);
-    method public android.app.Notification.Builder setSound(android.net.Uri);
+    method public deprecated android.app.Notification.Builder setSound(android.net.Uri);
     method public deprecated android.app.Notification.Builder setSound(android.net.Uri, int);
-    method public android.app.Notification.Builder setSound(android.net.Uri, android.media.AudioAttributes);
+    method public deprecated android.app.Notification.Builder setSound(android.net.Uri, android.media.AudioAttributes);
     method public android.app.Notification.Builder setStyle(android.app.Notification.Style);
     method public android.app.Notification.Builder setSubText(java.lang.CharSequence);
     method public android.app.Notification.Builder setTicker(java.lang.CharSequence);
     method public deprecated android.app.Notification.Builder setTicker(java.lang.CharSequence, android.widget.RemoteViews);
     method public android.app.Notification.Builder setTimeout(long);
     method public android.app.Notification.Builder setUsesChronometer(boolean);
-    method public android.app.Notification.Builder setVibrate(long[]);
+    method public deprecated android.app.Notification.Builder setVibrate(long[]);
     method public android.app.Notification.Builder setVisibility(int);
     method public android.app.Notification.Builder setWhen(long);
   }
diff --git a/api/system-current.txt b/api/system-current.txt
index bc08f70..c23de1c 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -5251,26 +5251,26 @@
     field public static final int FLAG_NO_CLEAR = 32; // 0x20
     field public static final int FLAG_ONGOING_EVENT = 2; // 0x2
     field public static final int FLAG_ONLY_ALERT_ONCE = 8; // 0x8
-    field public static final int FLAG_SHOW_LIGHTS = 1; // 0x1
+    field public static final deprecated int FLAG_SHOW_LIGHTS = 1; // 0x1
     field public static final java.lang.String INTENT_CATEGORY_NOTIFICATION_PREFERENCES = "android.intent.category.NOTIFICATION_PREFERENCES";
-    field public static final int PRIORITY_DEFAULT = 0; // 0x0
-    field public static final int PRIORITY_HIGH = 1; // 0x1
-    field public static final int PRIORITY_LOW = -1; // 0xffffffff
-    field public static final int PRIORITY_MAX = 2; // 0x2
-    field public static final int PRIORITY_MIN = -2; // 0xfffffffe
+    field public static final deprecated int PRIORITY_DEFAULT = 0; // 0x0
+    field public static final deprecated int PRIORITY_HIGH = 1; // 0x1
+    field public static final deprecated int PRIORITY_LOW = -1; // 0xffffffff
+    field public static final deprecated int PRIORITY_MAX = 2; // 0x2
+    field public static final deprecated int PRIORITY_MIN = -2; // 0xfffffffe
     field public static final deprecated int STREAM_DEFAULT = -1; // 0xffffffff
     field public static final int VISIBILITY_PRIVATE = 0; // 0x0
     field public static final int VISIBILITY_PUBLIC = 1; // 0x1
     field public static final int VISIBILITY_SECRET = -1; // 0xffffffff
     field public android.app.Notification.Action[] actions;
-    field public android.media.AudioAttributes audioAttributes;
+    field public deprecated android.media.AudioAttributes audioAttributes;
     field public deprecated int audioStreamType;
     field public deprecated android.widget.RemoteViews bigContentView;
     field public java.lang.String category;
     field public int color;
     field public android.app.PendingIntent contentIntent;
     field public deprecated android.widget.RemoteViews contentView;
-    field public int defaults;
+    field public deprecated int defaults;
     field public android.app.PendingIntent deleteIntent;
     field public android.os.Bundle extras;
     field public int flags;
@@ -5279,16 +5279,16 @@
     field public deprecated int icon;
     field public int iconLevel;
     field public deprecated android.graphics.Bitmap largeIcon;
-    field public int ledARGB;
-    field public int ledOffMS;
-    field public int ledOnMS;
+    field public deprecated int ledARGB;
+    field public deprecated int ledOffMS;
+    field public deprecated int ledOnMS;
     field public deprecated int number;
-    field public int priority;
+    field public deprecated int priority;
     field public android.app.Notification publicVersion;
-    field public android.net.Uri sound;
+    field public deprecated android.net.Uri sound;
     field public java.lang.CharSequence tickerText;
     field public deprecated android.widget.RemoteViews tickerView;
-    field public long[] vibrate;
+    field public deprecated long[] vibrate;
     field public int visibility;
     field public long when;
   }
@@ -5392,7 +5392,7 @@
     method public android.app.Notification.Builder setCustomBigContentView(android.widget.RemoteViews);
     method public android.app.Notification.Builder setCustomContentView(android.widget.RemoteViews);
     method public android.app.Notification.Builder setCustomHeadsUpContentView(android.widget.RemoteViews);
-    method public android.app.Notification.Builder setDefaults(int);
+    method public deprecated android.app.Notification.Builder setDefaults(int);
     method public android.app.Notification.Builder setDeleteIntent(android.app.PendingIntent);
     method public android.app.Notification.Builder setExtras(android.os.Bundle);
     method public android.app.Notification.Builder setFullScreenIntent(android.app.PendingIntent, boolean);
@@ -5400,12 +5400,12 @@
     method public android.app.Notification.Builder setGroupSummary(boolean);
     method public android.app.Notification.Builder setLargeIcon(android.graphics.Bitmap);
     method public android.app.Notification.Builder setLargeIcon(android.graphics.drawable.Icon);
-    method public android.app.Notification.Builder setLights(int, int, int);
+    method public deprecated android.app.Notification.Builder setLights(int, int, int);
     method public android.app.Notification.Builder setLocalOnly(boolean);
     method public deprecated android.app.Notification.Builder setNumber(int);
     method public android.app.Notification.Builder setOngoing(boolean);
     method public android.app.Notification.Builder setOnlyAlertOnce(boolean);
-    method public android.app.Notification.Builder setPriority(int);
+    method public deprecated android.app.Notification.Builder setPriority(int);
     method public android.app.Notification.Builder setProgress(int, int, boolean);
     method public android.app.Notification.Builder setPublicVersion(android.app.Notification);
     method public android.app.Notification.Builder setRemoteInputHistory(java.lang.CharSequence[]);
@@ -5414,16 +5414,16 @@
     method public android.app.Notification.Builder setSmallIcon(int, int);
     method public android.app.Notification.Builder setSmallIcon(android.graphics.drawable.Icon);
     method public android.app.Notification.Builder setSortKey(java.lang.String);
-    method public android.app.Notification.Builder setSound(android.net.Uri);
+    method public deprecated android.app.Notification.Builder setSound(android.net.Uri);
     method public deprecated android.app.Notification.Builder setSound(android.net.Uri, int);
-    method public android.app.Notification.Builder setSound(android.net.Uri, android.media.AudioAttributes);
+    method public deprecated android.app.Notification.Builder setSound(android.net.Uri, android.media.AudioAttributes);
     method public android.app.Notification.Builder setStyle(android.app.Notification.Style);
     method public android.app.Notification.Builder setSubText(java.lang.CharSequence);
     method public android.app.Notification.Builder setTicker(java.lang.CharSequence);
     method public deprecated android.app.Notification.Builder setTicker(java.lang.CharSequence, android.widget.RemoteViews);
     method public android.app.Notification.Builder setTimeout(long);
     method public android.app.Notification.Builder setUsesChronometer(boolean);
-    method public android.app.Notification.Builder setVibrate(long[]);
+    method public deprecated android.app.Notification.Builder setVibrate(long[]);
     method public android.app.Notification.Builder setVisibility(int);
     method public android.app.Notification.Builder setWhen(long);
   }
diff --git a/api/test-current.txt b/api/test-current.txt
index 37505f5..d56a44d 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -5098,26 +5098,26 @@
     field public static final int FLAG_NO_CLEAR = 32; // 0x20
     field public static final int FLAG_ONGOING_EVENT = 2; // 0x2
     field public static final int FLAG_ONLY_ALERT_ONCE = 8; // 0x8
-    field public static final int FLAG_SHOW_LIGHTS = 1; // 0x1
+    field public static final deprecated int FLAG_SHOW_LIGHTS = 1; // 0x1
     field public static final java.lang.String INTENT_CATEGORY_NOTIFICATION_PREFERENCES = "android.intent.category.NOTIFICATION_PREFERENCES";
-    field public static final int PRIORITY_DEFAULT = 0; // 0x0
-    field public static final int PRIORITY_HIGH = 1; // 0x1
-    field public static final int PRIORITY_LOW = -1; // 0xffffffff
-    field public static final int PRIORITY_MAX = 2; // 0x2
-    field public static final int PRIORITY_MIN = -2; // 0xfffffffe
+    field public static final deprecated int PRIORITY_DEFAULT = 0; // 0x0
+    field public static final deprecated int PRIORITY_HIGH = 1; // 0x1
+    field public static final deprecated int PRIORITY_LOW = -1; // 0xffffffff
+    field public static final deprecated int PRIORITY_MAX = 2; // 0x2
+    field public static final deprecated int PRIORITY_MIN = -2; // 0xfffffffe
     field public static final deprecated int STREAM_DEFAULT = -1; // 0xffffffff
     field public static final int VISIBILITY_PRIVATE = 0; // 0x0
     field public static final int VISIBILITY_PUBLIC = 1; // 0x1
     field public static final int VISIBILITY_SECRET = -1; // 0xffffffff
     field public android.app.Notification.Action[] actions;
-    field public android.media.AudioAttributes audioAttributes;
+    field public deprecated android.media.AudioAttributes audioAttributes;
     field public deprecated int audioStreamType;
     field public deprecated android.widget.RemoteViews bigContentView;
     field public java.lang.String category;
     field public int color;
     field public android.app.PendingIntent contentIntent;
     field public deprecated android.widget.RemoteViews contentView;
-    field public int defaults;
+    field public deprecated int defaults;
     field public android.app.PendingIntent deleteIntent;
     field public android.os.Bundle extras;
     field public int flags;
@@ -5126,16 +5126,16 @@
     field public deprecated int icon;
     field public int iconLevel;
     field public deprecated android.graphics.Bitmap largeIcon;
-    field public int ledARGB;
-    field public int ledOffMS;
-    field public int ledOnMS;
+    field public deprecated int ledARGB;
+    field public deprecated int ledOffMS;
+    field public deprecated int ledOnMS;
     field public deprecated int number;
-    field public int priority;
+    field public deprecated int priority;
     field public android.app.Notification publicVersion;
-    field public android.net.Uri sound;
+    field public deprecated android.net.Uri sound;
     field public java.lang.CharSequence tickerText;
     field public deprecated android.widget.RemoteViews tickerView;
-    field public long[] vibrate;
+    field public deprecated long[] vibrate;
     field public int visibility;
     field public long when;
   }
@@ -5239,7 +5239,7 @@
     method public android.app.Notification.Builder setCustomBigContentView(android.widget.RemoteViews);
     method public android.app.Notification.Builder setCustomContentView(android.widget.RemoteViews);
     method public android.app.Notification.Builder setCustomHeadsUpContentView(android.widget.RemoteViews);
-    method public android.app.Notification.Builder setDefaults(int);
+    method public deprecated android.app.Notification.Builder setDefaults(int);
     method public android.app.Notification.Builder setDeleteIntent(android.app.PendingIntent);
     method public android.app.Notification.Builder setExtras(android.os.Bundle);
     method public android.app.Notification.Builder setFullScreenIntent(android.app.PendingIntent, boolean);
@@ -5247,12 +5247,12 @@
     method public android.app.Notification.Builder setGroupSummary(boolean);
     method public android.app.Notification.Builder setLargeIcon(android.graphics.Bitmap);
     method public android.app.Notification.Builder setLargeIcon(android.graphics.drawable.Icon);
-    method public android.app.Notification.Builder setLights(int, int, int);
+    method public deprecated android.app.Notification.Builder setLights(int, int, int);
     method public android.app.Notification.Builder setLocalOnly(boolean);
     method public deprecated android.app.Notification.Builder setNumber(int);
     method public android.app.Notification.Builder setOngoing(boolean);
     method public android.app.Notification.Builder setOnlyAlertOnce(boolean);
-    method public android.app.Notification.Builder setPriority(int);
+    method public deprecated android.app.Notification.Builder setPriority(int);
     method public android.app.Notification.Builder setProgress(int, int, boolean);
     method public android.app.Notification.Builder setPublicVersion(android.app.Notification);
     method public android.app.Notification.Builder setRemoteInputHistory(java.lang.CharSequence[]);
@@ -5261,16 +5261,16 @@
     method public android.app.Notification.Builder setSmallIcon(int, int);
     method public android.app.Notification.Builder setSmallIcon(android.graphics.drawable.Icon);
     method public android.app.Notification.Builder setSortKey(java.lang.String);
-    method public android.app.Notification.Builder setSound(android.net.Uri);
+    method public deprecated android.app.Notification.Builder setSound(android.net.Uri);
     method public deprecated android.app.Notification.Builder setSound(android.net.Uri, int);
-    method public android.app.Notification.Builder setSound(android.net.Uri, android.media.AudioAttributes);
+    method public deprecated android.app.Notification.Builder setSound(android.net.Uri, android.media.AudioAttributes);
     method public android.app.Notification.Builder setStyle(android.app.Notification.Style);
     method public android.app.Notification.Builder setSubText(java.lang.CharSequence);
     method public android.app.Notification.Builder setTicker(java.lang.CharSequence);
     method public deprecated android.app.Notification.Builder setTicker(java.lang.CharSequence, android.widget.RemoteViews);
     method public android.app.Notification.Builder setTimeout(long);
     method public android.app.Notification.Builder setUsesChronometer(boolean);
-    method public android.app.Notification.Builder setVibrate(long[]);
+    method public deprecated android.app.Notification.Builder setVibrate(long[]);
     method public android.app.Notification.Builder setVisibility(int);
     method public android.app.Notification.Builder setWhen(long);
   }
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index dc9506c..b7eda25 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -338,7 +338,9 @@
      * <p>
      * To play the default notification sound, see {@link #defaults}.
      * </p>
+     * @deprecated use {@link NotificationChannel#getSound()}.
      */
+    @Deprecated
     public Uri sound;
 
     /**
@@ -346,7 +348,7 @@
      * the default stream type for notifications be used.  Currently the
      * default stream type is {@link AudioManager#STREAM_NOTIFICATION}.
      *
-     * @deprecated Use {@link #audioAttributes} instead.
+     * @deprecated Use {@link NotificationChannel#getAudioAttributes()} instead.
      */
     @Deprecated
     public static final int STREAM_DEFAULT = -1;
@@ -371,7 +373,10 @@
 
     /**
      * The {@link AudioAttributes audio attributes} to use when playing the sound.
+     *
+     * @deprecated use {@link NotificationChannel#getAudioAttributes()} instead.
      */
+    @Deprecated
     public AudioAttributes audioAttributes = AUDIO_ATTRIBUTES_DEFAULT;
 
     /**
@@ -381,12 +386,10 @@
      * To vibrate the default pattern, see {@link #defaults}.
      * </p>
      *
-     * <p>
-     * A notification that vibrates is more likely to be presented as a heads-up notification.
-     * </p>
-     *
      * @see android.os.Vibrator#vibrate(long[],int)
+     * @deprecated use {@link NotificationChannel#getVibrationPattern()}.
      */
+    @Deprecated
     public long[] vibrate;
 
     /**
@@ -394,8 +397,10 @@
      *
      * @see #FLAG_SHOW_LIGHTS
      * @see #flags
+     * @deprecated use {@link NotificationChannel#shouldShowLights()}.
      */
     @ColorInt
+    @Deprecated
     public int ledARGB;
 
     /**
@@ -404,7 +409,9 @@
      *
      * @see #FLAG_SHOW_LIGHTS
      * @see #flags
+     * @deprecated use {@link NotificationChannel#shouldShowLights()}.
      */
+    @Deprecated
     public int ledOnMS;
 
     /**
@@ -413,7 +420,10 @@
      *
      * @see #FLAG_SHOW_LIGHTS
      * @see #flags
+     *
+     * @deprecated use {@link NotificationChannel#shouldShowLights()}.
      */
+    @Deprecated
     public int ledOffMS;
 
     /**
@@ -423,7 +433,12 @@
      * {@link #DEFAULT_VIBRATE}, {@link #DEFAULT_LIGHTS}. For all default
      * values, use {@link #DEFAULT_ALL}.
      * </p>
+     *
+     * @deprecated use {@link NotificationChannel#getSound()} and
+     * {@link NotificationChannel#shouldShowLights()} and
+     * {@link NotificationChannel#shouldVibrate()}.
      */
+    @Deprecated
     public int defaults;
 
     /**
@@ -443,7 +458,9 @@
      * <p>
      * The alpha channel must be set for forward compatibility.
      *
+     * @deprecated use {@link NotificationChannel#shouldShowLights()}.
      */
+    @Deprecated
     public static final int FLAG_SHOW_LIGHTS        = 0x00000001;
 
     /**
@@ -532,33 +549,48 @@
     /**
      * Default notification {@link #priority}. If your application does not prioritize its own
      * notifications, use this value for all notifications.
+     *
+     * @deprecated use {@link NotificationManager#IMPORTANCE_DEFAULT} instead.
      */
+    @Deprecated
     public static final int PRIORITY_DEFAULT = 0;
 
     /**
      * Lower {@link #priority}, for items that are less important. The UI may choose to show these
      * items smaller, or at a different position in the list, compared with your app's
      * {@link #PRIORITY_DEFAULT} items.
+     *
+     * @deprecated use {@link NotificationManager#IMPORTANCE_LOW} instead.
      */
+    @Deprecated
     public static final int PRIORITY_LOW = -1;
 
     /**
      * Lowest {@link #priority}; these items might not be shown to the user except under special
      * circumstances, such as detailed notification logs.
+     *
+     * @deprecated use {@link NotificationManager#IMPORTANCE_MIN} instead.
      */
+    @Deprecated
     public static final int PRIORITY_MIN = -2;
 
     /**
      * Higher {@link #priority}, for more important notifications or alerts. The UI may choose to
      * show these items larger, or at a different position in notification lists, compared with
      * your app's {@link #PRIORITY_DEFAULT} items.
+     *
+     * @deprecated use {@link NotificationManager#IMPORTANCE_HIGH} instead.
      */
+    @Deprecated
     public static final int PRIORITY_HIGH = 1;
 
     /**
      * Highest {@link #priority}, for your application's most important items that require the
      * user's prompt attention or input.
+     *
+     * @deprecated use {@link NotificationManager#IMPORTANCE_HIGH} instead.
      */
+    @Deprecated
     public static final int PRIORITY_MAX = 2;
 
     /**
@@ -575,8 +607,10 @@
      * as a heads-up notification.
      * </p>
      *
+     * @deprecated use {@link NotificationChannel#getImportance()} instead.
      */
     @Priority
+    @Deprecated
     public int priority;
 
     /**
@@ -2956,8 +2990,9 @@
          * It will be played using the {@link #AUDIO_ATTRIBUTES_DEFAULT default audio attributes}
          * for notifications.
          *
-         * @see Notification#sound
+         * @deprecated use {@link NotificationChannel#setSound(Uri, AudioAttributes)} instead.
          */
+        @Deprecated
         public Builder setSound(Uri sound) {
             mN.sound = sound;
             mN.audioAttributes = AUDIO_ATTRIBUTES_DEFAULT;
@@ -2969,8 +3004,7 @@
          *
          * See {@link android.media.AudioManager} for the <code>STREAM_</code> constants.
          *
-         * @deprecated use {@link #setSound(Uri, AudioAttributes)} instead.
-         * @see Notification#sound
+         * @deprecated use {@link NotificationChannel#setSound(Uri, AudioAttributes)}.
          */
         @Deprecated
         public Builder setSound(Uri sound, int streamType) {
@@ -2984,8 +3018,10 @@
          * Set the sound to play, along with specific {@link AudioAttributes audio attributes} to
          * use during playback.
          *
+         * @deprecated use {@link NotificationChannel#setSound(Uri, AudioAttributes)} instead.
          * @see Notification#sound
          */
+        @Deprecated
         public Builder setSound(Uri sound, AudioAttributes audioAttributes) {
             mN.sound = sound;
             mN.audioAttributes = audioAttributes;
@@ -3002,8 +3038,10 @@
          * A notification that vibrates is more likely to be presented as a heads-up notification.
          * </p>
          *
+         * @deprecated use {@link NotificationChannel#setVibrationPattern(long[])} instead.
          * @see Notification#vibrate
          */
+        @Deprecated
         public Builder setVibrate(long[] pattern) {
             mN.vibrate = pattern;
             return this;
@@ -3016,11 +3054,12 @@
 
          * Not all devices will honor all (or even any) of these values.
          *
-
+         * @deprecated use {@link NotificationChannel#setLights(boolean)} instead.
          * @see Notification#ledARGB
          * @see Notification#ledOnMS
          * @see Notification#ledOffMS
          */
+        @Deprecated
         public Builder setLights(@ColorInt int argb, int onMs, int offMs) {
             mN.ledARGB = argb;
             mN.ledOnMS = onMs;
@@ -3108,7 +3147,12 @@
          * {@link #DEFAULT_SOUND}, {@link #DEFAULT_VIBRATE}, {@link #DEFAULT_LIGHTS}.
          * <p>
          * For all default values, use {@link #DEFAULT_ALL}.
+         *
+         * @deprecated use {@link NotificationChannel#enableVibration(boolean)} and
+         * {@link NotificationChannel#setLights(boolean)} and
+         * {@link NotificationChannel#setSound(Uri, AudioAttributes)} instead.
          */
+        @Deprecated
         public Builder setDefaults(int defaults) {
             mN.defaults = defaults;
             return this;
@@ -3118,7 +3162,9 @@
          * Set the priority of this notification.
          *
          * @see Notification#priority
+         * @deprecated use {@link NotificationChannel#setImportance(int)} instead.
          */
+        @Deprecated
         public Builder setPriority(@Priority int pri) {
             mN.priority = pri;
             return this;
diff --git a/core/java/android/app/NotificationChannel.java b/core/java/android/app/NotificationChannel.java
index 58ff496..afcbcdf 100644
--- a/core/java/android/app/NotificationChannel.java
+++ b/core/java/android/app/NotificationChannel.java
@@ -347,12 +347,15 @@
     }
 
     /**
-     * Sets whether notification posted to this channel should vibrate.
+     * Sets the vibration pattern for notifications posted to this channel. If the provided
+     * pattern is valid (non-null, non-empty), will {@link #enableVibration(boolean)} enable
+     * vibration} as well. Otherwise, vibration will be disabled.
      *
      * Only modifiable before the channel is submitted to
      * {@link NotificationManager#notify(String, int, Notification)}.
      */
     public void setVibrationPattern(long[] vibrationPattern) {
+        this.mVibrationEnabled = vibrationPattern != null && vibrationPattern.length > 0;
         this.mVibration = vibrationPattern;
     }
 
diff --git a/core/java/android/service/notification/StatusBarNotification.java b/core/java/android/service/notification/StatusBarNotification.java
index 85baf4e..85bccf7 100644
--- a/core/java/android/service/notification/StatusBarNotification.java
+++ b/core/java/android/service/notification/StatusBarNotification.java
@@ -130,7 +130,7 @@
         }
         return user.getIdentifier() + "|" + pkg + "|" +
                 (group == null
-                        ? "p:" + notification.priority
+                        ? "c:" + notification.getChannel()
                         : "g:" + group);
     }
 
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index e557203..18ac76a 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -261,10 +261,6 @@
 
     private Light mNotificationLight;
     Light mAttentionLight;
-    private int mDefaultNotificationColor;
-    private int mDefaultNotificationLedOn;
-
-    private int mDefaultNotificationLedOff;
 
     private long[] mFallbackVibrationPattern;
     private boolean mUseAttentionLight;
@@ -1119,13 +1115,6 @@
         mNotificationLight = lightsManager.getLight(LightsManager.LIGHT_ID_NOTIFICATIONS);
         mAttentionLight = lightsManager.getLight(LightsManager.LIGHT_ID_ATTENTION);
 
-        mDefaultNotificationColor = resources.getColor(
-                R.color.config_defaultNotificationColor);
-        mDefaultNotificationLedOn = resources.getInteger(
-                R.integer.config_defaultNotificationLedOn);
-        mDefaultNotificationLedOff = resources.getInteger(
-                R.integer.config_defaultNotificationLedOff);
-
         mFallbackVibrationPattern = getLongArray(resources,
                 R.array.config_notificationFallbackVibePattern,
                 VIBRATE_PATTERN_MAXLEN,
@@ -3068,10 +3057,6 @@
             }
         }
 
-        // Sanitize inputs
-        notification.priority = clamp(notification.priority, Notification.PRIORITY_MIN,
-                Notification.PRIORITY_MAX);
-
         // setup local book-keeping
         final NotificationRecord r = new NotificationRecord(getContext(), n, channel);
         mHandler.post(new EnqueueNotificationRunnable(userId, r));
@@ -3429,7 +3414,7 @@
         // light
         // release the light
         boolean wasShowLights = mLights.remove(key);
-        if (shouldShowLights(record) && aboveThreshold
+        if (record.getLight() != null && aboveThreshold
                 && ((record.getSuppressedVisualEffects()
                 & NotificationListenerService.SUPPRESSED_EFFECT_SCREEN_OFF) == 0)) {
             mLights.add(key);
@@ -3456,11 +3441,6 @@
         }
     }
 
-    private boolean shouldShowLights(final NotificationRecord record) {
-        return record.getChannel().shouldShowLights()
-                || (record.getNotification().flags & Notification.FLAG_SHOW_LIGHTS) != 0;
-    }
-
     private boolean playSound(final NotificationRecord record, Uri soundUri) {
         boolean looping = (record.getNotification().flags & Notification.FLAG_INSISTENT) != 0;
         // do not play notifications if there is a user of exclusive audio focus
@@ -4237,20 +4217,11 @@
         if (ledNotification == null || mInCall || mScreenOn) {
             mNotificationLight.turnOff();
         } else {
-            final Notification ledno = ledNotification.sbn.getNotification();
-            int ledARGB = ledno.ledARGB;
-            int ledOnMS = ledno.ledOnMS;
-            int ledOffMS = ledno.ledOffMS;
-            if ((ledno.defaults & Notification.DEFAULT_LIGHTS) != 0
-                    || (ledno.flags & Notification.FLAG_SHOW_LIGHTS) == 0) {
-                ledARGB = mDefaultNotificationColor;
-                ledOnMS = mDefaultNotificationLedOn;
-                ledOffMS = mDefaultNotificationLedOff;
-            }
-            if (mNotificationPulseEnabled) {
+            NotificationRecord.Light light = ledNotification.getLight();
+            if (light != null && mNotificationPulseEnabled) {
                 // pulse repeatedly
-                mNotificationLight.setFlashing(ledARGB, Light.LIGHT_FLASH_TIMED,
-                        ledOnMS, ledOffMS);
+                mNotificationLight.setFlashing(light.color, Light.LIGHT_FLASH_TIMED,
+                        light.onMs, light.offMs);
             }
         }
     }
diff --git a/services/core/java/com/android/server/notification/NotificationRecord.java b/services/core/java/com/android/server/notification/NotificationRecord.java
index ed2da68..d26aa9e 100644
--- a/services/core/java/com/android/server/notification/NotificationRecord.java
+++ b/services/core/java/com/android/server/notification/NotificationRecord.java
@@ -122,6 +122,7 @@
     private ArrayList<SnoozeCriterion> mSnoozeCriteria;
     private boolean mShowBadge;
     private LogMaker mLogMaker;
+    private Light mLight;
 
     @VisibleForTesting
     public NotificationRecord(Context context, StatusBarNotification sbn,
@@ -140,6 +141,7 @@
         mVibration = calculateVibration();
         mAttributes = calculateAttributes();
         mImportance = calculateImportance();
+        mLight = calculateLights();
     }
 
     private boolean isPreChannelsNotification() {
@@ -175,6 +177,34 @@
         return sound;
     }
 
+    private Light calculateLights() {
+        int defaultLightColor = mContext.getResources().getColor(
+                com.android.internal.R.color.config_defaultNotificationColor);
+        int defaultLightOn = mContext.getResources().getInteger(
+                com.android.internal.R.integer.config_defaultNotificationLedOn);
+        int defaultLightOff = mContext.getResources().getInteger(
+                com.android.internal.R.integer.config_defaultNotificationLedOff);
+
+        Light light = getChannel().shouldShowLights() ? new Light(defaultLightColor,
+                defaultLightOn, defaultLightOff) : null;
+        if (mPreChannelsNotification
+                && (getChannel().getUserLockedFields()
+                & NotificationChannel.USER_LOCKED_LIGHTS) == 0) {
+            final Notification notification = sbn.getNotification();
+            if ((notification.flags & Notification.FLAG_SHOW_LIGHTS) != 0) {
+                light = new Light(notification.ledARGB, notification.ledOnMS,
+                        notification.ledOffMS);
+                if ((notification.defaults & Notification.DEFAULT_LIGHTS) != 0) {
+                    light = new Light(defaultLightColor, defaultLightOn,
+                            defaultLightOff);
+                }
+            } else {
+                light = null;
+            }
+        }
+        return light;
+    }
+
     private long[] calculateVibration() {
         long[] vibration;
         final long[] defaultVibration =  NotificationManagerService.getLongArray(
@@ -239,6 +269,8 @@
             n.priority = Notification.PRIORITY_MAX;
         }
 
+        n.priority = NotificationManagerService.clamp(n.priority, Notification.PRIORITY_MIN,
+                Notification.PRIORITY_MAX);
         switch (n.priority) {
             case Notification.PRIORITY_MIN:
                 requestedImportance = IMPORTANCE_MIN;
@@ -322,15 +354,7 @@
         pw.println(prefix + "  deleteIntent=" + notification.deleteIntent);
         pw.println(prefix + "  tickerText=" + notification.tickerText);
         pw.println(prefix + "  contentView=" + notification.contentView);
-        pw.println(prefix + String.format("  defaults=0x%08x flags=0x%08x",
-                notification.defaults, notification.flags));
-        pw.println(prefix + "  sound=" + notification.sound);
-        pw.println(prefix + "  audioStreamType=" + notification.audioStreamType);
-        pw.println(prefix + "  audioAttributes=" + notification.audioAttributes);
         pw.println(prefix + String.format("  color=0x%08x", notification.color));
-        pw.println(prefix + "  vibrate=" + Arrays.toString(notification.vibrate));
-        pw.println(prefix + String.format("  led=0x%08x onMs=%d offMs=%d",
-                notification.ledARGB, notification.ledOnMS, notification.ledOffMS));
         pw.println(prefix + "  timeout=" + TimeUtils.formatForLogging(notification.getTimeout()));
         if (notification.actions != null && notification.actions.length > 0) {
             pw.println(prefix + "  actions={");
@@ -398,12 +422,22 @@
         pw.println(prefix + "  mVisibleSinceMs=" + mVisibleSinceMs);
         pw.println(prefix + "  mUpdateTimeMs=" + mUpdateTimeMs);
         pw.println(prefix + "  mSuppressedVisualEffects= " + mSuppressedVisualEffects);
-        pw.println(prefix + "  notificationChannel= " + notification.getChannel());
+        if (mPreChannelsNotification) {
+            pw.println(prefix + String.format("  defaults=0x%08x flags=0x%08x",
+                    notification.defaults, notification.flags));
+            pw.println(prefix + "  n.sound=" + notification.sound);
+            pw.println(prefix + "  n.audioStreamType=" + notification.audioStreamType);
+            pw.println(prefix + "  n.audioAttributes=" + notification.audioAttributes);
+            pw.println(prefix + String.format("  led=0x%08x onMs=%d offMs=%d",
+                    notification.ledARGB, notification.ledOnMS, notification.ledOffMS));
+            pw.println(prefix + "  vibrate=" + Arrays.toString(notification.vibrate));
+        }
         pw.println(prefix + "  mSound= " + mSound);
         pw.println(prefix + "  mVibration= " + mVibration);
         pw.println(prefix + "  mAttributes= " + mAttributes);
+        pw.println(prefix + "  mLight= " + mLight);
         pw.println(prefix + "  mShowBadge=" + mShowBadge);
-        pw.println(prefix + "  channel=" + getChannel());
+        pw.println(prefix + "  effectiveNotificationChannel=" + getChannel());
         if (getPeopleOverride() != null) {
             pw.println(prefix + "  overridePeople= " + TextUtils.join(",", getPeopleOverride()));
         }
@@ -682,6 +716,10 @@
         return mShowBadge;
     }
 
+    public Light getLight() {
+        return mLight;
+    }
+
     public Uri getSound() {
         return mSound;
     }
@@ -730,4 +768,47 @@
     public LogMaker getLogMaker() {
         return getLogMaker(System.currentTimeMillis());
     }
+
+    @VisibleForTesting
+    static final class Light {
+        public final int color;
+        public final int onMs;
+        public final int offMs;
+
+        public Light(int color, int onMs, int offMs) {
+            this.color = color;
+            this.onMs = onMs;
+            this.offMs = offMs;
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            if (this == o) return true;
+            if (o == null || getClass() != o.getClass()) return false;
+
+            Light light = (Light) o;
+
+            if (color != light.color) return false;
+            if (onMs != light.onMs) return false;
+            return offMs == light.offMs;
+
+        }
+
+        @Override
+        public int hashCode() {
+            int result = color;
+            result = 31 * result + onMs;
+            result = 31 * result + offMs;
+            return result;
+        }
+
+        @Override
+        public String toString() {
+            return "Light{" +
+                    "color=" + color +
+                    ", onMs=" + onMs +
+                    ", offMs=" + offMs +
+                    '}';
+        }
+    }
 }
diff --git a/services/tests/notification/src/com/android/server/notification/BuzzBeepBlinkTest.java b/services/tests/notification/src/com/android/server/notification/BuzzBeepBlinkTest.java
index d91e8df..9202cce 100644
--- a/services/tests/notification/src/com/android/server/notification/BuzzBeepBlinkTest.java
+++ b/services/tests/notification/src/com/android/server/notification/BuzzBeepBlinkTest.java
@@ -333,17 +333,6 @@
     }
 
     @Test
-    public void testLightsFromChannel() throws Exception {
-        NotificationRecord r = getQuietNotification();
-        r.setImportance(NotificationManager.IMPORTANCE_DEFAULT, "for testing");
-        r.getChannel().setLights(true);
-
-        mService.buzzBeepBlinkLocked(r);
-
-        verifyLights();
-    }
-
-    @Test
     public void testBeepInsistently() throws Exception {
         NotificationRecord r = getInsistentBeepyNotification();
 
@@ -353,16 +342,6 @@
     }
 
     @Test
-    public void testChannelNoOverwriteCustomLights() throws Exception {
-        NotificationRecord r = getCustomLightsNotification();
-        r.getChannel().setLights(true);
-
-        mService.buzzBeepBlinkLocked(r);
-
-        verifyCustomLights();
-    }
-
-    @Test
     public void testNoInterruptionForMin() throws Exception {
         NotificationRecord r = getBeepyNotification();
         r.setImportance(NotificationManager.IMPORTANCE_MIN, "foo");
@@ -562,7 +541,7 @@
     }
 
     @Test
-    public void testVibratTwice() throws Exception {
+    public void testVibrateTwice() throws Exception {
         NotificationRecord r = getBuzzyNotification();
 
         // set up internal state
diff --git a/services/tests/notification/src/com/android/server/notification/NotificationRecordTest.java b/services/tests/notification/src/com/android/server/notification/NotificationRecordTest.java
index 2ab1f30..0ec368f 100644
--- a/services/tests/notification/src/com/android/server/notification/NotificationRecordTest.java
+++ b/services/tests/notification/src/com/android/server/notification/NotificationRecordTest.java
@@ -16,7 +16,9 @@
 package com.android.server.notification;
 
 import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
 import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertNull;
 import static junit.framework.Assert.assertTrue;
 
 import static org.mockito.Matchers.anyInt;
@@ -76,7 +78,6 @@
     final ApplicationInfo legacy = new ApplicationInfo();
     final ApplicationInfo upgrade = new ApplicationInfo();
 
-
     private static final long[] CUSTOM_VIBRATION = new long[] {
             300, 400, 300, 400, 300, 400, 300, 400, 300, 400, 300, 400,
             300, 400, 300, 400, 300, 400, 300, 400, 300, 400, 300, 400,
@@ -87,6 +88,8 @@
             .setContentType(AudioAttributes.CONTENT_TYPE_UNKNOWN)
             .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
             .build();
+    private static final NotificationRecord.Light CUSTOM_LIGHT =
+            new NotificationRecord.Light(1, 2, 3);
 
     @Before
     public void setUp() {
@@ -105,7 +108,7 @@
     }
 
     private StatusBarNotification getNotification(boolean preO, boolean noisy, boolean defaultSound,
-            boolean buzzy, boolean defaultVibration) {
+            boolean buzzy, boolean defaultVibration, boolean lights, boolean defaultLights) {
         when(mMockContext.getApplicationInfo()).thenReturn(preO ? legacy : upgrade);
         final Builder builder = new Builder(mMockContext)
                 .setContentTitle("foo")
@@ -129,6 +132,17 @@
                 channel.setVibrationPattern(CUSTOM_CHANNEL_VIBRATION);
             }
         }
+        if (lights) {
+            if (defaultLights) {
+                defaults |= Notification.DEFAULT_LIGHTS;
+            } else {
+                builder.setLights(CUSTOM_LIGHT.color, CUSTOM_LIGHT.onMs, CUSTOM_LIGHT.offMs);
+            }
+            channel.setLights(true);
+        } else {
+            channel.setLights(false);
+        }
+
         builder.setDefaults(defaults);
         if (!preO) {
             builder.setChannel(channelId);
@@ -154,7 +168,8 @@
         defaultChannel.setSound(null, null);
         // pre upgrade, default sound.
         StatusBarNotification sbn = getNotification(true /*preO */, true /* noisy */,
-                true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */);
+                true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */,
+                false /* lights */, false /*defaultLights */);
 
         NotificationRecord record = new NotificationRecord(mMockContext, sbn, defaultChannel);
         assertEquals(Settings.System.DEFAULT_NOTIFICATION_URI, record.getSound());
@@ -166,7 +181,8 @@
         defaultChannel.setSound(null, null);
         // pre upgrade, custom sound.
         StatusBarNotification sbn = getNotification(true /*preO */, true /* noisy */,
-                false /* defaultSound */, false /* buzzy */, false /* defaultBuzz */);
+                false /* defaultSound */, false /* buzzy */, false /* defaultBuzz */,
+                false /* lights */, false /*defaultLights */);
 
         NotificationRecord record = new NotificationRecord(mMockContext, sbn, defaultChannel);
         assertEquals(CUSTOM_SOUND, record.getSound());
@@ -179,7 +195,8 @@
         defaultChannel.lockFields(NotificationChannel.USER_LOCKED_SOUND);
         // pre upgrade, default sound.
         StatusBarNotification sbn = getNotification(true /*preO */, true /* noisy */,
-                true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */);
+                true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */,
+                false /* lights */, false /*defaultLights */);
 
         NotificationRecord record = new NotificationRecord(mMockContext, sbn, defaultChannel);
         assertEquals(CUSTOM_SOUND, record.getSound());
@@ -191,7 +208,8 @@
         channel.setSound(CUSTOM_SOUND, CUSTOM_ATTRIBUTES);
         // post upgrade, default sound.
         StatusBarNotification sbn = getNotification(false /*preO */, true /* noisy */,
-                true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */);
+                true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */,
+                false /* lights */, false /*defaultLights */);
 
         NotificationRecord record = new NotificationRecord(mMockContext, sbn, channel);
         assertEquals(CUSTOM_SOUND, record.getSound());
@@ -203,7 +221,8 @@
         defaultChannel.enableVibration(false);
         // pre upgrade, default vibration.
         StatusBarNotification sbn = getNotification(true /*preO */, false /* noisy */,
-                false /* defaultSound */, true /* buzzy */, true /* defaultBuzz */);
+                false /* defaultSound */, true /* buzzy */, true /* defaultBuzz */,
+                false /* lights */, false /*defaultLights */);
 
         NotificationRecord record = new NotificationRecord(mMockContext, sbn, defaultChannel);
         assertNotNull(record.getVibration());
@@ -214,7 +233,8 @@
         defaultChannel.enableVibration(false);
         // pre upgrade, custom vibration.
         StatusBarNotification sbn = getNotification(true /*preO */, false /* noisy */,
-                false /* defaultSound */, true /* buzzy */, false /* defaultBuzz */);
+                false /* defaultSound */, true /* buzzy */, false /* defaultBuzz */,
+                false /* lights */, false /*defaultLights */);
 
         NotificationRecord record = new NotificationRecord(mMockContext, sbn, defaultChannel);
         assertEquals(CUSTOM_VIBRATION, record.getVibration());
@@ -226,7 +246,8 @@
         defaultChannel.lockFields(NotificationChannel.USER_LOCKED_VIBRATION);
         // pre upgrade, custom vibration.
         StatusBarNotification sbn = getNotification(true /*preO */, false /* noisy */,
-                false /* defaultSound */, true /* buzzy */, false /* defaultBuzz */);
+                false /* defaultSound */, true /* buzzy */, false /* defaultBuzz */,
+                false /* lights */, false /*defaultLights */);
 
         NotificationRecord record = new NotificationRecord(mMockContext, sbn, defaultChannel);
         assertTrue(!Objects.equals(CUSTOM_VIBRATION, record.getVibration()));
@@ -237,7 +258,8 @@
         channel.enableVibration(true);
         // post upgrade, custom vibration.
         StatusBarNotification sbn = getNotification(false /*preO */, false /* noisy */,
-                false /* defaultSound */, true /* buzzy */, false /* defaultBuzz */);
+                false /* defaultSound */, true /* buzzy */, false /* defaultBuzz */,
+                false /* lights */, false /*defaultLights */);
 
         NotificationRecord record = new NotificationRecord(mMockContext, sbn, channel);
         assertEquals(CUSTOM_CHANNEL_VIBRATION, record.getVibration());
@@ -246,7 +268,8 @@
     @Test
     public void testImportance_preUpgrade() throws Exception {
         StatusBarNotification sbn = getNotification(true /*preO */, true /* noisy */,
-                true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */);
+                true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */,
+                false /* lights */, false /*defaultLights */);
         NotificationRecord record = new NotificationRecord(mMockContext, sbn, defaultChannel);
         assertEquals(NotificationManager.IMPORTANCE_HIGH, record.getImportance());
     }
@@ -256,7 +279,8 @@
         defaultChannel.setImportance(NotificationManager.IMPORTANCE_LOW);
         defaultChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
         StatusBarNotification sbn = getNotification(true /*preO */, true /* noisy */,
-                true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */);
+                true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */,
+                false /* lights */, false /*defaultLights */);
 
         NotificationRecord record = new NotificationRecord(mMockContext, sbn, defaultChannel);
         assertEquals(NotificationManager.IMPORTANCE_LOW, record.getImportance());
@@ -265,8 +289,67 @@
     @Test
     public void testImportance_upgrade() throws Exception {
         StatusBarNotification sbn = getNotification(false /*preO */, true /* noisy */,
-                true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */);
+                true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */,
+                false /* lights */, false /*defaultLights */);
         NotificationRecord record = new NotificationRecord(mMockContext, sbn, channel);
         assertEquals(NotificationManager.IMPORTANCE_DEFAULT, record.getImportance());
     }
+
+    @Test
+    public void testLights_preUpgrade_noLight() throws Exception {
+        StatusBarNotification sbn = getNotification(true /*preO */, true /* noisy */,
+                true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */,
+                false /* lights */, false /*defaultLights */);
+        NotificationRecord record = new NotificationRecord(mMockContext, sbn, defaultChannel);
+        assertNull(record.getLight());
+    }
+
+
+    @Test
+    public void testLights_preUpgrade() throws Exception {
+        StatusBarNotification sbn = getNotification(true /*preO */, true /* noisy */,
+                true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */,
+                true /* lights */, false /*defaultLights */);
+        NotificationRecord record = new NotificationRecord(mMockContext, sbn, defaultChannel);
+        assertEquals(CUSTOM_LIGHT, record.getLight());
+    }
+
+    @Test
+    public void testLights_locked_preUpgrade() throws Exception {
+        defaultChannel.setLights(true);
+        defaultChannel.lockFields(NotificationChannel.USER_LOCKED_LIGHTS);
+        StatusBarNotification sbn = getNotification(true /*preO */, true /* noisy */,
+                true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */,
+                true /* lights */, false /*defaultLights */);
+
+        NotificationRecord record = new NotificationRecord(mMockContext, sbn, defaultChannel);
+        assertFalse(CUSTOM_LIGHT.equals(record.getLight()));
+    }
+
+    @Test
+    public void testLights_upgrade() throws Exception {
+        int defaultLightColor = mMockContext.getResources().getColor(
+                com.android.internal.R.color.config_defaultNotificationColor);
+        int defaultLightOn = mMockContext.getResources().getInteger(
+                com.android.internal.R.integer.config_defaultNotificationLedOn);
+        int defaultLightOff = mMockContext.getResources().getInteger(
+                com.android.internal.R.integer.config_defaultNotificationLedOff);
+
+        NotificationRecord.Light expected = new NotificationRecord.Light(
+                defaultLightColor, defaultLightOn, defaultLightOff);
+        StatusBarNotification sbn = getNotification(false /*preO */, true /* noisy */,
+                true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */,
+                true /* lights */, false /*defaultLights */);
+        NotificationRecord record = new NotificationRecord(mMockContext, sbn, channel);
+        assertEquals(expected, record.getLight());
+    }
+
+    @Test
+    public void testLights_upgrade_noLight() throws Exception {
+        StatusBarNotification sbn = getNotification(false /*preO */, true /* noisy */,
+                true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */,
+                false /* lights */, false /*defaultLights */);
+        NotificationRecord record = new NotificationRecord(mMockContext, sbn, defaultChannel);
+        assertNull(record.getLight());
+    }
 }