Update ShadowContentResolver to extend from the official shadow package. Also removes redundant API
Bug: 319052511 Test: atest SettingsRoboTests Change-Id: I88ccbb5ca8c239f42c8bc6bb3a875bb4c503bdc9
This commit is contained in:
@@ -16,16 +16,10 @@
|
|||||||
|
|
||||||
package com.android.settings.testutils.shadow;
|
package com.android.settings.testutils.shadow;
|
||||||
|
|
||||||
import static android.provider.SearchIndexablesContract.INDEXABLES_RAW_COLUMNS;
|
|
||||||
|
|
||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
import android.annotation.UserIdInt;
|
import android.annotation.UserIdInt;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.SyncAdapterType;
|
import android.content.SyncAdapterType;
|
||||||
import android.database.Cursor;
|
|
||||||
import android.database.MatrixCursor;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.provider.SearchIndexablesContract;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import org.robolectric.annotation.Implementation;
|
import org.robolectric.annotation.Implementation;
|
||||||
@@ -35,7 +29,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Implements(ContentResolver.class)
|
@Implements(ContentResolver.class)
|
||||||
public class ShadowContentResolver {
|
public class ShadowContentResolver extends org.robolectric.shadows.ShadowContentResolver {
|
||||||
|
|
||||||
private static SyncAdapterType[] sSyncAdapterTypes = new SyncAdapterType[0];
|
private static SyncAdapterType[] sSyncAdapterTypes = new SyncAdapterType[0];
|
||||||
private static Map<String, Integer> sSyncable = new HashMap<>();
|
private static Map<String, Integer> sSyncable = new HashMap<>();
|
||||||
@@ -47,24 +41,15 @@ public class ShadowContentResolver {
|
|||||||
return sSyncAdapterTypes;
|
return sSyncAdapterTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Implementation
|
|
||||||
protected final Cursor query(Uri uri, String[] projection, String selection,
|
|
||||||
String[] selectionArgs, String sortOrder) {
|
|
||||||
MatrixCursor cursor = new MatrixCursor(INDEXABLES_RAW_COLUMNS);
|
|
||||||
MatrixCursor.RowBuilder builder = cursor.newRow()
|
|
||||||
.add(SearchIndexablesContract.NonIndexableKey.COLUMN_KEY_VALUE, "");
|
|
||||||
return cursor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Implementation
|
@Implementation
|
||||||
protected static int getIsSyncableAsUser(Account account, String authority, int userId) {
|
protected static int getIsSyncableAsUser(Account account, String authority, int userId) {
|
||||||
return sSyncable.containsKey(authority) ? sSyncable.get(authority) : 1;
|
return sSyncable.getOrDefault(authority, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Implementation
|
@Implementation
|
||||||
protected static boolean getSyncAutomaticallyAsUser(Account account, String authority,
|
protected static boolean getSyncAutomaticallyAsUser(Account account, String authority,
|
||||||
int userId) {
|
int userId) {
|
||||||
return sSyncAutomatically.containsKey(authority) ? sSyncAutomatically.get(authority) : true;
|
return sSyncAutomatically.getOrDefault(authority, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Implementation
|
@Implementation
|
||||||
|
Reference in New Issue
Block a user