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

Commit 663e26be authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11931036 from 33500b7c to 24Q3-release

Change-Id: Iebd8a8febfa49ffd8223f8a7e27fc1f40bdd9ebb
parents 9070ee8c 33500b7c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -315,6 +315,7 @@ android_app {
        "com.android.btservices",
    ],
    errorprone: {
        enabled: true,
        javacflags: [
            // "-Xep:AndroidFrameworkRequiresPermission:ERROR",
            "-Xep:AlmostJavadoc:ERROR",
+10 −12
Original line number Diff line number Diff line
@@ -102,7 +102,6 @@ namespace android {
/**
 * Client callback methods
 */

static jmethodID method_onClientRegistered;
static jmethodID method_onConnected;
static jmethodID method_onDisconnected;
@@ -185,6 +184,7 @@ static jmethodID method_onSyncReport;
static jmethodID method_onSyncStarted;
static jmethodID method_onSyncTransferredCallback;
static jmethodID method_onBigInfoReport;

/**
 * Distance Measurement callback methods
 */
@@ -1921,6 +1921,7 @@ static void gattClientReadScanReportsNative(JNIEnv* /* env */,
/**
 * Native server functions
 */

static void gattServerRegisterAppNative(JNIEnv* /* env */, jobject /* object */,
                                        jlong app_uuid_lsb, jlong app_uuid_msb,
                                        jboolean eatt_support) {
@@ -2578,15 +2579,10 @@ static void stopDistanceMeasurementNative(JNIEnv* env, jobject /* object */,
}

/**
 * JNI function definitinos
 * JNI function definitions
 */

// JNI functions defined in AdvertiseManagerNativeInterface class.

// JNI functions defined in PeriodicScanManager class.
// JNI functions defined in DistanceMeasurementManager class.

// JNI functions defined in GattNativeInterface class.
// JNI functions defined in ScanNativeInterface class.
static int register_com_android_bluetooth_gatt_scan(JNIEnv* env) {
  const JNINativeMethod methods[] = {
      {"initializeNative", "()V", (void*)scanInitializeNative},
@@ -2657,6 +2653,7 @@ static int register_com_android_bluetooth_gatt_scan(JNIEnv* env) {
  return 0;
}

// JNI functions defined in AdvertiseManagerNativeInterface class.
static int register_com_android_bluetooth_gatt_advertise_manager(JNIEnv* env) {
  const JNINativeMethod methods[] = {
      {"initializeNative", "()V", (void*)advertiseInitializeNative},
@@ -2707,10 +2704,10 @@ static int register_com_android_bluetooth_gatt_advertise_manager(JNIEnv* env) {
  GET_JAVA_METHODS(env,
                   "com/android/bluetooth/gatt/AdvertiseManagerNativeInterface",
                   javaMethods);

  return 0;
}

// JNI functions defined in PeriodicScanNativeInterface class.
static int register_com_android_bluetooth_gatt_periodic_scan(JNIEnv* env) {
  const JNINativeMethod methods[] = {
      {"initializeNative", "()V", (void*)periodicScanInitializeNative},
@@ -2724,7 +2721,8 @@ static int register_com_android_bluetooth_gatt_periodic_scan(JNIEnv* env) {
       (void*)transferSetInfoNative},
  };
  const int result = REGISTER_NATIVE_METHODS(
      env, "com/android/bluetooth/le_scan/PeriodicScanNativeInterface", methods);
      env, "com/android/bluetooth/le_scan/PeriodicScanNativeInterface",
      methods);
  if (result != 0) {
    return result;
  }
@@ -2740,10 +2738,10 @@ static int register_com_android_bluetooth_gatt_periodic_scan(JNIEnv* env) {
  GET_JAVA_METHODS(env,
                   "com/android/bluetooth/le_scan/PeriodicScanNativeInterface",
                   javaMethods);

  return 0;
}

// JNI functions defined in DistanceMeasurementNativeInterface class.
static int register_com_android_bluetooth_gatt_distance_measurement(
    JNIEnv* env) {
  const JNINativeMethod methods[] = {
@@ -2774,10 +2772,10 @@ static int register_com_android_bluetooth_gatt_distance_measurement(
  GET_JAVA_METHODS(
      env, "com/android/bluetooth/gatt/DistanceMeasurementNativeInterface",
      javaMethods);

  return 0;
}

// JNI functions defined in GattNativeInterface class.
static int register_com_android_bluetooth_gatt_(JNIEnv* env) {
  const JNINativeMethod methods[] = {
      {"initializeNative", "()V", (void*)initializeNative},
+41 −14
Original line number Diff line number Diff line
@@ -285,10 +285,6 @@ public class BassClientService extends ProfileService {
        log("updatePeriodicAdvertisementResultMap: broadcastName: " + broadcastName);
        log("mSyncHandleToDeviceMap" + mSyncHandleToDeviceMap);
        log("mPeriodicAdvertisementResultMap" + mPeriodicAdvertisementResultMap);
        // Cache the SyncHandle and source device
        if (mSyncHandleToDeviceMap != null && syncHandle != BassConstants.INVALID_SYNC_HANDLE) {
            mSyncHandleToDeviceMap.put(syncHandle, device);
        }
        if (mPeriodicAdvertisementResultMap != null) {
            HashMap<Integer, PeriodicAdvertisementResult> paResMap =
                    mPeriodicAdvertisementResultMap.get(device);
@@ -314,6 +310,33 @@ public class BassClientService extends ProfileService {
                log("PAResmap: update >>>");
                if (bId == BassConstants.INVALID_BROADCAST_ID) {
                    // Update when onSyncEstablished, try to retrieve valid broadcast id
                    if (leaudioBroadcastExtractPeriodicScannerFromStateMachine()) {
                        bId = getBroadcastIdForSyncHandle(BassConstants.INVALID_SYNC_HANDLE);

                        if (bId == BassConstants.INVALID_BROADCAST_ID
                                || !paResMap.containsKey(bId)) {
                            Log.e(TAG, "PAResmap: error! no valid broadcast id found>>>");
                            return;
                        }

                        int oldBroadcastId = getBroadcastIdForSyncHandle(syncHandle);
                        if (oldBroadcastId != BassConstants.INVALID_BROADCAST_ID
                                && oldBroadcastId != bId) {
                            log(
                                    "updatePeriodicAdvertisementResultMap: SyncEstablished on the"
                                            + " same syncHandle="
                                            + syncHandle
                                            + ", before syncLost");
                            if (leaudioBroadcastMonitorSourceSyncStatus()) {
                                log(
                                        "Notify broadcast source lost, broadcast id: "
                                                + oldBroadcastId);
                                mCallbacks.notifySourceLost(oldBroadcastId);
                            }
                            clearAllDataForSyncHandle(syncHandle);
                            mCachedBroadcasts.remove(oldBroadcastId);
                        }
                    } else {
                        for (Map.Entry<Integer, PeriodicAdvertisementResult> entry :
                                paResMap.entrySet()) {
                            PeriodicAdvertisementResult value = entry.getValue();
@@ -327,11 +350,15 @@ public class BassClientService extends ProfileService {
                            return;
                        }
                    }
                }
                PeriodicAdvertisementResult paRes = paResMap.get(bId);
                if (advSid != BassConstants.INVALID_ADV_SID) {
                    paRes.updateAdvSid(advSid);
                }
                if (syncHandle != BassConstants.INVALID_SYNC_HANDLE) {
                    if (mSyncHandleToDeviceMap != null) {
                        mSyncHandleToDeviceMap.put(syncHandle, device);
                    }
                    paRes.updateSyncHandle(syncHandle);
                    if (paRes.getBroadcastId() != BassConstants.INVALID_BROADCAST_ID) {
                        // broadcast successfully synced
+24 −46
Original line number Diff line number Diff line
@@ -165,10 +165,9 @@ public class LeAudioService extends ProfileService {
            leaudioApiSynchronizedBlockFix() ? mGroupReadWriteLock.readLock() : mGroupLock;
    private final Lock mGroupWriteLock =
            leaudioApiSynchronizedBlockFix() ? mGroupReadWriteLock.writeLock() : mGroupLock;
    private final Context mContext;
    ServiceFactory mServiceFactory = new ServiceFactory();

    LeAudioNativeInterface mLeAudioNativeInterface;
    private final LeAudioNativeInterface mNativeInterface;
    boolean mLeAudioNativeIsInitialized = false;
    boolean mLeAudioInbandRingtoneSupportedByPlatform = true;
    boolean mBluetoothEnabled = false;
@@ -218,15 +217,13 @@ public class LeAudioService extends ProfileService {
    ScanCallback mScanCallback;

    public LeAudioService(Context ctx) {
        super(ctx);
        mContext = ctx;
        this(ctx, LeAudioNativeInterface.getInstance());
    }

    @VisibleForTesting
    LeAudioService(Context ctx, LeAudioNativeInterface nativeInterface) {
        super(ctx);
        mLeAudioNativeInterface = nativeInterface;
        mContext = ctx;
        mNativeInterface = Objects.requireNonNull(nativeInterface);
    }

    private class LeAudioGroupDescriptor {
@@ -423,12 +420,6 @@ public class LeAudioService extends ProfileService {
                Objects.requireNonNull(
                        AdapterService.getAdapterService(),
                        "AdapterService cannot be null when LeAudioService starts");
        if (mLeAudioNativeInterface == null) {
            mLeAudioNativeInterface =
                    Objects.requireNonNull(
                            LeAudioNativeInterface.getInstance(),
                            "LeAudioNativeInterface cannot be null when LeAudioService starts");
        }
        mDatabaseManager =
                Objects.requireNonNull(
                        mAdapterService.getDatabase(),
@@ -503,16 +494,10 @@ public class LeAudioService extends ProfileService {
            mTmapStarted = registerTmap();
        }

        LeAudioNativeInterface nativeInterface = mLeAudioNativeInterface;
        if (nativeInterface == null) {
            Log.w(TAG, "the service is stopped. ignore init()");
            return;
        }
        nativeInterface.init(mLeAudioCodecConfig.getCodecConfigOffloading());
        mNativeInterface.init(mLeAudioCodecConfig.getCodecConfigOffloading());

        if (leaudioUseAudioModeListener()) {
            mAudioManager.addOnModeChangedListener(
                    mContext.getMainExecutor(), mAudioModeChangeListener);
            mAudioManager.addOnModeChangedListener(getMainExecutor(), mAudioModeChangeListener);
        }
    }

@@ -594,8 +579,7 @@ public class LeAudioService extends ProfileService {
        }

        // Cleanup native interfaces
        mLeAudioNativeInterface.cleanup();
        mLeAudioNativeInterface = null;
        mNativeInterface.cleanup();
        mLeAudioNativeIsInitialized = false;
        mBluetoothEnabled = false;
        mHfpHandoverDevice = null;
@@ -718,7 +702,7 @@ public class LeAudioService extends ProfileService {
            Log.e(TAG, "setEnabledState, mLeAudioNativeIsInitialized is not initialized");
            return;
        }
        mLeAudioNativeInterface.setEnableState(device, enabled);
        mNativeInterface.setEnableState(device, enabled);
    }

    public boolean connect(BluetoothDevice device) {
@@ -965,7 +949,7 @@ public class LeAudioService extends ProfileService {
            Log.e(TAG, "Le Audio not initialized properly.");
            return false;
        }
        return mLeAudioNativeInterface.groupAddNode(groupId, device);
        return mNativeInterface.groupAddNode(groupId, device);
    }

    /**
@@ -980,7 +964,7 @@ public class LeAudioService extends ProfileService {
            Log.e(TAG, "Le Audio not initialized properly.");
            return false;
        }
        return mLeAudioNativeInterface.groupRemoveNode(groupId, device);
        return mNativeInterface.groupRemoveNode(groupId, device);
    }

    /**
@@ -1108,8 +1092,7 @@ public class LeAudioService extends ProfileService {
                            + " group is deactivated.");
            mCreateBroadcastQueue.add(broadcastSettings);
            if (Flags.leaudioBroadcastAudioHandoverPolicies()) {
                mLeAudioNativeInterface.setUnicastMonitorMode(
                        LeAudioStackEvent.DIRECTION_SINK, true);
                mNativeInterface.setUnicastMonitorMode(LeAudioStackEvent.DIRECTION_SINK, true);
            }
            removeActiveDevice(true);

@@ -1329,7 +1312,7 @@ public class LeAudioService extends ProfileService {

        Log.d(TAG, "destroyBroadcast");
        if (Flags.leaudioBroadcastAudioHandoverPolicies()) {
            mLeAudioNativeInterface.setUnicastMonitorMode(LeAudioStackEvent.DIRECTION_SINK, false);
            mNativeInterface.setUnicastMonitorMode(LeAudioStackEvent.DIRECTION_SINK, false);
        }
        mLeAudioBroadcasterNativeInterface.destroyBroadcast(broadcastId);
    }
@@ -1409,11 +1392,10 @@ public class LeAudioService extends ProfileService {

        if (active) {
            mIsSourceStreamMonitorModeEnabled = true;
            mLeAudioNativeInterface.setUnicastMonitorMode(LeAudioStackEvent.DIRECTION_SOURCE, true);
            mNativeInterface.setUnicastMonitorMode(LeAudioStackEvent.DIRECTION_SOURCE, true);
        } else {
            if (mIsSourceStreamMonitorModeEnabled) {
                mLeAudioNativeInterface.setUnicastMonitorMode(
                        LeAudioStackEvent.DIRECTION_SOURCE, false);
                mNativeInterface.setUnicastMonitorMode(LeAudioStackEvent.DIRECTION_SOURCE, false);
            }

            mIsSourceStreamMonitorModeEnabled = false;
@@ -2022,8 +2004,7 @@ public class LeAudioService extends ProfileService {
                    && ((newSupportedAudioDirections & AUDIO_DIRECTION_INPUT_BIT) != 0)) {
                newInDevice = getLeadDeviceForTheGroup(groupId);
            } else if (Flags.leaudioBroadcastAudioHandoverPolicies() && wasSetSinkListeningMode()) {
                mLeAudioNativeInterface.setUnicastMonitorMode(
                        LeAudioStackEvent.DIRECTION_SINK, false);
                mNativeInterface.setUnicastMonitorMode(LeAudioStackEvent.DIRECTION_SINK, false);
            }
        }

@@ -2212,7 +2193,7 @@ public class LeAudioService extends ProfileService {
            }
        }

        mLeAudioNativeInterface.groupSetActive(groupId);
        mNativeInterface.groupSetActive(groupId);
        if (groupId == LE_AUDIO_GROUP_ID_INVALID) {
            /* Native will clear its states and send us group Inactive.
             * However we would like to notify audio framework that LeAudio is not
@@ -2623,8 +2604,7 @@ public class LeAudioService extends ProfileService {
        if (bassClientService == null) {
            Log.e(TAG, "handleSourceStreamStatusChange: BASS Client service is not available");

            mLeAudioNativeInterface.setUnicastMonitorMode(
                    LeAudioStackEvent.DIRECTION_SOURCE, false);
            mNativeInterface.setUnicastMonitorMode(LeAudioStackEvent.DIRECTION_SOURCE, false);
        }

        bassClientService.handleUnicastSourceStreamStatusChange(status);
@@ -2689,8 +2669,7 @@ public class LeAudioService extends ProfileService {

        groupDescriptor.updateAllowedContexts(sinkContextTypes, sourceContextTypes);

        mLeAudioNativeInterface.setGroupAllowedContextMask(
                groupId, sinkContextTypes, sourceContextTypes);
        mNativeInterface.setGroupAllowedContextMask(groupId, sinkContextTypes, sourceContextTypes);
    }

    @VisibleForTesting
@@ -2881,7 +2860,7 @@ public class LeAudioService extends ProfileService {

        if (!leaudioUseAudioModeListener()) {
            if (mQueuedInCallValue.isPresent()) {
                mLeAudioNativeInterface.setInCall(mQueuedInCallValue.get());
                mNativeInterface.setInCall(mQueuedInCallValue.get());
                mQueuedInCallValue = Optional.empty();
            }
        }
@@ -3538,7 +3517,7 @@ public class LeAudioService extends ProfileService {

        sm =
                LeAudioStateMachine.make(
                        device, this, mLeAudioNativeInterface, mStateMachinesThread.getLooper());
                        device, this, mNativeInterface, mStateMachinesThread.getLooper());
        descriptor.mStateMachine = sm;
        return sm;
    }
@@ -3574,7 +3553,7 @@ public class LeAudioService extends ProfileService {

                if (descriptor.mGroupId != LE_AUDIO_GROUP_ID_INVALID) {
                    /* In case device is still in the group, let's remove it */
                    mLeAudioNativeInterface.groupRemoveNode(descriptor.mGroupId, device);
                    mNativeInterface.groupRemoveNode(descriptor.mGroupId, device);
                }

                descriptor.mGroupId = LE_AUDIO_GROUP_ID_INVALID;
@@ -3943,7 +3922,7 @@ public class LeAudioService extends ProfileService {
            }
        }

        mLeAudioNativeInterface.setInCall(inCall);
        mNativeInterface.setInCall(inCall);

        if (!leaudioUseAudioModeListener()) {
            /* For clearing inCall mode */
@@ -3974,7 +3953,7 @@ public class LeAudioService extends ProfileService {
            Log.e(TAG, "Le Audio not initialized properly.");
            return;
        }
        mLeAudioNativeInterface.sendAudioProfilePreferences(
        mNativeInterface.sendAudioProfilePreferences(
                groupId, isOutputPreferenceLeAudio, isDuplexPreferenceLeAudio);
    }

@@ -4184,7 +4163,7 @@ public class LeAudioService extends ProfileService {
            Log.e(TAG, "Le Audio not initialized properly.");
            return;
        }
        mLeAudioNativeInterface.setCcidInformation(ccid, contextType);
        mNativeInterface.setCcidInformation(ccid, contextType);
    }

    /**
@@ -4785,8 +4764,7 @@ public class LeAudioService extends ProfileService {
            return;
        }

        mLeAudioNativeInterface.setCodecConfigPreference(
                groupId, inputCodecConfig, outputCodecConfig);
        mNativeInterface.setCodecConfigPreference(groupId, inputCodecConfig, outputCodecConfig);
    }

    /**
+2 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.bluetooth.le_scan;

import android.annotation.Nullable;
import android.bluetooth.BluetoothDevice;

public class AdvtFilterOnFoundOnLostInfo {
    private int mClientIf;
@@ -100,6 +101,7 @@ public class AdvtFilterOnFoundOnLostInfo {
        return mAddress;
    }

    @BluetoothDevice.AddressType
    public int getAddressType() {
        return mAddrType;
    }
Loading