Yell when calling installd with PM lock held.
As a matter of policy, we should never be holding the mPackages lock while calling down into installd. This little bit of logic helps us catch accidental cases where this happens. Change-Id: I676c81df43ef936ffd36290d45a79429630c1b4b
This commit is contained in:
@@ -25,10 +25,10 @@ import android.os.Message;
|
|||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.util.LocalLog;
|
import android.util.LocalLog;
|
||||||
import android.util.Log;
|
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
|
import com.android.internal.util.Preconditions;
|
||||||
import com.google.android.collect.Lists;
|
import com.google.android.collect.Lists;
|
||||||
|
|
||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
@@ -58,7 +58,7 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo
|
|||||||
private LocalLog mLocalLog;
|
private LocalLog mLocalLog;
|
||||||
|
|
||||||
private volatile boolean mDebug = false;
|
private volatile boolean mDebug = false;
|
||||||
private volatile Object mLockWarning;
|
private volatile Object mWarnIfHeld;
|
||||||
|
|
||||||
private final ResponseQueue mResponseQueue;
|
private final ResponseQueue mResponseQueue;
|
||||||
|
|
||||||
@@ -110,11 +110,12 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Yell loudly if someone tries making future {@link #execute(Command)} calls while holding a
|
* Yell loudly if someone tries making future {@link #execute(Command)}
|
||||||
* lock on the given object.
|
* calls while holding a lock on the given object.
|
||||||
*/
|
*/
|
||||||
public void setLockWarning(Object lockWarning) {
|
public void setWarnIfHeld(Object warnIfHeld) {
|
||||||
mLockWarning = lockWarning;
|
Preconditions.checkState(mWarnIfHeld == null);
|
||||||
|
mWarnIfHeld = Preconditions.checkNotNull(warnIfHeld);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -404,8 +405,9 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo
|
|||||||
*/
|
*/
|
||||||
public NativeDaemonEvent[] executeForList(long timeoutMs, String cmd, Object... args)
|
public NativeDaemonEvent[] executeForList(long timeoutMs, String cmd, Object... args)
|
||||||
throws NativeDaemonConnectorException {
|
throws NativeDaemonConnectorException {
|
||||||
if (mLockWarning != null && Thread.holdsLock(mLockWarning)) {
|
if (mWarnIfHeld != null && Thread.holdsLock(mWarnIfHeld)) {
|
||||||
Log.wtf(TAG, "Calling thread is holding lock " + mLockWarning, new Throwable());
|
Slog.wtf(TAG, "Calling thread " + Thread.currentThread().getName() + " is holding 0x"
|
||||||
|
+ Integer.toHexString(System.identityHashCode(mWarnIfHeld)), new Throwable());
|
||||||
}
|
}
|
||||||
|
|
||||||
final long startTime = SystemClock.elapsedRealtime();
|
final long startTime = SystemClock.elapsedRealtime();
|
||||||
|
|||||||
Reference in New Issue
Block a user