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
151a153d
Commit
151a153d
authored
Jan 24, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix toasts and timeouts
parent
ad131854
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
3 deletions
+27
-3
Policy.java
app/src/main/java/com/topjohnwu/magisk/superuser/Policy.java
+13
-0
SuReceiver.java
.../main/java/com/topjohnwu/magisk/superuser/SuReceiver.java
+13
-2
SuRequestActivity.java
...ava/com/topjohnwu/magisk/superuser/SuRequestActivity.java
+1
-1
No files found.
app/src/main/java/com/topjohnwu/magisk/superuser/Policy.java
View file @
151a153d
package
com
.
topjohnwu
.
magisk
.
superuser
;
import
android.content.ContentValues
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
import
android.database.Cursor
;
...
...
@@ -12,6 +14,17 @@ public class Policy {
public
Policy
()
{}
public
Policy
(
int
uid
,
PackageManager
pm
)
throws
Throwable
{
String
[]
pkgs
=
pm
.
getPackagesForUid
(
uid
);
if
(
pkgs
!=
null
&&
pkgs
.
length
>
0
)
{
PackageInfo
info
=
pm
.
getPackageInfo
(
pkgs
[
0
],
0
);
packageName
=
pkgs
[
0
];
appName
=
info
.
applicationInfo
.
loadLabel
(
pm
).
toString
();
logging
=
true
;
notification
=
true
;
}
else
throw
new
Throwable
();
}
public
Policy
(
Cursor
c
)
{
uid
=
c
.
getInt
(
c
.
getColumnIndex
(
"uid"
));
packageName
=
c
.
getString
(
c
.
getColumnIndex
(
"package_name"
));
...
...
app/src/main/java/com/topjohnwu/magisk/superuser/SuReceiver.java
View file @
151a153d
...
...
@@ -4,6 +4,7 @@ import android.content.BroadcastReceiver;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.os.Process
;
import
android.widget.Toast
;
import
com.topjohnwu.magisk.R
;
...
...
@@ -13,15 +14,25 @@ public class SuReceiver extends BroadcastReceiver {
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
int
fromUid
,
toUid
,
pid
;
String
command
,
action
;
Policy
policy
;
if
(
intent
==
null
)
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
action
=
intent
.
getStringExtra
(
"action"
);
if
(
action
==
null
)
return
;
SuDatabaseHelper
dbHelper
=
new
SuDatabaseHelper
(
context
);
Policy
policy
=
dbHelper
.
getPolicy
(
fromUid
);
if
(
policy
==
null
)
return
;
policy
=
dbHelper
.
getPolicy
(
fromUid
);
if
(
policy
==
null
)
try
{
policy
=
new
Policy
(
fromUid
,
context
.
getPackageManager
());
}
catch
(
Throwable
throwable
)
{
return
;
}
if
(
policy
.
notification
)
{
String
message
;
switch
(
action
)
{
...
...
app/src/main/java/com/topjohnwu/magisk/superuser/SuRequestActivity.java
View file @
151a153d
...
...
@@ -71,7 +71,7 @@ public class SuRequestActivity extends AppCompatActivity {
packageNameView
.
setText
(
packageName
);
grant_btn
.
setOnClickListener
(
v
->
handleAction
(
true
,
timeoutList
[
timeout
.
getSelectedItemPosition
()]));
deny_btn
.
setOnClickListener
(
v
->
handleAction
(
false
,
0
));
deny_btn
.
setOnClickListener
(
v
->
handleAction
(
false
,
timeoutList
[
timeout
.
getSelectedItemPosition
()]
));
}
void
handleAction
(
boolean
action
,
int
timeout
)
{
...
...
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