Loading cmds/dumpsys/tests/dumpsys_test.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ class ServiceManagerMock : public IServiceManager { MOCK_METHOD1(waitForService, sp<IBinder>(const String16&)); MOCK_METHOD1(isDeclared, bool(const String16&)); MOCK_METHOD1(getDeclaredInstances, Vector<String16>(const String16&)); MOCK_METHOD1(updatableViaApex, std::optional<String16>(const String16&)); protected: MOCK_METHOD0(onAsBinder, IBinder*()); }; Loading cmds/servicemanager/ServiceManager.cpp +64 −15 Original line number Diff line number Diff line Loading @@ -58,7 +58,12 @@ static bool forEachManifest(const std::function<bool(const ManifestWithDescripti return false; } static bool isVintfDeclared(const std::string& name) { struct AidlName { std::string package; std::string iface; std::string instance; static bool fill(const std::string& name, AidlName* aname) { size_t firstSlash = name.find('/'); size_t lastDot = name.rfind('.', firstSlash); if (firstSlash == std::string::npos || lastDot == std::string::npos) { Loading @@ -66,14 +71,21 @@ static bool isVintfDeclared(const std::string& name) { << "some.package.foo.IFoo/default) but got: " << name; return false; } const std::string package = name.substr(0, lastDot); const std::string iface = name.substr(lastDot+1, firstSlash-lastDot-1); const std::string instance = name.substr(firstSlash+1); aname->package = name.substr(0, lastDot); aname->iface = name.substr(lastDot + 1, firstSlash - lastDot - 1); aname->instance = name.substr(firstSlash + 1); return true; } }; static bool isVintfDeclared(const std::string& name) { AidlName aname; if (!AidlName::fill(name, &aname)) return false; bool found = forEachManifest([&](const ManifestWithDescription& mwd) { if (mwd.manifest->hasAidlInstance(package, iface, instance)) { if (mwd.manifest->hasAidlInstance(aname.package, aname.iface, aname.instance)) { LOG(INFO) << "Found " << name << " in " << mwd.description << " VINTF manifest."; return true; return true; // break } return false; // continue }); Loading @@ -81,13 +93,34 @@ static bool isVintfDeclared(const std::string& name) { if (!found) { // Although it is tested, explicitly rebuilding qualified name, in case it // becomes something unexpected. LOG(ERROR) << "Could not find " << package << "." << iface << "/" << instance << " in the VINTF manifest."; LOG(ERROR) << "Could not find " << aname.package << "." << aname.iface << "/" << aname.instance << " in the VINTF manifest."; } return found; } static std::optional<std::string> getVintfUpdatableApex(const std::string& name) { AidlName aname; if (!AidlName::fill(name, &aname)) return std::nullopt; std::optional<std::string> updatableViaApex; forEachManifest([&](const ManifestWithDescription& mwd) { mwd.manifest->forEachInstance([&](const auto& manifestInstance) { if (manifestInstance.format() != vintf::HalFormat::AIDL) return true; if (manifestInstance.package() != aname.package) return true; if (manifestInstance.interface() != aname.iface) return true; if (manifestInstance.instance() != aname.instance) return true; updatableViaApex = manifestInstance.updatableViaApex(); return false; // break (libvintf uses opposite convention) }); return false; // continue }); return updatableViaApex; } static std::vector<std::string> getVintfInstances(const std::string& interface) { size_t lastDot = interface.rfind('.'); if (lastDot == std::string::npos) { Loading Loading @@ -388,6 +421,22 @@ binder::Status ServiceManager::getDeclaredInstances(const std::string& interface return Status::ok(); } Status ServiceManager::updatableViaApex(const std::string& name, std::optional<std::string>* outReturn) { auto ctx = mAccess->getCallingContext(); if (!mAccess->canFind(ctx, name)) { return Status::fromExceptionCode(Status::EX_SECURITY); } *outReturn = std::nullopt; #ifndef VENDORSERVICEMANAGER *outReturn = getVintfUpdatableApex(name); #endif return Status::ok(); } void ServiceManager::removeRegistrationCallback(const wp<IBinder>& who, ServiceCallbackMap::iterator* it, bool* found) { Loading cmds/servicemanager/ServiceManager.h +2 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,8 @@ public: binder::Status isDeclared(const std::string& name, bool* outReturn) override; binder::Status getDeclaredInstances(const std::string& interface, std::vector<std::string>* outReturn) override; binder::Status updatableViaApex(const std::string& name, std::optional<std::string>* outReturn) override; binder::Status registerClientCallback(const std::string& name, const sp<IBinder>& service, const sp<IClientCallback>& cb) override; binder::Status tryUnregisterService(const std::string& name, const sp<IBinder>& binder) override; Loading include/android/surface_control.h +36 −0 Original line number Diff line number Diff line Loading @@ -147,6 +147,28 @@ typedef struct ASurfaceTransactionStats ASurfaceTransactionStats; typedef void (*ASurfaceTransaction_OnComplete)(void* context, ASurfaceTransactionStats* stats) __INTRODUCED_IN(29); /** * The ASurfaceTransaction_OnCommit callback is invoked when transaction is applied and the updates * are ready to be presented. This callback will be invoked before the * ASurfaceTransaction_OnComplete callback. * * \param context Optional context provided by the client that is passed into the callback. * * \param stats Opaque handle that can be passed to ASurfaceTransactionStats functions to query * information about the transaction. The handle is only valid during the callback. * Present and release fences are not available for this callback. Querying them using * ASurfaceTransactionStats_getPresentFenceFd and ASurfaceTransactionStats_getPreviousReleaseFenceFd * will result in failure. * * THREADING * The transaction committed callback can be invoked on any thread. * * Available since API level 31. */ typedef void (*ASurfaceTransaction_OnCommit)(void* context, ASurfaceTransactionStats* stats) __INTRODUCED_IN(31); /** * Returns the timestamp of when the frame was latched by the framework. Once a frame is * latched by the framework, it is presented at the following hardware vsync. Loading @@ -161,6 +183,8 @@ int64_t ASurfaceTransactionStats_getLatchTime(ASurfaceTransactionStats* surface_ * The recipient of the callback takes ownership of the fence and is responsible for closing * it. If a device does not support present fences, a -1 will be returned. * * This query is not valid for ASurfaceTransaction_OnCommit callback. * * Available since API level 29. */ int ASurfaceTransactionStats_getPresentFenceFd(ASurfaceTransactionStats* surface_transaction_stats) Loading Loading @@ -218,6 +242,8 @@ int64_t ASurfaceTransactionStats_getAcquireTime(ASurfaceTransactionStats* surfac * The client must ensure that all pending refs on a buffer are released before attempting to reuse * this buffer, otherwise synchronization errors may occur. * * This query is not valid for ASurfaceTransaction_OnCommit callback. * * Available since API level 29. */ int ASurfaceTransactionStats_getPreviousReleaseFenceFd( Loading @@ -235,6 +261,16 @@ int ASurfaceTransactionStats_getPreviousReleaseFenceFd( void ASurfaceTransaction_setOnComplete(ASurfaceTransaction* transaction, void* context, ASurfaceTransaction_OnComplete func) __INTRODUCED_IN(29); /** * Sets the callback that will be invoked when the updates from this transaction are applied and are * ready to be presented. This callback will be invoked before the ASurfaceTransaction_OnComplete * callback. * * Available since API level 31. */ void ASurfaceTransaction_setOnCommit(ASurfaceTransaction* transaction, void* context, ASurfaceTransaction_OnCommit func) __INTRODUCED_IN(31); /** * Reparents the \a surface_control from its old parent to the \a new_parent surface control. * Any children of the reparented \a surface_control will remain children of the \a surface_control. Loading libs/binder/IServiceManager.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ public: sp<IBinder> waitForService(const String16& name16) override; bool isDeclared(const String16& name) override; Vector<String16> getDeclaredInstances(const String16& interface) override; std::optional<String16> updatableViaApex(const String16& name) override; // for legacy ABI const String16& getInterfaceDescriptor() const override { Loading Loading @@ -388,4 +389,12 @@ Vector<String16> ServiceManagerShim::getDeclaredInstances(const String16& interf return res; } std::optional<String16> ServiceManagerShim::updatableViaApex(const String16& name) { std::optional<std::string> declared; if (!mTheRealServiceManager->updatableViaApex(String8(name).c_str(), &declared).isOk()) { return std::nullopt; } return declared ? std::optional<String16>(String16(declared.value().c_str())) : std::nullopt; } } // namespace android Loading
cmds/dumpsys/tests/dumpsys_test.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ class ServiceManagerMock : public IServiceManager { MOCK_METHOD1(waitForService, sp<IBinder>(const String16&)); MOCK_METHOD1(isDeclared, bool(const String16&)); MOCK_METHOD1(getDeclaredInstances, Vector<String16>(const String16&)); MOCK_METHOD1(updatableViaApex, std::optional<String16>(const String16&)); protected: MOCK_METHOD0(onAsBinder, IBinder*()); }; Loading
cmds/servicemanager/ServiceManager.cpp +64 −15 Original line number Diff line number Diff line Loading @@ -58,7 +58,12 @@ static bool forEachManifest(const std::function<bool(const ManifestWithDescripti return false; } static bool isVintfDeclared(const std::string& name) { struct AidlName { std::string package; std::string iface; std::string instance; static bool fill(const std::string& name, AidlName* aname) { size_t firstSlash = name.find('/'); size_t lastDot = name.rfind('.', firstSlash); if (firstSlash == std::string::npos || lastDot == std::string::npos) { Loading @@ -66,14 +71,21 @@ static bool isVintfDeclared(const std::string& name) { << "some.package.foo.IFoo/default) but got: " << name; return false; } const std::string package = name.substr(0, lastDot); const std::string iface = name.substr(lastDot+1, firstSlash-lastDot-1); const std::string instance = name.substr(firstSlash+1); aname->package = name.substr(0, lastDot); aname->iface = name.substr(lastDot + 1, firstSlash - lastDot - 1); aname->instance = name.substr(firstSlash + 1); return true; } }; static bool isVintfDeclared(const std::string& name) { AidlName aname; if (!AidlName::fill(name, &aname)) return false; bool found = forEachManifest([&](const ManifestWithDescription& mwd) { if (mwd.manifest->hasAidlInstance(package, iface, instance)) { if (mwd.manifest->hasAidlInstance(aname.package, aname.iface, aname.instance)) { LOG(INFO) << "Found " << name << " in " << mwd.description << " VINTF manifest."; return true; return true; // break } return false; // continue }); Loading @@ -81,13 +93,34 @@ static bool isVintfDeclared(const std::string& name) { if (!found) { // Although it is tested, explicitly rebuilding qualified name, in case it // becomes something unexpected. LOG(ERROR) << "Could not find " << package << "." << iface << "/" << instance << " in the VINTF manifest."; LOG(ERROR) << "Could not find " << aname.package << "." << aname.iface << "/" << aname.instance << " in the VINTF manifest."; } return found; } static std::optional<std::string> getVintfUpdatableApex(const std::string& name) { AidlName aname; if (!AidlName::fill(name, &aname)) return std::nullopt; std::optional<std::string> updatableViaApex; forEachManifest([&](const ManifestWithDescription& mwd) { mwd.manifest->forEachInstance([&](const auto& manifestInstance) { if (manifestInstance.format() != vintf::HalFormat::AIDL) return true; if (manifestInstance.package() != aname.package) return true; if (manifestInstance.interface() != aname.iface) return true; if (manifestInstance.instance() != aname.instance) return true; updatableViaApex = manifestInstance.updatableViaApex(); return false; // break (libvintf uses opposite convention) }); return false; // continue }); return updatableViaApex; } static std::vector<std::string> getVintfInstances(const std::string& interface) { size_t lastDot = interface.rfind('.'); if (lastDot == std::string::npos) { Loading Loading @@ -388,6 +421,22 @@ binder::Status ServiceManager::getDeclaredInstances(const std::string& interface return Status::ok(); } Status ServiceManager::updatableViaApex(const std::string& name, std::optional<std::string>* outReturn) { auto ctx = mAccess->getCallingContext(); if (!mAccess->canFind(ctx, name)) { return Status::fromExceptionCode(Status::EX_SECURITY); } *outReturn = std::nullopt; #ifndef VENDORSERVICEMANAGER *outReturn = getVintfUpdatableApex(name); #endif return Status::ok(); } void ServiceManager::removeRegistrationCallback(const wp<IBinder>& who, ServiceCallbackMap::iterator* it, bool* found) { Loading
cmds/servicemanager/ServiceManager.h +2 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,8 @@ public: binder::Status isDeclared(const std::string& name, bool* outReturn) override; binder::Status getDeclaredInstances(const std::string& interface, std::vector<std::string>* outReturn) override; binder::Status updatableViaApex(const std::string& name, std::optional<std::string>* outReturn) override; binder::Status registerClientCallback(const std::string& name, const sp<IBinder>& service, const sp<IClientCallback>& cb) override; binder::Status tryUnregisterService(const std::string& name, const sp<IBinder>& binder) override; Loading
include/android/surface_control.h +36 −0 Original line number Diff line number Diff line Loading @@ -147,6 +147,28 @@ typedef struct ASurfaceTransactionStats ASurfaceTransactionStats; typedef void (*ASurfaceTransaction_OnComplete)(void* context, ASurfaceTransactionStats* stats) __INTRODUCED_IN(29); /** * The ASurfaceTransaction_OnCommit callback is invoked when transaction is applied and the updates * are ready to be presented. This callback will be invoked before the * ASurfaceTransaction_OnComplete callback. * * \param context Optional context provided by the client that is passed into the callback. * * \param stats Opaque handle that can be passed to ASurfaceTransactionStats functions to query * information about the transaction. The handle is only valid during the callback. * Present and release fences are not available for this callback. Querying them using * ASurfaceTransactionStats_getPresentFenceFd and ASurfaceTransactionStats_getPreviousReleaseFenceFd * will result in failure. * * THREADING * The transaction committed callback can be invoked on any thread. * * Available since API level 31. */ typedef void (*ASurfaceTransaction_OnCommit)(void* context, ASurfaceTransactionStats* stats) __INTRODUCED_IN(31); /** * Returns the timestamp of when the frame was latched by the framework. Once a frame is * latched by the framework, it is presented at the following hardware vsync. Loading @@ -161,6 +183,8 @@ int64_t ASurfaceTransactionStats_getLatchTime(ASurfaceTransactionStats* surface_ * The recipient of the callback takes ownership of the fence and is responsible for closing * it. If a device does not support present fences, a -1 will be returned. * * This query is not valid for ASurfaceTransaction_OnCommit callback. * * Available since API level 29. */ int ASurfaceTransactionStats_getPresentFenceFd(ASurfaceTransactionStats* surface_transaction_stats) Loading Loading @@ -218,6 +242,8 @@ int64_t ASurfaceTransactionStats_getAcquireTime(ASurfaceTransactionStats* surfac * The client must ensure that all pending refs on a buffer are released before attempting to reuse * this buffer, otherwise synchronization errors may occur. * * This query is not valid for ASurfaceTransaction_OnCommit callback. * * Available since API level 29. */ int ASurfaceTransactionStats_getPreviousReleaseFenceFd( Loading @@ -235,6 +261,16 @@ int ASurfaceTransactionStats_getPreviousReleaseFenceFd( void ASurfaceTransaction_setOnComplete(ASurfaceTransaction* transaction, void* context, ASurfaceTransaction_OnComplete func) __INTRODUCED_IN(29); /** * Sets the callback that will be invoked when the updates from this transaction are applied and are * ready to be presented. This callback will be invoked before the ASurfaceTransaction_OnComplete * callback. * * Available since API level 31. */ void ASurfaceTransaction_setOnCommit(ASurfaceTransaction* transaction, void* context, ASurfaceTransaction_OnCommit func) __INTRODUCED_IN(31); /** * Reparents the \a surface_control from its old parent to the \a new_parent surface control. * Any children of the reparented \a surface_control will remain children of the \a surface_control. Loading
libs/binder/IServiceManager.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ public: sp<IBinder> waitForService(const String16& name16) override; bool isDeclared(const String16& name) override; Vector<String16> getDeclaredInstances(const String16& interface) override; std::optional<String16> updatableViaApex(const String16& name) override; // for legacy ABI const String16& getInterfaceDescriptor() const override { Loading Loading @@ -388,4 +389,12 @@ Vector<String16> ServiceManagerShim::getDeclaredInstances(const String16& interf return res; } std::optional<String16> ServiceManagerShim::updatableViaApex(const String16& name) { std::optional<std::string> declared; if (!mTheRealServiceManager->updatableViaApex(String8(name).c_str(), &declared).isOk()) { return std::nullopt; } return declared ? std::optional<String16>(String16(declared.value().c_str())) : std::nullopt; } } // namespace android