<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
+ <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<!-- Permissions needed to save Telemetry logs to SD card -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Permissions needed for GoogleMaps -->
<activity android:name="org.altusmetrum.AltosDroid.AltosDroid"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden"
- android:launchMode="singleTop">
+ android:launchMode="singleTop"
+ android:exported="true">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
if (device != null) {
Intent i = new Intent(this, AltosDroid.class);
- PendingIntent pi = PendingIntent.getActivity(this, 0, new Intent("hello world", null, this, AltosDroid.class), 0);
+ int flag;
+
+ if (android.os.Build.VERSION.SDK_INT >= 31) // android.os.Build.VERSION_CODES.S
+ flag = 33554432; // PendingIntent.FLAG_MUTABLE
+ else
+ flag = 0;
+ PendingIntent pi = PendingIntent.getActivity(this, 0, new Intent("hello world", null, this, AltosDroid.class), flag);
if (AltosUsb.request_permission(this, device, pi)) {
connectUsb(device);
public boolean have_storage_permission = false;
public boolean have_bluetooth_permission = false;
public boolean have_bluetooth_connect_permission = false;
+ public boolean have_bluetooth_scan_permission = false;
public boolean asked_permission = false;
static final String BLUETOOTH_CONNECT = "android.permission.BLUETOOTH_CONNECT";
+ static final String BLUETOOTH_SCAN = "android.permission.BLUETOOTH_SCAN";
AltosMapOnline map_online;
if (permissions[i].equals(BLUETOOTH_CONNECT)) {
have_bluetooth_connect_permission = true;
}
+ if (permissions[i].equals(BLUETOOTH_SCAN)) {
+ have_bluetooth_scan_permission = true;
+ }
}
}
}
{
have_bluetooth_connect_permission = true;
}
+ if (ActivityCompat.checkSelfPermission(this,
+ BLUETOOTH_SCAN)
+ == PackageManager.PERMISSION_GRANTED)
+ {
+ have_bluetooth_scan_permission = true;
+ }
int count = 0;
if (!have_location_permission)
count += 1;
count += 1;
if (!have_bluetooth_connect_permission)
count += 1;
+ if (!have_bluetooth_scan_permission)
+ count += 1;
if (count > 0)
{
String[] permissions = new String[count];
permissions[i++] = Manifest.permission.BLUETOOTH;
if (!have_bluetooth_connect_permission)
permissions[i++] = BLUETOOTH_CONNECT;
+ if (!have_bluetooth_scan_permission)
+ permissions[i++] = BLUETOOTH_SCAN;
ActivityCompat.requestPermissions(this, permissions, MY_PERMISSION_REQUEST);
}
}
import android.content.Intent;
import android.content.Context;
import android.os.*;
+import android.os.Build.*;
import android.widget.Toast;
import androidx.core.app.NotificationCompat;
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
AltosDebug.debug("Received start id %d: %s", startId, intent);
+ int flag;
+
+ if (android.os.Build.VERSION.SDK_INT >= 31) // android.os.Build.VERSION_CODES.S
+ flag = 33554432; // PendingIntent.FLAG_MUTABLE
+ else
+ flag = 0;
// The PendingIntent to launch our activity if the user selects this notification
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
- new Intent(this, AltosDroid.class), 0);
+ new Intent(this, AltosDroid.class), flag);
String channelId =
(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)