Merge "Removing the prototype Car trust agent apk."
diff --git a/TrustAgent/Android.mk b/TrustAgent/Android.mk
deleted file mode 100644
index bef1402..0000000
--- a/TrustAgent/Android.mk
+++ /dev/null
@@ -1,48 +0,0 @@
-# Copyright (C) 2016 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-ifneq ($(TARGET_BUILD_PDK), true)
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-
-LOCAL_USE_AAPT2 := true
-
-LOCAL_JAVA_LIBRARIES += android.car
-
-LOCAL_STATIC_ANDROID_LIBRARIES += \
-    androidx.car_car
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := CarTrustAgentService
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-LOCAL_PRIVILEGED_MODULE := true
-
-# Remove this to verify permission checks are working correctly
-LOCAL_CERTIFICATE := platform
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_PROGUARD_ENABLED := disabled
-
-LOCAL_DEX_PREOPT := false
-
-include $(BUILD_PACKAGE)
-
-endif
diff --git a/TrustAgent/AndroidManifest.xml b/TrustAgent/AndroidManifest.xml
deleted file mode 100644
index 2b7944d..0000000
--- a/TrustAgent/AndroidManifest.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  ~ Copyright (C) 2016 The Android Open Source Project
-  ~
-  ~ Licensed under the Apache License, Version 2.0 (the "License");
-  ~ you may not use this file except in compliance with the License.
-  ~ You may obtain a copy of the License at
-  ~
-  ~      http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License
-  -->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="com.android.car.trust">
-    <uses-sdk android:minSdkVersion="23" android:targetSdkVersion="23"/>
-
-    <!-- Need Bluetooth LE -->
-    <uses-feature android:name="android.hardware.bluetooth_le" android:required="true" />
-
-    <uses-permission android:name="android.permission.BLUETOOTH" />
-    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
-    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
-    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
-
-    <!-- Needed to unlock user -->
-    <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
-    <!-- TODO(b/77717079) INTERACT_ACROSS_USERS_FULL should have granted INTERACT_ACROSS_USERS -->
-    <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" />
-    <uses-permission android:name="android.permission.MANAGE_USERS" />
-    <uses-permission android:name="android.permission.CONTROL_KEYGUARD" />
-    <uses-permission android:name="android.permission.PROVIDE_TRUST_AGENT" />
-    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
-
-    <application
-        android:label="@string/app_name"
-        android:theme="@style/Theme.Car.NoActionBar"
-        android:supportsRtl="true">
-
-        <service
-            android:name=".CarBleTrustAgent"
-            android:permission="android.permission.BIND_TRUST_AGENT"
-            android:directBootAware="true"
-            android:exported="true"
-            android:singleUser="true">
-            <intent-filter>
-                <action android:name="android.service.trust.TrustAgentService" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
-            <!-- Warning: the meta data must be included if the service is direct boot aware.
-                 If not included, the device will crash before boot completes. Rendering the
-                 device unusable. -->
-            <meta-data android:name="android.service.trust.trustagent"
-                       android:resource="@xml/car_sample_trust_agent"/>
-        </service>
-
-        <!-- CarTrustAgentBleService needs to be direct boot aware, since the trust agent
-             binds to it during direct boot.-->
-        <service
-            android:name=".CarTrustAgentBleService"
-            android:directBootAware="true"
-            android:singleUser="true">
-            <!-- Warning: the meta data must be included if the service is direct boot aware.
-                 If not included, the device will crash before boot completes. Rendering the device
-                 unusable. -->
-            <meta-data android:name="android.service.trust.trustagent"
-                       android:resource="@xml/car_sample_trust_agent"/>
-        </service>
-
-        <activity
-            android:name=".CarEnrolmentActivity"
-            android:label="@string/app_name"
-            android:exported="true"
-            android:launchMode="singleInstance">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.LAUNCHER" />
-            </intent-filter>
-        </activity>
-
-    </application>
-</manifest>
diff --git a/TrustAgent/res/layout/car_enrolment_activity.xml b/TrustAgent/res/layout/car_enrolment_activity.xml
deleted file mode 100644
index 70632f7..0000000
--- a/TrustAgent/res/layout/car_enrolment_activity.xml
+++ /dev/null
@@ -1,69 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-<LinearLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:background="@android:color/black"
-    android:orientation="vertical"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent">
-
-    <RelativeLayout
-        android:layout_width="match_parent"
-        android:layout_height="@dimen/car_app_bar_height" >
-
-        <TextView
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_alignParentStart="true"
-            android:layout_centerVertical="true"
-            android:layout_marginStart="@dimen/car_margin"
-            android:text="@string/app_name"
-            android:textAppearance="@style/TextAppearance.Car.Body1.Light" />
-
-        <Button
-            android:id="@+id/revoke_trust_button"
-            android:layout_width="wrap_content"
-            android:layout_centerVertical="true"
-            android:layout_toStartOf="@+id/start_button"
-            android:layout_marginEnd="@dimen/car_padding_4"
-            android:text="@string/revoke_trust"
-            style="?android:attr/borderlessButtonStyle" />
-
-        <Button
-            android:id="@+id/start_button"
-            android:layout_width="wrap_content"
-            android:layout_alignParentEnd="true"
-            android:layout_centerVertical="true"
-            android:layout_marginEnd="@dimen/car_keyline_1"
-            android:text="@string/start_advertising"
-            style="?android:attr/buttonStyle" />
-
-        <View
-            android:background="@color/car_list_divider_light"
-            android:layout_width="match_parent"
-            android:layout_height="@dimen/car_list_divider_height"
-            android:layout_alignParentBottom="true" />
-    </RelativeLayout>
-
-    <androidx.car.widget.PagedListView
-        android:id="@+id/list"
-        android:layout_marginTop="@dimen/car_padding_4"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        app:showPagedListViewDivider="false"
-        app:gutter="both"/>
-</LinearLayout>
diff --git a/TrustAgent/res/layout/output_line.xml b/TrustAgent/res/layout/output_line.xml
deleted file mode 100644
index 53eba57..0000000
--- a/TrustAgent/res/layout/output_line.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  ~ Copyright (C) 2018 The Android Open Source Project
-  ~
-  ~ Licensed under the Apache License, Version 2.0 (the "License");
-  ~ you may not use this file except in compliance with the License.
-  ~ You may obtain a copy of the License at
-  ~
-  ~      http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-<TextView
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/output"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:textAppearance="@style/TextAppearance.Car.Body3.Light" />
diff --git a/TrustAgent/res/values/strings.xml b/TrustAgent/res/values/strings.xml
deleted file mode 100644
index c8dcc18..0000000
--- a/TrustAgent/res/values/strings.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-<resources>
-    <string name="app_name">CarTrustAgentService</string>
-    <string name="trust_granted_explanation">Unlock via escrow token, now granting trust</string>
-
-    <!-- service/characteristics uuid for unlocking a device -->
-    <string name="unlock_service_uuid" translatable="false">5e2a68a1-27be-43f9-8d1e-4546976fabd7</string>
-    <string name="unlock_escrow_token_uiid" translatable="false">5e2a68a2-27be-43f9-8d1e-4546976fabd7</string>
-    <string name="unlock_handle_uiid" translatable="false">5e2a68a3-27be-43f9-8d1e-4546976fabd7</string>
-
-    <!-- service/characteristics uuid for adding new escrow token -->
-    <string name="enrollment_service_uuid" translatable="false">5e2a68a4-27be-43f9-8d1e-4546976fabd7</string>
-    <string name="enrollment_handle_uuid" translatable="false">5e2a68a5-27be-43f9-8d1e-4546976fabd7</string>
-    <string name="enrollment_token_uuid" translatable="false">5e2a68a6-27be-43f9-8d1e-4546976fabd7</string>
-
-    <string name="pref_key_token_handle" translatable="false">token-handle-key</string>
-    <string name="pref_key_escrow_token" translatable="false">escrow-token-key</string>
-
-    <string name="unlock_button">Unlock Car</string>
-    <string name="enroll_button">Enroll New Token</string>
-
-    <string name="start_advertising">Start Advertising</string>
-    <string name="revoke_trust">Revoke Trust</string>
-
-    <string name="token_handle_shared_preferences" translatable="false">com.android.car.trust.TOKEN_HANDLE</string>
-
-</resources>
diff --git a/TrustAgent/res/xml/car_sample_trust_agent.xml b/TrustAgent/res/xml/car_sample_trust_agent.xml
deleted file mode 100644
index 0c7d91d..0000000
--- a/TrustAgent/res/xml/car_sample_trust_agent.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  ~ Copyright (C) 2017 The Android Open Source Project
-  ~
-  ~ Licensed under the Apache License, Version 2.0 (the "License");
-  ~ you may not use this file except in compliance with the License.
-  ~ You may obtain a copy of the License at
-  ~
-  ~      http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License
-  -->
-<trust-agent xmlns:android="http://schemas.android.com/apk/res/android"
-             xmlns:priv-android="http://schemas.android.com/apk/prv/res/android"
-             android:settingsActivity=".MainActivity"
-             priv-android:unlockProfile="true" />
diff --git a/TrustAgent/src/com/android/car/trust/CarBleTrustAgent.java b/TrustAgent/src/com/android/car/trust/CarBleTrustAgent.java
deleted file mode 100644
index 1dfbd50..0000000
--- a/TrustAgent/src/com/android/car/trust/CarBleTrustAgent.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.car.trust;
-
-import android.annotation.Nullable;
-import android.app.ActivityManager;
-import android.app.UserSwitchObserver;
-import android.bluetooth.BluetoothAdapter;
-import android.car.trust.ICarTrustAgentBleService;
-import android.car.trust.ICarTrustAgentTokenRequestDelegate;
-import android.car.trust.ICarTrustAgentUnlockCallback;
-import android.content.BroadcastReceiver;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.ServiceConnection;
-import android.os.IBinder;
-import android.os.RemoteException;
-import android.os.UserHandle;
-import android.service.trust.TrustAgentService;
-import android.util.Log;
-
-/**
- * A BluetoothLE (BLE) based {@link TrustAgentService} that uses the escrow token unlock APIs. </p>
- *
- * This trust agent runs during direct boot and binds to a BLE service that listens for remote
- * devices to trigger an unlock. <p/>
- *
- * The permissions for this agent must be enabled as priv-app permissions for it to start.
- */
-public class CarBleTrustAgent extends TrustAgentService {
-
-    private static final String TAG = CarBleTrustAgent.class.getSimpleName();
-
-    /**
-     * {@link CarTrustAgentBleService} will callback this function when it receives both
-     * handle and token.
-     */
-    private final ICarTrustAgentUnlockCallback mUnlockCallback =
-            new ICarTrustAgentUnlockCallback.Stub() {
-        @Override
-        public void onUnlockDataReceived(byte[] token, long handle) throws RemoteException {
-            UserHandle userHandle = getUserHandleByTokenHandle(handle);
-            if (userHandle == null) {
-                Log.e(TAG, "Unable to find user by token handle " + handle);
-                return;
-            }
-
-            int uid = userHandle.getIdentifier();
-            if (ActivityManager.getCurrentUser() != uid) {
-                Log.d(TAG, "Switch to user: " + uid);
-                // Try to unlock when user switch completes
-                ActivityManager.getService().registerUserSwitchObserver(
-                        getUserSwitchObserver(uid, token, handle), TAG);
-                ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
-                am.switchUser(uid);
-            } else {
-                unlockUserInternally(uid, token, handle);
-            }
-        }
-    };
-
-    /**
-     * Delegates the escrow token API calls from {@link CarTrustAgentBleService} to
-     * {@link TrustAgentService}. Due to the asynchronous nature, the results will be posted to
-     * {@link CarTrustAgentBleService} by the following calls
-     * <ul>
-     *     <li>{@link #onEscrowTokenAdded(byte[], long, UserHandle)}</li>
-     *     <li>{@link #onEscrowTokenRemoved(long, boolean)}</li>
-     *     <li>{@link #onEscrowTokenStateReceived(long, int)}</li>
-     * </ul>
-     */
-    private final ICarTrustAgentTokenRequestDelegate mTokenRequestDelegate =
-            new ICarTrustAgentTokenRequestDelegate.Stub() {
-        @Override
-        public void revokeTrust() {
-            CarBleTrustAgent.this.revokeTrust();
-        }
-
-        @Override
-        public void addEscrowToken(byte[] token, int uid) {
-            CarBleTrustAgent.this.addEscrowToken(token, UserHandle.of(uid));
-        }
-
-        @Override
-        public void removeEscrowToken(long handle, int uid) {
-            CarBleTrustAgent.this.removeEscrowToken(handle, UserHandle.of(uid));
-        }
-
-        @Override
-        public void isEscrowTokenActive(long handle, int uid) {
-            CarBleTrustAgent.this.isEscrowTokenActive(handle, UserHandle.of(uid));
-        }
-    };
-
-    /**
-     * Service connection to {@link CarTrustAgentBleService}
-     */
-    private final ServiceConnection mServiceConnection = new ServiceConnection() {
-        @Override
-        public void onServiceConnected(ComponentName name, IBinder service) {
-            Log.d(TAG, "CarTrustAgentBleService connected");
-            mCarTrustAgentBleServiceBound = true;
-            mCarTrustAgentBleService = ICarTrustAgentBleService.Stub.asInterface(service);
-            try {
-                mCarTrustAgentBleService.registerUnlockCallback(mUnlockCallback);
-                mCarTrustAgentBleService.setTokenRequestDelegate(mTokenRequestDelegate);
-            } catch (RemoteException e) {
-                Log.e(TAG, "Error registerUnlockCallback", e);
-            }
-        }
-
-        @Override
-        public void onServiceDisconnected(ComponentName name) {
-            Log.d(TAG, "CarTrustAgentBleService disconnected");
-            if (mCarTrustAgentBleService != null) {
-                try {
-                    mCarTrustAgentBleService.unregisterUnlockCallback(mUnlockCallback);
-                    mCarTrustAgentBleService.setTokenRequestDelegate(null);
-                    mCarTrustAgentBleService.stopUnlockAdvertising();
-                } catch (RemoteException e) {
-                    Log.e(TAG, "Error unregisterUnlockCallback", e);
-                }
-                mCarTrustAgentBleService = null;
-                mCarTrustAgentBleServiceBound = false;
-            }
-        }
-    };
-
-    /**
-     * Receives the bluetooth state change broadcasts. Bluetooth is restarted when switching user,
-     * we need to ensure calling {@link ICarTrustAgentBleService#startUnlockAdvertising} after
-     * bluetooth is started.
-     */
-    private final BroadcastReceiver mBluetoothBroadcastReceiver = new BroadcastReceiver() {
-        @Override
-        public void onReceive(Context context, Intent intent) {
-            switch (intent.getAction()) {
-                case BluetoothAdapter.ACTION_STATE_CHANGED:
-                    onBluetoothStateChanged(intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1));
-                    break;
-            }
-        }
-    };
-
-    private ICarTrustAgentBleService mCarTrustAgentBleService;
-    private boolean mCarTrustAgentBleServiceBound;
-
-    /**
-     * TODO: Currently it relies on {@link #onDeviceLocked()} and {@link #onDeviceUnlocked()}
-     * callback, and these callbacks won't happen if the user has unlocked once.
-     */
-    private boolean mIsOnLockScreen;
-
-    @Override
-    public void onCreate() {
-        super.onCreate();
-        setManagingTrust(true);
-        bindService(new Intent(this, CarTrustAgentBleService.class),
-                mServiceConnection, Context.BIND_AUTO_CREATE);
-        IntentFilter intentFilter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
-        registerReceiver(mBluetoothBroadcastReceiver, intentFilter);
-    }
-
-    @Override
-    public void onDestroy() {
-        Log.d(TAG, "Car Trust agent shutting down");
-        if (mCarTrustAgentBleServiceBound) {
-            unbindService(mServiceConnection);
-        }
-        unregisterReceiver(mBluetoothBroadcastReceiver);
-        super.onDestroy();
-    }
-
-    @Override
-    public void onDeviceLocked() {
-        super.onDeviceLocked();
-        mIsOnLockScreen = true;
-        if (mCarTrustAgentBleServiceBound) {
-            try {
-                mCarTrustAgentBleService.startUnlockAdvertising();
-            } catch (RemoteException e) {
-                Log.e(TAG, "Error startUnlockAdvertising", e);
-            }
-        }
-    }
-
-    @Override
-    public void onDeviceUnlocked() {
-        super.onDeviceUnlocked();
-        mIsOnLockScreen = false;
-        if (mCarTrustAgentBleServiceBound) {
-            try {
-                mCarTrustAgentBleService.stopUnlockAdvertising();
-            } catch (RemoteException e) {
-                Log.e(TAG, "Error stopUnlockAdvertising", e);
-            }
-        }
-        // Revoke trust right after to enable keyguard when switching user
-        revokeTrust();
-    }
-
-    private UserSwitchObserver getUserSwitchObserver(int uid,
-            byte[] token, long handle) {
-        return new UserSwitchObserver() {
-            @Override
-            public void onUserSwitchComplete(int newUserId) throws RemoteException {
-                if (uid != newUserId) return;
-                unlockUserInternally(uid, token, handle);
-                ActivityManager.getService().unregisterUserSwitchObserver(this);
-            }
-
-            @Override
-            public void onLockedBootComplete(int newUserId) {
-                // ignored.
-            }
-        };
-    }
-
-    private void unlockUserInternally(int uid, byte[] token, long handle) {
-        Log.d(TAG, "About to unlock user: " + uid);
-        unlockUserWithToken(handle, token, UserHandle.of(uid));
-        grantTrust("Granting trust from escrow token",
-                0, FLAG_GRANT_TRUST_DISMISS_KEYGUARD);
-    }
-
-    private void onBluetoothStateChanged(int state) {
-        Log.d(TAG, "onBluetoothStateChanged: " + state);
-        if ((state == BluetoothAdapter.STATE_ON || state == BluetoothAdapter.STATE_BLE_ON)
-                && mCarTrustAgentBleServiceBound
-                && mIsOnLockScreen) {
-            try {
-                mCarTrustAgentBleService.startUnlockAdvertising();
-            } catch (RemoteException e) {
-                Log.e(TAG, "Error startUnlockAdvertising", e);
-            }
-        }
-    }
-
-    @Override
-    public void onEscrowTokenRemoved(long handle, boolean successful) {
-        if (mCarTrustAgentBleServiceBound) {
-            try {
-                mCarTrustAgentBleService.onEscrowTokenRemoved(handle, successful);
-                Log.v(TAG, "Callback onEscrowTokenRemoved");
-            } catch (RemoteException e) {
-                Log.e(TAG, "Error callback onEscrowTokenRemoved", e);
-            }
-        }
-    }
-
-    @Override
-    public void onEscrowTokenStateReceived(long handle, int tokenState) {
-        boolean isActive = tokenState == TOKEN_STATE_ACTIVE;
-        if (mCarTrustAgentBleServiceBound) {
-            try {
-                mCarTrustAgentBleService.onEscrowTokenActiveStateChanged(handle, isActive);
-                Log.v(TAG, "Callback onEscrowTokenActiveStateChanged");
-            } catch (RemoteException e) {
-                Log.e(TAG, "Error callback onEscrowTokenActiveStateChanged", e);
-            }
-        }
-    }
-
-    @Override
-    public void onEscrowTokenAdded(byte[] token, long handle, UserHandle user) {
-        if (mCarTrustAgentBleServiceBound) {
-            try {
-                mCarTrustAgentBleService.onEscrowTokenAdded(token, handle, user.getIdentifier());
-                Log.v(TAG, "Callback onEscrowTokenAdded");
-            } catch (RemoteException e) {
-                Log.e(TAG, "Error callback onEscrowTokenAdded", e);
-            }
-        }
-    }
-
-    private @Nullable UserHandle getUserHandleByTokenHandle(long tokenHandle) {
-        if (mCarTrustAgentBleServiceBound) {
-            try {
-                int userId = mCarTrustAgentBleService.getUserIdByEscrowTokenHandle(tokenHandle);
-                return userId < 0 ? null : UserHandle.of(userId);
-            } catch (RemoteException e) {
-                Log.e(TAG, "Error getUserHandleByTokenHandle");
-            }
-        }
-        return null;
-    }
-}
diff --git a/TrustAgent/src/com/android/car/trust/CarEnrolmentActivity.java b/TrustAgent/src/com/android/car/trust/CarEnrolmentActivity.java
deleted file mode 100644
index f93c1b4..0000000
--- a/TrustAgent/src/com/android/car/trust/CarEnrolmentActivity.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-package com.android.car.trust;
-
-import android.Manifest;
-import android.app.Activity;
-import android.bluetooth.BluetoothDevice;
-import android.car.trust.ICarTrustAgentBleCallback;
-import android.car.trust.ICarTrustAgentBleService;
-import android.car.trust.ICarTrustAgentEnrolmentCallback;
-import android.car.trust.ICarTrustAgentTokenResponseCallback;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.content.SharedPreferences;
-import android.content.pm.PackageManager;
-import android.os.Bundle;
-import android.os.IBinder;
-import android.os.RemoteException;
-import android.os.UserHandle;
-import android.preference.PreferenceManager;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-import androidx.car.widget.PagedListView;
-import androidx.recyclerview.widget.RecyclerView;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Setup activity that binds {@link CarTrustAgentBleService} and starts the enrolment process.
- */
-public class CarEnrolmentActivity extends Activity {
-
-    private static final String TAG = CarEnrolmentActivity.class.getSimpleName();
-
-    private static final String SP_HANDLE_KEY = "sp-test";
-    private static final int FINE_LOCATION_REQUEST_CODE = 42;
-
-    private PagedListView mList;
-    private OutputAdapter mOutputAdapter;
-    private BluetoothDevice mBluetoothDevice;
-    private ICarTrustAgentBleService mCarTrustAgentBleService;
-    private boolean mCarTrustAgentBleServiceBound;
-    private SharedPreferences mPrefs;
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.car_enrolment_activity);
-
-        mPrefs = PreferenceManager.getDefaultSharedPreferences(/* context= */ this);
-
-        findViewById(R.id.start_button).setOnClickListener(v -> {
-            if (!mCarTrustAgentBleServiceBound) {
-                Intent bindIntent = new Intent(this, CarTrustAgentBleService.class);
-                bindService(bindIntent, mServiceConnection, Context.BIND_AUTO_CREATE);
-            }
-        });
-
-        findViewById(R.id.revoke_trust_button).setOnClickListener(v -> {
-            if (mCarTrustAgentBleServiceBound) {
-                try {
-                    mCarTrustAgentBleService.revokeTrust();
-                } catch (RemoteException e) {
-                    Log.e(TAG, "Error revokeTrust", e);
-                }
-            }
-        });
-
-        mOutputAdapter = new OutputAdapter();
-
-        mList = findViewById(R.id.list);
-        mList.setAdapter(mOutputAdapter);
-    }
-
-    @Override
-    protected void onResume() {
-        super.onResume();
-
-        if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION)
-                != PackageManager.PERMISSION_GRANTED) {
-            requestPermissions(
-                    new String[] { android.Manifest.permission.ACCESS_FINE_LOCATION },
-                    FINE_LOCATION_REQUEST_CODE);
-        }
-    }
-
-    @Override
-    protected void onStop() {
-        super.onStop();
-
-        if (mCarTrustAgentBleServiceBound) {
-            unbindService(mServiceConnection);
-            mCarTrustAgentBleServiceBound = false;
-        }
-    }
-
-    private void appendOutputText(String text) {
-        runOnUiThread(() -> {
-            mOutputAdapter.addOutput(text);
-            mList.scrollToPosition(mOutputAdapter.getItemCount() - 1);
-        });
-    }
-
-    private void addEscrowToken(byte[] token) throws RemoteException {
-        if (!mCarTrustAgentBleServiceBound) {
-            Log.e(TAG, "No CarTrustAgentBleService bounded");
-            return;
-        }
-        mCarTrustAgentBleService.addEscrowToken(token, UserHandle.myUserId());
-    }
-
-    private void checkTokenHandle() {
-        long tokenHandle = mPrefs.getLong(SP_HANDLE_KEY, -1);
-        if (tokenHandle != -1) {
-            if (Log.isLoggable(TAG, Log.DEBUG)) {
-                Log.d(TAG, "Checking handle active: " + tokenHandle);
-            }
-
-            if (mCarTrustAgentBleServiceBound) {
-                try {
-                    // Due to the asynchronous nature of isEscrowTokenActive in
-                    // TrustAgentService, query result will be delivered via
-                    // {@link #mCarTrustAgentTokenResponseCallback}
-                    mCarTrustAgentBleService.isEscrowTokenActive(tokenHandle,
-                            UserHandle.myUserId());
-                } catch (RemoteException e) {
-                    Log.e(TAG, "Error isEscrowTokenActive", e);
-                }
-            }
-        } else {
-            appendOutputText("No handles found");
-        }
-    }
-
-    /**
-     * Receives escrow token callbacks, registered on {@link CarTrustAgentBleService}
-     */
-    private final ICarTrustAgentTokenResponseCallback mCarTrustAgentTokenResponseCallback =
-            new ICarTrustAgentTokenResponseCallback.Stub() {
-        @Override
-        public void onEscrowTokenAdded(byte[] token, long handle, int uid) {
-            runOnUiThread(() -> {
-                mPrefs.edit().putLong(SP_HANDLE_KEY, handle).apply();
-
-                if (Log.isLoggable(TAG, Log.DEBUG)) {
-                    Log.d(TAG, "stored new handle for user: " + uid);
-                }
-            });
-
-            if (mBluetoothDevice == null) {
-                Log.e(TAG, "No active bluetooth found to add escrow token");
-                return;
-            }
-
-            try {
-                // Notify the enrolment client that escrow token has been added
-                mCarTrustAgentBleService.sendEnrolmentHandle(mBluetoothDevice, handle);
-                appendOutputText("Escrow Token Added. Handle: " + handle);
-                appendOutputText("Lock and unlock the device to activate token");
-            } catch (RemoteException e) {
-                Log.e(TAG, "Error sendEnrolmentHandle", e);
-            }
-        }
-
-        @Override
-        public void onEscrowTokenRemoved(long handle, boolean successful) {
-            appendOutputText("Escrow token Removed. Handle: " + handle);
-        }
-
-        @Override
-        public void onEscrowTokenActiveStateChanged(long handle, boolean active) {
-            appendOutputText("Is token active? " + active + " handle: " + handle);
-        }
-    };
-
-    /**
-     * Receives BLE state change callbacks, registered on {@link CarTrustAgentBleService}
-     */
-    private final ICarTrustAgentBleCallback mBleConnectionCallback =
-            new ICarTrustAgentBleCallback.Stub() {
-        @Override
-        public void onBleServerStartSuccess() {
-            appendOutputText("Server started");
-        }
-
-        @Override
-        public void onBleServerStartFailure(int errorCode) {
-            appendOutputText("Server failed to start, error code: " + errorCode);
-        }
-
-        @Override
-        public void onBleDeviceConnected(BluetoothDevice device) {
-            mBluetoothDevice = device;
-            appendOutputText("Device connected: " + device.getName()
-                    + " address: " + device.getAddress());
-        }
-
-        @Override
-        public void onBleDeviceDisconnected(BluetoothDevice device) {
-            mBluetoothDevice = null;
-            appendOutputText("Device disconnected: " + device.getName()
-                    + " address: " + device.getAddress());
-        }
-    };
-
-    /**
-     * {@link CarTrustAgentBleService} will callback this when receives enrolment data.
-     *
-     * <p>Here is the place we can prompt to the user on HU whether or not to add this
-     * {@link #mBluetoothDevice} as a trust device.
-     */
-    private final ICarTrustAgentEnrolmentCallback mEnrolmentCallback =
-            new ICarTrustAgentEnrolmentCallback.Stub() {
-        @Override
-        public void onEnrolmentDataReceived(byte[] token) {
-            appendOutputText("Enrolment data received ");
-            try {
-                addEscrowToken(token);
-            } catch (RemoteException e) {
-                Log.e(TAG, "Error addEscrowToken", e);
-            }
-        }
-    };
-
-    /**
-     * Service connection to {@link CarTrustAgentBleService}
-     */
-    private final ServiceConnection mServiceConnection = new ServiceConnection() {
-        @Override
-        public void onServiceConnected(ComponentName name, IBinder service) {
-            mCarTrustAgentBleServiceBound = true;
-            mCarTrustAgentBleService = ICarTrustAgentBleService.Stub.asInterface(service);
-            try {
-                mCarTrustAgentBleService.registerBleCallback(mBleConnectionCallback);
-                mCarTrustAgentBleService.registerEnrolmentCallback(mEnrolmentCallback);
-                mCarTrustAgentBleService.setTokenResponseCallback(
-                        mCarTrustAgentTokenResponseCallback);
-                mCarTrustAgentBleService.startEnrolmentAdvertising();
-            } catch (RemoteException e) {
-                Log.e(TAG, "Error startEnrolmentAdvertising", e);
-            }
-            checkTokenHandle();
-        }
-
-        @Override
-        public void onServiceDisconnected(ComponentName name) {
-            if (mCarTrustAgentBleService != null) {
-                try {
-                    mCarTrustAgentBleService.unregisterBleCallback(mBleConnectionCallback);
-                    mCarTrustAgentBleService.unregisterEnrolmentCallback(mEnrolmentCallback);
-                    mCarTrustAgentBleService.setTokenResponseCallback(null);
-                    mCarTrustAgentBleService.stopEnrolmentAdvertising();
-                } catch (RemoteException e) {
-                    Log.e(TAG, "Error unregister callbacks", e);
-                }
-                mCarTrustAgentBleService = null;
-            }
-            mCarTrustAgentBleServiceBound = false;
-        }
-    };
-
-    /** Adapter that displays the output of TrustAgent connections. */
-    private static class OutputAdapter extends RecyclerView.Adapter<OutputAdapter.ViewHolder> {
-        private final List<String> mOutput = new ArrayList<>();
-
-        /** Adds the given string as output to be displayed. */
-        public void addOutput(String output) {
-            mOutput.add(output);
-            notifyItemInserted(mOutput.size() - 1);
-        }
-
-        @Override
-        public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
-            return new ViewHolder(LayoutInflater.from(parent.getContext())
-                    .inflate(R.layout.output_line, parent, false));
-        }
-
-        @Override
-        public void onBindViewHolder(ViewHolder holder, int position) {
-            holder.mTextView.setText(mOutput.get(position));
-        }
-
-        @Override
-        public int getItemCount() {
-            return mOutput.size();
-        }
-
-        /** ViewHolder for {@link OutputAdapter}. */
-        public static class ViewHolder extends RecyclerView.ViewHolder {
-            private final TextView mTextView;
-
-            ViewHolder(View itemView) {
-                super(itemView);
-                mTextView = itemView.findViewById(R.id.output);
-            }
-        }
-    }
-}
diff --git a/TrustAgent/src/com/android/car/trust/CarTrustAgentBleService.java b/TrustAgent/src/com/android/car/trust/CarTrustAgentBleService.java
deleted file mode 100644
index d70fd2f..0000000
--- a/TrustAgent/src/com/android/car/trust/CarTrustAgentBleService.java
+++ /dev/null
@@ -1,475 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.car.trust;
-
-import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothGattCharacteristic;
-import android.bluetooth.BluetoothGattService;
-import android.bluetooth.le.AdvertiseCallback;
-import android.bluetooth.le.AdvertiseSettings;
-import android.car.trust.ICarTrustAgentBleCallback;
-import android.car.trust.ICarTrustAgentBleService;
-import android.car.trust.ICarTrustAgentEnrolmentCallback;
-import android.car.trust.ICarTrustAgentTokenRequestDelegate;
-import android.car.trust.ICarTrustAgentTokenResponseCallback;
-import android.car.trust.ICarTrustAgentUnlockCallback;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.os.IBinder;
-import android.os.RemoteCallbackList;
-import android.os.RemoteException;
-import android.util.Log;
-
-import java.nio.ByteBuffer;
-import java.text.DateFormat;
-import java.util.UUID;
-
-/**
- * Abstracts enrolment and unlock token exchange via BluetoothLE (BLE).
- * {@link CarBleTrustAgent} and any enrolment client should bind to
- * {@link ICarTrustAgentBleService}.
- */
-public class CarTrustAgentBleService extends SimpleBleServer {
-    private static final String TAG = CarTrustAgentBleService.class.getSimpleName();
-
-    private RemoteCallbackList<ICarTrustAgentBleCallback> mBleCallbacks;
-    private RemoteCallbackList<ICarTrustAgentEnrolmentCallback> mEnrolmentCallbacks;
-    private RemoteCallbackList<ICarTrustAgentUnlockCallback> mUnlockCallbacks;
-    private ICarTrustAgentTokenRequestDelegate mTokenRequestDelegate;
-    private ICarTrustAgentTokenResponseCallback mTokenResponseCallback;
-    private CarTrustAgentBleWrapper mCarTrustBleService;
-
-    private UUID mEnrolmentEscrowTokenUuid;
-    private UUID mEnrolmentTokenHandleUuid;
-    private BluetoothGattService mEnrolmentGattService;
-
-    private UUID mUnlockEscrowTokenUuid;
-    private UUID mUnlockTokenHandleUuid;
-    private BluetoothGattService mUnlockGattService;
-
-    private byte[] mCurrentUnlockToken;
-    private Long mCurrentUnlockHandle;
-
-    private SharedPreferences mTokenHandleSharedPreferences;
-
-    @Override
-    public void onCreate() {
-        super.onCreate();
-        mBleCallbacks = new RemoteCallbackList<>();
-        mEnrolmentCallbacks = new RemoteCallbackList<>();
-        mUnlockCallbacks = new RemoteCallbackList<>();
-        mCarTrustBleService = new CarTrustAgentBleWrapper();
-
-        mEnrolmentEscrowTokenUuid = UUID.fromString(getString(R.string.enrollment_token_uuid));
-        mEnrolmentTokenHandleUuid = UUID.fromString(getString(R.string.enrollment_handle_uuid));
-        mUnlockEscrowTokenUuid = UUID.fromString(getString(R.string.unlock_escrow_token_uiid));
-        mUnlockTokenHandleUuid = UUID.fromString(getString(R.string.unlock_handle_uiid));
-
-        setupEnrolmentBleServer();
-        setupUnlockBleServer();
-
-        mTokenHandleSharedPreferences = getSharedPreferences(
-                getString(R.string.token_handle_shared_preferences),
-                MODE_PRIVATE);
-    }
-
-    @Override
-    public IBinder onBind(Intent intent) {
-        return mCarTrustBleService;
-    }
-
-    @Override
-    public int onStartCommand(Intent intent, int flags, int startId) {
-        // keep it alive.
-        return START_STICKY;
-    }
-
-    @Override
-    public void onCharacteristicWrite(final BluetoothDevice device, int requestId,
-            BluetoothGattCharacteristic characteristic, boolean preparedWrite, boolean
-            responseNeeded, int offset, byte[] value) {
-        UUID uuid = characteristic.getUuid();
-
-        if (Log.isLoggable(TAG, Log.DEBUG)) {
-            Log.d(TAG, "onCharacteristicWrite received uuid: " + uuid);
-        }
-
-        if (uuid.equals(mEnrolmentEscrowTokenUuid)) {
-            final int callbackCount = mEnrolmentCallbacks.beginBroadcast();
-            for (int i = 0; i < callbackCount; i++) {
-                try {
-                    mEnrolmentCallbacks.getBroadcastItem(i).onEnrolmentDataReceived(value);
-                } catch (RemoteException e) {
-                    Log.e(TAG, "Error callback onEnrolmentDataReceived", e);
-                }
-            }
-            mEnrolmentCallbacks.finishBroadcast();
-        } else if (uuid.equals(mUnlockEscrowTokenUuid)) {
-            mCurrentUnlockToken = value;
-            maybeSendUnlockToken();
-        } else if (uuid.equals(mUnlockTokenHandleUuid)) {
-            mCurrentUnlockHandle = getLong(value);
-            maybeSendUnlockToken();
-        }
-    }
-
-    @Override
-    public void onCharacteristicRead(BluetoothDevice device,
-            int requestId, int offset, final BluetoothGattCharacteristic characteristic) {
-        // Ignored read requests.
-    }
-
-    @Override
-    protected void onAdvertiseStartSuccess() {
-        final int callbackCount = mBleCallbacks.beginBroadcast();
-        for (int i = 0; i < callbackCount; i++) {
-            try {
-                mBleCallbacks.getBroadcastItem(i).onBleServerStartSuccess();
-            } catch (RemoteException e) {
-                Log.e(TAG, "Error callback onBleServerStartSuccess", e);
-            }
-        }
-        mBleCallbacks.finishBroadcast();
-    }
-
-    @Override
-    protected void onAdvertiseStartFailure(int errorCode) {
-        final int callbackCount = mBleCallbacks.beginBroadcast();
-        for (int i = 0; i < callbackCount; i++) {
-            try {
-                mBleCallbacks.getBroadcastItem(i).onBleServerStartFailure(errorCode);
-            } catch (RemoteException e) {
-                Log.e(TAG, "Error callback onBleServerStartFailure", e);
-            }
-        }
-        mBleCallbacks.finishBroadcast();
-    }
-
-    @Override
-    protected void onAdvertiseDeviceConnected(BluetoothDevice device) {
-        final int callbackCount = mBleCallbacks.beginBroadcast();
-        for (int i = 0; i < callbackCount; i++) {
-            try {
-                mBleCallbacks.getBroadcastItem(i).onBleDeviceConnected(device);
-            } catch (RemoteException e) {
-                Log.e(TAG, "Error callback onBleDeviceConnected", e);
-            }
-        }
-        mBleCallbacks.finishBroadcast();
-    }
-
-    @Override
-    protected void onAdvertiseDeviceDisconnected(BluetoothDevice device) {
-        final int callbackCount = mBleCallbacks.beginBroadcast();
-        for (int i = 0; i < callbackCount; i++) {
-            try {
-                mBleCallbacks.getBroadcastItem(i).onBleDeviceDisconnected(device);
-            } catch (RemoteException e) {
-                Log.e(TAG, "Error callback onBleDeviceDisconnected", e);
-            }
-        }
-        mBleCallbacks.finishBroadcast();
-    }
-
-    @Override
-    public void onDestroy() {
-        stopAdvertising(mEnrolmentAdvertisingCallback);
-        stopAdvertising(mUnlockAdvertisingCallback);
-        super.onDestroy();
-    }
-
-    private void setupEnrolmentBleServer() {
-        mEnrolmentGattService = new BluetoothGattService(
-                UUID.fromString(getString(R.string.enrollment_service_uuid)),
-                BluetoothGattService.SERVICE_TYPE_PRIMARY);
-
-        // Characteristic to describe the escrow token being used for unlock
-        BluetoothGattCharacteristic enrolmentEscrowToken = new BluetoothGattCharacteristic(
-                mEnrolmentEscrowTokenUuid,
-                BluetoothGattCharacteristic.PROPERTY_WRITE,
-                BluetoothGattCharacteristic.PERMISSION_WRITE);
-
-        // Characteristic to describe the handle being used for this escrow token
-        BluetoothGattCharacteristic enrolmentTokenHandle = new BluetoothGattCharacteristic(
-                mEnrolmentTokenHandleUuid,
-                BluetoothGattCharacteristic.PROPERTY_NOTIFY,
-                BluetoothGattCharacteristic.PERMISSION_READ);
-
-        mEnrolmentGattService.addCharacteristic(enrolmentEscrowToken);
-        mEnrolmentGattService.addCharacteristic(enrolmentTokenHandle);
-    }
-
-    private void setupUnlockBleServer() {
-        mUnlockGattService = new BluetoothGattService(
-                UUID.fromString(getString(R.string.unlock_service_uuid)),
-                BluetoothGattService.SERVICE_TYPE_PRIMARY);
-
-        // Characteristic to describe the escrow token being used for unlock
-        BluetoothGattCharacteristic unlockEscrowToken = new BluetoothGattCharacteristic(
-                mUnlockEscrowTokenUuid,
-                BluetoothGattCharacteristic.PROPERTY_WRITE,
-                BluetoothGattCharacteristic.PERMISSION_WRITE);
-
-        // Characteristic to describe the handle being used for this escrow token
-        BluetoothGattCharacteristic unlockTokenHandle = new BluetoothGattCharacteristic(
-                mUnlockTokenHandleUuid,
-                BluetoothGattCharacteristic.PROPERTY_WRITE,
-                BluetoothGattCharacteristic.PERMISSION_WRITE);
-
-        mUnlockGattService.addCharacteristic(unlockEscrowToken);
-        mUnlockGattService.addCharacteristic(unlockTokenHandle);
-    }
-
-    private synchronized void maybeSendUnlockToken() {
-        if (mCurrentUnlockToken == null || mCurrentUnlockHandle == null) {
-            return;
-        }
-
-        if (Log.isLoggable(TAG, Log.DEBUG)) {
-            Log.d(TAG, "Handle and token both received, requesting unlock. Time: "
-                    + DateFormat.getDateInstance(DateFormat.SHORT).format(
-                            System.currentTimeMillis()));
-        }
-
-        int callbackCount = mUnlockCallbacks.beginBroadcast();
-        for (int i = 0; i < callbackCount; i++) {
-            try {
-                mUnlockCallbacks.getBroadcastItem(i).onUnlockDataReceived(
-                        mCurrentUnlockToken, mCurrentUnlockHandle);
-            } catch (RemoteException e) {
-                Log.e(TAG, "Error callback onUnlockDataReceived", e);
-            }
-        }
-        mUnlockCallbacks.finishBroadcast();
-        mCurrentUnlockHandle = null;
-        mCurrentUnlockToken = null;
-    }
-
-    private static byte[] getBytes(long primitive) {
-        ByteBuffer buffer = ByteBuffer.allocate(Long.SIZE / Byte.SIZE);
-        buffer.putLong(0, primitive);
-        return buffer.array();
-    }
-
-    private static long getLong(byte[] bytes) {
-        ByteBuffer buffer = ByteBuffer.allocate(Long.SIZE / Byte.SIZE);
-        buffer.put(bytes);
-        buffer.flip();
-        return buffer.getLong();
-    }
-
-    private final AdvertiseCallback mEnrolmentAdvertisingCallback = new AdvertiseCallback() {
-        @Override
-        public void onStartSuccess(AdvertiseSettings settingsInEffect) {
-            super.onStartSuccess(settingsInEffect);
-            onAdvertiseStartSuccess();
-
-            if (Log.isLoggable(TAG, Log.DEBUG)) {
-                Log.d(TAG, "Successfully started advertising service");
-            }
-        }
-
-        @Override
-        public void onStartFailure(int errorCode) {
-            Log.e(TAG, "Failed to advertise, errorCode: " + errorCode);
-
-            super.onStartFailure(errorCode);
-            onAdvertiseStartFailure(errorCode);
-        }
-    };
-
-    private final AdvertiseCallback mUnlockAdvertisingCallback = new AdvertiseCallback() {
-        @Override
-        public void onStartSuccess(AdvertiseSettings settingsInEffect) {
-            super.onStartSuccess(settingsInEffect);
-            onAdvertiseStartSuccess();
-
-            if (Log.isLoggable(TAG, Log.DEBUG)) {
-                Log.d(TAG, "Successfully started advertising service");
-            }
-        }
-
-        @Override
-        public void onStartFailure(int errorCode) {
-            Log.e(TAG, "Failed to advertise, errorCode: " + errorCode);
-
-            super.onStartFailure(errorCode);
-            onAdvertiseStartFailure(errorCode);
-        }
-    };
-
-    private final class CarTrustAgentBleWrapper extends ICarTrustAgentBleService.Stub {
-        @Override
-        public void registerBleCallback(ICarTrustAgentBleCallback callback) {
-            mBleCallbacks.register(callback);
-        }
-
-        @Override
-        public void unregisterBleCallback(ICarTrustAgentBleCallback callback) {
-            mBleCallbacks.unregister(callback);
-        }
-
-        @Override
-        public void startEnrolmentAdvertising() {
-            stopEnrolmentAdvertising();
-            stopUnlockAdvertising();
-
-            if (Log.isLoggable(TAG, Log.DEBUG)) {
-                Log.d(TAG, "startEnrolmentAdvertising");
-            }
-            startAdvertising(mEnrolmentGattService, mEnrolmentAdvertisingCallback);
-        }
-
-        @Override
-        public void stopEnrolmentAdvertising() {
-            if (Log.isLoggable(TAG, Log.DEBUG)) {
-                Log.d(TAG, "stopEnrolmentAdvertising");
-            }
-
-            stopAdvertising(mEnrolmentAdvertisingCallback);
-        }
-
-        @Override
-        public void sendEnrolmentHandle(BluetoothDevice device, long handle) {
-            if (Log.isLoggable(TAG, Log.DEBUG)) {
-                Log.d(TAG, "sendEnrolmentHandle: " + handle);
-            }
-            BluetoothGattCharacteristic enrolmentTokenHandle =
-                    mEnrolmentGattService.getCharacteristic(mEnrolmentTokenHandleUuid);
-            enrolmentTokenHandle.setValue(getBytes(handle));
-            notifyCharacteristicChanged(device, enrolmentTokenHandle, false);
-        }
-
-        @Override
-        public void registerEnrolmentCallback(ICarTrustAgentEnrolmentCallback callback) {
-            mEnrolmentCallbacks.register(callback);
-        }
-
-        @Override
-        public void unregisterEnrolmentCallback(ICarTrustAgentEnrolmentCallback callback) {
-            mEnrolmentCallbacks.unregister(callback);
-        }
-
-        @Override
-        public void startUnlockAdvertising() {
-            stopUnlockAdvertising();
-            stopEnrolmentAdvertising();
-
-            if (Log.isLoggable(TAG, Log.DEBUG)) {
-                Log.d(TAG, "startUnlockAdvertising");
-            }
-            startAdvertising(mUnlockGattService, mUnlockAdvertisingCallback);
-        }
-
-        @Override
-        public void stopUnlockAdvertising() {
-            if (Log.isLoggable(TAG, Log.DEBUG)) {
-                Log.d(TAG, "stopUnlockAdvertising");
-            }
-            stopAdvertising(mUnlockAdvertisingCallback);
-        }
-
-        @Override
-        public void registerUnlockCallback(ICarTrustAgentUnlockCallback callback) {
-            mUnlockCallbacks.register(callback);
-        }
-
-        @Override
-        public void unregisterUnlockCallback(ICarTrustAgentUnlockCallback callback) {
-            mUnlockCallbacks.unregister(callback);
-        }
-
-        @Override
-        public void setTokenRequestDelegate(ICarTrustAgentTokenRequestDelegate delegate) {
-            mTokenRequestDelegate = delegate;
-        }
-
-        @Override
-        public void revokeTrust() throws RemoteException {
-            if (mTokenRequestDelegate != null) {
-                mTokenRequestDelegate.revokeTrust();
-            }
-        }
-
-        @Override
-        public void addEscrowToken(byte[] token, int uid) throws RemoteException {
-            if (mTokenRequestDelegate != null) {
-                mTokenRequestDelegate.addEscrowToken(token, uid);
-            }
-        }
-
-        @Override
-        public void removeEscrowToken(long handle, int uid) throws RemoteException {
-            if (mTokenRequestDelegate != null) {
-                mTokenRequestDelegate.removeEscrowToken(handle, uid);
-            }
-        }
-
-        @Override
-        public void isEscrowTokenActive(long handle, int uid) throws RemoteException {
-            if (mTokenRequestDelegate != null) {
-                mTokenRequestDelegate.isEscrowTokenActive(handle, uid);
-            }
-        }
-
-        @Override
-        public void setTokenResponseCallback(ICarTrustAgentTokenResponseCallback callback) {
-            mTokenResponseCallback = callback;
-        }
-
-        @Override
-        public void onEscrowTokenAdded(byte[] token, long handle, int uid)
-                throws RemoteException {
-            if (Log.isLoggable(TAG, Log.DEBUG)) {
-                Log.d(TAG, "onEscrowTokenAdded handle:" + handle + " uid:" + uid);
-            }
-
-            mTokenHandleSharedPreferences.edit()
-                    .putInt(String.valueOf(handle), uid)
-                    .apply();
-            if (mTokenResponseCallback != null) {
-                mTokenResponseCallback.onEscrowTokenAdded(token, handle, uid);
-            }
-        }
-
-        @Override
-        public void onEscrowTokenRemoved(long handle, boolean successful) throws RemoteException {
-            if (Log.isLoggable(TAG, Log.DEBUG)) {
-                Log.d(TAG, "onEscrowTokenRemoved handle:" + handle);
-            }
-
-            mTokenHandleSharedPreferences.edit()
-                    .remove(String.valueOf(handle))
-                    .apply();
-            if (mTokenResponseCallback != null) {
-                mTokenResponseCallback.onEscrowTokenRemoved(handle, successful);
-            }
-        }
-
-        @Override
-        public void onEscrowTokenActiveStateChanged(long handle, boolean active)
-                throws RemoteException {
-            if (mTokenResponseCallback != null) {
-                mTokenResponseCallback.onEscrowTokenActiveStateChanged(handle, active);
-            }
-        }
-
-        @Override
-        public int getUserIdByEscrowTokenHandle(long tokenHandle) {
-            return mTokenHandleSharedPreferences.getInt(String.valueOf(tokenHandle), -1);
-        }
-    }
-}
diff --git a/TrustAgent/src/com/android/car/trust/SimpleBleServer.java b/TrustAgent/src/com/android/car/trust/SimpleBleServer.java
deleted file mode 100644
index 260f5ac..0000000
--- a/TrustAgent/src/com/android/car/trust/SimpleBleServer.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-package com.android.car.trust;
-
-import static android.bluetooth.BluetoothProfile.GATT_SERVER;
-
-import android.app.Service;
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothGatt;
-import android.bluetooth.BluetoothGattCharacteristic;
-import android.bluetooth.BluetoothGattServer;
-import android.bluetooth.BluetoothGattServerCallback;
-import android.bluetooth.BluetoothGattService;
-import android.bluetooth.BluetoothManager;
-import android.bluetooth.BluetoothProfile;
-import android.bluetooth.le.AdvertiseCallback;
-import android.bluetooth.le.AdvertiseData;
-import android.bluetooth.le.AdvertiseSettings;
-import android.bluetooth.le.BluetoothLeAdvertiser;
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.os.Handler;
-import android.os.ParcelUuid;
-import android.util.Log;
-
-/**
- * A generic service to start a BLE
- */
-public abstract class SimpleBleServer extends Service {
-    private static final String TAG = SimpleBleServer.class.getSimpleName();
-
-    private static final int BLE_RETRY_LIMIT = 5;
-    private static final int BLE_RETRY_INTERVAL_MS = 1000;
-
-    private final Handler mHandler = new Handler();
-
-    private BluetoothManager mBluetoothManager;
-    private BluetoothLeAdvertiser mAdvertiser;
-    private BluetoothGattServer mGattServer;
-    private int mAdvertiserStartCount;
-
-    /**
-     * Starts the GATT server with the given {@link BluetoothGattService} and begins
-     * advertising.
-     *
-     * <p>It is possible that BLE service is still in TURNING_ON state when this method is invoked.
-     * Therefore, several retries will be made to ensure advertising is started.
-     *
-     * @param service {@link BluetoothGattService} that will be discovered by clients
-     */
-    protected void startAdvertising(BluetoothGattService service,
-            AdvertiseCallback advertiseCallback) {
-        if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
-            Log.e(TAG, "System does not support BLE");
-            return;
-        }
-
-        // Only open one Gatt server.
-        if (mGattServer == null) {
-            mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
-            mGattServer = mBluetoothManager.openGattServer(this, mGattServerCallback);
-
-            if (mGattServer == null) {
-                Log.e(TAG, "Gatt Server not created");
-                return;
-            }
-        }
-
-        mGattServer.clearServices();
-        mGattServer.addService(service);
-
-        AdvertiseSettings settings = new AdvertiseSettings.Builder()
-                .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY)
-                .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH)
-                .setConnectable(true)
-                .build();
-
-        AdvertiseData data = new AdvertiseData.Builder()
-                .setIncludeDeviceName(true)
-                .addServiceUuid(new ParcelUuid(service.getUuid()))
-                .build();
-
-        mAdvertiserStartCount = 0;
-        startAdvertisingInternally(settings, data, advertiseCallback);
-    }
-
-    private void startAdvertisingInternally(AdvertiseSettings settings, AdvertiseData data,
-            AdvertiseCallback advertiseCallback) {
-        mAdvertiserStartCount += 1;
-        mAdvertiser = BluetoothAdapter.getDefaultAdapter().getBluetoothLeAdvertiser();
-        if (mAdvertiser == null && mAdvertiserStartCount < BLE_RETRY_LIMIT) {
-            mHandler.postDelayed(
-                    () -> startAdvertisingInternally(settings, data, advertiseCallback),
-                            BLE_RETRY_INTERVAL_MS);
-        } else {
-            mHandler.removeCallbacks(null);
-            mAdvertiser.startAdvertising(settings, data, advertiseCallback);
-            mAdvertiserStartCount = 0;
-        }
-    }
-
-    protected void stopAdvertising(AdvertiseCallback advertiseCallback) {
-        if (mAdvertiser != null) {
-            mAdvertiser.stopAdvertising(advertiseCallback);
-        }
-    }
-
-    /**
-     * Notifies the characteristic change via {@link BluetoothGattServer}
-     */
-    protected void notifyCharacteristicChanged(BluetoothDevice device,
-            BluetoothGattCharacteristic characteristic, boolean confirm) {
-        if (mGattServer != null) {
-            mGattServer.notifyCharacteristicChanged(device, characteristic, confirm);
-        }
-    }
-
-    @Override
-    public void onDestroy() {
-        // Stops the advertiser and GATT server. This needs to be done to avoid leaks
-        if (mAdvertiser != null) {
-            mAdvertiser.cleanup();
-        }
-
-        if (mGattServer != null) {
-            mGattServer.clearServices();
-            try {
-                for (BluetoothDevice d : mBluetoothManager.getConnectedDevices(GATT_SERVER)) {
-                    mGattServer.cancelConnection(d);
-                }
-            } catch (UnsupportedOperationException e) {
-                Log.e(TAG, "Error getting connected devices", e);
-            } finally {
-                mGattServer.close();
-            }
-        }
-        super.onDestroy();
-    }
-
-    // Delegate to subclass
-    protected void onAdvertiseStartSuccess() { }
-    protected void onAdvertiseStartFailure(int errorCode) { }
-    protected void onAdvertiseDeviceConnected(BluetoothDevice device) { }
-    protected void onAdvertiseDeviceDisconnected(BluetoothDevice device) { }
-
-    /**
-     * Triggered when this BleService receives a write request from a remote
-     * device. Sub-classes should implement how to handle requests.
-     */
-    protected abstract void onCharacteristicWrite(BluetoothDevice device, int requestId,
-            BluetoothGattCharacteristic characteristic, boolean preparedWrite, boolean
-            responseNeeded, int offset, byte[] value);
-
-    /**
-     * Triggered when this BleService receives a read request from a remote device.
-     */
-    protected abstract void onCharacteristicRead(BluetoothDevice device,
-            int requestId, int offset, final BluetoothGattCharacteristic characteristic);
-
-    private final BluetoothGattServerCallback mGattServerCallback =
-            new BluetoothGattServerCallback() {
-        @Override
-        public void onConnectionStateChange(BluetoothDevice device,
-                final int status, final int newState) {
-            switch (newState) {
-                case BluetoothProfile.STATE_CONNECTED:
-                    onAdvertiseDeviceConnected(device);
-                    break;
-                case BluetoothProfile.STATE_DISCONNECTED:
-                    onAdvertiseDeviceDisconnected(device);
-                    break;
-                default:
-                    Log.w(TAG, "Connection state not connecting or disconnecting; ignoring: "
-                            + newState);
-            }
-        }
-
-        @Override
-        public void onServiceAdded(final int status, BluetoothGattService service) {
-            if (Log.isLoggable(TAG, Log.DEBUG)) {
-                Log.d(TAG, "Service added status: " + status + " uuid: " + service.getUuid());
-            }
-        }
-
-        @Override
-        public void onCharacteristicReadRequest(BluetoothDevice device,
-                int requestId, int offset, final BluetoothGattCharacteristic characteristic) {
-            if (Log.isLoggable(TAG, Log.DEBUG)) {
-                Log.d(TAG, "Read request for characteristic: " + characteristic.getUuid());
-            }
-
-            mGattServer.sendResponse(device, requestId,
-                    BluetoothGatt.GATT_SUCCESS, offset, characteristic.getValue());
-            onCharacteristicRead(device, requestId, offset, characteristic);
-        }
-
-        @Override
-        public void onCharacteristicWriteRequest(final BluetoothDevice device, int requestId,
-                BluetoothGattCharacteristic characteristic, boolean preparedWrite, boolean
-                responseNeeded, int offset, byte[] value) {
-            if (Log.isLoggable(TAG, Log.DEBUG)) {
-                Log.d(TAG, "Write request for characteristic: " + characteristic.getUuid());
-            }
-
-            mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS,
-                    offset, value);
-            onCharacteristicWrite(device, requestId, characteristic,
-                    preparedWrite, responseNeeded, offset, value);
-        }
-    };
-}
diff --git a/car_product/build/car.mk b/car_product/build/car.mk
index c2161bc..ce7264b 100644
--- a/car_product/build/car.mk
+++ b/car_product/build/car.mk
@@ -86,7 +86,6 @@
 # Automotive specific packages
 PRODUCT_PACKAGES += \
     CarService \
-    CarTrustAgentService \
     CarDialerApp \
     CarRadioApp \
     OverviewApp \