Set ACRA install source
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
c905ef6083
commit
520df16885
@ -69,9 +69,10 @@ public class Application extends android.app.Application {
|
|||||||
* check the DN of the certs that signed the apk, without even bothering to try
|
* check the DN of the certs that signed the apk, without even bothering to try
|
||||||
* validating that they're authentic. It's a good enough heuristic.
|
* validating that they're authentic. It's a good enough heuristic.
|
||||||
*/
|
*/
|
||||||
private static boolean shouldEnableCrashReporting(final Context context) {
|
@Nullable
|
||||||
|
private static String getInstallSource(final Context context) {
|
||||||
if (BuildConfig.DEBUG)
|
if (BuildConfig.DEBUG)
|
||||||
return false;
|
return null;
|
||||||
try {
|
try {
|
||||||
final CertificateFactory cf = CertificateFactory.getInstance("X509");
|
final CertificateFactory cf = CertificateFactory.getInstance("X509");
|
||||||
for (final Signature sig : context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_SIGNATURES).signatures) {
|
for (final Signature sig : context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_SIGNATURES).signatures) {
|
||||||
@ -82,21 +83,25 @@ public class Application extends android.app.Application {
|
|||||||
continue;
|
continue;
|
||||||
switch (parts[1]) {
|
switch (parts[1]) {
|
||||||
case "Google Inc.":
|
case "Google Inc.":
|
||||||
|
return "Play Store";
|
||||||
case "fdroid.org":
|
case "fdroid.org":
|
||||||
return true;
|
return "F-Droid";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (final Exception ignored) { }
|
} catch (final Exception ignored) { }
|
||||||
}
|
}
|
||||||
} catch (final Exception ignored) { }
|
} catch (final Exception ignored) { }
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void attachBaseContext(final Context context) {
|
protected void attachBaseContext(final Context context) {
|
||||||
super.attachBaseContext(context);
|
super.attachBaseContext(context);
|
||||||
if (shouldEnableCrashReporting(context))
|
final String installSource = getInstallSource(context);
|
||||||
|
if (installSource != null) {
|
||||||
ACRA.init(this);
|
ACRA.init(this);
|
||||||
|
ACRA.getErrorReporter().putCustomData("installSource", installSource);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Application get() {
|
public static Application get() {
|
||||||
@ -165,9 +170,11 @@ public class Application extends android.app.Application {
|
|||||||
|
|
||||||
asyncWorker.supplyAsync(Application::getBackend).thenAccept(backend -> {
|
asyncWorker.supplyAsync(Application::getBackend).thenAccept(backend -> {
|
||||||
futureBackend.complete(backend);
|
futureBackend.complete(backend);
|
||||||
ACRA.getErrorReporter().putCustomData("backend", backend.getClass().getSimpleName());
|
if (ACRA.isInitialised()) {
|
||||||
asyncWorker.supplyAsync(backend::getVersion).thenAccept(version ->
|
ACRA.getErrorReporter().putCustomData("backend", backend.getClass().getSimpleName());
|
||||||
ACRA.getErrorReporter().putCustomData("backendVersion", version));
|
asyncWorker.supplyAsync(backend::getVersion).thenAccept(version ->
|
||||||
|
ACRA.getErrorReporter().putCustomData("backendVersion", version));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user