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

Unverified Commit 99861251 authored by Michael Bestas's avatar Michael Bestas
Browse files

Merge tag 'android-13.0.0_r20' into staging/lineage-20.0_merge-android-13.0.0_r20

Android 13.0.0 release 20

# -----BEGIN PGP SIGNATURE-----
#
# iF0EABECAB0WIQRDQNE1cO+UXoOBCWTorT+BmrEOeAUCY7SAYgAKCRDorT+BmrEO
# ePDEAJ4hsOaWX0MoJxmtTWkMgjKeKYYtLQCcCO50Fl6pWz+Cds1gfkH3yAroQEI=
# =iZB+
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Jan  3 21:22:10 2023 EET
# gpg:                using DSA key 4340D13570EF945E83810964E8AD3F819AB10E78
# gpg: Good signature from "The Android Open Source Project <initial-contribution@android.com>" [marginal]
# gpg: initial-contribution@android.com: Verified 1497 signatures in the past
#      14 months.  Encrypted 4 messages in the past 11 months.
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 4340 D135 70EF 945E 8381  0964 E8AD 3F81 9AB1 0E78

# By Songchun Fan (3) and others
# Via Android Build Coastguard Worker
* tag 'android-13.0.0_r20':
  Revert "Fix system zen rules by using owner package name if caller is system"
  Revert "Check rule package name in ZenModeHelper.addAutomaticRule"
  Ensure that only SysUI can override pending intent launch flags
  Add protections against queueing a UsbRequest when the underlying UsbDeviceConnection is closed.
  [SettingsProvider] workaround for DevicePolicyResourcesManager
  RESTRICT AUTOMERGE Revoke SYSTEM_ALERT_WINDOW on upgrade past api 23
  [RESTRICT AUTOMERGE][SettingsProvider] key size limit for mutating settings
  Enable user graularity for lockdown mode
  RESTRICT AUTOMERGE Validate permission tree size on permission update
  [RESTRICT AUTOMERGE] [SettingsProvider] mem limit should be checked before settings are updated
  Disable all A11yServices from an uninstalled package.
  [2/2] Fix sharing to another profile where an app has multiple targets
  Fix QSPanel horizontal layout issue after unfolding
  Trim the activity info of another uid if no privilege

