Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
44e36feb
Commit
44e36feb
authored
May 27, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve multiuser settings and notification
parent
2a7d9968
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
25 deletions
+48
-25
SettingsActivity.java
app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java
+6
-0
SuReceiver.java
.../main/java/com/topjohnwu/magisk/superuser/SuReceiver.java
+16
-5
SuRequestActivity.java
...ava/com/topjohnwu/magisk/superuser/SuRequestActivity.java
+17
-12
strings.xml
app/src/main/res/values/strings.xml
+9
-8
No files found.
app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java
View file @
44e36feb
...
...
@@ -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
;
...
...
app/src/main/java/com/topjohnwu/magisk/superuser/SuReceiver.java
View file @
44e36feb
...
...
@@ -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
);
...
...
app/src/main/java/com/topjohnwu/magisk/superuser/SuRequestActivity.java
View file @
44e36feb
...
...
@@ -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
());
if
(
hasTimeout
)
{
timer
.
start
();
}
else
{
cancelTimeout
();
}
}
@Override
...
...
app/src/main/res/values/strings.xml
View file @
44e36feb
...
...
@@ -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>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment