Merge "Toast: Fix JE caused by service not bind" am: ddf2f52d9f am: 3f03d5851a am: 913bec9fc9 am: 5e747139ca

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2092527

Change-Id: I2f7861f0878ace146b2e2a3a8cfb00c2135fca3f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Chavi Weingarten
2022-05-31 18:16:30 +00:00
committed by Automerger Merge Worker

View File

@@ -369,9 +369,6 @@ public class DisplayHashController {
if (mServiceConnection == null) { if (mServiceConnection == null) {
if (DEBUG) Slog.v(TAG, "creating connection"); if (DEBUG) Slog.v(TAG, "creating connection");
// Create the connection
mServiceConnection = new DisplayHashingServiceConnection();
final ComponentName component = getServiceComponentName(); final ComponentName component = getServiceComponentName();
if (DEBUG) Slog.v(TAG, "binding to: " + component); if (DEBUG) Slog.v(TAG, "binding to: " + component);
if (component != null) { if (component != null) {
@@ -379,6 +376,8 @@ public class DisplayHashController {
intent.setComponent(component); intent.setComponent(component);
final long token = Binder.clearCallingIdentity(); final long token = Binder.clearCallingIdentity();
try { try {
// Create the connection
mServiceConnection = new DisplayHashingServiceConnection();
mContext.bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE); mContext.bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE);
if (DEBUG) Slog.v(TAG, "bound"); if (DEBUG) Slog.v(TAG, "bound");
} finally { } finally {
@@ -387,9 +386,11 @@ public class DisplayHashController {
} }
} }
if (mServiceConnection != null) {
mServiceConnection.runCommandLocked(command); mServiceConnection.runCommandLocked(command);
} }
} }
}
@Nullable @Nullable
private ServiceInfo getServiceInfo() { private ServiceInfo getServiceInfo() {