Merge "Get rid of unnecessary policy file saves" into qt-dev
am: ffc7647e57
Change-Id: I69c5eb5ced58b21144c228f1fefac75688b59384
This commit is contained in:
@@ -1281,7 +1281,6 @@ public class NotificationManagerService extends SystemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mHandler.scheduleOnPackageChanged(removingPackage, changeUserId, pkgList, uidList);
|
mHandler.scheduleOnPackageChanged(removingPackage, changeUserId, pkgList, uidList);
|
||||||
handleSavePolicyFile();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -6264,13 +6263,16 @@ public class NotificationManagerService extends SystemService {
|
|||||||
|
|
||||||
private void handleOnPackageChanged(boolean removingPackage, int changeUserId,
|
private void handleOnPackageChanged(boolean removingPackage, int changeUserId,
|
||||||
String[] pkgList, int[] uidList) {
|
String[] pkgList, int[] uidList) {
|
||||||
|
boolean preferencesChanged = removingPackage;
|
||||||
mListeners.onPackagesChanged(removingPackage, pkgList, uidList);
|
mListeners.onPackagesChanged(removingPackage, pkgList, uidList);
|
||||||
mAssistants.onPackagesChanged(removingPackage, pkgList, uidList);
|
mAssistants.onPackagesChanged(removingPackage, pkgList, uidList);
|
||||||
mConditionProviders.onPackagesChanged(removingPackage, pkgList, uidList);
|
mConditionProviders.onPackagesChanged(removingPackage, pkgList, uidList);
|
||||||
mPreferencesHelper.onPackagesChanged(
|
preferencesChanged |= mPreferencesHelper.onPackagesChanged(
|
||||||
removingPackage, changeUserId, pkgList, uidList);
|
removingPackage, changeUserId, pkgList, uidList);
|
||||||
|
if (preferencesChanged) {
|
||||||
handleSavePolicyFile();
|
handleSavePolicyFile();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected class WorkerHandler extends Handler
|
protected class WorkerHandler extends Handler
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -334,33 +334,35 @@ public class PreferencesHelper implements RankingConfig {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteDefaultChannelIfNeededLocked(PackagePreferences r) throws
|
private boolean deleteDefaultChannelIfNeededLocked(PackagePreferences r) throws
|
||||||
PackageManager.NameNotFoundException {
|
PackageManager.NameNotFoundException {
|
||||||
if (!r.channels.containsKey(NotificationChannel.DEFAULT_CHANNEL_ID)) {
|
if (!r.channels.containsKey(NotificationChannel.DEFAULT_CHANNEL_ID)) {
|
||||||
// Not present
|
// Not present
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldHaveDefaultChannel(r)) {
|
if (shouldHaveDefaultChannel(r)) {
|
||||||
// Keep the default channel until upgraded.
|
// Keep the default channel until upgraded.
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove Default Channel.
|
// Remove Default Channel.
|
||||||
r.channels.remove(NotificationChannel.DEFAULT_CHANNEL_ID);
|
r.channels.remove(NotificationChannel.DEFAULT_CHANNEL_ID);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createDefaultChannelIfNeededLocked(PackagePreferences r) throws
|
private boolean createDefaultChannelIfNeededLocked(PackagePreferences r) throws
|
||||||
PackageManager.NameNotFoundException {
|
PackageManager.NameNotFoundException {
|
||||||
if (r.channels.containsKey(NotificationChannel.DEFAULT_CHANNEL_ID)) {
|
if (r.channels.containsKey(NotificationChannel.DEFAULT_CHANNEL_ID)) {
|
||||||
r.channels.get(NotificationChannel.DEFAULT_CHANNEL_ID).setName(mContext.getString(
|
r.channels.get(NotificationChannel.DEFAULT_CHANNEL_ID).setName(mContext.getString(
|
||||||
com.android.internal.R.string.default_notification_channel_label));
|
com.android.internal.R.string.default_notification_channel_label));
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!shouldHaveDefaultChannel(r)) {
|
if (!shouldHaveDefaultChannel(r)) {
|
||||||
// Keep the default channel until upgraded.
|
// Keep the default channel until upgraded.
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create Default Channel
|
// Create Default Channel
|
||||||
@@ -381,6 +383,8 @@ public class PreferencesHelper implements RankingConfig {
|
|||||||
channel.lockFields(NotificationChannel.USER_LOCKED_VISIBILITY);
|
channel.lockFields(NotificationChannel.USER_LOCKED_VISIBILITY);
|
||||||
}
|
}
|
||||||
r.channels.put(channel.getId(), channel);
|
r.channels.put(channel.getId(), channel);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeXml(XmlSerializer out, boolean forBackup, int userId) throws IOException {
|
public void writeXml(XmlSerializer out, boolean forBackup, int userId) throws IOException {
|
||||||
@@ -1687,10 +1691,10 @@ public class PreferencesHelper implements RankingConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPackagesChanged(boolean removingPackage, int changeUserId, String[] pkgList,
|
public boolean onPackagesChanged(boolean removingPackage, int changeUserId, String[] pkgList,
|
||||||
int[] uidList) {
|
int[] uidList) {
|
||||||
if (pkgList == null || pkgList.length == 0) {
|
if (pkgList == null || pkgList.length == 0) {
|
||||||
return; // nothing to do
|
return false; // nothing to do
|
||||||
}
|
}
|
||||||
boolean updated = false;
|
boolean updated = false;
|
||||||
if (removingPackage) {
|
if (removingPackage) {
|
||||||
@@ -1727,8 +1731,8 @@ public class PreferencesHelper implements RankingConfig {
|
|||||||
PackagePreferences fullPackagePreferences = getPackagePreferencesLocked(pkg,
|
PackagePreferences fullPackagePreferences = getPackagePreferencesLocked(pkg,
|
||||||
mPm.getPackageUidAsUser(pkg, changeUserId));
|
mPm.getPackageUidAsUser(pkg, changeUserId));
|
||||||
if (fullPackagePreferences != null) {
|
if (fullPackagePreferences != null) {
|
||||||
createDefaultChannelIfNeededLocked(fullPackagePreferences);
|
updated |= createDefaultChannelIfNeededLocked(fullPackagePreferences);
|
||||||
deleteDefaultChannelIfNeededLocked(fullPackagePreferences);
|
updated |= deleteDefaultChannelIfNeededLocked(fullPackagePreferences);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
@@ -1739,6 +1743,7 @@ public class PreferencesHelper implements RankingConfig {
|
|||||||
if (updated) {
|
if (updated) {
|
||||||
updateConfig();
|
updateConfig();
|
||||||
}
|
}
|
||||||
|
return updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearData(String pkg, int uid) {
|
public void clearData(String pkg, int uid) {
|
||||||
|
|||||||
Reference in New Issue
Block a user