diff options
author | Brad Fitzpatrick <bradfitz@android.com> | 2010-07-27 14:04:14 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-07-27 14:04:14 -0700 |
commit | 84fabc0ce3d7c3da73903380d0d6141d60fa4448 (patch) | |
tree | 7fc1a8cf6897f7ada12afe7cca8b883c4f912be3 | |
parent | ebd19e0f48b0cb246c246274a256a9bb494b7e7a (diff) | |
parent | 245cb7846c82f7c0840e13f0b994d356846b1678 (diff) | |
download | frameworks_base-84fabc0ce3d7c3da73903380d0d6141d60fa4448.zip frameworks_base-84fabc0ce3d7c3da73903380d0d6141d60fa4448.tar.gz frameworks_base-84fabc0ce3d7c3da73903380d0d6141d60fa4448.tar.bz2 |
am 245cb784: am 84c924a6: Merge "Replace several IPCThreadState::get() lookups with one." into gingerbread
Merge commit '245cb7846c82f7c0840e13f0b994d356846b1678'
* commit '245cb7846c82f7c0840e13f0b994d356846b1678':
Replace several IPCThreadState::get() lookups with one.
-rw-r--r-- | core/java/android/os/StrictMode.java | 2 | ||||
-rw-r--r-- | core/jni/android_util_Binder.cpp | 14 | ||||
-rw-r--r-- | include/binder/Parcel.h | 12 | ||||
-rw-r--r-- | libs/binder/Parcel.cpp | 10 |
4 files changed, 21 insertions, 17 deletions
diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java index dc92590..d4b0500 100644 --- a/core/java/android/os/StrictMode.java +++ b/core/java/android/os/StrictMode.java @@ -97,7 +97,7 @@ public final class StrictMode { * via Parcel.writeNoException() (amusingly) where the caller can * choose how to react. */ - private static ThreadLocal<ArrayList<ApplicationErrorReport.CrashInfo>> gatheredViolations = + private static final ThreadLocal<ArrayList<ApplicationErrorReport.CrashInfo>> gatheredViolations = new ThreadLocal<ArrayList<ApplicationErrorReport.CrashInfo>>() { @Override protected ArrayList<ApplicationErrorReport.CrashInfo> initialValue() { // Starts null to avoid unnecessary allocations when diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp index 040b324..5c4e4fd 100644 --- a/core/jni/android_util_Binder.cpp +++ b/core/jni/android_util_Binder.cpp @@ -1566,15 +1566,15 @@ static void android_os_Parcel_enforceInterface(JNIEnv* env, jobject clazz, jstri if (parcel != NULL) { const jchar* str = env->GetStringCritical(name, 0); if (str) { - const int32_t old_strict_policy = - IPCThreadState::self()->getStrictModePolicy(); - int32_t strict_policy; - bool isValid = parcel->enforceInterface( + IPCThreadState* threadState = IPCThreadState::self(); + const int32_t oldPolicy = threadState->getStrictModePolicy(); + const bool isValid = parcel->enforceInterface( String16(str, env->GetStringLength(name)), - &strict_policy); + threadState); env->ReleaseStringCritical(name, str); if (isValid) { - if (old_strict_policy != strict_policy) { + const int32_t newPolicy = threadState->getStrictModePolicy(); + if (oldPolicy != newPolicy) { // Need to keep the Java-level thread-local strict // mode policy in sync for the libcore // enforcements, which involves an upcall back @@ -1582,7 +1582,7 @@ static void android_os_Parcel_enforceInterface(JNIEnv* env, jobject clazz, jstri // Parcel.enforceInterface signature, as it's // pseudo-public, and used via AIDL // auto-generation...) - set_dalvik_blockguard_policy(env, strict_policy); + set_dalvik_blockguard_policy(env, newPolicy); } return; // everything was correct -> return silently } diff --git a/include/binder/Parcel.h b/include/binder/Parcel.h index fd0fc1f..32c9a1d5 100644 --- a/include/binder/Parcel.h +++ b/include/binder/Parcel.h @@ -26,11 +26,12 @@ // --------------------------------------------------------------------------- namespace android { +class Flattenable; class IBinder; +class IPCThreadState; class ProcessState; class String8; class TextOutput; -class Flattenable; struct flat_binder_object; // defined in support_p/binder_module.h @@ -61,10 +62,13 @@ public: // Parses the RPC header, returning true if the interface name // in the header matches the expected interface from the caller. - // If strict_policy_out is non-NULL, the RPC header's StrictMode policy - // mask is returned. + // + // Additionally, enforceInterface does part of the work of + // propagating the StrictMode policy mask, populating the current + // IPCThreadState, which as an optimization may optionally be + // passed in. bool enforceInterface(const String16& interface, - int32_t* strict_policy_out = NULL) const; + IPCThreadState* threadState = NULL) const; bool checkInterface(IBinder*) const; void freeData(); diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index 60babad..18f75df 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -458,13 +458,13 @@ bool Parcel::checkInterface(IBinder* binder) const } bool Parcel::enforceInterface(const String16& interface, - int32_t* strict_policy_out) const + IPCThreadState* threadState) const { - int32_t strict_policy = readInt32(); - IPCThreadState::self()->setStrictModePolicy(strict_policy); - if (strict_policy_out != NULL) { - *strict_policy_out = strict_policy; + int32_t strictPolicy = readInt32(); + if (threadState == NULL) { + threadState = IPCThreadState::self(); } + threadState->setStrictModePolicy(strictPolicy); const String16 str(readString16()); if (str == interface) { return true; |