Loading libs/binder/include/binder/Stability.h +3 −3 Original line number Diff line number Diff line Loading @@ -57,6 +57,9 @@ public: // can be called to use that same interface within the local partition. static void forceDowngradeToLocalStability(const sp<IBinder>& binder); // WARNING: Below APIs are only ever expected to be called by auto-generated code. // Instead of calling them, you should set the stability of a .aidl interface // WARNING: The only client of // - forceDowngradeToSystemStability() and; // - korceDowngradeToVendorStability() Loading @@ -82,9 +85,6 @@ public: // can be called to use that same interface within the system partition. static void forceDowngradeToSystemStability(const sp<IBinder>& binder); // WARNING: Below APIs are only ever expected to be called by auto-generated code. // Instead of calling them, you should set the stability of a .aidl interface // WARNING: This is only ever expected to be called by auto-generated code. You likely want to // change or modify the stability class of the interface you are using. // This must be called as soon as the binder in question is constructed. No thread safety Loading libs/binder/tests/binderStabilityTest.cpp +29 −2 Original line number Diff line number Diff line Loading @@ -132,7 +132,7 @@ TEST(BinderStability, OnlyVintfStabilityBinderNeedsVintfDeclaration) { EXPECT_TRUE(Stability::requiresVintfDeclaration(BadStableBinder::vintf())); } TEST(BinderStability, ForceDowngradeStability) { TEST(BinderStability, ForceDowngradeToLocalStability) { sp<IBinder> someBinder = BadStableBinder::vintf(); EXPECT_TRUE(Stability::requiresVintfDeclaration(someBinder)); Loading @@ -143,7 +143,7 @@ TEST(BinderStability, ForceDowngradeStability) { EXPECT_FALSE(Stability::requiresVintfDeclaration(someBinder)); } TEST(BinderStability, NdkForceDowngradeStability) { TEST(BinderStability, NdkForceDowngradeToLocalStability) { sp<IBinder> someBinder = BadStableBinder::vintf(); EXPECT_TRUE(Stability::requiresVintfDeclaration(someBinder)); Loading @@ -154,6 +154,33 @@ TEST(BinderStability, NdkForceDowngradeStability) { EXPECT_FALSE(Stability::requiresVintfDeclaration(someBinder)); } TEST(BinderStability, ForceDowngradeToVendorStability) { sp<IBinder> serverBinder = android::defaultServiceManager()->getService(kSystemStabilityServer); auto server = interface_cast<IBinderStabilityTest>(serverBinder); ASSERT_NE(nullptr, server.get()); ASSERT_NE(nullptr, IInterface::asBinder(server)->remoteBinder()); { sp<BadStableBinder> binder = BadStableBinder::vintf(); EXPECT_TRUE(Stability::requiresVintfDeclaration(binder)); EXPECT_TRUE(server->sendAndCallBinder(binder).isOk()); EXPECT_TRUE(binder->gotUserTransaction); } { sp<BadStableBinder> binder = BadStableBinder::vintf(); // This method should never be called directly. This is done only for the test. Stability::forceDowngradeToVendorStability(binder); // Binder downgraded to vendor stability, cannot be called from system context EXPECT_FALSE(Stability::requiresVintfDeclaration(binder)); EXPECT_EQ(BAD_TYPE, server->sendAndCallBinder(binder).exceptionCode()); EXPECT_FALSE(binder->gotUserTransaction); } } TEST(BinderStability, VintfStabilityServerMustBeDeclaredInManifest) { sp<IBinder> vintfServer = BadStableBinder::vintf(); Loading Loading
libs/binder/include/binder/Stability.h +3 −3 Original line number Diff line number Diff line Loading @@ -57,6 +57,9 @@ public: // can be called to use that same interface within the local partition. static void forceDowngradeToLocalStability(const sp<IBinder>& binder); // WARNING: Below APIs are only ever expected to be called by auto-generated code. // Instead of calling them, you should set the stability of a .aidl interface // WARNING: The only client of // - forceDowngradeToSystemStability() and; // - korceDowngradeToVendorStability() Loading @@ -82,9 +85,6 @@ public: // can be called to use that same interface within the system partition. static void forceDowngradeToSystemStability(const sp<IBinder>& binder); // WARNING: Below APIs are only ever expected to be called by auto-generated code. // Instead of calling them, you should set the stability of a .aidl interface // WARNING: This is only ever expected to be called by auto-generated code. You likely want to // change or modify the stability class of the interface you are using. // This must be called as soon as the binder in question is constructed. No thread safety Loading
libs/binder/tests/binderStabilityTest.cpp +29 −2 Original line number Diff line number Diff line Loading @@ -132,7 +132,7 @@ TEST(BinderStability, OnlyVintfStabilityBinderNeedsVintfDeclaration) { EXPECT_TRUE(Stability::requiresVintfDeclaration(BadStableBinder::vintf())); } TEST(BinderStability, ForceDowngradeStability) { TEST(BinderStability, ForceDowngradeToLocalStability) { sp<IBinder> someBinder = BadStableBinder::vintf(); EXPECT_TRUE(Stability::requiresVintfDeclaration(someBinder)); Loading @@ -143,7 +143,7 @@ TEST(BinderStability, ForceDowngradeStability) { EXPECT_FALSE(Stability::requiresVintfDeclaration(someBinder)); } TEST(BinderStability, NdkForceDowngradeStability) { TEST(BinderStability, NdkForceDowngradeToLocalStability) { sp<IBinder> someBinder = BadStableBinder::vintf(); EXPECT_TRUE(Stability::requiresVintfDeclaration(someBinder)); Loading @@ -154,6 +154,33 @@ TEST(BinderStability, NdkForceDowngradeStability) { EXPECT_FALSE(Stability::requiresVintfDeclaration(someBinder)); } TEST(BinderStability, ForceDowngradeToVendorStability) { sp<IBinder> serverBinder = android::defaultServiceManager()->getService(kSystemStabilityServer); auto server = interface_cast<IBinderStabilityTest>(serverBinder); ASSERT_NE(nullptr, server.get()); ASSERT_NE(nullptr, IInterface::asBinder(server)->remoteBinder()); { sp<BadStableBinder> binder = BadStableBinder::vintf(); EXPECT_TRUE(Stability::requiresVintfDeclaration(binder)); EXPECT_TRUE(server->sendAndCallBinder(binder).isOk()); EXPECT_TRUE(binder->gotUserTransaction); } { sp<BadStableBinder> binder = BadStableBinder::vintf(); // This method should never be called directly. This is done only for the test. Stability::forceDowngradeToVendorStability(binder); // Binder downgraded to vendor stability, cannot be called from system context EXPECT_FALSE(Stability::requiresVintfDeclaration(binder)); EXPECT_EQ(BAD_TYPE, server->sendAndCallBinder(binder).exceptionCode()); EXPECT_FALSE(binder->gotUserTransaction); } } TEST(BinderStability, VintfStabilityServerMustBeDeclaredInManifest) { sp<IBinder> vintfServer = BadStableBinder::vintf(); Loading