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

Commit 1a960e60 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 10179466 from 0db6e80e to udc-qpr1-release

Change-Id: I3c3ddb0063cf720d8fe96bc0ab1163e7ba3727f1
parents 564e2bcd 0db6e80e
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -5006,12 +5006,6 @@ public class Notification implements Parcelable
            return mUserExtras;
        }
        private Bundle getAllExtras() {
            final Bundle saveExtras = (Bundle) mUserExtras.clone();
            saveExtras.putAll(mN.extras);
            return saveExtras;
        }
        /**
         * Add an action to this notification. Actions are typically displayed by
         * the system as a button adjacent to the notification content.
@@ -6617,9 +6611,16 @@ public class Notification implements Parcelable
                                + " vs bubble: " + mN.mBubbleMetadata.getShortcutId());
            }
            // first, add any extras from the calling code
            // Adds any new extras provided by the user.
            if (mUserExtras != null) {
                mN.extras = getAllExtras();
                final Bundle saveExtras = (Bundle) mUserExtras.clone();
                if (SystemProperties.getBoolean(
                        "persist.sysui.notification.builder_extras_override", false)) {
                    mN.extras.putAll(saveExtras);
                } else {
                    saveExtras.putAll(mN.extras);
                    mN.extras = saveExtras;
                }
            }
            mN.creationTime = System.currentTimeMillis();
+4 −17
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.preference.VolumePreference.VolumeStore;
import android.provider.DeviceConfig;
import android.provider.Settings;
import android.provider.Settings.Global;
import android.provider.Settings.System;
@@ -47,7 +46,6 @@ import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
import com.android.internal.os.SomeArgs;

import java.util.concurrent.TimeUnit;
@@ -295,14 +293,8 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
        if (zenMuted) {
            mSeekBar.setProgress(mLastAudibleStreamVolume, true);
        } else if (mNotificationOrRing && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) {
            /**
             * the first variable above is preserved and the conditions below are made explicit
             * so that when user attempts to slide the notification seekbar out of vibrate the
             * seekbar doesn't wrongly snap back to 0 when the streams aren't aliased
             */
            if (!DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI,
                    SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, false)
                    || mStreamType == AudioManager.STREAM_RING
            // For ringer-mode affected streams, show volume as zero when ringermode is vibrate
            if (mStreamType == AudioManager.STREAM_RING
                    || (mStreamType == AudioManager.STREAM_NOTIFICATION && mMuted)) {
                mSeekBar.setProgress(0, true);
            }
@@ -397,9 +389,7 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
        // set the time of stop volume
        if ((mStreamType == AudioManager.STREAM_VOICE_CALL
                || mStreamType == AudioManager.STREAM_RING
                || (DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI,
                SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, false)
                && mStreamType == AudioManager.STREAM_NOTIFICATION)
                || mStreamType == AudioManager.STREAM_NOTIFICATION
                || mStreamType == AudioManager.STREAM_ALARM)) {
            sStopVolumeTime = java.lang.System.currentTimeMillis();
        }
