From b05b68826799ee104288e0f137c963d8761f8a5b Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sat, 12 Oct 2019 03:57:56 -0400 Subject: [PATCH] Fix issues in stub APK --- stub/src/main/AndroidManifest.xml | 7 +------ .../com/topjohnwu/magisk/BootLauncher.java | 16 ---------------- .../com/topjohnwu/magisk/MainActivity.java | 19 +++++++++++++------ 3 files changed, 14 insertions(+), 28 deletions(-) delete mode 100644 stub/src/main/java/com/topjohnwu/magisk/BootLauncher.java diff --git a/stub/src/main/AndroidManifest.xml b/stub/src/main/AndroidManifest.xml index 96be5b68d..6a0bfc6d1 100644 --- a/stub/src/main/AndroidManifest.xml +++ b/stub/src/main/AndroidManifest.xml @@ -3,6 +3,7 @@ package="com.topjohnwu.magisk"> + @@ -16,11 +17,5 @@ - - - - - - diff --git a/stub/src/main/java/com/topjohnwu/magisk/BootLauncher.java b/stub/src/main/java/com/topjohnwu/magisk/BootLauncher.java deleted file mode 100644 index 39390d026..000000000 --- a/stub/src/main/java/com/topjohnwu/magisk/BootLauncher.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.topjohnwu.magisk; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.text.TextUtils; - -public class BootLauncher extends BroadcastReceiver { - @Override - public void onReceive(Context context, Intent intent) { - if (TextUtils.equals(intent.getAction(), Intent.ACTION_BOOT_COMPLETED)) { - Intent i = new Intent(context, MainActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - context.startActivity(i); - } - } -} diff --git a/stub/src/main/java/com/topjohnwu/magisk/MainActivity.java b/stub/src/main/java/com/topjohnwu/magisk/MainActivity.java index 4c0be34d8..2d6e8b325 100644 --- a/stub/src/main/java/com/topjohnwu/magisk/MainActivity.java +++ b/stub/src/main/java/com/topjohnwu/magisk/MainActivity.java @@ -4,6 +4,7 @@ import android.app.Activity; import android.app.AlertDialog; import android.app.Application; import android.os.Bundle; +import android.util.Log; import com.topjohnwu.magisk.utils.APKInstall; import com.topjohnwu.magisk.net.Networking; @@ -16,16 +17,19 @@ import java.io.File; public class MainActivity extends Activity { + private static final String TAG = "MMStub"; + private static final boolean IS_CANARY = BuildConfig.VERSION_NAME.contains("-"); private static final String URL = - "https://raw.githubusercontent.com/topjohnwu/magisk_files/master/" + - (BuildConfig.VERSION_NAME.contains("-") ? "canary_builds/release.json" : "stable.json"); + "https://raw.githubusercontent.com/topjohnwu/magisk_files/" + + (IS_CANARY ? "canary/release.json" : "master/stable.json"); private String apkLink; private void dlAPK() { Application app = getApplication(); Networking.get(apkLink) - .getAsFile(new File(getFilesDir(), "manager.apk"), apk -> APKInstall.install(app, apk)); + .getAsFile(new File(getFilesDir(), "manager.apk"), + apk -> APKInstall.install(app, apk)); finish(); } @@ -35,10 +39,13 @@ public class MainActivity extends Activity { Networking.init(this); if (Networking.checkNetworkStatus(this)) { Networking.get(URL) - .setErrorHandler(((conn, e) -> finish())) + .setErrorHandler(((conn, e) -> { + Log.d(TAG, "network error", e); + finish(); + })) .getAsJSONObject(new JSONLoader()); } else { - new AlertDialog.Builder(this, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT) + new AlertDialog.Builder(this) .setCancelable(false) .setTitle(R.string.app_name) .setMessage(R.string.no_internet_msg) @@ -54,7 +61,7 @@ public class MainActivity extends Activity { try { JSONObject manager = json.getJSONObject("app"); apkLink = manager.getString("link"); - new AlertDialog.Builder(MainActivity.this, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT) + new AlertDialog.Builder(MainActivity.this) .setCancelable(false) .setTitle(R.string.app_name) .setMessage(R.string.upgrade_msg)