diff options
author | 2021-03-31 12:13:56 -0400 | |
---|---|---|
committer | 2021-04-02 16:21:44 -0400 | |
commit | 8b8029151899d012f80add3f55f38f5f7f20bd01 (patch) | |
tree | e76b53c5e898b80ff92cd29945fbaef6839b2ee0 /libs/binder/Stability.cpp | |
parent | 78a58c8af4458905bc5b644207a5badd315cc775 (diff) |
libbinder_ndk: Add stability downgrade
This can be used to allow registering a service with a VINTF interface
without requiring a manifest declaration.
This is useful for test services or in the case of a system proxy
service that implements the same interface as the vintf service.
Bug: 183154648
Bug: 177664629
Test: atest binderStabilityTest
Change-Id: Ibd8dad46945a339b77dca70484082fda06220ee3
Diffstat (limited to 'libs/binder/Stability.cpp')
-rw-r--r-- | libs/binder/Stability.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/libs/binder/Stability.cpp b/libs/binder/Stability.cpp index 06830c027b..709cf67127 100644 --- a/libs/binder/Stability.cpp +++ b/libs/binder/Stability.cpp @@ -38,18 +38,30 @@ Stability::Category Stability::Category::currentFromLevel(Level level) { }; } -void Stability::forceDowngradeCompilationUnit(const sp<IBinder>& binder) { +void Stability::forceDowngradeToStability(const sp<IBinder>& binder, Level level) { // Downgrading a remote binder would require also copying the version from // the binder sent here. In practice though, we don't need to downgrade the // stability of a remote binder, since this would as an effect only restrict // what we can do to it. LOG_ALWAYS_FATAL_IF(!binder || !binder->localBinder(), "Can only downgrade local binder"); - auto stability = Category::currentFromLevel(getLocalLevel()); + auto stability = Category::currentFromLevel(level); status_t result = setRepr(binder.get(), stability.repr(), REPR_LOG | REPR_ALLOW_DOWNGRADE); LOG_ALWAYS_FATAL_IF(result != OK, "Should only mark known object."); } +void Stability::forceDowngradeToLocalStability(const sp<IBinder>& binder) { + forceDowngradeToStability(binder, getLocalLevel()); +} + +void Stability::forceDowngradeToSystemStability(const sp<IBinder>& binder) { + forceDowngradeToStability(binder, Level::SYSTEM); +} + +void Stability::forceDowngradeToVendorStability(const sp<IBinder>& binder) { + forceDowngradeToStability(binder, Level::VENDOR); +} + std::string Stability::Category::debugString() { return levelString(level) + " wire protocol version " + std::to_string(version); |