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,14 +209,9 @@ public class FDroidApp extends Application {
|
||||
updateLanguage();
|
||||
|
||||
ACRA.init(this);
|
||||
// if this is the ACRA process, do not run the rest of onCreate()
|
||||
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)) {
|
||||
if (isAcraProcess()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
private BluetoothAdapter getBluetoothAdapter() {
|
||||
// to use the new, recommended way of getting the adapter
|
||||
|
Loading…
x
Reference in New Issue
Block a user