Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 1 | /* |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 2 | * Copyright (C) 2013 The Android Open Source Project |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 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 | |
Dianne Hackborn | 35654b6 | 2013-01-14 17:38:02 -0800 | [diff] [blame] | 19 | import android.app.AppOpsManager; |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 20 | import android.app.AsyncNotedAppOp; |
Stanislav Zholnin | 90516b9 | 2020-01-20 14:03:06 +0000 | [diff] [blame] | 21 | import android.app.SyncNotedAppOp; |
| 22 | import android.app.RuntimeAppOpAccessMessage; |
Svet Ganov | ad0a49b | 2018-10-29 10:07:08 -0700 | [diff] [blame] | 23 | import android.content.pm.ParceledListSlice; |
Jason Monk | 6206299 | 2014-05-06 09:55:28 -0400 | [diff] [blame] | 24 | import android.os.Bundle; |
Svet Ganov | 8455ba2 | 2019-01-02 13:05:56 -0800 | [diff] [blame] | 25 | import android.os.RemoteCallback; |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 26 | import com.android.internal.app.IAppOpsCallback; |
Svetoslav Ganov | 2d20fb4 | 2018-02-08 15:52:10 -0800 | [diff] [blame] | 27 | import com.android.internal.app.IAppOpsActiveCallback; |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 28 | import com.android.internal.app.IAppOpsAsyncNotedCallback; |
Svet Ganov | b3d2ae2 | 2018-12-17 22:06:15 -0800 | [diff] [blame] | 29 | import com.android.internal.app.IAppOpsNotedCallback; |
Adam Bookatz | 182862e | 2020-04-27 21:58:22 -0700 | [diff] [blame] | 30 | import com.android.internal.app.IAppOpsStartedCallback; |
Stanislav Zholnin | 90516b9 | 2020-01-20 14:03:06 +0000 | [diff] [blame] | 31 | import com.android.internal.app.MessageSamplingConfig; |
Dianne Hackborn | 35654b6 | 2013-01-14 17:38:02 -0800 | [diff] [blame] | 32 | |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 33 | interface IAppOpsService { |
Jean-Michel Trivi | fcf1e54 | 2019-02-25 12:20:35 -0800 | [diff] [blame] | 34 | // These methods are also called by native code, so must |
Peter Visontay | cee7632 | 2017-09-05 11:43:36 +0100 | [diff] [blame] | 35 | // be kept in sync with frameworks/native/libs/binder/include/binder/IAppOpsService.h |
Jean-Michel Trivi | fcf1e54 | 2019-02-25 12:20:35 -0800 | [diff] [blame] | 36 | // and not be reordered |
Dianne Hackborn | 35654b6 | 2013-01-14 17:38:02 -0800 | [diff] [blame] | 37 | int checkOperation(int code, int uid, String packageName); |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame] | 38 | int noteOperation(int code, int uid, String packageName, @nullable String attributionTag, |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 39 | boolean shouldCollectAsyncNotedOp, String message); |
Philip P. Moltmann | 6c6403e | 2019-12-09 10:08:29 -0800 | [diff] [blame] | 40 | int startOperation(IBinder clientId, int code, int uid, String packageName, |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame] | 41 | @nullable String attributionTag, boolean startIfModeDefault, |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 42 | boolean shouldCollectAsyncNotedOp, String message); |
Andrei Onea | fa152f9 | 2019-02-27 15:58:05 +0000 | [diff] [blame] | 43 | @UnsupportedAppUsage |
Philip P. Moltmann | 6c6403e | 2019-12-09 10:08:29 -0800 | [diff] [blame] | 44 | void finishOperation(IBinder clientId, int code, int uid, String packageName, |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame] | 45 | @nullable String attributionTag); |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 46 | void startWatchingMode(int op, String packageName, IAppOpsCallback callback); |
| 47 | void stopWatchingMode(IAppOpsCallback callback); |
Svet Ganov | b9d71a6 | 2015-04-30 10:38:13 -0700 | [diff] [blame] | 48 | int permissionToOpCode(String permission); |
Jean-Michel Trivi | fcf1e54 | 2019-02-25 12:20:35 -0800 | [diff] [blame] | 49 | int checkAudioOperation(int code, int usage, int uid, String packageName); |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 50 | boolean shouldCollectNotes(int opCode); |
Yin-Chia Yeh | 51d8516 | 2019-08-06 15:31:39 -0700 | [diff] [blame] | 51 | void setCameraAudioRestriction(int mode); |
Jean-Michel Trivi | fcf1e54 | 2019-02-25 12:20:35 -0800 | [diff] [blame] | 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 | |
Philip P. Moltmann | 59076d8 | 2019-08-19 15:00:40 -0700 | [diff] [blame] | 55 | int noteProxyOperation(int code, int proxiedUid, String proxiedPackageName, |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame] | 56 | String proxiedAttributionTag, int proxyUid, String proxyPackageName, |
| 57 | String proxyAttributionTag, boolean shouldCollectAsyncNotedOp, String message); |
Dianne Hackborn | d7d28e6 | 2013-02-12 14:59:53 -0800 | [diff] [blame] | 58 | |
| 59 | // Remaining methods are only used in Java. |
Dianne Hackborn | d4a8b9d | 2013-09-06 13:36:57 -0700 | [diff] [blame] | 60 | int checkPackage(int uid, String packageName); |
Stanislav Zholnin | 90516b9 | 2020-01-20 14:03:06 +0000 | [diff] [blame] | 61 | RuntimeAppOpAccessMessage collectRuntimeAppOpAccessMessage(); |
| 62 | MessageSamplingConfig reportRuntimeAppOpAccessMessageAndGetConfig(String packageName, |
| 63 | in SyncNotedAppOp appOp, String message); |
Andrei Onea | fa152f9 | 2019-02-27 15:58:05 +0000 | [diff] [blame] | 64 | @UnsupportedAppUsage |
Dianne Hackborn | d7d28e6 | 2013-02-12 14:59:53 -0800 | [diff] [blame] | 65 | List<AppOpsManager.PackageOps> getPackagesForOps(in int[] ops); |
Andrei Onea | fa152f9 | 2019-02-27 15:58:05 +0000 | [diff] [blame] | 66 | @UnsupportedAppUsage |
Dianne Hackborn | d7d28e6 | 2013-02-12 14:59:53 -0800 | [diff] [blame] | 67 | List<AppOpsManager.PackageOps> getOpsForPackage(int uid, String packageName, in int[] ops); |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame] | 68 | void getHistoricalOps(int uid, String packageName, String attributionTag, in List<String> ops, |
Philip P. Moltmann | 4aacd71 | 2020-01-03 12:32:20 -0800 | [diff] [blame] | 69 | int filter, long beginTimeMillis, long endTimeMillis, int flags, |
| 70 | in RemoteCallback callback); |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame] | 71 | void getHistoricalOpsFromDiskRaw(int uid, String packageName, String attributionTag, |
Philip P. Moltmann | 4aacd71 | 2020-01-03 12:32:20 -0800 | [diff] [blame] | 72 | in List<String> ops, int filter, long beginTimeMillis, long endTimeMillis, int flags, |
| 73 | in RemoteCallback callback); |
Svet Ganov | 8455ba2 | 2019-01-02 13:05:56 -0800 | [diff] [blame] | 74 | 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 Ganov | 185ddf6 | 2020-06-04 21:40:26 -0700 | [diff] [blame] | 79 | void rebootHistory(long offlineDurationMillis); |
Dianne Hackborn | c7214a3 | 2017-04-11 13:32:47 -0700 | [diff] [blame] | 80 | List<AppOpsManager.PackageOps> getUidOps(int uid, in int[] ops); |
Svet Ganov | 2af5708 | 2015-07-30 08:44:20 -0700 | [diff] [blame] | 81 | void setUidMode(int code, int uid, int mode); |
Andrei Onea | fa152f9 | 2019-02-27 15:58:05 +0000 | [diff] [blame] | 82 | @UnsupportedAppUsage |
Dianne Hackborn | d7d28e6 | 2013-02-12 14:59:53 -0800 | [diff] [blame] | 83 | void setMode(int code, int uid, String packageName, int mode); |
Andrei Onea | fa152f9 | 2019-02-27 15:58:05 +0000 | [diff] [blame] | 84 | @UnsupportedAppUsage |
Dianne Hackborn | 7b7c58b | 2014-12-02 18:32:20 -0800 | [diff] [blame] | 85 | void resetAllModes(int reqUserId, String reqPackageName); |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 86 | void setAudioRestriction(int code, int usage, int uid, int mode, in String[] exceptionPackages); |
Jason Monk | 6206299 | 2014-05-06 09:55:28 -0400 | [diff] [blame] | 87 | |
Svet Ganov | 9cea80cd | 2016-02-16 11:47:00 -0800 | [diff] [blame] | 88 | void setUserRestrictions(in Bundle restrictions, IBinder token, int userHandle); |
Ruben Brunk | 29931bc | 2016-03-11 00:24:26 -0800 | [diff] [blame] | 89 | void setUserRestriction(int code, boolean restricted, IBinder token, int userHandle, in String[] exceptionPackages); |
Jason Monk | 6206299 | 2014-05-06 09:55:28 -0400 | [diff] [blame] | 90 | void removeUser(int userHandle); |
Jeff Sharkey | 35e46d2 | 2017-06-09 10:01:20 -0600 | [diff] [blame] | 91 | |
Svetoslav Ganov | 2d20fb4 | 2018-02-08 15:52:10 -0800 | [diff] [blame] | 92 | void startWatchingActive(in int[] ops, IAppOpsActiveCallback callback); |
| 93 | void stopWatchingActive(IAppOpsActiveCallback callback); |
Jeff Sharkey | 35e46d2 | 2017-06-09 10:01:20 -0600 | [diff] [blame] | 94 | boolean isOperationActive(int code, int uid, String packageName); |
Dianne Hackborn | 65a4f25 | 2018-05-08 17:30:48 -0700 | [diff] [blame] | 95 | |
Adam Bookatz | 182862e | 2020-04-27 21:58:22 -0700 | [diff] [blame] | 96 | void startWatchingStarted(in int[] ops, IAppOpsStartedCallback callback); |
| 97 | void stopWatchingStarted(IAppOpsStartedCallback callback); |
| 98 | |
Dianne Hackborn | 65a4f25 | 2018-05-08 17:30:48 -0700 | [diff] [blame] | 99 | void startWatchingModeWithFlags(int op, String packageName, int flags, IAppOpsCallback callback); |
Svet Ganov | b3d2ae2 | 2018-12-17 22:06:15 -0800 | [diff] [blame] | 100 | |
| 101 | void startWatchingNoted(in int[] ops, IAppOpsNotedCallback callback); |
| 102 | void stopWatchingNoted(IAppOpsNotedCallback callback); |
Svet Ganov | 9d528a1 | 2018-12-19 17:23:11 -0800 | [diff] [blame] | 103 | |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 104 | void startWatchingAsyncNoted(String packageName, IAppOpsAsyncNotedCallback callback); |
| 105 | void stopWatchingAsyncNoted(String packageName, IAppOpsAsyncNotedCallback callback); |
| 106 | List<AsyncNotedAppOp> extractAsyncOps(String packageName); |
| 107 | |
Svet Ganov | 9d528a1 | 2018-12-19 17:23:11 -0800 | [diff] [blame] | 108 | int checkOperationRaw(int code, int uid, String packageName); |
Svet Ganov | 8e5bf96 | 2019-03-19 23:59:03 -0700 | [diff] [blame] | 109 | |
| 110 | void reloadNonHistoricalState(); |
David Cheung | 2ead966 | 2020-02-19 16:11:06 -0800 | [diff] [blame] | 111 | |
| 112 | void collectNoteOpCallsForValidation(String stackTrace, int op, String packageName, long version); |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 113 | } |