Set Root.FLAG_LOCAL_ONLY for MTP roots.
The flag indicate whether the root needs network access or not. MTP
should be LOCAL_ONLY root.
Bug: 30867267
Change-Id: Ia272d4a389cc1ca628d7b963caa37f3dbb6747e3
(cherry picked from commit 83c679e722)
This commit is contained in:
@@ -873,7 +873,7 @@ class MtpDatabase {
|
||||
}
|
||||
|
||||
private static int getRootFlags(int[] operationsSupported) {
|
||||
int rootFlag = Root.FLAG_SUPPORTS_IS_CHILD;
|
||||
int rootFlag = Root.FLAG_SUPPORTS_IS_CHILD | Root.FLAG_LOCAL_ONLY;
|
||||
if (MtpDeviceRecord.isWritingSupported(operationsSupported)) {
|
||||
rootFlag |= Root.FLAG_SUPPORTS_CREATE;
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public class MtpDatabaseTest extends AndroidTestCase {
|
||||
cursor.moveToNext();
|
||||
assertEquals(1, getInt(cursor, Root.COLUMN_ROOT_ID));
|
||||
assertEquals(
|
||||
Root.FLAG_SUPPORTS_IS_CHILD | Root.FLAG_SUPPORTS_CREATE,
|
||||
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));
|
||||
|
||||
@@ -210,7 +210,11 @@ public class MtpDocumentsProviderTest extends AndroidTestCase {
|
||||
assertEquals(2, cursor.getCount());
|
||||
cursor.moveToNext();
|
||||
assertEquals("1", cursor.getString(0));
|
||||
assertEquals(Root.FLAG_SUPPORTS_IS_CHILD | Root.FLAG_SUPPORTS_CREATE, cursor.getInt(1));
|
||||
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));
|
||||
@@ -225,7 +229,8 @@ public class MtpDocumentsProviderTest extends AndroidTestCase {
|
||||
cursor.moveToNext();
|
||||
cursor.moveToNext();
|
||||
assertEquals("2", cursor.getString(0));
|
||||
assertEquals(Root.FLAG_SUPPORTS_IS_CHILD, cursor.getInt(1));
|
||||
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));
|
||||
@@ -271,7 +276,9 @@ public class MtpDocumentsProviderTest extends AndroidTestCase {
|
||||
|
||||
cursor.moveToNext();
|
||||
assertEquals("1", cursor.getString(0));
|
||||
assertEquals(Root.FLAG_SUPPORTS_IS_CHILD | Root.FLAG_SUPPORTS_CREATE, cursor.getInt(1));
|
||||
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));
|
||||
@@ -279,7 +286,9 @@ public class MtpDocumentsProviderTest extends AndroidTestCase {
|
||||
|
||||
cursor.moveToNext();
|
||||
assertEquals("2", cursor.getString(0));
|
||||
assertEquals(Root.FLAG_SUPPORTS_IS_CHILD | Root.FLAG_SUPPORTS_CREATE, cursor.getInt(1));
|
||||
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));
|
||||
|
||||
Reference in New Issue
Block a user