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

Commit f999fa6c authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6812348 from a1603bbd to rvc-qpr1-release

Change-Id: I91983184398f7319bae9d0096f919f45cd3969ac
parents df091bcd a1603bbd
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -720,10 +720,9 @@
        <service android:name=".controls.controller.AuxiliaryPersistenceWrapper$DeletionJobService"
                 android:permission="android.permission.BIND_JOB_SERVICE"/>

        <!-- started from ControlsFavoritingActivity -->
        <!-- started from ControlsRequestReceiver -->
        <activity
            android:name=".controls.management.ControlsRequestDialog"
            android:exported="true"
            android:theme="@style/Theme.ControlsRequestDialog"
            android:finishOnCloseSystemDialogs="true"
            android:showForAllUsers="true"
+4 −0
Original line number Diff line number Diff line
@@ -87,6 +87,10 @@ class ControlsFavoritePersistenceWrapper(
     * @param list a list of favorite controls. The list will be stored in the same order.
     */
    fun storeFavorites(structures: List<StructureInfo>) {
        if (structures.isEmpty() && !file.exists()) {
            // Do not create a new file to store nothing
            return
        }
        executor.execute {
            Log.d(TAG, "Saving data to file: $file")
            val atomicFile = AtomicFile(file)
+12 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import com.android.systemui.util.concurrency.FakeExecutor
import com.android.systemui.util.time.FakeSystemClock
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -78,4 +79,15 @@ class ControlsFavoritePersistenceWrapperTest : SysuiTestCase() {

        assertEquals(list, wrapper.readFavorites())
    }

    @Test
    fun testSaveEmptyOnNonExistingFile() {
        if (file.exists()) {
            file.delete()
        }

        wrapper.storeFavorites(emptyList())

        assertFalse(file.exists())
    }
}
+5 −3
Original line number Diff line number Diff line
@@ -476,8 +476,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
        sendIIMsgNoDelay(MSG_II_SET_HEARING_AID_VOLUME, SENDMSG_REPLACE, index, streamType);
    }

    /*package*/ void postSetModeOwnerPid(int pid) {
        sendIMsgNoDelay(MSG_I_SET_MODE_OWNER_PID, SENDMSG_REPLACE, pid);
    /*package*/ void postSetModeOwnerPid(int pid, int mode) {
        sendIIMsgNoDelay(MSG_I_SET_MODE_OWNER_PID, SENDMSG_REPLACE, pid, mode);
    }

    /*package*/ void postBluetoothA2dpDeviceConfigChange(@NonNull BluetoothDevice device) {
@@ -949,7 +949,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
                        synchronized (mDeviceStateLock) {
                            if (mModeOwnerPid != msg.arg1) {
                                mModeOwnerPid = msg.arg1;
                                if (msg.arg2 != AudioSystem.MODE_RINGTONE) {
                                    updateSpeakerphoneOn("setNewModeOwner");
                                }
                                if (mModeOwnerPid != 0) {
                                    mBtHelper.disconnectBluetoothSco(mModeOwnerPid);
                                }
+21 −12
Original line number Diff line number Diff line
@@ -3680,13 +3680,15 @@ public class AudioService extends IAudioService.Stub
        private final IBinder mCb; // To be notified of client's death
        private final int mPid;
        private final int mUid;
        private String mPackage;
        private final boolean mIsPrivileged;
        private final String mPackage;
        private int mMode = AudioSystem.MODE_NORMAL; // Current mode set by this client

        SetModeDeathHandler(IBinder cb, int pid, int uid, String caller) {
        SetModeDeathHandler(IBinder cb, int pid, int uid, boolean isPrivileged, String caller) {
            mCb = cb;
            mPid = pid;
            mUid = uid;
            mIsPrivileged = isPrivileged;
            mPackage = caller;
        }

@@ -3698,12 +3700,13 @@ public class AudioService extends IAudioService.Stub
                if (index < 0) {
                    Log.w(TAG, "unregistered setMode() client died");
                } else {
                    newModeOwnerPid = setModeInt(AudioSystem.MODE_NORMAL, mCb, mPid, mUid, TAG);
                    newModeOwnerPid = setModeInt(
                            AudioSystem.MODE_NORMAL, mCb, mPid, mUid, mIsPrivileged, TAG);
                }
            }
            // when entering RINGTONE, IN_CALL or IN_COMMUNICATION mode, clear all
            // SCO connections not started by the application changing the mode when pid changes
            mDeviceBroker.postSetModeOwnerPid(newModeOwnerPid);
            mDeviceBroker.postSetModeOwnerPid(newModeOwnerPid, AudioService.this.getMode());
        }

        public int getPid() {
@@ -3729,6 +3732,10 @@ public class AudioService extends IAudioService.Stub
        public String getPackage() {
            return mPackage;
        }

        public boolean isPrivileged() {
            return mIsPrivileged;
        }
    }

    /** @see AudioManager#setMode(int) */
@@ -3780,18 +3787,19 @@ public class AudioService extends IAudioService.Stub
                        + " without permission or being mode owner");
                return;
            }
            newModeOwnerPid = setModeInt(
                mode, cb, callingPid, Binder.getCallingUid(), callingPackage);
            newModeOwnerPid = setModeInt(mode, cb, callingPid, Binder.getCallingUid(),
                    hasModifyPhoneStatePermission, callingPackage);
        }
        // when entering RINGTONE, IN_CALL or IN_COMMUNICATION mode, clear all
        // SCO connections not started by the application changing the mode when pid changes
        mDeviceBroker.postSetModeOwnerPid(newModeOwnerPid);
        mDeviceBroker.postSetModeOwnerPid(newModeOwnerPid, getMode());
    }

    // setModeInt() returns a valid PID if the audio mode was successfully set to
    // any mode other than NORMAL.
    @GuardedBy("mDeviceBroker.mSetModeLock")
    private int setModeInt(int mode, IBinder cb, int pid, int uid, String caller) {
    private int setModeInt(
            int mode, IBinder cb, int pid, int uid, boolean isPrivileged, String caller) {
        if (DEBUG_MODE) {
            Log.v(TAG, "setModeInt(mode=" + mode + ", pid=" + pid
                    + ", uid=" + uid + ", caller=" + caller + ")");
@@ -3843,7 +3851,7 @@ public class AudioService extends IAudioService.Stub
                }
            } else {
                if (hdlr == null) {
                    hdlr = new SetModeDeathHandler(cb, pid, uid, caller);
                    hdlr = new SetModeDeathHandler(cb, pid, uid, isPrivileged, caller);
                }
                // Register for client death notification
                try {
@@ -3902,7 +3910,8 @@ public class AudioService extends IAudioService.Stub
            // change of mode may require volume to be re-applied on some devices
            updateAbsVolumeMultiModeDevices(oldMode, actualMode);

            if (actualMode == AudioSystem.MODE_IN_COMMUNICATION) {
            if (actualMode == AudioSystem.MODE_IN_COMMUNICATION
                    && !hdlr.isPrivileged()) {
                sendMsg(mAudioHandler,
                        MSG_CHECK_MODE_FOR_UID,
                        SENDMSG_QUEUE,
@@ -6419,8 +6428,8 @@ public class AudioService extends IAudioService.Stub
                                    CHECK_MODE_FOR_UID_PERIOD_MS);
                            break;
                        }
                        // For now just log the fact that an app is hogging the audio mode.
                        // TODO(b/160260850): remove abusive app from audio mode stack.
                        setModeInt(AudioSystem.MODE_NORMAL, h.getBinder(), h.getPid(), h.getUid(),
                                h.isPrivileged(), "MSG_CHECK_MODE_FOR_UID");
                        mModeLogger.log(new PhoneStateEvent(h.getPackage(), h.getPid()));
                    }
                    break;
Loading