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
c39170c4
Commit
c39170c4
authored
Nov 05, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Organize constants
parent
fd19fbf3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
381 additions
and
340 deletions
+381
-340
AboutActivity.java
app/src/main/java/com/topjohnwu/magisk/AboutActivity.java
+4
-7
FlashActivity.java
app/src/main/java/com/topjohnwu/magisk/FlashActivity.java
+9
-17
MagiskFragment.java
app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java
+6
-6
MagiskLogFragment.java
...src/main/java/com/topjohnwu/magisk/MagiskLogFragment.java
+9
-11
MagiskManager.java
app/src/main/java/com/topjohnwu/magisk/MagiskManager.java
+47
-63
MainActivity.java
app/src/main/java/com/topjohnwu/magisk/MainActivity.java
+5
-4
ModulesFragment.java
app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java
+4
-5
SettingsActivity.java
app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java
+43
-44
SplashActivity.java
app/src/main/java/com/topjohnwu/magisk/SplashActivity.java
+3
-2
ApplicationAdapter.java
...ava/com/topjohnwu/magisk/adapters/ApplicationAdapter.java
+3
-14
CheckSafetyNet.java
...main/java/com/topjohnwu/magisk/asyncs/CheckSafetyNet.java
+7
-11
CheckUpdates.java
...c/main/java/com/topjohnwu/magisk/asyncs/CheckUpdates.java
+5
-10
DownloadBusybox.java
...ain/java/com/topjohnwu/magisk/asyncs/DownloadBusybox.java
+8
-10
FlashZip.java
app/src/main/java/com/topjohnwu/magisk/asyncs/FlashZip.java
+2
-1
HideManager.java
...rc/main/java/com/topjohnwu/magisk/asyncs/HideManager.java
+6
-8
InstallMagisk.java
.../main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java
+5
-4
LoadModules.java
...rc/main/java/com/topjohnwu/magisk/asyncs/LoadModules.java
+2
-1
ProcessRepoZip.java
...main/java/com/topjohnwu/magisk/asyncs/ProcessRepoZip.java
+3
-2
UpdateRepos.java
...rc/main/java/com/topjohnwu/magisk/asyncs/UpdateRepos.java
+8
-13
Repo.java
app/src/main/java/com/topjohnwu/magisk/container/Repo.java
+5
-9
RepoDatabaseHelper.java
...ava/com/topjohnwu/magisk/database/RepoDatabaseHelper.java
+2
-1
SuDatabaseHelper.java
.../java/com/topjohnwu/magisk/database/SuDatabaseHelper.java
+1
-18
ManagerUpdate.java
...in/java/com/topjohnwu/magisk/receivers/ManagerUpdate.java
+3
-3
OnBootIntentService.java
...va/com/topjohnwu/magisk/services/OnBootIntentService.java
+3
-5
SuReceiver.java
.../main/java/com/topjohnwu/magisk/superuser/SuReceiver.java
+9
-14
SuRequestActivity.java
...ava/com/topjohnwu/magisk/superuser/SuRequestActivity.java
+5
-10
BootSigner.java
app/src/main/java/com/topjohnwu/magisk/utils/BootSigner.java
+2
-2
Const.java
app/src/main/java/com/topjohnwu/magisk/utils/Const.java
+136
-0
Logger.java
app/src/main/java/com/topjohnwu/magisk/utils/Logger.java
+3
-4
ShowUI.java
app/src/main/java/com/topjohnwu/magisk/utils/ShowUI.java
+31
-35
Utils.java
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
+0
-1
ZipUtils.java
app/src/main/java/com/topjohnwu/magisk/utils/ZipUtils.java
+1
-4
app_settings.xml
app/src/main/res/xml/app_settings.xml
+1
-1
No files found.
app/src/main/java/com/topjohnwu/magisk/AboutActivity.java
View file @
c39170c4
...
@@ -17,6 +17,7 @@ import android.widget.TextView;
...
@@ -17,6 +17,7 @@ import android.widget.TextView;
import
com.topjohnwu.magisk.components.AboutCardRow
;
import
com.topjohnwu.magisk.components.AboutCardRow
;
import
com.topjohnwu.magisk.components.Activity
;
import
com.topjohnwu.magisk.components.Activity
;
import
com.topjohnwu.magisk.components.AlertDialogBuilder
;
import
com.topjohnwu.magisk.components.AlertDialogBuilder
;
import
com.topjohnwu.magisk.utils.Const
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
...
@@ -27,10 +28,6 @@ import butterknife.ButterKnife;
...
@@ -27,10 +28,6 @@ import butterknife.ButterKnife;
public
class
AboutActivity
extends
Activity
{
public
class
AboutActivity
extends
Activity
{
private
static
final
String
DONATION_URL
=
"https://www.paypal.me/topjohnwu"
;
private
static
final
String
XDA_THREAD
=
"http://forum.xda-developers.com/showthread.php?t=3432382"
;
private
static
final
String
SOURCE_CODE_URL
=
"https://github.com/topjohnwu/MagiskManager"
;
@BindView
(
R
.
id
.
toolbar
)
Toolbar
toolbar
;
@BindView
(
R
.
id
.
toolbar
)
Toolbar
toolbar
;
@BindView
(
R
.
id
.
app_version_info
)
AboutCardRow
appVersionInfo
;
@BindView
(
R
.
id
.
app_version_info
)
AboutCardRow
appVersionInfo
;
@BindView
(
R
.
id
.
app_changelog
)
AboutCardRow
appChangelog
;
@BindView
(
R
.
id
.
app_changelog
)
AboutCardRow
appChangelog
;
...
@@ -120,13 +117,13 @@ public class AboutActivity extends Activity {
...
@@ -120,13 +117,13 @@ public class AboutActivity extends Activity {
}
}
appSourceCode
.
removeSummary
();
appSourceCode
.
removeSummary
();
appSourceCode
.
setOnClickListener
(
view
->
startActivity
(
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
SOURCE_CODE_URL
))));
appSourceCode
.
setOnClickListener
(
view
->
startActivity
(
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
Const
.
Url
.
SOURCE_CODE_URL
))));
supportThread
.
removeSummary
();
supportThread
.
removeSummary
();
supportThread
.
setOnClickListener
(
view
->
startActivity
(
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
XDA_THREAD
))));
supportThread
.
setOnClickListener
(
view
->
startActivity
(
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
Const
.
Url
.
XDA_THREAD
))));
donation
.
removeSummary
();
donation
.
removeSummary
();
donation
.
setOnClickListener
(
view
->
startActivity
(
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
DONATION_URL
))));
donation
.
setOnClickListener
(
view
->
startActivity
(
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
Const
.
Url
.
DONATION_URL
))));
setFloating
();
setFloating
();
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/FlashActivity.java
View file @
c39170c4
...
@@ -16,6 +16,7 @@ import com.topjohnwu.magisk.asyncs.FlashZip;
...
@@ -16,6 +16,7 @@ import com.topjohnwu.magisk.asyncs.FlashZip;
import
com.topjohnwu.magisk.asyncs.InstallMagisk
;
import
com.topjohnwu.magisk.asyncs.InstallMagisk
;
import
com.topjohnwu.magisk.components.Activity
;
import
com.topjohnwu.magisk.components.Activity
;
import
com.topjohnwu.magisk.container.AdaptiveList
;
import
com.topjohnwu.magisk.container.AdaptiveList
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Shell
;
import
butterknife.BindView
;
import
butterknife.BindView
;
...
@@ -24,15 +25,6 @@ import butterknife.OnClick;
...
@@ -24,15 +25,6 @@ import butterknife.OnClick;
public
class
FlashActivity
extends
Activity
{
public
class
FlashActivity
extends
Activity
{
public
static
final
String
SET_ACTION
=
"action"
;
public
static
final
String
SET_BOOT
=
"boot"
;
public
static
final
String
SET_ENC
=
"enc"
;
public
static
final
String
SET_VERITY
=
"verity"
;
public
static
final
String
FLASH_ZIP
=
"flash"
;
public
static
final
String
PATCH_BOOT
=
"patch"
;
public
static
final
String
FLASH_MAGISK
=
"magisk"
;
@BindView
(
R
.
id
.
toolbar
)
Toolbar
toolbar
;
@BindView
(
R
.
id
.
toolbar
)
Toolbar
toolbar
;
@BindView
(
R
.
id
.
txtLog
)
TextView
flashLogs
;
@BindView
(
R
.
id
.
txtLog
)
TextView
flashLogs
;
@BindView
(
R
.
id
.
button_panel
)
LinearLayout
buttonPanel
;
@BindView
(
R
.
id
.
button_panel
)
LinearLayout
buttonPanel
;
...
@@ -75,22 +67,22 @@ public class FlashActivity extends Activity {
...
@@ -75,22 +67,22 @@ public class FlashActivity extends Activity {
Intent
intent
=
getIntent
();
Intent
intent
=
getIntent
();
Uri
uri
=
intent
.
getData
();
Uri
uri
=
intent
.
getData
();
boolean
keepEnc
=
intent
.
getBooleanExtra
(
SET_ENC
,
false
);
boolean
keepEnc
=
intent
.
getBooleanExtra
(
Const
.
Key
.
FLASH_
SET_ENC
,
false
);
boolean
keepVerity
=
intent
.
getBooleanExtra
(
SET_VERITY
,
false
);
boolean
keepVerity
=
intent
.
getBooleanExtra
(
Const
.
Key
.
FLASH_
SET_VERITY
,
false
);
switch
(
getIntent
().
getStringExtra
(
SET
_ACTION
))
{
switch
(
getIntent
().
getStringExtra
(
Const
.
Key
.
FLASH
_ACTION
))
{
case
FLASH_ZIP:
case
Const
.
Value
.
FLASH_ZIP
:
new
FlashZip
(
this
,
uri
,
rootShellOutput
)
new
FlashZip
(
this
,
uri
,
rootShellOutput
)
.
setCallBack
(()
->
buttonPanel
.
setVisibility
(
View
.
VISIBLE
))
.
setCallBack
(()
->
buttonPanel
.
setVisibility
(
View
.
VISIBLE
))
.
exec
();
.
exec
();
break
;
break
;
case
PATCH_BOOT:
case
Const
.
Value
.
PATCH_BOOT
:
new
InstallMagisk
(
this
,
rootShellOutput
,
uri
,
keepEnc
,
keepVerity
,
(
Uri
)
intent
.
getParcelableExtra
(
SET_BOOT
))
new
InstallMagisk
(
this
,
rootShellOutput
,
uri
,
keepEnc
,
keepVerity
,
(
Uri
)
intent
.
getParcelableExtra
(
Const
.
Key
.
FLASH_
SET_BOOT
))
.
setCallBack
(()
->
buttonPanel
.
setVisibility
(
View
.
VISIBLE
))
.
setCallBack
(()
->
buttonPanel
.
setVisibility
(
View
.
VISIBLE
))
.
exec
();
.
exec
();
break
;
break
;
case
FLASH_MAGISK:
case
Const
.
Value
.
FLASH_MAGISK
:
String
boot
=
intent
.
getStringExtra
(
SET_BOOT
);
String
boot
=
intent
.
getStringExtra
(
Const
.
Key
.
FLASH_
SET_BOOT
);
if
(
getMagiskManager
().
remoteMagiskVersionCode
<
1370
)
{
if
(
getMagiskManager
().
remoteMagiskVersionCode
<
1370
)
{
// Use legacy installation method
// Use legacy installation method
Shell
.
su_raw
(
Shell
.
su_raw
(
...
...
app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java
View file @
c39170c4
...
@@ -43,13 +43,13 @@ import butterknife.Unbinder;
...
@@ -43,13 +43,13 @@ import butterknife.Unbinder;
public
class
MagiskFragment
extends
Fragment
public
class
MagiskFragment
extends
Fragment
implements
Topic
.
Subscriber
,
SwipeRefreshLayout
.
OnRefreshListener
,
ExpandableView
{
implements
Topic
.
Subscriber
,
SwipeRefreshLayout
.
OnRefreshListener
,
ExpandableView
{
p
ublic
static
final
int
CAUSE_SERVICE_DISCONNECTED
=
0x01
;
p
rivate
static
final
int
CAUSE_SERVICE_DISCONNECTED
=
0x01
;
p
ublic
static
final
int
CAUSE_NETWORK_LOST
=
0x02
;
p
rivate
static
final
int
CAUSE_NETWORK_LOST
=
0x02
;
p
ublic
static
final
int
RESPONSE_ERR
=
0x04
;
p
rivate
static
final
int
RESPONSE_ERR
=
0x04
;
p
ublic
static
final
int
CONNECTION_FAIL
=
0x08
;
p
rivate
static
final
int
CONNECTION_FAIL
=
0x08
;
p
ublic
static
final
int
BASIC_PASS
=
0x10
;
p
rivate
static
final
int
BASIC_PASS
=
0x10
;
p
ublic
static
final
int
CTS_PASS
=
0x20
;
p
rivate
static
final
int
CTS_PASS
=
0x20
;
private
Container
expandableContainer
=
new
Container
();
private
Container
expandableContainer
=
new
Container
();
...
...
app/src/main/java/com/topjohnwu/magisk/MagiskLogFragment.java
View file @
c39170c4
...
@@ -22,6 +22,7 @@ import android.widget.Toast;
...
@@ -22,6 +22,7 @@ import android.widget.Toast;
import
com.topjohnwu.magisk.asyncs.ParallelTask
;
import
com.topjohnwu.magisk.asyncs.ParallelTask
;
import
com.topjohnwu.magisk.components.Fragment
;
import
com.topjohnwu.magisk.components.Fragment
;
import
com.topjohnwu.magisk.components.SnackbarMaker
;
import
com.topjohnwu.magisk.components.SnackbarMaker
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
...
@@ -36,8 +37,6 @@ import butterknife.Unbinder;
...
@@ -36,8 +37,6 @@ import butterknife.Unbinder;
public
class
MagiskLogFragment
extends
Fragment
{
public
class
MagiskLogFragment
extends
Fragment
{
private
static
final
String
MAGISK_LOG
=
"/cache/magisk.log"
;
private
Unbinder
unbinder
;
private
Unbinder
unbinder
;
@BindView
(
R
.
id
.
txtLog
)
TextView
txtLog
;
@BindView
(
R
.
id
.
txtLog
)
TextView
txtLog
;
...
@@ -117,11 +116,11 @@ public class MagiskLogFragment extends Fragment {
...
@@ -117,11 +116,11 @@ public class MagiskLogFragment extends Fragment {
switch
(
mode
)
{
switch
(
mode
)
{
case
0
:
case
0
:
StringBuildingList
logList
=
new
StringBuildingList
();
StringBuildingList
logList
=
new
StringBuildingList
();
Shell
.
su
(
logList
,
"cat "
+
MAGISK_LOG
+
" | tail -n 1000"
);
Shell
.
su
(
logList
,
"cat "
+
Const
.
MAGISK_LOG
+
" | tail -n 1000"
);
return
logList
.
toString
();
return
logList
.
getCharSequence
();
case
1
:
case
1
:
Shell
.
su_raw
(
"echo -n > "
+
MAGISK_LOG
);
Shell
.
su_raw
(
"echo -n > "
+
Const
.
MAGISK_LOG
);
SnackbarMaker
.
make
(
txtLog
,
R
.
string
.
logs_cleared
,
Snackbar
.
LENGTH_SHORT
).
show
();
SnackbarMaker
.
make
(
txtLog
,
R
.
string
.
logs_cleared
,
Snackbar
.
LENGTH_SHORT
).
show
();
return
""
;
return
""
;
...
@@ -142,7 +141,7 @@ public class MagiskLogFragment extends Fragment {
...
@@ -142,7 +141,7 @@ public class MagiskLogFragment extends Fragment {
try
(
FileWriter
out
=
new
FileWriter
(
targetFile
))
{
try
(
FileWriter
out
=
new
FileWriter
(
targetFile
))
{
FileWritingList
fileWritingList
=
new
FileWritingList
(
out
);
FileWritingList
fileWritingList
=
new
FileWritingList
(
out
);
Shell
.
su
(
fileWritingList
,
"cat "
+
MAGISK_LOG
);
Shell
.
su
(
fileWritingList
,
"cat "
+
Const
.
MAGISK_LOG
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
return
false
;
return
false
;
...
@@ -158,7 +157,7 @@ public class MagiskLogFragment extends Fragment {
...
@@ -158,7 +157,7 @@ public class MagiskLogFragment extends Fragment {
switch
(
mode
)
{
switch
(
mode
)
{
case
0
:
case
0
:
case
1
:
case
1
:
String
llog
=
(
String
)
o
;
CharSequence
llog
=
(
CharSequence
)
o
;
progressBar
.
setVisibility
(
View
.
GONE
);
progressBar
.
setVisibility
(
View
.
GONE
);
if
(
TextUtils
.
isEmpty
(
llog
))
if
(
TextUtils
.
isEmpty
(
llog
))
txtLog
.
setText
(
R
.
string
.
log_is_empty
);
txtLog
.
setText
(
R
.
string
.
log_is_empty
);
...
@@ -170,7 +169,7 @@ public class MagiskLogFragment extends Fragment {
...
@@ -170,7 +169,7 @@ public class MagiskLogFragment extends Fragment {
case
2
:
case
2
:
boolean
bool
=
(
boolean
)
o
;
boolean
bool
=
(
boolean
)
o
;
if
(
bool
)
{
if
(
bool
)
{
MagiskManager
.
toast
(
targetFile
.
toString
(),
Toast
.
LENGTH_LONG
);
MagiskManager
.
toast
(
targetFile
.
getPath
(),
Toast
.
LENGTH_LONG
);
}
else
{
}
else
{
MagiskManager
.
toast
(
R
.
string
.
logs_save_failed
,
Toast
.
LENGTH_LONG
);
MagiskManager
.
toast
(
R
.
string
.
logs_save_failed
,
Toast
.
LENGTH_LONG
);
}
}
...
@@ -205,9 +204,8 @@ public class MagiskLogFragment extends Fragment {
...
@@ -205,9 +204,8 @@ public class MagiskLogFragment extends Fragment {
return
true
;
return
true
;
}
}
@Override
public
CharSequence
getCharSequence
()
{
public
String
toString
()
{
return
builder
;
return
builder
.
toString
();
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/MagiskManager.java
View file @
c39170c4
This diff is collapsed.
Click to expand it.
app/src/main/java/com/topjohnwu/magisk/MainActivity.java
View file @
c39170c4
...
@@ -16,6 +16,7 @@ import android.view.MenuItem;
...
@@ -16,6 +16,7 @@ import android.view.MenuItem;
import
android.view.View
;
import
android.view.View
;
import
com.topjohnwu.magisk.components.Activity
;
import
com.topjohnwu.magisk.components.Activity
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Topic
;
import
com.topjohnwu.magisk.utils.Topic
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
...
@@ -70,7 +71,7 @@ public class MainActivity extends Activity
...
@@ -70,7 +71,7 @@ public class MainActivity extends Activity
toggle
.
syncState
();
toggle
.
syncState
();
if
(
savedInstanceState
==
null
)
if
(
savedInstanceState
==
null
)
navigate
(
getIntent
().
getStringExtra
(
MagiskManager
.
INTENT
_SECTION
));
navigate
(
getIntent
().
getStringExtra
(
Const
.
Key
.
OPEN
_SECTION
));
navigationView
.
setNavigationItemSelectedListener
(
this
);
navigationView
.
setNavigationItemSelectedListener
(
this
);
...
@@ -115,7 +116,7 @@ public class MainActivity extends Activity
...
@@ -115,7 +116,7 @@ public class MainActivity extends Activity
Menu
menu
=
navigationView
.
getMenu
();
Menu
menu
=
navigationView
.
getMenu
();
menu
.
findItem
(
R
.
id
.
magiskhide
).
setVisible
(
menu
.
findItem
(
R
.
id
.
magiskhide
).
setVisible
(
Shell
.
rootAccess
()
&&
getMagiskManager
().
magiskVersionCode
>=
1300
Shell
.
rootAccess
()
&&
getMagiskManager
().
magiskVersionCode
>=
1300
&&
prefs
.
getBoolean
(
"magiskhide"
,
false
));
&&
prefs
.
getBoolean
(
Const
.
Key
.
MAGISKHIDE
,
false
));
menu
.
findItem
(
R
.
id
.
modules
).
setVisible
(
menu
.
findItem
(
R
.
id
.
modules
).
setVisible
(
Shell
.
rootAccess
()
&&
getMagiskManager
().
magiskVersionCode
>=
0
);
Shell
.
rootAccess
()
&&
getMagiskManager
().
magiskVersionCode
>=
0
);
menu
.
findItem
(
R
.
id
.
downloads
).
setVisible
(
Utils
.
checkNetworkStatus
()
&&
menu
.
findItem
(
R
.
id
.
downloads
).
setVisible
(
Utils
.
checkNetworkStatus
()
&&
...
@@ -141,7 +142,7 @@ public class MainActivity extends Activity
...
@@ -141,7 +142,7 @@ public class MainActivity extends Activity
case
"downloads"
:
case
"downloads"
:
itemId
=
R
.
id
.
downloads
;
itemId
=
R
.
id
.
downloads
;
break
;
break
;
case
"magiskhide"
:
case
Const
.
Key
.
MAGISKHIDE
:
itemId
=
R
.
id
.
magiskhide
;
itemId
=
R
.
id
.
magiskhide
;
break
;
break
;
case
"log"
:
case
"log"
:
...
@@ -176,7 +177,7 @@ public class MainActivity extends Activity
...
@@ -176,7 +177,7 @@ public class MainActivity extends Activity
displayFragment
(
new
ReposFragment
(),
"downloads"
,
true
);
displayFragment
(
new
ReposFragment
(),
"downloads"
,
true
);
break
;
break
;
case
R
.
id
.
magiskhide
:
case
R
.
id
.
magiskhide
:
displayFragment
(
new
MagiskHideFragment
(),
"magiskhide"
,
true
);
displayFragment
(
new
MagiskHideFragment
(),
Const
.
Key
.
MAGISKHIDE
,
true
);
break
;
break
;
case
R
.
id
.
log
:
case
R
.
id
.
log
:
displayFragment
(
new
LogFragment
(),
"log"
,
false
);
displayFragment
(
new
LogFragment
(),
"log"
,
false
);
...
...
app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java
View file @
c39170c4
...
@@ -16,6 +16,7 @@ import com.topjohnwu.magisk.adapters.ModulesAdapter;
...
@@ -16,6 +16,7 @@ import com.topjohnwu.magisk.adapters.ModulesAdapter;
import
com.topjohnwu.magisk.asyncs.LoadModules
;
import
com.topjohnwu.magisk.asyncs.LoadModules
;
import
com.topjohnwu.magisk.components.Fragment
;
import
com.topjohnwu.magisk.components.Fragment
;
import
com.topjohnwu.magisk.container.Module
;
import
com.topjohnwu.magisk.container.Module
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Topic
;
import
com.topjohnwu.magisk.utils.Topic
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
...
@@ -29,8 +30,6 @@ import butterknife.Unbinder;
...
@@ -29,8 +30,6 @@ import butterknife.Unbinder;
public
class
ModulesFragment
extends
Fragment
implements
Topic
.
Subscriber
{
public
class
ModulesFragment
extends
Fragment
implements
Topic
.
Subscriber
{
private
static
final
int
FETCH_ZIP_CODE
=
2
;
private
Unbinder
unbinder
;
private
Unbinder
unbinder
;
@BindView
(
R
.
id
.
swipeRefreshLayout
)
SwipeRefreshLayout
mSwipeRefreshLayout
;
@BindView
(
R
.
id
.
swipeRefreshLayout
)
SwipeRefreshLayout
mSwipeRefreshLayout
;
@BindView
(
R
.
id
.
recyclerView
)
RecyclerView
recyclerView
;
@BindView
(
R
.
id
.
recyclerView
)
RecyclerView
recyclerView
;
...
@@ -40,7 +39,7 @@ public class ModulesFragment extends Fragment implements Topic.Subscriber {
...
@@ -40,7 +39,7 @@ public class ModulesFragment extends Fragment implements Topic.Subscriber {
Utils
.
runWithPermission
(
getActivity
(),
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
,
()
->
{
Utils
.
runWithPermission
(
getActivity
(),
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
,
()
->
{
Intent
intent
=
new
Intent
(
Intent
.
ACTION_GET_CONTENT
);
Intent
intent
=
new
Intent
(
Intent
.
ACTION_GET_CONTENT
);
intent
.
setType
(
"application/zip"
);
intent
.
setType
(
"application/zip"
);
startActivityForResult
(
intent
,
FETCH_ZIP_CODE
);
startActivityForResult
(
intent
,
Const
.
ID
.
FETCH_ZIP
);
});
});
}
}
...
@@ -86,10 +85,10 @@ public class ModulesFragment extends Fragment implements Topic.Subscriber {
...
@@ -86,10 +85,10 @@ public class ModulesFragment extends Fragment implements Topic.Subscriber {
@Override
@Override
public
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
public
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
if
(
requestCode
==
FETCH_ZIP_CODE
&&
resultCode
==
Activity
.
RESULT_OK
&&
data
!=
null
)
{
if
(
requestCode
==
Const
.
ID
.
FETCH_ZIP
&&
resultCode
==
Activity
.
RESULT_OK
&&
data
!=
null
)
{
// Get the URI of the selected file
// Get the URI of the selected file
Intent
intent
=
new
Intent
(
getActivity
(),
FlashActivity
.
class
);
Intent
intent
=
new
Intent
(
getActivity
(),
FlashActivity
.
class
);
intent
.
setData
(
data
.
getData
()).
putExtra
(
FlashActivity
.
SET_ACTION
,
FlashActivity
.
FLASH_ZIP
);
intent
.
setData
(
data
.
getData
()).
putExtra
(
Const
.
Key
.
FLASH_ACTION
,
Const
.
Value
.
FLASH_ZIP
);
startActivity
(
intent
);
startActivity
(
intent
);
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java
View file @
c39170c4
...
@@ -17,9 +17,8 @@ import android.widget.Toast;
...
@@ -17,9 +17,8 @@ import android.widget.Toast;
import
com.topjohnwu.magisk.asyncs.CheckUpdates
;
import
com.topjohnwu.magisk.asyncs.CheckUpdates
;
import
com.topjohnwu.magisk.asyncs.HideManager
;
import
com.topjohnwu.magisk.asyncs.HideManager
;
import
com.topjohnwu.magisk.asyncs.UpdateRepos
;
import
com.topjohnwu.magisk.components.Activity
;
import
com.topjohnwu.magisk.components.Activity
;
import
com.topjohnwu.magisk.
database.SuDatabaseHelper
;
import
com.topjohnwu.magisk.
utils.Const
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Topic
;
import
com.topjohnwu.magisk.utils.Topic
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
...
@@ -94,16 +93,23 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
...
@@ -94,16 +93,23 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
generalCatagory
=
(
PreferenceCategory
)
findPreference
(
"general"
);
generalCatagory
=
(
PreferenceCategory
)
findPreference
(
"general"
);
PreferenceCategory
magiskCategory
=
(
PreferenceCategory
)
findPreference
(
"magisk"
);
PreferenceCategory
magiskCategory
=
(
PreferenceCategory
)
findPreference
(
"magisk"
);
PreferenceCategory
suCategory
=
(
PreferenceCategory
)
findPreference
(
"superuser"
);
PreferenceCategory
suCategory
=
(
PreferenceCategory
)
findPreference
(
"superuser"
);
updateChannel
=
(
ListPreference
)
findPreference
(
"update_channel"
);
suAccess
=
(
ListPreference
)
findPreference
(
"su_access"
);
autoRes
=
(
ListPreference
)
findPreference
(
"su_auto_response"
);
requestTimeout
=
(
ListPreference
)
findPreference
(
"su_request_timeout"
);
suNotification
=
(
ListPreference
)
findPreference
(
"su_notification"
);
multiuserMode
=
(
ListPreference
)
findPreference
(
"multiuser_mode"
);
namespaceMode
=
(
ListPreference
)
findPreference
(
"mnt_ns"
);
SwitchPreference
reauth
=
(
SwitchPreference
)
findPreference
(
"su_reauth"
);
Preference
hideManager
=
findPreference
(
"hide"
);
Preference
hideManager
=
findPreference
(
"hide"
);
findPreference
(
"clear"
).
setOnPreferenceClickListener
((
pref
)
->
{
mm
.
prefs
.
edit
().
remove
(
Const
.
Key
.
ETAG_KEY
).
apply
();
mm
.
repoDB
.
clearRepo
();
MagiskManager
.
toast
(
R
.
string
.
repo_cache_cleared
,
Toast
.
LENGTH_SHORT
);
return
true
;
});
updateChannel
=
(
ListPreference
)
findPreference
(
Const
.
Key
.
UPDATE_CHANNEL
);
suAccess
=
(
ListPreference
)
findPreference
(
Const
.
Key
.
ROOT_ACCESS
);
autoRes
=
(
ListPreference
)
findPreference
(
Const
.
Key
.
SU_AUTO_RESPONSE
);
requestTimeout
=
(
ListPreference
)
findPreference
(
Const
.
Key
.
SU_REQUEST_TIMEOUT
);
suNotification
=
(
ListPreference
)
findPreference
(
Const
.
Key
.
SU_NOTIFICATION
);
multiuserMode
=
(
ListPreference
)
findPreference
(
Const
.
Key
.
SU_MULTIUSER_MODE
);
namespaceMode
=
(
ListPreference
)
findPreference
(
Const
.
Key
.
SU_MNT_NS
);
SwitchPreference
reauth
=
(
SwitchPreference
)
findPreference
(
Const
.
Key
.
SU_REAUTH
);
setSummary
();
setSummary
();
...
@@ -117,14 +123,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
...
@@ -117,14 +123,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
suCategory
.
removePreference
(
reauth
);
suCategory
.
removePreference
(
reauth
);
}
}
findPreference
(
"clear"
).
setOnPreferenceClickListener
((
pref
)
->
{
if
(
mm
.
getPackageName
().
equals
(
Const
.
ORIG_PKG_NAME
))
{
mm
.
prefs
.
edit
().
remove
(
UpdateRepos
.
ETAG_KEY
).
apply
();
mm
.
repoDB
.
clearRepo
();
MagiskManager
.
toast
(
R
.
string
.
repo_cache_cleared
,
Toast
.
LENGTH_SHORT
);
return
true
;
});
if
(
mm
.
getPackageName
().
equals
(
MagiskManager
.
ORIG_PKG_NAME
))
{
hideManager
.
setOnPreferenceClickListener
((
pref
)
->
{
hideManager
.
setOnPreferenceClickListener
((
pref
)
->
{
Utils
.
runWithPermission
(
getActivity
(),
Utils
.
runWithPermission
(
getActivity
(),
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
,
...
@@ -166,7 +165,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
...
@@ -166,7 +165,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
lp
.
setEntries
(
entries
);
lp
.
setEntries
(
entries
);
lp
.
setEntryValues
(
entryValues
);
lp
.
setEntryValues
(
entryValues
);
lp
.
setTitle
(
R
.
string
.
language
);
lp
.
setTitle
(
R
.
string
.
language
);
lp
.
setKey
(
"locale"
);
lp
.
setKey
(
Const
.
Key
.
LOCALE
);
lp
.
setSummary
(
MagiskManager
.
locale
.
getDisplayName
(
MagiskManager
.
locale
));
lp
.
setSummary
(
MagiskManager
.
locale
.
getDisplayName
(
MagiskManager
.
locale
));
if
(
isNew
)
{
if
(
isNew
)
{
generalCatagory
.
addPreference
(
lp
);
generalCatagory
.
addPreference
(
lp
);
...
@@ -192,56 +191,56 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
...
@@ -192,56 +191,56 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
boolean
enabled
;
boolean
enabled
;
switch
(
key
)
{
switch
(
key
)
{
case
"dark_theme"
:
case
Const
.
Key
.
DARK_THEME
:
enabled
=
prefs
.
getBoolean
(
"dark_theme"
,
false
);
enabled
=
prefs
.
getBoolean
(
Const
.
Key
.
DARK_THEME
,
false
);
if
(
mm
.
isDarkTheme
!=
enabled
)
{
if
(
mm
.
isDarkTheme
!=
enabled
)
{
mm
.
reloadActivity
.
publish
(
false
);
mm
.
reloadActivity
.
publish
(
false
);
}
}
break
;
break
;
case
"disable"
:
case
Const
.
Key
.
DISABLE
:
enabled
=
prefs
.
getBoolean
(
"disable"
,
false
);
enabled
=
prefs
.
getBoolean
(
Const
.
Key
.
DISABLE
,
false
);
if
(
enabled
)
{
if
(
enabled
)
{
Utils
.
createFile
(
MagiskManager
.
MAGISK_DISABLE_FILE
);
Utils
.
createFile
(
Const
.
MAGISK_DISABLE_FILE
);
}
else
{
}
else
{
Utils
.
removeItem
(
MagiskManager
.
MAGISK_DISABLE_FILE
);
Utils
.
removeItem
(
Const
.
MAGISK_DISABLE_FILE
);
}
}
Toast
.
makeText
(
getActivity
(),
R
.
string
.
settings_reboot_toast
,
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
getActivity
(),
R
.
string
.
settings_reboot_toast
,
Toast
.
LENGTH_LONG
).
show
();
break
;
break
;
case
"magiskhide"
:
case
Const
.
Key
.
MAGISKHIDE
:
enabled
=
prefs
.
getBoolean
(
"magiskhide"
,
false
);
enabled
=
prefs
.
getBoolean
(
Const
.
Key
.
MAGISKHIDE
,
false
);
if
(
enabled
)
{
if
(
enabled
)
{
Shell
.
su_raw
(
"magiskhide --enable"
);
Shell
.
su_raw
(
"magiskhide --enable"
);
}
else
{
}
else
{
Shell
.
su_raw
(
"magiskhide --disable"
);
Shell
.
su_raw
(
"magiskhide --disable"
);
}
}
break
;
break
;
case
"hosts"
:
case
Const
.
Key
.
HOSTS
:
enabled
=
prefs
.
getBoolean
(
"hosts"
,
false
);
enabled
=
prefs
.
getBoolean
(
Const
.
Key
.
HOSTS
,
false
);
if
(
enabled
)
{
if
(
enabled
)
{
Shell
.
su_raw
(
Shell
.
su_raw
(
"cp -af /system/etc/hosts "
+
MagiskManager
.
MAGISK_HOST_FILE
,
"cp -af /system/etc/hosts "
+
Const
.
MAGISK_HOST_FILE
,
"mount -o bind "
+
MagiskManager
.
MAGISK_HOST_FILE
+
" /system/etc/hosts"
);
"mount -o bind "
+
Const
.
MAGISK_HOST_FILE
+
" /system/etc/hosts"
);
}
else
{
}
else
{
Shell
.
su_raw
(
Shell
.
su_raw
(
"umount -l /system/etc/hosts"
,
"umount -l /system/etc/hosts"
,
"rm -f "
+
MagiskManager
.
MAGISK_HOST_FILE
);
"rm -f "
+
Const
.
MAGISK_HOST_FILE
);
}
}
break
;
break
;
case
"su_access"
:
case
Const
.
Key
.
ROOT_ACCESS
:
mm
.
suDB
.
setSettings
(
SuDatabaseHelper
.
ROOT_ACCESS
,
Utils
.
getPrefsInt
(
prefs
,
"su_access"
));
mm
.
suDB
.
setSettings
(
Const
.
Key
.
ROOT_ACCESS
,
Utils
.
getPrefsInt
(
prefs
,
Const
.
Key
.
ROOT_ACCESS
));
break
;
break
;
case
"multiuser_mode"
:
case
Const
.
Key
.
SU_MULTIUSER_MODE
:
mm
.
suDB
.
setSettings
(
SuDatabaseHelper
.
MULTIUSER_MODE
,
Utils
.
getPrefsInt
(
prefs
,
"multiuser_mode"
));
mm
.
suDB
.
setSettings
(
Const
.
Key
.
SU_MULTIUSER_MODE
,
Utils
.
getPrefsInt
(
prefs
,
Const
.
Key
.
SU_MULTIUSER_MODE
));
break
;
break
;
case
"mnt_ns"
:
case
Const
.
Key
.
SU_MNT_NS
:
mm
.
suDB
.
setSettings
(
SuDatabaseHelper
.
MNT_NS
,
Utils
.
getPrefsInt
(
prefs
,
"mnt_ns"
));
mm
.
suDB
.
setSettings
(
Const
.
Key
.
SU_MNT_NS
,
Utils
.
getPrefsInt
(
prefs
,
Const
.
Key
.
SU_MNT_NS
));
break
;
break
;
case
"locale"
:
case
Const
.
Key
.
LOCALE
:
mm
.
setLocale
();
mm
.
setLocale
();
mm
.
reloadActivity
.
publish
(
false
);
mm
.
reloadActivity
.
publish
(
false
);
break
;
break
;
case
"update_channel"
:
case
Const
.
Key
.
UPDATE_CHANNEL
:
mm
.
updateChannel
=
Utils
.
getPrefsInt
(
prefs
,
"update_channel"
);
mm
.
updateChannel
=
Utils
.
getPrefsInt
(
prefs
,
Const
.
Key
.
UPDATE_CHANNEL
);
new
CheckUpdates
(
true
).
exec
();
new
CheckUpdates
(
true
).
exec
();
break
;
break
;
}
}
...
@@ -259,7 +258,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
...
@@ -259,7 +258,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
suNotification
.
setSummary
(
getResources
()
suNotification
.
setSummary
(
getResources
()
.
getStringArray
(
R
.
array
.
su_notification
)[
mm
.
suNotificationType
]);
.
getStringArray
(
R
.
array
.
su_notification
)[
mm
.
suNotificationType
]);
requestTimeout
.
setSummary
(
requestTimeout
.
setSummary
(
getString
(
R
.
string
.
request_timeout_summary
,
prefs
.
getString
(
"su_request_timeout"
,
"10"
)));
getString
(
R
.
string
.
request_timeout_summary
,
prefs
.
getString
(
Const
.
Key
.
SU_REQUEST_TIMEOUT
,
"10"
)));
multiuserMode
.
setSummary
(
getResources
()
multiuserMode
.
setSummary
(
getResources
()
.
getStringArray
(
R
.
array
.
multiuser_summary
)[
mm
.
multiuserMode
]);
.
getStringArray
(
R
.
array
.
multiuser_summary
)[
mm
.
multiuserMode
]);
namespaceMode
.
setSummary
(
getResources
()
namespaceMode
.
setSummary
(
getResources
()
...
@@ -268,7 +267,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
...
@@ -268,7 +267,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
@Override
@Override
public
void
onTopicPublished
(
Topic
topic
,
Object
result
)
{
public
void
onTopicPublished
(
Topic
topic
,
Object
result
)
{
setLocalePreference
((
ListPreference
)
findPreference
(
"locale"
));
setLocalePreference
((
ListPreference
)
findPreference
(
Const
.
Key
.
LOCALE
));
}
}
@Override
@Override
...
...
app/src/main/java/com/topjohnwu/magisk/SplashActivity.java
View file @
c39170c4
...
@@ -4,6 +4,7 @@ import android.content.Intent;
...
@@ -4,6 +4,7 @@ import android.content.Intent;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
com.topjohnwu.magisk.components.Activity
;
import
com.topjohnwu.magisk.components.Activity
;
import
com.topjohnwu.magisk.utils.Const
;
public
class
SplashActivity
extends
Activity
{
public
class
SplashActivity
extends
Activity
{
...
@@ -14,9 +15,9 @@ public class SplashActivity extends Activity {
...
@@ -14,9 +15,9 @@ public class SplashActivity extends Activity {
getMagiskManager
().
startup
();
getMagiskManager
().
startup
();
Intent
intent
=
new
Intent
(
this
,
MainActivity
.
class
);
Intent
intent
=
new
Intent
(
this
,
MainActivity
.
class
);
String
section
=
getIntent
().
getStringExtra
(
MagiskManager
.
INTENT
_SECTION
);
String
section
=
getIntent
().
getStringExtra
(
Const
.
Key
.
OPEN
_SECTION
);
if
(
section
!=
null
)
{
if
(
section
!=
null
)
{
intent
.
putExtra
(
MagiskManager
.
INTENT
_SECTION
,
section
);
intent
.
putExtra
(
Const
.
Key
.
OPEN
_SECTION
,
section
);
}
}
startActivity
(
intent
);
startActivity
(
intent
);
finish
();
finish
();
...
...
app/src/main/java/com/topjohnwu/magisk/adapters/ApplicationAdapter.java
View file @
c39170c4
...
@@ -17,12 +17,12 @@ import android.widget.TextView;
...
@@ -17,12 +17,12 @@ import android.widget.TextView;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.asyncs.ParallelTask
;
import
com.topjohnwu.magisk.asyncs.ParallelTask
;
import
com.topjohnwu.magisk.components.SnackbarMaker
;
import
com.topjohnwu.magisk.components.SnackbarMaker
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Topic
;
import
com.topjohnwu.magisk.utils.Topic
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.List
;
...
@@ -32,17 +32,6 @@ import butterknife.ButterKnife;
...
@@ -32,17 +32,6 @@ import butterknife.ButterKnife;
public
class
ApplicationAdapter
extends
RecyclerView
.
Adapter
<
ApplicationAdapter
.
ViewHolder
>
{
public
class
ApplicationAdapter
extends
RecyclerView
.
Adapter
<
ApplicationAdapter
.
ViewHolder
>
{
public
static
final
List
<
String
>
BLACKLIST
=
Arrays
.
asList
(
"android"
,
"com.topjohnwu.magisk"
,
"com.google.android.gms"
);
private
static
final
List
<
String
>
SNLIST
=
Arrays
.
asList
(
"com.google.android.apps.walletnfcrel"
,
"com.nianticlabs.pokemongo"
);
private
List
<
ApplicationInfo
>
mOriginalList
,
mList
;
private
List
<
ApplicationInfo
>
mOriginalList
,
mList
;
private
List
<
String
>
mHideList
;
private
List
<
String
>
mHideList
;
private
PackageManager
pm
;
private
PackageManager
pm
;
...
@@ -80,7 +69,7 @@ public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.
...
@@ -80,7 +69,7 @@ public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.
holder
.
itemView
.
setOnClickListener
(
null
);
holder
.
itemView
.
setOnClickListener
(
null
);
holder
.
checkBox
.
setOnCheckedChangeListener
(
null
);
holder
.
checkBox
.
setOnCheckedChangeListener
(
null
);
if
(
SN
LIST
.
contains
(
info
.
packageName
))
{
if
(
Const
.
SN_DEFAULT
LIST
.
contains
(
info
.
packageName
))
{
holder
.
checkBox
.
setChecked
(
true
);
holder
.
checkBox
.
setChecked
(
true
);
holder
.
checkBox
.
setEnabled
(
false
);
holder
.
checkBox
.
setEnabled
(
false
);
holder
.
itemView
.
setOnClickListener
(
v
->
holder
.
itemView
.
setOnClickListener
(
v
->
...
@@ -160,7 +149,7 @@ public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.
...
@@ -160,7 +149,7 @@ public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.
mOriginalList
=
pm
.
getInstalledApplications
(
0
);
mOriginalList
=
pm
.
getInstalledApplications
(
0
);
for
(
Iterator
<
ApplicationInfo
>
i
=
mOriginalList
.
iterator
();
i
.
hasNext
();
)
{
for
(
Iterator
<
ApplicationInfo
>
i
=
mOriginalList
.
iterator
();
i
.
hasNext
();
)
{
ApplicationInfo
info
=
i
.
next
();
ApplicationInfo
info
=
i
.
next
();
if
(
ApplicationAdapter
.
BLACKLIST
.
contains
(
info
.
packageName
)
||
!
info
.
enabled
)
{
if
(
Const
.
SN_
BLACKLIST
.
contains
(
info
.
packageName
)
||
!
info
.
enabled
)
{
i
.
remove
();
i
.
remove
();
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/asyncs/CheckSafetyNet.java
View file @
c39170c4
...
@@ -4,6 +4,7 @@ import android.app.Activity;
...
@@ -4,6 +4,7 @@ import android.app.Activity;
import
com.topjohnwu.crypto.ByteArrayStream
;
import
com.topjohnwu.crypto.ByteArrayStream
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.WebService
;
import
com.topjohnwu.magisk.utils.WebService
;
...
@@ -18,11 +19,6 @@ import dalvik.system.DexClassLoader;
...
@@ -18,11 +19,6 @@ import dalvik.system.DexClassLoader;
public
class
CheckSafetyNet
extends
ParallelTask
<
Void
,
Void
,
Exception
>
{
public
class
CheckSafetyNet
extends
ParallelTask
<
Void
,
Void
,
Exception
>
{
public
static
final
int
SNET_VER
=
3
;
private
static
final
String
SNET_URL
=
"https://www.dropbox.com/s/jg2yhcrn3l9fckc/snet.apk?dl=1"
;
private
static
final
String
PKG
=
"com.topjohnwu.snet"
;
private
File
dexPath
;
private
File
dexPath
;
private
DexClassLoader
loader
;
private
DexClassLoader
loader
;
...
@@ -34,18 +30,18 @@ public class CheckSafetyNet extends ParallelTask<Void, Void, Exception> {
...
@@ -34,18 +30,18 @@ public class CheckSafetyNet extends ParallelTask<Void, Void, Exception> {
@Override
@Override
protected
void
onPreExecute
()
{
protected
void
onPreExecute
()
{
MagiskManager
mm
=
MagiskManager
.
get
();
MagiskManager
mm
=
MagiskManager
.
get
();
if
(
mm
.
snet_version
!=
C
heckSafetyNet
.
SNET_VER
)
{
if
(
mm
.
snet_version
!=
C
onst
.
Value
.
SNET_VER
)
{
Shell
.
sh
(
"rm -rf "
+
dexPath
.
getParent
());
Shell
.
sh
(
"rm -rf "
+
dexPath
.
getParent
());
}
}
mm
.
snet_version
=
C
heckSafetyNet
.
SNET_VER
;
mm
.
snet_version
=
C
onst
.
Value
.
SNET_VER
;
mm
.
prefs
.
edit
().
putInt
(
"snet_version"
,
CheckSafetyNet
.
SNET_VER
).
apply
();
mm
.
prefs
.
edit
().
putInt
(
Const
.
Key
.
SNET_VER
,
Const
.
Value
.
SNET_VER
).
apply
();
}
}
@Override
@Override
protected
Exception
doInBackground
(
Void
...
voids
)
{
protected
Exception
doInBackground
(
Void
...
voids
)
{
try
{
try
{
if
(!
dexPath
.
exists
())
{
if
(!
dexPath
.
exists
())
{
HttpURLConnection
conn
=
WebService
.
request
(
SNET_URL
,
null
);
HttpURLConnection
conn
=
WebService
.
request
(
Const
.
Url
.
SNET_URL
,
null
);
ByteArrayStream
bas
=
new
ByteArrayStream
();
ByteArrayStream
bas
=
new
ByteArrayStream
();
bas
.
readFrom
(
conn
.
getInputStream
());
bas
.
readFrom
(
conn
.
getInputStream
());
conn
.
disconnect
();
conn
.
disconnect
();
...
@@ -68,8 +64,8 @@ public class CheckSafetyNet extends ParallelTask<Void, Void, Exception> {
...
@@ -68,8 +64,8 @@ public class CheckSafetyNet extends ParallelTask<Void, Void, Exception> {
MagiskManager
mm
=
MagiskManager
.
get
();
MagiskManager
mm
=
MagiskManager
.
get
();
try
{
try
{
if
(
err
!=
null
)
throw
err
;
if
(
err
!=
null
)
throw
err
;
Class
<?>
helperClazz
=
loader
.
loadClass
(
PKG
+
".SafetyNetHelper"
);
Class
<?>
helperClazz
=
loader
.
loadClass
(
Const
.
SNET_
PKG
+
".SafetyNetHelper"
);
Class
<?>
callbackClazz
=
loader
.
loadClass
(
PKG
+
".SafetyNetCallback"
);
Class
<?>
callbackClazz
=
loader
.
loadClass
(
Const
.
SNET_
PKG
+
".SafetyNetCallback"
);
Object
helper
=
helperClazz
.
getConstructors
()[
0
].
newInstance
(
Object
helper
=
helperClazz
.
getConstructors
()[
0
].
newInstance
(
getActivity
(),
dexPath
.
getPath
(),
Proxy
.
newProxyInstance
(
getActivity
(),
dexPath
.
getPath
(),
Proxy
.
newProxyInstance
(
loader
,
new
Class
[]
{
callbackClazz
},
(
proxy
,
method
,
args
)
->
{
loader
,
new
Class
[]
{
callbackClazz
},
(
proxy
,
method
,
args
)
->
{
...
...
app/src/main/java/com/topjohnwu/magisk/asyncs/CheckUpdates.java
View file @
c39170c4
...
@@ -2,6 +2,7 @@ package com.topjohnwu.magisk.asyncs;
...
@@ -2,6 +2,7 @@ package com.topjohnwu.magisk.asyncs;
import
com.topjohnwu.magisk.BuildConfig
;
import
com.topjohnwu.magisk.BuildConfig
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.ShowUI
;
import
com.topjohnwu.magisk.utils.ShowUI
;
import
com.topjohnwu.magisk.utils.WebService
;
import
com.topjohnwu.magisk.utils.WebService
;
...
@@ -10,12 +11,6 @@ import org.json.JSONObject;
...
@@ -10,12 +11,6 @@ import org.json.JSONObject;
public
class
CheckUpdates
extends
ParallelTask
<
Void
,
Void
,
Void
>
{
public
class
CheckUpdates
extends
ParallelTask
<
Void
,
Void
,
Void
>
{
public
static
final
int
STABLE_CHANNEL
=
0
;
public
static
final
int
BETA_CHANNEL
=
1
;
private
static
final
String
STABLE_URL
=
"https://raw.githubusercontent.com/topjohnwu/MagiskManager/update/stable.json"
;
private
static
final
String
BETA_URL
=
"https://raw.githubusercontent.com/topjohnwu/MagiskManager/update/beta.json"
;
private
boolean
showNotification
;
private
boolean
showNotification
;
public
CheckUpdates
()
{
public
CheckUpdates
()
{
...
@@ -31,11 +26,11 @@ public class CheckUpdates extends ParallelTask<Void, Void, Void> {
...
@@ -31,11 +26,11 @@ public class CheckUpdates extends ParallelTask<Void, Void, Void> {
MagiskManager
mm
=
MagiskManager
.
get
();
MagiskManager
mm
=
MagiskManager
.
get
();
String
jsonStr
;
String
jsonStr
;
switch
(
mm
.
updateChannel
)
{
switch
(
mm
.
updateChannel
)
{
case
STABLE_CHANNEL:
case
Const
.
Value
.
STABLE_CHANNEL
:
jsonStr
=
WebService
.
getString
(
STABLE_URL
);
jsonStr
=
WebService
.
getString
(
Const
.
Url
.
STABLE_URL
);
break
;
break
;
case
BETA_CHANNEL:
case
Const
.
Value
.
BETA_CHANNEL
:
jsonStr
=
WebService
.
getString
(
BETA_URL
);
jsonStr
=
WebService
.
getString
(
Const
.
Url
.
BETA_URL
);
break
;
break
;
default
:
default
:
jsonStr
=
null
;
jsonStr
=
null
;
...
...
app/src/main/java/com/topjohnwu/magisk/asyncs/DownloadBusybox.java
View file @
c39170c4
...
@@ -4,6 +4,7 @@ import android.content.Context;
...
@@ -4,6 +4,7 @@ import android.content.Context;
import
android.os.Build
;
import
android.os.Build
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.WebService
;
import
com.topjohnwu.magisk.utils.WebService
;
...
@@ -16,9 +17,6 @@ import java.net.HttpURLConnection;
...
@@ -16,9 +17,6 @@ import java.net.HttpURLConnection;
public
class
DownloadBusybox
extends
ParallelTask
<
Void
,
Void
,
Void
>
{
public
class
DownloadBusybox
extends
ParallelTask
<
Void
,
Void
,
Void
>
{
private
static
final
String
BUSYBOX_ARM
=
"https://github.com/topjohnwu/ndk-busybox/releases/download/1.27.2/busybox-arm"
;
private
static
final
String
BUSYBOX_X86
=
"https://github.com/topjohnwu/ndk-busybox/releases/download/1.27.2/busybox-x86"
;
@Override
@Override
protected
Void
doInBackground
(
Void
...
voids
)
{
protected
Void
doInBackground
(
Void
...
voids
)
{
Context
context
=
MagiskManager
.
get
();
Context
context
=
MagiskManager
.
get
();
...
@@ -28,8 +26,8 @@ public class DownloadBusybox extends ParallelTask<Void, Void, Void> {
...
@@ -28,8 +26,8 @@ public class DownloadBusybox extends ParallelTask<Void, Void, Void> {
HttpURLConnection
conn
=
WebService
.
request
(
HttpURLConnection
conn
=
WebService
.
request
(
Build
.
SUPPORTED_32_BIT_ABIS
[
0
].
contains
(
"x86"
)
?
Build
.
SUPPORTED_32_BIT_ABIS
[
0
].
contains
(
"x86"
)
?
BUSYBOX_X86
:
Const
.
Url
.
BUSYBOX_X86
:
BUSYBOX_ARM
,
Const
.
Url
.
BUSYBOX_ARM
,
null
null
);
);
if
(
conn
==
null
)
throw
new
IOException
();
if
(
conn
==
null
)
throw
new
IOException
();
...
@@ -41,11 +39,11 @@ public class DownloadBusybox extends ParallelTask<Void, Void, Void> {
...
@@ -41,11 +39,11 @@ public class DownloadBusybox extends ParallelTask<Void, Void, Void> {
}
}
if
(
busybox
.
exists
())
{
if
(
busybox
.
exists
())
{
Shell
.
su
(
Shell
.
su
(
"rm -rf "
+
MagiskManager
.
BUSYBOXPATH
,
"rm -rf "
+
Const
.
BUSYBOXPATH
,
"mkdir -p "
+
MagiskManager
.
BUSYBOXPATH
,
"mkdir -p "
+
Const
.
BUSYBOXPATH
,
"cp "
+
busybox
+
" "
+
MagiskManager
.
BUSYBOXPATH
,
"cp "
+
busybox
+
" "
+
Const
.
BUSYBOXPATH
,
"chmod -R 755 "
+
MagiskManager
.
BUSYBOXPATH
,
"chmod -R 755 "
+
Const
.
BUSYBOXPATH
,
MagiskManager
.
BUSYBOXPATH
+
"/busybox --install -s "
+
MagiskManager
.
BUSYBOXPATH
Const
.
BUSYBOXPATH
+
"/busybox --install -s "
+
Const
.
BUSYBOXPATH
);
);
busybox
.
delete
();
busybox
.
delete
();
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/asyncs/FlashZip.java
View file @
c39170c4
...
@@ -7,6 +7,7 @@ import android.text.TextUtils;
...
@@ -7,6 +7,7 @@ import android.text.TextUtils;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.container.AdaptiveList
;
import
com.topjohnwu.magisk.container.AdaptiveList
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.ZipUtils
;
import
com.topjohnwu.magisk.utils.ZipUtils
;
...
@@ -93,7 +94,7 @@ public class FlashZip extends ParallelTask<Void, Void, Integer> {
...
@@ -93,7 +94,7 @@ public class FlashZip extends ParallelTask<Void, Void, Integer> {
MagiskManager
mm
=
MagiskManager
.
get
();
MagiskManager
mm
=
MagiskManager
.
get
();
Shell
.
su_raw
(
Shell
.
su_raw
(
"rm -rf "
+
mCachedFile
.
getParent
(),
"rm -rf "
+
mCachedFile
.
getParent
(),
"rm -rf "
+
MagiskManager
.
TMP_FOLDER_PATH
"rm -rf "
+
Const
.
TMP_FOLDER_PATH
);
);
switch
(
result
)
{
switch
(
result
)
{
case
-
1
:
case
-
1
:
...
...
app/src/main/java/com/topjohnwu/magisk/asyncs/HideManager.java
View file @
c39170c4
...
@@ -6,7 +6,7 @@ import android.widget.Toast;
...
@@ -6,7 +6,7 @@ import android.widget.Toast;
import
com.topjohnwu.crypto.JarMap
;
import
com.topjohnwu.crypto.JarMap
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.
database.SuDatabaseHelper
;
import
com.topjohnwu.magisk.
utils.Const
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.ZipUtils
;
import
com.topjohnwu.magisk.utils.ZipUtils
;
...
@@ -20,8 +20,6 @@ import java.util.jar.JarEntry;
...
@@ -20,8 +20,6 @@ import java.util.jar.JarEntry;
public
class
HideManager
extends
ParallelTask
<
Void
,
Void
,
Boolean
>
{
public
class
HideManager
extends
ParallelTask
<
Void
,
Void
,
Boolean
>
{
private
static
final
String
ANDROID_MANIFEST
=
"AndroidManifest.xml"
;
private
String
genPackageName
(
String
prefix
,
int
length
)
{
private
String
genPackageName
(
String
prefix
,
int
length
)
{
StringBuilder
builder
=
new
StringBuilder
(
length
);
StringBuilder
builder
=
new
StringBuilder
(
length
);
builder
.
append
(
prefix
);
builder
.
append
(
prefix
);
...
@@ -101,17 +99,17 @@ public class HideManager extends ParallelTask<Void, Void, Boolean> {
...
@@ -101,17 +99,17 @@ public class HideManager extends ParallelTask<Void, Void, Boolean> {
// Generate a new unhide app with random package name
// Generate a new unhide app with random package name
File
repack
=
new
File
(
Environment
.
getExternalStorageDirectory
()
+
"/MagiskManager"
,
"repack.apk"
);
File
repack
=
new
File
(
Environment
.
getExternalStorageDirectory
()
+
"/MagiskManager"
,
"repack.apk"
);
repack
.
getParentFile
().
mkdirs
();
repack
.
getParentFile
().
mkdirs
();
String
pkg
=
genPackageName
(
"com."
,
MagiskManager
.
ORIG_PKG_NAME
.
length
());
String
pkg
=
genPackageName
(
"com."
,
Const
.
ORIG_PKG_NAME
.
length
());
try
{
try
{
// Read whole APK into memory
// Read whole APK into memory
JarMap
apk
=
new
JarMap
(
new
FileInputStream
(
mm
.
getPackageCodePath
()));
JarMap
apk
=
new
JarMap
(
new
FileInputStream
(
mm
.
getPackageCodePath
()));
JarEntry
je
=
new
JarEntry
(
ANDROID_MANIFEST
);
JarEntry
je
=
new
JarEntry
(
Const
.
ANDROID_MANIFEST
);
byte
xml
[]
=
apk
.
getRawData
(
je
);
byte
xml
[]
=
apk
.
getRawData
(
je
);
if
(!
findAndPatch
(
xml
,
MagiskManager
.
ORIG_PKG_NAME
,
pkg
))
if
(!
findAndPatch
(
xml
,
Const
.
ORIG_PKG_NAME
,
pkg
))
return
false
;
return
false
;
if
(!
findAndPatch
(
xml
,
MagiskManager
.
ORIG_PKG_NAME
+
".provider"
,
pkg
+
".provider"
))
if
(!
findAndPatch
(
xml
,
Const
.
ORIG_PKG_NAME
+
".provider"
,
pkg
+
".provider"
))
return
false
;
return
false
;
// Write in changes
// Write in changes
...
@@ -133,7 +131,7 @@ public class HideManager extends ParallelTask<Void, Void, Boolean> {
...
@@ -133,7 +131,7 @@ public class HideManager extends ParallelTask<Void, Void, Boolean> {
if
(!
Utils
.
isValidShellResponse
(
ret
)
||
!
Boolean
.
parseBoolean
(
ret
.
get
(
0
)))
if
(!
Utils
.
isValidShellResponse
(
ret
)
||
!
Boolean
.
parseBoolean
(
ret
.
get
(
0
)))
return
false
;
return
false
;
mm
.
suDB
.
setStrings
(
SuDatabaseHelper
.
REQUESTER
,
pkg
);
mm
.
suDB
.
setStrings
(
Const
.
Key
.
SU_
REQUESTER
,
pkg
);
Shell
.
su_raw
(
String
.
format
(
Locale
.
US
,
"pm uninstall --user %d %s"
,
mm
.
userId
,
mm
.
getPackageName
()));
Shell
.
su_raw
(
String
.
format
(
Locale
.
US
,
"pm uninstall --user %d %s"
,
mm
.
userId
,
mm
.
getPackageName
()));
return
true
;
return
true
;
...
...
app/src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java
View file @
c39170c4
...
@@ -11,6 +11,7 @@ import com.topjohnwu.crypto.SignBoot;
...
@@ -11,6 +11,7 @@ import com.topjohnwu.crypto.SignBoot;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.container.AdaptiveList
;
import
com.topjohnwu.magisk.container.AdaptiveList
;
import
com.topjohnwu.magisk.container.TarEntry
;
import
com.topjohnwu.magisk.container.TarEntry
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.ZipUtils
;
import
com.topjohnwu.magisk.utils.ZipUtils
;
...
@@ -202,10 +203,10 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
...
@@ -202,10 +203,10 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
File
signed
=
new
File
(
install
.
getParent
(),
"signed.img"
);
File
signed
=
new
File
(
install
.
getParent
(),
"signed.img"
);
AssetManager
assets
=
mm
.
getAssets
();
AssetManager
assets
=
mm
.
getAssets
();
try
(
try
(
InputStream
in
=
new
FileInputStream
(
patched_boot
);
InputStream
in
=
new
FileInputStream
(
patched_boot
);
OutputStream
out
=
new
BufferedOutputStream
(
new
FileOutputStream
(
signed
));
OutputStream
out
=
new
BufferedOutputStream
(
new
FileOutputStream
(
signed
));
InputStream
keyIn
=
assets
.
open
(
ZipUtils
.
PRIVATE_KEY_NAME
);
InputStream
keyIn
=
assets
.
open
(
Const
.
PRIVATE_KEY_NAME
);
InputStream
certIn
=
assets
.
open
(
ZipUtils
.
PUBLIC_KEY_NAME
)
InputStream
certIn
=
assets
.
open
(
Const
.
PUBLIC_KEY_NAME
)
)
{
)
{
SignBoot
.
doSignature
(
"/boot"
,
in
,
out
,
keyIn
,
certIn
);
SignBoot
.
doSignature
(
"/boot"
,
in
,
out
,
keyIn
,
certIn
);
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/asyncs/LoadModules.java
View file @
c39170c4
...
@@ -3,6 +3,7 @@ package com.topjohnwu.magisk.asyncs;
...
@@ -3,6 +3,7 @@ package com.topjohnwu.magisk.asyncs;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.container.Module
;
import
com.topjohnwu.magisk.container.Module
;
import
com.topjohnwu.magisk.container.ValueSortedMap
;
import
com.topjohnwu.magisk.container.ValueSortedMap
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Shell
;
import
java.util.List
;
import
java.util.List
;
...
@@ -10,7 +11,7 @@ import java.util.List;
...
@@ -10,7 +11,7 @@ import java.util.List;
public
class
LoadModules
extends
ParallelTask
<
Void
,
Void
,
Void
>
{
public
class
LoadModules
extends
ParallelTask
<
Void
,
Void
,
Void
>
{
private
List
<
String
>
getModList
()
{
private
List
<
String
>
getModList
()
{
String
command
=
"ls -d "
+
MagiskManager
.
MAGISK_PATH
+
"/* | grep -v lost+found"
;
String
command
=
"ls -d "
+
Const
.
MAGISK_PATH
+
"/* | grep -v lost+found"
;
return
Shell
.
su
(
command
);
return
Shell
.
su
(
command
);
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/asyncs/ProcessRepoZip.java
View file @
c39170c4
...
@@ -13,6 +13,7 @@ import com.topjohnwu.magisk.FlashActivity;
...
@@ -13,6 +13,7 @@ import com.topjohnwu.magisk.FlashActivity;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.container.InputStreamWrapper
;
import
com.topjohnwu.magisk.container.InputStreamWrapper
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.WebService
;
import
com.topjohnwu.magisk.utils.WebService
;
...
@@ -165,8 +166,8 @@ public class ProcessRepoZip extends ParallelTask<Void, Object, Boolean> {
...
@@ -165,8 +166,8 @@ public class ProcessRepoZip extends ParallelTask<Void, Object, Boolean> {
Uri
uri
=
Uri
.
fromFile
(
mFile
);
Uri
uri
=
Uri
.
fromFile
(
mFile
);
if
(
result
)
{
if
(
result
)
{
if
(
Shell
.
rootAccess
()
&&
mInstall
)
{
if
(
Shell
.
rootAccess
()
&&
mInstall
)
{
Intent
intent
=
new
Intent
(
getActivity
()
,
FlashActivity
.
class
);
Intent
intent
=
new
Intent
(
activity
,
FlashActivity
.
class
);
intent
.
setData
(
uri
).
putExtra
(
FlashActivity
.
SET_ACTION
,
FlashActivity
.
FLASH_ZIP
);
intent
.
setData
(
uri
).
putExtra
(
Const
.
Key
.
FLASH_ACTION
,
Const
.
Value
.
FLASH_ZIP
);
activity
.
startActivity
(
intent
);
activity
.
startActivity
(
intent
);
}
else
{
}
else
{
Utils
.
showUriSnack
(
activity
,
uri
);
Utils
.
showUriSnack
(
activity
,
uri
);
...
...
app/src/main/java/com/topjohnwu/magisk/asyncs/UpdateRepos.java
View file @
c39170c4
...
@@ -7,6 +7,7 @@ import com.topjohnwu.magisk.MagiskManager;
...
@@ -7,6 +7,7 @@ import com.topjohnwu.magisk.MagiskManager;
import
com.topjohnwu.magisk.ReposFragment
;
import
com.topjohnwu.magisk.ReposFragment
;
import
com.topjohnwu.magisk.container.Repo
;
import
com.topjohnwu.magisk.container.Repo
;
import
com.topjohnwu.magisk.database.RepoDatabaseHelper
;
import
com.topjohnwu.magisk.database.RepoDatabaseHelper
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.utils.WebService
;
import
com.topjohnwu.magisk.utils.WebService
;
...
@@ -26,12 +27,6 @@ import java.util.Map;
...
@@ -26,12 +27,6 @@ import java.util.Map;
public
class
UpdateRepos
extends
ParallelTask
<
Void
,
Void
,
Void
>
{
public
class
UpdateRepos
extends
ParallelTask
<
Void
,
Void
,
Void
>
{
private
static
final
String
REPO_URL
=
"https://api.github.com/users/Magisk-Modules-Repo/repos?per_page=100&page=%d"
;
public
static
final
String
ETAG_KEY
=
"ETag"
;
private
static
final
String
IF_NONE_MATCH
=
"If-None-Match"
;
private
static
final
String
LINK_KEY
=
"Link"
;
private
static
final
int
CHECK_ETAG
=
0
;
private
static
final
int
CHECK_ETAG
=
0
;
private
static
final
int
LOAD_NEXT
=
1
;
private
static
final
int
LOAD_NEXT
=
1
;
private
static
final
int
LOAD_PREV
=
2
;
private
static
final
int
LOAD_PREV
=
2
;
...
@@ -52,7 +47,7 @@ public class UpdateRepos extends ParallelTask<Void, Void, Void> {
...
@@ -52,7 +47,7 @@ public class UpdateRepos extends ParallelTask<Void, Void, Void> {
File
old
=
new
File
(
mm
.
getApplicationInfo
().
dataDir
+
"/shared_prefs"
,
"RepoMap.xml"
);
File
old
=
new
File
(
mm
.
getApplicationInfo
().
dataDir
+
"/shared_prefs"
,
"RepoMap.xml"
);
if
(
old
.
exists
()
||
prefs
.
getString
(
"repomap"
,
null
)
!=
null
)
{
if
(
old
.
exists
()
||
prefs
.
getString
(
"repomap"
,
null
)
!=
null
)
{
old
.
delete
();
old
.
delete
();
prefs
.
edit
().
remove
(
"version"
).
remove
(
"repomap"
).
remove
(
ETAG_KEY
).
apply
();
prefs
.
edit
().
remove
(
"version"
).
remove
(
"repomap"
).
remove
(
Const
.
Key
.
ETAG_KEY
).
apply
();
repoDB
.
clearRepo
();
repoDB
.
clearRepo
();
}
}
forceUpdate
=
force
;
forceUpdate
=
force
;
...
@@ -111,8 +106,8 @@ public class UpdateRepos extends ParallelTask<Void, Void, Void> {
...
@@ -111,8 +106,8 @@ public class UpdateRepos extends ParallelTask<Void, Void, Void> {
if
(
mode
==
CHECK_ETAG
&&
page
<
etags
.
size
())
{
if
(
mode
==
CHECK_ETAG
&&
page
<
etags
.
size
())
{
etag
=
etags
.
get
(
page
);
etag
=
etags
.
get
(
page
);
}
}
header
.
put
(
IF_NONE_MATCH
,
etag
);
header
.
put
(
Const
.
Key
.
IF_NONE_MATCH
,
etag
);
String
url
=
String
.
format
(
Locale
.
US
,
REPO_URL
,
page
+
1
);
String
url
=
String
.
format
(
Locale
.
US
,
Const
.
Url
.
REPO_URL
,
page
+
1
);
HttpURLConnection
conn
=
WebService
.
request
(
url
,
header
);
HttpURLConnection
conn
=
WebService
.
request
(
url
,
header
);
try
{
try
{
...
@@ -129,11 +124,11 @@ public class UpdateRepos extends ParallelTask<Void, Void, Void> {
...
@@ -129,11 +124,11 @@ public class UpdateRepos extends ParallelTask<Void, Void, Void> {
}
}
// Update ETAG
// Update ETAG
etag
=
header
.
get
(
ETAG_KEY
);
etag
=
header
.
get
(
Const
.
Key
.
ETAG_KEY
);
etag
=
etag
.
substring
(
etag
.
indexOf
(
'\"'
),
etag
.
lastIndexOf
(
'\"'
)
+
1
);
etag
=
etag
.
substring
(
etag
.
indexOf
(
'\"'
),
etag
.
lastIndexOf
(
'\"'
)
+
1
);
newEtags
.
add
(
etag
);
newEtags
.
add
(
etag
);
String
links
=
header
.
get
(
LINK_KEY
);
String
links
=
header
.
get
(
Const
.
Key
.
LINK_KEY
);
if
(
links
!=
null
)
{
if
(
links
!=
null
)
{
for
(
String
s
:
links
.
split
(
", "
))
{
for
(
String
s
:
links
.
split
(
", "
))
{
if
(
mode
!=
LOAD_PREV
&&
s
.
contains
(
"next"
))
{
if
(
mode
!=
LOAD_PREV
&&
s
.
contains
(
"next"
))
{
...
@@ -167,7 +162,7 @@ public class UpdateRepos extends ParallelTask<Void, Void, Void> {
...
@@ -167,7 +162,7 @@ public class UpdateRepos extends ParallelTask<Void, Void, Void> {
@Override
@Override
protected
Void
doInBackground
(
Void
...
voids
)
{
protected
Void
doInBackground
(
Void
...
voids
)
{
etags
=
new
ArrayList
<>(
Arrays
.
asList
(
prefs
.
getString
(
ETAG_KEY
,
""
).
split
(
","
)));
etags
=
new
ArrayList
<>(
Arrays
.
asList
(
prefs
.
getString
(
Const
.
Key
.
ETAG_KEY
,
""
).
split
(
","
)));
cached
=
repoDB
.
getRepoIDList
();
cached
=
repoDB
.
getRepoIDList
();
if
(!
loadPage
(
0
,
CHECK_ETAG
))
{
if
(!
loadPage
(
0
,
CHECK_ETAG
))
{
...
@@ -204,7 +199,7 @@ public class UpdateRepos extends ParallelTask<Void, Void, Void> {
...
@@ -204,7 +199,7 @@ public class UpdateRepos extends ParallelTask<Void, Void, Void> {
if
(
i
!=
0
)
etagBuilder
.
append
(
","
);
if
(
i
!=
0
)
etagBuilder
.
append
(
","
);
etagBuilder
.
append
(
newEtags
.
get
(
i
));
etagBuilder
.
append
(
newEtags
.
get
(
i
));
}
}
prefs
.
edit
().
putString
(
ETAG_KEY
,
etagBuilder
.
toString
()).
apply
();
prefs
.
edit
().
putString
(
Const
.
Key
.
ETAG_KEY
,
etagBuilder
.
toString
()).
apply
();
return
null
;
return
null
;
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/container/Repo.java
View file @
c39170c4
...
@@ -3,17 +3,13 @@ package com.topjohnwu.magisk.container;
...
@@ -3,17 +3,13 @@ package com.topjohnwu.magisk.container;
import
android.content.ContentValues
;
import
android.content.ContentValues
;
import
android.database.Cursor
;
import
android.database.Cursor
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.WebService
;
import
com.topjohnwu.magisk.utils.WebService
;
import
java.util.Date
;
import
java.util.Date
;
public
class
Repo
extends
BaseModule
{
public
class
Repo
extends
BaseModule
{
public
static
final
int
MIN_TEMPLATE_VER
=
4
;
private
static
final
String
FILE_URL
=
"https://raw.githubusercontent.com/Magisk-Modules-Repo/%s/master/%s"
;
private
static
final
String
ZIP_URL
=
"https://github.com/Magisk-Modules-Repo/%s/archive/master.zip"
;
private
String
repoName
;
private
String
repoName
;
private
Date
mLastUpdate
;
private
Date
mLastUpdate
;
...
@@ -44,7 +40,7 @@ public class Repo extends BaseModule {
...
@@ -44,7 +40,7 @@ public class Repo extends BaseModule {
if
(
getVersionCode
()
<
0
)
{
if
(
getVersionCode
()
<
0
)
{
throw
new
IllegalRepoException
(
"Repo ["
+
repoName
+
"] does not contain versionCode"
);
throw
new
IllegalRepoException
(
"Repo ["
+
repoName
+
"] does not contain versionCode"
);
}
}
if
(
getTemplateVersion
()
<
MIN_TEMPLATE_VER
)
{
if
(
getTemplateVersion
()
<
Const
.
Value
.
MIN_TEMPLATE_VER
)
{
throw
new
IllegalRepoException
(
"Repo ["
+
repoName
+
"] is outdated"
);
throw
new
IllegalRepoException
(
"Repo ["
+
repoName
+
"] is outdated"
);
}
}
}
}
...
@@ -70,15 +66,15 @@ public class Repo extends BaseModule {
...
@@ -70,15 +66,15 @@ public class Repo extends BaseModule {
}
}
public
String
getZipUrl
()
{
public
String
getZipUrl
()
{
return
String
.
format
(
ZIP_URL
,
repoName
);
return
String
.
format
(
Const
.
Url
.
ZIP_URL
,
repoName
);
}
}
public
String
getManifestUrl
()
{
public
String
getManifestUrl
()
{
return
String
.
format
(
FILE_URL
,
repoName
,
"module.prop"
);
return
String
.
format
(
Const
.
Url
.
FILE_URL
,
repoName
,
"module.prop"
);
}
}
public
String
getDetailUrl
()
{
public
String
getDetailUrl
()
{
return
String
.
format
(
FILE_URL
,
repoName
,
"README.md"
);
return
String
.
format
(
Const
.
Url
.
FILE_URL
,
repoName
,
"README.md"
);
}
}
public
Date
getLastUpdate
()
{
public
Date
getLastUpdate
()
{
...
...
app/src/main/java/com/topjohnwu/magisk/database/RepoDatabaseHelper.java
View file @
c39170c4
...
@@ -7,6 +7,7 @@ import android.database.sqlite.SQLiteOpenHelper;
...
@@ -7,6 +7,7 @@ import android.database.sqlite.SQLiteOpenHelper;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.container.Repo
;
import
com.topjohnwu.magisk.container.Repo
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
java.util.LinkedList
;
import
java.util.LinkedList
;
...
@@ -27,7 +28,7 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
...
@@ -27,7 +28,7 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
// Clear bad repos
// Clear bad repos
mDb
.
delete
(
TABLE_NAME
,
"template<?"
,
mDb
.
delete
(
TABLE_NAME
,
"template<?"
,
new
String
[]
{
String
.
valueOf
(
Repo
.
MIN_TEMPLATE_VER
)
});
new
String
[]
{
String
.
valueOf
(
Const
.
Value
.
MIN_TEMPLATE_VER
)
});
}
}
@Override
@Override
...
...
app/src/main/java/com/topjohnwu/magisk/database/SuDatabaseHelper.java
View file @
c39170c4
...
@@ -25,25 +25,8 @@ import java.util.List;
...
@@ -25,25 +25,8 @@ import java.util.List;
public
class
SuDatabaseHelper
extends
SQLiteOpenHelper
{
public
class
SuDatabaseHelper
extends
SQLiteOpenHelper
{
public
static
final
String
ROOT_ACCESS
=
"root_access"
;
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
String
MULTIUSER_MODE
=
"multiuser_mode"
;
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
String
MNT_NS
=
"mnt_ns"
;
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
String
REQUESTER
=
"requester"
;
public
static
final
String
DB_NAME
=
"su.db"
;
public
static
final
String
DB_NAME
=
"su.db"
;
private
static
final
int
DATABASE_VER
=
5
;
private
static
final
int
DATABASE_VER
=
5
;
private
static
final
String
POLICY_TABLE
=
"policies"
;
private
static
final
String
POLICY_TABLE
=
"policies"
;
private
static
final
String
LOG_TABLE
=
"logs"
;
private
static
final
String
LOG_TABLE
=
"logs"
;
...
...
app/src/main/java/com/topjohnwu/magisk/receivers/ManagerUpdate.java
View file @
c39170c4
...
@@ -7,7 +7,7 @@ import android.net.Uri;
...
@@ -7,7 +7,7 @@ import android.net.Uri;
import
android.os.Build
;
import
android.os.Build
;
import
android.support.v4.content.FileProvider
;
import
android.support.v4.content.FileProvider
;
import
com.topjohnwu.magisk.
MagiskManager
;
import
com.topjohnwu.magisk.
utils.Const
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
java.io.File
;
import
java.io.File
;
...
@@ -35,8 +35,8 @@ public class ManagerUpdate extends BroadcastReceiver {
...
@@ -35,8 +35,8 @@ public class ManagerUpdate extends BroadcastReceiver {
}
}
}
}
},
},
intent
.
getStringExtra
(
MagiskManager
.
INTEN
T_LINK
),
intent
.
getStringExtra
(
Const
.
Key
.
INTENT_SE
T_LINK
),
Utils
.
getLegalFilename
(
"MagiskManager-v"
+
Utils
.
getLegalFilename
(
"MagiskManager-v"
+
intent
.
getStringExtra
(
MagiskManager
.
INTEN
T_VERSION
)
+
".apk"
));
intent
.
getStringExtra
(
Const
.
Key
.
INTENT_SE
T_VERSION
)
+
".apk"
));
}
}
}
}
app/src/main/java/com/topjohnwu/magisk/services/OnBootIntentService.java
View file @
c39170c4
...
@@ -5,13 +5,11 @@ import android.content.Intent;
...
@@ -5,13 +5,11 @@ import android.content.Intent;
import
android.os.Build
;
import
android.os.Build
;
import
android.support.v4.app.NotificationCompat
;
import
android.support.v4.app.NotificationCompat
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.utils.Const
;
public
class
OnBootIntentService
extends
IntentService
{
public
class
OnBootIntentService
extends
IntentService
{
private
static
final
int
ONBOOT_NOTIFICATION_ID
=
3
;
public
OnBootIntentService
()
{
public
OnBootIntentService
()
{
super
(
"OnBootIntentService"
);
super
(
"OnBootIntentService"
);
}
}
...
@@ -21,11 +19,11 @@ public class OnBootIntentService extends IntentService {
...
@@ -21,11 +19,11 @@ public class OnBootIntentService extends IntentService {
super
.
onCreate
();
super
.
onCreate
();
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
NotificationCompat
.
Builder
builder
=
NotificationCompat
.
Builder
builder
=
new
NotificationCompat
.
Builder
(
this
,
MagiskManager
.
NOTIFICATION_CHANNEL
);
new
NotificationCompat
.
Builder
(
this
,
Const
.
ID
.
NOTIFICATION_CHANNEL
);
builder
.
setSmallIcon
(
R
.
drawable
.
ic_magisk
)
builder
.
setSmallIcon
(
R
.
drawable
.
ic_magisk
)
.
setContentTitle
(
"onBoot"
)
.
setContentTitle
(
"onBoot"
)
.
setContentText
(
"Running onBoot operations..."
);
.
setContentText
(
"Running onBoot operations..."
);
startForeground
(
ONBOOT_NOTIFICATION_ID
,
builder
.
build
());
startForeground
(
Const
.
ID
.
ONBOOT_NOTIFICATION_ID
,
builder
.
build
());
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/superuser/SuReceiver.java
View file @
c39170c4
...
@@ -11,32 +11,27 @@ import com.topjohnwu.magisk.MagiskManager;
...
@@ -11,32 +11,27 @@ import com.topjohnwu.magisk.MagiskManager;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.container.Policy
;
import
com.topjohnwu.magisk.container.Policy
;
import
com.topjohnwu.magisk.container.SuLogEntry
;
import
com.topjohnwu.magisk.container.SuLogEntry
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Utils
;
import
java.util.Date
;
import
java.util.Date
;
public
class
SuReceiver
extends
BroadcastReceiver
{
public
class
SuReceiver
extends
BroadcastReceiver
{
public
static
final
int
NO_NOTIFICATION
=
0
;
public
static
final
int
TOAST
=
1
;
private
static
final
int
NOTIFY_NORMAL_LOG
=
0
;
private
static
final
int
NOTIFY_USER_TOASTS
=
1
;
private
static
final
int
NOTIFY_USER_TO_OWNER
=
2
;
@Override
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
int
fromUid
,
toUid
,
pid
,
mode
;
int
fromUid
,
toUid
,
pid
,
mode
;
String
command
,
action
;
String
command
,
action
;
Policy
policy
;
Policy
policy
;
MagiskManager
m
agiskManager
=
(
MagiskManager
)
context
.
getApplicationContext
(
);
MagiskManager
m
m
=
Utils
.
getMagiskManager
(
context
);
if
(
intent
==
null
)
return
;
if
(
intent
==
null
)
return
;
mode
=
intent
.
getIntExtra
(
"mode"
,
-
1
);
mode
=
intent
.
getIntExtra
(
"mode"
,
-
1
);
if
(
mode
<
0
)
return
;
if
(
mode
<
0
)
return
;
if
(
mode
==
NOTIFY_USER_TO_OWNER
)
{
if
(
mode
==
Const
.
Value
.
NOTIFY_USER_TO_OWNER
)
{
MagiskManager
.
toast
(
R
.
string
.
multiuser_hint_owner_request
,
Toast
.
LENGTH_LONG
);
MagiskManager
.
toast
(
R
.
string
.
multiuser_hint_owner_request
,
Toast
.
LENGTH_LONG
);
return
;
return
;
}
}
...
@@ -48,7 +43,7 @@ public class SuReceiver extends BroadcastReceiver {
...
@@ -48,7 +43,7 @@ public class SuReceiver extends BroadcastReceiver {
action
=
intent
.
getStringExtra
(
"action"
);
action
=
intent
.
getStringExtra
(
"action"
);
if
(
action
==
null
)
return
;
if
(
action
==
null
)
return
;
policy
=
m
agiskManager
.
suDB
.
getPolicy
(
fromUid
);
policy
=
m
m
.
suDB
.
getPolicy
(
fromUid
);
if
(
policy
==
null
)
{
if
(
policy
==
null
)
{
try
{
try
{
policy
=
new
Policy
(
fromUid
,
context
.
getPackageManager
());
policy
=
new
Policy
(
fromUid
,
context
.
getPackageManager
());
...
@@ -74,11 +69,11 @@ public class SuReceiver extends BroadcastReceiver {
...
@@ -74,11 +69,11 @@ public class SuReceiver extends BroadcastReceiver {
return
;
return
;
}
}
if
(
policy
.
notification
&&
m
agiskManager
.
suNotificationType
==
TOAST
)
{
if
(
policy
.
notification
&&
m
m
.
suNotificationType
==
Const
.
Value
.
NOTIFICATION_
TOAST
)
{
m
agiskManager
.
toast
(
message
,
Toast
.
LENGTH_SHORT
);
M
agiskManager
.
toast
(
message
,
Toast
.
LENGTH_SHORT
);
}
}
if
(
mode
==
NOTIFY_NORMAL_LOG
&&
policy
.
logging
)
{
if
(
mode
==
Const
.
Value
.
NOTIFY_NORMAL_LOG
&&
policy
.
logging
)
{
toUid
=
intent
.
getIntExtra
(
"to.uid"
,
-
1
);
toUid
=
intent
.
getIntExtra
(
"to.uid"
,
-
1
);
if
(
toUid
<
0
)
return
;
if
(
toUid
<
0
)
return
;
pid
=
intent
.
getIntExtra
(
"pid"
,
-
1
);
pid
=
intent
.
getIntExtra
(
"pid"
,
-
1
);
...
@@ -89,7 +84,7 @@ public class SuReceiver extends BroadcastReceiver {
...
@@ -89,7 +84,7 @@ public class SuReceiver extends BroadcastReceiver {
log
.
fromPid
=
pid
;
log
.
fromPid
=
pid
;
log
.
command
=
command
;
log
.
command
=
command
;
log
.
date
=
new
Date
();
log
.
date
=
new
Date
();
m
agiskManager
.
suDB
.
addLog
(
log
);
m
m
.
suDB
.
addLog
(
log
);
}
}
}
}
}
}
app/src/main/java/com/topjohnwu/magisk/superuser/SuRequestActivity.java
View file @
c39170c4
...
@@ -22,6 +22,7 @@ import com.topjohnwu.magisk.R;
...
@@ -22,6 +22,7 @@ import com.topjohnwu.magisk.R;
import
com.topjohnwu.magisk.asyncs.ParallelTask
;
import
com.topjohnwu.magisk.asyncs.ParallelTask
;
import
com.topjohnwu.magisk.components.Activity
;
import
com.topjohnwu.magisk.components.Activity
;
import
com.topjohnwu.magisk.container.Policy
;
import
com.topjohnwu.magisk.container.Policy
;
import
com.topjohnwu.magisk.utils.Const
;
import
java.io.DataInputStream
;
import
java.io.DataInputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -31,12 +32,6 @@ import butterknife.ButterKnife;
...
@@ -31,12 +32,6 @@ import butterknife.ButterKnife;
public
class
SuRequestActivity
extends
Activity
{
public
class
SuRequestActivity
extends
Activity
{
public
static
final
int
PROMPT
=
0
;
public
static
final
int
AUTO_DENY
=
1
;
public
static
final
int
AUTO_ALLOW
=
2
;
private
static
final
int
[]
timeoutList
=
{
0
,
-
1
,
10
,
20
,
30
,
60
};
@BindView
(
R
.
id
.
su_popup
)
LinearLayout
suPopup
;
@BindView
(
R
.
id
.
su_popup
)
LinearLayout
suPopup
;
@BindView
(
R
.
id
.
timeout
)
Spinner
timeout
;
@BindView
(
R
.
id
.
timeout
)
Spinner
timeout
;
@BindView
(
R
.
id
.
app_icon
)
ImageView
appIcon
;
@BindView
(
R
.
id
.
app_icon
)
ImageView
appIcon
;
...
@@ -86,13 +81,13 @@ public class SuRequestActivity extends Activity {
...
@@ -86,13 +81,13 @@ public class SuRequestActivity extends Activity {
private
void
showRequest
()
{
private
void
showRequest
()
{
switch
(
mm
.
suResponseType
)
{
switch
(
mm
.
suResponseType
)
{
case
AUTO_DENY:
case
Const
.
Value
.
SU_
AUTO_DENY
:
handleAction
(
Policy
.
DENY
,
0
);
handleAction
(
Policy
.
DENY
,
0
);
return
;
return
;
case
AUTO_ALLOW:
case
Const
.
Value
.
SU_
AUTO_ALLOW
:
handleAction
(
Policy
.
ALLOW
,
0
);
handleAction
(
Policy
.
ALLOW
,
0
);
return
;
return
;
case
PROMPT:
case
Const
.
Value
.
SU_
PROMPT
:
default
:
default
:
}
}
...
@@ -169,7 +164,7 @@ public class SuRequestActivity extends Activity {
...
@@ -169,7 +164,7 @@ public class SuRequestActivity extends Activity {
}
}
void
handleAction
(
int
action
)
{
void
handleAction
(
int
action
)
{
handleAction
(
action
,
timeoutList
[
timeout
.
getSelectedItemPosition
()]);
handleAction
(
action
,
Const
.
Value
.
timeoutList
[
timeout
.
getSelectedItemPosition
()]);
}
}
void
handleAction
(
int
action
,
int
time
)
{
void
handleAction
(
int
action
,
int
time
)
{
...
...
app/src/main/java/com/topjohnwu/magisk/utils/BootSigner.java
View file @
c39170c4
...
@@ -31,8 +31,8 @@ public class BootSigner {
...
@@ -31,8 +31,8 @@ public class BootSigner {
}
else
{
}
else
{
/* Use internal test keys */
/* Use internal test keys */
JarFile
apk
=
new
JarFile
(
System
.
getProperty
(
"java.class.path"
));
JarFile
apk
=
new
JarFile
(
System
.
getProperty
(
"java.class.path"
));
JarEntry
keyEntry
=
apk
.
getJarEntry
(
"assets/"
+
ZipUtils
.
PRIVATE_KEY_NAME
);
JarEntry
keyEntry
=
apk
.
getJarEntry
(
"assets/"
+
Const
.
PRIVATE_KEY_NAME
);
JarEntry
sigEntry
=
apk
.
getJarEntry
(
"assets/"
+
ZipUtils
.
PUBLIC_KEY_NAME
);
JarEntry
sigEntry
=
apk
.
getJarEntry
(
"assets/"
+
Const
.
PUBLIC_KEY_NAME
);
keyIn
=
apk
.
getInputStream
(
keyEntry
);
keyIn
=
apk
.
getInputStream
(
keyEntry
);
certIn
=
apk
.
getInputStream
(
sigEntry
);
certIn
=
apk
.
getInputStream
(
sigEntry
);
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Const.java
0 → 100644
View file @
c39170c4
package
com
.
topjohnwu
.
magisk
.
utils
;
import
java.util.Arrays
;
import
java.util.List
;
public
class
Const
{
public
static
final
String
DEBUG_TAG
=
"MagiskManager"
;
public
static
final
String
ORIG_PKG_NAME
=
"com.topjohnwu.magisk"
;
public
static
final
String
SNET_PKG
=
"com.topjohnwu.snet"
;
public
static
final
String
MAGISKHIDE_PROP
=
"persist.magisk.hide"
;
public
static
final
String
DISABLE_INDICATION_PROP
=
"ro.magisk.disable"
;
// APK content
public
static
final
String
PUBLIC_KEY_NAME
=
"public.certificate.x509.pem"
;
public
static
final
String
PRIVATE_KEY_NAME
=
"private.key.pk8"
;
public
static
final
String
UNINSTALLER
=
"magisk_uninstaller.sh"
;
public
static
final
String
UTIL_FUNCTIONS
=
"util_functions.sh"
;
public
static
final
String
ANDROID_MANIFEST
=
"AndroidManifest.xml"
;
// Paths
public
static
final
String
MAGISK_DISABLE_FILE
=
"/cache/.disable_magisk"
;
public
static
final
String
MAGISK_HOST_FILE
=
"/magisk/.core/hosts"
;
public
static
final
String
TMP_FOLDER_PATH
=
"/dev/tmp"
;
public
static
final
String
MAGISK_PATH
=
"/magisk"
;
public
static
final
String
MAGISK_LOG
=
"/cache/magisk.log"
;
public
static
final
String
BUSYBOXPATH
=
"/dev/magisk/bin"
;
/* A list of apps that should not be shown as hide-able */
public
static
final
List
<
String
>
SN_BLACKLIST
=
Arrays
.
asList
(
"android"
,
"com.topjohnwu.magisk"
,
"com.google.android.gms"
);
/* A list of apps that already uses SafetyNet
* They DO NOT need to be added to hide list */
public
static
final
List
<
String
>
SN_DEFAULTLIST
=
Arrays
.
asList
(
"com.google.android.apps.walletnfcrel"
,
"com.nianticlabs.pokemongo"
);
public
static
class
ID
{
public
static
final
int
UPDATE_SERVICE_ID
=
1
;
public
static
final
int
FETCH_ZIP
=
2
;
public
static
final
int
SELECT_BOOT
=
3
;
// notifications
public
static
final
int
MAGISK_UPDATE_NOTIFICATION_ID
=
4
;
public
static
final
int
APK_UPDATE_NOTIFICATION_ID
=
5
;
public
static
final
int
ONBOOT_NOTIFICATION_ID
=
6
;
public
static
final
String
NOTIFICATION_CHANNEL
=
"magisk_update_notice"
;
}
public
static
class
Url
{
public
static
final
String
STABLE_URL
=
"https://raw.githubusercontent.com/topjohnwu/MagiskManager/update/stable.json"
;
public
static
final
String
BETA_URL
=
"https://raw.githubusercontent.com/topjohnwu/MagiskManager/update/beta.json"
;
public
static
final
String
SNET_URL
=
"https://www.dropbox.com/s/jg2yhcrn3l9fckc/snet.apk?dl=1"
;
public
static
final
String
BUSYBOX_ARM
=
"https://github.com/topjohnwu/ndk-busybox/releases/download/1.27.2/busybox-arm"
;
public
static
final
String
BUSYBOX_X86
=
"https://github.com/topjohnwu/ndk-busybox/releases/download/1.27.2/busybox-x86"
;
public
static
final
String
REPO_URL
=
"https://api.github.com/users/Magisk-Modules-Repo/repos?per_page=100&page=%d"
;
public
static
final
String
FILE_URL
=
"https://raw.githubusercontent.com/Magisk-Modules-Repo/%s/master/%s"
;
public
static
final
String
ZIP_URL
=
"https://github.com/Magisk-Modules-Repo/%s/archive/master.zip"
;
public
static
final
String
DONATION_URL
=
"https://www.paypal.me/topjohnwu"
;
public
static
final
String
XDA_THREAD
=
"http://forum.xda-developers.com/showthread.php?t=3432382"
;
public
static
final
String
SOURCE_CODE_URL
=
"https://github.com/topjohnwu/MagiskManager"
;
}
public
static
class
Key
{
// su
public
static
final
String
ROOT_ACCESS
=
"root_access"
;
public
static
final
String
SU_MULTIUSER_MODE
=
"multiuser_mode"
;
public
static
final
String
SU_MNT_NS
=
"mnt_ns"
;
public
static
final
String
SU_REQUESTER
=
"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"
;
// intents
public
static
final
String
OPEN_SECTION
=
"section"
;
public
static
final
String
INTENT_SET_VERSION
=
"version"
;
public
static
final
String
INTENT_SET_LINK
=
"link"
;
public
static
final
String
FLASH_ACTION
=
"action"
;
public
static
final
String
FLASH_SET_BOOT
=
"boot"
;
public
static
final
String
FLASH_SET_ENC
=
"enc"
;
public
static
final
String
FLASH_SET_VERITY
=
"verity"
;
// others
public
static
final
String
UPDATE_NOTIFICATION
=
"notification"
;
public
static
final
String
UPDATE_CHANNEL
=
"update_channel"
;
public
static
final
String
BOOT_FORMAT
=
"boot_format"
;
public
static
final
String
SNET_VER
=
"snet_version"
;
public
static
final
String
UPDATE_SERVICE_VER
=
"update_service_version"
;
public
static
final
String
MAGISKHIDE
=
"magiskhide"
;
public
static
final
String
HOSTS
=
"hosts"
;
public
static
final
String
DISABLE
=
"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
class
Value
{
public
static
final
int
STABLE_CHANNEL
=
0
;
public
static
final
int
BETA_CHANNEL
=
1
;
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
NOTIFY_NORMAL_LOG
=
0
;
public
static
final
int
NOTIFY_USER_TOASTS
=
1
;
public
static
final
int
NOTIFY_USER_TO_OWNER
=
2
;
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
PATCH_BOOT
=
"patch"
;
public
static
final
String
FLASH_MAGISK
=
"magisk"
;
public
static
final
int
[]
timeoutList
=
{
0
,
-
1
,
10
,
20
,
30
,
60
};
public
static
final
int
UPDATE_SERVICE_VER
=
1
;
public
static
final
int
SNET_VER
=
3
;
public
static
final
int
MIN_TEMPLATE_VER
=
4
;
}
}
app/src/main/java/com/topjohnwu/magisk/utils/Logger.java
View file @
c39170c4
...
@@ -6,11 +6,10 @@ import java.util.Locale;
...
@@ -6,11 +6,10 @@ import java.util.Locale;
public
class
Logger
{
public
class
Logger
{
public
static
final
String
DEBUG_TAG
=
"MagiskManager"
;
private
static
final
boolean
SHELL_LOGGING
=
false
;
private
static
final
boolean
SHELL_LOGGING
=
false
;
public
static
void
debug
(
String
line
)
{
public
static
void
debug
(
String
line
)
{
Log
.
d
(
DEBUG_TAG
,
"DEBUG: "
+
line
);
Log
.
d
(
Const
.
DEBUG_TAG
,
"DEBUG: "
+
line
);
}
}
public
static
void
debug
(
String
fmt
,
Object
...
args
)
{
public
static
void
debug
(
String
fmt
,
Object
...
args
)
{
...
@@ -18,7 +17,7 @@ public class Logger {
...
@@ -18,7 +17,7 @@ public class Logger {
}
}
public
static
void
error
(
String
line
)
{
public
static
void
error
(
String
line
)
{
Log
.
e
(
DEBUG_TAG
,
"ERROR: "
+
line
);
Log
.
e
(
Const
.
DEBUG_TAG
,
"ERROR: "
+
line
);
}
}
public
static
void
error
(
String
fmt
,
Object
...
args
)
{
public
static
void
error
(
String
fmt
,
Object
...
args
)
{
...
@@ -27,7 +26,7 @@ public class Logger {
...
@@ -27,7 +26,7 @@ public class Logger {
public
static
void
shell
(
boolean
in
,
String
line
)
{
public
static
void
shell
(
boolean
in
,
String
line
)
{
if
(
SHELL_LOGGING
)
{
if
(
SHELL_LOGGING
)
{
Log
.
d
(
DEBUG_TAG
,
(
in
?
"SHELLIN : "
:
"SHELLOUT: "
)
+
line
);
Log
.
d
(
Const
.
DEBUG_TAG
,
(
in
?
"SHELLIN : "
:
"SHELLOUT: "
)
+
line
);
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/utils/ShowUI.java
View file @
c39170c4
This diff is collapsed.
Click to expand it.
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
View file @
c39170c4
...
@@ -39,7 +39,6 @@ import java.util.Locale;
...
@@ -39,7 +39,6 @@ import java.util.Locale;
public
class
Utils
{
public
class
Utils
{
public
static
final
String
UTIL_FUNCTIONS
=
"util_functions.sh"
;
public
static
boolean
isDownloading
=
false
;
public
static
boolean
isDownloading
=
false
;
public
static
boolean
itemExist
(
String
path
)
{
public
static
boolean
itemExist
(
String
path
)
{
...
...
app/src/main/java/com/topjohnwu/magisk/utils/ZipUtils.java
View file @
c39170c4
...
@@ -15,9 +15,6 @@ import java.util.jar.JarEntry;
...
@@ -15,9 +15,6 @@ import java.util.jar.JarEntry;
import
java.util.jar.JarInputStream
;
import
java.util.jar.JarInputStream
;
public
class
ZipUtils
{
public
class
ZipUtils
{
// File name in assets
public
static
final
String
PUBLIC_KEY_NAME
=
"public.certificate.x509.pem"
;
public
static
final
String
PRIVATE_KEY_NAME
=
"private.key.pk8"
;
static
{
static
{
System
.
loadLibrary
(
"zipadjust"
);
System
.
loadLibrary
(
"zipadjust"
);
...
@@ -69,7 +66,7 @@ public class ZipUtils {
...
@@ -69,7 +66,7 @@ public class ZipUtils {
public
static
void
signZip
(
JarMap
input
,
File
output
,
boolean
minSign
)
throws
Exception
{
public
static
void
signZip
(
JarMap
input
,
File
output
,
boolean
minSign
)
throws
Exception
{
AssetManager
assets
=
MagiskManager
.
get
().
getAssets
();
AssetManager
assets
=
MagiskManager
.
get
().
getAssets
();
SignAPK
.
signZip
(
SignAPK
.
signZip
(
assets
.
open
(
PUBLIC_KEY_NAME
),
assets
.
open
(
PRIVATE_KEY_NAME
),
assets
.
open
(
Const
.
PUBLIC_KEY_NAME
),
assets
.
open
(
Const
.
PRIVATE_KEY_NAME
),
input
,
output
,
minSign
);
input
,
output
,
minSign
);
}
}
}
}
\ No newline at end of file
app/src/main/res/xml/app_settings.xml
View file @
c39170c4
...
@@ -72,7 +72,7 @@
...
@@ -72,7 +72,7 @@
android:title=
"@string/superuser"
>
android:title=
"@string/superuser"
>
<ListPreference
<ListPreference
android:key=
"
su
_access"
android:key=
"
root
_access"
android:title=
"@string/superuser_access"
android:title=
"@string/superuser_access"
android:entries=
"@array/su_access"
android:entries=
"@array/su_access"
android:entryValues=
"@array/value_array"
/>
android:entryValues=
"@array/value_array"
/>
...
...
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