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
fa60daf9
Commit
fa60daf9
authored
Jun 05, 2022
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Verify caller before uninstallation
parent
aadb2d82
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
11 deletions
+16
-11
BaseMainActivity.kt
...c/main/java/com/topjohnwu/magisk/arch/BaseMainActivity.kt
+11
-1
Config.kt
app/src/main/java/com/topjohnwu/magisk/core/Config.kt
+1
-1
Provider.kt
app/src/main/java/com/topjohnwu/magisk/core/Provider.kt
+1
-6
HideAPK.kt
app/src/main/java/com/topjohnwu/magisk/core/tasks/HideAPK.kt
+3
-3
No files found.
app/src/main/java/com/topjohnwu/magisk/arch/BaseMainActivity.kt
View file @
fa60daf9
...
@@ -9,6 +9,7 @@ import androidx.databinding.ViewDataBinding
...
@@ -9,6 +9,7 @@ import androidx.databinding.ViewDataBinding
import
androidx.lifecycle.lifecycleScope
import
androidx.lifecycle.lifecycleScope
import
com.topjohnwu.magisk.BuildConfig.APPLICATION_ID
import
com.topjohnwu.magisk.BuildConfig.APPLICATION_ID
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.StubApk
import
com.topjohnwu.magisk.core.Config
import
com.topjohnwu.magisk.core.Config
import
com.topjohnwu.magisk.core.Const
import
com.topjohnwu.magisk.core.Const
import
com.topjohnwu.magisk.core.JobService
import
com.topjohnwu.magisk.core.JobService
...
@@ -95,10 +96,19 @@ abstract class BaseMainActivity<Binding : ViewDataBinding> : NavigationActivity<
...
@@ -95,10 +96,19 @@ abstract class BaseMainActivity<Binding : ViewDataBinding> : NavigationActivity<
}
}
private
fun
preLoad
()
{
private
fun
preLoad
()
{
val
prevPkg
=
intent
.
getStringExtra
(
Const
.
Key
.
PREV_PKG
)
val
prevPkg
=
intent
.
getStringExtra
(
Const
.
Key
.
PREV_PKG
)
?.
let
{
// Make sure the calling package matches (prevent DoS)
if
(
it
==
callingPackage
)
it
else
null
}
Config
.
load
(
prevPkg
)
Config
.
load
(
prevPkg
)
handleRepackage
(
prevPkg
)
handleRepackage
(
prevPkg
)
if
(
prevPkg
!=
null
)
{
StubApk
.
restartProcess
(
this
)
}
Notifications
.
setup
(
this
)
Notifications
.
setup
(
this
)
JobService
.
schedule
(
this
)
JobService
.
schedule
(
this
)
Shortcuts
.
setupDynamic
(
this
)
Shortcuts
.
setupDynamic
(
this
)
...
...
app/src/main/java/com/topjohnwu/magisk/core/Config.kt
View file @
fa60daf9
...
@@ -163,7 +163,7 @@ object Config : PreferenceConfig, DBConfig {
...
@@ -163,7 +163,7 @@ object Config : PreferenceConfig, DBConfig {
fun
load
(
pkg
:
String
?)
{
fun
load
(
pkg
:
String
?)
{
// Only try to load prefs when fresh install and a previous package name is set
// Only try to load prefs when fresh install and a previous package name is set
if
(
pkg
!=
null
&&
prefs
.
all
.
isEmpty
())
runCatching
{
if
(
pkg
!=
null
&&
prefs
.
all
.
isEmpty
())
runCatching
{
context
.
contentResolver
.
openInputStream
(
Provider
.
PREFS_URI
(
pkg
))
?.
use
{
context
.
contentResolver
.
openInputStream
(
Provider
.
preferencesUri
(
pkg
))
?.
use
{
prefs
.
edit
{
parsePrefs
(
it
)
}
prefs
.
edit
{
parsePrefs
(
it
)
}
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/core/Provider.kt
View file @
fa60daf9
...
@@ -6,7 +6,6 @@ import android.os.ParcelFileDescriptor
...
@@ -6,7 +6,6 @@ import android.os.ParcelFileDescriptor
import
android.os.ParcelFileDescriptor.MODE_READ_ONLY
import
android.os.ParcelFileDescriptor.MODE_READ_ONLY
import
com.topjohnwu.magisk.core.base.BaseProvider
import
com.topjohnwu.magisk.core.base.BaseProvider
import
com.topjohnwu.magisk.core.su.SuCallbackHandler
import
com.topjohnwu.magisk.core.su.SuCallbackHandler
import
java.io.File
class
Provider
:
BaseProvider
()
{
class
Provider
:
BaseProvider
()
{
...
@@ -17,17 +16,13 @@ class Provider : BaseProvider() {
...
@@ -17,17 +16,13 @@ class Provider : BaseProvider() {
override
fun
openFile
(
uri
:
Uri
,
mode
:
String
):
ParcelFileDescriptor
?
{
override
fun
openFile
(
uri
:
Uri
,
mode
:
String
):
ParcelFileDescriptor
?
{
return
when
(
uri
.
encodedPath
?:
return
null
)
{
return
when
(
uri
.
encodedPath
?:
return
null
)
{
"/apk_file"
->
ParcelFileDescriptor
.
open
(
File
(
context
!!
.
packageCodePath
),
MODE_READ_ONLY
)
"/prefs_file"
->
ParcelFileDescriptor
.
open
(
Config
.
prefsFile
,
MODE_READ_ONLY
)
"/prefs_file"
->
ParcelFileDescriptor
.
open
(
Config
.
prefsFile
,
MODE_READ_ONLY
)
else
->
super
.
openFile
(
uri
,
mode
)
else
->
super
.
openFile
(
uri
,
mode
)
}
}
}
}
companion
object
{
companion
object
{
fun
APK_URI
(
pkg
:
String
)
=
fun
preferencesUri
(
pkg
:
String
):
Uri
=
Uri
.
Builder
().
scheme
(
"content"
).
authority
(
"$pkg.provider"
).
path
(
"apk_file"
).
build
()
fun
PREFS_URI
(
pkg
:
String
)
=
Uri
.
Builder
().
scheme
(
"content"
).
authority
(
"$pkg.provider"
).
path
(
"prefs_file"
).
build
()
Uri
.
Builder
().
scheme
(
"content"
).
authority
(
"$pkg.provider"
).
path
(
"prefs_file"
).
build
()
}
}
}
}
app/src/main/java/com/topjohnwu/magisk/core/tasks/HideAPK.kt
View file @
fa60daf9
...
@@ -97,10 +97,10 @@ object HideAPK {
...
@@ -97,10 +97,10 @@ object HideAPK {
Config
.
suManager
=
if
(
pkg
==
APPLICATION_ID
)
""
else
pkg
Config
.
suManager
=
if
(
pkg
==
APPLICATION_ID
)
""
else
pkg
val
self
=
activity
.
packageName
val
self
=
activity
.
packageName
val
flag
=
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
val
flag
=
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
activity
.
grantUriPermission
(
pkg
,
Provider
.
APK_URI
(
self
),
flag
)
activity
.
grantUriPermission
(
pkg
,
Provider
.
preferencesUri
(
self
),
flag
)
activity
.
grantUriPermission
(
pkg
,
Provider
.
PREFS_URI
(
self
),
flag
)
intent
.
putExtra
(
Const
.
Key
.
PREV_PKG
,
self
)
intent
.
putExtra
(
Const
.
Key
.
PREV_PKG
,
self
)
activity
.
startActivity
(
intent
)
intent
.
flags
=
0
activity
.
startActivityForResult
(
intent
,
Int
.
MAX_VALUE
)
activity
.
finish
()
activity
.
finish
()
}
}
...
...
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