• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.AsyncNotedAppOp;
21 import android.app.SyncNotedAppOp;
22 import android.app.RuntimeAppOpAccessMessage;
23 import android.content.pm.ParceledListSlice;
24 import android.os.Bundle;
25 import android.os.RemoteCallback;
26 import com.android.internal.app.IAppOpsCallback;
27 import com.android.internal.app.IAppOpsActiveCallback;
28 import com.android.internal.app.IAppOpsAsyncNotedCallback;
29 import com.android.internal.app.IAppOpsNotedCallback;
30 import com.android.internal.app.IAppOpsStartedCallback;
31 import com.android.internal.app.MessageSamplingConfig;
32 
33 interface IAppOpsService {
34     // These methods are also called by native code, so must
35     // be kept in sync with frameworks/native/libs/binder/include/binder/IAppOpsService.h
36     // and not be reordered
checkOperation(int code, int uid, String packageName)37     int checkOperation(int code, int uid, String packageName);
noteOperation(int code, int uid, String packageName, @nullable String attributionTag, boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage)38     int noteOperation(int code, int uid, String packageName, @nullable String attributionTag,
39             boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage);
startOperation(IBinder clientId, int code, int uid, String packageName, @nullable String attributionTag, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage)40     int startOperation(IBinder clientId, int code, int uid, String packageName,
41             @nullable String attributionTag, boolean startIfModeDefault,
42             boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage);
43     @UnsupportedAppUsage
finishOperation(IBinder clientId, int code, int uid, String packageName, @nullable String attributionTag)44     void finishOperation(IBinder clientId, int code, int uid, String packageName,
45             @nullable String attributionTag);
startWatchingMode(int op, String packageName, IAppOpsCallback callback)46     void startWatchingMode(int op, String packageName, IAppOpsCallback callback);
stopWatchingMode(IAppOpsCallback callback)47     void stopWatchingMode(IAppOpsCallback callback);
permissionToOpCode(String permission)48     int permissionToOpCode(String permission);
checkAudioOperation(int code, int usage, int uid, String packageName)49     int checkAudioOperation(int code, int usage, int uid, String packageName);
shouldCollectNotes(int opCode)50     boolean shouldCollectNotes(int opCode);
setCameraAudioRestriction(int mode)51     void setCameraAudioRestriction(int mode);
52     // End of methods also called by native code.
53     // Any new method exposed to native must be added after the last one, do not reorder
54 
noteProxyOperation(int code, int proxiedUid, String proxiedPackageName, String proxiedAttributionTag, int proxyUid, String proxyPackageName, String proxyAttributionTag, boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage)55     int noteProxyOperation(int code, int proxiedUid, String proxiedPackageName,
56             String proxiedAttributionTag, int proxyUid, String proxyPackageName,
57             String proxyAttributionTag, boolean shouldCollectAsyncNotedOp, String message,
58             boolean shouldCollectMessage);
59 
60     // Remaining methods are only used in Java.
checkPackage(int uid, String packageName)61     int checkPackage(int uid, String packageName);
collectRuntimeAppOpAccessMessage()62     RuntimeAppOpAccessMessage collectRuntimeAppOpAccessMessage();
reportRuntimeAppOpAccessMessageAndGetConfig(String packageName, in SyncNotedAppOp appOp, String message)63     MessageSamplingConfig reportRuntimeAppOpAccessMessageAndGetConfig(String packageName,
64             in SyncNotedAppOp appOp, String message);
65     @UnsupportedAppUsage
getPackagesForOps(in int[] ops)66     List<AppOpsManager.PackageOps> getPackagesForOps(in int[] ops);
67     @UnsupportedAppUsage
getOpsForPackage(int uid, String packageName, in int[] ops)68     List<AppOpsManager.PackageOps> getOpsForPackage(int uid, String packageName, in int[] ops);
getHistoricalOps(int uid, String packageName, String attributionTag, in List<String> ops, int filter, long beginTimeMillis, long endTimeMillis, int flags, in RemoteCallback callback)69     void getHistoricalOps(int uid, String packageName, String attributionTag, in List<String> ops,
70             int filter, long beginTimeMillis, long endTimeMillis, int flags,
71             in RemoteCallback callback);
getHistoricalOpsFromDiskRaw(int uid, String packageName, String attributionTag, in List<String> ops, int filter, long beginTimeMillis, long endTimeMillis, int flags, in RemoteCallback callback)72     void getHistoricalOpsFromDiskRaw(int uid, String packageName, String attributionTag,
73             in List<String> ops, int filter, long beginTimeMillis, long endTimeMillis, int flags,
74             in RemoteCallback callback);
offsetHistory(long duration)75     void offsetHistory(long duration);
setHistoryParameters(int mode, long baseSnapshotInterval, int compressionStep)76     void setHistoryParameters(int mode, long baseSnapshotInterval, int compressionStep);
addHistoricalOps(in AppOpsManager.HistoricalOps ops)77     void addHistoricalOps(in AppOpsManager.HistoricalOps ops);
resetHistoryParameters()78     void resetHistoryParameters();
clearHistory()79     void clearHistory();
rebootHistory(long offlineDurationMillis)80     void rebootHistory(long offlineDurationMillis);
getUidOps(int uid, in int[] ops)81     List<AppOpsManager.PackageOps> getUidOps(int uid, in int[] ops);
setUidMode(int code, int uid, int mode)82     void setUidMode(int code, int uid, int mode);
83     @UnsupportedAppUsage
setMode(int code, int uid, String packageName, int mode)84     void setMode(int code, int uid, String packageName, int mode);
85     @UnsupportedAppUsage
resetAllModes(int reqUserId, String reqPackageName)86     void resetAllModes(int reqUserId, String reqPackageName);
setAudioRestriction(int code, int usage, int uid, int mode, in String[] exceptionPackages)87     void setAudioRestriction(int code, int usage, int uid, int mode, in String[] exceptionPackages);
88 
setUserRestrictions(in Bundle restrictions, IBinder token, int userHandle)89     void setUserRestrictions(in Bundle restrictions, IBinder token, int userHandle);
setUserRestriction(int code, boolean restricted, IBinder token, int userHandle, in String[] exceptionPackages)90     void setUserRestriction(int code, boolean restricted, IBinder token, int userHandle, in String[] exceptionPackages);
removeUser(int userHandle)91     void removeUser(int userHandle);
92 
startWatchingActive(in int[] ops, IAppOpsActiveCallback callback)93     void startWatchingActive(in int[] ops, IAppOpsActiveCallback callback);
stopWatchingActive(IAppOpsActiveCallback callback)94     void stopWatchingActive(IAppOpsActiveCallback callback);
isOperationActive(int code, int uid, String packageName)95     boolean isOperationActive(int code, int uid, String packageName);
96 
startWatchingStarted(in int[] ops, IAppOpsStartedCallback callback)97     void startWatchingStarted(in int[] ops, IAppOpsStartedCallback callback);
stopWatchingStarted(IAppOpsStartedCallback callback)98     void stopWatchingStarted(IAppOpsStartedCallback callback);
99 
startWatchingModeWithFlags(int op, String packageName, int flags, IAppOpsCallback callback)100     void startWatchingModeWithFlags(int op, String packageName, int flags, IAppOpsCallback callback);
101 
startWatchingNoted(in int[] ops, IAppOpsNotedCallback callback)102     void startWatchingNoted(in int[] ops, IAppOpsNotedCallback callback);
stopWatchingNoted(IAppOpsNotedCallback callback)103     void stopWatchingNoted(IAppOpsNotedCallback callback);
104 
startWatchingAsyncNoted(String packageName, IAppOpsAsyncNotedCallback callback)105     void startWatchingAsyncNoted(String packageName, IAppOpsAsyncNotedCallback callback);
stopWatchingAsyncNoted(String packageName, IAppOpsAsyncNotedCallback callback)106     void stopWatchingAsyncNoted(String packageName, IAppOpsAsyncNotedCallback callback);
extractAsyncOps(String packageName)107     List<AsyncNotedAppOp> extractAsyncOps(String packageName);
108 
checkOperationRaw(int code, int uid, String packageName)109     int checkOperationRaw(int code, int uid, String packageName);
110 
reloadNonHistoricalState()111     void reloadNonHistoricalState();
112 
collectNoteOpCallsForValidation(String stackTrace, int op, String packageName, long version)113     void collectNoteOpCallsForValidation(String stackTrace, int op, String packageName, long version);
114 }
115