Source:
<code>private void doStart() { if (mAdapter == null) { Log.w(mName, "Can't start profile service: device does not have BT"); return; } mAdapterService = AdapterService.getAdapterService(); if (mAdapterService == null) { Log.w(mName, "Could not add this profile because AdapterService is null."); return; } mAdapterService.addProfile(this); IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_USER_SWITCHED); filter.addAction(Intent.ACTION_USER_UNLOCKED); mUserSwitchedReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL); if (userId == UserHandle.USER_NULL) { Log.e(mName, "userChangeReceiver received an invalid EXTRA_USER_HANDLE"); return; } if (Intent.ACTION_USER_SWITCHED.equals(action)) { Log.d(mName, "User switched to userId " + userId); setCurrentUser(userId); } else if (Intent.ACTION_USER_UNLOCKED.equals(intent.getAction())) { Log.d(mName, "Unlocked userId " + userId); setUserUnlocked(userId); } } }; getApplicationContext().registerReceiver(mUserSwitchedReceiver, filter); int currentUserId = ActivityManager.getCurrentUser(); setCurrentUser(currentUserId); UserManager userManager = UserManager.get(getApplicationContext()); mProfileStarted = start(); if (!mProfileStarted) { Log.e(mName, "Error starting profile. start() returned false."); return; } <START> if (userManager.isUserUnlocked(currentUserId)) { setUserUnlocked(currentUserId); } <END> mAdapterService.onProfileServiceStateChanged(this, BluetoothAdapter.STATE_ON); }</code><technical_language>service run infrastructure setup? Therefore, setUserUnlocked() called start(). service cached user unlock information if setUserUnlocked is called start()? Also, if move setUserUnlocked(), move broadcast receiver registration triggers setUserUnlocked() call</technical_language>

Target:
private void doStart() { if (mAdapter == null) { Log.w(mName, "Can't start profile service: device does not have BT"); return; } mAdapterService = AdapterService.getAdapterService(); if (mAdapterService == null) { Log.w(mName, "Could not add this profile because AdapterService is null."); return; } mAdapterService.addProfile(this); IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_USER_SWITCHED); filter.addAction(Intent.ACTION_USER_UNLOCKED); mUserSwitchedReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL); if (userId == UserHandle.USER_NULL) { Log.e(mName, "userChangeReceiver received an invalid EXTRA_USER_HANDLE"); return; } if (Intent.ACTION_USER_SWITCHED.equals(action)) { Log.d(mName, "User switched to userId " + userId); setCurrentUser(userId); } else if (Intent.ACTION_USER_UNLOCKED.equals(intent.getAction())) { Log.d(mName, "Unlocked userId " + userId); setUserUnlocked(userId); } } }; getApplicationContext().registerReceiver(mUserSwitchedReceiver, filter); int currentUserId = ActivityManager.getCurrentUser(); setCurrentUser(currentUserId); UserManager userManager = UserManager.get(getApplicationContext()); if (userManager.isUserUnlocked(currentUserId)) { setUserUnlocked(currentUserId); } mProfileStarted = start(); if (!mProfileStarted) { Log.e(mName, "Error starting profile. start() returned false."); return; } mAdapterService.onProfileServiceStateChanged(this, BluetoothAdapter.STATE_ON); }