Loading core/java/android/app/Notification.java +3 −3 Original line number Diff line number Diff line Loading @@ -195,7 +195,7 @@ public class Notification implements Parcelable * <p> * Avoids spamming the system with overly large strings such as full e-mails. */ private static final int MAX_CHARSEQUENCE_LENGTH = 5 * 1024; private static final int MAX_CHARSEQUENCE_LENGTH = 1024; /** * Maximum entries of reply text that are accepted by Builder and friends. Loading Loading @@ -7240,7 +7240,7 @@ public class Notification implements Parcelable */ public Message(@NonNull CharSequence text, long timestamp, @Nullable Person sender, boolean remoteInputHistory) { mText = text; mText = safeCharSequence(text); mTimestamp = timestamp; mSender = sender; mRemoteInputHistory = remoteInputHistory; Loading Loading @@ -7350,7 +7350,7 @@ public class Notification implements Parcelable bundle.putLong(KEY_TIMESTAMP, mTimestamp); if (mSender != null) { // Legacy listeners need this bundle.putCharSequence(KEY_SENDER, mSender.getName()); bundle.putCharSequence(KEY_SENDER, safeCharSequence(mSender.getName())); bundle.putParcelable(KEY_SENDER_PERSON, mSender); } if (mDataMimeType != null) { Loading core/java/android/net/NetworkSpecifier.java +26 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ package android.net; /** * Describes specific properties of a network for use in a {@link NetworkRequest}. * Describes specific properties of a requested network for use in a {@link NetworkRequest}. * * Applications cannot instantiate this class by themselves, but can obtain instances of * subclasses of this class via other APIs. Loading Loading @@ -49,4 +49,29 @@ public abstract class NetworkSpecifier { public void assertValidFromUid(int requestorUid) { // empty } /** * Optional method which can be overridden by concrete implementations of NetworkSpecifier to * perform any redaction of information from the NetworkSpecifier, e.g. if it contains * sensitive information. The default implementation simply returns the object itself - i.e. * no information is redacted. A concrete implementation may return a modified (copy) of the * NetworkSpecifier, or even return a null to fully remove all information. * <p> * This method is relevant to NetworkSpecifier objects used by agents - those are shared with * apps by default. Some agents may store sensitive matching information in the specifier, * e.g. a Wi-Fi SSID (which should not be shared since it may leak location). Those classes * can redact to a null. Other agents use the Network Specifier to share public information * with apps - those should not be redacted. * <p> * The default implementation redacts no information. * * @return A NetworkSpecifier object to be passed along to the requesting app. * * @hide */ public NetworkSpecifier redact() { // TODO (b/122160111): convert default to null once all platform NetworkSpecifiers // implement this method. return this; } } core/java/android/os/LocaleList.java +6 −5 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.util.proto.ProtoOutputStream; import com.android.internal.annotations.GuardedBy; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; Loading Loading @@ -171,18 +172,18 @@ public final class LocaleList implements Parcelable { /** * Creates a new {@link LocaleList}. * * If two or more same locales are passed, the repeated locales will be dropped. * <p>For empty lists of {@link Locale} items it is better to use {@link #getEmptyLocaleList()}, * which returns a pre-constructed empty list.</p> * * @throws NullPointerException if any of the input locales is <code>null</code>. * @throws IllegalArgumentException if any of the input locales repeat. */ public LocaleList(@NonNull Locale... list) { if (list.length == 0) { mList = sEmptyList; mStringRepresentation = ""; } else { final Locale[] localeList = new Locale[list.length]; final ArrayList<Locale> localeList = new ArrayList<>(); final HashSet<Locale> seenLocales = new HashSet<Locale>(); final StringBuilder sb = new StringBuilder(); for (int i = 0; i < list.length; i++) { Loading @@ -190,10 +191,10 @@ public final class LocaleList implements Parcelable { if (l == null) { throw new NullPointerException("list[" + i + "] is null"); } else if (seenLocales.contains(l)) { throw new IllegalArgumentException("list[" + i + "] is a repetition"); // Dropping duplicated locale entries. } else { final Locale localeClone = (Locale) l.clone(); localeList[i] = localeClone; localeList.add(localeClone); sb.append(localeClone.toLanguageTag()); if (i < list.length - 1) { sb.append(','); Loading @@ -201,7 +202,7 @@ public final class LocaleList implements Parcelable { seenLocales.add(localeClone); } } mList = localeList; mList = localeList.toArray(new Locale[localeList.size()]); mStringRepresentation = sb.toString(); } } Loading services/core/java/com/android/server/ConnectivityService.java +5 −1 Original line number Diff line number Diff line Loading @@ -1434,6 +1434,9 @@ public class ConnectivityService extends IConnectivityManager.Stub newNc.setUids(null); newNc.setSSID(null); } if (newNc.getNetworkSpecifier() != null) { newNc.setNetworkSpecifier(newNc.getNetworkSpecifier().redact()); } return newNc; } Loading Loading @@ -5186,7 +5189,8 @@ public class ConnectivityService extends IConnectivityManager.Stub } switch (notificationType) { case ConnectivityManager.CALLBACK_AVAILABLE: { putParcelable(bundle, new NetworkCapabilities(networkAgent.networkCapabilities)); putParcelable(bundle, networkCapabilitiesRestrictedForCallerPermissions( networkAgent.networkCapabilities, nri.mPid, nri.mUid)); putParcelable(bundle, new LinkProperties(networkAgent.linkProperties)); break; } Loading services/core/java/com/android/server/pm/PackageManagerService.java +23 −11 Original line number Diff line number Diff line Loading @@ -3787,14 +3787,10 @@ public class PackageManagerService extends IPackageManager.Stub Iterator<ResolveInfo> iter = matches.iterator(); while (iter.hasNext()) { final ResolveInfo rInfo = iter.next(); final PackageSetting ps = mSettings.mPackages.get(rInfo.activityInfo.packageName); if (ps != null) { final PermissionsState permissionsState = ps.getPermissionsState(); if (permissionsState.hasPermission(Manifest.permission.INSTALL_PACKAGES, 0) || Build.IS_ENG) { if (checkPermission(Manifest.permission.INSTALL_PACKAGES, rInfo.activityInfo.packageName, 0) == PERMISSION_GRANTED || Build.IS_ENG) { continue; } } iter.remove(); } if (matches.size() == 0) { Loading Loading @@ -4036,8 +4032,24 @@ public class PackageManagerService extends IPackageManager.Stub final int[] gids = (flags & PackageManager.GET_GIDS) == 0 ? EMPTY_INT_ARRAY : permissionsState.computeGids(userId); // Compute granted permissions only if package has requested permissions final Set<String> permissions = ArrayUtils.isEmpty(p.requestedPermissions) Set<String> permissions = ArrayUtils.isEmpty(p.requestedPermissions) ? Collections.<String>emptySet() : permissionsState.getPermissions(userId); if (state.instantApp) { permissions = new ArraySet<>(permissions); permissions.removeIf(permissionName -> { BasePermission permission = mPermissionManager.getPermissionTEMP( permissionName); if (permission == null) { return true; } if (!permission.isInstant()) { EventLog.writeEvent(0x534e4554, "140256621", UserHandle.getUid(userId, ps.appId), permissionName); return true; } return false; }); } PackageInfo packageInfo = mayFakeSignature(p, PackageParser.generatePackageInfo(p, gids, flags, ps.firstInstallTime, ps.lastUpdateTime, permissions, state, userId), Loading Loading @@ -8054,10 +8066,9 @@ public class PackageManagerService extends IPackageManager.Stub private void addPackageHoldingPermissions(ArrayList<PackageInfo> list, PackageSetting ps, String[] permissions, boolean[] tmp, int flags, int userId) { int numMatch = 0; final PermissionsState permissionsState = ps.getPermissionsState(); for (int i=0; i<permissions.length; i++) { final String permission = permissions[i]; if (permissionsState.hasPermission(permission, userId)) { if (checkPermission(permission, ps.name, userId) == PERMISSION_GRANTED) { tmp[i] = true; numMatch++; } else { Loading Loading @@ -19176,7 +19187,8 @@ public class PackageManagerService extends IPackageManager.Stub } final int userId = user == null ? UserHandle.USER_ALL : user.getIdentifier(); if (ps.getPermissionsState().hasPermission(Manifest.permission.SUSPEND_APPS, userId)) { if (checkPermission(Manifest.permission.SUSPEND_APPS, packageName, userId) == PERMISSION_GRANTED) { unsuspendForSuspendingPackage(packageName, userId); } Loading
core/java/android/app/Notification.java +3 −3 Original line number Diff line number Diff line Loading @@ -195,7 +195,7 @@ public class Notification implements Parcelable * <p> * Avoids spamming the system with overly large strings such as full e-mails. */ private static final int MAX_CHARSEQUENCE_LENGTH = 5 * 1024; private static final int MAX_CHARSEQUENCE_LENGTH = 1024; /** * Maximum entries of reply text that are accepted by Builder and friends. Loading Loading @@ -7240,7 +7240,7 @@ public class Notification implements Parcelable */ public Message(@NonNull CharSequence text, long timestamp, @Nullable Person sender, boolean remoteInputHistory) { mText = text; mText = safeCharSequence(text); mTimestamp = timestamp; mSender = sender; mRemoteInputHistory = remoteInputHistory; Loading Loading @@ -7350,7 +7350,7 @@ public class Notification implements Parcelable bundle.putLong(KEY_TIMESTAMP, mTimestamp); if (mSender != null) { // Legacy listeners need this bundle.putCharSequence(KEY_SENDER, mSender.getName()); bundle.putCharSequence(KEY_SENDER, safeCharSequence(mSender.getName())); bundle.putParcelable(KEY_SENDER_PERSON, mSender); } if (mDataMimeType != null) { Loading
core/java/android/net/NetworkSpecifier.java +26 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ package android.net; /** * Describes specific properties of a network for use in a {@link NetworkRequest}. * Describes specific properties of a requested network for use in a {@link NetworkRequest}. * * Applications cannot instantiate this class by themselves, but can obtain instances of * subclasses of this class via other APIs. Loading Loading @@ -49,4 +49,29 @@ public abstract class NetworkSpecifier { public void assertValidFromUid(int requestorUid) { // empty } /** * Optional method which can be overridden by concrete implementations of NetworkSpecifier to * perform any redaction of information from the NetworkSpecifier, e.g. if it contains * sensitive information. The default implementation simply returns the object itself - i.e. * no information is redacted. A concrete implementation may return a modified (copy) of the * NetworkSpecifier, or even return a null to fully remove all information. * <p> * This method is relevant to NetworkSpecifier objects used by agents - those are shared with * apps by default. Some agents may store sensitive matching information in the specifier, * e.g. a Wi-Fi SSID (which should not be shared since it may leak location). Those classes * can redact to a null. Other agents use the Network Specifier to share public information * with apps - those should not be redacted. * <p> * The default implementation redacts no information. * * @return A NetworkSpecifier object to be passed along to the requesting app. * * @hide */ public NetworkSpecifier redact() { // TODO (b/122160111): convert default to null once all platform NetworkSpecifiers // implement this method. return this; } }
core/java/android/os/LocaleList.java +6 −5 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.util.proto.ProtoOutputStream; import com.android.internal.annotations.GuardedBy; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; Loading Loading @@ -171,18 +172,18 @@ public final class LocaleList implements Parcelable { /** * Creates a new {@link LocaleList}. * * If two or more same locales are passed, the repeated locales will be dropped. * <p>For empty lists of {@link Locale} items it is better to use {@link #getEmptyLocaleList()}, * which returns a pre-constructed empty list.</p> * * @throws NullPointerException if any of the input locales is <code>null</code>. * @throws IllegalArgumentException if any of the input locales repeat. */ public LocaleList(@NonNull Locale... list) { if (list.length == 0) { mList = sEmptyList; mStringRepresentation = ""; } else { final Locale[] localeList = new Locale[list.length]; final ArrayList<Locale> localeList = new ArrayList<>(); final HashSet<Locale> seenLocales = new HashSet<Locale>(); final StringBuilder sb = new StringBuilder(); for (int i = 0; i < list.length; i++) { Loading @@ -190,10 +191,10 @@ public final class LocaleList implements Parcelable { if (l == null) { throw new NullPointerException("list[" + i + "] is null"); } else if (seenLocales.contains(l)) { throw new IllegalArgumentException("list[" + i + "] is a repetition"); // Dropping duplicated locale entries. } else { final Locale localeClone = (Locale) l.clone(); localeList[i] = localeClone; localeList.add(localeClone); sb.append(localeClone.toLanguageTag()); if (i < list.length - 1) { sb.append(','); Loading @@ -201,7 +202,7 @@ public final class LocaleList implements Parcelable { seenLocales.add(localeClone); } } mList = localeList; mList = localeList.toArray(new Locale[localeList.size()]); mStringRepresentation = sb.toString(); } } Loading
services/core/java/com/android/server/ConnectivityService.java +5 −1 Original line number Diff line number Diff line Loading @@ -1434,6 +1434,9 @@ public class ConnectivityService extends IConnectivityManager.Stub newNc.setUids(null); newNc.setSSID(null); } if (newNc.getNetworkSpecifier() != null) { newNc.setNetworkSpecifier(newNc.getNetworkSpecifier().redact()); } return newNc; } Loading Loading @@ -5186,7 +5189,8 @@ public class ConnectivityService extends IConnectivityManager.Stub } switch (notificationType) { case ConnectivityManager.CALLBACK_AVAILABLE: { putParcelable(bundle, new NetworkCapabilities(networkAgent.networkCapabilities)); putParcelable(bundle, networkCapabilitiesRestrictedForCallerPermissions( networkAgent.networkCapabilities, nri.mPid, nri.mUid)); putParcelable(bundle, new LinkProperties(networkAgent.linkProperties)); break; } Loading
services/core/java/com/android/server/pm/PackageManagerService.java +23 −11 Original line number Diff line number Diff line Loading @@ -3787,14 +3787,10 @@ public class PackageManagerService extends IPackageManager.Stub Iterator<ResolveInfo> iter = matches.iterator(); while (iter.hasNext()) { final ResolveInfo rInfo = iter.next(); final PackageSetting ps = mSettings.mPackages.get(rInfo.activityInfo.packageName); if (ps != null) { final PermissionsState permissionsState = ps.getPermissionsState(); if (permissionsState.hasPermission(Manifest.permission.INSTALL_PACKAGES, 0) || Build.IS_ENG) { if (checkPermission(Manifest.permission.INSTALL_PACKAGES, rInfo.activityInfo.packageName, 0) == PERMISSION_GRANTED || Build.IS_ENG) { continue; } } iter.remove(); } if (matches.size() == 0) { Loading Loading @@ -4036,8 +4032,24 @@ public class PackageManagerService extends IPackageManager.Stub final int[] gids = (flags & PackageManager.GET_GIDS) == 0 ? EMPTY_INT_ARRAY : permissionsState.computeGids(userId); // Compute granted permissions only if package has requested permissions final Set<String> permissions = ArrayUtils.isEmpty(p.requestedPermissions) Set<String> permissions = ArrayUtils.isEmpty(p.requestedPermissions) ? Collections.<String>emptySet() : permissionsState.getPermissions(userId); if (state.instantApp) { permissions = new ArraySet<>(permissions); permissions.removeIf(permissionName -> { BasePermission permission = mPermissionManager.getPermissionTEMP( permissionName); if (permission == null) { return true; } if (!permission.isInstant()) { EventLog.writeEvent(0x534e4554, "140256621", UserHandle.getUid(userId, ps.appId), permissionName); return true; } return false; }); } PackageInfo packageInfo = mayFakeSignature(p, PackageParser.generatePackageInfo(p, gids, flags, ps.firstInstallTime, ps.lastUpdateTime, permissions, state, userId), Loading Loading @@ -8054,10 +8066,9 @@ public class PackageManagerService extends IPackageManager.Stub private void addPackageHoldingPermissions(ArrayList<PackageInfo> list, PackageSetting ps, String[] permissions, boolean[] tmp, int flags, int userId) { int numMatch = 0; final PermissionsState permissionsState = ps.getPermissionsState(); for (int i=0; i<permissions.length; i++) { final String permission = permissions[i]; if (permissionsState.hasPermission(permission, userId)) { if (checkPermission(permission, ps.name, userId) == PERMISSION_GRANTED) { tmp[i] = true; numMatch++; } else { Loading Loading @@ -19176,7 +19187,8 @@ public class PackageManagerService extends IPackageManager.Stub } final int userId = user == null ? UserHandle.USER_ALL : user.getIdentifier(); if (ps.getPermissionsState().hasPermission(Manifest.permission.SUSPEND_APPS, userId)) { if (checkPermission(Manifest.permission.SUSPEND_APPS, packageName, userId) == PERMISSION_GRANTED) { unsuspendForSuspendingPackage(packageName, userId); }