Loading core/java/android/service/trust/TrustAgentService.java +40 −12 Original line number Diff line number Diff line Loading @@ -80,6 +80,11 @@ public class TrustAgentService extends Service { private ITrustAgentServiceCallback mCallback; private Runnable mPendingGrantTrustTask; // Lock used to access mPendingGrantTrustTask and mCallback. private final Object mLock = new Object(); private Handler mHandler = new Handler() { public void handleMessage(android.os.Message msg) { switch (msg.what) { Loading Loading @@ -127,13 +132,25 @@ public class TrustAgentService extends Service { * @param initiatedByUser indicates that the user has explicitly initiated an action that proves * the user is about to use the device. */ public final void grantTrust(CharSequence message, long durationMs, boolean initiatedByUser) { public final void grantTrust( final CharSequence message, final long durationMs, final boolean initiatedByUser) { synchronized (mLock) { if (mCallback != null) { try { mCallback.grantTrust(message.toString(), durationMs, initiatedByUser); } catch (RemoteException e) { onError("calling enableTrust()"); } } else { // Remember trust has been granted so we can effectively grant it once the service // is bound. mPendingGrantTrustTask = new Runnable() { @Override public void run() { grantTrust(message, durationMs, initiatedByUser); } }; } } } Loading @@ -141,6 +158,10 @@ public class TrustAgentService extends Service { * Call to revoke trust on the device. */ public final void revokeTrust() { synchronized (mLock) { if (mPendingGrantTrustTask != null) { mPendingGrantTrustTask = null; } if (mCallback != null) { try { mCallback.revokeTrust(); Loading @@ -149,6 +170,7 @@ public class TrustAgentService extends Service { } } } } @Override public final IBinder onBind(Intent intent) { Loading @@ -164,7 +186,13 @@ public class TrustAgentService extends Service { } public void setCallback(ITrustAgentServiceCallback callback) { synchronized (mLock) { mCallback = callback; if (mPendingGrantTrustTask != null) { mPendingGrantTrustTask.run(); mPendingGrantTrustTask = null; } } } } Loading Loading
core/java/android/service/trust/TrustAgentService.java +40 −12 Original line number Diff line number Diff line Loading @@ -80,6 +80,11 @@ public class TrustAgentService extends Service { private ITrustAgentServiceCallback mCallback; private Runnable mPendingGrantTrustTask; // Lock used to access mPendingGrantTrustTask and mCallback. private final Object mLock = new Object(); private Handler mHandler = new Handler() { public void handleMessage(android.os.Message msg) { switch (msg.what) { Loading Loading @@ -127,13 +132,25 @@ public class TrustAgentService extends Service { * @param initiatedByUser indicates that the user has explicitly initiated an action that proves * the user is about to use the device. */ public final void grantTrust(CharSequence message, long durationMs, boolean initiatedByUser) { public final void grantTrust( final CharSequence message, final long durationMs, final boolean initiatedByUser) { synchronized (mLock) { if (mCallback != null) { try { mCallback.grantTrust(message.toString(), durationMs, initiatedByUser); } catch (RemoteException e) { onError("calling enableTrust()"); } } else { // Remember trust has been granted so we can effectively grant it once the service // is bound. mPendingGrantTrustTask = new Runnable() { @Override public void run() { grantTrust(message, durationMs, initiatedByUser); } }; } } } Loading @@ -141,6 +158,10 @@ public class TrustAgentService extends Service { * Call to revoke trust on the device. */ public final void revokeTrust() { synchronized (mLock) { if (mPendingGrantTrustTask != null) { mPendingGrantTrustTask = null; } if (mCallback != null) { try { mCallback.revokeTrust(); Loading @@ -149,6 +170,7 @@ public class TrustAgentService extends Service { } } } } @Override public final IBinder onBind(Intent intent) { Loading @@ -164,7 +186,13 @@ public class TrustAgentService extends Service { } public void setCallback(ITrustAgentServiceCallback callback) { synchronized (mLock) { mCallback = callback; if (mPendingGrantTrustTask != null) { mPendingGrantTrustTask.run(); mPendingGrantTrustTask = null; } } } } Loading