1 /*
2  * Copyright (C) 2013 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 com.android.internal.app;
18 
19 import android.app.AppOpsManager;
20 import android.app.AppOpsManager;
21 import android.content.pm.ParceledListSlice;
22 import android.os.Bundle;
23 import android.os.RemoteCallback;
24 import com.android.internal.app.IAppOpsCallback;
25 import com.android.internal.app.IAppOpsActiveCallback;
26 import com.android.internal.app.IAppOpsNotedCallback;
27 
28 interface IAppOpsService {
29     // These methods are also called by native code, so must
30     // be kept in sync with frameworks/native/libs/binder/include/binder/IAppOpsService.h
31     // and not be reordered
checkOperation(int code, int uid, String packageName)32     int checkOperation(int code, int uid, String packageName);
noteOperation(int code, int uid, String packageName)33     int noteOperation(int code, int uid, String packageName);
startOperation(IBinder token, int code, int uid, String packageName, boolean startIfModeDefault)34     int startOperation(IBinder token, int code, int uid, String packageName,
35             boolean startIfModeDefault);
36     @UnsupportedAppUsage
finishOperation(IBinder token, int code, int uid, String packageName)37     void finishOperation(IBinder token, int code, int uid, String packageName);
startWatchingMode(int op, String packageName, IAppOpsCallback callback)38     void startWatchingMode(int op, String packageName, IAppOpsCallback callback);
stopWatchingMode(IAppOpsCallback callback)39     void stopWatchingMode(IAppOpsCallback callback);
getToken(IBinder clientToken)40     IBinder getToken(IBinder clientToken);
permissionToOpCode(String permission)41     int permissionToOpCode(String permission);
checkAudioOperation(int code, int usage, int uid, String packageName)42     int checkAudioOperation(int code, int usage, int uid, String packageName);
43     // End of methods also called by native code.
44     // Any new method exposed to native must be added after the last one, do not reorder
45 
noteProxyOperation(int code, int proxyUid, String proxyPackageName, int callingUid, String callingPackageName)46     int noteProxyOperation(int code, int proxyUid, String proxyPackageName,
47                 int callingUid, String callingPackageName);
48 
49     // Remaining methods are only used in Java.
checkPackage(int uid, String packageName)50     int checkPackage(int uid, String packageName);
51     @UnsupportedAppUsage
getPackagesForOps(in int[] ops)52     List<AppOpsManager.PackageOps> getPackagesForOps(in int[] ops);
53     @UnsupportedAppUsage
getOpsForPackage(int uid, String packageName, in int[] ops)54     List<AppOpsManager.PackageOps> getOpsForPackage(int uid, String packageName, in int[] ops);
getHistoricalOps(int uid, String packageName, in List<String> ops, long beginTimeMillis, long endTimeMillis, int flags, in RemoteCallback callback)55     void getHistoricalOps(int uid, String packageName, in List<String> ops, long beginTimeMillis,
56             long endTimeMillis, int flags, in RemoteCallback callback);
getHistoricalOpsFromDiskRaw(int uid, String packageName, in List<String> ops, long beginTimeMillis, long endTimeMillis, int flags, in RemoteCallback callback)57     void getHistoricalOpsFromDiskRaw(int uid, String packageName, in List<String> ops,
58             long beginTimeMillis, long endTimeMillis, int flags, in RemoteCallback callback);
offsetHistory(long duration)59     void offsetHistory(long duration);
setHistoryParameters(int mode, long baseSnapshotInterval, int compressionStep)60     void setHistoryParameters(int mode, long baseSnapshotInterval, int compressionStep);
addHistoricalOps(in AppOpsManager.HistoricalOps ops)61     void addHistoricalOps(in AppOpsManager.HistoricalOps ops);
resetHistoryParameters()62     void resetHistoryParameters();
clearHistory()63     void clearHistory();
getUidOps(int uid, in int[] ops)64     List<AppOpsManager.PackageOps> getUidOps(int uid, in int[] ops);
setUidMode(int code, int uid, int mode)65     void setUidMode(int code, int uid, int mode);
66     @UnsupportedAppUsage
setMode(int code, int uid, String packageName, int mode)67     void setMode(int code, int uid, String packageName, int mode);
68     @UnsupportedAppUsage
resetAllModes(int reqUserId, String reqPackageName)69     void resetAllModes(int reqUserId, String reqPackageName);
setAudioRestriction(int code, int usage, int uid, int mode, in String[] exceptionPackages)70     void setAudioRestriction(int code, int usage, int uid, int mode, in String[] exceptionPackages);
71 
setUserRestrictions(in Bundle restrictions, IBinder token, int userHandle)72     void setUserRestrictions(in Bundle restrictions, IBinder token, int userHandle);
setUserRestriction(int code, boolean restricted, IBinder token, int userHandle, in String[] exceptionPackages)73     void setUserRestriction(int code, boolean restricted, IBinder token, int userHandle, in String[] exceptionPackages);
removeUser(int userHandle)74     void removeUser(int userHandle);
75 
startWatchingActive(in int[] ops, IAppOpsActiveCallback callback)76     void startWatchingActive(in int[] ops, IAppOpsActiveCallback callback);
stopWatchingActive(IAppOpsActiveCallback callback)77     void stopWatchingActive(IAppOpsActiveCallback callback);
isOperationActive(int code, int uid, String packageName)78     boolean isOperationActive(int code, int uid, String packageName);
79 
startWatchingModeWithFlags(int op, String packageName, int flags, IAppOpsCallback callback)80     void startWatchingModeWithFlags(int op, String packageName, int flags, IAppOpsCallback callback);
81 
startWatchingNoted(in int[] ops, IAppOpsNotedCallback callback)82     void startWatchingNoted(in int[] ops, IAppOpsNotedCallback callback);
stopWatchingNoted(IAppOpsNotedCallback callback)83     void stopWatchingNoted(IAppOpsNotedCallback callback);
84 
checkOperationRaw(int code, int uid, String packageName)85     int checkOperationRaw(int code, int uid, String packageName);
86 
reloadNonHistoricalState()87     void reloadNonHistoricalState();
88 }
89