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
f2611f64
Commit
f2611f64
authored
Sep 30, 2016
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Various fixes
parent
d788bd83
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
63 additions
and
63 deletions
+63
-63
build.gradle
app/build.gradle
+1
-1
MagiskFragment.java
app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java
+19
-10
ModulesFragment.java
app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java
+1
-1
RootFragment.java
app/src/main/java/com/topjohnwu/magisk/RootFragment.java
+0
-1
SettingsActivity.java
app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java
+0
-1
SplashActivity.java
app/src/main/java/com/topjohnwu/magisk/SplashActivity.java
+21
-17
Async.java
app/src/main/java/com/topjohnwu/magisk/utils/Async.java
+21
-21
Utils.java
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
+0
-11
No files found.
app/build.gradle
View file @
f2611f64
...
...
@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
android
{
compileSdkVersion
24
buildToolsVersion
"24.0.
3
"
buildToolsVersion
"24.0.
2
"
defaultConfig
{
applicationId
"com.topjohnwu.magisk"
...
...
app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java
View file @
f2611f64
...
...
@@ -9,10 +9,10 @@ import android.os.AsyncTask;
import
android.os.Bundle
;
import
android.preference.PreferenceManager
;
import
android.support.annotation.Nullable
;
import
android.support.graphics.drawable.animated.BuildConfig
;
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
;
...
...
@@ -23,9 +23,11 @@ import android.widget.TextView;
import
com.topjohnwu.magisk.receivers.DownloadReceiver
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Utils
;
import
java.io.File
;
import
java.util.List
;
import
butterknife.BindColor
;
import
butterknife.BindView
;
...
...
@@ -107,7 +109,7 @@ public class MagiskFragment extends Fragment {
appCheckUpdatesProgress
.
setVisibility
(
View
.
VISIBLE
);
magiskCheckUpdatesProgress
.
setVisibility
(
View
.
VISIBLE
);
new
Async
.
CheckUpdates
(
getActivity
()
).
executeOnExecutor
(
AsyncTask
.
THREAD_POOL_EXECUTOR
);
new
Async
.
CheckUpdates
(
prefs
).
executeOnExecutor
(
AsyncTask
.
THREAD_POOL_EXECUTOR
);
});
if
(
prefs
.
getBoolean
(
"update_check_done"
,
false
))
{
...
...
@@ -147,6 +149,13 @@ public class MagiskFragment extends Fragment {
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
);
...
...
@@ -204,13 +213,7 @@ public class MagiskFragment extends Fragment {
.
show
());
}
int
appVersionCode
=
0
;
try
{
appVersionCode
=
getActivity
().
getPackageManager
().
getPackageInfo
(
getActivity
().
getPackageName
(),
0
).
versionCode
;
}
catch
(
PackageManager
.
NameNotFoundException
e
)
{
e
.
printStackTrace
();
}
if
(
remoteAppVersionCode
>
appVersionCode
)
{
if
(
remoteAppVersionCode
>
BuildConfig
.
VERSION_CODE
)
{
appCheckUpdatesContainer
.
setBackgroundColor
(
colorInfo
);
appCheckUpdatesIcon
.
setImageResource
(
R
.
drawable
.
ic_file_download
);
appCheckUpdatesStatus
.
setText
(
getString
(
R
.
string
.
app_update_available
,
remoteAppVersion
));
...
...
@@ -258,7 +261,13 @@ public class MagiskFragment extends Fragment {
new
DownloadReceiver
()
{
@Override
public
void
task
(
Uri
uri
)
{
new
Async
.
FlashZIP
(
mContext
,
uri
).
executeOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
new
Async
.
FlashZIP
(
mContext
,
uri
)
{
@Override
protected
void
done
()
{
Shell
.
su
(
"setprop magisk.version "
+
String
.
valueOf
(
remoteMagiskVersion
));
super
.
done
();
}
}.
executeOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
}
},
magiskLink
,
...
...
app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java
View file @
f2611f64
...
...
@@ -59,7 +59,7 @@ public class ModulesFragment extends Fragment {
mSwipeRefreshLayout
.
setOnRefreshListener
(()
->
{
recyclerView
.
setVisibility
(
View
.
GONE
);
prefs
.
edit
().
putBoolean
(
"module_done"
,
false
).
apply
();
new
Async
.
LoadModules
(
getActivity
()
).
executeOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
new
Async
.
LoadModules
(
prefs
).
executeOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
});
if
(
prefs
.
getBoolean
(
"module_done"
,
false
))
{
...
...
app/src/main/java/com/topjohnwu/magisk/RootFragment.java
View file @
f2611f64
...
...
@@ -2,7 +2,6 @@ package com.topjohnwu.magisk;
import
android.app.Fragment
;
import
android.content.SharedPreferences
;
import
android.graphics.Color
;
import
android.os.AsyncTask
;
import
android.os.Bundle
;
import
android.preference.PreferenceManager
;
...
...
app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java
View file @
f2611f64
...
...
@@ -12,7 +12,6 @@ import android.support.v7.app.ActionBar;
import
android.support.v7.app.AppCompatActivity
;
import
android.support.v7.widget.Toolbar
;
import
android.view.WindowManager
;
import
android.widget.Toast
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Logger
;
...
...
app/src/main/java/com/topjohnwu/magisk/SplashActivity.java
View file @
f2611f64
package
com
.
topjohnwu
.
magisk
;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.os.AsyncTask
;
...
...
@@ -12,38 +13,41 @@ import com.topjohnwu.magisk.utils.Logger;
import
com.topjohnwu.magisk.utils.Utils
;
public
class
SplashActivity
extends
AppCompatActivity
{
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
SharedPreferences
defaultP
refs
=
PreferenceManager
.
getDefaultSharedPreferences
(
getApplication
());
if
(
defaultP
refs
.
getString
(
"theme"
,
""
).
equals
(
"Dark"
))
{
SharedPreferences
p
refs
=
PreferenceManager
.
getDefaultSharedPreferences
(
getApplication
());
if
(
p
refs
.
getString
(
"theme"
,
""
).
equals
(
"Dark"
))
{
setTheme
(
R
.
style
.
AppTheme_dh
);
}
Logger
.
devLog
=
defaultP
refs
.
getBoolean
(
"developer_logging"
,
false
);
Logger
.
logShell
=
defaultP
refs
.
getBoolean
(
"shell_logging"
,
false
);
Logger
.
devLog
=
p
refs
.
getBoolean
(
"developer_logging"
,
false
);
Logger
.
logShell
=
p
refs
.
getBoolean
(
"shell_logging"
,
false
);
// Initialize
Utils
.
init
(
this
);
defaultPrefs
.
edit
()
prefs
.
edit
()
.
putBoolean
(
"module_done"
,
false
)
.
putBoolean
(
"repo_done"
,
false
)
.
putBoolean
(
"update_check_done"
,
false
)
.
putBoolean
(
"root"
,
Utils
.
rootEnabled
())
.
apply
();
new
Async
.
CheckUpdates
(
this
).
executeOnExecutor
(
AsyncTask
.
THREAD_POOL_EXECUTOR
);
new
Async
.
constructEnv
(
this
).
executeOnExecutor
(
AsyncTask
.
THREAD_POOL_EXECUTOR
);
new
Async
.
LoadModules
(
this
).
executeOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
new
Async
.
LoadRepos
(
this
).
executeOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
// Start main activity
Intent
intent
=
new
Intent
(
this
,
MainActivity
.
class
);
startActivity
(
intent
);
new
Async
.
CheckUpdates
(
prefs
).
executeOnExecutor
(
AsyncTask
.
THREAD_POOL_EXECUTOR
);
new
Async
.
constructEnv
(
getApplicationInfo
()).
executeOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
new
Async
.
LoadModules
(
prefs
)
{
@Override
protected
void
onPostExecute
(
Void
v
)
{
super
.
onPostExecute
(
v
);
new
Async
.
LoadRepos
(
getApplicationContext
()).
executeOnExecutor
(
AsyncTask
.
THREAD_POOL_EXECUTOR
);
// Start main activity
Intent
intent
=
new
Intent
(
getApplicationContext
(),
MainActivity
.
class
);
startActivity
(
intent
);
finish
();
}
}.
executeOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
finish
();
}
}
app/src/main/java/com/topjohnwu/magisk/utils/Async.java
View file @
f2611f64
...
...
@@ -3,6 +3,7 @@ package com.topjohnwu.magisk.utils;
import
android.app.ProgressDialog
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
android.content.pm.ApplicationInfo
;
import
android.database.Cursor
;
import
android.net.Uri
;
import
android.os.AsyncTask
;
...
...
@@ -34,20 +35,20 @@ public class Async {
public
static
class
constructEnv
extends
AsyncTask
<
Void
,
Void
,
Void
>
{
Context
mContext
;
ApplicationInfo
mInfo
;
public
constructEnv
(
Context
context
)
{
m
Context
=
context
;
public
constructEnv
(
ApplicationInfo
info
)
{
m
Info
=
info
;
}
@Override
protected
Void
doInBackground
(
Void
...
voids
)
{
String
toolPath
=
m
Context
.
getApplicationInfo
()
.
dataDir
+
"/tools"
;
String
busybox
=
m
Context
.
getApplicationInfo
()
.
dataDir
+
"/lib/libbusybox.so"
;
String
zip
=
m
Context
.
getApplicationInfo
()
.
dataDir
+
"/lib/libzip.so"
;
String
toolPath
=
m
Info
.
dataDir
+
"/tools"
;
String
busybox
=
m
Info
.
dataDir
+
"/lib/libbusybox.so"
;
String
zip
=
m
Info
.
dataDir
+
"/lib/libzip.so"
;
if
(
Shell
.
rootAccess
())
{
if
(!
Utils
.
itemExist
(
false
,
toolPath
))
{
Shell
.
s
h
(
Shell
.
s
u
(
"rm -rf "
+
toolPath
,
"mkdir "
+
toolPath
,
"chmod 755 "
+
toolPath
,
...
...
@@ -60,6 +61,7 @@ public class Async {
"ln -s "
+
zip
+
" zip"
);
}
Shell
.
su
(
"PATH="
+
toolPath
+
":$PATH"
);
}
return
null
;
...
...
@@ -68,10 +70,10 @@ public class Async {
public
static
class
CheckUpdates
extends
AsyncTask
<
Void
,
Void
,
Void
>
{
private
Context
mContext
;
private
SharedPreferences
mPrefs
;
public
CheckUpdates
(
Context
context
)
{
m
Context
=
context
;
public
CheckUpdates
(
SharedPreferences
prefs
)
{
m
Prefs
=
prefs
;
}
@Override
...
...
@@ -100,17 +102,16 @@ public class Async {
@Override
protected
void
onPostExecute
(
Void
v
)
{
SharedPreferences
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
mContext
);
prefs
.
edit
().
putBoolean
(
"update_check_done"
,
true
).
apply
();
mPrefs
.
edit
().
putBoolean
(
"update_check_done"
,
true
).
apply
();
}
}
public
static
class
LoadModules
extends
AsyncTask
<
Void
,
Void
,
Void
>
{
private
Context
mContext
;
private
SharedPreferences
mPrefs
;
public
LoadModules
(
Context
context
)
{
m
Context
=
context
;
public
LoadModules
(
SharedPreferences
prefs
)
{
m
Prefs
=
prefs
;
}
@Override
...
...
@@ -121,8 +122,7 @@ public class Async {
@Override
protected
void
onPostExecute
(
Void
v
)
{
SharedPreferences
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
mContext
);
prefs
.
edit
().
putBoolean
(
"module_done"
,
true
).
apply
();
mPrefs
.
edit
().
putBoolean
(
"module_done"
,
true
).
apply
();
}
}
...
...
@@ -142,8 +142,8 @@ public class Async {
@Override
protected
void
onPostExecute
(
Void
v
)
{
SharedPreferences
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
mContext
);
prefs
.
edit
()
.
putBoolean
(
"repo_done"
,
true
).
apply
();
PreferenceManager
.
getDefaultSharedPreferences
(
mContext
).
edit
()
.
putBoolean
(
"repo_done"
,
true
).
apply
();
}
}
...
...
@@ -308,8 +308,8 @@ public class Async {
protected
void
done
()
{
SharedPreferences
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
mContext
);
prefs
.
edit
().
putBoolean
(
"module_done"
,
false
).
apply
();
new
LoadModules
(
mContext
).
executeOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
prefs
.
edit
().
putBoolean
(
"module_done"
,
false
).
putBoolean
(
"update_check_done"
,
true
).
apply
();
new
LoadModules
(
prefs
).
executeOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
AlertDialog
.
Builder
builder
;
String
theme
=
PreferenceManager
.
getDefaultSharedPreferences
(
mContext
).
getString
(
"theme"
,
""
);
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
View file @
f2611f64
...
...
@@ -39,17 +39,6 @@ public class Utils {
private
static
final
String
cryptoPass
=
"MagiskRox666"
;
private
static
final
String
secret
=
"GTYybRBTYf5his9kQ16ZNO7qgkBJ/5MyVe4CGceAOIoXgSnnk8FTd4F1dE9p5Eus"
;
public
static
void
init
(
Context
context
)
{
List
<
String
>
ret
=
Shell
.
sh
(
"getprop magisk.version"
);
if
(
ret
.
get
(
0
).
isEmpty
())
{
MagiskFragment
.
magiskVersion
=
-
1
;
}
else
{
MagiskFragment
.
magiskVersion
=
Integer
.
parseInt
(
ret
.
get
(
0
));
}
String
toolPath
=
context
.
getApplicationInfo
().
dataDir
+
"/tools"
;
Shell
.
su
(
"PATH="
+
toolPath
+
":$PATH"
);
}
public
static
boolean
itemExist
(
String
path
)
{
return
itemExist
(
true
,
path
);
}
...
...
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