@@ -117,6 +117,7 @@ public class MainActivity extends ActionBarActivity implements NetworkRadar.Targ
117117 private long mLastBackPressTime = 0 ;
118118 private ActionMode mActionMode = null ;
119119 private ListView lv ;
120+ private boolean isRootMissing = false ;
120121
121122 private void createUpdateStatusText () {
122123 if (mUpdateStatus != null ) return ;
@@ -243,7 +244,37 @@ public void run() {
243244 });
244245 }
245246
247+ private boolean startCore () {
248+ isRootMissing = false ;
249+ try {
250+ System .initCore ();
251+
252+ return true ;
253+ } catch (System .SuException e ) {
254+ onInitializationError (getString (R .string .only_4_root ));
255+ isRootMissing = true ;
256+ } catch (System .DaemonException e ) {
257+ Logger .error (e .getMessage ());
258+ }
259+
260+ return false ;
261+ }
262+
263+ private void onCoreBeating () {
264+ if (Client .hadCrashed ()) {
265+ Logger .warning ("Client has previously crashed, building a crash report." );
266+ CrashReporter .notifyNativeLibraryCrash ();
267+ onInitializationError (getString (R .string .JNI_crash_detected ));
268+ }
269+ }
270+
246271 private void onCoreUpdated () {
272+ if (startCore ()) {
273+ onCoreBeating ();
274+ } else if ( isRootMissing ) {
275+ return ;
276+ }
277+
247278 MainActivity .this .runOnUiThread (new Runnable () {
248279 @ Override
249280 public void run () {
@@ -338,21 +369,12 @@ public void run() {
338369 boolean coreBeating = System .isCoreInitialized ();
339370
340371 if (coreInstalled && !coreBeating ) {
341- try {
342- System .initCore ();
343- coreBeating = true ;
344-
345- if (Client .hadCrashed ()) {
346- Logger .warning ("Client has previously crashed, building a crash report." );
347- CrashReporter .notifyNativeLibraryCrash ();
348- onInitializationError (getString (R .string .JNI_crash_detected ));
372+ coreBeating = startCore ();
373+ if (coreBeating ) {
374+ onCoreBeating ();
375+ } else if ( isRootMissing ) {
376+ return ;
349377 }
350- } catch (System .SuException e ) {
351- onInitializationError (getString (R .string .only_4_root ));
352- return ;
353- } catch (System .DaemonException e ) {
354- Logger .error (e .getMessage ());
355- }
356378 }
357379
358380 if (!connectivityAvailable ) {
0 commit comments