mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-28 04:25:27 +00:00
Add beta update channel
This commit is contained in:
parent
02e0955924
commit
4e3787bc0d
@ -12,11 +12,14 @@ import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.topjohnwu.magisk.asyncs.CheckUpdates;
|
||||
import com.topjohnwu.magisk.asyncs.DownloadBusybox;
|
||||
import com.topjohnwu.magisk.asyncs.ParallelTask;
|
||||
import com.topjohnwu.magisk.database.RepoDatabaseHelper;
|
||||
import com.topjohnwu.magisk.database.SuDatabaseHelper;
|
||||
import com.topjohnwu.magisk.module.Module;
|
||||
import com.topjohnwu.magisk.superuser.SuReceiver;
|
||||
import com.topjohnwu.magisk.superuser.SuRequestActivity;
|
||||
import com.topjohnwu.magisk.utils.SafetyNetHelper;
|
||||
import com.topjohnwu.magisk.utils.Shell;
|
||||
import com.topjohnwu.magisk.utils.Topic;
|
||||
@ -88,6 +91,7 @@ public class MagiskManager extends Application {
|
||||
public int suNotificationType;
|
||||
public int suNamespaceMode;
|
||||
public String localeConfig;
|
||||
public int updateChannel;
|
||||
|
||||
// Global resources
|
||||
public SharedPreferences prefs;
|
||||
@ -154,14 +158,15 @@ public class MagiskManager extends Application {
|
||||
|
||||
// su
|
||||
suRequestTimeout = Utils.getPrefsInt(prefs, "su_request_timeout", 10);
|
||||
suResponseType = Utils.getPrefsInt(prefs, "su_auto_response", 0);
|
||||
suNotificationType = Utils.getPrefsInt(prefs, "su_notification", 1);
|
||||
suResponseType = Utils.getPrefsInt(prefs, "su_auto_response", SuRequestActivity.PROMPT);
|
||||
suNotificationType = Utils.getPrefsInt(prefs, "su_notification", SuReceiver.TOAST);
|
||||
suReauth = prefs.getBoolean("su_reauth", false);
|
||||
suAccessState = suDB.getSettings(SuDatabaseHelper.ROOT_ACCESS, 3);
|
||||
multiuserMode = suDB.getSettings(SuDatabaseHelper.MULTIUSER_MODE, 0);
|
||||
suNamespaceMode = suDB.getSettings(SuDatabaseHelper.MNT_NS, 1);
|
||||
suAccessState = suDB.getSettings(SuDatabaseHelper.ROOT_ACCESS, SuDatabaseHelper.ROOT_ACCESS_APPS_AND_ADB);
|
||||
multiuserMode = suDB.getSettings(SuDatabaseHelper.MULTIUSER_MODE, SuDatabaseHelper.MULTIUSER_MODE_OWNER_ONLY);
|
||||
suNamespaceMode = suDB.getSettings(SuDatabaseHelper.MNT_NS, SuDatabaseHelper.NAMESPACE_MODE_REQUESTER);
|
||||
|
||||
updateNotification = prefs.getBoolean("notification", true);
|
||||
updateChannel = Utils.getPrefsInt(prefs, "update_channel", CheckUpdates.STABLE_CHANNEL);
|
||||
}
|
||||
|
||||
public void toast(String msg, int duration) {
|
||||
@ -192,6 +197,7 @@ public class MagiskManager extends Application {
|
||||
.putString("su_access", String.valueOf(suAccessState))
|
||||
.putString("multiuser_mode", String.valueOf(multiuserMode))
|
||||
.putString("mnt_ns", String.valueOf(suNamespaceMode))
|
||||
.putString("update_channel", String.valueOf(updateChannel))
|
||||
.putString("busybox_version", BUSYBOX_VERSION)
|
||||
.putString("locale", localeConfig)
|
||||
.apply();
|
||||
|
@ -14,6 +14,7 @@ import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.topjohnwu.magisk.asyncs.CheckUpdates;
|
||||
import com.topjohnwu.magisk.asyncs.HideManager;
|
||||
import com.topjohnwu.magisk.components.Activity;
|
||||
import com.topjohnwu.magisk.database.SuDatabaseHelper;
|
||||
@ -76,7 +77,8 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
|
||||
private SharedPreferences prefs;
|
||||
private PreferenceScreen prefScreen;
|
||||
|
||||
private ListPreference suAccess, autoRes, suNotification, requestTimeout, multiuserMode, namespaceMode;
|
||||
private ListPreference updateChannel, suAccess, autoRes, suNotification,
|
||||
requestTimeout, multiuserMode, namespaceMode;
|
||||
private MagiskManager magiskManager;
|
||||
private PreferenceCategory generalCatagory;
|
||||
|
||||
@ -93,6 +95,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
|
||||
PreferenceCategory suCategory = (PreferenceCategory) findPreference("superuser");
|
||||
PreferenceCategory developer = (PreferenceCategory) findPreference("developer");
|
||||
|
||||
updateChannel = (ListPreference) findPreference("update_channel");
|
||||
suAccess = (ListPreference) findPreference("su_access");
|
||||
autoRes = (ListPreference) findPreference("su_auto_response");
|
||||
requestTimeout = (ListPreference) findPreference("su_request_timeout");
|
||||
@ -224,25 +227,25 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
|
||||
}
|
||||
break;
|
||||
case "su_access":
|
||||
magiskManager.suAccessState = Utils.getPrefsInt(prefs, "su_access", 3);
|
||||
magiskManager.suAccessState = Utils.getPrefsInt(prefs, "su_access");
|
||||
magiskManager.suDB.setSettings(SuDatabaseHelper.ROOT_ACCESS, magiskManager.suAccessState);
|
||||
break;
|
||||
case "multiuser_mode":
|
||||
magiskManager.multiuserMode = Utils.getPrefsInt(prefs, "multiuser_mode", 0);
|
||||
magiskManager.multiuserMode = Utils.getPrefsInt(prefs, "multiuser_mode");
|
||||
magiskManager.suDB.setSettings(SuDatabaseHelper.MULTIUSER_MODE, magiskManager.multiuserMode);
|
||||
break;
|
||||
case "mnt_ns":
|
||||
magiskManager.suNamespaceMode = Utils.getPrefsInt(prefs, "mnt_ns", 1);
|
||||
magiskManager.suNamespaceMode = Utils.getPrefsInt(prefs, "mnt_ns");
|
||||
magiskManager.suDB.setSettings(SuDatabaseHelper.MNT_NS, magiskManager.suNamespaceMode);
|
||||
break;
|
||||
case "su_request_timeout":
|
||||
magiskManager.suRequestTimeout = Utils.getPrefsInt(prefs, "su_request_timeout", 10);
|
||||
magiskManager.suRequestTimeout = Utils.getPrefsInt(prefs, "su_request_timeout");
|
||||
break;
|
||||
case "su_auto_response":
|
||||
magiskManager.suResponseType = Utils.getPrefsInt(prefs, "su_auto_response", 0);
|
||||
magiskManager.suResponseType = Utils.getPrefsInt(prefs, "su_auto_response");
|
||||
break;
|
||||
case "su_notification":
|
||||
magiskManager.suNotificationType = Utils.getPrefsInt(prefs, "su_notification", 1);
|
||||
magiskManager.suNotificationType = Utils.getPrefsInt(prefs, "su_notification");
|
||||
break;
|
||||
case "developer_logging":
|
||||
MagiskManager.devLogging = prefs.getBoolean("developer_logging", false);
|
||||
@ -254,6 +257,10 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
|
||||
magiskManager.setLocale();
|
||||
magiskManager.reloadActivity.publish(false);
|
||||
break;
|
||||
case "update_channel":
|
||||
magiskManager.updateChannel = Utils.getPrefsInt(prefs, "update_channel");
|
||||
new CheckUpdates(magiskManager, true).exec();
|
||||
break;
|
||||
}
|
||||
setSummary();
|
||||
}
|
||||
@ -263,6 +270,8 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
|
||||
}
|
||||
|
||||
private void setSummary() {
|
||||
updateChannel.setSummary(getResources()
|
||||
.getStringArray(R.array.update_channel)[magiskManager.updateChannel]);
|
||||
suAccess.setSummary(getResources()
|
||||
.getStringArray(R.array.su_access)[magiskManager.suAccessState]);
|
||||
autoRes.setSummary(getResources()
|
||||
|
@ -12,7 +12,11 @@ import org.json.JSONObject;
|
||||
|
||||
public class CheckUpdates extends ParallelTask<Void, Void, Void> {
|
||||
|
||||
private static final String UPDATE_JSON = "https://raw.githubusercontent.com/topjohnwu/MagiskManager/update/magisk_update.json";
|
||||
public static final int STABLE_CHANNEL = 0;
|
||||
public static final int BETA_CHANNEL = 1;
|
||||
|
||||
private static final String STABLE_URL = "https://raw.githubusercontent.com/topjohnwu/MagiskManager/update/stable.json";
|
||||
private static final String BETA_URL = "https://raw.githubusercontent.com/topjohnwu/MagiskManager/update/beta.json";
|
||||
|
||||
private boolean showNotification = false;
|
||||
|
||||
@ -29,7 +33,17 @@ public class CheckUpdates extends ParallelTask<Void, Void, Void> {
|
||||
protected Void doInBackground(Void... voids) {
|
||||
MagiskManager magiskManager = getMagiskManager();
|
||||
if (magiskManager == null) return null;
|
||||
String jsonStr = WebService.getString(UPDATE_JSON);
|
||||
String jsonStr;
|
||||
switch (magiskManager.updateChannel) {
|
||||
case STABLE_CHANNEL:
|
||||
jsonStr = WebService.getString(STABLE_URL);
|
||||
break;
|
||||
case BETA_CHANNEL:
|
||||
jsonStr = WebService.getString(BETA_URL);
|
||||
break;
|
||||
default:
|
||||
jsonStr = null;
|
||||
}
|
||||
try {
|
||||
JSONObject json = new JSONObject(jsonStr);
|
||||
JSONObject magisk = json.getJSONObject("magisk");
|
||||
|
@ -24,8 +24,20 @@ import java.util.List;
|
||||
public class SuDatabaseHelper extends SQLiteOpenHelper {
|
||||
|
||||
public static final String ROOT_ACCESS = "root_access";
|
||||
public static final int ROOT_ACCESS_DISABLED = 0;
|
||||
public static final int ROOT_ACCESS_APPS_ONLY = 1;
|
||||
public static final int ROOT_ACCESS_ADB_ONLY = 2;
|
||||
public static final int ROOT_ACCESS_APPS_AND_ADB = 3;
|
||||
|
||||
public static final String MULTIUSER_MODE = "multiuser_mode";
|
||||
public static final int MULTIUSER_MODE_OWNER_ONLY = 0;
|
||||
public static final int MULTIUSER_MODE_OWNER_MANAGED = 1;
|
||||
public static final int MULTIUSER_MODE_USER = 2;
|
||||
|
||||
public static final String MNT_NS = "mnt_ns";
|
||||
public static final int NAMESPACE_MODE_GLOBAL = 0;
|
||||
public static final int NAMESPACE_MODE_REQUESTER = 1;
|
||||
public static final int NAMESPACE_MODE_ISOLATE = 2;
|
||||
|
||||
private static final int DATABASE_VER = 3;
|
||||
private static final String POLICY_TABLE = "policies";
|
||||
|
@ -14,8 +14,9 @@ import java.util.Date;
|
||||
|
||||
public class SuReceiver extends BroadcastReceiver {
|
||||
|
||||
private static final int NO_NOTIFICATION = 0;
|
||||
private static final int TOAST = 1;
|
||||
public static final int NO_NOTIFICATION = 0;
|
||||
public static final int TOAST = 1;
|
||||
|
||||
private static final int NOTIFY_NORMAL_LOG = 0;
|
||||
private static final int NOTIFY_USER_TOASTS = 1;
|
||||
private static final int NOTIFY_USER_TO_OWNER = 2;
|
||||
|
@ -30,10 +30,11 @@ import butterknife.ButterKnife;
|
||||
|
||||
public class SuRequestActivity extends Activity {
|
||||
|
||||
public static final int PROMPT = 0;
|
||||
public static final int AUTO_DENY = 1;
|
||||
public static final int AUTO_ALLOW = 2;
|
||||
|
||||
private static final int[] timeoutList = {0, -1, 10, 20, 30, 60};
|
||||
private static final int PROMPT = 0;
|
||||
private static final int AUTO_DENY = 1;
|
||||
private static final int AUTO_ALLOW = 2;
|
||||
|
||||
@BindView(R.id.su_popup) LinearLayout suPopup;
|
||||
@BindView(R.id.timeout) Spinner timeout;
|
||||
|
@ -132,6 +132,10 @@ public class Utils {
|
||||
return Integer.parseInt(prefs.getString(key, String.valueOf(def)));
|
||||
}
|
||||
|
||||
public static int getPrefsInt(SharedPreferences prefs, String key) {
|
||||
return getPrefsInt(prefs, key, 0);
|
||||
}
|
||||
|
||||
public static MagiskManager getMagiskManager(Context context) {
|
||||
return (MagiskManager) context.getApplicationContext();
|
||||
}
|
||||
|
@ -14,7 +14,6 @@
|
||||
<item>@string/settings_su_app</item>
|
||||
<item>@string/settings_su_adb</item>
|
||||
<item>@string/settings_su_app_adb</item>
|
||||
|
||||
</string-array>
|
||||
|
||||
<string-array name="value_array">
|
||||
@ -73,4 +72,9 @@
|
||||
<item>@string/isolate_summary</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="update_channel">
|
||||
<item>@string/settings_update_stable</item>
|
||||
<item>@string/settings_update_beta</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
@ -151,6 +151,9 @@
|
||||
<string name="settings_hide_manager_summary">Temporarily hide Magisk Manager.\nThis will install a new app called \"Unhide Magisk Manager\"</string>
|
||||
<string name="language">Language</string>
|
||||
<string name="system_default">(System Default)</string>
|
||||
<string name="settings_update_channel_title">Update Channel</string>
|
||||
<string name="settings_update_stable">Stable</string>
|
||||
<string name="settings_update_beta">Beta</string>
|
||||
|
||||
<string name="settings_core_only_title">Magisk Core Only Mode</string>
|
||||
<string name="settings_core_only_summary">Enable only core features, all modules will not be loaded. MagiskSU, MagiskHide, and systemless hosts will still be enabled</string>
|
||||
|
@ -15,6 +15,12 @@
|
||||
android:title="@string/settings_notification_title"
|
||||
android:summary="@string/settings_notification_summary" />
|
||||
|
||||
<ListPreference
|
||||
android:key="update_channel"
|
||||
android:title="@string/settings_update_channel_title"
|
||||
android:entries="@array/update_channel"
|
||||
android:entryValues="@array/value_array" />
|
||||
|
||||
<Preference
|
||||
android:key="clear"
|
||||
android:title="@string/settings_clear_cache_title"
|
||||
|
Loading…
Reference in New Issue
Block a user