diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2020-10-05 21:00:23 -0700 |
---|---|---|
committer | Xin Li <delphij@google.com> | 2020-10-06 16:49:03 +0000 |
commit | e325f5b1ae1bca229592776e2d2ae26a8c88c68f (patch) | |
tree | f83f147f144d7e165d63f33c70207dd92423fa7f | |
parent | 8dcc0164cc8a8bbdc81da6537cda5a4eca9ede68 (diff) | |
parent | f5184a65fa134718444376ff8eb7944717990a3a (diff) |
DO NOT MERGE - Merge RP1A.201005.006
Bug: 168212094
Merged-In: Iac1f8eafc4d25a5a7c8b6d8eed3f6686705fc2fb
Change-Id: Id9e5f7c81b0629d5b4dde43271d0120be43f16be
7 files changed, 137 insertions, 5 deletions
diff --git a/libs/hwui/service/GraphicsStatsService.cpp b/libs/hwui/service/GraphicsStatsService.cpp index 644d5fbd5bf9..e4198017aee0 100644 --- a/libs/hwui/service/GraphicsStatsService.cpp +++ b/libs/hwui/service/GraphicsStatsService.cpp @@ -559,6 +559,7 @@ void GraphicsStatsService::finishDumpInMemory(Dump* dump, AStatsEventList* data, AStatsEvent_writeBool(event, !lastFullDay); AStatsEvent_build(event); } + delete dump; } diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotNotificationsController.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotNotificationsController.java index fbcd6ba0ff47..42dde4064a97 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotNotificationsController.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotNotificationsController.java @@ -205,7 +205,8 @@ public class ScreenshotNotificationsController { mPublicNotificationBuilder .setContentTitle(mResources.getString(R.string.screenshot_saved_title)) .setContentText(mResources.getString(R.string.screenshot_saved_text)) - .setContentIntent(PendingIntent.getActivity(mContext, 0, launchIntent, 0)) + .setContentIntent(PendingIntent + .getActivity(mContext, 0, launchIntent, PendingIntent.FLAG_IMMUTABLE)) .setWhen(now) .setAutoCancel(true) .setColor(mContext.getColor( @@ -213,7 +214,8 @@ public class ScreenshotNotificationsController { mNotificationBuilder .setContentTitle(mResources.getString(R.string.screenshot_saved_title)) .setContentText(mResources.getString(R.string.screenshot_saved_text)) - .setContentIntent(PendingIntent.getActivity(mContext, 0, launchIntent, 0)) + .setContentIntent(PendingIntent + .getActivity(mContext, 0, launchIntent, PendingIntent.FLAG_IMMUTABLE)) .setWhen(now) .setAutoCancel(true) .setColor(mContext.getColor( diff --git a/packages/SystemUI/src/com/android/systemui/util/leak/LeakReporter.java b/packages/SystemUI/src/com/android/systemui/util/leak/LeakReporter.java index b25df5f9c07f..5e7280840bb9 100644 --- a/packages/SystemUI/src/com/android/systemui/util/leak/LeakReporter.java +++ b/packages/SystemUI/src/com/android/systemui/util/leak/LeakReporter.java @@ -104,9 +104,13 @@ public class LeakReporter { .setContentText(String.format( "SystemUI has detected %d leaked objects. Tap to send", garbageCount)) .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb) - .setContentIntent(PendingIntent.getActivityAsUser(mContext, 0, + .setContentIntent(PendingIntent.getActivityAsUser( + mContext, + 0, getIntent(hprofFile, dumpFile), - PendingIntent.FLAG_UPDATE_CURRENT, null, UserHandle.CURRENT)); + PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE, + null, + UserHandle.CURRENT)); notiMan.notify(TAG, 0, builder.build()); } catch (IOException e) { Log.e(TAG, "Couldn't dump heap for leak", e); diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 09c0ba37028a..d990c1e9fbe1 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -3318,6 +3318,10 @@ public class ActivityManagerService extends IActivityManager.Stub @Override public boolean setProcessMemoryTrimLevel(String process, int userId, int level) throws RemoteException { + if (!isCallerShell()) { + EventLog.writeEvent(0x534e4554, 160390416, Binder.getCallingUid(), ""); + throw new SecurityException("Only shell can call it"); + } synchronized (this) { final ProcessRecord app = findProcessLocked(process, userId, "setProcessMemoryTrimLevel"); if (app == null) { diff --git a/services/core/java/com/android/server/notification/PreferencesHelper.java b/services/core/java/com/android/server/notification/PreferencesHelper.java index bc78d66037fe..c3cb42f95cc6 100644 --- a/services/core/java/com/android/server/notification/PreferencesHelper.java +++ b/services/core/java/com/android/server/notification/PreferencesHelper.java @@ -75,6 +75,7 @@ import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -173,6 +174,8 @@ public class PreferencesHelper implements RankingConfig { private boolean mAllowInvalidShortcuts = false; + private Map<String, List<String>> mOemLockedApps = new HashMap(); + public PreferencesHelper(Context context, PackageManager pm, RankingHandler rankingHandler, ZenModeHelper zenHelper, NotificationChannelLogger notificationChannelLogger, AppOpsManager appOpsManager, @@ -314,6 +317,12 @@ public class PreferencesHelper implements RankingConfig { } channel.setImportanceLockedByCriticalDeviceFunction( r.defaultAppLockedImportance); + channel.setImportanceLockedByOEM(r.oemLockedImportance); + if (!channel.isImportanceLockedByOEM()) { + if (r.oemLockedChannels.contains(channel.getId())) { + channel.setImportanceLockedByOEM(true); + } + } boolean isInvalidShortcutChannel = channel.getConversationId() != null && channel.getConversationId().contains( @@ -396,6 +405,14 @@ public class PreferencesHelper implements RankingConfig { r.visibility = visibility; r.showBadge = showBadge; r.bubblePreference = bubblePreference; + if (mOemLockedApps.containsKey(r.pkg)) { + List<String> channels = mOemLockedApps.get(r.pkg); + if (channels == null || channels.isEmpty()) { + r.oemLockedImportance = true; + } else { + r.oemLockedChannels = channels; + } + } try { createDefaultChannelIfNeededLocked(r); @@ -1149,8 +1166,10 @@ public class PreferencesHelper implements RankingConfig { String channelId = appSplit.length == 2 ? appSplit[1] : null; synchronized (mPackagePreferences) { + boolean foundApp = false; for (PackagePreferences r : mPackagePreferences.values()) { if (r.pkg.equals(appName)) { + foundApp = true; if (channelId == null) { // lock all channels for the app r.oemLockedImportance = true; @@ -1168,6 +1187,14 @@ public class PreferencesHelper implements RankingConfig { } } } + if (!foundApp) { + List<String> channels = + mOemLockedApps.getOrDefault(appName, new ArrayList<>()); + if (channelId != null) { + channels.add(channelId); + } + mOemLockedApps.put(appName, channels); + } } } } diff --git a/services/core/java/com/android/server/pm/BackgroundDexOptService.java b/services/core/java/com/android/server/pm/BackgroundDexOptService.java index 0dfa081e7695..48ec9b4b502d 100644 --- a/services/core/java/com/android/server/pm/BackgroundDexOptService.java +++ b/services/core/java/com/android/server/pm/BackgroundDexOptService.java @@ -337,6 +337,7 @@ public class BackgroundDexOptService extends JobService { private int idleOptimizePackages(PackageManagerService pm, ArraySet<String> pkgs, long lowStorageThreshold) { ArraySet<String> updatedPackages = new ArraySet<>(); + ArraySet<String> updatedPackagesDueToSecondaryDex = new ArraySet<>(); try { final boolean supportSecondaryDex = supportSecondaryDex(); @@ -391,11 +392,14 @@ public class BackgroundDexOptService extends JobService { } int secondaryResult = optimizePackages(pm, pkgs, lowStorageThreshold, - /*isForPrimaryDex*/ false, updatedPackages); + /*isForPrimaryDex*/ false, updatedPackagesDueToSecondaryDex); return secondaryResult; } finally { // Always let the pinner service know about changes. notifyPinService(updatedPackages); + // Only notify IORap the primary dex opt, because we don't want to + // invalidate traces unnecessary due to b/161633001 and that it's + // better to have a trace than no trace at all. notifyPackagesUpdated(updatedPackages); } } diff --git a/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java index 4dc8ad9d0a98..a118e0df1338 100644 --- a/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java @@ -2670,6 +2670,96 @@ public class PreferencesHelperTest extends UiServiceTestCase { } @Test + public void testLockChannelsForOEM_onlyGivenPkg_appDoesNotExistYet() { + mHelper.lockChannelsForOEM(new String[] {PKG_O}); + + NotificationChannel a = new NotificationChannel("a", "a", IMPORTANCE_HIGH); + NotificationChannel b = new NotificationChannel("b", "b", IMPORTANCE_LOW); + mHelper.createNotificationChannel(PKG_O, 3, a, true, false); + mHelper.createNotificationChannel(PKG_N_MR1, 30, b, false, false); + + assertTrue(mHelper.getNotificationChannel(PKG_O, 3, a.getId(), false) + .isImportanceLockedByOEM()); + assertFalse(mHelper.getNotificationChannel(PKG_N_MR1, 30, b.getId(), false) + .isImportanceLockedByOEM()); + } + + @Test + public void testLockChannelsForOEM_channelSpecific_appDoesNotExistYet() { + mHelper.lockChannelsForOEM(new String[] {PKG_O + ":b", PKG_O + ":c"}); + + NotificationChannel a = new NotificationChannel("a", "a", IMPORTANCE_HIGH); + NotificationChannel b = new NotificationChannel("b", "b", IMPORTANCE_LOW); + NotificationChannel c = new NotificationChannel("c", "c", IMPORTANCE_DEFAULT); + // different uids, same package + mHelper.createNotificationChannel(PKG_O, 3, a, true, false); + mHelper.createNotificationChannel(PKG_O, 3, b, false, false); + mHelper.createNotificationChannel(PKG_O, 30, c, true, true); + + assertFalse(mHelper.getNotificationChannel(PKG_O, 3, a.getId(), false) + .isImportanceLockedByOEM()); + assertTrue(mHelper.getNotificationChannel(PKG_O, 3, b.getId(), false) + .isImportanceLockedByOEM()); + assertTrue(mHelper.getNotificationChannel(PKG_O, 30, c.getId(), false) + .isImportanceLockedByOEM()); + } + + @Test + public void testLockChannelsForOEM_onlyGivenPkg_appDoesNotExistYet_restoreData() + throws Exception { + mHelper.lockChannelsForOEM(new String[] {PKG_O}); + + final String xml = "<ranking version=\"1\">\n" + + "<package name=\"" + PKG_O + "\" uid=\"" + UID_O + "\" >\n" + + "<channel id=\"a\" name=\"a\" importance=\"3\"/>" + + "<channel id=\"b\" name=\"b\" importance=\"3\"/>" + + "</package>" + + "<package name=\"" + PKG_N_MR1 + "\" uid=\"" + UID_N_MR1 + "\" >\n" + + "<channel id=\"a\" name=\"a\" importance=\"3\"/>" + + "<channel id=\"b\" name=\"b\" importance=\"3\"/>" + + "</package>" + + "</ranking>"; + XmlPullParser parser = Xml.newPullParser(); + parser.setInput(new BufferedInputStream(new ByteArrayInputStream(xml.getBytes())), + null); + parser.nextTag(); + mHelper.readXml(parser, false, UserHandle.USER_ALL); + + assertTrue(mHelper.getNotificationChannel(PKG_O, UID_O, "a", false) + .isImportanceLockedByOEM()); + assertFalse(mHelper.getNotificationChannel(PKG_N_MR1, UID_N_MR1, "b", false) + .isImportanceLockedByOEM()); + } + + @Test + public void testLockChannelsForOEM_channelSpecific_appDoesNotExistYet_restoreData() + throws Exception { + mHelper.lockChannelsForOEM(new String[] {PKG_O + ":b", PKG_O + ":c"}); + + final String xml = "<ranking version=\"1\">\n" + + "<package name=\"" + PKG_O + "\" uid=\"" + 3 + "\" >\n" + + "<channel id=\"a\" name=\"a\" importance=\"3\"/>" + + "<channel id=\"b\" name=\"b\" importance=\"3\"/>" + + "</package>" + + "<package name=\"" + PKG_O + "\" uid=\"" + 30 + "\" >\n" + + "<channel id=\"c\" name=\"c\" importance=\"3\"/>" + + "</package>" + + "</ranking>"; + XmlPullParser parser = Xml.newPullParser(); + parser.setInput(new BufferedInputStream(new ByteArrayInputStream(xml.getBytes())), + null); + parser.nextTag(); + mHelper.readXml(parser, false, UserHandle.USER_ALL); + + assertFalse(mHelper.getNotificationChannel(PKG_O, 3, "a", false) + .isImportanceLockedByOEM()); + assertTrue(mHelper.getNotificationChannel(PKG_O, 3, "b", false) + .isImportanceLockedByOEM()); + assertTrue(mHelper.getNotificationChannel(PKG_O, 30, "c", false) + .isImportanceLockedByOEM()); + } + + @Test public void testLockChannelsForOEM_channelSpecific_clearData() { NotificationChannel a = new NotificationChannel("a", "a", IMPORTANCE_HIGH); mHelper.getImportance(PKG_O, UID_O); |