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
a3f0ef8e
Commit
a3f0ef8e
authored
Feb 20, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Many improvements and bug fixes
Close #114
parent
8eba05ed
Show whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
305 additions
and
213 deletions
+305
-213
InstallFragment.java
app/src/main/java/com/topjohnwu/magisk/InstallFragment.java
+135
-100
MagiskHideFragment.java
...rc/main/java/com/topjohnwu/magisk/MagiskHideFragment.java
+2
-1
MagiskLogFragment.java
...src/main/java/com/topjohnwu/magisk/MagiskLogFragment.java
+7
-4
MagiskManager.java
app/src/main/java/com/topjohnwu/magisk/MagiskManager.java
+4
-3
MainActivity.java
app/src/main/java/com/topjohnwu/magisk/MainActivity.java
+13
-8
ReposFragment.java
app/src/main/java/com/topjohnwu/magisk/ReposFragment.java
+3
-2
SettingsActivity.java
app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java
+10
-5
StatusFragment.java
app/src/main/java/com/topjohnwu/magisk/StatusFragment.java
+22
-18
SuLogAdapter.java
...main/java/com/topjohnwu/magisk/adapters/SuLogAdapter.java
+3
-1
GetBootBlocks.java
.../main/java/com/topjohnwu/magisk/asyncs/GetBootBlocks.java
+3
-4
LoadApps.java
app/src/main/java/com/topjohnwu/magisk/asyncs/LoadApps.java
+2
-1
LoadRepos.java
app/src/main/java/com/topjohnwu/magisk/asyncs/LoadRepos.java
+2
-1
MagiskHide.java
...src/main/java/com/topjohnwu/magisk/asyncs/MagiskHide.java
+5
-4
ProcessMagiskZip.java
...in/java/com/topjohnwu/magisk/asyncs/ProcessMagiskZip.java
+6
-3
ProcessRepoZip.java
...main/java/com/topjohnwu/magisk/asyncs/ProcessRepoZip.java
+3
-2
AlertDialogBuilder.java
...a/com/topjohnwu/magisk/components/AlertDialogBuilder.java
+6
-3
SnackbarMaker.java
...n/java/com/topjohnwu/magisk/components/SnackbarMaker.java
+1
-3
RepoDatabaseHelper.java
...ava/com/topjohnwu/magisk/database/RepoDatabaseHelper.java
+4
-2
SuDatabaseHelper.java
.../java/com/topjohnwu/magisk/database/SuDatabaseHelper.java
+10
-6
SuLogDatabaseHelper.java
...va/com/topjohnwu/magisk/database/SuLogDatabaseHelper.java
+9
-5
Module.java
app/src/main/java/com/topjohnwu/magisk/module/Module.java
+2
-1
Repo.java
app/src/main/java/com/topjohnwu/magisk/module/Repo.java
+0
-4
SuReceiver.java
.../main/java/com/topjohnwu/magisk/superuser/SuReceiver.java
+6
-4
SuRequestActivity.java
...ava/com/topjohnwu/magisk/superuser/SuRequestActivity.java
+5
-3
CallbackEvent.java
...c/main/java/com/topjohnwu/magisk/utils/CallbackEvent.java
+6
-3
Shell.java
app/src/main/java/com/topjohnwu/magisk/utils/Shell.java
+4
-2
Utils.java
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
+2
-1
WebService.java
app/src/main/java/com/topjohnwu/magisk/utils/WebService.java
+3
-2
ZipUtils.java
app/src/main/java/com/topjohnwu/magisk/utils/ZipUtils.java
+18
-9
fragment_install.xml
app/src/main/res/layout/fragment_install.xml
+2
-2
strings.xml
app/src/main/res/values-zh-rTW/strings.xml
+5
-3
colors.xml
app/src/main/res/values/colors.xml
+0
-3
strings.xml
app/src/main/res/values/strings.xml
+2
-0
No files found.
app/src/main/java/com/topjohnwu/magisk/InstallFragment.java
View file @
a3f0ef8e
...
@@ -6,6 +6,7 @@ import android.net.Uri;
...
@@ -6,6 +6,7 @@ import android.net.Uri;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.os.CountDownTimer
;
import
android.os.CountDownTimer
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
android.support.design.widget.Snackbar
;
import
android.support.v7.widget.CardView
;
import
android.support.v7.widget.CardView
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.View
;
...
@@ -19,6 +20,7 @@ import android.widget.TextView;
...
@@ -19,6 +20,7 @@ import android.widget.TextView;
import
com.topjohnwu.magisk.asyncs.ProcessMagiskZip
;
import
com.topjohnwu.magisk.asyncs.ProcessMagiskZip
;
import
com.topjohnwu.magisk.components.AlertDialogBuilder
;
import
com.topjohnwu.magisk.components.AlertDialogBuilder
;
import
com.topjohnwu.magisk.components.Fragment
;
import
com.topjohnwu.magisk.components.Fragment
;
import
com.topjohnwu.magisk.components.SnackbarMaker
;
import
com.topjohnwu.magisk.receivers.DownloadReceiver
;
import
com.topjohnwu.magisk.receivers.DownloadReceiver
;
import
com.topjohnwu.magisk.utils.CallbackEvent
;
import
com.topjohnwu.magisk.utils.CallbackEvent
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Shell
;
...
@@ -34,6 +36,7 @@ import java.util.Locale;
...
@@ -34,6 +36,7 @@ import java.util.Locale;
import
butterknife.BindView
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
import
butterknife.ButterKnife
;
import
butterknife.OnClick
;
import
butterknife.Unbinder
;
import
butterknife.Unbinder
;
public
class
InstallFragment
extends
Fragment
implements
CallbackEvent
.
Listener
<
Void
>
{
public
class
InstallFragment
extends
Fragment
implements
CallbackEvent
.
Listener
<
Void
>
{
...
@@ -41,46 +44,51 @@ public class InstallFragment extends Fragment implements CallbackEvent.Listener<
...
@@ -41,46 +44,51 @@ public class InstallFragment extends Fragment implements CallbackEvent.Listener<
private
static
final
String
UNINSTALLER
=
"magisk_uninstaller.sh"
;
private
static
final
String
UNINSTALLER
=
"magisk_uninstaller.sh"
;
private
Unbinder
unbinder
;
@BindView
(
R
.
id
.
current_version_title
)
TextView
currentVersionTitle
;
@BindView
(
R
.
id
.
current_version_title
)
TextView
currentVersionTitle
;
@BindView
(
R
.
id
.
install_title
)
TextView
installTitle
;
@BindView
(
R
.
id
.
install_title
)
TextView
installTitle
;
@BindView
(
R
.
id
.
block_spinner
)
Spinner
spinner
;
@BindView
(
R
.
id
.
block_spinner
)
Spinner
spinner
;
@BindView
(
R
.
id
.
detect_bootimage
)
Button
detectButton
;
@BindView
(
R
.
id
.
detect_bootimage
)
Button
detectButton
;
@BindView
(
R
.
id
.
flash_button
)
CardView
flashButton
;
@BindView
(
R
.
id
.
install_button
)
CardView
installButton
;
@BindView
(
R
.
id
.
install_text
)
TextView
installText
;
@BindView
(
R
.
id
.
uninstall_button
)
CardView
uninstallButton
;
@BindView
(
R
.
id
.
uninstall_button
)
CardView
uninstallButton
;
@BindView
(
R
.
id
.
keep_force_enc
)
CheckBox
keepEncChkbox
;
@BindView
(
R
.
id
.
keep_force_enc
)
CheckBox
keepEncChkbox
;
@BindView
(
R
.
id
.
keep_verity
)
CheckBox
keepVerityChkbox
;
@BindView
(
R
.
id
.
keep_verity
)
CheckBox
keepVerityChkbox
;
@Nullable
@OnClick
(
R
.
id
.
detect_bootimage
)
@Override
public
void
toAutoDetect
()
{
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
if
(
magiskManager
.
bootBlock
!=
null
)
{
View
v
=
inflater
.
inflate
(
R
.
layout
.
fragment_install
,
container
,
false
);
spinner
.
setSelection
(
0
);
unbinder
=
ButterKnife
.
bind
(
this
,
v
);
}
detectButton
.
setOnClickListener
(
v1
->
toAutoDetect
());
}
if
(
getApplication
().
magiskVersion
<
0
)
currentVersionTitle
.
setText
(
getString
(
R
.
string
.
current_magisk_title
,
getString
(
R
.
string
.
version_none
)));
@OnClick
(
R
.
id
.
install_button
)
else
public
void
install
()
{
currentVersionTitle
.
setText
(
getString
(
R
.
string
.
current_magisk_title
,
"v"
+
getApplication
().
magiskVersionString
));
String
bootImage
=
null
;
installTitle
.
setText
(
getString
(
R
.
string
.
install_magisk_title
,
"v"
+
String
.
format
(
Locale
.
US
,
"%.1f"
,
getApplication
().
remoteMagiskVersion
)));
if
(
magiskManager
.
blockList
!=
null
)
{
flashButton
.
setOnClickListener
(
v1
->
{
int
idx
=
spinner
.
getSelectedItemPosition
();
String
bootImage
;
if
(
magiskManager
.
bootBlock
!=
null
)
{
if
(
getApplication
().
bootBlock
!=
null
)
{
if
(
idx
>
0
)
{
if
(
spinner
.
getSelectedItemPosition
()
>
0
)
bootImage
=
magiskManager
.
blockList
.
get
(
idx
-
1
);
bootImage
=
getApplication
().
blockList
.
get
(
spinner
.
getSelectedItemPosition
()
-
1
);
}
else
}
else
{
bootImage
=
getApplication
().
bootBlock
;
if
(
idx
>
0
)
{
bootImage
=
magiskManager
.
blockList
.
get
(
idx
-
1
);
}
else
{
}
else
{
bootImage
=
getApplication
().
blockList
.
get
(
spinner
.
getSelectedItemPosition
());
SnackbarMaker
.
make
(
getActivity
(),
R
.
string
.
manual_boot_image
,
Snackbar
.
LENGTH_LONG
);
}
}
}
}
String
filename
=
"Magisk-v"
+
getApplication
().
remoteMagiskVersion
+
".zip"
;
final
String
finalBootImage
=
bootImage
;
String
filename
=
"Magisk-v"
+
magiskManager
.
remoteMagiskVersion
+
".zip"
;
new
AlertDialogBuilder
(
getActivity
())
new
AlertDialogBuilder
(
getActivity
())
.
setTitle
(
getString
(
R
.
string
.
repo_install_title
,
getString
(
R
.
string
.
magisk
)))
.
setTitle
(
getString
(
R
.
string
.
repo_install_title
,
getString
(
R
.
string
.
magisk
)))
.
setMessage
(
getString
(
R
.
string
.
repo_install_msg
,
filename
))
.
setMessage
(
getString
(
R
.
string
.
repo_install_msg
,
filename
))
.
setCancelable
(
true
)
.
setCancelable
(
true
)
.
setPositiveButton
(
R
.
string
.
install
,
(
dialogInterface
,
i
)
->
Utils
.
dlAndReceive
(
.
setPositiveButton
(
Shell
.
rootAccess
()
?
R
.
string
.
install
:
R
.
string
.
download
,
(
dialogInterface
,
i
)
->
Utils
.
dlAndReceive
(
getActivity
(),
getActivity
(),
new
DownloadReceiver
()
{
new
DownloadReceiver
()
{
private
String
boot
=
b
ootImage
;
private
String
boot
=
finalB
ootImage
;
private
boolean
enc
=
keepEncChkbox
.
isChecked
();
private
boolean
enc
=
keepEncChkbox
.
isChecked
();
private
boolean
verity
=
keepVerityChkbox
.
isChecked
();
private
boolean
verity
=
keepVerityChkbox
.
isChecked
();
...
@@ -89,30 +97,30 @@ public class InstallFragment extends Fragment implements CallbackEvent.Listener<
...
@@ -89,30 +97,30 @@ public class InstallFragment extends Fragment implements CallbackEvent.Listener<
new
ProcessMagiskZip
(
getActivity
(),
uri
,
boot
,
enc
,
verity
).
exec
();
new
ProcessMagiskZip
(
getActivity
(),
uri
,
boot
,
enc
,
verity
).
exec
();
}
}
},
},
getApplication
()
.
magiskLink
,
magiskManager
.
magiskLink
,
Utils
.
getLegalFilename
(
filename
)))
Utils
.
getLegalFilename
(
filename
)))
.
setNeutralButton
(
R
.
string
.
release_notes
,
(
dialog
,
which
)
->
{
.
setNeutralButton
(
R
.
string
.
release_notes
,
(
dialog
,
which
)
->
{
getActivity
().
startActivity
(
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
getApplication
()
.
releaseNoteLink
)));
magiskManager
.
startActivity
(
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
magiskManager
.
releaseNoteLink
)));
})
})
.
setNegativeButton
(
R
.
string
.
no_thanks
,
null
)
.
setNegativeButton
(
R
.
string
.
no_thanks
,
null
)
.
show
();
.
show
();
});
}
if
(
getApplication
().
magiskVersion
<
10.3
)
{
uninstallButton
.
setVisibility
(
View
.
GONE
);
@OnClick
(
R
.
id
.
uninstall_button
)
}
else
{
public
void
uninstall
()
{
uninstallButton
.
setOnClickListener
(
vi
->
{
new
AlertDialogBuilder
(
getActivity
())
new
AlertDialogBuilder
(
getActivity
())
.
setTitle
(
R
.
string
.
uninstall_magisk_title
)
.
setTitle
(
R
.
string
.
uninstall_magisk_title
)
.
setMessage
(
R
.
string
.
uninstall_magisk_msg
)
.
setMessage
(
R
.
string
.
uninstall_magisk_msg
)
.
setPositiveButton
(
R
.
string
.
yes
,
(
dialogInterface
,
i
)
->
{
.
setPositiveButton
(
R
.
string
.
yes
,
(
dialogInterface
,
i
)
->
{
try
{
try
{
InputStream
in
=
getActivity
()
.
getAssets
().
open
(
UNINSTALLER
);
InputStream
in
=
magiskManager
.
getAssets
().
open
(
UNINSTALLER
);
File
uninstaller
=
new
File
(
getActivity
().
getCacheDir
().
getAbsolutePath
()
+
"/"
+
UNINSTALLER
);
File
uninstaller
=
new
File
(
magiskManager
.
getCacheDir
(),
UNINSTALLER
);
FileOutputStream
out
=
new
FileOutputStream
(
uninstaller
);
FileOutputStream
out
=
new
FileOutputStream
(
uninstaller
);
byte
[]
bytes
=
new
byte
[
1024
];
byte
[]
bytes
=
new
byte
[
1024
];
int
read
;
int
read
;
while
((
read
=
in
.
read
(
bytes
))
!=
-
1
)
while
((
read
=
in
.
read
(
bytes
))
!=
-
1
)
{
out
.
write
(
bytes
,
0
,
read
);
out
.
write
(
bytes
,
0
,
read
);
}
in
.
close
();
in
.
close
();
out
.
close
();
out
.
close
();
ProgressDialog
progress
=
new
ProgressDialog
(
getActivity
());
ProgressDialog
progress
=
new
ProgressDialog
(
getActivity
());
...
@@ -127,7 +135,7 @@ public class InstallFragment extends Fragment implements CallbackEvent.Listener<
...
@@ -127,7 +135,7 @@ public class InstallFragment extends Fragment implements CallbackEvent.Listener<
@Override
@Override
public
void
onFinish
()
{
public
void
onFinish
()
{
progress
.
setMessage
(
getString
(
R
.
string
.
reboot_countdown
,
0
));
progress
.
setMessage
(
getString
(
R
.
string
.
reboot_countdown
,
0
));
Shell
.
su
(
true
,
"cp -a
f "
+
uninstaller
+
" /cache/"
+
UNINSTALLER
,
Shell
.
su
(
true
,
"mv -
f "
+
uninstaller
+
" /cache/"
+
UNINSTALLER
,
"reboot"
);
"reboot"
);
}
}
}.
start
();
}.
start
();
...
@@ -137,12 +145,25 @@ public class InstallFragment extends Fragment implements CallbackEvent.Listener<
...
@@ -137,12 +145,25 @@ public class InstallFragment extends Fragment implements CallbackEvent.Listener<
})
})
.
setNegativeButton
(
R
.
string
.
no_thanks
,
null
)
.
setNegativeButton
(
R
.
string
.
no_thanks
,
null
)
.
show
();
.
show
();
});
}
}
if
(
getApplication
().
blockDetectionDone
.
isTriggered
)
{
private
Unbinder
unbinder
;
updateUI
();
private
MagiskManager
magiskManager
;
@Nullable
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
View
v
=
inflater
.
inflate
(
R
.
layout
.
fragment_install
,
container
,
false
);
unbinder
=
ButterKnife
.
bind
(
this
,
v
);
magiskManager
=
getApplication
();
if
(
magiskManager
.
magiskVersion
<
0
)
{
currentVersionTitle
.
setText
(
getString
(
R
.
string
.
current_magisk_title
,
getString
(
R
.
string
.
version_none
)));
}
else
{
currentVersionTitle
.
setText
(
getString
(
R
.
string
.
current_magisk_title
,
"v"
+
magiskManager
.
magiskVersionString
));
}
}
installTitle
.
setText
(
getString
(
R
.
string
.
install_magisk_title
,
"v"
+
String
.
format
(
Locale
.
US
,
"%.1f"
,
magiskManager
.
remoteMagiskVersion
)));
updateUI
();
return
v
;
return
v
;
}
}
...
@@ -152,32 +173,46 @@ public class InstallFragment extends Fragment implements CallbackEvent.Listener<
...
@@ -152,32 +173,46 @@ public class InstallFragment extends Fragment implements CallbackEvent.Listener<
}
}
private
void
updateUI
()
{
private
void
updateUI
()
{
List
<
String
>
items
=
new
ArrayList
<>(
getApplication
().
blockList
);
if
(
magiskManager
.
blockList
==
null
||
!
Shell
.
rootAccess
())
{
if
(
getApplication
().
bootBlock
!=
null
)
uninstallButton
.
setVisibility
(
View
.
GONE
);
items
.
add
(
0
,
getString
(
R
.
string
.
auto_detect
,
getApplication
().
bootBlock
));
installText
.
setText
(
R
.
string
.
download
);
detectButton
.
setEnabled
(
false
);
keepEncChkbox
.
setEnabled
(
false
);
keepVerityChkbox
.
setEnabled
(
false
);
spinner
.
setEnabled
(
false
);
}
else
{
uninstallButton
.
setVisibility
(
magiskManager
.
magiskVersion
>
10.3
?
View
.
VISIBLE
:
View
.
GONE
);
installText
.
setText
(
R
.
string
.
download_install
);
detectButton
.
setEnabled
(
true
);
keepEncChkbox
.
setEnabled
(
true
);
keepVerityChkbox
.
setEnabled
(
true
);
spinner
.
setEnabled
(
true
);
List
<
String
>
items
=
new
ArrayList
<>();
if
(
magiskManager
.
bootBlock
!=
null
)
{
items
.
add
(
getString
(
R
.
string
.
auto_detect
,
magiskManager
.
bootBlock
));
}
else
{
items
.
add
(
getString
(
R
.
string
.
cannot_auto_detect
));
}
items
.
addAll
(
magiskManager
.
blockList
);
ArrayAdapter
<
String
>
adapter
=
new
ArrayAdapter
<>(
getActivity
(),
ArrayAdapter
<
String
>
adapter
=
new
ArrayAdapter
<>(
getActivity
(),
android
.
R
.
layout
.
simple_spinner_item
,
items
);
android
.
R
.
layout
.
simple_spinner_item
,
items
);
adapter
.
setDropDownViewResource
(
android
.
R
.
layout
.
simple_spinner_dropdown_item
);
adapter
.
setDropDownViewResource
(
android
.
R
.
layout
.
simple_spinner_dropdown_item
);
spinner
.
setAdapter
(
adapter
);
spinner
.
setAdapter
(
adapter
);
toAutoDetect
();
toAutoDetect
();
}
}
private
void
toAutoDetect
()
{
if
(
getApplication
().
bootBlock
!=
null
)
{
spinner
.
setSelection
(
0
);
}
}
}
@Override
@Override
public
void
onStart
()
{
public
void
onStart
()
{
super
.
onStart
();
super
.
onStart
();
getActivity
().
setTitle
(
R
.
string
.
install
);
getActivity
().
setTitle
(
R
.
string
.
install
);
getApplication
()
.
blockDetectionDone
.
register
(
this
);
magiskManager
.
blockDetectionDone
.
register
(
this
);
}
}
@Override
@Override
public
void
onStop
()
{
public
void
onStop
()
{
getApplication
()
.
blockDetectionDone
.
unRegister
(
this
);
magiskManager
.
blockDetectionDone
.
unRegister
(
this
);
super
.
onStop
();
super
.
onStop
();
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/MagiskHideFragment.java
View file @
a3f0ef8e
...
@@ -71,8 +71,9 @@ public class MagiskHideFragment extends Fragment implements CallbackEvent.Listen
...
@@ -71,8 +71,9 @@ public class MagiskHideFragment extends Fragment implements CallbackEvent.Listen
}
}
};
};
if
(
getApplication
().
magiskHideDone
.
isTriggered
)
if
(
getApplication
().
magiskHideDone
.
isTriggered
)
{
onTrigger
(
getApplication
().
magiskHideDone
);
onTrigger
(
getApplication
().
magiskHideDone
);
}
return
view
;
return
view
;
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/MagiskLogFragment.java
View file @
a3f0ef8e
...
@@ -162,8 +162,9 @@ public class MagiskLogFragment extends Fragment {
...
@@ -162,8 +162,9 @@ public class MagiskLogFragment extends Fragment {
return
false
;
return
false
;
}
}
if
(!
Environment
.
getExternalStorageState
().
equals
(
Environment
.
MEDIA_MOUNTED
))
if
(!
Environment
.
getExternalStorageState
().
equals
(
Environment
.
MEDIA_MOUNTED
))
{
return
false
;
return
false
;
}
Calendar
now
=
Calendar
.
getInstance
();
Calendar
now
=
Calendar
.
getInstance
();
String
filename
=
String
.
format
(
String
filename
=
String
.
format
(
...
@@ -175,8 +176,9 @@ public class MagiskLogFragment extends Fragment {
...
@@ -175,8 +176,9 @@ public class MagiskLogFragment extends Fragment {
targetFile
=
new
File
(
Environment
.
getExternalStorageDirectory
().
getAbsolutePath
()
+
"/MagiskManager/"
+
filename
);
targetFile
=
new
File
(
Environment
.
getExternalStorageDirectory
().
getAbsolutePath
()
+
"/MagiskManager/"
+
filename
);
if
((!
targetFile
.
getParentFile
().
exists
()
&&
!
targetFile
.
getParentFile
().
mkdirs
())
if
((!
targetFile
.
getParentFile
().
exists
()
&&
!
targetFile
.
getParentFile
().
mkdirs
())
||
(
targetFile
.
exists
()
&&
!
targetFile
.
delete
()))
||
(
targetFile
.
exists
()
&&
!
targetFile
.
delete
()))
{
return
false
;
return
false
;
}
List
<
String
>
in
=
Utils
.
readFile
(
MAGISK_LOG
);
List
<
String
>
in
=
Utils
.
readFile
(
MAGISK_LOG
);
...
@@ -214,10 +216,11 @@ public class MagiskLogFragment extends Fragment {
...
@@ -214,10 +216,11 @@ public class MagiskLogFragment extends Fragment {
break
;
break
;
case
2
:
case
2
:
bool
=
(
boolean
)
o
;
bool
=
(
boolean
)
o
;
if
(
bool
)
if
(
bool
)
{
Toast
.
makeText
(
getActivity
(),
targetFile
.
toString
(),
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
getActivity
(),
targetFile
.
toString
(),
Toast
.
LENGTH_LONG
).
show
();
else
}
else
{
Toast
.
makeText
(
getActivity
(),
getString
(
R
.
string
.
logs_save_failed
),
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
getActivity
(),
getString
(
R
.
string
.
logs_save_failed
),
Toast
.
LENGTH_LONG
).
show
();
}
break
;
break
;
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/MagiskManager.java
View file @
a3f0ef8e
...
@@ -125,9 +125,9 @@ public class MagiskManager extends Application {
...
@@ -125,9 +125,9 @@ public class MagiskManager extends Application {
}
}
if
(
isSuClient
)
{
if
(
isSuClient
)
{
ret
=
Shell
.
sh
(
"getprop persist.sys.root_access"
);
ret
=
Shell
.
sh
(
"getprop persist.sys.root_access"
);
if
(
Utils
.
isValidShellResponse
(
ret
))
if
(
Utils
.
isValidShellResponse
(
ret
))
{
suAccessState
=
Integer
.
parseInt
(
ret
.
get
(
0
));
suAccessState
=
Integer
.
parseInt
(
ret
.
get
(
0
));
else
{
}
else
{
Shell
.
su
(
true
,
"setprop persist.sys.root_access 3"
);
Shell
.
su
(
true
,
"setprop persist.sys.root_access 3"
);
suAccessState
=
3
;
suAccessState
=
3
;
}
}
...
@@ -160,8 +160,9 @@ public class MagiskManager extends Application {
...
@@ -160,8 +160,9 @@ public class MagiskManager extends Application {
magiskHideStarted
=
false
;
magiskHideStarted
=
false
;
}
}
if
(
!
magiskHide
&&
magiskHideStarted
)
if
(
magiskHideStarted
)
{
magiskHide
=
true
;
magiskHide
=
true
;
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/MainActivity.java
View file @
a3f0ef8e
...
@@ -131,14 +131,16 @@ public class MainActivity extends Activity
...
@@ -131,14 +131,16 @@ public class MainActivity extends Activity
private
void
checkHideSection
()
{
private
void
checkHideSection
()
{
Menu
menu
=
navigationView
.
getMenu
();
Menu
menu
=
navigationView
.
getMenu
();
if
(
Shell
.
rootAccess
())
{
menu
.
findItem
(
R
.
id
.
magiskhide
).
setVisible
(
menu
.
findItem
(
R
.
id
.
magiskhide
).
setVisible
(
getApplicationContext
().
magiskVersion
>=
8
&&
prefs
.
getBoolean
(
"magiskhide"
,
false
));
Shell
.
rootAccess
()
&&
getApplicationContext
().
magiskVersion
>=
8
menu
.
findItem
(
R
.
id
.
modules
).
setVisible
(
getApplicationContext
().
magiskVersion
>=
4
);
&&
prefs
.
getBoolean
(
"magiskhide"
,
false
));
menu
.
findItem
(
R
.
id
.
downloads
).
setVisible
(
getApplicationContext
().
magiskVersion
>=
4
);
menu
.
findItem
(
R
.
id
.
modules
).
setVisible
(
menu
.
findItem
(
R
.
id
.
log
).
setVisible
(
true
);
Shell
.
rootAccess
()
&&
getApplicationContext
().
magiskVersion
>=
4
);
menu
.
findItem
(
R
.
id
.
superuser
).
setVisible
(
getApplicationContext
().
isSuClient
);
menu
.
findItem
(
R
.
id
.
downloads
).
setVisible
(
}
Shell
.
rootAccess
()
&&
getApplicationContext
().
magiskVersion
>=
4
);
menu
.
findItem
(
R
.
id
.
log
).
setVisible
(
Shell
.
rootAccess
());
menu
.
findItem
(
R
.
id
.
superuser
).
setVisible
(
Shell
.
rootAccess
()
&&
getApplicationContext
().
isSuClient
);
menu
.
findItem
(
R
.
id
.
install
).
setVisible
(
getApplicationContext
().
remoteMagiskVersion
>
0
);
menu
.
findItem
(
R
.
id
.
install
).
setVisible
(
getApplicationContext
().
remoteMagiskVersion
>
0
);
}
}
...
@@ -179,6 +181,7 @@ public class MainActivity extends Activity
...
@@ -179,6 +181,7 @@ public class MainActivity extends Activity
}
}
public
void
navigate
(
int
itemId
)
{
public
void
navigate
(
int
itemId
)
{
int
bak
=
mDrawerItem
;
mDrawerItem
=
itemId
;
mDrawerItem
=
itemId
;
navigationView
.
setCheckedItem
(
itemId
);
navigationView
.
setCheckedItem
(
itemId
);
switch
(
itemId
)
{
switch
(
itemId
)
{
...
@@ -205,9 +208,11 @@ public class MainActivity extends Activity
...
@@ -205,9 +208,11 @@ public class MainActivity extends Activity
break
;
break
;
case
R
.
id
.
settings
:
case
R
.
id
.
settings
:
startActivity
(
new
Intent
(
this
,
SettingsActivity
.
class
));
startActivity
(
new
Intent
(
this
,
SettingsActivity
.
class
));
mDrawerItem
=
bak
;
break
;
break
;
case
R
.
id
.
app_about
:
case
R
.
id
.
app_about
:
startActivity
(
new
Intent
(
this
,
AboutActivity
.
class
));
startActivity
(
new
Intent
(
this
,
AboutActivity
.
class
));
mDrawerItem
=
bak
;
break
;
break
;
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/ReposFragment.java
View file @
a3f0ef8e
...
@@ -133,10 +133,11 @@ public class ReposFragment extends Fragment implements CallbackEvent.Listener<Vo
...
@@ -133,10 +133,11 @@ public class ReposFragment extends Fragment implements CallbackEvent.Listener<Vo
for
(
Repo
repo
:
getApplication
().
repoMap
.
values
())
{
for
(
Repo
repo
:
getApplication
().
repoMap
.
values
())
{
Module
module
=
getApplication
().
moduleMap
.
get
(
repo
.
getId
());
Module
module
=
getApplication
().
moduleMap
.
get
(
repo
.
getId
());
if
(
module
!=
null
)
{
if
(
module
!=
null
)
{
if
(
repo
.
getVersionCode
()
>
module
.
getVersionCode
())
if
(
repo
.
getVersionCode
()
>
module
.
getVersionCode
())
{
mUpdateRepos
.
add
(
repo
);
mUpdateRepos
.
add
(
repo
);
else
}
else
{
mInstalledRepos
.
add
(
repo
);
mInstalledRepos
.
add
(
repo
);
}
}
else
{
}
else
{
mOthersRepos
.
add
(
repo
);
mOthersRepos
.
add
(
repo
);
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java
View file @
a3f0ef8e
...
@@ -112,10 +112,12 @@ public class SettingsActivity extends Activity {
...
@@ -112,10 +112,12 @@ public class SettingsActivity extends Activity {
prefScreen
.
removePreference
(
magiskCategory
);
prefScreen
.
removePreference
(
magiskCategory
);
prefScreen
.
removePreference
(
suCategory
);
prefScreen
.
removePreference
(
suCategory
);
}
else
{
}
else
{
if
(!
getApplication
().
isSuClient
)
if
(!
getApplication
().
isSuClient
)
{
prefScreen
.
removePreference
(
suCategory
);
prefScreen
.
removePreference
(
suCategory
);
if
(
getApplication
().
magiskVersion
<
11
)
}
if
(
getApplication
().
magiskVersion
<
11
)
{
prefScreen
.
removePreference
(
magiskCategory
);
prefScreen
.
removePreference
(
magiskCategory
);
}
if
(
getApplication
().
disabled
)
{
if
(
getApplication
().
disabled
)
{
busybox
.
setEnabled
(
false
);
busybox
.
setEnabled
(
false
);
magiskHide
.
setEnabled
(
false
);
magiskHide
.
setEnabled
(
false
);
...
@@ -146,8 +148,8 @@ public class SettingsActivity extends Activity {
...
@@ -146,8 +148,8 @@ public class SettingsActivity extends Activity {
enabled
=
prefs
.
getBoolean
(
"dark_theme"
,
false
);
enabled
=
prefs
.
getBoolean
(
"dark_theme"
,
false
);
if
(
getApplication
().
isDarkTheme
!=
enabled
)
{
if
(
getApplication
().
isDarkTheme
!=
enabled
)
{
getApplication
().
isDarkTheme
=
enabled
;
getApplication
().
isDarkTheme
=
enabled
;
getActivity
().
finish
();
getApplication
().
reloadMainActivity
.
trigger
();
getApplication
().
reloadMainActivity
.
trigger
();
getActivity
().
recreate
();
}
}
break
;
break
;
case
"disable"
:
case
"disable"
:
...
@@ -195,9 +197,12 @@ public class SettingsActivity extends Activity {
...
@@ -195,9 +197,12 @@ public class SettingsActivity extends Activity {
.
setPositiveButton
(
R
.
string
.
understand
,
(
dialog
,
which
)
->
new
MagiskHide
().
enable
())
.
setPositiveButton
(
R
.
string
.
understand
,
(
dialog
,
which
)
->
new
MagiskHide
().
enable
())
.
setCancelable
(
false
)
.
setCancelable
(
false
)
.
show
();
.
show
();
}
else
new
MagiskHide
().
enable
();
}
else
{
}
else
new
MagiskHide
().
enable
();
}
}
else
{
new
MagiskHide
().
disable
();
new
MagiskHide
().
disable
();
}
break
;
break
;
case
"hosts"
:
case
"hosts"
:
enabled
=
prefs
.
getBoolean
(
"hosts"
,
false
);
enabled
=
prefs
.
getBoolean
(
"hosts"
,
false
);
...
...
app/src/main/java/com/topjohnwu/magisk/StatusFragment.java
View file @
a3f0ef8e
...
@@ -22,6 +22,7 @@ import com.topjohnwu.magisk.utils.Utils;
...
@@ -22,6 +22,7 @@ import com.topjohnwu.magisk.utils.Utils;
import
butterknife.BindColor
;
import
butterknife.BindColor
;
import
butterknife.BindView
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
import
butterknife.ButterKnife
;
import
butterknife.OnClick
;
import
butterknife.Unbinder
;
import
butterknife.Unbinder
;
public
class
StatusFragment
extends
Fragment
implements
CallbackEvent
.
Listener
<
Void
>
{
public
class
StatusFragment
extends
Fragment
implements
CallbackEvent
.
Listener
<
Void
>
{
...
@@ -53,7 +54,27 @@ public class StatusFragment extends Fragment implements CallbackEvent.Listener<V
...
@@ -53,7 +54,27 @@ public class StatusFragment extends Fragment implements CallbackEvent.Listener<V
@BindColor
(
R
.
color
.
grey500
)
int
colorNeutral
;
@BindColor
(
R
.
color
.
grey500
)
int
colorNeutral
;
@BindColor
(
R
.
color
.
blue500
)
int
colorInfo
;
@BindColor
(
R
.
color
.
blue500
)
int
colorInfo
;
@BindColor
(
android
.
R
.
color
.
transparent
)
int
trans
;
@BindColor
(
android
.
R
.
color
.
transparent
)
int
trans
;
int
defaultColor
;
@OnClick
(
R
.
id
.
safetyNet_container
)
public
void
safetyNet
()
{
safetyNetProgress
.
setVisibility
(
View
.
VISIBLE
);
safetyNetContainer
.
setBackgroundColor
(
trans
);
safetyNetIcon
.
setImageResource
(
0
);
safetyNetStatusText
.
setText
(
R
.
string
.
checking_safetyNet_status
);
Utils
.
checkSafetyNet
(
getApplication
());
}
@OnClick
(
R
.
id
.
magisk_status_container
)
public
void
magisk
()
{
((
MainActivity
)
getActivity
()).
navigationView
.
setCheckedItem
(
R
.
id
.
install
);
FragmentTransaction
transaction
=
getFragmentManager
().
beginTransaction
();
transaction
.
setCustomAnimations
(
android
.
R
.
anim
.
fade_in
,
android
.
R
.
anim
.
fade_out
);
try
{
transaction
.
replace
(
R
.
id
.
content_frame
,
new
InstallFragment
(),
"install"
).
commit
();
}
catch
(
IllegalStateException
ignored
)
{}
}
private
int
defaultColor
;
@Nullable
@Nullable
@Override
@Override
...
@@ -83,23 +104,6 @@ public class StatusFragment extends Fragment implements CallbackEvent.Listener<V
...
@@ -83,23 +104,6 @@ public class StatusFragment extends Fragment implements CallbackEvent.Listener<V
new
CheckUpdates
(
getActivity
()).
exec
();
new
CheckUpdates
(
getActivity
()).
exec
();
});
});
safetyNetContainer
.
setOnClickListener
(
view
->
{
safetyNetProgress
.
setVisibility
(
View
.
VISIBLE
);
safetyNetContainer
.
setBackgroundColor
(
trans
);
safetyNetIcon
.
setImageResource
(
0
);
safetyNetStatusText
.
setText
(
R
.
string
.
checking_safetyNet_status
);
Utils
.
checkSafetyNet
(
getApplication
());
});
magiskStatusContainer
.
setOnClickListener
(
view
->
{
((
MainActivity
)
getActivity
()).
navigationView
.
setCheckedItem
(
R
.
id
.
install
);
FragmentTransaction
transaction
=
getFragmentManager
().
beginTransaction
();
transaction
.
setCustomAnimations
(
android
.
R
.
anim
.
fade_in
,
android
.
R
.
anim
.
fade_out
);
try
{
transaction
.
replace
(
R
.
id
.
content_frame
,
new
InstallFragment
(),
"install"
).
commit
();
}
catch
(
IllegalStateException
ignored
)
{}
});
if
(
getApplication
().
magiskVersion
<
0
&&
Shell
.
rootAccess
()
&&
!
noDialog
)
{
if
(
getApplication
().
magiskVersion
<
0
&&
Shell
.
rootAccess
()
&&
!
noDialog
)
{
noDialog
=
true
;
noDialog
=
true
;
new
AlertDialogBuilder
(
getActivity
())
new
AlertDialogBuilder
(
getActivity
())
...
...
app/src/main/java/com/topjohnwu/magisk/adapters/SuLogAdapter.java
View file @
a3f0ef8e
...
@@ -109,7 +109,9 @@ public class SuLogAdapter {
...
@@ -109,7 +109,9 @@ public class SuLogAdapter {
@Override
@Override
public
void
onBindGroupViewHolder
(
LogGroupViewHolder
holder
,
int
flatPosition
,
ExpandableGroup
group
)
{
public
void
onBindGroupViewHolder
(
LogGroupViewHolder
holder
,
int
flatPosition
,
ExpandableGroup
group
)
{
holder
.
date
.
setText
(
group
.
getTitle
());
holder
.
date
.
setText
(
group
.
getTitle
());
if
(
isGroupExpanded
(
flatPosition
))
holder
.
expand
();
if
(
isGroupExpanded
(
flatPosition
))
{
holder
.
expand
();
}
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/asyncs/GetBootBlocks.java
View file @
a3f0ef8e
...
@@ -13,9 +13,8 @@ public class GetBootBlocks extends SerialTask<Void, Void, Void> {
...
@@ -13,9 +13,8 @@ public class GetBootBlocks extends SerialTask<Void, Void, Void> {
@Override
@Override
protected
Void
doInBackground
(
Void
...
params
)
{
protected
Void
doInBackground
(
Void
...
params
)
{
if
(
Shell
.
rootAccess
())
{
magiskManager
.
blockList
=
Shell
.
su
(
"ls /dev/block | grep mmc"
);
magiskManager
.
blockList
=
Shell
.
su
(
"ls /dev/block | grep mmc"
);
if
(
magiskManager
.
bootBlock
==
null
)
if
(
magiskManager
.
bootBlock
==
null
)
{
magiskManager
.
bootBlock
=
Utils
.
detectBootImage
();
magiskManager
.
bootBlock
=
Utils
.
detectBootImage
();
}
}
return
null
;
return
null
;
...
...
app/src/main/java/com/topjohnwu/magisk/asyncs/LoadApps.java
View file @
a3f0ef8e
...
@@ -22,9 +22,10 @@ public class LoadApps extends ParallelTask<Void, Void, Void> {
...
@@ -22,9 +22,10 @@ public class LoadApps extends ParallelTask<Void, Void, Void> {
List
<
ApplicationInfo
>
list
=
pm
.
getInstalledApplications
(
0
);
List
<
ApplicationInfo
>
list
=
pm
.
getInstalledApplications
(
0
);
for
(
Iterator
<
ApplicationInfo
>
i
=
list
.
iterator
();
i
.
hasNext
();
)
{
for
(
Iterator
<
ApplicationInfo
>
i
=
list
.
iterator
();
i
.
hasNext
();
)
{
ApplicationInfo
info
=
i
.
next
();
ApplicationInfo
info
=
i
.
next
();
if
(
ApplicationAdapter
.
BLACKLIST
.
contains
(
info
.
packageName
)
||
!
info
.
enabled
)
if
(
ApplicationAdapter
.
BLACKLIST
.
contains
(
info
.
packageName
)
||
!
info
.
enabled
)
{
i
.
remove
();
i
.
remove
();
}
}
}
Collections
.
sort
(
list
,
(
a
,
b
)
->
a
.
loadLabel
(
pm
).
toString
().
toLowerCase
()
Collections
.
sort
(
list
,
(
a
,
b
)
->
a
.
loadLabel
(
pm
).
toString
().
toLowerCase
()
.
compareTo
(
b
.
loadLabel
(
pm
).
toString
().
toLowerCase
()));
.
compareTo
(
b
.
loadLabel
(
pm
).
toString
().
toLowerCase
()));
magiskManager
.
appList
=
Collections
.
unmodifiableList
(
list
);
magiskManager
.
appList
=
Collections
.
unmodifiableList
(
list
);
...
...
app/src/main/java/com/topjohnwu/magisk/asyncs/LoadRepos.java
View file @
a3f0ef8e
...
@@ -96,8 +96,9 @@ public class LoadRepos extends ParallelTask<Void, Void, Void> {
...
@@ -96,8 +96,9 @@ public class LoadRepos extends ParallelTask<Void, Void, Void> {
Logger
.
dev
(
"LoadRepos: Update cached repo "
+
id
);
Logger
.
dev
(
"LoadRepos: Update cached repo "
+
id
);
repo
.
update
(
updatedDate
);
repo
.
update
(
updatedDate
);
}
}
if
(
repo
.
getId
()
!=
null
)
if
(
repo
.
getId
()
!=
null
)
{
magiskManager
.
repoMap
.
put
(
id
,
repo
);
magiskManager
.
repoMap
.
put
(
id
,
repo
);
}
}
catch
(
BaseModule
.
CacheModException
ignored
)
{}
}
catch
(
BaseModule
.
CacheModException
ignored
)
{}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/asyncs/MagiskHide.java
View file @
a3f0ef8e
...
@@ -21,16 +21,18 @@ public class MagiskHide extends SerialTask<Object, Void, Void> {
...
@@ -21,16 +21,18 @@ public class MagiskHide extends SerialTask<Object, Void, Void> {
protected
Void
doInBackground
(
Object
...
params
)
{
protected
Void
doInBackground
(
Object
...
params
)
{
String
command
=
(
String
)
params
[
0
];
String
command
=
(
String
)
params
[
0
];
List
<
String
>
ret
=
Shell
.
su
(
MagiskManager
.
MAGISK_HIDE_PATH
+
command
);
List
<
String
>
ret
=
Shell
.
su
(
MagiskManager
.
MAGISK_HIDE_PATH
+
command
);
if
(
isList
)
if
(
isList
)
{
magiskManager
.
magiskHideList
=
ret
;
magiskManager
.
magiskHideList
=
ret
;
}
return
null
;
return
null
;
}
}
@Override
@Override
protected
void
onPostExecute
(
Void
v
)
{
protected
void
onPostExecute
(
Void
v
)
{
if
(
isList
)
if
(
isList
)
{
magiskManager
.
magiskHideDone
.
trigger
();
magiskManager
.
magiskHideDone
.
trigger
();
}
}
}
public
void
add
(
CharSequence
packageName
)
{
public
void
add
(
CharSequence
packageName
)
{
exec
(
"add "
+
packageName
);
exec
(
"add "
+
packageName
);
...
@@ -50,8 +52,7 @@ public class MagiskHide extends SerialTask<Object, Void, Void> {
...
@@ -50,8 +52,7 @@ public class MagiskHide extends SerialTask<Object, Void, Void> {
public
void
list
()
{
public
void
list
()
{
isList
=
true
;
isList
=
true
;
if
(
magiskManager
==
null
)
if
(
magiskManager
==
null
)
return
;
return
;
exec
(
"list"
);
exec
(
"list"
);
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/asyncs/ProcessMagiskZip.java
View file @
a3f0ef8e
...
@@ -45,7 +45,8 @@ public class ProcessMagiskZip extends ParallelTask<Void, Void, Boolean> {
...
@@ -45,7 +45,8 @@ public class ProcessMagiskZip extends ParallelTask<Void, Void, Boolean> {
ZipUtils
.
unzip
(
magiskManager
.
getContentResolver
().
openInputStream
(
mUri
),
tempdir
);
ZipUtils
.
unzip
(
magiskManager
.
getContentResolver
().
openInputStream
(
mUri
),
tempdir
);
// Running in parallel mode, open new shell
// Running in parallel mode, open new shell
Shell
.
su
(
true
,
Shell
.
su
(
true
,
"echo \"BOOTIMAGE=/dev/block/"
+
mBoot
+
"\" > /dev/.magisk"
,
"rm -f /dev/.magisk"
,
(
mBoot
!=
null
)
?
"echo \"BOOTIMAGE=/dev/block/"
+
mBoot
+
"\" >> /dev/.magisk"
:
""
,
"echo \"KEEPFORCEENCRYPT="
+
String
.
valueOf
(
mEnc
)
+
"\" >> /dev/.magisk"
,
"echo \"KEEPFORCEENCRYPT="
+
String
.
valueOf
(
mEnc
)
+
"\" >> /dev/.magisk"
,
"echo \"KEEPVERITY="
+
String
.
valueOf
(
mVerity
)
+
"\" >> /dev/.magisk"
,
"echo \"KEEPVERITY="
+
String
.
valueOf
(
mVerity
)
+
"\" >> /dev/.magisk"
,
"mkdir -p "
+
MagiskManager
.
TMP_FOLDER_PATH
,
"mkdir -p "
+
MagiskManager
.
TMP_FOLDER_PATH
,
...
@@ -66,13 +67,14 @@ public class ProcessMagiskZip extends ParallelTask<Void, Void, Boolean> {
...
@@ -66,13 +67,14 @@ public class ProcessMagiskZip extends ParallelTask<Void, Void, Boolean> {
@Override
@Override
protected
void
onPostExecute
(
Boolean
result
)
{
protected
void
onPostExecute
(
Boolean
result
)
{
progressDialog
.
dismiss
();
progressDialog
.
dismiss
();
if
(
result
)
if
(
result
)
{
new
FlashZip
(
activity
,
mUri
)
{
new
FlashZip
(
activity
,
mUri
)
{
@Override
@Override
protected
boolean
unzipAndCheck
()
throws
Exception
{
protected
boolean
unzipAndCheck
()
throws
Exception
{
// Don't need to check, as it is downloaded in correct form
// Don't need to check, as it is downloaded in correct form
return
true
;
return
true
;
}
}
@Override
@Override
protected
void
onSuccess
()
{
protected
void
onSuccess
()
{
new
SerialTask
<
Void
,
Void
,
Void
>(
activity
)
{
new
SerialTask
<
Void
,
Void
,
Void
>(
activity
)
{
...
@@ -87,7 +89,8 @@ public class ProcessMagiskZip extends ParallelTask<Void, Void, Boolean> {
...
@@ -87,7 +89,8 @@ public class ProcessMagiskZip extends ParallelTask<Void, Void, Boolean> {
super
.
onSuccess
();
super
.
onSuccess
();
}
}
}.
exec
();
}.
exec
();
else
}
else
{
Utils
.
showUriSnack
(
activity
,
mUri
);
Utils
.
showUriSnack
(
activity
,
mUri
);
}
}
}
}
}
app/src/main/java/com/topjohnwu/magisk/asyncs/ProcessRepoZip.java
View file @
a3f0ef8e
...
@@ -103,10 +103,11 @@ public class ProcessRepoZip extends ParallelTask<Void, Void, Boolean> {
...
@@ -103,10 +103,11 @@ public class ProcessRepoZip extends ParallelTask<Void, Void, Boolean> {
protected
void
onPostExecute
(
Boolean
result
)
{
protected
void
onPostExecute
(
Boolean
result
)
{
progressDialog
.
dismiss
();
progressDialog
.
dismiss
();
if
(
result
)
{
if
(
result
)
{
if
(
Shell
.
rootAccess
()
&&
mInstall
)
if
(
Shell
.
rootAccess
()
&&
mInstall
)
{
new
FlashZip
(
activity
,
mUri
).
exec
();
new
FlashZip
(
activity
,
mUri
).
exec
();
else
}
else
{
Utils
.
showUriSnack
(
activity
,
mUri
);
Utils
.
showUriSnack
(
activity
,
mUri
);
}
}
else
{
}
else
{
Toast
.
makeText
(
activity
,
R
.
string
.
process_error
,
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
activity
,
R
.
string
.
process_error
,
Toast
.
LENGTH_LONG
).
show
();
...
...
app/src/main/java/com/topjohnwu/magisk/components/AlertDialogBuilder.java
View file @
a3f0ef8e
...
@@ -93,8 +93,9 @@ public class AlertDialogBuilder extends AlertDialog.Builder {
...
@@ -93,8 +93,9 @@ public class AlertDialogBuilder extends AlertDialog.Builder {
positive
.
setText
(
text
);
positive
.
setText
(
text
);
positiveListener
=
listener
;
positiveListener
=
listener
;
positive
.
setOnClickListener
((
v
)
->
{
positive
.
setOnClickListener
((
v
)
->
{
if
(
positiveListener
!=
null
)
if
(
positiveListener
!=
null
)
{
positiveListener
.
onClick
(
dialog
,
DialogInterface
.
BUTTON_POSITIVE
);
positiveListener
.
onClick
(
dialog
,
DialogInterface
.
BUTTON_POSITIVE
);
}
dialog
.
dismiss
();
dialog
.
dismiss
();
});
});
return
this
;
return
this
;
...
@@ -112,8 +113,9 @@ public class AlertDialogBuilder extends AlertDialog.Builder {
...
@@ -112,8 +113,9 @@ public class AlertDialogBuilder extends AlertDialog.Builder {
negative
.
setText
(
text
);
negative
.
setText
(
text
);
negativeListener
=
listener
;
negativeListener
=
listener
;
negative
.
setOnClickListener
((
v
)
->
{
negative
.
setOnClickListener
((
v
)
->
{
if
(
negativeListener
!=
null
)
if
(
negativeListener
!=
null
)
{
negativeListener
.
onClick
(
dialog
,
DialogInterface
.
BUTTON_NEGATIVE
);
negativeListener
.
onClick
(
dialog
,
DialogInterface
.
BUTTON_NEGATIVE
);
}
dialog
.
dismiss
();
dialog
.
dismiss
();
});
});
return
this
;
return
this
;
...
@@ -131,8 +133,9 @@ public class AlertDialogBuilder extends AlertDialog.Builder {
...
@@ -131,8 +133,9 @@ public class AlertDialogBuilder extends AlertDialog.Builder {
neutral
.
setText
(
text
);
neutral
.
setText
(
text
);
neutralListener
=
listener
;
neutralListener
=
listener
;
neutral
.
setOnClickListener
((
v
)
->
{
neutral
.
setOnClickListener
((
v
)
->
{
if
(
neutralListener
!=
null
)
if
(
neutralListener
!=
null
)
{
neutralListener
.
onClick
(
dialog
,
DialogInterface
.
BUTTON_NEUTRAL
);
neutralListener
.
onClick
(
dialog
,
DialogInterface
.
BUTTON_NEUTRAL
);
}
dialog
.
dismiss
();
dialog
.
dismiss
();
});
});
return
this
;
return
this
;
...
...
app/src/main/java/com/topjohnwu/magisk/components/SnackbarMaker.java
View file @
a3f0ef8e
...
@@ -3,7 +3,6 @@ package com.topjohnwu.magisk.components;
...
@@ -3,7 +3,6 @@ package com.topjohnwu.magisk.components;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.support.annotation.StringRes
;
import
android.support.annotation.StringRes
;
import
android.support.design.widget.Snackbar
;
import
android.support.design.widget.Snackbar
;
import
android.text.TextUtils
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.TextView
;
import
android.widget.TextView
;
...
@@ -34,8 +33,7 @@ public class SnackbarMaker {
...
@@ -34,8 +33,7 @@ public class SnackbarMaker {
private
static
void
setup
(
Snackbar
snack
)
{
private
static
void
setup
(
Snackbar
snack
)
{
TextView
text
=
ButterKnife
.
findById
(
snack
.
getView
(),
android
.
support
.
design
.
R
.
id
.
snackbar_text
);
TextView
text
=
ButterKnife
.
findById
(
snack
.
getView
(),
android
.
support
.
design
.
R
.
id
.
snackbar_text
);
text
.
setMaxLines
(
2
);
text
.
setMaxLines
(
Integer
.
MAX_VALUE
);
text
.
setEllipsize
(
TextUtils
.
TruncateAt
.
START
);
}
}
}
}
app/src/main/java/com/topjohnwu/magisk/database/RepoDatabaseHelper.java
View file @
a3f0ef8e
...
@@ -40,8 +40,9 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
...
@@ -40,8 +40,9 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
public
void
addRepoMap
(
ValueSortedMap
<
String
,
Repo
>
map
)
{
public
void
addRepoMap
(
ValueSortedMap
<
String
,
Repo
>
map
)
{
SQLiteDatabase
db
=
getWritableDatabase
();
SQLiteDatabase
db
=
getWritableDatabase
();
Collection
<
Repo
>
list
=
map
.
values
();
Collection
<
Repo
>
list
=
map
.
values
();
for
(
Repo
repo
:
list
)
for
(
Repo
repo
:
list
)
{
db
.
replace
(
TABLE_NAME
,
null
,
repo
.
getContentValues
());
db
.
replace
(
TABLE_NAME
,
null
,
repo
.
getContentValues
());
}
db
.
close
();
db
.
close
();
}
}
...
@@ -54,8 +55,9 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
...
@@ -54,8 +55,9 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
public
void
removeRepo
(
ValueSortedMap
<
String
,
Repo
>
map
)
{
public
void
removeRepo
(
ValueSortedMap
<
String
,
Repo
>
map
)
{
SQLiteDatabase
db
=
getWritableDatabase
();
SQLiteDatabase
db
=
getWritableDatabase
();
Collection
<
Repo
>
list
=
map
.
values
();
Collection
<
Repo
>
list
=
map
.
values
();
for
(
Repo
repo
:
list
)
for
(
Repo
repo
:
list
)
{
db
.
delete
(
TABLE_NAME
,
"id=?"
,
new
String
[]
{
repo
.
getId
()
});
db
.
delete
(
TABLE_NAME
,
"id=?"
,
new
String
[]
{
repo
.
getId
()
});
}
db
.
close
();
db
.
close
();
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/database/SuDatabaseHelper.java
View file @
a3f0ef8e
...
@@ -22,15 +22,18 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
...
@@ -22,15 +22,18 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
@Override
@Override
public
void
onCreate
(
SQLiteDatabase
db
)
{
public
void
onCreate
(
SQLiteDatabase
db
)
{
onUpgrade
(
db
,
0
,
DATABASE_VER
);
}
@Override
public
void
onUpgrade
(
SQLiteDatabase
db
,
int
oldVersion
,
int
newVersion
)
{
if
(
oldVersion
==
0
)
{
db
.
execSQL
(
db
.
execSQL
(
"CREATE TABLE IF NOT EXISTS "
+
TABLE_NAME
+
" "
+
"CREATE TABLE IF NOT EXISTS "
+
TABLE_NAME
+
" "
+
"(uid INT, package_name TEXT, app_name TEXT, policy INT, "
+
"(uid INT, package_name TEXT, app_name TEXT, policy INT, "
+
"until INT, logging INT, notification INT, "
+
"until INT, logging INT, notification INT, "
+
"PRIMARY KEY(uid))"
);
"PRIMARY KEY(uid))"
);
}
}
@Override
public
void
onUpgrade
(
SQLiteDatabase
db
,
int
oldVersion
,
int
newVersion
)
{
// Currently new database, no upgrading
// Currently new database, no upgrading
}
}
...
@@ -45,9 +48,10 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
...
@@ -45,9 +48,10 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
Policy
policy
=
null
;
Policy
policy
=
null
;
SQLiteDatabase
db
=
getReadableDatabase
();
SQLiteDatabase
db
=
getReadableDatabase
();
try
(
Cursor
c
=
db
.
query
(
TABLE_NAME
,
null
,
"uid=?"
,
new
String
[]
{
String
.
valueOf
(
uid
)
},
null
,
null
,
null
))
{
try
(
Cursor
c
=
db
.
query
(
TABLE_NAME
,
null
,
"uid=?"
,
new
String
[]
{
String
.
valueOf
(
uid
)
},
null
,
null
,
null
))
{
if
(
c
.
moveToNext
())
if
(
c
.
moveToNext
())
{
policy
=
new
Policy
(
c
);
policy
=
new
Policy
(
c
);
}
}
}
db
.
close
();
db
.
close
();
return
policy
;
return
policy
;
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/database/SuLogDatabaseHelper.java
View file @
a3f0ef8e
...
@@ -25,14 +25,17 @@ public class SuLogDatabaseHelper extends SQLiteOpenHelper {
...
@@ -25,14 +25,17 @@ public class SuLogDatabaseHelper extends SQLiteOpenHelper {
@Override
@Override
public
void
onCreate
(
SQLiteDatabase
db
)
{
public
void
onCreate
(
SQLiteDatabase
db
)
{
onUpgrade
(
db
,
0
,
DATABASE_VER
);
}
@Override
public
void
onUpgrade
(
SQLiteDatabase
db
,
int
oldVersion
,
int
newVersion
)
{
if
(
oldVersion
==
0
)
{
db
.
execSQL
(
db
.
execSQL
(
"CREATE TABLE IF NOT EXISTS "
+
TABLE_NAME
+
" (id INTEGER PRIMARY KEY AUTOINCREMENT, "
+
"CREATE TABLE IF NOT EXISTS "
+
TABLE_NAME
+
" (id INTEGER PRIMARY KEY AUTOINCREMENT, "
+
"from_uid INT, package_name TEXT, app_name TEXT, from_pid INT, "
+
"from_uid INT, package_name TEXT, app_name TEXT, from_pid INT, "
+
"to_uid INT, action INT, time INT, command TEXT)"
);
"to_uid INT, action INT, time INT, command TEXT)"
);
}
}
@Override
public
void
onUpgrade
(
SQLiteDatabase
db
,
int
oldVersion
,
int
newVersion
)
{
// Currently new database, no upgrading
// Currently new database, no upgrading
}
}
...
@@ -63,9 +66,10 @@ public class SuLogDatabaseHelper extends SQLiteOpenHelper {
...
@@ -63,9 +66,10 @@ public class SuLogDatabaseHelper extends SQLiteOpenHelper {
db
.
delete
(
TABLE_NAME
,
"time < ?"
,
new
String
[]
{
String
.
valueOf
(
db
.
delete
(
TABLE_NAME
,
"time < ?"
,
new
String
[]
{
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
-
magiskManager
.
suLogTimeout
*
86400
)
});
System
.
currentTimeMillis
()
/
1000
-
magiskManager
.
suLogTimeout
*
86400
)
});
try
(
Cursor
c
=
db
.
query
(
TABLE_NAME
,
null
,
selection
,
null
,
null
,
null
,
"time DESC"
))
{
try
(
Cursor
c
=
db
.
query
(
TABLE_NAME
,
null
,
selection
,
null
,
null
,
null
,
"time DESC"
))
{
while
(
c
.
moveToNext
())
while
(
c
.
moveToNext
())
{
ret
.
add
(
new
SuLogEntry
(
c
));
ret
.
add
(
new
SuLogEntry
(
c
));
}
}
}
db
.
close
();
db
.
close
();
return
ret
;
return
ret
;
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/module/Module.java
View file @
a3f0ef8e
...
@@ -21,8 +21,9 @@ public class Module extends BaseModule {
...
@@ -21,8 +21,9 @@ public class Module extends BaseModule {
setId
(
path
.
substring
(
sep
+
1
));
setId
(
path
.
substring
(
sep
+
1
));
}
}
if
(
getName
()
==
null
)
if
(
getName
()
==
null
)
{
setName
(
getId
());
setName
(
getId
());
}
Logger
.
dev
(
"Creating Module, id: "
+
getId
());
Logger
.
dev
(
"Creating Module, id: "
+
getId
());
...
...
app/src/main/java/com/topjohnwu/magisk/module/Repo.java
View file @
a3f0ef8e
...
@@ -60,10 +60,6 @@ public class Repo extends BaseModule {
...
@@ -60,10 +60,6 @@ public class Repo extends BaseModule {
return
String
.
format
(
ZIP_URL
,
repoName
);
return
String
.
format
(
ZIP_URL
,
repoName
);
}
}
public
String
getLogUrl
()
{
return
String
.
format
(
FILE_URL
,
repoName
,
"changelog.txt"
);
}
public
String
getManifestUrl
()
{
public
String
getManifestUrl
()
{
return
String
.
format
(
FILE_URL
,
repoName
,
"module.prop"
);
return
String
.
format
(
FILE_URL
,
repoName
,
"module.prop"
);
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/superuser/SuReceiver.java
View file @
a3f0ef8e
...
@@ -38,11 +38,13 @@ public class SuReceiver extends BroadcastReceiver {
...
@@ -38,11 +38,13 @@ public class SuReceiver extends BroadcastReceiver {
SuDatabaseHelper
suDbHelper
=
new
SuDatabaseHelper
(
context
);
SuDatabaseHelper
suDbHelper
=
new
SuDatabaseHelper
(
context
);
policy
=
suDbHelper
.
getPolicy
(
fromUid
);
policy
=
suDbHelper
.
getPolicy
(
fromUid
);
if
(
policy
==
null
)
try
{
if
(
policy
==
null
)
{
try
{
policy
=
new
Policy
(
fromUid
,
context
.
getPackageManager
());
policy
=
new
Policy
(
fromUid
,
context
.
getPackageManager
());
}
catch
(
Throwable
throwable
)
{
}
catch
(
Throwable
throwable
)
{
return
;
return
;
}
}
}
magiskManager
.
initSuConfigs
();
magiskManager
.
initSuConfigs
();
...
...
app/src/main/java/com/topjohnwu/magisk/superuser/SuRequestActivity.java
View file @
a3f0ef8e
...
@@ -76,8 +76,9 @@ public class SuRequestActivity extends Activity implements CallbackEvent.Listene
...
@@ -76,8 +76,9 @@ public class SuRequestActivity extends Activity implements CallbackEvent.Listene
@Override
@Override
public
void
onEvent
(
int
fileEvent
,
String
path
)
{
public
void
onEvent
(
int
fileEvent
,
String
path
)
{
if
(
fileEvent
==
FileObserver
.
DELETE_SELF
)
{
if
(
fileEvent
==
FileObserver
.
DELETE_SELF
)
{
if
(
event
!=
null
)
if
(
event
!=
null
)
{
event
.
trigger
();
event
.
trigger
();
}
finish
();
finish
();
}
}
}
}
...
@@ -147,8 +148,9 @@ public class SuRequestActivity extends Activity implements CallbackEvent.Listene
...
@@ -147,8 +148,9 @@ public class SuRequestActivity extends Activity implements CallbackEvent.Listene
public
void
onTrigger
(
CallbackEvent
<
Policy
>
event
)
{
public
void
onTrigger
(
CallbackEvent
<
Policy
>
event
)
{
Policy
policy
=
event
.
getResult
();
Policy
policy
=
event
.
getResult
();
String
response
=
"socket:DENY"
;
String
response
=
"socket:DENY"
;
if
(
policy
!=
null
&&
policy
.
policy
==
Policy
.
ALLOW
)
if
(
policy
!=
null
&&
policy
.
policy
==
Policy
.
ALLOW
)
{
response
=
"socket:ALLOW"
;
response
=
"socket:ALLOW"
;
}
try
{
try
{
socket
.
getOutputStream
().
write
((
response
).
getBytes
());
socket
.
getOutputStream
().
write
((
response
).
getBytes
());
}
catch
(
Exception
ignored
)
{}
}
catch
(
Exception
ignored
)
{}
...
@@ -176,7 +178,7 @@ public class SuRequestActivity extends Activity implements CallbackEvent.Listene
...
@@ -176,7 +178,7 @@ public class SuRequestActivity extends Activity implements CallbackEvent.Listene
@Override
@Override
protected
Boolean
doInBackground
(
Void
...
params
)
{
protected
Boolean
doInBackground
(
Void
...
params
)
{
try
{
try
{
socket
=
new
LocalSocket
();
socket
=
new
LocalSocket
();
socket
.
connect
(
new
LocalSocketAddress
(
socketPath
,
LocalSocketAddress
.
Namespace
.
FILESYSTEM
));
socket
.
connect
(
new
LocalSocketAddress
(
socketPath
,
LocalSocketAddress
.
Namespace
.
FILESYSTEM
));
...
...
app/src/main/java/com/topjohnwu/magisk/utils/CallbackEvent.java
View file @
a3f0ef8e
...
@@ -10,8 +10,9 @@ public class CallbackEvent<Result> {
...
@@ -10,8 +10,9 @@ public class CallbackEvent<Result> {
private
Set
<
Listener
<
Result
>>
listeners
;
private
Set
<
Listener
<
Result
>>
listeners
;
public
void
register
(
Listener
<
Result
>
l
)
{
public
void
register
(
Listener
<
Result
>
l
)
{
if
(
listeners
==
null
)
if
(
listeners
==
null
)
{
listeners
=
new
HashSet
<>();
listeners
=
new
HashSet
<>();
}
listeners
.
add
(
l
);
listeners
.
add
(
l
);
}
}
...
@@ -20,9 +21,10 @@ public class CallbackEvent<Result> {
...
@@ -20,9 +21,10 @@ public class CallbackEvent<Result> {
}
}
public
void
unRegister
(
Listener
<
Result
>
l
)
{
public
void
unRegister
(
Listener
<
Result
>
l
)
{
if
(
listeners
!=
null
)
if
(
listeners
!=
null
)
{
listeners
.
remove
(
l
);
listeners
.
remove
(
l
);
}
}
}
public
void
trigger
()
{
public
void
trigger
()
{
trigger
(
null
);
trigger
(
null
);
...
@@ -32,10 +34,11 @@ public class CallbackEvent<Result> {
...
@@ -32,10 +34,11 @@ public class CallbackEvent<Result> {
result
=
r
;
result
=
r
;
isTriggered
=
true
;
isTriggered
=
true
;
if
(
listeners
!=
null
)
{
if
(
listeners
!=
null
)
{
for
(
Listener
<
Result
>
listener
:
listeners
)
for
(
Listener
<
Result
>
listener
:
listeners
)
{
listener
.
onTrigger
(
this
);
listener
.
onTrigger
(
this
);
}
}
}
}
}
public
Result
getResult
()
{
public
Result
getResult
()
{
return
result
;
return
result
;
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Shell.java
View file @
a3f0ef8e
...
@@ -120,11 +120,13 @@ public class Shell {
...
@@ -120,11 +120,13 @@ public class Shell {
StreamGobbler
STDOUT
;
StreamGobbler
STDOUT
;
// Create the default shell if not init
// Create the default shell if not init
if
(!
newShell
&&
!
isInit
)
if
(!
newShell
&&
!
isInit
)
{
init
();
init
();
}
if
(!
newShell
&&
!
rootAccess
())
if
(!
newShell
&&
!
rootAccess
())
{
return
null
;
return
null
;
}
if
(
newShell
)
{
if
(
newShell
)
{
res
=
Collections
.
synchronizedList
(
new
ArrayList
<
String
>());
res
=
Collections
.
synchronizedList
(
new
ArrayList
<
String
>());
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
View file @
a3f0ef8e
...
@@ -114,8 +114,9 @@ public class Utils {
...
@@ -114,8 +114,9 @@ public class Utils {
"echo \"${BOOTIMAGE##*/}\""
"echo \"${BOOTIMAGE##*/}\""
};
};
List
<
String
>
ret
=
Shell
.
su
(
commands
);
List
<
String
>
ret
=
Shell
.
su
(
commands
);
if
(
isValidShellResponse
(
ret
))
if
(
isValidShellResponse
(
ret
))
{
return
ret
.
get
(
0
);
return
ret
.
get
(
0
);
}
return
null
;
return
null
;
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/utils/WebService.java
View file @
a3f0ef8e
...
@@ -77,10 +77,11 @@ public class WebService {
...
@@ -77,10 +77,11 @@ public class WebService {
StringBuilder
result
=
new
StringBuilder
();
StringBuilder
result
=
new
StringBuilder
();
boolean
first
=
true
;
boolean
first
=
true
;
for
(
Map
.
Entry
<
String
,
String
>
entry
:
params
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
String
>
entry
:
params
.
entrySet
())
{
if
(
first
)
if
(
first
)
{
first
=
false
;
first
=
false
;
else
}
else
{
result
.
append
(
"&"
);
result
.
append
(
"&"
);
}
result
.
append
(
URLEncoder
.
encode
(
entry
.
getKey
(),
"UTF-8"
));
result
.
append
(
URLEncoder
.
encode
(
entry
.
getKey
(),
"UTF-8"
));
result
.
append
(
"="
);
result
.
append
(
"="
);
...
...
app/src/main/java/com/topjohnwu/magisk/utils/ZipUtils.java
View file @
a3f0ef8e
...
@@ -112,15 +112,18 @@ public class ZipUtils {
...
@@ -112,15 +112,18 @@ public class ZipUtils {
// Remove the top directory from the path
// Remove the top directory from the path
path
=
entry
.
getName
().
substring
(
entry
.
getName
().
indexOf
(
"/"
)
+
1
);
path
=
entry
.
getName
().
substring
(
entry
.
getName
().
indexOf
(
"/"
)
+
1
);
// If it's the top folder, ignore it
// If it's the top folder, ignore it
if
(
path
.
isEmpty
())
if
(
path
.
isEmpty
())
{
continue
;
continue
;
}
// Don't include placeholder
// Don't include placeholder
if
(
path
.
contains
(
"system/placeholder"
))
if
(
path
.
contains
(
"system/placeholder"
))
{
continue
;
continue
;
}
dest
.
putNextEntry
(
new
JarEntry
(
path
));
dest
.
putNextEntry
(
new
JarEntry
(
path
));
while
((
size
=
source
.
read
(
buffer
,
0
,
2048
))
!=
-
1
)
while
((
size
=
source
.
read
(
buffer
,
0
,
2048
))
!=
-
1
)
{
dest
.
write
(
buffer
,
0
,
size
);
dest
.
write
(
buffer
,
0
,
size
);
}
}
}
source
.
close
();
source
.
close
();
dest
.
close
();
dest
.
close
();
in
.
close
();
in
.
close
();
...
@@ -149,17 +152,20 @@ public class ZipUtils {
...
@@ -149,17 +152,20 @@ public class ZipUtils {
Enumeration
<
JarEntry
>
e
=
zipfile
.
entries
();
Enumeration
<
JarEntry
>
e
=
zipfile
.
entries
();
while
(
e
.
hasMoreElements
())
{
while
(
e
.
hasMoreElements
())
{
entry
=
e
.
nextElement
();
entry
=
e
.
nextElement
();
if
(!
entry
.
getName
().
contains
(
path
)
||
entry
.
isDirectory
())
if
(!
entry
.
getName
().
contains
(
path
)
||
entry
.
isDirectory
())
{
// Ignore directories, only create files
// Ignore directories, only create files
continue
;
continue
;
}
Logger
.
dev
(
"ZipUtils: Extracting: "
+
entry
);
Logger
.
dev
(
"ZipUtils: Extracting: "
+
entry
);
is
=
zipfile
.
getInputStream
(
entry
);
is
=
zipfile
.
getInputStream
(
entry
);
dest
=
new
File
(
folder
,
entry
.
getName
());
dest
=
new
File
(
folder
,
entry
.
getName
());
if
(
dest
.
getParentFile
().
mkdirs
())
if
(
dest
.
getParentFile
().
mkdirs
())
{
dest
.
createNewFile
();
dest
.
createNewFile
();
}
out
=
new
FileOutputStream
(
dest
);
out
=
new
FileOutputStream
(
dest
);
while
((
count
=
is
.
read
(
data
,
0
,
4096
))
!=
-
1
)
while
((
count
=
is
.
read
(
data
,
0
,
4096
))
!=
-
1
)
{
out
.
write
(
data
,
0
,
count
);
out
.
write
(
data
,
0
,
count
);
}
out
.
flush
();
out
.
flush
();
out
.
close
();
out
.
close
();
is
.
close
();
is
.
close
();
...
@@ -178,16 +184,19 @@ public class ZipUtils {
...
@@ -178,16 +184,19 @@ public class ZipUtils {
byte
data
[]
=
new
byte
[
4096
];
byte
data
[]
=
new
byte
[
4096
];
try
(
JarInputStream
zipfile
=
new
JarInputStream
(
file
))
{
try
(
JarInputStream
zipfile
=
new
JarInputStream
(
file
))
{
while
((
entry
=
zipfile
.
getNextJarEntry
())
!=
null
)
{
while
((
entry
=
zipfile
.
getNextJarEntry
())
!=
null
)
{
if
(!
entry
.
getName
().
contains
(
path
)
||
entry
.
isDirectory
())
if
(!
entry
.
getName
().
contains
(
path
)
||
entry
.
isDirectory
())
{
// Ignore directories, only create files
// Ignore directories, only create files
continue
;
continue
;
}
Logger
.
dev
(
"ZipUtils: Extracting: "
+
entry
);
Logger
.
dev
(
"ZipUtils: Extracting: "
+
entry
);
dest
=
new
File
(
folder
,
entry
.
getName
());
dest
=
new
File
(
folder
,
entry
.
getName
());
if
(
dest
.
getParentFile
().
mkdirs
())
if
(
dest
.
getParentFile
().
mkdirs
())
{
dest
.
createNewFile
();
dest
.
createNewFile
();
}
out
=
new
FileOutputStream
(
dest
);
out
=
new
FileOutputStream
(
dest
);
while
((
count
=
zipfile
.
read
(
data
,
0
,
4096
))
!=
-
1
)
while
((
count
=
zipfile
.
read
(
data
,
0
,
4096
))
!=
-
1
)
{
out
.
write
(
data
,
0
,
count
);
out
.
write
(
data
,
0
,
count
);
}
out
.
flush
();
out
.
flush
();
out
.
close
();
out
.
close
();
}
}
...
...
app/src/main/res/layout/fragment_install.xml
View file @
a3f0ef8e
...
@@ -159,7 +159,7 @@
...
@@ -159,7 +159,7 @@
</android.support.v7.widget.CardView>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
<android.support.v7.widget.CardView
android:id=
"@+id/
flash
_button"
android:id=
"@+id/
install
_button"
android:layout_gravity=
"center"
android:layout_gravity=
"center"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"4dp"
android:layout_marginBottom=
"4dp"
...
@@ -192,7 +192,7 @@
...
@@ -192,7 +192,7 @@
<TextView
<TextView
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:
text=
"@string/download_install
"
android:
id=
"@+id/install_text
"
android:ems=
"10"
android:ems=
"10"
android:gravity=
"center"
android:gravity=
"center"
android:layout_weight=
"1"
android:layout_weight=
"1"
...
...
app/src/main/res/values-zh-rTW/strings.xml
View file @
a3f0ef8e
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
<!--Install Fragment-->
<!--Install Fragment-->
<string
name=
"auto_detect"
>
(自動) %1$s
</string>
<string
name=
"auto_detect"
>
(自動) %1$s
</string>
<string
name=
"boot_image_title"
>
Boot
鏡
像位置
</string>
<string
name=
"boot_image_title"
>
Boot
映
像位置
</string>
<string
name=
"detect_button"
>
偵測
</string>
<string
name=
"detect_button"
>
偵測
</string>
<string
name=
"advanced_settings_title"
>
高級設置
</string>
<string
name=
"advanced_settings_title"
>
高級設置
</string>
<string
name=
"keep_force_encryption"
>
保持強制加密
</string>
<string
name=
"keep_force_encryption"
>
保持強制加密
</string>
...
@@ -181,13 +181,15 @@
...
@@ -181,13 +181,15 @@
<string
name=
"target_uid"
>
目標 UID:\u0020
</string>
<string
name=
"target_uid"
>
目標 UID:\u0020
</string>
<string
name=
"command"
>
"指令: "
</string>
<string
name=
"command"
>
"指令: "
</string>
<string
name=
"close"
>
關閉
</string>
<string
name=
"close"
>
關閉
</string>
<string
name=
"internal_storage"
>
Zip 已被儲存到:[內部儲存空間]%1$s
</string>
<string
name=
"internal_storage"
>
Zip 已被儲存到:
\n
[內部儲存空間]%1$s
</string>
<string
name=
"ok"
>
好
</string>
<string
name=
"ok"
>
好
</string>
<string
name=
"process_error"
>
處裡失敗
</string>
<string
name=
"process_error"
>
處裡失敗
</string>
<string
name=
"download"
>
下載
</string>
<string
name=
"download"
>
下載
</string>
<string
name=
"zip_process_title"
>
處理中
</string>
<string
name=
"zip_process_title"
>
處理中
</string>
<string
name=
"uninstall_magisk_title"
>
解除安裝 Magisk
</string>
<string
name=
"uninstall_magisk_title"
>
解除安裝 Magisk
</string>
<string
name=
"uninstall_magisk_msg"
>
這將會刪除所有模組,MagiskSU,並有可能在目前
未加密的情況下加密的的資料
\n你確定要繼續嗎?
</string>
<string
name=
"uninstall_magisk_msg"
>
這將會刪除所有模組,MagiskSU,並有可能在目前
資料未加密的情況下進行加密
\n你確定要繼續嗎?
</string>
<string
name=
"version_none"
>
(無)
</string>
<string
name=
"version_none"
>
(無)
</string>
<string
name=
"manual_boot_image"
>
請手動選取 boot 映像位置
</string>
<string
name=
"cannot_auto_detect"
>
(無法自動偵測)
</string>
</resources>
</resources>
app/src/main/res/values/colors.xml
View file @
a3f0ef8e
...
@@ -13,9 +13,6 @@
...
@@ -13,9 +13,6 @@
<color
name=
"blue500"
>
#2196F3
</color>
<color
name=
"blue500"
>
#2196F3
</color>
<color
name=
"yellow500"
>
#FFC107
</color>
<color
name=
"yellow500"
>
#FFC107
</color>
<color
name=
"dark_primary"
>
#bf360c
</color>
<color
name=
"dark_primary_dark"
>
#000000
</color>
<color
name=
"dark_secondary_text"
>
#dedede
</color>
<color
name=
"dark_secondary_text"
>
#dedede
</color>
<color
name=
"su_request_background"
>
#e0e0e0
</color>
<color
name=
"su_request_background"
>
#e0e0e0
</color>
...
...
app/src/main/res/values/strings.xml
View file @
a3f0ef8e
...
@@ -38,6 +38,7 @@
...
@@ -38,6 +38,7 @@
<!--Install Fragment-->
<!--Install Fragment-->
<string
name=
"auto_detect"
>
(Auto) %1$s
</string>
<string
name=
"auto_detect"
>
(Auto) %1$s
</string>
<string
name=
"cannot_auto_detect"
>
(Cannot auto detect)
</string>
<string
name=
"boot_image_title"
>
Boot Image Location
</string>
<string
name=
"boot_image_title"
>
Boot Image Location
</string>
<string
name=
"detect_button"
>
Detect
</string>
<string
name=
"detect_button"
>
Detect
</string>
<string
name=
"advanced_settings_title"
>
Advanced Settings
</string>
<string
name=
"advanced_settings_title"
>
Advanced Settings
</string>
...
@@ -124,6 +125,7 @@
...
@@ -124,6 +125,7 @@
<string
name=
"process_error"
>
Process error
</string>
<string
name=
"process_error"
>
Process error
</string>
<string
name=
"internal_storage"
>
The zip is stored in:\n[Internal Storage]%1$s
</string>
<string
name=
"internal_storage"
>
The zip is stored in:\n[Internal Storage]%1$s
</string>
<string
name=
"zip_process_title"
>
Processing
</string>
<string
name=
"zip_process_title"
>
Processing
</string>
<string
name=
"manual_boot_image"
>
Please manually select a boot image!
</string>
<!--Settings Activity -->
<!--Settings Activity -->
<string
name=
"settings_general_category"
>
General
</string>
<string
name=
"settings_general_category"
>
General
</string>
...
...
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