|
|
@@ -1,4 +1,3 @@
|
|
|
-using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using UnityEngine;
|
|
|
using UnityEngine.Events;
|
|
|
@@ -28,34 +27,26 @@ public class BluetoothHelperAndroid
|
|
|
int sdkInt = buildVersion.GetStatic<int>("SDK_INT");
|
|
|
List<string> permissionListA = new List<string>();
|
|
|
List<string> permissionListB = new List<string>();
|
|
|
- List<string> permissionListC = new List<string>();
|
|
|
if (sdkInt >= 23)
|
|
|
{
|
|
|
permissionListA.Add(Permission.CoarseLocation);
|
|
|
permissionListA.Add(Permission.FineLocation);
|
|
|
- if (sdkInt >= 29)
|
|
|
- permissionListB.Add("android.permission.ACCESS_BACKGROUND_LOCATION");
|
|
|
if (sdkInt < 31)
|
|
|
{
|
|
|
- permissionListC.Add("android.permission.BLUETOOTH");
|
|
|
- permissionListC.Add("android.permission.BLUETOOTH_ADMIN");
|
|
|
+ permissionListB.Add("android.permission.BLUETOOTH");
|
|
|
+ permissionListB.Add("android.permission.BLUETOOTH_ADMIN");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- permissionListC.Add("android.permission.BLUETOOTH_SCAN");
|
|
|
- permissionListC.Add("android.permission.BLUETOOTH_ADVERTISE");
|
|
|
- permissionListC.Add("android.permission.BLUETOOTH_CONNECT");
|
|
|
+ permissionListB.Add("android.permission.BLUETOOTH_SCAN");
|
|
|
+ permissionListB.Add("android.permission.BLUETOOTH_ADVERTISE");
|
|
|
+ permissionListB.Add("android.permission.BLUETOOTH_CONNECT");
|
|
|
}
|
|
|
}
|
|
|
if (IsPermissionsGranted(permissionListA)
|
|
|
- && IsPermissionsGranted(permissionListB)
|
|
|
- && IsPermissionsGranted(permissionListC)) return false;
|
|
|
- RequestUserPermissions(permissionListA.ToArray(), () =>
|
|
|
- {
|
|
|
- RequestUserPermissions(permissionListB.ToArray(), () =>
|
|
|
- {
|
|
|
- RequestUserPermissions(permissionListC.ToArray(), onAllGranted, onDenied);
|
|
|
- }, onDenied);
|
|
|
+ && IsPermissionsGranted(permissionListB)) return false;
|
|
|
+ RequestUserPermissions(permissionListA.ToArray(), () => {
|
|
|
+ RequestUserPermissions(permissionListB.ToArray(), onAllGranted, onDenied);
|
|
|
}, onDenied);
|
|
|
return true;
|
|
|
}
|