diff options
author | Dianne Hackborn <hackbod@google.com> | 2014-10-01 14:59:58 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2014-10-01 16:58:56 -0700 |
commit | 8d05172112436a81bed6e4a0810f8914509d8a4d (patch) | |
tree | 6436496aef38ce21c06c6d073fd28edcea204ba3 /packages/SettingsProvider | |
parent | f178591f26a535ec3cffa3520c3ca387ec44959b (diff) | |
download | frameworks_base-8d05172112436a81bed6e4a0810f8914509d8a4d.zip frameworks_base-8d05172112436a81bed6e4a0810f8914509d8a4d.tar.gz frameworks_base-8d05172112436a81bed6e4a0810f8914509d8a4d.tar.bz2 |
More work on issue #17656716: Unhandled exception in Window Manager
Fix Slog.wtf to not acquire the activity manager lock in its code
path, so that it can never deadlock. This was the original intention
of it, but part was missed.
Now we can put back in the code to detect when strict mode data is
getting large (a little more targeted now to the actual problem),
and use Slog.wtf to report it. And as a bonus, when this happens
we will now clear all of the collected violations, to avoid getting
in to the bad case where IPCs start failing. So this should be
good enough for L to fix the problem, with wtf reports for us to
see if the underlying issue is still happening.
Finally, switch a butch of stuff in the system process from Log.wtf
to Slog.wtf, since many of those are deadlocks waiting to happen.
Oh and fix a crash in the settings provider I noticed in APR.
Change-Id: I307d51b7a4db238fd1e5fe2f3f9bf1b9c6f1c041
Diffstat (limited to 'packages/SettingsProvider')
-rw-r--r-- | packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java | 59 |
1 files changed, 45 insertions, 14 deletions
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java index ba5d11d..8084eda 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java @@ -351,8 +351,11 @@ public class SettingsProvider extends ContentProvider { } public void onEvent(int event, String path) { - int modsInFlight = sKnownMutationsInFlight.get(mUserHandle).get(); - if (modsInFlight > 0) { + final AtomicInteger mutationCount; + synchronized (SettingsProvider.this) { + mutationCount = sKnownMutationsInFlight.get(mUserHandle); + } + if (mutationCount != null && mutationCount.get() > 0) { // our own modification. return; } @@ -952,8 +955,13 @@ public class SettingsProvider extends ContentProvider { checkWritePermissions(args); SettingsCache cache = cacheForTable(callingUser, args.table); - final AtomicInteger mutationCount = sKnownMutationsInFlight.get(callingUser); - mutationCount.incrementAndGet(); + final AtomicInteger mutationCount; + synchronized (this) { + mutationCount = sKnownMutationsInFlight.get(callingUser); + } + if (mutationCount != null) { + mutationCount.incrementAndGet(); + } DatabaseHelper dbH = getOrEstablishDatabase( TABLE_GLOBAL.equals(args.table) ? UserHandle.USER_OWNER : callingUser); SQLiteDatabase db = dbH.getWritableDatabase(); @@ -969,7 +977,9 @@ public class SettingsProvider extends ContentProvider { db.setTransactionSuccessful(); } finally { db.endTransaction(); - mutationCount.decrementAndGet(); + if (mutationCount != null) { + mutationCount.decrementAndGet(); + } } sendNotify(uri, callingUser); @@ -1105,12 +1115,19 @@ public class SettingsProvider extends ContentProvider { return Uri.withAppendedPath(url, name); } - final AtomicInteger mutationCount = sKnownMutationsInFlight.get(desiredUserHandle); - mutationCount.incrementAndGet(); + final AtomicInteger mutationCount; + synchronized (this) { + mutationCount = sKnownMutationsInFlight.get(callingUser); + } + if (mutationCount != null) { + mutationCount.incrementAndGet(); + } DatabaseHelper dbH = getOrEstablishDatabase(desiredUserHandle); SQLiteDatabase db = dbH.getWritableDatabase(); final long rowId = db.insert(args.table, null, initialValues); - mutationCount.decrementAndGet(); + if (mutationCount != null) { + mutationCount.decrementAndGet(); + } if (rowId <= 0) return null; SettingsCache.populate(cache, initialValues); // before we notify @@ -1137,12 +1154,19 @@ public class SettingsProvider extends ContentProvider { } checkWritePermissions(args); - final AtomicInteger mutationCount = sKnownMutationsInFlight.get(callingUser); - mutationCount.incrementAndGet(); + final AtomicInteger mutationCount; + synchronized (this) { + mutationCount = sKnownMutationsInFlight.get(callingUser); + } + if (mutationCount != null) { + mutationCount.incrementAndGet(); + } DatabaseHelper dbH = getOrEstablishDatabase(callingUser); SQLiteDatabase db = dbH.getWritableDatabase(); int count = db.delete(args.table, args.where, args.args); - mutationCount.decrementAndGet(); + if (mutationCount != null) { + mutationCount.decrementAndGet(); + } if (count > 0) { invalidateCache(callingUser, args.table); // before we notify sendNotify(url, callingUser); @@ -1170,12 +1194,19 @@ public class SettingsProvider extends ContentProvider { checkWritePermissions(args); checkUserRestrictions(initialValues.getAsString(Settings.Secure.NAME), callingUser); - final AtomicInteger mutationCount = sKnownMutationsInFlight.get(callingUser); - mutationCount.incrementAndGet(); + final AtomicInteger mutationCount; + synchronized (this) { + mutationCount = sKnownMutationsInFlight.get(callingUser); + } + if (mutationCount != null) { + mutationCount.incrementAndGet(); + } DatabaseHelper dbH = getOrEstablishDatabase(callingUser); SQLiteDatabase db = dbH.getWritableDatabase(); int count = db.update(args.table, initialValues, args.where, args.args); - mutationCount.decrementAndGet(); + if (mutationCount != null) { + mutationCount.decrementAndGet(); + } if (count > 0) { invalidateCache(callingUser, args.table); // before we notify sendNotify(url, callingUser); |