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
3f7f6e61
Commit
3f7f6e61
authored
Aug 23, 2022
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use VERSION_CODES instead of raw numbers
parent
c2f96975
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
33 additions
and
26 deletions
+33
-26
StubApk.java
app/shared/src/main/java/com/topjohnwu/magisk/StubApk.java
+3
-2
BaseActivity.kt
.../main/java/com/topjohnwu/magisk/core/base/BaseActivity.kt
+4
-3
DownloadService.kt
...ava/com/topjohnwu/magisk/core/download/DownloadService.kt
+2
-2
MediaStoreUtils.kt
...n/java/com/topjohnwu/magisk/core/utils/MediaStoreUtils.kt
+1
-1
RequestInstall.kt
...in/java/com/topjohnwu/magisk/core/utils/RequestInstall.kt
+1
-1
NetworkObserver.kt
...va/com/topjohnwu/magisk/core/utils/net/NetworkObserver.kt
+1
-1
XAndroid.kt
app/src/main/java/com/topjohnwu/magisk/ktx/XAndroid.kt
+3
-2
AppProcessInfo.kt
.../main/java/com/topjohnwu/magisk/ui/deny/AppProcessInfo.kt
+3
-1
SettingsViewModel.kt
...ava/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt
+5
-4
Notifications.kt
app/src/main/java/com/topjohnwu/magisk/view/Notifications.kt
+5
-4
Shortcuts.kt
app/src/main/java/com/topjohnwu/magisk/view/Shortcuts.kt
+2
-2
DownloadActivity.java
.../src/main/java/com/topjohnwu/magisk/DownloadActivity.java
+1
-1
DynLoad.java
stub/src/main/java/com/topjohnwu/magisk/DynLoad.java
+2
-2
No files found.
app/shared/src/main/java/com/topjohnwu/magisk/StubApk.java
View file @
3f7f6e61
...
@@ -11,6 +11,7 @@ import android.content.res.AssetManager;
...
@@ -11,6 +11,7 @@ import android.content.res.AssetManager;
import
android.content.res.Resources
;
import
android.content.res.Resources
;
import
android.content.res.loader.ResourcesLoader
;
import
android.content.res.loader.ResourcesLoader
;
import
android.content.res.loader.ResourcesProvider
;
import
android.content.res.loader.ResourcesProvider
;
import
android.os.Build
;
import
android.os.ParcelFileDescriptor
;
import
android.os.ParcelFileDescriptor
;
import
java.io.File
;
import
java.io.File
;
...
@@ -28,7 +29,7 @@ public class StubApk {
...
@@ -28,7 +29,7 @@ public class StubApk {
private
static
File
getDynDir
(
ApplicationInfo
info
)
{
private
static
File
getDynDir
(
ApplicationInfo
info
)
{
if
(
dynDir
==
null
)
{
if
(
dynDir
==
null
)
{
final
String
dataDir
;
final
String
dataDir
;
if
(
SDK_INT
>=
24
)
{
if
(
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
// Use device protected path to allow directBootAware
// Use device protected path to allow directBootAware
dataDir
=
info
.
deviceProtectedDataDir
;
dataDir
=
info
.
deviceProtectedDataDir
;
}
else
{
}
else
{
...
@@ -57,7 +58,7 @@ public class StubApk {
...
@@ -57,7 +58,7 @@ public class StubApk {
}
}
public
static
void
addAssetPath
(
Resources
res
,
String
path
)
{
public
static
void
addAssetPath
(
Resources
res
,
String
path
)
{
if
(
SDK_INT
>=
30
)
{
if
(
SDK_INT
>=
Build
.
VERSION_CODES
.
R
)
{
try
(
var
fd
=
ParcelFileDescriptor
.
open
(
new
File
(
path
),
MODE_READ_ONLY
))
{
try
(
var
fd
=
ParcelFileDescriptor
.
open
(
new
File
(
path
),
MODE_READ_ONLY
))
{
var
loader
=
new
ResourcesLoader
();
var
loader
=
new
ResourcesLoader
();
loader
.
addProvider
(
ResourcesProvider
.
loadFromApk
(
fd
));
loader
.
addProvider
(
ResourcesProvider
.
loadFromApk
(
fd
));
...
...
app/src/main/java/com/topjohnwu/magisk/core/base/BaseActivity.kt
View file @
3f7f6e61
...
@@ -52,7 +52,7 @@ abstract class BaseActivity : AppCompatActivity() {
...
@@ -52,7 +52,7 @@ abstract class BaseActivity : AppCompatActivity() {
val
realCallingPackage
:
String
?
get
()
{
val
realCallingPackage
:
String
?
get
()
{
callingPackage
?.
let
{
return
it
}
callingPackage
?.
let
{
return
it
}
if
(
Build
.
VERSION
.
SDK_INT
>=
22
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP_MR1
)
{
mReferrerField
.
get
(
this
)
?.
let
{
return
it
as
String
}
mReferrerField
.
get
(
this
)
?.
let
{
return
it
as
String
}
}
}
return
null
return
null
...
@@ -82,8 +82,9 @@ abstract class BaseActivity : AppCompatActivity() {
...
@@ -82,8 +82,9 @@ abstract class BaseActivity : AppCompatActivity() {
}
}
fun
withPermission
(
permission
:
String
,
callback
:
(
Boolean
)
->
Unit
)
{
fun
withPermission
(
permission
:
String
,
callback
:
(
Boolean
)
->
Unit
)
{
if
(
permission
==
WRITE_EXTERNAL_STORAGE
&&
Build
.
VERSION
.
SDK_INT
>=
30
)
{
if
(
permission
==
WRITE_EXTERNAL_STORAGE
&&
// We do not need external rw on 30+
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
R
)
{
// We do not need external rw on R+
callback
(
true
)
callback
(
true
)
return
return
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/core/download/DownloadService.kt
View file @
3f7f6e61
...
@@ -199,7 +199,7 @@ class DownloadService : NotificationService() {
...
@@ -199,7 +199,7 @@ class DownloadService : NotificationService() {
fun
getPendingIntent
(
context
:
Context
,
subject
:
Subject
):
PendingIntent
{
fun
getPendingIntent
(
context
:
Context
,
subject
:
Subject
):
PendingIntent
{
val
flag
=
FLAG_IMMUTABLE
or
FLAG_UPDATE_CURRENT
or
FLAG_ONE_SHOT
val
flag
=
FLAG_IMMUTABLE
or
FLAG_UPDATE_CURRENT
or
FLAG_ONE_SHOT
val
intent
=
intent
(
context
,
subject
)
val
intent
=
intent
(
context
,
subject
)
return
if
(
Build
.
VERSION
.
SDK_INT
>=
26
)
{
return
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
getForegroundService
(
context
,
REQUEST_CODE
,
intent
,
flag
)
getForegroundService
(
context
,
REQUEST_CODE
,
intent
,
flag
)
}
else
{
}
else
{
getService
(
context
,
REQUEST_CODE
,
intent
,
flag
)
getService
(
context
,
REQUEST_CODE
,
intent
,
flag
)
...
@@ -208,7 +208,7 @@ class DownloadService : NotificationService() {
...
@@ -208,7 +208,7 @@ class DownloadService : NotificationService() {
fun
start
(
context
:
Context
,
subject
:
Subject
)
{
fun
start
(
context
:
Context
,
subject
:
Subject
)
{
val
app
=
context
.
applicationContext
val
app
=
context
.
applicationContext
if
(
Build
.
VERSION
.
SDK_INT
>=
26
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
app
.
startForegroundService
(
intent
(
app
,
subject
))
app
.
startForegroundService
(
intent
(
app
,
subject
))
}
else
{
}
else
{
app
.
startService
(
intent
(
app
,
subject
))
app
.
startService
(
intent
(
app
,
subject
))
...
...
app/src/main/java/com/topjohnwu/magisk/core/utils/MediaStoreUtils.kt
View file @
3f7f6e61
...
@@ -87,7 +87,7 @@ object MediaStoreUtils {
...
@@ -87,7 +87,7 @@ object MediaStoreUtils {
@Throws
(
IOException
::
class
)
@Throws
(
IOException
::
class
)
fun
getFile
(
displayName
:
String
,
skipQuery
:
Boolean
=
false
):
UriFile
{
fun
getFile
(
displayName
:
String
,
skipQuery
:
Boolean
=
false
):
UriFile
{
if
(
Build
.
VERSION
.
SDK_INT
<
30
)
{
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
R
)
{
// Fallback to file based I/O pre Android 11
// Fallback to file based I/O pre Android 11
val
parent
=
File
(
Environment
.
getExternalStorageDirectory
(),
relativePath
)
val
parent
=
File
(
Environment
.
getExternalStorageDirectory
(),
relativePath
)
parent
.
mkdirs
()
parent
.
mkdirs
()
...
...
app/src/main/java/com/topjohnwu/magisk/core/utils/RequestInstall.kt
View file @
3f7f6e61
...
@@ -25,7 +25,7 @@ class RequestInstall : ActivityResultContract<Unit, Boolean>() {
...
@@ -25,7 +25,7 @@ class RequestInstall : ActivityResultContract<Unit, Boolean>() {
context
:
Context
,
context
:
Context
,
input
:
Unit
input
:
Unit
):
SynchronousResult
<
Boolean
>?
{
):
SynchronousResult
<
Boolean
>?
{
if
(
Build
.
VERSION
.
SDK_INT
<
26
)
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
O
)
return
SynchronousResult
(
true
)
return
SynchronousResult
(
true
)
if
(
context
.
packageManager
.
canRequestPackageInstalls
())
if
(
context
.
packageManager
.
canRequestPackageInstalls
())
return
SynchronousResult
(
true
)
return
SynchronousResult
(
true
)
...
...
app/src/main/java/com/topjohnwu/magisk/core/utils/net/NetworkObserver.kt
View file @
3f7f6e61
...
@@ -20,7 +20,7 @@ abstract class NetworkObserver(
...
@@ -20,7 +20,7 @@ abstract class NetworkObserver(
companion
object
{
companion
object
{
fun
observe
(
context
:
Context
,
callback
:
ConnectionCallback
):
NetworkObserver
{
fun
observe
(
context
:
Context
,
callback
:
ConnectionCallback
):
NetworkObserver
{
val
observer
:
NetworkObserver
=
if
(
Build
.
VERSION
.
SDK_INT
>=
23
)
val
observer
:
NetworkObserver
=
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
MarshmallowNetworkObserver
(
context
,
callback
)
MarshmallowNetworkObserver
(
context
,
callback
)
else
LollipopNetworkObserver
(
context
,
callback
)
else
LollipopNetworkObserver
(
context
,
callback
)
return
observer
.
apply
{
getCurrentState
()
}
return
observer
.
apply
{
getCurrentState
()
}
...
...
app/src/main/java/com/topjohnwu/magisk/ktx/XAndroid.kt
View file @
3f7f6e61
...
@@ -17,6 +17,7 @@ import android.graphics.drawable.AdaptiveIconDrawable
...
@@ -17,6 +17,7 @@ import android.graphics.drawable.AdaptiveIconDrawable
import
android.graphics.drawable.BitmapDrawable
import
android.graphics.drawable.BitmapDrawable
import
android.graphics.drawable.LayerDrawable
import
android.graphics.drawable.LayerDrawable
import
android.net.Uri
import
android.net.Uri
import
android.os.Build
import
android.os.Build.VERSION.SDK_INT
import
android.os.Build.VERSION.SDK_INT
import
android.os.Process
import
android.os.Process
import
android.view.View
import
android.view.View
...
@@ -44,7 +45,7 @@ fun Context.getBitmap(id: Int): Bitmap {
...
@@ -44,7 +45,7 @@ fun Context.getBitmap(id: Int): Bitmap {
var
drawable
=
AppCompatResources
.
getDrawable
(
this
,
id
)
!!
var
drawable
=
AppCompatResources
.
getDrawable
(
this
,
id
)
!!
if
(
drawable
is
BitmapDrawable
)
if
(
drawable
is
BitmapDrawable
)
return
drawable
.
bitmap
return
drawable
.
bitmap
if
(
SDK_INT
>=
26
&&
drawable
is
AdaptiveIconDrawable
)
{
if
(
SDK_INT
>=
Build
.
VERSION_CODES
.
O
&&
drawable
is
AdaptiveIconDrawable
)
{
drawable
=
LayerDrawable
(
arrayOf
(
drawable
.
background
,
drawable
.
foreground
))
drawable
=
LayerDrawable
(
arrayOf
(
drawable
.
background
,
drawable
.
foreground
))
}
}
val
bitmap
=
Bitmap
.
createBitmap
(
val
bitmap
=
Bitmap
.
createBitmap
(
...
@@ -58,7 +59,7 @@ fun Context.getBitmap(id: Int): Bitmap {
...
@@ -58,7 +59,7 @@ fun Context.getBitmap(id: Int): Bitmap {
}
}
val
Context
.
deviceProtectedContext
:
Context
get
()
=
val
Context
.
deviceProtectedContext
:
Context
get
()
=
if
(
SDK_INT
>=
24
)
{
if
(
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
createDeviceProtectedStorageContext
()
createDeviceProtectedStorageContext
()
}
else
{
this
}
}
else
{
this
}
...
...
app/src/main/java/com/topjohnwu/magisk/ui/deny/AppProcessInfo.kt
View file @
3f7f6e61
...
@@ -7,6 +7,7 @@ import android.content.pm.PackageManager
...
@@ -7,6 +7,7 @@ import android.content.pm.PackageManager
import
android.content.pm.PackageManager.*
import
android.content.pm.PackageManager.*
import
android.content.pm.ServiceInfo
import
android.content.pm.ServiceInfo
import
android.graphics.drawable.Drawable
import
android.graphics.drawable.Drawable
import
android.os.Build
import
android.os.Build.VERSION.SDK_INT
import
android.os.Build.VERSION.SDK_INT
import
androidx.core.os.ProcessCompat
import
androidx.core.os.ProcessCompat
import
com.topjohnwu.magisk.core.utils.currentLocale
import
com.topjohnwu.magisk.core.utils.currentLocale
...
@@ -67,7 +68,8 @@ class AppProcessInfo(
...
@@ -67,7 +68,8 @@ class AppProcessInfo(
val
proc
=
info
.
processName
?:
info
.
packageName
val
proc
=
info
.
processName
?:
info
.
packageName
createProcess
(
"${proc}_zygote"
)
createProcess
(
"${proc}_zygote"
)
}
else
{
}
else
{
val
proc
=
if
(
SDK_INT
>=
29
)
"${it.getProcName()}:${it.name}"
else
it
.
getProcName
()
val
proc
=
if
(
SDK_INT
>=
Build
.
VERSION_CODES
.
Q
)
"${it.getProcName()}:${it.name}"
else
it
.
getProcName
()
createProcess
(
proc
,
ISOLATED_MAGIC
)
createProcess
(
proc
,
ISOLATED_MAGIC
)
}
}
}
else
{
}
else
{
...
...
app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt
View file @
3f7f6e61
...
@@ -53,7 +53,8 @@ class SettingsViewModel : BaseViewModel(), BaseSettingsItem.Handler {
...
@@ -53,7 +53,8 @@ class SettingsViewModel : BaseViewModel(), BaseSettingsItem.Handler {
AppSettings
,
AppSettings
,
UpdateChannel
,
UpdateChannelUrl
,
DoHToggle
,
UpdateChecker
,
DownloadPath
UpdateChannel
,
UpdateChannelUrl
,
DoHToggle
,
UpdateChecker
,
DownloadPath
))
))
if
(
Build
.
VERSION
.
SDK_INT
>=
22
&&
Info
.
env
.
isActive
&&
Const
.
USER_ID
==
0
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP_MR1
&&
Info
.
env
.
isActive
&&
Const
.
USER_ID
==
0
)
{
if
(
hidden
)
list
.
add
(
Restore
)
else
list
.
add
(
Hide
)
if
(
hidden
)
list
.
add
(
Restore
)
else
list
.
add
(
Hide
)
}
}
...
@@ -75,15 +76,15 @@ class SettingsViewModel : BaseViewModel(), BaseSettingsItem.Handler {
...
@@ -75,15 +76,15 @@ class SettingsViewModel : BaseViewModel(), BaseSettingsItem.Handler {
Tapjack
,
Biometrics
,
AccessMode
,
MultiuserMode
,
MountNamespaceMode
,
Tapjack
,
Biometrics
,
AccessMode
,
MultiuserMode
,
MountNamespaceMode
,
AutomaticResponse
,
RequestTimeout
,
SUNotification
AutomaticResponse
,
RequestTimeout
,
SUNotification
))
))
if
(
Build
.
VERSION
.
SDK_INT
<
23
)
{
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
M
)
{
// Biometric is only available on 6.0+
// Biometric is only available on 6.0+
list
.
remove
(
Biometrics
)
list
.
remove
(
Biometrics
)
}
}
if
(
Build
.
VERSION
.
SDK_INT
<
26
)
{
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
O
)
{
// Re-authenticate is not feasible on 8.0+
// Re-authenticate is not feasible on 8.0+
list
.
add
(
Reauthenticate
)
list
.
add
(
Reauthenticate
)
}
}
if
(
Build
.
VERSION
.
SDK_INT
>=
31
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
S
)
{
// Can hide overlay windows on 12.0+
// Can hide overlay windows on 12.0+
list
.
remove
(
Tapjack
)
list
.
remove
(
Tapjack
)
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/view/Notifications.kt
View file @
3f7f6e61
...
@@ -7,6 +7,7 @@ import android.app.NotificationManager
...
@@ -7,6 +7,7 @@ import android.app.NotificationManager
import
android.app.PendingIntent
import
android.app.PendingIntent
import
android.content.Context
import
android.content.Context
import
android.content.Intent
import
android.content.Intent
import
android.os.Build
import
android.os.Build.VERSION.SDK_INT
import
android.os.Build.VERSION.SDK_INT
import
androidx.core.content.getSystemService
import
androidx.core.content.getSystemService
import
androidx.core.graphics.drawable.toIcon
import
androidx.core.graphics.drawable.toIcon
...
@@ -32,7 +33,7 @@ object Notifications {
...
@@ -32,7 +33,7 @@ object Notifications {
private
val
nextId
=
AtomicInteger
(
APP_UPDATE_NOTIFICATION_ID
)
private
val
nextId
=
AtomicInteger
(
APP_UPDATE_NOTIFICATION_ID
)
fun
setup
(
context
:
Context
)
{
fun
setup
(
context
:
Context
)
{
if
(
SDK_INT
>=
26
)
{
if
(
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
val
channel
=
NotificationChannel
(
UPDATE_CHANNEL
,
val
channel
=
NotificationChannel
(
UPDATE_CHANNEL
,
context
.
getString
(
R
.
string
.
update_channel
),
NotificationManager
.
IMPORTANCE_DEFAULT
)
context
.
getString
(
R
.
string
.
update_channel
),
NotificationManager
.
IMPORTANCE_DEFAULT
)
val
channel2
=
NotificationChannel
(
PROGRESS_CHANNEL
,
val
channel2
=
NotificationChannel
(
PROGRESS_CHANNEL
,
...
@@ -55,7 +56,7 @@ object Notifications {
...
@@ -55,7 +56,7 @@ object Notifications {
setup
(
context
)
setup
(
context
)
val
flag
=
PendingIntent
.
FLAG_IMMUTABLE
or
PendingIntent
.
FLAG_UPDATE_CURRENT
val
flag
=
PendingIntent
.
FLAG_IMMUTABLE
or
PendingIntent
.
FLAG_UPDATE_CURRENT
val
pending
=
PendingIntent
.
getActivity
(
context
,
0
,
selfLaunchIntent
(
context
),
flag
)
val
pending
=
PendingIntent
.
getActivity
(
context
,
0
,
selfLaunchIntent
(
context
),
flag
)
val
builder
=
if
(
SDK_INT
>=
26
)
{
val
builder
=
if
(
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
Notification
.
Builder
(
context
,
UPDATED_CHANNEL
)
Notification
.
Builder
(
context
,
UPDATED_CHANNEL
)
.
setSmallIcon
(
context
.
getBitmap
(
R
.
drawable
.
ic_magisk_outline
).
toIcon
())
.
setSmallIcon
(
context
.
getBitmap
(
R
.
drawable
.
ic_magisk_outline
).
toIcon
())
}
else
{
}
else
{
...
@@ -73,7 +74,7 @@ object Notifications {
...
@@ -73,7 +74,7 @@ object Notifications {
val
intent
=
DownloadService
.
getPendingIntent
(
context
,
Subject
.
App
())
val
intent
=
DownloadService
.
getPendingIntent
(
context
,
Subject
.
App
())
val
bitmap
=
context
.
getBitmap
(
R
.
drawable
.
ic_magisk_outline
)
val
bitmap
=
context
.
getBitmap
(
R
.
drawable
.
ic_magisk_outline
)
val
builder
=
if
(
SDK_INT
>=
26
)
{
val
builder
=
if
(
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
Notification
.
Builder
(
context
,
UPDATE_CHANNEL
)
Notification
.
Builder
(
context
,
UPDATE_CHANNEL
)
.
setSmallIcon
(
bitmap
.
toIcon
())
.
setSmallIcon
(
bitmap
.
toIcon
())
}
else
{
}
else
{
...
@@ -90,7 +91,7 @@ object Notifications {
...
@@ -90,7 +91,7 @@ object Notifications {
}
}
fun
progress
(
context
:
Context
,
title
:
CharSequence
):
Notification
.
Builder
{
fun
progress
(
context
:
Context
,
title
:
CharSequence
):
Notification
.
Builder
{
val
builder
=
if
(
SDK_INT
>=
26
)
{
val
builder
=
if
(
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
Notification
.
Builder
(
context
,
PROGRESS_CHANNEL
)
Notification
.
Builder
(
context
,
PROGRESS_CHANNEL
)
}
else
{
}
else
{
Notification
.
Builder
(
context
).
setPriority
(
Notification
.
PRIORITY_LOW
)
Notification
.
Builder
(
context
).
setPriority
(
Notification
.
PRIORITY_LOW
)
...
...
app/src/main/java/com/topjohnwu/magisk/view/Shortcuts.kt
View file @
3f7f6e61
...
@@ -19,7 +19,7 @@ import com.topjohnwu.magisk.utils.Utils
...
@@ -19,7 +19,7 @@ import com.topjohnwu.magisk.utils.Utils
object
Shortcuts
{
object
Shortcuts
{
fun
setupDynamic
(
context
:
Context
)
{
fun
setupDynamic
(
context
:
Context
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
25
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N_MR1
)
{
val
manager
=
context
.
getSystemService
<
ShortcutManager
>()
?:
return
val
manager
=
context
.
getSystemService
<
ShortcutManager
>()
?:
return
manager
.
dynamicShortcuts
=
getShortCuts
(
context
)
manager
.
dynamicShortcuts
=
getShortCuts
(
context
)
}
}
...
@@ -36,7 +36,7 @@ object Shortcuts {
...
@@ -36,7 +36,7 @@ object Shortcuts {
}
}
private
fun
Context
.
getIconCompat
(
id
:
Int
):
IconCompat
{
private
fun
Context
.
getIconCompat
(
id
:
Int
):
IconCompat
{
return
if
(
Build
.
VERSION
.
SDK_INT
>=
26
)
return
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
IconCompat
.
createWithAdaptiveBitmap
(
getBitmap
(
id
))
IconCompat
.
createWithAdaptiveBitmap
(
getBitmap
(
id
))
else
else
IconCompat
.
createWithBitmap
(
getBitmap
(
id
))
IconCompat
.
createWithBitmap
(
getBitmap
(
id
))
...
...
stub/src/main/java/com/topjohnwu/magisk/DownloadActivity.java
View file @
3f7f6e61
...
@@ -186,7 +186,7 @@ public class DownloadActivity extends Activity {
...
@@ -186,7 +186,7 @@ public class DownloadActivity extends Activity {
}
}
private
void
loadResources
()
throws
Exception
{
private
void
loadResources
()
throws
Exception
{
if
(
Build
.
VERSION
.
SDK_INT
>=
30
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
R
)
{
var
fd
=
Os
.
memfd_create
(
"res.apk"
,
0
);
var
fd
=
Os
.
memfd_create
(
"res.apk"
,
0
);
try
{
try
{
decryptResources
(
new
FileOutputStream
(
fd
));
decryptResources
(
new
FileOutputStream
(
fd
));
...
...
stub/src/main/java/com/topjohnwu/magisk/DynLoad.java
View file @
3f7f6e61
...
@@ -104,7 +104,7 @@ public class DynLoad {
...
@@ -104,7 +104,7 @@ public class DynLoad {
// Dynamically load APK and create the Application instance from the loaded APK
// Dynamically load APK and create the Application instance from the loaded APK
static
Application
createAndSetupApp
(
Application
context
)
{
static
Application
createAndSetupApp
(
Application
context
)
{
// On API >= 29, AppComponentFactory will replace the ClassLoader for us
// On API >= 29, AppComponentFactory will replace the ClassLoader for us
if
(
Build
.
VERSION
.
SDK_INT
<
29
)
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
Q
)
replaceClassLoader
(
context
);
replaceClassLoader
(
context
);
// noinspection InlinedApi
// noinspection InlinedApi
...
@@ -145,7 +145,7 @@ public class DynLoad {
...
@@ -145,7 +145,7 @@ public class DynLoad {
.
newInstance
(
data
.
getObject
());
.
newInstance
(
data
.
getObject
());
// Create the receiver component factory
// Create the receiver component factory
if
(
Build
.
VERSION
.
SDK_INT
>=
28
&&
componentFactory
!=
null
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
P
&&
componentFactory
!=
null
)
{
Object
factory
=
cl
.
loadClass
(
appInfo
.
appComponentFactory
).
newInstance
();
Object
factory
=
cl
.
loadClass
(
appInfo
.
appComponentFactory
).
newInstance
();
var
delegate
=
(
DelegateComponentFactory
)
componentFactory
;
var
delegate
=
(
DelegateComponentFactory
)
componentFactory
;
delegate
.
receiver
=
(
AppComponentFactory
)
factory
;
delegate
.
receiver
=
(
AppComponentFactory
)
factory
;
...
...
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