Loading core/java/android/app/Notification.java +23 −17 Original line number Diff line number Diff line Loading @@ -96,9 +96,9 @@ import com.android.internal.util.ContrastColorUtil; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.reflect.Array; import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Objects; Loading Loading @@ -1620,7 +1620,7 @@ public class Notification implements Parcelable * of non-textual RemoteInputs do not access these remote inputs. */ public RemoteInput[] getDataOnlyRemoteInputs() { return (RemoteInput[]) mExtras.getParcelableArray(EXTRA_DATA_ONLY_INPUTS); return getParcelableArrayFromBundle(mExtras, EXTRA_DATA_ONLY_INPUTS, RemoteInput.class); } /** Loading Loading @@ -1802,8 +1802,8 @@ public class Notification implements Parcelable checkContextualActionNullFields(); ArrayList<RemoteInput> dataOnlyInputs = new ArrayList<>(); RemoteInput[] previousDataInputs = (RemoteInput[]) mExtras.getParcelableArray(EXTRA_DATA_ONLY_INPUTS); RemoteInput[] previousDataInputs = getParcelableArrayFromBundle( mExtras, EXTRA_DATA_ONLY_INPUTS, RemoteInput.class); if (previousDataInputs != null) { for (RemoteInput input : previousDataInputs) { dataOnlyInputs.add(input); Loading Loading @@ -5368,8 +5368,8 @@ public class Notification implements Parcelable big.setViewVisibility(R.id.actions_container, View.GONE); } RemoteInputHistoryItem[] replyText = (RemoteInputHistoryItem[]) mN.extras.getParcelableArray(EXTRA_REMOTE_INPUT_HISTORY_ITEMS); RemoteInputHistoryItem[] replyText = getParcelableArrayFromBundle( mN.extras, EXTRA_REMOTE_INPUT_HISTORY_ITEMS, RemoteInputHistoryItem.class); if (validRemoteInput && replyText != null && replyText.length > 0 && !TextUtils.isEmpty(replyText[0].getText()) && p.maxRemoteInputHistory > 0) { Loading Loading @@ -8155,8 +8155,9 @@ public class Notification implements Parcelable if (mBuilder.mActions.size() > 0) { maxRows--; } RemoteInputHistoryItem[] remoteInputHistory = (RemoteInputHistoryItem[]) mBuilder.mN.extras.getParcelableArray(EXTRA_REMOTE_INPUT_HISTORY_ITEMS); RemoteInputHistoryItem[] remoteInputHistory = getParcelableArrayFromBundle( mBuilder.mN.extras, EXTRA_REMOTE_INPUT_HISTORY_ITEMS, RemoteInputHistoryItem.class); if (remoteInputHistory != null && remoteInputHistory.length > NUMBER_OF_HISTORY_ALLOWED_UNTIL_REDUCTION) { // Let's remove some messages to make room for the remote input history. Loading Loading @@ -9579,8 +9580,8 @@ public class Notification implements Parcelable mFlags = wearableBundle.getInt(KEY_FLAGS, DEFAULT_FLAGS); mDisplayIntent = wearableBundle.getParcelable(KEY_DISPLAY_INTENT); Notification[] pages = getNotificationArrayFromBundle( wearableBundle, KEY_PAGES); Notification[] pages = getParcelableArrayFromBundle( wearableBundle, KEY_PAGES, Notification.class); if (pages != null) { Collections.addAll(mPages, pages); } Loading Loading @@ -10838,17 +10839,22 @@ public class Notification implements Parcelable } /** * Get an array of Notification objects from a parcelable array bundle field. * Get an array of Parcelable objects from a parcelable array bundle field. * Update the bundle to have a typed array so fetches in the future don't need * to do an array copy. */ private static Notification[] getNotificationArrayFromBundle(Bundle bundle, String key) { Parcelable[] array = bundle.getParcelableArray(key); if (array instanceof Notification[] || array == null) { return (Notification[]) array; @Nullable private static <T extends Parcelable> T[] getParcelableArrayFromBundle( Bundle bundle, String key, Class<T> itemClass) { final Parcelable[] array = bundle.getParcelableArray(key); final Class<?> arrayClass = Array.newInstance(itemClass, 0).getClass(); if (arrayClass.isInstance(array) || array == null) { return (T[]) array; } final T[] typedArray = (T[]) Array.newInstance(itemClass, array.length); for (int i = 0; i < array.length; i++) { typedArray[i] = (T) array[i]; } Notification[] typedArray = Arrays.copyOf(array, array.length, Notification[].class); bundle.putParcelableArray(key, typedArray); return typedArray; } Loading packages/SettingsLib/res/drawable/ic_media_display_device.xml +6 −10 Original line number Diff line number Diff line Loading @@ -15,16 +15,12 @@ limitations under the License. --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="14dp" android:height="11dp" android:viewportWidth="14" android:viewportHeight="11" android:tint="?android:attr/colorControlNormal"> android:width="18dp" android:height="18dp" android:viewportWidth="18" android:viewportHeight="18"> <path android:pathData="M10,10v1H4v-1H1.5A1.5,1.5 0,0 1,0 8.5v-7A1.5,1.5 0, 0 1,1.5 0h11A1.5,1.5 0,0 1,14 1.5v7a1.5,1.5 0,0 1,-1.5 1.5H10zM1.5, 1a0.5,0.5 0,0 0,-0.5 0.5v7a0.5,0.5 0,0 0,0.5 0.5h11a0.5,0.5 0,0 0, 0.5 -0.5v-7a0.5,0.5 0,0 0,-0.5 -0.5h-11z" android:fillColor="#000000" android:pathData="M12,14V15H6V14H3.5C3.1022,14 2.7206,13.842 2.4393,13.5607C2.158,13.2794 2,12.8978 2,12.5V5.5C2,5.1022 2.158,4.7206 2.4393,4.4393C2.7206,4.158 3.1022,4 3.5,4H14.5C14.8978,4 15.2794,4.158 15.5607,4.4393C15.842,4.7206 16,5.1022 16,5.5V12.5C16,12.8978 15.842,13.2794 15.5607,13.5607C15.2794,13.842 14.8978,14 14.5,14H12ZM3.5,5C3.3674,5 3.2402,5.0527 3.1465,5.1465C3.0527,5.2402 3,5.3674 3,5.5V12.5C3,12.6326 3.0527,12.7598 3.1465,12.8536C3.2402,12.9473 3.3674,13 3.5,13H14.5C14.6326,13 14.7598,12.9473 14.8536,12.8536C14.9473,12.7598 15,12.6326 15,12.5V5.5C15,5.3674 14.9473,5.2402 14.8536,5.1465C14.7598,5.0527 14.6326,5 14.5,5H3.5Z" android:fillColor="#5F6368" android:fillType="evenOdd"/> </vector> No newline at end of file packages/SettingsLib/src/com/android/settingslib/media/InfoMediaDevice.java +20 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ */ package com.android.settingslib.media; import static android.media.MediaRoute2Info.FEATURE_REMOTE_GROUP_PLAYBACK; import static android.media.MediaRoute2Info.FEATURE_REMOTE_VIDEO_PLAYBACK; import static android.media.MediaRoute2Info.TYPE_GROUP; import static android.media.MediaRoute2Info.TYPE_REMOTE_SPEAKER; import static android.media.MediaRoute2Info.TYPE_REMOTE_TV; Loading @@ -29,6 +31,8 @@ import androidx.annotation.VisibleForTesting; import com.android.settingslib.R; import com.android.settingslib.bluetooth.BluetoothUtils; import java.util.List; /** * InfoMediaDevice extends MediaDevice to represents wifi device. */ Loading Loading @@ -62,7 +66,7 @@ public class InfoMediaDevice extends MediaDevice { @Override public Drawable getIconWithoutBackground() { return mContext.getDrawable(getDrawableResId()); return mContext.getDrawable(getDrawableResIdByFeature()); } @VisibleForTesting Loading @@ -83,6 +87,21 @@ public class InfoMediaDevice extends MediaDevice { return resId; } @VisibleForTesting int getDrawableResIdByFeature() { int resId; final List<String> features = mRouteInfo.getFeatures(); if (features.contains(FEATURE_REMOTE_GROUP_PLAYBACK)) { resId = R.drawable.ic_media_group_device; } else if (features.contains(FEATURE_REMOTE_VIDEO_PLAYBACK)) { resId = R.drawable.ic_media_display_device; } else { resId = R.drawable.ic_media_speaker_device; } return resId; } @Override public String getId() { return MediaDeviceUtils.getId(mRouteInfo); Loading packages/SettingsLib/tests/robotests/src/com/android/settingslib/media/InfoMediaDeviceTest.java +29 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.settingslib.media; import static android.media.MediaRoute2Info.FEATURE_REMOTE_AUDIO_PLAYBACK; import static android.media.MediaRoute2Info.FEATURE_REMOTE_GROUP_PLAYBACK; import static android.media.MediaRoute2Info.FEATURE_REMOTE_VIDEO_PLAYBACK; import static android.media.MediaRoute2Info.TYPE_GROUP; import static android.media.MediaRoute2Info.TYPE_REMOTE_SPEAKER; import static android.media.MediaRoute2Info.TYPE_REMOTE_TV; Loading @@ -38,6 +41,8 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import java.util.ArrayList; @RunWith(RobolectricTestRunner.class) public class InfoMediaDeviceTest { Loading Loading @@ -107,4 +112,28 @@ public class InfoMediaDeviceTest { assertThat(mInfoMediaDevice.getDrawableResId()).isEqualTo(R.drawable.ic_media_group_device); } @Test public void getDrawableResIdByFeature_returnCorrectResId() { final ArrayList<String> features = new ArrayList<>(); features.add(FEATURE_REMOTE_VIDEO_PLAYBACK); when(mRouteInfo.getFeatures()).thenReturn(features); assertThat(mInfoMediaDevice.getDrawableResIdByFeature()).isEqualTo( R.drawable.ic_media_display_device); features.clear(); features.add(FEATURE_REMOTE_AUDIO_PLAYBACK); when(mRouteInfo.getFeatures()).thenReturn(features); assertThat(mInfoMediaDevice.getDrawableResIdByFeature()).isEqualTo( R.drawable.ic_media_speaker_device); features.clear(); features.add(FEATURE_REMOTE_GROUP_PLAYBACK); when(mRouteInfo.getFeatures()).thenReturn(features); assertThat(mInfoMediaDevice.getDrawableResIdByFeature()).isEqualTo( R.drawable.ic_media_group_device); } } services/core/java/com/android/server/wm/KeyguardController.java +4 −3 Original line number Diff line number Diff line Loading @@ -133,10 +133,11 @@ class KeyguardController { * Update the Keyguard showing state. */ void setKeyguardShown(boolean keyguardShowing, boolean aodShowing) { // If keyguard is going away, but SystemUI aborted the transition, need to reset state. final boolean keyguardChanged = keyguardShowing != mKeyguardShowing || mKeyguardGoingAway && keyguardShowing; final boolean aodChanged = aodShowing != mAodShowing; // If keyguard is going away, but SystemUI aborted the transition, need to reset state. // Do not reset keyguardChanged status if this is aodChanged. final boolean keyguardChanged = (keyguardShowing != mKeyguardShowing) || (mKeyguardGoingAway && keyguardShowing && !aodChanged); if (!keyguardChanged && !aodChanged) { return; } Loading Loading
core/java/android/app/Notification.java +23 −17 Original line number Diff line number Diff line Loading @@ -96,9 +96,9 @@ import com.android.internal.util.ContrastColorUtil; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.reflect.Array; import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Objects; Loading Loading @@ -1620,7 +1620,7 @@ public class Notification implements Parcelable * of non-textual RemoteInputs do not access these remote inputs. */ public RemoteInput[] getDataOnlyRemoteInputs() { return (RemoteInput[]) mExtras.getParcelableArray(EXTRA_DATA_ONLY_INPUTS); return getParcelableArrayFromBundle(mExtras, EXTRA_DATA_ONLY_INPUTS, RemoteInput.class); } /** Loading Loading @@ -1802,8 +1802,8 @@ public class Notification implements Parcelable checkContextualActionNullFields(); ArrayList<RemoteInput> dataOnlyInputs = new ArrayList<>(); RemoteInput[] previousDataInputs = (RemoteInput[]) mExtras.getParcelableArray(EXTRA_DATA_ONLY_INPUTS); RemoteInput[] previousDataInputs = getParcelableArrayFromBundle( mExtras, EXTRA_DATA_ONLY_INPUTS, RemoteInput.class); if (previousDataInputs != null) { for (RemoteInput input : previousDataInputs) { dataOnlyInputs.add(input); Loading Loading @@ -5368,8 +5368,8 @@ public class Notification implements Parcelable big.setViewVisibility(R.id.actions_container, View.GONE); } RemoteInputHistoryItem[] replyText = (RemoteInputHistoryItem[]) mN.extras.getParcelableArray(EXTRA_REMOTE_INPUT_HISTORY_ITEMS); RemoteInputHistoryItem[] replyText = getParcelableArrayFromBundle( mN.extras, EXTRA_REMOTE_INPUT_HISTORY_ITEMS, RemoteInputHistoryItem.class); if (validRemoteInput && replyText != null && replyText.length > 0 && !TextUtils.isEmpty(replyText[0].getText()) && p.maxRemoteInputHistory > 0) { Loading Loading @@ -8155,8 +8155,9 @@ public class Notification implements Parcelable if (mBuilder.mActions.size() > 0) { maxRows--; } RemoteInputHistoryItem[] remoteInputHistory = (RemoteInputHistoryItem[]) mBuilder.mN.extras.getParcelableArray(EXTRA_REMOTE_INPUT_HISTORY_ITEMS); RemoteInputHistoryItem[] remoteInputHistory = getParcelableArrayFromBundle( mBuilder.mN.extras, EXTRA_REMOTE_INPUT_HISTORY_ITEMS, RemoteInputHistoryItem.class); if (remoteInputHistory != null && remoteInputHistory.length > NUMBER_OF_HISTORY_ALLOWED_UNTIL_REDUCTION) { // Let's remove some messages to make room for the remote input history. Loading Loading @@ -9579,8 +9580,8 @@ public class Notification implements Parcelable mFlags = wearableBundle.getInt(KEY_FLAGS, DEFAULT_FLAGS); mDisplayIntent = wearableBundle.getParcelable(KEY_DISPLAY_INTENT); Notification[] pages = getNotificationArrayFromBundle( wearableBundle, KEY_PAGES); Notification[] pages = getParcelableArrayFromBundle( wearableBundle, KEY_PAGES, Notification.class); if (pages != null) { Collections.addAll(mPages, pages); } Loading Loading @@ -10838,17 +10839,22 @@ public class Notification implements Parcelable } /** * Get an array of Notification objects from a parcelable array bundle field. * Get an array of Parcelable objects from a parcelable array bundle field. * Update the bundle to have a typed array so fetches in the future don't need * to do an array copy. */ private static Notification[] getNotificationArrayFromBundle(Bundle bundle, String key) { Parcelable[] array = bundle.getParcelableArray(key); if (array instanceof Notification[] || array == null) { return (Notification[]) array; @Nullable private static <T extends Parcelable> T[] getParcelableArrayFromBundle( Bundle bundle, String key, Class<T> itemClass) { final Parcelable[] array = bundle.getParcelableArray(key); final Class<?> arrayClass = Array.newInstance(itemClass, 0).getClass(); if (arrayClass.isInstance(array) || array == null) { return (T[]) array; } final T[] typedArray = (T[]) Array.newInstance(itemClass, array.length); for (int i = 0; i < array.length; i++) { typedArray[i] = (T) array[i]; } Notification[] typedArray = Arrays.copyOf(array, array.length, Notification[].class); bundle.putParcelableArray(key, typedArray); return typedArray; } Loading
packages/SettingsLib/res/drawable/ic_media_display_device.xml +6 −10 Original line number Diff line number Diff line Loading @@ -15,16 +15,12 @@ limitations under the License. --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="14dp" android:height="11dp" android:viewportWidth="14" android:viewportHeight="11" android:tint="?android:attr/colorControlNormal"> android:width="18dp" android:height="18dp" android:viewportWidth="18" android:viewportHeight="18"> <path android:pathData="M10,10v1H4v-1H1.5A1.5,1.5 0,0 1,0 8.5v-7A1.5,1.5 0, 0 1,1.5 0h11A1.5,1.5 0,0 1,14 1.5v7a1.5,1.5 0,0 1,-1.5 1.5H10zM1.5, 1a0.5,0.5 0,0 0,-0.5 0.5v7a0.5,0.5 0,0 0,0.5 0.5h11a0.5,0.5 0,0 0, 0.5 -0.5v-7a0.5,0.5 0,0 0,-0.5 -0.5h-11z" android:fillColor="#000000" android:pathData="M12,14V15H6V14H3.5C3.1022,14 2.7206,13.842 2.4393,13.5607C2.158,13.2794 2,12.8978 2,12.5V5.5C2,5.1022 2.158,4.7206 2.4393,4.4393C2.7206,4.158 3.1022,4 3.5,4H14.5C14.8978,4 15.2794,4.158 15.5607,4.4393C15.842,4.7206 16,5.1022 16,5.5V12.5C16,12.8978 15.842,13.2794 15.5607,13.5607C15.2794,13.842 14.8978,14 14.5,14H12ZM3.5,5C3.3674,5 3.2402,5.0527 3.1465,5.1465C3.0527,5.2402 3,5.3674 3,5.5V12.5C3,12.6326 3.0527,12.7598 3.1465,12.8536C3.2402,12.9473 3.3674,13 3.5,13H14.5C14.6326,13 14.7598,12.9473 14.8536,12.8536C14.9473,12.7598 15,12.6326 15,12.5V5.5C15,5.3674 14.9473,5.2402 14.8536,5.1465C14.7598,5.0527 14.6326,5 14.5,5H3.5Z" android:fillColor="#5F6368" android:fillType="evenOdd"/> </vector> No newline at end of file
packages/SettingsLib/src/com/android/settingslib/media/InfoMediaDevice.java +20 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ */ package com.android.settingslib.media; import static android.media.MediaRoute2Info.FEATURE_REMOTE_GROUP_PLAYBACK; import static android.media.MediaRoute2Info.FEATURE_REMOTE_VIDEO_PLAYBACK; import static android.media.MediaRoute2Info.TYPE_GROUP; import static android.media.MediaRoute2Info.TYPE_REMOTE_SPEAKER; import static android.media.MediaRoute2Info.TYPE_REMOTE_TV; Loading @@ -29,6 +31,8 @@ import androidx.annotation.VisibleForTesting; import com.android.settingslib.R; import com.android.settingslib.bluetooth.BluetoothUtils; import java.util.List; /** * InfoMediaDevice extends MediaDevice to represents wifi device. */ Loading Loading @@ -62,7 +66,7 @@ public class InfoMediaDevice extends MediaDevice { @Override public Drawable getIconWithoutBackground() { return mContext.getDrawable(getDrawableResId()); return mContext.getDrawable(getDrawableResIdByFeature()); } @VisibleForTesting Loading @@ -83,6 +87,21 @@ public class InfoMediaDevice extends MediaDevice { return resId; } @VisibleForTesting int getDrawableResIdByFeature() { int resId; final List<String> features = mRouteInfo.getFeatures(); if (features.contains(FEATURE_REMOTE_GROUP_PLAYBACK)) { resId = R.drawable.ic_media_group_device; } else if (features.contains(FEATURE_REMOTE_VIDEO_PLAYBACK)) { resId = R.drawable.ic_media_display_device; } else { resId = R.drawable.ic_media_speaker_device; } return resId; } @Override public String getId() { return MediaDeviceUtils.getId(mRouteInfo); Loading
packages/SettingsLib/tests/robotests/src/com/android/settingslib/media/InfoMediaDeviceTest.java +29 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.settingslib.media; import static android.media.MediaRoute2Info.FEATURE_REMOTE_AUDIO_PLAYBACK; import static android.media.MediaRoute2Info.FEATURE_REMOTE_GROUP_PLAYBACK; import static android.media.MediaRoute2Info.FEATURE_REMOTE_VIDEO_PLAYBACK; import static android.media.MediaRoute2Info.TYPE_GROUP; import static android.media.MediaRoute2Info.TYPE_REMOTE_SPEAKER; import static android.media.MediaRoute2Info.TYPE_REMOTE_TV; Loading @@ -38,6 +41,8 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import java.util.ArrayList; @RunWith(RobolectricTestRunner.class) public class InfoMediaDeviceTest { Loading Loading @@ -107,4 +112,28 @@ public class InfoMediaDeviceTest { assertThat(mInfoMediaDevice.getDrawableResId()).isEqualTo(R.drawable.ic_media_group_device); } @Test public void getDrawableResIdByFeature_returnCorrectResId() { final ArrayList<String> features = new ArrayList<>(); features.add(FEATURE_REMOTE_VIDEO_PLAYBACK); when(mRouteInfo.getFeatures()).thenReturn(features); assertThat(mInfoMediaDevice.getDrawableResIdByFeature()).isEqualTo( R.drawable.ic_media_display_device); features.clear(); features.add(FEATURE_REMOTE_AUDIO_PLAYBACK); when(mRouteInfo.getFeatures()).thenReturn(features); assertThat(mInfoMediaDevice.getDrawableResIdByFeature()).isEqualTo( R.drawable.ic_media_speaker_device); features.clear(); features.add(FEATURE_REMOTE_GROUP_PLAYBACK); when(mRouteInfo.getFeatures()).thenReturn(features); assertThat(mInfoMediaDevice.getDrawableResIdByFeature()).isEqualTo( R.drawable.ic_media_group_device); } }
services/core/java/com/android/server/wm/KeyguardController.java +4 −3 Original line number Diff line number Diff line Loading @@ -133,10 +133,11 @@ class KeyguardController { * Update the Keyguard showing state. */ void setKeyguardShown(boolean keyguardShowing, boolean aodShowing) { // If keyguard is going away, but SystemUI aborted the transition, need to reset state. final boolean keyguardChanged = keyguardShowing != mKeyguardShowing || mKeyguardGoingAway && keyguardShowing; final boolean aodChanged = aodShowing != mAodShowing; // If keyguard is going away, but SystemUI aborted the transition, need to reset state. // Do not reset keyguardChanged status if this is aodChanged. final boolean keyguardChanged = (keyguardShowing != mKeyguardShowing) || (mKeyguardGoingAway && keyguardShowing && !aodChanged); if (!keyguardChanged && !aodChanged) { return; } Loading