Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2db3415b authored by Fan Wu's avatar Fan Wu Committed by Android (Google) Code Review
Browse files

Merge "Update ShadowContentResolver to extend from the official shadow...

Merge "Update ShadowContentResolver to extend from the official shadow package. Also removes redundant API" into main
parents baa3893b 48bb9fe8
Loading
Loading
Loading
Loading
+3 −18
Original line number Diff line number Diff line
@@ -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<String, Integer> 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