Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 05157e53 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker Committed by Justin Dunlap
Browse files

Merge cherrypicks of ['googleplex-android-review.googlesource.com/24308899',...

Merge cherrypicks of ['googleplex-android-review.googlesource.com/24308899', 'googleplex-android-review.googlesource.com/24310240', 'googleplex-android-review.googlesource.com/23727470', 'googleplex-android-review.googlesource.com/24444452', 'googleplex-android-review.googlesource.com/24424817', 'googleplex-android-review.googlesource.com/23987679', 'googleplex-android-review.googlesource.com/23988011', 'googleplex-android-review.googlesource.com/24029253'] into security-aosp-udc-release.

Change-Id: I7e3ba1bcf27b128483fa16b6903356e44ce38572
parents 299fe6f5 bd0881cd
Loading
Loading
Loading
Loading
+5 −2
Original line number Original line Diff line number Diff line
@@ -3485,8 +3485,11 @@ public class Notification implements Parcelable
     *
     *
     * @hide
     * @hide
     */
     */
    public void setAllowlistToken(@Nullable IBinder token) {
    public void clearAllowlistToken() {
        mAllowlistToken = token;
        mAllowlistToken = null;
        if (publicVersion != null) {
            publicVersion.clearAllowlistToken();
        }
    }
    }
    /**
    /**
+2 −1
Original line number Original line Diff line number Diff line
@@ -172,7 +172,8 @@ public class UsbConfiguration implements Parcelable {
            String name = in.readString();
            String name = in.readString();
            int attributes = in.readInt();
            int attributes = in.readInt();
            int maxPower = in.readInt();
            int maxPower = in.readInt();
            Parcelable[] interfaces = in.readParcelableArray(UsbInterface.class.getClassLoader());
            Parcelable[] interfaces = in.readParcelableArray(
                    UsbInterface.class.getClassLoader(), UsbInterface.class);
            UsbConfiguration configuration = new UsbConfiguration(id, name, attributes, maxPower);
            UsbConfiguration configuration = new UsbConfiguration(id, name, attributes, maxPower);
            configuration.setInterfaces(interfaces);
            configuration.setInterfaces(interfaces);
            return configuration;
            return configuration;
+14 −9
Original line number Original line Diff line number Diff line
@@ -267,17 +267,22 @@ public final class MediaSession {
    }
    }


    /**
    /**
     * Set a pending intent for your media button receiver to allow restarting
     * Set a pending intent for your media button receiver to allow restarting playback after the
     * playback after the session has been stopped. If your app is started in
     * session has been stopped.
     * this way an {@link Intent#ACTION_MEDIA_BUTTON} intent will be sent via
     *
     * the pending intent.
     * <p>If your app is started in this way an {@link Intent#ACTION_MEDIA_BUTTON} intent will be
     * <p>
     * sent via the pending intent.
     * The pending intent is recommended to be explicit to follow the security recommendation of
     *
     * {@link PendingIntent#getActivity}.
     * <p>The provided {@link PendingIntent} must not target an activity. Passing an activity
     * pending intent will cause the call to be ignored. Refer to this <a
     * href="https://developer.android.com/guide/components/activities/background-starts">guide</a>
     * for more information.
     *
     * <p>The pending intent is recommended to be explicit to follow the security recommendation of
     * {@link PendingIntent#getService}.
     *
     *
     * @param mbr The {@link PendingIntent} to send the media button event to.
     * @param mbr The {@link PendingIntent} to send the media button event to.
     * @see PendingIntent#getActivity
     * @see PendingIntent#getActivity
     *
     * @deprecated Use {@link #setMediaButtonBroadcastReceiver(ComponentName)} instead.
     * @deprecated Use {@link #setMediaButtonBroadcastReceiver(ComponentName)} instead.
     */
     */
    @Deprecated
    @Deprecated
@@ -285,7 +290,7 @@ public final class MediaSession {
        try {
        try {
            mBinder.setMediaButtonReceiver(mbr);
            mBinder.setMediaButtonReceiver(mbr);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.wtf(TAG, "Failure in setMediaButtonReceiver.", e);
            e.rethrowFromSystemServer();
        }
        }
    }
    }


