Skip to content

Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.

addons: allow Bluetooth Connect on Android 11

GaneshVarma180b6b5514986
diff --git a/addons/bluetooth-connect/app/src/main/java/com/gathin/btconnect/MainActivity.java b/addons/bluetooth-connect/app/src/main/java/com/gathin/btconnect/MainActivity.java
index a0f899bb8..64661d310 100644
--- a/addons/bluetooth-connect/app/src/main/java/com/gathin/btconnect/MainActivity.java
+++ b/addons/bluetooth-connect/app/src/main/java/com/gathin/btconnect/MainActivity.java
@@ -13,6 +13,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
+import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@@ -75,7 +76,8 @@ public class MainActivity extends Activity {
@Override
protected void onResume() {
super.onResume();
- if (checkSelfPermission(Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
+ if (Build.VERSION.SDK_INT >= 31
+ && checkSelfPermission(Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{Manifest.permission.BLUETOOTH_CONNECT}, 1);
return;
}
@@ -125,7 +127,7 @@ public class MainActivity extends Activity {
super.onDestroy();
}
- /** Only runs after onResume has checked the Nearby devices permission. */
+ /** Only runs after onResume has checked Nearby devices on Android 12+. */
@SuppressLint("MissingPermission")
private void refresh() {
if (a2dp == null) return;
diff --git a/addons/bluetooth-connect/install.sh b/addons/bluetooth-connect/install.sh
index 5f9dc7b04..bdfe2a7f0 100755
--- a/addons/bluetooth-connect/install.sh
+++ b/addons/bluetooth-connect/install.sh
@@ -21,7 +21,7 @@ OUT=$(tv 'pm install -r /data/local/tmp/bluetooth-connect.apk; rm -f /data/local
echo "$OUT"
case "$OUT" in *Success*) ;; *) echo "ERROR: pm install failed" >&2; exit 1 ;; esac
-# Nearby devices, so the app lists and switches paired speakers without asking on the TV.
-tv "pm grant $PKG android.permission.BLUETOOTH_CONNECT; echo permission granted"
+# Nearby devices on Android 12+; Android 11 and older grant BLUETOOTH at install.
+tv "pm grant $PKG android.permission.BLUETOOTH_CONNECT 2>/dev/null; echo permission granted"
tv "am start -n $PKG/.MainActivity >/dev/null; echo opened"
echo "Installed. Bluetooth Connect is open on the TV; press Home and answer Show card for the card."