Skip to content

Commit

Permalink
Changes for targetSdkVersion >= 31
Browse files Browse the repository at this point in the history
  • Loading branch information
hoeveid committed Dec 18, 2022
1 parent 5dc80b1 commit 50a0dcb
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 12 deletions.
6 changes: 4 additions & 2 deletions AndroidManifestBadminton.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<!-- bluetooth -->
<!-- bluetooth (Legacy up to Android 11) -->
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <!-- for initiating and cancelling device discovery, and initiating connections -->
<!-- bluetooth (Android 12 upwards) -->
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

<!--<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />-->

<!-- android 9 casting -->
Expand Down Expand Up @@ -160,6 +163,5 @@
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>

</application>
</manifest>
9 changes: 8 additions & 1 deletion AndroidManifestRacketlon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
package="com.doubleyellow.racketlon">
<!-- PlayStoreID=4973204554147732137 -->

<!-- auto added by ?? so specifically remove it -->
<uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove"/>

<!--
<uses-feature android:name="android.permission.SEND_SMS" android:required="false" />
<uses-feature android:name="android.permission.INTERNET" android:required="true" />
Expand All @@ -20,9 +24,12 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<!-- bluetooth -->
<!-- bluetooth (Legacy up to Android 11) -->
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <!-- for initiating and cancelling device discovery, and initiating connections -->
<!-- bluetooth (Android 12 upwards) -->
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

<!--<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />-->

<!-- android 9 casting -->
Expand Down
13 changes: 10 additions & 3 deletions AndroidManifestSquore.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<!-- bluetooth -->
<!-- bluetooth (Legacy up to Android 11) -->
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <!-- for initiating and cancelling device discovery, and initiating connections -->
<!--<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />--> <!-- added for target 33 ?? -->
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <!-- for initiating and cancelling device discovery, and initiating connections -->
<!-- TEST: added for target 31+ for mirror with bluetooth -->
<!--
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
-->
<!-- bluetooth (Android 12 upwards) -->
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

<!--<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />-->

<!-- android 9 casting -->
Expand Down
5 changes: 4 additions & 1 deletion AndroidManifestTabletennis.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<!-- bluetooth -->
<!-- bluetooth (Legacy up to Android 11) -->
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <!-- for initiating and cancelling device discovery, and initiating connections -->
<!-- bluetooth (Android 12 upwards) -->
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

<!--<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />-->

<!-- android 9 casting -->
Expand Down
5 changes: 4 additions & 1 deletion AndroidManifestTennisPadel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<!-- bluetooth -->
<!-- bluetooth (Legacy up to Android 11) -->
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <!-- for initiating and cancelling device discovery, and initiating connections -->
<!-- bluetooth (Android 12 upwards) -->
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

<!--<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />-->

<!-- android 9 casting -->
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,21 @@ android {
minSdkVersion 19
targetSdkVersion 33
multiDexEnabled true // required since using firebase
versionCode 1915 * 10000 + 492
versionCode 1915 * 10000 + 493
versionName "4.50"
}
phoneTabletPost23 {
dimension "devicetype"
minSdkVersion 23
targetSdkVersion 33
versionCode 2315 * 10000 + 492
versionCode 2315 * 10000 + 493
versionName "4.50"
}
wearOs {
dimension "devicetype"
minSdkVersion 25 // 25 for Wear2.0 (23 would suffice for Wear1.0)
targetSdkVersion 33
versionCode 2501 * 10000 + 492
versionCode 2501 * 10000 + 493
versionName "4.50"
}
}
Expand Down
3 changes: 3 additions & 0 deletions res/values/bluetooth.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<string name="bt_connected_to_device_X">Connected to device %s</string>
<string name="bt_already_connected_to_X">Already connected to %s</string>

<string name="bt_app_not_allowed_bluetooth_permission">The app seems not to have your permission to use bluetooth</string>
<string name="bt_app_not_allowed_bluetooth_permission_info">Please allow this manually</string>

<string name="bt_unable_to_connect_device_X">Unable to connect device %s</string>
<string name="bt_unable_to_connect_device_info"><![CDATA[<html>Ensure that on selected target device %1$s
<ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,13 @@ public int[] getBluetoothDevices(boolean bRefresh) {
}

// Get a set of currently paired devices
Set<BluetoothDevice> pairedDevices = mBtAdapter.getBondedDevices();
Set<BluetoothDevice> pairedDevices = null; // requires android.permission.BLUETOOTH_CONNECT for targetSdkVersion 31+ (Android 12 upward)
try {
pairedDevices = mBtAdapter.getBondedDevices();
} catch (java.lang.SecurityException e) {
e.printStackTrace();
return new int[] { R.string.bt_app_not_allowed_bluetooth_permission, R.string.bt_app_not_allowed_bluetooth_permission_info };
}
if ( ListUtil.isEmpty(pairedDevices) ) {
return new int[] { R.string.bt_no_paired, R.string.bt_how_to_pair_info };
}
Expand Down
5 changes: 5 additions & 0 deletions src/com/doubleyellow/scoreboard/main/ScoreBoard.java
Original file line number Diff line number Diff line change
Expand Up @@ -7120,6 +7120,11 @@ private void setupBluetoothControl(boolean bStartTimer) {
} else {
// show dialog with info about how to solve/help/why
MyDialogBuilder.dialogWithOkOnly(this, iResIds[0], iResIds[1], false);

PreferenceValues.Permission hasPermission = PreferenceValues.doesUserHavePermissionToBluetoothConnect(this, true);
if ( PreferenceValues.Permission.Granted.equals(hasPermission) == false ) {
return;
}
}
/*
Intent nm = new Intent(this, DeviceListActivity.class);
Expand Down

0 comments on commit 50a0dcb

Please sign in to comment.