Extract code to check for ACRA process into method
Makes it easier to document the code and simplifies FDroidApp#onCreate().
This commit is contained in:
parent
2428a89288
commit
e2e1d3111c
@ -209,13 +209,8 @@ public class FDroidApp extends Application {
|
|||||||
updateLanguage();
|
updateLanguage();
|
||||||
|
|
||||||
ACRA.init(this);
|
ACRA.init(this);
|
||||||
// if this is the ACRA process, do not run the rest of onCreate()
|
if (isAcraProcess()) {
|
||||||
int pid = android.os.Process.myPid();
|
return;
|
||||||
ActivityManager manager = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE);
|
|
||||||
for (RunningAppProcessInfo processInfo : manager.getRunningAppProcesses()) {
|
|
||||||
if (processInfo.pid == pid && "org.fdroid.fdroid:acra".equals(processInfo.processName)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PRNGFixes.apply();
|
PRNGFixes.apply();
|
||||||
@ -317,6 +312,26 @@ public class FDroidApp extends Application {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asks if the current process is "org.fdroid.fdroid:acra". Note that it is not perfect, because
|
||||||
|
* some devices seem to not provide a list of running app processes when asked.
|
||||||
|
*
|
||||||
|
* The `android:process` statement in AndroidManifest.xml causes another process to be created
|
||||||
|
* to run {@link org.fdroid.fdroid.acra.CrashReportActivity}. This was causing lots of things
|
||||||
|
* to be started/run twice including {@link CleanCacheService} and {@link WifiStateChangeService}.
|
||||||
|
*/
|
||||||
|
private boolean isAcraProcess() {
|
||||||
|
int pid = android.os.Process.myPid();
|
||||||
|
ActivityManager manager = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE);
|
||||||
|
for (RunningAppProcessInfo processInfo : manager.getRunningAppProcesses()) {
|
||||||
|
if (processInfo.pid == pid && "org.fdroid.fdroid:acra".equals(processInfo.processName)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@TargetApi(18)
|
@TargetApi(18)
|
||||||
private BluetoothAdapter getBluetoothAdapter() {
|
private BluetoothAdapter getBluetoothAdapter() {
|
||||||
// to use the new, recommended way of getting the adapter
|
// to use the new, recommended way of getting the adapter
|
||||||
|
Loading…
x
Reference in New Issue
Block a user