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
80dad541
Commit
80dad541
authored
Dec 02, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some cleanups
parent
56a76df2
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
25 additions
and
36 deletions
+25
-36
Const.java
app/src/full/java/com/topjohnwu/magisk/Const.java
+4
-2
FlashActivity.java
app/src/full/java/com/topjohnwu/magisk/FlashActivity.java
+1
-2
SplashActivity.java
app/src/full/java/com/topjohnwu/magisk/SplashActivity.java
+3
-3
SuRequestActivity.java
...src/full/java/com/topjohnwu/magisk/SuRequestActivity.java
+1
-1
InstallMagisk.java
.../full/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java
+1
-2
PatchAPK.java
app/src/full/java/com/topjohnwu/magisk/asyncs/PatchAPK.java
+4
-3
ProcessRepoZip.java
...full/java/com/topjohnwu/magisk/asyncs/ProcessRepoZip.java
+1
-2
BaseActivity.java
...ll/java/com/topjohnwu/magisk/components/BaseActivity.java
+2
-2
InstallMethodDialog.java
.../com/topjohnwu/magisk/components/InstallMethodDialog.java
+1
-2
MagiskLogFragment.java
...ava/com/topjohnwu/magisk/fragments/MagiskLogFragment.java
+1
-2
SettingsFragment.java
...java/com/topjohnwu/magisk/fragments/SettingsFragment.java
+2
-1
DlInstallManager.java
...ull/java/com/topjohnwu/magisk/utils/DlInstallManager.java
+4
-4
Download.java
app/src/main/java/com/topjohnwu/magisk/utils/Download.java
+0
-10
No files found.
app/src/full/java/com/topjohnwu/magisk/Const.java
View file @
80dad541
package
com
.
topjohnwu
.
magisk
;
package
com
.
topjohnwu
.
magisk
;
import
android.os.Environment
;
import
android.os.Process
;
import
android.os.Process
;
import
java.io.File
;
import
java.io.File
;
...
@@ -9,7 +10,6 @@ import java.util.List;
...
@@ -9,7 +10,6 @@ import java.util.List;
public
class
Const
{
public
class
Const
{
public
static
final
String
DEBUG_TAG
=
"MagiskManager"
;
public
static
final
String
DEBUG_TAG
=
"MagiskManager"
;
public
static
final
String
ORIG_PKG_NAME
=
BuildConfig
.
APPLICATION_ID
;
public
static
final
String
MAGISKHIDE_PROP
=
"persist.magisk.hide"
;
public
static
final
String
MAGISKHIDE_PROP
=
"persist.magisk.hide"
;
// APK content
// APK content
...
@@ -19,11 +19,13 @@ public class Const {
...
@@ -19,11 +19,13 @@ public class Const {
// Paths
// Paths
public
static
final
String
MAGISK_PATH
=
"/sbin/.magisk/img"
;
public
static
final
String
MAGISK_PATH
=
"/sbin/.magisk/img"
;
public
static
final
File
EXTERNAL_PATH
;
public
static
File
MAGISK_DISABLE_FILE
;
public
static
File
MAGISK_DISABLE_FILE
;
static
{
static
{
/* Prevent crashing on unrooted devices */
MAGISK_DISABLE_FILE
=
new
File
(
"xxx"
);
MAGISK_DISABLE_FILE
=
new
File
(
"xxx"
);
EXTERNAL_PATH
=
Environment
.
getExternalStoragePublicDirectory
(
Environment
.
DIRECTORY_DOWNLOADS
);
EXTERNAL_PATH
.
mkdirs
();
}
}
public
static
final
String
BUSYBOX_PATH
=
"/sbin/.magisk/busybox"
;
public
static
final
String
BUSYBOX_PATH
=
"/sbin/.magisk/busybox"
;
...
...
app/src/full/java/com/topjohnwu/magisk/FlashActivity.java
View file @
80dad541
...
@@ -15,7 +15,6 @@ import android.widget.Toast;
...
@@ -15,7 +15,6 @@ import android.widget.Toast;
import
com.topjohnwu.magisk.asyncs.FlashZip
;
import
com.topjohnwu.magisk.asyncs.FlashZip
;
import
com.topjohnwu.magisk.asyncs.InstallMagisk
;
import
com.topjohnwu.magisk.asyncs.InstallMagisk
;
import
com.topjohnwu.magisk.components.BaseActivity
;
import
com.topjohnwu.magisk.components.BaseActivity
;
import
com.topjohnwu.magisk.utils.Download
;
import
com.topjohnwu.magisk.utils.RootUtils
;
import
com.topjohnwu.magisk.utils.RootUtils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.superuser.CallbackList
;
import
com.topjohnwu.superuser.CallbackList
;
...
@@ -59,7 +58,7 @@ public class FlashActivity extends BaseActivity {
...
@@ -59,7 +58,7 @@ public class FlashActivity extends BaseActivity {
now
.
get
(
Calendar
.
DAY_OF_MONTH
),
now
.
get
(
Calendar
.
HOUR_OF_DAY
),
now
.
get
(
Calendar
.
DAY_OF_MONTH
),
now
.
get
(
Calendar
.
HOUR_OF_DAY
),
now
.
get
(
Calendar
.
MINUTE
),
now
.
get
(
Calendar
.
SECOND
));
now
.
get
(
Calendar
.
MINUTE
),
now
.
get
(
Calendar
.
SECOND
));
File
logFile
=
new
File
(
Download
.
EXTERNAL_PATH
,
filename
);
File
logFile
=
new
File
(
Const
.
EXTERNAL_PATH
,
filename
);
try
(
FileWriter
writer
=
new
FileWriter
(
logFile
))
{
try
(
FileWriter
writer
=
new
FileWriter
(
logFile
))
{
for
(
String
s
:
logs
)
{
for
(
String
s
:
logs
)
{
writer
.
write
(
s
);
writer
.
write
(
s
);
...
...
app/src/full/java/com/topjohnwu/magisk/SplashActivity.java
View file @
80dad541
...
@@ -23,15 +23,15 @@ public class SplashActivity extends BaseActivity {
...
@@ -23,15 +23,15 @@ public class SplashActivity extends BaseActivity {
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
String
pkg
=
mm
.
mDB
.
getStrings
(
Const
.
Key
.
SU_MANAGER
,
null
);
String
pkg
=
mm
.
mDB
.
getStrings
(
Const
.
Key
.
SU_MANAGER
,
null
);
if
(
pkg
!=
null
&&
getPackageName
().
equals
(
Const
.
ORIG_PKG_NAME
))
{
if
(
pkg
!=
null
&&
getPackageName
().
equals
(
BuildConfig
.
APPLICATION_ID
))
{
mm
.
mDB
.
setStrings
(
Const
.
Key
.
SU_MANAGER
,
null
);
mm
.
mDB
.
setStrings
(
Const
.
Key
.
SU_MANAGER
,
null
);
Shell
.
su
(
"pm uninstall "
+
pkg
).
exec
();
Shell
.
su
(
"pm uninstall "
+
pkg
).
exec
();
}
}
if
(
TextUtils
.
equals
(
pkg
,
getPackageName
()))
{
if
(
TextUtils
.
equals
(
pkg
,
getPackageName
()))
{
try
{
try
{
// We are the manager, remove com.topjohnwu.magisk as it could be malware
// We are the manager, remove com.topjohnwu.magisk as it could be malware
getPackageManager
().
getApplicationInfo
(
Const
.
ORIG_PKG_NAME
,
0
);
getPackageManager
().
getApplicationInfo
(
BuildConfig
.
APPLICATION_ID
,
0
);
RootUtils
.
uninstallPkg
(
Const
.
ORIG_PKG_NAME
);
RootUtils
.
uninstallPkg
(
BuildConfig
.
APPLICATION_ID
);
}
catch
(
PackageManager
.
NameNotFoundException
ignored
)
{}
}
catch
(
PackageManager
.
NameNotFoundException
ignored
)
{}
}
}
...
...
app/src/full/java/com/topjohnwu/magisk/SuRequestActivity.java
View file @
80dad541
...
@@ -135,7 +135,7 @@ public class SuRequestActivity extends BaseActivity {
...
@@ -135,7 +135,7 @@ public class SuRequestActivity extends BaseActivity {
}
}
// Never allow com.topjohnwu.magisk (could be malware)
// Never allow com.topjohnwu.magisk (could be malware)
if
(
TextUtils
.
equals
(
policy
.
packageName
,
Const
.
ORIG_PKG_NAME
))
{
if
(
TextUtils
.
equals
(
policy
.
packageName
,
BuildConfig
.
APPLICATION_ID
))
{
finish
();
finish
();
return
;
return
;
}
}
...
...
app/src/full/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java
View file @
80dad541
...
@@ -14,7 +14,6 @@ import com.topjohnwu.magisk.FlashActivity;
...
@@ -14,7 +14,6 @@ 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.TarEntry
;
import
com.topjohnwu.magisk.container.TarEntry
;
import
com.topjohnwu.magisk.utils.Download
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.WebService
;
import
com.topjohnwu.magisk.utils.WebService
;
import
com.topjohnwu.magisk.utils.ZipUtils
;
import
com.topjohnwu.magisk.utils.ZipUtils
;
...
@@ -243,7 +242,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
...
@@ -243,7 +242,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
switch
(
mode
)
{
switch
(
mode
)
{
case
PATCH_MODE:
case
PATCH_MODE:
String
fmt
=
mm
.
prefs
.
getString
(
Const
.
Key
.
BOOT_FORMAT
,
".img"
);
String
fmt
=
mm
.
prefs
.
getString
(
Const
.
Key
.
BOOT_FORMAT
,
".img"
);
File
dest
=
new
File
(
Download
.
EXTERNAL_PATH
,
"patched_boot"
+
fmt
);
File
dest
=
new
File
(
Const
.
EXTERNAL_PATH
,
"patched_boot"
+
fmt
);
dest
.
getParentFile
().
mkdirs
();
dest
.
getParentFile
().
mkdirs
();
OutputStream
out
;
OutputStream
out
;
switch
(
fmt
)
{
switch
(
fmt
)
{
...
...
app/src/full/java/com/topjohnwu/magisk/asyncs/PatchAPK.java
View file @
80dad541
...
@@ -5,6 +5,7 @@ import android.app.ProgressDialog;
...
@@ -5,6 +5,7 @@ import android.app.ProgressDialog;
import
android.os.AsyncTask
;
import
android.os.AsyncTask
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.topjohnwu.magisk.BuildConfig
;
import
com.topjohnwu.magisk.Const
;
import
com.topjohnwu.magisk.Const
;
import
com.topjohnwu.magisk.Data
;
import
com.topjohnwu.magisk.Data
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.MagiskManager
;
...
@@ -82,11 +83,11 @@ public class PatchAPK {
...
@@ -82,11 +83,11 @@ public class PatchAPK {
// Generate a new app with random package name
// Generate a new app with random package name
SuFile
repack
=
new
SuFile
(
"/data/local/tmp/repack.apk"
);
SuFile
repack
=
new
SuFile
(
"/data/local/tmp/repack.apk"
);
String
pkg
=
genPackageName
(
"com."
,
Const
.
ORIG_PKG_NAME
.
length
());
String
pkg
=
genPackageName
(
"com."
,
BuildConfig
.
APPLICATION_ID
.
length
());
try
{
try
{
JarMap
apk
=
new
JarMap
(
mm
.
getPackageCodePath
());
JarMap
apk
=
new
JarMap
(
mm
.
getPackageCodePath
());
if
(!
patchPackageID
(
apk
,
Const
.
ORIG_PKG_NAME
,
pkg
))
if
(!
patchPackageID
(
apk
,
BuildConfig
.
APPLICATION_ID
,
pkg
))
return
false
;
return
false
;
SignAPK
.
sign
(
apk
,
new
SuFileOutputStream
(
repack
));
SignAPK
.
sign
(
apk
,
new
SuFileOutputStream
(
repack
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -101,7 +102,7 @@ public class PatchAPK {
...
@@ -101,7 +102,7 @@ public class PatchAPK {
mm
.
mDB
.
setStrings
(
Const
.
Key
.
SU_MANAGER
,
pkg
);
mm
.
mDB
.
setStrings
(
Const
.
Key
.
SU_MANAGER
,
pkg
);
Data
.
exportPrefs
();
Data
.
exportPrefs
();
RootUtils
.
rmAndLaunch
(
Const
.
ORIG_PKG_NAME
,
pkg
);
RootUtils
.
rmAndLaunch
(
BuildConfig
.
APPLICATION_ID
,
pkg
);
return
true
;
return
true
;
}
}
...
...
app/src/full/java/com/topjohnwu/magisk/asyncs/ProcessRepoZip.java
View file @
80dad541
...
@@ -13,7 +13,6 @@ import com.topjohnwu.magisk.R;
...
@@ -13,7 +13,6 @@ import com.topjohnwu.magisk.R;
import
com.topjohnwu.magisk.components.BaseActivity
;
import
com.topjohnwu.magisk.components.BaseActivity
;
import
com.topjohnwu.magisk.components.SnackbarMaker
;
import
com.topjohnwu.magisk.components.SnackbarMaker
;
import
com.topjohnwu.magisk.container.Repo
;
import
com.topjohnwu.magisk.container.Repo
;
import
com.topjohnwu.magisk.utils.Download
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.WebService
;
import
com.topjohnwu.magisk.utils.WebService
;
import
com.topjohnwu.magisk.utils.ZipUtils
;
import
com.topjohnwu.magisk.utils.ZipUtils
;
...
@@ -48,7 +47,7 @@ public class ProcessRepoZip extends ParallelTask<Void, Object, Boolean> {
...
@@ -48,7 +47,7 @@ public class ProcessRepoZip extends ParallelTask<Void, Object, Boolean> {
super
(
context
);
super
(
context
);
mRepo
=
repo
;
mRepo
=
repo
;
mInstall
=
install
&&
Shell
.
rootAccess
();
mInstall
=
install
&&
Shell
.
rootAccess
();
mFile
=
new
File
(
Download
.
EXTERNAL_PATH
,
repo
.
getDownloadFilename
());
mFile
=
new
File
(
Const
.
EXTERNAL_PATH
,
repo
.
getDownloadFilename
());
}
}
private
void
removeTopFolder
(
File
input
,
File
output
)
throws
IOException
{
private
void
removeTopFolder
(
File
input
,
File
output
)
throws
IOException
{
...
...
app/src/full/java/com/topjohnwu/magisk/components/BaseActivity.java
View file @
80dad541
...
@@ -8,11 +8,11 @@ import android.os.Bundle;
...
@@ -8,11 +8,11 @@ import android.os.Bundle;
import
android.view.WindowManager
;
import
android.view.WindowManager
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.topjohnwu.magisk.Const
;
import
com.topjohnwu.magisk.Data
;
import
com.topjohnwu.magisk.Data
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.NoUIActivity
;
import
com.topjohnwu.magisk.NoUIActivity
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.utils.Download
;
import
com.topjohnwu.magisk.utils.LocaleManager
;
import
com.topjohnwu.magisk.utils.LocaleManager
;
import
com.topjohnwu.magisk.utils.Topic
;
import
com.topjohnwu.magisk.utils.Topic
;
...
@@ -91,7 +91,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Topic.Au
...
@@ -91,7 +91,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Topic.Au
granted
=
false
;
granted
=
false
;
}
}
if
(
granted
)
{
if
(
granted
)
{
Download
.
EXTERNAL_PATH
.
mkdirs
();
Const
.
EXTERNAL_PATH
.
mkdirs
();
callback
.
run
();
callback
.
run
();
}
else
{
}
else
{
// Passed in context should be an activity if not granted, need to show dialog!
// Passed in context should be an activity if not granted, need to show dialog!
...
...
app/src/full/java/com/topjohnwu/magisk/components/InstallMethodDialog.java
View file @
80dad541
...
@@ -13,7 +13,6 @@ import com.topjohnwu.magisk.Const;
...
@@ -13,7 +13,6 @@ import com.topjohnwu.magisk.Const;
import
com.topjohnwu.magisk.Data
;
import
com.topjohnwu.magisk.Data
;
import
com.topjohnwu.magisk.FlashActivity
;
import
com.topjohnwu.magisk.FlashActivity
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.utils.Download
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
java.util.List
;
import
java.util.List
;
...
@@ -70,7 +69,7 @@ class InstallMethodDialog extends AlertDialog.Builder {
...
@@ -70,7 +69,7 @@ class InstallMethodDialog extends AlertDialog.Builder {
Data
.
remoteMagiskVersionString
,
Data
.
remoteMagiskVersionCode
);
Data
.
remoteMagiskVersionString
,
Data
.
remoteMagiskVersionCode
);
NotificationProgress
progress
=
new
NotificationProgress
(
filename
);
NotificationProgress
progress
=
new
NotificationProgress
(
filename
);
AndroidNetworking
AndroidNetworking
.
download
(
Data
.
magiskLink
,
Download
.
EXTERNAL_PATH
.
getPath
(),
filename
)
.
download
(
Data
.
magiskLink
,
Const
.
EXTERNAL_PATH
.
getPath
(),
filename
)
.
build
()
.
build
()
.
setDownloadProgressListener
(
progress
)
.
setDownloadProgressListener
(
progress
)
.
startDownload
(
new
DownloadListener
()
{
.
startDownload
(
new
DownloadListener
()
{
...
...
app/src/full/java/com/topjohnwu/magisk/fragments/MagiskLogFragment.java
View file @
80dad541
...
@@ -19,7 +19,6 @@ import com.topjohnwu.magisk.Const;
...
@@ -19,7 +19,6 @@ import com.topjohnwu.magisk.Const;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.components.BaseFragment
;
import
com.topjohnwu.magisk.components.BaseFragment
;
import
com.topjohnwu.magisk.components.SnackbarMaker
;
import
com.topjohnwu.magisk.components.SnackbarMaker
;
import
com.topjohnwu.magisk.utils.Download
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.Shell
;
...
@@ -100,7 +99,7 @@ public class MagiskLogFragment extends BaseFragment {
...
@@ -100,7 +99,7 @@ public class MagiskLogFragment extends BaseFragment {
now
.
get
(
Calendar
.
DAY_OF_MONTH
),
now
.
get
(
Calendar
.
HOUR_OF_DAY
),
now
.
get
(
Calendar
.
DAY_OF_MONTH
),
now
.
get
(
Calendar
.
HOUR_OF_DAY
),
now
.
get
(
Calendar
.
MINUTE
),
now
.
get
(
Calendar
.
SECOND
));
now
.
get
(
Calendar
.
MINUTE
),
now
.
get
(
Calendar
.
SECOND
));
File
logFile
=
new
File
(
Download
.
EXTERNAL_PATH
,
filename
);
File
logFile
=
new
File
(
Const
.
EXTERNAL_PATH
,
filename
);
try
{
try
{
logFile
.
createNewFile
();
logFile
.
createNewFile
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
...
...
app/src/full/java/com/topjohnwu/magisk/fragments/SettingsFragment.java
View file @
80dad541
...
@@ -10,6 +10,7 @@ import android.view.ViewGroup;
...
@@ -10,6 +10,7 @@ import android.view.ViewGroup;
import
android.widget.EditText
;
import
android.widget.EditText
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.topjohnwu.magisk.BuildConfig
;
import
com.topjohnwu.magisk.Const
;
import
com.topjohnwu.magisk.Const
;
import
com.topjohnwu.magisk.Data
;
import
com.topjohnwu.magisk.Data
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.MagiskManager
;
...
@@ -151,7 +152,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
...
@@ -151,7 +152,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
}
}
if
(
Shell
.
rootAccess
()
&&
Const
.
USER_ID
==
0
)
{
if
(
Shell
.
rootAccess
()
&&
Const
.
USER_ID
==
0
)
{
if
(
mm
.
getPackageName
().
equals
(
Const
.
ORIG_PKG_NAME
))
{
if
(
mm
.
getPackageName
().
equals
(
BuildConfig
.
APPLICATION_ID
))
{
generalCatagory
.
removePreference
(
restoreManager
);
generalCatagory
.
removePreference
(
restoreManager
);
}
else
{
}
else
{
if
(!
Download
.
checkNetworkStatus
(
mm
))
if
(!
Download
.
checkNetworkStatus
(
mm
))
...
...
app/src/full/java/com/topjohnwu/magisk/utils/DlInstallManager.java
View file @
80dad541
...
@@ -5,7 +5,7 @@ import android.os.AsyncTask;
...
@@ -5,7 +5,7 @@ import android.os.AsyncTask;
import
com.androidnetworking.AndroidNetworking
;
import
com.androidnetworking.AndroidNetworking
;
import
com.androidnetworking.error.ANError
;
import
com.androidnetworking.error.ANError
;
import
com.androidnetworking.interfaces.DownloadListener
;
import
com.androidnetworking.interfaces.DownloadListener
;
import
com.topjohnwu.magisk.
Const
;
import
com.topjohnwu.magisk.
BuildConfig
;
import
com.topjohnwu.magisk.Data
;
import
com.topjohnwu.magisk.Data
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
...
@@ -70,7 +70,7 @@ public class DlInstallManager {
...
@@ -70,7 +70,7 @@ public class DlInstallManager {
public
void
onDownloadComplete
(
File
apk
,
NotificationProgress
progress
)
{
public
void
onDownloadComplete
(
File
apk
,
NotificationProgress
progress
)
{
File
patched
=
apk
;
File
patched
=
apk
;
MagiskManager
mm
=
Data
.
MM
();
MagiskManager
mm
=
Data
.
MM
();
if
(!
mm
.
getPackageName
().
equals
(
Const
.
ORIG_PKG_NAME
))
{
if
(!
mm
.
getPackageName
().
equals
(
BuildConfig
.
APPLICATION_ID
))
{
progress
.
getNotification
()
progress
.
getNotification
()
.
setProgress
(
0
,
0
,
true
)
.
setProgress
(
0
,
0
,
true
)
.
setContentTitle
(
mm
.
getString
(
R
.
string
.
hide_manager_title
))
.
setContentTitle
(
mm
.
getString
(
R
.
string
.
hide_manager_title
))
...
@@ -79,7 +79,7 @@ public class DlInstallManager {
...
@@ -79,7 +79,7 @@ public class DlInstallManager {
patched
=
new
File
(
apk
.
getParent
(),
"patched.apk"
);
patched
=
new
File
(
apk
.
getParent
(),
"patched.apk"
);
try
{
try
{
JarMap
jarMap
=
new
JarMap
(
apk
);
JarMap
jarMap
=
new
JarMap
(
apk
);
PatchAPK
.
patchPackageID
(
jarMap
,
Const
.
ORIG_PKG_NAME
,
mm
.
getPackageName
());
PatchAPK
.
patchPackageID
(
jarMap
,
BuildConfig
.
APPLICATION_ID
,
mm
.
getPackageName
());
SignAPK
.
sign
(
jarMap
,
new
BufferedOutputStream
(
new
FileOutputStream
(
patched
)));
SignAPK
.
sign
(
jarMap
,
new
BufferedOutputStream
(
new
FileOutputStream
(
patched
)));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
return
;
return
;
...
@@ -97,7 +97,7 @@ public class DlInstallManager {
...
@@ -97,7 +97,7 @@ public class DlInstallManager {
progress
.
dismiss
();
progress
.
dismiss
();
Data
.
exportPrefs
();
Data
.
exportPrefs
();
if
(
ShellUtils
.
fastCmdResult
(
"pm install "
+
apk
))
if
(
ShellUtils
.
fastCmdResult
(
"pm install "
+
apk
))
RootUtils
.
rmAndLaunch
(
Data
.
MM
().
getPackageName
(),
Const
.
ORIG_PKG_NAME
);
RootUtils
.
rmAndLaunch
(
Data
.
MM
().
getPackageName
(),
BuildConfig
.
APPLICATION_ID
);
}
}
}
}
}
}
app/src/main/java/com/topjohnwu/magisk/utils/Download.java
View file @
80dad541
...
@@ -3,19 +3,9 @@ package com.topjohnwu.magisk.utils;
...
@@ -3,19 +3,9 @@ package com.topjohnwu.magisk.utils;
import
android.content.Context
;
import
android.content.Context
;
import
android.net.ConnectivityManager
;
import
android.net.ConnectivityManager
;
import
android.net.NetworkInfo
;
import
android.net.NetworkInfo
;
import
android.os.Environment
;
import
java.io.File
;
public
class
Download
{
public
class
Download
{
public
static
final
File
EXTERNAL_PATH
=
Environment
.
getExternalStoragePublicDirectory
(
Environment
.
DIRECTORY_DOWNLOADS
);
static
{
EXTERNAL_PATH
.
mkdirs
();
}
public
static
String
getLegalFilename
(
CharSequence
filename
)
{
public
static
String
getLegalFilename
(
CharSequence
filename
)
{
return
filename
.
toString
().
replace
(
" "
,
"_"
).
replace
(
"'"
,
""
).
replace
(
"\""
,
""
)
return
filename
.
toString
().
replace
(
" "
,
"_"
).
replace
(
"'"
,
""
).
replace
(
"\""
,
""
)
.
replace
(
"$"
,
""
).
replace
(
"`"
,
""
).
replace
(
"*"
,
""
).
replace
(
"/"
,
"_"
)
.
replace
(
"$"
,
""
).
replace
(
"`"
,
""
).
replace
(
"*"
,
""
).
replace
(
"/"
,
"_"
)
...
...
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