OSDN Git Service

Fix crashes after notifying bad notification
authordooyoung.hwang <dooyoung.hwang@lge.com>
Tue, 4 Oct 2016 09:55:31 +0000 (18:55 +0900)
committerSelim Cinek <cinek@google.com>
Wed, 12 Oct 2016 00:37:23 +0000 (17:37 -0700)
If applications whose targetSDK is below N build notification
without contentView, contentView is created at inside of build()
function in Notification.Builder. If application apply
removeAllViews to this contentView, Notification View can have
id 'status_bar_latest_event_content' without standard layout of
notification. When inflating this notification, SystemUI try to wrap
it with NotificationTemplateViewWrapper(its id is
'status_bar_latest_event_content'), and crash, because it does not
have expected views.

Test: Install & launch attached apk in below BUG url to N devices,
and try to make notification by clicking 'do it' button.

https://code.google.com/p/android/issues/detail?id=223479

Bug:31948446
Change-Id: Ifcdc79a117613e8afd2e8ed098afd211cceabf88

packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java

index 98957dd..e7bb24e 100644 (file)
@@ -1706,6 +1706,23 @@ public abstract class BaseStatusBar extends SystemUI implements
                         sbn.getPackageContext(mContext),
                         contentContainerPublic, mOnClickHandler);
             }
+
+            if (contentViewLocal != null) {
+                contentViewLocal.setIsRootNamespace(true);
+                contentContainer.setContractedChild(contentViewLocal);
+            }
+            if (bigContentViewLocal != null) {
+                bigContentViewLocal.setIsRootNamespace(true);
+                contentContainer.setExpandedChild(bigContentViewLocal);
+            }
+            if (headsUpContentViewLocal != null) {
+                headsUpContentViewLocal.setIsRootNamespace(true);
+                contentContainer.setHeadsUpChild(headsUpContentViewLocal);
+            }
+            if (publicViewLocal != null) {
+                publicViewLocal.setIsRootNamespace(true);
+                contentContainerPublic.setContractedChild(publicViewLocal);
+            }
         }
         catch (RuntimeException e) {
             final String ident = sbn.getPackageName() + "/0x" + Integer.toHexString(sbn.getId());
@@ -1713,23 +1730,6 @@ public abstract class BaseStatusBar extends SystemUI implements
             return false;
         }
 
-        if (contentViewLocal != null) {
-            contentViewLocal.setIsRootNamespace(true);
-            contentContainer.setContractedChild(contentViewLocal);
-        }
-        if (bigContentViewLocal != null) {
-            bigContentViewLocal.setIsRootNamespace(true);
-            contentContainer.setExpandedChild(bigContentViewLocal);
-        }
-        if (headsUpContentViewLocal != null) {
-            headsUpContentViewLocal.setIsRootNamespace(true);
-            contentContainer.setHeadsUpChild(headsUpContentViewLocal);
-        }
-        if (publicViewLocal != null) {
-            publicViewLocal.setIsRootNamespace(true);
-            contentContainerPublic.setContractedChild(publicViewLocal);
-        }
-
         // Extract target SDK version.
         try {
             ApplicationInfo info = pmUser.getApplicationInfo(sbn.getPackageName(), 0);