Fix issues in stub APK
This commit is contained in:
parent
f3d7f85063
commit
b05b688267
@ -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">
|
||||
@ -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>
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user