Snap for 6504394 from e0395188f5 to mainline-release

Change-Id: I74f29eb87ef6977b5549ac3877b351816afa63c6
This commit is contained in:
android-build-team Robot
2020-05-18 07:09:37 +00:00
11 changed files with 114 additions and 37 deletions

View File

@@ -4689,7 +4689,7 @@
<!-- Title for the 'virtual keyboard' preference sub-screen. [CHAR LIMIT=35] --> <!-- Title for the 'virtual keyboard' preference sub-screen. [CHAR LIMIT=35] -->
<string name="virtual_keyboard_category">On-screen keyboard</string> <string name="virtual_keyboard_category">On-screen keyboard</string>
<!-- Title for the 'available virtual keyboard' preference sub-screen. [CHAR LIMIT=35] --> <!-- Title for the 'available virtual keyboard' preference sub-screen. [CHAR LIMIT=35] -->
<string name="available_virtual_keyboard_category">Available virtual keyboard</string> <string name="available_virtual_keyboard_category">Available On-screen keyboard</string>
<!-- Title for the button to trigger the 'Manage keyboards' preference sub-screen, where the user can turn on/off installed virtual keyboards.[CHAR LIMIT=35] --> <!-- Title for the button to trigger the 'Manage keyboards' preference sub-screen, where the user can turn on/off installed virtual keyboards.[CHAR LIMIT=35] -->
<string name="add_virtual_keyboard">Manage on-screen keyboards</string> <string name="add_virtual_keyboard">Manage on-screen keyboards</string>
<!-- Title for the 'keyboard assistance' preference category. [CHAR LIMIT=35] --> <!-- Title for the 'keyboard assistance' preference category. [CHAR LIMIT=35] -->
@@ -4707,7 +4707,7 @@
<!-- Title for the 'Work profile keyboards & tools' preference category inside Languages and inputs'. [CHAR LIMIT=50] --> <!-- Title for the 'Work profile keyboards & tools' preference category inside Languages and inputs'. [CHAR LIMIT=50] -->
<string name="language_and_input_for_work_category_title">Work profile keyboards &amp; tools</string> <string name="language_and_input_for_work_category_title">Work profile keyboards &amp; tools</string>
<!-- Title for the 'Virtual keyboards for work' preference. [CHAR LIMIT=45] --> <!-- Title for the 'Virtual keyboards for work' preference. [CHAR LIMIT=45] -->
<string name="virtual_keyboards_for_work_title">Virtual keyboard for work</string> <string name="virtual_keyboards_for_work_title">On-screen keyboard for work</string>
<!-- Summary text for keyboards when no layout has been selected. [CHAR LIMIT=35] --> <!-- Summary text for keyboards when no layout has been selected. [CHAR LIMIT=35] -->
<string name="default_keyboard_layout">Default</string> <string name="default_keyboard_layout">Default</string>

View File

@@ -25,7 +25,8 @@
<com.android.settings.widget.GearPreference <com.android.settings.widget.GearPreference
android:key="default_assist" android:key="default_assist"
android:title="@string/default_digital_assistant_title" android:title="@string/default_digital_assistant_title"
android:summary="@string/summary_placeholder" /> android:summary="@string/summary_placeholder"
settings:searchable="false"/>
<Preference <Preference
android:key="gesture_assist_application" android:key="gesture_assist_application"

View File

@@ -19,6 +19,7 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto" xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="zen_mode_calls_settings_page" android:key="zen_mode_calls_settings_page"
settings:searchable="false"
android:title="@string/zen_mode_calls_title"> android:title="@string/zen_mode_calls_title">
<PreferenceCategory <PreferenceCategory

View File

@@ -17,7 +17,9 @@
<PreferenceScreen <PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="zen_mode_messages_settings_page" android:key="zen_mode_messages_settings_page"
settings:searchable="false"
android:title="@string/zen_mode_messages_title" > android:title="@string/zen_mode_messages_title" >
<PreferenceCategory <PreferenceCategory

View File

