1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 import android.accounts.Account; 18 import android.annotation.UserIdInt; 19 import android.content.ContentResolver; 20 import android.content.SyncAdapterType; 21 import android.content.SyncInfo; 22 import android.os.Bundle; 23 24 import java.util.List; 25 26 public class ContentResolverCompat { getSyncAutomaticallyAsUser( Account account, String authority, @UserIdInt int userId)27 public static boolean getSyncAutomaticallyAsUser( 28 Account account, String authority, @UserIdInt int userId) { 29 return ContentResolver.getSyncAutomaticallyAsUser(account, authority, userId); 30 } 31 getCurrentSyncsAsUser(@serIdInt int userId)32 public static List<SyncInfo> getCurrentSyncsAsUser(@UserIdInt int userId) { 33 return ContentResolver.getCurrentSyncsAsUser(userId); 34 } 35 getSyncStatusAsUser(Account account, String authority, @UserIdInt int userId)36 public static SyncStatusInfoCompat getSyncStatusAsUser(Account account, String authority, 37 38 @UserIdInt int userId) { 39 return new SyncStatusInfoCompat( 40 ContentResolver.getSyncStatusAsUser(account, authority, userId)); 41 } 42 43 public static final int SYNC_OBSERVER_TYPE_STATUS = 1 << 3; 44 getIsSyncableAsUser( Account account, String authority, @UserIdInt int userId)45 public static int getIsSyncableAsUser( 46 Account account, String authority, @UserIdInt int userId) { 47 return ContentResolver.getIsSyncableAsUser(account, authority, userId); 48 } 49 setSyncAutomaticallyAsUser( Account account, String authority, boolean sync, @UserIdInt int userId)50 public static void setSyncAutomaticallyAsUser( 51 Account account, String authority, boolean sync, @UserIdInt int userId) { 52 ContentResolver.setSyncAutomaticallyAsUser(account, authority, sync, userId); 53 } 54 getMasterSyncAutomaticallyAsUser(@serIdInt int userId)55 public static boolean getMasterSyncAutomaticallyAsUser(@UserIdInt int userId) { 56 return ContentResolver.getMasterSyncAutomaticallyAsUser(userId); 57 } 58 getSyncAdapterTypesAsUser(@serIdInt int userId)59 public static SyncAdapterType[] getSyncAdapterTypesAsUser(@UserIdInt int userId) { 60 return ContentResolver.getSyncAdapterTypesAsUser(userId); 61 } 62 63 public static final int SYNC_ERROR_SYNC_ALREADY_IN_PROGRESS = 1; 64 requestSyncAsUser( Account account, String authority, @UserIdInt int userId, Bundle extras)65 public static void requestSyncAsUser( 66 Account account, String authority, @UserIdInt int userId, Bundle extras) { 67 ContentResolver.requestSyncAsUser(account, authority, userId, extras); 68 } 69 cancelSyncAsUser(Account account, String authority, @UserIdInt int userId)70 public static void cancelSyncAsUser(Account account, String authority, @UserIdInt int userId) { 71 ContentResolver.cancelSyncAsUser(account, authority, userId); 72 } 73 } 74