Skip to content

Commit

Permalink
Merge branch 'android-12'
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgyoung committed Aug 8, 2021
2 parents bf87639 + a61d049 commit 6ea2fe2
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

<application>
<receiver android:name="org.altbeacon.beacon.startup.StartupBroadcastReceiver">
<receiver android:name="org.altbeacon.beacon.startup.StartupBroadcastReceiver" android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.ACTION_POWER_CONNECTED"/>
Expand Down
7 changes: 6 additions & 1 deletion lib/src/main/java/org/altbeacon/beacon/BeaconParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,12 @@ else if (endIndex > pduToParse.getEndIndex() && !mAllowPduOverflow) {
String name = null;
if (device != null) {
macAddress = device.getAddress();
name = device.getName();
try {
name = device.getName();
}
catch (SecurityException e) {
Log.d(TAG,"Cannot read device name without Manifest.permission.BLUETOOTH_CONNECT");
}
}

beacon.mIdentifiers = identifiers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import java.util.List;

import static android.app.PendingIntent.FLAG_ONE_SHOT;
import static android.app.PendingIntent.FLAG_IMMUTABLE;
import static android.app.PendingIntent.getBroadcast;

/**
Expand Down Expand Up @@ -358,7 +359,7 @@ public void onTaskRemoved(Intent rootIntent) {

private PendingIntent getRestartIntent() {
Intent restartIntent = new Intent(getApplicationContext(), StartupBroadcastReceiver.class);
return getBroadcast(getApplicationContext(), 1, restartIntent, FLAG_ONE_SHOT);
return getBroadcast(getApplicationContext(), 1, restartIntent, FLAG_ONE_SHOT | FLAG_IMMUTABLE);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ void stopAndroidOBackgroundScan() {
PendingIntent getScanCallbackIntent() {
Intent intent = new Intent(mContext, StartupBroadcastReceiver.class);
intent.putExtra("o-scan", true);
return PendingIntent.getBroadcast(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
return PendingIntent.getBroadcast(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
}

private final CycledLeScanCallback mCycledLeScanCallback = new CycledLeScanCallback() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ protected PendingIntent getWakeUpOperation() {
if (mWakeUpOperation == null) {
Intent wakeupIntent = new Intent(mContext, StartupBroadcastReceiver.class);
wakeupIntent.putExtra("wakeup", true);
mWakeUpOperation = PendingIntent.getBroadcast(mContext, 0, wakeupIntent, PendingIntent.FLAG_UPDATE_CURRENT);
mWakeUpOperation = PendingIntent.getBroadcast(mContext, 0, wakeupIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
}
return mWakeUpOperation;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public void run() {
LogManager.e(npe, TAG, "Cannot start scan. Unexpected NPE.");
} catch (SecurityException e) {
// Thrown by Samsung Knox devices if bluetooth access denied for an app
LogManager.e(TAG, "Cannot start scan. Security Exception");
LogManager.e(TAG, "Cannot start scan. Security Exception: "+e.getMessage(), e);
}

}
Expand Down Expand Up @@ -292,7 +292,7 @@ public void run() {
LogManager.e(npe, TAG, "Cannot stop scan. Unexpected NPE.");
} catch (SecurityException e) {
// Thrown by Samsung Knox devices if bluetooth access denied for an app
LogManager.e(TAG, "Cannot stop scan. Security Exception");
LogManager.e(TAG, "Cannot stop scan. Security Exception", e);
}

}
Expand All @@ -308,7 +308,7 @@ private boolean isBluetoothOn() {
LogManager.w(TAG, "Cannot get bluetooth adapter");
}
catch (SecurityException e) {
LogManager.w(TAG, "SecurityException checking if bluetooth is on");
LogManager.w(TAG, "SecurityException checking if bluetooth is on", e);
}
return false;
}
Expand All @@ -327,7 +327,7 @@ private BluetoothLeScanner getScanner() {
}
}
catch (SecurityException e) {
LogManager.w(TAG, "SecurityException making new Android L scanner");
LogManager.w(TAG, "SecurityException making new Android L scanner", e);
}
return mScanner;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ private void sendScreenNotification(String message, String detail) {

PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(
0,
PendingIntent.FLAG_UPDATE_CURRENT
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE
);
builder.setContentIntent(resultPendingIntent);
NotificationManager notificationManager =
Expand Down

0 comments on commit 6ea2fe2

Please sign in to comment.