Skip to content

Commit

Permalink
Fix issues in stub APK
Browse files Browse the repository at this point in the history
  • Loading branch information
topjohnwu committed Oct 12, 2019
1 parent f3d7f85 commit b05b688
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 28 deletions.
7 changes: 1 addition & 6 deletions stub/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package="com.topjohnwu.magisk">

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.INTERNET"/>

<application tools:ignore="GoogleAppIndexingWarning"
android:allowBackup="true">
Expand All @@ -16,11 +17,5 @@
</intent-filter>
</activity>

<receiver android:name=".BootLauncher">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>

</application>
</manifest>
16 changes: 0 additions & 16 deletions stub/src/main/java/com/topjohnwu/magisk/BootLauncher.java

This file was deleted.

19 changes: 13 additions & 6 deletions stub/src/main/java/com/topjohnwu/magisk/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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;
Expand All @@ -16,16 +17,19 @@

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();
}

Expand All @@ -35,10 +39,13 @@ protected void onCreate(Bundle savedInstanceState) {
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)
Expand All @@ -54,7 +61,7 @@ public void onResponse(JSONObject json) {
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)
Expand Down

0 comments on commit b05b688

Please sign in to comment.