Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1994f418 authored by Adam Powell's avatar Adam Powell Committed by Android Git Automerger
Browse files

am d4a453ce: Merge "Compatibility fix for apps that construct...

am d4a453ce: Merge "Compatibility fix for apps that construct Notification.Builders early" into lmp-preview-dev

* commit 'd4a453ce132c926c136015e6799b0528656c9409':
  Compatibility fix for apps that construct Notification.Builders early
parents 1a745106 da44532b
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -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();
        }