diff options
-rw-r--r-- | src/com/android/documentsui/files/ActionHandler.java | 25 | ||||
-rw-r--r-- | tests/unit/com/android/documentsui/files/ActionHandlerTest.java | 13 |
2 files changed, 32 insertions, 6 deletions
diff --git a/src/com/android/documentsui/files/ActionHandler.java b/src/com/android/documentsui/files/ActionHandler.java index 20b831856..1fa771178 100644 --- a/src/com/android/documentsui/files/ActionHandler.java +++ b/src/com/android/documentsui/files/ActionHandler.java @@ -19,10 +19,12 @@ package com.android.documentsui.files; import static android.content.ContentResolver.wrap; import static com.android.documentsui.base.SharedMinimal.DEBUG; +import static com.android.documentsui.flags.Flags.desktopFileHandling; import android.app.DownloadManager; import android.content.ActivityNotFoundException; import android.content.ClipData; +import android.content.ComponentName; import android.content.ContentProviderClient; import android.content.ContentResolver; import android.content.Intent; @@ -543,12 +545,23 @@ public class ActionHandler<T extends FragmentActivity & AbstractActionHandler.Co return; } - Intent intent = Intent.createChooser(buildViewIntent(doc), null); - intent.putExtra(Intent.EXTRA_AUTO_LAUNCH_SINGLE_CHOICE, false); - try { - doc.userId.startActivityAsUser(mActivity, intent); - } catch (ActivityNotFoundException e) { - mDialogs.showNoApplicationFound(); + if (desktopFileHandling()) { + Intent intent = buildViewIntent(doc); + intent.setComponent( + new ComponentName("android", "com.android.internal.app.ResolverActivity")); + try { + doc.userId.startActivityAsUser(mActivity, intent); + } catch (ActivityNotFoundException e) { + mDialogs.showNoApplicationFound(); + } + } else { + Intent intent = Intent.createChooser(buildViewIntent(doc), null); + intent.putExtra(Intent.EXTRA_AUTO_LAUNCH_SINGLE_CHOICE, false); + try { + doc.userId.startActivityAsUser(mActivity, intent); + } catch (ActivityNotFoundException e) { + mDialogs.showNoApplicationFound(); + } } } diff --git a/tests/unit/com/android/documentsui/files/ActionHandlerTest.java b/tests/unit/com/android/documentsui/files/ActionHandlerTest.java index 6aaa3e5d2..3de1a8ca7 100644 --- a/tests/unit/com/android/documentsui/files/ActionHandlerTest.java +++ b/tests/unit/com/android/documentsui/files/ActionHandlerTest.java @@ -460,6 +460,7 @@ public class ActionHandlerTest { } @Test + @DisableFlags({Flags.FLAG_DESKTOP_FILE_HANDLING}) public void testShowChooser() throws Exception { mActivity.currentRoot = TestProvidersAccess.DOWNLOADS; @@ -468,6 +469,18 @@ public class ActionHandlerTest { } @Test + @EnableFlags({Flags.FLAG_DESKTOP_FILE_HANDLING}) + public void testShowChooserDesktop() throws Exception { + mActivity.currentRoot = TestProvidersAccess.DOWNLOADS; + + mHandler.showChooserForDoc(TestEnv.FILE_PDF); + Intent actual = mActivity.startActivity.getLastValue(); + assertEquals(Intent.ACTION_VIEW, actual.getAction()); + assertEquals("ComponentInfo{android/com.android.internal.app.ResolverActivity}", + actual.getComponent().toString()); + } + + @Test public void testInitLocation_LaunchToStackLocation() { DocumentStack path = new DocumentStack(Roots.create("123"), mEnv.model.getDocument("1")); |