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
0a6140c6
Commit
0a6140c6
authored
Feb 21, 2021
by
vvb2060
Committed by
John Wu
Feb 22, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Try install with root first
parent
bba2ac88
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
4 deletions
+12
-4
APKInstall.java
.../src/main/java/com/topjohnwu/magisk/utils/APKInstall.java
+5
-2
HideAPK.kt
app/src/main/java/com/topjohnwu/magisk/core/tasks/HideAPK.kt
+7
-2
No files found.
app/shared/src/main/java/com/topjohnwu/magisk/utils/APKInstall.java
View file @
0a6140c6
...
@@ -21,6 +21,7 @@ public class APKInstall {
...
@@ -21,6 +21,7 @@ public class APKInstall {
if
(
Build
.
VERSION
.
SDK_INT
>=
24
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
24
)
{
intent
.
setData
(
FileProvider
.
getUriForFile
(
c
,
c
.
getPackageName
()
+
".provider"
,
apk
));
intent
.
setData
(
FileProvider
.
getUriForFile
(
c
,
c
.
getPackageName
()
+
".provider"
,
apk
));
}
else
{
}
else
{
//noinspection ResultOfMethodCallIgnored SetWorldReadable
apk
.
setReadable
(
true
,
false
);
apk
.
setReadable
(
true
,
false
);
intent
.
setData
(
Uri
.
fromFile
(
apk
));
intent
.
setData
(
Uri
.
fromFile
(
apk
));
}
}
...
@@ -31,15 +32,17 @@ public class APKInstall {
...
@@ -31,15 +32,17 @@ public class APKInstall {
c
.
startActivity
(
installIntent
(
c
,
apk
));
c
.
startActivity
(
installIntent
(
c
,
apk
));
}
}
public
static
void
installAndWait
(
Activity
c
,
File
apk
,
BroadcastReceiver
r
)
{
public
static
void
registerInstallReceiver
(
Context
c
,
BroadcastReceiver
r
)
{
IntentFilter
filter
=
new
IntentFilter
();
IntentFilter
filter
=
new
IntentFilter
();
filter
.
addAction
(
Intent
.
ACTION_PACKAGE_REPLACED
);
filter
.
addAction
(
Intent
.
ACTION_PACKAGE_REPLACED
);
filter
.
addAction
(
Intent
.
ACTION_PACKAGE_ADDED
);
filter
.
addAction
(
Intent
.
ACTION_PACKAGE_ADDED
);
filter
.
addDataScheme
(
"package"
);
filter
.
addDataScheme
(
"package"
);
c
.
getApplicationContext
().
registerReceiver
(
r
,
filter
);
c
.
getApplicationContext
().
registerReceiver
(
r
,
filter
);
}
public
static
void
installHideResult
(
Activity
c
,
File
apk
)
{
Intent
intent
=
installIntent
(
c
,
apk
);
Intent
intent
=
installIntent
(
c
,
apk
);
intent
.
putExtra
(
Intent
.
EXTRA_RETURN_RESULT
,
true
);
intent
.
putExtra
(
Intent
.
EXTRA_RETURN_RESULT
,
true
);
c
.
startActivityForResult
(
intent
,
0
);
c
.
startActivityForResult
(
intent
,
0
);
// Ignore result, use install receiver
}
}
}
}
app/src/main/java/com/topjohnwu/magisk/core/tasks/HideAPK.kt
View file @
0a6140c6
...
@@ -21,6 +21,7 @@ import com.topjohnwu.magisk.utils.APKInstall
...
@@ -21,6 +21,7 @@ import com.topjohnwu.magisk.utils.APKInstall
import
com.topjohnwu.magisk.utils.Utils
import
com.topjohnwu.magisk.utils.Utils
import
com.topjohnwu.signing.JarMap
import
com.topjohnwu.signing.JarMap
import
com.topjohnwu.signing.SignApk
import
com.topjohnwu.signing.SignApk
import
com.topjohnwu.superuser.Shell
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.withContext
import
kotlinx.coroutines.withContext
import
timber.log.Timber
import
timber.log.Timber
...
@@ -141,7 +142,9 @@ object HideAPK {
...
@@ -141,7 +142,9 @@ object HideAPK {
return
false
return
false
// Install and auto launch app
// Install and auto launch app
APKInstall
.
installAndWait
(
activity
,
repack
,
WaitPackageReceiver
(
pkg
,
activity
))
APKInstall
.
registerInstallReceiver
(
activity
,
WaitPackageReceiver
(
pkg
,
activity
))
if
(!
Shell
.
su
(
"adb_pm_install $repack"
).
exec
().
isSuccess
)
APKInstall
.
installHideResult
(
activity
,
repack
)
return
true
return
true
}
}
...
@@ -156,6 +159,8 @@ object HideAPK {
...
@@ -156,6 +159,8 @@ object HideAPK {
fun
restore
(
activity
:
Activity
)
{
fun
restore
(
activity
:
Activity
)
{
val
apk
=
DynAPK
.
current
(
activity
)
val
apk
=
DynAPK
.
current
(
activity
)
APKInstall
.
installAndWait
(
activity
,
apk
,
WaitPackageReceiver
(
APPLICATION_ID
,
activity
))
APKInstall
.
registerInstallReceiver
(
activity
,
WaitPackageReceiver
(
APPLICATION_ID
,
activity
))
if
(!
Shell
.
su
(
"adb_pm_install $apk"
).
exec
().
isSuccess
)
APKInstall
.
installHideResult
(
activity
,
apk
)
}
}
}
}
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