mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-24 10:35:26 +00:00
Add Superuser settings
This commit is contained in:
parent
09bdbc1224
commit
cd4dfc9861
@ -28,6 +28,7 @@ public class Global {
|
|||||||
public static String bootBlock = null;
|
public static String bootBlock = null;
|
||||||
public static boolean isSuClient = false;
|
public static boolean isSuClient = false;
|
||||||
public static String suVersion = null;
|
public static String suVersion = null;
|
||||||
|
public static int shellUid;
|
||||||
}
|
}
|
||||||
public static class Data {
|
public static class Data {
|
||||||
public static ValueSortedMap<String, Repo> repoMap = new ValueSortedMap<>();
|
public static ValueSortedMap<String, Repo> repoMap = new ValueSortedMap<>();
|
||||||
@ -47,9 +48,11 @@ public class Global {
|
|||||||
public static boolean isDarkTheme;
|
public static boolean isDarkTheme;
|
||||||
public static boolean shellLogging;
|
public static boolean shellLogging;
|
||||||
public static boolean devLogging;
|
public static boolean devLogging;
|
||||||
public static int suRequestTimeout = 10;
|
public static int suRequestTimeout;
|
||||||
public static int suLogTimeout = 14;
|
public static int suLogTimeout = 14;
|
||||||
|
public static int suAccessState;
|
||||||
|
public static int suResponseType;
|
||||||
|
public static int suNotificationType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init(Context context) {
|
public static void init(Context context) {
|
||||||
@ -63,6 +66,34 @@ public class Global {
|
|||||||
Info.isSuClient = Info.suVersion.toUpperCase().contains("MAGISK");
|
Info.isSuClient = Info.suVersion.toUpperCase().contains("MAGISK");
|
||||||
}
|
}
|
||||||
updateMagiskInfo();
|
updateMagiskInfo();
|
||||||
|
initSuConfigs(context);
|
||||||
|
// Initialize prefs
|
||||||
|
prefs.edit()
|
||||||
|
.putBoolean("magiskhide", Utils.itemExist(false, "/magisk/.core/magiskhide/enable"))
|
||||||
|
.putBoolean("busybox", Utils.commandExists("busybox"))
|
||||||
|
.putBoolean("hosts", Utils.itemExist(false, "/magisk/.core/hosts"))
|
||||||
|
.putString("su_request_timeout", String.valueOf(Configs.suRequestTimeout))
|
||||||
|
.putString("su_auto_response", String.valueOf(Configs.suResponseType))
|
||||||
|
.putString("su_notification", String.valueOf(Configs.suNotificationType))
|
||||||
|
.putString("su_access", String.valueOf(Configs.suAccessState))
|
||||||
|
.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void initSuConfigs(Context context) {
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
List<String> ret = Shell.sh("getprop persist.sys.root_access");
|
||||||
|
if (Utils.isValidShellResponse(ret))
|
||||||
|
Configs.suAccessState = Integer.parseInt(ret.get(0));
|
||||||
|
else {
|
||||||
|
Shell.su("setprop persist.sys.root_access 3");
|
||||||
|
Configs.suAccessState = 3;
|
||||||
|
}
|
||||||
|
Configs.suRequestTimeout = Utils.getPrefsInt(prefs, "su_request_timeout", 10);
|
||||||
|
Configs.suResponseType = Utils.getPrefsInt(prefs, "su_auto_response", 0);
|
||||||
|
Configs.suNotificationType = Utils.getPrefsInt(prefs, "su_notification", 1);
|
||||||
|
ret = Shell.sh("id -u shell");
|
||||||
|
if (Utils.isValidShellResponse(ret))
|
||||||
|
Info.shellUid = Integer.parseInt(ret.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void updateMagiskInfo() {
|
static void updateMagiskInfo() {
|
||||||
|
@ -6,6 +6,7 @@ import android.preference.CheckBoxPreference;
|
|||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.preference.PreferenceScreen;
|
||||||
import android.preference.SwitchPreference;
|
import android.preference.SwitchPreference;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
@ -29,8 +30,6 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
String theme = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("theme", "");
|
|
||||||
Logger.dev("AboutActivity: Theme is " + theme);
|
|
||||||
if (Global.Configs.isDarkTheme) {
|
if (Global.Configs.isDarkTheme) {
|
||||||
setTheme(R.style.AppTheme_dh);
|
setTheme(R.style.AppTheme_dh);
|
||||||
}
|
}
|
||||||
@ -74,6 +73,7 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
implements SharedPreferences.OnSharedPreferenceChangeListener {
|
implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
private SharedPreferences prefs;
|
private SharedPreferences prefs;
|
||||||
|
private PreferenceScreen prefScreen;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@ -81,6 +81,7 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
addPreferencesFromResource(R.xml.app_settings);
|
addPreferencesFromResource(R.xml.app_settings);
|
||||||
PreferenceManager.setDefaultValues(getActivity(), R.xml.app_settings, false);
|
PreferenceManager.setDefaultValues(getActivity(), R.xml.app_settings, false);
|
||||||
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||||
|
prefScreen = getPreferenceScreen();
|
||||||
|
|
||||||
CheckBoxPreference busyboxPreference = (CheckBoxPreference) findPreference("busybox");
|
CheckBoxPreference busyboxPreference = (CheckBoxPreference) findPreference("busybox");
|
||||||
CheckBoxPreference magiskhidePreference = (CheckBoxPreference) findPreference("magiskhide");
|
CheckBoxPreference magiskhidePreference = (CheckBoxPreference) findPreference("magiskhide");
|
||||||
@ -122,21 +123,21 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
|
||||||
Logger.dev("Settings: Prefs change " + key);
|
Logger.dev("Settings: Prefs change " + key);
|
||||||
boolean checked;
|
boolean enabled;
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "dark_theme":
|
case "dark_theme":
|
||||||
checked = prefs.getBoolean("dark_theme", false);
|
enabled = prefs.getBoolean("dark_theme", false);
|
||||||
if (Global.Configs.isDarkTheme != checked) {
|
if (Global.Configs.isDarkTheme != enabled) {
|
||||||
Global.Configs.isDarkTheme = checked;
|
Global.Configs.isDarkTheme = enabled;
|
||||||
getActivity().recreate();
|
getActivity().recreate();
|
||||||
Global.Events.reloadMainActivity.trigger();
|
Global.Events.reloadMainActivity.trigger();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "magiskhide":
|
case "magiskhide":
|
||||||
checked = prefs.getBoolean("magiskhide", false);
|
enabled = prefs.getBoolean("magiskhide", false);
|
||||||
new Async.RootTask<Void, Void, Void>() {
|
new Async.RootTask<Void, Void, Void>() {
|
||||||
private boolean enable = checked;
|
private boolean enable = enabled;
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
protected Void doInBackground(Void... params) {
|
||||||
if (enable) {
|
if (enable) {
|
||||||
@ -151,9 +152,9 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
Toast.makeText(getActivity(), R.string.settings_reboot_toast, Toast.LENGTH_LONG).show();
|
Toast.makeText(getActivity(), R.string.settings_reboot_toast, Toast.LENGTH_LONG).show();
|
||||||
break;
|
break;
|
||||||
case "busybox":
|
case "busybox":
|
||||||
checked = prefs.getBoolean("busybox", false);
|
enabled = prefs.getBoolean("busybox", false);
|
||||||
new Async.RootTask<Void, Void, Void>() {
|
new Async.RootTask<Void, Void, Void>() {
|
||||||
private boolean enable = checked;
|
private boolean enable = enabled;
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
protected Void doInBackground(Void... params) {
|
||||||
if (enable) {
|
if (enable) {
|
||||||
@ -167,9 +168,9 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
Toast.makeText(getActivity(), R.string.settings_reboot_toast, Toast.LENGTH_LONG).show();
|
Toast.makeText(getActivity(), R.string.settings_reboot_toast, Toast.LENGTH_LONG).show();
|
||||||
break;
|
break;
|
||||||
case "hosts":
|
case "hosts":
|
||||||
checked = prefs.getBoolean("hosts", false);
|
enabled = prefs.getBoolean("hosts", false);
|
||||||
new Async.RootTask<Void, Void, Void>() {
|
new Async.RootTask<Void, Void, Void>() {
|
||||||
private boolean enable = checked;
|
private boolean enable = enabled;
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... voids) {
|
protected Void doInBackground(Void... voids) {
|
||||||
if (enable) {
|
if (enable) {
|
||||||
@ -183,6 +184,19 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
}.exec();
|
}.exec();
|
||||||
break;
|
break;
|
||||||
|
case "su_access":
|
||||||
|
Global.Configs.suAccessState = Utils.getPrefsInt(prefs, "su_access", 0);
|
||||||
|
Shell.su("setprop persist.sys.root_access " + Global.Configs.suAccessState);
|
||||||
|
break;
|
||||||
|
case "su_request_timeout":
|
||||||
|
Global.Configs.suRequestTimeout = Utils.getPrefsInt(prefs, "su_request_timeout", 10);
|
||||||
|
break;
|
||||||
|
case "su_auto_response":
|
||||||
|
Global.Configs.suResponseType = Utils.getPrefsInt(prefs, "su_auto_response", 0);
|
||||||
|
break;
|
||||||
|
case "su_notification":
|
||||||
|
Global.Configs.suNotificationType = Utils.getPrefsInt(prefs, "su_notification", 1);
|
||||||
|
break;
|
||||||
case "developer_logging":
|
case "developer_logging":
|
||||||
Global.Configs.devLogging = prefs.getBoolean("developer_logging", false);
|
Global.Configs.devLogging = prefs.getBoolean("developer_logging", false);
|
||||||
break;
|
break;
|
||||||
@ -190,7 +204,6 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
Global.Configs.shellLogging = prefs.getBoolean("shell_logging", false);
|
Global.Configs.shellLogging = prefs.getBoolean("shell_logging", false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import android.preference.PreferenceManager;
|
|||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
|
||||||
import com.topjohnwu.magisk.utils.Async;
|
import com.topjohnwu.magisk.utils.Async;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
|
||||||
|
|
||||||
public class SplashActivity extends AppCompatActivity {
|
public class SplashActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@ -23,13 +22,6 @@ public class SplashActivity extends AppCompatActivity {
|
|||||||
setTheme(R.style.AppTheme_dh);
|
setTheme(R.style.AppTheme_dh);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize prefs
|
|
||||||
prefs.edit()
|
|
||||||
.putBoolean("magiskhide", Utils.itemExist(false, "/magisk/.core/magiskhide/enable"))
|
|
||||||
.putBoolean("busybox", Utils.commandExists("busybox"))
|
|
||||||
.putBoolean("hosts", Utils.itemExist(false, "/magisk/.core/hosts"))
|
|
||||||
.apply();
|
|
||||||
|
|
||||||
// Start all async tasks
|
// Start all async tasks
|
||||||
new Async.GetBootBlocks().exec();
|
new Async.GetBootBlocks().exec();
|
||||||
new Async.CheckUpdates().exec();
|
new Async.CheckUpdates().exec();
|
||||||
|
@ -172,6 +172,7 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
|
|||||||
color = colorBad;
|
color = colorBad;
|
||||||
image = R.drawable.ic_cancel;
|
image = R.drawable.ic_cancel;
|
||||||
rootStatusText.setText(R.string.not_rooted);
|
rootStatusText.setText(R.string.not_rooted);
|
||||||
|
rootInfoText.setText(R.string.root_info_warning);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (Global.Info.suVersion != null) {
|
if (Global.Info.suVersion != null) {
|
||||||
@ -186,6 +187,7 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
|
|||||||
color = colorNeutral;
|
color = colorNeutral;
|
||||||
image = R.drawable.ic_help;
|
image = R.drawable.ic_help;
|
||||||
rootStatusText.setText(R.string.root_error);
|
rootStatusText.setText(R.string.root_error);
|
||||||
|
rootInfoText.setText(R.string.root_info_warning);
|
||||||
}
|
}
|
||||||
rootStatusContainer.setBackgroundColor(color);
|
rootStatusContainer.setBackgroundColor(color);
|
||||||
rootStatusText.setTextColor(color);
|
rootStatusText.setTextColor(color);
|
||||||
|
@ -117,8 +117,6 @@ public class PolicyAdapter extends RecyclerView.Adapter<PolicyAdapter.ViewHolder
|
|||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
policyList.remove(position);
|
policyList.remove(position);
|
||||||
dbHelper.deletePolicy(policy.uid);
|
dbHelper.deletePolicy(policy.uid);
|
||||||
notifyItemRemoved(position);
|
|
||||||
notifyItemRangeChanged(position, policyList.size());
|
|
||||||
onBindViewHolder(holder, position);
|
onBindViewHolder(holder, position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ public class SuLogAdapter {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
holder.appName.setText(logEntry.appName);
|
holder.appName.setText(logEntry.appName);
|
||||||
holder.action.setText(logEntry.action ? context.getString(R.string.grant) : context.getString(R.string.deny, ""));
|
holder.action.setText(context.getString(logEntry.action ? R.string.grant : R.string.deny));
|
||||||
holder.command.setText(logEntry.command);
|
holder.command.setText(logEntry.command);
|
||||||
holder.fromPid.setText(String.valueOf(logEntry.fromPid));
|
holder.fromPid.setText(String.valueOf(logEntry.fromPid));
|
||||||
holder.toUid.setText(String.valueOf(logEntry.toUid));
|
holder.toUid.setText(String.valueOf(logEntry.toUid));
|
||||||
|
@ -4,12 +4,16 @@ import android.content.Intent;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.Global;
|
||||||
|
|
||||||
public class RequestActivity extends AppCompatActivity {
|
public class RequestActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
Global.initSuConfigs(this);
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
if (intent == null) {
|
if (intent == null) {
|
||||||
finish();
|
finish();
|
||||||
|
@ -6,11 +6,17 @@ import android.content.Intent;
|
|||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.Global;
|
||||||
import com.topjohnwu.magisk.R;
|
import com.topjohnwu.magisk.R;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class SuReceiver extends BroadcastReceiver {
|
public class SuReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
|
private static final int NO_NOTIFICATION = 0;
|
||||||
|
private static final int TOAST = 1;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
int fromUid, toUid, pid;
|
int fromUid, toUid, pid;
|
||||||
@ -34,9 +40,11 @@ public class SuReceiver extends BroadcastReceiver {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Global.initSuConfigs(context);
|
||||||
|
|
||||||
SuLogEntry log = new SuLogEntry(policy);
|
SuLogEntry log = new SuLogEntry(policy);
|
||||||
|
|
||||||
if (policy.notification) {
|
if (policy.notification && Global.Configs.suNotificationType == TOAST) {
|
||||||
String message;
|
String message;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case "allow":
|
case "allow":
|
||||||
|
@ -34,6 +34,10 @@ public class SuRequestActivity extends AppCompatActivity {
|
|||||||
private final static int SU_PROTOCOL_NAME_MAX = 20;
|
private final static int SU_PROTOCOL_NAME_MAX = 20;
|
||||||
private final static int SU_PROTOCOL_VALUE_MAX = 256;
|
private final static int SU_PROTOCOL_VALUE_MAX = 256;
|
||||||
|
|
||||||
|
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.su_popup) LinearLayout suPopup;
|
||||||
@BindView(R.id.timeout) Spinner timeout;
|
@BindView(R.id.timeout) Spinner timeout;
|
||||||
@BindView(R.id.app_icon) ImageView appIcon;
|
@BindView(R.id.app_icon) ImageView appIcon;
|
||||||
@ -64,24 +68,41 @@ public class SuRequestActivity extends AppCompatActivity {
|
|||||||
new SocketManager().execute();
|
new SocketManager().execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateUI() throws Throwable {
|
void showRequest() {
|
||||||
|
|
||||||
|
packageName = info.packageName;
|
||||||
|
appName = info.applicationInfo.loadLabel(pm).toString();
|
||||||
|
|
||||||
|
switch (Global.Configs.suResponseType) {
|
||||||
|
case AUTO_DENY:
|
||||||
|
handleAction(false, 0);
|
||||||
|
return;
|
||||||
|
case AUTO_ALLOW:
|
||||||
|
handleAction(true, 0);
|
||||||
|
return;
|
||||||
|
case PROMPT:
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
setContentView(R.layout.activity_request);
|
setContentView(R.layout.activity_request);
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.timeout, android.R.layout.simple_spinner_item);
|
|
||||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
|
||||||
timeout.setAdapter(adapter);
|
|
||||||
appIcon.setImageDrawable(info.applicationInfo.loadIcon(pm));
|
appIcon.setImageDrawable(info.applicationInfo.loadIcon(pm));
|
||||||
appNameView.setText(appName);
|
appNameView.setText(appName);
|
||||||
packageNameView.setText(packageName);
|
packageNameView.setText(packageName);
|
||||||
|
|
||||||
|
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.allow_timeout, android.R.layout.simple_spinner_item);
|
||||||
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
|
timeout.setAdapter(adapter);
|
||||||
|
|
||||||
timer = new CountDownTimer(Global.Configs.suRequestTimeout * 1000, 1000) {
|
timer = new CountDownTimer(Global.Configs.suRequestTimeout * 1000, 1000) {
|
||||||
@Override
|
@Override
|
||||||
public void onTick(long millisUntilFinished) {
|
public void onTick(long millisUntilFinished) {
|
||||||
deny_btn.setText(getString(R.string.deny, "(" + millisUntilFinished / 1000 + ")"));
|
deny_btn.setText(getString(R.string.deny_with_str, "(" + millisUntilFinished / 1000 + ")"));
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onFinish() {
|
public void onFinish() {
|
||||||
deny_btn.setText(getString(R.string.deny, "(0)"));
|
deny_btn.setText(getString(R.string.deny_with_str, "(0)"));
|
||||||
handleAction(false, -1);
|
handleAction(false, -1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -90,16 +111,15 @@ public class SuRequestActivity extends AppCompatActivity {
|
|||||||
deny_btn.setOnClickListener(v -> handleAction(false, timeoutList[timeout.getSelectedItemPosition()]));
|
deny_btn.setOnClickListener(v -> handleAction(false, timeoutList[timeout.getSelectedItemPosition()]));
|
||||||
suPopup.setOnClickListener((v) -> {
|
suPopup.setOnClickListener((v) -> {
|
||||||
timer.cancel();
|
timer.cancel();
|
||||||
deny_btn.setText(getString(R.string.deny, ""));
|
deny_btn.setText(getString(R.string.deny));
|
||||||
});
|
});
|
||||||
timeout.setOnTouchListener((v, event) -> {
|
timeout.setOnTouchListener((v, event) -> {
|
||||||
timer.cancel();
|
timer.cancel();
|
||||||
deny_btn.setText(getString(R.string.deny, ""));
|
deny_btn.setText(getString(R.string.deny));
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
timer.start();
|
timer.start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleAction(boolean action, int timeout) {
|
void handleAction(boolean action, int timeout) {
|
||||||
@ -175,14 +195,9 @@ public class SuRequestActivity extends AppCompatActivity {
|
|||||||
try {
|
try {
|
||||||
if (!result) throw new Throwable();
|
if (!result) throw new Throwable();
|
||||||
String[] pkgs = pm.getPackagesForUid(uid);
|
String[] pkgs = pm.getPackagesForUid(uid);
|
||||||
if (pkgs != null && pkgs.length > 0) {
|
if (pkgs == null || pkgs.length == 0) throw new Throwable();
|
||||||
info = pm.getPackageInfo(pkgs[0], 0);
|
info = pm.getPackageInfo(pkgs[0], 0);
|
||||||
packageName = pkgs[0];
|
showRequest();
|
||||||
appName = info.applicationInfo.loadLabel(pm).toString();
|
|
||||||
updateUI();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
throw new Throwable();
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
handleAction(false, -1);
|
handleAction(false, -1);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import android.app.AlertDialog;
|
|||||||
import android.app.DownloadManager;
|
import android.app.DownloadManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
@ -146,4 +147,8 @@ public class Utils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getPrefsInt(SharedPreferences prefs, String key, int def) {
|
||||||
|
return Integer.parseInt(prefs.getString(key, String.valueOf(def)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -99,7 +99,7 @@
|
|||||||
|
|
||||||
<Button
|
<Button
|
||||||
style="?android:buttonBarButtonStyle"
|
style="?android:buttonBarButtonStyle"
|
||||||
android:text="@string/deny"
|
android:text="@string/deny_with_str"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/deny_btn"
|
android:id="@+id/deny_btn"
|
||||||
|
@ -85,8 +85,6 @@
|
|||||||
<string name="settings_general_category">عام</string>
|
<string name="settings_general_category">عام</string>
|
||||||
<string name="settings_dark_theme_title">السمة</string>
|
<string name="settings_dark_theme_title">السمة</string>
|
||||||
<string name="settings_dark_theme_summary">أختر سمة</string>
|
<string name="settings_dark_theme_summary">أختر سمة</string>
|
||||||
<string name="theme_default">إفتراضي</string>
|
|
||||||
<string name="theme_dark">غامق</string>
|
|
||||||
|
|
||||||
<string name="settings_magiskhide_title">تمكين إخفاء Magisk</string>
|
<string name="settings_magiskhide_title">تمكين إخفاء Magisk</string>
|
||||||
<string name="settings_magiskhide_summary">إخفاء Magisk من مختلف حالات الإكتشاف</string>
|
<string name="settings_magiskhide_summary">إخفاء Magisk من مختلف حالات الإكتشاف</string>
|
||||||
|
@ -116,8 +116,6 @@
|
|||||||
<string name="settings_general_category">Allgemein</string>
|
<string name="settings_general_category">Allgemein</string>
|
||||||
<string name="settings_dark_theme_title">Thema</string>
|
<string name="settings_dark_theme_title">Thema</string>
|
||||||
<string name="settings_dark_theme_summary">Wähle ein Thema</string>
|
<string name="settings_dark_theme_summary">Wähle ein Thema</string>
|
||||||
<string name="theme_default">Standard</string>
|
|
||||||
<string name="theme_dark">Dunkel</string>
|
|
||||||
<string name="settings_clear_cache_title">Repo-Cache löschen</string>
|
<string name="settings_clear_cache_title">Repo-Cache löschen</string>
|
||||||
<string name="settings_clear_cache_summary">Löscht die gespeicherten Informtionen der Online-Repos, erzwingt eine Aktualisierung</string>
|
<string name="settings_clear_cache_summary">Löscht die gespeicherten Informtionen der Online-Repos, erzwingt eine Aktualisierung</string>
|
||||||
|
|
||||||
@ -138,7 +136,7 @@
|
|||||||
|
|
||||||
<!--Superuser-->
|
<!--Superuser-->
|
||||||
<string name="su_request_title">Superuser-Anfrage</string>
|
<string name="su_request_title">Superuser-Anfrage</string>
|
||||||
<string name="deny">Gewähren%1$s</string>
|
<string name="deny_with_str">Gewähren%1$s</string>
|
||||||
<string name="grant">Verweigern%1$s</string>
|
<string name="grant">Verweigern%1$s</string>
|
||||||
<string name="su_warning">Gewährt vollen Zugriff auf das Gerät.\nVerweigere, wenn du dir unsicher bist!</string>
|
<string name="su_warning">Gewährt vollen Zugriff auf das Gerät.\nVerweigere, wenn du dir unsicher bist!</string>
|
||||||
<string name="forever">Dauerhaft</string>
|
<string name="forever">Dauerhaft</string>
|
||||||
|
@ -82,8 +82,6 @@
|
|||||||
<string name="settings_general_category">General</string>
|
<string name="settings_general_category">General</string>
|
||||||
<string name="settings_dark_theme_title">Tema</string>
|
<string name="settings_dark_theme_title">Tema</string>
|
||||||
<string name="settings_dark_theme_summary">Selecciona un tema</string>
|
<string name="settings_dark_theme_summary">Selecciona un tema</string>
|
||||||
<string name="theme_default">Por defecto</string>
|
|
||||||
<string name="theme_dark">Oscuro</string>
|
|
||||||
|
|
||||||
<string name="settings_magiskhide_title">Habilitar Magisk Hide</string>
|
<string name="settings_magiskhide_title">Habilitar Magisk Hide</string>
|
||||||
<string name="settings_magiskhide_summary">Ocultar Magisk de varias detecciones</string>
|
<string name="settings_magiskhide_summary">Ocultar Magisk de varias detecciones</string>
|
||||||
|
@ -80,8 +80,6 @@
|
|||||||
<string name="settings_general_category">Generali</string>
|
<string name="settings_general_category">Generali</string>
|
||||||
<string name="settings_dark_theme_title">Tema</string>
|
<string name="settings_dark_theme_title">Tema</string>
|
||||||
<string name="settings_dark_theme_summary">Scegli un tema</string>
|
<string name="settings_dark_theme_summary">Scegli un tema</string>
|
||||||
<string name="theme_default">Default</string>
|
|
||||||
<string name="theme_dark">Scuro</string>
|
|
||||||
|
|
||||||
<string name="settings_busybox_title">Abilita BusyBox</string>
|
<string name="settings_busybox_title">Abilita BusyBox</string>
|
||||||
<string name="settings_busybox_summary">Make Magisk\'s built-in BusyBox be visible in PATH</string>
|
<string name="settings_busybox_summary">Make Magisk\'s built-in BusyBox be visible in PATH</string>
|
||||||
|
@ -80,8 +80,6 @@
|
|||||||
<string name="settings_general_category">Algemeen</string>
|
<string name="settings_general_category">Algemeen</string>
|
||||||
<string name="settings_dark_theme_title">Thema</string>
|
<string name="settings_dark_theme_title">Thema</string>
|
||||||
<string name="settings_dark_theme_summary">Selecteer een thema</string>
|
<string name="settings_dark_theme_summary">Selecteer een thema</string>
|
||||||
<string name="theme_default">Standaard</string>
|
|
||||||
<string name="theme_dark">Donker</string>
|
|
||||||
|
|
||||||
<string name="settings_busybox_title">Schakel BusyBox in</string>
|
<string name="settings_busybox_title">Schakel BusyBox in</string>
|
||||||
<string name="settings_busybox_summary">Maakt Magisk\'s ingebouwde BusyBox zichtbaar in PATH</string>
|
<string name="settings_busybox_summary">Maakt Magisk\'s ingebouwde BusyBox zichtbaar in PATH</string>
|
||||||
|
@ -111,8 +111,6 @@
|
|||||||
|
|
||||||
<!--Settings Activity -->
|
<!--Settings Activity -->
|
||||||
<string name="settings_general_category">Ogólne</string>
|
<string name="settings_general_category">Ogólne</string>
|
||||||
<string name="theme_default">Domyślny</string>
|
|
||||||
<string name="theme_dark">Ciemny</string>
|
|
||||||
<string name="settings_clear_cache_title">Wyczyść Cache Repozytorium</string>
|
<string name="settings_clear_cache_title">Wyczyść Cache Repozytorium</string>
|
||||||
<string name="settings_clear_cache_summary">Wyczyść cache dla repozytorium, wymusza odświeżenie online przez aplikację</string>
|
<string name="settings_clear_cache_summary">Wyczyść cache dla repozytorium, wymusza odświeżenie online przez aplikację</string>
|
||||||
|
|
||||||
@ -131,7 +129,7 @@
|
|||||||
|
|
||||||
<!--Superuser-->
|
<!--Superuser-->
|
||||||
<string name="su_request_title">Prośba dostępu Superusera</string>
|
<string name="su_request_title">Prośba dostępu Superusera</string>
|
||||||
<string name="deny">Odmów%1$s</string>
|
<string name="deny_with_str">Odmów%1$s</string>
|
||||||
<string name="grant">Przyznaj</string>
|
<string name="grant">Przyznaj</string>
|
||||||
<string name="su_warning">Udziela pełnego dostępu do urządzenia.\nOdmów jeśli nie jesteś pewien!</string>
|
<string name="su_warning">Udziela pełnego dostępu do urządzenia.\nOdmów jeśli nie jesteś pewien!</string>
|
||||||
<string name="forever">Zawsze</string>
|
<string name="forever">Zawsze</string>
|
||||||
|
@ -109,8 +109,6 @@
|
|||||||
<string name="settings_general_category">Geral</string>
|
<string name="settings_general_category">Geral</string>
|
||||||
<string name="settings_dark_theme_title">Tema</string>
|
<string name="settings_dark_theme_title">Tema</string>
|
||||||
<string name="settings_dark_theme_summary">Escolha um tema</string>
|
<string name="settings_dark_theme_summary">Escolha um tema</string>
|
||||||
<string name="theme_default">Padrão</string>
|
|
||||||
<string name="theme_dark">Escuro</string>
|
|
||||||
|
|
||||||
<string name="settings_magiskhide_title">Ativar Magisk Hide</string>
|
<string name="settings_magiskhide_title">Ativar Magisk Hide</string>
|
||||||
<string name="settings_magiskhide_summary">Ocultar Magisk de várias detecções</string>
|
<string name="settings_magiskhide_summary">Ocultar Magisk de várias detecções</string>
|
||||||
|
@ -106,8 +106,6 @@
|
|||||||
<string name="settings_general_category">常规</string>
|
<string name="settings_general_category">常规</string>
|
||||||
<string name="settings_dark_theme_title">主题</string>
|
<string name="settings_dark_theme_title">主题</string>
|
||||||
<string name="settings_dark_theme_summary">选择一个主题</string>
|
<string name="settings_dark_theme_summary">选择一个主题</string>
|
||||||
<string name="theme_default">默认</string>
|
|
||||||
<string name="theme_dark">深色</string>
|
|
||||||
|
|
||||||
<string name="settings_magiskhide_title">启用 Magisk 隐藏</string>
|
<string name="settings_magiskhide_title">启用 Magisk 隐藏</string>
|
||||||
<string name="settings_magiskhide_summary">隐藏 Magisk 使其不被多种方法检测到</string>
|
<string name="settings_magiskhide_summary">隐藏 Magisk 使其不被多种方法检测到</string>
|
||||||
|
@ -1,14 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string-array name="themes">
|
<string-array name="allow_timeout">
|
||||||
<item>@string/theme_default</item>
|
|
||||||
<item>@string/theme_dark</item>
|
|
||||||
</string-array>
|
|
||||||
<string-array name="themes_values">
|
|
||||||
<item>@string/theme_default_value</item>
|
|
||||||
<item>@string/theme_dark_value</item>
|
|
||||||
</string-array>
|
|
||||||
<string-array name="timeout">
|
|
||||||
<item>@string/forever</item>
|
<item>@string/forever</item>
|
||||||
<item>@string/once</item>
|
<item>@string/once</item>
|
||||||
<item>@string/tenmin</item>
|
<item>@string/tenmin</item>
|
||||||
@ -16,4 +8,45 @@
|
|||||||
<item>@string/thirtymin</item>
|
<item>@string/thirtymin</item>
|
||||||
<item>@string/sixtymin</item>
|
<item>@string/sixtymin</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="su_access">
|
||||||
|
<item>@string/settings_su_disable</item>
|
||||||
|
<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">
|
||||||
|
<item>0</item>
|
||||||
|
<item>1</item>
|
||||||
|
<item>2</item>
|
||||||
|
<item>3</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="request_timeout">
|
||||||
|
<item>@string/settings_su_request_10</item>
|
||||||
|
<item>@string/settings_su_request_20</item>
|
||||||
|
<item>@string/settings_su_request_30</item>
|
||||||
|
<item>@string/settings_su_request_60</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="request_timeout_value">
|
||||||
|
<item>10</item>
|
||||||
|
<item>20</item>
|
||||||
|
<item>30</item>
|
||||||
|
<item>60</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="auto_response">
|
||||||
|
<item>@string/prompt</item>
|
||||||
|
<item>@string/deny</item>
|
||||||
|
<item>@string/grant</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="su_notification">
|
||||||
|
<item>@string/none</item>
|
||||||
|
<item>@string/toast</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -122,32 +122,39 @@
|
|||||||
<!--Settings Activity -->
|
<!--Settings Activity -->
|
||||||
<string name="settings_general_category">General</string>
|
<string name="settings_general_category">General</string>
|
||||||
<string name="settings_dark_theme_title">Dark Theme</string>
|
<string name="settings_dark_theme_title">Dark Theme</string>
|
||||||
<string name="settings_dark_theme_summary">Toggle dark theme</string>
|
<string name="settings_dark_theme_summary">Enable dark theme</string>
|
||||||
<string name="theme_default">Default</string>
|
|
||||||
<string name="theme_dark">Dark</string>
|
|
||||||
<string name="settings_clear_cache_title">Clear Repo Cache</string>
|
<string name="settings_clear_cache_title">Clear Repo Cache</string>
|
||||||
<string name="settings_clear_cache_summary">Clear the cached information for online repos, forces the app to refresh online</string>
|
<string name="settings_clear_cache_summary">Clear the cached information for online repos, forces the app to refresh online</string>
|
||||||
|
|
||||||
<string name="settings_magiskhide_title">Enable Magisk Hide</string>
|
<string name="settings_magiskhide_title">Enable Magisk Hide</string>
|
||||||
<string name="settings_magiskhide_summary">Hide Magisk from various detections</string>
|
<string name="settings_magiskhide_summary">Hide Magisk from various detections\nRequires reboot</string>
|
||||||
<string name="settings_busybox_title">Enable BusyBox</string>
|
<string name="settings_busybox_title">Enable BusyBox</string>
|
||||||
<string name="settings_busybox_summary">Bind mount Magisk\'s built-in busybox to xbin</string>
|
<string name="settings_busybox_summary">Bind mount Magisk\'s built-in busybox to xbin\nRequires reboot</string>
|
||||||
<string name="settings_hosts_title">Enable systemless hosts</string>
|
<string name="settings_hosts_title">Enable systemless hosts</string>
|
||||||
<string name="settings_hosts_summary">Systemless support for Adblock apps</string>
|
<string name="settings_hosts_summary">Systemless support for Adblock apps</string>
|
||||||
|
|
||||||
<string name="settings_development_category">Development</string>
|
<string name="settings_su_app_adb">Apps and ADB</string>
|
||||||
|
<string name="settings_su_app">Apps only</string>
|
||||||
|
<string name="settings_su_adb">ADB only</string>
|
||||||
|
<string name="settings_su_disable">Disabled</string>
|
||||||
|
<string name="settings_su_request_10">10 seconds</string>
|
||||||
|
<string name="settings_su_request_20">20 seconds</string>
|
||||||
|
<string name="settings_su_request_30">30 seconds</string>
|
||||||
|
<string name="settings_su_request_60">60 seconds</string>
|
||||||
|
|
||||||
|
<string name="settings_development_category">App Development</string>
|
||||||
<string name="settings_developer_logging_title">Enable advanced debug logging</string>
|
<string name="settings_developer_logging_title">Enable advanced debug logging</string>
|
||||||
<string name="settings_developer_logging_summary">Check this to enable verbose logging</string>
|
<string name="settings_developer_logging_summary">Check this to enable verbose logging</string>
|
||||||
<string name="settings_shell_logging_title">Enable shell command debug logging</string>
|
<string name="settings_shell_logging_title">Enable shell command debug logging</string>
|
||||||
<string name="settings_shell_logging_summary">Check this to enable logging all shell commands and its output</string>
|
<string name="settings_shell_logging_summary">Check this to enable logging all shell commands and its output</string>
|
||||||
|
|
||||||
<!-- Themes -->
|
<!-- Themes -->
|
||||||
<string name="theme_default_value" translatable="false">default</string>
|
|
||||||
<string name="theme_dark_value" translatable="false">dark</string>
|
|
||||||
|
|
||||||
<!--Superuser-->
|
<!--Superuser-->
|
||||||
<string name="su_request_title">Superuser Request</string>
|
<string name="su_request_title">Superuser Request</string>
|
||||||
<string name="deny">Deny%1$s</string>
|
<string name="deny_with_str">Deny%1$s</string>
|
||||||
|
<string name="deny">Deny</string>
|
||||||
|
<string name="prompt">Prompt</string>
|
||||||
<string name="grant">Grant</string>
|
<string name="grant">Grant</string>
|
||||||
<string name="su_warning">Grants full access to your device.\nDeny if you\'re not sure!</string>
|
<string name="su_warning">Grants full access to your device.\nDeny if you\'re not sure!</string>
|
||||||
<string name="forever">Forever</string>
|
<string name="forever">Forever</string>
|
||||||
@ -168,6 +175,8 @@
|
|||||||
<string name="su_snack_revoke">%1$s rights are revoked</string>
|
<string name="su_snack_revoke">%1$s rights are revoked</string>
|
||||||
<string name="su_revoke_title">Revoke?</string>
|
<string name="su_revoke_title">Revoke?</string>
|
||||||
<string name="su_revoke_msg">Confirm to revoke %1$s rights?</string>
|
<string name="su_revoke_msg">Confirm to revoke %1$s rights?</string>
|
||||||
|
<string name="toast">Toast</string>
|
||||||
|
<string name="none">None</string>
|
||||||
|
|
||||||
<!--Superuser logs-->
|
<!--Superuser logs-->
|
||||||
<string name="pid">PID:\u0020</string>
|
<string name="pid">PID:\u0020</string>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:title="Magisk">
|
android:title="@string/magisk">
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="magiskhide"
|
android:key="magiskhide"
|
||||||
@ -40,16 +40,45 @@
|
|||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:title="@string/superuser">
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
android:key="su_access"
|
||||||
|
android:title="Superuser Access"
|
||||||
|
android:entries="@array/su_access"
|
||||||
|
android:entryValues="@array/value_array" />
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
android:key="su_auto_response"
|
||||||
|
android:title="Automatic Response"
|
||||||
|
android:entries="@array/auto_response"
|
||||||
|
android:entryValues="@array/value_array" />
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
android:key="su_request_timeout"
|
||||||
|
android:title="Request Timeout"
|
||||||
|
android:entries="@array/request_timeout"
|
||||||
|
android:entryValues="@array/request_timeout_value" />
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
android:key="su_notification"
|
||||||
|
android:title="Superuser Notification"
|
||||||
|
android:entries="@array/su_notification"
|
||||||
|
android:entryValues="@array/value_array" />
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:title="@string/settings_development_category">
|
android:title="@string/settings_development_category">
|
||||||
|
|
||||||
<CheckBoxPreference
|
<SwitchPreference
|
||||||
android:key="developer_logging"
|
android:key="developer_logging"
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:title="@string/settings_developer_logging_title"
|
android:title="@string/settings_developer_logging_title"
|
||||||
android:summary="@string/settings_developer_logging_summary" />
|
android:summary="@string/settings_developer_logging_summary" />
|
||||||
|
|
||||||
<CheckBoxPreference
|
<SwitchPreference
|
||||||
android:key="shell_logging"
|
android:key="shell_logging"
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:title="@string/settings_shell_logging_title"
|
android:title="@string/settings_shell_logging_title"
|
||||||
|
Loading…
Reference in New Issue
Block a user