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
57985365
Commit
57985365
authored
Jan 23, 2021
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unnecessary hacks
parent
ab9a83c8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
33 deletions
+3
-33
Hacks.kt
app/src/main/java/com/topjohnwu/magisk/core/Hacks.kt
+3
-2
XJava.kt
app/src/main/java/com/topjohnwu/magisk/ktx/XJava.kt
+0
-31
No files found.
app/src/main/java/com/topjohnwu/magisk/core/Hacks.kt
View file @
57985365
...
@@ -20,7 +20,6 @@ import com.topjohnwu.magisk.R
...
@@ -20,7 +20,6 @@ import com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.core.download.DownloadService
import
com.topjohnwu.magisk.core.download.DownloadService
import
com.topjohnwu.magisk.core.utils.refreshLocale
import
com.topjohnwu.magisk.core.utils.refreshLocale
import
com.topjohnwu.magisk.core.utils.updateConfig
import
com.topjohnwu.magisk.core.utils.updateConfig
import
com.topjohnwu.magisk.ktx.forceGetDeclaredField
import
com.topjohnwu.magisk.ui.MainActivity
import
com.topjohnwu.magisk.ui.MainActivity
import
com.topjohnwu.magisk.ui.surequest.SuRequestActivity
import
com.topjohnwu.magisk.ui.surequest.SuRequestActivity
...
@@ -137,8 +136,10 @@ private class JobSchedulerWrapper(private val base: JobScheduler) : JobScheduler
...
@@ -137,8 +136,10 @@ private class JobSchedulerWrapper(private val base: JobScheduler) : JobScheduler
service
.
packageName
,
service
.
packageName
,
Info
.
stubChk
.
classToComponent
[
name
]
?:
name
Info
.
stubChk
.
classToComponent
[
name
]
?:
name
)
)
javaClass
.
getDeclaredField
(
"service"
).
apply
{
isAccessible
=
true
}.
set
(
this
,
component
)
javaClass
.
forceGetDeclaredField
(
"service"
)
?.
set
(
this
,
component
)
return
this
return
this
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/ktx/XJava.kt
View file @
57985365
...
@@ -6,8 +6,6 @@ import timber.log.Timber
...
@@ -6,8 +6,6 @@ import timber.log.Timber
import
java.io.File
import
java.io.File
import
java.io.InputStream
import
java.io.InputStream
import
java.io.OutputStream
import
java.io.OutputStream
import
java.lang.reflect.Field
import
java.lang.reflect.Method
import
java.text.SimpleDateFormat
import
java.text.SimpleDateFormat
import
java.util.*
import
java.util.*
import
java.util.zip.ZipEntry
import
java.util.zip.ZipEntry
...
@@ -110,32 +108,3 @@ fun Locale.toLangTag(): String {
...
@@ -110,32 +108,3 @@ fun Locale.toLangTag(): String {
fun
SimpleDateFormat
.
parseOrNull
(
date
:
String
)
=
fun
SimpleDateFormat
.
parseOrNull
(
date
:
String
)
=
runCatching
{
parse
(
date
)
}.
onFailure
{
Timber
.
e
(
it
)
}.
getOrNull
()
runCatching
{
parse
(
date
)
}.
onFailure
{
Timber
.
e
(
it
)
}.
getOrNull
()
// Reflection hacks
private
val
loadClass
=
ClassLoader
::
class
.
java
.
getMethod
(
"loadClass"
,
String
::
class
.
java
)
private
val
getDeclaredMethod
=
Class
::
class
.
java
.
getMethod
(
"getDeclaredMethod"
,
String
::
class
.
java
,
arrayOf
<
Class
<*>>()
::
class
.
java
)
private
val
getDeclaredField
=
Class
::
class
.
java
.
getMethod
(
"getDeclaredField"
,
String
::
class
.
java
)
fun
ClassLoader
.
forceLoadClass
(
name
:
String
)
=
runCatching
{
loadClass
.
invoke
(
this
,
name
)
}.
getOrNull
()
as
Class
<*>?
fun
Class
<*>.
forceGetDeclaredMethod
(
name
:
String
,
vararg
types
:
Class
<
*
>)
=
(
runCatching
{
getDeclaredMethod
.
invoke
(
this
,
name
,
types
)
}.
getOrNull
()
as
Method
?)
?.
also
{
it
.
isAccessible
=
true
}
fun
Class
<*>.
forceGetDeclaredField
(
name
:
String
)
=
(
runCatching
{
getDeclaredField
.
invoke
(
this
,
name
)
}.
getOrNull
()
as
Field
?)
?.
also
{
it
.
isAccessible
=
true
}
inline
fun
<
reified
T
>
T
.
forceGetClass
(
name
:
String
)
=
T
::
class
.
java
.
classLoader
?.
forceLoadClass
(
name
)
fun
Class
<*>.
forceGetField
(
name
:
String
):
Field
?
=
forceGetDeclaredField
(
name
)
?:
superclass
?.
forceGetField
(
name
)
fun
Class
<*>.
forceGetMethod
(
name
:
String
,
vararg
types
:
Class
<
*
>):
Method
?
=
forceGetDeclaredMethod
(
name
,
*
types
)
?:
superclass
?.
forceGetMethod
(
name
,
*
types
)
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