Loading AndroidManifest.xml +5 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,11 @@ <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="vnd.android.document/root" /> </intent-filter> <intent-filter> <action android:name="android.provider.action.BROWSE" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="vnd.android.document/directory" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW_DOWNLOADS" /> <category android:name="android.intent.category.DEFAULT" /> Loading src/com/android/documentsui/AbstractActionHandler.java +33 −0 Original line number Diff line number Diff line Loading @@ -22,12 +22,14 @@ import android.content.Intent; import android.content.pm.ResolveInfo; import android.net.Uri; import android.os.Parcelable; import android.provider.DocumentsContract; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.util.Log; import com.android.documentsui.AbstractActionHandler.CommonAddons; import com.android.documentsui.LoadDocStackTask.LoadDocStackCallback; import com.android.documentsui.archives.ArchivesProvider; import com.android.documentsui.base.BooleanConsumer; import com.android.documentsui.base.DocumentInfo; import com.android.documentsui.base.DocumentStack; Loading Loading @@ -287,6 +289,37 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> .executeOnExecutor(mExecutors.lookup(uri.getAuthority())); } protected final boolean launchToDocument(Uri uri) { // We don't support launching to a document in an archive. if (!ArchivesProvider.AUTHORITY.equals(uri.getAuthority())) { loadDocument(uri, this::onStackLoaded); return true; } return false; } private void onStackLoaded(@Nullable DocumentStack stack) { if (stack != null) { if (!stack.peek().isDirectory()) { // Requested document is not a directory. Pop it so that we can launch into its // parent. stack.pop(); } mState.stack.reset(stack); mActivity.refreshCurrentRootAndDirectory(AnimationView.ANIM_NONE); Metrics.logLaunchAtLocation(mActivity, mState, stack.getRoot().getUri()); } else { Log.w(TAG, "Failed to launch into the given uri. Launch to default location."); launchToDefaultLocation(); Metrics.logLaunchAtLocation(mActivity, mState, null); } } protected abstract void launchToDefaultLocation(); protected final void loadHomeDir() { loadRoot(Shared.getDefaultRootUri(mActivity)); } Loading src/com/android/documentsui/Metrics.java +4 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ public final class Metrics { private static final String COUNT_STARTUP_MS = "docsui_startup_ms"; private static final String COUNT_DRAWER_OPENED = "docsui_drawer_opened"; private static final String COUNT_USER_ACTION = "docsui_menu_action"; private static final String COUNT_BROWSE_AT_LOCATION = "docsui_browse_at_location"; private static final String COUNT_CREATE_AT_LOCATION = "docsui_create_at_location"; private static final String COUNT_OPEN_AT_LOCATION = "docsui_open_at_location"; private static final String COUNT_GET_CONTENT_AT_LOCATION = "docsui_get_content_at_location"; Loading Loading @@ -437,6 +438,9 @@ public final class Metrics { */ public static void logLaunchAtLocation(Context context, State state, @Nullable Uri rootUri) { switch (state.action) { case State.ACTION_BROWSE: logHistogram(context, COUNT_BROWSE_AT_LOCATION, sanitizeRoot(rootUri)); break; case State.ACTION_CREATE: logHistogram(context, COUNT_CREATE_AT_LOCATION, sanitizeRoot(rootUri)); break; Loading src/com/android/documentsui/files/ActionHandler.java +23 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import android.content.ClipData; import android.content.Intent; import android.net.Uri; import android.provider.DocumentsContract; import android.provider.DocumentsContract.Root; import android.provider.DocumentsContract.Document; import android.util.Log; import com.android.documentsui.AbstractActionHandler; Loading Loading @@ -354,10 +356,20 @@ public class ActionHandler<T extends Activity & Addons> extends AbstractActionHa return; } if (launchToDocument(intent)) { if (DEBUG) Log.d(TAG, "Launched to a document."); return; } if (DEBUG) Log.d(TAG, "Launching directly into Home directory."); loadHomeDir(); } @Override protected void launchToDefaultLocation() { loadHomeDir(); } // If a non-empty stack is present in our state, it was read (presumably) // from EXTRA_STACK intent extra. In this case, we'll skip other means of // loading or restoring the stack (like URI). Loading Loading @@ -397,6 +409,17 @@ public class ActionHandler<T extends Activity & Addons> extends AbstractActionHa return false; } private boolean launchToDocument(Intent intent) { if (DocumentsContract.ACTION_BROWSE.equals(intent.getAction())) { Uri uri = intent.getData(); if (DocumentsContract.isDocumentUri(mActivity, uri)) { return launchToDocument(intent.getData()); } } return false; } @Override public void showChooserForDoc(DocumentInfo doc) { assert(!doc.isContainer()); Loading src/com/android/documentsui/picker/ActionHandler.java +7 −23 Original line number Diff line number Diff line Loading @@ -107,6 +107,11 @@ class ActionHandler<T extends Activity & Addons> extends AbstractActionHandler<T loadLastAccessedStack(); } @Override protected void launchToDefaultLocation() { loadLastAccessedStack(); } private boolean launchHomeForCopyDestination(Intent intent) { // As a matter of policy we don't load the last used stack for the copy // destination picker (user is already in Files app). Loading @@ -122,35 +127,14 @@ class ActionHandler<T extends Activity & Addons> extends AbstractActionHandler<T } private boolean launchToDocument(Intent intent) { final Uri uri = intent.getParcelableExtra(DocumentsContract.EXTRA_INITIAL_URI); Uri uri = intent.getParcelableExtra(DocumentsContract.EXTRA_INITIAL_URI); if (uri != null) { loadDocument(uri, this::onStackLoaded); return true; return launchToDocument(uri); } return false; } private void onStackLoaded(@Nullable DocumentStack stack) { if (stack != null) { if (!stack.peek().isContainer()) { // Requested document is not a container. Pop it so that we can launch into its // parent. stack.pop(); } mState.stack.reset(stack); mActivity.refreshCurrentRootAndDirectory(AnimationView.ANIM_NONE); Metrics.logLaunchAtLocation(mActivity, mState, stack.getRoot().getUri()); } else { Log.w(TAG, "Failed to launch into the given uri. Load last accessed stack."); loadLastAccessedStack(); Metrics.logLaunchAtLocation(mActivity, mState, null); } } private void loadLastAccessedStack() { if (DEBUG) Log.d(TAG, "Attempting to load last used stack for calling package."); new LoadLastAccessedStackTask<>(mActivity, mState, mRoots).execute(); Loading Loading
AndroidManifest.xml +5 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,11 @@ <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="vnd.android.document/root" /> </intent-filter> <intent-filter> <action android:name="android.provider.action.BROWSE" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="vnd.android.document/directory" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW_DOWNLOADS" /> <category android:name="android.intent.category.DEFAULT" /> Loading
src/com/android/documentsui/AbstractActionHandler.java +33 −0 Original line number Diff line number Diff line Loading @@ -22,12 +22,14 @@ import android.content.Intent; import android.content.pm.ResolveInfo; import android.net.Uri; import android.os.Parcelable; import android.provider.DocumentsContract; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.util.Log; import com.android.documentsui.AbstractActionHandler.CommonAddons; import com.android.documentsui.LoadDocStackTask.LoadDocStackCallback; import com.android.documentsui.archives.ArchivesProvider; import com.android.documentsui.base.BooleanConsumer; import com.android.documentsui.base.DocumentInfo; import com.android.documentsui.base.DocumentStack; Loading Loading @@ -287,6 +289,37 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> .executeOnExecutor(mExecutors.lookup(uri.getAuthority())); } protected final boolean launchToDocument(Uri uri) { // We don't support launching to a document in an archive. if (!ArchivesProvider.AUTHORITY.equals(uri.getAuthority())) { loadDocument(uri, this::onStackLoaded); return true; } return false; } private void onStackLoaded(@Nullable DocumentStack stack) { if (stack != null) { if (!stack.peek().isDirectory()) { // Requested document is not a directory. Pop it so that we can launch into its // parent. stack.pop(); } mState.stack.reset(stack); mActivity.refreshCurrentRootAndDirectory(AnimationView.ANIM_NONE); Metrics.logLaunchAtLocation(mActivity, mState, stack.getRoot().getUri()); } else { Log.w(TAG, "Failed to launch into the given uri. Launch to default location."); launchToDefaultLocation(); Metrics.logLaunchAtLocation(mActivity, mState, null); } } protected abstract void launchToDefaultLocation(); protected final void loadHomeDir() { loadRoot(Shared.getDefaultRootUri(mActivity)); } Loading
src/com/android/documentsui/Metrics.java +4 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ public final class Metrics { private static final String COUNT_STARTUP_MS = "docsui_startup_ms"; private static final String COUNT_DRAWER_OPENED = "docsui_drawer_opened"; private static final String COUNT_USER_ACTION = "docsui_menu_action"; private static final String COUNT_BROWSE_AT_LOCATION = "docsui_browse_at_location"; private static final String COUNT_CREATE_AT_LOCATION = "docsui_create_at_location"; private static final String COUNT_OPEN_AT_LOCATION = "docsui_open_at_location"; private static final String COUNT_GET_CONTENT_AT_LOCATION = "docsui_get_content_at_location"; Loading Loading @@ -437,6 +438,9 @@ public final class Metrics { */ public static void logLaunchAtLocation(Context context, State state, @Nullable Uri rootUri) { switch (state.action) { case State.ACTION_BROWSE: logHistogram(context, COUNT_BROWSE_AT_LOCATION, sanitizeRoot(rootUri)); break; case State.ACTION_CREATE: logHistogram(context, COUNT_CREATE_AT_LOCATION, sanitizeRoot(rootUri)); break; Loading
src/com/android/documentsui/files/ActionHandler.java +23 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import android.content.ClipData; import android.content.Intent; import android.net.Uri; import android.provider.DocumentsContract; import android.provider.DocumentsContract.Root; import android.provider.DocumentsContract.Document; import android.util.Log; import com.android.documentsui.AbstractActionHandler; Loading Loading @@ -354,10 +356,20 @@ public class ActionHandler<T extends Activity & Addons> extends AbstractActionHa return; } if (launchToDocument(intent)) { if (DEBUG) Log.d(TAG, "Launched to a document."); return; } if (DEBUG) Log.d(TAG, "Launching directly into Home directory."); loadHomeDir(); } @Override protected void launchToDefaultLocation() { loadHomeDir(); } // If a non-empty stack is present in our state, it was read (presumably) // from EXTRA_STACK intent extra. In this case, we'll skip other means of // loading or restoring the stack (like URI). Loading Loading @@ -397,6 +409,17 @@ public class ActionHandler<T extends Activity & Addons> extends AbstractActionHa return false; } private boolean launchToDocument(Intent intent) { if (DocumentsContract.ACTION_BROWSE.equals(intent.getAction())) { Uri uri = intent.getData(); if (DocumentsContract.isDocumentUri(mActivity, uri)) { return launchToDocument(intent.getData()); } } return false; } @Override public void showChooserForDoc(DocumentInfo doc) { assert(!doc.isContainer()); Loading
src/com/android/documentsui/picker/ActionHandler.java +7 −23 Original line number Diff line number Diff line Loading @@ -107,6 +107,11 @@ class ActionHandler<T extends Activity & Addons> extends AbstractActionHandler<T loadLastAccessedStack(); } @Override protected void launchToDefaultLocation() { loadLastAccessedStack(); } private boolean launchHomeForCopyDestination(Intent intent) { // As a matter of policy we don't load the last used stack for the copy // destination picker (user is already in Files app). Loading @@ -122,35 +127,14 @@ class ActionHandler<T extends Activity & Addons> extends AbstractActionHandler<T } private boolean launchToDocument(Intent intent) { final Uri uri = intent.getParcelableExtra(DocumentsContract.EXTRA_INITIAL_URI); Uri uri = intent.getParcelableExtra(DocumentsContract.EXTRA_INITIAL_URI); if (uri != null) { loadDocument(uri, this::onStackLoaded); return true; return launchToDocument(uri); } return false; } private void onStackLoaded(@Nullable DocumentStack stack) { if (stack != null) { if (!stack.peek().isContainer()) { // Requested document is not a container. Pop it so that we can launch into its // parent. stack.pop(); } mState.stack.reset(stack); mActivity.refreshCurrentRootAndDirectory(AnimationView.ANIM_NONE); Metrics.logLaunchAtLocation(mActivity, mState, stack.getRoot().getUri()); } else { Log.w(TAG, "Failed to launch into the given uri. Load last accessed stack."); loadLastAccessedStack(); Metrics.logLaunchAtLocation(mActivity, mState, null); } } private void loadLastAccessedStack() { if (DEBUG) Log.d(TAG, "Attempting to load last used stack for calling package."); new LoadLastAccessedStackTask<>(mActivity, mState, mRoots).execute(); Loading