From 48bb9fe8e267453432bdcd30e920f975ef97e0a5 Mon Sep 17 00:00:00 2001 From: Fan Wu Date: Fri, 12 Jan 2024 11:29:49 +0800 Subject: [PATCH] Update ShadowContentResolver to extend from the official shadow package. Also removes redundant API Bug: 319052511 Test: atest SettingsRoboTests Change-Id: I88ccbb5ca8c239f42c8bc6bb3a875bb4c503bdc9 --- .../shadow/ShadowContentResolver.java | 21 +++---------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowContentResolver.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowContentResolver.java index 5d9202fb70e..e259cad1093 100644 --- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowContentResolver.java +++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowContentResolver.java @@ -16,16 +16,10 @@ package com.android.settings.testutils.shadow; -import static android.provider.SearchIndexablesContract.INDEXABLES_RAW_COLUMNS; - import android.accounts.Account; import android.annotation.UserIdInt; import android.content.ContentResolver; 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 org.robolectric.annotation.Implementation; @@ -35,7 +29,7 @@ import java.util.HashMap; import java.util.Map; @Implements(ContentResolver.class) -public class ShadowContentResolver { +public class ShadowContentResolver extends org.robolectric.shadows.ShadowContentResolver { private static SyncAdapterType[] sSyncAdapterTypes = new SyncAdapterType[0]; private static Map sSyncable = new HashMap<>(); @@ -47,24 +41,15 @@ public class ShadowContentResolver { 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 protected static int getIsSyncableAsUser(Account account, String authority, int userId) { - return sSyncable.containsKey(authority) ? sSyncable.get(authority) : 1; + return sSyncable.getOrDefault(authority, 1); } @Implementation protected static boolean getSyncAutomaticallyAsUser(Account account, String authority, int userId) { - return sSyncAutomatically.containsKey(authority) ? sSyncAutomatically.get(authority) : true; + return sSyncAutomatically.getOrDefault(authority, true); } @Implementation