Refactored to ensure thread safety
clearServiceWatcher() called on the main thread but resetStaticState() called on the instrumentation thread. Refactored the code to ensure thread safety. Fixes: 166685544 Test: atest ContentCapturePerfTests Change-Id: I9adced9e068112c43554b495bd6dc591f8775945
This commit is contained in:
@@ -51,13 +51,14 @@ public class MyContentCaptureService extends ContentCaptureService {
|
||||
sServiceWatcher = null;
|
||||
}
|
||||
|
||||
public static void clearServiceWatcher() {
|
||||
if (sServiceWatcher != null) {
|
||||
if (sServiceWatcher.mReadyToClear) {
|
||||
sServiceWatcher.mService = null;
|
||||
private static void clearServiceWatcher() {
|
||||
final ServiceWatcher sw = sServiceWatcher;
|
||||
if (sw != null) {
|
||||
if (sw.mReadyToClear) {
|
||||
sw.mService = null;
|
||||
sServiceWatcher = null;
|
||||
} else {
|
||||
sServiceWatcher.mReadyToClear = true;
|
||||
sw.mReadyToClear = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user