Merge changes Ia1d03ae7,I6ecf0396 into main
* changes:
Build a file in kotlin
Move change-ids in its own separate lib
diff --git a/android/app/src/com/android/bluetooth/le_audio/LeAudioService.java b/android/app/src/com/android/bluetooth/le_audio/LeAudioService.java
index 159c6d4..8c9ca87 100644
--- a/android/app/src/com/android/bluetooth/le_audio/LeAudioService.java
+++ b/android/app/src/com/android/bluetooth/le_audio/LeAudioService.java
@@ -2027,21 +2027,33 @@
private class AudioServerScanCallback extends IScannerCallback.Stub {
// See BluetoothLeScanner.BleScanCallbackWrapper.mScannerId
- int mScannerId = 0;
+ static final int SCANNER_NOT_INITIALIZED = -2;
+ static final int SCANNER_INITIALIZING = -1;
+ int mScannerId = SCANNER_NOT_INITIALIZED;
synchronized void startBackgroundScan() {
- if (mScannerId != 0) {
- Log.d(TAG, "Scanner is already registered with id " + mScannerId);
+ if (mScannerId >= 0) {
+ Log.i(
+ TAG,
+ "startBackgroundScan: Scanner is already registered with id " + mScannerId);
return;
}
+
+ if (mScannerId == SCANNER_INITIALIZING) {
+ Log.i(TAG, "startBackgroundScan: Scanner is already initializing");
+ return;
+ }
+
+ mScannerId = SCANNER_INITIALIZING;
+
mAdapterService
.getBluetoothScanController()
.registerScannerInternal(this, getAttributionSource(), null);
}
synchronized void stopBackgroundScan() {
- if (mScannerId == 0) {
- Log.d(TAG, "Scanner is already unregistered");
+ if (mScannerId < 0) {
+ Log.d(TAG, "Scanner is not running (mScannerId=" + mScannerId + ")");
return;
}
mAdapterService
@@ -2051,11 +2063,16 @@
mAdapterService
.getBluetoothScanController()
.unregisterScannerInternal(mScannerId);
- mScannerId = 0;
+ mScannerId = SCANNER_NOT_INITIALIZED;
}
@Override
public synchronized void onScannerRegistered(int status, int scannerId) {
+ Log.d(TAG, "onScannerRegistered: status: " + status + ", id:" + scannerId);
+ if (status != 0) {
+ mScannerId = SCANNER_NOT_INITIALIZED;
+ return;
+ }
mScannerId = scannerId;
/* Filter we are building here will not match to anything.
diff --git a/android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java b/android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java
index 6efdb17..7bf72bc 100644
--- a/android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java
+++ b/android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java
@@ -51,7 +51,6 @@
import com.android.bluetooth.BluetoothMethodProxy;
import com.android.bluetooth.R;
import com.android.bluetooth.Utils;
-import com.android.bluetooth.flags.Flags;
import com.google.common.annotations.VisibleForTesting;
@@ -234,7 +233,7 @@
case NOTIFY:
synchronized (BluetoothOppNotification.this) {
if (mPendingUpdate > 0 && mUpdateNotificationThread == null) {
- Log.v(TAG, "new notify threadi!");
+ Log.v(TAG, "new notify thread!");
mUpdateNotificationThread = new NotificationUpdateThread();
mUpdateNotificationThread.start();
Log.v(TAG, "send delay message");
diff --git a/android/app/src/com/android/bluetooth/opp/BluetoothOppService.java b/android/app/src/com/android/bluetooth/opp/BluetoothOppService.java
index a8c653d..4bf981a 100644
--- a/android/app/src/com/android/bluetooth/opp/BluetoothOppService.java
+++ b/android/app/src/com/android/bluetooth/opp/BluetoothOppService.java
@@ -51,7 +51,6 @@
import android.media.MediaScannerConnection;
import android.media.MediaScannerConnection.MediaScannerConnectionClient;
import android.net.Uri;
-import android.os.Binder;
import android.os.Handler;
import android.os.Message;
import android.os.Process;
@@ -135,7 +134,7 @@
private BluetoothShareContentObserver mObserver;
/** Class to handle Notification Manager updates */
- @VisibleForTesting BluetoothOppNotification mNotifier;
+ @VisibleForTesting final BluetoothOppNotification mNotifier;
private boolean mPendingUpdate;
@@ -236,28 +235,6 @@
BluetoothStatsLog.BLUETOOTH_CONTENT_PROFILE_ERROR_REPORTED__TYPE__LOG_WARN,
0);
}
- }
-
- public static boolean isEnabled() {
- return BluetoothProperties.isProfileOppEnabled().orElse(false);
- }
-
- @Override
- protected IProfileServiceBinder initBinder() {
- return new OppBinder();
- }
-
- private static class OppBinder extends Binder implements IProfileServiceBinder {
-
- OppBinder() {}
-
- @Override
- public void cleanup() {}
- }
-
- @Override
- public void start() {
- Log.v(TAG, "start()");
setComponentAvailable(OPP_PROVIDER, true);
setComponentAvailable(INCOMING_FILE_CONFIRM_ACTIVITY, true);
@@ -282,6 +259,15 @@
setBluetoothOppService(this);
}
+ public static boolean isEnabled() {
+ return BluetoothProperties.isProfileOppEnabled().orElse(false);
+ }
+
+ @Override
+ protected IProfileServiceBinder initBinder() {
+ return null;
+ }
+
@Override
public void stop() {
if (sBluetoothOppService == null) {
@@ -457,7 +443,7 @@
BluetoothStatsLog
.BLUETOOTH_CONTENT_PROFILE_ERROR_REPORTED__TYPE__EXCEPTION,
7);
- Log.e(TAG, "close tranport error");
+ Log.e(TAG, "close transport error");
}
} else {
Log.i(TAG, "OPP busy! Retry after 1 second");
@@ -623,9 +609,7 @@
}
}
- if (mNotifier != null) {
- mNotifier.cancelOppNotifications();
- }
+ mNotifier.cancelOppNotifications();
}
/* suppose we auto accept an incoming OPUSH connection */
diff --git a/android/app/src/com/android/bluetooth/pan/PanNativeInterface.java b/android/app/src/com/android/bluetooth/pan/PanNativeInterface.java
index 0580c58..cb4f561 100644
--- a/android/app/src/com/android/bluetooth/pan/PanNativeInterface.java
+++ b/android/app/src/com/android/bluetooth/pan/PanNativeInterface.java
@@ -22,41 +22,19 @@
import android.bluetooth.BluetoothProfile;
import android.util.Log;
-import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
/** Provides Bluetooth Pan native interface for the Pan service */
public class PanNativeInterface {
private static final String TAG = PanNativeInterface.class.getSimpleName();
- private PanService mPanService;
- @GuardedBy("INSTANCE_LOCK")
- private static PanNativeInterface sInstance;
+ private final PanService mPanService;
- private static final Object INSTANCE_LOCK = new Object();
-
- private PanNativeInterface() {}
-
- /** Get singleton instance. */
- public static PanNativeInterface getInstance() {
- synchronized (INSTANCE_LOCK) {
- if (sInstance == null) {
- sInstance = new PanNativeInterface();
- }
- return sInstance;
- }
- }
-
- /** Set singleton instance. */
- @VisibleForTesting
- public static void setInstance(PanNativeInterface instance) {
- synchronized (INSTANCE_LOCK) {
- sInstance = instance;
- }
- }
-
- void init(PanService panService) {
+ PanNativeInterface(PanService panService) {
mPanService = panService;
+ }
+
+ void init() {
initializeNative();
}
diff --git a/android/app/src/com/android/bluetooth/pan/PanService.java b/android/app/src/com/android/bluetooth/pan/PanService.java
index ee57196..d59d74e 100644
--- a/android/app/src/com/android/bluetooth/pan/PanService.java
+++ b/android/app/src/com/android/bluetooth/pan/PanService.java
@@ -19,6 +19,10 @@
import static android.Manifest.permission.BLUETOOTH_CONNECT;
import static android.Manifest.permission.BLUETOOTH_PRIVILEGED;
import static android.Manifest.permission.TETHER_PRIVILEGED;
+import static android.bluetooth.BluetoothUtils.logRemoteException;
+
+import static java.util.Objects.requireNonNull;
+import static java.util.Objects.requireNonNullElseGet;
import android.annotation.RequiresPermission;
import android.bluetooth.BluetoothDevice;
@@ -29,7 +33,6 @@
import android.bluetooth.IBluetoothPan;
import android.bluetooth.IBluetoothPanCallback;
import android.content.AttributionSource;
-import android.content.Context;
import android.content.Intent;
import android.content.res.Resources.NotFoundException;
import android.net.TetheringInterface;
@@ -57,53 +60,49 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
/** Provides Bluetooth Pan Device profile, as a service in the Bluetooth application. */
public class PanService extends ProfileService {
private static final String TAG = PanService.class.getSimpleName();
+
private static PanService sPanService;
private static final int BLUETOOTH_MAX_PAN_CONNECTIONS = 5;
- @VisibleForTesting ConcurrentHashMap<BluetoothDevice, BluetoothPanDevice> mPanDevices;
-
- private int mMaxPanDevices;
- private String mPanIfName;
- @VisibleForTesting boolean mIsTethering = false;
- private HashMap<String, IBluetoothPanCallback> mBluetoothTetheringCallbacks;
-
- private TetheringManager mTetheringManager;
- private DatabaseManager mDatabaseManager;
- @VisibleForTesting UserManager mUserManager;
-
private static final int MESSAGE_CONNECT = 1;
private static final int MESSAGE_DISCONNECT = 2;
private static final int MESSAGE_CONNECT_STATE_CHANGED = 11;
+
+ @VisibleForTesting
+ final ConcurrentHashMap<BluetoothDevice, BluetoothPanDevice> mPanDevices =
+ new ConcurrentHashMap<>();
+
+ private final Map<String, IBluetoothPanCallback> mBluetoothTetheringCallbacks = new HashMap<>();
+ private final AdapterService mAdapterService;
+ private final PanNativeInterface mNativeInterface;
+ private final DatabaseManager mDatabaseManager;
+ private final TetheringManager mTetheringManager;
+ private final UserManager mUserManager;
+ private final int mMaxPanDevices;
+
+ private String mPanIfName;
+ @VisibleForTesting boolean mIsTethering = false;
private boolean mTetherOn = false;
-
private BluetoothTetheringNetworkFactory mNetworkFactory;
- private boolean mStarted = false;
- private AdapterService mAdapterService;
-
- @VisibleForTesting PanNativeInterface mNativeInterface;
-
- TetheringManager.TetheringEventCallback mTetheringCallback =
+ final TetheringManager.TetheringEventCallback mTetheringCallback =
new TetheringManager.TetheringEventCallback() {
@Override
public void onError(TetheringInterface iface, int error) {
if (mIsTethering && iface.getType() == TetheringManager.TETHERING_BLUETOOTH) {
- // tethering is fail because of @TetheringIfaceError error.
+ // Tethering fail because of @TetheringIfaceError error.
Log.e(TAG, "Error setting up tether interface: " + error);
- for (Map.Entry device : mPanDevices.entrySet()) {
+ for (BluetoothDevice device : mPanDevices.keySet()) {
mNativeInterface.disconnect(
Flags.panUseIdentityAddress()
- ? Utils.getByteBrEdrAddress(
- (BluetoothDevice) device.getKey())
- : Utils.getByteAddress(
- (BluetoothDevice) device.getKey()));
+ ? Utils.getByteBrEdrAddress(mAdapterService, device)
+ : Utils.getByteAddress(device));
}
mPanDevices.clear();
mIsTethering = false;
@@ -111,8 +110,35 @@
}
};
- public PanService(Context ctx) {
- super(ctx);
+ public PanService(AdapterService adapterService) {
+ this(adapterService, null);
+ }
+
+ @VisibleForTesting
+ PanService(AdapterService adapterService, PanNativeInterface nativeInterface) {
+ super(requireNonNull(adapterService));
+ mAdapterService = adapterService;
+ mDatabaseManager = requireNonNull(mAdapterService.getDatabase());
+ mNativeInterface =
+ requireNonNullElseGet(nativeInterface, () -> new PanNativeInterface(this));
+ mUserManager = requireNonNull(getSystemService(UserManager.class));
+ mTetheringManager = requireNonNull(getSystemService(TetheringManager.class));
+
+ int maxPanDevice;
+ try {
+ maxPanDevice =
+ getResources()
+ .getInteger(com.android.bluetooth.R.integer.config_max_pan_devices);
+ } catch (NotFoundException e) {
+ maxPanDevice = BLUETOOTH_MAX_PAN_CONNECTIONS;
+ }
+ mMaxPanDevices = maxPanDevice;
+
+ mNativeInterface.init();
+
+ mTetheringManager.registerTetheringEventCallback(
+ new HandlerExecutor(new Handler(Looper.getMainLooper())), mTetheringCallback);
+ setPanService(this);
}
public static boolean isEnabled() {
@@ -143,50 +169,8 @@
}
@Override
- public void start() {
- mAdapterService =
- Objects.requireNonNull(
- AdapterService.getAdapterService(),
- "AdapterService cannot be null when PanService starts");
- mDatabaseManager =
- Objects.requireNonNull(
- AdapterService.getAdapterService().getDatabase(),
- "DatabaseManager cannot be null when PanService starts");
- mNativeInterface =
- Objects.requireNonNull(
- PanNativeInterface.getInstance(),
- "PanNativeInterface cannot be null when PanService starts");
-
- mBluetoothTetheringCallbacks = new HashMap<>();
- mPanDevices = new ConcurrentHashMap<BluetoothDevice, BluetoothPanDevice>();
- try {
- mMaxPanDevices =
- getResources()
- .getInteger(com.android.bluetooth.R.integer.config_max_pan_devices);
- } catch (NotFoundException e) {
- mMaxPanDevices = BLUETOOTH_MAX_PAN_CONNECTIONS;
- }
- mNativeInterface.init(this);
-
- mUserManager = getSystemService(UserManager.class);
-
- mTetheringManager = getSystemService(TetheringManager.class);
- mTetheringManager.registerTetheringEventCallback(
- new HandlerExecutor(new Handler(Looper.getMainLooper())), mTetheringCallback);
- setPanService(this);
- mStarted = true;
- }
-
- @Override
public void stop() {
- if (!mStarted) {
- Log.w(TAG, "stop() called before start()");
- return;
- }
- if (mTetheringManager != null) {
- mTetheringManager.unregisterTetheringEventCallback(mTetheringCallback);
- mTetheringManager = null;
- }
+ mTetheringManager.unregisterTetheringEventCallback(mTetheringCallback);
mNativeInterface.cleanup();
mHandler.removeCallbacksAndMessages(null);
}
@@ -196,29 +180,25 @@
// TODO(b/72948646): this should be moved to stop()
setPanService(null);
- mUserManager = null;
-
- if (mPanDevices != null) {
- int[] desiredStates = {
- BluetoothProfile.STATE_CONNECTING,
- BluetoothProfile.STATE_CONNECTED,
- BluetoothProfile.STATE_DISCONNECTING
- };
- List<BluetoothDevice> devList = getDevicesMatchingConnectionStates(desiredStates);
- for (BluetoothDevice device : devList) {
- BluetoothPanDevice panDevice = mPanDevices.get(device);
- Log.d(TAG, "panDevice: " + panDevice + " device address: " + device);
- if (panDevice != null) {
- handlePanDeviceStateChange(
- device,
- mPanIfName,
- BluetoothProfile.STATE_DISCONNECTED,
- panDevice.mLocalRole,
- panDevice.mRemoteRole);
- }
+ int[] desiredStates = {
+ BluetoothProfile.STATE_CONNECTING,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.STATE_DISCONNECTING
+ };
+ List<BluetoothDevice> devList = getDevicesMatchingConnectionStates(desiredStates);
+ for (BluetoothDevice device : devList) {
+ BluetoothPanDevice panDevice = mPanDevices.get(device);
+ Log.d(TAG, "panDevice: " + panDevice + " device address: " + device);
+ if (panDevice != null) {
+ handlePanDeviceStateChange(
+ device,
+ mPanIfName,
+ BluetoothProfile.STATE_DISCONNECTED,
+ panDevice.mLocalRole,
+ panDevice.mRemoteRole);
}
- mPanDevices.clear();
}
+ mPanDevices.clear();
}
private final Handler mHandler =
@@ -230,7 +210,8 @@
BluetoothDevice connectDevice = (BluetoothDevice) msg.obj;
if (!mNativeInterface.connect(
Flags.identityAddressNullIfNotKnown()
- ? Utils.getByteBrEdrAddress(connectDevice)
+ ? Utils.getByteBrEdrAddress(
+ mAdapterService, connectDevice)
: mAdapterService.getByteIdentityAddress(
connectDevice))) {
handlePanDeviceStateChange(
@@ -251,7 +232,8 @@
BluetoothDevice disconnectDevice = (BluetoothDevice) msg.obj;
if (!mNativeInterface.disconnect(
Flags.identityAddressNullIfNotKnown()
- ? Utils.getByteBrEdrAddress(disconnectDevice)
+ ? Utils.getByteBrEdrAddress(
+ mAdapterService, disconnectDevice)
: mAdapterService.getByteIdentityAddress(
disconnectDevice))) {
handlePanDeviceStateChange(
@@ -663,7 +645,7 @@
mPanDevices.remove(device);
mNativeInterface.disconnect(
Flags.panUseIdentityAddress()
- ? Utils.getByteBrEdrAddress(device)
+ ? Utils.getByteBrEdrAddress(mAdapterService, device)
: Utils.getByteAddress(device));
return;
}
@@ -675,7 +657,7 @@
cb.onAvailable(iface);
}
} catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
+ logRemoteException(TAG, e);
}
}
} else if (state == BluetoothProfile.STATE_DISCONNECTED) {
@@ -690,12 +672,12 @@
cb.onUnavailable();
}
} catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
+ logRemoteException(TAG, e);
}
mIsTethering = false;
}
}
- } else if (mStarted) {
+ } else {
// PANU Role = reverse Tether
Log.d(
TAG,
diff --git a/android/app/src/com/android/bluetooth/sap/SapService.java b/android/app/src/com/android/bluetooth/sap/SapService.java
index 6401b27..8615534 100644
--- a/android/app/src/com/android/bluetooth/sap/SapService.java
+++ b/android/app/src/com/android/bluetooth/sap/SapService.java
@@ -19,6 +19,8 @@
import static android.Manifest.permission.BLUETOOTH_CONNECT;
import static android.Manifest.permission.BLUETOOTH_PRIVILEGED;
+import static java.util.Objects.requireNonNull;
+
import android.annotation.RequiresPermission;
import android.annotation.SuppressLint;
import android.app.AlarmManager;
@@ -60,15 +62,10 @@
import java.util.List;
public class SapService extends ProfileService implements AdapterService.BluetoothStateCallback {
+ private static final String TAG = "SapService";
private static final String SDP_SAP_SERVICE_NAME = "SIM Access";
private static final int SDP_SAP_VERSION = 0x0102;
- private static final String TAG = "SapService";
-
- /**
- * To log debug/verbose in SAP, use the command "setprop log.tag.SapService DEBUG" or "setprop
- * log.tag.SapService VERBOSE" and then "adb root" + "adb shell "stop; start""
- */
/* Message ID's */
private static final int START_LISTENER = 1;
@@ -100,8 +97,9 @@
"com.android.bluetooth.sap.USER_CONFIRM_TIMEOUT";
private static final int USER_CONFIRM_TIMEOUT_VALUE = 25000;
+ private final AdapterService mAdapterService;
+
private PowerManager.WakeLock mWakeLock = null;
- private AdapterService mAdapterService;
private SocketAcceptThread mAcceptThread = null;
private BluetoothServerSocket mServerSocket = null;
private int mSdpHandle = -1;
@@ -113,9 +111,7 @@
private SapServer mSapServer = null;
private AlarmManager mAlarmManager = null;
private boolean mRemoveTimeoutMsg = false;
-
private boolean mIsWaitingAuthorization = false;
- private boolean mIsRegistered = false;
private static SapService sSapService;
@@ -123,9 +119,22 @@
BluetoothUuid.SAP,
};
- public SapService(Context ctx) {
- super(ctx);
+ public SapService(AdapterService adapterService) {
+ super(requireNonNull(adapterService));
+ mAdapterService = adapterService;
BluetoothSap.invalidateBluetoothGetConnectionStateCache();
+
+ IntentFilter filter = new IntentFilter();
+ filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
+ filter.addAction(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY);
+ filter.addAction(USER_CONFIRM_TIMEOUT_ACTION);
+
+ registerReceiver(mSapReceiver, filter);
+
+ mAdapterService.registerBluetoothStateCallback(getMainExecutor(), this);
+ // start RFCOMM listener
+ mSessionStatusHandler.sendMessage(mSessionStatusHandler.obtainMessage(START_LISTENER));
+ setSapService(this);
}
public static boolean isEnabled() {
@@ -148,7 +157,7 @@
private void removeSdpRecord() {
SdpManagerNativeInterface nativeInterface = SdpManagerNativeInterface.getInstance();
- if (mAdapterService != null && mSdpHandle >= 0 && nativeInterface.isAvailable()) {
+ if (mSdpHandle >= 0 && nativeInterface.isAvailable()) {
Log.v(TAG, "Removing SDP record handle: " + mSdpHandle);
nativeInterface.removeSdpRecord(mSdpHandle);
mSdpHandle = -1;
@@ -203,9 +212,6 @@
if (!initSocketOK) {
// Need to break out of this loop if BT is being turned off.
- if (mAdapterService == null) {
- break;
- }
int state = mAdapterService.getState();
if ((state != BluetoothAdapter.STATE_TURNING_ON)
&& (state != BluetoothAdapter.STATE_ON)) {
@@ -636,7 +642,7 @@
Log.d(TAG, "Saved connectionPolicy " + device + " = " + connectionPolicy);
enforceCallingOrSelfPermission(
BLUETOOTH_PRIVILEGED, "Need BLUETOOTH_PRIVILEGED permission");
- AdapterService.getAdapterService()
+ mAdapterService
.getDatabase()
.setProfileConnectionPolicy(device, BluetoothProfile.SAP, connectionPolicy);
if (connectionPolicy == BluetoothProfile.CONNECTION_POLICY_FORBIDDEN) {
@@ -659,7 +665,7 @@
public int getConnectionPolicy(BluetoothDevice device) {
enforceCallingOrSelfPermission(
BLUETOOTH_PRIVILEGED, "Need BLUETOOTH_PRIVILEGED permission");
- return AdapterService.getAdapterService()
+ return mAdapterService
.getDatabase()
.getProfileConnectionPolicy(device, BluetoothProfile.SAP);
}
@@ -670,41 +676,10 @@
}
@Override
- public void start() {
- Log.v(TAG, "start()");
- IntentFilter filter = new IntentFilter();
- filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
- filter.addAction(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY);
- filter.addAction(USER_CONFIRM_TIMEOUT_ACTION);
-
- try {
- registerReceiver(mSapReceiver, filter);
- mIsRegistered = true;
- } catch (Exception e) {
- Log.w(TAG, "Unable to register sap receiver", e);
- }
- mInterrupted = false;
- mAdapterService = AdapterService.getAdapterService();
- mAdapterService.registerBluetoothStateCallback(getMainExecutor(), this);
- // start RFCOMM listener
- mSessionStatusHandler.sendMessage(mSessionStatusHandler.obtainMessage(START_LISTENER));
- setSapService(this);
- }
-
- @Override
public void stop() {
Log.v(TAG, "stop()");
- if (!mIsRegistered) {
- Log.i(TAG, "Avoid unregister when receiver it is not registered");
- return;
- }
setSapService(null);
- try {
- mIsRegistered = false;
- unregisterReceiver(mSapReceiver);
- } catch (Exception e) {
- Log.w(TAG, "Unable to unregister sap receiver", e);
- }
+ unregisterReceiver(mSapReceiver);
mAdapterService.unregisterBluetoothStateCallback(this);
setState(BluetoothSap.STATE_DISCONNECTED, BluetoothSap.RESULT_CANCELED);
sendShutdownMessage();
diff --git a/android/app/tests/unit/src/com/android/bluetooth/btservice/ProfileServiceTest.java b/android/app/tests/unit/src/com/android/bluetooth/btservice/ProfileServiceTest.java
index 2e7225e..1e615e7 100644
--- a/android/app/tests/unit/src/com/android/bluetooth/btservice/ProfileServiceTest.java
+++ b/android/app/tests/unit/src/com/android/bluetooth/btservice/ProfileServiceTest.java
@@ -44,7 +44,6 @@
import com.android.bluetooth.hid.HidDeviceNativeInterface;
import com.android.bluetooth.hid.HidHostNativeInterface;
import com.android.bluetooth.le_audio.LeAudioNativeInterface;
-import com.android.bluetooth.pan.PanNativeInterface;
import org.junit.After;
import org.junit.Assert;
@@ -89,7 +88,6 @@
@Mock private HearingAidNativeInterface mHearingAidNativeInterface;
@Mock private HidDeviceNativeInterface mHidDeviceNativeInterface;
@Mock private HidHostNativeInterface mHidHostNativeInterface;
- @Mock private PanNativeInterface mPanNativeInterface;
@Mock private LeAudioNativeInterface mLeAudioInterface;
private void setProfileState(int profile, int state) {
@@ -155,6 +153,7 @@
&& profile != BluetoothProfile.VOLUME_CONTROL
&& profile != BluetoothProfile.CSIP_SET_COORDINATOR
&& profile != BluetoothProfile.GATT
+ && profile != BluetoothProfile.PAN
&& profile != BluetoothProfile.A2DP)
.toArray();
TestUtils.setAdapterService(mAdapterService);
@@ -169,7 +168,6 @@
HearingAidNativeInterface.setInstance(mHearingAidNativeInterface);
HidDeviceNativeInterface.setInstance(mHidDeviceNativeInterface);
HidHostNativeInterface.setInstance(mHidHostNativeInterface);
- PanNativeInterface.setInstance(mPanNativeInterface);
LeAudioNativeInterface.setInstance(mLeAudioInterface);
}
@@ -187,7 +185,6 @@
HearingAidNativeInterface.setInstance(null);
HidDeviceNativeInterface.setInstance(null);
HidHostNativeInterface.setInstance(null);
- PanNativeInterface.setInstance(null);
LeAudioNativeInterface.setInstance(null);
}
diff --git a/android/app/tests/unit/src/com/android/bluetooth/opp/BluetoothOppServiceCleanupTest.java b/android/app/tests/unit/src/com/android/bluetooth/opp/BluetoothOppServiceCleanupTest.java
index 2183c19..935c1bf4 100644
--- a/android/app/tests/unit/src/com/android/bluetooth/opp/BluetoothOppServiceCleanupTest.java
+++ b/android/app/tests/unit/src/com/android/bluetooth/opp/BluetoothOppServiceCleanupTest.java
@@ -61,7 +61,6 @@
BluetoothOppService service = null;
try {
service = new BluetoothOppService(adapterService);
- service.start();
service.setAvailable(true);
// Call stop while UpdateThread is running.
diff --git a/android/app/tests/unit/src/com/android/bluetooth/opp/BluetoothOppServiceTest.java b/android/app/tests/unit/src/com/android/bluetooth/opp/BluetoothOppServiceTest.java
index 7e54701..dd14319 100644
--- a/android/app/tests/unit/src/com/android/bluetooth/opp/BluetoothOppServiceTest.java
+++ b/android/app/tests/unit/src/com/android/bluetooth/opp/BluetoothOppServiceTest.java
@@ -81,7 +81,6 @@
AdapterService adapterService = new AdapterService(mTargetContext);
mService = new BluetoothOppService(adapterService);
- mService.start();
mService.setAvailable(true);
mIsBluetoothOppServiceStarted = true;
diff --git a/android/app/tests/unit/src/com/android/bluetooth/pan/PanServiceTest.java b/android/app/tests/unit/src/com/android/bluetooth/pan/PanServiceTest.java
index d2fddd8..37927d2 100644
--- a/android/app/tests/unit/src/com/android/bluetooth/pan/PanServiceTest.java
+++ b/android/app/tests/unit/src/com/android/bluetooth/pan/PanServiceTest.java
@@ -32,6 +32,7 @@
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.net.TetheringInterface;
+import android.net.TetheringManager;
import android.os.UserManager;
import androidx.test.InstrumentationRegistry;
@@ -55,15 +56,6 @@
@MediumTest
@RunWith(AndroidJUnit4.class)
public class PanServiceTest {
- private static final String REMOTE_DEVICE_ADDRESS = "00:00:00:00:00:00";
- private static final byte[] REMOTE_DEVICE_ADDRESS_AS_ARRAY = new byte[] {0, 0, 0, 0, 0, 0};
-
- private static final int TIMEOUT_MS = 5_000;
-
- private PanService mService = null;
- private BluetoothAdapter mAdapter = null;
- private BluetoothDevice mRemoteDevice;
-
@Rule public MockitoRule mockitoRule = MockitoJUnit.rule();
@Mock private AdapterService mAdapterService;
@@ -71,31 +63,34 @@
@Mock private PanNativeInterface mNativeInterface;
@Mock private UserManager mMockUserManager;
- @Before
- public void setUp() throws Exception {
- Context targetContext = InstrumentationRegistry.getTargetContext();
- TestUtils.setAdapterService(mAdapterService);
- doReturn(mDatabaseManager).when(mAdapterService).getDatabase();
- PanNativeInterface.setInstance(mNativeInterface);
- mService = new PanService(targetContext);
- mService.start();
- mService.setAvailable(true);
+ private static final byte[] REMOTE_DEVICE_ADDRESS_AS_ARRAY = new byte[] {0, 0, 0, 0, 0, 0};
- // Try getting the Bluetooth adapter
- mAdapter = BluetoothAdapter.getDefaultAdapter();
- assertThat(mAdapter).isNotNull();
- mService.mUserManager = mMockUserManager;
- mRemoteDevice = mAdapter.getRemoteDevice(REMOTE_DEVICE_ADDRESS);
+ private static final int TIMEOUT_MS = 5_000;
+
+ private final BluetoothAdapter mAdapter = BluetoothAdapter.getDefaultAdapter();
+ private final BluetoothDevice mRemoteDevice = TestUtils.getTestDevice(mAdapter, 0);
+ private final Context mTargetContext = InstrumentationRegistry.getTargetContext();
+
+ private PanService mService;
+
+ @Before
+ public void setUp() {
+ doReturn(mTargetContext.getResources()).when(mAdapterService).getResources();
+ doReturn(mDatabaseManager).when(mAdapterService).getDatabase();
+ TestUtils.mockGetSystemService(
+ mAdapterService, Context.USER_SERVICE, UserManager.class, mMockUserManager);
+ TestUtils.mockGetSystemService(
+ mAdapterService, Context.TETHERING_SERVICE, TetheringManager.class);
+
+ mService = new PanService(mAdapterService, mNativeInterface);
+ mService.setAvailable(true);
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
mService.stop();
mService.cleanup();
- PanNativeInterface.setInstance(null);
- mService = PanService.getPanService();
- assertThat(mService).isNull();
- TestUtils.clearAdapterService(mAdapterService);
+ assertThat(PanService.getPanService()).isNull();
}
@Test
diff --git a/android/app/tests/unit/src/com/android/bluetooth/sap/SapServiceTest.java b/android/app/tests/unit/src/com/android/bluetooth/sap/SapServiceTest.java
index 63a52d7..6da23ea 100644
--- a/android/app/tests/unit/src/com/android/bluetooth/sap/SapServiceTest.java
+++ b/android/app/tests/unit/src/com/android/bluetooth/sap/SapServiceTest.java
@@ -18,17 +18,16 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
-import android.content.Context;
import android.content.Intent;
import android.os.Looper;
import androidx.test.filters.MediumTest;
-import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import com.android.bluetooth.TestUtils;
@@ -47,40 +46,32 @@
@MediumTest
@RunWith(AndroidJUnit4.class)
public class SapServiceTest {
- private SapService mService = null;
- private BluetoothAdapter mAdapter = null;
- private Context mTargetContext;
-
@Rule public MockitoRule mockitoRule = MockitoJUnit.rule();
@Mock private AdapterService mAdapterService;
@Mock private DatabaseManager mDatabaseManager;
- private BluetoothDevice mDevice;
+
+ private final BluetoothAdapter mAdapter = BluetoothAdapter.getDefaultAdapter();
+ private final BluetoothDevice mDevice = TestUtils.getTestDevice(mAdapter, 0);
+
+ private SapService mService;
@Before
- public void setUp() throws Exception {
- mTargetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
- TestUtils.setAdapterService(mAdapterService);
+ public void setUp() {
+ doReturn(mDatabaseManager).when(mAdapterService).getDatabase();
if (Looper.myLooper() == null) {
Looper.prepare();
}
- mService = new SapService(mTargetContext);
- mService.start();
+ mService = new SapService(mAdapterService);
mService.setAvailable(true);
- // Try getting the Bluetooth adapter
- mAdapter = BluetoothAdapter.getDefaultAdapter();
- assertThat(mAdapter).isNotNull();
- mDevice = TestUtils.getTestDevice(mAdapter, 0);
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
mService.stop();
- mService = SapService.getSapService();
- assertThat(mService).isNull();
- TestUtils.clearAdapterService(mAdapterService);
+ assertThat(SapService.getSapService()).isNull();
}
@Test
@@ -89,22 +80,9 @@
assertThat(mService.getConnectedDevices()).isEmpty();
}
- /** Test stop SAP Service */
- @Test
- public void testStopSapService() throws Exception {
- // SAP Service is already running: test stop(). Note: must be done on the main thread
- InstrumentationRegistry.getInstrumentation()
- .runOnMainSync(
- () -> {
- mService.stop();
- mService.start();
- });
- }
-
/** Test get connection policy for BluetoothDevice */
@Test
public void testGetConnectionPolicy() {
- when(mAdapterService.getDatabase()).thenReturn(mDatabaseManager);
when(mDatabaseManager.getProfileConnectionPolicy(mDevice, BluetoothProfile.SAP))
.thenReturn(BluetoothProfile.CONNECTION_POLICY_UNKNOWN);
assertThat(mService.getConnectionPolicy(mDevice))
@@ -137,6 +115,6 @@
Intent intent = new Intent(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY);
intent.putExtra(
BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE, BluetoothDevice.REQUEST_TYPE_SIM_ACCESS);
- mService.mSapReceiver.onReceive(mTargetContext, intent);
+ mService.mSapReceiver.onReceive(null, intent);
}
}
diff --git a/flags/Android.bp b/flags/Android.bp
index 694fd7a..8a1dc66 100644
--- a/flags/Android.bp
+++ b/flags/Android.bp
@@ -19,7 +19,6 @@
"btif_dm.aconfig",
"btm_ble.aconfig",
"connectivity.aconfig",
- "device_iot_config.aconfig",
"dis.aconfig",
"framework.aconfig",
"gap.aconfig",
diff --git a/flags/BUILD.gn b/flags/BUILD.gn
index 6c7185a..9f96d85 100644
--- a/flags/BUILD.gn
+++ b/flags/BUILD.gn
@@ -12,7 +12,6 @@
"btif_dm.aconfig",
"btm_ble.aconfig",
"connectivity.aconfig",
- "device_iot_config.aconfig",
"dis.aconfig",
"framework.aconfig",
"gap.aconfig",
diff --git a/flags/device_iot_config.aconfig b/flags/device_iot_config.aconfig
deleted file mode 100644
index a0fe92c..0000000
--- a/flags/device_iot_config.aconfig
+++ /dev/null
@@ -1,9 +0,0 @@
-package: "com.android.bluetooth.flags"
-container: "com.android.bt"
-
-flag {
- name: "device_iot_config_logging"
- namespace: "bluetooth"
- description: "Enable device IOT information storage."
- bug: "290844229"
-}
diff --git a/flags/security.aconfig b/flags/security.aconfig
index 3cb969e..ddfd786 100644
--- a/flags/security.aconfig
+++ b/flags/security.aconfig
@@ -36,10 +36,10 @@
}
flag {
- name: "le_enc_on_reconnection"
+ name: "le_enc_on_reconnect"
namespace: "bluetooth"
description: "Encrypt LE link on reconnection with bonded devices"
- bug: "356201480"
+ bug: "388864535"
metadata {
purpose: PURPOSE_BUGFIX
}
diff --git a/framework/java/android/bluetooth/BluetoothSocket.java b/framework/java/android/bluetooth/BluetoothSocket.java
index e5b6ea1..97bdf59 100644
--- a/framework/java/android/bluetooth/BluetoothSocket.java
+++ b/framework/java/android/bluetooth/BluetoothSocket.java
@@ -978,7 +978,7 @@
if (mL2capBuffer.remaining() == 0) {
if (VDBG) Log.v(TAG, "l2cap buffer empty, refilling...");
if (fillL2capRxBuffer() == -1) {
- throw new IOException("bt socket closed, read return: " + ret);
+ return -1;
}
}
if (bytesToRead > mL2capBuffer.remaining()) {
diff --git a/system/bta/le_audio/le_audio_client_test.cc b/system/bta/le_audio/le_audio_client_test.cc
index 2828ef7..3e14dca 100644
--- a/system/bta/le_audio/le_audio_client_test.cc
+++ b/system/bta/le_audio/le_audio_client_test.cc
@@ -12245,86 +12245,92 @@
// Stop
StopStreaming(group_id, true);
- // Check if cache configuration is still present
- ASSERT_TRUE(group->GetCachedConfiguration(types::LeAudioContextType::CONVERSATIONAL)
- ->confs.get(le_audio::types::kLeAudioDirectionSink)
- .size());
- ASSERT_TRUE(group->GetCachedConfiguration(types::LeAudioContextType::CONVERSATIONAL)
- ->confs.get(le_audio::types::kLeAudioDirectionSource)
- .size());
+ if (com::android::bluetooth::flags::leaudio_use_audio_recording_listener()) {
+ // simulate suspend timeout passed, alarm executing
+ fake_osi_alarm_set_on_mloop_.cb(fake_osi_alarm_set_on_mloop_.data);
+ SyncOnMainLoop();
+ } else {
+ // Check if cache configuration is still present
+ ASSERT_TRUE(group->GetCachedConfiguration(types::LeAudioContextType::CONVERSATIONAL)
+ ->confs.get(le_audio::types::kLeAudioDirectionSink)
+ .size());
+ ASSERT_TRUE(group->GetCachedConfiguration(types::LeAudioContextType::CONVERSATIONAL)
+ ->confs.get(le_audio::types::kLeAudioDirectionSource)
+ .size());
- // Release, Sink HAL client should remain in monitor mode
- EXPECT_CALL(*mock_le_audio_source_hal_client_, Stop()).Times(1);
- EXPECT_CALL(*mock_le_audio_source_hal_client_, OnDestroyed()).Times(1);
- EXPECT_CALL(*mock_le_audio_sink_hal_client_, Stop()).Times(0);
- EXPECT_CALL(*mock_le_audio_sink_hal_client_, OnDestroyed()).Times(0);
- LeAudioClient::Get()->GroupSetActive(bluetooth::groups::kGroupUnknown);
- SyncOnMainLoop();
+ // Release, Sink HAL client should remain in monitor mode
+ EXPECT_CALL(*mock_le_audio_source_hal_client_, Stop()).Times(1);
+ EXPECT_CALL(*mock_le_audio_source_hal_client_, OnDestroyed()).Times(1);
+ EXPECT_CALL(*mock_le_audio_sink_hal_client_, Stop()).Times(0);
+ EXPECT_CALL(*mock_le_audio_sink_hal_client_, OnDestroyed()).Times(0);
+ LeAudioClient::Get()->GroupSetActive(bluetooth::groups::kGroupUnknown);
+ SyncOnMainLoop();
- Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
- Mock::VerifyAndClearExpectations(mock_le_audio_source_hal_client_);
- Mock::VerifyAndClearExpectations(mock_le_audio_sink_hal_client_);
+ Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
+ Mock::VerifyAndClearExpectations(mock_le_audio_source_hal_client_);
+ Mock::VerifyAndClearExpectations(mock_le_audio_sink_hal_client_);
- // Re-initialize mock for destroyed hal client
- RegisterSourceHalClientMock();
+ // Re-initialize mock for destroyed hal client
+ RegisterSourceHalClientMock();
- // Setting group inactive, shall not change cached configuration
- ASSERT_TRUE(group->GetCachedConfiguration(types::LeAudioContextType::CONVERSATIONAL)
- ->confs.get(le_audio::types::kLeAudioDirectionSink)
- .size());
- ASSERT_TRUE(group->GetCachedConfiguration(types::LeAudioContextType::CONVERSATIONAL)
- ->confs.get(le_audio::types::kLeAudioDirectionSource)
- .size());
+ // Setting group inactive, shall not change cached configuration
+ ASSERT_TRUE(group->GetCachedConfiguration(types::LeAudioContextType::CONVERSATIONAL)
+ ->confs.get(le_audio::types::kLeAudioDirectionSink)
+ .size());
+ ASSERT_TRUE(group->GetCachedConfiguration(types::LeAudioContextType::CONVERSATIONAL)
+ ->confs.get(le_audio::types::kLeAudioDirectionSource)
+ .size());
- EXPECT_CALL(mock_audio_hal_client_callbacks_,
- OnUnicastMonitorModeStatus(bluetooth::le_audio::types::kLeAudioDirectionSink,
- UnicastMonitorModeStatus::STREAMING_REQUESTED))
- .Times(1);
+ EXPECT_CALL(mock_audio_hal_client_callbacks_,
+ OnUnicastMonitorModeStatus(bluetooth::le_audio::types::kLeAudioDirectionSink,
+ UnicastMonitorModeStatus::STREAMING_REQUESTED))
+ .Times(1);
- // Start streaming to trigger next group going to IDLE state
- LocalAudioSinkResume();
+ // Start streaming to trigger next group going to IDLE state
+ LocalAudioSinkResume();
- EXPECT_CALL(*mock_le_audio_source_hal_client_, Start(_, _, _)).Times(1);
- EXPECT_CALL(*mock_le_audio_sink_hal_client_, Start(_, _, _)).Times(1);
- LeAudioClient::Get()->GroupSetActive(group_id);
- Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
- SyncOnMainLoop();
+ EXPECT_CALL(*mock_le_audio_source_hal_client_, Start(_, _, _)).Times(1);
+ EXPECT_CALL(*mock_le_audio_sink_hal_client_, Start(_, _, _)).Times(1);
+ LeAudioClient::Get()->GroupSetActive(group_id);
+ Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
+ SyncOnMainLoop();
- Mock::VerifyAndClearExpectations(mock_le_audio_source_hal_client_);
+ Mock::VerifyAndClearExpectations(mock_le_audio_source_hal_client_);
- StartStreaming(AUDIO_USAGE_VOICE_COMMUNICATION, AUDIO_CONTENT_TYPE_SPEECH, group_id);
- SyncOnMainLoop();
- Mock::VerifyAndClearExpectations(mock_le_audio_source_hal_client_);
+ StartStreaming(AUDIO_USAGE_VOICE_COMMUNICATION, AUDIO_CONTENT_TYPE_SPEECH, group_id);
+ SyncOnMainLoop();
+ Mock::VerifyAndClearExpectations(mock_le_audio_source_hal_client_);
- // Stop streaming and expect Service to be informed about straming suspension
- EXPECT_CALL(mock_audio_hal_client_callbacks_,
- OnUnicastMonitorModeStatus(bluetooth::le_audio::types::kLeAudioDirectionSink,
- UnicastMonitorModeStatus::STREAMING_SUSPENDED))
- .Times(1);
+ // Stop streaming and expect Service to be informed about straming suspension
+ EXPECT_CALL(mock_audio_hal_client_callbacks_,
+ OnUnicastMonitorModeStatus(bluetooth::le_audio::types::kLeAudioDirectionSink,
+ UnicastMonitorModeStatus::STREAMING_SUSPENDED))
+ .Times(1);
- // Stop
- StopStreaming(group_id, true);
+ // Stop
+ StopStreaming(group_id, true);
- // Release, Sink HAL client should remain in monitor mode
- EXPECT_CALL(*mock_le_audio_source_hal_client_, Stop()).Times(1);
- EXPECT_CALL(*mock_le_audio_source_hal_client_, OnDestroyed()).Times(1);
- EXPECT_CALL(*mock_le_audio_sink_hal_client_, Stop()).Times(0);
- EXPECT_CALL(*mock_le_audio_sink_hal_client_, OnDestroyed()).Times(0);
- LeAudioClient::Get()->GroupSetActive(bluetooth::groups::kGroupUnknown);
- SyncOnMainLoop();
+ // Release, Sink HAL client should remain in monitor mode
+ EXPECT_CALL(*mock_le_audio_source_hal_client_, Stop()).Times(1);
+ EXPECT_CALL(*mock_le_audio_source_hal_client_, OnDestroyed()).Times(1);
+ EXPECT_CALL(*mock_le_audio_sink_hal_client_, Stop()).Times(0);
+ EXPECT_CALL(*mock_le_audio_sink_hal_client_, OnDestroyed()).Times(0);
+ LeAudioClient::Get()->GroupSetActive(bluetooth::groups::kGroupUnknown);
+ SyncOnMainLoop();
- Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
- Mock::VerifyAndClearExpectations(mock_le_audio_source_hal_client_);
- Mock::VerifyAndClearExpectations(mock_le_audio_sink_hal_client_);
+ Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
+ Mock::VerifyAndClearExpectations(mock_le_audio_source_hal_client_);
+ Mock::VerifyAndClearExpectations(mock_le_audio_sink_hal_client_);
- // De-activate monitoring mode
- EXPECT_CALL(*mock_le_audio_sink_hal_client_, Stop()).Times(1);
- EXPECT_CALL(*mock_le_audio_sink_hal_client_, OnDestroyed()).Times(1);
- do_in_main_thread(base::BindOnce(
- &LeAudioClient::SetUnicastMonitorMode, base::Unretained(LeAudioClient::Get()),
- bluetooth::le_audio::types::kLeAudioDirectionSink, false /* enable */));
- SyncOnMainLoop();
- Mock::VerifyAndClearExpectations(mock_le_audio_sink_hal_client_);
+ // De-activate monitoring mode
+ EXPECT_CALL(*mock_le_audio_sink_hal_client_, Stop()).Times(1);
+ EXPECT_CALL(*mock_le_audio_sink_hal_client_, OnDestroyed()).Times(1);
+ do_in_main_thread(base::BindOnce(
+ &LeAudioClient::SetUnicastMonitorMode, base::Unretained(LeAudioClient::Get()),
+ bluetooth::le_audio::types::kLeAudioDirectionSink, false /* enable */));
+ SyncOnMainLoop();
+ Mock::VerifyAndClearExpectations(mock_le_audio_sink_hal_client_);
+ }
}
TEST_F(UnicastTestHandoverMode, SetSinkMonitorModeWhileUnicastIsInactive) {
@@ -12392,33 +12398,39 @@
// Stop
StopStreaming(group_id, true);
- // Check if cache configuration is still present
- ASSERT_TRUE(group->GetCachedConfiguration(types::LeAudioContextType::CONVERSATIONAL)
- ->confs.get(le_audio::types::kLeAudioDirectionSink)
- .size());
- ASSERT_TRUE(group->GetCachedConfiguration(types::LeAudioContextType::CONVERSATIONAL)
- ->confs.get(le_audio::types::kLeAudioDirectionSource)
- .size());
+ if (com::android::bluetooth::flags::leaudio_use_audio_recording_listener()) {
+ // simulate suspend timeout passed, alarm executing
+ fake_osi_alarm_set_on_mloop_.cb(fake_osi_alarm_set_on_mloop_.data);
+ SyncOnMainLoop();
+ } else {
+ // Check if cache configuration is still present
+ ASSERT_TRUE(group->GetCachedConfiguration(types::LeAudioContextType::CONVERSATIONAL)
+ ->confs.get(le_audio::types::kLeAudioDirectionSink)
+ .size());
+ ASSERT_TRUE(group->GetCachedConfiguration(types::LeAudioContextType::CONVERSATIONAL)
+ ->confs.get(le_audio::types::kLeAudioDirectionSource)
+ .size());
- // Release, Sink HAL client should remain in monitor mode
- EXPECT_CALL(*mock_le_audio_source_hal_client_, Stop()).Times(1);
- EXPECT_CALL(*mock_le_audio_source_hal_client_, OnDestroyed()).Times(1);
- EXPECT_CALL(*mock_le_audio_sink_hal_client_, Stop()).Times(0);
- EXPECT_CALL(*mock_le_audio_sink_hal_client_, OnDestroyed()).Times(0);
- LeAudioClient::Get()->GroupSetActive(bluetooth::groups::kGroupUnknown);
- SyncOnMainLoop();
+ // Release, Sink HAL client should remain in monitor mode
+ EXPECT_CALL(*mock_le_audio_source_hal_client_, Stop()).Times(1);
+ EXPECT_CALL(*mock_le_audio_source_hal_client_, OnDestroyed()).Times(1);
+ EXPECT_CALL(*mock_le_audio_sink_hal_client_, Stop()).Times(0);
+ EXPECT_CALL(*mock_le_audio_sink_hal_client_, OnDestroyed()).Times(0);
+ LeAudioClient::Get()->GroupSetActive(bluetooth::groups::kGroupUnknown);
+ SyncOnMainLoop();
- Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
- Mock::VerifyAndClearExpectations(mock_le_audio_source_hal_client_);
- Mock::VerifyAndClearExpectations(mock_le_audio_sink_hal_client_);
+ Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
+ Mock::VerifyAndClearExpectations(mock_le_audio_source_hal_client_);
+ Mock::VerifyAndClearExpectations(mock_le_audio_sink_hal_client_);
- // Setting group inactive, shall not change cached configuration
- ASSERT_TRUE(group->GetCachedConfiguration(types::LeAudioContextType::CONVERSATIONAL)
- ->confs.get(le_audio::types::kLeAudioDirectionSink)
- .size());
- ASSERT_TRUE(group->GetCachedConfiguration(types::LeAudioContextType::CONVERSATIONAL)
- ->confs.get(le_audio::types::kLeAudioDirectionSource)
- .size());
+ // Setting group inactive, shall not change cached configuration
+ ASSERT_TRUE(group->GetCachedConfiguration(types::LeAudioContextType::CONVERSATIONAL)
+ ->confs.get(le_audio::types::kLeAudioDirectionSink)
+ .size());
+ ASSERT_TRUE(group->GetCachedConfiguration(types::LeAudioContextType::CONVERSATIONAL)
+ ->confs.get(le_audio::types::kLeAudioDirectionSource)
+ .size());
+ }
}
TEST_F(UnicastTestHandoverMode, ClearSinkMonitorModeWhileUnicastIsActive) {
diff --git a/system/device/Android.bp b/system/device/Android.bp
index d96d3f9..d517664 100644
--- a/system/device/Android.bp
+++ b/system/device/Android.bp
@@ -95,17 +95,14 @@
"liblog",
],
static_libs: [
- "bluetooth_flags_c_lib",
"libbluetooth-types",
"libbluetooth_log",
"libbt-platform-protos-lite",
"libbtcore",
"libbtdevice",
"libchrome",
- "libflagtest",
"libgmock",
"libosi",
- "server_configurable_flags",
],
header_libs: ["libbluetooth_headers"],
}
diff --git a/system/device/src/device_iot_config.cc b/system/device/src/device_iot_config.cc
index 4513e68..f247eff 100644
--- a/system/device/src/device_iot_config.cc
+++ b/system/device/src/device_iot_config.cc
@@ -21,7 +21,6 @@
#include "device/include/device_iot_config.h"
#include <bluetooth/log.h>
-#include <com_android_bluetooth_flags.h>
#include <ctype.h>
#include <string.h>
#include <time.h>
@@ -49,10 +48,6 @@
using namespace bluetooth;
bool device_iot_config_has_section(const std::string& section) {
- if (!com::android::bluetooth::flags::device_iot_config_logging()) {
- return false;
- }
-
log::assert_that(config != NULL, "assert failed: config != NULL");
std::unique_lock<std::mutex> lock(config_lock);
@@ -60,10 +55,6 @@
}
bool device_iot_config_exist(const std::string& section, const std::string& key) {
- if (!com::android::bluetooth::flags::device_iot_config_logging()) {
- return false;
- }
-
log::assert_that(config != NULL, "assert failed: config != NULL");
std::unique_lock<std::mutex> lock(config_lock);
@@ -71,10 +62,6 @@
}
bool device_iot_config_get_int(const std::string& section, const std::string& key, int& value) {
- if (!com::android::bluetooth::flags::device_iot_config_logging()) {
- return false;
- }
-
log::assert_that(config != NULL, "assert failed: config != NULL");
std::unique_lock<std::mutex> lock(config_lock);
@@ -87,10 +74,6 @@
}
bool device_iot_config_set_int(const std::string& section, const std::string& key, int value) {
- if (!com::android::bluetooth::flags::device_iot_config_logging()) {
- return false;
- }
-
log::assert_that(config != NULL, "assert failed: config != NULL");
std::unique_lock<std::mutex> lock(config_lock);
@@ -107,10 +90,6 @@
}
bool device_iot_config_int_add_one(const std::string& section, const std::string& key) {
- if (!com::android::bluetooth::flags::device_iot_config_logging()) {
- return false;
- }
-
log::assert_that(config != NULL, "assert failed: config != NULL");
int result = 0;
@@ -128,10 +107,6 @@
}
bool device_iot_config_get_hex(const std::string& section, const std::string& key, int& value) {
- if (!com::android::bluetooth::flags::device_iot_config_logging()) {
- return false;
- }
-
log::assert_that(config != NULL, "assert failed: config != NULL");
std::unique_lock<std::mutex> lock(config_lock);
@@ -159,10 +134,6 @@
bool device_iot_config_set_hex(const std::string& section, const std::string& key, int value,
int byte_num) {
- if (!com::android::bluetooth::flags::device_iot_config_logging()) {
- return false;
- }
-
log::assert_that(config != NULL, "assert failed: config != NULL");
char value_str[32] = {0};
@@ -189,10 +160,6 @@
bool device_iot_config_set_hex_if_greater(const std::string& section, const std::string& key,
int value, int byte_num) {
- if (!com::android::bluetooth::flags::device_iot_config_logging()) {
- return false;
- }
-
int stored_value = 0;
bool ret = device_iot_config_get_hex(section, key, stored_value);
if (ret && stored_value >= value) {
@@ -204,10 +171,6 @@
bool device_iot_config_get_str(const std::string& section, const std::string& key, char* value,
int* size_bytes) {
- if (!com::android::bluetooth::flags::device_iot_config_logging()) {
- return false;
- }
-
log::assert_that(config != NULL, "assert failed: config != NULL");
log::assert_that(value != NULL, "assert failed: value != NULL");
log::assert_that(size_bytes != NULL, "assert failed: size_bytes != NULL");
@@ -227,10 +190,6 @@
bool device_iot_config_set_str(const std::string& section, const std::string& key,
const std::string& value) {
- if (!com::android::bluetooth::flags::device_iot_config_logging()) {
- return false;
- }
-
log::assert_that(config != NULL, "assert failed: config != NULL");
std::unique_lock<std::mutex> lock(config_lock);
@@ -246,10 +205,6 @@
bool device_iot_config_get_bin(const std::string& section, const std::string& key, uint8_t* value,
size_t* length) {
- if (!com::android::bluetooth::flags::device_iot_config_logging()) {
- return false;
- }
-
log::assert_that(config != NULL, "assert failed: config != NULL");
log::assert_that(value != NULL, "assert failed: value != NULL");
log::assert_that(length != NULL, "assert failed: length != NULL");
@@ -293,10 +248,6 @@
}
size_t device_iot_config_get_bin_length(const std::string& section, const std::string& key) {
- if (!com::android::bluetooth::flags::device_iot_config_logging()) {
- return 0;
- }
-
log::assert_that(config != NULL, "assert failed: config != NULL");
std::unique_lock<std::mutex> lock(config_lock);
@@ -312,10 +263,6 @@
bool device_iot_config_set_bin(const std::string& section, const std::string& key,
const uint8_t* value, size_t length) {
- if (!com::android::bluetooth::flags::device_iot_config_logging()) {
- return false;
- }
-
const char* lookup = "0123456789abcdef";
log::assert_that(config != NULL, "assert failed: config != NULL");
@@ -350,10 +297,6 @@
}
bool device_iot_config_remove(const std::string& section, const std::string& key) {
- if (!com::android::bluetooth::flags::device_iot_config_logging()) {
- return false;
- }
-
log::assert_that(config != NULL, "assert failed: config != NULL");
std::unique_lock<std::mutex> lock(config_lock);
@@ -361,10 +304,6 @@
}
void device_iot_config_flush(void) {
- if (!com::android::bluetooth::flags::device_iot_config_logging()) {
- return;
- }
-
log::assert_that(config != NULL, "assert failed: config != NULL");
log::assert_that(config_timer != NULL, "assert failed: config_timer != NULL");
@@ -376,10 +315,6 @@
}
bool device_iot_config_clear(void) {
- if (!com::android::bluetooth::flags::device_iot_config_logging()) {
- return true;
- }
-
log::assert_that(config != NULL, "assert failed: config != NULL");
log::assert_that(config_timer != NULL, "assert failed: config_timer != NULL");
@@ -400,10 +335,6 @@
}
void device_debug_iot_config_dump(int fd) {
- if (!com::android::bluetooth::flags::device_iot_config_logging()) {
- return;
- }
-
dprintf(fd, "\nBluetooth Iot Config:\n");
dprintf(fd, " Config Source: ");
diff --git a/system/device/src/device_iot_config_int.cc b/system/device/src/device_iot_config_int.cc
index 33b5f81..fa65e13 100644
--- a/system/device/src/device_iot_config_int.cc
+++ b/system/device/src/device_iot_config_int.cc
@@ -21,7 +21,6 @@
#include "device_iot_config_int.h"
#include <bluetooth/log.h>
-#include <com_android_bluetooth_flags.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
@@ -184,10 +183,6 @@
.clean_up = device_iot_config_module_clean_up};
void device_iot_config_write(uint16_t event, UNUSED_ATTR char* p_param) {
- if (!com::android::bluetooth::flags::device_iot_config_logging()) {
- return;
- }
-
log::assert_that(config != NULL, "assert failed: config != NULL");
log::assert_that(config_timer != NULL, "assert failed: config_timer != NULL");
@@ -223,10 +218,6 @@
}
void device_iot_config_save_async(void) {
- if (!com::android::bluetooth::flags::device_iot_config_logging()) {
- return;
- }
-
log::assert_that(config != NULL, "assert failed: config != NULL");
log::assert_that(config_timer != NULL, "assert failed: config_timer != NULL");
@@ -235,10 +226,6 @@
}
int device_iot_config_get_device_num(const config_t& conf) {
- if (!com::android::bluetooth::flags::device_iot_config_logging()) {
- return 0;
- }
-
int devices = 0;
for (const auto& entry : conf.sections) {
diff --git a/system/device/test/device_iot_config_test.cc b/system/device/test/device_iot_config_test.cc
index 4693c74..958a76b 100644
--- a/system/device/test/device_iot_config_test.cc
+++ b/system/device/test/device_iot_config_test.cc
@@ -18,8 +18,6 @@
#include "device/include/device_iot_config.h"
-#include <com_android_bluetooth_flags.h>
-#include <flag_macros.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <sys/mman.h>
@@ -34,8 +32,6 @@
#include "test/mock/mock_osi_future.h"
#include "test/mock/mock_osi_properties.h"
-#define TEST_BT com::android::bluetooth::flags
-
using namespace bluetooth;
using namespace testing;
@@ -132,8 +128,7 @@
}
};
-TEST_F_WITH_FLAGS(DeviceIotConfigModuleTest, test_device_iot_config_module_init_is_factory_reset,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigModuleTest, test_device_iot_config_module_init_is_factory_reset) {
bool is_factory_reset = false;
config_t* config_new_return_value = NULL;
config_t* config_new_empty_return_value = NULL;
@@ -192,8 +187,7 @@
test::mock::osi_config::config_new_empty.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigModuleTest, test_device_iot_config_module_init_no_config,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigModuleTest, test_device_iot_config_module_init_no_config) {
test::mock::osi_config::config_new.body = [&](const char* /*filename*/) {
return std::unique_ptr<config_t>(nullptr);
};
@@ -217,8 +211,7 @@
test::mock::osi_config::config_new_empty.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigModuleTest, test_device_iot_config_module_init_original,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigModuleTest, test_device_iot_config_module_init_original) {
std::string enable_logging_property_get_value;
std::string factory_reset_property_get_value;
config_t* config_new_return_value = NULL;
@@ -268,8 +261,7 @@
test::mock::osi_config::config_new_empty.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigModuleTest, test_device_iot_config_module_init_backup,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigModuleTest, test_device_iot_config_module_init_backup) {
std::string enable_logging_property_get_value;
std::string factory_reset_property_get_value;
config_t* config_new_return_value = NULL;
@@ -322,8 +314,7 @@
test::mock::osi_config::config_new_empty.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigModuleTest, test_device_iot_config_module_init_new_file,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigModuleTest, test_device_iot_config_module_init_new_file) {
std::string enable_logging_property_get_value;
std::string factory_reset_property_get_value;
config_t* config_new_return_value = NULL;
@@ -367,8 +358,7 @@
test::mock::osi_config::config_new_empty.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigModuleTest, test_device_iot_config_module_init_version_invalid,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigModuleTest, test_device_iot_config_module_init_version_invalid) {
std::string enable_logging_property_get_value;
std::string factory_reset_property_get_value;
config_t* config_new_return_value = NULL;
@@ -418,9 +408,8 @@
test::mock::osi_config::config_new_empty.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigModuleTest,
- test_device_iot_config_module_init_version_new_config_new_empty_success,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigModuleTest,
+ test_device_iot_config_module_init_version_new_config_new_empty_success) {
std::string enable_logging_property_get_value;
std::string factory_reset_property_get_value;
config_t* config_new_return_value = NULL;
@@ -495,9 +484,8 @@
test::mock::osi_config::config_new_empty.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigModuleTest,
- test_device_iot_config_module_init_version_new_config_new_empty_fail,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigModuleTest,
+ test_device_iot_config_module_init_version_new_config_new_empty_fail) {
std::string enable_logging_property_get_value;
std::string factory_reset_property_get_value;
config_t* config_new_return_value = NULL;
@@ -572,9 +560,7 @@
test::mock::osi_config::config_new_empty.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigModuleTest,
- test_device_iot_config_module_init_original_timestamp_null,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigModuleTest, test_device_iot_config_module_init_original_timestamp_null) {
std::string enable_logging_property_get_value;
std::string factory_reset_property_get_value;
config_t* config_new_return_value = NULL;
@@ -622,8 +608,7 @@
test::mock::osi_config::config_new_empty.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigModuleTest, test_device_iot_config_module_init_alarm_new_fail,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigModuleTest, test_device_iot_config_module_init_alarm_new_fail) {
std::string enable_logging_property_get_value;
std::string factory_reset_property_get_value;
config_t* config_new_return_value = NULL;
@@ -675,8 +660,7 @@
test::mock::osi_config::config_new_empty.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigModuleTest, test_device_iot_config_module_start_up,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigModuleTest, test_device_iot_config_module_start_up) {
std::string enable_logging_property_get_value;
std::string factory_reset_property_get_value;
@@ -699,8 +683,7 @@
test::mock::osi_config::config_new_empty.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigModuleTest, test_device_iot_config_module_shutdown,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigModuleTest, test_device_iot_config_module_shutdown) {
bool return_value;
std::string enable_logging_property_get_value;
std::string factory_reset_property_get_value;
@@ -745,8 +728,7 @@
test::mock::osi_alarm::alarm_is_scheduled.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigModuleTest, test_device_iot_config_module_clean_up,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigModuleTest, test_device_iot_config_module_clean_up) {
bool return_value;
std::string enable_logging_property_get_value;
std::string factory_reset_property_get_value;
@@ -867,8 +849,7 @@
}
};
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_sections_sort_by_entry_key,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_sections_sort_by_entry_key) {
{
config_t conf;
device_iot_config_sections_sort_by_entry_key(conf, NULL);
@@ -925,8 +906,7 @@
}
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_has_section,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_has_section) {
std::string actual_section, expected_section = "abc";
bool return_value = false;
@@ -958,8 +938,7 @@
test::mock::osi_config::config_has_section.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_exist,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_exist) {
std::string actual_section, actual_key, expected_section = "abc", expected_key = "def";
bool return_value = false;
@@ -993,8 +972,7 @@
test::mock::osi_config::config_has_key.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_has_key_value,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_has_key_value) {
std::string actual_section, actual_key, expected_section = "abc", expected_key = "def";
std::string expected_value_str = "xyz", actual_value_str;
const std::string* actual_def_value = NULL;
@@ -1080,8 +1058,7 @@
test::mock::osi_config::config_get_string.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_get_int,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_get_int) {
std::string actual_section, actual_key, expected_section = "abc", expected_key = "def";
bool return_value = false;
int int_value = 0, new_value = 0xff;
@@ -1126,8 +1103,7 @@
test::mock::osi_config::config_get_int.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_addr_get_int,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_addr_get_int) {
const RawAddress peer_addr{};
std::string actual_section, actual_key, expected_section = "00:00:00:00:00:00",
expected_key = "def";
@@ -1174,8 +1150,7 @@
test::mock::osi_config::config_get_int.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_set_int,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_set_int) {
std::string actual_section, actual_key, expected_section = "abc", expected_key = "def";
std::string string_return_value = "123456789";
std::string old_string_value = string_return_value;
@@ -1229,8 +1204,7 @@
test::mock::osi_alarm::alarm_set.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_addr_set_int,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_addr_set_int) {
const RawAddress peer_addr{};
std::string actual_key, expected_key = "def";
std::string actual_section, expected_section = "00:00:00:00:00:00";
@@ -1286,8 +1260,7 @@
test::mock::osi_alarm::alarm_set.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_int_add_one,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_int_add_one) {
std::string actual_section, actual_key, expected_section = "abc", expected_key = "def";
int int_value = 0, get_default_value, set_value;
@@ -1393,8 +1366,7 @@
test::mock::osi_alarm::alarm_set.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_addr_int_add_one,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_addr_int_add_one) {
const RawAddress peer_addr{};
std::string actual_section, actual_key, expected_section = "00:00:00:00:00:00",
expected_key = "def";
@@ -1501,8 +1473,7 @@
test::mock::osi_alarm::alarm_set.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_get_hex,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_get_hex) {
std::string actual_section, actual_key, expected_section = "00:00:00:00:00:00",
expected_key = "def";
int int_value = 0;
@@ -1661,8 +1632,7 @@
test::mock::osi_config::config_get_string.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_addr_get_hex,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_addr_get_hex) {
const RawAddress peer_addr{};
std::string actual_section, actual_key, expected_section = "00:00:00:00:00:00",
expected_key = "def";
@@ -1818,8 +1788,7 @@
test::mock::osi_config::config_get_string.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_set_hex,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_set_hex) {
std::string actual_key, expected_key = "def";
std::string actual_section, expected_section = "00:00:00:00:00:00";
std::string string_return_value;
@@ -1966,8 +1935,7 @@
test::mock::osi_alarm::alarm_set.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_addr_set_hex,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_addr_set_hex) {
const RawAddress peer_addr{};
std::string actual_key, expected_key = "def";
std::string actual_section, expected_section = "00:00:00:00:00:00";
@@ -2119,8 +2087,7 @@
test::mock::osi_alarm::alarm_set.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_addr_set_hex_if_greater,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_addr_set_hex_if_greater) {
const RawAddress peer_addr{};
std::string actual_key, expected_key = "def";
std::string actual_section, expected_section = "00:00:00:00:00:00";
@@ -2205,8 +2172,7 @@
test::mock::osi_alarm::alarm_set.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_get_str,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_get_str) {
std::string actual_section, actual_key, expected_section = "abc", expected_key = "def";
std::string actual_value_str;
const std::string* actual_def_value = NULL;
@@ -2260,8 +2226,7 @@
test::mock::osi_config::config_get_string.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_set_str,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_set_str) {
std::string actual_key, expected_key = "def";
std::string actual_section, expected_section = "00:00:00:00:00:00";
std::string input_value;
@@ -2324,8 +2289,7 @@
test::mock::osi_alarm::alarm_set.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_addr_set_str,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_addr_set_str) {
const RawAddress peer_addr{};
std::string actual_key, expected_key = "def";
std::string actual_section, expected_section = "00:00:00:00:00:00";
@@ -2389,8 +2353,7 @@
test::mock::osi_alarm::alarm_set.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_get_bin,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_get_bin) {
std::string actual_section, actual_key, expected_section = "abc", expected_key = "def";
std::string actual_value_str;
const std::string* actual_def_value = NULL;
@@ -2496,8 +2459,7 @@
test::mock::osi_config::config_get_string.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_get_bin_length,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_get_bin_length) {
std::string actual_section, actual_key, expected_section = "abc", expected_key = "def";
std::string actual_value_str;
const std::string* actual_def_value = NULL;
@@ -2573,8 +2535,7 @@
test::mock::osi_config::config_get_string.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_set_bin,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_set_bin) {
std::string actual_key, expected_key = "def";
std::string actual_section, expected_section = "00:00:00:00:00:00";
std::string string_return_value;
@@ -2680,8 +2641,7 @@
test::mock::osi_alarm::alarm_set.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_addr_set_bin,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_addr_set_bin) {
const RawAddress peer_addr{};
std::string actual_key, expected_key = "def";
std::string actual_section, expected_section = "00:00:00:00:00:00";
@@ -2788,8 +2748,7 @@
test::mock::osi_alarm::alarm_set.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_remove,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_remove) {
std::string actual_key, expected_key = "def";
std::string actual_section, expected_section = "00:00:00:00:00:00";
bool return_value;
@@ -2828,8 +2787,7 @@
test::mock::osi_config::config_remove_key.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_save_async,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_save_async) {
{
reset_mock_function_count_map();
@@ -2839,8 +2797,7 @@
}
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_flush,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_flush) {
bool return_value;
test::mock::osi_alarm::alarm_is_scheduled.body = [&](const alarm_t* /*alarm*/) -> bool {
@@ -2876,8 +2833,7 @@
test::mock::osi_alarm::alarm_is_scheduled.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_clear,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_clear) {
config_t* config_new_empty_return_value;
bool config_save_return_value;
@@ -2935,8 +2891,7 @@
test::mock::osi_config::config_save.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_timer_save_cb,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_timer_save_cb) {
{
reset_mock_function_count_map();
@@ -2946,8 +2901,7 @@
}
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_set_modified_time,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_set_modified_time) {
{
reset_mock_function_count_map();
@@ -2957,8 +2911,7 @@
}
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_get_device_num,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_get_device_num) {
{
config_t config;
auto num = device_iot_config_get_device_num(config);
@@ -2980,8 +2933,7 @@
}
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_restrict_device_num,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_restrict_device_num) {
section_t section = {.name = "00:01:02:03:04:05"};
{
@@ -3032,8 +2984,7 @@
}
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_compare_key,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_compare_key) {
{
entry_t first =
{
@@ -3095,8 +3046,7 @@
}
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_write,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_write) {
test::mock::osi_config::config_save.body =
[&](const config_t& /*config*/, const std::string& /*filename*/) -> bool { return true; };
@@ -3122,8 +3072,7 @@
test::mock::osi_config::config_save.body = {};
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_debug_iot_config_dump,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_debug_iot_config_dump) {
{
errno = 0;
int fd = -1;
@@ -3152,8 +3101,7 @@
}
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_iot_config_is_factory_reset,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_iot_config_is_factory_reset) {
bool return_value;
test::mock::osi_properties::osi_property_get_bool.body =
[&](const char* /*key*/, bool /*default_value*/) -> bool { return return_value; };
@@ -3169,8 +3117,7 @@
}
}
-TEST_F_WITH_FLAGS(DeviceIotConfigTest, test_device_debug_iot_config_delete_files,
- REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
+TEST_F(DeviceIotConfigTest, test_device_debug_iot_config_delete_files) {
{
errno = 0;
int file_fd = -1;
@@ -3199,248 +3146,3 @@
EXPECT_EQ(errno, ENOENT);
}
}
-class DeviceIotConfigDisabledTest : public testing::Test {
-protected:
- void SetUp() override {
- test::mock::osi_alarm::alarm_new.body = [&](const char* /*name*/) -> alarm_t* {
- return &placeholder_alarm;
- };
-
- test::mock::osi_alarm::alarm_set.body = [&](alarm_t* /*alarm*/, uint64_t /*interval_ms*/,
- alarm_callback_t /*cb*/,
- void* /*data*/) { return; };
-
- test::mock::osi_alarm::alarm_free.body = [](alarm_t* /*alarm*/) {};
-
- test::mock::osi_alarm::alarm_is_scheduled.body = [&](const alarm_t* /*alarm*/) -> bool {
- return false;
- };
-
- test::mock::osi_future::future_new_immediate.body = [&](void* /*value*/) -> future_t* {
- return &placeholder_future;
- };
-
- test::mock::osi_config::config_new_empty.body = [&]() -> std::unique_ptr<config_t> {
- return std::make_unique<config_t>();
- };
-
- test::mock::osi_config::config_new.body =
- [&](const char* /*filename*/) -> std::unique_ptr<config_t> {
- return std::make_unique<config_t>();
- };
-
- test::mock::osi_config::config_get_int.body =
- [&](const config_t& /*config*/, const std::string& /*section*/,
- const std::string& /*key*/, int def_value) { return def_value; };
-
- test::mock::osi_config::config_set_int.body =
- [&](config_t* /*config*/, const std::string& /*section*/, const std::string& /*key*/,
- int /*value*/) { return; };
-
- test::mock::osi_config::config_get_string.body =
- [&](const config_t& /*config*/, const std::string& /*section*/,
- const std::string& /*key*/, const std::string* def_value) { return def_value; };
-
- test::mock::osi_config::config_set_string.body =
- [&](config_t* /*config*/, const std::string& /*section*/, const std::string& /*key*/,
- const std::string& /*value*/) { return; };
-
- test::mock::osi_allocator::osi_free.body = [&](void* /*ptr*/) {};
-
- device_iot_config_module_init();
- device_iot_config_module_start_up();
-
- reset_mock_function_count_map();
- }
-
- void TearDown() override {
- test::mock::osi_alarm::alarm_new = {};
- test::mock::osi_alarm::alarm_set = {};
- test::mock::osi_alarm::alarm_free = {};
- test::mock::osi_alarm::alarm_is_scheduled = {};
- test::mock::osi_future::future_new_immediate = {};
- test::mock::osi_properties::osi_property_get = {};
- test::mock::osi_config::config_new_empty = {};
- test::mock::osi_config::config_new = {};
- test::mock::osi_config::config_get_int = {};
- test::mock::osi_config::config_set_int = {};
- test::mock::osi_config::config_get_string = {};
- test::mock::osi_config::config_set_string = {};
- test::mock::osi_allocator::osi_free = {};
- }
-};
-
-TEST_F_WITH_FLAGS(DeviceIotConfigDisabledTest, test_device_iot_config_disabled,
- REQUIRES_FLAGS_DISABLED(ACONFIG_FLAG(TEST_BT, device_iot_config_logging))) {
- const RawAddress peer_addr{};
- std::string section, key, value_str;
- int value_int{};
-
- {
- reset_mock_function_count_map();
-
- EXPECT_FALSE(device_iot_config_has_section(section));
- EXPECT_EQ(get_func_call_size(), 0);
- }
-
- {
- reset_mock_function_count_map();
-
- EXPECT_FALSE(device_iot_config_exist(section, key));
- EXPECT_EQ(get_func_call_size(), 0);
- }
-
- {
- reset_mock_function_count_map();
-
- EXPECT_FALSE(device_iot_config_get_int(section, key, value_int));
- EXPECT_EQ(get_func_call_size(), 0);
- }
-
- {
- reset_mock_function_count_map();
-
- EXPECT_FALSE(DEVICE_IOT_CONFIG_ADDR_GET_INT(peer_addr, key, value_int));
- EXPECT_EQ(get_func_call_size(), 0);
- }
-
- {
- reset_mock_function_count_map();
-
- EXPECT_FALSE(device_iot_config_set_int(section, key, 0));
- EXPECT_EQ(get_func_call_size(), 0);
- }
-
- {
- reset_mock_function_count_map();
-
- EXPECT_FALSE(DEVICE_IOT_CONFIG_ADDR_SET_INT(peer_addr, key, 0));
- EXPECT_EQ(get_func_call_size(), 0);
- }
-
- {
- reset_mock_function_count_map();
-
- EXPECT_FALSE(device_iot_config_int_add_one(section, key));
- EXPECT_EQ(get_func_call_size(), 0);
- }
-
- {
- reset_mock_function_count_map();
-
- EXPECT_FALSE(DEVICE_IOT_CONFIG_ADDR_INT_ADD_ONE(peer_addr, key));
- EXPECT_EQ(get_func_call_size(), 0);
- }
-
- {
- reset_mock_function_count_map();
-
- EXPECT_FALSE(device_iot_config_get_hex(section, key, value_int));
- EXPECT_EQ(get_func_call_size(), 0);
- }
-
- {
- reset_mock_function_count_map();
-
- EXPECT_FALSE(DEVICE_IOT_CONFIG_ADDR_GET_HEX(peer_addr, key, value_int));
- EXPECT_EQ(get_func_call_size(), 0);
- }
-
- {
- reset_mock_function_count_map();
-
- EXPECT_FALSE(device_iot_config_set_hex(section, key, 0, 0));
- EXPECT_EQ(get_func_call_size(), 0);
- }
-
- {
- reset_mock_function_count_map();
-
- EXPECT_FALSE(DEVICE_IOT_CONFIG_ADDR_SET_HEX(peer_addr, key, 0, 0));
- EXPECT_EQ(get_func_call_size(), 0);
- }
-
- {
- reset_mock_function_count_map();
-
- EXPECT_FALSE(DEVICE_IOT_CONFIG_ADDR_SET_HEX_IF_GREATER(peer_addr, key, 0, 0));
- EXPECT_EQ(get_func_call_size(), 0);
- }
-
- {
- reset_mock_function_count_map();
-
- EXPECT_FALSE(device_iot_config_get_str(section, key, NULL, NULL));
- EXPECT_EQ(get_func_call_size(), 0);
- }
-
- {
- reset_mock_function_count_map();
-
- EXPECT_FALSE(device_iot_config_set_str(section, key, value_str));
- EXPECT_EQ(get_func_call_size(), 0);
- }
-
- {
- reset_mock_function_count_map();
-
- EXPECT_FALSE(DEVICE_IOT_CONFIG_ADDR_SET_STR(peer_addr, key, value_str));
- EXPECT_EQ(get_func_call_size(), 0);
- }
-
- {
- reset_mock_function_count_map();
-
- EXPECT_FALSE(device_iot_config_get_bin(section, key, NULL, NULL));
- EXPECT_EQ(get_func_call_size(), 0);
- }
-
- {
- reset_mock_function_count_map();
-
- EXPECT_FALSE(device_iot_config_set_bin(section, key, NULL, 0));
- EXPECT_EQ(get_func_call_size(), 0);
- }
-
- {
- reset_mock_function_count_map();
-
- EXPECT_FALSE(DEVICE_IOT_CONFIG_ADDR_SET_BIN(peer_addr, key, NULL, 0));
- EXPECT_EQ(get_func_call_size(), 0);
- }
-
- {
- reset_mock_function_count_map();
-
- EXPECT_FALSE(device_iot_config_remove(section, key));
- EXPECT_EQ(get_func_call_size(), 0);
- }
-
- {
- reset_mock_function_count_map();
-
- EXPECT_EQ(device_iot_config_get_bin_length(section, key), 0u);
- EXPECT_EQ(get_func_call_size(), 0);
- }
-
- {
- reset_mock_function_count_map();
-
- device_iot_config_flush();
- EXPECT_EQ(get_func_call_size(), 0);
- }
-
- {
- reset_mock_function_count_map();
-
- EXPECT_TRUE(device_iot_config_clear());
- EXPECT_EQ(get_func_call_size(), 0);
- }
-
- {
- reset_mock_function_count_map();
-
- device_debug_iot_config_dump(0);
- EXPECT_EQ(get_func_call_size(), 0);
- }
-}
diff --git a/system/stack/btm/btm_ble_sec.cc b/system/stack/btm/btm_ble_sec.cc
index 2ab87a0..e05091f 100644
--- a/system/stack/btm/btm_ble_sec.cc
+++ b/system/stack/btm/btm_ble_sec.cc
@@ -1595,7 +1595,7 @@
}
// Encrypt the link if device is bonded
- if (com::android::bluetooth::flags::le_enc_on_reconnection() &&
+ if (com::android::bluetooth::flags::le_enc_on_reconnect() &&
p_dev_rec->sec_rec.is_le_link_key_known()) {
btm_ble_set_encryption(bda, BTM_BLE_SEC_ENCRYPT,
p_dev_rec->role_central ? HCI_ROLE_CENTRAL : HCI_ROLE_PERIPHERAL);
diff --git a/system/stack/btm/btm_sec.cc b/system/stack/btm/btm_sec.cc
index 47dda74..9afa217 100644
--- a/system/stack/btm/btm_sec.cc
+++ b/system/stack/btm/btm_sec.cc
@@ -1029,7 +1029,7 @@
: p_dev_rec->sec_rec.classic_link;
/* Enqueue security request if security is active */
- if (!com::android::bluetooth::flags::le_enc_on_reconnection()) {
+ if (!com::android::bluetooth::flags::le_enc_on_reconnect()) {
if (p_dev_rec->sec_rec.p_callback ||
(p_dev_rec->sec_rec.le_link != tSECURITY_STATE::IDLE &&
p_dev_rec->sec_rec.classic_link != tSECURITY_STATE::IDLE)) {
@@ -4974,7 +4974,7 @@
node = list_next(node);
log::debug("btm_sec_check_pending_enc_req : sec_act=0x{:x}", p_e->sec_act);
if (p_e->bd_addr == p_dev_rec->bd_addr && p_e->psm == 0 && p_e->transport == transport) {
- if (!com::android::bluetooth::flags::le_enc_on_reconnection()) {
+ if (!com::android::bluetooth::flags::le_enc_on_reconnect()) {
if (encr_enable == 0 || transport == BT_TRANSPORT_BR_EDR ||
p_e->sec_act == BTM_BLE_SEC_ENCRYPT || p_e->sec_act == BTM_BLE_SEC_ENCRYPT_NO_MITM ||
(p_e->sec_act == BTM_BLE_SEC_ENCRYPT_MITM &&