+31 −0
Original line number Original line Diff line number Diff line
@@ -1948,6 +1948,9 @@ public class SettingsProvider extends ContentProvider {
            cacheName = Settings.System.ALARM_ALERT_CACHE;
            cacheName = Settings.System.ALARM_ALERT_CACHE;
        }
        }
        if (cacheName != null) {
        if (cacheName != null) {
            if (!isValidAudioUri(name, value)) {
                return false;
            }
            final File cacheFile = new File(
            final File cacheFile = new File(
                    getRingtoneCacheDir(owningUserId), cacheName);
                    getRingtoneCacheDir(owningUserId), cacheName);
            cacheFile.delete();
            cacheFile.delete();
@@ -1980,6 +1983,34 @@ public class SettingsProvider extends ContentProvider {
        }
        }
    }
    }


    private boolean isValidAudioUri(String name, String uri) {
        if (uri != null) {
            Uri audioUri = Uri.parse(uri);
            if (Settings.AUTHORITY.equals(
                    ContentProvider.getAuthorityWithoutUserId(audioUri.getAuthority()))) {
                // Don't accept setting the default uri to self-referential URIs like
                // Settings.System.DEFAULT_RINGTONE_URI, which is an alias to the value of this
                // setting.
                return false;
            }
            final String mimeType = getContext().getContentResolver().getType(audioUri);
            if (mimeType == null) {
                Slog.e(LOG_TAG,
                        "mutateSystemSetting for setting: " + name + " URI: " + audioUri
                        + " ignored: failure to find mimeType (no access from this context?)");
                return false;
            }
            if (!(mimeType.startsWith("audio/") || mimeType.equals("application/ogg")
                    || mimeType.equals("application/x-flac"))) {
                Slog.e(LOG_TAG,
                        "mutateSystemSetting for setting: " + name + " URI: " + audioUri
                        + " ignored: associated mimeType: " + mimeType + " is not an audio type");
                return false;
            }
        }
        return true;
    }

    private boolean hasWriteSecureSettingsPermission() {
    private boolean hasWriteSecureSettingsPermission() {
        // Write secure settings is a more protected permission. If caller has it we are good.
        // Write secure settings is a more protected permission. If caller has it we are good.
        return getContext().checkCallingOrSelfPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
        return getContext().checkCallingOrSelfPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
+21 −2
Original line number Original line Diff line number Diff line
@@ -3074,6 +3074,22 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
        }
    }
    }
    /**
     * Enforces that the uid of the caller matches the uid of the package.
     *
     * @param packageName the name of the package to match uid against.
     * @param callingUid the uid of the caller.
     * @throws SecurityException if the calling uid doesn't match uid of the package.
     */
    private void enforceCallingPackage(String packageName, int callingUid) {
        final int userId = UserHandle.getUserId(callingUid);
        final int packageUid = getPackageManagerInternal().getPackageUid(packageName,
                /*flags=*/ 0, userId);
        if (packageUid != callingUid) {
            throw new SecurityException(packageName + " does not belong to uid " + callingUid);
        }
    }
    @Override
    @Override
    public void setPackageScreenCompatMode(String packageName, int mode) {
    public void setPackageScreenCompatMode(String packageName, int mode) {
        mActivityTaskManager.setPackageScreenCompatMode(packageName, mode);
        mActivityTaskManager.setPackageScreenCompatMode(packageName, mode);
@@ -13618,13 +13634,16 @@ public class ActivityManagerService extends IActivityManager.Stub
    // A backup agent has just come up
    // A backup agent has just come up
    @Override
    @Override
    public void backupAgentCreated(String agentPackageName, IBinder agent, int userId) {
    public void backupAgentCreated(String agentPackageName, IBinder agent, int userId) {
        final int callingUid = Binder.getCallingUid();
        enforceCallingPackage(agentPackageName, callingUid);
        // Resolve the target user id and enforce permissions.
        // Resolve the target user id and enforce permissions.
        userId = mUserController.handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(),
        userId = mUserController.handleIncomingUser(Binder.getCallingPid(), callingUid,
                userId, /* allowAll */ false, ALLOW_FULL_ONLY, "backupAgentCreated", null);
                userId, /* allowAll */ false, ALLOW_FULL_ONLY, "backupAgentCreated", null);
        if (DEBUG_BACKUP) {
        if (DEBUG_BACKUP) {
            Slog.v(TAG_BACKUP, "backupAgentCreated: " + agentPackageName + " = " + agent
            Slog.v(TAG_BACKUP, "backupAgentCreated: " + agentPackageName + " = " + agent
                    + " callingUserId = " + UserHandle.getCallingUserId() + " userId = " + userId
                    + " callingUserId = " + UserHandle.getCallingUserId() + " userId = " + userId
                    + " callingUid = " + Binder.getCallingUid() + " uid = " + Process.myUid());
                    + " callingUid = " + callingUid + " uid = " + Process.myUid());
        }
        }
        synchronized(this) {
        synchronized(this) {
Loading