mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-28 04:25:27 +00:00
Improve multiuser settings and notification
This commit is contained in:
parent
2a7d996881
commit
44e36feb09
@ -83,6 +83,12 @@ public class SettingsActivity extends Activity {
|
||||
|
||||
setSummary();
|
||||
|
||||
// Disable dangerous settings in user mode if selected owner manage
|
||||
if (getActivity().getApplicationInfo().uid > 99999) {
|
||||
prefScreen.removePreference(magiskCategory);
|
||||
prefScreen.removePreference(suCategory);
|
||||
}
|
||||
|
||||
findPreference("clear").setOnPreferenceClickListener((pref) -> {
|
||||
Utils.clearRepoCache(getActivity());
|
||||
return true;
|
||||
|
@ -17,11 +17,13 @@ public class SuReceiver extends BroadcastReceiver {
|
||||
|
||||
private static final int NO_NOTIFICATION = 0;
|
||||
private 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;
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
int fromUid, toUid, pid;
|
||||
int fromUid, toUid, pid, mode;
|
||||
String command, action;
|
||||
Policy policy;
|
||||
|
||||
@ -29,6 +31,14 @@ public class SuReceiver extends BroadcastReceiver {
|
||||
|
||||
if (intent == null) return;
|
||||
|
||||
mode = intent.getIntExtra("mode", -1);
|
||||
if (mode < 0) return;
|
||||
|
||||
if (mode == NOTIFY_USER_TO_OWNER) {
|
||||
magiskManager.toast(R.string.multiuser_hint_owner_request, Toast.LENGTH_LONG);
|
||||
return;
|
||||
}
|
||||
|
||||
fromUid = intent.getIntExtra("from.uid", -1);
|
||||
if (fromUid < 0) return;
|
||||
if (fromUid == Process.myUid()) return; // Don't show anything if it's Magisk Manager
|
||||
@ -64,10 +74,11 @@ public class SuReceiver extends BroadcastReceiver {
|
||||
return;
|
||||
}
|
||||
|
||||
if (policy.notification && magiskManager.suNotificationType == TOAST)
|
||||
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
|
||||
if (policy.notification && magiskManager.suNotificationType == TOAST) {
|
||||
magiskManager.toast(message, Toast.LENGTH_SHORT);
|
||||
}
|
||||
|
||||
if (policy.logging) {
|
||||
if (mode == NOTIFY_NORMAL_LOG && policy.logging) {
|
||||
toUid = intent.getIntExtra("to.uid", -1);
|
||||
if (toUid < 0) return;
|
||||
pid = intent.getIntExtra("pid", -1);
|
||||
|
@ -55,6 +55,7 @@ public class SuRequestActivity extends Activity implements CallbackEvent.Listene
|
||||
private MagiskManager magiskManager;
|
||||
|
||||
private int uid;
|
||||
private boolean hasTimeout;
|
||||
private Policy policy;
|
||||
private CountDownTimer timer;
|
||||
private CallbackEvent.Listener<Policy> self;
|
||||
@ -70,6 +71,7 @@ public class SuRequestActivity extends Activity implements CallbackEvent.Listene
|
||||
|
||||
Intent intent = getIntent();
|
||||
socketPath = intent.getStringExtra("socket");
|
||||
hasTimeout = intent.getBooleanExtra("timeout", true);
|
||||
self = this;
|
||||
|
||||
new FileObserver(socketPath) {
|
||||
@ -87,7 +89,13 @@ public class SuRequestActivity extends Activity implements CallbackEvent.Listene
|
||||
new SocketManager(this).exec();
|
||||
}
|
||||
|
||||
void showRequest() {
|
||||
private boolean cancelTimeout() {
|
||||
timer.cancel();
|
||||
deny_btn.setText(getString(R.string.deny));
|
||||
return false;
|
||||
}
|
||||
|
||||
private void showRequest() {
|
||||
|
||||
switch (magiskManager.suResponseType) {
|
||||
case AUTO_DENY:
|
||||
@ -126,17 +134,14 @@ public class SuRequestActivity extends Activity implements CallbackEvent.Listene
|
||||
|
||||
grant_btn.setOnClickListener(v -> handleAction(Policy.ALLOW));
|
||||
deny_btn.setOnClickListener(v -> handleAction(Policy.DENY));
|
||||
suPopup.setOnClickListener((v) -> {
|
||||
timer.cancel();
|
||||
deny_btn.setText(getString(R.string.deny));
|
||||
});
|
||||
timeout.setOnTouchListener((v, event) -> {
|
||||
timer.cancel();
|
||||
deny_btn.setText(getString(R.string.deny));
|
||||
return false;
|
||||
});
|
||||
suPopup.setOnClickListener((v) -> cancelTimeout());
|
||||
timeout.setOnTouchListener((v, event) -> cancelTimeout());
|
||||
|
||||
timer.start();
|
||||
if (hasTimeout) {
|
||||
timer.start();
|
||||
} else {
|
||||
cancelTimeout();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -162,6 +162,15 @@
|
||||
<string name="superuser_notification">Superuser Notification</string>
|
||||
<string name="request_timeout_summary">%1$s seconds</string>
|
||||
|
||||
<string name="multiuser_mode">Multiuser Mode</string>
|
||||
<string name="settings_owner_only">Device Owner Only</string>
|
||||
<string name="settings_owner_manage">Device Owner Managed</string>
|
||||
<string name="settings_user_independent">User Independent</string>
|
||||
<string name="owner_only_summary">Only owner has root access</string>
|
||||
<string name="owner_manage_summary">Only owner can manage root access and receive request prompts</string>
|
||||
<string name="user_indepenent_summary">Each user has its own separate root rules</string>
|
||||
<string name="multiuser_hint_owner_request">A request has been sent to the device owner. Please switch to the owner and grant the permission</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_summary">Check this to enable verbose logging</string>
|
||||
@ -201,12 +210,4 @@
|
||||
<string name="target_uid">Target UID:\u0020</string>
|
||||
<string name="command">Command:\u0020</string>
|
||||
|
||||
<string name="multiuser_mode">Multiuser Mode</string>
|
||||
<string name="settings_owner_only">Device Owner Only</string>
|
||||
<string name="settings_owner_manage">Device Owner Managed</string>
|
||||
<string name="settings_user_independent">User Independent</string>
|
||||
<string name="owner_only_summary">Only owner has root access</string>
|
||||
<string name="owner_manage_summary">Only owner can manage root access and receive request prompts</string>
|
||||
<string name="user_indepenent_summary">Each user has its own separate root rules</string>
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user