From ec30ca35aa6bb51643d266b73f3c93d30c96ac3f Mon Sep 17 00:00:00 2001 From: Fyodor Kupolov Date: Thu, 16 Jun 2016 15:09:29 -0700 Subject: Call AppOpsService from the handler thread Otherwise it may cause deadlocks, for instance if updateUserRestrictionsInternalLR is called with AMS lock held. Bug: 28888422 Change-Id: I455c7392f206ff0bb6c99ec5c4a531921a115070 --- .../java/com/android/server/pm/UserManagerService.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java index a85064b70f22..c4b904779ef4 100644 --- a/services/core/java/com/android/server/pm/UserManagerService.java +++ b/services/core/java/com/android/server/pm/UserManagerService.java @@ -1303,14 +1303,16 @@ public class UserManagerService extends IUserManager.Stub { } if (mAppOpsService != null) { // We skip it until system-ready. - final long token = Binder.clearCallingIdentity(); - try { - mAppOpsService.setUserRestrictions(effective, mUserRestriconToken, userId); - } catch (RemoteException e) { - Log.w(LOG_TAG, "Unable to notify AppOpsService of UserRestrictions"); - } finally { - Binder.restoreCallingIdentity(token); - } + mHandler.post(new Runnable() { + @Override + public void run() { + try { + mAppOpsService.setUserRestrictions(effective, mUserRestriconToken, userId); + } catch (RemoteException e) { + Log.w(LOG_TAG, "Unable to notify AppOpsService of UserRestrictions"); + } + } + }); } propagateUserRestrictionsLR(userId, effective, prevAppliedRestrictions); -- cgit v1.2.3-59-g8ed1b