diff options
Diffstat (limited to 'TrustAgent/src/com/android/car/trust/CarTrustAgentBleService.java')
-rw-r--r-- | TrustAgent/src/com/android/car/trust/CarTrustAgentBleService.java | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/TrustAgent/src/com/android/car/trust/CarTrustAgentBleService.java b/TrustAgent/src/com/android/car/trust/CarTrustAgentBleService.java index f8ba90f3..2cc20800 100644 --- a/TrustAgent/src/com/android/car/trust/CarTrustAgentBleService.java +++ b/TrustAgent/src/com/android/car/trust/CarTrustAgentBleService.java | |||
@@ -25,6 +25,7 @@ import android.car.trust.ICarTrustAgentTokenRequestDelegate; | |||
25 | import android.car.trust.ICarTrustAgentTokenResponseCallback; | 25 | import android.car.trust.ICarTrustAgentTokenResponseCallback; |
26 | import android.car.trust.ICarTrustAgentUnlockCallback; | 26 | import android.car.trust.ICarTrustAgentUnlockCallback; |
27 | import android.content.Intent; | 27 | import android.content.Intent; |
28 | import android.content.SharedPreferences; | ||
28 | import android.os.IBinder; | 29 | import android.os.IBinder; |
29 | import android.os.ParcelUuid; | 30 | import android.os.ParcelUuid; |
30 | import android.os.RemoteCallbackList; | 31 | import android.os.RemoteCallbackList; |
@@ -62,6 +63,8 @@ public class CarTrustAgentBleService extends SimpleBleServer { | |||
62 | private byte[] mCurrentUnlockToken; | 63 | private byte[] mCurrentUnlockToken; |
63 | private Long mCurrentUnlockHandle; | 64 | private Long mCurrentUnlockHandle; |
64 | 65 | ||
66 | private SharedPreferences mTokenHandleSharedPreferences; | ||
67 | |||
65 | @Override | 68 | @Override |
66 | public void onCreate() { | 69 | public void onCreate() { |
67 | super.onCreate(); | 70 | super.onCreate(); |
@@ -72,6 +75,10 @@ public class CarTrustAgentBleService extends SimpleBleServer { | |||
72 | 75 | ||
73 | setupEnrolmentBleServer(); | 76 | setupEnrolmentBleServer(); |
74 | setupUnlockBleServer(); | 77 | setupUnlockBleServer(); |
78 | |||
79 | mTokenHandleSharedPreferences = getSharedPreferences( | ||
80 | getString(R.string.token_handle_shared_preferences), | ||
81 | MODE_PRIVATE); | ||
75 | } | 82 | } |
76 | 83 | ||
77 | @Override | 84 | @Override |
@@ -260,8 +267,8 @@ public class CarTrustAgentBleService extends SimpleBleServer { | |||
260 | 267 | ||
261 | @Override | 268 | @Override |
262 | public void startEnrolmentAdvertising() { | 269 | public void startEnrolmentAdvertising() { |
263 | Log.d(TAG, "startEnrolmentAdvertising"); | ||
264 | stopUnlockAdvertising(); | 270 | stopUnlockAdvertising(); |
271 | Log.d(TAG, "startEnrolmentAdvertising"); | ||
265 | startAdvertising(mEnrolmentUuid, mEnrolmentGattServer); | 272 | startAdvertising(mEnrolmentUuid, mEnrolmentGattServer); |
266 | } | 273 | } |
267 | 274 | ||
@@ -290,8 +297,8 @@ public class CarTrustAgentBleService extends SimpleBleServer { | |||
290 | 297 | ||
291 | @Override | 298 | @Override |
292 | public void startUnlockAdvertising() { | 299 | public void startUnlockAdvertising() { |
293 | Log.d(TAG, "startUnlockAdvertising"); | ||
294 | stopEnrolmentAdvertising(); | 300 | stopEnrolmentAdvertising(); |
301 | Log.d(TAG, "startUnlockAdvertising"); | ||
295 | startAdvertising(mUnlockUuid, mUnlockGattServer); | 302 | startAdvertising(mUnlockUuid, mUnlockGattServer); |
296 | } | 303 | } |
297 | 304 | ||
@@ -353,6 +360,9 @@ public class CarTrustAgentBleService extends SimpleBleServer { | |||
353 | public void onEscrowTokenAdded(byte[] token, long handle, int uid) | 360 | public void onEscrowTokenAdded(byte[] token, long handle, int uid) |
354 | throws RemoteException { | 361 | throws RemoteException { |
355 | Log.d(TAG, "onEscrowTokenAdded handle:" + handle + " uid:" + uid); | 362 | Log.d(TAG, "onEscrowTokenAdded handle:" + handle + " uid:" + uid); |
363 | mTokenHandleSharedPreferences.edit() | ||
364 | .putInt(String.valueOf(handle), uid) | ||
365 | .apply(); | ||
356 | if (mTokenResponseCallback != null) { | 366 | if (mTokenResponseCallback != null) { |
357 | mTokenResponseCallback.onEscrowTokenAdded(token, handle, uid); | 367 | mTokenResponseCallback.onEscrowTokenAdded(token, handle, uid); |
358 | } | 368 | } |
@@ -361,6 +371,9 @@ public class CarTrustAgentBleService extends SimpleBleServer { | |||
361 | @Override | 371 | @Override |
362 | public void onEscrowTokenRemoved(long handle, boolean successful) throws RemoteException { | 372 | public void onEscrowTokenRemoved(long handle, boolean successful) throws RemoteException { |
363 | Log.d(TAG, "onEscrowTokenRemoved handle:" + handle); | 373 | Log.d(TAG, "onEscrowTokenRemoved handle:" + handle); |
374 | mTokenHandleSharedPreferences.edit() | ||
375 | .remove(String.valueOf(handle)) | ||
376 | .apply(); | ||
364 | if (mTokenResponseCallback != null) { | 377 | if (mTokenResponseCallback != null) { |
365 | mTokenResponseCallback.onEscrowTokenRemoved(handle, successful); | 378 | mTokenResponseCallback.onEscrowTokenRemoved(handle, successful); |
366 | } | 379 | } |
@@ -373,5 +386,10 @@ public class CarTrustAgentBleService extends SimpleBleServer { | |||
373 | mTokenResponseCallback.onEscrowTokenActiveStateChanged(handle, active); | 386 | mTokenResponseCallback.onEscrowTokenActiveStateChanged(handle, active); |
374 | } | 387 | } |
375 | } | 388 | } |
389 | |||
390 | @Override | ||
391 | public int getUserIdByEscrowTokenHandle(long tokenHandle) { | ||
392 | return mTokenHandleSharedPreferences.getInt(String.valueOf(tokenHandle), -1); | ||
393 | } | ||
376 | } | 394 | } |
377 | } | 395 | } |