Loading services/core/java/com/android/server/notification/RankingHelper.java +119 −99 Original line number Diff line number Diff line Loading @@ -232,8 +232,10 @@ public class RankingHelper implements RankingConfig { private Record getRecord(String pkg, int uid) { final String key = recordKey(pkg, uid); synchronized (mRecords) { return mRecords.get(key); } } private Record getOrCreateRecord(String pkg, int uid) { return getOrCreateRecord(pkg, uid, Loading @@ -243,7 +245,9 @@ public class RankingHelper implements RankingConfig { private Record getOrCreateRecord(String pkg, int uid, int importance, int priority, int visibility, boolean showBadge) { final String key = recordKey(pkg, uid); Record r = (uid == Record.UNKNOWN_UID) ? mRestoredWithoutUids.get(pkg) : mRecords.get(key); synchronized (mRecords) { Record r = (uid == Record.UNKNOWN_UID) ? mRestoredWithoutUids.get(pkg) : mRecords.get( key); if (r == null) { r = new Record(); r.pkg = pkg; Loading @@ -267,6 +271,7 @@ public class RankingHelper implements RankingConfig { } return r; } } private boolean shouldHaveDefaultChannel(Record r) throws NameNotFoundException { final int userId = UserHandle.getUserId(r.uid); Loading Loading @@ -346,6 +351,7 @@ public class RankingHelper implements RankingConfig { out.startTag(null, TAG_RANKING); out.attribute(null, ATT_VERSION, Integer.toString(XML_VERSION)); synchronized (mRecords) { final int N = mRecords.size(); for (int i = 0; i < N; i++) { final Record r = mRecords.valueAt(i); Loading Loading @@ -388,6 +394,7 @@ public class RankingHelper implements RankingConfig { out.endTag(null, TAG_PACKAGE); } } } out.endTag(null, TAG_RANKING); } Loading Loading @@ -814,7 +821,9 @@ public class RankingHelper implements RankingConfig { pw.println("per-package config:"); } pw.println("Records:"); synchronized (mRecords) { dumpRecords(pw, prefix, filter, mRecords); } pw.println("Restored without uid:"); dumpRecords(pw, prefix, filter, mRestoredWithoutUids); } Loading Loading @@ -870,6 +879,7 @@ public class RankingHelper implements RankingConfig { } catch (JSONException e) { // pass } synchronized (mRecords) { final int N = mRecords.size(); for (int i = 0; i < N; i++) { final Record r = mRecords.valueAt(i); Loading Loading @@ -902,6 +912,7 @@ public class RankingHelper implements RankingConfig { records.put(record); } } } try { ranking.put("records", records); } catch (JSONException e) { Loading Loading @@ -940,6 +951,7 @@ public class RankingHelper implements RankingConfig { } public Map<Integer, String> getPackageBans() { synchronized (mRecords) { final int N = mRecords.size(); ArrayMap<Integer, String> packageBans = new ArrayMap<>(N); for (int i = 0; i < N; i++) { Loading @@ -948,8 +960,10 @@ public class RankingHelper implements RankingConfig { packageBans.put(r.uid, r.pkg); } } return packageBans; } } /** * Dump only the channel information as structured JSON for the stats collector. Loading Loading @@ -981,6 +995,7 @@ public class RankingHelper implements RankingConfig { private Map<String, Integer> getPackageChannels() { ArrayMap<String, Integer> packageChannels = new ArrayMap<>(); synchronized (mRecords) { for (int i = 0; i < mRecords.size(); i++) { final Record r = mRecords.valueAt(i); int channelCount = 0; Loading @@ -991,6 +1006,7 @@ public class RankingHelper implements RankingConfig { } packageChannels.put(r.pkg, channelCount); } } return packageChannels; } Loading @@ -1006,7 +1022,9 @@ public class RankingHelper implements RankingConfig { for (int i = 0; i < size; i++) { final String pkg = pkgList[i]; final int uid = uidList[i]; synchronized (mRecords) { mRecords.remove(recordKey(pkg, uid)); } mRestoredWithoutUids.remove(pkg); updated = true; } Loading @@ -1018,7 +1036,9 @@ public class RankingHelper implements RankingConfig { try { r.uid = mPm.getPackageUidAsUser(r.pkg, changeUserId); mRestoredWithoutUids.remove(pkg); synchronized (mRecords) { mRecords.put(recordKey(r.pkg, r.uid), r); } updated = true; } catch (NameNotFoundException e) { // noop Loading Loading
services/core/java/com/android/server/notification/RankingHelper.java +119 −99 Original line number Diff line number Diff line Loading @@ -232,8 +232,10 @@ public class RankingHelper implements RankingConfig { private Record getRecord(String pkg, int uid) { final String key = recordKey(pkg, uid); synchronized (mRecords) { return mRecords.get(key); } } private Record getOrCreateRecord(String pkg, int uid) { return getOrCreateRecord(pkg, uid, Loading @@ -243,7 +245,9 @@ public class RankingHelper implements RankingConfig { private Record getOrCreateRecord(String pkg, int uid, int importance, int priority, int visibility, boolean showBadge) { final String key = recordKey(pkg, uid); Record r = (uid == Record.UNKNOWN_UID) ? mRestoredWithoutUids.get(pkg) : mRecords.get(key); synchronized (mRecords) { Record r = (uid == Record.UNKNOWN_UID) ? mRestoredWithoutUids.get(pkg) : mRecords.get( key); if (r == null) { r = new Record(); r.pkg = pkg; Loading @@ -267,6 +271,7 @@ public class RankingHelper implements RankingConfig { } return r; } } private boolean shouldHaveDefaultChannel(Record r) throws NameNotFoundException { final int userId = UserHandle.getUserId(r.uid); Loading Loading @@ -346,6 +351,7 @@ public class RankingHelper implements RankingConfig { out.startTag(null, TAG_RANKING); out.attribute(null, ATT_VERSION, Integer.toString(XML_VERSION)); synchronized (mRecords) { final int N = mRecords.size(); for (int i = 0; i < N; i++) { final Record r = mRecords.valueAt(i); Loading Loading @@ -388,6 +394,7 @@ public class RankingHelper implements RankingConfig { out.endTag(null, TAG_PACKAGE); } } } out.endTag(null, TAG_RANKING); } Loading Loading @@ -814,7 +821,9 @@ public class RankingHelper implements RankingConfig { pw.println("per-package config:"); } pw.println("Records:"); synchronized (mRecords) { dumpRecords(pw, prefix, filter, mRecords); } pw.println("Restored without uid:"); dumpRecords(pw, prefix, filter, mRestoredWithoutUids); } Loading Loading @@ -870,6 +879,7 @@ public class RankingHelper implements RankingConfig { } catch (JSONException e) { // pass } synchronized (mRecords) { final int N = mRecords.size(); for (int i = 0; i < N; i++) { final Record r = mRecords.valueAt(i); Loading Loading @@ -902,6 +912,7 @@ public class RankingHelper implements RankingConfig { records.put(record); } } } try { ranking.put("records", records); } catch (JSONException e) { Loading Loading @@ -940,6 +951,7 @@ public class RankingHelper implements RankingConfig { } public Map<Integer, String> getPackageBans() { synchronized (mRecords) { final int N = mRecords.size(); ArrayMap<Integer, String> packageBans = new ArrayMap<>(N); for (int i = 0; i < N; i++) { Loading @@ -948,8 +960,10 @@ public class RankingHelper implements RankingConfig { packageBans.put(r.uid, r.pkg); } } return packageBans; } } /** * Dump only the channel information as structured JSON for the stats collector. Loading Loading @@ -981,6 +995,7 @@ public class RankingHelper implements RankingConfig { private Map<String, Integer> getPackageChannels() { ArrayMap<String, Integer> packageChannels = new ArrayMap<>(); synchronized (mRecords) { for (int i = 0; i < mRecords.size(); i++) { final Record r = mRecords.valueAt(i); int channelCount = 0; Loading @@ -991,6 +1006,7 @@ public class RankingHelper implements RankingConfig { } packageChannels.put(r.pkg, channelCount); } } return packageChannels; } Loading @@ -1006,7 +1022,9 @@ public class RankingHelper implements RankingConfig { for (int i = 0; i < size; i++) { final String pkg = pkgList[i]; final int uid = uidList[i]; synchronized (mRecords) { mRecords.remove(recordKey(pkg, uid)); } mRestoredWithoutUids.remove(pkg); updated = true; } Loading @@ -1018,7 +1036,9 @@ public class RankingHelper implements RankingConfig { try { r.uid = mPm.getPackageUidAsUser(r.pkg, changeUserId); mRestoredWithoutUids.remove(pkg); synchronized (mRecords) { mRecords.put(recordKey(r.pkg, r.uid), r); } updated = true; } catch (NameNotFoundException e) { // noop Loading