IAppOpsCallback.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. #define LOG_TAG "AppOpsCallback"
  17. #include <binder/IAppOpsCallback.h>
  18. #include <utils/Log.h>
  19. #include <binder/Parcel.h>
  20. #include <utils/String8.h>
  21. #include <private/binder/Static.h>
  22. namespace android {
  23. // ----------------------------------------------------------------------
  24. class BpAppOpsCallback : public BpInterface<IAppOpsCallback>
  25. {
  26. public:
  27. BpAppOpsCallback(const sp<IBinder>& impl)
  28. : BpInterface<IAppOpsCallback>(impl)
  29. {
  30. }
  31. virtual void opChanged(int32_t op, const String16& packageName) {
  32. Parcel data, reply;
  33. data.writeInterfaceToken(IAppOpsCallback::getInterfaceDescriptor());
  34. data.writeInt32(op);
  35. data.writeString16(packageName);
  36. remote()->transact(OP_CHANGED_TRANSACTION, data, &reply);
  37. }
  38. };
  39. IMPLEMENT_META_INTERFACE(AppOpsCallback, "com.android.internal.app.IAppOpsCallback");
  40. // ----------------------------------------------------------------------
  41. status_t BnAppOpsCallback::onTransact(
  42. uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
  43. {
  44. switch(code) {
  45. case OP_CHANGED_TRANSACTION: {
  46. CHECK_INTERFACE(IAppOpsCallback, data, reply);
  47. int32_t op = data.readInt32();
  48. String16 packageName = data.readString16();
  49. opChanged(op, packageName);
  50. reply->writeNoException();
  51. return NO_ERROR;
  52. } break;
  53. default:
  54. return BBinder::onTransact(code, data, reply, flags);
  55. }
  56. }
  57. }; // namespace android