Skip to content

Commit 05e9a53

Browse files
author
F43nd1r
committed
backport oreo fixes to acra 4
1 parent 3af731a commit 05e9a53

9 files changed

+37
-20
lines changed

acra/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ apply plugin: 'com.jfrog.artifactory'
66

77
android {
88
compileSdkVersion Integer.parseInt(androidVersion)
9-
buildToolsVersion '25.0.2'
109

1110
lintOptions {
1211
abortOnError false
1312
}
1413

1514
defaultConfig {
16-
minSdkVersion 8
15+
minSdkVersion 14
1716
targetSdkVersion androidVersion
1817
versionName version
1918
consumerProguardFile proguardFile
@@ -26,7 +25,8 @@ android {
2625
}
2726

2827
dependencies {
29-
compile "com.android.support:support-v4:$supportVersion"
28+
compile "com.android.support:support-compat:$supportVersion"
29+
compile "com.android.support:support-fragment:$supportVersion"
3030
compile "com.android.support:support-annotations:$supportVersion"
3131
annotationProcessor project(':annotationprocessor')
3232
provided project(':annotations')

acra/gradle.properties

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
version=4.10.0
2-
group=com.faendir
1+
version=4.11
2+
group=ch.acra
33
archivesBaseName=acra
4-
androidVersion=24
5-
supportVersion=24.1.1
4+
androidVersion=27
5+
supportVersion=27.1.0
66
proguardFile=src/main/proguard/proguard.cfg
77
release.useAutomaticVersion=true
88
ossrhUser=

acra/src/main/AndroidManifest.xml

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
1818
package="ch.acra.acra">
1919

20+
<uses-permission android:name="android.permission.WAKE_LOCK"/>
21+
2022
<application>
2123
<activity
2224
android:name="org.acra.dialog.CrashReportDialog"
@@ -29,6 +31,7 @@
2931
<service
3032
android:name="org.acra.sender.SenderService"
3133
android:exported="false"
34+
android:permission="android.permission.BIND_JOB_SERVICE"
3235
android:process=":acra" />
3336

3437
<provider

acra/src/main/java/org/acra/builder/ReportExecutor.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.content.Context;
77
import android.content.Intent;
88
import android.content.SharedPreferences;
9+
import android.os.Build;
910
import android.os.Debug;
1011
import android.os.Looper;
1112
import android.support.annotation.NonNull;
@@ -125,10 +126,13 @@ public void execute(@NonNull final ReportBuilder reportBuilder) {
125126
reportPrimer.primeReport(context, reportBuilder);
126127

127128
boolean sendOnlySilentReports = false;
128-
final ReportingInteractionMode reportingInteractionMode;
129+
ReportingInteractionMode reportingInteractionMode;
129130
if (!reportBuilder.isSendSilently()) {
130131
// No interaction mode defined in the ReportBuilder, we assume it has been set during ACRA.initACRA()
131132
reportingInteractionMode = config.reportingInteractionMode();
133+
if (reportingInteractionMode == ReportingInteractionMode.NOTIFICATION && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
134+
reportingInteractionMode = ReportingInteractionMode.SILENT;
135+
}
132136
} else {
133137
reportingInteractionMode = ReportingInteractionMode.SILENT;
134138

acra/src/main/java/org/acra/sender/SenderService.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import android.content.Intent;
2020
import android.support.annotation.NonNull;
2121
import android.support.annotation.Nullable;
22+
import android.support.v4.app.JobIntentService;
2223

2324
import org.acra.ACRA;
2425
import org.acra.ACRAConstants;
@@ -34,22 +35,21 @@
3435

3536
import static org.acra.ACRA.LOG_TAG;
3637

37-
public class SenderService extends IntentService {
38+
public class SenderService extends JobIntentService {
3839

3940
public static final String EXTRA_ONLY_SEND_SILENT_REPORTS = "onlySendSilentReports";
4041
public static final String EXTRA_APPROVE_REPORTS_FIRST = "approveReportsFirst";
4142
public static final String EXTRA_ACRA_CONFIG = "acraConfig";
4243

43-
private final ReportLocator locator = new ReportLocator(this);
44+
private final ReportLocator locator;
4445

4546
public SenderService() {
46-
super("ACRA SenderService");
47-
setIntentRedelivery(true);
47+
locator = new ReportLocator(this);
4848
}
4949

5050
@Override
51-
protected void onHandleIntent(@Nullable final Intent intent) {
52-
if (intent == null || !intent.hasExtra(EXTRA_ACRA_CONFIG)) {
51+
protected void onHandleWork(@NonNull final Intent intent) {
52+
if (!intent.hasExtra(EXTRA_ACRA_CONFIG)) {
5353
if(ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "SenderService was started but no valid intent was delivered, will now quit");
5454
return;
5555
}

acra/src/main/java/org/acra/sender/SenderServiceStarter.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.content.Context;
44
import android.content.Intent;
55
import android.support.annotation.NonNull;
6+
import android.support.v4.app.JobIntentService;
67

78
import org.acra.ACRA;
89
import org.acra.config.ACRAConfiguration;
@@ -30,10 +31,10 @@ public SenderServiceStarter(@NonNull Context context, @NonNull ACRAConfiguration
3031
*/
3132
public void startService(boolean onlySendSilentReports, boolean approveReportsFirst) {
3233
if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "About to start SenderService");
33-
final Intent intent = new Intent(context, SenderService.class);
34+
final Intent intent = new Intent();
3435
intent.putExtra(SenderService.EXTRA_ONLY_SEND_SILENT_REPORTS, onlySendSilentReports);
3536
intent.putExtra(SenderService.EXTRA_APPROVE_REPORTS_FIRST, approveReportsFirst);
3637
intent.putExtra(SenderService.EXTRA_ACRA_CONFIG, config);
37-
context.startService(intent);
38+
JobIntentService.enqueueWork(context, SenderService.class, 0, intent);
3839
}
3940
}

acra/src/main/java/org/acra/util/ApplicationStartupProcessor.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import android.content.Context;
44
import android.content.SharedPreferences;
55
import android.content.pm.PackageInfo;
6+
import android.os.Handler;
7+
import android.os.Looper;
68
import android.support.annotation.NonNull;
79
import android.widget.Toast;
810
import org.acra.ACRA;
@@ -79,7 +81,12 @@ public void sendApprovedReports() {
7981

8082
// Send the approved reports.
8183
final SenderServiceStarter starter = new SenderServiceStarter(context, config);
82-
starter.startService(false, false);
84+
new Handler(Looper.getMainLooper()).post(new Runnable() {
85+
@Override
86+
public void run() {
87+
starter.startService(false, false);
88+
}
89+
});
8390

8491
}
8592

build.gradle

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
buildscript {
44
repositories {
55
jcenter()
6+
google()
67
}
78
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.3.3'
9+
classpath 'com.android.tools.build:gradle:3.1.0-rc02'
910
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
1011
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.4.0"
1112
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.9.0"
@@ -21,6 +22,7 @@ apply plugin: 'io.codearte.nexus-staging'
2122
allprojects {
2223
repositories {
2324
jcenter()
25+
google()
2426
}
2527
}
2628

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Fri Feb 17 03:38:03 CET 2017
1+
#Wed Mar 21 18:52:10 CET 2018
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

0 commit comments

Comments
 (0)