Merge "Prevent SystemCaptionsManagerService init from blocking unlockUser" into rvc-dev am: ae34fd76ff
Change-Id: I84677cc70a3a0905810ce863975fecae1057ff1b
This commit is contained in:
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.server.systemcaptions;
|
package com.android.server.systemcaptions;
|
||||||
|
|
||||||
|
import static com.android.internal.util.function.pooled.PooledLambda.obtainMessage;
|
||||||
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -37,6 +39,8 @@ final class RemoteSystemCaptionsManagerService {
|
|||||||
private static final String SERVICE_INTERFACE =
|
private static final String SERVICE_INTERFACE =
|
||||||
"android.service.systemcaptions.SystemCaptionsManagerService";
|
"android.service.systemcaptions.SystemCaptionsManagerService";
|
||||||
|
|
||||||
|
private static final int MSG_BIND = 1;
|
||||||
|
|
||||||
private final Object mLock = new Object();
|
private final Object mLock = new Object();
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
@@ -71,18 +75,26 @@ final class RemoteSystemCaptionsManagerService {
|
|||||||
if (mVerbose) {
|
if (mVerbose) {
|
||||||
Slog.v(TAG, "initialize()");
|
Slog.v(TAG, "initialize()");
|
||||||
}
|
}
|
||||||
ensureBound();
|
scheduleBind();
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroy() {
|
/**
|
||||||
|
* Destroys this service.
|
||||||
|
*/
|
||||||
|
public void destroy() {
|
||||||
|
mHandler.sendMessage(
|
||||||
|
obtainMessage(RemoteSystemCaptionsManagerService::handleDestroy, this));
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleDestroy() {
|
||||||
if (mVerbose) {
|
if (mVerbose) {
|
||||||
Slog.v(TAG, "destroy()");
|
Slog.v(TAG, "handleDestroy()");
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (mDestroyed) {
|
if (mDestroyed) {
|
||||||
if (mVerbose) {
|
if (mVerbose) {
|
||||||
Slog.v(TAG, "destroy(): Already destroyed");
|
Slog.v(TAG, "handleDestroy(): Already destroyed");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -97,14 +109,24 @@ final class RemoteSystemCaptionsManagerService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureBound() {
|
private void scheduleBind() {
|
||||||
|
if (mHandler.hasMessages(MSG_BIND)) {
|
||||||
|
if (mVerbose) Slog.v(TAG, "scheduleBind(): already scheduled");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mHandler.sendMessage(
|
||||||
|
obtainMessage(RemoteSystemCaptionsManagerService::handleEnsureBound, this)
|
||||||
|
.setWhat(MSG_BIND));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleEnsureBound() {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (mService != null || mBinding) {
|
if (mService != null || mBinding) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mVerbose) {
|
if (mVerbose) {
|
||||||
Slog.v(TAG, "ensureBound(): binding");
|
Slog.v(TAG, "handleEnsureBound(): binding");
|
||||||
}
|
}
|
||||||
mBinding = true;
|
mBinding = true;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user