Merge "Replace several IPCThreadState::get() lookups with one." into gingerbread
This commit is contained in:
committed by
Android (Google) Code Review
commit
84c924a6c5
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user