Skip to content

Commit 594f18c

Browse files
committed
core initialization does not belong to the update task ( closes #247 , merge #248 )
1 parent d06a4ac commit 594f18c

2 files changed

Lines changed: 36 additions & 21 deletions

File tree

cSploit/src/org/csploit/android/MainActivity.java

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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) {

cSploit/src/org/csploit/android/core/UpdateService.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,8 +1430,6 @@ protected void onHandleIntent(Intent intent) {
14301430
installGems();
14311431
else if (what_to_do == action.gems_update)
14321432
updateGems();
1433-
else if (what_to_do == action.core_update)
1434-
System.initCore();
14351433

14361434
deleteTemporaryFiles();
14371435
createVersionFile();
@@ -1482,11 +1480,6 @@ else if (what_to_do == action.core_update)
14821480
} catch (ChildManager.ChildDiedException e) {
14831481
sendError(what_to_do, R.string.error_occured);
14841482
System.errorLogging(e);
1485-
} catch (System.SuException e) {
1486-
sendError(what_to_do, R.string.only_4_root);
1487-
} catch (System.DaemonException e) {
1488-
sendError(what_to_do, R.string.heart_attack);
1489-
Logger.error(e.getMessage());
14901483
} finally {
14911484
if(exitForError) {
14921485
if(what_to_do == action.msf_update || what_to_do == action.gems_update)

0 commit comments

Comments
 (0)