Loading libs/binder/IActivityManager.cpp +47 −0 Original line number Diff line number Diff line Loading @@ -131,6 +131,53 @@ public: *outResult = reply.readInt32(); return NO_ERROR; } virtual status_t logFgsApiBegin(int32_t apiType, int32_t appUid, int32_t appPid) { Parcel data, reply; data.writeInterfaceToken(IActivityManager::getInterfaceDescriptor()); data.writeInt32(apiType); data.writeInt32(appUid); data.writeInt32(appPid); status_t err = remote()->transact(LOG_FGS_API_BEGIN_TRANSACTION, data, &reply); if (err != NO_ERROR || ((err = reply.readExceptionCode()) != NO_ERROR)) { ALOGD("FGS Logger Transaction failed"); ALOGD("%d", err); return err; } return NO_ERROR; } virtual status_t logFgsApiEnd(int32_t apiType, int32_t appUid, int32_t appPid) { Parcel data, reply; data.writeInterfaceToken(IActivityManager::getInterfaceDescriptor()); data.writeInt32(apiType); data.writeInt32(appUid); data.writeInt32(appPid); status_t err = remote()->transact(LOG_FGS_API_END_TRANSACTION, data, &reply); if (err != NO_ERROR || ((err = reply.readExceptionCode()) != NO_ERROR)) { ALOGD("FGS Logger Transaction failed"); ALOGD("%d", err); return err; } return NO_ERROR; } virtual status_t logFgsApiStateChanged(int32_t apiType, int32_t state, int32_t appUid, int32_t appPid) { Parcel data, reply; data.writeInterfaceToken(IActivityManager::getInterfaceDescriptor()); data.writeInt32(apiType); data.writeInt32(state); data.writeInt32(appUid); data.writeInt32(appPid); status_t err = remote()->transact(LOG_FGS_API_BEGIN_TRANSACTION, data, &reply); if (err != NO_ERROR || ((err = reply.readExceptionCode()) != NO_ERROR)) { ALOGD("FGS Logger Transaction failed"); ALOGD("%d", err); return err; } return NO_ERROR; } }; // ------------------------------------------------------------------------------------ Loading libs/binder/include_activitymanager/binder/IActivityManager.h +7 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,10 @@ public: const pid_t pid, const uid_t uid, int32_t* outResult) = 0; virtual status_t logFgsApiBegin(int32_t apiType, int32_t appUid, int32_t appPid) = 0; virtual status_t logFgsApiEnd(int32_t apiType, int32_t appUid, int32_t appPid) = 0; virtual status_t logFgsApiStateChanged(int32_t apiType, int32_t state, int32_t appUid, int32_t appPid) = 0; enum { OPEN_CONTENT_URI_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, Loading @@ -50,6 +54,9 @@ public: IS_UID_ACTIVE_TRANSACTION, GET_UID_PROCESS_STATE_TRANSACTION, CHECK_PERMISSION_TRANSACTION, LOG_FGS_API_BEGIN_TRANSACTION, LOG_FGS_API_END_TRANSACTION, LOG_FGS_API_STATE_CHANGED_TRANSACTION }; }; Loading libs/binder/tests/binderRpcTest.cpp +10 −3 Original line number Diff line number Diff line Loading @@ -382,9 +382,16 @@ std::unique_ptr<ProcessSession> BinderRpc::createRpcTestSocketServerProcessEtc( status = session->setupPreconnectedClient({}, [=]() { #ifdef BINDER_RPC_TO_TRUSTY_TEST auto port = trustyIpcPort(serverVersion); for (size_t i = 0; i < 5; i++) { // Try to connect several times, // in case the service is slow to start int tipcFd = tipc_connect(kTrustyIpcDevice, port.c_str()); return tipcFd >= 0 ? android::base::unique_fd(tipcFd) : android::base::unique_fd(); if (tipcFd >= 0) { return android::base::unique_fd(tipcFd); } usleep(50000); } return android::base::unique_fd(); #else LOG_ALWAYS_FATAL("Tried to connect to Trusty outside of vendor"); return android::base::unique_fd(); Loading libs/binder/tests/parcel_fuzzer/binder.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -374,7 +374,8 @@ std::vector<ParcelRead<::android::Parcel>> BINDER_PARCEL_READ_FUNCTIONS { parcelables::GenericDataParcelable genericDataParcelable; status_t status = genericDataParcelable.readFromParcel(&p); FUZZ_LOG() << " status: " << status; FUZZ_LOG() << " toString() result: " << genericDataParcelable.toString(); std::string toString = genericDataParcelable.toString(); FUZZ_LOG() << " toString() result: " << toString; }, }; // clang-format on Loading libs/binder/tests/parcel_fuzzer/binder_ndk.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -198,6 +198,8 @@ std::vector<ParcelRead<NdkParcelAdapter>> BINDER_NDK_PARCEL_READ_FUNCTIONS{ aidl::parcelables::GenericDataParcelable genericDataParcelable; binder_status_t status = genericDataParcelable.readFromParcel(p.aParcel()); FUZZ_LOG() << "status: " << status; std::string toString = genericDataParcelable.toString(); FUZZ_LOG() << "toString() result: " << toString; }, [](const NdkParcelAdapter& p, FuzzedDataProvider& provider) { FUZZ_LOG() << "about to marshal AParcel"; Loading Loading
libs/binder/IActivityManager.cpp +47 −0 Original line number Diff line number Diff line Loading @@ -131,6 +131,53 @@ public: *outResult = reply.readInt32(); return NO_ERROR; } virtual status_t logFgsApiBegin(int32_t apiType, int32_t appUid, int32_t appPid) { Parcel data, reply; data.writeInterfaceToken(IActivityManager::getInterfaceDescriptor()); data.writeInt32(apiType); data.writeInt32(appUid); data.writeInt32(appPid); status_t err = remote()->transact(LOG_FGS_API_BEGIN_TRANSACTION, data, &reply); if (err != NO_ERROR || ((err = reply.readExceptionCode()) != NO_ERROR)) { ALOGD("FGS Logger Transaction failed"); ALOGD("%d", err); return err; } return NO_ERROR; } virtual status_t logFgsApiEnd(int32_t apiType, int32_t appUid, int32_t appPid) { Parcel data, reply; data.writeInterfaceToken(IActivityManager::getInterfaceDescriptor()); data.writeInt32(apiType); data.writeInt32(appUid); data.writeInt32(appPid); status_t err = remote()->transact(LOG_FGS_API_END_TRANSACTION, data, &reply); if (err != NO_ERROR || ((err = reply.readExceptionCode()) != NO_ERROR)) { ALOGD("FGS Logger Transaction failed"); ALOGD("%d", err); return err; } return NO_ERROR; } virtual status_t logFgsApiStateChanged(int32_t apiType, int32_t state, int32_t appUid, int32_t appPid) { Parcel data, reply; data.writeInterfaceToken(IActivityManager::getInterfaceDescriptor()); data.writeInt32(apiType); data.writeInt32(state); data.writeInt32(appUid); data.writeInt32(appPid); status_t err = remote()->transact(LOG_FGS_API_BEGIN_TRANSACTION, data, &reply); if (err != NO_ERROR || ((err = reply.readExceptionCode()) != NO_ERROR)) { ALOGD("FGS Logger Transaction failed"); ALOGD("%d", err); return err; } return NO_ERROR; } }; // ------------------------------------------------------------------------------------ Loading
libs/binder/include_activitymanager/binder/IActivityManager.h +7 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,10 @@ public: const pid_t pid, const uid_t uid, int32_t* outResult) = 0; virtual status_t logFgsApiBegin(int32_t apiType, int32_t appUid, int32_t appPid) = 0; virtual status_t logFgsApiEnd(int32_t apiType, int32_t appUid, int32_t appPid) = 0; virtual status_t logFgsApiStateChanged(int32_t apiType, int32_t state, int32_t appUid, int32_t appPid) = 0; enum { OPEN_CONTENT_URI_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, Loading @@ -50,6 +54,9 @@ public: IS_UID_ACTIVE_TRANSACTION, GET_UID_PROCESS_STATE_TRANSACTION, CHECK_PERMISSION_TRANSACTION, LOG_FGS_API_BEGIN_TRANSACTION, LOG_FGS_API_END_TRANSACTION, LOG_FGS_API_STATE_CHANGED_TRANSACTION }; }; Loading
libs/binder/tests/binderRpcTest.cpp +10 −3 Original line number Diff line number Diff line Loading @@ -382,9 +382,16 @@ std::unique_ptr<ProcessSession> BinderRpc::createRpcTestSocketServerProcessEtc( status = session->setupPreconnectedClient({}, [=]() { #ifdef BINDER_RPC_TO_TRUSTY_TEST auto port = trustyIpcPort(serverVersion); for (size_t i = 0; i < 5; i++) { // Try to connect several times, // in case the service is slow to start int tipcFd = tipc_connect(kTrustyIpcDevice, port.c_str()); return tipcFd >= 0 ? android::base::unique_fd(tipcFd) : android::base::unique_fd(); if (tipcFd >= 0) { return android::base::unique_fd(tipcFd); } usleep(50000); } return android::base::unique_fd(); #else LOG_ALWAYS_FATAL("Tried to connect to Trusty outside of vendor"); return android::base::unique_fd(); Loading
libs/binder/tests/parcel_fuzzer/binder.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -374,7 +374,8 @@ std::vector<ParcelRead<::android::Parcel>> BINDER_PARCEL_READ_FUNCTIONS { parcelables::GenericDataParcelable genericDataParcelable; status_t status = genericDataParcelable.readFromParcel(&p); FUZZ_LOG() << " status: " << status; FUZZ_LOG() << " toString() result: " << genericDataParcelable.toString(); std::string toString = genericDataParcelable.toString(); FUZZ_LOG() << " toString() result: " << toString; }, }; // clang-format on Loading
libs/binder/tests/parcel_fuzzer/binder_ndk.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -198,6 +198,8 @@ std::vector<ParcelRead<NdkParcelAdapter>> BINDER_NDK_PARCEL_READ_FUNCTIONS{ aidl::parcelables::GenericDataParcelable genericDataParcelable; binder_status_t status = genericDataParcelable.readFromParcel(p.aParcel()); FUZZ_LOG() << "status: " << status; std::string toString = genericDataParcelable.toString(); FUZZ_LOG() << "toString() result: " << toString; }, [](const NdkParcelAdapter& p, FuzzedDataProvider& provider) { FUZZ_LOG() << "about to marshal AParcel"; Loading