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