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
478b7eeb
Commit
478b7eeb
authored
Jan 24, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stop countdown when user reacts
parent
151a153d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
4 deletions
+27
-4
SuRequestActivity.java
...ava/com/topjohnwu/magisk/superuser/SuRequestActivity.java
+25
-2
activity_request.xml
app/src/main/res/layout/activity_request.xml
+1
-1
strings.xml
app/src/main/res/values/strings.xml
+1
-1
No files found.
app/src/main/java/com/topjohnwu/magisk/superuser/SuRequestActivity.java
View file @
478b7eeb
...
@@ -8,11 +8,13 @@ import android.net.LocalSocket;
...
@@ -8,11 +8,13 @@ import android.net.LocalSocket;
import
android.net.LocalSocketAddress
;
import
android.net.LocalSocketAddress
;
import
android.os.AsyncTask
;
import
android.os.AsyncTask
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.os.CountDownTimer
;
import
android.support.v7.app.AppCompatActivity
;
import
android.support.v7.app.AppCompatActivity
;
import
android.view.Window
;
import
android.view.Window
;
import
android.widget.ArrayAdapter
;
import
android.widget.ArrayAdapter
;
import
android.widget.Button
;
import
android.widget.Button
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.Spinner
;
import
android.widget.Spinner
;
import
android.widget.TextView
;
import
android.widget.TextView
;
...
@@ -30,6 +32,7 @@ public class SuRequestActivity extends AppCompatActivity {
...
@@ -30,6 +32,7 @@ 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
;
@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
;
@BindView
(
R
.
id
.
app_name
)
TextView
appNameView
;
@BindView
(
R
.
id
.
app_name
)
TextView
appNameView
;
...
@@ -42,8 +45,9 @@ public class SuRequestActivity extends AppCompatActivity {
...
@@ -42,8 +45,9 @@ public class SuRequestActivity extends AppCompatActivity {
private
PackageManager
pm
;
private
PackageManager
pm
;
private
PackageInfo
info
;
private
PackageInfo
info
;
private
int
uid
;
private
int
uid
,
countdown
=
10
;
private
String
appName
,
packageName
;
private
String
appName
,
packageName
;
private
CountDownTimer
timer
;
private
int
[]
timeoutList
=
{
0
,
-
1
,
10
,
20
,
30
,
60
};
private
int
[]
timeoutList
=
{
0
,
-
1
,
10
,
20
,
30
,
60
};
...
@@ -70,8 +74,27 @@ public class SuRequestActivity extends AppCompatActivity {
...
@@ -70,8 +74,27 @@ public class SuRequestActivity extends AppCompatActivity {
appNameView
.
setText
(
appName
);
appNameView
.
setText
(
appName
);
packageNameView
.
setText
(
packageName
);
packageNameView
.
setText
(
packageName
);
timer
=
new
CountDownTimer
(
countdown
*
1000
,
1000
)
{
@Override
public
void
onTick
(
long
millisUntilFinished
)
{
deny_btn
.
setText
(
getString
(
R
.
string
.
deny
,
"("
+
millisUntilFinished
/
1000
+
")"
));
}
@Override
public
void
onFinish
()
{
deny_btn
.
setText
(
getString
(
R
.
string
.
deny
,
"(0)"
));
handleAction
(
false
,
-
1
);
}
};
grant_btn
.
setOnClickListener
(
v
->
handleAction
(
true
,
timeoutList
[
timeout
.
getSelectedItemPosition
()]));
grant_btn
.
setOnClickListener
(
v
->
handleAction
(
true
,
timeoutList
[
timeout
.
getSelectedItemPosition
()]));
deny_btn
.
setOnClickListener
(
v
->
handleAction
(
false
,
timeoutList
[
timeout
.
getSelectedItemPosition
()]));
deny_btn
.
setOnClickListener
(
v
->
handleAction
(
false
,
timeoutList
[
timeout
.
getSelectedItemPosition
()]));
suPopup
.
setOnClickListener
(
v
->
{
timer
.
cancel
();
deny_btn
.
setText
(
getString
(
R
.
string
.
deny
,
""
));
});
timer
.
start
();
}
}
void
handleAction
(
boolean
action
,
int
timeout
)
{
void
handleAction
(
boolean
action
,
int
timeout
)
{
...
@@ -85,7 +108,7 @@ public class SuRequestActivity extends AppCompatActivity {
...
@@ -85,7 +108,7 @@ public class SuRequestActivity extends AppCompatActivity {
policy
.
uid
=
uid
;
policy
.
uid
=
uid
;
policy
.
packageName
=
packageName
;
policy
.
packageName
=
packageName
;
policy
.
appName
=
appName
;
policy
.
appName
=
appName
;
policy
.
until
=
(
timeout
==
0
)
?
0
:
System
.
currentTimeMillis
()
+
timeout
*
60
*
1000
;
policy
.
until
=
(
timeout
==
0
)
?
0
:
(
System
.
currentTimeMillis
()
/
1000
+
timeout
*
60
)
;
policy
.
policy
=
action
?
2
:
1
;
policy
.
policy
=
action
?
2
:
1
;
policy
.
logging
=
true
;
policy
.
logging
=
true
;
policy
.
notification
=
true
;
policy
.
notification
=
true
;
...
...
app/src/main/res/layout/activity_request.xml
View file @
478b7eeb
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/su_popup"
tools:context=
".superuser.RequestActivity"
tools:context=
".superuser.RequestActivity"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
...
...
app/src/main/res/values/strings.xml
View file @
478b7eeb
...
@@ -145,7 +145,7 @@
...
@@ -145,7 +145,7 @@
<!--Superuser-->
<!--Superuser-->
<string
name=
"su_request_title"
>
Superuser Request
</string>
<string
name=
"su_request_title"
>
Superuser Request
</string>
<string
name=
"deny"
>
Deny
</string>
<string
name=
"deny"
>
Deny
%1$s
</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>
...
...
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