From 2d01be108d6c9ca07302dd45674ce45b40ed8160 Mon Sep 17 00:00:00 2001 From: Garfield Tan Date: Wed, 1 Mar 2017 11:04:35 -0800 Subject: [PATCH] Remove DocumentsContract.ACTION_BROWSE. Test: Code builds and tests pass. Bug: 35760993 Change-Id: I7e540b71a7be60d250ffec899eb5c08941dc24a8 --- .../MusicViewHolderController.java | 6 ++++-- .../deviceinfo/PrivateVolumeSettings.java | 18 ++++++++++++------ .../MusicViewHolderControllerTest.java | 3 ++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/com/android/settings/applications/MusicViewHolderController.java b/src/com/android/settings/applications/MusicViewHolderController.java index d7c142ff664..4599fcc24c6 100644 --- a/src/com/android/settings/applications/MusicViewHolderController.java +++ b/src/com/android/settings/applications/MusicViewHolderController.java @@ -68,8 +68,10 @@ public class MusicViewHolderController implements FileViewHolderController { @Override public void onClick(Fragment fragment) { - Intent intent = new Intent(DocumentsContract.ACTION_BROWSE); - intent.setData(DocumentsContract.buildRootUri(AUTHORITY_MEDIA, "audio_root")); + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setDataAndType( + DocumentsContract.buildRootUri(AUTHORITY_MEDIA, "audio_root"), + DocumentsContract.Root.MIME_TYPE_ITEM); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.putExtra(Intent.EXTRA_USER_ID, mUser); Utils.launchIntent(fragment, intent); diff --git a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java index eb07a7fd4af..076ec05b894 100644 --- a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java +++ b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java @@ -483,20 +483,26 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment { } break; case R.string.storage_detail_images: { - intent = new Intent(DocumentsContract.ACTION_BROWSE); - intent.setData(DocumentsContract.buildRootUri(AUTHORITY_MEDIA, "images_root")); + intent = new Intent(Intent.ACTION_VIEW); + intent.setDataAndType( + DocumentsContract.buildRootUri(AUTHORITY_MEDIA, "images_root"), + DocumentsContract.Root.MIME_TYPE_ITEM); intent.addCategory(Intent.CATEGORY_DEFAULT); } break; case R.string.storage_detail_videos: { - intent = new Intent(DocumentsContract.ACTION_BROWSE); - intent.setData(DocumentsContract.buildRootUri(AUTHORITY_MEDIA, "videos_root")); + intent = new Intent(Intent.ACTION_VIEW); + intent.setDataAndType( + DocumentsContract.buildRootUri(AUTHORITY_MEDIA, "videos_root"), + DocumentsContract.Root.MIME_TYPE_ITEM); intent.addCategory(Intent.CATEGORY_DEFAULT); } break; case R.string.storage_detail_audio: { - intent = new Intent(DocumentsContract.ACTION_BROWSE); - intent.setData(DocumentsContract.buildRootUri(AUTHORITY_MEDIA, "audio_root")); + intent = new Intent(DocumentsContract.Root.MIME_TYPE_ITEM); + intent.setDataAndType( + DocumentsContract.buildRootUri(AUTHORITY_MEDIA, "audio_root"), + DocumentsContract.Root.MIME_TYPE_ITEM); intent.addCategory(Intent.CATEGORY_DEFAULT); } break; diff --git a/tests/robotests/src/com/android/settings/applications/MusicViewHolderControllerTest.java b/tests/robotests/src/com/android/settings/applications/MusicViewHolderControllerTest.java index 592293d8f7b..9bc74827c22 100644 --- a/tests/robotests/src/com/android/settings/applications/MusicViewHolderControllerTest.java +++ b/tests/robotests/src/com/android/settings/applications/MusicViewHolderControllerTest.java @@ -99,9 +99,10 @@ public class MusicViewHolderControllerTest { verify(mFragment).startActivity(argumentCaptor.capture()); Intent intent = argumentCaptor.getValue(); - assertThat(intent.getAction()).isEqualTo(DocumentsContract.ACTION_BROWSE); + assertThat(intent.getAction()).isEqualTo(Intent.ACTION_VIEW); assertThat(intent.getData()).isEqualTo(DocumentsContract.buildRootUri( "com.android.providers.media.documents", "audio_root")); + assertThat(intent.getType()).isEqualTo(DocumentsContract.Root.MIME_TYPE_ITEM); } }