From f1377f506c764a8b254b60ee28e38e12ccc8135c Mon Sep 17 00:00:00 2001 From: Svet Ganov Date: Tue, 28 Apr 2015 12:09:01 -0700 Subject: [PATCH] Respect the record audio app op - frameworks native Change-Id: Id747767377953fd644a538aad3f603d6c50875a2 --- include/binder/AppOpsManager.h | 26 ++++++++++++++++++- include/binder/IPermissionController.h | 11 +++++--- libs/binder/IPermissionController.cpp | 35 +++++++++++++++++++++++++- 3 files changed, 66 insertions(+), 6 deletions(-) diff --git a/include/binder/AppOpsManager.h b/include/binder/AppOpsManager.h index 256cb949b..ea339527a 100644 --- a/include/binder/AppOpsManager.h +++ b/include/binder/AppOpsManager.h @@ -63,7 +63,31 @@ public: OP_ACCESS_NOTIFICATIONS = 25, OP_CAMERA = 26, OP_RECORD_AUDIO = 27, - OP_PLAY_AUDIO = 28 + OP_PLAY_AUDIO = 28, + OP_READ_CLIPBOARD = 29, + OP_WRITE_CLIPBOARD = 30, + OP_TAKE_MEDIA_BUTTONS = 31, + OP_TAKE_AUDIO_FOCUS = 32, + OP_AUDIO_MASTER_VOLUME = 33, + OP_AUDIO_VOICE_VOLUME = 34, + OP_AUDIO_RING_VOLUME = 35, + OP_AUDIO_MEDIA_VOLUME = 36, + OP_AUDIO_ALARM_VOLUME = 37, + OP_AUDIO_NOTIFICATION_VOLUME = 38, + OP_AUDIO_BLUETOOTH_VOLUME = 39, + OP_WAKE_LOCK = 40, + OP_MONITOR_LOCATION = 41, + OP_MONITOR_HIGH_POWER_LOCATION = 42, + OP_GET_USAGE_STATS = 43, + OP_MUTE_MICROPHONE = 44, + OP_TOAST_WINDOW = 45, + OP_PROJECT_MEDIA = 46, + OP_ACTIVATE_VPN = 47, + OP_WRITE_WALLPAPER = 48, + OP_ASSIST_STRUCTURE = 49, + OP_ASSIST_SCREENSHOT = 50, + OP_READ_PHONE_STATE = 51, + OP_ADD_VOICEMAIL = 52 }; AppOpsManager(); diff --git a/include/binder/IPermissionController.h b/include/binder/IPermissionController.h index f9d371bd1..f3f0a924e 100644 --- a/include/binder/IPermissionController.h +++ b/include/binder/IPermissionController.h @@ -19,6 +19,7 @@ #define ANDROID_IPERMISSION_CONTROLLER_H #include +#include namespace android { @@ -29,11 +30,13 @@ class IPermissionController : public IInterface public: DECLARE_META_INTERFACE(PermissionController); - virtual bool checkPermission(const String16& permission, - int32_t pid, int32_t uid) = 0; - + virtual bool checkPermission(const String16& permission, int32_t pid, int32_t uid) = 0; + + virtual void getPackagesForUid(const uid_t uid, Vector &packages) = 0; + enum { - CHECK_PERMISSION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION + CHECK_PERMISSION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, + GET_PACKAGES_FOR_UID_TRANSACTION = CHECK_PERMISSION_TRANSACTION + 1 }; }; diff --git a/libs/binder/IPermissionController.cpp b/libs/binder/IPermissionController.cpp index 437113d44..67dac27b8 100644 --- a/libs/binder/IPermissionController.cpp +++ b/libs/binder/IPermissionController.cpp @@ -48,6 +48,25 @@ public: if (reply.readExceptionCode() != 0) return 0; return reply.readInt32() != 0; } + + virtual void getPackagesForUid(const uid_t uid, Vector& packages) + { + Parcel data, reply; + data.writeInterfaceToken(IPermissionController::getInterfaceDescriptor()); + data.writeInt32(uid); + remote()->transact(GET_PACKAGES_FOR_UID_TRANSACTION, data, &reply); + // fail on exception + if (reply.readExceptionCode() != 0) { + return; + } + const int32_t size = reply.readInt32(); + if (size <= 0) { + return; + } + for (int i = 0; i < size; i++) { + packages.push(reply.readString16()); + } + } }; IMPLEMENT_META_INTERFACE(PermissionController, "android.os.IPermissionController"); @@ -57,7 +76,6 @@ IMPLEMENT_META_INTERFACE(PermissionController, "android.os.IPermissionController status_t BnPermissionController::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { - //printf("PermissionController received: "); data.print(); switch(code) { case CHECK_PERMISSION_TRANSACTION: { CHECK_INTERFACE(IPermissionController, data, reply); @@ -69,6 +87,21 @@ status_t BnPermissionController::onTransact( reply->writeInt32(res ? 1 : 0); return NO_ERROR; } break; + + case GET_PACKAGES_FOR_UID_TRANSACTION: { + CHECK_INTERFACE(IPermissionController, data, reply); + int32_t uid = data.readInt32(); + Vector packages; + getPackagesForUid(uid, packages); + reply->writeNoException(); + size_t size = packages.size(); + reply->writeInt32(size); + for (size_t i = 0; i < size; i++) { + reply->writeString16(packages[i]); + } + return NO_ERROR; + } break; + default: return BBinder::onTransact(code, data, reply, flags); }