Skip to content

Commit 9fad56c

Browse files
Merge "Add AppOps overload to be able to watch foreground changes." into sc-dev am: 001bb2f
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/22465455 Change-Id: I261f1e6f3309e2b2d685cb448c0c1f3ec35e3ae6 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2 parents bc5214e + 001bb2f commit 9fad56c

4 files changed

Lines changed: 28 additions & 0 deletions

File tree

libs/permission/AppOpsManager.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,14 @@ void AppOpsManager::startWatchingMode(int32_t op, const String16& packageName,
146146
}
147147
}
148148

149+
void AppOpsManager::startWatchingMode(int32_t op, const String16& packageName, int32_t flags,
150+
const sp<IAppOpsCallback>& callback) {
151+
sp<IAppOpsService> service = getService();
152+
if (service != nullptr) {
153+
service->startWatchingModeWithFlags(op, packageName, flags, callback);
154+
}
155+
}
156+
149157
void AppOpsManager::stopWatchingMode(const sp<IAppOpsCallback>& callback) {
150158
sp<IAppOpsService> service = getService();
151159
if (service != nullptr) {

libs/permission/IAppOpsService.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,17 @@ class BpAppOpsService : public BpInterface<IAppOpsService>
166166
}
167167
return reply.readBool();
168168
}
169+
170+
virtual void startWatchingModeWithFlags(int32_t op, const String16& packageName,
171+
int32_t flags, const sp<IAppOpsCallback>& callback) {
172+
Parcel data, reply;
173+
data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor());
174+
data.writeInt32(op);
175+
data.writeString16(packageName);
176+
data.writeInt32(flags);
177+
data.writeStrongBinder(IInterface::asBinder(callback));
178+
remote()->transact(START_WATCHING_MODE_WITH_FLAGS_TRANSACTION, data, &reply);
179+
}
169180
};
170181

171182
IMPLEMENT_META_INTERFACE(AppOpsService, "com.android.internal.app.IAppOpsService")

libs/permission/include/binder/AppOpsManager.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ class AppOpsManager
150150
_NUM_OP = 116
151151
};
152152

153+
enum {
154+
WATCH_FOREGROUND_CHANGES = 1 << 0
155+
};
156+
153157
AppOpsManager();
154158

155159
int32_t checkOp(int32_t op, int32_t uid, const String16& callingPackage);
@@ -173,6 +177,8 @@ class AppOpsManager
173177
const std::optional<String16>& attributionTag);
174178
void startWatchingMode(int32_t op, const String16& packageName,
175179
const sp<IAppOpsCallback>& callback);
180+
void startWatchingMode(int32_t op, const String16& packageName, int32_t flags,
181+
const sp<IAppOpsCallback>& callback);
176182
void stopWatchingMode(const sp<IAppOpsCallback>& callback);
177183
int32_t permissionToOpCode(const String16& permission);
178184
void setCameraAudioRestriction(int32_t mode);

libs/permission/include/binder/IAppOpsService.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class IAppOpsService : public IInterface
5252
const String16& packageName) = 0;
5353
virtual void setCameraAudioRestriction(int32_t mode) = 0;
5454
virtual bool shouldCollectNotes(int32_t opCode) = 0;
55+
virtual void startWatchingModeWithFlags(int32_t op, const String16& packageName,
56+
int32_t flags, const sp<IAppOpsCallback>& callback) = 0;
5557

5658
enum {
5759
CHECK_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION,
@@ -64,6 +66,7 @@ class IAppOpsService : public IInterface
6466
CHECK_AUDIO_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+7,
6567
SHOULD_COLLECT_NOTES_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+8,
6668
SET_CAMERA_AUDIO_RESTRICTION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+9,
69+
START_WATCHING_MODE_WITH_FLAGS_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+10,
6770
};
6871

6972
enum {

0 commit comments

Comments
 (0)