am 84c924a6: Merge "Replace several IPCThreadState::get() lookups with one." into gingerbread
Merge commit '84c924a6c53cb63ca018013c9fda0077413d0005' into gingerbread-plus-aosp * commit '84c924a6c53cb63ca018013c9fda0077413d0005': Replace several IPCThreadState::get() lookups with one.
This commit is contained in:
@@ -97,7 +97,7 @@ public final class StrictMode {
|
|||||||
* via Parcel.writeNoException() (amusingly) where the caller can
|
* via Parcel.writeNoException() (amusingly) where the caller can
|
||||||
* choose how to react.
|
* choose how to react.
|
||||||
*/
|
*/
|
||||||
private static ThreadLocal<ArrayList<ApplicationErrorReport.CrashInfo>> gatheredViolations =
|
private static final ThreadLocal<ArrayList<ApplicationErrorReport.CrashInfo>> gatheredViolations =
|
||||||
new ThreadLocal<ArrayList<ApplicationErrorReport.CrashInfo>>() {
|
new ThreadLocal<ArrayList<ApplicationErrorReport.CrashInfo>>() {
|
||||||
@Override protected ArrayList<ApplicationErrorReport.CrashInfo> initialValue() {
|
@Override protected ArrayList<ApplicationErrorReport.CrashInfo> initialValue() {
|
||||||
// Starts null to avoid unnecessary allocations when
|
// 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) {
|
if (parcel != NULL) {
|
||||||
const jchar* str = env->GetStringCritical(name, 0);
|
const jchar* str = env->GetStringCritical(name, 0);
|
||||||
if (str) {
|
if (str) {
|
||||||
const int32_t old_strict_policy =
|
IPCThreadState* threadState = IPCThreadState::self();
|
||||||
IPCThreadState::self()->getStrictModePolicy();
|
const int32_t oldPolicy = threadState->getStrictModePolicy();
|
||||||
int32_t strict_policy;
|
const bool isValid = parcel->enforceInterface(
|
||||||
bool isValid = parcel->enforceInterface(
|
|
||||||
String16(str, env->GetStringLength(name)),
|
String16(str, env->GetStringLength(name)),
|
||||||
&strict_policy);
|
threadState);
|
||||||
env->ReleaseStringCritical(name, str);
|
env->ReleaseStringCritical(name, str);
|
||||||
if (isValid) {
|
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
|
// Need to keep the Java-level thread-local strict
|
||||||
// mode policy in sync for the libcore
|
// mode policy in sync for the libcore
|
||||||
// enforcements, which involves an upcall back
|
// 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
|
// Parcel.enforceInterface signature, as it's
|
||||||
// pseudo-public, and used via AIDL
|
// pseudo-public, and used via AIDL
|
||||||
// auto-generation...)
|
// auto-generation...)
|
||||||
set_dalvik_blockguard_policy(env, strict_policy);
|
set_dalvik_blockguard_policy(env, newPolicy);
|
||||||
}
|
}
|
||||||
return; // everything was correct -> return silently
|
return; // everything was correct -> return silently
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,11 +26,12 @@
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
|
class Flattenable;
|
||||||
class IBinder;
|
class IBinder;
|
||||||
|
class IPCThreadState;
|
||||||
class ProcessState;
|
class ProcessState;
|
||||||
class String8;
|
class String8;
|
||||||
class TextOutput;
|
class TextOutput;
|
||||||
class Flattenable;
|
|
||||||
|
|
||||||
struct flat_binder_object; // defined in support_p/binder_module.h
|
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
|
// Parses the RPC header, returning true if the interface name
|
||||||
// in the header matches the expected interface from the caller.
|
// 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,
|
bool enforceInterface(const String16& interface,
|
||||||
int32_t* strict_policy_out = NULL) const;
|
IPCThreadState* threadState = NULL) const;
|
||||||
bool checkInterface(IBinder*) const;
|
bool checkInterface(IBinder*) const;
|
||||||
|
|
||||||
void freeData();
|
void freeData();
|
||||||
|
|||||||
@@ -458,13 +458,13 @@ bool Parcel::checkInterface(IBinder* binder) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Parcel::enforceInterface(const String16& interface,
|
bool Parcel::enforceInterface(const String16& interface,
|
||||||
int32_t* strict_policy_out) const
|
IPCThreadState* threadState) const
|
||||||
{
|
{
|
||||||
int32_t strict_policy = readInt32();
|
int32_t strictPolicy = readInt32();
|
||||||
IPCThreadState::self()->setStrictModePolicy(strict_policy);
|
if (threadState == NULL) {
|
||||||
if (strict_policy_out != NULL) {
|
threadState = IPCThreadState::self();
|
||||||
*strict_policy_out = strict_policy;
|
|
||||||
}
|
}
|
||||||
|
threadState->setStrictModePolicy(strictPolicy);
|
||||||
const String16 str(readString16());
|
const String16 str(readString16());
|
||||||
if (str == interface) {
|
if (str == interface) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user