Loading android/app/jni/com_android_bluetooth_gatt.cpp +16 −2 Original line number Diff line number Diff line Loading @@ -1244,7 +1244,7 @@ public: void OnDistanceMeasurementResult(RawAddress address, uint32_t centimeter, uint32_t error_centimeter, int azimuth_angle, int error_azimuth_angle, int altitude_angle, int error_altitude_angle, long elapsedRealtimeNanos, int error_altitude_angle, uint64_t elapsedRealtimeNanos, int8_t confidence_level, uint8_t method) { std::shared_lock<std::shared_mutex> lock(callbacks_mutex); CallbackEnv sCallbackEnv(__func__); Loading Loading @@ -2400,6 +2400,14 @@ static AdvertiseParameters parseParams(JNIEnv* env, jobject i) { int8_t txPowerLevel = env->CallIntMethod(i, methodId); methodId = env->GetMethodID(clazz, "getOwnAddressType", "()I"); int8_t ownAddressType = env->CallIntMethod(i, methodId); methodId = env->GetMethodID(clazz, "isDirected", "()Z"); jboolean isDirected = env->CallBooleanMethod(i, methodId); methodId = env->GetMethodID(clazz, "isHighDutyCycle", "()Z"); jboolean isHighDutyCycle = env->CallIntMethod(i, methodId); methodId = env->GetMethodID(clazz, "getPeerAddress", "()Ljava/lang/String;"); jstring peerAddress = (jstring)env->CallObjectMethod(i, methodId); methodId = env->GetMethodID(clazz, "getPeerAddressType", "()I"); int8_t peerAddressType = env->CallIntMethod(i, methodId); uint16_t props = 0; if (isConnectable) { Loading @@ -2408,9 +2416,12 @@ static AdvertiseParameters parseParams(JNIEnv* env, jobject i) { if (isScannable) { props |= 0x02; } if (isDiscoverable) { if (isDirected) { props |= 0x04; } if (isHighDutyCycle) { props |= 0x08; } if (isLegacy) { props |= 0x10; } Loading @@ -2434,6 +2445,9 @@ static AdvertiseParameters parseParams(JNIEnv* env, jobject i) { p.secondary_advertising_phy = secondaryPhy; p.scan_request_notification_enable = false; p.own_address_type = ownAddressType; p.peer_address = str2addr(env, peerAddress); p.peer_address_type = peerAddressType; p.discoverable = isDiscoverable; return p; } Loading android/app/lint-baseline.xml +150 −1888 File changed.File size exceeds preview limit. View original file View changed file android/app/src/com/android/bluetooth/btservice/AdapterService.java +12 −24 Original line number Diff line number Diff line Loading @@ -314,8 +314,8 @@ public class AdapterService extends Service { private UserManager mUserManager; private CompanionDeviceManager mCompanionDeviceManager; // Phone Policy is not used on all devices. Ensure you null check before using it @Nullable private PhonePolicy mPhonePolicy; // Phone Policy is not used on all devices and can be empty private Optional<PhonePolicy> mPhonePolicy = Optional.empty(); private ActiveDeviceManager mActiveDeviceManager; private final DatabaseManager mDatabaseManager; Loading Loading @@ -716,8 +716,7 @@ public class AdapterService extends Service { */ if (!isAutomotiveDevice && getResources().getBoolean(R.bool.enable_phone_policy)) { Log.i(TAG, "Phone policy enabled"); mPhonePolicy = new PhonePolicy(this, new ServiceFactory()); mPhonePolicy.start(); mPhonePolicy = Optional.of(new PhonePolicy(this, mLooper, new ServiceFactory())); } else { Log.i(TAG, "Phone policy disabled"); } Loading Loading @@ -1470,9 +1469,7 @@ public class AdapterService extends Service { mBluetoothKeystoreService.cleanup(); } if (mPhonePolicy != null) { mPhonePolicy.cleanup(); } mPhonePolicy.ifPresent(policy -> policy.cleanup()); mSilenceDeviceManager.cleanup(); Loading Loading @@ -2701,9 +2698,7 @@ public class AdapterService extends Service { } service.logUserBondResponse(device, false, source); service.mBondAttemptCallerInfo.remove(device.getAddress()); if (service.mPhonePolicy != null) { service.mPhonePolicy.onRemoveBondRequest(device); } service.mPhonePolicy.ifPresent(policy -> policy.onRemoveBondRequest(device)); deviceProp.setBondingInitiatedLocally(false); Message msg = service.mBondStateMachine.obtainMessage(BondStateMachine.REMOVE_BOND); Loading Loading @@ -6125,11 +6120,8 @@ public class AdapterService extends Service { } } /** Update PhonePolicy when new {@link BluetoothDevice} creates an ACL connection. */ public void updatePhonePolicyOnAclConnect(BluetoothDevice device) { if (mPhonePolicy != null) { mPhonePolicy.handleAclConnected(device); } void updatePhonePolicyOnAclConnect(BluetoothDevice device) { mPhonePolicy.ifPresent(policy -> policy.handleAclConnected(device)); } /** Loading Loading @@ -6175,18 +6167,16 @@ public class AdapterService extends Service { */ public void handleProfileConnectionStateChange( int profile, BluetoothDevice device, int fromState, int toState) { if (mPhonePolicy != null) { mPhonePolicy.profileConnectionStateChanged(profile, device, fromState, toState); } mPhonePolicy.ifPresent( policy -> policy.profileConnectionStateChanged(profile, device, fromState, toState)); } /** Handle Bluetooth app state when active device changes for a given {@code profile}. */ public void handleActiveDeviceChange(int profile, BluetoothDevice device) { mActiveDeviceManager.profileActiveDeviceChanged(profile, device); mSilenceDeviceManager.profileActiveDeviceChanged(profile, device); if (mPhonePolicy != null) { mPhonePolicy.profileActiveDeviceChanged(profile, device); } mPhonePolicy.ifPresent(policy -> policy.profileActiveDeviceChanged(profile, device)); } /** Notify MAP and Pbap when a new sdp search record is found. */ Loading Loading @@ -7077,9 +7067,7 @@ public class AdapterService extends Service { for (int i = 0; i < uuids.length; i++) { Log.d(TAG, "sendUuidsInternal: index=" + i + " uuid=" + uuids[i]); } if (mPhonePolicy != null) { mPhonePolicy.onUuidsDiscovered(device, uuids); } mPhonePolicy.ifPresent(policy -> policy.onUuidsDiscovered(device, uuids)); } /** Clear storage */ Loading Loading
android/app/jni/com_android_bluetooth_gatt.cpp +16 −2 Original line number Diff line number Diff line Loading @@ -1244,7 +1244,7 @@ public: void OnDistanceMeasurementResult(RawAddress address, uint32_t centimeter, uint32_t error_centimeter, int azimuth_angle, int error_azimuth_angle, int altitude_angle, int error_altitude_angle, long elapsedRealtimeNanos, int error_altitude_angle, uint64_t elapsedRealtimeNanos, int8_t confidence_level, uint8_t method) { std::shared_lock<std::shared_mutex> lock(callbacks_mutex); CallbackEnv sCallbackEnv(__func__); Loading Loading @@ -2400,6 +2400,14 @@ static AdvertiseParameters parseParams(JNIEnv* env, jobject i) { int8_t txPowerLevel = env->CallIntMethod(i, methodId); methodId = env->GetMethodID(clazz, "getOwnAddressType", "()I"); int8_t ownAddressType = env->CallIntMethod(i, methodId); methodId = env->GetMethodID(clazz, "isDirected", "()Z"); jboolean isDirected = env->CallBooleanMethod(i, methodId); methodId = env->GetMethodID(clazz, "isHighDutyCycle", "()Z"); jboolean isHighDutyCycle = env->CallIntMethod(i, methodId); methodId = env->GetMethodID(clazz, "getPeerAddress", "()Ljava/lang/String;"); jstring peerAddress = (jstring)env->CallObjectMethod(i, methodId); methodId = env->GetMethodID(clazz, "getPeerAddressType", "()I"); int8_t peerAddressType = env->CallIntMethod(i, methodId); uint16_t props = 0; if (isConnectable) { Loading @@ -2408,9 +2416,12 @@ static AdvertiseParameters parseParams(JNIEnv* env, jobject i) { if (isScannable) { props |= 0x02; } if (isDiscoverable) { if (isDirected) { props |= 0x04; } if (isHighDutyCycle) { props |= 0x08; } if (isLegacy) { props |= 0x10; } Loading @@ -2434,6 +2445,9 @@ static AdvertiseParameters parseParams(JNIEnv* env, jobject i) { p.secondary_advertising_phy = secondaryPhy; p.scan_request_notification_enable = false; p.own_address_type = ownAddressType; p.peer_address = str2addr(env, peerAddress); p.peer_address_type = peerAddressType; p.discoverable = isDiscoverable; return p; } Loading
android/app/lint-baseline.xml +150 −1888 File changed.File size exceeds preview limit. View original file View changed file
android/app/src/com/android/bluetooth/btservice/AdapterService.java +12 −24 Original line number Diff line number Diff line Loading @@ -314,8 +314,8 @@ public class AdapterService extends Service { private UserManager mUserManager; private CompanionDeviceManager mCompanionDeviceManager; // Phone Policy is not used on all devices. Ensure you null check before using it @Nullable private PhonePolicy mPhonePolicy; // Phone Policy is not used on all devices and can be empty private Optional<PhonePolicy> mPhonePolicy = Optional.empty(); private ActiveDeviceManager mActiveDeviceManager; private final DatabaseManager mDatabaseManager; Loading Loading @@ -716,8 +716,7 @@ public class AdapterService extends Service { */ if (!isAutomotiveDevice && getResources().getBoolean(R.bool.enable_phone_policy)) { Log.i(TAG, "Phone policy enabled"); mPhonePolicy = new PhonePolicy(this, new ServiceFactory()); mPhonePolicy.start(); mPhonePolicy = Optional.of(new PhonePolicy(this, mLooper, new ServiceFactory())); } else { Log.i(TAG, "Phone policy disabled"); } Loading Loading @@ -1470,9 +1469,7 @@ public class AdapterService extends Service { mBluetoothKeystoreService.cleanup(); } if (mPhonePolicy != null) { mPhonePolicy.cleanup(); } mPhonePolicy.ifPresent(policy -> policy.cleanup()); mSilenceDeviceManager.cleanup(); Loading Loading @@ -2701,9 +2698,7 @@ public class AdapterService extends Service { } service.logUserBondResponse(device, false, source); service.mBondAttemptCallerInfo.remove(device.getAddress()); if (service.mPhonePolicy != null) { service.mPhonePolicy.onRemoveBondRequest(device); } service.mPhonePolicy.ifPresent(policy -> policy.onRemoveBondRequest(device)); deviceProp.setBondingInitiatedLocally(false); Message msg = service.mBondStateMachine.obtainMessage(BondStateMachine.REMOVE_BOND); Loading Loading @@ -6125,11 +6120,8 @@ public class AdapterService extends Service { } } /** Update PhonePolicy when new {@link BluetoothDevice} creates an ACL connection. */ public void updatePhonePolicyOnAclConnect(BluetoothDevice device) { if (mPhonePolicy != null) { mPhonePolicy.handleAclConnected(device); } void updatePhonePolicyOnAclConnect(BluetoothDevice device) { mPhonePolicy.ifPresent(policy -> policy.handleAclConnected(device)); } /** Loading Loading @@ -6175,18 +6167,16 @@ public class AdapterService extends Service { */ public void handleProfileConnectionStateChange( int profile, BluetoothDevice device, int fromState, int toState) { if (mPhonePolicy != null) { mPhonePolicy.profileConnectionStateChanged(profile, device, fromState, toState); } mPhonePolicy.ifPresent( policy -> policy.profileConnectionStateChanged(profile, device, fromState, toState)); } /** Handle Bluetooth app state when active device changes for a given {@code profile}. */ public void handleActiveDeviceChange(int profile, BluetoothDevice device) { mActiveDeviceManager.profileActiveDeviceChanged(profile, device); mSilenceDeviceManager.profileActiveDeviceChanged(profile, device); if (mPhonePolicy != null) { mPhonePolicy.profileActiveDeviceChanged(profile, device); } mPhonePolicy.ifPresent(policy -> policy.profileActiveDeviceChanged(profile, device)); } /** Notify MAP and Pbap when a new sdp search record is found. */ Loading Loading @@ -7077,9 +7067,7 @@ public class AdapterService extends Service { for (int i = 0; i < uuids.length; i++) { Log.d(TAG, "sendUuidsInternal: index=" + i + " uuid=" + uuids[i]); } if (mPhonePolicy != null) { mPhonePolicy.onUuidsDiscovered(device, uuids); } mPhonePolicy.ifPresent(policy -> policy.onUuidsDiscovered(device, uuids)); } /** Clear storage */ Loading