From 4c5c80d42168d65e519b8387558b027bdc4cc31d Mon Sep 17 00:00:00 2001 From: Stanley Wang Date: Tue, 12 May 2020 19:26:06 +0800 Subject: [PATCH 1/8] Fix the search result "Free up space" doesn't work. Can't find the target component if add the class name and package name to the intent. So remove them. Fixes: 152682394 Test: manual test the search result Change-Id: I3b69486f6338b458c795860f7b3de9c119cb09de --- src/com/android/settings/deviceinfo/StorageSettings.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/com/android/settings/deviceinfo/StorageSettings.java b/src/com/android/settings/deviceinfo/StorageSettings.java index de6394e61ea..14f8deaa44e 100644 --- a/src/com/android/settings/deviceinfo/StorageSettings.java +++ b/src/com/android/settings/deviceinfo/StorageSettings.java @@ -618,12 +618,7 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index data.title = context.getString(R.string.storage_menu_free); data.key = KEY_STORAGE_SETTINGS_FREE_SPACE; data.screenTitle = context.getString(R.string.storage_menu_free); - // We need to define all three in order for this to trigger properly. data.intentAction = StorageManager.ACTION_MANAGE_STORAGE; - data.intentTargetPackage = - context.getString(R.string.config_deletion_helper_package); - data.intentTargetClass = - context.getString(R.string.config_deletion_helper_class); result.add(data); return result; From badcb4e415e226de347c020389a43473979f370d Mon Sep 17 00:00:00 2001 From: Edgar Wang Date: Fri, 15 May 2020 00:48:05 +0800 Subject: [PATCH 2/8] Remove duplicate search result when search "Calls" and "Messages". Settings indexed entries and screen title both, which caused duplicated result. so we make screen title as non-searchable to resolve duplicate. Bug: 155849111 Test: manual Change-Id: I2d0dd718c25499a574a35509d99668358ce07baa --- res/xml/zen_mode_calls_settings.xml | 1 + res/xml/zen_mode_messages_settings.xml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/res/xml/zen_mode_calls_settings.xml b/res/xml/zen_mode_calls_settings.xml index f54c496fa33..acd802334c3 100644 --- a/res/xml/zen_mode_calls_settings.xml +++ b/res/xml/zen_mode_calls_settings.xml @@ -19,6 +19,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:settings="http://schemas.android.com/apk/res-auto" android:key="zen_mode_calls_settings_page" + settings:searchable="false" android:title="@string/zen_mode_calls_title"> Date: Fri, 15 May 2020 13:42:24 +0800 Subject: [PATCH 3/8] Update string to keep On-screen keyboard naming consistent Bug: 153675083 Test: manual Change-Id: I64a193435bbf189cc417410e736f73d789fbbe1e --- res/values/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 366254f2bc7..a1dd0dfbfe4 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -4689,7 +4689,7 @@ On-screen keyboard - Available virtual keyboard + Available On-screen keyboard Manage on-screen keyboards @@ -4707,7 +4707,7 @@ Work profile keyboards & tools - Virtual keyboard for work + On-screen keyboard for work Default From a5280fcc51bbf04d57e41df4caf91f05d2f10b1a Mon Sep 17 00:00:00 2001 From: Tim Peng Date: Thu, 14 May 2020 12:37:45 +0800 Subject: [PATCH 4/8] "Play null on" displayed under media volume -Reset package name when it is different with previous one -Add test case Bug: 156224161 Test: make -j50 RunSettingsRoboTests Change-Id: Ifcacc171d86017b702f51343036e0ebf0e0d1989 --- .../media/MediaOutputIndicatorWorker.java | 17 ++++--- .../media/MediaOutputIndicatorWorkerTest.java | 45 ++++++++++++++++--- 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/src/com/android/settings/media/MediaOutputIndicatorWorker.java b/src/com/android/settings/media/MediaOutputIndicatorWorker.java index e04f1dd28a1..0c6c434c9dd 100644 --- a/src/com/android/settings/media/MediaOutputIndicatorWorker.java +++ b/src/com/android/settings/media/MediaOutputIndicatorWorker.java @@ -81,14 +81,17 @@ public class MediaOutputIndicatorWorker extends SliceBackgroundWorker implements mContext.registerReceiver(mReceiver, intentFilter); mLocalBluetoothManager.getEventManager().registerCallback(this); - if (mLocalMediaManager == null) { - final MediaController controller = getActiveLocalMediaController(); - if (controller != null) { - mPackageName = controller.getPackageName(); - } - mLocalMediaManager = new LocalMediaManager(mContext, mPackageName, null); + final MediaController controller = getActiveLocalMediaController(); + if (controller == null) { + mPackageName = null; + } else { + mPackageName = controller.getPackageName(); + } + if (mLocalMediaManager == null || !TextUtils.equals(mPackageName, + mLocalMediaManager.getPackageName())) { + mLocalMediaManager = new LocalMediaManager(mContext, mPackageName, + null /* notification */); } - mLocalMediaManager.registerCallback(this); mLocalMediaManager.startScan(); } diff --git a/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorWorkerTest.java b/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorWorkerTest.java index d96541d43b6..dd3a2367780 100644 --- a/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorWorkerTest.java +++ b/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorWorkerTest.java @@ -62,6 +62,8 @@ import java.util.List; @Config(shadows = {ShadowBluetoothAdapter.class, ShadowBluetoothUtils.class}) public class MediaOutputIndicatorWorkerTest { private static final Uri URI = Uri.parse("content://com.android.settings.slices/test"); + private static final String TEST_PACKAGE_NAME = "com.android.test"; + private static final String TEST_PACKAGE_NAME2 = "com.android.test2"; @Mock private BluetoothEventManager mBluetoothEventManager; @@ -109,6 +111,33 @@ public class MediaOutputIndicatorWorkerTest { verify(mLocalMediaManager).startScan(); } + @Test + public void onSlicePinned_packageUpdated_checkPackageName() { + initPlayback(); + when(mMediaController.getPlaybackInfo()).thenReturn(mPlaybackInfo); + when(mMediaController.getPlaybackState()).thenReturn(mPlaybackState); + when(mMediaController.getPackageName()).thenReturn(TEST_PACKAGE_NAME); + + mMediaOutputIndicatorWorker.onSlicePinned(); + assertThat(mMediaOutputIndicatorWorker.mLocalMediaManager.getPackageName()).matches( + TEST_PACKAGE_NAME); + + when(mMediaController.getPackageName()).thenReturn(TEST_PACKAGE_NAME2); + mMediaOutputIndicatorWorker.onSlicePinned(); + + assertThat(mMediaOutputIndicatorWorker.mLocalMediaManager.getPackageName()).matches( + TEST_PACKAGE_NAME2); + } + + @Test + public void onSlicePinned_noActiveController_noPackageName() { + mMediaControllers.clear(); + + mMediaOutputIndicatorWorker.onSlicePinned(); + + assertThat(mMediaOutputIndicatorWorker.mLocalMediaManager.getPackageName()).isNull(); + } + @Test public void onSliceUnpinned_unRegisterCallback() { mMediaOutputIndicatorWorker.mLocalMediaManager = mLocalMediaManager; @@ -138,6 +167,16 @@ public class MediaOutputIndicatorWorkerTest { @Test public void getActiveLocalMediaController_localMediaPlaying_returnController() { + initPlayback(); + + when(mMediaController.getPlaybackInfo()).thenReturn(mPlaybackInfo); + when(mMediaController.getPlaybackState()).thenReturn(mPlaybackState); + + assertThat(mMediaOutputIndicatorWorker.getActiveLocalMediaController()).isEqualTo( + mMediaController); + } + + private void initPlayback() { mPlaybackInfo = new MediaController.PlaybackInfo( MediaController.PlaybackInfo.PLAYBACK_TYPE_LOCAL, VolumeProvider.VOLUME_CONTROL_ABSOLUTE, @@ -148,12 +187,6 @@ public class MediaOutputIndicatorWorkerTest { mPlaybackState = new PlaybackState.Builder() .setState(PlaybackState.STATE_PLAYING, 0, 1) .build(); - - when(mMediaController.getPlaybackInfo()).thenReturn(mPlaybackInfo); - when(mMediaController.getPlaybackState()).thenReturn(mPlaybackState); - - assertThat(mMediaOutputIndicatorWorker.getActiveLocalMediaController()).isEqualTo( - mMediaController); } @Test From 77bec31eb58e00c6df21c2349e02478073e14334 Mon Sep 17 00:00:00 2001 From: Tim Peng Date: Thu, 14 May 2020 14:02:48 +0800 Subject: [PATCH 5/8] Output switcher shows the device list by an incorrect package name -Reset package name when it is different with previous one -Add test case Bug: 156561856 Test: make -j50 RunSettingsRoboTests Change-Id: I7931ebbc59ab404f12473fe29f2735ad3a8197fd --- .../media/MediaDeviceUpdateWorker.java | 3 +- .../media/MediaDeviceUpdateWorkerTest.java | 36 ++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/media/MediaDeviceUpdateWorker.java b/src/com/android/settings/media/MediaDeviceUpdateWorker.java index 92cc0e37003..a97681165d4 100644 --- a/src/com/android/settings/media/MediaDeviceUpdateWorker.java +++ b/src/com/android/settings/media/MediaDeviceUpdateWorker.java @@ -73,7 +73,8 @@ public class MediaDeviceUpdateWorker extends SliceBackgroundWorker protected void onSlicePinned() { mMediaDevices.clear(); mIsTouched = false; - if (mLocalMediaManager == null) { + if (mLocalMediaManager == null || !TextUtils.equals(mPackageName, + mLocalMediaManager.getPackageName())) { mLocalMediaManager = new LocalMediaManager(mContext, mPackageName, null); } diff --git a/tests/robotests/src/com/android/settings/media/MediaDeviceUpdateWorkerTest.java b/tests/robotests/src/com/android/settings/media/MediaDeviceUpdateWorkerTest.java index e8f70271487..624bbd8101f 100644 --- a/tests/robotests/src/com/android/settings/media/MediaDeviceUpdateWorkerTest.java +++ b/tests/robotests/src/com/android/settings/media/MediaDeviceUpdateWorkerTest.java @@ -35,12 +35,17 @@ import android.media.RoutingSessionInfo; import android.net.Uri; import com.android.settings.testutils.shadow.ShadowAudioManager; +import com.android.settings.testutils.shadow.ShadowBluetoothAdapter; +import com.android.settings.testutils.shadow.ShadowBluetoothUtils; +import com.android.settingslib.bluetooth.BluetoothEventManager; +import com.android.settingslib.bluetooth.LocalBluetoothManager; import com.android.settingslib.media.LocalMediaManager; import com.android.settingslib.media.MediaDevice; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; @@ -51,16 +56,28 @@ import java.util.ArrayList; import java.util.List; @RunWith(RobolectricTestRunner.class) -@Config(shadows = ShadowAudioManager.class) +@Config(shadows = {ShadowAudioManager.class, ShadowBluetoothAdapter.class, + ShadowBluetoothUtils.class}) public class MediaDeviceUpdateWorkerTest { private static final Uri URI = Uri.parse("content://com.android.settings.slices/test"); + private static final Uri URI1 = Uri.parse("content://com.android.settings.slices/action/" + + "media_output?media_package_name=com.music1"); + private static final Uri URI2 = Uri.parse("content://com.android.settings.slices/action/" + + "media_output?media_package_name=com.music2"); + private static final String TEST_DEVICE_PACKAGE_NAME1 = "com.music1"; + private static final String TEST_DEVICE_PACKAGE_NAME2 = "com.music2"; private static final String TEST_DEVICE_1_ID = "test_device_1_id"; private static final String TEST_DEVICE_2_ID = "test_device_2_id"; private static final String TEST_DEVICE_3_ID = "test_device_3_id"; private final List mMediaDevices = new ArrayList<>(); + @Mock + private LocalBluetoothManager mLocalBluetoothManager; + @Mock + private BluetoothEventManager mBluetoothEventManager; + private MediaDeviceUpdateWorker mMediaDeviceUpdateWorker; private ContentResolver mResolver; private Context mContext; @@ -209,4 +226,21 @@ public class MediaDeviceUpdateWorkerTest { assertThat(mMediaDeviceUpdateWorker.getActiveRemoteMediaDevice()).containsExactly( remoteSessionInfo); } + + @Test + public void onSlicePinned_packageUpdated_checkPackageName() { + ShadowBluetoothUtils.sLocalBluetoothManager = mLocalBluetoothManager; + when(mLocalBluetoothManager.getEventManager()).thenReturn(mBluetoothEventManager); + mMediaDeviceUpdateWorker = new MediaDeviceUpdateWorker(mContext, URI1); + mMediaDeviceUpdateWorker.onSlicePinned(); + + assertThat(mMediaDeviceUpdateWorker.mLocalMediaManager.getPackageName()).matches( + TEST_DEVICE_PACKAGE_NAME1); + + mMediaDeviceUpdateWorker = new MediaDeviceUpdateWorker(mContext, URI2); + mMediaDeviceUpdateWorker.onSlicePinned(); + + assertThat(mMediaDeviceUpdateWorker.mLocalMediaManager.getPackageName()).matches( + TEST_DEVICE_PACKAGE_NAME2); + } } From d3fa045e351bf195055cb962df77367171f08150 Mon Sep 17 00:00:00 2001 From: Alex Kershaw Date: Sat, 16 May 2020 20:30:26 +0100 Subject: [PATCH 6/8] Close Settings page when cross-profile appop is granted Fixes: 156365481 Test: manual Change-Id: I9250ef5db0c40a42a25a2dedf84a47d1b1da11f1 --- .../InteractAcrossProfilesDetails.java | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java index ad47c03a90b..4e7a9e9372e 100644 --- a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java +++ b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java @@ -120,18 +120,10 @@ public class InteractAcrossProfilesDetails extends AppInfoBase if (!mCrossProfileApps.canConfigureInteractAcrossProfiles(mPackageName)) { logNonConfigurableAppMetrics(); } - Bundle bundle = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGS); - if (bundle == null) { - logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_LAUNCHED_FROM_SETTINGS); - return; - } - Intent intent = (Intent) bundle.get(INTENT_KEY); - if (intent == null) { - logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_LAUNCHED_FROM_SETTINGS); - return; - } - if (ACTION_MANAGE_CROSS_PROFILE_ACCESS.equals(intent.getAction())) { + if (launchedByApp()) { logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_LAUNCHED_FROM_APP); + } else { + logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_LAUNCHED_FROM_SETTINGS); } } @@ -275,6 +267,9 @@ public class InteractAcrossProfilesDetails extends AppInfoBase logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_USER_CONSENTED); enableInteractAcrossProfiles(true); refreshUi(); + if (launchedByApp()) { + setIntentAndFinish(/* appChanged= */ true); + } } }) .setNegativeButton(R.string.deny, new DialogInterface.OnClickListener() { @@ -469,4 +464,16 @@ public class InteractAcrossProfilesDetails extends AppInfoBase public int getMetricsCategory() { return SettingsEnums.INTERACT_ACROSS_PROFILES; } + + private boolean launchedByApp() { + final Bundle bundle = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGS); + if (bundle == null) { + return false; + } + final Intent intent = (Intent) bundle.get(INTENT_KEY); + if (intent == null) { + return false; + } + return ACTION_MANAGE_CROSS_PROFILE_ACCESS.equals(intent.getAction()); + } } From 2282386c99cf45eef2f0b40c899110955601e98e Mon Sep 17 00:00:00 2001 From: jasonwshsu Date: Tue, 5 May 2020 11:14:30 +0800 Subject: [PATCH 7/8] Change caption summary to get the whole translated string directly. Bug: 154076977 Test: manual test Change-Id: I9ddf1d52c1632c203713466dd9cf7b15de018a4d --- .../settings/accessibility/CaptionPropertiesFragment.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/accessibility/CaptionPropertiesFragment.java b/src/com/android/settings/accessibility/CaptionPropertiesFragment.java index 40eb2cd7ef7..786585ad72e 100644 --- a/src/com/android/settings/accessibility/CaptionPropertiesFragment.java +++ b/src/com/android/settings/accessibility/CaptionPropertiesFragment.java @@ -123,12 +123,12 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment private CharSequence geTextAppearanceSummary(Context context) { final String[] fontSizeSummaries = context.getResources().getStringArray( - R.array.captioning_font_size_selector_titles); + R.array.captioning_font_size_selector_summaries); final float fontSize = mCaptioningManager.getFontScale(); final int idx = Floats.indexOf(mFontSizeValuesArray, fontSize); - final String fontSizeSummary = fontSizeSummaries[idx == /* not exist */ -1 ? 0 : idx]; - return context.getString(R.string.captioning_caption_appearance_summary, fontSizeSummary); + + return fontSizeSummaries[idx == /* not exist */ -1 ? 0 : idx]; } public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = From f0ca8d43096788fe8f0241f9e025a3723f3ba613 Mon Sep 17 00:00:00 2001 From: Edgar Wang Date: Fri, 15 May 2020 10:20:43 +0800 Subject: [PATCH 8/8] Remove duplicate search result of "Assistant apps" since even if user want to find "Default Assistant apps" preference, user still can find it when search the screen title or direct enter permission cotroller page. Bug: 155849417 Test: manual Change-Id: I10628ac24e13eca99611cf14cf17e89b1d072c85 --- res/xml/manage_assist.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/res/xml/manage_assist.xml b/res/xml/manage_assist.xml index 3430c0518ea..59ba2f53b9e 100644 --- a/res/xml/manage_assist.xml +++ b/res/xml/manage_assist.xml @@ -25,7 +25,8 @@ + android:summary="@string/summary_placeholder" + settings:searchable="false"/>