summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2014-05-30 20:01:53 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-05-30 20:01:54 +0000
commitda44532b615b1a965c94cc43d68eca92fd2ef79d (patch)
treed9f284e85b871851a36298e00a0bb0ee68953744 /core
parentb0e25870dcfd4f8d3f067657566557a36b66c560 (diff)
parentbf06fa047954e85cf9df554d0b3d4eb4b19a950e (diff)
downloadframeworks_base-da44532b615b1a965c94cc43d68eca92fd2ef79d.zip
frameworks_base-da44532b615b1a965c94cc43d68eca92fd2ef79d.tar.gz
frameworks_base-da44532b615b1a965c94cc43d68eca92fd2ef79d.tar.bz2
Merge "Compatibility fix for apps that construct Notification.Builders early" into lmp-preview-dev
Diffstat (limited to 'core')
-rw-r--r--core/java/android/app/Notification.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 90aeaae..8dba1dc 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -1671,7 +1671,6 @@ public class Notification implements Parcelable
private Notification mPublicVersion = null;
private final NotificationColorUtil mColorUtil;
private ArrayList<String> mPeople;
- private boolean mPreQuantum;
private int mColor = COLOR_DEFAULT;
/**
@@ -1694,6 +1693,15 @@ public class Notification implements Parcelable
* object.
*/
public Builder(Context context) {
+ /*
+ * Important compatibility note!
+ * Some apps out in the wild create a Notification.Builder in their Activity subclass
+ * constructor for later use. At this point Activities - themselves subclasses of
+ * ContextWrapper - do not have their inner Context populated yet. This means that
+ * any calls to Context methods from within this constructor can cause NPEs in existing
+ * apps. Any data populated from mContext should therefore be populated lazily to
+ * preserve compatibility.
+ */
mContext = context;
// Set defaults to match the defaults of a Notification
@@ -1702,7 +1710,6 @@ public class Notification implements Parcelable
mPriority = PRIORITY_DEFAULT;
mPeople = new ArrayList<String>();
- mPreQuantum = context.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.L;
mColorUtil = NotificationColorUtil.getInstance();
}