Loading core/res/res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -2764,4 +2764,7 @@ and followed the pertinent sections of the escrow tokens section of the CDD <link>--> <!-- TODO(b/35230407) complete the link field --> <bool name="config_allowEscrowTokenForTrustAgent">false</bool> <!-- Colon separated list of package names that should be granted Notification Listener access --> <string name="config_defaultListenerAccessPackages" translatable="false"></string> </resources> core/res/res/values/symbols.xml +2 −0 Original line number Diff line number Diff line Loading @@ -2878,4 +2878,6 @@ <java-symbol type="string" name="alert_windows_notification_turn_off_action" /> <java-symbol type="drawable" name="alert_window_layer" /> <!-- Colon separated list of package names that should be granted Notification Listener access --> <java-symbol type="string" name="config_defaultListenerAccessPackages" /> </resources> packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +60 −2 Original line number Diff line number Diff line Loading @@ -32,6 +32,8 @@ import android.content.pm.ApplicationInfo; import android.content.pm.IPackageManager; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.content.pm.UserInfo; import android.database.Cursor; import android.database.MatrixCursor; Loading @@ -58,7 +60,7 @@ import android.os.UserHandle; import android.os.UserManager; import android.os.UserManagerInternal; import android.provider.Settings; import android.provider.Settings.Global; import android.service.notification.NotificationListenerService; import android.text.TextUtils; import android.util.ArrayMap; import android.util.ArraySet; Loading Loading @@ -2735,7 +2737,7 @@ public class SettingsProvider extends ContentProvider { } private final class UpgradeController { private static final int SETTINGS_VERSION = 140; private static final int SETTINGS_VERSION = 141; private final int mUserId; Loading Loading @@ -3204,6 +3206,62 @@ public class SettingsProvider extends ContentProvider { currentVersion = 140; } if (currentVersion == 140) { // Version 141: One-time grant of notification listener privileges // to packages specified in overlay. String defaultListenerAccess = getContext().getResources().getString( com.android.internal.R.string.config_defaultListenerAccessPackages); if (defaultListenerAccess != null) { StringBuffer newListeners = new StringBuffer(); for (String whitelistPkg : defaultListenerAccess.split(":")) { // Gather all notification listener components for candidate pkgs. Intent serviceIntent = new Intent(NotificationListenerService.SERVICE_INTERFACE) .setPackage(whitelistPkg); List<ResolveInfo> installedServices = getContext().getPackageManager().queryIntentServicesAsUser( serviceIntent, PackageManager.GET_SERVICES | PackageManager.GET_META_DATA | PackageManager.MATCH_DIRECT_BOOT_AWARE | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, userId); for (int i = 0, count = installedServices.size(); i < count; i++) { ResolveInfo resolveInfo = installedServices.get(i); ServiceInfo info = resolveInfo.serviceInfo; if (!android.Manifest.permission.BIND_NOTIFICATION_LISTENER_SERVICE .equals(info.permission)) { continue; } newListeners.append(":") .append(info.getComponentName().flattenToString()); } } if (newListeners.length() > 0) { final SettingsState secureSetting = getSecureSettingsLocked(userId); final Setting existingSetting = secureSetting.getSettingLocked( Settings.Secure.ENABLED_NOTIFICATION_LISTENERS); if (existingSetting.isNull()) { secureSetting.insertSettingLocked( Settings.Secure.ENABLED_NOTIFICATION_LISTENERS, newListeners.toString(), null, true, SettingsState.SYSTEM_PACKAGE_NAME); } else { StringBuilder currentSetting = new StringBuilder(existingSetting.getValue()); currentSetting.append(newListeners.toString()); secureSetting.updateSettingLocked( Settings.Secure.ENABLED_NOTIFICATION_LISTENERS, currentSetting.toString(), null, true, SettingsState.SYSTEM_PACKAGE_NAME); } } } currentVersion = 141; } if (currentVersion != newVersion) { Slog.wtf("SettingsProvider", "warning: upgrading settings database to version " + newVersion + " left it at " Loading Loading
core/res/res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -2764,4 +2764,7 @@ and followed the pertinent sections of the escrow tokens section of the CDD <link>--> <!-- TODO(b/35230407) complete the link field --> <bool name="config_allowEscrowTokenForTrustAgent">false</bool> <!-- Colon separated list of package names that should be granted Notification Listener access --> <string name="config_defaultListenerAccessPackages" translatable="false"></string> </resources>
core/res/res/values/symbols.xml +2 −0 Original line number Diff line number Diff line Loading @@ -2878,4 +2878,6 @@ <java-symbol type="string" name="alert_windows_notification_turn_off_action" /> <java-symbol type="drawable" name="alert_window_layer" /> <!-- Colon separated list of package names that should be granted Notification Listener access --> <java-symbol type="string" name="config_defaultListenerAccessPackages" /> </resources>
packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +60 −2 Original line number Diff line number Diff line Loading @@ -32,6 +32,8 @@ import android.content.pm.ApplicationInfo; import android.content.pm.IPackageManager; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.content.pm.UserInfo; import android.database.Cursor; import android.database.MatrixCursor; Loading @@ -58,7 +60,7 @@ import android.os.UserHandle; import android.os.UserManager; import android.os.UserManagerInternal; import android.provider.Settings; import android.provider.Settings.Global; import android.service.notification.NotificationListenerService; import android.text.TextUtils; import android.util.ArrayMap; import android.util.ArraySet; Loading Loading @@ -2735,7 +2737,7 @@ public class SettingsProvider extends ContentProvider { } private final class UpgradeController { private static final int SETTINGS_VERSION = 140; private static final int SETTINGS_VERSION = 141; private final int mUserId; Loading Loading @@ -3204,6 +3206,62 @@ public class SettingsProvider extends ContentProvider { currentVersion = 140; } if (currentVersion == 140) { // Version 141: One-time grant of notification listener privileges // to packages specified in overlay. String defaultListenerAccess = getContext().getResources().getString( com.android.internal.R.string.config_defaultListenerAccessPackages); if (defaultListenerAccess != null) { StringBuffer newListeners = new StringBuffer(); for (String whitelistPkg : defaultListenerAccess.split(":")) { // Gather all notification listener components for candidate pkgs. Intent serviceIntent = new Intent(NotificationListenerService.SERVICE_INTERFACE) .setPackage(whitelistPkg); List<ResolveInfo> installedServices = getContext().getPackageManager().queryIntentServicesAsUser( serviceIntent, PackageManager.GET_SERVICES | PackageManager.GET_META_DATA | PackageManager.MATCH_DIRECT_BOOT_AWARE | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, userId); for (int i = 0, count = installedServices.size(); i < count; i++) { ResolveInfo resolveInfo = installedServices.get(i); ServiceInfo info = resolveInfo.serviceInfo; if (!android.Manifest.permission.BIND_NOTIFICATION_LISTENER_SERVICE .equals(info.permission)) { continue; } newListeners.append(":") .append(info.getComponentName().flattenToString()); } } if (newListeners.length() > 0) { final SettingsState secureSetting = getSecureSettingsLocked(userId); final Setting existingSetting = secureSetting.getSettingLocked( Settings.Secure.ENABLED_NOTIFICATION_LISTENERS); if (existingSetting.isNull()) { secureSetting.insertSettingLocked( Settings.Secure.ENABLED_NOTIFICATION_LISTENERS, newListeners.toString(), null, true, SettingsState.SYSTEM_PACKAGE_NAME); } else { StringBuilder currentSetting = new StringBuilder(existingSetting.getValue()); currentSetting.append(newListeners.toString()); secureSetting.updateSettingLocked( Settings.Secure.ENABLED_NOTIFICATION_LISTENERS, currentSetting.toString(), null, true, SettingsState.SYSTEM_PACKAGE_NAME); } } } currentVersion = 141; } if (currentVersion != newVersion) { Slog.wtf("SettingsProvider", "warning: upgrading settings database to version " + newVersion + " left it at " Loading