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
a328e2bf
Commit
a328e2bf
authored
Apr 18, 2021
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hide annoying stack traces when hidden
parent
4c1ea0e4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
7 deletions
+23
-7
proguard-rules.pro
app/proguard-rules.pro
+4
-0
BaseActivity.kt
.../main/java/com/topjohnwu/magisk/core/base/BaseActivity.kt
+11
-0
XJava.kt
app/src/main/java/com/topjohnwu/magisk/ktx/XJava.kt
+4
-0
CheckSafetyNetEvent.kt
.../com/topjohnwu/magisk/ui/safetynet/CheckSafetyNetEvent.kt
+4
-7
No files found.
app/proguard-rules.pro
View file @
a328e2bf
...
@@ -31,6 +31,10 @@
...
@@ -31,6 +31,10 @@
# Stub
# Stub
-
keep
class
com
.
topjohnwu
.
magisk
.
core
.
App
{
<
init
>
(
java
.
lang
.
Object
);
}
-
keep
class
com
.
topjohnwu
.
magisk
.
core
.
App
{
<
init
>
(
java
.
lang
.
Object
);
}
-
keepclassmembers
class
androidx
.
appcompat
.
app
.
AppCompatDelegateImpl
{
boolean
mActivityHandlesUiModeChecked
;
boolean
mActivityHandlesUiMode
;
}
# Strip Timber verbose and debug logging
# Strip Timber verbose and debug logging
-
assumenosideeffects
class
timber
.
log
.
Timber
$
Tree
{
-
assumenosideeffects
class
timber
.
log
.
Timber
$
Tree
{
...
...
app/src/main/java/com/topjohnwu/magisk/core/base/BaseActivity.kt
View file @
a328e2bf
...
@@ -7,6 +7,7 @@ import android.content.Intent
...
@@ -7,6 +7,7 @@ import android.content.Intent
import
android.content.pm.PackageManager
import
android.content.pm.PackageManager
import
android.content.res.Configuration
import
android.content.res.Configuration
import
android.os.Build
import
android.os.Build
import
android.os.Bundle
import
android.widget.Toast
import
android.widget.Toast
import
androidx.annotation.CallSuper
import
androidx.annotation.CallSuper
import
androidx.appcompat.app.AppCompatActivity
import
androidx.appcompat.app.AppCompatActivity
...
@@ -16,6 +17,7 @@ import androidx.core.content.ContextCompat
...
@@ -16,6 +17,7 @@ import androidx.core.content.ContextCompat
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.core.utils.currentLocale
import
com.topjohnwu.magisk.core.utils.currentLocale
import
com.topjohnwu.magisk.core.wrap
import
com.topjohnwu.magisk.core.wrap
import
com.topjohnwu.magisk.ktx.reflectField
import
com.topjohnwu.magisk.ktx.set
import
com.topjohnwu.magisk.ktx.set
import
com.topjohnwu.magisk.utils.Utils
import
com.topjohnwu.magisk.utils.Utils
import
kotlin.random.Random
import
kotlin.random.Random
...
@@ -43,6 +45,15 @@ abstract class BaseActivity : AppCompatActivity() {
...
@@ -43,6 +45,15 @@ abstract class BaseActivity : AppCompatActivity() {
super
.
attachBaseContext
(
base
.
wrap
(
true
))
super
.
attachBaseContext
(
base
.
wrap
(
true
))
}
}
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
// Overwrite private members to avoid nasty "false" stack traces being logged
val
delegate
=
delegate
val
clz
=
delegate
.
javaClass
clz
.
reflectField
(
"mActivityHandlesUiModeChecked"
).
set
(
delegate
,
true
)
clz
.
reflectField
(
"mActivityHandlesUiMode"
).
set
(
delegate
,
false
)
super
.
onCreate
(
savedInstanceState
)
}
fun
withPermission
(
permission
:
String
,
builder
:
PermissionRequestBuilder
.()
->
Unit
)
{
fun
withPermission
(
permission
:
String
,
builder
:
PermissionRequestBuilder
.()
->
Unit
)
{
val
request
=
PermissionRequestBuilder
().
apply
(
builder
).
build
()
val
request
=
PermissionRequestBuilder
().
apply
(
builder
).
build
()
...
...
app/src/main/java/com/topjohnwu/magisk/ktx/XJava.kt
View file @
a328e2bf
...
@@ -5,6 +5,7 @@ import timber.log.Timber
...
@@ -5,6 +5,7 @@ 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.text.SimpleDateFormat
import
java.text.SimpleDateFormat
import
java.util.*
import
java.util.*
import
java.util.zip.ZipEntry
import
java.util.zip.ZipEntry
...
@@ -48,3 +49,6 @@ fun <K, V> MutableMap<K, V>.synchronized() = Collections.synchronizedMap(this)
...
@@ -48,3 +49,6 @@ fun <K, V> MutableMap<K, V>.synchronized() = Collections.synchronizedMap(this)
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
()
fun
Class
<*>.
reflectField
(
name
:
String
):
Field
=
getDeclaredField
(
name
).
apply
{
isAccessible
=
true
}
app/src/main/java/com/topjohnwu/magisk/ui/safetynet/CheckSafetyNetEvent.kt
View file @
a328e2bf
...
@@ -13,6 +13,7 @@ import com.topjohnwu.magisk.arch.ViewEventWithScope
...
@@ -13,6 +13,7 @@ import com.topjohnwu.magisk.arch.ViewEventWithScope
import
com.topjohnwu.magisk.core.Const
import
com.topjohnwu.magisk.core.Const
import
com.topjohnwu.magisk.data.repository.NetworkService
import
com.topjohnwu.magisk.data.repository.NetworkService
import
com.topjohnwu.magisk.ktx.createClassLoader
import
com.topjohnwu.magisk.ktx.createClassLoader
import
com.topjohnwu.magisk.ktx.reflectField
import
com.topjohnwu.magisk.ktx.writeTo
import
com.topjohnwu.magisk.ktx.writeTo
import
com.topjohnwu.magisk.view.MagiskDialog
import
com.topjohnwu.magisk.view.MagiskDialog
import
com.topjohnwu.signing.CryptoUtils
import
com.topjohnwu.signing.CryptoUtils
...
@@ -31,7 +32,6 @@ import timber.log.Timber
...
@@ -31,7 +32,6 @@ import timber.log.Timber
import
java.io.ByteArrayInputStream
import
java.io.ByteArrayInputStream
import
java.io.File
import
java.io.File
import
java.io.IOException
import
java.io.IOException
import
java.lang.reflect.Field
import
java.lang.reflect.InvocationHandler
import
java.lang.reflect.InvocationHandler
import
java.security.GeneralSecurityException
import
java.security.GeneralSecurityException
import
java.security.SecureRandom
import
java.security.SecureRandom
...
@@ -100,14 +100,11 @@ class CheckSafetyNetEvent(
...
@@ -100,14 +100,11 @@ class CheckSafetyNetEvent(
helper
.
attest
(
nonce
)
helper
.
attest
(
nonce
)
}
}
private
fun
Class
<*>.
field
(
name
:
String
):
Field
=
getDeclaredField
(
name
).
apply
{
isAccessible
=
true
}
// All of these fields are whitelisted
// All of these fields are whitelisted
private
fun
BaseDexClassLoader
.
getDexFiles
():
List
<
DexFile
>
{
private
fun
BaseDexClassLoader
.
getDexFiles
():
List
<
DexFile
>
{
val
pathList
=
BaseDexClassLoader
::
class
.
java
.
f
ield
(
"pathList"
).
get
(
this
)
val
pathList
=
BaseDexClassLoader
::
class
.
java
.
reflectF
ield
(
"pathList"
).
get
(
this
)
val
dexElements
=
pathList
.
javaClass
.
f
ield
(
"dexElements"
).
get
(
pathList
)
as
Array
<*>
val
dexElements
=
pathList
.
javaClass
.
reflectF
ield
(
"dexElements"
).
get
(
pathList
)
as
Array
<*>
val
fileField
=
dexElements
.
javaClass
.
componentType
.
f
ield
(
"dexFile"
)
val
fileField
=
dexElements
.
javaClass
.
componentType
.
reflectF
ield
(
"dexFile"
)
return
dexElements
.
map
{
fileField
.
get
(
it
)
as
DexFile
}
return
dexElements
.
map
{
fileField
.
get
(
it
)
as
DexFile
}
}
}
...
...
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