blob: e614a0eb996b9a4b165c66e77f8689a80e7fa8f2 [file] [log] [blame]
Dianne Hackborna06de0f2012-12-11 16:34:47 -08001/*
Dianne Hackbornc2293022013-02-06 23:14:49 -08002 * Copyright (C) 2013 The Android Open Source Project
Dianne Hackborna06de0f2012-12-11 16:34:47 -08003 *
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
17package com.android.internal.app;
18
Dianne Hackborn35654b62013-01-14 17:38:02 -080019import android.app.AppOpsManager;
Philip P. Moltmann2b08aaf2019-06-10 08:49:11 -070020import android.app.AsyncNotedAppOp;
Stanislav Zholnin90516b92020-01-20 14:03:06 +000021import android.app.SyncNotedAppOp;
22import android.app.RuntimeAppOpAccessMessage;
Svet Ganovad0a49b2018-10-29 10:07:08 -070023import android.content.pm.ParceledListSlice;
Jason Monk62062992014-05-06 09:55:28 -040024import android.os.Bundle;
Svet Ganov8455ba22019-01-02 13:05:56 -080025import android.os.RemoteCallback;
Dianne Hackbornc2293022013-02-06 23:14:49 -080026import com.android.internal.app.IAppOpsCallback;
Svetoslav Ganov2d20fb42018-02-08 15:52:10 -080027import com.android.internal.app.IAppOpsActiveCallback;
Philip P. Moltmann2b08aaf2019-06-10 08:49:11 -070028import com.android.internal.app.IAppOpsAsyncNotedCallback;
Svet Ganovb3d2ae22018-12-17 22:06:15 -080029import com.android.internal.app.IAppOpsNotedCallback;
Adam Bookatz182862e2020-04-27 21:58:22 -070030import com.android.internal.app.IAppOpsStartedCallback;
Stanislav Zholnin90516b92020-01-20 14:03:06 +000031import com.android.internal.app.MessageSamplingConfig;
Dianne Hackborn35654b62013-01-14 17:38:02 -080032
Dianne Hackborna06de0f2012-12-11 16:34:47 -080033interface IAppOpsService {
Jean-Michel Trivifcf1e542019-02-25 12:20:35 -080034 // These methods are also called by native code, so must
Peter Visontaycee76322017-09-05 11:43:36 +010035 // be kept in sync with frameworks/native/libs/binder/include/binder/IAppOpsService.h
Jean-Michel Trivifcf1e542019-02-25 12:20:35 -080036 // and not be reordered
Dianne Hackborn35654b62013-01-14 17:38:02 -080037 int checkOperation(int code, int uid, String packageName);
Philip P. Moltmann12ac3f42020-03-05 15:01:29 -080038 int noteOperation(int code, int uid, String packageName, @nullable String attributionTag,
Philip P. Moltmannda554e42019-12-20 11:21:02 -080039 boolean shouldCollectAsyncNotedOp, String message);
Philip P. Moltmann6c6403e2019-12-09 10:08:29 -080040 int startOperation(IBinder clientId, int code, int uid, String packageName,
Philip P. Moltmann12ac3f42020-03-05 15:01:29 -080041 @nullable String attributionTag, boolean startIfModeDefault,
Philip P. Moltmannda554e42019-12-20 11:21:02 -080042 boolean shouldCollectAsyncNotedOp, String message);
Andrei Oneafa152f92019-02-27 15:58:05 +000043 @UnsupportedAppUsage
Philip P. Moltmann6c6403e2019-12-09 10:08:29 -080044 void finishOperation(IBinder clientId, int code, int uid, String packageName,
Philip P. Moltmann12ac3f42020-03-05 15:01:29 -080045 @nullable String attributionTag);
Dianne Hackbornc2293022013-02-06 23:14:49 -080046 void startWatchingMode(int op, String packageName, IAppOpsCallback callback);
47 void stopWatchingMode(IAppOpsCallback callback);
Svet Ganovb9d71a62015-04-30 10:38:13 -070048 int permissionToOpCode(String permission);
Jean-Michel Trivifcf1e542019-02-25 12:20:35 -080049 int checkAudioOperation(int code, int usage, int uid, String packageName);
Philip P. Moltmann2b08aaf2019-06-10 08:49:11 -070050 boolean shouldCollectNotes(int opCode);
Yin-Chia Yeh51d85162019-08-06 15:31:39 -070051 void setCameraAudioRestriction(int mode);
Jean-Michel Trivifcf1e542019-02-25 12:20:35 -080052 // 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
Philip P. Moltmann59076d82019-08-19 15:00:40 -070055 int noteProxyOperation(int code, int proxiedUid, String proxiedPackageName,
Philip P. Moltmann12ac3f42020-03-05 15:01:29 -080056 String proxiedAttributionTag, int proxyUid, String proxyPackageName,
57 String proxyAttributionTag, boolean shouldCollectAsyncNotedOp, String message);
Dianne Hackbornd7d28e62013-02-12 14:59:53 -080058
59 // Remaining methods are only used in Java.
Dianne Hackbornd4a8b9d2013-09-06 13:36:57 -070060 int checkPackage(int uid, String packageName);
Stanislav Zholnin90516b92020-01-20 14:03:06 +000061 RuntimeAppOpAccessMessage collectRuntimeAppOpAccessMessage();
62 MessageSamplingConfig reportRuntimeAppOpAccessMessageAndGetConfig(String packageName,
63 in SyncNotedAppOp appOp, String message);
Andrei Oneafa152f92019-02-27 15:58:05 +000064 @UnsupportedAppUsage
Dianne Hackbornd7d28e62013-02-12 14:59:53 -080065 List<AppOpsManager.PackageOps> getPackagesForOps(in int[] ops);
Andrei Oneafa152f92019-02-27 15:58:05 +000066 @UnsupportedAppUsage
Dianne Hackbornd7d28e62013-02-12 14:59:53 -080067 List<AppOpsManager.PackageOps> getOpsForPackage(int uid, String packageName, in int[] ops);
Philip P. Moltmann12ac3f42020-03-05 15:01:29 -080068 void getHistoricalOps(int uid, String packageName, String attributionTag, in List<String> ops,
Philip P. Moltmann4aacd712020-01-03 12:32:20 -080069 int filter, long beginTimeMillis, long endTimeMillis, int flags,
70 in RemoteCallback callback);
Philip P. Moltmann12ac3f42020-03-05 15:01:29 -080071 void getHistoricalOpsFromDiskRaw(int uid, String packageName, String attributionTag,
Philip P. Moltmann4aacd712020-01-03 12:32:20 -080072 in List<String> ops, int filter, long beginTimeMillis, long endTimeMillis, int flags,
73 in RemoteCallback callback);
Svet Ganov8455ba22019-01-02 13:05:56 -080074 void offsetHistory(long duration);
75 void setHistoryParameters(int mode, long baseSnapshotInterval, int compressionStep);
76 void addHistoricalOps(in AppOpsManager.HistoricalOps ops);
77 void resetHistoryParameters();
78 void clearHistory();
Svet Ganov185ddf62020-06-04 21:40:26 -070079 void rebootHistory(long offlineDurationMillis);
Dianne Hackbornc7214a32017-04-11 13:32:47 -070080 List<AppOpsManager.PackageOps> getUidOps(int uid, in int[] ops);
Svet Ganov2af57082015-07-30 08:44:20 -070081 void setUidMode(int code, int uid, int mode);
Andrei Oneafa152f92019-02-27 15:58:05 +000082 @UnsupportedAppUsage
Dianne Hackbornd7d28e62013-02-12 14:59:53 -080083 void setMode(int code, int uid, String packageName, int mode);
Andrei Oneafa152f92019-02-27 15:58:05 +000084 @UnsupportedAppUsage
Dianne Hackborn7b7c58b2014-12-02 18:32:20 -080085 void resetAllModes(int reqUserId, String reqPackageName);
John Spurlock7b414672014-07-18 13:02:39 -040086 void setAudioRestriction(int code, int usage, int uid, int mode, in String[] exceptionPackages);
Jason Monk62062992014-05-06 09:55:28 -040087
Svet Ganov9cea80cd2016-02-16 11:47:00 -080088 void setUserRestrictions(in Bundle restrictions, IBinder token, int userHandle);
Ruben Brunk29931bc2016-03-11 00:24:26 -080089 void setUserRestriction(int code, boolean restricted, IBinder token, int userHandle, in String[] exceptionPackages);
Jason Monk62062992014-05-06 09:55:28 -040090 void removeUser(int userHandle);
Jeff Sharkey35e46d22017-06-09 10:01:20 -060091
Svetoslav Ganov2d20fb42018-02-08 15:52:10 -080092 void startWatchingActive(in int[] ops, IAppOpsActiveCallback callback);
93 void stopWatchingActive(IAppOpsActiveCallback callback);
Jeff Sharkey35e46d22017-06-09 10:01:20 -060094 boolean isOperationActive(int code, int uid, String packageName);
Dianne Hackborn65a4f252018-05-08 17:30:48 -070095
Adam Bookatz182862e2020-04-27 21:58:22 -070096 void startWatchingStarted(in int[] ops, IAppOpsStartedCallback callback);
97 void stopWatchingStarted(IAppOpsStartedCallback callback);
98
Dianne Hackborn65a4f252018-05-08 17:30:48 -070099 void startWatchingModeWithFlags(int op, String packageName, int flags, IAppOpsCallback callback);
Svet Ganovb3d2ae22018-12-17 22:06:15 -0800100
101 void startWatchingNoted(in int[] ops, IAppOpsNotedCallback callback);
102 void stopWatchingNoted(IAppOpsNotedCallback callback);
Svet Ganov9d528a12018-12-19 17:23:11 -0800103
Philip P. Moltmann2b08aaf2019-06-10 08:49:11 -0700104 void startWatchingAsyncNoted(String packageName, IAppOpsAsyncNotedCallback callback);
105 void stopWatchingAsyncNoted(String packageName, IAppOpsAsyncNotedCallback callback);
106 List<AsyncNotedAppOp> extractAsyncOps(String packageName);
107
Svet Ganov9d528a12018-12-19 17:23:11 -0800108 int checkOperationRaw(int code, int uid, String packageName);
Svet Ganov8e5bf962019-03-19 23:59:03 -0700109
110 void reloadNonHistoricalState();
David Cheung2ead9662020-02-19 16:11:06 -0800111
112 void collectNoteOpCallsForValidation(String stackTrace, int op, String packageName, long version);
Dianne Hackborna06de0f2012-12-11 16:34:47 -0800113}