diff options
| author | 2021-07-02 15:11:29 -0500 | |
|---|---|---|
| committer | 2021-07-02 16:44:00 -0500 | |
| commit | 21905f7d2b976fea361767d61ba17ffbb1059d70 (patch) | |
| tree | 3665fabdd88e90db1edabd9817e04cd64f5c2d84 | |
| parent | d003be936938a26283eeea0c50a38cad134e62bc (diff) | |
Use userId 0 to bind the DisplayHashingService
Clear calling identity and use system user id to bind the service. This
is because the DisplayHashingSevice doesn't need to be run per user and
can just be run as system.
Test: atest DisplayHashManagerTest
Bug: 184783122
Change-Id: Id15efeddefff632e339139899a17a550e517dd5b
| -rw-r--r-- | services/core/java/com/android/server/wm/DisplayHashController.java | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/wm/DisplayHashController.java b/services/core/java/com/android/server/wm/DisplayHashController.java index 0cf4379da02a..64a57588113c 100644 --- a/services/core/java/com/android/server/wm/DisplayHashController.java +++ b/services/core/java/com/android/server/wm/DisplayHashController.java @@ -47,7 +47,6 @@ import android.os.Looper; import android.os.Message; import android.os.RemoteCallback; import android.os.RemoteException; -import android.os.UserHandle; import android.service.displayhash.DisplayHashParams; import android.service.displayhash.DisplayHashingService; import android.service.displayhash.IDisplayHashingService; @@ -380,8 +379,7 @@ public class DisplayHashController { intent.setComponent(component); final long token = Binder.clearCallingIdentity(); try { - mContext.bindServiceAsUser(intent, mServiceConnection, - Context.BIND_AUTO_CREATE, UserHandle.CURRENT); + mContext.bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE); if (DEBUG) Slog.v(TAG, "bound"); } finally { Binder.restoreCallingIdentity(token); @@ -404,8 +402,15 @@ public class DisplayHashController { final Intent intent = new Intent(DisplayHashingService.SERVICE_INTERFACE); intent.setPackage(packageName); - final ResolveInfo resolveInfo = mContext.getPackageManager().resolveService(intent, - PackageManager.GET_SERVICES | PackageManager.GET_META_DATA); + final ResolveInfo resolveInfo; + final long token = Binder.clearCallingIdentity(); + try { + resolveInfo = mContext.getPackageManager().resolveService(intent, + PackageManager.GET_SERVICES | PackageManager.GET_META_DATA); + } finally { + Binder.restoreCallingIdentity(token); + } + if (resolveInfo == null || resolveInfo.serviceInfo == null) { Slog.w(TAG, "No valid components found."); return null; |