TrustAgentService.java revision a06d5ca1d96af3555ad4e384994e6321a0c5bb9c
1ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos/**
2ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos * Copyright (C) 2014 The Android Open Source Project
3ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos *
4ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos * Licensed under the Apache License, Version 2.0 (the "License");
5ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos * you may not use this file except in compliance with the License.
6ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos * You may obtain a copy of the License at
7ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos *
8ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos *      http://www.apache.org/licenses/LICENSE-2.0
9ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos *
10ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos * Unless required by applicable law or agreed to in writing, software
11ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos * distributed under the License is distributed on an "AS IS" BASIS,
12ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos * See the License for the specific language governing permissions and
14ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos * limitations under the License.
15ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos */
16ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos
17ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roospackage android.service.trust;
18ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos
19cb9fbc3a30b562a61e316af54fb0aa1d26ce0a73Adrian Roosimport android.Manifest;
20ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roosimport android.annotation.SdkConstant;
21a06d5ca1d96af3555ad4e384994e6321a0c5bb9cAdrian Roosimport android.annotation.SystemApi;
22ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roosimport android.app.Service;
23604e7558ef32098644b2f9456d7743a07ae789dcJim Millerimport android.app.admin.DevicePolicyManager;
24cb9fbc3a30b562a61e316af54fb0aa1d26ce0a73Adrian Roosimport android.content.ComponentName;
25ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roosimport android.content.Intent;
26cb9fbc3a30b562a61e316af54fb0aa1d26ce0a73Adrian Roosimport android.content.pm.PackageManager;
27cb9fbc3a30b562a61e316af54fb0aa1d26ce0a73Adrian Roosimport android.content.pm.ServiceInfo;
28604e7558ef32098644b2f9456d7743a07ae789dcJim Millerimport android.os.Bundle;
29ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roosimport android.os.Handler;
30ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roosimport android.os.IBinder;
31ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roosimport android.os.RemoteException;
32cb9fbc3a30b562a61e316af54fb0aa1d26ce0a73Adrian Roosimport android.util.Log;
33ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roosimport android.util.Slog;
34ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos
35ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos/**
36ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos * A service that notifies the system about whether it believes the environment of the device
37ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos * to be trusted.
38ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos *
3918ea893a2319e2a192188d2288bb881149c9b06eAdrian Roos * <p>Trust agents may only be provided by the platform.</p>
4018ea893a2319e2a192188d2288bb881149c9b06eAdrian Roos *
41ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos * <p>To extend this class, you must declare the service in your manifest file with
427e03dfcb796ef1a6000a5fd5fda03c9e15ea62e1Adrian Roos * the {@link android.Manifest.permission#BIND_TRUST_AGENT} permission
43ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos * and include an intent filter with the {@link #SERVICE_INTERFACE} action. For example:</p>
44ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos * <pre>
45ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos * &lt;service android:name=".TrustAgent"
46ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos *          android:label="&#64;string/service_name"
477e03dfcb796ef1a6000a5fd5fda03c9e15ea62e1Adrian Roos *          android:permission="android.permission.BIND_TRUST_AGENT">
48ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos *     &lt;intent-filter>
49ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos *         &lt;action android:name="android.service.trust.TrustAgentService" />
50ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos *     &lt;/intent-filter>
51ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos *     &lt;meta-data android:name="android.service.trust.trustagent"
52ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos *          android:value="&#64;xml/trust_agent" />
53ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos * &lt;/service></pre>
54ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos *
55ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos * <p>The associated meta-data file can specify an activity that is accessible through Settings
56ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos * and should allow configuring the trust agent, as defined in
57ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos * {@link android.R.styleable#TrustAgent}. For example:</p>
58ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos *
59ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos * <pre>
607e03dfcb796ef1a6000a5fd5fda03c9e15ea62e1Adrian Roos * &lt;trust-agent xmlns:android="http://schemas.android.com/apk/res/android"
61ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos *          android:settingsActivity=".TrustAgentSettings" /></pre>
62a06d5ca1d96af3555ad4e384994e6321a0c5bb9cAdrian Roos *
63a06d5ca1d96af3555ad4e384994e6321a0c5bb9cAdrian Roos * @hide
64ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos */
65a06d5ca1d96af3555ad4e384994e6321a0c5bb9cAdrian Roos@SystemApi
66ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roospublic class TrustAgentService extends Service {
67ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos    private final String TAG = TrustAgentService.class.getSimpleName() +
68ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos            "[" + getClass().getSimpleName() + "]";
69ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos
70ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos    /**
71ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos     * The {@link Intent} that must be declared as handled by the service.
72ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos     */
73ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos    @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION)
74ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos    public static final String SERVICE_INTERFACE
75ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos            = "android.service.trust.TrustAgentService";
76ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos
77ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos    /**
78ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos     * The name of the {@code meta-data} tag pointing to additional configuration of the trust
79ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos     * agent.
80ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos     */
81ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos    public static final String TRUST_AGENT_META_DATA = "android.service.trust.trustagent";
82ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos
83604e7558ef32098644b2f9456d7743a07ae789dcJim Miller    /**
84604e7558ef32098644b2f9456d7743a07ae789dcJim Miller     * A white list of features that the given trust agent should support when otherwise disabled
85604e7558ef32098644b2f9456d7743a07ae789dcJim Miller     * by device policy.
86604e7558ef32098644b2f9456d7743a07ae789dcJim Miller     */
87604e7558ef32098644b2f9456d7743a07ae789dcJim Miller    public static final String KEY_FEATURES = "trust_agent_features";
88604e7558ef32098644b2f9456d7743a07ae789dcJim Miller
89ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos    private static final int MSG_UNLOCK_ATTEMPT = 1;
90ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos
91ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos    private static final boolean DEBUG = false;
92ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos
93ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos    private ITrustAgentServiceCallback mCallback;
94ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos
954f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli    private Runnable mPendingGrantTrustTask;
964f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli
974f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli    // Lock used to access mPendingGrantTrustTask and mCallback.
984f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli    private final Object mLock = new Object();
994f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli
100ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos    private Handler mHandler = new Handler() {
101ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos        public void handleMessage(android.os.Message msg) {
102ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos            switch (msg.what) {
103ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos                case MSG_UNLOCK_ATTEMPT:
104ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos                    onUnlockAttempt(msg.arg1 != 0);
105ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos                    break;
106ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos            }
107ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos        };
108ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos    };
109ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos
110cb9fbc3a30b562a61e316af54fb0aa1d26ce0a73Adrian Roos    @Override
111cb9fbc3a30b562a61e316af54fb0aa1d26ce0a73Adrian Roos    public void onCreate() {
112cb9fbc3a30b562a61e316af54fb0aa1d26ce0a73Adrian Roos        super.onCreate();
113cb9fbc3a30b562a61e316af54fb0aa1d26ce0a73Adrian Roos        ComponentName component = new ComponentName(this, getClass());
114cb9fbc3a30b562a61e316af54fb0aa1d26ce0a73Adrian Roos        try {
115cb9fbc3a30b562a61e316af54fb0aa1d26ce0a73Adrian Roos            ServiceInfo serviceInfo = getPackageManager().getServiceInfo(component, 0 /* flags */);
116cb9fbc3a30b562a61e316af54fb0aa1d26ce0a73Adrian Roos            if (!Manifest.permission.BIND_TRUST_AGENT.equals(serviceInfo.permission)) {
117cb9fbc3a30b562a61e316af54fb0aa1d26ce0a73Adrian Roos                throw new IllegalStateException(component.flattenToShortString()
118cb9fbc3a30b562a61e316af54fb0aa1d26ce0a73Adrian Roos                        + " is not declared with the permission "
119cb9fbc3a30b562a61e316af54fb0aa1d26ce0a73Adrian Roos                        + "\"" + Manifest.permission.BIND_TRUST_AGENT + "\"");
120cb9fbc3a30b562a61e316af54fb0aa1d26ce0a73Adrian Roos            }
121cb9fbc3a30b562a61e316af54fb0aa1d26ce0a73Adrian Roos        } catch (PackageManager.NameNotFoundException e) {
122cb9fbc3a30b562a61e316af54fb0aa1d26ce0a73Adrian Roos            Log.e(TAG, "Can't get ServiceInfo for " + component.toShortString());
123cb9fbc3a30b562a61e316af54fb0aa1d26ce0a73Adrian Roos        }
124cb9fbc3a30b562a61e316af54fb0aa1d26ce0a73Adrian Roos    }
125cb9fbc3a30b562a61e316af54fb0aa1d26ce0a73Adrian Roos
126ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos    /**
127ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos     * Called when the user attempted to authenticate on the device.
128ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos     *
129ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos     * @param successful true if the attempt succeeded
130ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos     */
1317e03dfcb796ef1a6000a5fd5fda03c9e15ea62e1Adrian Roos    public void onUnlockAttempt(boolean successful) {
132ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos    }
133ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos
134ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos    private void onError(String msg) {
135ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos        Slog.v(TAG, "Remote exception while " + msg);
136ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos    }
137ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos
138ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos    /**
139604e7558ef32098644b2f9456d7743a07ae789dcJim Miller     * Called when device policy wants to restrict features in the TrustAgent in response to
140604e7558ef32098644b2f9456d7743a07ae789dcJim Miller     * {@link DevicePolicyManager#setTrustAgentFeaturesEnabled(ComponentName, ComponentName, java.util.List) }.
141604e7558ef32098644b2f9456d7743a07ae789dcJim Miller     * TrustAgents that support this feature should overload this method and return 'true'.
142604e7558ef32098644b2f9456d7743a07ae789dcJim Miller     *
143604e7558ef32098644b2f9456d7743a07ae789dcJim Miller     * The list of options can be obtained by calling
144604e7558ef32098644b2f9456d7743a07ae789dcJim Miller     * options.getStringArrayList({@link #KEY_FEATURES}). Presence of a feature string in the list
145604e7558ef32098644b2f9456d7743a07ae789dcJim Miller     * means it should be enabled ("white-listed"). Absence of the feature means it should be
146604e7558ef32098644b2f9456d7743a07ae789dcJim Miller     * disabled. An empty list means all features should be disabled.
147604e7558ef32098644b2f9456d7743a07ae789dcJim Miller     *
148604e7558ef32098644b2f9456d7743a07ae789dcJim Miller     * This function is only called if {@link DevicePolicyManager#KEYGUARD_DISABLE_TRUST_AGENTS} is
149604e7558ef32098644b2f9456d7743a07ae789dcJim Miller     * set.
150604e7558ef32098644b2f9456d7743a07ae789dcJim Miller     *
151604e7558ef32098644b2f9456d7743a07ae789dcJim Miller     * @param options Option feature bundle.
152604e7558ef32098644b2f9456d7743a07ae789dcJim Miller     * @return true if the {@link #TrustAgentService()} supports this feature.
153604e7558ef32098644b2f9456d7743a07ae789dcJim Miller     */
154604e7558ef32098644b2f9456d7743a07ae789dcJim Miller    public boolean onSetTrustAgentFeaturesEnabled(Bundle options) {
155604e7558ef32098644b2f9456d7743a07ae789dcJim Miller        return false;
156604e7558ef32098644b2f9456d7743a07ae789dcJim Miller    }
157604e7558ef32098644b2f9456d7743a07ae789dcJim Miller
158604e7558ef32098644b2f9456d7743a07ae789dcJim Miller    /**
1597e03dfcb796ef1a6000a5fd5fda03c9e15ea62e1Adrian Roos     * Call to grant trust on the device.
160ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos     *
161ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos     * @param message describes why the device is trusted, e.g. "Trusted by location".
162ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos     * @param durationMs amount of time in milliseconds to keep the device in a trusted state. Trust
163ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos     *                   for this agent will automatically be revoked when the timeout expires.
164ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos     * @param initiatedByUser indicates that the user has explicitly initiated an action that proves
165ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos     *                        the user is about to use the device.
166ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos     */
1674f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli    public final void grantTrust(
1684f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli            final CharSequence message, final long durationMs, final boolean initiatedByUser) {
1694f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli        synchronized (mLock) {
1704f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli            if (mCallback != null) {
1714f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli                try {
1724f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli                    mCallback.grantTrust(message.toString(), durationMs, initiatedByUser);
1734f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli                } catch (RemoteException e) {
1744f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli                    onError("calling enableTrust()");
1754f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli                }
1764f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli            } else {
1774f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli                // Remember trust has been granted so we can effectively grant it once the service
1784f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli                // is bound.
1794f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli                mPendingGrantTrustTask = new Runnable() {
1804f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli                    @Override
1814f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli                    public void run() {
1824f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli                        grantTrust(message, durationMs, initiatedByUser);
1834f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli                    }
1844f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli                };
185ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos            }
186ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos        }
187ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos    }
188ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos
189ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos    /**
190ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos     * Call to revoke trust on the device.
191ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos     */
1927e03dfcb796ef1a6000a5fd5fda03c9e15ea62e1Adrian Roos    public final void revokeTrust() {
1934f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli        synchronized (mLock) {
1944f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli            if (mPendingGrantTrustTask != null) {
1954f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli                mPendingGrantTrustTask = null;
1964f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli            }
1974f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli            if (mCallback != null) {
1984f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli                try {
1994f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli                    mCallback.revokeTrust();
2004f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli                } catch (RemoteException e) {
2014f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli                    onError("calling revokeTrust()");
2024f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli                }
203ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos            }
204ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos        }
205ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos    }
206ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos
207ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos    @Override
208ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos    public final IBinder onBind(Intent intent) {
209ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos        if (DEBUG) Slog.v(TAG, "onBind() intent = " + intent);
210ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos        return new TrustAgentServiceWrapper();
211ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos    }
212ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos
213ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos    private final class TrustAgentServiceWrapper extends ITrustAgentService.Stub {
214ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos        @Override
215ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos        public void onUnlockAttempt(boolean successful) {
216ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos            mHandler.obtainMessage(MSG_UNLOCK_ATTEMPT, successful ? 1 : 0, 0)
217ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos                    .sendToTarget();
218ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos        }
219ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos
220604e7558ef32098644b2f9456d7743a07ae789dcJim Miller        @Override
221ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos        public void setCallback(ITrustAgentServiceCallback callback) {
2224f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli            synchronized (mLock) {
2234f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli                mCallback = callback;
2244f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli                if (mPendingGrantTrustTask != null) {
2254f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli                    mPendingGrantTrustTask.run();
2264f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli                    mPendingGrantTrustTask = null;
2274f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli                }
2284f22777efb6dc99b61c664b39b4087fe89f0c050Jay Civelli            }
229ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos        }
230604e7558ef32098644b2f9456d7743a07ae789dcJim Miller
231604e7558ef32098644b2f9456d7743a07ae789dcJim Miller        @Override
232604e7558ef32098644b2f9456d7743a07ae789dcJim Miller        public boolean setTrustAgentFeaturesEnabled(Bundle features) {
233604e7558ef32098644b2f9456d7743a07ae789dcJim Miller            synchronized (mLock) {
234604e7558ef32098644b2f9456d7743a07ae789dcJim Miller                return onSetTrustAgentFeaturesEnabled(features);
235604e7558ef32098644b2f9456d7743a07ae789dcJim Miller            }
236604e7558ef32098644b2f9456d7743a07ae789dcJim Miller        }
237ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos    }
238ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos
239ff2144ccb4215acf4587fc628493b3d49dca6043Adrian Roos}
240