Migrate MTP components into new project.
Bug: 138999976
Test: manual
Change-Id: I440fc37ff7b2be48b415989eb64b528a0c89b833
diff --git a/packages/MtpDocumentsProvider/Android.bp b/packages/MtpDocumentsProvider/Android.bp
deleted file mode 100644
index 3dafa26..0000000
--- a/packages/MtpDocumentsProvider/Android.bp
+++ /dev/null
@@ -1,11 +0,0 @@
-android_app {
- name: "MtpDocumentsProvider",
-
- srcs: ["src/**/*.java"],
- platform_apis: true,
- certificate: "media",
- privileged: true,
- optimize: {
- proguard_flags_files: ["proguard.flags"],
- },
-}
diff --git a/packages/MtpDocumentsProvider/AndroidManifest.xml b/packages/MtpDocumentsProvider/AndroidManifest.xml
deleted file mode 100644
index c0a59b3..0000000
--- a/packages/MtpDocumentsProvider/AndroidManifest.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.mtp"
- android:sharedUserId="android.media">
- <uses-feature android:name="android.hardware.usb.host" />
- <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
- <uses-permission android:name="android.permission.MANAGE_USB" />
- <application android:label="@string/app_label">
- <provider
- android:name=".MtpDocumentsProvider"
- android:authorities="com.android.mtp.documents"
- android:grantUriPermissions="true"
- android:exported="true"
- android:permission="android.permission.MANAGE_DOCUMENTS">
- <intent-filter>
- <action android:name="android.content.action.DOCUMENTS_PROVIDER" />
- </intent-filter>
- </provider>
-
- <service android:name=".MtpDocumentsService" />
-
- <activity android:name=".ReceiverActivity"
- android:label="@string/downloads_app_label"
- android:icon="@mipmap/ic_launcher_download"
- android:theme="@android:style/Theme.NoDisplay"
- android:excludeFromRecents="true">
- <intent-filter>
- <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
- </intent-filter>
- <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
- android:resource="@xml/device_filter" />
- </activity>
-
- <receiver android:name=".UsbIntentReceiver" android:exported="true">
- <intent-filter>
- <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
- <action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" />
- </intent-filter>
- <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
- android:resource="@xml/device_filter" />
- </receiver>
- </application>
-</manifest>
diff --git a/packages/MtpDocumentsProvider/MOVED b/packages/MtpDocumentsProvider/MOVED
new file mode 100644
index 0000000..6c8a519
--- /dev/null
+++ b/packages/MtpDocumentsProvider/MOVED
@@ -0,0 +1 @@
+../../../../packages/services/Mtp
diff --git a/packages/MtpDocumentsProvider/perf_tests/Android.mk b/packages/MtpDocumentsProvider/perf_tests/Android.mk
deleted file mode 100644
index d2f1c7a..0000000
--- a/packages/MtpDocumentsProvider/perf_tests/Android.mk
+++ /dev/null
@@ -1,13 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_STATIC_JAVA_LIBRARIES := androidx.test.rules
-LOCAL_PACKAGE_NAME := MtpDocumentsProviderPerfTests
-LOCAL_PRIVATE_PLATFORM_APIS := true
-LOCAL_INSTRUMENTATION_FOR := MtpDocumentsProvider
-LOCAL_CERTIFICATE := media
-LOCAL_COMPATIBILITY_SUITE += device-tests
-
-include $(BUILD_PACKAGE)
diff --git a/packages/MtpDocumentsProvider/perf_tests/AndroidManifest.xml b/packages/MtpDocumentsProvider/perf_tests/AndroidManifest.xml
deleted file mode 100644
index 4367652..0000000
--- a/packages/MtpDocumentsProvider/perf_tests/AndroidManifest.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.mtp.perftests"
- android:sharedUserId="android.media">
-
- <application>
- <uses-library android:name="android.test.runner" />
- </application>
-
- <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
- android:targetPackage="com.android.mtp"
- android:label="Performance tests for MtpDocumentsProvider." />
-</manifest>
diff --git a/packages/MtpDocumentsProvider/perf_tests/AndroidTest.xml b/packages/MtpDocumentsProvider/perf_tests/AndroidTest.xml
deleted file mode 100644
index 8b7292b..0000000
--- a/packages/MtpDocumentsProvider/perf_tests/AndroidTest.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 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.
--->
-<configuration description="Runs MtpDocumentsProviderPerfTests metric instrumentation.">
- <option name="test-suite-tag" value="apct" />
- <option name="test-suite-tag" value="apct-metric-instrumentation" />
- <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
- <option name="cleanup-apks" value="true" />
- <option name="test-file-name" value="MtpDocumentsProviderPerfTests.apk" />
- </target_preparer>
-
- <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
- <option name="package" value="com.android.mtp.perftests" />
- </test>
-</configuration>
diff --git a/packages/MtpDocumentsProvider/perf_tests/src/com/android/mtp/AppFusePerfTest.java b/packages/MtpDocumentsProvider/perf_tests/src/com/android/mtp/AppFusePerfTest.java
deleted file mode 100644
index 58b9c67..0000000
--- a/packages/MtpDocumentsProvider/perf_tests/src/com/android/mtp/AppFusePerfTest.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.mtp;
-
-import android.app.Activity;
-import android.content.Context;
-import android.os.Bundle;
-import android.os.ParcelFileDescriptor;
-import android.os.ProxyFileDescriptorCallback;
-import android.os.storage.StorageManager;
-import android.system.ErrnoException;
-
-import androidx.test.InstrumentationRegistry;
-import androidx.test.filters.LargeTest;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-import java.io.IOException;
-
-@RunWith(JUnit4.class)
-public class AppFusePerfTest {
- final static int SIZE = 10 * 1024 * 1024; // 10MB
-
- @Test
- @LargeTest
- public void testReadWriteFile() throws IOException {
- final Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
- final StorageManager storageManager = context.getSystemService(StorageManager.class);
-
- final byte[] bytes = new byte[SIZE];
- final int SAMPLES = 100;
- final double[] readTime = new double[SAMPLES];
- final double[] writeTime = new double[SAMPLES];
-
- for (int i = 0; i < SAMPLES; i++) {
- final ParcelFileDescriptor fd = storageManager.openProxyFileDescriptor(
- ParcelFileDescriptor.MODE_READ_ONLY, new TestCallback());
- try (final ParcelFileDescriptor.AutoCloseInputStream stream =
- new ParcelFileDescriptor.AutoCloseInputStream(fd)) {
- final long startTime = System.nanoTime();
- stream.read(bytes);
- readTime[i] = (System.nanoTime() - startTime) / 1000.0 / 1000.0;
- }
- }
-
- for (int i = 0; i < SAMPLES; i++) {
- final ParcelFileDescriptor fd = storageManager.openProxyFileDescriptor(
- ParcelFileDescriptor.MODE_WRITE_ONLY | ParcelFileDescriptor.MODE_TRUNCATE,
- new TestCallback());
- try (final ParcelFileDescriptor.AutoCloseOutputStream stream =
- new ParcelFileDescriptor.AutoCloseOutputStream(fd)) {
- final long startTime = System.nanoTime();
- stream.write(bytes);
- writeTime[i] = (System.nanoTime() - startTime) / 1000.0 / 1000.0;
- }
- }
-
- double readAverage = 0;
- double writeAverage = 0;
- double readSquaredAverage = 0;
- double writeSquaredAverage = 0;
- for (int i = 0; i < SAMPLES; i++) {
- readAverage += readTime[i];
- writeAverage += writeTime[i];
- readSquaredAverage += readTime[i] * readTime[i];
- writeSquaredAverage += writeTime[i] * writeTime[i];
- }
-
- readAverage /= SAMPLES;
- writeAverage /= SAMPLES;
- readSquaredAverage /= SAMPLES;
- writeSquaredAverage /= SAMPLES;
-
- final Bundle results = new Bundle();
- results.putDouble("readAverage", readAverage);
- results.putDouble("readStandardDeviation",
- Math.sqrt(readSquaredAverage - readAverage * readAverage));
- results.putDouble("writeAverage", writeAverage);
- results.putDouble("writeStandardDeviation",
- Math.sqrt(writeSquaredAverage - writeAverage * writeAverage));
- InstrumentationRegistry.getInstrumentation().sendStatus(Activity.RESULT_OK, results);
- }
-
- private static class TestCallback extends ProxyFileDescriptorCallback {
- @Override
- public long onGetSize() throws ErrnoException {
- return SIZE;
- }
-
- @Override
- public int onRead(long offset, int size, byte[] data) throws ErrnoException {
- return size;
- }
-
- @Override
- public int onWrite(long offset, int size, byte[] data) throws ErrnoException {
- return size;
- }
-
- @Override
- public void onFsync() throws ErrnoException {}
-
- @Override
- public void onRelease() {}
- }
-}
diff --git a/packages/MtpDocumentsProvider/proguard.flags b/packages/MtpDocumentsProvider/proguard.flags
deleted file mode 100644
index e660121..0000000
--- a/packages/MtpDocumentsProvider/proguard.flags
+++ /dev/null
@@ -1,4 +0,0 @@
-# Keeps methods that are invoked by JNI.
--keepclassmembers class * {
- @com.android.mtp.annotations.UsedByNative *;
-}
diff --git a/packages/MtpDocumentsProvider/res/drawable-hdpi/ic_root_mtp.png b/packages/MtpDocumentsProvider/res/drawable-hdpi/ic_root_mtp.png
deleted file mode 100644
index 7691433..0000000
--- a/packages/MtpDocumentsProvider/res/drawable-hdpi/ic_root_mtp.png
+++ /dev/null
Binary files differ
diff --git a/packages/MtpDocumentsProvider/res/drawable-mdpi/ic_root_mtp.png b/packages/MtpDocumentsProvider/res/drawable-mdpi/ic_root_mtp.png
deleted file mode 100644
index 1cf7b3a..0000000
--- a/packages/MtpDocumentsProvider/res/drawable-mdpi/ic_root_mtp.png
+++ /dev/null
Binary files differ
diff --git a/packages/MtpDocumentsProvider/res/drawable-xhdpi/ic_root_mtp.png b/packages/MtpDocumentsProvider/res/drawable-xhdpi/ic_root_mtp.png
deleted file mode 100644
index 27e3542..0000000
--- a/packages/MtpDocumentsProvider/res/drawable-xhdpi/ic_root_mtp.png
+++ /dev/null
Binary files differ
diff --git a/packages/MtpDocumentsProvider/res/drawable-xxhdpi/ic_root_mtp.png b/packages/MtpDocumentsProvider/res/drawable-xxhdpi/ic_root_mtp.png
deleted file mode 100644
index 3df2578b..0000000
--- a/packages/MtpDocumentsProvider/res/drawable-xxhdpi/ic_root_mtp.png
+++ /dev/null
Binary files differ
diff --git a/packages/MtpDocumentsProvider/res/drawable-xxxhdpi/ic_root_mtp.png b/packages/MtpDocumentsProvider/res/drawable-xxxhdpi/ic_root_mtp.png
deleted file mode 100644
index fd2b795..0000000
--- a/packages/MtpDocumentsProvider/res/drawable-xxxhdpi/ic_root_mtp.png
+++ /dev/null
Binary files differ
diff --git a/packages/MtpDocumentsProvider/res/mipmap-hdpi/ic_launcher_download.png b/packages/MtpDocumentsProvider/res/mipmap-hdpi/ic_launcher_download.png
deleted file mode 100644
index f958bbd..0000000
--- a/packages/MtpDocumentsProvider/res/mipmap-hdpi/ic_launcher_download.png
+++ /dev/null
Binary files differ
diff --git a/packages/MtpDocumentsProvider/res/mipmap-mdpi/ic_launcher_download.png b/packages/MtpDocumentsProvider/res/mipmap-mdpi/ic_launcher_download.png
deleted file mode 100644
index f2e9376..0000000
--- a/packages/MtpDocumentsProvider/res/mipmap-mdpi/ic_launcher_download.png
+++ /dev/null
Binary files differ
diff --git a/packages/MtpDocumentsProvider/res/mipmap-xhdpi/ic_launcher_download.png b/packages/MtpDocumentsProvider/res/mipmap-xhdpi/ic_launcher_download.png
deleted file mode 100644
index 4dc5336..0000000
--- a/packages/MtpDocumentsProvider/res/mipmap-xhdpi/ic_launcher_download.png
+++ /dev/null
Binary files differ
diff --git a/packages/MtpDocumentsProvider/res/mipmap-xxhdpi/ic_launcher_download.png b/packages/MtpDocumentsProvider/res/mipmap-xxhdpi/ic_launcher_download.png
deleted file mode 100644
index 8716290..0000000
--- a/packages/MtpDocumentsProvider/res/mipmap-xxhdpi/ic_launcher_download.png
+++ /dev/null
Binary files differ
diff --git a/packages/MtpDocumentsProvider/res/mipmap-xxxhdpi/ic_launcher_download.png b/packages/MtpDocumentsProvider/res/mipmap-xxxhdpi/ic_launcher_download.png
deleted file mode 100644
index f5be219..0000000
--- a/packages/MtpDocumentsProvider/res/mipmap-xxxhdpi/ic_launcher_download.png
+++ /dev/null
Binary files differ
diff --git a/packages/MtpDocumentsProvider/res/values-af/strings.xml b/packages/MtpDocumentsProvider/res/values-af/strings.xml
deleted file mode 100644
index c2c8761..0000000
--- a/packages/MtpDocumentsProvider/res/values-af/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP-gasheer"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Aflaaie"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Toegang tot lêers word tans van <xliff:g id="DEVICE_MODEL">%1$s</xliff:g> af verkry"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Die ander toestel is besig. Jy kan nie lêers oordra voordat dit beskikbaar is nie."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Geen lêers is gevind nie. Die ander toestel is dalk gesluit. Indien wel, ontsluit dit en probeer weer."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-am/strings.xml b/packages/MtpDocumentsProvider/res/values-am/strings.xml
deleted file mode 100644
index 7b721c8..0000000
--- a/packages/MtpDocumentsProvider/res/values-am/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"የMTP አስተናጋጅ"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"የወረዱ"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"ፋይሎችን ከ<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> በመድረስ ላይ"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"ሌላኛው መሣሪያ ሥራ በዝቶበታል። እስከሚገኝ ድረስ ፋይሎችን ማስተላለፍ አይችሉም።"</string>
- <string name="error_locked_device" msgid="7557872102188356147">"ምንም ፋይሎች አልተገኙም። ሌላኛው መሣሪያ ተቆልፎ ሊሆን ይችላል። ተቆልፎ ከሆነ ይክፈቱት እና እንደገና ይሞክሩ።"</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-ar/strings.xml b/packages/MtpDocumentsProvider/res/values-ar/strings.xml
deleted file mode 100644
index 284a860..0000000
--- a/packages/MtpDocumentsProvider/res/values-ar/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"مضيف بروتوكول نقل الوسائط (MTP)"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"التنزيلات"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"جارٍ الوصول إلى الملفات من <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"الجهاز الآخر مشغول، ولا يمكنك نقل الملفات إلا بعد أن يصبح متاحًا."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"لم يتم العثور على ملفات، وربما يكون الجهاز الآخر في وضع القفل. إذا كان الأمر كذلك، فعليك إلغاء قفله وإعادة المحاولة."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-as/strings.xml b/packages/MtpDocumentsProvider/res/values-as/strings.xml
deleted file mode 100644
index c8bdbd6..0000000
--- a/packages/MtpDocumentsProvider/res/values-as/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"এমটিপি হ\'ষ্ট"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"ডাউনল\'ডসমূহ"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g>ৰ পৰা ফাইলসমূহ চোৱা হৈছে"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"আনটো ডিভাইচ ব্যস্ত হৈ আছে। সেইটো উপলব্ধ নোহোৱালৈকে আপুনি ফাইলসমূহ স্থানান্তৰ কৰিব নোৱাৰে।"</string>
- <string name="error_locked_device" msgid="7557872102188356147">"কোনো ফাইল পোৱা নগ\'ল। আনটো ডিভাইচ লক হৈ থাকিব পাৰে। যদি লক হৈ আছে, তেন্তে আনলক কৰি আকৌ চেষ্টা কৰক।"</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-az/strings.xml b/packages/MtpDocumentsProvider/res/values-az/strings.xml
deleted file mode 100644
index e8ed124..0000000
--- a/packages/MtpDocumentsProvider/res/values-az/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP Host"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Endirmələr"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Fayllara <xliff:g id="DEVICE_MODEL">%1$s</xliff:g> cihazından daxil olunur"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Digər cihaz məşğuldur. Əlçatan olmayana kimi fayl köçürə bilməzsiniz."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Fayl tapılmadı. Digər cihaz kilidlənmiş ola bilər. Elədirsə, kiliddən çıxarın və yenidən cəhd edin."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-b+sr+Latn/strings.xml b/packages/MtpDocumentsProvider/res/values-b+sr+Latn/strings.xml
deleted file mode 100644
index bc900996..0000000
--- a/packages/MtpDocumentsProvider/res/values-b+sr+Latn/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP host"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Preuzimanja"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Pristup datotekama sa uređaja <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Drugi uređaj je zauzet. Datoteke možete da prenesete tek kad on postane dostupan."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Nije pronađena nijedna datoteka. Drugi uređaj je možda zaključan. Ako jeste, otključajte ga i pokušajte ponovo."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-be/strings.xml b/packages/MtpDocumentsProvider/res/values-be/strings.xml
deleted file mode 100644
index f6263ac..0000000
--- a/packages/MtpDocumentsProvider/res/values-be/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"Вузел MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Спампоўкі"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Доступ да файлаў з <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Іншая прылада занята. Вы не можаце перадаць файлы, пакуль яна не стане даступнай."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Файлы не знойдзены. Іншая прылада можа быць заблакіравана. Калі гэта так, разблакіруйце яе і паўтарыце спробу."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-bg/strings.xml b/packages/MtpDocumentsProvider/res/values-bg/strings.xml
deleted file mode 100644
index 52d3119..0000000
--- a/packages/MtpDocumentsProvider/res/values-bg/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP хост"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Изтегляния"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="STORAGE_NAME">%2$s</xliff:g> на <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"От <xliff:g id="DEVICE_MODEL">%1$s</xliff:g> се осъществява достъп до файловете"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Другото устройство е заето. Не можете да прехвърляте файлове, докато то не се освободи."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Няма намерени файлове. Другото устройство може да е заключено. Ако е така, отключете го и опитайте отново."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-bn/strings.xml b/packages/MtpDocumentsProvider/res/values-bn/strings.xml
deleted file mode 100644
index 7fad89e..0000000
--- a/packages/MtpDocumentsProvider/res/values-bn/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP হোস্ট"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"ডাউনলোডগুলি"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> থেকে ফাইলগুলিকে অ্যাক্সেস করা হচ্ছে"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"অন্য ডিভাইসটি ব্যস্ত আছে৷ এটি উপলব্ধ না হওয়া পর্যন্ত আপনি ফাইলগুলিকে স্থানান্তর করতে পারবেন না৷"</string>
- <string name="error_locked_device" msgid="7557872102188356147">"কোনো ফাইল পাওয়া যায়নি৷ অন্য ডিভাইসটি লক থাকতে পারে৷ যদি তাই হয়, তাহলে এটিকে আনলক করে আবার চেষ্টা করুন৷"</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-bs/strings.xml b/packages/MtpDocumentsProvider/res/values-bs/strings.xml
deleted file mode 100644
index 18c2363..0000000
--- a/packages/MtpDocumentsProvider/res/values-bs/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP Host"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Preuzimanja"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Pristupanje fajlovima iz uređaja <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Drugi uređaj je zauzet. Nećete moći prenositi fajlove dok ne bude dostupan."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Fajlovi nisu pronađeni. Moguće je da je drugi uređaj zaključan. Ako jeste, otključajte ga i pokušajte ponovo."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-ca/strings.xml b/packages/MtpDocumentsProvider/res/values-ca/strings.xml
deleted file mode 100644
index b2aa599..0000000
--- a/packages/MtpDocumentsProvider/res/values-ca/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"Amfitrió MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Baixades"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="STORAGE_NAME">%2$s</xliff:g> de <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"S\'està accedint als fitxers del dispositiu <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"L\'altre dispositiu està ocupat. No pots transferir fitxers fins que estigui disponible."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"No s\'han trobat fitxers. És possible que l\'altre dispositiu estigui bloquejat. Si és així, desbloqueja\'l i torna-ho a provar."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-cs/strings.xml b/packages/MtpDocumentsProvider/res/values-cs/strings.xml
deleted file mode 100644
index 2156e8c..0000000
--- a/packages/MtpDocumentsProvider/res/values-cs/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"Hostitel MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Stahování"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> – <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Používání souborů ze zařízení <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Druhé zařízení je zaneprázdněné. Dokud nebude dostupné, soubory nelze přenést."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Nebyly nalezeny žádné soubory. Druhé zařízení je možná uzamčené. Pokud ano, odemkněte jej a zkuste to znovu."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-da/strings.xml b/packages/MtpDocumentsProvider/res/values-da/strings.xml
deleted file mode 100644
index b82c5e8..0000000
--- a/packages/MtpDocumentsProvider/res/values-da/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP-host"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Downloads"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Adgang til filer fra <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Den anden enhed er optaget. Du kan ikke overføre filer, før den er tilgængelig."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Der blev ikke fundet nogen filer. Den anden enhed er muligvis låst. Hvis dette er tilfældet, skal du låse den op og prøve igen."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-de/strings.xml b/packages/MtpDocumentsProvider/res/values-de/strings.xml
deleted file mode 100644
index 9a71c76..0000000
--- a/packages/MtpDocumentsProvider/res/values-de/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP-Host"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Downloads"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="STORAGE_NAME">%2$s</xliff:g> von <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Zugriff auf Dateien von <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Das andere Gerät ist nicht verfügbar. Du kannst die Dateien übertragen, sobald das Gerät wieder verfügbar ist."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Keine Dateien gefunden. Das andere Gerät ist möglicherweise gesperrt. Entsperre es in diesem Fall und versuche es noch einmal."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-el/strings.xml b/packages/MtpDocumentsProvider/res/values-el/strings.xml
deleted file mode 100644
index 562d295..0000000
--- a/packages/MtpDocumentsProvider/res/values-el/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"Κεντρικός υπολογιστής MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Λήψεις"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Πρόσβαση στα αρχεία από τη συσκευή <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Η άλλη συσκευή είναι απασχολημένη. Δεν μπορείτε να μεταφέρετε αρχεία μέχρι να γίνει διαθέσιμη."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Δεν βρέθηκαν αρχεία. Η άλλη συσκευή ενδέχεται να είναι κλειδωμένη. Εάν ισχύει αυτό, ξεκλειδώστε την και δοκιμάστε ξανά."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-en-rAU/strings.xml b/packages/MtpDocumentsProvider/res/values-en-rAU/strings.xml
deleted file mode 100644
index 5f2167e..0000000
--- a/packages/MtpDocumentsProvider/res/values-en-rAU/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP Host"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Downloads"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Accessing files from <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"The other device is busy. You can\'t transfer files until it\'s available."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"No files found. The other device may be locked. If so, unlock it and try again."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-en-rCA/strings.xml b/packages/MtpDocumentsProvider/res/values-en-rCA/strings.xml
deleted file mode 100644
index 5f2167e..0000000
--- a/packages/MtpDocumentsProvider/res/values-en-rCA/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP Host"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Downloads"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Accessing files from <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"The other device is busy. You can\'t transfer files until it\'s available."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"No files found. The other device may be locked. If so, unlock it and try again."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-en-rGB/strings.xml b/packages/MtpDocumentsProvider/res/values-en-rGB/strings.xml
deleted file mode 100644
index 5f2167e..0000000
--- a/packages/MtpDocumentsProvider/res/values-en-rGB/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP Host"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Downloads"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Accessing files from <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"The other device is busy. You can\'t transfer files until it\'s available."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"No files found. The other device may be locked. If so, unlock it and try again."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-en-rIN/strings.xml b/packages/MtpDocumentsProvider/res/values-en-rIN/strings.xml
deleted file mode 100644
index 5f2167e..0000000
--- a/packages/MtpDocumentsProvider/res/values-en-rIN/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP Host"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Downloads"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Accessing files from <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"The other device is busy. You can\'t transfer files until it\'s available."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"No files found. The other device may be locked. If so, unlock it and try again."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-en-rXC/strings.xml b/packages/MtpDocumentsProvider/res/values-en-rXC/strings.xml
deleted file mode 100644
index e968a55..0000000
--- a/packages/MtpDocumentsProvider/res/values-en-rXC/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP Host"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Downloads"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Accessing files from <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"The other device is busy. You can\'t transfer files until it\'s available."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"No files found. The other device may be locked. If so, unlock it and try again."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-es-rUS/strings.xml b/packages/MtpDocumentsProvider/res/values-es-rUS/strings.xml
deleted file mode 100644
index 740d224..0000000
--- a/packages/MtpDocumentsProvider/res/values-es-rUS/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"Host MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Descargas"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Accediendo a los archivos de <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"El otro dispositivo está ocupado. No podrás transferir archivos hasta que esté disponible."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"No se encontraron archivos. Es posible que el otro dispositivo esté bloqueado. Si es así, desbloquéalo y vuelve a intentarlo."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-es/strings.xml b/packages/MtpDocumentsProvider/res/values-es/strings.xml
deleted file mode 100644
index d80a75a..0000000
--- a/packages/MtpDocumentsProvider/res/values-es/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"Host de MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Descargas"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="STORAGE_NAME">%2$s</xliff:g> de <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Accediendo a los archivos desde <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"El otro dispositivo está ocupado. No se pueden transferir archivos hasta que esté disponible."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"No se ha encontrado ningún archivo. Es posible que el otro dispositivo esté bloqueado. Si es así, desbloquéalo y vuelve a intentarlo."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-et/strings.xml b/packages/MtpDocumentsProvider/res/values-et/strings.xml
deleted file mode 100644
index 7568777..0000000
--- a/packages/MtpDocumentsProvider/res/values-et/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP host"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Allalaadimised"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g>, <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Juurdepääsemine failidele seadmest <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Teine seade on hõivatud. Te ei saa faile üle viia enne, kui see seade on saadaval."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Faile ei leitud. Teine seade võib olla lukustatud. Kui see on nii, avage see ja proovige uuesti."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-eu/strings.xml b/packages/MtpDocumentsProvider/res/values-eu/strings.xml
deleted file mode 100644
index dc9d463..0000000
--- a/packages/MtpDocumentsProvider/res/values-eu/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP ostalaria"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Deskargak"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> gailuko fitxategiak atzitzen"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Beste gailua lanpetuta dago. Erabilgarri egon arte ezingo duzu transferitu fitxategirik."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Ez da aurkitu fitxategirik. Baliteke beste gailua blokeatuta egotea. Hala bada, desblokea ezazu eta saiatu berriro."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-fa/strings.xml b/packages/MtpDocumentsProvider/res/values-fa/strings.xml
deleted file mode 100644
index 9ac58c7..0000000
--- a/packages/MtpDocumentsProvider/res/values-fa/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"میزبان MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"بارگیریها"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"دسترسی به فایلها از <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"دستگاه دیگر مشغول است. تا زمانی که این دستگاه دردسترس قرار نگیرد نمیتوانید فایلها را منتقل کنید."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"فایلی پیدا نشد. دستگاه دیگر ممکن است قفل باشد. اگر اینطور است، قفل آن را باز کنید و دوباره تلاش کنید."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-fi/strings.xml b/packages/MtpDocumentsProvider/res/values-fi/strings.xml
deleted file mode 100644
index 0a61d08..0000000
--- a/packages/MtpDocumentsProvider/res/values-fi/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP-isäntä"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Lataukset"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Käytetään laitteen <xliff:g id="DEVICE_MODEL">%1$s</xliff:g> tiedostoja"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Toinen laite on varattu. Et voi siirtää tiedostoja, ennen kuin se on käytettävissä."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Tiedostoja ei löytynyt. Toinen laite voi olla lukittu. Jos näin on, avaa se ja yritä uudelleen."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-fr-rCA/strings.xml b/packages/MtpDocumentsProvider/res/values-fr-rCA/strings.xml
deleted file mode 100644
index 281760e..0000000
--- a/packages/MtpDocumentsProvider/res/values-fr-rCA/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"Hôte MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Téléchargements"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Accès aux fichiers à partir de l\'appareil <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"L\'autre appareil est occupé. Vous devez attendre qu\'il soit disponible pour transférer des fichiers."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Aucun fichier trouvé. L\'autre appareil est peut-être verrouillé. Si c\'est le cas, déverrouillez-le, puis réessayez."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-fr/strings.xml b/packages/MtpDocumentsProvider/res/values-fr/strings.xml
deleted file mode 100644
index 96c713b..0000000
--- a/packages/MtpDocumentsProvider/res/values-fr/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"Hôte MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Téléchargements"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="STORAGE_NAME">%2$s</xliff:g> – <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Accès aux fichiers depuis le <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>…"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"L\'autre appareil est occupé. Vous devez attendre qu\'il soit disponible pour transférer des fichiers."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Aucun fichier trouvé. L\'autre appareil est peut-être verrouillé. Si tel est le cas, déverrouillez-le, puis réessayez."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-gl/strings.xml b/packages/MtpDocumentsProvider/res/values-gl/strings.xml
deleted file mode 100644
index 7e61c7c..0000000
--- a/packages/MtpDocumentsProvider/res/values-gl/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"Host MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Descargas"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="STORAGE_NAME">%2$s</xliff:g> de <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Accedendo aos ficheiros do dispositivo <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"O outro dispositivo está ocupado. Non podes transferir ficheiros ata que estea dispoñible."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Non se atopou ningún ficheiro. Se o outro dispositivo está bloqueado, desbloquéao e téntao de novo."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-gu/strings.xml b/packages/MtpDocumentsProvider/res/values-gu/strings.xml
deleted file mode 100644
index 468bd9d..0000000
--- a/packages/MtpDocumentsProvider/res/values-gu/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP હોસ્ટ"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"ડાઉનલોડ્સ"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> ની ફાઇલોને ઍક્સેસ કરી રહ્યાં છે"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"અન્ય ઉપકરણ વ્યસ્ત છે. તે ઉપલબ્ધ ન થાય ત્યાં સુધી તમે ફાઇલોને ટ્રાન્સફર કરી શકતાં નથી."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"કોઈ ફાઇલો મળી નહીં. અન્ય ઉપકરણ લૉક કરેલ હોઈ શકે છે. જો આમ હોય, તો તેને અનલૉક કરો અને ફરી પ્રયાસ કરો."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-hi/strings.xml b/packages/MtpDocumentsProvider/res/values-hi/strings.xml
deleted file mode 100644
index e469fc0..0000000
--- a/packages/MtpDocumentsProvider/res/values-hi/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP होस्ट"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"डाउनलोड"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> से फ़ाइलें ऐक्सेस कर रहा है"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"दूसरा डिवाइस व्यस्त है. आप उसके उपलब्ध हो जाने तक फ़ाइलें ट्रांसफ़र नहीं कर सकते."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"कोई फ़ाइल नहीं मिली. हो सकता है कि दूसरा डिवाइस लॉक हो. अगर ऐसा है, तो उसे अनलॉक करें और दोबारा कोशिश करें."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-hr/strings.xml b/packages/MtpDocumentsProvider/res/values-hr/strings.xml
deleted file mode 100644
index 63fc5c7..0000000
--- a/packages/MtpDocumentsProvider/res/values-hr/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP host"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Preuzimanja"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g><xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Pristupanje datotekama s uređaja <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Drugi je uređaj zauzet. Datoteke ćete moći prenijeti kada postane dostupan."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Datoteke nisu pronađene. Drugi je uređaj možda zaključan. U tom ga slučaju otključajte i pokušajte ponovo."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-hu/strings.xml b/packages/MtpDocumentsProvider/res/values-hu/strings.xml
deleted file mode 100644
index e5b822c..0000000
--- a/packages/MtpDocumentsProvider/res/values-hu/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP Host"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Letöltések"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Hozzáférés a fájlokhoz a következő eszközről: <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"A másik eszköz elfoglalt. Nem vihetők át fájlok addig, amíg rendelkezésre nem áll."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Nem található fájl. Lehet, hogy a másik eszköz zárolva van. Ha igen, oldja fel, és próbálkozzon újra."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-hy/strings.xml b/packages/MtpDocumentsProvider/res/values-hy/strings.xml
deleted file mode 100644
index 3a6bfb5..0000000
--- a/packages/MtpDocumentsProvider/res/values-hy/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP խնամորդ"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Ներբեռնումներ"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Մուտք է գործում ֆայլեր <xliff:g id="DEVICE_MODEL">%1$s</xliff:g> սարքից"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Մյուս սարքը զբաղված է: Ֆայլերը կարող եք փոխանցել միայն երբ այն հասանելի է:"</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Ֆայլեր չեն գտնվել: Հնարավոր է, որ մյուս սարքը կողպված է: Եթե դա այդպես է, ապակողպեք այն և փորձեք նորից:"</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-in/strings.xml b/packages/MtpDocumentsProvider/res/values-in/strings.xml
deleted file mode 100644
index 6f65337..0000000
--- a/packages/MtpDocumentsProvider/res/values-in/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"Host MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Download"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Mengakses file dari <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Perangkat lainnya sedang sibuk. Anda dapat mentransfer file jika telah tersedia."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"File tidak ditemukan. Perangkat lainnya mungkin terkunci. Jika begitu, buka kuncinya dan coba lagi."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-is/strings.xml b/packages/MtpDocumentsProvider/res/values-is/strings.xml
deleted file mode 100644
index 9388f7e..0000000
--- a/packages/MtpDocumentsProvider/res/values-is/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP-hýsill"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Niðurhal"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Fær aðgang að skrám frá <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Hitt tækið er upptekið. Þú getur ekki fært skrár fyrr en það er tiltækt."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Engar skrár fundust. Hitt tækið gæti verið læst. Ef svo er skaltu opna það og reyna aftur."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-it/strings.xml b/packages/MtpDocumentsProvider/res/values-it/strings.xml
deleted file mode 100644
index a41699f..0000000
--- a/packages/MtpDocumentsProvider/res/values-it/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"Host MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Download"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="STORAGE_NAME">%2$s</xliff:g> di <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Accesso ai file da <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"L\'altro dispositivo è occupato. I file non possono essere trasferiti fino a quando non sarà disponibile."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Nessun file trovato. L\'altro dispositivo potrebbe essere bloccato. In questo caso, sbloccalo e riprova."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-iw/strings.xml b/packages/MtpDocumentsProvider/res/values-iw/strings.xml
deleted file mode 100644
index 62dfe7d..0000000
--- a/packages/MtpDocumentsProvider/res/values-iw/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"מארח פרוטוקול העברת מדיה (MTP)"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"הורדות"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"גישה לקבצים מ-<xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"המכשיר השני לא פנוי. ניתן יהיה להעביר קבצים רק לאחר שהוא יהיה זמין."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"לא נמצאו קבצים. ייתכן שהמכשיר השני נעול. אם כן, פתח אותו ונסה שוב."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-ja/strings.xml b/packages/MtpDocumentsProvider/res/values-ja/strings.xml
deleted file mode 100644
index 72ab33d..0000000
--- a/packages/MtpDocumentsProvider/res/values-ja/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP ホスト"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"ダウンロード"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> からファイルにアクセスしています"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"接続先のデバイスは使用中のため、利用できるようになるまでファイルを転送できません。"</string>
- <string name="error_locked_device" msgid="7557872102188356147">"ファイルが見つかりません。接続先のデバイスがロックされている可能性があります。その場合は、ロックを解除してからもう一度お試しください。"</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-ka/strings.xml b/packages/MtpDocumentsProvider/res/values-ka/strings.xml
deleted file mode 100644
index 33812df..0000000
--- a/packages/MtpDocumentsProvider/res/values-ka/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP ჰოსტი"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"ჩამოტვირთვები"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"მიმდინარეობს <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>-ზე არსებულ ფაილებზე წვდომა"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"სხვა მოწყობილობა დაკავებულია. ფაილების გადატანა ვერ მოხერხდება, სანამ ის ხელმისაწვდომი არ გახდება."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"ფაილები ვერ მოიძებნა. მეორე მოწყობილობა შეიძლება დაბლოკილი იყოს. ამ შემთხვევაში, განბლოკეთ ის და ცადეთ ხელახლა."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-kk/strings.xml b/packages/MtpDocumentsProvider/res/values-kk/strings.xml
deleted file mode 100644
index a6dea5b..0000000
--- a/packages/MtpDocumentsProvider/res/values-kk/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP хосты"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Жүктеп алынғандар"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Файлдарға <xliff:g id="DEVICE_MODEL">%1$s</xliff:g> құрылғысынан кіру"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Екінші құрылғы бос емес. Ол босамайынша, файлдар тасымалданбайды."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Ешқандай файл табылмады. Екінші құрылғы құлыптаулы болуы мүмкін. Құлыптаулы болса, құлпын ашып, қайталап көріңіз."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-km/strings.xml b/packages/MtpDocumentsProvider/res/values-km/strings.xml
deleted file mode 100644
index baffa95..0000000
--- a/packages/MtpDocumentsProvider/res/values-km/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"ម៉ាស៊ីន MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"ដោយឡូត"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"កំពុងចូលដំណើរការពី <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"ឧបករណ៍ផ្សេងទៀតកំពុងជាប់រវល់។ អ្នកមិនផ្ទេរឯកសារបានទេ រហូតទាល់តែវាអាចប្រើបាន។"</string>
- <string name="error_locked_device" msgid="7557872102188356147">"រកមិនឃើញឯកសារទេ។ ឧបករណ៍ផ្សេងទៀតប្រហែលជាត្រូវបានចាក់សោ។ ប្រសិនបើវាត្រូវបានចាក់សោមែន សូមដោះសោ ហើយព្យាយាមម្តងទៀត។"</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-kn/strings.xml b/packages/MtpDocumentsProvider/res/values-kn/strings.xml
deleted file mode 100644
index 3f16c14..0000000
--- a/packages/MtpDocumentsProvider/res/values-kn/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP ಹೋಸ್ಟ್"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"ಡೌನ್ಲೋಡ್ಗಳು"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> ನಿಂದ ಫೈಲ್ಗಳನ್ನು ಪ್ರವೇಶಿಸಲಾಗುತ್ತಿದೆ"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"ಬೇರೆಯ ಸಾಧನವು ಕಾರ್ಯನಿರತವಾಗಿದೆ. ಇದು ಲಭ್ಯವಾಗುವವರೆಗೆ ಫೈಲ್ಗಳನ್ನು ನಿಮಗೆ ವರ್ಗಾಯಿಸಲು ಸಾಧ್ಯವಾಗುವುದಿಲ್ಲ."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"ಯಾವುದೇ ಫೈಲ್ಗಳು ಕಂಡುಬಂದಿಲ್ಲ. ಬೇರೆಯ ಸಾಧನವು ಲಾಕ್ ಆಗಿರಬಹುದು. ಹಾಗಾದಲ್ಲಿ, ಇದನ್ನು ಅನ್ಲಾಕ್ ಮಾಡಿ ಹಾಗೂ ಮತ್ತೆ ಪ್ರಯತ್ನಿಸಿ."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-ko/strings.xml b/packages/MtpDocumentsProvider/res/values-ko/strings.xml
deleted file mode 100644
index bbe2fe6..0000000
--- a/packages/MtpDocumentsProvider/res/values-ko/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP 호스트"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"다운로드"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g>에서 파일에 액세스 중"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"다른 기기가 사용 중입니다. 다른 기기를 사용할 수 있을 때까지 파일을 전송할 수 없습니다."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"파일이 없습니다. 다른 기기가 잠겨 있을 수 있습니다. 기기의 잠금을 해제하고 다시 시도하세요."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-ky/strings.xml b/packages/MtpDocumentsProvider/res/values-ky/strings.xml
deleted file mode 100644
index e60a494..0000000
--- a/packages/MtpDocumentsProvider/res/values-ky/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP хосту"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Жүктөлүп алынган нерселер"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> түзмөгүндөгү файлдар колдонулууда"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Берки түзмөк бош эмес. Ал бошомоюнча файлдарды өткөрө албайсыз."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Бир дагы файл табылган жок. Берки түзмөк кулпуланып турат окшойт. Кулпусун ачып, кайра аракет кылып көрүңүз."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-lo/strings.xml b/packages/MtpDocumentsProvider/res/values-lo/strings.xml
deleted file mode 100644
index bcc0ee6..0000000
--- a/packages/MtpDocumentsProvider/res/values-lo/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"ໂຮສ MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"ການດາວໂຫລດ"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"ກຳລັງເຂົ້າເຖິງໄຟລ໌ຈາກ <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"ອຸປະກອນອື່ນບໍ່ຫວ່າງເທື່ອ. ທ່ານບໍ່ສາມາດໂອນຍ້າຍໄຟລ໌ໄດ້ຈົນກວ່າມັນຈະຫວ່າງ."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"ບໍ່ພົບໄຟລ໌. ອຸປະກອນອີກເຄື່ອງອາດຖືກລັອກໄວ້ຢູ່. ຫາກມັນຖືກລັອກໄວ້, ໃຫ້ປົດລັອກມັນກ່ອນແລ້ວລອງໃໝ່ອີກຄັ້ງ."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-lt/strings.xml b/packages/MtpDocumentsProvider/res/values-lt/strings.xml
deleted file mode 100644
index 8bff3a8..0000000
--- a/packages/MtpDocumentsProvider/res/values-lt/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MPP priegloba"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Atsisiuntimai"</string>
- <string name="root_name" msgid="5819495383921089536">"„<xliff:g id="DEVICE_MODEL">%1$s</xliff:g>“ <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Pasiekiami failai iš „<xliff:g id="DEVICE_MODEL">%1$s</xliff:g>“"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Kitas įrenginys yra užsiėmęs. Failus galėsite perkelti tik tada, kai jis bus pasiekiamas."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Nerasta failų. Gali būti, kad kitas įrenginys yra užrakintas. Jei taip yra, atrakinkite jį ir bandykite dar kartą."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-lv/strings.xml b/packages/MtpDocumentsProvider/res/values-lv/strings.xml
deleted file mode 100644
index 5e96338..0000000
--- a/packages/MtpDocumentsProvider/res/values-lv/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP saimniekdators"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Lejupielādes"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Piekļuve failiem no: <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Otra ierīce ir aizņemta. Varēsiet pārsūtīt failus tikai tad, kad tā būs pieejama."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Neviens fails netika atrasts. Iespējams, otra ierīce ir bloķēta. Ja tā ir, atbloķējiet ierīci un mēģiniet vēlreiz."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-mk/strings.xml b/packages/MtpDocumentsProvider/res/values-mk/strings.xml
deleted file mode 100644
index 6028b71..0000000
--- a/packages/MtpDocumentsProvider/res/values-mk/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP-хост"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Преземања"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Се пристапува до датотеки од <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Другиот уред е зафатен. Не може да се пренесуваат датотеки сѐ додека не стане достапен."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Не се најдени датотеки. Другиот уред можеби е заклучен. Ако е така, отклучете го и обидете се повторно."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-ml/strings.xml b/packages/MtpDocumentsProvider/res/values-ml/strings.xml
deleted file mode 100644
index 49eb847..0000000
--- a/packages/MtpDocumentsProvider/res/values-ml/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP ഹോസ്റ്റ്"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"ഡൗണ്ലോഡുകൾ"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> ഉപകരണത്തിൽ നിന്ന് ഫയലുകൾ ആക്സസ്സ് ചെയ്യുന്നു"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"രണ്ടാമത്തെ ഉപകരണം തിരക്കിലാണ്. അത് ലഭ്യമാകുന്നത് വരെ നിങ്ങൾക്ക് ഫയലുകൾ കൈമാറാൻ കഴിയില്ല."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"ഫയലുകളൊന്നും കണ്ടെത്തിയില്ല. രണ്ടാമത്തെ ഉപകരണം ലോക്കുചെയ്ത നിലയിലായിരിക്കാം. ആണെങ്കിൽ, അൺലോക്കുചെയ്ത് വീണ്ടും ശ്രമിക്കുക."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-mn/strings.xml b/packages/MtpDocumentsProvider/res/values-mn/strings.xml
deleted file mode 100644
index 43b8204..0000000
--- a/packages/MtpDocumentsProvider/res/values-mn/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP Хост"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Таталт"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g>-с файлд хандаж байна"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Нөгөө төхөөрөмж завгүй байна. Үүнийг боломжтой болох хүртэл файл шилжүүлэх боломжгүй."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Файл олдсонгүй. Нөгөө төхөөрөмж түгжигдсэн байж болзошгүй. Ингэсэн тохиолдолд түгжээг нь тайлаад, дахин оролдоно уу."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-mr/strings.xml b/packages/MtpDocumentsProvider/res/values-mr/strings.xml
deleted file mode 100644
index 983112c..0000000
--- a/packages/MtpDocumentsProvider/res/values-mr/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP होस्ट"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"डाउनलोड"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> मधून फायलींंमध्ये प्रवेश करत आहे"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"दुसरे डिव्हाइस व्यस्त आहे. ते उपलब्ध होईपर्यंत तुम्ही फायली ट्रान्सफर करू शकत नाही."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"कोणत्याही फायली आढळल्या नाहीत. दुसरे डिव्हाइस कदाचित बंद असू शकते. तसे असल्यास, ते अनलॉक करा आणि पुन्हा प्रयत्न करा."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-ms/strings.xml b/packages/MtpDocumentsProvider/res/values-ms/strings.xml
deleted file mode 100644
index febec1d..0000000
--- a/packages/MtpDocumentsProvider/res/values-ms/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"Hos MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Muat turun"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Mengakses fail daripada <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Peranti lain sedang sibuk. Anda tidak boleh memindahkan fail sehingga peranti itu tersedia."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Tiada fail ditemui. Peranti lain itu mungkin dikunci. Jika benar, sila buka kuncinya dan cuba lagi."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-my/strings.xml b/packages/MtpDocumentsProvider/res/values-my/strings.xml
deleted file mode 100644
index 8b509fb..0000000
--- a/packages/MtpDocumentsProvider/res/values-my/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP လက်ခံစက်"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"ဒေါင်းလုဒ်များ"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> မှ ဖိုင်များကို အသုံးပြုနေသည်"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"တခြားစက်ပစ္စည်းသည် မအားသေးပါ။ ၎င်းအဆင်သင့် မဖြစ်သေးသ၍ ဖိုင်များကို လွှဲပြောင်း၍ရမည် မဟုတ်ပါ။"</string>
- <string name="error_locked_device" msgid="7557872102188356147">"မည်သည့်ဖိုင်မျှ မတွေ့ပါ။ ၎င်းစက်ပစ္စည်းကို လော့ခ်ချထားပုံရပါသည်။ သို့ဖြစ်လျှင် ၎င်းကိုလော့ခ်ဖြုတ်ပြီး ထပ်လုပ်ကြည့်ပါ။"</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-nb/strings.xml b/packages/MtpDocumentsProvider/res/values-nb/strings.xml
deleted file mode 100644
index 40fabed..0000000
--- a/packages/MtpDocumentsProvider/res/values-nb/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP-vert"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Nedlastinger"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="STORAGE_NAME">%2$s</xliff:g> på <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Bruker filer på <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Den andre enheten er opptatt. Du kan ikke overføre filer før den er tilgjengelig."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Ingen filer ble funnet. Den andre enheten kan være låst. I så fall må du låse den opp og prøve igjen."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-ne/strings.xml b/packages/MtpDocumentsProvider/res/values-ne/strings.xml
deleted file mode 100644
index 53c0954..0000000
--- a/packages/MtpDocumentsProvider/res/values-ne/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP होस्ट"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"डाउनलोडहरू"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> बाट फाइलहरूमाथि पहुँच राख्दै"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"अर्को यन्त्र व्यस्त छ। त्यो यन्त्र उपलब्ध नभएसम्म तपाईं फाइल स्थानान्तरण गर्न सक्नुहुन्न।"</string>
- <string name="error_locked_device" msgid="7557872102188356147">"कुनै फाइल भेट्टिएन। अर्को यन्त्र लक गरिएको हुन सक्छ। यदि त्यसो हो भने त्यसलाई अनलक गरेर फेरि प्रयास गर्नुहोस्।"</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-nl/strings.xml b/packages/MtpDocumentsProvider/res/values-nl/strings.xml
deleted file mode 100644
index b1a01b2..0000000
--- a/packages/MtpDocumentsProvider/res/values-nl/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP-host"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Downloads"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Bestanden openen op <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Het andere apparaat wordt gebruikt. Je moet wachten tot het beschikbaar is om bestanden te kunnen overzetten."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Geen bestanden gevonden. Het kan zijn dat het andere apparaat is vergrendeld. Als dat het geval is, ontgrendel je het en probeer je het opnieuw."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-or/strings.xml b/packages/MtpDocumentsProvider/res/values-or/strings.xml
deleted file mode 100644
index 79de689..0000000
--- a/packages/MtpDocumentsProvider/res/values-or/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP ହୋଷ୍ଟ"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"ଡାଉନଲୋଡ୍"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g>ରୁ ଫାଇଲ୍ ଆକ୍ସେସ୍ କରାଯାଉଛି"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"ଅନ୍ୟ ଡିଭାଇସଟି ବ୍ୟସ୍ତ ଅଛି। ଏହା ଉପଲବ୍ଧ ନହେବା ପର୍ଯ୍ୟନ୍ତ ଆପଣ ଫାଇଲ୍ ଟ୍ରାନ୍ସଫର୍ କରିପାରିବେ ନାହିଁ।"</string>
- <string name="error_locked_device" msgid="7557872102188356147">"କୌଣସି ଫାଇଲ୍ ମିଳିଲା ନାହିଁ। ଅନ୍ୟ ଡିଭାଇସଟି ଲକ୍ ହୋଇଯାଇଥାଇପାରେ। ଯଦି ଏପରି ହୋଇଥାଏ, ଏହାକୁ ଅନଲକ୍ କରି ପୁଣି ଚେଷ୍ଟା କରନ୍ତୁ।"</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-pa/strings.xml b/packages/MtpDocumentsProvider/res/values-pa/strings.xml
deleted file mode 100644
index 7e3b892..0000000
--- a/packages/MtpDocumentsProvider/res/values-pa/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP ਹੋਸਟ"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"ਡਾਊਨਲੋਡ"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> ਦੀਆਂ ਫ਼ਾਈਲਾਂ \'ਤੇ ਪਹੁੰਚ ਕੀਤੀ ਜਾ ਰਹੀ ਹੈ"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"ਦੂਜਾ ਡੀਵਾਈਸ ਰੁਝੇਵੇਂ ਵਿੱਚ ਹੈ। ਉਸਦੇ ਉਪਲਬਧ ਹੋਣ ਤੱਕ ਤੁਸੀਂ ਫ਼ਾਈਲਾਂ ਦਾ ਤਬਾਦਲਾ ਨਹੀਂ ਕਰ ਸਕਦੇ।"</string>
- <string name="error_locked_device" msgid="7557872102188356147">"ਕੋਈ ਫ਼ਾਈਲਾਂ ਨਹੀਂ ਮਿਲੀਆਂ। ਹੋ ਸਕਦਾ ਹੈ ਕਿ ਦੂਜਾ ਡੀਵਾਈਸ ਲਾਕ ਹੋਵੇ। ਜੇਕਰ ਇੰਝ ਹੈ, ਤਾਂ ਉਸਨੂੰ ਅਣਲਾਕ ਕਰੋ ਅਤੇ ਦੁਬਾਰਾ ਕੋਸ਼ਿਸ਼ ਕਰੋ।"</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-pl/strings.xml b/packages/MtpDocumentsProvider/res/values-pl/strings.xml
deleted file mode 100644
index 69fa0f4..0000000
--- a/packages/MtpDocumentsProvider/res/values-pl/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"Host MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Pobrane"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> – <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Uzyskuję dostęp do plików na urządzeniu <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Drugie urządzenie jest zajęte. Dopóki nie będzie dostępne, nie możesz przesłać plików."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Nie znaleziono plików. Drugie urządzenie może być zablokowane. Jeśli tak jest, odblokuj je i spróbuj ponownie."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-pt-rBR/strings.xml b/packages/MtpDocumentsProvider/res/values-pt-rBR/strings.xml
deleted file mode 100644
index 03a1426..0000000
--- a/packages/MtpDocumentsProvider/res/values-pt-rBR/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"Host do MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Downloads"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="STORAGE_NAME">%2$s</xliff:g> do <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Acessando arquivos do <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"O outro dispositivo está ocupado. Não é possível transferir arquivos até que ele esteja disponível."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Nenhum arquivo encontrado. É possível que o outro dispositivo esteja bloqueado. Se for o caso, desbloqueie-o e tente novamente."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-pt-rPT/strings.xml b/packages/MtpDocumentsProvider/res/values-pt-rPT/strings.xml
deleted file mode 100644
index 05d32d4..0000000
--- a/packages/MtpDocumentsProvider/res/values-pt-rPT/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"Anfitrião MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Transferências"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Aceder a ficheiros do <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"O outro dispositivo está ocupado. Não pode transferir os ficheiros enquanto não estiver disponível."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Nenhum ficheiro encontrado. O outro dispositivo pode estar bloqueado. Se assim for, desbloqueie e tente novamente."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-pt/strings.xml b/packages/MtpDocumentsProvider/res/values-pt/strings.xml
deleted file mode 100644
index 03a1426..0000000
--- a/packages/MtpDocumentsProvider/res/values-pt/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"Host do MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Downloads"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="STORAGE_NAME">%2$s</xliff:g> do <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Acessando arquivos do <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"O outro dispositivo está ocupado. Não é possível transferir arquivos até que ele esteja disponível."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Nenhum arquivo encontrado. É possível que o outro dispositivo esteja bloqueado. Se for o caso, desbloqueie-o e tente novamente."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-ro/strings.xml b/packages/MtpDocumentsProvider/res/values-ro/strings.xml
deleted file mode 100644
index 21ebc57..0000000
--- a/packages/MtpDocumentsProvider/res/values-ro/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"Gazdă MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Descărcări"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Se accesează fișierele de pe <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Celălalt dispozitiv este ocupat. Nu puteți să transferați fișiere înainte să fie disponibil."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Nu s-au găsit fișiere. Este posibil ca celălalt dispozitiv să fie blocat. În acest caz, deblocați-l și încercați din nou."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-ru/strings.xml b/packages/MtpDocumentsProvider/res/values-ru/strings.xml
deleted file mode 100644
index 717f12f..0000000
--- a/packages/MtpDocumentsProvider/res/values-ru/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP-хост"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Загрузки"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="STORAGE_NAME">%2$s</xliff:g> <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Доступ к файлам на устройстве <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>…"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Другое устройство занято. Вы сможете передать файлы, когда оно будет доступно."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Файлы не найдены. Если другое устройство заблокировано, разблокируйте его и повторите попытку."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-si/strings.xml b/packages/MtpDocumentsProvider/res/values-si/strings.xml
deleted file mode 100644
index 7a096b0..0000000
--- a/packages/MtpDocumentsProvider/res/values-si/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP සංග්රාහක"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"බාගැනීම්"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> වෙතින් ගොනු වෙත පිවිසීම"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"අනෙක් උපාංගය කාර්ය බහුලය. එය ලබා ගත හැකි වන තෙක් ඔබට ගොනු මාරු කළ නොහැකිය."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"ගොනු හමු නොවීය. අනෙක් උපාංගය අගුලු දමා තිබිය හැකිය. එසේ නම්, එය අගුලු හැර නැවත උත්සාහ කරන්න."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-sk/strings.xml b/packages/MtpDocumentsProvider/res/values-sk/strings.xml
deleted file mode 100644
index 365e1b7..0000000
--- a/packages/MtpDocumentsProvider/res/values-sk/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"Hostiteľ MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Stiahnuté súbory"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Prístup k súborom zo zariadenia <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Druhé zariadenie je zaneprázdnené. Súbory bude možné preniesť, keď bude k dispozícii."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Nenašli sa žiadne súbory. Druhé zariadenie môže byť uzamknuté. Ak je to tak, odomknite ho a skúste to znova."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-sl/strings.xml b/packages/MtpDocumentsProvider/res/values-sl/strings.xml
deleted file mode 100644
index 60945d6..0000000
--- a/packages/MtpDocumentsProvider/res/values-sl/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"Gostitelj MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Prenosi"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Dostopanje do datotek iz naprave <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Druga naprava ni na voljo. Dokler ne bo na voljo, ne bo mogoče prenašati datotek."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Ni datotek. Druga naprava je morda zaklenjena. Če je zaklenjena, jo odklenite in poskusite znova."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-sq/strings.xml b/packages/MtpDocumentsProvider/res/values-sq/strings.xml
deleted file mode 100644
index d92f29f..0000000
--- a/packages/MtpDocumentsProvider/res/values-sq/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"Pritësi i protokollit MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Shkarkimet"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Po qaset te skedarët nga <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Pajisja tjetër është e zënë. Nuk mund të transferosh skedarë deri sa të jetë në dispozicion."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Nuk u gjet asnjë skedar. Pajisja tjetër mund të jetë e kyçur. Nëse po, shkyçe dhe provo përsëri."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-sr/strings.xml b/packages/MtpDocumentsProvider/res/values-sr/strings.xml
deleted file mode 100644
index d91c5c4..0000000
--- a/packages/MtpDocumentsProvider/res/values-sr/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP хост"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Преузимања"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Приступ датотекама са уређаја <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Други уређај је заузет. Датотеке можете да пренесете тек кад он постане доступан."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Није пронађена ниједна датотека. Други уређај је можда закључан. Ако јесте, откључајте га и покушајте поново."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-sv/strings.xml b/packages/MtpDocumentsProvider/res/values-sv/strings.xml
deleted file mode 100644
index 26818eb..0000000
--- a/packages/MtpDocumentsProvider/res/values-sv/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP-värd"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Nedladdningar"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Åtkomst till filer från <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Den andra enheten är upptagen. Du kan inte överföra filer förrän den är tillgänglig."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Inga filer hittades. Den andra enheten kan vara låst. Om den är det låser du upp den och försöker igen."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-sw/strings.xml b/packages/MtpDocumentsProvider/res/values-sw/strings.xml
deleted file mode 100644
index de3ed54..0000000
--- a/packages/MtpDocumentsProvider/res/values-sw/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"Seva pangishi ya MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Vipakuliwa"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Inafikia faili kwenye <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Kifaa hicho kingine kinatumika. Huwezi kuhamisha faili hadi kipatikane."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Hakuna faili zilizopatikana. Huenda kifaa hicho kingine kimefungwa. Ikiwa kimefungwa, kifungue na ujaribu tena."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-ta/strings.xml b/packages/MtpDocumentsProvider/res/values-ta/strings.xml
deleted file mode 100644
index c6e6e620..0000000
--- a/packages/MtpDocumentsProvider/res/values-ta/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP ஹோஸ்ட்"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"இறக்கங்கள்"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> இலிருந்து கோப்புகளை அணுகுகிறது"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"பிற சாதனம் பணிமிகுதியில் உள்ளதால், அந்தப் பணி முடியும் வரை கோப்புகளை இடமாற்ற முடியாது."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"கோப்புகள் இல்லை. பிற சாதனம் பூட்டப்பட்டிருக்கக்கூடும் என்பதால் முதலில் அதைத் திறந்து, மீண்டும் முயலவும்."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-te/strings.xml b/packages/MtpDocumentsProvider/res/values-te/strings.xml
deleted file mode 100644
index b3436bf..0000000
--- a/packages/MtpDocumentsProvider/res/values-te/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP హోస్ట్"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"డౌన్లోడ్లు"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> నుండి ఫైల్లను యాక్సెస్ చేస్తోంది"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"ఇతర పరికరం బిజీగా ఉంది. అది అందుబాటులోకి వచ్చే వరకు మీరు ఫైల్లను బదిలీ చేయలేరు."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"ఫైల్లు ఏవీ కనుగొనబడలేదు. ఇతర పరికరం లాక్ చేయబడి ఉండవచ్చు. అలా జరిగి ఉంటే, దాన్ని అన్లాక్ చేసి, ఆపై మళ్లీ ప్రయత్నించండి."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-th/strings.xml b/packages/MtpDocumentsProvider/res/values-th/strings.xml
deleted file mode 100644
index d2b62fe..0000000
--- a/packages/MtpDocumentsProvider/res/values-th/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"โฮสต์ MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"ดาวน์โหลด"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"กำลังเข้าถึงไฟล์จาก <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"อุปกรณ์อีกเครื่องหนึ่งไม่ว่าง คุณไม่สามารถโอนไฟล์จนกว่าอุปกรณ์จะสามารถใช้ได้"</string>
- <string name="error_locked_device" msgid="7557872102188356147">"ไม่พบไฟล์ อุปกรณ์อีกเครื่องหนึ่งอาจล็อกอยู่ หากเป็นเช่นนั้น ให้ปลดล็อกและลองอีกครั้ง"</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-tl/strings.xml b/packages/MtpDocumentsProvider/res/values-tl/strings.xml
deleted file mode 100644
index 68b2eba..0000000
--- a/packages/MtpDocumentsProvider/res/values-tl/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"Host ng MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Mga Download"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Nag-a-access ng mga file mula sa <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Abala ang kabilang device. Hindi ka makakapaglipat ng mga file hanggang sa maging available ito."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Walang natagpuang mga file. Maaaring naka-lock ang kabilang device. Kung gayon, i-unlock ito at subukang muli."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-tr/strings.xml b/packages/MtpDocumentsProvider/res/values-tr/strings.xml
deleted file mode 100644
index 14250ef..0000000
--- a/packages/MtpDocumentsProvider/res/values-tr/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP Ana Makinesi"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"İndirilenler"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> cihazdaki dosyalara erişiliyor"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Diğer cihaz meşgul. Cihaz kullanılabilir duruma gelene kadar dosyaları aktaramazsınız."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Hiçbir dosya bulunamadı. Diğer cihaz kilitli olabilir. Kilitliyse, kilidini açıp tekrar deneyin."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-uk/strings.xml b/packages/MtpDocumentsProvider/res/values-uk/strings.xml
deleted file mode 100644
index 8589f8c..0000000
--- a/packages/MtpDocumentsProvider/res/values-uk/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"Хост MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Завантаження"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Відкриваються файли з пристрою <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Інший пристрій зайнятий. Щоб передавати файли, він має бути доступним."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Не вдалося знайти файли. Можливо, інший пристрій заблоковано. У такому разі розблокуйте його та повторіть спробу."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-ur/strings.xml b/packages/MtpDocumentsProvider/res/values-ur/strings.xml
deleted file mode 100644
index 17578ae..0000000
--- a/packages/MtpDocumentsProvider/res/values-ur/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP میزبان"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"ڈاؤن لوڈز"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> سے فائلوں کی رسائی ہو رہی ہے"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"دوسرا آلہ مصروف ہے۔ اس کے دستیاب ہونے تک آپ فائلیں منتقل نہیں کر سکتے۔"</string>
- <string name="error_locked_device" msgid="7557872102188356147">"کوئی فائلیں نہیں ملیں۔ ہو سکتا ہے دوسرا آلہ مقفل ہو۔ اگر ایسا ہے تو اسے غیر مقفل کریں اور دوبارہ کوشش کریں۔"</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-uz/strings.xml b/packages/MtpDocumentsProvider/res/values-uz/strings.xml
deleted file mode 100644
index c511172..0000000
--- a/packages/MtpDocumentsProvider/res/values-uz/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP Host"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Yuklanmalar"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g><xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> qurilmasidan fayllar o‘qilmoqda"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Ulangan qurilma band. U bo‘shamaguncha fayllarni o‘tkazib bo‘lmaydi."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Hech qanday fayl topilmadi. Ulangan qurilma qulflangan bo‘lishi mumkin. Agar shunday bo‘lsa, uni qulfdan chiqaring va qayta urinib ko‘ring."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-vi/strings.xml b/packages/MtpDocumentsProvider/res/values-vi/strings.xml
deleted file mode 100644
index 0eb6310..0000000
--- a/packages/MtpDocumentsProvider/res/values-vi/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"Máy chủ MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Tải xuống"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Đang truy cập tệp từ <xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Thiết bị khác đang bận. Bạn không thể chuyển tệp cho đến khi thiết bị rảnh."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Không tìm thấy tệp. Thiết bị khác có thể đã bị khóa. Nếu như vậy, hãy mở khóa thiết bị rồi thử lại."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-zh-rCN/strings.xml b/packages/MtpDocumentsProvider/res/values-zh-rCN/strings.xml
deleted file mode 100644
index 7f1f394..0000000
--- a/packages/MtpDocumentsProvider/res/values-zh-rCN/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"MTP 主机"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"下载"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"正在访问 <xliff:g id="DEVICE_MODEL">%1$s</xliff:g> 的文件"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"另一台设备正忙。您必须等到该设备可用时才能传输文件。"</string>
- <string name="error_locked_device" msgid="7557872102188356147">"未找到任何文件。另一台设备可能处于锁定状态;如果是这样,请解锁该设备并重试。"</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-zh-rHK/strings.xml b/packages/MtpDocumentsProvider/res/values-zh-rHK/strings.xml
deleted file mode 100644
index be8c548..0000000
--- a/packages/MtpDocumentsProvider/res/values-zh-rHK/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"媒體傳輸協定主機"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"下載"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> 的「<xliff:g id="STORAGE_NAME">%2$s</xliff:g>」"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"正在從 <xliff:g id="DEVICE_MODEL">%1$s</xliff:g> 存取檔案"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"另一部裝置目前處於忙碌狀態,要等到該裝置可用時才能轉移檔案。"</string>
- <string name="error_locked_device" msgid="7557872102188356147">"找不到檔案。如果另一部裝置處於鎖定狀態,請解鎖該裝置,然後再試一次。"</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-zh-rTW/strings.xml b/packages/MtpDocumentsProvider/res/values-zh-rTW/strings.xml
deleted file mode 100644
index 2fe3c06..0000000
--- a/packages/MtpDocumentsProvider/res/values-zh-rTW/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"媒體傳輸通訊協定主機"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"下載"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"正在從 <xliff:g id="DEVICE_MODEL">%1$s</xliff:g> 存取檔案"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"另一個裝置忙碌中。必須等到該裝置可用時才能轉移檔案。"</string>
- <string name="error_locked_device" msgid="7557872102188356147">"找不到任何檔案。如果另一個裝置處於鎖定狀態,請將該裝置解鎖後再試一次。"</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values-zu/strings.xml b/packages/MtpDocumentsProvider/res/values-zu/strings.xml
deleted file mode 100644
index f3f7206..0000000
--- a/packages/MtpDocumentsProvider/res/values-zu/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 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.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" msgid="6271216747302322594">"Ukusingatha kwe-MTP"</string>
- <string name="downloads_app_label" msgid="7120690641874849726">"Okulandiwe"</string>
- <string name="root_name" msgid="5819495383921089536">"<xliff:g id="DEVICE_MODEL">%1$s</xliff:g> <xliff:g id="STORAGE_NAME">%2$s</xliff:g>"</string>
- <string name="accessing_notification_title" msgid="3030133609230917944">"Ifinyelela kumafayela kusukela ku-<xliff:g id="DEVICE_MODEL">%1$s</xliff:g>"</string>
- <string name="error_busy_device" msgid="3997316850357386589">"Enye idivayisi imatasatasa. Awukwazi ukudlulisela amafayela ize itholakale."</string>
- <string name="error_locked_device" msgid="7557872102188356147">"Awekho amafayela atholiwe. Enye idivayisi kungenzeka ikhiyiwe. Uma kunjalo, yivule uphinde uzame futhi."</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/values/strings.xml b/packages/MtpDocumentsProvider/res/values/strings.xml
deleted file mode 100644
index b94aba0..0000000
--- a/packages/MtpDocumentsProvider/res/values/strings.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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.
--->
-
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <!-- App title of MtpDocumentsProvider [CHAR LIMIT=32] -->
- <string name="app_label">MTP Host</string>
- <!-- App title of DocumentsUI [CHAR LIMIT=32] -->
- <string name="downloads_app_label">Downloads</string>
- <!-- Name of MTP root shown in UI. Please align the two strings (device
- model and storage name) in proper order in the language.
- [CHAR LIMIT=32] -->
- <string name="root_name"><xliff:g id="device_model" example="Nexus 9">%1$s</xliff:g> <xliff:g id="storage_name" example="Internal Storage">%2$s</xliff:g></string>
- <!-- Title of notification showing Files app is accessing files in a MTP device. [CHAR LIMIT=60]-->
- <string name="accessing_notification_title">Accessing files from <xliff:g id="device_model" example="Nexus 9">%1$s</xliff:g></string>
- <!-- Error message shown in Files app when the connected MTP device is busy. [CHAR LIMIT=150]-->
- <string name="error_busy_device">The other device is busy. You can\'t transfer files until it\'s available.</string>
- <!-- Error message shown in Files app when the connected MTP device may be locked. [CHAR LIMIT=150]-->
- <string name="error_locked_device">No files found. The other device may be locked. If so, unlock it and try again.</string>
-</resources>
diff --git a/packages/MtpDocumentsProvider/res/xml/device_filter.xml b/packages/MtpDocumentsProvider/res/xml/device_filter.xml
deleted file mode 100644
index 7afa2b1..0000000
--- a/packages/MtpDocumentsProvider/res/xml/device_filter.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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.
--->
-<resources>
- <!-- filter for MTP/PTP devices -->
- <usb-device class="255" subclass="255" protocol="0" />
- <usb-device class="6" subclass="1" protocol="1" />
-</resources>
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/BusyDeviceException.java b/packages/MtpDocumentsProvider/src/com/android/mtp/BusyDeviceException.java
deleted file mode 100644
index 83488cd..0000000
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/BusyDeviceException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.mtp;
-
-import java.io.IOException;
-
-/**
- * Exception thrown when the device is busy and the requested operation cannon be completed.
- */
-class BusyDeviceException extends IOException {
- BusyDeviceException() {
- super("The MTP device is busy.");
- }
-}
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/DocumentLoader.java b/packages/MtpDocumentsProvider/src/com/android/mtp/DocumentLoader.java
deleted file mode 100644
index 6ed4ea1..0000000
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/DocumentLoader.java
+++ /dev/null
@@ -1,432 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.mtp;
-
-import android.annotation.Nullable;
-import android.annotation.WorkerThread;
-import android.content.ContentResolver;
-import android.database.Cursor;
-import android.mtp.MtpConstants;
-import android.mtp.MtpObjectInfo;
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.Process;
-import android.provider.DocumentsContract;
-import android.util.Log;
-
-import com.android.internal.util.Preconditions;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.LinkedList;
-
-/**
- * Loader for MTP document.
- * At the first request, the loader returns only first NUM_INITIAL_ENTRIES. Then it launches
- * background thread to load the rest documents and caches its result for next requests.
- * TODO: Rename this class to ObjectInfoLoader
- */
-class DocumentLoader implements AutoCloseable {
- static final int NUM_INITIAL_ENTRIES = 10;
- static final int NUM_LOADING_ENTRIES = 20;
- static final int NOTIFY_PERIOD_MS = 500;
-
- private final MtpDeviceRecord mDevice;
- private final MtpManager mMtpManager;
- private final ContentResolver mResolver;
- private final MtpDatabase mDatabase;
- private final TaskList mTaskList = new TaskList();
- private Thread mBackgroundThread;
-
- DocumentLoader(MtpDeviceRecord device, MtpManager mtpManager, ContentResolver resolver,
- MtpDatabase database) {
- mDevice = device;
- mMtpManager = mtpManager;
- mResolver = resolver;
- mDatabase = database;
- }
-
- /**
- * Queries the child documents of given parent.
- * It loads the first NUM_INITIAL_ENTRIES of object info, then launches the background thread
- * to load the rest.
- */
- synchronized Cursor queryChildDocuments(String[] columnNames, Identifier parent)
- throws IOException {
- assert parent.mDeviceId == mDevice.deviceId;
-
- LoaderTask task = mTaskList.findTask(parent);
- if (task == null) {
- if (parent.mDocumentId == null) {
- throw new FileNotFoundException("Parent not found.");
- }
- // TODO: Handle nit race around here.
- // 1. getObjectHandles.
- // 2. putNewDocument.
- // 3. startAddingChildDocuemnts.
- // 4. stopAddingChildDocuments - It removes the new document added at the step 2,
- // because it is not updated between start/stopAddingChildDocuments.
- task = new LoaderTask(mMtpManager, mDatabase, mDevice.operationsSupported, parent);
- task.loadObjectHandles();
- task.loadObjectInfoList(NUM_INITIAL_ENTRIES);
- } else {
- // Once remove the existing task in order to add it to the head of the list.
- mTaskList.remove(task);
- }
-
- mTaskList.addFirst(task);
- if (task.getState() == LoaderTask.STATE_LOADING) {
- resume();
- }
- return task.createCursor(mResolver, columnNames);
- }
-
- /**
- * Resumes a background thread.
- */
- synchronized void resume() {
- if (mBackgroundThread == null) {
- mBackgroundThread = new BackgroundLoaderThread();
- mBackgroundThread.start();
- }
- }
-
- /**
- * Obtains next task to be run in background thread, or release the reference to background
- * thread.
- *
- * Worker thread that receives null task needs to exit.
- */
- @WorkerThread
- synchronized @Nullable LoaderTask getNextTaskOrReleaseBackgroundThread() {
- Preconditions.checkState(mBackgroundThread != null);
-
- for (final LoaderTask task : mTaskList) {
- if (task.getState() == LoaderTask.STATE_LOADING) {
- return task;
- }
- }
-
- final Identifier identifier = mDatabase.getUnmappedDocumentsParent(mDevice.deviceId);
- if (identifier != null) {
- final LoaderTask existingTask = mTaskList.findTask(identifier);
- if (existingTask != null) {
- Preconditions.checkState(existingTask.getState() != LoaderTask.STATE_LOADING);
- mTaskList.remove(existingTask);
- }
- final LoaderTask newTask = new LoaderTask(
- mMtpManager, mDatabase, mDevice.operationsSupported, identifier);
- newTask.loadObjectHandles();
- mTaskList.addFirst(newTask);
- return newTask;
- }
-
- mBackgroundThread = null;
- return null;
- }
-
- /**
- * Terminates background thread.
- */
- @Override
- public void close() throws InterruptedException {
- final Thread thread;
- synchronized (this) {
- mTaskList.clear();
- thread = mBackgroundThread;
- }
- if (thread != null) {
- thread.interrupt();
- thread.join();
- }
- }
-
- synchronized void clearCompletedTasks() {
- mTaskList.clearCompletedTasks();
- }
-
- /**
- * Cancels the task for |parentIdentifier|.
- *
- * Task is removed from the cached list and it will create new task when |parentIdentifier|'s
- * children are queried next.
- */
- void cancelTask(Identifier parentIdentifier) {
- final LoaderTask task;
- synchronized (this) {
- task = mTaskList.findTask(parentIdentifier);
- }
- if (task != null) {
- task.cancel();
- mTaskList.remove(task);
- }
- }
-
- /**
- * Background thread to fetch object info.
- */
- private class BackgroundLoaderThread extends Thread {
- /**
- * Finds task that needs to be processed, then loads NUM_LOADING_ENTRIES of object info and
- * store them to the database. If it does not find a task, exits the thread.
- */
- @Override
- public void run() {
- Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
- while (!Thread.interrupted()) {
- final LoaderTask task = getNextTaskOrReleaseBackgroundThread();
- if (task == null) {
- return;
- }
- task.loadObjectInfoList(NUM_LOADING_ENTRIES);
- final boolean shouldNotify =
- task.getState() != LoaderTask.STATE_CANCELLED &&
- (task.mLastNotified.getTime() <
- new Date().getTime() - NOTIFY_PERIOD_MS ||
- task.getState() != LoaderTask.STATE_LOADING);
- if (shouldNotify) {
- task.notify(mResolver);
- }
- }
- }
- }
-
- /**
- * Task list that has helper methods to search/clear tasks.
- */
- private static class TaskList extends LinkedList<LoaderTask> {
- LoaderTask findTask(Identifier parent) {
- for (int i = 0; i < size(); i++) {
- if (get(i).mIdentifier.equals(parent))
- return get(i);
- }
- return null;
- }
-
- void clearCompletedTasks() {
- int i = 0;
- while (i < size()) {
- if (get(i).getState() == LoaderTask.STATE_COMPLETED) {
- remove(i);
- } else {
- i++;
- }
- }
- }
- }
-
- /**
- * Loader task.
- * Each task is responsible for fetching child documents for the given parent document.
- */
- private static class LoaderTask {
- static final int STATE_START = 0;
- static final int STATE_LOADING = 1;
- static final int STATE_COMPLETED = 2;
- static final int STATE_ERROR = 3;
- static final int STATE_CANCELLED = 4;
-
- final MtpManager mManager;
- final MtpDatabase mDatabase;
- final int[] mOperationsSupported;
- final Identifier mIdentifier;
- int[] mObjectHandles;
- int mState;
- Date mLastNotified;
- int mPosition;
- IOException mError;
-
- LoaderTask(MtpManager manager, MtpDatabase database, int[] operationsSupported,
- Identifier identifier) {
- assert operationsSupported != null;
- assert identifier.mDocumentType != MtpDatabaseConstants.DOCUMENT_TYPE_DEVICE;
- mManager = manager;
- mDatabase = database;
- mOperationsSupported = operationsSupported;
- mIdentifier = identifier;
- mObjectHandles = null;
- mState = STATE_START;
- mPosition = 0;
- mLastNotified = new Date();
- }
-
- synchronized void loadObjectHandles() {
- assert mState == STATE_START;
- mPosition = 0;
- int parentHandle = mIdentifier.mObjectHandle;
- // Need to pass the special value MtpManager.OBJECT_HANDLE_ROOT_CHILDREN to
- // getObjectHandles if we would like to obtain children under the root.
- if (mIdentifier.mDocumentType == MtpDatabaseConstants.DOCUMENT_TYPE_STORAGE) {
- parentHandle = MtpManager.OBJECT_HANDLE_ROOT_CHILDREN;
- }
- try {
- mObjectHandles = mManager.getObjectHandles(
- mIdentifier.mDeviceId, mIdentifier.mStorageId, parentHandle);
- mState = STATE_LOADING;
- } catch (IOException error) {
- mError = error;
- mState = STATE_ERROR;
- }
- }
-
- /**
- * Returns a cursor that traverses the child document of the parent document handled by the
- * task.
- * The returned task may have a EXTRA_LOADING flag.
- */
- synchronized Cursor createCursor(ContentResolver resolver, String[] columnNames)
- throws IOException {
- final Bundle extras = new Bundle();
- switch (getState()) {
- case STATE_LOADING:
- extras.putBoolean(DocumentsContract.EXTRA_LOADING, true);
- break;
- case STATE_ERROR:
- throw mError;
- }
- final Cursor cursor =
- mDatabase.queryChildDocuments(columnNames, mIdentifier.mDocumentId);
- cursor.setExtras(extras);
- cursor.setNotificationUri(resolver, createUri());
- return cursor;
- }
-
- /**
- * Stores object information into database.
- */
- void loadObjectInfoList(int count) {
- synchronized (this) {
- if (mState != STATE_LOADING) {
- return;
- }
- if (mPosition == 0) {
- try{
- mDatabase.getMapper().startAddingDocuments(mIdentifier.mDocumentId);
- } catch (FileNotFoundException error) {
- mError = error;
- mState = STATE_ERROR;
- return;
- }
- }
- }
- final ArrayList<MtpObjectInfo> infoList = new ArrayList<>();
- for (int chunkEnd = mPosition + count;
- mPosition < mObjectHandles.length && mPosition < chunkEnd;
- mPosition++) {
- try {
- infoList.add(mManager.getObjectInfo(
- mIdentifier.mDeviceId, mObjectHandles[mPosition]));
- } catch (IOException error) {
- Log.e(MtpDocumentsProvider.TAG, "Failed to load object info", error);
- }
- }
- final long[] objectSizeList = new long[infoList.size()];
- for (int i = 0; i < infoList.size(); i++) {
- final MtpObjectInfo info = infoList.get(i);
- // Compressed size is 32-bit unsigned integer but getCompressedSize returns the
- // value in Java int (signed 32-bit integer). Use getCompressedSizeLong instead
- // to get the value in Java long.
- if (info.getCompressedSizeLong() != 0xffffffffl) {
- objectSizeList[i] = info.getCompressedSizeLong();
- continue;
- }
-
- if (!MtpDeviceRecord.isSupported(
- mOperationsSupported,
- MtpConstants.OPERATION_GET_OBJECT_PROP_DESC) ||
- !MtpDeviceRecord.isSupported(
- mOperationsSupported,
- MtpConstants.OPERATION_GET_OBJECT_PROP_VALUE)) {
- objectSizeList[i] = -1;
- continue;
- }
-
- // Object size is more than 4GB.
- try {
- objectSizeList[i] = mManager.getObjectSizeLong(
- mIdentifier.mDeviceId,
- info.getObjectHandle(),
- info.getFormat());
- } catch (IOException error) {
- Log.e(MtpDocumentsProvider.TAG, "Failed to get object size property.", error);
- objectSizeList[i] = -1;
- }
- }
- synchronized (this) {
- // Check if the task is cancelled or not.
- if (mState != STATE_LOADING) {
- return;
- }
- try {
- mDatabase.getMapper().putChildDocuments(
- mIdentifier.mDeviceId,
- mIdentifier.mDocumentId,
- mOperationsSupported,
- infoList.toArray(new MtpObjectInfo[infoList.size()]),
- objectSizeList);
- } catch (FileNotFoundException error) {
- // Looks like the parent document information is removed.
- // Adding documents has already cancelled in Mapper so we don't need to invoke
- // stopAddingDocuments.
- mError = error;
- mState = STATE_ERROR;
- return;
- }
- if (mPosition >= mObjectHandles.length) {
- try{
- mDatabase.getMapper().stopAddingDocuments(mIdentifier.mDocumentId);
- mState = STATE_COMPLETED;
- } catch (FileNotFoundException error) {
- mError = error;
- mState = STATE_ERROR;
- return;
- }
- }
- }
- }
-
- /**
- * Cancels the task.
- */
- synchronized void cancel() {
- mDatabase.getMapper().cancelAddingDocuments(mIdentifier.mDocumentId);
- mState = STATE_CANCELLED;
- }
-
- /**
- * Returns a state of the task.
- */
- int getState() {
- return mState;
- }
-
- /**
- * Notifies a change of child list of the document.
- */
- void notify(ContentResolver resolver) {
- resolver.notifyChange(createUri(), null, false);
- mLastNotified = new Date();
- }
-
- private Uri createUri() {
- return DocumentsContract.buildChildDocumentsUri(
- MtpDocumentsProvider.AUTHORITY, mIdentifier.mDocumentId);
- }
- }
-}
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/Identifier.java b/packages/MtpDocumentsProvider/src/com/android/mtp/Identifier.java
deleted file mode 100644
index 124d207..0000000
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/Identifier.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.mtp;
-
-import java.util.Objects;
-import static com.android.mtp.MtpDatabaseConstants.DocumentType;
-
-/**
- * Static utilities for ID.
- */
-class Identifier {
- final int mDeviceId;
- final int mStorageId;
- final int mObjectHandle;
- final String mDocumentId;
- final @DocumentType int mDocumentType;
-
- Identifier(int deviceId, int storageId, int objectHandle, String documentId,
- @DocumentType int documentType) {
- mDeviceId = deviceId;
- mStorageId = storageId;
- mObjectHandle = objectHandle;
- mDocumentId = documentId;
- mDocumentType = documentType;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof Identifier))
- return false;
- final Identifier other = (Identifier) obj;
- return mDeviceId == other.mDeviceId && mStorageId == other.mStorageId &&
- mObjectHandle == other.mObjectHandle && mDocumentId.equals(other.mDocumentId);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(mDeviceId, mStorageId, mObjectHandle, mDocumentId);
- }
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("Identifier { ");
-
- builder.append("mDeviceId: ");
- builder.append(mDeviceId);
- builder.append(", ");
-
- builder.append("mStorageId: ");
- builder.append(mStorageId);
- builder.append(", ");
-
- builder.append("mObjectHandle: ");
- builder.append(mObjectHandle);
- builder.append(", ");
-
- builder.append("mDocumentId: ");
- builder.append(mDocumentId);
- builder.append(", ");
-
- builder.append("mDocumentType: ");
- builder.append(mDocumentType);
- builder.append(" }");
- return builder.toString();
- }
-}
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/Mapper.java b/packages/MtpDocumentsProvider/src/com/android/mtp/Mapper.java
deleted file mode 100644
index 63f18f3..0000000
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/Mapper.java
+++ /dev/null
@@ -1,472 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.mtp;
-
-import android.annotation.Nullable;
-import android.content.ContentValues;
-import android.database.Cursor;
-import android.database.DatabaseUtils;
-import android.database.sqlite.SQLiteDatabase;
-import android.mtp.MtpObjectInfo;
-import android.provider.DocumentsContract.Document;
-import android.provider.DocumentsContract.Root;
-import android.util.ArraySet;
-import android.util.Log;
-
-import com.android.internal.util.Preconditions;
-
-import java.io.FileNotFoundException;
-import java.util.Set;
-
-import static com.android.mtp.MtpDatabaseConstants.*;
-import static com.android.mtp.MtpDatabase.strings;
-
-/**
- * Mapping operations for MtpDatabase.
- * Also see the comments of {@link MtpDatabase}.
- */
-class Mapper {
- private static final String[] EMPTY_ARGS = new String[0];
- private final MtpDatabase mDatabase;
-
- /**
- * IDs which currently Mapper operates mapping for.
- */
- private final Set<String> mInMappingIds = new ArraySet<>();
-
- Mapper(MtpDatabase database) {
- mDatabase = database;
- }
-
- /**
- * Puts device information to database.
- *
- * @return If device is added to the database.
- * @throws FileNotFoundException
- */
- synchronized boolean putDeviceDocument(MtpDeviceRecord device) throws FileNotFoundException {
- final SQLiteDatabase database = mDatabase.getSQLiteDatabase();
- database.beginTransaction();
- try {
- final ContentValues[] valuesList = new ContentValues[1];
- final ContentValues[] extraValuesList = new ContentValues[1];
- valuesList[0] = new ContentValues();
- extraValuesList[0] = new ContentValues();
- MtpDatabase.getDeviceDocumentValues(valuesList[0], extraValuesList[0], device);
- final boolean changed = putDocuments(
- null,
- valuesList,
- extraValuesList,
- COLUMN_PARENT_DOCUMENT_ID + " IS NULL",
- EMPTY_ARGS,
- strings(COLUMN_DEVICE_ID, COLUMN_MAPPING_KEY));
- database.setTransactionSuccessful();
- return changed;
- } finally {
- database.endTransaction();
- }
- }
-
- /**
- * Puts root information to database.
- *
- * @param parentDocumentId Document ID of device document.
- * @param roots List of root information.
- * @return If roots are added or removed from the database.
- * @throws FileNotFoundException
- */
- synchronized boolean putStorageDocuments(
- String parentDocumentId, int[] operationsSupported, MtpRoot[] roots)
- throws FileNotFoundException {
- final SQLiteDatabase database = mDatabase.getSQLiteDatabase();
- database.beginTransaction();
- try {
- final ContentValues[] valuesList = new ContentValues[roots.length];
- final ContentValues[] extraValuesList = new ContentValues[roots.length];
- for (int i = 0; i < roots.length; i++) {
- valuesList[i] = new ContentValues();
- extraValuesList[i] = new ContentValues();
- MtpDatabase.getStorageDocumentValues(
- valuesList[i],
- extraValuesList[i],
- parentDocumentId,
- operationsSupported,
- roots[i]);
- }
- final boolean changed = putDocuments(
- parentDocumentId,
- valuesList,
- extraValuesList,
- COLUMN_PARENT_DOCUMENT_ID + " = ?",
- strings(parentDocumentId),
- strings(COLUMN_STORAGE_ID, Document.COLUMN_DISPLAY_NAME));
-
- database.setTransactionSuccessful();
- return changed;
- } finally {
- database.endTransaction();
- }
- }
-
- /**
- * Puts document information to database.
- *
- * @param deviceId Device ID
- * @param parentId Parent document ID.
- * @param documents List of document information.
- * @param documentSizes 64-bit size of documents. MtpObjectInfo#getComporessedSize will be
- * ignored because it does not contain 4GB> object size. Can be -1 if the size is unknown.
- * @throws FileNotFoundException
- */
- synchronized void putChildDocuments(
- int deviceId, String parentId,
- int[] operationsSupported,
- MtpObjectInfo[] documents,
- long[] documentSizes)
- throws FileNotFoundException {
- assert documents.length == documentSizes.length;
- final ContentValues[] valuesList = new ContentValues[documents.length];
- for (int i = 0; i < documents.length; i++) {
- valuesList[i] = new ContentValues();
- MtpDatabase.getObjectDocumentValues(
- valuesList[i],
- deviceId,
- parentId,
- operationsSupported,
- documents[i],
- documentSizes[i]);
- }
- putDocuments(
- parentId,
- valuesList,
- null,
- COLUMN_PARENT_DOCUMENT_ID + " = ?",
- strings(parentId),
- strings(COLUMN_OBJECT_HANDLE, Document.COLUMN_DISPLAY_NAME));
- }
-
- void clearMapping() {
- final SQLiteDatabase database = mDatabase.getSQLiteDatabase();
- database.beginTransaction();
- try {
- mInMappingIds.clear();
- // Disconnect all device rows.
- try {
- startAddingDocuments(null);
- stopAddingDocuments(null);
- } catch (FileNotFoundException exception) {
- Log.e(MtpDocumentsProvider.TAG, "Unexpected FileNotFoundException.", exception);
- throw new RuntimeException(exception);
- }
- database.setTransactionSuccessful();
- } finally {
- database.endTransaction();
- }
- }
-
- /**
- * Starts adding new documents.
- * It changes the direct child documents of the given document from VALID to INVALIDATED.
- * Note that it keeps DISCONNECTED documents as they are.
- *
- * @param parentDocumentId Parent document ID or NULL for root documents.
- * @throws FileNotFoundException
- */
- void startAddingDocuments(@Nullable String parentDocumentId) throws FileNotFoundException {
- final String selection;
- final String[] args;
- if (parentDocumentId != null) {
- selection = COLUMN_PARENT_DOCUMENT_ID + " = ?";
- args = strings(parentDocumentId);
- } else {
- selection = COLUMN_PARENT_DOCUMENT_ID + " IS NULL";
- args = EMPTY_ARGS;
- }
-
- final SQLiteDatabase database = mDatabase.getSQLiteDatabase();
- database.beginTransaction();
- try {
- getParentOrHaltMapping(parentDocumentId);
- Preconditions.checkState(!mInMappingIds.contains(parentDocumentId));
-
- // Set all valid documents as invalidated.
- final ContentValues values = new ContentValues();
- values.put(COLUMN_ROW_STATE, ROW_STATE_INVALIDATED);
- database.update(
- TABLE_DOCUMENTS,
- values,
- selection + " AND " + COLUMN_ROW_STATE + " = ?",
- DatabaseUtils.appendSelectionArgs(args, strings(ROW_STATE_VALID)));
-
- database.setTransactionSuccessful();
- mInMappingIds.add(parentDocumentId);
- } finally {
- database.endTransaction();
- }
- }
-
- /**
- * Puts the documents into the database.
- * If the mapping mode is not heuristic, it just adds the rows to the database or updates the
- * existing rows with the new values. If the mapping mode is heuristic, it adds some new rows as
- * 'pending' state when that rows may be corresponding to existing 'invalidated' rows. Then
- * {@link #stopAddingDocuments(String)} turns the pending rows into 'valid'
- * rows. If the methods adds rows to database, it updates valueList with correct document ID.
- *
- * @param parentId Parent document ID.
- * @param valuesList Values for documents to be stored in the database.
- * @param rootExtraValuesList Values for root extra to be stored in the database.
- * @param selection SQL where closure to select rows that shares the same parent.
- * @param args Argument for selection SQL.
- * @return Whether the database content is changed.
- * @throws FileNotFoundException When parentId is not registered in the database.
- */
- private boolean putDocuments(
- String parentId,
- ContentValues[] valuesList,
- @Nullable ContentValues[] rootExtraValuesList,
- String selection,
- String[] args,
- String[] mappingKeys) throws FileNotFoundException {
- final SQLiteDatabase database = mDatabase.getSQLiteDatabase();
- boolean changed = false;
- database.beginTransaction();
- try {
- getParentOrHaltMapping(parentId);
- Preconditions.checkState(mInMappingIds.contains(parentId));
- final ContentValues oldRowSnapshot = new ContentValues();
- final ContentValues newRowSnapshot = new ContentValues();
- for (int i = 0; i < valuesList.length; i++) {
- final ContentValues values = valuesList[i];
- final ContentValues rootExtraValues;
- if (rootExtraValuesList != null) {
- rootExtraValues = rootExtraValuesList[i];
- } else {
- rootExtraValues = null;
- }
- try (final Cursor candidateCursor =
- queryCandidate(selection, args, mappingKeys, values)) {
- final long rowId;
- if (candidateCursor == null) {
- rowId = database.insert(TABLE_DOCUMENTS, null, values);
- changed = true;
- } else {
- candidateCursor.moveToNext();
- rowId = candidateCursor.getLong(0);
- if (!changed) {
- mDatabase.writeRowSnapshot(String.valueOf(rowId), oldRowSnapshot);
- }
- database.update(
- TABLE_DOCUMENTS,
- values,
- SELECTION_DOCUMENT_ID,
- strings(rowId));
- }
- // Document ID is a primary integer key of the table. So the returned row
- // IDs should be same with the document ID.
- values.put(Document.COLUMN_DOCUMENT_ID, rowId);
- if (rootExtraValues != null) {
- rootExtraValues.put(Root.COLUMN_ROOT_ID, rowId);
- database.replace(TABLE_ROOT_EXTRA, null, rootExtraValues);
- }
-
- if (!changed) {
- mDatabase.writeRowSnapshot(String.valueOf(rowId), newRowSnapshot);
- // Put row state as string because SQLite returns snapshot values as string.
- oldRowSnapshot.put(COLUMN_ROW_STATE, String.valueOf(ROW_STATE_VALID));
- if (!oldRowSnapshot.equals(newRowSnapshot)) {
- changed = true;
- }
- }
- }
- }
-
- database.setTransactionSuccessful();
- return changed;
- } finally {
- database.endTransaction();
- }
- }
-
- /**
- * Stops adding documents.
- * It handles 'invalidated' and 'disconnected' documents which we don't put corresponding
- * documents so far.
- * If the type adding document is 'device' or 'storage', the document may appear again
- * afterward. The method marks such documents as 'disconnected'. If the type of adding document
- * is 'object', it seems the documents are really removed from the remote MTP device. So the
- * method deletes the metadata from the database.
- *
- * @param parentId Parent document ID or null for root documents.
- * @return Whether the methods changes file metadata in database.
- * @throws FileNotFoundException
- */
- boolean stopAddingDocuments(@Nullable String parentId) throws FileNotFoundException {
- final String selection;
- final String[] args;
- if (parentId != null) {
- selection = COLUMN_PARENT_DOCUMENT_ID + " = ?";
- args = strings(parentId);
- } else {
- selection = COLUMN_PARENT_DOCUMENT_ID + " IS NULL";
- args = EMPTY_ARGS;
- }
-
- final SQLiteDatabase database = mDatabase.getSQLiteDatabase();
- database.beginTransaction();
- try {
- final Identifier parentIdentifier = getParentOrHaltMapping(parentId);
- Preconditions.checkState(mInMappingIds.contains(parentId));
- mInMappingIds.remove(parentId);
-
- boolean changed = false;
- // Delete/disconnect all invalidated/disconnected rows that cannot be mapped.
- // If parentIdentifier is null, added documents are devices.
- // if parentIdentifier is DOCUMENT_TYPE_DEVICE, added documents are storages.
- final boolean keepUnmatchedDocument =
- parentIdentifier == null ||
- parentIdentifier.mDocumentType == DOCUMENT_TYPE_DEVICE;
- if (keepUnmatchedDocument) {
- if (mDatabase.disconnectDocumentsRecursively(
- COLUMN_ROW_STATE + " = ? AND " + selection,
- DatabaseUtils.appendSelectionArgs(strings(ROW_STATE_INVALIDATED), args))) {
- changed = true;
- }
- } else {
- if (mDatabase.deleteDocumentsAndRootsRecursively(
- COLUMN_ROW_STATE + " IN (?, ?) AND " + selection,
- DatabaseUtils.appendSelectionArgs(
- strings(ROW_STATE_INVALIDATED, ROW_STATE_DISCONNECTED), args))) {
- changed = true;
- }
- }
-
- database.setTransactionSuccessful();
- return changed;
- } finally {
- database.endTransaction();
- }
- }
-
- /**
- * Cancels adding documents.
- * @param parentId
- */
- void cancelAddingDocuments(@Nullable String parentId) {
- final String selection;
- final String[] args;
- if (parentId != null) {
- selection = COLUMN_PARENT_DOCUMENT_ID + " = ?";
- args = strings(parentId);
- } else {
- selection = COLUMN_PARENT_DOCUMENT_ID + " IS NULL";
- args = EMPTY_ARGS;
- }
-
- final SQLiteDatabase database = mDatabase.getSQLiteDatabase();
- database.beginTransaction();
- try {
- if (!mInMappingIds.contains(parentId)) {
- return;
- }
- mInMappingIds.remove(parentId);
- final ContentValues values = new ContentValues();
- values.put(COLUMN_ROW_STATE, ROW_STATE_VALID);
- mDatabase.getSQLiteDatabase().update(
- TABLE_DOCUMENTS,
- values,
- selection + " AND " + COLUMN_ROW_STATE + " = ?",
- DatabaseUtils.appendSelectionArgs(args, strings(ROW_STATE_INVALIDATED)));
- database.setTransactionSuccessful();
- } finally {
- database.endTransaction();
- }
- }
-
- /**
- * Queries candidate for each mappingKey, and returns the first cursor that includes a
- * candidate.
- *
- * @param selection Pre-selection for candidate.
- * @param args Arguments for selection.
- * @param mappingKeys List of mapping key columns.
- * @param values Values of document that Mapper tries to map.
- * @return Cursor for mapping candidate or null when Mapper does not find any candidate.
- */
- private @Nullable Cursor queryCandidate(
- String selection, String[] args, String[] mappingKeys, ContentValues values) {
- for (final String mappingKey : mappingKeys) {
- final Cursor candidateCursor = queryCandidate(selection, args, mappingKey, values);
- if (candidateCursor.getCount() == 0) {
- candidateCursor.close();
- continue;
- }
- return candidateCursor;
- }
- return null;
- }
-
- /**
- * Looks for mapping candidate with given mappingKey.
- *
- * @param selection Pre-selection for candidate.
- * @param args Arguments for selection.
- * @param mappingKey Column name of mapping key.
- * @param values Values of document that Mapper tries to map.
- * @return Cursor for mapping candidate.
- */
- private Cursor queryCandidate(
- String selection, String[] args, String mappingKey, ContentValues values) {
- final SQLiteDatabase database = mDatabase.getSQLiteDatabase();
- return database.query(
- TABLE_DOCUMENTS,
- strings(Document.COLUMN_DOCUMENT_ID),
- selection + " AND " +
- COLUMN_ROW_STATE + " IN (?, ?) AND " +
- mappingKey + " = ?",
- DatabaseUtils.appendSelectionArgs(
- args,
- strings(ROW_STATE_INVALIDATED,
- ROW_STATE_DISCONNECTED,
- values.getAsString(mappingKey))),
- null,
- null,
- null,
- "1");
- }
-
- /**
- * Returns the parent identifier from parent document ID if the parent ID is found in the
- * database. Otherwise it halts mapping and throws FileNotFoundException.
- *
- * @param parentId Parent document ID
- * @return Parent identifier
- * @throws FileNotFoundException
- */
- private @Nullable Identifier getParentOrHaltMapping(
- @Nullable String parentId) throws FileNotFoundException {
- if (parentId == null) {
- return null;
- }
- try {
- return mDatabase.createIdentifier(parentId);
- } catch (FileNotFoundException error) {
- mInMappingIds.remove(parentId);
- throw error;
- }
- }
-}
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDatabase.java b/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDatabase.java
deleted file mode 100644
index 59c205a..0000000
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDatabase.java
+++ /dev/null
@@ -1,921 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.mtp;
-
-import static com.android.mtp.MtpDatabaseConstants.*;
-
-import android.annotation.Nullable;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.res.Resources;
-import android.database.Cursor;
-import android.database.DatabaseUtils;
-import android.database.MatrixCursor;
-import android.database.MatrixCursor.RowBuilder;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-import android.database.sqlite.SQLiteQueryBuilder;
-import android.media.MediaFile;
-import android.mtp.MtpConstants;
-import android.mtp.MtpObjectInfo;
-import android.net.Uri;
-import android.provider.DocumentsContract;
-import android.provider.MetadataReader;
-import android.provider.DocumentsContract.Document;
-import android.provider.DocumentsContract.Root;
-
-import com.android.internal.annotations.VisibleForTesting;
-import com.android.internal.util.Preconditions;
-
-import java.io.FileNotFoundException;
-import java.util.HashSet;
-import java.util.Objects;
-import java.util.Set;
-
-/**
- * Database for MTP objects.
- * The object handle which is identifier for object in MTP protocol is not stable over sessions.
- * When we resume the process, we need to remap our document ID with MTP's object handle.
- *
- * If the remote MTP device is backed by typical file system, the file name
- * is unique among files in a directory. However, MTP protocol itself does
- * not guarantee the uniqueness of name so we cannot use fullpath as ID.
- *
- * Instead of fullpath, we use artificial ID generated by MtpDatabase itself. The database object
- * remembers the map of document ID and object handle, and remaps new object handle with document ID
- * by comparing the directory structure and object name.
- *
- * To start putting documents into the database, the client needs to call
- * {@link Mapper#startAddingDocuments(String)} with the parent document ID. Also it
- * needs to call {@link Mapper#stopAddingDocuments(String)} after putting all child
- * documents to the database. (All explanations are same for root documents)
- *
- * database.getMapper().startAddingDocuments();
- * database.getMapper().putChildDocuments();
- * database.getMapper().stopAddingDocuments();
- *
- * To update the existing documents, the client code can repeat to call the three methods again.
- * The newly added rows update corresponding existing rows that have same MTP identifier like
- * objectHandle.
- *
- * The client can call putChildDocuments multiple times to add documents by chunk, but it needs to
- * put all documents under the parent before calling stopAddingChildDocuments. Otherwise missing
- * documents are regarded as deleted, and will be removed from the database.
- *
- * If the client calls clearMtpIdentifier(), it clears MTP identifier in the database. In this case,
- * the database tries to find corresponding rows by using document's name instead of MTP identifier
- * at the next update cycle.
- *
- * TODO: Improve performance by SQL optimization.
- */
-class MtpDatabase {
- private final SQLiteDatabase mDatabase;
- private final Mapper mMapper;
-
- SQLiteDatabase getSQLiteDatabase() {
- return mDatabase;
- }
-
- MtpDatabase(Context context, int flags) {
- final OpenHelper helper = new OpenHelper(context, flags);
- mDatabase = helper.getWritableDatabase();
- mMapper = new Mapper(this);
- }
-
- void close() {
- mDatabase.close();
- }
-
- /**
- * Returns operations for mapping.
- * @return Mapping operations.
- */
- Mapper getMapper() {
- return mMapper;
- }
-
- /**
- * Queries roots information.
- * @param columnNames Column names defined in {@link android.provider.DocumentsContract.Root}.
- * @return Database cursor.
- */
- Cursor queryRoots(Resources resources, String[] columnNames) {
- final String selection =
- COLUMN_ROW_STATE + " IN (?, ?) AND " + COLUMN_DOCUMENT_TYPE + " = ?";
- final Cursor deviceCursor = mDatabase.query(
- TABLE_DOCUMENTS,
- strings(COLUMN_DEVICE_ID),
- selection,
- strings(ROW_STATE_VALID, ROW_STATE_INVALIDATED, DOCUMENT_TYPE_DEVICE),
- COLUMN_DEVICE_ID,
- null,
- null,
- null);
-
- try {
- final SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
- builder.setTables(JOIN_ROOTS);
- builder.setProjectionMap(COLUMN_MAP_ROOTS);
- final MatrixCursor result = new MatrixCursor(columnNames);
- final ContentValues values = new ContentValues();
-
- while (deviceCursor.moveToNext()) {
- final int deviceId = deviceCursor.getInt(0);
- final Cursor storageCursor = builder.query(
- mDatabase,
- columnNames,
- selection + " AND " + COLUMN_DEVICE_ID + " = ?",
- strings(ROW_STATE_VALID,
- ROW_STATE_INVALIDATED,
- DOCUMENT_TYPE_STORAGE,
- deviceId),
- null,
- null,
- null);
- try {
- values.clear();
- try (final Cursor deviceRoot = builder.query(
- mDatabase,
- columnNames,
- selection + " AND " + COLUMN_DEVICE_ID + " = ?",
- strings(ROW_STATE_VALID,
- ROW_STATE_INVALIDATED,
- DOCUMENT_TYPE_DEVICE,
- deviceId),
- null,
- null,
- null)) {
- deviceRoot.moveToNext();
- DatabaseUtils.cursorRowToContentValues(deviceRoot, values);
- }
-
- if (storageCursor.getCount() != 0) {
- long capacityBytes = 0;
- long availableBytes = 0;
- final int capacityIndex =
- storageCursor.getColumnIndex(Root.COLUMN_CAPACITY_BYTES);
- final int availableIndex =
- storageCursor.getColumnIndex(Root.COLUMN_AVAILABLE_BYTES);
- while (storageCursor.moveToNext()) {
- // If requested columnNames does not include COLUMN_XXX_BYTES, we
- // don't calculate corresponding values.
- if (capacityIndex != -1) {
- capacityBytes += storageCursor.getLong(capacityIndex);
- }
- if (availableIndex != -1) {
- availableBytes += storageCursor.getLong(availableIndex);
- }
- }
- values.put(Root.COLUMN_CAPACITY_BYTES, capacityBytes);
- values.put(Root.COLUMN_AVAILABLE_BYTES, availableBytes);
- } else {
- values.putNull(Root.COLUMN_CAPACITY_BYTES);
- values.putNull(Root.COLUMN_AVAILABLE_BYTES);
- }
- if (storageCursor.getCount() == 1 && values.containsKey(Root.COLUMN_TITLE)) {
- storageCursor.moveToFirst();
- // Add storage name to device name if we have only 1 storage.
- values.put(
- Root.COLUMN_TITLE,
- resources.getString(
- R.string.root_name,
- values.getAsString(Root.COLUMN_TITLE),
- storageCursor.getString(
- storageCursor.getColumnIndex(Root.COLUMN_TITLE))));
- }
- } finally {
- storageCursor.close();
- }
-
- putValuesToCursor(values, result);
- }
-
- return result;
- } finally {
- deviceCursor.close();
- }
- }
-
- /**
- * Queries root documents information.
- * @param columnNames Column names defined in
- * {@link android.provider.DocumentsContract.Document}.
- * @return Database cursor.
- */
- @VisibleForTesting
- Cursor queryRootDocuments(String[] columnNames) {
- return mDatabase.query(
- TABLE_DOCUMENTS,
- columnNames,
- COLUMN_ROW_STATE + " IN (?, ?) AND " + COLUMN_DOCUMENT_TYPE + " = ?",
- strings(ROW_STATE_VALID, ROW_STATE_INVALIDATED, DOCUMENT_TYPE_STORAGE),
- null,
- null,
- null);
- }
-
- /**
- * Queries documents information.
- * @param columnNames Column names defined in
- * {@link android.provider.DocumentsContract.Document}.
- * @return Database cursor.
- */
- Cursor queryChildDocuments(String[] columnNames, String parentDocumentId) {
- return mDatabase.query(
- TABLE_DOCUMENTS,
- columnNames,
- COLUMN_ROW_STATE + " IN (?, ?) AND " + COLUMN_PARENT_DOCUMENT_ID + " = ?",
- strings(ROW_STATE_VALID, ROW_STATE_INVALIDATED, parentDocumentId),
- null,
- null,
- null);
- }
-
- /**
- * Returns document IDs of storages under the given device document.
- *
- * @param documentId Document ID that points a device.
- * @return Storage document IDs.
- * @throws FileNotFoundException The given document ID is not registered in database.
- */
- String[] getStorageDocumentIds(String documentId)
- throws FileNotFoundException {
- Preconditions.checkArgument(createIdentifier(documentId).mDocumentType ==
- DOCUMENT_TYPE_DEVICE);
- // Check if the parent document is device that has single storage.
- try (final Cursor cursor = mDatabase.query(
- TABLE_DOCUMENTS,
- strings(Document.COLUMN_DOCUMENT_ID),
- COLUMN_ROW_STATE + " IN (?, ?) AND " +
- COLUMN_PARENT_DOCUMENT_ID + " = ? AND " +
- COLUMN_DOCUMENT_TYPE + " = ?",
- strings(ROW_STATE_VALID,
- ROW_STATE_INVALIDATED,
- documentId,
- DOCUMENT_TYPE_STORAGE),
- null,
- null,
- null)) {
- final String[] ids = new String[cursor.getCount()];
- for (int i = 0; cursor.moveToNext(); i++) {
- ids[i] = cursor.getString(0);
- }
- return ids;
- }
- }
-
- /**
- * Queries a single document.
- * @param documentId
- * @param projection
- * @return Database cursor.
- */
- Cursor queryDocument(String documentId, String[] projection) {
- return mDatabase.query(
- TABLE_DOCUMENTS,
- projection,
- SELECTION_DOCUMENT_ID,
- strings(documentId),
- null,
- null,
- null,
- "1");
- }
-
- @Nullable String getDocumentIdForDevice(int deviceId) {
- final Cursor cursor = mDatabase.query(
- TABLE_DOCUMENTS,
- strings(Document.COLUMN_DOCUMENT_ID),
- COLUMN_DOCUMENT_TYPE + " = ? AND " + COLUMN_DEVICE_ID + " = ?",
- strings(DOCUMENT_TYPE_DEVICE, deviceId),
- null,
- null,
- null,
- "1");
- try {
- if (cursor.moveToNext()) {
- return cursor.getString(0);
- } else {
- return null;
- }
- } finally {
- cursor.close();
- }
- }
-
- /**
- * Obtains parent identifier.
- * @param documentId
- * @return parent identifier.
- * @throws FileNotFoundException
- */
- Identifier getParentIdentifier(String documentId) throws FileNotFoundException {
- final Cursor cursor = mDatabase.query(
- TABLE_DOCUMENTS,
- strings(COLUMN_PARENT_DOCUMENT_ID),
- SELECTION_DOCUMENT_ID,
- strings(documentId),
- null,
- null,
- null,
- "1");
- try {
- if (cursor.moveToNext()) {
- return createIdentifier(cursor.getString(0));
- } else {
- throw new FileNotFoundException("Cannot find a row having ID = " + documentId);
- }
- } finally {
- cursor.close();
- }
- }
-
- String getDeviceDocumentId(int deviceId) throws FileNotFoundException {
- try (final Cursor cursor = mDatabase.query(
- TABLE_DOCUMENTS,
- strings(Document.COLUMN_DOCUMENT_ID),
- COLUMN_DEVICE_ID + " = ? AND " + COLUMN_DOCUMENT_TYPE + " = ? AND " +
- COLUMN_ROW_STATE + " != ?",
- strings(deviceId, DOCUMENT_TYPE_DEVICE, ROW_STATE_DISCONNECTED),
- null,
- null,
- null,
- "1")) {
- if (cursor.getCount() > 0) {
- cursor.moveToNext();
- return cursor.getString(0);
- } else {
- throw new FileNotFoundException("The device ID not found: " + deviceId);
- }
- }
- }
-
- /**
- * Adds new document under the parent.
- * The method does not affect invalidated and pending documents because we know the document is
- * newly added and never mapped with existing ones.
- * @param parentDocumentId
- * @param info
- * @param size Object size. info#getCompressedSize() will be ignored because it does not contain
- * object size more than 4GB.
- * @return Document ID of added document.
- */
- String putNewDocument(
- int deviceId, String parentDocumentId, int[] operationsSupported, MtpObjectInfo info,
- long size) {
- final ContentValues values = new ContentValues();
- getObjectDocumentValues(
- values, deviceId, parentDocumentId, operationsSupported, info, size);
- mDatabase.beginTransaction();
- try {
- final long id = mDatabase.insert(TABLE_DOCUMENTS, null, values);
- mDatabase.setTransactionSuccessful();
- return Long.toString(id);
- } finally {
- mDatabase.endTransaction();
- }
- }
-
- /**
- * Deletes document and its children.
- * @param documentId
- */
- void deleteDocument(String documentId) {
- deleteDocumentsAndRootsRecursively(SELECTION_DOCUMENT_ID, strings(documentId));
- }
-
- /**
- * Gets identifier from document ID.
- * @param documentId Document ID.
- * @return Identifier.
- * @throws FileNotFoundException
- */
- Identifier createIdentifier(String documentId) throws FileNotFoundException {
- // Currently documentId is old format.
- final Cursor cursor = mDatabase.query(
- TABLE_DOCUMENTS,
- strings(COLUMN_DEVICE_ID,
- COLUMN_STORAGE_ID,
- COLUMN_OBJECT_HANDLE,
- COLUMN_DOCUMENT_TYPE),
- SELECTION_DOCUMENT_ID + " AND " + COLUMN_ROW_STATE + " IN (?, ?)",
- strings(documentId, ROW_STATE_VALID, ROW_STATE_INVALIDATED),
- null,
- null,
- null,
- "1");
- try {
- if (cursor.getCount() == 0) {
- throw new FileNotFoundException("ID \"" + documentId + "\" is not found.");
- } else {
- cursor.moveToNext();
- return new Identifier(
- cursor.getInt(0),
- cursor.getInt(1),
- cursor.getInt(2),
- documentId,
- cursor.getInt(3));
- }
- } finally {
- cursor.close();
- }
- }
-
- /**
- * Deletes a document, and its root information if the document is a root document.
- * @param selection Query to select documents.
- * @param args Arguments for selection.
- * @return Whether the method deletes rows.
- */
- boolean deleteDocumentsAndRootsRecursively(String selection, String[] args) {
- mDatabase.beginTransaction();
- try {
- boolean changed = false;
- final Cursor cursor = mDatabase.query(
- TABLE_DOCUMENTS,
- strings(Document.COLUMN_DOCUMENT_ID),
- selection,
- args,
- null,
- null,
- null);
- try {
- while (cursor.moveToNext()) {
- if (deleteDocumentsAndRootsRecursively(
- COLUMN_PARENT_DOCUMENT_ID + " = ?",
- strings(cursor.getString(0)))) {
- changed = true;
- }
- }
- } finally {
- cursor.close();
- }
- if (deleteDocumentsAndRoots(selection, args)) {
- changed = true;
- }
- mDatabase.setTransactionSuccessful();
- return changed;
- } finally {
- mDatabase.endTransaction();
- }
- }
-
- /**
- * Marks the documents and their child as disconnected documents.
- * @param selection
- * @param args
- * @return True if at least one row is updated.
- */
- boolean disconnectDocumentsRecursively(String selection, String[] args) {
- mDatabase.beginTransaction();
- try {
- boolean changed = false;
- try (final Cursor cursor = mDatabase.query(
- TABLE_DOCUMENTS,
- strings(Document.COLUMN_DOCUMENT_ID),
- selection,
- args,
- null,
- null,
- null)) {
- while (cursor.moveToNext()) {
- if (disconnectDocumentsRecursively(
- COLUMN_PARENT_DOCUMENT_ID + " = ?",
- strings(cursor.getString(0)))) {
- changed = true;
- }
- }
- }
- if (disconnectDocuments(selection, args)) {
- changed = true;
- }
- mDatabase.setTransactionSuccessful();
- return changed;
- } finally {
- mDatabase.endTransaction();
- }
- }
-
- boolean deleteDocumentsAndRoots(String selection, String[] args) {
- mDatabase.beginTransaction();
- try {
- int deleted = 0;
- deleted += mDatabase.delete(
- TABLE_ROOT_EXTRA,
- Root.COLUMN_ROOT_ID + " IN (" + SQLiteQueryBuilder.buildQueryString(
- false,
- TABLE_DOCUMENTS,
- new String[] { Document.COLUMN_DOCUMENT_ID },
- selection,
- null,
- null,
- null,
- null) + ")",
- args);
- deleted += mDatabase.delete(TABLE_DOCUMENTS, selection, args);
- mDatabase.setTransactionSuccessful();
- // TODO Remove mappingState.
- return deleted != 0;
- } finally {
- mDatabase.endTransaction();
- }
- }
-
- boolean disconnectDocuments(String selection, String[] args) {
- mDatabase.beginTransaction();
- try {
- final ContentValues values = new ContentValues();
- values.put(COLUMN_ROW_STATE, ROW_STATE_DISCONNECTED);
- values.putNull(COLUMN_DEVICE_ID);
- values.putNull(COLUMN_STORAGE_ID);
- values.putNull(COLUMN_OBJECT_HANDLE);
- final boolean updated = mDatabase.update(TABLE_DOCUMENTS, values, selection, args) != 0;
- mDatabase.setTransactionSuccessful();
- return updated;
- } finally {
- mDatabase.endTransaction();
- }
- }
-
- int getRowState(String documentId) throws FileNotFoundException {
- try (final Cursor cursor = mDatabase.query(
- TABLE_DOCUMENTS,
- strings(COLUMN_ROW_STATE),
- SELECTION_DOCUMENT_ID,
- strings(documentId),
- null,
- null,
- null)) {
- if (cursor.getCount() == 0) {
- throw new FileNotFoundException();
- }
- cursor.moveToNext();
- return cursor.getInt(0);
- }
- }
-
- void writeRowSnapshot(String documentId, ContentValues values) throws FileNotFoundException {
- try (final Cursor cursor = mDatabase.query(
- JOIN_ROOTS,
- strings("*"),
- SELECTION_DOCUMENT_ID,
- strings(documentId),
- null,
- null,
- null,
- "1")) {
- if (cursor.getCount() == 0) {
- throw new FileNotFoundException();
- }
- cursor.moveToNext();
- values.clear();
- DatabaseUtils.cursorRowToContentValues(cursor, values);
- }
- }
-
- void updateObject(String documentId, int deviceId, String parentId, int[] operationsSupported,
- MtpObjectInfo info, Long size) {
- final ContentValues values = new ContentValues();
- getObjectDocumentValues(values, deviceId, parentId, operationsSupported, info, size);
-
- mDatabase.beginTransaction();
- try {
- mDatabase.update(
- TABLE_DOCUMENTS,
- values,
- Document.COLUMN_DOCUMENT_ID + " = ?",
- strings(documentId));
- mDatabase.setTransactionSuccessful();
- } finally {
- mDatabase.endTransaction();
- }
- }
-
- /**
- * Obtains a document that has already mapped but has unmapped children.
- * @param deviceId Device to find documents.
- * @return Identifier of found document or null.
- */
- @Nullable Identifier getUnmappedDocumentsParent(int deviceId) {
- final String fromClosure =
- TABLE_DOCUMENTS + " AS child INNER JOIN " +
- TABLE_DOCUMENTS + " AS parent ON " +
- "child." + COLUMN_PARENT_DOCUMENT_ID + " = " +
- "parent." + Document.COLUMN_DOCUMENT_ID;
- final String whereClosure =
- "parent." + COLUMN_DEVICE_ID + " = ? AND " +
- "parent." + COLUMN_ROW_STATE + " IN (?, ?) AND " +
- "parent." + COLUMN_DOCUMENT_TYPE + " != ? AND " +
- "child." + COLUMN_ROW_STATE + " = ?";
- try (final Cursor cursor = mDatabase.query(
- fromClosure,
- strings("parent." + COLUMN_DEVICE_ID,
- "parent." + COLUMN_STORAGE_ID,
- "parent." + COLUMN_OBJECT_HANDLE,
- "parent." + Document.COLUMN_DOCUMENT_ID,
- "parent." + COLUMN_DOCUMENT_TYPE),
- whereClosure,
- strings(deviceId, ROW_STATE_VALID, ROW_STATE_INVALIDATED, DOCUMENT_TYPE_DEVICE,
- ROW_STATE_DISCONNECTED),
- null,
- null,
- null,
- "1")) {
- if (cursor.getCount() == 0) {
- return null;
- }
- cursor.moveToNext();
- return new Identifier(
- cursor.getInt(0),
- cursor.getInt(1),
- cursor.getInt(2),
- cursor.getString(3),
- cursor.getInt(4));
- }
- }
-
- /**
- * Removes metadata except for data used by outgoingPersistedUriPermissions.
- */
- void cleanDatabase(Uri[] outgoingPersistedUris) {
- mDatabase.beginTransaction();
- try {
- final Set<String> ids = new HashSet<>();
- for (final Uri uri : outgoingPersistedUris) {
- String documentId = DocumentsContract.getDocumentId(uri);
- while (documentId != null) {
- if (ids.contains(documentId)) {
- break;
- }
- ids.add(documentId);
- try (final Cursor cursor = mDatabase.query(
- TABLE_DOCUMENTS,
- strings(COLUMN_PARENT_DOCUMENT_ID),
- SELECTION_DOCUMENT_ID,
- strings(documentId),
- null,
- null,
- null)) {
- documentId = cursor.moveToNext() ? cursor.getString(0) : null;
- }
- }
- }
- deleteDocumentsAndRoots(
- Document.COLUMN_DOCUMENT_ID + " NOT IN " + getIdList(ids), null);
- mDatabase.setTransactionSuccessful();
- } finally {
- mDatabase.endTransaction();
- }
- }
-
- int getLastBootCount() {
- try (final Cursor cursor = mDatabase.query(
- TABLE_LAST_BOOT_COUNT, strings(COLUMN_VALUE), null, null, null, null, null)) {
- if (cursor.moveToNext()) {
- return cursor.getInt(0);
- } else {
- return 0;
- }
- }
- }
-
- void setLastBootCount(int value) {
- Preconditions.checkArgumentNonnegative(value, "Boot count must not be negative.");
- mDatabase.beginTransaction();
- try {
- final ContentValues values = new ContentValues();
- values.put(COLUMN_VALUE, value);
- mDatabase.delete(TABLE_LAST_BOOT_COUNT, null, null);
- mDatabase.insert(TABLE_LAST_BOOT_COUNT, null, values);
- mDatabase.setTransactionSuccessful();
- } finally {
- mDatabase.endTransaction();
- }
- }
-
- private static class OpenHelper extends SQLiteOpenHelper {
- public OpenHelper(Context context, int flags) {
- super(context,
- flags == FLAG_DATABASE_IN_MEMORY ? null : DATABASE_NAME,
- null,
- DATABASE_VERSION);
- }
-
- @Override
- public void onCreate(SQLiteDatabase db) {
- db.execSQL(QUERY_CREATE_DOCUMENTS);
- db.execSQL(QUERY_CREATE_ROOT_EXTRA);
- db.execSQL(QUERY_CREATE_LAST_BOOT_COUNT);
- }
-
- @Override
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- db.execSQL("DROP TABLE IF EXISTS " + TABLE_DOCUMENTS);
- db.execSQL("DROP TABLE IF EXISTS " + TABLE_ROOT_EXTRA);
- db.execSQL("DROP TABLE IF EXISTS " + TABLE_LAST_BOOT_COUNT);
- onCreate(db);
- }
- }
-
- @VisibleForTesting
- static void deleteDatabase(Context context) {
- context.deleteDatabase(DATABASE_NAME);
- }
-
- static void getDeviceDocumentValues(
- ContentValues values,
- ContentValues extraValues,
- MtpDeviceRecord device) {
- values.clear();
- values.put(COLUMN_DEVICE_ID, device.deviceId);
- values.putNull(COLUMN_STORAGE_ID);
- values.putNull(COLUMN_OBJECT_HANDLE);
- values.putNull(COLUMN_PARENT_DOCUMENT_ID);
- values.put(COLUMN_ROW_STATE, ROW_STATE_VALID);
- values.put(COLUMN_DOCUMENT_TYPE, DOCUMENT_TYPE_DEVICE);
- values.put(COLUMN_MAPPING_KEY, device.deviceKey);
- values.put(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR);
- values.put(Document.COLUMN_DISPLAY_NAME, device.name);
- values.putNull(Document.COLUMN_SUMMARY);
- values.putNull(Document.COLUMN_LAST_MODIFIED);
- values.put(Document.COLUMN_ICON, R.drawable.ic_root_mtp);
- values.put(Document.COLUMN_FLAGS, getDocumentFlags(
- device.operationsSupported,
- Document.MIME_TYPE_DIR,
- 0,
- MtpConstants.PROTECTION_STATUS_NONE,
- // Storages are placed under device so we cannot create a document just under
- // device.
- DOCUMENT_TYPE_DEVICE) & ~Document.FLAG_DIR_SUPPORTS_CREATE);
- values.putNull(Document.COLUMN_SIZE);
-
- extraValues.clear();
- extraValues.put(Root.COLUMN_FLAGS, getRootFlags(device.operationsSupported));
- extraValues.putNull(Root.COLUMN_AVAILABLE_BYTES);
- extraValues.putNull(Root.COLUMN_CAPACITY_BYTES);
- extraValues.put(Root.COLUMN_MIME_TYPES, "");
- }
-
- /**
- * Gets {@link ContentValues} for the given root.
- * @param values {@link ContentValues} that receives values.
- * @param extraValues {@link ContentValues} that receives extra values for roots.
- * @param parentDocumentId Parent document ID.
- * @param operationsSupported Array of Operation code supported by the device.
- * @param root Root to be converted {@link ContentValues}.
- */
- static void getStorageDocumentValues(
- ContentValues values,
- ContentValues extraValues,
- String parentDocumentId,
- int[] operationsSupported,
- MtpRoot root) {
- values.clear();
- values.put(COLUMN_DEVICE_ID, root.mDeviceId);
- values.put(COLUMN_STORAGE_ID, root.mStorageId);
- values.putNull(COLUMN_OBJECT_HANDLE);
- values.put(COLUMN_PARENT_DOCUMENT_ID, parentDocumentId);
- values.put(COLUMN_ROW_STATE, ROW_STATE_VALID);
- values.put(COLUMN_DOCUMENT_TYPE, DOCUMENT_TYPE_STORAGE);
- values.put(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR);
- values.put(Document.COLUMN_DISPLAY_NAME, root.mDescription);
- values.putNull(Document.COLUMN_SUMMARY);
- values.putNull(Document.COLUMN_LAST_MODIFIED);
- values.put(Document.COLUMN_ICON, R.drawable.ic_root_mtp);
- values.put(Document.COLUMN_FLAGS, getDocumentFlags(
- operationsSupported,
- Document.MIME_TYPE_DIR,
- 0,
- MtpConstants.PROTECTION_STATUS_NONE,
- DOCUMENT_TYPE_STORAGE));
- values.put(Document.COLUMN_SIZE, root.mMaxCapacity - root.mFreeSpace);
-
- extraValues.put(Root.COLUMN_FLAGS, getRootFlags(operationsSupported));
- extraValues.put(Root.COLUMN_AVAILABLE_BYTES, root.mFreeSpace);
- extraValues.put(Root.COLUMN_CAPACITY_BYTES, root.mMaxCapacity);
- extraValues.put(Root.COLUMN_MIME_TYPES, "");
- }
-
- /**
- * Gets {@link ContentValues} for the given MTP object.
- * @param values {@link ContentValues} that receives values.
- * @param deviceId Device ID of the object.
- * @param parentId Parent document ID of the object.
- * @param info MTP object info. getCompressedSize will be ignored.
- * @param size 64-bit size of documents. Negative value is regarded as unknown size.
- */
- static void getObjectDocumentValues(
- ContentValues values, int deviceId, String parentId,
- int[] operationsSupported, MtpObjectInfo info, long size) {
- values.clear();
- final String mimeType = getMimeType(info);
- values.put(COLUMN_DEVICE_ID, deviceId);
- values.put(COLUMN_STORAGE_ID, info.getStorageId());
- values.put(COLUMN_OBJECT_HANDLE, info.getObjectHandle());
- values.put(COLUMN_PARENT_DOCUMENT_ID, parentId);
- values.put(COLUMN_ROW_STATE, ROW_STATE_VALID);
- values.put(COLUMN_DOCUMENT_TYPE, DOCUMENT_TYPE_OBJECT);
- values.put(Document.COLUMN_MIME_TYPE, mimeType);
- values.put(Document.COLUMN_DISPLAY_NAME, info.getName());
- values.putNull(Document.COLUMN_SUMMARY);
- values.put(
- Document.COLUMN_LAST_MODIFIED,
- info.getDateModified() != 0 ? info.getDateModified() : null);
- values.putNull(Document.COLUMN_ICON);
- values.put(Document.COLUMN_FLAGS, getDocumentFlags(
- operationsSupported, mimeType, info.getThumbCompressedSizeLong(),
- info.getProtectionStatus(), DOCUMENT_TYPE_OBJECT));
- if (size >= 0) {
- values.put(Document.COLUMN_SIZE, size);
- } else {
- values.putNull(Document.COLUMN_SIZE);
- }
- }
-
- private static String getMimeType(MtpObjectInfo info) {
- if (info.getFormat() == MtpConstants.FORMAT_ASSOCIATION) {
- return DocumentsContract.Document.MIME_TYPE_DIR;
- }
-
- return MediaFile.getMimeType(info.getName(), info.getFormat());
- }
-
- private static int getRootFlags(int[] operationsSupported) {
- int rootFlag = Root.FLAG_SUPPORTS_IS_CHILD | Root.FLAG_LOCAL_ONLY;
- if (MtpDeviceRecord.isWritingSupported(operationsSupported)) {
- rootFlag |= Root.FLAG_SUPPORTS_CREATE;
- }
- return rootFlag;
- }
-
- private static int getDocumentFlags(
- @Nullable int[] operationsSupported, String mimeType, long thumbnailSize,
- int protectionState, @DocumentType int documentType) {
- int flag = 0;
- if (!mimeType.equals(Document.MIME_TYPE_DIR) &&
- MtpDeviceRecord.isWritingSupported(operationsSupported) &&
- protectionState == MtpConstants.PROTECTION_STATUS_NONE) {
- flag |= Document.FLAG_SUPPORTS_WRITE;
- }
- if (MtpDeviceRecord.isSupported(
- operationsSupported, MtpConstants.OPERATION_DELETE_OBJECT) &&
- (protectionState == MtpConstants.PROTECTION_STATUS_NONE ||
- protectionState == MtpConstants.PROTECTION_STATUS_NON_TRANSFERABLE_DATA) &&
- documentType == DOCUMENT_TYPE_OBJECT) {
- flag |= Document.FLAG_SUPPORTS_DELETE;
- }
- if (mimeType.equals(Document.MIME_TYPE_DIR) &&
- MtpDeviceRecord.isWritingSupported(operationsSupported) &&
- protectionState == MtpConstants.PROTECTION_STATUS_NONE) {
- flag |= Document.FLAG_DIR_SUPPORTS_CREATE;
- }
- if (MetadataReader.isSupportedMimeType(mimeType)) {
- flag |= Document.FLAG_SUPPORTS_METADATA;
- }
- if (thumbnailSize > 0) {
- flag |= Document.FLAG_SUPPORTS_THUMBNAIL;
- }
- return flag;
- }
-
- static String[] strings(Object... args) {
- final String[] results = new String[args.length];
- for (int i = 0; i < args.length; i++) {
- results[i] = Objects.toString(args[i]);
- }
- return results;
- }
-
- static void putValuesToCursor(ContentValues values, MatrixCursor cursor) {
- final RowBuilder row = cursor.newRow();
- for (final String name : cursor.getColumnNames()) {
- row.add(values.get(name));
- }
- }
-
- private static String getIdList(Set<String> ids) {
- String result = "(";
- for (final String id : ids) {
- if (result.length() > 1) {
- result += ",";
- }
- result += id;
- }
- result += ")";
- return result;
- }
-}
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDatabaseConstants.java b/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDatabaseConstants.java
deleted file mode 100644
index 6d98e34..0000000
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDatabaseConstants.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.mtp;
-
-import android.annotation.IntDef;
-import android.database.sqlite.SQLiteQueryBuilder;
-import android.provider.DocumentsContract.Document;
-import android.provider.DocumentsContract.Root;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Class containing MtpDatabase constants.
- */
-class MtpDatabaseConstants {
- static final int DATABASE_VERSION = 5;
- static final String DATABASE_NAME = "database";
-
- static final int FLAG_DATABASE_IN_MEMORY = 1;
- static final int FLAG_DATABASE_IN_FILE = 0;
-
- /**
- * Table representing documents including root documents.
- */
- static final String TABLE_DOCUMENTS = "Documents";
-
- /**
- * Table containing additional information only available for root documents.
- * The table uses same primary keys with corresponding documents.
- */
- static final String TABLE_ROOT_EXTRA = "RootExtra";
-
- /**
- * Table containing last boot count.
- */
- static final String TABLE_LAST_BOOT_COUNT = "LastBootCount";
-
- /**
- * 'FROM' closure of joining TABLE_DOCUMENTS and TABLE_ROOT_EXTRA.
- */
- static final String JOIN_ROOTS = createJoinFromClosure(
- TABLE_DOCUMENTS,
- TABLE_ROOT_EXTRA,
- Document.COLUMN_DOCUMENT_ID,
- Root.COLUMN_ROOT_ID);
-
- static final String COLUMN_DEVICE_ID = "device_id";
- static final String COLUMN_STORAGE_ID = "storage_id";
- static final String COLUMN_OBJECT_HANDLE = "object_handle";
- static final String COLUMN_PARENT_DOCUMENT_ID = "parent_document_id";
- static final String COLUMN_DOCUMENT_TYPE = "document_type";
- static final String COLUMN_ROW_STATE = "row_state";
- static final String COLUMN_MAPPING_KEY = "mapping_key";
-
- /**
- * Value for TABLE_LAST_BOOT_COUNT.
- * Type: INTEGER
- */
- static final String COLUMN_VALUE = "value";
-
- /**
- * The state represents that the row has a valid object handle.
- */
- static final int ROW_STATE_VALID = 0;
-
- /**
- * The state represents that the rows added at the previous cycle and need to be updated with
- * fresh values.
- * The row may not have valid object handle. External application can still fetch the documents.
- * If the external application tries to fetch object handle, the provider resolves pending
- * documents with invalidated documents ahead.
- */
- static final int ROW_STATE_INVALIDATED = 1;
-
- /**
- * The documents are of device/storage that are disconnected now. The documents are invisible
- * but their document ID will be reuse when the device/storage is connected again.
- */
- static final int ROW_STATE_DISCONNECTED = 2;
-
- @IntDef(value = { DOCUMENT_TYPE_DEVICE, DOCUMENT_TYPE_STORAGE, DOCUMENT_TYPE_OBJECT })
- @Retention(RetentionPolicy.SOURCE)
- public @interface DocumentType {}
-
- /**
- * Document that represents a MTP device.
- */
- static final int DOCUMENT_TYPE_DEVICE = 0;
-
- /**
- * Document that represents a MTP storage.
- */
- static final int DOCUMENT_TYPE_STORAGE = 1;
-
- /**
- * Document that represents a MTP object.
- */
- static final int DOCUMENT_TYPE_OBJECT = 2;
-
- static final String SELECTION_DOCUMENT_ID = Document.COLUMN_DOCUMENT_ID + " = ?";
- static final String SELECTION_ROOT_ID = Root.COLUMN_ROOT_ID + " = ?";
-
- static final String QUERY_CREATE_DOCUMENTS =
- "CREATE TABLE " + TABLE_DOCUMENTS + " (" +
- Document.COLUMN_DOCUMENT_ID +
- " INTEGER PRIMARY KEY AUTOINCREMENT," +
- COLUMN_DEVICE_ID + " INTEGER," +
- COLUMN_STORAGE_ID + " INTEGER," +
- COLUMN_OBJECT_HANDLE + " INTEGER," +
- COLUMN_PARENT_DOCUMENT_ID + " INTEGER," +
- COLUMN_ROW_STATE + " INTEGER NOT NULL," +
- COLUMN_DOCUMENT_TYPE + " INTEGER NOT NULL," +
- COLUMN_MAPPING_KEY + " STRING," +
- Document.COLUMN_MIME_TYPE + " TEXT NOT NULL," +
- Document.COLUMN_DISPLAY_NAME + " TEXT NOT NULL," +
- Document.COLUMN_SUMMARY + " TEXT," +
- Document.COLUMN_LAST_MODIFIED + " INTEGER," +
- Document.COLUMN_ICON + " INTEGER," +
- Document.COLUMN_FLAGS + " INTEGER NOT NULL," +
- Document.COLUMN_SIZE + " INTEGER);";
-
- static final String QUERY_CREATE_ROOT_EXTRA =
- "CREATE TABLE " + TABLE_ROOT_EXTRA + " (" +
- Root.COLUMN_ROOT_ID + " INTEGER PRIMARY KEY," +
- Root.COLUMN_FLAGS + " INTEGER NOT NULL," +
- Root.COLUMN_AVAILABLE_BYTES + " INTEGER," +
- Root.COLUMN_CAPACITY_BYTES + " INTEGER," +
- Root.COLUMN_MIME_TYPES + " TEXT NOT NULL);";
-
- static final String QUERY_CREATE_LAST_BOOT_COUNT =
- "CREATE TABLE " + TABLE_LAST_BOOT_COUNT + " (value INTEGER NOT NULL);";
-
- /**
- * Map for columns names to provide DocumentContract.Root compatible columns.
- * @see SQLiteQueryBuilder#setProjectionMap(Map)
- */
- static final Map<String, String> COLUMN_MAP_ROOTS;
- static {
- COLUMN_MAP_ROOTS = new HashMap<>();
- COLUMN_MAP_ROOTS.put(Root.COLUMN_ROOT_ID, TABLE_ROOT_EXTRA + "." + Root.COLUMN_ROOT_ID);
- COLUMN_MAP_ROOTS.put(Root.COLUMN_FLAGS, TABLE_ROOT_EXTRA + "." + Root.COLUMN_FLAGS);
- COLUMN_MAP_ROOTS.put(
- Root.COLUMN_ICON,
- TABLE_DOCUMENTS + "." + Document.COLUMN_ICON + " AS " + Root.COLUMN_ICON);
- COLUMN_MAP_ROOTS.put(
- Root.COLUMN_TITLE,
- TABLE_DOCUMENTS + "." + Document.COLUMN_DISPLAY_NAME + " AS " + Root.COLUMN_TITLE);
- COLUMN_MAP_ROOTS.put(
- Root.COLUMN_SUMMARY,
- TABLE_DOCUMENTS + "." + Document.COLUMN_SUMMARY + " AS " + Root.COLUMN_SUMMARY);
- COLUMN_MAP_ROOTS.put(
- Root.COLUMN_DOCUMENT_ID,
- TABLE_DOCUMENTS + "." + Document.COLUMN_DOCUMENT_ID +
- " AS " + Root.COLUMN_DOCUMENT_ID);
- COLUMN_MAP_ROOTS.put(
- Root.COLUMN_AVAILABLE_BYTES, TABLE_ROOT_EXTRA + "." + Root.COLUMN_AVAILABLE_BYTES);
- COLUMN_MAP_ROOTS.put(
- Root.COLUMN_CAPACITY_BYTES, TABLE_ROOT_EXTRA + "." + Root.COLUMN_CAPACITY_BYTES);
- COLUMN_MAP_ROOTS.put(
- Root.COLUMN_MIME_TYPES, TABLE_ROOT_EXTRA + "." + Root.COLUMN_MIME_TYPES);
- COLUMN_MAP_ROOTS.put(COLUMN_DEVICE_ID, COLUMN_DEVICE_ID);
- }
-
- private static String createJoinFromClosure(
- String table1, String table2, String column1, String column2) {
- return table1 + " LEFT JOIN " + table2 +
- " ON " + table1 + "." + column1 + " = " + table2 + "." + column2;
- }
-}
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDeviceRecord.java b/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDeviceRecord.java
deleted file mode 100644
index c52b81d..0000000
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDeviceRecord.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.mtp;
-
-import android.annotation.Nullable;
-import android.mtp.MtpConstants;
-
-class MtpDeviceRecord {
- public final int deviceId;
- public final String name;
- public final @Nullable String deviceKey;
- public final boolean opened;
- public final MtpRoot[] roots;
- public final @Nullable int[] operationsSupported;
- public final @Nullable int[] eventsSupported;
-
- MtpDeviceRecord(int deviceId, String name, @Nullable String deviceKey, boolean opened,
- MtpRoot[] roots, @Nullable int[] operationsSupported,
- @Nullable int[] eventsSupported) {
- this.deviceId = deviceId;
- this.name = name;
- this.opened = opened;
- this.roots = roots;
- this.deviceKey = deviceKey;
- this.operationsSupported = operationsSupported;
- this.eventsSupported = eventsSupported;
- }
-
- /**
- * Helper method to check operations/events are supported by the device or not.
- */
- static boolean isSupported(@Nullable int[] supportedList, int code) {
- if (supportedList == null) {
- return false;
- }
- for (int i = 0; i < supportedList.length; i++) {
- if (supportedList[i] == code) {
- return true;
- }
- }
- return false;
- }
-
- static boolean isPartialReadSupported(@Nullable int[] supportedList, long fileSize) {
- if (isSupported(supportedList, MtpConstants.OPERATION_GET_PARTIAL_OBJECT_64)) {
- return true;
- }
- if (0 <= fileSize &&
- fileSize <= 0xffffffffL &&
- isSupported(supportedList, MtpConstants.OPERATION_GET_PARTIAL_OBJECT)) {
- return true;
- }
- return false;
- }
-
- static boolean isWritingSupported(@Nullable int[] supportedList) {
- return isSupported(supportedList, MtpConstants.OPERATION_SEND_OBJECT_INFO) &&
- isSupported(supportedList, MtpConstants.OPERATION_SEND_OBJECT);
- }
-}
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDocumentsProvider.java b/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDocumentsProvider.java
deleted file mode 100644
index 8c8116b..0000000
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDocumentsProvider.java
+++ /dev/null
@@ -1,856 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.mtp;
-
-import android.annotation.Nullable;
-import android.content.ContentResolver;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.UriPermission;
-import android.content.res.AssetFileDescriptor;
-import android.content.res.Resources;
-import android.database.Cursor;
-import android.database.DatabaseUtils;
-import android.database.MatrixCursor;
-import android.database.sqlite.SQLiteDiskIOException;
-import android.graphics.Point;
-import android.media.MediaFile;
-import android.mtp.MtpConstants;
-import android.mtp.MtpObjectInfo;
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.CancellationSignal;
-import android.os.FileUtils;
-import android.os.ParcelFileDescriptor;
-import android.os.ProxyFileDescriptorCallback;
-import android.os.storage.StorageManager;
-import android.provider.DocumentsContract;
-import android.provider.DocumentsContract.Document;
-import android.provider.DocumentsContract.Path;
-import android.provider.DocumentsContract.Root;
-import android.provider.DocumentsProvider;
-import android.provider.MetadataReader;
-import android.provider.Settings;
-import android.system.ErrnoException;
-import android.system.OsConstants;
-import android.util.Log;
-
-import com.android.internal.annotations.GuardedBy;
-import com.android.internal.annotations.VisibleForTesting;
-
-import libcore.io.IoUtils;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeoutException;
-
-/**
- * DocumentsProvider for MTP devices.
- */
-public class MtpDocumentsProvider extends DocumentsProvider {
- static final String AUTHORITY = "com.android.mtp.documents";
- static final String TAG = "MtpDocumentsProvider";
- static final String[] DEFAULT_ROOT_PROJECTION = new String[] {
- Root.COLUMN_ROOT_ID, Root.COLUMN_FLAGS, Root.COLUMN_ICON,
- Root.COLUMN_TITLE, Root.COLUMN_DOCUMENT_ID,
- Root.COLUMN_AVAILABLE_BYTES,
- };
- static final String[] DEFAULT_DOCUMENT_PROJECTION = new String[] {
- Document.COLUMN_DOCUMENT_ID, Document.COLUMN_MIME_TYPE,
- Document.COLUMN_DISPLAY_NAME, Document.COLUMN_LAST_MODIFIED,
- Document.COLUMN_FLAGS, Document.COLUMN_SIZE,
- };
-
- static final boolean DEBUG = false;
-
- private final Object mDeviceListLock = new Object();
-
- private static MtpDocumentsProvider sSingleton;
-
- private MtpManager mMtpManager;
- private ContentResolver mResolver;
- @GuardedBy("mDeviceListLock")
- private Map<Integer, DeviceToolkit> mDeviceToolkits;
- private RootScanner mRootScanner;
- private Resources mResources;
- private MtpDatabase mDatabase;
- private ServiceIntentSender mIntentSender;
- private Context mContext;
- private StorageManager mStorageManager;
-
- /**
- * Provides singleton instance to MtpDocumentsService.
- */
- static MtpDocumentsProvider getInstance() {
- return sSingleton;
- }
-
- @Override
- public boolean onCreate() {
- sSingleton = this;
- mContext = getContext();
- mResources = getContext().getResources();
- mMtpManager = new MtpManager(getContext());
- mResolver = getContext().getContentResolver();
- mDeviceToolkits = new HashMap<>();
- mDatabase = new MtpDatabase(getContext(), MtpDatabaseConstants.FLAG_DATABASE_IN_FILE);
- mRootScanner = new RootScanner(mResolver, mMtpManager, mDatabase);
- mIntentSender = new ServiceIntentSender(getContext());
- mStorageManager = getContext().getSystemService(StorageManager.class);
-
- // Check boot count and cleans database if it's first time to launch MtpDocumentsProvider
- // after booting.
- try {
- final int bootCount = Settings.Global.getInt(mResolver, Settings.Global.BOOT_COUNT, -1);
- final int lastBootCount = mDatabase.getLastBootCount();
- if (bootCount != -1 && bootCount != lastBootCount) {
- mDatabase.setLastBootCount(bootCount);
- final List<UriPermission> permissions =
- mResolver.getOutgoingPersistedUriPermissions();
- final Uri[] uris = new Uri[permissions.size()];
- for (int i = 0; i < permissions.size(); i++) {
- uris[i] = permissions.get(i).getUri();
- }
- mDatabase.cleanDatabase(uris);
- }
- } catch (SQLiteDiskIOException error) {
- // It can happen due to disk shortage.
- Log.e(TAG, "Failed to clean database.", error);
- return false;
- }
-
- resume();
- return true;
- }
-
- @VisibleForTesting
- boolean onCreateForTesting(
- Context context,
- Resources resources,
- MtpManager mtpManager,
- ContentResolver resolver,
- MtpDatabase database,
- StorageManager storageManager,
- ServiceIntentSender intentSender) {
- mContext = context;
- mResources = resources;
- mMtpManager = mtpManager;
- mResolver = resolver;
- mDeviceToolkits = new HashMap<>();
- mDatabase = database;
- mRootScanner = new RootScanner(mResolver, mMtpManager, mDatabase);
- mIntentSender = intentSender;
- mStorageManager = storageManager;
-
- resume();
- return true;
- }
-
- @Override
- public Cursor queryRoots(String[] projection) throws FileNotFoundException {
- if (projection == null) {
- projection = MtpDocumentsProvider.DEFAULT_ROOT_PROJECTION;
- }
- final Cursor cursor = mDatabase.queryRoots(mResources, projection);
- cursor.setNotificationUri(
- mResolver, DocumentsContract.buildRootsUri(MtpDocumentsProvider.AUTHORITY));
- return cursor;
- }
-
- @Override
- public Cursor queryDocument(String documentId, String[] projection)
- throws FileNotFoundException {
- if (projection == null) {
- projection = MtpDocumentsProvider.DEFAULT_DOCUMENT_PROJECTION;
- }
- final Cursor cursor = mDatabase.queryDocument(documentId, projection);
- final int cursorCount = cursor.getCount();
- if (cursorCount == 0) {
- cursor.close();
- throw new FileNotFoundException();
- } else if (cursorCount != 1) {
- cursor.close();
- Log.wtf(TAG, "Unexpected cursor size: " + cursorCount);
- return null;
- }
-
- final Identifier identifier = mDatabase.createIdentifier(documentId);
- if (identifier.mDocumentType != MtpDatabaseConstants.DOCUMENT_TYPE_DEVICE) {
- return cursor;
- }
- final String[] storageDocIds = mDatabase.getStorageDocumentIds(documentId);
- if (storageDocIds.length != 1) {
- return mDatabase.queryDocument(documentId, projection);
- }
-
- // If the documentId specifies a device having exact one storage, we repalce some device
- // attributes with the storage attributes.
- try {
- final String storageName;
- final int storageFlags;
- try (final Cursor storageCursor = mDatabase.queryDocument(
- storageDocIds[0],
- MtpDatabase.strings(Document.COLUMN_DISPLAY_NAME, Document.COLUMN_FLAGS))) {
- if (!storageCursor.moveToNext()) {
- throw new FileNotFoundException();
- }
- storageName = storageCursor.getString(0);
- storageFlags = storageCursor.getInt(1);
- }
-
- cursor.moveToNext();
- final ContentValues values = new ContentValues();
- DatabaseUtils.cursorRowToContentValues(cursor, values);
- if (values.containsKey(Document.COLUMN_DISPLAY_NAME)) {
- values.put(Document.COLUMN_DISPLAY_NAME, mResources.getString(
- R.string.root_name,
- values.getAsString(Document.COLUMN_DISPLAY_NAME),
- storageName));
- }
- values.put(Document.COLUMN_FLAGS, storageFlags);
- final MatrixCursor output = new MatrixCursor(projection, 1);
- MtpDatabase.putValuesToCursor(values, output);
- return output;
- } finally {
- cursor.close();
- }
- }
-
- @Override
- public Cursor queryChildDocuments(String parentDocumentId,
- String[] projection, String sortOrder) throws FileNotFoundException {
- if (DEBUG) {
- Log.d(TAG, "queryChildDocuments: " + parentDocumentId);
- }
- if (projection == null) {
- projection = MtpDocumentsProvider.DEFAULT_DOCUMENT_PROJECTION;
- }
- Identifier parentIdentifier = mDatabase.createIdentifier(parentDocumentId);
- try {
- openDevice(parentIdentifier.mDeviceId);
- if (parentIdentifier.mDocumentType == MtpDatabaseConstants.DOCUMENT_TYPE_DEVICE) {
- final String[] storageDocIds = mDatabase.getStorageDocumentIds(parentDocumentId);
- if (storageDocIds.length == 0) {
- // Remote device does not provide storages. Maybe it is locked.
- return createErrorCursor(projection, R.string.error_locked_device);
- } else if (storageDocIds.length > 1) {
- // Returns storage list from database.
- return mDatabase.queryChildDocuments(projection, parentDocumentId);
- }
-
- // Exact one storage is found. Skip storage and returns object in the single
- // storage.
- parentIdentifier = mDatabase.createIdentifier(storageDocIds[0]);
- }
-
- // Returns object list from document loader.
- return getDocumentLoader(parentIdentifier).queryChildDocuments(
- projection, parentIdentifier);
- } catch (BusyDeviceException exception) {
- return createErrorCursor(projection, R.string.error_busy_device);
- } catch (IOException exception) {
- Log.e(MtpDocumentsProvider.TAG, "queryChildDocuments", exception);
- throw new FileNotFoundException(exception.getMessage());
- }
- }
-
- @Override
- public ParcelFileDescriptor openDocument(
- String documentId, String mode, CancellationSignal signal)
- throws FileNotFoundException {
- if (DEBUG) {
- Log.d(TAG, "openDocument: " + documentId);
- }
- final Identifier identifier = mDatabase.createIdentifier(documentId);
- try {
- openDevice(identifier.mDeviceId);
- final MtpDeviceRecord device = getDeviceToolkit(identifier.mDeviceId).mDeviceRecord;
- // Turn off MODE_CREATE because openDocument does not allow to create new files.
- final int modeFlag =
- ParcelFileDescriptor.parseMode(mode) & ~ParcelFileDescriptor.MODE_CREATE;
- if ((modeFlag & ParcelFileDescriptor.MODE_READ_ONLY) != 0) {
- long fileSize;
- try {
- fileSize = getFileSize(documentId);
- } catch (UnsupportedOperationException exception) {
- fileSize = -1;
- }
- if (MtpDeviceRecord.isPartialReadSupported(
- device.operationsSupported, fileSize)) {
-
- return mStorageManager.openProxyFileDescriptor(
- modeFlag,
- new MtpProxyFileDescriptorCallback(Integer.parseInt(documentId)));
- } else {
- // If getPartialObject{|64} are not supported for the device, returns
- // non-seekable pipe FD instead.
- return getPipeManager(identifier).readDocument(mMtpManager, identifier);
- }
- } else if ((modeFlag & ParcelFileDescriptor.MODE_WRITE_ONLY) != 0) {
- // TODO: Clear the parent document loader task (if exists) and call notify
- // when writing is completed.
- if (MtpDeviceRecord.isWritingSupported(device.operationsSupported)) {
- return mStorageManager.openProxyFileDescriptor(
- modeFlag,
- new MtpProxyFileDescriptorCallback(Integer.parseInt(documentId)));
- } else {
- throw new UnsupportedOperationException(
- "The device does not support writing operation.");
- }
- } else {
- // TODO: Add support for "rw" mode.
- throw new UnsupportedOperationException("The provider does not support 'rw' mode.");
- }
- } catch (FileNotFoundException | RuntimeException error) {
- Log.e(MtpDocumentsProvider.TAG, "openDocument", error);
- throw error;
- } catch (IOException error) {
- Log.e(MtpDocumentsProvider.TAG, "openDocument", error);
- throw new IllegalStateException(error);
- }
- }
-
- @Override
- public AssetFileDescriptor openDocumentThumbnail(
- String documentId,
- Point sizeHint,
- CancellationSignal signal) throws FileNotFoundException {
- final Identifier identifier = mDatabase.createIdentifier(documentId);
- try {
- openDevice(identifier.mDeviceId);
- return new AssetFileDescriptor(
- getPipeManager(identifier).readThumbnail(mMtpManager, identifier),
- 0, // Start offset.
- AssetFileDescriptor.UNKNOWN_LENGTH);
- } catch (IOException error) {
- Log.e(MtpDocumentsProvider.TAG, "openDocumentThumbnail", error);
- throw new FileNotFoundException(error.getMessage());
- }
- }
-
- @Override
- public void deleteDocument(String documentId) throws FileNotFoundException {
- try {
- final Identifier identifier = mDatabase.createIdentifier(documentId);
- openDevice(identifier.mDeviceId);
- final Identifier parentIdentifier = mDatabase.getParentIdentifier(documentId);
- mMtpManager.deleteDocument(identifier.mDeviceId, identifier.mObjectHandle);
- mDatabase.deleteDocument(documentId);
- getDocumentLoader(parentIdentifier).cancelTask(parentIdentifier);
- notifyChildDocumentsChange(parentIdentifier.mDocumentId);
- if (parentIdentifier.mDocumentType == MtpDatabaseConstants.DOCUMENT_TYPE_STORAGE) {
- // If the parent is storage, the object might be appeared as child of device because
- // we skip storage when the device has only one storage.
- final Identifier deviceIdentifier = mDatabase.getParentIdentifier(
- parentIdentifier.mDocumentId);
- notifyChildDocumentsChange(deviceIdentifier.mDocumentId);
- }
- } catch (IOException error) {
- Log.e(MtpDocumentsProvider.TAG, "deleteDocument", error);
- throw new FileNotFoundException(error.getMessage());
- }
- }
-
- @Override
- public void onTrimMemory(int level) {
- synchronized (mDeviceListLock) {
- for (final DeviceToolkit toolkit : mDeviceToolkits.values()) {
- toolkit.mDocumentLoader.clearCompletedTasks();
- }
- }
- }
-
- @Override
- public String createDocument(String parentDocumentId, String mimeType, String displayName)
- throws FileNotFoundException {
- if (DEBUG) {
- Log.d(TAG, "createDocument: " + displayName);
- }
- final Identifier parentId;
- final MtpDeviceRecord record;
- final ParcelFileDescriptor[] pipe;
- try {
- parentId = mDatabase.createIdentifier(parentDocumentId);
- openDevice(parentId.mDeviceId);
- record = getDeviceToolkit(parentId.mDeviceId).mDeviceRecord;
- if (!MtpDeviceRecord.isWritingSupported(record.operationsSupported)) {
- throw new UnsupportedOperationException(
- "Writing operation is not supported by the device.");
- }
-
- final int parentObjectHandle;
- final int storageId;
- switch (parentId.mDocumentType) {
- case MtpDatabaseConstants.DOCUMENT_TYPE_DEVICE:
- final String[] storageDocumentIds =
- mDatabase.getStorageDocumentIds(parentId.mDocumentId);
- if (storageDocumentIds.length == 1) {
- final String newDocumentId =
- createDocument(storageDocumentIds[0], mimeType, displayName);
- notifyChildDocumentsChange(parentDocumentId);
- return newDocumentId;
- } else {
- throw new UnsupportedOperationException(
- "Cannot create a file under the device.");
- }
- case MtpDatabaseConstants.DOCUMENT_TYPE_STORAGE:
- storageId = parentId.mStorageId;
- parentObjectHandle = -1;
- break;
- case MtpDatabaseConstants.DOCUMENT_TYPE_OBJECT:
- storageId = parentId.mStorageId;
- parentObjectHandle = parentId.mObjectHandle;
- break;
- default:
- throw new IllegalArgumentException("Unexpected document type.");
- }
-
- pipe = ParcelFileDescriptor.createReliablePipe();
- int objectHandle = -1;
- MtpObjectInfo info = null;
- try {
- pipe[0].close(); // 0 bytes for a new document.
-
- final int formatCode = Document.MIME_TYPE_DIR.equals(mimeType) ?
- MtpConstants.FORMAT_ASSOCIATION :
- MediaFile.getFormatCode(displayName, mimeType);
- info = new MtpObjectInfo.Builder()
- .setStorageId(storageId)
- .setParent(parentObjectHandle)
- .setFormat(formatCode)
- .setName(displayName)
- .build();
-
- final String[] parts = FileUtils.splitFileName(mimeType, displayName);
- final String baseName = parts[0];
- final String extension = parts[1];
- for (int i = 0; i <= 32; i++) {
- final MtpObjectInfo infoUniqueName;
- if (i == 0) {
- infoUniqueName = info;
- } else {
- String suffixedName = baseName + " (" + i + " )";
- if (!extension.isEmpty()) {
- suffixedName += "." + extension;
- }
- infoUniqueName =
- new MtpObjectInfo.Builder(info).setName(suffixedName).build();
- }
- try {
- objectHandle = mMtpManager.createDocument(
- parentId.mDeviceId, infoUniqueName, pipe[1]);
- break;
- } catch (SendObjectInfoFailure exp) {
- // This can be caused when we have an existing file with the same name.
- continue;
- }
- }
- } finally {
- pipe[1].close();
- }
- if (objectHandle == -1) {
- throw new IllegalArgumentException(
- "The file name \"" + displayName + "\" is conflicted with existing files " +
- "and the provider failed to find unique name.");
- }
- final MtpObjectInfo infoWithHandle =
- new MtpObjectInfo.Builder(info).setObjectHandle(objectHandle).build();
- final String documentId = mDatabase.putNewDocument(
- parentId.mDeviceId, parentDocumentId, record.operationsSupported,
- infoWithHandle, 0l);
- getDocumentLoader(parentId).cancelTask(parentId);
- notifyChildDocumentsChange(parentDocumentId);
- return documentId;
- } catch (FileNotFoundException | RuntimeException error) {
- Log.e(TAG, "createDocument", error);
- throw error;
- } catch (IOException error) {
- Log.e(TAG, "createDocument", error);
- throw new IllegalStateException(error);
- }
- }
-
- @Override
- public Path findDocumentPath(String parentDocumentId, String childDocumentId)
- throws FileNotFoundException {
- final LinkedList<String> ids = new LinkedList<>();
- final Identifier childIdentifier = mDatabase.createIdentifier(childDocumentId);
-
- Identifier i = childIdentifier;
- outer: while (true) {
- if (i.mDocumentId.equals(parentDocumentId)) {
- ids.addFirst(i.mDocumentId);
- break;
- }
- switch (i.mDocumentType) {
- case MtpDatabaseConstants.DOCUMENT_TYPE_OBJECT:
- ids.addFirst(i.mDocumentId);
- i = mDatabase.getParentIdentifier(i.mDocumentId);
- break;
- case MtpDatabaseConstants.DOCUMENT_TYPE_STORAGE: {
- // Check if there is the multiple storage.
- final Identifier deviceIdentifier =
- mDatabase.getParentIdentifier(i.mDocumentId);
- final String[] storageIds =
- mDatabase.getStorageDocumentIds(deviceIdentifier.mDocumentId);
- // Add storage's document ID to the path only when the device has multiple
- // storages.
- if (storageIds.length > 1) {
- ids.addFirst(i.mDocumentId);
- break outer;
- }
- i = deviceIdentifier;
- break;
- }
- case MtpDatabaseConstants.DOCUMENT_TYPE_DEVICE:
- ids.addFirst(i.mDocumentId);
- break outer;
- }
- }
-
- if (parentDocumentId != null) {
- return new Path(null, ids);
- } else {
- return new Path(/* Should be same with root ID */ i.mDocumentId, ids);
- }
- }
-
- @Override
- public boolean isChildDocument(String parentDocumentId, String documentId) {
- try {
- Identifier identifier = mDatabase.createIdentifier(documentId);
- while (true) {
- if (parentDocumentId.equals(identifier.mDocumentId)) {
- return true;
- }
- if (identifier.mDocumentType == MtpDatabaseConstants.DOCUMENT_TYPE_DEVICE) {
- return false;
- }
- identifier = mDatabase.getParentIdentifier(identifier.mDocumentId);
- }
- } catch (FileNotFoundException error) {
- return false;
- }
- }
-
- @Override
- public @Nullable Bundle getDocumentMetadata(String docId) throws FileNotFoundException {
- String mimeType = getDocumentType(docId);
-
- if (!MetadataReader.isSupportedMimeType(mimeType)) {
- return null;
- }
-
- InputStream stream = null;
- try {
- stream = new ParcelFileDescriptor.AutoCloseInputStream(
- openDocument(docId, "r", null));
- Bundle metadata = new Bundle();
- MetadataReader.getMetadata(metadata, stream, mimeType, null);
- return metadata;
- } catch (IOException e) {
- Log.e(TAG, "An error occurred retrieving the metadata", e);
- return null;
- } finally {
- IoUtils.closeQuietly(stream);
- }
- }
-
- void openDevice(int deviceId) throws IOException {
- synchronized (mDeviceListLock) {
- if (mDeviceToolkits.containsKey(deviceId)) {
- return;
- }
- if (DEBUG) {
- Log.d(TAG, "Open device " + deviceId);
- }
- final MtpDeviceRecord device = mMtpManager.openDevice(deviceId);
- final DeviceToolkit toolkit =
- new DeviceToolkit(mMtpManager, mResolver, mDatabase, device);
- mDeviceToolkits.put(deviceId, toolkit);
- mIntentSender.sendUpdateNotificationIntent(getOpenedDeviceRecordsCache());
- try {
- mRootScanner.resume().await();
- } catch (InterruptedException error) {
- Log.e(TAG, "openDevice", error);
- }
- // Resume document loader to remap disconnected document ID. Must be invoked after the
- // root scanner resumes.
- toolkit.mDocumentLoader.resume();
- }
- }
-
- void closeDevice(int deviceId) throws IOException, InterruptedException {
- synchronized (mDeviceListLock) {
- closeDeviceInternal(deviceId);
- mIntentSender.sendUpdateNotificationIntent(getOpenedDeviceRecordsCache());
- }
- mRootScanner.resume();
- }
-
- MtpDeviceRecord[] getOpenedDeviceRecordsCache() {
- synchronized (mDeviceListLock) {
- final MtpDeviceRecord[] records = new MtpDeviceRecord[mDeviceToolkits.size()];
- int i = 0;
- for (final DeviceToolkit toolkit : mDeviceToolkits.values()) {
- records[i] = toolkit.mDeviceRecord;
- i++;
- }
- return records;
- }
- }
-
- /**
- * Obtains document ID for the given device ID.
- * @param deviceId
- * @return document ID
- * @throws FileNotFoundException device ID has not been build.
- */
- public String getDeviceDocumentId(int deviceId) throws FileNotFoundException {
- return mDatabase.getDeviceDocumentId(deviceId);
- }
-
- /**
- * Resumes root scanner to handle the update of device list.
- */
- void resumeRootScanner() {
- if (DEBUG) {
- Log.d(MtpDocumentsProvider.TAG, "resumeRootScanner");
- }
- mRootScanner.resume();
- }
-
- /**
- * Finalize the content provider for unit tests.
- */
- @Override
- public void shutdown() {
- synchronized (mDeviceListLock) {
- try {
- // Copy the opened key set because it will be modified when closing devices.
- final Integer[] keySet =
- mDeviceToolkits.keySet().toArray(new Integer[mDeviceToolkits.size()]);
- for (final int id : keySet) {
- closeDeviceInternal(id);
- }
- mRootScanner.pause();
- } catch (InterruptedException | IOException | TimeoutException e) {
- // It should fail unit tests by throwing runtime exception.
- throw new RuntimeException(e);
- } finally {
- mDatabase.close();
- super.shutdown();
- }
- }
- }
-
- private void notifyChildDocumentsChange(String parentDocumentId) {
- mResolver.notifyChange(
- DocumentsContract.buildChildDocumentsUri(AUTHORITY, parentDocumentId),
- null,
- false);
- }
-
- /**
- * Clears MTP identifier in the database.
- */
- private void resume() {
- synchronized (mDeviceListLock) {
- mDatabase.getMapper().clearMapping();
- }
- }
-
- private void closeDeviceInternal(int deviceId) throws IOException, InterruptedException {
- // TODO: Flush the device before closing (if not closed externally).
- if (!mDeviceToolkits.containsKey(deviceId)) {
- return;
- }
- if (DEBUG) {
- Log.d(TAG, "Close device " + deviceId);
- }
- getDeviceToolkit(deviceId).close();
- mDeviceToolkits.remove(deviceId);
- mMtpManager.closeDevice(deviceId);
- }
-
- private DeviceToolkit getDeviceToolkit(int deviceId) throws FileNotFoundException {
- synchronized (mDeviceListLock) {
- final DeviceToolkit toolkit = mDeviceToolkits.get(deviceId);
- if (toolkit == null) {
- throw new FileNotFoundException();
- }
- return toolkit;
- }
- }
-
- private PipeManager getPipeManager(Identifier identifier) throws FileNotFoundException {
- return getDeviceToolkit(identifier.mDeviceId).mPipeManager;
- }
-
- private DocumentLoader getDocumentLoader(Identifier identifier) throws FileNotFoundException {
- return getDeviceToolkit(identifier.mDeviceId).mDocumentLoader;
- }
-
- private long getFileSize(String documentId) throws FileNotFoundException {
- final Cursor cursor = mDatabase.queryDocument(
- documentId,
- MtpDatabase.strings(Document.COLUMN_SIZE, Document.COLUMN_DISPLAY_NAME));
- try {
- if (cursor.moveToNext()) {
- if (cursor.isNull(0)) {
- throw new UnsupportedOperationException();
- }
- return cursor.getLong(0);
- } else {
- throw new FileNotFoundException();
- }
- } finally {
- cursor.close();
- }
- }
-
- /**
- * Creates empty cursor with specific error message.
- *
- * @param projection Column names.
- * @param stringResId String resource ID of error message.
- * @return Empty cursor with error message.
- */
- private Cursor createErrorCursor(String[] projection, int stringResId) {
- final Bundle bundle = new Bundle();
- bundle.putString(DocumentsContract.EXTRA_ERROR, mResources.getString(stringResId));
- final Cursor cursor = new MatrixCursor(projection);
- cursor.setExtras(bundle);
- return cursor;
- }
-
- private static class DeviceToolkit implements AutoCloseable {
- public final PipeManager mPipeManager;
- public final DocumentLoader mDocumentLoader;
- public final MtpDeviceRecord mDeviceRecord;
-
- public DeviceToolkit(MtpManager manager,
- ContentResolver resolver,
- MtpDatabase database,
- MtpDeviceRecord record) {
- mPipeManager = new PipeManager(database);
- mDocumentLoader = new DocumentLoader(record, manager, resolver, database);
- mDeviceRecord = record;
- }
-
- @Override
- public void close() throws InterruptedException {
- mPipeManager.close();
- mDocumentLoader.close();
- }
- }
-
- private class MtpProxyFileDescriptorCallback extends ProxyFileDescriptorCallback {
- private final int mInode;
- private MtpFileWriter mWriter;
-
- MtpProxyFileDescriptorCallback(int inode) {
- mInode = inode;
- }
-
- @Override
- public long onGetSize() throws ErrnoException {
- try {
- return getFileSize(String.valueOf(mInode));
- } catch (FileNotFoundException e) {
- Log.e(TAG, e.getMessage(), e);
- throw new ErrnoException("onGetSize", OsConstants.ENOENT);
- }
- }
-
- @Override
- public int onRead(long offset, int size, byte[] data) throws ErrnoException {
- try {
- final Identifier identifier = mDatabase.createIdentifier(Integer.toString(mInode));
- final MtpDeviceRecord record = getDeviceToolkit(identifier.mDeviceId).mDeviceRecord;
- if (MtpDeviceRecord.isSupported(
- record.operationsSupported, MtpConstants.OPERATION_GET_PARTIAL_OBJECT_64)) {
-
- return (int) mMtpManager.getPartialObject64(
- identifier.mDeviceId, identifier.mObjectHandle, offset, size, data);
-
- }
- if (0 <= offset && offset <= 0xffffffffL && MtpDeviceRecord.isSupported(
- record.operationsSupported, MtpConstants.OPERATION_GET_PARTIAL_OBJECT)) {
- return (int) mMtpManager.getPartialObject(
- identifier.mDeviceId, identifier.mObjectHandle, offset, size, data);
- }
- throw new ErrnoException("onRead", OsConstants.ENOTSUP);
- } catch (IOException e) {
- Log.e(TAG, e.getMessage(), e);
- throw new ErrnoException("onRead", OsConstants.EIO);
- }
- }
-
- @Override
- public int onWrite(long offset, int size, byte[] data) throws ErrnoException {
- try {
- if (mWriter == null) {
- mWriter = new MtpFileWriter(mContext, String.valueOf(mInode));
- }
- return mWriter.write(offset, size, data);
- } catch (IOException e) {
- Log.e(TAG, e.getMessage(), e);
- throw new ErrnoException("onWrite", OsConstants.EIO);
- }
- }
-
- @Override
- public void onFsync() throws ErrnoException {
- tryFsync();
- }
-
- @Override
- public void onRelease() {
- try {
- tryFsync();
- } catch (ErrnoException error) {
- // Cannot recover from the error at onRelease. Client app should use fsync to
- // ensure the provider writes data correctly.
- Log.e(TAG, "Cannot recover from the error at onRelease.", error);
- } finally {
- if (mWriter != null) {
- IoUtils.closeQuietly(mWriter);
- }
- }
- }
-
- private void tryFsync() throws ErrnoException {
- try {
- if (mWriter != null) {
- final MtpDeviceRecord device =
- getDeviceToolkit(mDatabase.createIdentifier(
- mWriter.getDocumentId()).mDeviceId).mDeviceRecord;
- mWriter.flush(mMtpManager, mDatabase, device.operationsSupported);
- }
- } catch (IOException e) {
- Log.e(TAG, e.getMessage(), e);
- throw new ErrnoException("onWrite", OsConstants.EIO);
- }
- }
- }
-}
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDocumentsService.java b/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDocumentsService.java
deleted file mode 100644
index fa1a12030..0000000
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDocumentsService.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.mtp;
-
-import android.annotation.NonNull;
-import android.annotation.Nullable;
-import android.app.Notification;
-import android.app.Service;
-import android.app.NotificationManager;
-import android.content.Intent;
-import android.os.IBinder;
-import android.os.Parcelable;
-import android.service.notification.StatusBarNotification;
-import android.util.Log;
-import com.android.internal.util.Preconditions;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Service to manage lifetime of DocumentsProvider's process.
- * The service prevents the system from killing the process that holds USB connections. The service
- * starts to run when the first MTP device is opened, and stops when the last MTP device is closed.
- */
-public class MtpDocumentsService extends Service {
- static final String ACTION_UPDATE_NOTIFICATION = "com.android.mtp.UPDATE_NOTIFICATION";
- static final String EXTRA_DEVICE_IDS = "deviceIds";
- static final String EXTRA_DEVICE_NOTIFICATIONS = "deviceNotifications";
-
- private NotificationManager mNotificationManager;
-
- @Override
- public IBinder onBind(Intent intent) {
- // The service is used via intents.
- return null;
- }
-
- @Override
- public void onCreate() {
- super.onCreate();
- mNotificationManager = getSystemService(NotificationManager.class);
- }
-
- @Override
- public int onStartCommand(Intent intent, int flags, int startId) {
- // If intent is null, the service was restarted.
- if (intent == null || ACTION_UPDATE_NOTIFICATION.equals(intent.getAction())) {
- final int[] ids = intent.hasExtra(EXTRA_DEVICE_IDS) ?
- intent.getExtras().getIntArray(EXTRA_DEVICE_IDS) : null;
- final Notification[] notifications = intent.hasExtra(EXTRA_DEVICE_NOTIFICATIONS) ?
- castToNotifications(intent.getExtras().getParcelableArray(
- EXTRA_DEVICE_NOTIFICATIONS)) : null;
- return updateForegroundState(ids, notifications) ? START_STICKY : START_NOT_STICKY;
- }
- return START_NOT_STICKY;
- }
-
- /**
- * Updates the foreground state of the service.
- * @return Whether the service is foreground or not.
- */
- private boolean updateForegroundState(
- @Nullable int[] ids, @Nullable Notification[] notifications) {
- final Set<Integer> openedNotification = new HashSet<>();
- final int size = ids != null ? ids.length : 0;
- if (size != 0) {
- Preconditions.checkArgument(ids != null);
- Preconditions.checkArgument(notifications != null);
- Preconditions.checkArgument(ids.length == notifications.length);
- }
-
- for (int i = 0; i < size; i++) {
- if (i == 0) {
- // Mark this service as foreground with the notification so that the process is
- // not killed by the system while a MTP device is opened.
- startForeground(ids[i], notifications[i]);
- } else {
- // Only one notification can be shown as a foreground notification. We need to
- // show the rest as normal notification.
- mNotificationManager.notify(ids[i], notifications[i]);
- }
- openedNotification.add(ids[i]);
- }
-
- final StatusBarNotification[] activeNotifications =
- mNotificationManager.getActiveNotifications();
- for (final StatusBarNotification notification : activeNotifications) {
- if (!openedNotification.contains(notification.getId())) {
- mNotificationManager.cancel(notification.getId());
- }
- }
-
- if (size == 0) {
- // There is no opened device.
- stopForeground(true /* removeNotification */);
- stopSelf();
- return false;
- }
-
- return true;
- }
-
- private static @NonNull Notification[] castToNotifications(@NonNull Parcelable[] src) {
- Preconditions.checkNotNull(src);
- final Notification[] notifications = new Notification[src.length];
- for (int i = 0; i < src.length; i++) {
- notifications[i] = (Notification) src[i];
- }
- return notifications;
- }
-}
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpFileWriter.java b/packages/MtpDocumentsProvider/src/com/android/mtp/MtpFileWriter.java
deleted file mode 100644
index 3e1bedc..0000000
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpFileWriter.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.mtp;
-
-import android.content.Context;
-import android.mtp.MtpObjectInfo;
-import android.os.ParcelFileDescriptor;
-import android.system.ErrnoException;
-import android.system.Os;
-import android.system.OsConstants;
-
-import com.android.internal.util.Preconditions;
-
-import java.io.File;
-import java.io.IOException;
-
-class MtpFileWriter implements AutoCloseable {
- final ParcelFileDescriptor mCacheFd;
- final String mDocumentId;
- boolean mDirty;
-
- MtpFileWriter(Context context, String documentId) throws IOException {
- mDocumentId = documentId;
- mDirty = false;
- final File tempFile = File.createTempFile("mtp", "tmp", context.getCacheDir());
- mCacheFd = ParcelFileDescriptor.open(
- tempFile,
- ParcelFileDescriptor.MODE_READ_WRITE |
- ParcelFileDescriptor.MODE_TRUNCATE |
- ParcelFileDescriptor.MODE_CREATE);
- tempFile.delete();
- }
-
- String getDocumentId() {
- return mDocumentId;
- }
-
- int write(long offset, int size, byte[] bytes) throws IOException, ErrnoException {
- Preconditions.checkArgumentNonnegative(offset, "offset");
- Preconditions.checkArgumentNonnegative(size, "size");
- Preconditions.checkArgument(size <= bytes.length);
- if (size == 0) {
- return 0;
- }
- mDirty = true;
- Os.lseek(mCacheFd.getFileDescriptor(), offset, OsConstants.SEEK_SET);
- return Os.write(mCacheFd.getFileDescriptor(), bytes, 0, size);
- }
-
- void flush(MtpManager manager, MtpDatabase database, int[] operationsSupported)
- throws IOException, ErrnoException {
- // Skip unnecessary flush.
- if (!mDirty) {
- return;
- }
-
- // Get the placeholder object info.
- final Identifier identifier = database.createIdentifier(mDocumentId);
- final MtpObjectInfo placeholderObjectInfo =
- manager.getObjectInfo(identifier.mDeviceId, identifier.mObjectHandle);
-
- // Delete the target object info if it already exists (as a placeholder).
- manager.deleteDocument(identifier.mDeviceId, identifier.mObjectHandle);
-
- // Create the target object info with a correct file size and upload the file.
- final long size = Os.lseek(mCacheFd.getFileDescriptor(), 0, OsConstants.SEEK_END);
- final MtpObjectInfo targetObjectInfo = new MtpObjectInfo.Builder(placeholderObjectInfo)
- .setCompressedSize(size)
- .build();
-
- Os.lseek(mCacheFd.getFileDescriptor(), 0, OsConstants.SEEK_SET);
- final int newObjectHandle = manager.createDocument(
- identifier.mDeviceId, targetObjectInfo, mCacheFd);
-
- final MtpObjectInfo newObjectInfo = manager.getObjectInfo(
- identifier.mDeviceId, newObjectHandle);
- final Identifier parentIdentifier =
- database.getParentIdentifier(identifier.mDocumentId);
- database.updateObject(
- identifier.mDocumentId,
- identifier.mDeviceId,
- parentIdentifier.mDocumentId,
- operationsSupported,
- newObjectInfo,
- size);
-
- mDirty = false;
- }
-
- @Override
- public void close() throws IOException {
- mCacheFd.close();
- }
-}
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpManager.java b/packages/MtpDocumentsProvider/src/com/android/mtp/MtpManager.java
deleted file mode 100644
index a7de631..0000000
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpManager.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.mtp;
-
-import android.annotation.Nullable;
-import android.content.Context;
-import android.hardware.usb.UsbConstants;
-import android.hardware.usb.UsbDevice;
-import android.hardware.usb.UsbDeviceConnection;
-import android.hardware.usb.UsbInterface;
-import android.hardware.usb.UsbManager;
-import android.mtp.MtpConstants;
-import android.mtp.MtpDevice;
-import android.mtp.MtpDeviceInfo;
-import android.mtp.MtpEvent;
-import android.mtp.MtpObjectInfo;
-import android.mtp.MtpStorageInfo;
-import android.os.CancellationSignal;
-import android.os.ParcelFileDescriptor;
-import android.util.Log;
-import android.util.SparseArray;
-
-import com.android.internal.annotations.VisibleForTesting;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-
-/**
- * The model wrapping android.mtp API.
- */
-class MtpManager {
- final static int OBJECT_HANDLE_ROOT_CHILDREN = -1;
-
- /**
- * Subclass for PTP.
- */
- private static final int SUBCLASS_STILL_IMAGE_CAPTURE = 1;
-
- /**
- * Subclass for Android style MTP.
- */
- private static final int SUBCLASS_MTP = 0xff;
-
- /**
- * Protocol for Picture Transfer Protocol (PIMA 15470).
- */
- private static final int PROTOCOL_PICTURE_TRANSFER = 1;
-
- /**
- * Protocol for Android style MTP.
- */
- private static final int PROTOCOL_MTP = 0;
-
- private final UsbManager mManager;
- private final SparseArray<MtpDevice> mDevices = new SparseArray<>();
-
- MtpManager(Context context) {
- mManager = (UsbManager) context.getSystemService(Context.USB_SERVICE);
- }
-
- synchronized MtpDeviceRecord openDevice(int deviceId) throws IOException {
- UsbDevice rawDevice = null;
- for (final UsbDevice candidate : mManager.getDeviceList().values()) {
- if (candidate.getDeviceId() == deviceId) {
- rawDevice = candidate;
- break;
- }
- }
-
- ensureNotNull(rawDevice, "Not found USB device: " + deviceId);
-
- if (!mManager.hasPermission(rawDevice)) {
- mManager.grantPermission(rawDevice);
- if (!mManager.hasPermission(rawDevice)) {
- throw new IOException("Failed to grant a device permission.");
- }
- }
-
- final MtpDevice device = new MtpDevice(rawDevice);
-
- final UsbDeviceConnection connection = ensureNotNull(
- mManager.openDevice(rawDevice),
- "Failed to open a USB connection.");
-
- if (!device.open(connection)) {
- // We cannot open connection when another application use the device.
- throw new BusyDeviceException();
- }
-
- // Handle devices that fail to obtain storages just after opening a MTP session.
- final int[] storageIds = ensureNotNull(
- device.getStorageIds(),
- "Not found MTP storages in the device.");
-
- mDevices.put(deviceId, device);
- return createDeviceRecord(rawDevice);
- }
-
- synchronized void closeDevice(int deviceId) throws IOException {
- getDevice(deviceId).close();
- mDevices.remove(deviceId);
- }
-
- synchronized MtpDeviceRecord[] getDevices() {
- final ArrayList<MtpDeviceRecord> devices = new ArrayList<>();
- for (UsbDevice device : mManager.getDeviceList().values()) {
- if (!isMtpDevice(device)) {
- continue;
- }
- devices.add(createDeviceRecord(device));
- }
- return devices.toArray(new MtpDeviceRecord[devices.size()]);
- }
-
- MtpObjectInfo getObjectInfo(int deviceId, int objectHandle) throws IOException {
- final MtpDevice device = getDevice(deviceId);
- synchronized (device) {
- return ensureNotNull(
- device.getObjectInfo(objectHandle),
- "Failed to get object info: " + objectHandle);
- }
- }
-
- int[] getObjectHandles(int deviceId, int storageId, int parentObjectHandle)
- throws IOException {
- final MtpDevice device = getDevice(deviceId);
- synchronized (device) {
- return ensureNotNull(
- device.getObjectHandles(storageId, 0 /* all format */, parentObjectHandle),
- "Failed to fetch object handles.");
- }
- }
-
- byte[] getObject(int deviceId, int objectHandle, int expectedSize)
- throws IOException {
- final MtpDevice device = getDevice(deviceId);
- synchronized (device) {
- return ensureNotNull(
- device.getObject(objectHandle, expectedSize),
- "Failed to fetch object bytes");
- }
- }
-
- long getPartialObject(int deviceId, int objectHandle, long offset, long size, byte[] buffer)
- throws IOException {
- final MtpDevice device = getDevice(deviceId);
- synchronized (device) {
- return device.getPartialObject(objectHandle, offset, size, buffer);
- }
- }
-
- long getPartialObject64(int deviceId, int objectHandle, long offset, long size, byte[] buffer)
- throws IOException {
- final MtpDevice device = getDevice(deviceId);
- synchronized (device) {
- return device.getPartialObject64(objectHandle, offset, size, buffer);
- }
- }
-
- byte[] getThumbnail(int deviceId, int objectHandle) throws IOException {
- final MtpDevice device = getDevice(deviceId);
- synchronized (device) {
- return ensureNotNull(
- device.getThumbnail(objectHandle),
- "Failed to obtain thumbnail bytes");
- }
- }
-
- void deleteDocument(int deviceId, int objectHandle) throws IOException {
- final MtpDevice device = getDevice(deviceId);
- synchronized (device) {
- if (!device.deleteObject(objectHandle)) {
- throw new IOException("Failed to delete document");
- }
- }
- }
-
- int createDocument(int deviceId, MtpObjectInfo objectInfo,
- ParcelFileDescriptor source) throws IOException {
- final MtpDevice device = getDevice(deviceId);
- synchronized (device) {
- final MtpObjectInfo sendObjectInfoResult = device.sendObjectInfo(objectInfo);
- if (sendObjectInfoResult == null) {
- throw new SendObjectInfoFailure();
- }
- if (objectInfo.getFormat() != MtpConstants.FORMAT_ASSOCIATION) {
- if (!device.sendObject(sendObjectInfoResult.getObjectHandle(),
- sendObjectInfoResult.getCompressedSizeLong(), source)) {
- throw new IOException("Failed to send contents of a document");
- }
- }
- return sendObjectInfoResult.getObjectHandle();
- }
- }
-
- int getParent(int deviceId, int objectHandle) throws IOException {
- final MtpDevice device = getDevice(deviceId);
- synchronized (device) {
- final int result = (int) device.getParent(objectHandle);
- if (result == 0xffffffff) {
- throw new FileNotFoundException("Not found parent object");
- }
- return result;
- }
- }
-
- void importFile(int deviceId, int objectHandle, ParcelFileDescriptor target)
- throws IOException {
- final MtpDevice device = getDevice(deviceId);
- synchronized (device) {
- if (!device.importFile(objectHandle, target)) {
- throw new IOException("Failed to import file to FD");
- }
- }
- }
-
- @VisibleForTesting
- MtpEvent readEvent(int deviceId, CancellationSignal signal) throws IOException {
- final MtpDevice device = getDevice(deviceId);
- return device.readEvent(signal);
- }
-
- long getObjectSizeLong(int deviceId, int objectHandle, int format) throws IOException {
- final MtpDevice device = getDevice(deviceId);
- return device.getObjectSizeLong(objectHandle, format);
- }
-
- private synchronized MtpDevice getDevice(int deviceId) throws IOException {
- return ensureNotNull(
- mDevices.get(deviceId),
- "USB device " + deviceId + " is not opened.");
- }
-
- private MtpRoot[] getRoots(int deviceId) throws IOException {
- final MtpDevice device = getDevice(deviceId);
- synchronized (device) {
- final int[] storageIds =
- ensureNotNull(device.getStorageIds(), "Failed to obtain storage IDs.");
- final ArrayList<MtpRoot> roots = new ArrayList<>();
- for (int i = 0; i < storageIds.length; i++) {
- final MtpStorageInfo info = device.getStorageInfo(storageIds[i]);
- if (info == null) {
- continue;
- }
- roots.add(new MtpRoot(device.getDeviceId(), info));
- }
- return roots.toArray(new MtpRoot[roots.size()]);
- }
- }
-
- private MtpDeviceRecord createDeviceRecord(UsbDevice device) {
- final MtpDevice mtpDevice = mDevices.get(device.getDeviceId());
- final boolean opened = mtpDevice != null;
- final String name = device.getProductName();
- MtpRoot[] roots;
- int[] operationsSupported = null;
- int[] eventsSupported = null;
- if (opened) {
- try {
- roots = getRoots(device.getDeviceId());
- } catch (IOException exp) {
- Log.e(MtpDocumentsProvider.TAG, "Failed to open device", exp);
- // If we failed to fetch roots for the device, we still returns device model
- // with an empty set of roots so that the device is shown DocumentsUI as long as
- // the device is physically connected.
- roots = new MtpRoot[0];
- }
- final MtpDeviceInfo info = mtpDevice.getDeviceInfo();
- if (info != null) {
- operationsSupported = info.getOperationsSupported();
- eventsSupported = info.getEventsSupported();
- }
- } else {
- roots = new MtpRoot[0];
- }
- return new MtpDeviceRecord(
- device.getDeviceId(), name, device.getSerialNumber(), opened, roots,
- operationsSupported, eventsSupported);
- }
-
- static boolean isMtpDevice(UsbDevice device) {
- for (int i = 0; i < device.getInterfaceCount(); i++) {
- final UsbInterface usbInterface = device.getInterface(i);
- if ((usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_STILL_IMAGE &&
- usbInterface.getInterfaceSubclass() == SUBCLASS_STILL_IMAGE_CAPTURE &&
- usbInterface.getInterfaceProtocol() == PROTOCOL_PICTURE_TRANSFER)) {
- return true;
- }
- if (usbInterface.getInterfaceClass() == UsbConstants.USB_SUBCLASS_VENDOR_SPEC &&
- usbInterface.getInterfaceSubclass() == SUBCLASS_MTP &&
- usbInterface.getInterfaceProtocol() == PROTOCOL_MTP &&
- "MTP".equals(usbInterface.getName())) {
- return true;
- }
- }
- return false;
- }
-
- private static <T> T ensureNotNull(@Nullable T t, String errorMessage) throws IOException {
- if (t != null) {
- return t;
- } else {
- throw new IOException(errorMessage);
- }
- }
-}
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpRoot.java b/packages/MtpDocumentsProvider/src/com/android/mtp/MtpRoot.java
deleted file mode 100644
index 8530aaf..0000000
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpRoot.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.mtp;
-
-import android.mtp.MtpStorageInfo;
-
-import com.android.internal.annotations.VisibleForTesting;
-
-class MtpRoot {
- final int mDeviceId;
- final int mStorageId;
- final String mDescription;
- final long mFreeSpace;
- final long mMaxCapacity;
- final String mVolumeIdentifier;
-
- @VisibleForTesting
- MtpRoot(int deviceId,
- int storageId,
- String description,
- long freeSpace,
- long maxCapacity,
- String volumeIdentifier) {
- mDeviceId = deviceId;
- mStorageId = storageId;
- mDescription = description;
- mFreeSpace = freeSpace;
- mMaxCapacity = maxCapacity;
- mVolumeIdentifier = volumeIdentifier;
- }
-
- MtpRoot(int deviceId, MtpStorageInfo storageInfo) {
- mDeviceId = deviceId;
- mStorageId = storageInfo.getStorageId();
- mDescription = storageInfo.getDescription();
- mFreeSpace = storageInfo.getFreeSpace();
- mMaxCapacity = storageInfo.getMaxCapacity();
- mVolumeIdentifier = storageInfo.getVolumeIdentifier();
- }
-
- @Override
- public boolean equals(Object object) {
- if (!(object instanceof MtpRoot))
- return false;
- final MtpRoot other = (MtpRoot) object;
- return mDeviceId == other.mDeviceId &&
- mStorageId == other.mStorageId &&
- mDescription.equals(other.mDescription) &&
- mFreeSpace == other.mFreeSpace &&
- mMaxCapacity == other.mMaxCapacity &&
- mVolumeIdentifier.equals(other.mVolumeIdentifier);
- }
-
- @Override
- public int hashCode() {
- return mDeviceId ^ mStorageId ^ mDescription.hashCode() ^
- ((int) mFreeSpace) ^ ((int) mMaxCapacity) ^ mVolumeIdentifier.hashCode();
- }
-
- @Override
- public String toString() {
- return "MtpRoot{Name: " + mDescription + "}";
- }
-}
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/PipeManager.java b/packages/MtpDocumentsProvider/src/com/android/mtp/PipeManager.java
deleted file mode 100644
index 795bbc1..0000000
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/PipeManager.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.mtp;
-
-import android.os.ParcelFileDescriptor;
-import android.util.Log;
-
-import java.io.IOException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-class PipeManager {
- /**
- * Milliseconds we wait for background thread when pausing.
- */
- private final static long AWAIT_TERMINATION_TIMEOUT = 2000;
-
- final ExecutorService mExecutor;
- final MtpDatabase mDatabase;
-
- PipeManager(MtpDatabase database) {
- this(database, Executors.newSingleThreadExecutor());
- }
-
- PipeManager(MtpDatabase database, ExecutorService executor) {
- this.mDatabase = database;
- this.mExecutor = executor;
- }
-
- ParcelFileDescriptor readDocument(MtpManager model, Identifier identifier) throws IOException {
- final Task task = new ImportFileTask(model, identifier);
- mExecutor.execute(task);
- return task.getReadingFileDescriptor();
- }
-
- ParcelFileDescriptor readThumbnail(MtpManager model, Identifier identifier) throws IOException {
- final Task task = new GetThumbnailTask(model, identifier);
- mExecutor.execute(task);
- return task.getReadingFileDescriptor();
- }
-
- private static abstract class Task implements Runnable {
- protected final MtpManager mManager;
- protected final Identifier mIdentifier;
- protected final ParcelFileDescriptor[] mDescriptors;
-
- Task(MtpManager manager, Identifier identifier) throws IOException {
- mManager = manager;
- mIdentifier = identifier;
- mDescriptors = ParcelFileDescriptor.createReliablePipe();
- }
-
- ParcelFileDescriptor getReadingFileDescriptor() {
- return mDescriptors[0];
- }
- }
-
- private static class ImportFileTask extends Task {
- ImportFileTask(MtpManager model, Identifier identifier) throws IOException {
- super(model, identifier);
- }
-
- @Override
- public void run() {
- try {
- mManager.importFile(
- mIdentifier.mDeviceId, mIdentifier.mObjectHandle, mDescriptors[1]);
- mDescriptors[1].close();
- } catch (IOException error) {
- try {
- mDescriptors[1].closeWithError("Failed to stream a file.");
- } catch (IOException closeError) {
- Log.w(MtpDocumentsProvider.TAG, closeError.getMessage());
- }
- }
- }
- }
-
- private static class GetThumbnailTask extends Task {
- GetThumbnailTask(MtpManager model, Identifier identifier) throws IOException {
- super(model, identifier);
- }
-
- @Override
- public void run() {
- try {
- try (final ParcelFileDescriptor.AutoCloseOutputStream stream =
- new ParcelFileDescriptor.AutoCloseOutputStream(mDescriptors[1])) {
- try {
- stream.write(mManager.getThumbnail(
- mIdentifier.mDeviceId, mIdentifier.mObjectHandle));
- } catch (IOException error) {
- mDescriptors[1].closeWithError("Failed to stream a thumbnail.");
- }
- }
- } catch (IOException closeError) {
- Log.w(MtpDocumentsProvider.TAG, closeError.getMessage());
- }
- }
- }
-
- boolean close() throws InterruptedException {
- mExecutor.shutdownNow();
- return mExecutor.awaitTermination(AWAIT_TERMINATION_TIMEOUT, TimeUnit.MILLISECONDS);
- }
-}
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/ReceiverActivity.java b/packages/MtpDocumentsProvider/src/com/android/mtp/ReceiverActivity.java
deleted file mode 100644
index 19c2c14..0000000
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/ReceiverActivity.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.mtp;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.hardware.usb.UsbDevice;
-import android.hardware.usb.UsbManager;
-import android.net.Uri;
-import android.os.Bundle;
-import android.provider.DocumentsContract;
-import android.util.Log;
-
-import java.io.IOException;
-
-/**
- * Invisible activity to receive intents.
- * To show Files app for the UsbManager.ACTION_USB_DEVICE_ATTACHED intent, the intent should be
- * received by activity. The activity has NoDisplay theme and immediately terminate after routing
- * intent to DocumentsUI.
- */
-public class ReceiverActivity extends Activity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(getIntent().getAction())) {
- final UsbDevice device = getIntent().getParcelableExtra(UsbManager.EXTRA_DEVICE);
- try {
- final MtpDocumentsProvider provider = MtpDocumentsProvider.getInstance();
- provider.openDevice(device.getDeviceId());
- final String deviceRootId = provider.getDeviceDocumentId(device.getDeviceId());
- final Uri uri = DocumentsContract.buildRootUri(
- MtpDocumentsProvider.AUTHORITY, deviceRootId);
-
- final Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setDataAndType(uri, DocumentsContract.Root.MIME_TYPE_ITEM);
- intent.addCategory(Intent.CATEGORY_DEFAULT);
- this.startActivity(intent);
- } catch (IOException exception) {
- Log.e(MtpDocumentsProvider.TAG, "Failed to open device", exception);
- }
- }
- finish();
- }
-}
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/RootScanner.java b/packages/MtpDocumentsProvider/src/com/android/mtp/RootScanner.java
deleted file mode 100644
index 20be2ba..0000000
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/RootScanner.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.mtp;
-
-import android.content.ContentResolver;
-import android.net.Uri;
-import android.os.Process;
-import android.provider.DocumentsContract;
-import android.util.Log;
-
-import java.io.FileNotFoundException;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-final class RootScanner {
- /**
- * Polling interval in milliseconds used for first SHORT_POLLING_TIMES because it is more
- * likely to add new root just after the device is added.
- */
- private final static long SHORT_POLLING_INTERVAL = 2000;
-
- /**
- * Polling interval in milliseconds for low priority polling, when changes are not expected.
- */
- private final static long LONG_POLLING_INTERVAL = 30 * 1000;
-
- /**
- * @see #SHORT_POLLING_INTERVAL
- */
- private final static long SHORT_POLLING_TIMES = 10;
-
- /**
- * Milliseconds we wait for background thread when pausing.
- */
- private final static long AWAIT_TERMINATION_TIMEOUT = 2000;
-
- final ContentResolver mResolver;
- final MtpManager mManager;
- final MtpDatabase mDatabase;
-
- ExecutorService mExecutor;
- private UpdateRootsRunnable mCurrentTask;
-
- RootScanner(
- ContentResolver resolver,
- MtpManager manager,
- MtpDatabase database) {
- mResolver = resolver;
- mManager = manager;
- mDatabase = database;
- }
-
- /**
- * Notifies a change of the roots list via ContentResolver.
- */
- void notifyChange() {
- final Uri uri = DocumentsContract.buildRootsUri(MtpDocumentsProvider.AUTHORITY);
- mResolver.notifyChange(uri, null, false);
- }
-
- /**
- * Starts to check new changes right away.
- */
- synchronized CountDownLatch resume() {
- if (mExecutor == null) {
- // Only single thread updates the database.
- mExecutor = Executors.newSingleThreadExecutor();
- }
- if (mCurrentTask != null) {
- // Stop previous task.
- mCurrentTask.stop();
- }
- mCurrentTask = new UpdateRootsRunnable();
- mExecutor.execute(mCurrentTask);
- return mCurrentTask.mFirstScanCompleted;
- }
-
- /**
- * Stops background thread and wait for its termination.
- * @throws InterruptedException
- */
- synchronized void pause() throws InterruptedException, TimeoutException {
- if (mExecutor == null) {
- return;
- }
- mExecutor.shutdownNow();
- try {
- if (!mExecutor.awaitTermination(AWAIT_TERMINATION_TIMEOUT, TimeUnit.MILLISECONDS)) {
- throw new TimeoutException(
- "Timeout for terminating RootScanner's background thread.");
- }
- } finally {
- mExecutor = null;
- }
- }
-
- /**
- * Runnable to scan roots and update the database information.
- */
- private final class UpdateRootsRunnable implements Runnable {
- /**
- * Count down latch that specifies the runnable is stopped.
- */
- final CountDownLatch mStopped = new CountDownLatch(1);
-
- /**
- * Count down latch that specifies the first scan is completed.
- */
- final CountDownLatch mFirstScanCompleted = new CountDownLatch(1);
-
- @Override
- public void run() {
- Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
- int pollingCount = 0;
- while (mStopped.getCount() > 0) {
- boolean changed = false;
-
- // Update devices.
- final MtpDeviceRecord[] devices = mManager.getDevices();
- try {
- mDatabase.getMapper().startAddingDocuments(null /* parentDocumentId */);
- for (final MtpDeviceRecord device : devices) {
- if (mDatabase.getMapper().putDeviceDocument(device)) {
- changed = true;
- }
- }
- if (mDatabase.getMapper().stopAddingDocuments(
- null /* parentDocumentId */)) {
- changed = true;
- }
- } catch (FileNotFoundException exception) {
- // The top root (ID is null) must exist always.
- // FileNotFoundException is unexpected.
- Log.e(MtpDocumentsProvider.TAG, "Unexpected FileNotFoundException", exception);
- throw new AssertionError("Unexpected exception for the top parent", exception);
- }
-
- // Update roots.
- for (final MtpDeviceRecord device : devices) {
- final String documentId = mDatabase.getDocumentIdForDevice(device.deviceId);
- if (documentId == null) {
- continue;
- }
- try {
- mDatabase.getMapper().startAddingDocuments(documentId);
- if (mDatabase.getMapper().putStorageDocuments(
- documentId, device.operationsSupported, device.roots)) {
- changed = true;
- }
- if (mDatabase.getMapper().stopAddingDocuments(documentId)) {
- changed = true;
- }
- } catch (FileNotFoundException exception) {
- Log.e(MtpDocumentsProvider.TAG, "Parent document is gone.", exception);
- continue;
- }
- }
-
- if (changed) {
- notifyChange();
- }
- mFirstScanCompleted.countDown();
- pollingCount++;
- if (devices.length == 0) {
- break;
- }
- try {
- // Use SHORT_POLLING_PERIOD for the first SHORT_POLLING_TIMES because it is
- // more likely to add new root just after the device is added.
- // TODO: Use short interval only for a device that is just added.
- mStopped.await(pollingCount > SHORT_POLLING_TIMES ?
- LONG_POLLING_INTERVAL : SHORT_POLLING_INTERVAL, TimeUnit.MILLISECONDS);
- } catch (InterruptedException exp) {
- break;
- }
- }
- }
-
- void stop() {
- mStopped.countDown();
- }
- }
-}
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/SendObjectInfoFailure.java b/packages/MtpDocumentsProvider/src/com/android/mtp/SendObjectInfoFailure.java
deleted file mode 100644
index db7d777..0000000
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/SendObjectInfoFailure.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.mtp;
-
-import java.io.IOException;
-
-/**
- * Exception thrown when sendObjectInfo failed.
- */
-class SendObjectInfoFailure extends IOException {
- SendObjectInfoFailure() {
- super("Failed to MtpDevice#sendObjectInfo.");
- }
-}
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/ServiceIntentSender.java b/packages/MtpDocumentsProvider/src/com/android/mtp/ServiceIntentSender.java
deleted file mode 100644
index 629f6df..0000000
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/ServiceIntentSender.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.mtp;
-
-import android.annotation.NonNull;
-import android.app.Notification;
-import android.app.NotificationChannel;
-import android.app.NotificationManager;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import com.android.internal.annotations.VisibleForTesting;
-import com.android.internal.util.Preconditions;
-
-/**
- * Sends intent to MtpDocumentsService.
- */
-class ServiceIntentSender {
- private final static String CHANNEL_ID = "device_notification_channel";
- private final Context mContext;
-
- ServiceIntentSender(Context context) {
- mContext = context;
-
- // Create notification channel.
- final NotificationChannel mChannel = new NotificationChannel(
- CHANNEL_ID,
- context.getResources().getString(
- com.android.internal.R.string.default_notification_channel_label),
- NotificationManager.IMPORTANCE_LOW);
- final NotificationManager notificationManager =
- (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
- notificationManager.createNotificationChannel(mChannel);
- }
-
- @VisibleForTesting
- protected ServiceIntentSender() {
- mContext = null;
- }
-
- /**
- * Notify the change of opened device set.
- * @param records List of opened devices. Can be empty.
- */
- void sendUpdateNotificationIntent(@NonNull MtpDeviceRecord[] records) {
- Preconditions.checkNotNull(records);
- final Intent intent = new Intent(MtpDocumentsService.ACTION_UPDATE_NOTIFICATION);
- intent.setComponent(new ComponentName(mContext, MtpDocumentsService.class));
- if (records.length != 0) {
- final int[] ids = new int[records.length];
- final Notification[] notifications = new Notification[records.length];
- for (int i = 0; i < records.length; i++) {
- ids[i] = records[i].deviceId;
- notifications[i] = createNotification(mContext, records[i]);
- }
- intent.putExtra(MtpDocumentsService.EXTRA_DEVICE_IDS, ids);
- intent.putExtra(MtpDocumentsService.EXTRA_DEVICE_NOTIFICATIONS, notifications);
- mContext.startForegroundService(intent);
- } else {
- mContext.startService(intent);
- }
- }
-
- private static Notification createNotification(Context context, MtpDeviceRecord device) {
- final String title = context.getResources().getString(
- R.string.accessing_notification_title,
- device.name);
- return new Notification.Builder(context, CHANNEL_ID)
- .setLocalOnly(true)
- .setContentTitle(title)
- .setSmallIcon(com.android.internal.R.drawable.stat_sys_data_usb)
- .setCategory(Notification.CATEGORY_SYSTEM)
- .setFlag(Notification.FLAG_NO_CLEAR, true)
- .build();
- }
-}
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/UsbIntentReceiver.java b/packages/MtpDocumentsProvider/src/com/android/mtp/UsbIntentReceiver.java
deleted file mode 100644
index 0489ea8..0000000
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/UsbIntentReceiver.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.mtp;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.hardware.usb.UsbDevice;
-import android.hardware.usb.UsbManager;
-import android.util.Log;
-
-import java.io.IOException;
-
-public class UsbIntentReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- final UsbDevice device = intent.getExtras().getParcelable(UsbManager.EXTRA_DEVICE);
- switch (intent.getAction()) {
- case UsbManager.ACTION_USB_DEVICE_ATTACHED:
- MtpDocumentsProvider.getInstance().resumeRootScanner();
- break;
- case UsbManager.ACTION_USB_DEVICE_DETACHED:
- try {
- MtpDocumentsProvider.getInstance().closeDevice(device.getDeviceId());
- } catch (IOException | InterruptedException e) {
- Log.e(MtpDocumentsProvider.TAG, "Failed to close device", e);
- }
- break;
- }
- }
-}
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/annotations/UsedByNative.java b/packages/MtpDocumentsProvider/src/com/android/mtp/annotations/UsedByNative.java
deleted file mode 100644
index 2ded925..0000000
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/annotations/UsedByNative.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.mtp.annotations;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Target;
-
-/**
- * Annotation that shows the method is used by JNI.
- */
-@Target({ElementType.METHOD, ElementType.FIELD})
-public @interface UsedByNative {
- /**
- * JNI file name that uses the method.
- */
- String value();
-}
diff --git a/packages/MtpDocumentsProvider/tests/Android.mk b/packages/MtpDocumentsProvider/tests/Android.mk
deleted file mode 100644
index 11daac3..0000000
--- a/packages/MtpDocumentsProvider/tests/Android.mk
+++ /dev/null
@@ -1,14 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_JAVA_LIBRARIES := android.test.runner android.test.base android.test.mock
-LOCAL_STATIC_JAVA_LIBRARIES := junit
-LOCAL_PACKAGE_NAME := MtpDocumentsProviderTests
-LOCAL_PRIVATE_PLATFORM_APIS := true
-LOCAL_INSTRUMENTATION_FOR := MtpDocumentsProvider
-LOCAL_CERTIFICATE := media
-LOCAL_COMPATIBILITY_SUITE := device-tests
-
-include $(BUILD_PACKAGE)
diff --git a/packages/MtpDocumentsProvider/tests/AndroidManifest.xml b/packages/MtpDocumentsProvider/tests/AndroidManifest.xml
deleted file mode 100644
index e1307e9..0000000
--- a/packages/MtpDocumentsProvider/tests/AndroidManifest.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.mtp.tests"
- android:sharedUserId="android.media">
-
- <application>
- <uses-library android:name="android.test.runner" />
- <activity android:name="com.android.mtp.TestResultActivity"
- android:screenOrientation="locked"
- android:launchMode="singleInstance">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
- <instrumentation android:name="com.android.mtp.TestResultInstrumentation"
- android:targetPackage="com.android.mtp"
- android:label="Tests for MtpDocumentsProvider with the UI for output." />
-</manifest>
diff --git a/packages/MtpDocumentsProvider/tests/AndroidTest.xml b/packages/MtpDocumentsProvider/tests/AndroidTest.xml
deleted file mode 100644
index f84131c..0000000
--- a/packages/MtpDocumentsProvider/tests/AndroidTest.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 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.
--->
-<configuration description="Runs Tests for MtpDocumentsProvider with the UI for output.">
- <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
- <option name="test-file-name" value="MtpDocumentsProviderTests.apk" />
- </target_preparer>
-
- <option name="test-suite-tag" value="apct" />
- <option name="test-tag" value="MtpDocumentsProviderTests" />
- <test class="com.android.tradefed.testtype.InstrumentationTest" >
- <option name="package" value="com.android.mtp.tests" />
- <option name="runner" value="com.android.mtp.TestResultInstrumentation" />
- <option name="hidden-api-checks" value="false"/>
- </test>
-</configuration>
diff --git a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/DocumentLoaderTest.java b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/DocumentLoaderTest.java
deleted file mode 100644
index a3c6bd7..0000000
--- a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/DocumentLoaderTest.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.mtp;
-
-import android.content.Context;
-import android.database.Cursor;
-import android.mtp.MtpObjectInfo;
-import android.net.Uri;
-import android.provider.DocumentsContract;
-import android.provider.DocumentsContract.Document;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeoutException;
-
-@MediumTest
-public class DocumentLoaderTest extends AndroidTestCase {
- private MtpDatabase mDatabase;
- private BlockableTestMtpManager mManager;
- private TestContentResolver mResolver;
- private DocumentLoader mLoader;
- final private Identifier mParentIdentifier = new Identifier(
- 0, 0, 0, "2", MtpDatabaseConstants.DOCUMENT_TYPE_STORAGE);
-
- @Override
- public void setUp() throws Exception {
- mDatabase = new MtpDatabase(getContext(), MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
-
- mDatabase.getMapper().startAddingDocuments(null);
- mDatabase.getMapper().putDeviceDocument(
- new MtpDeviceRecord(0, "Device", null, true, new MtpRoot[0], null, null));
- mDatabase.getMapper().stopAddingDocuments(null);
-
- mDatabase.getMapper().startAddingDocuments("1");
- mDatabase.getMapper().putStorageDocuments("1", new int[0], new MtpRoot[] {
- new MtpRoot(0, 0, "Storage", 1000, 1000, "")
- });
- mDatabase.getMapper().stopAddingDocuments("1");
-
- mManager = new BlockableTestMtpManager(getContext());
- mResolver = new TestContentResolver();
- }
-
- @Override
- public void tearDown() throws Exception {
- mLoader.close();
- mDatabase.close();
- }
-
- public void testBasic() throws Exception {
- setUpLoader();
-
- final Uri uri = DocumentsContract.buildChildDocumentsUri(
- MtpDocumentsProvider.AUTHORITY, mParentIdentifier.mDocumentId);
- setUpDocument(mManager, 40);
- mManager.blockDocument(0, 15);
- mManager.blockDocument(0, 35);
-
- {
- final Cursor cursor = mLoader.queryChildDocuments(
- MtpDocumentsProvider.DEFAULT_DOCUMENT_PROJECTION, mParentIdentifier);
- assertEquals(DocumentLoader.NUM_INITIAL_ENTRIES, cursor.getCount());
- }
-
- Thread.sleep(DocumentLoader.NOTIFY_PERIOD_MS);
- mManager.unblockDocument(0, 15);
- mResolver.waitForNotification(uri, 1);
-
- {
- final Cursor cursor = mLoader.queryChildDocuments(
- MtpDocumentsProvider.DEFAULT_DOCUMENT_PROJECTION, mParentIdentifier);
- assertEquals(
- DocumentLoader.NUM_INITIAL_ENTRIES + DocumentLoader.NUM_LOADING_ENTRIES,
- cursor.getCount());
- }
-
- mManager.unblockDocument(0, 35);
- mResolver.waitForNotification(uri, 2);
-
- {
- final Cursor cursor = mLoader.queryChildDocuments(
- MtpDocumentsProvider.DEFAULT_DOCUMENT_PROJECTION, mParentIdentifier);
- assertEquals(40, cursor.getCount());
- }
-
- assertEquals(2, mResolver.getChangeCount(uri));
- }
-
- public void testError_GetObjectHandles() throws Exception {
- mManager = new BlockableTestMtpManager(getContext()) {
- @Override
- int[] getObjectHandles(int deviceId, int storageId, int parentObjectHandle)
- throws IOException {
- throw new IOException();
- }
- };
- setUpLoader();
- mManager.setObjectHandles(0, 0, MtpManager.OBJECT_HANDLE_ROOT_CHILDREN, null);
- try {
- try (final Cursor cursor = mLoader.queryChildDocuments(
- MtpDocumentsProvider.DEFAULT_DOCUMENT_PROJECTION, mParentIdentifier)) {}
- fail();
- } catch (IOException exception) {
- // Expect exception.
- }
- }
-
- public void testError_GetObjectInfo() throws Exception {
- mManager = new BlockableTestMtpManager(getContext()) {
- @Override
- MtpObjectInfo getObjectInfo(int deviceId, int objectHandle) throws IOException {
- if (objectHandle == DocumentLoader.NUM_INITIAL_ENTRIES) {
- throw new IOException();
- } else {
- return super.getObjectInfo(deviceId, objectHandle);
- }
- }
- };
- setUpLoader();
- setUpDocument(mManager, DocumentLoader.NUM_INITIAL_ENTRIES);
- try (final Cursor cursor = mLoader.queryChildDocuments(
- MtpDocumentsProvider.DEFAULT_DOCUMENT_PROJECTION, mParentIdentifier)) {
- // Even if MtpManager returns an error for a document, loading must complete.
- assertFalse(cursor.getExtras().getBoolean(DocumentsContract.EXTRA_LOADING));
- }
- }
-
- public void testCancelTask() throws IOException, InterruptedException, TimeoutException {
- setUpDocument(mManager,
- DocumentLoader.NUM_INITIAL_ENTRIES + 1);
-
- // Block the first iteration in the background thread.
- mManager.blockDocument(
- 0, DocumentLoader.NUM_INITIAL_ENTRIES + 1);
- setUpLoader();
- try (final Cursor cursor = mLoader.queryChildDocuments(
- MtpDocumentsProvider.DEFAULT_DOCUMENT_PROJECTION, mParentIdentifier)) {
- assertTrue(cursor.getExtras().getBoolean(DocumentsContract.EXTRA_LOADING));
- }
-
- final Uri uri = DocumentsContract.buildChildDocumentsUri(
- MtpDocumentsProvider.AUTHORITY, mParentIdentifier.mDocumentId);
- assertEquals(0, mResolver.getChangeCount(uri));
-
- // Clear task while the first iteration is being blocked.
- mLoader.cancelTask(mParentIdentifier);
- mManager.unblockDocument(
- 0, DocumentLoader.NUM_INITIAL_ENTRIES + 1);
- Thread.sleep(DocumentLoader.NOTIFY_PERIOD_MS);
- assertEquals(0, mResolver.getChangeCount(uri));
-
- // Check if it's OK to query invalidated task.
- try (final Cursor cursor = mLoader.queryChildDocuments(
- MtpDocumentsProvider.DEFAULT_DOCUMENT_PROJECTION, mParentIdentifier)) {
- assertTrue(cursor.getExtras().getBoolean(DocumentsContract.EXTRA_LOADING));
- }
- mResolver.waitForNotification(uri, 1);
- }
-
- private void setUpLoader() {
- mLoader = new DocumentLoader(
- new MtpDeviceRecord(
- 0, "Device", "Key", true, new MtpRoot[0],
- TestUtil.OPERATIONS_SUPPORTED, new int[0]),
- mManager,
- mResolver,
- mDatabase);
- }
-
- private void setUpDocument(TestMtpManager manager, int count) {
- int[] childDocuments = new int[count];
- for (int i = 0; i < childDocuments.length; i++) {
- final int objectHandle = i + 1;
- childDocuments[i] = objectHandle;
- manager.setObjectInfo(0, new MtpObjectInfo.Builder()
- .setObjectHandle(objectHandle)
- .setName(Integer.toString(i))
- .build());
- }
- manager.setObjectHandles(0, 0, MtpManager.OBJECT_HANDLE_ROOT_CHILDREN, childDocuments);
- }
-
- private static class BlockableTestMtpManager extends TestMtpManager {
- final private Map<String, CountDownLatch> blockedDocuments = new HashMap<>();
-
- BlockableTestMtpManager(Context context) {
- super(context);
- }
-
- void blockDocument(int deviceId, int objectHandle) {
- blockedDocuments.put(pack(deviceId, objectHandle), new CountDownLatch(1));
- }
-
- void unblockDocument(int deviceId, int objectHandle) {
- blockedDocuments.get(pack(deviceId, objectHandle)).countDown();
- }
-
- @Override
- MtpObjectInfo getObjectInfo(int deviceId, int objectHandle) throws IOException {
- final CountDownLatch latch = blockedDocuments.get(pack(deviceId, objectHandle));
- if (latch != null) {
- try {
- latch.await();
- } catch(InterruptedException e) {
- fail();
- }
- }
- return super.getObjectInfo(deviceId, objectHandle);
- }
- }
-}
diff --git a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/MtpDatabaseTest.java b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/MtpDatabaseTest.java
deleted file mode 100644
index 32b169e..0000000
--- a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/MtpDatabaseTest.java
+++ /dev/null
@@ -1,1133 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.mtp;
-
-import android.database.Cursor;
-import android.media.MediaFile;
-import android.media.MediaFile.MediaFileType;
-import android.mtp.MtpConstants;
-import android.mtp.MtpObjectInfo;
-import android.net.Uri;
-import android.provider.DocumentsContract;
-import android.provider.DocumentsContract.Document;
-import android.provider.DocumentsContract.Root;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-
-import java.io.FileNotFoundException;
-import java.util.Arrays;
-
-import static android.provider.DocumentsContract.Document.*;
-import static com.android.mtp.MtpDatabase.strings;
-import static com.android.mtp.MtpDatabaseConstants.*;
-import static com.android.mtp.TestUtil.OPERATIONS_SUPPORTED;
-
-@SmallTest
-public class MtpDatabaseTest extends AndroidTestCase {
- private static final String[] COLUMN_NAMES = new String[] {
- DocumentsContract.Document.COLUMN_DOCUMENT_ID,
- MtpDatabaseConstants.COLUMN_DEVICE_ID,
- MtpDatabaseConstants.COLUMN_STORAGE_ID,
- MtpDatabaseConstants.COLUMN_OBJECT_HANDLE,
- DocumentsContract.Document.COLUMN_MIME_TYPE,
- DocumentsContract.Document.COLUMN_DISPLAY_NAME,
- DocumentsContract.Document.COLUMN_SUMMARY,
- DocumentsContract.Document.COLUMN_LAST_MODIFIED,
- DocumentsContract.Document.COLUMN_ICON,
- DocumentsContract.Document.COLUMN_FLAGS,
- DocumentsContract.Document.COLUMN_SIZE,
- MtpDatabaseConstants.COLUMN_DOCUMENT_TYPE
- };
-
- private final TestResources resources = new TestResources();
- MtpDatabase mDatabase;
-
- @Override
- public void setUp() {
- mDatabase = new MtpDatabase(getContext(), MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- }
-
- @Override
- public void tearDown() {
- mDatabase.close();
- mDatabase = null;
- }
-
- private static int getInt(Cursor cursor, String columnName) {
- return cursor.getInt(cursor.getColumnIndex(columnName));
- }
-
- private static boolean isNull(Cursor cursor, String columnName) {
- return cursor.isNull(cursor.getColumnIndex(columnName));
- }
-
- private static String getString(Cursor cursor, String columnName) {
- return cursor.getString(cursor.getColumnIndex(columnName));
- }
-
- public void testPutSingleStorageDocuments() throws Exception {
- addTestDevice();
-
- mDatabase.getMapper().startAddingDocuments("1");
- mDatabase.getMapper().putStorageDocuments("1", OPERATIONS_SUPPORTED, new MtpRoot[] {
- new MtpRoot(0, 1, "Storage", 1000, 2000, "")
- });
- mDatabase.getMapper().stopAddingDocuments("1");
-
- {
- final Cursor cursor = mDatabase.queryRootDocuments(COLUMN_NAMES);
- assertEquals(1, cursor.getCount());
-
- cursor.moveToNext();
- assertEquals(2, getInt(cursor, COLUMN_DOCUMENT_ID));
- assertEquals(0, getInt(cursor, COLUMN_DEVICE_ID));
- assertEquals(1, getInt(cursor, COLUMN_STORAGE_ID));
- assertTrue(isNull(cursor, COLUMN_OBJECT_HANDLE));
- assertEquals(
- DocumentsContract.Document.MIME_TYPE_DIR, getString(cursor, COLUMN_MIME_TYPE));
- assertEquals("Storage", getString(cursor, COLUMN_DISPLAY_NAME));
- assertTrue(isNull(cursor, COLUMN_SUMMARY));
- assertTrue(isNull(cursor, COLUMN_LAST_MODIFIED));
- assertEquals(R.drawable.ic_root_mtp, getInt(cursor, COLUMN_ICON));
- assertEquals(Document.FLAG_DIR_SUPPORTS_CREATE, getInt(cursor, COLUMN_FLAGS));
- assertEquals(1000, getInt(cursor, COLUMN_SIZE));
- assertEquals(
- MtpDatabaseConstants.DOCUMENT_TYPE_STORAGE,
- getInt(cursor, COLUMN_DOCUMENT_TYPE));
-
- cursor.close();
- }
-
- {
- final Cursor cursor = mDatabase.queryRoots(resources, new String [] {
- Root.COLUMN_ROOT_ID,
- Root.COLUMN_FLAGS,
- Root.COLUMN_ICON,
- Root.COLUMN_TITLE,
- Root.COLUMN_SUMMARY,
- Root.COLUMN_DOCUMENT_ID,
- Root.COLUMN_AVAILABLE_BYTES,
- Root.COLUMN_CAPACITY_BYTES
- });
- assertEquals(1, cursor.getCount());
-
- cursor.moveToNext();
- assertEquals(1, getInt(cursor, Root.COLUMN_ROOT_ID));
- assertEquals(
- Root.FLAG_SUPPORTS_IS_CHILD | Root.FLAG_SUPPORTS_CREATE | Root.FLAG_LOCAL_ONLY,
- getInt(cursor, Root.COLUMN_FLAGS));
- assertEquals(R.drawable.ic_root_mtp, getInt(cursor, Root.COLUMN_ICON));
- assertEquals("Device Storage", getString(cursor, Root.COLUMN_TITLE));
- assertTrue(isNull(cursor, Root.COLUMN_SUMMARY));
- assertEquals(1, getInt(cursor, Root.COLUMN_DOCUMENT_ID));
- assertEquals(1000, getInt(cursor, Root.COLUMN_AVAILABLE_BYTES));
- assertEquals(2000, getInt(cursor, Root.COLUMN_CAPACITY_BYTES));
-
- cursor.close();
- }
- }
-
- public void testPutStorageDocuments() throws Exception {
- addTestDevice();
-
- mDatabase.getMapper().startAddingDocuments("1");
- mDatabase.getMapper().putStorageDocuments("1", OPERATIONS_SUPPORTED, new MtpRoot[] {
- new MtpRoot(0, 1, "Storage", 1000, 2000, ""),
- new MtpRoot(0, 2, "Storage", 2000, 4000, ""),
- new MtpRoot(0, 3, "/@#%&<>Storage", 3000, 6000,"")
- });
-
- {
- final Cursor cursor = mDatabase.queryRootDocuments(COLUMN_NAMES);
- assertEquals(3, cursor.getCount());
-
- cursor.moveToNext();
- assertEquals(2, getInt(cursor, COLUMN_DOCUMENT_ID));
- assertEquals(0, getInt(cursor, COLUMN_DEVICE_ID));
- assertEquals(1, getInt(cursor, COLUMN_STORAGE_ID));
- assertTrue(isNull(cursor, COLUMN_OBJECT_HANDLE));
- assertEquals(DocumentsContract.Document.MIME_TYPE_DIR, getString(cursor, COLUMN_MIME_TYPE));
- assertEquals("Storage", getString(cursor, COLUMN_DISPLAY_NAME));
- assertTrue(isNull(cursor, COLUMN_SUMMARY));
- assertTrue(isNull(cursor, COLUMN_LAST_MODIFIED));
- assertEquals(R.drawable.ic_root_mtp, getInt(cursor, COLUMN_ICON));
- assertEquals(Document.FLAG_DIR_SUPPORTS_CREATE, getInt(cursor, COLUMN_FLAGS));
- assertEquals(1000, getInt(cursor, COLUMN_SIZE));
- assertEquals(
- MtpDatabaseConstants.DOCUMENT_TYPE_STORAGE, getInt(cursor, COLUMN_DOCUMENT_TYPE));
-
- cursor.moveToNext();
- assertEquals(3, getInt(cursor, COLUMN_DOCUMENT_ID));
- assertEquals("Storage", getString(cursor, COLUMN_DISPLAY_NAME));
-
- cursor.moveToNext();
- assertEquals(4, getInt(cursor, COLUMN_DOCUMENT_ID));
- assertEquals("/@#%&<>Storage", getString(cursor, COLUMN_DISPLAY_NAME));
-
- cursor.close();
- }
- }
-
- private MtpObjectInfo createDocument(int objectHandle, String name, int format, int size) {
- final MtpObjectInfo.Builder builder = new MtpObjectInfo.Builder();
- builder.setObjectHandle(objectHandle);
- builder.setName(name);
- builder.setFormat(format);
- builder.setCompressedSize(size);
- return builder.build();
- }
-
- public void testPutChildDocuments() throws Exception {
- addTestDevice();
- addTestStorage("1");
-
- mDatabase.getMapper().startAddingDocuments("2");
- mDatabase.getMapper().putChildDocuments(0, "2", OPERATIONS_SUPPORTED, new MtpObjectInfo[] {
- createDocument(100, "note.txt", MtpConstants.FORMAT_TEXT, 1024),
- createDocument(101, "image.jpg", MtpConstants.FORMAT_EXIF_JPEG, 2 * 1024 * 1024),
- createDocument(102, "music.mp3", MtpConstants.FORMAT_MP3, 3 * 1024 * 1024)
- }, new long[] { 1024L, 2L * 1024L * 1024L, 3L * 1024L * 1024L});
-
- final Cursor cursor = mDatabase.queryChildDocuments(COLUMN_NAMES, "2");
- assertEquals(3, cursor.getCount());
-
- cursor.moveToNext();
- assertEquals(3, getInt(cursor, COLUMN_DOCUMENT_ID));
- assertEquals(0, getInt(cursor, COLUMN_DEVICE_ID));
- assertEquals(0, getInt(cursor, COLUMN_STORAGE_ID));
- assertEquals(100, getInt(cursor, COLUMN_OBJECT_HANDLE));
- assertEquals("text/plain", getString(cursor, COLUMN_MIME_TYPE));
- assertEquals("note.txt", getString(cursor, COLUMN_DISPLAY_NAME));
- assertTrue(isNull(cursor, COLUMN_SUMMARY));
- assertTrue(isNull(cursor, COLUMN_LAST_MODIFIED));
- assertTrue(isNull(cursor, COLUMN_ICON));
- assertEquals(
- COLUMN_FLAGS,
- DocumentsContract.Document.FLAG_SUPPORTS_DELETE |
- DocumentsContract.Document.FLAG_SUPPORTS_WRITE,
- cursor.getInt(9));
- assertEquals(1024, getInt(cursor, COLUMN_SIZE));
- assertEquals(
- MtpDatabaseConstants.DOCUMENT_TYPE_OBJECT, getInt(cursor, COLUMN_DOCUMENT_TYPE));
-
- cursor.moveToNext();
- assertEquals(4, getInt(cursor, COLUMN_DOCUMENT_ID));
- assertEquals(0, getInt(cursor, COLUMN_DEVICE_ID));
- assertEquals(0, getInt(cursor, COLUMN_STORAGE_ID));
- assertEquals(101, getInt(cursor, COLUMN_OBJECT_HANDLE));
- assertEquals("image/jpeg", getString(cursor, COLUMN_MIME_TYPE));
- assertEquals("image.jpg", getString(cursor, COLUMN_DISPLAY_NAME));
- assertTrue(isNull(cursor, COLUMN_SUMMARY));
- assertTrue(isNull(cursor, COLUMN_LAST_MODIFIED));
- assertTrue(isNull(cursor, COLUMN_ICON));
- assertEquals(
- COLUMN_FLAGS,
- DocumentsContract.Document.FLAG_SUPPORTS_DELETE |
- DocumentsContract.Document.FLAG_SUPPORTS_WRITE |
- DocumentsContract.Document.FLAG_SUPPORTS_METADATA,
- cursor.getInt(9));
- assertEquals(2 * 1024 * 1024, getInt(cursor, COLUMN_SIZE));
- assertEquals(
- MtpDatabaseConstants.DOCUMENT_TYPE_OBJECT, getInt(cursor, COLUMN_DOCUMENT_TYPE));
-
- cursor.moveToNext();
- assertEquals(5, getInt(cursor, COLUMN_DOCUMENT_ID));
- assertEquals(0, getInt(cursor, COLUMN_DEVICE_ID));
- assertEquals(0, getInt(cursor, COLUMN_STORAGE_ID));
- assertEquals(102, getInt(cursor, COLUMN_OBJECT_HANDLE));
- assertEquals("audio/mpeg", getString(cursor, COLUMN_MIME_TYPE));
- assertEquals("music.mp3", getString(cursor, COLUMN_DISPLAY_NAME));
- assertTrue(isNull(cursor, COLUMN_SUMMARY));
- assertTrue(isNull(cursor, COLUMN_LAST_MODIFIED));
- assertTrue(isNull(cursor, COLUMN_ICON));
- assertEquals(
- COLUMN_FLAGS,
- DocumentsContract.Document.FLAG_SUPPORTS_DELETE |
- DocumentsContract.Document.FLAG_SUPPORTS_WRITE,
- cursor.getInt(9));
- assertEquals(3 * 1024 * 1024, getInt(cursor, COLUMN_SIZE));
- assertEquals(
- MtpDatabaseConstants.DOCUMENT_TYPE_OBJECT, getInt(cursor, COLUMN_DOCUMENT_TYPE));
-
- cursor.close();
- }
-
- public void testPutChildDocuments_operationsSupported() throws Exception {
- addTestDevice();
- addTestStorage("1");
-
- // Put a document with empty supported operations.
- mDatabase.getMapper().startAddingDocuments("2");
- mDatabase.getMapper().putChildDocuments(0, "2", new int[0], new MtpObjectInfo[] {
- createDocument(100, "note.txt", MtpConstants.FORMAT_TEXT, 1024)
- }, new long[] { 1024L });
- mDatabase.getMapper().stopAddingDocuments("2");
-
- try (final Cursor cursor =
- mDatabase.queryChildDocuments(strings(Document.COLUMN_FLAGS), "2")) {
- assertEquals(1, cursor.getCount());
- cursor.moveToNext();
- assertEquals(0, cursor.getInt(0));
- }
-
- // Put a document with writable operations.
- mDatabase.getMapper().startAddingDocuments("2");
- mDatabase.getMapper().putChildDocuments(0, "2", new int[] {
- MtpConstants.OPERATION_SEND_OBJECT,
- MtpConstants.OPERATION_SEND_OBJECT_INFO,
- }, new MtpObjectInfo[] {
- createDocument(100, "note.txt", MtpConstants.FORMAT_TEXT, 1024)
- }, new long[] { 1024L });
- mDatabase.getMapper().stopAddingDocuments("2");
-
- try (final Cursor cursor =
- mDatabase.queryChildDocuments(strings(Document.COLUMN_FLAGS), "2")) {
- assertEquals(1, cursor.getCount());
- cursor.moveToNext();
- assertEquals(Document.FLAG_SUPPORTS_WRITE, cursor.getInt(0));
- }
-
- // Put a document with deletable operations.
- mDatabase.getMapper().startAddingDocuments("2");
- mDatabase.getMapper().putChildDocuments(0, "2", new int[] {
- MtpConstants.OPERATION_DELETE_OBJECT
- }, new MtpObjectInfo[] {
- createDocument(100, "note.txt", MtpConstants.FORMAT_TEXT, 1024)
- }, new long[] { 1024L });
- mDatabase.getMapper().stopAddingDocuments("2");
-
- try (final Cursor cursor =
- mDatabase.queryChildDocuments(strings(Document.COLUMN_FLAGS), "2")) {
- assertEquals(1, cursor.getCount());
- cursor.moveToNext();
- assertEquals(Document.FLAG_SUPPORTS_DELETE, cursor.getInt(0));
- }
- }
-
- public void testRestoreIdForRootDocuments() throws Exception {
- final String[] columns = new String[] {
- DocumentsContract.Document.COLUMN_DOCUMENT_ID,
- MtpDatabaseConstants.COLUMN_STORAGE_ID,
- DocumentsContract.Document.COLUMN_DISPLAY_NAME
- };
-
- // Add device and two storages.
- addTestDevice();
- mDatabase.getMapper().startAddingDocuments("1");
- mDatabase.getMapper().putStorageDocuments("1", OPERATIONS_SUPPORTED, new MtpRoot[] {
- new MtpRoot(0, 100, "Storage A", 1000, 0, ""),
- new MtpRoot(0, 101, "Storage B", 1001, 0, "")
- });
-
- {
- final Cursor cursor = mDatabase.queryRootDocuments(columns);
- assertEquals(2, cursor.getCount());
- cursor.moveToNext();
- assertEquals(2, getInt(cursor, COLUMN_DOCUMENT_ID));
- assertEquals(100, getInt(cursor, COLUMN_STORAGE_ID));
- assertEquals("Storage A", getString(cursor, COLUMN_DISPLAY_NAME));
- cursor.moveToNext();
- assertEquals(3, getInt(cursor, COLUMN_DOCUMENT_ID));
- assertEquals(101, getInt(cursor, COLUMN_STORAGE_ID));
- assertEquals("Storage B", getString(cursor, COLUMN_DISPLAY_NAME));
- cursor.close();
- }
-
- // Clear mapping and add a device.
- mDatabase.getMapper().clearMapping();
- addTestDevice();
-
- {
- final Cursor cursor = mDatabase.queryRootDocuments(columns);
- assertEquals(0, cursor.getCount());
- cursor.close();
- }
-
- // Add two storages, but one's name is different from previous one.
- mDatabase.getMapper().startAddingDocuments("1");
- mDatabase.getMapper().putStorageDocuments("1", OPERATIONS_SUPPORTED, new MtpRoot[] {
- new MtpRoot(0, 200, "Storage A", 2000, 0, ""),
- new MtpRoot(0, 202, "Storage C", 2002, 0, "")
- });
- mDatabase.getMapper().stopAddingDocuments("1");
-
- {
- // After compeleting mapping, Storage A can be obtained with new storage ID.
- final Cursor cursor = mDatabase.queryRootDocuments(columns);
- assertEquals(2, cursor.getCount());
- cursor.moveToNext();
- assertEquals(2, getInt(cursor, COLUMN_DOCUMENT_ID));
- assertEquals(200, getInt(cursor, COLUMN_STORAGE_ID));
- assertEquals("Storage A", getString(cursor, COLUMN_DISPLAY_NAME));
- cursor.moveToNext();
- assertEquals(4, getInt(cursor, COLUMN_DOCUMENT_ID));
- assertEquals(202, getInt(cursor, COLUMN_STORAGE_ID));
- assertEquals("Storage C", getString(cursor, COLUMN_DISPLAY_NAME));
- cursor.close();
- }
- }
-
- public void testRestoreIdForChildDocuments() throws Exception {
- final String[] columns = new String[] {
- DocumentsContract.Document.COLUMN_DOCUMENT_ID,
- MtpDatabaseConstants.COLUMN_OBJECT_HANDLE,
- DocumentsContract.Document.COLUMN_DISPLAY_NAME
- };
-
- addTestDevice();
- addTestStorage("1");
-
- mDatabase.getMapper().startAddingDocuments("2");
- mDatabase.getMapper().putChildDocuments(0, "2", OPERATIONS_SUPPORTED, new MtpObjectInfo[] {
- createDocument(100, "note.txt", MtpConstants.FORMAT_TEXT, 1024),
- createDocument(101, "image.jpg", MtpConstants.FORMAT_EXIF_JPEG, 2 * 1024 * 1024),
- createDocument(102, "music.mp3", MtpConstants.FORMAT_MP3, 3 * 1024 * 1024)
- }, new long[] { 1024L, 2L * 1024L * 1024L, 3L * 1024L * 1024L});
- mDatabase.getMapper().clearMapping();
-
- addTestDevice();
- addTestStorage("1");
-
- {
- // Don't return objects that lost MTP object handles.
- final Cursor cursor = mDatabase.queryChildDocuments(columns, "2");
- assertEquals(0, cursor.getCount());
- cursor.close();
- }
-
- mDatabase.getMapper().startAddingDocuments("2");
- mDatabase.getMapper().putChildDocuments(0, "2", OPERATIONS_SUPPORTED, new MtpObjectInfo[] {
- createDocument(200, "note.txt", MtpConstants.FORMAT_TEXT, 1024),
- createDocument(203, "video.mp4", MtpConstants.FORMAT_MP4_CONTAINER, 1024),
- }, new long[] { 1024L, 1024L });
- mDatabase.getMapper().stopAddingDocuments("2");
-
- {
- final Cursor cursor = mDatabase.queryChildDocuments(columns, "2");
- assertEquals(2, cursor.getCount());
-
- cursor.moveToNext();
- assertEquals(3, getInt(cursor, COLUMN_DOCUMENT_ID));
- assertEquals(200, getInt(cursor, COLUMN_OBJECT_HANDLE));
- assertEquals("note.txt", getString(cursor, COLUMN_DISPLAY_NAME));
-
- cursor.moveToNext();
- assertEquals(6, getInt(cursor, COLUMN_DOCUMENT_ID));
- assertEquals(203, getInt(cursor, COLUMN_OBJECT_HANDLE));
- assertEquals("video.mp4", getString(cursor, COLUMN_DISPLAY_NAME));
-
- cursor.close();
- }
- }
-
- public void testRestoreIdForDifferentDevices() throws Exception {
- final String[] columns = new String[] {
- DocumentsContract.Document.COLUMN_DOCUMENT_ID,
- MtpDatabaseConstants.COLUMN_STORAGE_ID,
- DocumentsContract.Document.COLUMN_DISPLAY_NAME
- };
- final String[] rootColumns = new String[] {
- Root.COLUMN_ROOT_ID,
- Root.COLUMN_AVAILABLE_BYTES
- };
- mDatabase.getMapper().startAddingDocuments(null);
- mDatabase.getMapper().putDeviceDocument(new MtpDeviceRecord(
- 0, "Device A", "Device key A", true, new MtpRoot[0], null, null));
- mDatabase.getMapper().putDeviceDocument(new MtpDeviceRecord(
- 1, "Device B", "Device key B", true, new MtpRoot[0], null, null));
- mDatabase.getMapper().stopAddingDocuments(null);
-
- mDatabase.getMapper().startAddingDocuments("1");
- mDatabase.getMapper().startAddingDocuments("2");
- mDatabase.getMapper().putStorageDocuments("1", OPERATIONS_SUPPORTED, new MtpRoot[] {
- new MtpRoot(0, 100, "Storage", 0, 0, "")
- });
- mDatabase.getMapper().putStorageDocuments("2", OPERATIONS_SUPPORTED, new MtpRoot[] {
- new MtpRoot(1, 100, "Storage", 0, 0, "")
- });
-
- {
- final Cursor cursor = mDatabase.queryRootDocuments(columns);
- assertEquals(2, cursor.getCount());
- cursor.moveToNext();
- assertEquals(3, getInt(cursor, COLUMN_DOCUMENT_ID));
- assertEquals(100, getInt(cursor, COLUMN_STORAGE_ID));
- assertEquals("Storage", getString(cursor, COLUMN_DISPLAY_NAME));
- cursor.moveToNext();
- assertEquals(4, getInt(cursor, COLUMN_DOCUMENT_ID));
- assertEquals(100, getInt(cursor, COLUMN_STORAGE_ID));
- assertEquals("Storage", getString(cursor, COLUMN_DISPLAY_NAME));
- cursor.close();
- }
-
- {
- final Cursor cursor = mDatabase.queryRoots(resources, rootColumns);
- assertEquals(2, cursor.getCount());
- cursor.moveToNext();
- assertEquals(1, getInt(cursor, Root.COLUMN_ROOT_ID));
- assertEquals(0, getInt(cursor, Root.COLUMN_AVAILABLE_BYTES));
- cursor.moveToNext();
- assertEquals(2, getInt(cursor, Root.COLUMN_ROOT_ID));
- assertEquals(0, getInt(cursor, Root.COLUMN_AVAILABLE_BYTES));
- cursor.close();
- }
-
- mDatabase.getMapper().clearMapping();
-
- mDatabase.getMapper().startAddingDocuments(null);
- mDatabase.getMapper().putDeviceDocument(new MtpDeviceRecord(
- 0, "Device A", "Device key A", true, new MtpRoot[0], null, null));
- mDatabase.getMapper().putDeviceDocument(new MtpDeviceRecord(
- 1, "Device B", "Device key B", true, new MtpRoot[0], null, null));
- mDatabase.getMapper().stopAddingDocuments(null);
-
- mDatabase.getMapper().startAddingDocuments("1");
- mDatabase.getMapper().startAddingDocuments("2");
- mDatabase.getMapper().putStorageDocuments("1", OPERATIONS_SUPPORTED, new MtpRoot[] {
- new MtpRoot(0, 200, "Storage", 2000, 0, "")
- });
- mDatabase.getMapper().putStorageDocuments("2", OPERATIONS_SUPPORTED, new MtpRoot[] {
- new MtpRoot(1, 300, "Storage", 3000, 0, "")
- });
- mDatabase.getMapper().stopAddingDocuments("1");
- mDatabase.getMapper().stopAddingDocuments("2");
-
- {
- final Cursor cursor = mDatabase.queryRootDocuments(columns);
- assertEquals(2, cursor.getCount());
- cursor.moveToNext();
- assertEquals(3, getInt(cursor, COLUMN_DOCUMENT_ID));
- assertEquals(200, getInt(cursor, COLUMN_STORAGE_ID));
- assertEquals("Storage", getString(cursor, COLUMN_DISPLAY_NAME));
- cursor.moveToNext();
- assertEquals(4, getInt(cursor, COLUMN_DOCUMENT_ID));
- assertEquals(300, getInt(cursor, COLUMN_STORAGE_ID));
- assertEquals("Storage", getString(cursor, COLUMN_DISPLAY_NAME));
- cursor.close();
- }
-
- {
- final Cursor cursor = mDatabase.queryRoots(resources, rootColumns);
- assertEquals(2, cursor.getCount());
- cursor.moveToNext();
- assertEquals(1, getInt(cursor, Root.COLUMN_ROOT_ID));
- assertEquals(2000, getInt(cursor, Root.COLUMN_AVAILABLE_BYTES));
- cursor.moveToNext();
- assertEquals(2, getInt(cursor, Root.COLUMN_ROOT_ID));
- assertEquals(3000, getInt(cursor, Root.COLUMN_AVAILABLE_BYTES));
- cursor.close();
- }
- }
-
- public void testRestoreIdForDifferentParents() throws Exception {
- final String[] columns = new String[] {
- DocumentsContract.Document.COLUMN_DOCUMENT_ID,
- MtpDatabaseConstants.COLUMN_OBJECT_HANDLE
- };
-
- // Add device, storage, and two directories.
- addTestDevice();
- addTestStorage("1");
- mDatabase.getMapper().startAddingDocuments("2");
- mDatabase.getMapper().putChildDocuments(0, "2", OPERATIONS_SUPPORTED, new MtpObjectInfo[] {
- createDocument(50, "A", MtpConstants.FORMAT_ASSOCIATION, 0),
- createDocument(51, "B", MtpConstants.FORMAT_ASSOCIATION, 0),
- }, new long[] { 0L, 0L });
- mDatabase.getMapper().stopAddingDocuments("2");
-
- // Put note.txt in each directory.
- mDatabase.getMapper().startAddingDocuments("3");
- mDatabase.getMapper().startAddingDocuments("4");
- mDatabase.getMapper().putChildDocuments(0, "3", OPERATIONS_SUPPORTED, new MtpObjectInfo[] {
- createDocument(100, "note.txt", MtpConstants.FORMAT_TEXT, 1024),
- }, new long[] { 1024L });
- mDatabase.getMapper().putChildDocuments(0, "4", OPERATIONS_SUPPORTED, new MtpObjectInfo[] {
- createDocument(101, "note.txt", MtpConstants.FORMAT_TEXT, 1024),
- }, new long[] { 1024L });
-
- // Clear mapping.
- mDatabase.getMapper().clearMapping();
-
- // Add device, storage, and two directories again.
- addTestDevice();
- addTestStorage("1");
- mDatabase.getMapper().startAddingDocuments("2");
- mDatabase.getMapper().putChildDocuments(0, "2", OPERATIONS_SUPPORTED, new MtpObjectInfo[] {
- createDocument(50, "A", MtpConstants.FORMAT_ASSOCIATION, 0),
- createDocument(51, "B", MtpConstants.FORMAT_ASSOCIATION, 0),
- }, new long[] { 0L, 0L });
- mDatabase.getMapper().stopAddingDocuments("2");
-
- // Add note.txt in each directory again.
- mDatabase.getMapper().startAddingDocuments("3");
- mDatabase.getMapper().startAddingDocuments("4");
- mDatabase.getMapper().putChildDocuments(0, "3", OPERATIONS_SUPPORTED, new MtpObjectInfo[] {
- createDocument(200, "note.txt", MtpConstants.FORMAT_TEXT, 1024),
- }, new long[] { 1024L });
- mDatabase.getMapper().putChildDocuments(0, "4", OPERATIONS_SUPPORTED, new MtpObjectInfo[] {
- createDocument(201, "note.txt", MtpConstants.FORMAT_TEXT, 1024),
- }, new long[] { 1024L });
- mDatabase.getMapper().stopAddingDocuments("3");
- mDatabase.getMapper().stopAddingDocuments("4");
-
- // Check if the two note.txt are mapped correctly.
- {
- final Cursor cursor = mDatabase.queryChildDocuments(columns, "3");
- assertEquals(1, cursor.getCount());
- cursor.moveToNext();
- assertEquals(5, getInt(cursor, COLUMN_DOCUMENT_ID));
- assertEquals(200, getInt(cursor, COLUMN_OBJECT_HANDLE));
- cursor.close();
- }
- {
- final Cursor cursor = mDatabase.queryChildDocuments(columns, "4");
- assertEquals(1, cursor.getCount());
- cursor.moveToNext();
- assertEquals(6, getInt(cursor, COLUMN_DOCUMENT_ID));
- assertEquals(201, getInt(cursor, COLUMN_OBJECT_HANDLE));
- cursor.close();
- }
- }
-
- public void testClearMtpIdentifierBeforeResolveRootDocuments() throws Exception {
- final String[] columns = new String[] {
- DocumentsContract.Document.COLUMN_DOCUMENT_ID,
- MtpDatabaseConstants.COLUMN_STORAGE_ID,
- DocumentsContract.Document.COLUMN_DISPLAY_NAME
- };
- final String[] rootColumns = new String[] {
- Root.COLUMN_ROOT_ID,
- Root.COLUMN_AVAILABLE_BYTES
- };
-
- addTestDevice();
-
- mDatabase.getMapper().startAddingDocuments("1");
- mDatabase.getMapper().putStorageDocuments("1", OPERATIONS_SUPPORTED, new MtpRoot[] {
- new MtpRoot(0, 100, "Storage", 0, 0, ""),
- });
- mDatabase.getMapper().clearMapping();
-
- addTestDevice();
-
- try (final Cursor cursor = mDatabase.queryRoots(resources, rootColumns)) {
- assertEquals(1, cursor.getCount());
- cursor.moveToNext();
- assertEquals("1", getString(cursor, Root.COLUMN_ROOT_ID));
- }
-
- mDatabase.getMapper().startAddingDocuments("1");
- mDatabase.getMapper().putStorageDocuments("1", OPERATIONS_SUPPORTED, new MtpRoot[] {
- new MtpRoot(0, 200, "Storage", 2000, 0, ""),
- });
- mDatabase.getMapper().clearMapping();
-
- addTestDevice();
-
- mDatabase.getMapper().startAddingDocuments("1");
- mDatabase.getMapper().putStorageDocuments("1", OPERATIONS_SUPPORTED, new MtpRoot[] {
- new MtpRoot(0, 300, "Storage", 3000, 0, ""),
- });
- mDatabase.getMapper().stopAddingDocuments("1");
-
- {
- final Cursor cursor = mDatabase.queryRootDocuments(columns);
- assertEquals(1, cursor.getCount());
- cursor.moveToNext();
- assertEquals(2, getInt(cursor, COLUMN_DOCUMENT_ID));
- assertEquals(300, getInt(cursor, COLUMN_STORAGE_ID));
- assertEquals("Storage", getString(cursor, COLUMN_DISPLAY_NAME));
- cursor.close();
- }
- {
- final Cursor cursor = mDatabase.queryRoots(resources, rootColumns);
- assertEquals(1, cursor.getCount());
- cursor.moveToNext();
- assertEquals(1, getInt(cursor, Root.COLUMN_ROOT_ID));
- assertEquals(3000, getInt(cursor, Root.COLUMN_AVAILABLE_BYTES));
- cursor.close();
- }
- }
-
- public void testPutSameNameRootsAfterClearing() throws Exception {
- final String[] columns = new String[] {
- DocumentsContract.Document.COLUMN_DOCUMENT_ID,
- MtpDatabaseConstants.COLUMN_STORAGE_ID,
- DocumentsContract.Document.COLUMN_DISPLAY_NAME
- };
-
- // Add a device and a storage.
- addTestDevice();
- addTestStorage("1");
-
- // Disconnect devices.
- mDatabase.getMapper().clearMapping();
-
- // Add a device and two storages that has same name.
- addTestDevice();
- mDatabase.getMapper().startAddingDocuments("1");
- mDatabase.getMapper().putStorageDocuments("1", OPERATIONS_SUPPORTED, new MtpRoot[] {
- new MtpRoot(0, 200, "Storage", 2000, 0, ""),
- new MtpRoot(0, 201, "Storage", 2001, 0, ""),
- });
- mDatabase.getMapper().stopAddingDocuments("1");
-
- {
- final Cursor cursor = mDatabase.queryRootDocuments(columns);
- assertEquals(2, cursor.getCount());
-
- // First storage reuse document ID of previous storage.
- cursor.moveToNext();
- // One reuses exisitng document ID 1.
- assertEquals(2, getInt(cursor, COLUMN_DOCUMENT_ID));
- assertEquals(200, getInt(cursor, COLUMN_STORAGE_ID));
- assertEquals("Storage", getString(cursor, COLUMN_DISPLAY_NAME));
-
- // Second one has new document ID.
- cursor.moveToNext();
- assertEquals(3, getInt(cursor, COLUMN_DOCUMENT_ID));
- assertEquals(201, getInt(cursor, COLUMN_STORAGE_ID));
- assertEquals("Storage", getString(cursor, COLUMN_DISPLAY_NAME));
-
- cursor.close();
- }
- }
-
- public void testReplaceExistingRoots() throws Exception {
- addTestDevice();
-
- // The client code should be able to replace existing rows with new information.
- // Add one.
- mDatabase.getMapper().startAddingDocuments("1");
- mDatabase.getMapper().putStorageDocuments("1", OPERATIONS_SUPPORTED, new MtpRoot[] {
- new MtpRoot(0, 100, "Storage A", 0, 0, ""),
- });
- mDatabase.getMapper().stopAddingDocuments("1");
- // Replace it.
- mDatabase.getMapper().startAddingDocuments("1");
- mDatabase.getMapper().putStorageDocuments("1", OPERATIONS_SUPPORTED, new MtpRoot[] {
- new MtpRoot(0, 100, "Storage B", 1000, 1000, ""),
- });
- mDatabase.getMapper().stopAddingDocuments("1");
- {
- final String[] columns = new String[] {
- DocumentsContract.Document.COLUMN_DOCUMENT_ID,
- MtpDatabaseConstants.COLUMN_STORAGE_ID,
- DocumentsContract.Document.COLUMN_DISPLAY_NAME
- };
- final Cursor cursor = mDatabase.queryRootDocuments(columns);
- assertEquals(1, cursor.getCount());
- cursor.moveToNext();
- assertEquals(2, getInt(cursor, COLUMN_DOCUMENT_ID));
- assertEquals(100, getInt(cursor, COLUMN_STORAGE_ID));
- assertEquals("Storage B", getString(cursor, COLUMN_DISPLAY_NAME));
- cursor.close();
- }
- {
- final String[] columns = new String[] {
- Root.COLUMN_ROOT_ID,
- Root.COLUMN_TITLE,
- Root.COLUMN_AVAILABLE_BYTES
- };
- final Cursor cursor = mDatabase.queryRoots(resources, columns);
- assertEquals(1, cursor.getCount());
- cursor.moveToNext();
- assertEquals(1, getInt(cursor, Root.COLUMN_ROOT_ID));
- assertEquals("Device Storage B", getString(cursor, Root.COLUMN_TITLE));
- assertEquals(1000, getInt(cursor, Root.COLUMN_AVAILABLE_BYTES));
- cursor.close();
- }
- }
-
- public void testFailToReplaceExisitingUnmappedRoots() throws Exception {
- // The client code should not be able to replace rows before resolving 'unmapped' rows.
- // Add one.
- addTestDevice();
- mDatabase.getMapper().startAddingDocuments("1");
- mDatabase.getMapper().putStorageDocuments("1", OPERATIONS_SUPPORTED, new MtpRoot[] {
- new MtpRoot(0, 100, "Storage A", 0, 0, ""),
- });
- mDatabase.getMapper().clearMapping();
-
- addTestDevice();
- try (final Cursor oldCursor =
- mDatabase.queryRoots(resources, strings(Root.COLUMN_ROOT_ID))) {
- assertEquals(1, oldCursor.getCount());
- oldCursor.moveToNext();
- assertEquals("1", getString(oldCursor, Root.COLUMN_ROOT_ID));
-
- // Add one.
- mDatabase.getMapper().startAddingDocuments("1");
- mDatabase.getMapper().putStorageDocuments("1", OPERATIONS_SUPPORTED, new MtpRoot[] {
- new MtpRoot(0, 101, "Storage B", 1000, 1000, ""),
- });
- // Add one more before resolving unmapped documents.
- mDatabase.getMapper().putStorageDocuments("1", OPERATIONS_SUPPORTED, new MtpRoot[] {
- new MtpRoot(0, 102, "Storage B", 1000, 1000, ""),
- });
- mDatabase.getMapper().stopAddingDocuments("1");
-
- // Because the roots shares the same name, the roots should have new IDs.
- try (final Cursor newCursor = mDatabase.queryChildDocuments(
- strings(Document.COLUMN_DOCUMENT_ID), "1")) {
- assertEquals(2, newCursor.getCount());
- newCursor.moveToNext();
- assertFalse(oldCursor.getString(0).equals(newCursor.getString(0)));
- newCursor.moveToNext();
- assertFalse(oldCursor.getString(0).equals(newCursor.getString(0)));
- }
- }
- }
-
- public void testQueryDocuments() throws Exception {
- addTestDevice();
- addTestStorage("1");
-
- final Cursor cursor = mDatabase.queryDocument("2", strings(Document.COLUMN_DISPLAY_NAME));
- assertEquals(1, cursor.getCount());
- cursor.moveToNext();
- assertEquals("Storage", getString(cursor, Document.COLUMN_DISPLAY_NAME));
- cursor.close();
- }
-
- public void testQueryRoots() throws Exception {
- // Add device document.
- addTestDevice();
-
- // It the device does not have storages, it shows a device root.
- {
- final Cursor cursor = mDatabase.queryRoots(resources, strings(Root.COLUMN_TITLE));
- assertEquals(1, cursor.getCount());
- cursor.moveToNext();
- assertEquals("Device", cursor.getString(0));
- cursor.close();
- }
-
- mDatabase.getMapper().startAddingDocuments("1");
- mDatabase.getMapper().putStorageDocuments("1", OPERATIONS_SUPPORTED, new MtpRoot[] {
- new MtpRoot(0, 100, "Storage A", 0, 0, "")
- });
- mDatabase.getMapper().stopAddingDocuments("1");
-
- // It the device has single storage, it shows a storage root.
- {
- final Cursor cursor = mDatabase.queryRoots(resources, strings(Root.COLUMN_TITLE));
- assertEquals(1, cursor.getCount());
- cursor.moveToNext();
- assertEquals("Device Storage A", cursor.getString(0));
- cursor.close();
- }
-
- mDatabase.getMapper().startAddingDocuments("1");
- mDatabase.getMapper().putStorageDocuments("1", OPERATIONS_SUPPORTED, new MtpRoot[] {
- new MtpRoot(0, 100, "Storage A", 0, 0, ""),
- new MtpRoot(0, 101, "Storage B", 0, 0, "")
- });
- mDatabase.getMapper().stopAddingDocuments("1");
-
- // It the device has multiple storages, it shows a device root.
- {
- final Cursor cursor = mDatabase.queryRoots(resources, strings(Root.COLUMN_TITLE));
- assertEquals(1, cursor.getCount());
- cursor.moveToNext();
- assertEquals("Device", cursor.getString(0));
- cursor.close();
- }
- }
-
- public void testGetParentId() throws FileNotFoundException {
- addTestDevice();
-
- mDatabase.getMapper().startAddingDocuments("1");
- mDatabase.getMapper().putStorageDocuments("1", OPERATIONS_SUPPORTED, new MtpRoot[] {
- new MtpRoot(0, 100, "Storage A", 0, 0, ""),
- });
- mDatabase.getMapper().stopAddingDocuments("1");
-
- mDatabase.getMapper().startAddingDocuments("2");
- mDatabase.getMapper().putChildDocuments(0, "2", OPERATIONS_SUPPORTED, new MtpObjectInfo[] {
- createDocument(200, "note.txt", MtpConstants.FORMAT_TEXT, 1024),
- }, new long[] { 1024L });
- mDatabase.getMapper().stopAddingDocuments("2");
-
- assertEquals("2", mDatabase.getParentIdentifier("3").mDocumentId);
- }
-
- public void testDeleteDocument() throws Exception {
- addTestDevice();
- addTestStorage("1");
-
- mDatabase.getMapper().startAddingDocuments("2");
- mDatabase.getMapper().putChildDocuments(0, "2", OPERATIONS_SUPPORTED, new MtpObjectInfo[] {
- createDocument(200, "dir", MtpConstants.FORMAT_ASSOCIATION, 1024),
- }, new long[] { 1024L });
- mDatabase.getMapper().stopAddingDocuments("2");
-
- mDatabase.getMapper().startAddingDocuments("3");
- mDatabase.getMapper().putChildDocuments(0, "3", OPERATIONS_SUPPORTED, new MtpObjectInfo[] {
- createDocument(200, "note.txt", MtpConstants.FORMAT_TEXT, 1024),
- }, new long[] { 1024L });
- mDatabase.getMapper().stopAddingDocuments("3");
-
- mDatabase.deleteDocument("3");
-
- {
- // Do not query deleted documents.
- final Cursor cursor =
- mDatabase.queryChildDocuments(strings(Document.COLUMN_DOCUMENT_ID), "2");
- assertEquals(0, cursor.getCount());
- cursor.close();
- }
-
- {
- // Child document should be deleted also.
- final Cursor cursor =
- mDatabase.queryDocument("4", strings(Document.COLUMN_DOCUMENT_ID));
- assertEquals(0, cursor.getCount());
- cursor.close();
- }
- }
-
- public void testPutNewDocument() throws Exception {
- addTestDevice();
- addTestStorage("1");
-
- assertEquals(
- "3",
- mDatabase.putNewDocument(
- 0, "2", OPERATIONS_SUPPORTED,
- createDocument(200, "note.txt", MtpConstants.FORMAT_TEXT, 1024),
- 1024L));
-
- {
- final Cursor cursor =
- mDatabase.queryChildDocuments(strings(Document.COLUMN_DOCUMENT_ID), "2");
- assertEquals(1, cursor.getCount());
- cursor.moveToNext();
- assertEquals("3", cursor.getString(0));
- cursor.close();
- }
-
- // The new document should not be mapped with existing invalidated document.
- mDatabase.getMapper().clearMapping();
- addTestDevice();
- addTestStorage("1");
-
- mDatabase.getMapper().startAddingDocuments("2");
- mDatabase.putNewDocument(
- 0, "2", OPERATIONS_SUPPORTED,
- createDocument(201, "note.txt", MtpConstants.FORMAT_TEXT, 1024),
- 1024L);
- mDatabase.getMapper().stopAddingDocuments("2");
-
- {
- final Cursor cursor =
- mDatabase.queryChildDocuments(strings(Document.COLUMN_DOCUMENT_ID), "2");
- assertEquals(1, cursor.getCount());
- cursor.moveToNext();
- assertEquals("4", cursor.getString(0));
- cursor.close();
- }
- }
-
- public void testGetDocumentIdForDevice() throws Exception {
- addTestDevice();
- assertEquals("1", mDatabase.getDocumentIdForDevice(0));
- }
-
- public void testGetClosedDevice() throws Exception {
- mDatabase.getMapper().startAddingDocuments(null);
- mDatabase.getMapper().putDeviceDocument(new MtpDeviceRecord(
- 0, "Device", null /* deviceKey */, /* opened is */ false, new MtpRoot[0], null,
- null));
- mDatabase.getMapper().stopAddingDocuments(null);
-
- final String[] columns = new String [] {
- DocumentsContract.Root.COLUMN_ROOT_ID,
- DocumentsContract.Root.COLUMN_TITLE,
- DocumentsContract.Root.COLUMN_AVAILABLE_BYTES
- };
- try (final Cursor cursor = mDatabase.queryRoots(resources, columns)) {
- assertEquals(1, cursor.getCount());
- assertTrue(cursor.moveToNext());
- assertEquals(1, cursor.getLong(0));
- assertEquals("Device", cursor.getString(1));
- assertTrue(cursor.isNull(2));
- }
- }
-
- public void testMappingWithoutKey() throws FileNotFoundException {
- mDatabase.getMapper().startAddingDocuments(null);
- mDatabase.getMapper().putDeviceDocument(new MtpDeviceRecord(
- 0, "Device", null /* device key */, /* opened is */ true, new MtpRoot[0], null,
- null));
- mDatabase.getMapper().stopAddingDocuments(null);
-
- mDatabase.getMapper().startAddingDocuments(null);
- mDatabase.getMapper().putDeviceDocument(new MtpDeviceRecord(
- 0, "Device", null /* device key */, /* opened is */ true, new MtpRoot[0], null,
- null));
- mDatabase.getMapper().stopAddingDocuments(null);
-
- try (final Cursor cursor =
- mDatabase.queryRoots(resources, strings(DocumentsContract.Root.COLUMN_ROOT_ID))) {
- assertEquals(1, cursor.getCount());
- assertTrue(cursor.moveToNext());
- assertEquals(1, cursor.getLong(0));
- }
- }
-
- public void testMappingFailsWithoutKey() throws FileNotFoundException {
- mDatabase.getMapper().startAddingDocuments(null);
- mDatabase.getMapper().putDeviceDocument(new MtpDeviceRecord(
- 0, "Device", null /* device key */, /* opened is */ true, new MtpRoot[0], null,
- null));
- mDatabase.getMapper().stopAddingDocuments(null);
-
- // MTP identifier is cleared here. Mapping no longer works without device key.
- mDatabase.getMapper().startAddingDocuments(null);
- mDatabase.getMapper().stopAddingDocuments(null);
-
- mDatabase.getMapper().startAddingDocuments(null);
- mDatabase.getMapper().putDeviceDocument(new MtpDeviceRecord(
- 0, "Device", null /* device key */, /* opened is */ true, new MtpRoot[0], null,
- null));
- mDatabase.getMapper().stopAddingDocuments(null);
-
- try (final Cursor cursor =
- mDatabase.queryRoots(resources, strings(DocumentsContract.Root.COLUMN_ROOT_ID))) {
- assertEquals(1, cursor.getCount());
- assertTrue(cursor.moveToNext());
- assertEquals(2, cursor.getLong(0));
- }
- }
-
- public void testUpdateDocumentWithoutChange() throws FileNotFoundException {
- mDatabase.getMapper().startAddingDocuments(null);
- assertTrue(mDatabase.getMapper().putDeviceDocument(new MtpDeviceRecord(
- 0, "Device", "device_key", /* opened is */ true, new MtpRoot[0], null,
- null)));
- assertFalse(mDatabase.getMapper().stopAddingDocuments(null));
-
- mDatabase.getMapper().startAddingDocuments(null);
- assertFalse(mDatabase.getMapper().putDeviceDocument(new MtpDeviceRecord(
- 0, "Device", "device_key", /* opened is */ true, new MtpRoot[0], null,
- null)));
- assertFalse(mDatabase.getMapper().stopAddingDocuments(null));
- }
-
- public void testSetBootCount() {
- assertEquals(0, mDatabase.getLastBootCount());
- mDatabase.setLastBootCount(10);
- assertEquals(10, mDatabase.getLastBootCount());
- try {
- mDatabase.setLastBootCount(-1);
- fail();
- } catch (IllegalArgumentException e) {}
- }
-
- public void testCleanDatabase() throws FileNotFoundException {
- // Add tree.
- addTestDevice();
- addTestStorage("1");
- mDatabase.getMapper().startAddingDocuments("2");
- mDatabase.getMapper().putChildDocuments(0, "2", OPERATIONS_SUPPORTED, new MtpObjectInfo[] {
- createDocument(100, "apple.txt", MtpConstants.FORMAT_TEXT, 1024),
- createDocument(101, "orange.txt", MtpConstants.FORMAT_TEXT, 1024),
- }, new long[] { 1024L, 1024L });
- mDatabase.getMapper().stopAddingDocuments("2");
-
- // Disconnect the device.
- mDatabase.getMapper().startAddingDocuments(null);
- mDatabase.getMapper().stopAddingDocuments(null);
-
- // Clean database.
- mDatabase.cleanDatabase(new Uri[] {
- DocumentsContract.buildDocumentUri(MtpDocumentsProvider.AUTHORITY, "3")
- });
-
- // Add tree again.
- addTestDevice();
- addTestStorage("1");
- mDatabase.getMapper().startAddingDocuments("2");
- mDatabase.getMapper().putChildDocuments(0, "2", OPERATIONS_SUPPORTED, new MtpObjectInfo[] {
- createDocument(100, "apple.txt", MtpConstants.FORMAT_TEXT, 1024),
- createDocument(101, "orange.txt", MtpConstants.FORMAT_TEXT, 1024),
- }, new long[] { 1024L, 1024L });
- mDatabase.getMapper().stopAddingDocuments("2");
-
- try (final Cursor cursor = mDatabase.queryChildDocuments(
- strings(COLUMN_DOCUMENT_ID, Document.COLUMN_DISPLAY_NAME), "2")) {
- assertEquals(2, cursor.getCount());
-
- // Persistent uri uses the same ID.
- cursor.moveToNext();
- assertEquals("3", cursor.getString(0));
- assertEquals("apple.txt", cursor.getString(1));
-
- // Others does not.
- cursor.moveToNext();
- assertEquals("5", cursor.getString(0));
- assertEquals("orange.txt", cursor.getString(1));
- }
- }
-
- public void testFormatCodeForMpeg() throws FileNotFoundException {
- addTestDevice();
- addTestStorage("1");
- mDatabase.getMapper().startAddingDocuments("2");
- mDatabase.getMapper().putChildDocuments(0, "2", OPERATIONS_SUPPORTED, new MtpObjectInfo[] {
- createDocument(100, "audio.m4a", MtpConstants.FORMAT_MPEG, 1000),
- createDocument(101, "video.m4v", MtpConstants.FORMAT_MPEG, 1000),
- createDocument(102, "unknown.mp4", MtpConstants.FORMAT_MPEG, 1000),
- createDocument(103, "inconsistent.txt", MtpConstants.FORMAT_MPEG, 1000),
- createDocument(104, "noext", MtpConstants.FORMAT_UNDEFINED, 1000),
- }, new long[] { 1000L, 1000L, 1000L, 1000L, 1000L });
- mDatabase.getMapper().stopAddingDocuments("2");
- try (final Cursor cursor = mDatabase.queryChildDocuments(
- strings(COLUMN_DISPLAY_NAME, COLUMN_MIME_TYPE),
- "2")) {
- assertEquals(5, cursor.getCount());
- cursor.moveToNext();
- assertEquals("audio.m4a", cursor.getString(0));
- assertEquals("audio/mp4", cursor.getString(1));
- cursor.moveToNext();
- assertEquals("video.m4v", cursor.getString(0));
- assertEquals("video/mp4", cursor.getString(1));
- cursor.moveToNext();
- // Assume that the file is video as we don't have any hints to find out if the file is
- // video or audio.
- assertEquals("unknown.mp4", cursor.getString(0));
- assertEquals("video/mp4", cursor.getString(1));
- // Don't return mime type that is inconsistent with format code.
- cursor.moveToNext();
- assertEquals("inconsistent.txt", cursor.getString(0));
- assertEquals("video/mpeg", cursor.getString(1));
- cursor.moveToNext();
- assertEquals("noext", cursor.getString(0));
- assertEquals("application/octet-stream", cursor.getString(1));
- }
- }
-
- private void addTestDevice() throws FileNotFoundException {
- TestUtil.addTestDevice(mDatabase);
- }
-
- private void addTestStorage(String parentId) throws FileNotFoundException {
- TestUtil.addTestStorage(mDatabase, parentId);
- }
-}
diff --git a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/MtpDocumentsProviderTest.java b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/MtpDocumentsProviderTest.java
deleted file mode 100644
index 65c86df..0000000
--- a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/MtpDocumentsProviderTest.java
+++ /dev/null
@@ -1,1040 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.mtp;
-
-import android.database.Cursor;
-import android.mtp.MtpConstants;
-import android.mtp.MtpObjectInfo;
-import android.net.Uri;
-import android.os.ParcelFileDescriptor;
-import android.os.storage.StorageManager;
-import android.provider.DocumentsContract.Document;
-import android.provider.DocumentsContract.Path;
-import android.provider.DocumentsContract.Root;
-import android.system.Os;
-import android.system.OsConstants;
-import android.provider.DocumentsContract;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.Queue;
-import java.util.concurrent.TimeoutException;
-
-import static com.android.mtp.MtpDatabase.strings;
-import static com.android.mtp.TestUtil.OPERATIONS_SUPPORTED;
-
-@MediumTest
-public class MtpDocumentsProviderTest extends AndroidTestCase {
- private final static Uri ROOTS_URI =
- DocumentsContract.buildRootsUri(MtpDocumentsProvider.AUTHORITY);
- private TestContentResolver mResolver;
- private MtpDocumentsProvider mProvider;
- private TestMtpManager mMtpManager;
- private final TestResources mResources = new TestResources();
- private MtpDatabase mDatabase;
-
- @Override
- public void setUp() throws IOException {
- mResolver = new TestContentResolver();
- mMtpManager = new TestMtpManager(getContext());
- }
-
- @Override
- public void tearDown() {
- mProvider.shutdown();
- MtpDatabase.deleteDatabase(getContext());
- }
-
- public void testOpenAndCloseDevice() throws Exception {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- mMtpManager.addValidDevice(new MtpDeviceRecord(
- 0,
- "Device A",
- null /* deviceKey */,
- false /* unopened */,
- new MtpRoot[] {
- new MtpRoot(
- 0 /* deviceId */,
- 1 /* storageId */,
- "Storage A" /* volume description */,
- 1024 /* free space */,
- 2048 /* total space */,
- "" /* no volume identifier */)
- },
- OPERATIONS_SUPPORTED,
- null));
-
- mProvider.resumeRootScanner();
- mResolver.waitForNotification(ROOTS_URI, 1);
-
- mProvider.openDevice(0);
- mResolver.waitForNotification(ROOTS_URI, 2);
-
- mProvider.closeDevice(0);
- mResolver.waitForNotification(ROOTS_URI, 3);
- }
-
- public void testOpenAndCloseErrorDevice() throws Exception {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- try {
- mProvider.openDevice(1);
- fail();
- } catch (Throwable error) {
- assertTrue(error instanceof IOException);
- }
- assertEquals(0, mProvider.getOpenedDeviceRecordsCache().length);
-
- // Check if the following notification is the first one or not.
- mMtpManager.addValidDevice(new MtpDeviceRecord(
- 0,
- "Device A",
- null /* deviceKey */,
- false /* unopened */,
- new MtpRoot[] {
- new MtpRoot(
- 0 /* deviceId */,
- 1 /* storageId */,
- "Storage A" /* volume description */,
- 1024 /* free space */,
- 2048 /* total space */,
- "" /* no volume identifier */)
- },
- OPERATIONS_SUPPORTED,
- null));
- mProvider.resumeRootScanner();
- mResolver.waitForNotification(ROOTS_URI, 1);
- mProvider.openDevice(0);
- mResolver.waitForNotification(ROOTS_URI, 2);
- }
-
- public void testOpenDeviceOnDemand() throws Exception {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- mMtpManager.addValidDevice(new MtpDeviceRecord(
- 0,
- "Device A",
- null /* deviceKey */,
- false /* unopened */,
- new MtpRoot[] {
- new MtpRoot(
- 0 /* deviceId */,
- 1 /* storageId */,
- "Storage A" /* volume description */,
- 1024 /* free space */,
- 2048 /* total space */,
- "" /* no volume identifier */)
- },
- OPERATIONS_SUPPORTED,
- null));
- mMtpManager.setObjectHandles(0, 1, -1, new int[0]);
- mProvider.resumeRootScanner();
- mResolver.waitForNotification(ROOTS_URI, 1);
- final String[] columns = new String[] {
- DocumentsContract.Root.COLUMN_TITLE,
- DocumentsContract.Root.COLUMN_DOCUMENT_ID
- };
- try (final Cursor cursor = mProvider.queryRoots(columns)) {
- assertEquals(1, cursor.getCount());
- assertTrue(cursor.moveToNext());
- assertEquals("Device A", cursor.getString(0));
- assertEquals(1, cursor.getLong(1));
- }
- {
- final MtpDeviceRecord[] openedDevice = mProvider.getOpenedDeviceRecordsCache();
- assertEquals(0, openedDevice.length);
- }
- // Device is opened automatically when querying its children.
- try (final Cursor cursor = mProvider.queryChildDocuments("1", null, (String) null)) {}
-
- {
- final MtpDeviceRecord[] openedDevice = mProvider.getOpenedDeviceRecordsCache();
- assertEquals(1, openedDevice.length);
- assertEquals(0, openedDevice[0].deviceId);
- }
- }
-
- public void testQueryRoots() throws Exception {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- mMtpManager.addValidDevice(new MtpDeviceRecord(
- 0,
- "Device A",
- "Device key A",
- false /* unopened */,
- new MtpRoot[] {
- new MtpRoot(
- 0 /* deviceId */,
- 1 /* storageId */,
- "Storage A" /* volume description */,
- 1024 /* free space */,
- 2048 /* total space */,
- "" /* no volume identifier */)
- },
- OPERATIONS_SUPPORTED,
- null));
- mMtpManager.addValidDevice(new MtpDeviceRecord(
- 1,
- "Device B",
- "Device key B",
- false /* unopened */,
- new MtpRoot[] {
- new MtpRoot(
- 1 /* deviceId */,
- 1 /* storageId */,
- "Storage B" /* volume description */,
- 2048 /* free space */,
- 4096 /* total space */,
- "Identifier B" /* no volume identifier */)
- },
- new int[0] /* No operations supported */,
- null));
-
- {
- mProvider.openDevice(0);
- mResolver.waitForNotification(ROOTS_URI, 1);
- final Cursor cursor = mProvider.queryRoots(null);
- assertEquals(2, cursor.getCount());
- cursor.moveToNext();
- assertEquals("1", cursor.getString(0));
- assertEquals(
- Root.FLAG_SUPPORTS_IS_CHILD |
- Root.FLAG_SUPPORTS_CREATE |
- Root.FLAG_LOCAL_ONLY,
- cursor.getInt(1));
- assertEquals(R.drawable.ic_root_mtp, cursor.getInt(2));
- assertEquals("Device A Storage A", cursor.getString(3));
- assertEquals("1", cursor.getString(4));
- assertEquals(1024, cursor.getInt(5));
- }
-
- {
- mProvider.openDevice(1);
- mResolver.waitForNotification(ROOTS_URI, 2);
- final Cursor cursor = mProvider.queryRoots(null);
- assertEquals(2, cursor.getCount());
- cursor.moveToNext();
- cursor.moveToNext();
- assertEquals("2", cursor.getString(0));
- assertEquals(
- Root.FLAG_SUPPORTS_IS_CHILD | Root.FLAG_LOCAL_ONLY, cursor.getInt(1));
- assertEquals(R.drawable.ic_root_mtp, cursor.getInt(2));
- assertEquals("Device B Storage B", cursor.getString(3));
- assertEquals("2", cursor.getString(4));
- assertEquals(2048, cursor.getInt(5));
- }
- }
-
- public void testQueryRoots_error() throws Exception {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- mMtpManager.addValidDevice(new MtpDeviceRecord(
- 0,
- "Device A",
- "Device key A",
- false /* unopened */,
- new MtpRoot[0],
- OPERATIONS_SUPPORTED,
- null));
- mMtpManager.addValidDevice(new MtpDeviceRecord(
- 1,
- "Device B",
- "Device key B",
- false /* unopened */,
- new MtpRoot[] {
- new MtpRoot(
- 1 /* deviceId */,
- 1 /* storageId */,
- "Storage B" /* volume description */,
- 2048 /* free space */,
- 4096 /* total space */,
- "Identifier B" /* no volume identifier */)
- },
- OPERATIONS_SUPPORTED,
- null));
- {
- mProvider.openDevice(0);
- mResolver.waitForNotification(ROOTS_URI, 1);
-
- mProvider.openDevice(1);
- mResolver.waitForNotification(ROOTS_URI, 2);
-
- final Cursor cursor = mProvider.queryRoots(null);
- assertEquals(2, cursor.getCount());
-
- cursor.moveToNext();
- assertEquals("1", cursor.getString(0));
- assertEquals(
- Root.FLAG_SUPPORTS_IS_CHILD | Root.FLAG_SUPPORTS_CREATE | Root.FLAG_LOCAL_ONLY,
- cursor.getInt(1));
- assertEquals(R.drawable.ic_root_mtp, cursor.getInt(2));
- assertEquals("Device A", cursor.getString(3));
- assertEquals("1", cursor.getString(4));
- assertEquals(0, cursor.getInt(5));
-
- cursor.moveToNext();
- assertEquals("2", cursor.getString(0));
- assertEquals(
- Root.FLAG_SUPPORTS_IS_CHILD | Root.FLAG_SUPPORTS_CREATE | Root.FLAG_LOCAL_ONLY,
- cursor.getInt(1));
- assertEquals(R.drawable.ic_root_mtp, cursor.getInt(2));
- assertEquals("Device B Storage B", cursor.getString(3));
- assertEquals("2", cursor.getString(4));
- assertEquals(2048, cursor.getInt(5));
- }
- }
-
- public void testQueryDocument() throws IOException, InterruptedException, TimeoutException {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- setupRoots(0, new MtpRoot[] { new MtpRoot(0, 0, "Storage", 1000, 1000, "") });
- setupDocuments(
- 0,
- 0,
- MtpManager.OBJECT_HANDLE_ROOT_CHILDREN,
- "1",
- new MtpObjectInfo[] {
- new MtpObjectInfo.Builder()
- .setObjectHandle(100)
- .setFormat(MtpConstants.FORMAT_EXIF_JPEG)
- .setName("image.jpg")
- .setDateModified(1422716400000L)
- .setCompressedSize(1024 * 1024 * 5)
- .setThumbCompressedSize(50 * 1024)
- .build()
- });
-
- final Cursor cursor = mProvider.queryDocument("3", null);
- assertEquals(1, cursor.getCount());
-
- cursor.moveToNext();
-
- assertEquals("3", cursor.getString(0));
- assertEquals("image/jpeg", cursor.getString(1));
- assertEquals("image.jpg", cursor.getString(2));
- assertEquals(1422716400000L, cursor.getLong(3));
- assertEquals(
- DocumentsContract.Document.FLAG_SUPPORTS_DELETE |
- DocumentsContract.Document.FLAG_SUPPORTS_WRITE |
- DocumentsContract.Document.FLAG_SUPPORTS_THUMBNAIL |
- DocumentsContract.Document.FLAG_SUPPORTS_METADATA,
- cursor.getInt(4));
- assertEquals(1024 * 1024 * 5, cursor.getInt(5));
- }
-
- public void testQueryDocument_directory()
- throws IOException, InterruptedException, TimeoutException {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- setupRoots(0, new MtpRoot[] { new MtpRoot(0, 0, "Storage", 1000, 1000, "") });
- setupDocuments(
- 0,
- 0,
- MtpManager.OBJECT_HANDLE_ROOT_CHILDREN,
- "1",
- new MtpObjectInfo[] {
- new MtpObjectInfo.Builder()
- .setObjectHandle(2)
- .setStorageId(1)
- .setFormat(MtpConstants.FORMAT_ASSOCIATION)
- .setName("directory")
- .setDateModified(1422716400000L)
- .build()
- });
-
- final Cursor cursor = mProvider.queryDocument("3", null);
- assertEquals(1, cursor.getCount());
-
- cursor.moveToNext();
- assertEquals("3", cursor.getString(0));
- assertEquals(DocumentsContract.Document.MIME_TYPE_DIR, cursor.getString(1));
- assertEquals("directory", cursor.getString(2));
- assertEquals(1422716400000L, cursor.getLong(3));
- assertEquals(
- DocumentsContract.Document.FLAG_SUPPORTS_DELETE |
- DocumentsContract.Document.FLAG_DIR_SUPPORTS_CREATE,
- cursor.getInt(4));
- assertEquals(0, cursor.getInt(5));
- }
-
- public void testQueryDocument_forStorage()
- throws IOException, InterruptedException, TimeoutException {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- setupRoots(0, new MtpRoot[] {
- new MtpRoot(
- 0 /* deviceId */,
- 1 /* storageId */,
- "Storage A" /* volume description */,
- 1024 /* free space */,
- 4096 /* total space */,
- "" /* no volume identifier */)
- });
- final Cursor cursor = mProvider.queryDocument("2", null);
- assertEquals(1, cursor.getCount());
-
- cursor.moveToNext();
- assertEquals("2", cursor.getString(0));
- assertEquals(DocumentsContract.Document.MIME_TYPE_DIR, cursor.getString(1));
- assertEquals("Storage A", cursor.getString(2));
- assertTrue(cursor.isNull(3));
- assertEquals(DocumentsContract.Document.FLAG_DIR_SUPPORTS_CREATE, cursor.getInt(4));
- assertEquals(3072, cursor.getInt(5));
- }
-
- public void testQueryDocument_forDeviceWithSingleStorage()
- throws IOException, InterruptedException, TimeoutException {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- setupRoots(0, new MtpRoot[] {
- new MtpRoot(
- 0 /* deviceId */,
- 1 /* storageId */,
- "Storage A" /* volume description */,
- 1024 /* free space */,
- 4096 /* total space */,
- "" /* no volume identifier */)
- });
- final Cursor cursor = mProvider.queryDocument("1", null);
- assertEquals(1, cursor.getCount());
-
- cursor.moveToNext();
- assertEquals("1", cursor.getString(0));
- assertEquals(DocumentsContract.Document.MIME_TYPE_DIR, cursor.getString(1));
- assertEquals("Device Storage A", cursor.getString(2));
- assertTrue(cursor.isNull(3));
- assertEquals(DocumentsContract.Document.FLAG_DIR_SUPPORTS_CREATE, cursor.getInt(4));
- assertTrue(cursor.isNull(5));
- }
-
- public void testQueryDocument_forDeviceWithTwoStorages()
- throws IOException, InterruptedException, TimeoutException {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- setupRoots(0, new MtpRoot[] {
- new MtpRoot(
- 0 /* deviceId */,
- 1 /* storageId */,
- "Storage A" /* volume description */,
- 1024 /* free space */,
- 4096 /* total space */,
- "" /* no volume identifier */),
- new MtpRoot(
- 0 /* deviceId */,
- 2 /* storageId */,
- "Storage B" /* volume description */,
- 1024 /* free space */,
- 4096 /* total space */,
- "" /* no volume identifier */)
- });
- final Cursor cursor = mProvider.queryDocument("1", null);
- assertEquals(1, cursor.getCount());
-
- cursor.moveToNext();
- assertEquals("1", cursor.getString(0));
- assertEquals(DocumentsContract.Document.MIME_TYPE_DIR, cursor.getString(1));
- assertEquals("Device", cursor.getString(2));
- assertTrue(cursor.isNull(3));
- assertEquals(0, cursor.getInt(4));
- assertTrue(cursor.isNull(5));
- }
-
- public void testQueryChildDocuments() throws Exception {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- setupRoots(0, new MtpRoot[] { new MtpRoot(0, 0, "Storage", 1000, 1000, "") });
- setupDocuments(
- 0,
- 0,
- MtpManager.OBJECT_HANDLE_ROOT_CHILDREN,
- "1",
- new MtpObjectInfo[] {
- new MtpObjectInfo.Builder()
- .setObjectHandle(100)
- .setFormat(MtpConstants.FORMAT_EXIF_JPEG)
- .setName("image.jpg")
- .setCompressedSize(1024 * 1024 * 5)
- .setThumbCompressedSize(5 * 1024)
- .setProtectionStatus(MtpConstants.PROTECTION_STATUS_READ_ONLY)
- .build()
- });
-
- final Cursor cursor = mProvider.queryChildDocuments("1", null, (String) null);
- assertEquals(1, cursor.getCount());
-
- assertTrue(cursor.moveToNext());
- assertEquals("3", cursor.getString(0));
- assertEquals("image/jpeg", cursor.getString(1));
- assertEquals("image.jpg", cursor.getString(2));
- assertEquals(0, cursor.getLong(3));
- assertEquals(Document.FLAG_SUPPORTS_THUMBNAIL
- | Document.FLAG_SUPPORTS_METADATA, cursor.getInt(4));
- assertEquals(1024 * 1024 * 5, cursor.getInt(5));
-
- cursor.close();
- }
-
- public void testQueryChildDocuments_cursorError() throws Exception {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- try {
- mProvider.queryChildDocuments("1", null, (String) null);
- fail();
- } catch (FileNotFoundException error) {}
- }
-
- public void testQueryChildDocuments_documentError() throws Exception {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- setupRoots(0, new MtpRoot[] { new MtpRoot(0, 0, "Storage", 1000, 1000, "") });
- mMtpManager.setObjectHandles(0, 0, -1, new int[] { 1 });
- try (final Cursor cursor = mProvider.queryChildDocuments("1", null, (String) null)) {
- assertEquals(0, cursor.getCount());
- assertFalse(cursor.getExtras().getBoolean(DocumentsContract.EXTRA_LOADING));
- }
- }
-
- public void testDeleteDocument() throws IOException, InterruptedException, TimeoutException {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- setupRoots(0, new MtpRoot[] {
- new MtpRoot(0, 0, "Storage", 0, 0, "")
- });
- setupDocuments(0, 0, MtpManager.OBJECT_HANDLE_ROOT_CHILDREN, "1", new MtpObjectInfo[] {
- new MtpObjectInfo.Builder()
- .setName("test.txt")
- .setObjectHandle(1)
- .setParent(-1)
- .build()
- });
-
- mProvider.deleteDocument("3");
- assertEquals(1, mResolver.getChangeCount(
- DocumentsContract.buildChildDocumentsUri(
- MtpDocumentsProvider.AUTHORITY, "1")));
- }
-
- public void testDeleteDocument_error()
- throws IOException, InterruptedException, TimeoutException {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- setupRoots(0, new MtpRoot[] {
- new MtpRoot(0, 0, "Storage", 0, 0, "")
- });
- setupDocuments(0, 0, MtpManager.OBJECT_HANDLE_ROOT_CHILDREN, "1", new MtpObjectInfo[] {
- new MtpObjectInfo.Builder()
- .setName("test.txt")
- .setObjectHandle(1)
- .setParent(-1)
- .build()
- });
- try {
- mProvider.deleteDocument("4");
- fail();
- } catch (Throwable e) {
- assertTrue(e instanceof IOException);
- }
- assertEquals(0, mResolver.getChangeCount(
- DocumentsContract.buildChildDocumentsUri(
- MtpDocumentsProvider.AUTHORITY, "1")));
- }
-
- public void testOpenDocument() throws Exception {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- setupRoots(0, new MtpRoot[] {
- new MtpRoot(0, 0, "Storage", 0, 0, "")
- });
- final byte[] bytes = "Hello world".getBytes();
- setupDocuments(0, 0, MtpManager.OBJECT_HANDLE_ROOT_CHILDREN, "1", new MtpObjectInfo[] {
- new MtpObjectInfo.Builder()
- .setName("test.txt")
- .setObjectHandle(1)
- .setCompressedSize(bytes.length)
- .setParent(-1)
- .build()
- });
- mMtpManager.setImportFileBytes(0, 1, bytes);
- try (final ParcelFileDescriptor fd = mProvider.openDocument("3", "r", null)) {
- final byte[] readBytes = new byte[5];
- assertEquals(6, Os.lseek(fd.getFileDescriptor(), 6, OsConstants.SEEK_SET));
- assertEquals(5, Os.read(fd.getFileDescriptor(), readBytes, 0, 5));
- assertTrue(Arrays.equals("world".getBytes(), readBytes));
-
- assertEquals(0, Os.lseek(fd.getFileDescriptor(), 0, OsConstants.SEEK_SET));
- assertEquals(5, Os.read(fd.getFileDescriptor(), readBytes, 0, 5));
- assertTrue(Arrays.equals("Hello".getBytes(), readBytes));
- }
- }
-
- public void testOpenDocument_shortBytes() throws Exception {
- mMtpManager = new TestMtpManager(getContext()) {
- @Override
- MtpObjectInfo getObjectInfo(int deviceId, int objectHandle) throws IOException {
- if (objectHandle == 1) {
- return new MtpObjectInfo.Builder(super.getObjectInfo(deviceId, objectHandle))
- .setObjectHandle(1).setCompressedSize(1024 * 1024).build();
- }
-
- return super.getObjectInfo(deviceId, objectHandle);
- }
- };
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- setupRoots(0, new MtpRoot[] {
- new MtpRoot(0, 0, "Storage", 0, 0, "")
- });
- final byte[] bytes = "Hello world".getBytes();
- setupDocuments(0, 0, MtpManager.OBJECT_HANDLE_ROOT_CHILDREN, "1", new MtpObjectInfo[] {
- new MtpObjectInfo.Builder()
- .setName("test.txt")
- .setObjectHandle(1)
- .setCompressedSize(bytes.length)
- .setParent(-1)
- .build()
- });
- mMtpManager.setImportFileBytes(0, 1, bytes);
- try (final ParcelFileDescriptor fd = mProvider.openDocument("3", "r", null)) {
- final byte[] readBytes = new byte[1024 * 1024];
- assertEquals(11, Os.read(fd.getFileDescriptor(), readBytes, 0, readBytes.length));
- }
- }
-
- public void testOpenDocument_writing() throws Exception {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- setupRoots(0, new MtpRoot[] {
- new MtpRoot(0, 100, "Storage", 0, 0, "")
- });
- final String documentId = mProvider.createDocument("2", "text/plain", "test.txt");
- {
- final ParcelFileDescriptor fd = mProvider.openDocument(documentId, "w", null);
- try (ParcelFileDescriptor.AutoCloseOutputStream stream =
- new ParcelFileDescriptor.AutoCloseOutputStream(fd)) {
- stream.write("Hello".getBytes());
- fd.getFileDescriptor().sync();
- }
- }
- {
- final ParcelFileDescriptor fd = mProvider.openDocument(documentId, "r", null);
- try (ParcelFileDescriptor.AutoCloseInputStream stream =
- new ParcelFileDescriptor.AutoCloseInputStream(fd)) {
- final byte[] bytes = new byte[5];
- stream.read(bytes);
- assertTrue(Arrays.equals("Hello".getBytes(), bytes));
- }
- }
- }
-
- public void testBusyDevice() throws Exception {
- mMtpManager = new TestMtpManager(getContext()) {
- @Override
- synchronized MtpDeviceRecord openDevice(int deviceId)
- throws IOException {
- throw new BusyDeviceException();
- }
- };
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- mMtpManager.addValidDevice(new MtpDeviceRecord(
- 0, "Device A", null /* deviceKey */, false /* unopened */, new MtpRoot[0],
- OPERATIONS_SUPPORTED, null));
-
- mProvider.resumeRootScanner();
- mResolver.waitForNotification(ROOTS_URI, 1);
-
- try (final Cursor cursor = mProvider.queryRoots(null)) {
- assertEquals(1, cursor.getCount());
- }
-
- try (final Cursor cursor = mProvider.queryChildDocuments("1", null, (String) null)) {
- assertEquals(0, cursor.getCount());
- assertEquals(
- "error_busy_device",
- cursor.getExtras().getString(DocumentsContract.EXTRA_ERROR));
- }
- }
-
- public void testLockedDevice() throws Exception {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- mMtpManager.addValidDevice(new MtpDeviceRecord(
- 0, "Device A", null, false /* unopened */, new MtpRoot[0], OPERATIONS_SUPPORTED,
- null));
-
- mProvider.resumeRootScanner();
- mResolver.waitForNotification(ROOTS_URI, 1);
-
- try (final Cursor cursor = mProvider.queryRoots(null)) {
- assertEquals(1, cursor.getCount());
- }
-
- try (final Cursor cursor = mProvider.queryChildDocuments("1", null, (String) null)) {
- assertEquals(0, cursor.getCount());
- assertEquals(
- "error_locked_device",
- cursor.getExtras().getString(DocumentsContract.EXTRA_ERROR));
- }
- }
-
- public void testMappingDisconnectedDocuments() throws Exception {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- mMtpManager.addValidDevice(new MtpDeviceRecord(
- 0,
- "Device A",
- "device key",
- true /* opened */,
- new MtpRoot[] {
- new MtpRoot(
- 0 /* deviceId */,
- 1 /* storageId */,
- "Storage A" /* volume description */,
- 1024 /* free space */,
- 2048 /* total space */,
- "" /* no volume identifier */)
- },
- OPERATIONS_SUPPORTED,
- null));
-
- final String[] names = strings("Directory A", "Directory B", "Directory C");
- final int objectHandleOffset = 100;
- for (int i = 0; i < names.length; i++) {
- final int parentHandle = i == 0 ?
- MtpManager.OBJECT_HANDLE_ROOT_CHILDREN : objectHandleOffset + i - 1;
- final int objectHandle = i + objectHandleOffset;
- mMtpManager.setObjectHandles(0, 1, parentHandle, new int[] { objectHandle });
- mMtpManager.setObjectInfo(
- 0,
- new MtpObjectInfo.Builder()
- .setName(names[i])
- .setObjectHandle(objectHandle)
- .setFormat(MtpConstants.FORMAT_ASSOCIATION)
- .setStorageId(1)
- .build());
- }
-
- mProvider.resumeRootScanner();
- mResolver.waitForNotification(ROOTS_URI, 1);
-
- final int documentIdOffset = 2;
- for (int i = 0; i < names.length; i++) {
- try (final Cursor cursor = mProvider.queryChildDocuments(
- String.valueOf(documentIdOffset + i),
- strings(Document.COLUMN_DOCUMENT_ID, Document.COLUMN_DISPLAY_NAME),
- (String) null)) {
- assertEquals(1, cursor.getCount());
- cursor.moveToNext();
- assertEquals(String.valueOf(documentIdOffset + i + 1), cursor.getString(0));
- assertEquals(names[i], cursor.getString(1));
- }
- }
-
- mProvider.closeDevice(0);
- mResolver.waitForNotification(ROOTS_URI, 2);
-
- mProvider.openDevice(0);
- mResolver.waitForNotification(ROOTS_URI, 3);
-
- for (int i = 0; i < names.length; i++) {
- mResolver.waitForNotification(DocumentsContract.buildChildDocumentsUri(
- MtpDocumentsProvider.AUTHORITY,
- String.valueOf(documentIdOffset + i)), 1);
- try (final Cursor cursor = mProvider.queryChildDocuments(
- String.valueOf(documentIdOffset + i),
- strings(Document.COLUMN_DOCUMENT_ID),
- (String) null)) {
- assertEquals(1, cursor.getCount());
- cursor.moveToNext();
- assertEquals(String.valueOf(documentIdOffset + i + 1), cursor.getString(0));
- }
- }
- }
-
- public void testCreateDocument() throws Exception {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- setupRoots(0, new MtpRoot[] {
- new MtpRoot(0, 100, "Storage A", 100, 100, null)
- });
- final String documentId = mProvider.createDocument("1", "text/plain", "note.txt");
- final Uri deviceUri = DocumentsContract.buildChildDocumentsUri(
- MtpDocumentsProvider.AUTHORITY, "1");
- final Uri storageUri = DocumentsContract.buildChildDocumentsUri(
- MtpDocumentsProvider.AUTHORITY, "2");
- mResolver.waitForNotification(storageUri, 1);
- mResolver.waitForNotification(deviceUri, 1);
- try (final Cursor cursor = mProvider.queryDocument(documentId, null)) {
- assertTrue(cursor.moveToNext());
- assertEquals(
- "note.txt",
- cursor.getString(cursor.getColumnIndex(Document.COLUMN_DISPLAY_NAME)));
- assertEquals(
- "text/plain",
- cursor.getString(cursor.getColumnIndex(Document.COLUMN_MIME_TYPE)));
- }
- }
-
- public void testCreateDocument_noWritingSupport() throws Exception {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- mMtpManager.addValidDevice(new MtpDeviceRecord(
- 0, "Device A", null /* deviceKey */, false /* unopened */,
- new MtpRoot[] {
- new MtpRoot(
- 0 /* deviceId */,
- 1 /* storageId */,
- "Storage A" /* volume description */,
- 1024 /* free space */,
- 2048 /* total space */,
- "" /* no volume identifier */)
- },
- new int[0] /* no operations supported */, null));
- mProvider.resumeRootScanner();
- mResolver.waitForNotification(ROOTS_URI, 1);
- try {
- mProvider.createDocument("1", "text/palin", "note.txt");
- fail();
- } catch (UnsupportedOperationException exception) {}
- }
-
- public void testOpenDocument_noWritingSupport() throws Exception {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- mMtpManager.addValidDevice(new MtpDeviceRecord(
- 0, "Device A", null /* deviceKey */, false /* unopened */,
- new MtpRoot[] {
- new MtpRoot(
- 0 /* deviceId */,
- 1 /* storageId */,
- "Storage A" /* volume description */,
- 1024 /* free space */,
- 2048 /* total space */,
- "" /* no volume identifier */)
- },
- new int[0] /* no operations supported */, null));
- mMtpManager.setObjectHandles(
- 0, 1, MtpManager.OBJECT_HANDLE_ROOT_CHILDREN, new int[] { 100 });
- mMtpManager.setObjectInfo(
- 0, new MtpObjectInfo.Builder().setObjectHandle(100).setName("note.txt").build());
- mProvider.resumeRootScanner();
- mResolver.waitForNotification(ROOTS_URI, 1);
- try (final Cursor cursor = mProvider.queryChildDocuments(
- "1", strings(Document.COLUMN_DOCUMENT_ID), (String) null)) {
- assertEquals(1, cursor.getCount());
- cursor.moveToNext();
- assertEquals("3", cursor.getString(0));
- }
- try {
- mProvider.openDocument("3", "w", null);
- fail();
- } catch (UnsupportedOperationException exception) {}
- }
-
- public void testObjectSizeLong() throws Exception {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- setupRoots(0, new MtpRoot[] { new MtpRoot(0, 0, "Storage", 1000, 1000, "") });
- mMtpManager.setObjectSizeLong(0, 100, MtpConstants.FORMAT_EXIF_JPEG, 0x400000000L);
- setupDocuments(
- 0,
- 0,
- MtpManager.OBJECT_HANDLE_ROOT_CHILDREN,
- "1",
- new MtpObjectInfo[] {
- new MtpObjectInfo.Builder()
- .setObjectHandle(100)
- .setFormat(MtpConstants.FORMAT_EXIF_JPEG)
- .setName("image.jpg")
- .setCompressedSize(0xffffffffl)
- .build()
- });
-
- final Cursor cursor = mProvider.queryDocument("3", new String[] {
- DocumentsContract.Document.COLUMN_SIZE
- });
- assertEquals(1, cursor.getCount());
-
- cursor.moveToNext();
- assertEquals(0x400000000L, cursor.getLong(0));
- }
-
- public void testFindDocumentPath_singleStorage_toRoot() throws Exception {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- setupRoots(0, new MtpRoot[] { new MtpRoot(0, 0, "Storage", 1000, 1000, "") });
- setupHierarchyDocuments("1");
-
- final Path path = mProvider.findDocumentPath(null, "15");
- assertEquals("1", path.getRootId());
- assertEquals(4, path.getPath().size());
- assertEquals("1", path.getPath().get(0));
- assertEquals("3", path.getPath().get(1));
- assertEquals("6", path.getPath().get(2));
- assertEquals("15", path.getPath().get(3));
- }
-
- public void testFindDocumentPath_singleStorage_toDoc() throws Exception {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- setupRoots(0, new MtpRoot[] { new MtpRoot(0, 0, "Storage", 1000, 1000, "") });
- setupHierarchyDocuments("1");
-
- final Path path = mProvider.findDocumentPath("3", "18");
- assertNull(path.getRootId());
- assertEquals(3, path.getPath().size());
- assertEquals("3", path.getPath().get(0));
- assertEquals("7", path.getPath().get(1));
- assertEquals("18", path.getPath().get(2));
- }
-
- public void testFindDocumentPath_multiStorage_toRoot() throws Exception {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- setupRoots(0, new MtpRoot[] {
- new MtpRoot(0, 0, "Storage A", 1000, 1000, ""),
- new MtpRoot(0, 1, "Storage B", 1000, 1000, "") });
- setupHierarchyDocuments("2");
-
- final Path path = mProvider.findDocumentPath(null, "16");
- assertEquals("2", path.getRootId());
- assertEquals(4, path.getPath().size());
- assertEquals("2", path.getPath().get(0));
- assertEquals("4", path.getPath().get(1));
- assertEquals("7", path.getPath().get(2));
- assertEquals("16", path.getPath().get(3));
- }
-
- public void testFindDocumentPath_multiStorage_toDoc() throws Exception {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- setupRoots(0, new MtpRoot[] {
- new MtpRoot(0, 0, "Storage A", 1000, 1000, ""),
- new MtpRoot(0, 1, "Storage B", 1000, 1000, "") });
- setupHierarchyDocuments("2");
-
- final Path path = mProvider.findDocumentPath("4", "19");
- assertNull(path.getRootId());
- assertEquals(3, path.getPath().size());
- assertEquals("4", path.getPath().get(0));
- assertEquals("8", path.getPath().get(1));
- assertEquals("19", path.getPath().get(2));
- }
-
- public void testIsChildDocument() throws Exception {
- setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- setupRoots(0, new MtpRoot[] { new MtpRoot(0, 0, "Storage", 1000, 1000, "") });
- setupHierarchyDocuments("1");
- assertTrue(mProvider.isChildDocument("1", "1"));
- assertTrue(mProvider.isChildDocument("1", "14"));
- assertTrue(mProvider.isChildDocument("2", "14"));
- assertTrue(mProvider.isChildDocument("5", "14"));
- assertFalse(mProvider.isChildDocument("3", "14"));
- assertFalse(mProvider.isChildDocument("6", "14"));
- }
-
- private void setupProvider(int flag) {
- mDatabase = new MtpDatabase(getContext(), flag);
- mProvider = new MtpDocumentsProvider();
- final StorageManager storageManager = getContext().getSystemService(StorageManager.class);
- assertTrue(mProvider.onCreateForTesting(
- getContext(),
- mResources,
- mMtpManager,
- mResolver,
- mDatabase,
- storageManager,
- new TestServiceIntentSender()));
- }
-
- private String[] getStrings(Cursor cursor) {
- try {
- final String[] results = new String[cursor.getCount()];
- for (int i = 0; cursor.moveToNext(); i++) {
- results[i] = cursor.getString(0);
- }
- return results;
- } finally {
- cursor.close();
- }
- }
-
- private String[] setupRoots(int deviceId, MtpRoot[] roots)
- throws InterruptedException, TimeoutException, IOException {
- final int changeCount = mResolver.getChangeCount(ROOTS_URI);
- mMtpManager.addValidDevice(
- new MtpDeviceRecord(deviceId, "Device", null /* deviceKey */, false /* unopened */,
- roots, OPERATIONS_SUPPORTED, null));
- mProvider.openDevice(deviceId);
- mResolver.waitForNotification(ROOTS_URI, changeCount + 1);
- return getStrings(mProvider.queryRoots(strings(DocumentsContract.Root.COLUMN_ROOT_ID)));
- }
-
- private String[] setupDocuments(
- int deviceId,
- int storageId,
- int parentHandle,
- String parentDocumentId,
- MtpObjectInfo[] objects) throws FileNotFoundException {
- final int[] handles = new int[objects.length];
- int i = 0;
- for (final MtpObjectInfo info : objects) {
- handles[i++] = info.getObjectHandle();
- mMtpManager.setObjectInfo(deviceId, info);
- }
- mMtpManager.setObjectHandles(deviceId, storageId, parentHandle, handles);
- return getStrings(mProvider.queryChildDocuments(
- parentDocumentId,
- strings(DocumentsContract.Document.COLUMN_DOCUMENT_ID),
- (String) null));
- }
-
- static class HierarchyDocument {
- int depth;
- String documentId;
- int objectHandle;
- int parentHandle;
-
- HierarchyDocument createChildDocument(int newHandle) {
- final HierarchyDocument doc = new HierarchyDocument();
- doc.depth = depth - 1;
- doc.objectHandle = newHandle;
- doc.parentHandle = objectHandle;
- return doc;
- }
-
- MtpObjectInfo toObjectInfo() {
- return new MtpObjectInfo.Builder()
- .setName("doc_" + documentId)
- .setFormat(depth > 0 ?
- MtpConstants.FORMAT_ASSOCIATION : MtpConstants.FORMAT_TEXT)
- .setObjectHandle(objectHandle)
- .setParent(parentHandle)
- .build();
- }
- }
-
- private void setupHierarchyDocuments(String documentId) throws Exception {
- final Queue<HierarchyDocument> ids = new LinkedList<>();
- final HierarchyDocument firstDocument = new HierarchyDocument();
- firstDocument.depth = 3;
- firstDocument.documentId = documentId;
- firstDocument.objectHandle = MtpManager.OBJECT_HANDLE_ROOT_CHILDREN;
- ids.add(firstDocument);
-
- int objectHandle = 100;
- while (!ids.isEmpty()) {
- final HierarchyDocument document = ids.remove();
- final HierarchyDocument[] children = new HierarchyDocument[] {
- document.createChildDocument(objectHandle++),
- document.createChildDocument(objectHandle++),
- document.createChildDocument(objectHandle++),
- };
- final String[] childDocIds = setupDocuments(
- 0, 0, document.objectHandle, document.documentId, new MtpObjectInfo[] {
- children[0].toObjectInfo(),
- children[1].toObjectInfo(),
- children[2].toObjectInfo(),
- });
- children[0].documentId = childDocIds[0];
- children[1].documentId = childDocIds[1];
- children[2].documentId = childDocIds[2];
-
- if (children[0].depth > 0) {
- ids.add(children[0]);
- ids.add(children[1]);
- ids.add(children[2]);
- }
- }
- }
-}
diff --git a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/MtpManagerTest.java b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/MtpManagerTest.java
deleted file mode 100644
index 5ada14f..0000000
--- a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/MtpManagerTest.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.mtp;
-
-import android.content.Context;
-import android.hardware.usb.UsbDevice;
-import android.hardware.usb.UsbManager;
-import android.mtp.MtpConstants;
-import android.mtp.MtpEvent;
-import android.mtp.MtpObjectInfo;
-import android.os.CancellationSignal;
-import android.os.OperationCanceledException;
-import android.os.ParcelFileDescriptor;
-import android.os.SystemClock;
-import android.test.InstrumentationTestCase;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.concurrent.Callable;
-import java.util.concurrent.FutureTask;
-import java.util.concurrent.TimeUnit;
-
-@RealDeviceTest
-public class MtpManagerTest extends InstrumentationTestCase {
- private static final int TIMEOUT_MS = 1000;
- UsbManager mUsbManager;
- MtpManager mManager;
- UsbDevice mUsbDevice;
-
- @Override
- public void setUp() throws Exception {
- mUsbManager = getContext().getSystemService(UsbManager.class);
- mManager = new MtpManager(getContext());
- mUsbDevice = TestUtil.setupMtpDevice(getInstrumentation(), mUsbManager, mManager);
- }
-
- @Override
- public void tearDown() throws IOException {
- mManager.closeDevice(mUsbDevice.getDeviceId());
- }
-
- @Override
- public TestResultInstrumentation getInstrumentation() {
- return (TestResultInstrumentation) super.getInstrumentation();
- }
-
- public void testCancelEvent() throws Exception {
- final CancellationSignal signal = new CancellationSignal();
- final FutureTask<Boolean> future = new FutureTask<Boolean>(
- new Callable<Boolean>() {
- @Override
- public Boolean call() throws IOException {
- try {
- while (true) {
- mManager.readEvent(mUsbDevice.getDeviceId(), signal);
- }
- } catch (OperationCanceledException exception) {
- return true;
- }
- }
- });
- final Thread thread = new Thread(future);
- thread.start();
- SystemClock.sleep(TIMEOUT_MS);
- signal.cancel();
- assertTrue(future.get(TIMEOUT_MS, TimeUnit.MILLISECONDS));
- }
-
- public void testOperationsSupported() {
- final MtpDeviceRecord[] records = mManager.getDevices();
- assertEquals(1, records.length);
- assertNotNull(records[0].operationsSupported);
- getInstrumentation().show(Arrays.toString(records[0].operationsSupported));
- }
-
- public void testEventsSupported() {
- final MtpDeviceRecord[] records = mManager.getDevices();
- assertEquals(1, records.length);
- assertNotNull(records[0].eventsSupported);
- getInstrumentation().show(Arrays.toString(records[0].eventsSupported));
- }
-
- public void testDeviceKey() {
- final MtpDeviceRecord[] records = mManager.getDevices();
- assertEquals(1, records.length);
- assertNotNull(records[0].deviceKey);
- getInstrumentation().show("deviceKey: " + records[0].deviceKey);
- }
-
- public void testEventObjectAdded() throws Exception {
- while (true) {
- getInstrumentation().show("Please take a photo by using connected MTP device.");
- final CancellationSignal signal = new CancellationSignal();
- MtpEvent event = mManager.readEvent(mUsbDevice.getDeviceId(), signal);
- if (event.getEventCode() != MtpEvent.EVENT_OBJECT_ADDED) {
- continue;
- }
- assertTrue(event.getObjectHandle() != 0);
- break;
- }
- }
-
- public void testCreateDocumentAndGetPartialObject() throws Exception {
- int storageId = 0;
- for (final MtpDeviceRecord record : mManager.getDevices()) {
- if (record.deviceId == mUsbDevice.getDeviceId()) {
- storageId = record.roots[0].mStorageId;
- break;
- }
- }
- assertTrue("Valid storage not found.", storageId != 0);
-
- final String testFileName = "MtpManagerTest_testFile.txt";
- for (final int handle : mManager.getObjectHandles(
- mUsbDevice.getDeviceId(), storageId, MtpManager.OBJECT_HANDLE_ROOT_CHILDREN)) {
- if (mManager.getObjectInfo(mUsbDevice.getDeviceId(), handle)
- .getName().equals(testFileName)) {
- mManager.deleteDocument(mUsbDevice.getDeviceId(), handle);
- break;
- }
- }
-
- final ParcelFileDescriptor[] fds = ParcelFileDescriptor.createPipe();
- final byte[] expectedBytes = "Hello Android!".getBytes("ascii");
- try (final ParcelFileDescriptor.AutoCloseOutputStream stream =
- new ParcelFileDescriptor.AutoCloseOutputStream(fds[1])) {
- stream.write(expectedBytes);
- }
- final int objectHandle = mManager.createDocument(
- mUsbDevice.getDeviceId(),
- new MtpObjectInfo.Builder()
- .setStorageId(storageId)
- .setName(testFileName)
- .setCompressedSize(expectedBytes.length)
- .setFormat(MtpConstants.FORMAT_TEXT)
- .build(),
- fds[0]);
- final byte[] bytes = new byte[100];
- assertEquals(5, mManager.getPartialObject(
- mUsbDevice.getDeviceId(), objectHandle, 0, 5, bytes));
- assertEquals("Hello", new String(bytes, 0, 5, "ascii"));
- assertEquals(8, mManager.getPartialObject(
- mUsbDevice.getDeviceId(), objectHandle, 6, 100, bytes));
- assertEquals("Android!", new String(bytes, 0, 8, "ascii"));
- }
-
- private Context getContext() {
- return getInstrumentation().getContext();
- }
-}
diff --git a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/PipeManagerTest.java b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/PipeManagerTest.java
deleted file mode 100644
index 53dc3db..0000000
--- a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/PipeManagerTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.mtp;
-
-import android.os.ParcelFileDescriptor;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-
-import java.io.IOException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-@MediumTest
-public class PipeManagerTest extends AndroidTestCase {
- private static final byte[] HELLO_BYTES = new byte[] { 'h', 'e', 'l', 'l', 'o' };
-
- private TestMtpManager mtpManager;
- private ExecutorService mExecutor;
- private PipeManager mPipeManager;
- private MtpDatabase mDatabase;
-
- @Override
- public void setUp() {
- mtpManager = new TestMtpManager(getContext());
- mExecutor = Executors.newSingleThreadExecutor();
- mDatabase = new MtpDatabase(getContext(), MtpDatabaseConstants.FLAG_DATABASE_IN_MEMORY);
- mPipeManager = new PipeManager(mDatabase, mExecutor);
- }
-
- @Override
- protected void tearDown() throws Exception {
- assertTrue(mPipeManager.close());
- mDatabase.close();
- }
-
- public void testReadDocument_basic() throws Exception {
- mtpManager.setImportFileBytes(0, 1, HELLO_BYTES);
- final ParcelFileDescriptor descriptor = mPipeManager.readDocument(
- mtpManager,
- new Identifier(0, 0, 1, null, MtpDatabaseConstants.DOCUMENT_TYPE_OBJECT));
- assertDescriptor(descriptor, HELLO_BYTES);
- }
-
- public void testReadDocument_error() throws Exception {
- final ParcelFileDescriptor descriptor = mPipeManager.readDocument(
- mtpManager,
- new Identifier(0, 0, 1, null, MtpDatabaseConstants.DOCUMENT_TYPE_OBJECT));
- assertDescriptorError(descriptor);
- }
-
- public void testReadThumbnail_basic() throws Exception {
- mtpManager.setThumbnail(0, 1, HELLO_BYTES);
- final ParcelFileDescriptor descriptor = mPipeManager.readThumbnail(
- mtpManager,
- new Identifier(0, 0, 1, null, MtpDatabaseConstants.DOCUMENT_TYPE_OBJECT));
- assertDescriptor(descriptor, HELLO_BYTES);
- }
-
- public void testReadThumbnail_error() throws Exception {
- final ParcelFileDescriptor descriptor = mPipeManager.readThumbnail(
- mtpManager,
- new Identifier(0, 0, 1, null, MtpDatabaseConstants.DOCUMENT_TYPE_OBJECT));
- assertDescriptorError(descriptor);
- }
-
- private void assertDescriptor(ParcelFileDescriptor descriptor, byte[] expectedBytes)
- throws IOException, InterruptedException {
- mExecutor.shutdown();
- assertTrue(mExecutor.awaitTermination(1000, TimeUnit.MILLISECONDS));
- try (final ParcelFileDescriptor.AutoCloseInputStream stream =
- new ParcelFileDescriptor.AutoCloseInputStream(descriptor)) {
- byte[] results = new byte[100];
- assertEquals(expectedBytes.length, stream.read(results));
- for (int i = 0; i < expectedBytes.length; i++) {
- assertEquals(expectedBytes[i], results[i]);
- }
- }
- }
-
- private void assertDescriptorError(ParcelFileDescriptor descriptor)
- throws InterruptedException {
- mExecutor.shutdown();
- assertTrue(mExecutor.awaitTermination(1000, TimeUnit.MILLISECONDS));
- try {
- descriptor.checkError();
- fail();
- } catch (Throwable error) {
- assertTrue(error instanceof IOException);
- }
- }
-}
diff --git a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/RealDeviceTest.java b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/RealDeviceTest.java
deleted file mode 100644
index 22daaf29..0000000
--- a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/RealDeviceTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.mtp;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE, ElementType.METHOD})
-@interface RealDeviceTest {}
diff --git a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestContentResolver.java b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestContentResolver.java
deleted file mode 100644
index 7e772c3..0000000
--- a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestContentResolver.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.mtp;
-
-import android.database.ContentObserver;
-import android.net.Uri;
-import android.test.mock.MockContentResolver;
-
-import junit.framework.Assert;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.Phaser;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-class TestContentResolver extends MockContentResolver {
- private static final int TIMEOUT_PERIOD_MS = 3000;
- private final Map<Uri, Phaser> mPhasers = new HashMap<>();
-
- @Override
- public void notifyChange(Uri uri, ContentObserver observer, boolean syncToNetwork) {
- getPhaser(uri).arrive();
- }
-
-
- void waitForNotification(Uri uri, int count) throws InterruptedException, TimeoutException {
- Assert.assertEquals(count, getPhaser(uri).awaitAdvanceInterruptibly(
- count - 1, TIMEOUT_PERIOD_MS, TimeUnit.MILLISECONDS));
- }
-
- int getChangeCount(Uri uri) {
- if (mPhasers.containsKey(uri)) {
- return mPhasers.get(uri).getPhase();
- } else {
- return 0;
- }
- }
-
- private synchronized Phaser getPhaser(Uri uri) {
- Phaser phaser = mPhasers.get(uri);
- if (phaser == null) {
- phaser = new Phaser(1);
- mPhasers.put(uri, phaser);
- }
- return phaser;
- }
-}
diff --git a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestMtpManager.java b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestMtpManager.java
deleted file mode 100644
index f20bbec..0000000
--- a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestMtpManager.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.mtp;
-
-import android.content.Context;
-import android.mtp.MtpObjectInfo;
-import android.os.ParcelFileDescriptor;
-import android.util.SparseArray;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import junit.framework.Assert;
-
-public class TestMtpManager extends MtpManager {
- public static final int CREATED_DOCUMENT_HANDLE = 1000;
-
- protected static String pack(int... args) {
- return Arrays.toString(args);
- }
-
- private final SparseArray<MtpDeviceRecord> mDevices = new SparseArray<>();
- private final Map<String, MtpObjectInfo> mObjectInfos = new HashMap<>();
- private final Map<String, int[]> mObjectHandles = new HashMap<>();
- private final Map<String, byte[]> mThumbnailBytes = new HashMap<>();
- private final Map<String, byte[]> mImportFileBytes = new HashMap<>();
- private final Map<String, Long> mObjectSizeLongs = new HashMap<>();
-
- TestMtpManager(Context context) {
- super(context);
- }
-
- void addValidDevice(MtpDeviceRecord device) {
- mDevices.put(device.deviceId, device);
- }
-
- void setObjectHandles(int deviceId, int storageId, int parentHandle, int[] objectHandles) {
- mObjectHandles.put(pack(deviceId, storageId, parentHandle), objectHandles);
- }
-
- void setObjectInfo(int deviceId, MtpObjectInfo objectInfo) {
- mObjectInfos.put(pack(deviceId, objectInfo.getObjectHandle()), objectInfo);
- }
-
- void setImportFileBytes(int deviceId, int objectHandle, byte[] bytes) {
- mImportFileBytes.put(pack(deviceId, objectHandle), bytes);
- }
-
- byte[] getImportFileBytes(int deviceId, int objectHandle) {
- return mImportFileBytes.get(pack(deviceId, objectHandle));
- }
-
- void setThumbnail(int deviceId, int objectHandle, byte[] bytes) {
- mThumbnailBytes.put(pack(deviceId, objectHandle), bytes);
- }
-
- void setObjectSizeLong(int deviceId, int objectHandle, int format, long value) {
- mObjectSizeLongs.put(pack(deviceId, objectHandle, format), value);
- }
-
- @Override
- synchronized MtpDeviceRecord[] getDevices() {
- final MtpDeviceRecord[] result = new MtpDeviceRecord[mDevices.size()];
- for (int i = 0; i < mDevices.size(); i++) {
- final MtpDeviceRecord device = mDevices.valueAt(i);
- if (device.opened) {
- result[i] = device;
- } else {
- result[i] = new MtpDeviceRecord(
- device.deviceId, device.name, device.deviceKey, device.opened,
- new MtpRoot[0], null, null);
- }
- }
- return result;
- }
-
- @Override
- synchronized MtpDeviceRecord openDevice(int deviceId) throws IOException {
- final MtpDeviceRecord device = mDevices.get(deviceId);
- if (device == null) {
- throw new IOException();
- }
- final MtpDeviceRecord record = new MtpDeviceRecord(
- device.deviceId, device.name, device.deviceKey, true, device.roots,
- device.operationsSupported, device.eventsSupported);
- mDevices.put(deviceId, record);
- return record;
- }
-
- @Override
- synchronized void closeDevice(int deviceId) throws IOException {
- final MtpDeviceRecord device = mDevices.get(deviceId);
- if (device == null) {
- throw new IOException();
- }
- mDevices.put(
- deviceId,
- new MtpDeviceRecord(device.deviceId, device.name, device.deviceKey, false,
- device.roots, device.operationsSupported, device.eventsSupported));
- }
-
- @Override
- MtpObjectInfo getObjectInfo(int deviceId, int objectHandle) throws IOException {
- final String key = pack(deviceId, objectHandle);
- if (mObjectInfos.containsKey(key)) {
- return mObjectInfos.get(key);
- } else {
- throw new IOException("getObjectInfo error: " + key);
- }
- }
-
- @Override
- int[] getObjectHandles(int deviceId, int storageId, int parentObjectHandle) throws IOException {
- final String key = pack(deviceId, storageId, parentObjectHandle);
- if (mObjectHandles.containsKey(key)) {
- return mObjectHandles.get(key);
- } else {
- throw new IOException("getObjectHandles error: " + key);
- }
- }
-
- @Override
- void importFile(int deviceId, int objectHandle, ParcelFileDescriptor target)
- throws IOException {
- final String key = pack(deviceId, objectHandle);
- if (mImportFileBytes.containsKey(key)) {
- try (final ParcelFileDescriptor.AutoCloseOutputStream outputStream =
- new ParcelFileDescriptor.AutoCloseOutputStream(target)) {
- outputStream.write(mImportFileBytes.get(key));
- }
- } else {
- throw new IOException("importFile error: " + key);
- }
- }
-
- @Override
- int createDocument(int deviceId, MtpObjectInfo objectInfo, ParcelFileDescriptor source)
- throws IOException {
- Assert.assertNotSame(0, objectInfo.getStorageId());
- Assert.assertNotSame(-1, objectInfo.getStorageId());
- Assert.assertNotSame(0, objectInfo.getParent());
- final String key = pack(deviceId, CREATED_DOCUMENT_HANDLE);
- if (mObjectInfos.containsKey(key)) {
- throw new IOException();
- }
- final MtpObjectInfo newInfo = new MtpObjectInfo.Builder(objectInfo).
- setObjectHandle(CREATED_DOCUMENT_HANDLE).build();
- mObjectInfos.put(key, newInfo);
- if (objectInfo.getFormat() != 0x3001) {
- try (final ParcelFileDescriptor.AutoCloseInputStream inputStream =
- new ParcelFileDescriptor.AutoCloseInputStream(source)) {
- final byte[] buffer = new byte[objectInfo.getCompressedSize()];
- if (inputStream.read(buffer, 0, objectInfo.getCompressedSize()) !=
- objectInfo.getCompressedSize()) {
- throw new IOException();
- }
-
- mImportFileBytes.put(pack(deviceId, CREATED_DOCUMENT_HANDLE), buffer);
- }
- }
- return CREATED_DOCUMENT_HANDLE;
- }
-
- @Override
- byte[] getThumbnail(int deviceId, int objectHandle) throws IOException {
- final String key = pack(deviceId, objectHandle);
- if (mThumbnailBytes.containsKey(key)) {
- return mThumbnailBytes.get(key);
- } else {
- throw new IOException("getThumbnail error: " + key);
- }
- }
-
- @Override
- void deleteDocument(int deviceId, int objectHandle) throws IOException {
- final String key = pack(deviceId, objectHandle);
- if (mObjectInfos.containsKey(key)) {
- mObjectInfos.remove(key);
- } else {
- throw new IOException();
- }
- }
-
- @Override
- int getParent(int deviceId, int objectHandle) throws IOException {
- final String key = pack(deviceId, objectHandle);
- if (mObjectInfos.containsKey(key)) {
- return mObjectInfos.get(key).getParent();
- } else {
- throw new IOException();
- }
- }
-
- @Override
- byte[] getObject(int deviceId, int objectHandle, int expectedSize) throws IOException {
- return mImportFileBytes.get(pack(deviceId, objectHandle));
- }
-
- @Override
- long getPartialObject(int deviceId, int objectHandle, long offset, long size, byte[] buffer)
- throws IOException {
- final byte[] bytes = mImportFileBytes.get(pack(deviceId, objectHandle));
- int i = 0;
- while (i < size && i + offset < bytes.length) {
- buffer[i] = bytes[(int) (i + offset)];
- i++;
- }
- return i;
- }
-
- @Override
- long getObjectSizeLong(int deviceId, int objectHandle, int format) throws IOException {
- final String key = pack(deviceId, objectHandle, format);
- if (mObjectSizeLongs.containsKey(key)) {
- return mObjectSizeLongs.get(key);
- } else {
- throw new IOException();
- }
- }
-}
diff --git a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestResources.java b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestResources.java
deleted file mode 100644
index 8676b5a..0000000
--- a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestResources.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.mtp;
-
-import android.test.mock.MockResources;
-
-class TestResources extends MockResources {
- @Override
- public String getString(int id) throws NotFoundException {
- switch (id) {
- case R.string.root_name:
- return "%1$s %2$s";
- case R.string.error_busy_device:
- return "error_busy_device";
- case R.string.error_locked_device:
- return "error_locked_device";
- }
- throw new NotFoundException();
- }
-
- @Override
- public String getString(int id, Object... formatArgs) throws NotFoundException {
- return String.format(getString(id), formatArgs);
- }
-}
diff --git a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestResultActivity.java b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestResultActivity.java
deleted file mode 100644
index 9f2bb2a..0000000
--- a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestResultActivity.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.mtp;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.ViewGroup.LayoutParams;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-
-/**
- * Activity that shows the test results instead of adb while using USB port to connect MTP device.
- */
-public class TestResultActivity extends Activity {
- private final static String TAG = "MtpDocumentsProviderTest";
- private TextView mTextView;
-
- static void show(Context context, String message) {
- Log.d(TAG, message);
- final Intent intent = new Intent(context, TestResultActivity.class);
- intent.putExtra("message", message);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(intent);
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- final LinearLayout linearLayout = new LinearLayout(this);
- linearLayout.setOrientation(LinearLayout.VERTICAL);
- setContentView(linearLayout);
-
- mTextView = new TextView(this);
- mTextView.setText(getIntent().getStringExtra("message") + "\n");
- linearLayout.addView(
- mTextView, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
- }
-
- @Override
- protected void onNewIntent(Intent intent) {
- super.onNewIntent(intent);
- mTextView.setText(mTextView.getText() + intent.getStringExtra("message") + "\n");
- }
-}
diff --git a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestResultInstrumentation.java b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestResultInstrumentation.java
deleted file mode 100644
index 4e4cf78..0000000
--- a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestResultInstrumentation.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.mtp;
-
-import android.os.Bundle;
-import android.test.InstrumentationTestRunner;
-
-import junit.framework.AssertionFailedError;
-import junit.framework.Test;
-import junit.framework.TestListener;
-
-/**
- * Instrumentation that can show the test result in the TestResultActivity.
- * It's useful when it runs testcases with a real USB device and could not use USB port for ADB.
- */
-public class TestResultInstrumentation extends InstrumentationTestRunner implements TestListener {
- private boolean mHasError = false;
-
- @Override
- public void onCreate(Bundle arguments) {
- if (arguments == null) {
- arguments = new Bundle();
- }
- final boolean includeRealDeviceTest =
- Boolean.parseBoolean(arguments.getString("realDeviceTest", "false"));
- if (!includeRealDeviceTest) {
- arguments.putString("notAnnotation", "com.android.mtp.RealDeviceTest");
- }
- super.onCreate(arguments);
- if (includeRealDeviceTest) {
- // Show the test result by using activity because we need to disconnect USB cable
- // from adb host while testing with real MTP device.
- addTestListener(this);
- }
- }
-
- @Override
- public void addError(Test test, Throwable t) {
- mHasError = true;
- show("ERROR", test, t);
- }
-
- @Override
- public void addFailure(Test test, AssertionFailedError t) {
- mHasError = true;
- show("FAIL", test, t);
- }
-
- @Override
- public void endTest(Test test) {
- if (!mHasError) {
- show("PASS", test, null);
- }
- }
-
- @Override
- public void startTest(Test test) {
- mHasError = false;
- }
-
- void show(String message) {
- TestResultActivity.show(getContext(), " " + message);
- }
-
- private void show(String tag, Test test, Throwable t) {
- String message = "";
- if (t != null && t.getMessage() != null) {
- message = t.getMessage();
- }
- TestResultActivity.show(
- getContext(), String.format("[%s] %s %s", tag, test.toString(), message));
- }
-}
diff --git a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestServiceIntentSender.java b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestServiceIntentSender.java
deleted file mode 100644
index 17b3086..0000000
--- a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestServiceIntentSender.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.mtp;
-
-class TestServiceIntentSender extends ServiceIntentSender {
- @Override
- void sendUpdateNotificationIntent(MtpDeviceRecord[] record) {}
-}
diff --git a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestUtil.java b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestUtil.java
deleted file mode 100644
index 8805d19..0000000
--- a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestUtil.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.mtp;
-
-import android.hardware.usb.UsbDevice;
-import android.hardware.usb.UsbDeviceConnection;
-import android.hardware.usb.UsbManager;
-import android.mtp.MtpConstants;
-import android.os.SystemClock;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Objects;
-
-/**
- * Static utility methods for testing.
- */
-final class TestUtil {
- private TestUtil() {}
-
- static final int[] OPERATIONS_SUPPORTED = new int[] {
- MtpConstants.OPERATION_GET_PARTIAL_OBJECT,
- MtpConstants.OPERATION_SEND_OBJECT,
- MtpConstants.OPERATION_SEND_OBJECT_INFO,
- MtpConstants.OPERATION_DELETE_OBJECT,
- MtpConstants.OPERATION_GET_OBJECT_PROP_DESC,
- MtpConstants.OPERATION_GET_OBJECT_PROP_VALUE
- };
-
- /**
- * Requests permission for a MTP device and returns the first MTP device that has at least one
- * storage.
- */
- static UsbDevice setupMtpDevice(
- TestResultInstrumentation instrumentation,
- UsbManager usbManager,
- MtpManager manager) {
- while (true) {
- try {
- final UsbDevice device = findMtpDevice(usbManager, manager);
- waitForStorages(instrumentation, manager, device.getDeviceId());
- return device;
- } catch (IOException exp) {
- instrumentation.show(Objects.toString(exp.getMessage()));
- SystemClock.sleep(1000);
- // When the MTP device is Android, and it changes the USB device type from
- // "Charging" to "MTP", the device ID will be updated. We need to find a device
- // again.
- continue;
- }
- }
- }
-
- static void addTestDevice(MtpDatabase database) throws FileNotFoundException {
- database.getMapper().startAddingDocuments(null);
- database.getMapper().putDeviceDocument(new MtpDeviceRecord(
- 0, "Device", "device_key", /* opened is */ true, new MtpRoot[0],
- OPERATIONS_SUPPORTED, null));
- database.getMapper().stopAddingDocuments(null);
- }
-
- static void addTestStorage(MtpDatabase database, String parentId) throws FileNotFoundException {
- database.getMapper().startAddingDocuments(parentId);
- database.getMapper().putStorageDocuments(parentId, OPERATIONS_SUPPORTED, new MtpRoot[] {
- new MtpRoot(0, 100, "Storage", 1024, 1024, ""),
- });
- database.getMapper().stopAddingDocuments(parentId);
- }
-
- private static UsbDevice findMtpDevice(
- UsbManager usbManager,
- MtpManager manager) throws IOException {
- final HashMap<String,UsbDevice> devices = usbManager.getDeviceList();
- if (devices.size() == 0) {
- throw new IOException("Device not found.");
- }
- final UsbDevice device = devices.values().iterator().next();
- // Tries to get ownership of the device in case that another application use it.
- if (usbManager.hasPermission(device)) {
- final UsbDeviceConnection connection = usbManager.openDevice(device);
- for (int i = 0; i < device.getInterfaceCount(); i++) {
- // Since the test runs real environment, we need to call claim interface with
- // force = true to rob interfaces from other applications.
- connection.claimInterface(device.getInterface(i), true);
- connection.releaseInterface(device.getInterface(i));
- }
- connection.close();
- }
- manager.openDevice(device.getDeviceId());
- return device;
- }
-
- private static void waitForStorages(
- TestResultInstrumentation instrumentation,
- MtpManager manager,
- int deviceId) throws IOException {
- while (true) {
- MtpDeviceRecord device = null;
- for (final MtpDeviceRecord deviceCandidate : manager.getDevices()) {
- if (deviceCandidate.deviceId == deviceId) {
- device = deviceCandidate;
- break;
- }
- }
- if (device == null) {
- throw new IOException("Device was detached.");
- }
- if (device.roots.length == 0) {
- instrumentation.show("Wait for storages.");
- SystemClock.sleep(1000);
- continue;
- }
- return;
- }
- }
-}