Merge "DO NOT MERGE - Merge RP1A.201005.006"

This commit is contained in:
Xin Li
2020-10-06 20:17:27 +00:00
committed by Gerrit Code Review
7 changed files with 137 additions and 5 deletions

View File

@@ -559,6 +559,7 @@ void GraphicsStatsService::finishDumpInMemory(Dump* dump, AStatsEventList* data,
AStatsEvent_writeBool(event, !lastFullDay);
AStatsEvent_build(event);
}
delete dump;
}

View File

@@ -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(

View File

@@ -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);

View File

@@ -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) {

View File

@@ -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);
}
}
}
}

View File

@@ -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);
}
}

View File

@@ -2669,6 +2669,96 @@ public class PreferencesHelperTest extends UiServiceTestCase {
.isImportanceLockedByOEM());
}
@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);