Loading android/app/src/com/android/bluetooth/btservice/ProfileService.java +1 −1 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ public abstract class ProfileService extends ContextWrapper { protected abstract IProfileServiceBinder initBinder(); /** Start service */ public abstract void start(); public void start() {} /** Stop service */ public abstract void stop(); Loading android/app/src/com/android/bluetooth/hfp/HeadsetService.java +12 −38 Original line number Diff line number Diff line Loading @@ -139,11 +139,11 @@ public class HeadsetService extends ProfileService { private final Looper mStateMachinesLooper; private final Handler mStateMachinesThreadHandler; private final HandlerThread mStateMachinesThread; // This is also used as a lock for shared data in HeadsetService private final HeadsetSystemInterface mSystemInterface; private int mMaxHeadsetConnections = 1; private BluetoothDevice mActiveDevice; // This is also used as a lock for shared data in HeadsetService private HeadsetSystemInterface mSystemInterface; private boolean mAudioRouteAllowed = true; // Indicates whether SCO audio needs to be forced to open regardless ANY OTHER restrictions private boolean mForceScoAudio; Loading @@ -157,7 +157,6 @@ public class HeadsetService extends ProfileService { // Timeout when voice recognition is started by remote device @VisibleForTesting static int sStartVrTimeoutMs = 5000; private ArrayList<StateMachineTask> mPendingClccResponses = new ArrayList<>(); private boolean mStarted; private static HeadsetService sHeadsetService; @VisibleForTesting boolean mIsAptXSwbEnabled = false; Loading Loading @@ -192,23 +191,6 @@ public class HeadsetService extends ProfileService { mStateMachinesLooper = mStateMachinesThread.getLooper(); } mStateMachinesThreadHandler = new Handler(mStateMachinesLooper); } public static boolean isEnabled() { return BluetoothProperties.isProfileHfpAgEnabled().orElse(false); } @Override public IProfileServiceBinder initBinder() { return new BluetoothHeadsetBinder(this); } @Override public void start() { Log.i(TAG, "start()"); if (mStarted) { throw new IllegalStateException("start() called twice"); } setComponentAvailable(HFP_AG_IN_CALL_SERVICE, true); Loading @@ -234,12 +216,6 @@ public class HeadsetService extends ProfileService { mIsAptXSwbEnabled, mActiveDevice); } // Step 5: Check if state machine table is empty, crash if not if (mStateMachines.size() > 0) { throw new IllegalStateException( "start(): mStateMachines is not empty, " + mStateMachines.size() + " is already created. Was stop() called properly?"); } // Step 6: Setup broadcast receivers IntentFilter filter = new IntentFilter(); filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY); Loading @@ -247,21 +223,20 @@ public class HeadsetService extends ProfileService { filter.addAction(AudioManager.ACTION_VOLUME_CHANGED); filter.addAction(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY); registerReceiver(mHeadsetReceiver, filter); // Step 7: Mark service as started mStarted = true; } public static boolean isEnabled() { return BluetoothProperties.isProfileHfpAgEnabled().orElse(false); } @Override public IProfileServiceBinder initBinder() { return new BluetoothHeadsetBinder(this); } @Override public void stop() { Log.i(TAG, "stop()"); if (!mStarted) { Log.w(TAG, "stop() called before start()"); // Still return true because it is considered "stopped" and doesn't have any functional // impact on the user return; } // Step 7: Mark service as stopped mStarted = false; // Step 6: Tear down broadcast receivers unregisterReceiver(mHeadsetReceiver); synchronized (mStateMachines) { Loading Loading @@ -323,7 +298,7 @@ public class HeadsetService extends ProfileService { * @return True if the object can accept binder calls, False otherwise */ public boolean isAlive() { return isAvailable() && mStarted; return isAvailable(); } /** Loading Loading @@ -2430,7 +2405,6 @@ public class HeadsetService extends ProfileService { ProfileService.println(sb, "mVirtualCallStarted: " + mVirtualCallStarted); ProfileService.println(sb, "mDialingOutTimeoutEvent: " + mDialingOutTimeoutEvent); ProfileService.println(sb, "mForceScoAudio: " + mForceScoAudio); ProfileService.println(sb, "mStarted: " + mStarted); ProfileService.println(sb, "AudioManager.isBluetoothScoOn(): " + isScoOn); ProfileService.println(sb, "Telecom.isInCall(): " + mSystemInterface.isInCall()); ProfileService.println(sb, "Telecom.isRinging(): " + mSystemInterface.isRinging()); Loading android/app/src/com/android/bluetooth/hfp/HeadsetSystemInterface.java +5 −6 Original line number Diff line number Diff line Loading @@ -37,11 +37,10 @@ import com.android.internal.annotations.VisibleForTesting; import java.util.List; /** * Defines system calls that is used by state machine/service to either send or receive * messages from the Android System. * Defines system calls that is used by state machine/service to either send or receive messages * from the Android System. */ @VisibleForTesting public class HeadsetSystemInterface { class HeadsetSystemInterface { private static final String TAG = HeadsetSystemInterface.class.getSimpleName(); private final HeadsetService mHeadsetService; Loading Loading @@ -78,7 +77,7 @@ public class HeadsetSystemInterface { } /** * Get audio manager. Most audio manager oprations are pass through and therefore are not * Get audio manager. Most audio manager operations are pass through and therefore are not * individually managed by this class * * @return audio manager for setting audio parameters Loading Loading @@ -232,7 +231,7 @@ public class HeadsetSystemInterface { /** * Get the phone number of this device without incall service * * @return emptry if unavailable * @return empty if unavailable */ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) private String getNumberWithoutInCallService() { Loading Loading
android/app/src/com/android/bluetooth/btservice/ProfileService.java +1 −1 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ public abstract class ProfileService extends ContextWrapper { protected abstract IProfileServiceBinder initBinder(); /** Start service */ public abstract void start(); public void start() {} /** Stop service */ public abstract void stop(); Loading
android/app/src/com/android/bluetooth/hfp/HeadsetService.java +12 −38 Original line number Diff line number Diff line Loading @@ -139,11 +139,11 @@ public class HeadsetService extends ProfileService { private final Looper mStateMachinesLooper; private final Handler mStateMachinesThreadHandler; private final HandlerThread mStateMachinesThread; // This is also used as a lock for shared data in HeadsetService private final HeadsetSystemInterface mSystemInterface; private int mMaxHeadsetConnections = 1; private BluetoothDevice mActiveDevice; // This is also used as a lock for shared data in HeadsetService private HeadsetSystemInterface mSystemInterface; private boolean mAudioRouteAllowed = true; // Indicates whether SCO audio needs to be forced to open regardless ANY OTHER restrictions private boolean mForceScoAudio; Loading @@ -157,7 +157,6 @@ public class HeadsetService extends ProfileService { // Timeout when voice recognition is started by remote device @VisibleForTesting static int sStartVrTimeoutMs = 5000; private ArrayList<StateMachineTask> mPendingClccResponses = new ArrayList<>(); private boolean mStarted; private static HeadsetService sHeadsetService; @VisibleForTesting boolean mIsAptXSwbEnabled = false; Loading Loading @@ -192,23 +191,6 @@ public class HeadsetService extends ProfileService { mStateMachinesLooper = mStateMachinesThread.getLooper(); } mStateMachinesThreadHandler = new Handler(mStateMachinesLooper); } public static boolean isEnabled() { return BluetoothProperties.isProfileHfpAgEnabled().orElse(false); } @Override public IProfileServiceBinder initBinder() { return new BluetoothHeadsetBinder(this); } @Override public void start() { Log.i(TAG, "start()"); if (mStarted) { throw new IllegalStateException("start() called twice"); } setComponentAvailable(HFP_AG_IN_CALL_SERVICE, true); Loading @@ -234,12 +216,6 @@ public class HeadsetService extends ProfileService { mIsAptXSwbEnabled, mActiveDevice); } // Step 5: Check if state machine table is empty, crash if not if (mStateMachines.size() > 0) { throw new IllegalStateException( "start(): mStateMachines is not empty, " + mStateMachines.size() + " is already created. Was stop() called properly?"); } // Step 6: Setup broadcast receivers IntentFilter filter = new IntentFilter(); filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY); Loading @@ -247,21 +223,20 @@ public class HeadsetService extends ProfileService { filter.addAction(AudioManager.ACTION_VOLUME_CHANGED); filter.addAction(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY); registerReceiver(mHeadsetReceiver, filter); // Step 7: Mark service as started mStarted = true; } public static boolean isEnabled() { return BluetoothProperties.isProfileHfpAgEnabled().orElse(false); } @Override public IProfileServiceBinder initBinder() { return new BluetoothHeadsetBinder(this); } @Override public void stop() { Log.i(TAG, "stop()"); if (!mStarted) { Log.w(TAG, "stop() called before start()"); // Still return true because it is considered "stopped" and doesn't have any functional // impact on the user return; } // Step 7: Mark service as stopped mStarted = false; // Step 6: Tear down broadcast receivers unregisterReceiver(mHeadsetReceiver); synchronized (mStateMachines) { Loading Loading @@ -323,7 +298,7 @@ public class HeadsetService extends ProfileService { * @return True if the object can accept binder calls, False otherwise */ public boolean isAlive() { return isAvailable() && mStarted; return isAvailable(); } /** Loading Loading @@ -2430,7 +2405,6 @@ public class HeadsetService extends ProfileService { ProfileService.println(sb, "mVirtualCallStarted: " + mVirtualCallStarted); ProfileService.println(sb, "mDialingOutTimeoutEvent: " + mDialingOutTimeoutEvent); ProfileService.println(sb, "mForceScoAudio: " + mForceScoAudio); ProfileService.println(sb, "mStarted: " + mStarted); ProfileService.println(sb, "AudioManager.isBluetoothScoOn(): " + isScoOn); ProfileService.println(sb, "Telecom.isInCall(): " + mSystemInterface.isInCall()); ProfileService.println(sb, "Telecom.isRinging(): " + mSystemInterface.isRinging()); Loading
android/app/src/com/android/bluetooth/hfp/HeadsetSystemInterface.java +5 −6 Original line number Diff line number Diff line Loading @@ -37,11 +37,10 @@ import com.android.internal.annotations.VisibleForTesting; import java.util.List; /** * Defines system calls that is used by state machine/service to either send or receive * messages from the Android System. * Defines system calls that is used by state machine/service to either send or receive messages * from the Android System. */ @VisibleForTesting public class HeadsetSystemInterface { class HeadsetSystemInterface { private static final String TAG = HeadsetSystemInterface.class.getSimpleName(); private final HeadsetService mHeadsetService; Loading Loading @@ -78,7 +77,7 @@ public class HeadsetSystemInterface { } /** * Get audio manager. Most audio manager oprations are pass through and therefore are not * Get audio manager. Most audio manager operations are pass through and therefore are not * individually managed by this class * * @return audio manager for setting audio parameters Loading Loading @@ -232,7 +231,7 @@ public class HeadsetSystemInterface { /** * Get the phone number of this device without incall service * * @return emptry if unavailable * @return empty if unavailable */ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) private String getNumberWithoutInCallService() { Loading