Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android 12 #313

Merged
merged 3 commits into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@

buildscript {
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'

classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

plugins {
id "com.jfrog.bintray" version "1.8.5"
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
6 changes: 3 additions & 3 deletions dfu/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 29
compileSdkVersion 31

defaultConfig {
minSdkVersion 18
targetSdkVersion 29
targetSdkVersion 31
versionCode 25
versionName VERSION_NAME
}
Expand All @@ -19,7 +19,7 @@ android {
}

dependencies {
implementation 'androidx.core:core:1.5.0-alpha05'
implementation 'androidx.core:core:1.6.0'
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'com.google.code.gson:gson:2.8.6'
Expand Down
7 changes: 5 additions & 2 deletions dfu/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="no.nordicsemi.android.dfu">

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

</manifest>
29 changes: 25 additions & 4 deletions dfu/src/main/java/no/nordicsemi/android/dfu/DfuBaseService.java
Original file line number Diff line number Diff line change
Expand Up @@ -1764,7 +1764,12 @@ public void updateProgressNotification() {
intent.putExtra(EXTRA_DEVICE_ADDRESS, deviceAddress);
intent.putExtra(EXTRA_DEVICE_NAME, deviceName);
intent.putExtra(EXTRA_PROGRESS, progress);
final PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

int flags = PendingIntent.FLAG_UPDATE_CURRENT;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
flags |= PendingIntent.FLAG_IMMUTABLE;
}
final PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, flags);
builder.setContentIntent(pendingIntent);

// Any additional configuration?
Expand All @@ -1786,7 +1791,13 @@ protected void updateProgressNotification(@NonNull final NotificationCompat.Buil
if (progress != PROGRESS_ABORTED && progress != PROGRESS_COMPLETED) {
final Intent abortIntent = new Intent(BROADCAST_ACTION);
abortIntent.putExtra(EXTRA_ACTION, ACTION_ABORT);
final PendingIntent pendingAbortIntent = PendingIntent.getBroadcast(this, 1, abortIntent, PendingIntent.FLAG_UPDATE_CURRENT);

int flags = PendingIntent.FLAG_UPDATE_CURRENT;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
flags |= PendingIntent.FLAG_IMMUTABLE;
}

final PendingIntent pendingAbortIntent = PendingIntent.getBroadcast(this, 1, abortIntent, flags);
builder.addAction(R.drawable.ic_action_notify_cancel, getString(R.string.dfu_action_abort), pendingAbortIntent);
}
}
Expand Down Expand Up @@ -1823,7 +1834,13 @@ private void report(final int error) {
intent.putExtra(EXTRA_DEVICE_ADDRESS, deviceAddress);
intent.putExtra(EXTRA_DEVICE_NAME, deviceName);
intent.putExtra(EXTRA_PROGRESS, error); // this may contains ERROR_CONNECTION_MASK bit!
final PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

int flags = PendingIntent.FLAG_UPDATE_CURRENT;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
flags |= PendingIntent.FLAG_IMMUTABLE;
}

final PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, flags);
builder.setContentIntent(pendingIntent);

// Any additional configuration?
Expand Down Expand Up @@ -1859,7 +1876,11 @@ private void startForeground() {
targetIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
targetIntent.putExtra(EXTRA_DEVICE_ADDRESS, mDeviceAddress);
targetIntent.putExtra(EXTRA_DEVICE_NAME, mDeviceName);
final PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, targetIntent, PendingIntent.FLAG_UPDATE_CURRENT);
int flags = PendingIntent.FLAG_UPDATE_CURRENT;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
flags |= PendingIntent.FLAG_IMMUTABLE;
}
final PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, targetIntent, flags);
builder.setContentIntent(pendingIntent);
} else {
logw("getNotificationTarget() should not return null if the service is to be started as a foreground service");
Expand Down