Loading core/java/android/provider/DocumentsProvider.java +17 −13 Original line number Diff line number Diff line Loading @@ -730,6 +730,23 @@ public abstract class DocumentsProvider extends ContentProvider { throws FileNotFoundException { final Context context = getContext(); final Bundle out = new Bundle(); if (METHOD_EJECT_ROOT.equals(method)) { // Given that certain system apps can hold MOUNT_UNMOUNT permission, but only apps // signed with platform signature can hold MANAGE_DOCUMENTS, we are going to check for // MANAGE_DOCUMENTS here instead getContext().enforceCallingPermission( android.Manifest.permission.MANAGE_DOCUMENTS, null); final Uri rootUri = extras.getParcelable(DocumentsContract.EXTRA_URI); final String rootId = DocumentsContract.getRootId(rootUri); final boolean ejected = ejectRoot(rootId); out.putBoolean(DocumentsContract.EXTRA_RESULT, ejected); return out; } final Uri documentUri = extras.getParcelable(DocumentsContract.EXTRA_URI); final String authority = documentUri.getAuthority(); final String documentId = DocumentsContract.getDocumentId(documentUri); Loading @@ -739,8 +756,6 @@ public abstract class DocumentsProvider extends ContentProvider { "Requested authority " + authority + " doesn't match provider " + mAuthority); } final Bundle out = new Bundle(); // If the URI is a tree URI performs some validation. enforceTree(documentUri); Loading Loading @@ -858,17 +873,6 @@ public abstract class DocumentsProvider extends ContentProvider { // It's responsibility of the provider to revoke any grants, as the document may be // still attached to another parents. } else if (METHOD_EJECT_ROOT.equals(method)) { // Given that certain system apps can hold MOUNT_UNMOUNT permission, but only apps // signed with platform signature can hold MANAGE_DOCUMENTS, we are going to check for // MANAGE_DOCUMENTS here instead getContext().enforceCallingPermission( android.Manifest.permission.MANAGE_DOCUMENTS, null); final Uri rootUri = extras.getParcelable(DocumentsContract.EXTRA_URI); final String rootId = DocumentsContract.getRootId(rootUri); final boolean ejected = ejectRoot(rootId); out.putBoolean(DocumentsContract.EXTRA_RESULT, ejected); } else { throw new UnsupportedOperationException("Method not supported " + method); } Loading packages/DocumentsUI/res/color/item_eject_icon.xml 0 → 100644 +20 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2016 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_enabled="false" android:alpha="@*android:dimen/disabled_alpha_material_light" android:color="@*android:color/primary_text_default_material_light" /> <item android:color="@*android:color/primary_text_default_material_light" /> </selector> packages/DocumentsUI/res/drawable/ic_eject.xml 0 → 100644 +24 −0 Original line number Diff line number Diff line <!-- Copyright (C) 2016 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24.0" android:viewportHeight="24.0"> <path android:fillColor="#FF737373" android:pathData="M5 17h14v2H5zm7-12L5.33 15h13.34z"/> </vector> packages/DocumentsUI/res/layout/item_root.xml +17 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,8 @@ android:layout_height="wrap_content" android:paddingTop="8dp" android:paddingBottom="8dp" android:orientation="vertical"> android:orientation="vertical" android:layout_weight="1"> <TextView android:id="@android:id/title" Loading @@ -70,4 +71,19 @@ </LinearLayout> <FrameLayout android:layout_width="@dimen/icon_size" android:layout_height="@dimen/icon_size" android:duplicateParentState="true"> <ImageView android:id="@+id/unmount_icon" android:layout_width="@dimen/root_icon_size" android:layout_height="match_parent" android:scaleType="centerInside" android:contentDescription="@string/menu_eject_root" android:visibility="gone" /> </FrameLayout> </com.android.documentsui.RootItemView> packages/DocumentsUI/res/menu/root_context_menu.xml 0 → 100644 +24 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2016 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/menu_eject_root" android:title="@string/menu_eject_root" /> <item android:id="@+id/menu_settings" android:title="@string/menu_settings" /> </menu> Loading
core/java/android/provider/DocumentsProvider.java +17 −13 Original line number Diff line number Diff line Loading @@ -730,6 +730,23 @@ public abstract class DocumentsProvider extends ContentProvider { throws FileNotFoundException { final Context context = getContext(); final Bundle out = new Bundle(); if (METHOD_EJECT_ROOT.equals(method)) { // Given that certain system apps can hold MOUNT_UNMOUNT permission, but only apps // signed with platform signature can hold MANAGE_DOCUMENTS, we are going to check for // MANAGE_DOCUMENTS here instead getContext().enforceCallingPermission( android.Manifest.permission.MANAGE_DOCUMENTS, null); final Uri rootUri = extras.getParcelable(DocumentsContract.EXTRA_URI); final String rootId = DocumentsContract.getRootId(rootUri); final boolean ejected = ejectRoot(rootId); out.putBoolean(DocumentsContract.EXTRA_RESULT, ejected); return out; } final Uri documentUri = extras.getParcelable(DocumentsContract.EXTRA_URI); final String authority = documentUri.getAuthority(); final String documentId = DocumentsContract.getDocumentId(documentUri); Loading @@ -739,8 +756,6 @@ public abstract class DocumentsProvider extends ContentProvider { "Requested authority " + authority + " doesn't match provider " + mAuthority); } final Bundle out = new Bundle(); // If the URI is a tree URI performs some validation. enforceTree(documentUri); Loading Loading @@ -858,17 +873,6 @@ public abstract class DocumentsProvider extends ContentProvider { // It's responsibility of the provider to revoke any grants, as the document may be // still attached to another parents. } else if (METHOD_EJECT_ROOT.equals(method)) { // Given that certain system apps can hold MOUNT_UNMOUNT permission, but only apps // signed with platform signature can hold MANAGE_DOCUMENTS, we are going to check for // MANAGE_DOCUMENTS here instead getContext().enforceCallingPermission( android.Manifest.permission.MANAGE_DOCUMENTS, null); final Uri rootUri = extras.getParcelable(DocumentsContract.EXTRA_URI); final String rootId = DocumentsContract.getRootId(rootUri); final boolean ejected = ejectRoot(rootId); out.putBoolean(DocumentsContract.EXTRA_RESULT, ejected); } else { throw new UnsupportedOperationException("Method not supported " + method); } Loading
packages/DocumentsUI/res/color/item_eject_icon.xml 0 → 100644 +20 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2016 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_enabled="false" android:alpha="@*android:dimen/disabled_alpha_material_light" android:color="@*android:color/primary_text_default_material_light" /> <item android:color="@*android:color/primary_text_default_material_light" /> </selector>
packages/DocumentsUI/res/drawable/ic_eject.xml 0 → 100644 +24 −0 Original line number Diff line number Diff line <!-- Copyright (C) 2016 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24.0" android:viewportHeight="24.0"> <path android:fillColor="#FF737373" android:pathData="M5 17h14v2H5zm7-12L5.33 15h13.34z"/> </vector>
packages/DocumentsUI/res/layout/item_root.xml +17 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,8 @@ android:layout_height="wrap_content" android:paddingTop="8dp" android:paddingBottom="8dp" android:orientation="vertical"> android:orientation="vertical" android:layout_weight="1"> <TextView android:id="@android:id/title" Loading @@ -70,4 +71,19 @@ </LinearLayout> <FrameLayout android:layout_width="@dimen/icon_size" android:layout_height="@dimen/icon_size" android:duplicateParentState="true"> <ImageView android:id="@+id/unmount_icon" android:layout_width="@dimen/root_icon_size" android:layout_height="match_parent" android:scaleType="centerInside" android:contentDescription="@string/menu_eject_root" android:visibility="gone" /> </FrameLayout> </com.android.documentsui.RootItemView>
packages/DocumentsUI/res/menu/root_context_menu.xml 0 → 100644 +24 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2016 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/menu_eject_root" android:title="@string/menu_eject_root" /> <item android:id="@+id/menu_settings" android:title="@string/menu_settings" /> </menu>