OSDN Git Service

Add config flag to show/hide internal storage.
authorAga Wronska <agawronska@google.com>
Mon, 21 Mar 2016 18:28:03 +0000 (11:28 -0700)
committerAga Wronska <agawronska@google.com>
Tue, 22 Mar 2016 00:33:27 +0000 (17:33 -0700)
Hide internal storage by default.

Revert "Always show intern storage."

This reverts commit 7c4395804e450533afb553ab992c47f737da8a9b.

Bug: 27683276

Change-Id: I04ea8b9a307babcea003f9bec200d41265a42c7f

core/java/android/os/storage/VolumeInfo.java
core/java/android/provider/DocumentsContract.java
packages/DocumentsUI/res/values/config.xml
packages/DocumentsUI/src/com/android/documentsui/RootsFragment.java
packages/DocumentsUI/src/com/android/documentsui/model/RootInfo.java
packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java
packages/Shell/src/com/android/shell/BugreportStorageProvider.java

index ea0597d..4b70649 100644 (file)
@@ -438,6 +438,10 @@ public class VolumeInfo implements Parcelable {
         final Intent intent = new Intent(DocumentsContract.ACTION_BROWSE);
         intent.addCategory(Intent.CATEGORY_DEFAULT);
         intent.setData(uri);
+
+        // note that docsui treats this as *force* show advanced. So sending
+        // false permits advanced to be shown based on user preferences.
+        intent.putExtra(DocumentsContract.EXTRA_SHOW_ADVANCED, isPrimary());
         intent.putExtra(DocumentsContract.EXTRA_SHOW_FILESIZE, true);
         return intent;
     }
index 4ad7969..4412459 100644 (file)
@@ -93,6 +93,9 @@ public final class DocumentsContract {
     public static final String EXTRA_PACKAGE_NAME = "android.content.extra.PACKAGE_NAME";
 
     /** {@hide} */
+    public static final String EXTRA_SHOW_ADVANCED = "android.content.extra.SHOW_ADVANCED";
+
+    /** {@hide} */
     public static final String EXTRA_SHOW_FILESIZE = "android.content.extra.SHOW_FILESIZE";
 
     /** {@hide} */
@@ -556,13 +559,22 @@ public final class DocumentsContract {
         public static final int FLAG_EMPTY = 1 << 16;
 
         /**
+         * Flag indicating that this root should only be visible to advanced
+         * users.
+         *
+         * @see #COLUMN_FLAGS
+         * @hide
+         */
+        public static final int FLAG_ADVANCED = 1 << 17;
+
+        /**
          * Flag indicating that this root has settings.
          *
          * @see #COLUMN_FLAGS
          * @see DocumentsContract#ACTION_DOCUMENT_ROOT_SETTINGS
          * @hide
          */
-        public static final int FLAG_HAS_SETTINGS = 1 << 17;
+        public static final int FLAG_HAS_SETTINGS = 1 << 18;
 
         /**
          * Flag indicating that this root is on removable SD card storage.
@@ -570,7 +582,7 @@ public final class DocumentsContract {
          * @see #COLUMN_FLAGS
          * @hide
          */
-        public static final int FLAG_REMOVABLE_SD = 1 << 18;
+        public static final int FLAG_REMOVABLE_SD = 1 << 19;
 
         /**
          * Flag indicating that this root is on removable USB storage.
@@ -578,7 +590,7 @@ public final class DocumentsContract {
          * @see #COLUMN_FLAGS
          * @hide
          */
-        public static final int FLAG_REMOVABLE_USB = 1 << 19;
+        public static final int FLAG_REMOVABLE_USB = 1 << 20;
     }
 
     /**
index ebb3969..408603e 100644 (file)
@@ -24,5 +24,6 @@
     <!-- Indicates if the home directory should be hidden in the roots list, that is presented
          in the drawer/left side panel ) -->
     <bool name="home_root_hidden">true</bool>
-
+    <!-- Indicates if the advanced roots like internal storage should be hidden in the roots list) -->
+    <bool name="advanced_roots_hidden">true</bool>
 </resources>
index 54e6287..1864431 100644 (file)
@@ -320,6 +320,8 @@ public class RootsFragment extends Fragment {
 
                 if (root.isHome() && isHomeRootHidden(context)) {
                     continue;
+                } else if (root.isAdvanced() && areAdvancedRootsHidden(context)) {
+                    continue;
                 } else if (root.isLibrary()) {
                     if (DEBUG) Log.d(TAG, "Adding " + root + " as library.");
                     libraries.add(item);
@@ -377,6 +379,13 @@ public class RootsFragment extends Fragment {
             return context.getResources().getBoolean(R.bool.home_root_hidden);
         }
 
+        /*
+         * Indicates if the advanced roots should be hidden.
+         */
+        private boolean areAdvancedRootsHidden(Context context) {
+            return context.getResources().getBoolean(R.bool.advanced_roots_hidden);
+        }
+
         @Override
         public View getView(int position, View convertView, ViewGroup parent) {
             final Item item = getItem(position);
index 3960475..0709652 100644 (file)
@@ -298,6 +298,10 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> {
         return (flags & Root.FLAG_SUPPORTS_SEARCH) != 0;
     }
 
+    public boolean isAdvanced() {
+        return (flags & Root.FLAG_ADVANCED) != 0;
+    }
+
     public boolean isLocalOnly() {
         return (flags & Root.FLAG_LOCAL_ONLY) != 0;
     }
index 9a51b05..62f33bf 100644 (file)
@@ -196,6 +196,7 @@ public class ExternalStorageProvider extends DocumentsProvider {
             if (volume.isPrimary()) {
                 // save off the primary volume for subsequent "Home" dir initialization.
                 primaryVolume = volume;
+                root.flags |= Root.FLAG_ADVANCED;
             }
             // Dunno when this would NOT be the case, but never hurts to be correct.
             if (volume.isMountedWritable()) {
index 49759c5..814aa8c 100644 (file)
@@ -56,7 +56,7 @@ public class BugreportStorageProvider extends DocumentsProvider {
         final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));
         final RowBuilder row = result.newRow();
         row.add(Root.COLUMN_ROOT_ID, DOC_ID_ROOT);
-        row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY);
+        row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_ADVANCED);
         row.add(Root.COLUMN_ICON, android.R.mipmap.sym_def_app_icon);
         row.add(Root.COLUMN_TITLE, getContext().getString(R.string.bugreport_storage_title));
         row.add(Root.COLUMN_DOCUMENT_ID, DOC_ID_ROOT);