diff options
| -rw-r--r-- | core/java/android/os/Binder.java | 13 | ||||
| -rw-r--r-- | core/jni/android_util_Binder.cpp | 24 |
2 files changed, 35 insertions, 2 deletions
diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java index 357c0c97b22c..2e6d2cc4a66a 100644 --- a/core/java/android/os/Binder.java +++ b/core/java/android/os/Binder.java @@ -502,6 +502,19 @@ public class Binder implements IBinder { public static final native void restoreCallingWorkSource(long token); /** + * Mark as being built with VINTF-level stability promise. This API should + * only ever be invoked by the build system. It means that the interface + * represented by this binder is guaranteed to be kept stable for several + * years, and the build system also keeps snapshots of these APIs and + * invokes the AIDL compiler to make sure that these snapshots are + * backwards compatible. Instead of using this API, use an @VintfStability + * interface. + * + * @hide + */ + public final native void markVintfStability(); + + /** * Flush any Binder commands pending in the current thread to the kernel * driver. This can be * useful to call before performing an operation that may block for a long diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp index fe7e508872ab..a236f3143f84 100644 --- a/core/jni/android_util_Binder.cpp +++ b/core/jni/android_util_Binder.cpp @@ -30,12 +30,13 @@ #include <unistd.h> #include <android-base/stringprintf.h> +#include <binder/BpBinder.h> #include <binder/IInterface.h> -#include <binder/IServiceManager.h> #include <binder/IPCThreadState.h> +#include <binder/IServiceManager.h> #include <binder/Parcel.h> -#include <binder/BpBinder.h> #include <binder/ProcessState.h> +#include <binder/Stability.h> #include <cutils/atomic.h> #include <log/log.h> #include <utils/KeyedVector.h> @@ -459,6 +460,9 @@ public: sp<JavaBBinder> b = mBinder.promote(); if (b == NULL) { b = new JavaBBinder(env, obj); + if (mVintf) { + ::android::internal::Stability::markVintf(b.get()); + } mBinder = b; ALOGV("Creating JavaBinder %p (refs %p) for Object %p, weakCount=%" PRId32 "\n", b.get(), b->getWeakRefs(), obj, b->getWeakRefs()->getWeakCount()); @@ -473,9 +477,18 @@ public: return mBinder.promote(); } + void markVintf() { + mVintf = true; + } + private: Mutex mLock; wp<JavaBBinder> mBinder; + + // in the future, we might condense this into int32_t stability, or if there + // is too much binder state here, we can think about making JavaBBinder an + // sp here (avoid recreating it) + bool mVintf = false; }; // ---------------------------------------------------------------------------- @@ -962,6 +975,12 @@ static void android_os_Binder_restoreCallingWorkSource(jlong token) IPCThreadState::self()->restoreCallingWorkSource(token); } +static void android_os_Binder_markVintfStability(JNIEnv* env, jobject clazz) { + JavaBBinderHolder* jbh = + (JavaBBinderHolder*) env->GetLongField(clazz, gBinderOffsets.mObject); + jbh->markVintf(); +} + static void android_os_Binder_flushPendingCommands(JNIEnv* env, jobject clazz) { IPCThreadState::self()->flushCommands(); @@ -1038,6 +1057,7 @@ static const JNINativeMethod gBinderMethods[] = { // @CriticalNative { "clearCallingWorkSource", "()J", (void*)android_os_Binder_clearCallingWorkSource }, { "restoreCallingWorkSource", "(J)V", (void*)android_os_Binder_restoreCallingWorkSource }, + { "markVintfStability", "()V", (void*)android_os_Binder_markVintfStability}, { "flushPendingCommands", "()V", (void*)android_os_Binder_flushPendingCommands }, { "getNativeBBinderHolder", "()J", (void*)android_os_Binder_getNativeBBinderHolder }, { "getNativeFinalizer", "()J", (void*)android_os_Binder_getNativeFinalizer }, |