tilakMDS / acra

Automatically exported from code.google.com/p/acra
0 stars 0 forks source link

If acra.alwaysaccept preference is set, ACRA sends report without waiting for DIALOG output #143

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In the "old" NOTIFICATION mode, ACRA would not require any user interaction and 
just send the report immediately if the preference acra.alwaysaccept was set.

With the DIALOG mode, the report is also sent immediately, but the dialog is 
still shown, and its output ignored (leading the the following warning in the 
log).

09-24 11:08:49.320: DEBUG/ACRA(18980): Add user comment to 
1348477711000.stacktrace
09-24 11:08:49.365: WARN/ACRA(18980): User comment not added:
        java.io.FileNotFoundException: /data/data/com.frogsparks.mytrails/files/1348477711000.stacktrace: open failed: ENOENT (No such file or directory)
        at libcore.io.IoBridge.open(IoBridge.java:416)
        at java.io.FileInputStream.<init>(FileInputStream.java:78)
        at android.app.ContextImpl.openFileInput(ContextImpl.java:786)
        at android.content.ContextWrapper.openFileInput(ContextWrapper.java:166)
        at org.acra.CrashReportPersister.load(CrashReportPersister.java:63)
        at org.acra.CrashReportDialog$1.onClick(CrashReportDialog.java:150)
        at android.view.View.performClick(View.java:4211)
        at android.view.View$PerformClick.run(View.java:17267)
        at android.os.Handler.handleCallback(Handler.java:615)
        at android.os.Handler.dispatchMessage(Handler.java:92)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4898)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
        at dalvik.system.NativeStart.main(Native Method)
        Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
        at libcore.io.Posix.open(Native Method)
        at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
        at libcore.io.IoBridge.open(IoBridge.java:400)
        ... 16 more

ACRA should not display the dialog when that pref is set.

Original issue reported on code.google.com by pa...@paour.com on 24 Sep 2012 at 9:18

GoogleCodeExporter commented 9 years ago

Original comment by kevin.gaudin on 24 Sep 2012 at 10:11

GoogleCodeExporter commented 9 years ago
Fixed in this snapshot:
https://oss.sonatype.org/content/repositories/snapshots/ch/acra/acra/4.3.1-SNAPS
HOT/acra-4.3.1-20120925.193215-1.jar

Please test it and confirm that it's working for you. I'll publish an updated 
release then.

Thanks for reporting this.

Kevin

Original comment by kevin.gaudin on 25 Sep 2012 at 7:37

GoogleCodeExporter commented 9 years ago
Hi Kevin,

I have verified the fix: in autoaccept mode, the dialog is no longer shown.

However, this snapshot contains another change that is causing issues for me: I 
used to wrap the call to ACRA.init() in a check for whether the app is 
debuggable. When I do that, the latest snapshot throws state exceptions when I 
try to get the ErrorReporter instance (if ACRA wasn't initialized).

So I switched to using sendReportsInDevMode=true, but this doesn't do what I 
need, which is disable ACRA entirely (no error dialog). Would it be possible to 
either return to relaxed checks, or add another flag, like disableAcraInDevMode?

Original comment by pa...@paour.com on 26 Sep 2012 at 8:29

GoogleCodeExporter commented 9 years ago
Could you please copy here the failing init code ?

Original comment by kevin.gaudin on 4 Oct 2012 at 5:10

GoogleCodeExporter commented 9 years ago
        debuggable = ((getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) > 0);

        if (!debuggable) { 
            ACRA.init(this);
        } else {
            Log.d(MyTrails.APPTAG, TAG + "onCreate debuggable: disabling ACRA");
        }

        super.onCreate();

        instance = this;

        ErrorReporter reporter = ErrorReporter.getInstance();  // causes an InvalidStateException because ACRA.init() hasn't been called
        reporter.putCustomData("version", getString(R.string.version));
        reporter.putCustomData("build", getString(R.string.revision));

Original comment by pa...@paour.com on 4 Oct 2012 at 7:34

GoogleCodeExporter commented 9 years ago
There's something strange... 

I really did only modify the issue with the DIALOG showing in this snapshot.

ErrorReporter.getInstance() does not exist anymore in ACRA 4.3. You should be 
using ACRA.getErrorReporter().

Then, it makes no sense trying to get the ErrorReporter if ACRA.init() has not 
been called as it would return null. Your calls to putCustomData would crash.

Original comment by kevin.gaudin on 11 Oct 2012 at 10:41

GoogleCodeExporter commented 9 years ago
When I look at the method signature for ErrorReporter.getInstance() in the jar 
for 4.3 (release) that I use in my shipping app (and I did verify it was 4.3.0 
by looking at the maven manifest in the jar), it shows that it is still there, 
but deprecated (and with a functional change).

I'll switch to using ACRA.getErrorReporter, but you may want to actually remove 
that method, since the functional change causes an exception (so better to 
catch the change at compile- rather than run-time).

Original comment by pa...@paour.com on 12 Oct 2012 at 7:57

GoogleCodeExporter commented 9 years ago
Actually, ACRA.getErrorReporter doesn't just return null when ACRA.init() 
hasn't been called, it also throws an IllegalStateException...

Original comment by pa...@paour.com on 12 Oct 2012 at 2:35

GoogleCodeExporter commented 9 years ago
It does not return anything since it throws an exception.
I was just saying that if it did not throw an exception, then it could only 
return null... and that would make your code crash anyway.

Though, I have to think about your idea of a disableAcraInDevMode.

Another option could be to do this:
ACRA.init(this);
if(debuggable) {
    ACRA.getErrorReporter().setEnabled(false);
}

ErrorReporter.setEnabled() is the method which is called when a 
SharedPreference change occurs to enable/disable ACRA. Dialogs are not 
displayed if it is set to false.

Original comment by kevin.gaudin on 13 Oct 2012 at 12:22

GoogleCodeExporter commented 9 years ago
Good idea, I'll do that.

Original comment by pa...@paour.com on 15 Oct 2012 at 8:28

GoogleCodeExporter commented 9 years ago
Delivered in v4.3.1: https://github.com/downloads/ACRA/acra/acra-4.3.1.zip

Original comment by kevin.gaudin on 16 Oct 2012 at 9:14