Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ba5b3b88 authored by Michael Sun's avatar Michael Sun
Browse files

btaa: initialize BTAA service and JNI interface upon adapter creation

Initialize BTAA service and its JNI interface on adapter creation.

Tag: #feature
Bug: 172501038
Test: atest BluetoothInstrumentationTests:com.android.bluetooth.\
btservice.activityattribution

Change-Id: Iec50f67bddf9082a14abc3dcd92d1efedde4087b
parent 31c98104
Loading
Loading
Loading
Loading
+5 −3
Original line number Original line Diff line number Diff line
@@ -155,6 +155,8 @@ int register_com_android_bluetooth_sdp (JNIEnv* env);
int register_com_android_bluetooth_hearing_aid(JNIEnv* env);
int register_com_android_bluetooth_hearing_aid(JNIEnv* env);


int register_com_android_bluetooth_btservice_BluetoothKeystore(JNIEnv* env);
int register_com_android_bluetooth_btservice_BluetoothKeystore(JNIEnv* env);
}

int register_com_android_bluetooth_btservice_activity_attribution(JNIEnv* env);
}  // namespace android


#endif /* COM_ANDROID_BLUETOOTH_H */
#endif /* COM_ANDROID_BLUETOOTH_H */
+7 −0
Original line number Original line Diff line number Diff line
@@ -1401,6 +1401,13 @@ jint JNI_OnLoad(JavaVM* jvm, void* reserved) {
    return JNI_ERR;
    return JNI_ERR;
  }
  }


  status =
      android::register_com_android_bluetooth_btservice_activity_attribution(e);
  if (status < 0) {
    ALOGE("jni activity attribution registration failure: %d", status);
    return JNI_ERR;
  }

  status =
  status =
      android::register_com_android_bluetooth_btservice_BluetoothKeystore(e);
      android::register_com_android_bluetooth_btservice_BluetoothKeystore(e);
  if (status < 0) {
  if (status < 0) {
+9 −0
Original line number Original line Diff line number Diff line
@@ -84,6 +84,7 @@ import com.android.bluetooth.Utils;
import com.android.bluetooth.a2dp.A2dpService;
import com.android.bluetooth.a2dp.A2dpService;
import com.android.bluetooth.a2dpsink.A2dpSinkService;
import com.android.bluetooth.a2dpsink.A2dpSinkService;
import com.android.bluetooth.btservice.RemoteDevices.DeviceProperties;
import com.android.bluetooth.btservice.RemoteDevices.DeviceProperties;
import com.android.bluetooth.btservice.activityattribution.ActivityAttributionService;
import com.android.bluetooth.btservice.bluetoothkeystore.BluetoothKeystoreService;
import com.android.bluetooth.btservice.bluetoothkeystore.BluetoothKeystoreService;
import com.android.bluetooth.btservice.storage.DatabaseManager;
import com.android.bluetooth.btservice.storage.DatabaseManager;
import com.android.bluetooth.btservice.storage.MetadataDatabase;
import com.android.bluetooth.btservice.storage.MetadataDatabase;
@@ -234,6 +235,7 @@ public class AdapterService extends Service {
    private BluetoothKeystoreService mBluetoothKeystoreService;
    private BluetoothKeystoreService mBluetoothKeystoreService;
    private A2dpService mA2dpService;
    private A2dpService mA2dpService;
    private A2dpSinkService mA2dpSinkService;
    private A2dpSinkService mA2dpSinkService;
    private ActivityAttributionService mActivityAttributionService;
    private HeadsetService mHeadsetService;
    private HeadsetService mHeadsetService;
    private HeadsetClientService mHeadsetClientService;
    private HeadsetClientService mHeadsetClientService;
    private BluetoothMapService mMapService;
    private BluetoothMapService mMapService;
@@ -444,6 +446,8 @@ public class AdapterService extends Service {
        mJniCallbacks = new JniCallbacks(this, mAdapterProperties);
        mJniCallbacks = new JniCallbacks(this, mAdapterProperties);
        mBluetoothKeystoreService = new BluetoothKeystoreService(isNiapMode());
        mBluetoothKeystoreService = new BluetoothKeystoreService(isNiapMode());
        mBluetoothKeystoreService.start();
        mBluetoothKeystoreService.start();
        mActivityAttributionService = new ActivityAttributionService();
        mActivityAttributionService.start();
        int configCompareResult = mBluetoothKeystoreService.getCompareResult();
        int configCompareResult = mBluetoothKeystoreService.getCompareResult();


        // Android TV doesn't show consent dialogs for just works and encryption only le pairing
        // Android TV doesn't show consent dialogs for just works and encryption only le pairing
@@ -464,6 +468,7 @@ public class AdapterService extends Service {
                ServiceManager.getService(BatteryStats.SERVICE_NAME));
                ServiceManager.getService(BatteryStats.SERVICE_NAME));


        mBluetoothKeystoreService.initJni();
        mBluetoothKeystoreService.initJni();
        mActivityAttributionService.initJni();


        mSdpManager = SdpManager.init(this);
        mSdpManager = SdpManager.init(this);
        registerReceiver(mAlarmBroadcastReceiver, new IntentFilter(ACTION_ALARM_WAKEUP));
        registerReceiver(mAlarmBroadcastReceiver, new IntentFilter(ACTION_ALARM_WAKEUP));
@@ -766,6 +771,10 @@ public class AdapterService extends Service {
            mBluetoothKeystoreService.cleanup();
            mBluetoothKeystoreService.cleanup();
        }
        }


        if (mActivityAttributionService != null) {
            mActivityAttributionService.cleanup();
        }

        if (mNativeAvailable) {
        if (mNativeAvailable) {
            debugLog("cleanup() - Cleaning up adapter native");
            debugLog("cleanup() - Cleaning up adapter native");
            cleanupNative();
            cleanupNative();