Pass whether the local device is an atv device to the native layer to
determine whether to include pairing dialogs for justworks and
encryption only LE pairing
Tag: #feature
Bug: 157038281
Test: Manual
Merged-In: Ib7575ff3d5f7e0c208743eff652440f7947dfed7
Change-Id: Ib7575ff3d5f7e0c208743eff652440f7947dfed7
(cherry picked from commit 0b2002b32a8459297d3bb50fce83dfa17e9ed778)
diff --git a/jni/com_android_bluetooth_btservice_AdapterService.cpp b/jni/com_android_bluetooth_btservice_AdapterService.cpp
index dc2e07a..ecda5ac 100644
--- a/jni/com_android_bluetooth_btservice_AdapterService.cpp
+++ b/jni/com_android_bluetooth_btservice_AdapterService.cpp
@@ -645,7 +645,7 @@
}
}
-static bool initNative(JNIEnv* env, jobject obj) {
+static bool initNative(JNIEnv* env, jobject obj, jboolean isAtvDevice) {
ALOGV("%s", __func__);
android_bluetooth_UidTraffic.clazz =
@@ -659,7 +659,7 @@
return JNI_FALSE;
}
- int ret = sBluetoothInterface->init(&sBluetoothCallbacks);
+ int ret = sBluetoothInterface->init(&sBluetoothCallbacks, isAtvDevice == JNI_TRUE ? 1 : 0);
if (ret != BT_STATUS_SUCCESS) {
ALOGE("Error while setting the callbacks: %d\n", ret);
sBluetoothInterface = NULL;
@@ -1211,7 +1211,7 @@
static JNINativeMethod sMethods[] = {
/* name, signature, funcPtr */
{"classInitNative", "()V", (void*)classInitNative},
- {"initNative", "()Z", (void*)initNative},
+ {"initNative", "(Z)Z", (void*)initNative},
{"cleanupNative", "()V", (void*)cleanupNative},
{"enableNative", "(Z)Z", (void*)enableNative},
{"disableNative", "()Z", (void*)disableNative},
diff --git a/src/com/android/bluetooth/btservice/AdapterService.java b/src/com/android/bluetooth/btservice/AdapterService.java
index a7ff901..8da1baf 100644
--- a/src/com/android/bluetooth/btservice/AdapterService.java
+++ b/src/com/android/bluetooth/btservice/AdapterService.java
@@ -33,6 +33,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
+import android.content.pm.PackageManager;
import android.os.AsyncTask;
import android.os.BatteryStats;
import android.os.Binder;
@@ -394,7 +395,11 @@
mAdapterProperties = new AdapterProperties(this);
mAdapterStateMachine = AdapterState.make(this, mAdapterProperties);
mJniCallbacks = new JniCallbacks(mAdapterStateMachine, mAdapterProperties);
- initNative();
+
+ // Android TV doesn't show consent dialogs for just works and encryption only le pairing
+ boolean isAtvDevice = getApplicationContext().getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_LEANBACK_ONLY);
+ initNative(isAtvDevice);
mNativeAvailable=true;
mCallbacks = new RemoteCallbackList<IBluetoothCallback>();
//Load the name and address
@@ -2267,7 +2272,7 @@
};
private native static void classInitNative();
- private native boolean initNative();
+ private native boolean initNative(boolean isAtvDevice);
private native void cleanupNative();
/*package*/ native boolean enableNative(boolean startRestricted);
/*package*/ native boolean disableNative();