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
a189dec1
Commit
a189dec1
authored
Jan 21, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Centralize configuration management
parent
85821679
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
583 additions
and
263 deletions
+583
-263
MainActivity.java
app/src/full/java/com/topjohnwu/magisk/MainActivity.java
+4
-4
SplashActivity.java
app/src/full/java/com/topjohnwu/magisk/SplashActivity.java
+6
-8
SuRequestActivity.java
...src/full/java/com/topjohnwu/magisk/SuRequestActivity.java
+7
-8
BaseActivity.java
...ll/java/com/topjohnwu/magisk/components/BaseActivity.java
+2
-2
InstallMethodDialog.java
.../com/topjohnwu/magisk/components/InstallMethodDialog.java
+3
-3
MagiskInstallDialog.java
.../com/topjohnwu/magisk/components/MagiskInstallDialog.java
+6
-6
ManagerInstallDialog.java
...com/topjohnwu/magisk/components/ManagerInstallDialog.java
+4
-4
Notifications.java
...l/java/com/topjohnwu/magisk/components/Notifications.java
+4
-4
UninstallDialog.java
...java/com/topjohnwu/magisk/components/UninstallDialog.java
+3
-3
MagiskFragment.java
...l/java/com/topjohnwu/magisk/fragments/MagiskFragment.java
+16
-17
ReposFragment.java
...ll/java/com/topjohnwu/magisk/fragments/ReposFragment.java
+4
-5
SettingsFragment.java
...java/com/topjohnwu/magisk/fragments/SettingsFragment.java
+83
-76
GeneralReceiver.java
.../java/com/topjohnwu/magisk/receivers/GeneralReceiver.java
+3
-3
ShortcutReceiver.java
...java/com/topjohnwu/magisk/receivers/ShortcutReceiver.java
+3
-3
UpdateCheckService.java
...ava/com/topjohnwu/magisk/services/UpdateCheckService.java
+3
-3
AppUtils.java
app/src/full/java/com/topjohnwu/magisk/utils/AppUtils.java
+2
-2
DownloadApp.java
...src/full/java/com/topjohnwu/magisk/utils/DownloadApp.java
+4
-4
FingerprintHelper.java
...ll/java/com/topjohnwu/magisk/utils/FingerprintHelper.java
+3
-2
PatchAPK.java
app/src/full/java/com/topjohnwu/magisk/utils/PatchAPK.java
+3
-3
SuConnector.java
...src/full/java/com/topjohnwu/magisk/utils/SuConnector.java
+3
-3
App.java
core/src/main/java/com/topjohnwu/core/App.java
+0
-1
Config.java
core/src/main/java/com/topjohnwu/core/Config.java
+367
-0
Const.java
core/src/main/java/com/topjohnwu/core/Const.java
+5
-51
MagiskDB.java
core/src/main/java/com/topjohnwu/core/database/MagiskDB.java
+2
-2
RepoDatabaseHelper.java
.../java/com/topjohnwu/core/database/RepoDatabaseHelper.java
+6
-6
CheckUpdates.java
.../src/main/java/com/topjohnwu/core/tasks/CheckUpdates.java
+16
-17
MagiskInstaller.java
...c/main/java/com/topjohnwu/core/tasks/MagiskInstaller.java
+6
-6
UpdateRepos.java
core/src/main/java/com/topjohnwu/core/tasks/UpdateRepos.java
+4
-3
LocaleManager.java
...src/main/java/com/topjohnwu/core/utils/LocaleManager.java
+2
-2
RootUtils.java
core/src/main/java/com/topjohnwu/core/utils/RootUtils.java
+5
-6
Utils.java
core/src/main/java/com/topjohnwu/core/utils/Utils.java
+4
-6
No files found.
app/src/full/java/com/topjohnwu/magisk/MainActivity.java
View file @
a189dec1
...
@@ -9,8 +9,8 @@ import android.view.MenuItem;
...
@@ -9,8 +9,8 @@ import android.view.MenuItem;
import
android.view.View
;
import
android.view.View
;
import
com.google.android.material.navigation.NavigationView
;
import
com.google.android.material.navigation.NavigationView
;
import
com.topjohnwu.core.Config
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Data
;
import
com.topjohnwu.core.utils.Topic
;
import
com.topjohnwu.core.utils.Topic
;
import
com.topjohnwu.core.utils.Utils
;
import
com.topjohnwu.core.utils.Utils
;
import
com.topjohnwu.magisk.components.BaseActivity
;
import
com.topjohnwu.magisk.components.BaseActivity
;
...
@@ -125,10 +125,10 @@ public class MainActivity extends BaseActivity
...
@@ -125,10 +125,10 @@ public class MainActivity extends BaseActivity
public
void
checkHideSection
()
{
public
void
checkHideSection
()
{
Menu
menu
=
navigationView
.
getMenu
();
Menu
menu
=
navigationView
.
getMenu
();
menu
.
findItem
(
R
.
id
.
magiskhide
).
setVisible
(
Shell
.
rootAccess
()
&&
menu
.
findItem
(
R
.
id
.
magiskhide
).
setVisible
(
Shell
.
rootAccess
()
&&
app
.
prefs
.
getBoolean
(
Const
.
Key
.
MAGISKHIDE
,
false
));
(
boolean
)
Config
.
get
(
Config
.
Key
.
MAGISKHIDE
));
menu
.
findItem
(
R
.
id
.
modules
).
setVisible
(
Shell
.
rootAccess
()
&&
Data
.
magiskVersionCode
>=
0
);
menu
.
findItem
(
R
.
id
.
modules
).
setVisible
(
Shell
.
rootAccess
()
&&
Config
.
magiskVersionCode
>=
0
);
menu
.
findItem
(
R
.
id
.
downloads
).
setVisible
(
Networking
.
checkNetworkStatus
(
this
)
menu
.
findItem
(
R
.
id
.
downloads
).
setVisible
(
Networking
.
checkNetworkStatus
(
this
)
&&
Shell
.
rootAccess
()
&&
Data
.
magiskVersionCode
>=
0
);
&&
Shell
.
rootAccess
()
&&
Config
.
magiskVersionCode
>=
0
);
menu
.
findItem
(
R
.
id
.
log
).
setVisible
(
Shell
.
rootAccess
());
menu
.
findItem
(
R
.
id
.
log
).
setVisible
(
Shell
.
rootAccess
());
menu
.
findItem
(
R
.
id
.
superuser
).
setVisible
(
Utils
.
showSuperUser
());
menu
.
findItem
(
R
.
id
.
superuser
).
setVisible
(
Utils
.
showSuperUser
());
}
}
...
...
app/src/full/java/com/topjohnwu/magisk/SplashActivity.java
View file @
a189dec1
...
@@ -5,8 +5,8 @@ import android.content.pm.PackageManager;
...
@@ -5,8 +5,8 @@ import android.content.pm.PackageManager;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
com.topjohnwu.core.Config
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Data
;
import
com.topjohnwu.core.tasks.CheckUpdates
;
import
com.topjohnwu.core.tasks.CheckUpdates
;
import
com.topjohnwu.core.tasks.UpdateRepos
;
import
com.topjohnwu.core.tasks.UpdateRepos
;
import
com.topjohnwu.core.utils.LocaleManager
;
import
com.topjohnwu.core.utils.LocaleManager
;
...
@@ -27,9 +27,9 @@ public class SplashActivity extends BaseActivity {
...
@@ -27,9 +27,9 @@ public class SplashActivity extends BaseActivity {
// Dynamic detect all locales
// Dynamic detect all locales
LocaleManager
.
loadAvailableLocales
(
R
.
string
.
app_changelog
);
LocaleManager
.
loadAvailableLocales
(
R
.
string
.
app_changelog
);
String
pkg
=
app
.
mDB
.
getStrings
(
Const
.
Key
.
SU_MANAGER
,
null
);
String
pkg
=
Config
.
get
(
Config
.
Key
.
SU_MANAGER
);
if
(
pkg
!=
null
&&
getPackageName
().
equals
(
BuildConfig
.
APPLICATION_ID
))
{
if
(
pkg
!=
null
&&
getPackageName
().
equals
(
BuildConfig
.
APPLICATION_ID
))
{
app
.
mDB
.
setStrings
(
Const
.
Key
.
SU_MANAGER
,
null
);
Config
.
remove
(
Config
.
Key
.
SU_MANAGER
);
Shell
.
su
(
"pm uninstall "
+
pkg
).
exec
();
Shell
.
su
(
"pm uninstall "
+
pkg
).
exec
();
}
}
if
(
TextUtils
.
equals
(
pkg
,
getPackageName
()))
{
if
(
TextUtils
.
equals
(
pkg
,
getPackageName
()))
{
...
@@ -41,12 +41,13 @@ public class SplashActivity extends BaseActivity {
...
@@ -41,12 +41,13 @@ public class SplashActivity extends BaseActivity {
}
}
// Magisk working as expected
// Magisk working as expected
if
(
Shell
.
rootAccess
()
&&
Data
.
magiskVersionCode
>
0
)
{
if
(
Shell
.
rootAccess
()
&&
Config
.
magiskVersionCode
>
0
)
{
// Load modules
// Load modules
Utils
.
loadModules
();
Utils
.
loadModules
();
}
}
Data
.
importPrefs
();
// Set default configs
Config
.
initialize
();
// Create notification channel on Android O
// Create notification channel on Android O
Notifications
.
setup
(
this
);
Notifications
.
setup
(
this
);
...
@@ -64,9 +65,6 @@ public class SplashActivity extends BaseActivity {
...
@@ -64,9 +65,6 @@ public class SplashActivity extends BaseActivity {
new
UpdateRepos
().
exec
();
new
UpdateRepos
().
exec
();
}
}
// Write back default values
Data
.
writeConfig
();
app
.
init
=
true
;
app
.
init
=
true
;
Intent
intent
=
new
Intent
(
this
,
ClassMap
.
get
(
MainActivity
.
class
));
Intent
intent
=
new
Intent
(
this
,
ClassMap
.
get
(
MainActivity
.
class
));
...
...
app/src/full/java/com/topjohnwu/magisk/SuRequestActivity.java
View file @
a189dec1
...
@@ -15,8 +15,7 @@ import android.widget.LinearLayout;
...
@@ -15,8 +15,7 @@ import android.widget.LinearLayout;
import
android.widget.Spinner
;
import
android.widget.Spinner
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Config
;
import
com.topjohnwu.core.Data
;
import
com.topjohnwu.core.container.Policy
;
import
com.topjohnwu.core.container.Policy
;
import
com.topjohnwu.magisk.components.BaseActivity
;
import
com.topjohnwu.magisk.components.BaseActivity
;
import
com.topjohnwu.magisk.utils.FingerprintHelper
;
import
com.topjohnwu.magisk.utils.FingerprintHelper
;
...
@@ -103,14 +102,14 @@ public class SuRequestActivity extends BaseActivity {
...
@@ -103,14 +102,14 @@ public class SuRequestActivity extends BaseActivity {
return
;
return
;
}
}
switch
(
Data
.
suResponseType
)
{
switch
(
(
int
)
Config
.
get
(
Config
.
Key
.
SU_AUTO_RESPONSE
)
)
{
case
Con
st
.
Value
.
SU_AUTO_DENY
:
case
Con
fig
.
Value
.
SU_AUTO_DENY
:
handleAction
(
Policy
.
DENY
,
0
);
handleAction
(
Policy
.
DENY
,
0
);
return
;
return
;
case
Con
st
.
Value
.
SU_AUTO_ALLOW
:
case
Con
fig
.
Value
.
SU_AUTO_ALLOW
:
handleAction
(
Policy
.
ALLOW
,
0
);
handleAction
(
Policy
.
ALLOW
,
0
);
return
;
return
;
case
Con
st
.
Value
.
SU_PROMPT
:
case
Con
fig
.
Value
.
SU_PROMPT
:
default
:
default
:
}
}
...
@@ -134,7 +133,7 @@ public class SuRequestActivity extends BaseActivity {
...
@@ -134,7 +133,7 @@ public class SuRequestActivity extends BaseActivity {
adapter
.
setDropDownViewResource
(
android
.
R
.
layout
.
simple_spinner_dropdown_item
);
adapter
.
setDropDownViewResource
(
android
.
R
.
layout
.
simple_spinner_dropdown_item
);
timeout
.
setAdapter
(
adapter
);
timeout
.
setAdapter
(
adapter
);
timer
=
new
CountDownTimer
(
Data
.
suRequestTimeout
*
1000
,
1000
)
{
timer
=
new
CountDownTimer
(
(
int
)
Config
.
get
(
Config
.
Key
.
SU_REQUEST_TIMEOUT
)
*
1000
,
1000
)
{
@Override
@Override
public
void
onTick
(
long
millisUntilFinished
)
{
public
void
onTick
(
long
millisUntilFinished
)
{
deny_btn
.
setText
(
getString
(
R
.
string
.
deny_with_str
,
"("
+
millisUntilFinished
/
1000
+
")"
));
deny_btn
.
setText
(
getString
(
R
.
string
.
deny_with_str
,
"("
+
millisUntilFinished
/
1000
+
")"
));
...
@@ -210,7 +209,7 @@ public class SuRequestActivity extends BaseActivity {
...
@@ -210,7 +209,7 @@ public class SuRequestActivity extends BaseActivity {
}
}
private
void
handleAction
(
int
action
)
{
private
void
handleAction
(
int
action
)
{
handleAction
(
action
,
Con
st
.
Value
.
timeoutList
[
timeout
.
getSelectedItemPosition
()]);
handleAction
(
action
,
Con
fig
.
Value
.
TIMEOUT_LIST
[
timeout
.
getSelectedItemPosition
()]);
}
}
private
void
handleAction
(
int
action
,
int
time
)
{
private
void
handleAction
(
int
action
,
int
time
)
{
...
...
app/src/full/java/com/topjohnwu/magisk/components/BaseActivity.java
View file @
a189dec1
...
@@ -10,8 +10,8 @@ import android.view.WindowManager;
...
@@ -10,8 +10,8 @@ import android.view.WindowManager;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.Config
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Data
;
import
com.topjohnwu.core.utils.LocaleManager
;
import
com.topjohnwu.core.utils.LocaleManager
;
import
com.topjohnwu.core.utils.Topic
;
import
com.topjohnwu.core.utils.Topic
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
...
@@ -59,7 +59,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Topic.Au
...
@@ -59,7 +59,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Topic.Au
@Override
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
Topic
.
subscribe
(
this
);
Topic
.
subscribe
(
this
);
if
(
Data
.
isDarkTheme
&&
getDarkTheme
()
!=
-
1
)
{
if
(
getDarkTheme
()
!=
-
1
&&
(
boolean
)
Config
.
get
(
Config
.
Key
.
DARK_THEME
)
)
{
setTheme
(
getDarkTheme
());
setTheme
(
getDarkTheme
());
}
}
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
...
...
app/src/full/java/com/topjohnwu/magisk/components/InstallMethodDialog.java
View file @
a189dec1
...
@@ -5,8 +5,8 @@ import android.content.Intent;
...
@@ -5,8 +5,8 @@ import android.content.Intent;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.google.android.material.snackbar.Snackbar
;
import
com.google.android.material.snackbar.Snackbar
;
import
com.topjohnwu.core.Config
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Data
;
import
com.topjohnwu.core.utils.Utils
;
import
com.topjohnwu.core.utils.Utils
;
import
com.topjohnwu.magisk.ClassMap
;
import
com.topjohnwu.magisk.ClassMap
;
import
com.topjohnwu.magisk.FlashActivity
;
import
com.topjohnwu.magisk.FlashActivity
;
...
@@ -65,10 +65,10 @@ class InstallMethodDialog extends AlertDialog.Builder {
...
@@ -65,10 +65,10 @@ class InstallMethodDialog extends AlertDialog.Builder {
private
void
downloadOnly
(
BaseActivity
a
)
{
private
void
downloadOnly
(
BaseActivity
a
)
{
a
.
runWithExternalRW
(()
->
{
a
.
runWithExternalRW
(()
->
{
String
filename
=
Utils
.
fmt
(
"Magisk-v%s(%d).zip"
,
String
filename
=
Utils
.
fmt
(
"Magisk-v%s(%d).zip"
,
Data
.
remoteMagiskVersionString
,
Data
.
remoteMagiskVersionCode
);
Config
.
remoteMagiskVersionString
,
Config
.
remoteMagiskVersionCode
);
File
zip
=
new
File
(
Const
.
EXTERNAL_PATH
,
filename
);
File
zip
=
new
File
(
Const
.
EXTERNAL_PATH
,
filename
);
ProgressNotification
progress
=
new
ProgressNotification
(
filename
);
ProgressNotification
progress
=
new
ProgressNotification
(
filename
);
Networking
.
get
(
Data
.
magiskLink
)
Networking
.
get
(
Config
.
magiskLink
)
.
setDownloadProgressListener
(
progress
)
.
setDownloadProgressListener
(
progress
)
.
setErrorHandler
(((
conn
,
e
)
->
progress
.
dlFail
()))
.
setErrorHandler
(((
conn
,
e
)
->
progress
.
dlFail
()))
.
getAsFile
(
zip
,
f
->
{
.
getAsFile
(
zip
,
f
->
{
...
...
app/src/full/java/com/topjohnwu/magisk/components/MagiskInstallDialog.java
View file @
a189dec1
...
@@ -3,7 +3,7 @@ package com.topjohnwu.magisk.components;
...
@@ -3,7 +3,7 @@ package com.topjohnwu.magisk.components;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
com.topjohnwu.core.
Data
;
import
com.topjohnwu.core.
Config
;
import
com.topjohnwu.core.utils.Utils
;
import
com.topjohnwu.core.utils.Utils
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.utils.AppUtils
;
import
com.topjohnwu.magisk.utils.AppUtils
;
...
@@ -17,7 +17,7 @@ public class MagiskInstallDialog extends CustomAlertDialog {
...
@@ -17,7 +17,7 @@ public class MagiskInstallDialog extends CustomAlertDialog {
public
MagiskInstallDialog
(
BaseActivity
a
)
{
public
MagiskInstallDialog
(
BaseActivity
a
)
{
super
(
a
);
super
(
a
);
String
filename
=
Utils
.
fmt
(
"Magisk-v%s(%d).zip"
,
String
filename
=
Utils
.
fmt
(
"Magisk-v%s(%d).zip"
,
Data
.
remoteMagiskVersionString
,
Data
.
remoteMagiskVersionCode
);
Config
.
remoteMagiskVersionString
,
Config
.
remoteMagiskVersionCode
);
setTitle
(
a
.
getString
(
R
.
string
.
repo_install_title
,
a
.
getString
(
R
.
string
.
magisk
)));
setTitle
(
a
.
getString
(
R
.
string
.
repo_install_title
,
a
.
getString
(
R
.
string
.
magisk
)));
setMessage
(
a
.
getString
(
R
.
string
.
repo_install_msg
,
filename
));
setMessage
(
a
.
getString
(
R
.
string
.
repo_install_msg
,
filename
));
setCancelable
(
true
);
setCancelable
(
true
);
...
@@ -35,13 +35,13 @@ public class MagiskInstallDialog extends CustomAlertDialog {
...
@@ -35,13 +35,13 @@ public class MagiskInstallDialog extends CustomAlertDialog {
new
InstallMethodDialog
(
a
,
options
).
show
();
new
InstallMethodDialog
(
a
,
options
).
show
();
});
});
setNegativeButton
(
R
.
string
.
no_thanks
,
null
);
setNegativeButton
(
R
.
string
.
no_thanks
,
null
);
if
(!
TextUtils
.
isEmpty
(
Data
.
magiskNoteLink
))
{
if
(!
TextUtils
.
isEmpty
(
Config
.
magiskNoteLink
))
{
setNeutralButton
(
R
.
string
.
release_notes
,
(
d
,
i
)
->
{
setNeutralButton
(
R
.
string
.
release_notes
,
(
d
,
i
)
->
{
if
(
Data
.
magiskNoteLink
.
contains
(
"forum.xda-developers"
))
{
if
(
Config
.
magiskNoteLink
.
contains
(
"forum.xda-developers"
))
{
// Open forum links in browser
// Open forum links in browser
AppUtils
.
openLink
(
a
,
Uri
.
parse
(
Data
.
magiskNoteLink
));
AppUtils
.
openLink
(
a
,
Uri
.
parse
(
Config
.
magiskNoteLink
));
}
else
{
}
else
{
MarkDownWindow
.
show
(
a
,
null
,
Data
.
magiskNoteLink
);
MarkDownWindow
.
show
(
a
,
null
,
Config
.
magiskNoteLink
);
}
}
});
});
}
}
...
...
app/src/full/java/com/topjohnwu/magisk/components/ManagerInstallDialog.java
View file @
a189dec1
...
@@ -2,7 +2,7 @@ package com.topjohnwu.magisk.components;
...
@@ -2,7 +2,7 @@ package com.topjohnwu.magisk.components;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
com.topjohnwu.core.
Data
;
import
com.topjohnwu.core.
Config
;
import
com.topjohnwu.core.utils.Utils
;
import
com.topjohnwu.core.utils.Utils
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.utils.DownloadApp
;
import
com.topjohnwu.magisk.utils.DownloadApp
;
...
@@ -14,14 +14,14 @@ public class ManagerInstallDialog extends CustomAlertDialog {
...
@@ -14,14 +14,14 @@ public class ManagerInstallDialog extends CustomAlertDialog {
public
ManagerInstallDialog
(
@NonNull
BaseActivity
a
)
{
public
ManagerInstallDialog
(
@NonNull
BaseActivity
a
)
{
super
(
a
);
super
(
a
);
String
name
=
Utils
.
fmt
(
"MagiskManager v%s(%d)"
,
String
name
=
Utils
.
fmt
(
"MagiskManager v%s(%d)"
,
Data
.
remoteManagerVersionString
,
Data
.
remoteManagerVersionCode
);
Config
.
remoteManagerVersionString
,
Config
.
remoteManagerVersionCode
);
setTitle
(
a
.
getString
(
R
.
string
.
repo_install_title
,
a
.
getString
(
R
.
string
.
app_name
)));
setTitle
(
a
.
getString
(
R
.
string
.
repo_install_title
,
a
.
getString
(
R
.
string
.
app_name
)));
setMessage
(
a
.
getString
(
R
.
string
.
repo_install_msg
,
name
));
setMessage
(
a
.
getString
(
R
.
string
.
repo_install_msg
,
name
));
setCancelable
(
true
);
setCancelable
(
true
);
setPositiveButton
(
R
.
string
.
install
,
(
d
,
i
)
->
DownloadApp
.
upgrade
(
name
));
setPositiveButton
(
R
.
string
.
install
,
(
d
,
i
)
->
DownloadApp
.
upgrade
(
name
));
setNegativeButton
(
R
.
string
.
no_thanks
,
null
);
setNegativeButton
(
R
.
string
.
no_thanks
,
null
);
if
(!
TextUtils
.
isEmpty
(
Data
.
managerNoteLink
))
{
if
(!
TextUtils
.
isEmpty
(
Config
.
managerNoteLink
))
{
setNeutralButton
(
R
.
string
.
app_changelog
,
(
d
,
i
)
->
MarkDownWindow
.
show
(
a
,
null
,
Data
.
managerNoteLink
));
setNeutralButton
(
R
.
string
.
app_changelog
,
(
d
,
i
)
->
MarkDownWindow
.
show
(
a
,
null
,
Config
.
managerNoteLink
));
}
}
}
}
}
}
app/src/full/java/com/topjohnwu/magisk/components/Notifications.java
View file @
a189dec1
...
@@ -8,8 +8,8 @@ import android.content.Intent;
...
@@ -8,8 +8,8 @@ import android.content.Intent;
import
android.os.Build
;
import
android.os.Build
;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.Config
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Data
;
import
com.topjohnwu.core.utils.Utils
;
import
com.topjohnwu.core.utils.Utils
;
import
com.topjohnwu.magisk.ClassMap
;
import
com.topjohnwu.magisk.ClassMap
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
...
@@ -52,7 +52,7 @@ public class Notifications {
...
@@ -52,7 +52,7 @@ public class Notifications {
NotificationCompat
.
Builder
builder
=
new
NotificationCompat
.
Builder
(
app
,
Const
.
ID
.
UPDATE_NOTIFICATION_CHANNEL
);
NotificationCompat
.
Builder
builder
=
new
NotificationCompat
.
Builder
(
app
,
Const
.
ID
.
UPDATE_NOTIFICATION_CHANNEL
);
builder
.
setSmallIcon
(
R
.
drawable
.
ic_magisk_outline
)
builder
.
setSmallIcon
(
R
.
drawable
.
ic_magisk_outline
)
.
setContentTitle
(
app
.
getString
(
R
.
string
.
magisk_update_title
))
.
setContentTitle
(
app
.
getString
(
R
.
string
.
magisk_update_title
))
.
setContentText
(
app
.
getString
(
R
.
string
.
magisk_update_available
,
Data
.
remoteMagiskVersionString
))
.
setContentText
(
app
.
getString
(
R
.
string
.
magisk_update_available
,
Config
.
remoteMagiskVersionString
))
.
setVibrate
(
new
long
[]{
0
,
100
,
100
,
100
})
.
setVibrate
(
new
long
[]{
0
,
100
,
100
,
100
})
.
setAutoCancel
(
true
)
.
setAutoCancel
(
true
)
.
setContentIntent
(
pendingIntent
);
.
setContentIntent
(
pendingIntent
);
...
@@ -63,11 +63,11 @@ public class Notifications {
...
@@ -63,11 +63,11 @@ public class Notifications {
public
static
void
managerUpdate
()
{
public
static
void
managerUpdate
()
{
App
app
=
App
.
self
;
App
app
=
App
.
self
;
String
name
=
Utils
.
fmt
(
"MagiskManager v%s(%d)"
,
String
name
=
Utils
.
fmt
(
"MagiskManager v%s(%d)"
,
Data
.
remoteManagerVersionString
,
Data
.
remoteManagerVersionCode
);
Config
.
remoteManagerVersionString
,
Config
.
remoteManagerVersionCode
);
Intent
intent
=
new
Intent
(
app
,
ClassMap
.
get
(
GeneralReceiver
.
class
));
Intent
intent
=
new
Intent
(
app
,
ClassMap
.
get
(
GeneralReceiver
.
class
));
intent
.
setAction
(
Const
.
Key
.
BROADCAST_MANAGER_UPDATE
);
intent
.
setAction
(
Const
.
Key
.
BROADCAST_MANAGER_UPDATE
);
intent
.
putExtra
(
Const
.
Key
.
INTENT_SET_LINK
,
Data
.
managerLink
);
intent
.
putExtra
(
Const
.
Key
.
INTENT_SET_LINK
,
Config
.
managerLink
);
intent
.
putExtra
(
Const
.
Key
.
INTENT_SET_NAME
,
name
);
intent
.
putExtra
(
Const
.
Key
.
INTENT_SET_NAME
,
name
);
PendingIntent
pendingIntent
=
PendingIntent
.
getBroadcast
(
app
,
PendingIntent
pendingIntent
=
PendingIntent
.
getBroadcast
(
app
,
Const
.
ID
.
APK_UPDATE_NOTIFICATION_ID
,
intent
,
PendingIntent
.
FLAG_UPDATE_CURRENT
);
Const
.
ID
.
APK_UPDATE_NOTIFICATION_ID
,
intent
,
PendingIntent
.
FLAG_UPDATE_CURRENT
);
...
...
app/src/full/java/com/topjohnwu/magisk/components/UninstallDialog.java
View file @
a189dec1
...
@@ -7,8 +7,8 @@ import android.net.Uri;
...
@@ -7,8 +7,8 @@ import android.net.Uri;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.topjohnwu.core.Config
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Data
;
import
com.topjohnwu.core.utils.Utils
;
import
com.topjohnwu.core.utils.Utils
;
import
com.topjohnwu.magisk.ClassMap
;
import
com.topjohnwu.magisk.ClassMap
;
import
com.topjohnwu.magisk.FlashActivity
;
import
com.topjohnwu.magisk.FlashActivity
;
...
@@ -39,11 +39,11 @@ public class UninstallDialog extends CustomAlertDialog {
...
@@ -39,11 +39,11 @@ public class UninstallDialog extends CustomAlertDialog {
}
}
});
});
});
});
if
(!
TextUtils
.
isEmpty
(
Data
.
uninstallerLink
))
{
if
(!
TextUtils
.
isEmpty
(
Config
.
uninstallerLink
))
{
setPositiveButton
(
R
.
string
.
complete_uninstall
,
(
d
,
i
)
->
{
setPositiveButton
(
R
.
string
.
complete_uninstall
,
(
d
,
i
)
->
{
File
zip
=
new
File
(
activity
.
getFilesDir
(),
"uninstaller.zip"
);
File
zip
=
new
File
(
activity
.
getFilesDir
(),
"uninstaller.zip"
);
ProgressNotification
progress
=
new
ProgressNotification
(
zip
.
getName
());
ProgressNotification
progress
=
new
ProgressNotification
(
zip
.
getName
());
Networking
.
get
(
Data
.
uninstallerLink
)
Networking
.
get
(
Config
.
uninstallerLink
)
.
setDownloadProgressListener
(
progress
)
.
setDownloadProgressListener
(
progress
)
.
setErrorHandler
(((
conn
,
e
)
->
progress
.
dlFail
()))
.
setErrorHandler
(((
conn
,
e
)
->
progress
.
dlFail
()))
.
getAsFile
(
zip
,
f
->
{
.
getAsFile
(
zip
,
f
->
{
...
...
app/src/full/java/com/topjohnwu/magisk/fragments/MagiskFragment.java
View file @
a189dec1
...
@@ -15,8 +15,7 @@ import android.widget.ProgressBar;
...
@@ -15,8 +15,7 @@ import android.widget.ProgressBar;
import
android.widget.RelativeLayout
;
import
android.widget.RelativeLayout
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Config
;
import
com.topjohnwu.core.Data
;
import
com.topjohnwu.core.tasks.CheckUpdates
;
import
com.topjohnwu.core.tasks.CheckUpdates
;
import
com.topjohnwu.core.tasks.SafetyNet
;
import
com.topjohnwu.core.tasks.SafetyNet
;
import
com.topjohnwu.core.utils.ISafetyNetHelper
;
import
com.topjohnwu.core.utils.ISafetyNetHelper
;
...
@@ -112,7 +111,7 @@ public class MagiskFragment extends BaseFragment
...
@@ -112,7 +111,7 @@ public class MagiskFragment extends BaseFragment
@OnClick
(
R
.
id
.
install_button
)
@OnClick
(
R
.
id
.
install_button
)
void
install
()
{
void
install
()
{
// Show Manager update first
// Show Manager update first
if
(
Data
.
remoteManagerVersionCode
>
BuildConfig
.
VERSION_CODE
)
{
if
(
Config
.
remoteManagerVersionCode
>
BuildConfig
.
VERSION_CODE
)
{
new
ManagerInstallDialog
((
BaseActivity
)
requireActivity
()).
show
();
new
ManagerInstallDialog
((
BaseActivity
)
requireActivity
()).
show
();
return
;
return
;
}
}
...
@@ -137,10 +136,10 @@ public class MagiskFragment extends BaseFragment
...
@@ -137,10 +136,10 @@ public class MagiskFragment extends BaseFragment
expandableContainer
.
expandLayout
=
expandLayout
;
expandableContainer
.
expandLayout
=
expandLayout
;
setupExpandable
();
setupExpandable
();
keepVerityChkbox
.
setChecked
(
Data
.
keepVerity
);
keepVerityChkbox
.
setChecked
(
Config
.
keepVerity
);
keepVerityChkbox
.
setOnCheckedChangeListener
((
view
,
checked
)
->
Data
.
keepVerity
=
checked
);
keepVerityChkbox
.
setOnCheckedChangeListener
((
view
,
checked
)
->
Config
.
keepVerity
=
checked
);
keepEncChkbox
.
setChecked
(
Data
.
keepEnc
);
keepEncChkbox
.
setChecked
(
Config
.
keepEnc
);
keepEncChkbox
.
setOnCheckedChangeListener
((
view
,
checked
)
->
Data
.
keepEnc
=
checked
);
keepEncChkbox
.
setOnCheckedChangeListener
((
view
,
checked
)
->
Config
.
keepEnc
=
checked
);
mSwipeRefreshLayout
.
setOnRefreshListener
(
this
);
mSwipeRefreshLayout
.
setOnRefreshListener
(
this
);
updateUI
();
updateUI
();
...
@@ -150,7 +149,7 @@ public class MagiskFragment extends BaseFragment
...
@@ -150,7 +149,7 @@ public class MagiskFragment extends BaseFragment
@Override
@Override
public
void
onRefresh
()
{
public
void
onRefresh
()
{
Data
.
loadMagiskInfo
();
Config
.
loadMagiskInfo
();
updateUI
();
updateUI
();
magiskUpdateText
.
setText
(
R
.
string
.
checking_for_updates
);
magiskUpdateText
.
setText
(
R
.
string
.
checking_for_updates
);
...
@@ -160,8 +159,8 @@ public class MagiskFragment extends BaseFragment
...
@@ -160,8 +159,8 @@ public class MagiskFragment extends BaseFragment
safetyNetStatusText
.
setText
(
R
.
string
.
safetyNet_check_text
);
safetyNetStatusText
.
setText
(
R
.
string
.
safetyNet_check_text
);
Topic
.
reset
(
getSubscribedTopics
());
Topic
.
reset
(
getSubscribedTopics
());
Data
.
remoteMagiskVersionString
=
null
;
Config
.
remoteMagiskVersionString
=
null
;
Data
.
remoteMagiskVersionCode
=
-
1
;
Config
.
remoteMagiskVersionCode
=
-
1
;
collapse
();
collapse
();
shownDialog
=
false
;
shownDialog
=
false
;
...
@@ -216,18 +215,18 @@ public class MagiskFragment extends BaseFragment
...
@@ -216,18 +215,18 @@ public class MagiskFragment extends BaseFragment
magiskUpdate
.
setVisibility
(
hasNetwork
?
View
.
VISIBLE
:
View
.
GONE
);
magiskUpdate
.
setVisibility
(
hasNetwork
?
View
.
VISIBLE
:
View
.
GONE
);
installOptionCard
.
setVisibility
(
hasNetwork
?
View
.
VISIBLE
:
View
.
GONE
);
installOptionCard
.
setVisibility
(
hasNetwork
?
View
.
VISIBLE
:
View
.
GONE
);
uninstallButton
.
setVisibility
(
hasRoot
?
View
.
VISIBLE
:
View
.
GONE
);
uninstallButton
.
setVisibility
(
hasRoot
?
View
.
VISIBLE
:
View
.
GONE
);
coreOnlyNotice
.
setVisibility
(
app
.
prefs
.
getBoolean
(
Const
.
Key
.
COREONLY
,
false
)
?
View
.
VISIBLE
:
View
.
GONE
);
coreOnlyNotice
.
setVisibility
(
Config
.
get
(
Config
.
Key
.
COREONLY
)
?
View
.
VISIBLE
:
View
.
GONE
);
int
image
,
color
;
int
image
,
color
;
if
(
Data
.
magiskVersionCode
<
0
)
{
if
(
Config
.
magiskVersionCode
<
0
)
{
color
=
colorBad
;
color
=
colorBad
;
image
=
R
.
drawable
.
ic_cancel
;
image
=
R
.
drawable
.
ic_cancel
;
magiskVersionText
.
setText
(
R
.
string
.
magisk_version_error
);
magiskVersionText
.
setText
(
R
.
string
.
magisk_version_error
);
}
else
{
}
else
{
color
=
colorOK
;
color
=
colorOK
;
image
=
R
.
drawable
.
ic_check_circle
;
image
=
R
.
drawable
.
ic_check_circle
;
magiskVersionText
.
setText
(
getString
(
R
.
string
.
current_magisk_title
,
"v"
+
Data
.
magiskVersionString
));
magiskVersionText
.
setText
(
getString
(
R
.
string
.
current_magisk_title
,
"v"
+
Config
.
magiskVersionString
));
}
}
magiskStatusIcon
.
setImageResource
(
image
);
magiskStatusIcon
.
setImageResource
(
image
);
...
@@ -239,7 +238,7 @@ public class MagiskFragment extends BaseFragment
...
@@ -239,7 +238,7 @@ public class MagiskFragment extends BaseFragment
safetyNetCard
.
setVisibility
(
hasGms
()
?
View
.
VISIBLE
:
View
.
GONE
);
safetyNetCard
.
setVisibility
(
hasGms
()
?
View
.
VISIBLE
:
View
.
GONE
);
if
(
Data
.
remoteMagiskVersionCode
<
0
)
{
if
(
Config
.
remoteMagiskVersionCode
<
0
)
{
color
=
colorNeutral
;
color
=
colorNeutral
;
image
=
R
.
drawable
.
ic_help
;
image
=
R
.
drawable
.
ic_help
;
magiskUpdateText
.
setText
(
R
.
string
.
invalid_update_channel
);
magiskUpdateText
.
setText
(
R
.
string
.
invalid_update_channel
);
...
@@ -247,11 +246,11 @@ public class MagiskFragment extends BaseFragment
...
@@ -247,11 +246,11 @@ public class MagiskFragment extends BaseFragment
}
else
{
}
else
{
color
=
colorOK
;
color
=
colorOK
;
image
=
R
.
drawable
.
ic_check_circle
;
image
=
R
.
drawable
.
ic_check_circle
;
magiskUpdateText
.
setText
(
getString
(
R
.
string
.
install_magisk_title
,
"v"
+
Data
.
remoteMagiskVersionString
));
magiskUpdateText
.
setText
(
getString
(
R
.
string
.
install_magisk_title
,
"v"
+
Config
.
remoteMagiskVersionString
));
installButton
.
setVisibility
(
View
.
VISIBLE
);
installButton
.
setVisibility
(
View
.
VISIBLE
);
if
(
Data
.
remoteManagerVersionCode
>
BuildConfig
.
VERSION_CODE
)
{
if
(
Config
.
remoteManagerVersionCode
>
BuildConfig
.
VERSION_CODE
)
{
installText
.
setText
(
getString
(
R
.
string
.
update
,
getString
(
R
.
string
.
app_name
)));
installText
.
setText
(
getString
(
R
.
string
.
update
,
getString
(
R
.
string
.
app_name
)));
}
else
if
(
Data
.
magiskVersionCode
>
0
&&
Data
.
remoteMagiskVersionCode
>
Data
.
magiskVersionCode
)
{
}
else
if
(
Config
.
magiskVersionCode
>
0
&&
Config
.
remoteMagiskVersionCode
>
Config
.
magiskVersionCode
)
{
installText
.
setText
(
getString
(
R
.
string
.
update
,
getString
(
R
.
string
.
magisk
)));
installText
.
setText
(
getString
(
R
.
string
.
update
,
getString
(
R
.
string
.
magisk
)));
}
else
{
}
else
{
installText
.
setText
(
R
.
string
.
install
);
installText
.
setText
(
R
.
string
.
install
);
...
...
app/src/full/java/com/topjohnwu/magisk/fragments/ReposFragment.java
View file @
a189dec1
...
@@ -11,8 +11,7 @@ import android.view.ViewGroup;
...
@@ -11,8 +11,7 @@ import android.view.ViewGroup;
import
android.widget.SearchView
;
import
android.widget.SearchView
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Config
;
import
com.topjohnwu.core.Data
;
import
com.topjohnwu.core.container.Module
;
import
com.topjohnwu.core.container.Module
;
import
com.topjohnwu.core.tasks.UpdateRepos
;
import
com.topjohnwu.core.tasks.UpdateRepos
;
import
com.topjohnwu.core.utils.Topic
;
import
com.topjohnwu.core.utils.Topic
;
...
@@ -106,9 +105,9 @@ public class ReposFragment extends BaseFragment implements Topic.Subscriber {
...
@@ -106,9 +105,9 @@ public class ReposFragment extends BaseFragment implements Topic.Subscriber {
if
(
item
.
getItemId
()
==
R
.
id
.
repo_sort
)
{
if
(
item
.
getItemId
()
==
R
.
id
.
repo_sort
)
{
new
AlertDialog
.
Builder
(
getActivity
())
new
AlertDialog
.
Builder
(
getActivity
())
.
setTitle
(
R
.
string
.
sorting_order
)
.
setTitle
(
R
.
string
.
sorting_order
)
.
setSingleChoiceItems
(
R
.
array
.
sorting_orders
,
Data
.
repoOrder
,
(
d
,
which
)
->
{
.
setSingleChoiceItems
(
R
.
array
.
sorting_orders
,
Data
.
repoOrder
=
which
;
Config
.
get
(
Config
.
Key
.
REPO_ORDER
),
(
d
,
which
)
->
{
app
.
prefs
.
edit
().
putInt
(
Const
.
Key
.
REPO_ORDER
,
Data
.
repoOrder
).
apply
(
);
Config
.
set
(
Config
.
Key
.
REPO_ORDER
,
which
);
adapter
.
notifyDBChanged
();
adapter
.
notifyDBChanged
();
d
.
dismiss
();
d
.
dismiss
();
}).
show
();
}).
show
();
...
...
app/src/full/java/com/topjohnwu/magisk/fragments/SettingsFragment.java
View file @
a189dec1
This diff is collapsed.
Click to expand it.
app/src/full/java/com/topjohnwu/magisk/receivers/GeneralReceiver.java
View file @
a189dec1
...
@@ -6,8 +6,8 @@ import android.content.Intent;
...
@@ -6,8 +6,8 @@ import android.content.Intent;
import
android.os.AsyncTask
;
import
android.os.AsyncTask
;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.Config
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Data
;
import
com.topjohnwu.magisk.ClassMap
;
import
com.topjohnwu.magisk.ClassMap
;
import
com.topjohnwu.magisk.SuRequestActivity
;
import
com.topjohnwu.magisk.SuRequestActivity
;
import
com.topjohnwu.magisk.components.Notifications
;
import
com.topjohnwu.magisk.components.Notifications
;
...
@@ -66,7 +66,7 @@ public class GeneralReceiver extends BroadcastReceiver {
...
@@ -66,7 +66,7 @@ public class GeneralReceiver extends BroadcastReceiver {
break
;
break
;
case
Intent
.
ACTION_PACKAGE_REPLACED
:
case
Intent
.
ACTION_PACKAGE_REPLACED
:
// This will only work pre-O
// This will only work pre-O
if
(
app
.
prefs
.
getBoolean
(
Const
.
Key
.
SU_REAUTH
,
false
))
{
if
(
Config
.
get
(
Config
.
Key
.
SU_REAUTH
))
{
app
.
mDB
.
deletePolicy
(
getPkg
(
intent
));
app
.
mDB
.
deletePolicy
(
getPkg
(
intent
));
}
}
break
;
break
;
...
@@ -76,7 +76,7 @@ public class GeneralReceiver extends BroadcastReceiver {
...
@@ -76,7 +76,7 @@ public class GeneralReceiver extends BroadcastReceiver {
Shell
.
su
(
"magiskhide --rm "
+
pkg
).
submit
();
Shell
.
su
(
"magiskhide --rm "
+
pkg
).
submit
();
break
;
break
;
case
Const
.
Key
.
BROADCAST_MANAGER_UPDATE
:
case
Const
.
Key
.
BROADCAST_MANAGER_UPDATE
:
Data
.
managerLink
=
intent
.
getStringExtra
(
Const
.
Key
.
INTENT_SET_LINK
);
Config
.
managerLink
=
intent
.
getStringExtra
(
Const
.
Key
.
INTENT_SET_LINK
);
DownloadApp
.
upgrade
(
intent
.
getStringExtra
(
Const
.
Key
.
INTENT_SET_NAME
));
DownloadApp
.
upgrade
(
intent
.
getStringExtra
(
Const
.
Key
.
INTENT_SET_NAME
));
break
;
break
;
case
Const
.
Key
.
BROADCAST_REBOOT
:
case
Const
.
Key
.
BROADCAST_REBOOT
:
...
...
app/src/full/java/com/topjohnwu/magisk/receivers/ShortcutReceiver.java
View file @
a189dec1
...
@@ -9,8 +9,8 @@ import android.graphics.drawable.Icon;
...
@@ -9,8 +9,8 @@ import android.graphics.drawable.Icon;
import
android.os.Build
;
import
android.os.Build
;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.Config
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Data
;
import
com.topjohnwu.core.utils.Utils
;
import
com.topjohnwu.core.utils.Utils
;
import
com.topjohnwu.magisk.ClassMap
;
import
com.topjohnwu.magisk.ClassMap
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
...
@@ -45,7 +45,7 @@ public class ShortcutReceiver extends BroadcastReceiver {
...
@@ -45,7 +45,7 @@ public class ShortcutReceiver extends BroadcastReceiver {
.
setRank
(
0
)
.
setRank
(
0
)
.
build
());
.
build
());
}
}
if
(
root
&&
app
.
prefs
.
getBoolean
(
Const
.
Key
.
MAGISKHIDE
,
false
))
{
if
(
root
&&
(
boolean
)
Config
.
get
(
Config
.
Key
.
MAGISKHIDE
))
{
shortCuts
.
add
(
new
ShortcutInfo
.
Builder
(
app
,
"magiskhide"
)
shortCuts
.
add
(
new
ShortcutInfo
.
Builder
(
app
,
"magiskhide"
)
.
setShortLabel
(
app
.
getString
(
R
.
string
.
magiskhide
))
.
setShortLabel
(
app
.
getString
(
R
.
string
.
magiskhide
))
.
setIntent
(
new
Intent
(
app
,
ClassMap
.
get
(
SplashActivity
.
class
))
.
setIntent
(
new
Intent
(
app
,
ClassMap
.
get
(
SplashActivity
.
class
))
...
@@ -56,7 +56,7 @@ public class ShortcutReceiver extends BroadcastReceiver {
...
@@ -56,7 +56,7 @@ public class ShortcutReceiver extends BroadcastReceiver {
.
setRank
(
1
)
.
setRank
(
1
)
.
build
());
.
build
());
}
}
if
(!
app
.
prefs
.
getBoolean
(
Const
.
Key
.
COREONLY
,
false
)
&&
root
&&
Data
.
magiskVersionCode
>=
0
)
{
if
(!
(
boolean
)
Config
.
get
(
Config
.
Key
.
COREONLY
)
&&
root
&&
Config
.
magiskVersionCode
>=
0
)
{
shortCuts
.
add
(
new
ShortcutInfo
.
Builder
(
app
,
"modules"
)
shortCuts
.
add
(
new
ShortcutInfo
.
Builder
(
app
,
"modules"
)
.
setShortLabel
(
app
.
getString
(
R
.
string
.
modules
))
.
setShortLabel
(
app
.
getString
(
R
.
string
.
modules
))
.
setIntent
(
new
Intent
(
app
,
ClassMap
.
get
(
SplashActivity
.
class
))
.
setIntent
(
new
Intent
(
app
,
ClassMap
.
get
(
SplashActivity
.
class
))
...
...
app/src/full/java/com/topjohnwu/magisk/services/UpdateCheckService.java
View file @
a189dec1
package
com
.
topjohnwu
.
magisk
.
services
;
package
com
.
topjohnwu
.
magisk
.
services
;
import
com.topjohnwu.core.
Data
;
import
com.topjohnwu.core.
Config
;
import
com.topjohnwu.core.tasks.CheckUpdates
;
import
com.topjohnwu.core.tasks.CheckUpdates
;
import
com.topjohnwu.magisk.BuildConfig
;
import
com.topjohnwu.magisk.BuildConfig
;
import
com.topjohnwu.magisk.components.Notifications
;
import
com.topjohnwu.magisk.components.Notifications
;
...
@@ -20,9 +20,9 @@ public class UpdateCheckService extends DelegateWorker {
...
@@ -20,9 +20,9 @@ public class UpdateCheckService extends DelegateWorker {
}
}
private
void
onCheckDone
()
{
private
void
onCheckDone
()
{
if
(
BuildConfig
.
VERSION_CODE
<
Data
.
remoteManagerVersionCode
)
{
if
(
BuildConfig
.
VERSION_CODE
<
Config
.
remoteManagerVersionCode
)
{
Notifications
.
managerUpdate
();
Notifications
.
managerUpdate
();
}
else
if
(
Data
.
magiskVersionCode
<
Data
.
remoteMagiskVersionCode
)
{
}
else
if
(
Config
.
magiskVersionCode
<
Config
.
remoteMagiskVersionCode
)
{
Notifications
.
magiskUpdate
();
Notifications
.
magiskUpdate
();
}
}
}
}
...
...
app/src/full/java/com/topjohnwu/magisk/utils/AppUtils.java
View file @
a189dec1
...
@@ -5,7 +5,7 @@ import android.content.Intent;
...
@@ -5,7 +5,7 @@ import android.content.Intent;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.topjohnwu.core.
App
;
import
com.topjohnwu.core.
Config
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.utils.Utils
;
import
com.topjohnwu.core.utils.Utils
;
import
com.topjohnwu.magisk.ClassMap
;
import
com.topjohnwu.magisk.ClassMap
;
...
@@ -23,7 +23,7 @@ import androidx.work.WorkManager;
...
@@ -23,7 +23,7 @@ import androidx.work.WorkManager;
public
class
AppUtils
{
public
class
AppUtils
{
public
static
void
scheduleUpdateCheck
()
{
public
static
void
scheduleUpdateCheck
()
{
if
(
App
.
self
.
prefs
.
getBoolean
(
Const
.
Key
.
CHECK_UPDATES
,
true
))
{
if
(
Config
.
get
(
Config
.
Key
.
CHECK_UPDATES
))
{
Constraints
constraints
=
new
Constraints
.
Builder
()
Constraints
constraints
=
new
Constraints
.
Builder
()
.
setRequiredNetworkType
(
NetworkType
.
CONNECTED
)
.
setRequiredNetworkType
(
NetworkType
.
CONNECTED
)
.
build
();
.
build
();
...
...
app/src/full/java/com/topjohnwu/magisk/utils/DownloadApp.java
View file @
a189dec1
...
@@ -3,7 +3,7 @@ package com.topjohnwu.magisk.utils;
...
@@ -3,7 +3,7 @@ package com.topjohnwu.magisk.utils;
import
android.os.AsyncTask
;
import
android.os.AsyncTask
;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.
Data
;
import
com.topjohnwu.core.
Config
;
import
com.topjohnwu.core.utils.RootUtils
;
import
com.topjohnwu.core.utils.RootUtils
;
import
com.topjohnwu.core.utils.Utils
;
import
com.topjohnwu.core.utils.Utils
;
import
com.topjohnwu.magisk.BuildConfig
;
import
com.topjohnwu.magisk.BuildConfig
;
...
@@ -25,7 +25,7 @@ public class DownloadApp {
...
@@ -25,7 +25,7 @@ public class DownloadApp {
public
static
void
restore
()
{
public
static
void
restore
()
{
String
name
=
Utils
.
fmt
(
"MagiskManager v%s(%d)"
,
String
name
=
Utils
.
fmt
(
"MagiskManager v%s(%d)"
,
Data
.
remoteManagerVersionString
,
Data
.
remoteManagerVersionCode
);
Config
.
remoteManagerVersionString
,
Config
.
remoteManagerVersionCode
);
dlInstall
(
name
,
new
RestoreManager
());
dlInstall
(
name
,
new
RestoreManager
());
}
}
...
@@ -33,7 +33,7 @@ public class DownloadApp {
...
@@ -33,7 +33,7 @@ public class DownloadApp {
File
apk
=
new
File
(
App
.
self
.
getCacheDir
(),
"manager.apk"
);
File
apk
=
new
File
(
App
.
self
.
getCacheDir
(),
"manager.apk"
);
ProgressNotification
progress
=
new
ProgressNotification
(
name
);
ProgressNotification
progress
=
new
ProgressNotification
(
name
);
listener
.
progress
=
progress
;
listener
.
progress
=
progress
;
Networking
.
get
(
Data
.
managerLink
)
Networking
.
get
(
Config
.
managerLink
)
.
setExecutor
(
AsyncTask
.
THREAD_POOL_EXECUTOR
)
.
setExecutor
(
AsyncTask
.
THREAD_POOL_EXECUTOR
)
.
setDownloadProgressListener
(
progress
)
.
setDownloadProgressListener
(
progress
)
.
setErrorHandler
((
conn
,
e
)
->
progress
.
dlFail
())
.
setErrorHandler
((
conn
,
e
)
->
progress
.
dlFail
())
...
@@ -85,7 +85,7 @@ public class DownloadApp {
...
@@ -85,7 +85,7 @@ public class DownloadApp {
.
setContentTitle
(
app
.
getString
(
R
.
string
.
restore_img_msg
))
.
setContentTitle
(
app
.
getString
(
R
.
string
.
restore_img_msg
))
.
setContentText
(
""
);
.
setContentText
(
""
);
progress
.
update
();
progress
.
update
();
Data
.
exportPrefs
();
Config
.
export
();
// Make it world readable
// Make it world readable
apk
.
setReadable
(
true
,
false
);
apk
.
setReadable
(
true
,
false
);
if
(
ShellUtils
.
fastCmdResult
(
"pm install "
+
apk
))
if
(
ShellUtils
.
fastCmdResult
(
"pm install "
+
apk
))
...
...
app/src/full/java/com/topjohnwu/magisk/utils/FingerprintHelper.java
View file @
a189dec1
...
@@ -17,6 +17,7 @@ import android.view.Gravity;
...
@@ -17,6 +17,7 @@ import android.view.Gravity;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.Config
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.utils.Utils
;
import
com.topjohnwu.core.utils.Utils
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
...
@@ -36,9 +37,9 @@ public abstract class FingerprintHelper {
...
@@ -36,9 +37,9 @@ public abstract class FingerprintHelper {
private
CancellationSignal
cancel
;
private
CancellationSignal
cancel
;
public
static
boolean
useFingerPrint
()
{
public
static
boolean
useFingerPrint
()
{
boolean
fp
=
App
.
self
.
mDB
.
getSettings
(
Const
.
Key
.
SU_FINGERPRINT
,
0
)
!=
0
;
boolean
fp
=
Config
.
get
(
Config
.
Key
.
SU_FINGERPRINT
)
;
if
(
fp
&&
!
canUseFingerprint
())
{
if
(
fp
&&
!
canUseFingerprint
())
{
App
.
self
.
mDB
.
setSettings
(
Const
.
Key
.
SU_FINGERPRINT
,
0
);
Config
.
set
(
Config
.
Key
.
SU_FINGERPRINT
,
false
);
fp
=
false
;
fp
=
false
;
}
}
return
fp
;
return
fp
;
...
...
app/src/full/java/com/topjohnwu/magisk/utils/PatchAPK.java
View file @
a189dec1
...
@@ -4,8 +4,8 @@ import android.os.AsyncTask;
...
@@ -4,8 +4,8 @@ import android.os.AsyncTask;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.Config
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Data
;
import
com.topjohnwu.core.utils.RootUtils
;
import
com.topjohnwu.core.utils.RootUtils
;
import
com.topjohnwu.core.utils.Utils
;
import
com.topjohnwu.core.utils.Utils
;
import
com.topjohnwu.magisk.BuildConfig
;
import
com.topjohnwu.magisk.BuildConfig
;
...
@@ -110,8 +110,8 @@ public class PatchAPK {
...
@@ -110,8 +110,8 @@ public class PatchAPK {
if
(!
ShellUtils
.
fastCmdResult
(
"pm install "
+
repack
))
if
(!
ShellUtils
.
fastCmdResult
(
"pm install "
+
repack
))
return
false
;
return
false
;
app
.
mDB
.
setStrings
(
Const
.
Key
.
SU_MANAGER
,
pkg
);
Config
.
set
(
Config
.
Key
.
SU_MANAGER
,
pkg
);
Data
.
exportPrefs
();
Config
.
export
();
RootUtils
.
rmAndLaunch
(
BuildConfig
.
APPLICATION_ID
,
pkg
);
RootUtils
.
rmAndLaunch
(
BuildConfig
.
APPLICATION_ID
,
pkg
);
return
true
;
return
true
;
...
...
app/src/full/java/com/topjohnwu/magisk/utils/SuConnector.java
View file @
a189dec1
...
@@ -10,8 +10,7 @@ import android.text.TextUtils;
...
@@ -10,8 +10,7 @@ import android.text.TextUtils;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Config
;
import
com.topjohnwu.core.Data
;
import
com.topjohnwu.core.container.Policy
;
import
com.topjohnwu.core.container.Policy
;
import
com.topjohnwu.core.container.SuLogEntry
;
import
com.topjohnwu.core.container.SuLogEntry
;
import
com.topjohnwu.core.utils.Utils
;
import
com.topjohnwu.core.utils.Utils
;
...
@@ -123,7 +122,8 @@ public abstract class SuConnector {
...
@@ -123,7 +122,8 @@ public abstract class SuConnector {
private
static
void
handleNotify
(
Policy
policy
)
{
private
static
void
handleNotify
(
Policy
policy
)
{
String
message
=
App
.
self
.
getString
(
policy
.
policy
==
Policy
.
ALLOW
?
String
message
=
App
.
self
.
getString
(
policy
.
policy
==
Policy
.
ALLOW
?
R
.
string
.
su_allow_toast
:
R
.
string
.
su_deny_toast
,
policy
.
appName
);
R
.
string
.
su_allow_toast
:
R
.
string
.
su_deny_toast
,
policy
.
appName
);
if
(
policy
.
notification
&&
Data
.
suNotificationType
==
Const
.
Value
.
NOTIFICATION_TOAST
)
if
(
policy
.
notification
&&
(
int
)
Config
.
get
(
Config
.
Key
.
SU_NOTIFICATION
)
==
Config
.
Value
.
NOTIFICATION_TOAST
)
Utils
.
toast
(
message
,
Toast
.
LENGTH_SHORT
);
Utils
.
toast
(
message
,
Toast
.
LENGTH_SHORT
);
}
}
...
...
core/src/main/java/com/topjohnwu/core/App.java
View file @
a189dec1
...
@@ -48,7 +48,6 @@ public class App extends ContainerApp {
...
@@ -48,7 +48,6 @@ public class App extends ContainerApp {
Networking
.
init
(
this
);
Networking
.
init
(
this
);
LocaleManager
.
setLocale
(
this
);
LocaleManager
.
setLocale
(
this
);
Data
.
loadConfig
();
}
}
@Override
@Override
...
...
core/src/main/java/com/topjohnwu/core/
Data
.java
→
core/src/main/java/com/topjohnwu/core/
Config
.java
View file @
a189dec1
This diff is collapsed.
Click to expand it.
core/src/main/java/com/topjohnwu/core/Const.java
View file @
a189dec1
...
@@ -79,19 +79,10 @@ public class Const {
...
@@ -79,19 +79,10 @@ public class Const {
public
static
final
String
SNET_URL
=
"https://raw.githubusercontent.com/topjohnwu/magisk_files/b66b1a914978e5f4c4bbfd74a59f4ad371bac107/snet.apk"
;
public
static
final
String
SNET_URL
=
"https://raw.githubusercontent.com/topjohnwu/magisk_files/b66b1a914978e5f4c4bbfd74a59f4ad371bac107/snet.apk"
;
}
}
public
static
class
Key
{
public
static
class
Key
{
// su
// others
public
static
final
String
ROOT_ACCESS
=
"root_access"
;
public
static
final
String
LINK_KEY
=
"Link"
;
public
static
final
String
SU_MULTIUSER_MODE
=
"multiuser_mode"
;
public
static
final
String
IF_NONE_MATCH
=
"If-None-Match"
;
public
static
final
String
SU_MNT_NS
=
"mnt_ns"
;
public
static
final
String
SU_MANAGER
=
"requester"
;
public
static
final
String
SU_REQUEST_TIMEOUT
=
"su_request_timeout"
;
public
static
final
String
SU_AUTO_RESPONSE
=
"su_auto_response"
;
public
static
final
String
SU_NOTIFICATION
=
"su_notification"
;
public
static
final
String
SU_REAUTH
=
"su_reauth"
;
public
static
final
String
SU_FINGERPRINT
=
"su_fingerprint"
;
// intents
// intents
public
static
final
String
OPEN_SECTION
=
"section"
;
public
static
final
String
OPEN_SECTION
=
"section"
;
public
static
final
String
INTENT_SET_NAME
=
"filename"
;
public
static
final
String
INTENT_SET_NAME
=
"filename"
;
...
@@ -100,52 +91,15 @@ public class Const {
...
@@ -100,52 +91,15 @@ public class Const {
public
static
final
String
FLASH_SET_BOOT
=
"boot"
;
public
static
final
String
FLASH_SET_BOOT
=
"boot"
;
public
static
final
String
BROADCAST_MANAGER_UPDATE
=
"manager_update"
;
public
static
final
String
BROADCAST_MANAGER_UPDATE
=
"manager_update"
;
public
static
final
String
BROADCAST_REBOOT
=
"reboot"
;
public
static
final
String
BROADCAST_REBOOT
=
"reboot"
;
// others
public
static
final
String
CHECK_UPDATES
=
"check_update"
;
public
static
final
String
UPDATE_CHANNEL
=
"update_channel"
;
public
static
final
String
CUSTOM_CHANNEL
=
"custom_channel"
;
public
static
final
String
BOOT_FORMAT
=
"boot_format"
;
public
static
final
String
UPDATE_SERVICE_VER
=
"update_service_version"
;
public
static
final
String
APP_VER
=
"app_version"
;
public
static
final
String
MAGISKHIDE
=
"magiskhide"
;
public
static
final
String
HOSTS
=
"hosts"
;
public
static
final
String
COREONLY
=
"disable"
;
public
static
final
String
LOCALE
=
"locale"
;
public
static
final
String
DARK_THEME
=
"dark_theme"
;
public
static
final
String
ETAG_KEY
=
"ETag"
;
public
static
final
String
LINK_KEY
=
"Link"
;
public
static
final
String
IF_NONE_MATCH
=
"If-None-Match"
;
public
static
final
String
REPO_ORDER
=
"repo_order"
;
}
}
public
static
class
Value
{
public
static
class
Value
{
public
static
final
int
STABLE_CHANNEL
=
0
;
public
static
final
int
BETA_CHANNEL
=
1
;
public
static
final
int
CUSTOM_CHANNEL
=
2
;
public
static
final
int
ROOT_ACCESS_DISABLED
=
0
;
public
static
final
int
ROOT_ACCESS_APPS_ONLY
=
1
;
public
static
final
int
ROOT_ACCESS_ADB_ONLY
=
2
;
public
static
final
int
ROOT_ACCESS_APPS_AND_ADB
=
3
;
public
static
final
int
MULTIUSER_MODE_OWNER_ONLY
=
0
;
public
static
final
int
MULTIUSER_MODE_OWNER_MANAGED
=
1
;
public
static
final
int
MULTIUSER_MODE_USER
=
2
;
public
static
final
int
NAMESPACE_MODE_GLOBAL
=
0
;
public
static
final
int
NAMESPACE_MODE_REQUESTER
=
1
;
public
static
final
int
NAMESPACE_MODE_ISOLATE
=
2
;
public
static
final
int
NO_NOTIFICATION
=
0
;
public
static
final
int
NOTIFICATION_TOAST
=
1
;
public
static
final
int
SU_PROMPT
=
0
;
public
static
final
int
SU_AUTO_DENY
=
1
;
public
static
final
int
SU_AUTO_ALLOW
=
2
;
public
static
final
String
FLASH_ZIP
=
"flash"
;
public
static
final
String
FLASH_ZIP
=
"flash"
;
public
static
final
String
PATCH_BOOT
=
"patch"
;
public
static
final
String
PATCH_BOOT
=
"patch"
;
public
static
final
String
FLASH_MAGISK
=
"magisk"
;
public
static
final
String
FLASH_MAGISK
=
"magisk"
;
public
static
final
String
FLASH_INACTIVE_SLOT
=
"slot"
;
public
static
final
String
FLASH_INACTIVE_SLOT
=
"slot"
;
public
static
final
String
UNINSTALL
=
"uninstall"
;
public
static
final
String
UNINSTALL
=
"uninstall"
;
public
static
final
int
[]
timeoutList
=
{
0
,
-
1
,
10
,
20
,
30
,
60
};
public
static
final
int
ORDER_NAME
=
0
;
public
static
final
int
ORDER_DATE
=
1
;
}
}
}
}
core/src/main/java/com/topjohnwu/core/database/MagiskDB.java
View file @
a189dec1
...
@@ -6,7 +6,7 @@ import android.content.pm.PackageManager;
...
@@ -6,7 +6,7 @@ import android.content.pm.PackageManager;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.
Data
;
import
com.topjohnwu.core.
Config
;
import
com.topjohnwu.core.container.Policy
;
import
com.topjohnwu.core.container.Policy
;
import
com.topjohnwu.core.container.SuLogEntry
;
import
com.topjohnwu.core.container.SuLogEntry
;
import
com.topjohnwu.core.utils.LocaleManager
;
import
com.topjohnwu.core.utils.LocaleManager
;
...
@@ -85,7 +85,7 @@ public class MagiskDB {
...
@@ -85,7 +85,7 @@ public class MagiskDB {
"DELETE FROM %s WHERE until > 0 AND until < %d;"
+
"DELETE FROM %s WHERE until > 0 AND until < %d;"
+
"DELETE FROM %s WHERE time < %d"
,
"DELETE FROM %s WHERE time < %d"
,
POLICY_TABLE
,
System
.
currentTimeMillis
()
/
1000
,
POLICY_TABLE
,
System
.
currentTimeMillis
()
/
1000
,
LOG_TABLE
,
System
.
currentTimeMillis
()
-
Data
.
suLogTimeout
*
86400000
LOG_TABLE
,
System
.
currentTimeMillis
()
-
Config
.
suLogTimeout
*
86400000
);
);
}
}
...
...
core/src/main/java/com/topjohnwu/core/database/RepoDatabaseHelper.java
View file @
a189dec1
...
@@ -7,7 +7,7 @@ import android.database.sqlite.SQLiteOpenHelper;
...
@@ -7,7 +7,7 @@ import android.database.sqlite.SQLiteOpenHelper;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.
Data
;
import
com.topjohnwu.core.
Config
;
import
com.topjohnwu.core.container.Repo
;
import
com.topjohnwu.core.container.Repo
;
import
java.util.HashSet
;
import
java.util.HashSet
;
...
@@ -43,7 +43,7 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
...
@@ -43,7 +43,7 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
"CREATE TABLE IF NOT EXISTS "
+
TABLE_NAME
+
" "
+
"CREATE TABLE IF NOT EXISTS "
+
TABLE_NAME
+
" "
+
"(id TEXT, name TEXT, version TEXT, versionCode INT, minMagisk INT, "
+
"(id TEXT, name TEXT, version TEXT, versionCode INT, minMagisk INT, "
+
"author TEXT, description TEXT, last_update INT, PRIMARY KEY(id))"
);
"author TEXT, description TEXT, last_update INT, PRIMARY KEY(id))"
);
App
.
self
.
prefs
.
edit
().
remove
(
Const
.
Key
.
ETAG_KEY
).
apply
(
);
Config
.
remove
(
Config
.
Key
.
ETAG_KEY
);
}
}
}
}
...
@@ -95,15 +95,15 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
...
@@ -95,15 +95,15 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
public
Cursor
getRepoCursor
()
{
public
Cursor
getRepoCursor
()
{
String
orderBy
=
null
;
String
orderBy
=
null
;
switch
(
Data
.
repoOrder
)
{
switch
(
(
int
)
Config
.
get
(
Config
.
Key
.
REPO_ORDER
)
)
{
case
Con
st
.
Value
.
ORDER_NAME
:
case
Con
fig
.
Value
.
ORDER_NAME
:
orderBy
=
"name COLLATE NOCASE"
;
orderBy
=
"name COLLATE NOCASE"
;
break
;
break
;
case
Con
st
.
Value
.
ORDER_DATE
:
case
Con
fig
.
Value
.
ORDER_DATE
:
orderBy
=
"last_update DESC"
;
orderBy
=
"last_update DESC"
;
}
}
return
mDb
.
query
(
TABLE_NAME
,
null
,
"minMagisk<=? AND minMagisk>=?"
,
return
mDb
.
query
(
TABLE_NAME
,
null
,
"minMagisk<=? AND minMagisk>=?"
,
new
String
[]
{
String
.
valueOf
(
Data
.
magiskVersionCode
),
String
.
valueOf
(
Const
.
MIN_MODULE_VER
)
},
new
String
[]
{
String
.
valueOf
(
Config
.
magiskVersionCode
),
String
.
valueOf
(
Const
.
MIN_MODULE_VER
)
},
null
,
null
,
orderBy
);
null
,
null
,
orderBy
);
}
}
...
...
core/src/main/java/com/topjohnwu/core/tasks/CheckUpdates.java
View file @
a189dec1
package
com
.
topjohnwu
.
core
.
tasks
;
package
com
.
topjohnwu
.
core
.
tasks
;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.
Data
;
import
com.topjohnwu.core.
Config
;
import
com.topjohnwu.core.utils.Topic
;
import
com.topjohnwu.core.utils.Topic
;
import
com.topjohnwu.net.Networking
;
import
com.topjohnwu.net.Networking
;
import
com.topjohnwu.net.Request
;
import
com.topjohnwu.net.Request
;
...
@@ -43,14 +42,14 @@ public class CheckUpdates {
...
@@ -43,14 +42,14 @@ public class CheckUpdates {
private
static
Request
getRequest
()
{
private
static
Request
getRequest
()
{
String
url
;
String
url
;
switch
(
Data
.
updateChannel
)
{
switch
(
(
int
)
Config
.
get
(
Config
.
Key
.
UPDATE_CHANNEL
)
)
{
case
Con
st
.
Value
.
BETA_CHANNEL
:
case
Con
fig
.
Value
.
BETA_CHANNEL
:
url
=
Const
.
Url
.
BETA_URL
;
url
=
Const
.
Url
.
BETA_URL
;
break
;
break
;
case
Con
st
.
Value
.
CUSTOM_CHANNEL
:
case
Con
fig
.
Value
.
CUSTOM_CHANNEL
:
url
=
App
.
self
.
prefs
.
getString
(
Const
.
Key
.
CUSTOM_CHANNEL
,
""
);
url
=
Config
.
get
(
Config
.
Key
.
CUSTOM_CHANNEL
);
break
;
break
;
case
Con
st
.
Value
.
STABLE_CHANNEL
:
case
Con
fig
.
Value
.
STABLE_CHANNEL
:
default
:
default
:
url
=
Const
.
Url
.
STABLE_URL
;
url
=
Const
.
Url
.
STABLE_URL
;
break
;
break
;
...
@@ -79,20 +78,20 @@ public class CheckUpdates {
...
@@ -79,20 +78,20 @@ public class CheckUpdates {
@Override
@Override
public
void
onResponse
(
JSONObject
json
)
{
public
void
onResponse
(
JSONObject
json
)
{
JSONObject
magisk
=
getJson
(
json
,
"magisk"
);
JSONObject
magisk
=
getJson
(
json
,
"magisk"
);
Data
.
remoteMagiskVersionString
=
getString
(
magisk
,
"version"
,
null
);
Config
.
remoteMagiskVersionString
=
getString
(
magisk
,
"version"
,
null
);
Data
.
remoteMagiskVersionCode
=
getInt
(
magisk
,
"versionCode"
,
-
1
);
Config
.
remoteMagiskVersionCode
=
getInt
(
magisk
,
"versionCode"
,
-
1
);
Data
.
magiskLink
=
getString
(
magisk
,
"link"
,
null
);
Config
.
magiskLink
=
getString
(
magisk
,
"link"
,
null
);
Data
.
magiskNoteLink
=
getString
(
magisk
,
"note"
,
null
);
Config
.
magiskNoteLink
=
getString
(
magisk
,
"note"
,
null
);
Data
.
magiskMD5
=
getString
(
magisk
,
"md5"
,
null
);
Config
.
magiskMD5
=
getString
(
magisk
,
"md5"
,
null
);
JSONObject
manager
=
getJson
(
json
,
"app"
);
JSONObject
manager
=
getJson
(
json
,
"app"
);
Data
.
remoteManagerVersionString
=
getString
(
manager
,
"version"
,
null
);
Config
.
remoteManagerVersionString
=
getString
(
manager
,
"version"
,
null
);
Data
.
remoteManagerVersionCode
=
getInt
(
manager
,
"versionCode"
,
-
1
);
Config
.
remoteManagerVersionCode
=
getInt
(
manager
,
"versionCode"
,
-
1
);
Data
.
managerLink
=
getString
(
manager
,
"link"
,
null
);
Config
.
managerLink
=
getString
(
manager
,
"link"
,
null
);
Data
.
managerNoteLink
=
getString
(
manager
,
"note"
,
null
);
Config
.
managerNoteLink
=
getString
(
manager
,
"note"
,
null
);
JSONObject
uninstaller
=
getJson
(
json
,
"uninstaller"
);
JSONObject
uninstaller
=
getJson
(
json
,
"uninstaller"
);
Data
.
uninstallerLink
=
getString
(
uninstaller
,
"link"
,
null
);
Config
.
uninstallerLink
=
getString
(
uninstaller
,
"link"
,
null
);
Topic
.
publish
(
Topic
.
UPDATE_CHECK_DONE
);
Topic
.
publish
(
Topic
.
UPDATE_CHECK_DONE
);
...
...
core/src/main/java/com/topjohnwu/core/tasks/MagiskInstaller.java
View file @
a189dec1
...
@@ -7,7 +7,7 @@ import android.text.TextUtils;
...
@@ -7,7 +7,7 @@ import android.text.TextUtils;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.
Data
;
import
com.topjohnwu.core.
Config
;
import
com.topjohnwu.core.R
;
import
com.topjohnwu.core.R
;
import
com.topjohnwu.core.container.TarEntry
;
import
com.topjohnwu.core.container.TarEntry
;
import
com.topjohnwu.core.utils.Utils
;
import
com.topjohnwu.core.utils.Utils
;
...
@@ -120,9 +120,9 @@ public abstract class MagiskInstaller {
...
@@ -120,9 +120,9 @@ public abstract class MagiskInstaller {
File
zip
=
new
File
(
App
.
self
.
getCacheDir
(),
"magisk.zip"
);
File
zip
=
new
File
(
App
.
self
.
getCacheDir
(),
"magisk.zip"
);
if
(!
ShellUtils
.
checkSum
(
"MD5"
,
zip
,
Data
.
magiskMD5
))
{
if
(!
ShellUtils
.
checkSum
(
"MD5"
,
zip
,
Config
.
magiskMD5
))
{
console
.
add
(
"- Downloading zip"
);
console
.
add
(
"- Downloading zip"
);
Networking
.
get
(
Data
.
magiskLink
)
Networking
.
get
(
Config
.
magiskLink
)
.
setDownloadProgressListener
(
new
ProgressLog
())
.
setDownloadProgressListener
(
new
ProgressLog
())
.
execForFile
(
zip
);
.
execForFile
(
zip
);
}
else
{
}
else
{
...
@@ -217,7 +217,7 @@ public abstract class MagiskInstaller {
...
@@ -217,7 +217,7 @@ public abstract class MagiskInstaller {
// Patch boot image
// Patch boot image
if
(!
Shell
.
sh
(
Utils
.
fmt
(
"cd %s; KEEPFORCEENCRYPT=%b KEEPVERITY=%b "
+
if
(!
Shell
.
sh
(
Utils
.
fmt
(
"cd %s; KEEPFORCEENCRYPT=%b KEEPVERITY=%b "
+
"sh update-binary indep boot_patch.sh %s"
,
"sh update-binary indep boot_patch.sh %s"
,
installDir
,
Data
.
keepEnc
,
Data
.
keepVerity
,
srcBoot
))
installDir
,
Config
.
keepEnc
,
Config
.
keepVerity
,
srcBoot
))
.
to
(
console
,
logs
).
exec
().
isSuccess
())
.
to
(
console
,
logs
).
exec
().
isSuccess
())
return
false
;
return
false
;
...
@@ -245,14 +245,14 @@ public abstract class MagiskInstaller {
...
@@ -245,14 +245,14 @@ public abstract class MagiskInstaller {
if
(!
Shell
.
su
(
Utils
.
fmt
(
"direct_install %s %s"
,
installDir
,
srcBoot
))
if
(!
Shell
.
su
(
Utils
.
fmt
(
"direct_install %s %s"
,
installDir
,
srcBoot
))
.
to
(
console
,
logs
).
exec
().
isSuccess
())
.
to
(
console
,
logs
).
exec
().
isSuccess
())
return
false
;
return
false
;
if
(!
Data
.
keepVerity
)
if
(!
Config
.
keepVerity
)
Shell
.
su
(
"find_dtbo_image"
,
"patch_dtbo_image"
).
to
(
console
,
logs
).
exec
();
Shell
.
su
(
"find_dtbo_image"
,
"patch_dtbo_image"
).
to
(
console
,
logs
).
exec
();
return
true
;
return
true
;
}
}
protected
boolean
storeBoot
()
{
protected
boolean
storeBoot
()
{
File
patched
=
new
File
(
installDir
,
"new-boot.img"
);
File
patched
=
new
File
(
installDir
,
"new-boot.img"
);
String
fmt
=
App
.
self
.
prefs
.
getString
(
Const
.
Key
.
BOOT_FORMAT
,
".img"
);
String
fmt
=
Config
.
get
(
Config
.
Key
.
BOOT_FORMAT
);
File
dest
=
new
File
(
Const
.
EXTERNAL_PATH
,
"patched_boot"
+
fmt
);
File
dest
=
new
File
(
Const
.
EXTERNAL_PATH
,
"patched_boot"
+
fmt
);
dest
.
getParentFile
().
mkdirs
();
dest
.
getParentFile
().
mkdirs
();
OutputStream
os
;
OutputStream
os
;
...
...
core/src/main/java/com/topjohnwu/core/tasks/UpdateRepos.java
View file @
a189dec1
...
@@ -5,6 +5,7 @@ import android.os.AsyncTask;
...
@@ -5,6 +5,7 @@ import android.os.AsyncTask;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Config
;
import
com.topjohnwu.core.container.Repo
;
import
com.topjohnwu.core.container.Repo
;
import
com.topjohnwu.core.utils.Logger
;
import
com.topjohnwu.core.utils.Logger
;
import
com.topjohnwu.core.utils.Topic
;
import
com.topjohnwu.core.utils.Topic
;
...
@@ -81,7 +82,7 @@ public class UpdateRepos {
...
@@ -81,7 +82,7 @@ public class UpdateRepos {
private
boolean
loadPage
(
int
page
)
{
private
boolean
loadPage
(
int
page
)
{
Request
req
=
Networking
.
get
(
Utils
.
fmt
(
Const
.
Url
.
REPO_URL
,
page
+
1
));
Request
req
=
Networking
.
get
(
Utils
.
fmt
(
Const
.
Url
.
REPO_URL
,
page
+
1
));
if
(
page
==
0
)
{
if
(
page
==
0
)
{
String
etag
=
app
.
prefs
.
getString
(
Const
.
Key
.
ETAG_KEY
,
null
);
String
etag
=
Config
.
get
(
Config
.
Key
.
ETAG_KEY
);
if
(
etag
!=
null
)
if
(
etag
!=
null
)
req
.
addHeaders
(
Const
.
Key
.
IF_NONE_MATCH
,
etag
);
req
.
addHeaders
(
Const
.
Key
.
IF_NONE_MATCH
,
etag
);
}
}
...
@@ -107,10 +108,10 @@ public class UpdateRepos {
...
@@ -107,10 +108,10 @@ public class UpdateRepos {
// Update ETAG
// Update ETAG
if
(
page
==
0
)
{
if
(
page
==
0
)
{
String
etag
=
res
.
getConnection
().
getHeaderField
(
Con
st
.
Key
.
ETAG_KEY
);
String
etag
=
res
.
getConnection
().
getHeaderField
(
Con
fig
.
Key
.
ETAG_KEY
);
if
(
etag
!=
null
)
{
if
(
etag
!=
null
)
{
etag
=
etag
.
substring
(
etag
.
indexOf
(
'\"'
),
etag
.
lastIndexOf
(
'\"'
)
+
1
);
etag
=
etag
.
substring
(
etag
.
indexOf
(
'\"'
),
etag
.
lastIndexOf
(
'\"'
)
+
1
);
app
.
prefs
.
edit
().
putString
(
Const
.
Key
.
ETAG_KEY
,
etag
).
apply
(
);
Config
.
set
(
Config
.
Key
.
ETAG_KEY
,
etag
);
}
}
}
}
...
...
core/src/main/java/com/topjohnwu/core/utils/LocaleManager.java
View file @
a189dec1
...
@@ -6,7 +6,7 @@ import android.content.res.Resources;
...
@@ -6,7 +6,7 @@ import android.content.res.Resources;
import
android.os.Build
;
import
android.os.Build
;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.Con
st
;
import
com.topjohnwu.core.Con
fig
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.Shell
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -87,7 +87,7 @@ public class LocaleManager {
...
@@ -87,7 +87,7 @@ public class LocaleManager {
}
}
public
static
void
setLocale
(
App
app
)
{
public
static
void
setLocale
(
App
app
)
{
String
localeConfig
=
app
.
prefs
.
getString
(
Const
.
Key
.
LOCALE
,
""
);
String
localeConfig
=
Config
.
get
(
Config
.
Key
.
LOCALE
);
if
(
localeConfig
.
isEmpty
())
{
if
(
localeConfig
.
isEmpty
())
{
locale
=
defaultLocale
;
locale
=
defaultLocale
;
}
else
{
}
else
{
...
...
core/src/main/java/com/topjohnwu/core/utils/RootUtils.java
View file @
a189dec1
...
@@ -3,13 +3,12 @@ package com.topjohnwu.core.utils;
...
@@ -3,13 +3,12 @@ package com.topjohnwu.core.utils;
import
android.content.Context
;
import
android.content.Context
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.
Data
;
import
com.topjohnwu.core.
Config
;
import
com.topjohnwu.core.R
;
import
com.topjohnwu.core.R
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.ShellUtils
;
import
com.topjohnwu.superuser.ShellUtils
;
import
com.topjohnwu.superuser.io.SuFile
;
import
com.topjohnwu.superuser.io.SuFile
;
import
java.io.File
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.NonNull
;
...
@@ -27,7 +26,7 @@ public class RootUtils extends Shell.Initializer {
...
@@ -27,7 +26,7 @@ public class RootUtils extends Shell.Initializer {
job
.
add
(
context
.
getResources
().
openRawResource
(
R
.
raw
.
util_functions
))
job
.
add
(
context
.
getResources
().
openRawResource
(
R
.
raw
.
util_functions
))
.
add
(
context
.
getResources
().
openRawResource
(
R
.
raw
.
utils
));
.
add
(
context
.
getResources
().
openRawResource
(
R
.
raw
.
utils
));
Const
.
MAGISK_DISABLE_FILE
=
new
SuFile
(
"/cache/.disable_magisk"
);
Const
.
MAGISK_DISABLE_FILE
=
new
SuFile
(
"/cache/.disable_magisk"
);
Data
.
loadMagiskInfo
();
Config
.
loadMagiskInfo
();
}
else
{
}
else
{
InputStream
nonroot
=
context
.
getResources
().
openRawResource
(
R
.
raw
.
nonroot_utils
);
InputStream
nonroot
=
context
.
getResources
().
openRawResource
(
R
.
raw
.
nonroot_utils
);
job
.
add
(
nonroot
);
job
.
add
(
nonroot
);
...
@@ -35,9 +34,9 @@ public class RootUtils extends Shell.Initializer {
...
@@ -35,9 +34,9 @@ public class RootUtils extends Shell.Initializer {
job
.
add
(
"mount_partitions"
,
"get_flags"
,
"run_migrations"
,
"export BOOTMODE=true"
).
exec
();
job
.
add
(
"mount_partitions"
,
"get_flags"
,
"run_migrations"
,
"export BOOTMODE=true"
).
exec
();
Data
.
keepVerity
=
Boolean
.
parseBoolean
(
ShellUtils
.
fastCmd
(
"echo $KEEPVERITY"
));
Config
.
keepVerity
=
Boolean
.
parseBoolean
(
ShellUtils
.
fastCmd
(
"echo $KEEPVERITY"
));
Data
.
keepEnc
=
Boolean
.
parseBoolean
(
ShellUtils
.
fastCmd
(
"echo $KEEPFORCEENCRYPT"
));
Config
.
keepEnc
=
Boolean
.
parseBoolean
(
ShellUtils
.
fastCmd
(
"echo $KEEPFORCEENCRYPT"
));
Data
.
recovery
=
Boolean
.
parseBoolean
(
ShellUtils
.
fastCmd
(
"echo $RECOVERYMODE"
));
Config
.
recovery
=
Boolean
.
parseBoolean
(
ShellUtils
.
fastCmd
(
"echo $RECOVERYMODE"
));
return
true
;
return
true
;
}
}
}
}
core/src/main/java/com/topjohnwu/core/utils/Utils.java
View file @
a189dec1
...
@@ -15,7 +15,7 @@ import android.widget.Toast;
...
@@ -15,7 +15,7 @@ import android.widget.Toast;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.App
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.Const
;
import
com.topjohnwu.core.
Data
;
import
com.topjohnwu.core.
Config
;
import
com.topjohnwu.core.container.Module
;
import
com.topjohnwu.core.container.Module
;
import
com.topjohnwu.core.container.ValueSortedMap
;
import
com.topjohnwu.core.container.ValueSortedMap
;
import
com.topjohnwu.net.Networking
;
import
com.topjohnwu.net.Networking
;
...
@@ -111,11 +111,9 @@ public class Utils {
...
@@ -111,11 +111,9 @@ public class Utils {
}
}
public
static
boolean
showSuperUser
()
{
public
static
boolean
showSuperUser
()
{
if
(
Data
.
multiuserState
<
0
)
Data
.
multiuserState
=
App
.
self
.
mDB
.
getSettings
(
Const
.
Key
.
SU_MULTIUSER_MODE
,
Const
.
Value
.
MULTIUSER_MODE_OWNER_ONLY
);
return
Shell
.
rootAccess
()
&&
(
Const
.
USER_ID
==
0
||
return
Shell
.
rootAccess
()
&&
(
Const
.
USER_ID
==
0
||
Data
.
multiuserState
!=
Const
.
Value
.
MULTIUSER_MODE_OWNER_MANAGED
);
(
int
)
Config
.
get
(
Config
.
Key
.
SU_MULTIUSER_MODE
)
!=
Config
.
Value
.
MULTIUSER_MODE_OWNER_MANAGED
);
}
}
public
static
Context
getDEContext
()
{
public
static
Context
getDEContext
()
{
...
@@ -124,6 +122,6 @@ public class Utils {
...
@@ -124,6 +122,6 @@ public class Utils {
}
}
public
static
void
reboot
()
{
public
static
void
reboot
()
{
Shell
.
su
(
"/system/bin/reboot"
+
(
Data
.
recovery
?
" recovery"
:
""
)).
submit
();
Shell
.
su
(
"/system/bin/reboot"
+
(
Config
.
recovery
?
" recovery"
:
""
)).
submit
();
}
}
}
}
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