@@ -686,10 +676,7 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
        }

        private void updateVolumeSlider(int streamType, int streamValue) {
            final boolean streamMatch =  !DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI,
                    SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, false)
                    && mNotificationOrRing ? isNotificationOrRing(streamType) :
                    streamType == mStreamType;
            final boolean streamMatch = (streamType == mStreamType);
            if (mSeekBar != null && streamMatch && streamValue != -1) {
                final boolean muted = mAudioManager.isStreamMute(mStreamType)
                        || streamValue == 0;
+0 −5
Original line number Diff line number Diff line
@@ -548,11 +548,6 @@ public final class SystemUiDeviceConfigFlags {
    public static final String TASK_MANAGER_INFORM_JOB_SCHEDULER_OF_PENDING_APP_STOP =
            "task_manager_inform_job_scheduler_of_pending_app_stop";

    /**
     * (boolean) Whether to show notification volume control slider separate from ring.
     */
    public static final String VOLUME_SEPARATE_NOTIFICATION = "volume_separate_notification";

    /**
     * (boolean) Whether widget provider info would be saved to / loaded from system persistence
     * layer as opposed to individual manifests in respective apps.
+13 −10
Original line number Diff line number Diff line
@@ -163,6 +163,8 @@ public class PointerLocationView extends View implements InputDeviceListener,
    @UnsupportedAppUsage
    private boolean mPrintCoords = true;

    private float mDensity;

    public PointerLocationView(Context c) {
        super(c);
        setFocusableInTouchMode(true);
@@ -357,19 +359,20 @@ public class PointerLocationView extends View implements InputDeviceListener,

                // Draw current touch ellipse.
                mPaint.setARGB(255, pressureLevel, 255 - pressureLevel, 128);
                drawOval(canvas, ps.mCoords.x, ps.mCoords.y, ps.mCoords.touchMajor,
                        ps.mCoords.touchMinor, ps.mCoords.orientation, mPaint);
                drawOval(canvas, ps.mCoords.x, ps.mCoords.y, ps.mCoords.touchMajor * mDensity,
                        ps.mCoords.touchMinor * mDensity, ps.mCoords.orientation, mPaint);

                // Draw current tool ellipse.
                mPaint.setARGB(255, pressureLevel, 128, 255 - pressureLevel);
                drawOval(canvas, ps.mCoords.x, ps.mCoords.y, ps.mCoords.toolMajor,
                        ps.mCoords.toolMinor, ps.mCoords.orientation, mPaint);
                drawOval(canvas, ps.mCoords.x, ps.mCoords.y, ps.mCoords.toolMajor * mDensity,
                        ps.mCoords.toolMinor * mDensity, ps.mCoords.orientation, mPaint);

                // Draw the orientation arrow.
                float arrowSize = ps.mCoords.toolMajor * 0.7f;
                if (arrowSize < 20) {
                    arrowSize = 20;
                }
                arrowSize *= mDensity;
                mPaint.setARGB(255, pressureLevel, 255, 0);
                float orientationVectorX = (float) (Math.sin(ps.mCoords.orientation)
                        * arrowSize);
@@ -398,7 +401,7 @@ public class PointerLocationView extends View implements InputDeviceListener,
                canvas.drawCircle(
                        ps.mCoords.x + orientationVectorX * tiltScale,
                        ps.mCoords.y + orientationVectorY * tiltScale,
                        3.0f, mPaint);
                        3.0f * mDensity, mPaint);

                // Draw the current bounding box
                if (ps.mHasBoundingBox) {
@@ -1003,10 +1006,10 @@ public class PointerLocationView extends View implements InputDeviceListener,

    // Compute size by display density.
    private void configureDensityDependentFactors() {
        final float density = getResources().getDisplayMetrics().density;
        mTextPaint.setTextSize(10 * density);
        mPaint.setStrokeWidth(1 * density);
        mCurrentPointPaint.setStrokeWidth(1 * density);
        mPathPaint.setStrokeWidth(1 * density);
        mDensity = getResources().getDisplayMetrics().density;
        mTextPaint.setTextSize(10 * mDensity);
        mPaint.setStrokeWidth(1 * mDensity);
        mCurrentPointPaint.setStrokeWidth(1 * mDensity);
        mPathPaint.setStrokeWidth(1 * mDensity);
    }
}
+107 −0
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@ import static android.app.Notification.EXTRA_MESSAGING_PERSON;
import static android.app.Notification.EXTRA_PEOPLE_LIST;
import static android.app.Notification.EXTRA_PICTURE;
import static android.app.Notification.EXTRA_PICTURE_ICON;
import static android.app.Notification.EXTRA_SUMMARY_TEXT;
import static android.app.Notification.EXTRA_TITLE;
import static android.app.Notification.MessagingStyle.Message.KEY_DATA_URI;
import static android.app.Notification.MessagingStyle.Message.KEY_SENDER_PERSON;
import static android.app.Notification.MessagingStyle.Message.KEY_TEXT;
@@ -76,6 +78,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.SystemProperties;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
@@ -111,6 +114,9 @@ public class NotificationTest {
    @Before
    public void setUp() {
        mContext = InstrumentationRegistry.getContext();
        // TODO(b/169435530): remove this flag set once resolved.
        SystemProperties.set("persist.sysui.notification.builder_extras_override",
                Boolean.toString(false));
    }

    @Test
@@ -1481,6 +1487,107 @@ public class NotificationTest {
        Assert.assertEquals(actionWithFreeformRemoteInput, remoteInputActionPair.second);
    }

    // Ensures that extras in a Notification Builder can be updated.
    @Test
    public void testExtras_cachedExtrasOverwrittenByUserProvided() {
        // Sets the flag to new state.
        // TODO(b/169435530): remove this set value once resolved.
        SystemProperties.set("persist.sysui.notification.builder_extras_override",
                Boolean.toString(true));
        Bundle extras = new Bundle();
        extras.putCharSequence(EXTRA_TITLE, "test title");
        extras.putCharSequence(EXTRA_SUMMARY_TEXT, "summary text");

        Notification.Builder builder = new Notification.Builder(mContext, "test id")
                .addExtras(extras);

        Notification notification = builder.build();
        assertThat(notification.extras.getCharSequence(EXTRA_TITLE).toString()).isEqualTo(
                "test title");
        assertThat(notification.extras.getCharSequence(EXTRA_SUMMARY_TEXT).toString()).isEqualTo(
                "summary text");

        extras.putCharSequence(EXTRA_TITLE, "new title");
        builder.addExtras(extras);
        notification = builder.build();
        assertThat(notification.extras.getCharSequence(EXTRA_TITLE).toString()).isEqualTo(
                "new title");
        assertThat(notification.extras.getCharSequence(EXTRA_SUMMARY_TEXT).toString()).isEqualTo(
                "summary text");
    }

    // Ensures that extras in a Notification Builder can be updated by an extender.
    @Test
    public void testExtras_cachedExtrasOverwrittenByExtender() {
        // Sets the flag to new state.
        // TODO(b/169435530): remove this set value once resolved.
        SystemProperties.set("persist.sysui.notification.builder_extras_override",
                Boolean.toString(true));
        Notification.CarExtender extender = new Notification.CarExtender().setColor(1234);

        Notification notification = new Notification.Builder(mContext, "test id")
                .extend(extender).build();

        extender.setColor(5678);

        Notification.Builder.recoverBuilder(mContext, notification).extend(extender).build();

        Notification.CarExtender recoveredExtender = new Notification.CarExtender(notification);
        assertThat(recoveredExtender.getColor()).isEqualTo(5678);
    }

    // Validates pre-flag flip behavior, that extras in a Notification Builder cannot be updated.
    // TODO(b/169435530): remove this test once resolved.
    @Test
    public void testExtras_cachedExtrasOverwrittenByUserProvidedOld() {
        // Sets the flag to old state.
        SystemProperties.set("persist.sysui.notification.builder_extras_override",
                Boolean.toString(false));

        Bundle extras = new Bundle();
        extras.putCharSequence(EXTRA_TITLE, "test title");
        extras.putCharSequence(EXTRA_SUMMARY_TEXT, "summary text");

        Notification.Builder builder = new Notification.Builder(mContext, "test id")
                .addExtras(extras);

        Notification notification = builder.build();
        assertThat(notification.extras.getCharSequence(EXTRA_TITLE).toString()).isEqualTo(
                "test title");
        assertThat(notification.extras.getCharSequence(EXTRA_SUMMARY_TEXT).toString()).isEqualTo(
                "summary text");

        extras.putCharSequence(EXTRA_TITLE, "new title");
        builder.addExtras(extras);
        notification = builder.build();
        assertThat(notification.extras.getCharSequence(EXTRA_TITLE).toString()).isEqualTo(
                "test title");
        assertThat(notification.extras.getCharSequence(EXTRA_SUMMARY_TEXT).toString()).isEqualTo(
                "summary text");
    }

    // Validates pre-flag flip behavior, that extras in a Notification Builder cannot be updated
    // by an extender.
    // TODO(b/169435530): remove this test once resolved.
    @Test
    public void testExtras_cachedExtrasOverwrittenByExtenderOld() {
        // Sets the flag to old state.
        SystemProperties.set("persist.sysui.notification.builder_extras_override",
                Boolean.toString(false));

        Notification.CarExtender extender = new Notification.CarExtender().setColor(1234);

        Notification notification = new Notification.Builder(mContext, "test id")
                .extend(extender).build();

        extender.setColor(5678);

        Notification.Builder.recoverBuilder(mContext, notification).extend(extender).build();

        Notification.CarExtender recoveredExtender = new Notification.CarExtender(notification);
        assertThat(recoveredExtender.getColor()).isEqualTo(1234);
    }

    private void assertValid(Notification.Colors c) {
        // Assert that all colors are populated
        assertThat(c.getBackgroundColor()).isNotEqualTo(Notification.COLOR_INVALID);
Loading