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
6eb814ef
Commit
6eb814ef
authored
Jan 25, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some small issues
parent
bcc69523
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
18 deletions
+37
-18
SettingsActivity.java
app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java
+1
-7
ModuleHelper.java
...c/main/java/com/topjohnwu/magisk/module/ModuleHelper.java
+13
-0
SuRequestActivity.java
...ava/com/topjohnwu/magisk/superuser/SuRequestActivity.java
+10
-1
Async.java
app/src/main/java/com/topjohnwu/magisk/utils/Async.java
+5
-4
Logger.java
app/src/main/java/com/topjohnwu/magisk/utils/Logger.java
+8
-6
No files found.
app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java
View file @
6eb814ef
...
...
@@ -91,13 +91,7 @@ public class SettingsActivity extends AppCompatActivity {
Preference
clear
=
findPreference
(
"clear"
);
clear
.
setOnPreferenceClickListener
((
pref
)
->
{
SharedPreferences
repoMap
=
getActivity
().
getSharedPreferences
(
ModuleHelper
.
FILE_KEY
,
Context
.
MODE_PRIVATE
);
repoMap
.
edit
()
.
putString
(
ModuleHelper
.
ETAG_KEY
,
""
)
.
putInt
(
ModuleHelper
.
VERSION_KEY
,
0
)
.
apply
();
new
Async
.
LoadRepos
(
getActivity
()).
exec
();
Toast
.
makeText
(
getActivity
(),
R
.
string
.
repo_cache_cleared
,
Toast
.
LENGTH_LONG
).
show
();
ModuleHelper
.
clearRepoCache
(
getActivity
());
return
true
;
});
...
...
app/src/main/java/com/topjohnwu/magisk/module/ModuleHelper.java
View file @
6eb814ef
...
...
@@ -2,11 +2,13 @@ package com.topjohnwu.magisk.module;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
android.widget.Toast
;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
com.topjohnwu.magisk.Global
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.ValueSortedMap
;
...
...
@@ -163,4 +165,15 @@ public class ModuleHelper {
}
}
public
static
void
clearRepoCache
(
Context
context
)
{
SharedPreferences
repoMap
=
context
.
getSharedPreferences
(
FILE_KEY
,
Context
.
MODE_PRIVATE
);
repoMap
.
edit
()
.
remove
(
ETAG_KEY
)
.
remove
(
VERSION_KEY
)
.
apply
();
Global
.
Events
.
repoLoadDone
.
isTriggered
=
false
;
new
Async
.
LoadRepos
(
context
).
exec
();
Toast
.
makeText
(
context
,
R
.
string
.
repo_cache_cleared
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
app/src/main/java/com/topjohnwu/magisk/superuser/SuRequestActivity.java
View file @
6eb814ef
package
com
.
topjohnwu
.
magisk
.
superuser
;
import
android.content.ContentValues
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
...
...
@@ -10,7 +11,10 @@ import android.os.AsyncTask;
import
android.os.Bundle
;
import
android.os.CountDownTimer
;
import
android.support.v7.app.AppCompatActivity
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.Window
;
import
android.widget.AdapterView
;
import
android.widget.ArrayAdapter
;
import
android.widget.Button
;
import
android.widget.ImageView
;
...
...
@@ -87,10 +91,15 @@ public class SuRequestActivity extends AppCompatActivity {
grant_btn
.
setOnClickListener
(
v
->
handleAction
(
true
,
timeoutList
[
timeout
.
getSelectedItemPosition
()]));
deny_btn
.
setOnClickListener
(
v
->
handleAction
(
false
,
timeoutList
[
timeout
.
getSelectedItemPosition
()]));
suPopup
.
setOnClickListener
(
v
->
{
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
;
});
timer
.
start
();
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Async.java
View file @
6eb814ef
...
...
@@ -194,7 +194,7 @@ public class Async {
publishProgress
(
mContext
.
getString
(
R
.
string
.
copying_msg
));
mCachedFile
=
new
File
(
mContext
.
getCacheDir
().
getAbsolutePath
()
+
"/install.zip"
);
if
(
mCachedFile
.
exists
()
&&
!
mCachedFile
.
delete
())
{
Log
.
e
(
Logger
.
TAG
,
"FlashZip: Error while deleting already existing file"
);
Log
ger
.
error
(
"FlashZip: Error while deleting already existing file"
);
throw
new
IOException
();
}
try
(
...
...
@@ -203,15 +203,16 @@ public class Async {
)
{
byte
buffer
[]
=
new
byte
[
1024
];
int
length
;
if
(
in
==
null
)
throw
new
FileNotFoundException
();
while
((
length
=
in
.
read
(
buffer
))
>
0
)
{
outputStream
.
write
(
buffer
,
0
,
length
);
}
Logger
.
dev
(
"FlashZip: File created successfully - "
+
mCachedFile
.
getPath
());
}
catch
(
FileNotFoundException
e
)
{
Log
.
e
(
Logger
.
TAG
,
"FlashZip: Invalid Uri"
);
Log
ger
.
error
(
"FlashZip: Invalid Uri"
);
throw
e
;
}
catch
(
IOException
e
)
{
Log
.
e
(
Logger
.
TAG
,
"FlashZip: Error in creating file"
);
Log
ger
.
error
(
"FlashZip: Error in creating file"
);
throw
e
;
}
}
...
...
@@ -331,7 +332,7 @@ public class Async {
}
@Override
protected
void
onPostExecute
(
Void
aVoid
)
{
protected
void
onPostExecute
(
Void
v
)
{
Global
.
Events
.
blockDetectionDone
.
trigger
();
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Logger.java
View file @
6eb814ef
...
...
@@ -7,26 +7,28 @@ import com.topjohnwu.magisk.Global;
public
class
Logger
{
public
static
final
String
TAG
=
"Magisk"
;
public
static
final
String
DEV_TAG
=
"Magisk: DEV"
;
public
static
final
String
DEBUG_TAG
=
"Magisk: DEBUG"
;
public
static
void
debug
(
String
msg
)
{
Log
.
d
(
DEBUG_TAG
,
msg
);
Log
.
d
(
TAG
,
"DEBUG: "
+
msg
);
}
public
static
void
error
(
String
msg
)
{
Log
.
e
(
TAG
,
"ERROR: "
+
msg
);
}
public
static
void
dev
(
String
msg
,
Object
...
args
)
{
if
(
Global
.
Configs
.
devLogging
)
{
if
(
args
.
length
==
1
&&
args
[
0
]
instanceof
Throwable
)
{
Log
.
d
(
DEV_TAG
,
msg
,
(
Throwable
)
args
[
0
]);
Log
.
d
(
TAG
,
"DEV: "
+
msg
,
(
Throwable
)
args
[
0
]);
}
else
{
Log
.
d
(
DEV_TAG
,
String
.
format
(
msg
,
args
));
Log
.
d
(
TAG
,
"DEV: "
+
String
.
format
(
msg
,
args
));
}
}
}
public
static
void
dev
(
String
msg
)
{
if
(
Global
.
Configs
.
devLogging
)
{
Log
.
d
(
DEV_TAG
,
msg
);
Log
.
d
(
TAG
,
"DEBUG: "
+
msg
);
}
}
...
...
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