Generate notifySyspropsChanged().

notifySyspropsChanged() can be used to notify
any HIDL interface of the fact that a system
property has changed, upon which the process
hosting the interface can take action.

The current implementation calls
report_sysprop_change(), which is a libcutils
function that will call a set of previously
registered callbacks.

One such callback is used for atrace, where the
enabled trace categories are stored in system
properties, and we need to notify running
services when those properties have changed.
Without notifying them, we'd need to have a
process to be restarted *while* a trace is
already running, which in the best case is
clumsy, and in the worst case totally
impractical.

(We may want to move this out of libcutils at
some point, but that is out of the scope of
this CL).

Bug: 31262344
Test: mma, hidl_test, hidl_test_java, systrace works without restart
Change-Id: I7b368e2a89ac9947cd0f8c4311df6c31d3ef4a8a
diff --git a/Interface.cpp b/Interface.cpp
index 35cbce3..b72018d 100644
--- a/Interface.cpp
+++ b/Interface.cpp
@@ -45,6 +45,7 @@
     /////////////////// HIDL reserved
     FIRST_HIDL_TRANSACTION  = 0x00f00000,
     HIDL_DESCRIPTOR_CHAIN_TRANSACTION = FIRST_HIDL_TRANSACTION,
+    HIDL_SYSPROPS_CHANGED_TRANSACTION,
     LAST_HIDL_TRANSACTION   = 0x00ffffff,
 };
 
@@ -53,6 +54,24 @@
       mSuperType(super),
       mIsJavaCompatibleInProgress(false) {
     mReservedMethods.push_back(createDescriptorChainMethod());
+    mReservedMethods.push_back(createSyspropsChangedMethod());
+}
+
+Method *Interface::createSyspropsChangedMethod() const {
+    return new Method("notifySyspropsChanged",
+            new std::vector<TypedVar *>() /*args */,
+            new std::vector<TypedVar *>() /*results */,
+            true /*oneway */,
+            new std::vector<Annotation *>(),
+            HIDL_SYSPROPS_CHANGED_TRANSACTION,
+            [this](auto &out) { /*cppImpl */
+                out << "::android::report_sysprop_change();\n";
+                out << "return ::android::hardware::Void();";
+            },
+            [this](auto &out) { /* javaImpl */
+                out << "android.os.SystemProperties.reportSyspropChanged();";
+            }
+    );
 }
 
 Method *Interface::createDescriptorChainMethod() const {