Add version code to downloaded upgrades
This commit is contained in:
parent
691dc1d49e
commit
860b08d9ed
@ -40,7 +40,7 @@ public class ManagerUpdate extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
intent.getStringExtra(Const.Key.INTENT_SET_LINK),
|
intent.getStringExtra(Const.Key.INTENT_SET_LINK),
|
||||||
Utils.fmt("MagiskManager-v%s.apk", intent.getStringExtra(Const.Key.INTENT_SET_VERSION))
|
intent.getStringExtra(Const.Key.INTENT_SET_FILENAME)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ public class Const {
|
|||||||
|
|
||||||
// intents
|
// intents
|
||||||
public static final String OPEN_SECTION = "section";
|
public static final String OPEN_SECTION = "section";
|
||||||
public static final String INTENT_SET_VERSION = "version";
|
public static final String INTENT_SET_FILENAME = "filename";
|
||||||
public static final String INTENT_SET_LINK = "link";
|
public static final String INTENT_SET_LINK = "link";
|
||||||
public static final String INTENT_PERM = "perm_dialog";
|
public static final String INTENT_PERM = "perm_dialog";
|
||||||
public static final String FLASH_ACTION = "action";
|
public static final String FLASH_ACTION = "action";
|
||||||
|
@ -59,10 +59,12 @@ public class ShowUI {
|
|||||||
|
|
||||||
public static void managerUpdateNotification() {
|
public static void managerUpdateNotification() {
|
||||||
MagiskManager mm = MagiskManager.get();
|
MagiskManager mm = MagiskManager.get();
|
||||||
|
String filename = Utils.fmt("MagiskManager-v%s(%d).apk",
|
||||||
|
mm.remoteManagerVersionString, mm.remoteManagerVersionCode);
|
||||||
|
|
||||||
Intent intent = new Intent(mm, ManagerUpdate.class);
|
Intent intent = new Intent(mm, ManagerUpdate.class);
|
||||||
intent.putExtra(Const.Key.INTENT_SET_LINK, mm.managerLink);
|
intent.putExtra(Const.Key.INTENT_SET_LINK, mm.managerLink);
|
||||||
intent.putExtra(Const.Key.INTENT_SET_VERSION, mm.remoteManagerVersionString);
|
intent.putExtra(Const.Key.INTENT_SET_FILENAME, filename);
|
||||||
PendingIntent pendingIntent = PendingIntent.getBroadcast(mm,
|
PendingIntent pendingIntent = PendingIntent.getBroadcast(mm,
|
||||||
Const.ID.APK_UPDATE_NOTIFICATION_ID, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
Const.ID.APK_UPDATE_NOTIFICATION_ID, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
|
||||||
@ -100,7 +102,8 @@ public class ShowUI {
|
|||||||
|
|
||||||
public static void magiskInstallDialog(Activity activity) {
|
public static void magiskInstallDialog(Activity activity) {
|
||||||
MagiskManager mm = Utils.getMagiskManager(activity);
|
MagiskManager mm = Utils.getMagiskManager(activity);
|
||||||
String filename = Utils.fmt("Magisk-v%s.zip", mm.remoteMagiskVersionString);
|
String filename = Utils.fmt("Magisk-v%s(%d).zip",
|
||||||
|
mm.remoteMagiskVersionString, mm.remoteMagiskVersionCode);
|
||||||
new AlertDialogBuilder(activity)
|
new AlertDialogBuilder(activity)
|
||||||
.setTitle(mm.getString(R.string.repo_install_title, mm.getString(R.string.magisk)))
|
.setTitle(mm.getString(R.string.repo_install_title, mm.getString(R.string.magisk)))
|
||||||
.setMessage(mm.getString(R.string.repo_install_msg, filename))
|
.setMessage(mm.getString(R.string.repo_install_msg, filename))
|
||||||
@ -206,12 +209,7 @@ public class ShowUI {
|
|||||||
};
|
};
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
Utils.dlAndReceive(
|
Utils.dlAndReceive(activity, receiver, mm.magiskLink, filename);
|
||||||
activity,
|
|
||||||
receiver,
|
|
||||||
mm.magiskLink,
|
|
||||||
filename
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
).show();
|
).show();
|
||||||
})
|
})
|
||||||
@ -228,16 +226,17 @@ public class ShowUI {
|
|||||||
|
|
||||||
public static void managerInstallDialog(Activity activity) {
|
public static void managerInstallDialog(Activity activity) {
|
||||||
MagiskManager mm = Utils.getMagiskManager(activity);
|
MagiskManager mm = Utils.getMagiskManager(activity);
|
||||||
|
String filename = Utils.fmt("MagiskManager-v%s(%d).apk",
|
||||||
|
mm.remoteManagerVersionString, mm.remoteManagerVersionCode);
|
||||||
new AlertDialogBuilder(activity)
|
new AlertDialogBuilder(activity)
|
||||||
.setTitle(mm.getString(R.string.repo_install_title, mm.getString(R.string.app_name)))
|
.setTitle(mm.getString(R.string.repo_install_title, mm.getString(R.string.app_name)))
|
||||||
.setMessage(mm.getString(R.string.repo_install_msg,
|
.setMessage(mm.getString(R.string.repo_install_msg, filename))
|
||||||
Utils.fmt("MagiskManager-v%s.apk", mm.remoteManagerVersionString)))
|
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setPositiveButton(R.string.install, (d, i) -> {
|
.setPositiveButton(R.string.install, (d, i) -> {
|
||||||
Utils.runWithPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE, () -> {
|
Utils.runWithPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE, () -> {
|
||||||
Intent intent = new Intent(mm, ManagerUpdate.class);
|
Intent intent = new Intent(mm, ManagerUpdate.class);
|
||||||
intent.putExtra(Const.Key.INTENT_SET_LINK, mm.managerLink);
|
intent.putExtra(Const.Key.INTENT_SET_LINK, mm.managerLink);
|
||||||
intent.putExtra(Const.Key.INTENT_SET_VERSION, mm.remoteManagerVersionString);
|
intent.putExtra(Const.Key.INTENT_SET_FILENAME, filename);
|
||||||
mm.sendBroadcast(intent);
|
mm.sendBroadcast(intent);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
@ -82,9 +82,8 @@ public class Utils {
|
|||||||
|
|
||||||
public static String getLegalFilename(CharSequence filename) {
|
public static String getLegalFilename(CharSequence filename) {
|
||||||
return filename.toString().replace(" ", "_").replace("'", "").replace("\"", "")
|
return filename.toString().replace(" ", "_").replace("'", "").replace("\"", "")
|
||||||
.replace("$", "").replace("`", "").replace("(", "").replace(")", "")
|
.replace("$", "").replace("`", "").replace("*", "").replace("/", "_")
|
||||||
.replace("#", "").replace("@", "").replace("*", "").replace("/", "_")
|
.replace("#", "").replace("@", "").replace("\\", "_");
|
||||||
.replace("\\", "_");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getPrefsInt(SharedPreferences prefs, String key, int def) {
|
public static int getPrefsInt(SharedPreferences prefs, String key, int def) {
|
||||||
|
Loading…
Reference in New Issue
Block a user