From 78c4114101bdbd5cb4520ef4958b7b77d583bd4b Mon Sep 17 00:00:00 2001 From: "dooyoung.hwang" Date: Tue, 4 Oct 2016 18:55:31 +0900 Subject: [PATCH] Fix crashes after notifying bad notification 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 --- .../systemui/statusbar/BaseStatusBar.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 98957ddd5c002..e7bb24e236f01 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -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);