@@ -123,12 +123,12 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment
private CharSequence geTextAppearanceSummary(Context context) { private CharSequence geTextAppearanceSummary(Context context) {
final String[] fontSizeSummaries = context.getResources().getStringArray( 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 float fontSize = mCaptioningManager.getFontScale();
final int idx = Floats.indexOf(mFontSizeValuesArray, fontSize); 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 = public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =

View File

@@ -120,18 +120,10 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
if (!mCrossProfileApps.canConfigureInteractAcrossProfiles(mPackageName)) { if (!mCrossProfileApps.canConfigureInteractAcrossProfiles(mPackageName)) {
logNonConfigurableAppMetrics(); logNonConfigurableAppMetrics();
} }
Bundle bundle = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGS); if (launchedByApp()) {
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())) {
logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_LAUNCHED_FROM_APP); logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_LAUNCHED_FROM_APP);
} else {
logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_LAUNCHED_FROM_SETTINGS);
} }
} }
@@ -270,6 +262,9 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_USER_CONSENTED); logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_USER_CONSENTED);
enableInteractAcrossProfiles(true); enableInteractAcrossProfiles(true);
refreshUi(); refreshUi();
if (launchedByApp()) {
setIntentAndFinish(/* appChanged= */ true);
}
} }
}) })
.setNegativeButton(R.string.deny, new DialogInterface.OnClickListener() { .setNegativeButton(R.string.deny, new DialogInterface.OnClickListener() {
@@ -464,4 +459,16 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
public int getMetricsCategory() { public int getMetricsCategory() {
return SettingsEnums.INTERACT_ACROSS_PROFILES; 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());
}
} }

View File

@@ -618,12 +618,7 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
data.title = context.getString(R.string.storage_menu_free); data.title = context.getString(R.string.storage_menu_free);
data.key = KEY_STORAGE_SETTINGS_FREE_SPACE; data.key = KEY_STORAGE_SETTINGS_FREE_SPACE;
data.screenTitle = context.getString(R.string.storage_menu_free); 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.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); result.add(data);
return result; return result;

View File

@@ -73,7 +73,8 @@ public class MediaDeviceUpdateWorker extends SliceBackgroundWorker
protected void onSlicePinned() { protected void onSlicePinned() {
mMediaDevices.clear(); mMediaDevices.clear();
mIsTouched = false; mIsTouched = false;
if (mLocalMediaManager == null) { if (mLocalMediaManager == null || !TextUtils.equals(mPackageName,
mLocalMediaManager.getPackageName())) {
mLocalMediaManager = new LocalMediaManager(mContext, mPackageName, null); mLocalMediaManager = new LocalMediaManager(mContext, mPackageName, null);
} }

View File

@@ -81,14 +81,17 @@ public class MediaOutputIndicatorWorker extends SliceBackgroundWorker implements
mContext.registerReceiver(mReceiver, intentFilter); mContext.registerReceiver(mReceiver, intentFilter);
mLocalBluetoothManager.getEventManager().registerCallback(this); mLocalBluetoothManager.getEventManager().registerCallback(this);
if (mLocalMediaManager == null) { final MediaController controller = getActiveLocalMediaController();
final MediaController controller = getActiveLocalMediaController(); if (controller == null) {
if (controller != null) { mPackageName = null;
mPackageName = controller.getPackageName(); } else {
} mPackageName = controller.getPackageName();
mLocalMediaManager = new LocalMediaManager(mContext, mPackageName, null); }
if (mLocalMediaManager == null || !TextUtils.equals(mPackageName,
mLocalMediaManager.getPackageName())) {
mLocalMediaManager = new LocalMediaManager(mContext, mPackageName,
null /* notification */);
} }
mLocalMediaManager.registerCallback(this); mLocalMediaManager.registerCallback(this);
mLocalMediaManager.startScan(); mLocalMediaManager.startScan();
} }

View File

@@ -35,12 +35,17 @@ import android.media.RoutingSessionInfo;
import android.net.Uri; import android.net.Uri;
import com.android.settings.testutils.shadow.ShadowAudioManager; 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.LocalMediaManager;
import com.android.settingslib.media.MediaDevice; import com.android.settingslib.media.MediaDevice;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner; import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment; import org.robolectric.RuntimeEnvironment;
@@ -51,16 +56,28 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
@RunWith(RobolectricTestRunner.class) @RunWith(RobolectricTestRunner.class)
@Config(shadows = ShadowAudioManager.class) @Config(shadows = {ShadowAudioManager.class, ShadowBluetoothAdapter.class,
ShadowBluetoothUtils.class})
public class MediaDeviceUpdateWorkerTest { public class MediaDeviceUpdateWorkerTest {
private static final Uri URI = Uri.parse("content://com.android.settings.slices/test"); 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_1_ID = "test_device_1_id";
private static final String TEST_DEVICE_2_ID = "test_device_2_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 static final String TEST_DEVICE_3_ID = "test_device_3_id";
private final List<MediaDevice> mMediaDevices = new ArrayList<>(); private final List<MediaDevice> mMediaDevices = new ArrayList<>();
@Mock
private LocalBluetoothManager mLocalBluetoothManager;
@Mock
private BluetoothEventManager mBluetoothEventManager;
private MediaDeviceUpdateWorker mMediaDeviceUpdateWorker; private MediaDeviceUpdateWorker mMediaDeviceUpdateWorker;
private ContentResolver mResolver; private ContentResolver mResolver;
private Context mContext; private Context mContext;
@@ -209,4 +226,21 @@ public class MediaDeviceUpdateWorkerTest {
assertThat(mMediaDeviceUpdateWorker.getActiveRemoteMediaDevice()).containsExactly( assertThat(mMediaDeviceUpdateWorker.getActiveRemoteMediaDevice()).containsExactly(
remoteSessionInfo); 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);
}
} }

View File

@@ -62,6 +62,8 @@ import java.util.List;
@Config(shadows = {ShadowBluetoothAdapter.class, ShadowBluetoothUtils.class}) @Config(shadows = {ShadowBluetoothAdapter.class, ShadowBluetoothUtils.class})
public class MediaOutputIndicatorWorkerTest { public class MediaOutputIndicatorWorkerTest {
private static final Uri URI = Uri.parse("content://com.android.settings.slices/test"); 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 @Mock
private BluetoothEventManager mBluetoothEventManager; private BluetoothEventManager mBluetoothEventManager;
@@ -109,6 +111,33 @@ public class MediaOutputIndicatorWorkerTest {
verify(mLocalMediaManager).startScan(); 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 @Test
public void onSliceUnpinned_unRegisterCallback() { public void onSliceUnpinned_unRegisterCallback() {
mMediaOutputIndicatorWorker.mLocalMediaManager = mLocalMediaManager; mMediaOutputIndicatorWorker.mLocalMediaManager = mLocalMediaManager;
@@ -138,6 +167,16 @@ public class MediaOutputIndicatorWorkerTest {
@Test @Test
public void getActiveLocalMediaController_localMediaPlaying_returnController() { 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( mPlaybackInfo = new MediaController.PlaybackInfo(
MediaController.PlaybackInfo.PLAYBACK_TYPE_LOCAL, MediaController.PlaybackInfo.PLAYBACK_TYPE_LOCAL,
VolumeProvider.VOLUME_CONTROL_ABSOLUTE, VolumeProvider.VOLUME_CONTROL_ABSOLUTE,
@@ -148,12 +187,6 @@ public class MediaOutputIndicatorWorkerTest {
mPlaybackState = new PlaybackState.Builder() mPlaybackState = new PlaybackState.Builder()
.setState(PlaybackState.STATE_PLAYING, 0, 1) .setState(PlaybackState.STATE_PLAYING, 0, 1)
.build(); .build();
when(mMediaController.getPlaybackInfo()).thenReturn(mPlaybackInfo);
when(mMediaController.getPlaybackState()).thenReturn(mPlaybackState);
assertThat(mMediaOutputIndicatorWorker.getActiveLocalMediaController()).isEqualTo(
mMediaController);
} }
@Test @Test