libbinder: can't remark binder stability

Marking a binder should only ever happen by the AIDL compiler (where the
stability is tied to the build system and other API checks) or, for
existing hand-written binders, when they first leave the process.

In order to detect accidental mismarks of binders, it's a hard error.

Bug: 136027762
Test: binderStabilityTest
Change-Id: I8570300562b26c58da0ec872afbe130cac3d53bd
diff --git a/libs/binder/tests/binderStabilityTest.cpp b/libs/binder/tests/binderStabilityTest.cpp
index 490850e..0336b9e 100644
--- a/libs/binder/tests/binderStabilityTest.cpp
+++ b/libs/binder/tests/binderStabilityTest.cpp
@@ -275,6 +275,14 @@
     ASSERT_TRUE(MarksStabilityInConstructor::gDestructed);
 }
 
+TEST(BinderStability, RemarkDies) {
+    ASSERT_DEATH({
+        sp<IBinder> binder = new BBinder();
+        Stability::markCompilationUnit(binder.get()); // <-- only called for tests
+        Stability::markVndk(binder.get()); // <-- only called for tests
+    }, "Should only mark known object.");
+}
+
 int main(int argc, char** argv) {
     ::testing::InitGoogleTest(&argc, argv);