Merge "StrictMode fingerprinting / hashCode improvements."

This commit is contained in:
Brad Fitzpatrick
2010-11-23 11:19:53 -08:00
committed by Android (Google) Code Review
2 changed files with 21 additions and 3 deletions

View File

@@ -987,7 +987,7 @@ public final class StrictMode {
}
// Not perfect, but fast and good enough for dup suppression.
Integer crashFingerprint = info.crashInfo.stackTrace.hashCode();
Integer crashFingerprint = info.hashCode();
long lastViolationTime = 0;
if (mLastViolationTime.containsKey(crashFingerprint)) {
lastViolationTime = mLastViolationTime.get(crashFingerprint);
@@ -1550,6 +1550,24 @@ public final class StrictMode {
}
}
@Override
public int hashCode() {
int result = 17;
result = 37 * result + crashInfo.stackTrace.hashCode();
if (numAnimationsRunning != 0) {
result *= 37;
}
if (broadcastIntentAction != null) {
result = 37 * result + broadcastIntentAction.hashCode();
}
if (tags != null) {
for (String tag : tags) {
result = 37 * result + tag.hashCode();
}
}
return result;
}
/**
* Create an instance of ViolationInfo initialized from a Parcel.
*/

View File

@@ -557,7 +557,7 @@ public final class ActivityManagerService extends ActivityManagerNative
= new HashMap<PendingIntentRecord.Key, WeakReference<PendingIntentRecord>>();
/**
* Fingerprints (String.hashCode()) of stack traces that we've
* Fingerprints (hashCode()) of stack traces that we've
* already logged DropBox entries for. Guarded by itself. If
* something (rogue user app) forces this over
* MAX_DUP_SUPPRESSED_STACKS entries, the contents are cleared.
@@ -6671,7 +6671,7 @@ public final class ActivityManagerService extends ActivityManagerNative
ProcessRecord r = findAppProcess(app);
if ((violationMask & StrictMode.PENALTY_DROPBOX) != 0) {
Integer stackFingerprint = info.crashInfo.stackTrace.hashCode();
Integer stackFingerprint = info.hashCode();
boolean logIt = true;
synchronized (mAlreadyLoggedViolatedStacks) {
if (mAlreadyLoggedViolatedStacks.contains(stackFingerprint)) {