Home | History | Annotate | Download | only in accounts
      1 /*
      2  * Copyright (C) 2016 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 package android.accounts;
     18 
     19 import android.annotation.IntRange;
     20 import android.annotation.NonNull;
     21 import android.os.RemoteCallback;
     22 
     23 /**
     24  * Account manager local system service interface.
     25  *
     26  * @hide Only for use within the system server.
     27  */
     28 public abstract class AccountManagerInternal {
     29 
     30     /**
     31      * Listener for explicit UID account access grant changes.
     32      */
     33     public interface OnAppPermissionChangeListener {
     34 
     35         /**
     36          * Called when the explicit grant state for a given UID to
     37          * access an account changes.
     38          *
     39          * @param account The account
     40          * @param uid The UID for which the grant changed
     41          */
     42         public void onAppPermissionChanged(Account account, int uid);
     43     }
     44 
     45     /**
     46      * Requests that a given package is given access to an account.
     47      * The provided callback will be invoked with a {@link android.os.Bundle}
     48      * containing the result which will be a boolean value mapped to the
     49      * {@link AccountManager#KEY_BOOLEAN_RESULT} key.
     50      *
     51      * @param account The account for which to request.
     52      * @param packageName The package name for which to request.
     53      * @param userId Concrete user id for which to request.
     54      * @param callback A callback for receiving the result.
     55      */
     56     public abstract void requestAccountAccess(@NonNull Account account,
     57             @NonNull String packageName, @IntRange(from = 0) int userId,
     58             @NonNull RemoteCallback callback);
     59 
     60     /**
     61      * Check whether the given UID has access to the account.
     62      *
     63      * @param account The account
     64      * @param uid The UID
     65      * @return Whether the UID can access the account
     66      */
     67     public abstract boolean hasAccountAccess(@NonNull Account account, @IntRange(from = 0) int uid);
     68 
     69     /**
     70      * Adds a listener for explicit UID account access grant changes.
     71      *
     72      * @param listener The listener
     73      */
     74     public abstract void addOnAppPermissionChangeListener(
     75             @NonNull OnAppPermissionChangeListener listener);
     76 
     77     /**
     78      * Backups the account access permissions.
     79      * @param userId The user for which to backup.
     80      * @return The backup data.
     81      */
     82     public abstract byte[] backupAccountAccessPermissions(int userId);
     83 
     84     /**
     85      * Restores the account access permissions.
     86      * @param data The restore data.
     87      * @param userId The user for which to restore.
     88      */
     89     public abstract void restoreAccountAccessPermissions(byte[] data, int userId);
     90 }
     91