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

Commit 2d208046 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 9348344 from b62ee847 to tm-qpr2-release

Change-Id: If43f4374961e1f92673e9d67bf479eaf6d622cfe
parents 8b660256 b62ee847
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -1810,6 +1810,35 @@ static jboolean allowLowLatencyAudioNative(JNIEnv* env, jobject obj,
  return true;
}

static void metadataChangedNative(JNIEnv* env, jobject obj, jbyteArray address,
                                  jint key, jbyteArray value) {
  ALOGV("%s", __func__);
  if (!sBluetoothInterface) return;
  jbyte* addr = env->GetByteArrayElements(address, nullptr);
  if (addr == nullptr) {
    jniThrowIOException(env, EINVAL);
    return;
  }
  RawAddress addr_obj = {};
  addr_obj.FromOctets((uint8_t*)addr);

  if (value == NULL) {
    ALOGE("metadataChangedNative() ignoring NULL array");
    return;
  }

  uint16_t len = (uint16_t)env->GetArrayLength(value);
  jbyte* p_value = env->GetByteArrayElements(value, NULL);
  if (p_value == NULL) return;

  std::vector<uint8_t> val_vec(reinterpret_cast<uint8_t*>(p_value),
                               reinterpret_cast<uint8_t*>(p_value + len));
  env->ReleaseByteArrayElements(value, p_value, 0);

  sBluetoothInterface->metadata_changed(addr_obj, key, std::move(val_vec));
  return;
}

static JNINativeMethod sMethods[] = {
    /* name, signature, funcPtr */
    {"classInitNative", "()V", (void*)classInitNative},
@@ -1852,6 +1881,7 @@ static JNINativeMethod sMethods[] = {
    {"requestMaximumTxDataLengthNative", "([B)V",
     (void*)requestMaximumTxDataLengthNative},
    {"allowLowLatencyAudioNative", "(Z[B)Z", (void*)allowLowLatencyAudioNative},
    {"metadataChangedNative", "([BI[B)V", (void*)metadataChangedNative},
};

int register_com_android_bluetooth_btservice_AdapterService(JNIEnv* env) {
+3 −3
Original line number Diff line number Diff line
@@ -249,9 +249,9 @@
    <string name="bluetooth_opp_file_limit_exceeded">Files bigger than 4GB cannot be transferred</string>
    <string name="bluetooth_connect_action">Connect to Bluetooth</string>
    <string name="bluetooth_enabled_apm_title">Bluetooth on in airplane mode</string>
    <string name="bluetooth_enabled_apm_message">If you keep Bluetooth on, it will stay on the next time you\'re in airplane mode</string>
    <string name="bluetooth_enabled_apm_message">If you keep Bluetooth on, your phone will remember to keep it on the next time you\'re in airplane mode</string>
    <string name="bluetooth_stays_on_title">Bluetooth stays on</string>
    <string name="bluetooth_stays_on_message">Your phone remembers to keep Bluetooth on in airplane mode. To change this, turn off Bluetooth.</string>
    <string name="bluetooth_stays_on_message">Your phone remembers to keep Bluetooth on in airplane mode. Turn off Bluetooth if you don\'t want it to stay on.</string>
    <string name="bluetooth_and_wifi_stays_on_title">Wi-Fi and Bluetooth stay on</string>
    <string name="bluetooth_and_wifi_stays_on_message">Your phone remembers to keep Wi-Fi and Bluetooth on in airplane mode. To change this, turn them off.</string>
    <string name="bluetooth_and_wifi_stays_on_message">Your phone remembers to keep Wi-Fi and Bluetooth on in airplane mode. Turn off Wi-Fi and Bluetooth if you don\'t want them to stay on.</string>
</resources>
+8 −0
Original line number Diff line number Diff line
@@ -4979,6 +4979,12 @@ public class AdapterService extends Service {
    @VisibleForTesting
    public void metadataChanged(String address, int key, byte[] value) {
        BluetoothDevice device = mRemoteDevices.getDevice(Utils.getBytesFromAddress(address));

        // pass just interesting metadata to native, to reduce spam
        if (key == BluetoothDevice.METADATA_LE_AUDIO) {
            metadataChangedNative(Utils.getBytesFromAddress(address), key, value);
        }

        if (mMetadataListeners.containsKey(device)) {
            ArrayList<IBluetoothMetadataListener> list = mMetadataListeners.get(device);
            for (IBluetoothMetadataListener listener : list) {
@@ -5624,6 +5630,8 @@ public class AdapterService extends Service {

    private native boolean allowLowLatencyAudioNative(boolean allowed, byte[] address);

    private native void metadataChangedNative(byte[] address, int key, byte[] value);

    // Returns if this is a mock object. This is currently used in testing so that we may not call
    // System.exit() while finalizing the object. Otherwise GC of mock objects unfortunately ends up
    // calling finalize() which in turn calls System.exit() and the process crashes.
+0 −5
Original line number Diff line number Diff line
@@ -35,11 +35,6 @@ public class MetricsLogger {

    public static final boolean DEBUG = false;

    /**
     * Intent indicating Bluetooth counter metrics should send logs to BluetoothStatsLog
     */
    public static final String BLUETOOTH_COUNTER_METRICS_ACTION =
            "com.android.bluetooth.btservice.BLUETOOTH_COUNTER_METRICS_ACTION";
    // 6 hours timeout for counter metrics
    private static final long BLUETOOTH_COUNTER_METRICS_ACTION_DURATION_MILLIS = 6L * 3600L * 1000L;

+2 −2
Original line number Diff line number Diff line
@@ -74,9 +74,9 @@ public class BluetoothMapService extends ProfileService {
     * DEBUG log: "setprop log.tag.BluetoothMapService VERBOSE"
     */

    public static final boolean DEBUG = false;
    public static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);

    public static final boolean VERBOSE = false;
    public static final boolean VERBOSE = Log.isLoggable(TAG, Log.VERBOSE);

    /**
     * The component names for the owned provider and activity
Loading