Change-Id: Ic87834f3452e2a21d33a10611d97b85a315af687
parents 202ef84d 324a1c31
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -107,6 +107,34 @@ public class UsbDeviceConnection {
        }
    }

    /**
     * This is meant to be called by UsbRequest's queue() in order to synchronize on
     * UsbDeviceConnection's mLock to prevent the connection being closed while queueing.
     */
    /* package */ boolean queueRequest(UsbRequest request, ByteBuffer buffer, int length) {
        synchronized (mLock) {
            if (!isOpen()) {
                return false;
            }

            return request.queueIfConnectionOpen(buffer, length);
        }
    }

    /**
     * This is meant to be called by UsbRequest's queue() in order to synchronize on
     * UsbDeviceConnection's mLock to prevent the connection being closed while queueing.
     */
    /* package */ boolean queueRequest(UsbRequest request, @Nullable ByteBuffer buffer) {
        synchronized (mLock) {
            if (!isOpen()) {
                return false;
            }

            return request.queueIfConnectionOpen(buffer);
        }
    }

    /**
     * Releases all system resources related to the device.
     * Once the object is closed it cannot be used again.
+58 −10
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@ public class UsbRequest {
     * Releases all resources related to this request.
     */
    public void close() {
        synchronized (mLock) {
            if (mNativeContext != 0) {
                mEndpoint = null;
                mConnection = null;
@@ -120,6 +121,7 @@ public class UsbRequest {
                mCloseGuard.close();
            }
        }
    }

    @Override
    protected void finalize() throws Throwable {
@@ -191,10 +193,32 @@ public class UsbRequest {
     */
    @Deprecated
    public boolean queue(ByteBuffer buffer, int length) {
        UsbDeviceConnection connection = mConnection;
        if (connection == null) {
            // The expected exception by CTS Verifier - USB Device test
            throw new NullPointerException("invalid connection");
        }

        // Calling into the underlying UsbDeviceConnection to synchronize on its lock, to prevent
        // the connection being closed while queueing.
        return connection.queueRequest(this, buffer, length);
    }

    /**
     * This is meant to be called from UsbDeviceConnection after synchronizing using the lock over
     * there, to prevent the connection being closed while queueing.
     */
    /* package */ boolean queueIfConnectionOpen(ByteBuffer buffer, int length) {
        UsbDeviceConnection connection = mConnection;
        if (connection == null || !connection.isOpen()) {
            // The expected exception by CTS Verifier - USB Device test
            throw new NullPointerException("invalid connection");
        }

        boolean out = (mEndpoint.getDirection() == UsbConstants.USB_DIR_OUT);
        boolean result;

        if (mConnection.getContext().getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.P
        if (connection.getContext().getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.P
                && length > MAX_USBFS_BUFFER_SIZE) {
            length = MAX_USBFS_BUFFER_SIZE;
        }
@@ -243,6 +267,28 @@ public class UsbRequest {
     * @return true if the queueing operation succeeded
     */
    public boolean queue(@Nullable ByteBuffer buffer) {
        UsbDeviceConnection connection = mConnection;
        if (connection == null) {
            // The expected exception by CTS Verifier - USB Device test
            throw new IllegalStateException("invalid connection");
        }

        // Calling into the underlying UsbDeviceConnection to synchronize on its lock, to prevent
        // the connection being closed while queueing.
        return connection.queueRequest(this, buffer);
    }

    /**
     * This is meant to be called from UsbDeviceConnection after synchronizing using the lock over
     * there, to prevent the connection being closed while queueing.
     */
    /* package */ boolean queueIfConnectionOpen(@Nullable ByteBuffer buffer) {
        UsbDeviceConnection connection = mConnection;
        if (connection == null || !connection.isOpen()) {
            // The expected exception by CTS Verifier - USB Device test
            throw new IllegalStateException("invalid connection");
        }

        // Request need to be initialized
        Preconditions.checkState(mNativeContext != 0, "request is not initialized");

@@ -260,7 +306,7 @@ public class UsbRequest {
                mIsUsingNewQueue = true;
                wasQueued = native_queue(null, 0, 0);
            } else {
                if (mConnection.getContext().getApplicationInfo().targetSdkVersion
                if (connection.getContext().getApplicationInfo().targetSdkVersion
                        < Build.VERSION_CODES.P) {
                    // Can only send/receive MAX_USBFS_BUFFER_SIZE bytes at once
                    Preconditions.checkArgumentInRange(buffer.remaining(), 0, MAX_USBFS_BUFFER_SIZE,
@@ -363,11 +409,12 @@ public class UsbRequest {
     * @return true if cancelling succeeded
     */
    public boolean cancel() {
        if (mConnection == null) {
        UsbDeviceConnection connection = mConnection;
        if (connection == null) {
            return false;
        }

        return mConnection.cancelRequest(this);
        return connection.cancelRequest(this);
    }

    /**
@@ -382,7 +429,8 @@ public class UsbRequest {
     * @return true if cancelling succeeded.
     */
    /* package */ boolean cancelIfOpen() {
        if (mNativeContext == 0 || (mConnection != null && !mConnection.isOpen())) {
        UsbDeviceConnection connection = mConnection;
        if (mNativeContext == 0 || (connection != null && !connection.isOpen())) {
            Log.w(TAG,
                    "Detected attempt to cancel a request on a connection which isn't open");
            return false;
+20 −3
Original line number Diff line number Diff line
@@ -3344,9 +3344,26 @@ public final class Settings {
                    }
                }
                Bundle b;
                // b/252663068: if we're in system server and the caller did not call
                // clearCallingIdentity, the read would fail due to mismatched AttributionSources.
                // TODO(b/256013480): remove this bypass after fixing the callers in system server.
                if (namespace.equals(DeviceConfig.NAMESPACE_DEVICE_POLICY_MANAGER)
                        && Settings.isInSystemServer()
                        && Binder.getCallingUid() != Process.myUid()) {
                    final long token = Binder.clearCallingIdentity();
                    try {
                        // Fetch all flags for the namespace at once for caching purposes
                        b = cp.call(cr.getAttributionSource(),
                                mProviderHolder.mUri.getAuthority(), mCallListCommand, null, args);
                    } finally {
                        Binder.restoreCallingIdentity(token);
                    }
                } else {
                    // Fetch all flags for the namespace at once for caching purposes
                Bundle b = cp.call(cr.getAttributionSource(),
                    b = cp.call(cr.getAttributionSource(),
                            mProviderHolder.mUri.getAuthority(), mCallListCommand, null, args);
                }
                if (b == null) {
                    // Invalid response, return an empty map
                    return keyValues;
+2 −9
Original line number Diff line number Diff line
@@ -172,14 +172,14 @@ public class DisplayResolveInfo implements TargetInfo, Parcelable {

    @Override
    public boolean startAsCaller(ResolverActivity activity, Bundle options, int userId) {
        prepareIntentForCrossProfileLaunch(mResolvedIntent, userId);
        TargetInfo.prepareIntentForCrossProfileLaunch(mResolvedIntent, userId);
        activity.startActivityAsCaller(mResolvedIntent, options, false, userId);
        return true;
    }

    @Override
    public boolean startAsUser(Activity activity, Bundle options, UserHandle user) {
        prepareIntentForCrossProfileLaunch(mResolvedIntent, user.getIdentifier());
        TargetInfo.prepareIntentForCrossProfileLaunch(mResolvedIntent, user.getIdentifier());
        activity.startActivityAsUser(mResolvedIntent, options, user);
        return false;
    }
@@ -224,13 +224,6 @@ public class DisplayResolveInfo implements TargetInfo, Parcelable {
        }
    };

    private static void prepareIntentForCrossProfileLaunch(Intent intent, int targetUserId) {
        final int currentUserId = UserHandle.myUserId();
        if (targetUserId != currentUserId) {
            intent.fixUris(currentUserId);
        }
    }

    private DisplayResolveInfo(Parcel in) {
        mDisplayLabel = in.readCharSequence();
        mExtendedInfo = in.readCharSequence();
+1 −0
Original line number Diff line number Diff line
@@ -232,6 +232,7 @@ public final class SelectableTargetInfo implements ChooserTargetInfo {
        }
        intent.setComponent(mChooserTarget.getComponentName());
        intent.putExtras(mChooserTarget.getIntentExtras());
        TargetInfo.prepareIntentForCrossProfileLaunch(intent, userId);

        // Important: we will ignore the target security checks in ActivityManager
        // if and only if the ChooserTarget's target package is the same package
Loading