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
55410f02
Commit
55410f02
authored
Oct 01, 2016
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Magisk Version; remove unnecessary root calls
parent
f2611f64
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
43 deletions
+43
-43
MagiskFragment.java
app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java
+26
-23
ReposAdapter.java
app/src/main/java/com/topjohnwu/magisk/ReposAdapter.java
+2
-1
SplashActivity.java
app/src/main/java/com/topjohnwu/magisk/SplashActivity.java
+0
-1
Async.java
app/src/main/java/com/topjohnwu/magisk/utils/Async.java
+15
-18
No files found.
app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java
View file @
55410f02
...
...
@@ -3,7 +3,6 @@ package com.topjohnwu.magisk;
import
android.app.Fragment
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.content.pm.PackageManager
;
import
android.net.Uri
;
import
android.os.AsyncTask
;
import
android.os.Bundle
;
...
...
@@ -12,7 +11,6 @@ import android.support.annotation.Nullable;
import
android.support.v4.content.FileProvider
;
import
android.support.v4.widget.SwipeRefreshLayout
;
import
android.support.v7.app.AlertDialog
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
...
...
@@ -78,19 +76,7 @@ public class MagiskFragment extends Fragment {
View
v
=
inflater
.
inflate
(
R
.
layout
.
magisk_fragment
,
container
,
false
);
ButterKnife
.
bind
(
this
,
v
);
if
(
magiskVersion
==
-
1
)
{
magiskStatusContainer
.
setBackgroundColor
(
colorNeutral
);
magiskStatusIcon
.
setImageResource
(
statusUnknown
);
magiskVersionText
.
setTextColor
(
colorNeutral
);
magiskVersionText
.
setText
(
R
.
string
.
magisk_version_error
);
}
else
{
magiskStatusContainer
.
setBackgroundColor
(
colorOK
);
magiskStatusIcon
.
setImageResource
(
statusOK
);
magiskVersionText
.
setText
(
getString
(
R
.
string
.
magisk_version
,
String
.
valueOf
(
magiskVersion
)));
magiskVersionText
.
setTextColor
(
colorOK
);
}
updateMagiskVersion
();
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
getActivity
());
...
...
@@ -120,6 +106,7 @@ public class MagiskFragment extends Fragment {
if
(
s
.
equals
(
"update_check_done"
))
{
if
(
pref
.
getBoolean
(
s
,
false
))
{
Logger
.
dev
(
"MagiskFragment: UI refresh triggered"
);
updateMagiskVersion
();
updateUI
();
}
}
...
...
@@ -140,22 +127,38 @@ public class MagiskFragment extends Fragment {
prefs
.
unregisterOnSharedPreferenceChangeListener
(
listener
);
}
private
void
updateMagiskVersion
()
{
List
<
String
>
ret
=
Shell
.
sh
(
"getprop magisk.version"
);
if
(
ret
.
get
(
0
).
isEmpty
())
{
magiskVersion
=
-
1
;
}
else
{
magiskVersion
=
Integer
.
parseInt
(
ret
.
get
(
0
));
}
if
(
magiskVersion
==
-
1
)
{
magiskStatusContainer
.
setBackgroundColor
(
colorNeutral
);
magiskStatusIcon
.
setImageResource
(
statusUnknown
);
magiskVersionText
.
setTextColor
(
colorNeutral
);
magiskVersionText
.
setText
(
R
.
string
.
magisk_version_error
);
}
else
{
magiskStatusContainer
.
setBackgroundColor
(
colorOK
);
magiskStatusIcon
.
setImageResource
(
statusOK
);
magiskVersionText
.
setText
(
getString
(
R
.
string
.
magisk_version
,
String
.
valueOf
(
magiskVersion
)));
magiskVersionText
.
setTextColor
(
colorOK
);
}
}
private
void
updateUI
()
{
String
theme
=
PreferenceManager
.
getDefaultSharedPreferences
(
getActivity
())
.
getString
(
"theme"
,
""
);
String
theme
=
prefs
.
getString
(
"theme"
,
""
);
if
(
theme
.
equals
(
"Dark"
))
{
builder
=
new
AlertDialog
.
Builder
(
getActivity
(),
R
.
style
.
AlertDialog_dh
);
}
else
{
builder
=
new
AlertDialog
.
Builder
(
getActivity
());
}
List
<
String
>
ret
=
Shell
.
sh
(
"getprop magisk.version"
);
if
(
ret
.
get
(
0
).
isEmpty
())
{
magiskVersion
=
-
1
;
}
else
{
magiskVersion
=
Integer
.
parseInt
(
ret
.
get
(
0
));
}
if
(
remoteMagiskVersion
==
-
1
)
{
appCheckUpdatesContainer
.
setBackgroundColor
(
colorWarn
);
magiskCheckUpdatesContainer
.
setBackgroundColor
(
colorWarn
);
...
...
app/src/main/java/com/topjohnwu/magisk/ReposAdapter.java
View file @
55410f02
...
...
@@ -98,7 +98,8 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
protected
void
preProcessing
()
throws
Throwable
{
super
.
preProcessing
();
new
File
(
mUri
.
getPath
()).
delete
();
Shell
.
su
(
Shell
.
sh
(
"PATH="
+
context
.
getApplicationInfo
().
dataDir
+
"/tools:$PATH"
,
"cd "
+
mFile
.
getParent
(),
"mkdir git"
,
"unzip -o install.zip -d git"
,
...
...
app/src/main/java/com/topjohnwu/magisk/SplashActivity.java
View file @
55410f02
package
com
.
topjohnwu
.
magisk
;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.os.AsyncTask
;
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Async.java
View file @
55410f02
...
...
@@ -46,24 +46,20 @@ public class Async {
String
toolPath
=
mInfo
.
dataDir
+
"/tools"
;
String
busybox
=
mInfo
.
dataDir
+
"/lib/libbusybox.so"
;
String
zip
=
mInfo
.
dataDir
+
"/lib/libzip.so"
;
if
(
Shell
.
rootAccess
())
{
if
(!
Utils
.
itemExist
(
false
,
toolPath
))
{
Shell
.
su
(
"rm -rf "
+
toolPath
,
"mkdir "
+
toolPath
,
"chmod 755 "
+
toolPath
,
"cd "
+
toolPath
,
"ln -s "
+
busybox
+
" busybox"
,
"for tool in $(./busybox --list); do"
,
"ln -s "
+
busybox
+
" $tool"
,
"done"
,
"rm -f su sh"
,
"ln -s "
+
zip
+
" zip"
);
}
Shell
.
su
(
"PATH="
+
toolPath
+
":$PATH"
);
if
(!
Utils
.
itemExist
(
false
,
toolPath
))
{
Shell
.
sh
(
"mkdir "
+
toolPath
,
"chmod 755 "
+
toolPath
,
"cd "
+
toolPath
,
"ln -s "
+
busybox
+
" busybox"
,
"for tool in $(./busybox --list); do"
,
"ln -s "
+
busybox
+
" $tool"
,
"done"
,
"rm -f su sh"
,
"ln -s "
+
zip
+
" zip"
);
}
Shell
.
su
(
"PATH="
+
toolPath
+
":$PATH"
);
return
null
;
}
}
...
...
@@ -254,7 +250,7 @@ public class Async {
if
(
copyToSD
&&
mFile
!=
null
)
{
String
filename
=
(
mName
.
contains
(
".zip"
)
?
mName
:
mName
+
".zip"
);
filename
=
filename
.
replace
(
" "
,
"_"
).
replace
(
"'"
,
""
).
replace
(
"\""
,
""
)
.
replace
(
"$"
,
""
).
replace
(
"`"
,
""
).
replace
(
"("
,
"
_"
).
replace
(
")"
,
"_
"
)
.
replace
(
"$"
,
""
).
replace
(
"`"
,
""
).
replace
(
"("
,
"
"
).
replace
(
")"
,
"
"
)
.
replace
(
"#"
,
""
).
replace
(
"@"
,
""
).
replace
(
"*"
,
""
);
sdFile
=
new
File
(
Environment
.
getExternalStorageDirectory
()
+
"/MagiskManager/"
+
filename
);
Logger
.
dev
(
"FlashZip: Copy zip back to "
+
sdFile
.
getPath
());
...
...
@@ -268,6 +264,7 @@ public class Async {
mFile
.
delete
();
}
catch
(
IOException
e
)
{
// Use the badass way :)
e
.
printStackTrace
();
Shell
.
su
(
"cp -af "
+
mFile
.
getPath
()
+
" "
+
sdFile
.
getPath
());
if
(!
sdFile
.
exists
())
{
sdFile
=
null
;
...
...
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