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
4b30b224
Commit
4b30b224
authored
Jun 08, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove separate constant class
parent
16b232d2
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
24 additions
and
48 deletions
+24
-48
Const.kt
app/src/main/java/com/topjohnwu/magisk/Const.kt
+10
-14
Constants.kt
app/src/main/java/com/topjohnwu/magisk/Constants.kt
+0
-20
PolicyDao.kt
...main/java/com/topjohnwu/magisk/data/database/PolicyDao.kt
+2
-2
GithubRawApiServices.kt
...com/topjohnwu/magisk/data/network/GithubRawApiServices.kt
+3
-3
LogRepository.kt
...ava/com/topjohnwu/magisk/data/repository/LogRepository.kt
+1
-2
NetworkingModule.kt
...src/main/java/com/topjohnwu/magisk/di/NetworkingModule.kt
+2
-2
MagiskModule.kt
...in/java/com/topjohnwu/magisk/model/entity/MagiskModule.kt
+2
-2
FingerprintHelper.java
...in/java/com/topjohnwu/magisk/utils/FingerprintHelper.java
+3
-2
build.gradle
build.gradle
+1
-1
No files found.
app/src/main/java/com/topjohnwu/magisk/Const.kt
View file @
4b30b224
...
@@ -9,33 +9,28 @@ object Const {
...
@@ -9,33 +9,28 @@ object Const {
const
val
DEBUG_TAG
=
"MagiskManager"
const
val
DEBUG_TAG
=
"MagiskManager"
// APK content
const
val
ANDROID_MANIFEST
=
"AndroidManifest.xml"
const
val
SU_KEYSTORE_KEY
=
"su_key"
// Paths
// Paths
const
val
MAGISK_PATH
=
"/sbin/.magisk/img"
const
val
MAGISK_PATH
=
"/sbin/.magisk/img"
@JvmField
@JvmField
val
EXTERNAL_PATH
:
File
=
val
EXTERNAL_PATH
=
Environment
.
getExternalStoragePublicDirectory
(
Environment
.
DIRECTORY_DOWNLOADS
)
!!
Environment
.
getExternalStoragePublicDirectory
(
Environment
.
DIRECTORY_DOWNLOADS
)
@JvmField
@JvmField
var
MAGISK_DISABLE_FILE
:
File
=
File
(
"xxx"
)
var
MAGISK_DISABLE_FILE
=
File
(
"xxx"
)
const
val
TMP_FOLDER_PATH
=
"/dev/tmp"
const
val
TMP_FOLDER_PATH
=
"/dev/tmp"
const
val
MAGISK_LOG
=
"/cache/magisk.log"
const
val
MAGISK_LOG
=
"/cache/magisk.log"
const
val
MANAGER_CONFIGS
=
".tmp.magisk.config"
// Versions
// Versions
const
val
UPDATE_SERVICE_VER
=
1
const
val
UPDATE_SERVICE_VER
=
1
const
val
SNET_EXT_VER
=
12
const
val
SNET_EXT_VER
=
12
const
val
SNET_REVISION
=
"b66b1a914978e5f4c4bbfd74a59f4ad371bac107"
const
val
BOOTCTL_REVISION
=
"9c5dfc1b8245c0b5b524901ef0ff0f8335757b77"
// Misc
const
val
ANDROID_MANIFEST
=
"AndroidManifest.xml"
const
val
MAGISK_INSTALL_LOG_FILENAME
=
"magisk_install_log_%s.log"
const
val
MANAGER_CONFIGS
=
".tmp.magisk.config"
@JvmField
@JvmField
val
USER_ID
=
Process
.
myUid
()
/
100000
val
USER_ID
=
Process
.
myUid
()
/
100000
// Generic
const
val
MAGISK_INSTALL_LOG_FILENAME
=
"magisk_install_log_%s.log"
init
{
init
{
EXTERNAL_PATH
.
mkdirs
()
EXTERNAL_PATH
.
mkdirs
()
}
}
...
@@ -75,9 +70,10 @@ object Const {
...
@@ -75,9 +70,10 @@ object Const {
val
SNET_URL
=
getRaw
(
"b66b1a914978e5f4c4bbfd74a59f4ad371bac107"
,
"snet.apk"
)
val
SNET_URL
=
getRaw
(
"b66b1a914978e5f4c4bbfd74a59f4ad371bac107"
,
"snet.apk"
)
@JvmField
@JvmField
val
BOOTCTL_URL
=
getRaw
(
"9c5dfc1b8245c0b5b524901ef0ff0f8335757b77"
,
"bootctl"
)
val
BOOTCTL_URL
=
getRaw
(
"9c5dfc1b8245c0b5b524901ef0ff0f8335757b77"
,
"bootctl"
)
const
val
GITHUB_RAW_API_URL
=
"https://raw.githubusercontent.com/"
private
fun
getRaw
(
where
:
String
,
name
:
String
)
=
private
fun
getRaw
(
where
:
String
,
name
:
String
)
=
"
https://raw.githubusercontent.com/topjohnwu/magisk_files/%s/%s"
.
format
(
where
,
name
)
"
${GITHUB_RAW_API_URL}topjohnwu/magisk_files/$where/$name"
}
}
object
Key
{
object
Key
{
...
...
app/src/main/java/com/topjohnwu/magisk/Constants.kt
deleted
100644 → 0
View file @
16b232d2
package
com.topjohnwu.magisk
import
android.os.Process
object
Constants
{
// Paths
val
MAGISK_PATH
=
"/sbin/.magisk/img"
val
MAGISK_LOG
=
"/cache/magisk.log"
val
USER_ID
get
()
=
Process
.
myUid
()
/
100000
const
val
SNET_REVISION
=
"b66b1a914978e5f4c4bbfd74a59f4ad371bac107"
const
val
BOOTCTL_REVISION
=
"9c5dfc1b8245c0b5b524901ef0ff0f8335757b77"
const
val
GITHUB_URL
=
"https://github.com/"
const
val
GITHUB_API_URL
=
"https://api.github.com/"
const
val
GITHUB_RAW_API_URL
=
"https://raw.githubusercontent.com/"
}
\ No newline at end of file
app/src/main/java/com/topjohnwu/magisk/data/database/PolicyDao.kt
View file @
4b30b224
...
@@ -2,7 +2,7 @@ package com.topjohnwu.magisk.data.database
...
@@ -2,7 +2,7 @@ package com.topjohnwu.magisk.data.database
import
android.content.Context
import
android.content.Context
import
android.content.pm.PackageManager
import
android.content.pm.PackageManager
import
com.topjohnwu.magisk.Const
ants
import
com.topjohnwu.magisk.Const
import
com.topjohnwu.magisk.data.database.base.*
import
com.topjohnwu.magisk.data.database.base.*
import
com.topjohnwu.magisk.model.entity.MagiskPolicy
import
com.topjohnwu.magisk.model.entity.MagiskPolicy
import
com.topjohnwu.magisk.model.entity.toMap
import
com.topjohnwu.magisk.model.entity.toMap
...
@@ -60,7 +60,7 @@ class PolicyDao(
...
@@ -60,7 +60,7 @@ class PolicyDao(
fun
fetchAll
()
=
query
<
Select
>
{
fun
fetchAll
()
=
query
<
Select
>
{
condition
{
condition
{
equals
(
"uid/100000"
,
Const
ants
.
USER_ID
)
equals
(
"uid/100000"
,
Const
.
USER_ID
)
}
}
}.
flattenAsFlowable
{
it
}
}.
flattenAsFlowable
{
it
}
.
map
{
it
.
toPolicy
(
context
.
packageManager
)
}
.
map
{
it
.
toPolicy
(
context
.
packageManager
)
}
...
...
app/src/main/java/com/topjohnwu/magisk/data/network/GithubRawApiServices.kt
View file @
4b30b224
package
com.topjohnwu.magisk.data.network
package
com.topjohnwu.magisk.data.network
import
com.topjohnwu.magisk.Const
ants
import
com.topjohnwu.magisk.Const
import
com.topjohnwu.magisk.KConfig
import
com.topjohnwu.magisk.KConfig
import
com.topjohnwu.magisk.model.entity.MagiskConfig
import
com.topjohnwu.magisk.model.entity.MagiskConfig
import
io.reactivex.Single
import
io.reactivex.Single
...
@@ -32,11 +32,11 @@ interface GithubRawApiServices {
...
@@ -32,11 +32,11 @@ interface GithubRawApiServices {
@GET
(
"$MAGISK_FILES/{$REVISION}/snet.apk"
)
@GET
(
"$MAGISK_FILES/{$REVISION}/snet.apk"
)
@Streaming
@Streaming
fun
fetchSafetynet
(
@Path
(
REVISION
)
revision
:
String
=
Const
ants
.
SNET_REVISION
):
Single
<
ResponseBody
>
fun
fetchSafetynet
(
@Path
(
REVISION
)
revision
:
String
=
Const
.
SNET_REVISION
):
Single
<
ResponseBody
>
@GET
(
"$MAGISK_FILES/{$REVISION}/bootctl"
)
@GET
(
"$MAGISK_FILES/{$REVISION}/bootctl"
)
@Streaming
@Streaming
fun
fetchBootctl
(
@Path
(
REVISION
)
revision
:
String
=
Const
ants
.
BOOTCTL_REVISION
):
Single
<
ResponseBody
>
fun
fetchBootctl
(
@Path
(
REVISION
)
revision
:
String
=
Const
.
BOOTCTL_REVISION
):
Single
<
ResponseBody
>
//endregion
//endregion
...
...
app/src/main/java/com/topjohnwu/magisk/data/repository/LogRepository.kt
View file @
4b30b224
package
com.topjohnwu.magisk.data.repository
package
com.topjohnwu.magisk.data.repository
import
com.topjohnwu.magisk.Const
import
com.topjohnwu.magisk.Const
import
com.topjohnwu.magisk.Constants
import
com.topjohnwu.magisk.data.database.LogDao
import
com.topjohnwu.magisk.data.database.LogDao
import
com.topjohnwu.magisk.data.database.base.suRaw
import
com.topjohnwu.magisk.data.database.base.suRaw
import
com.topjohnwu.magisk.model.entity.MagiskLog
import
com.topjohnwu.magisk.model.entity.MagiskLog
...
@@ -20,7 +19,7 @@ class LogRepository(
...
@@ -20,7 +19,7 @@ class LogRepository(
.
map
{
it
.
sortByDescending
{
it
.
date
.
time
};
it
}
.
map
{
it
.
sortByDescending
{
it
.
date
.
time
};
it
}
.
map
{
it
.
wrap
()
}
.
map
{
it
.
wrap
()
}
fun
fetchMagiskLogs
()
=
"tail -n 5000 ${Const
ants
.MAGISK_LOG}"
.
suRaw
()
fun
fetchMagiskLogs
()
=
"tail -n 5000 ${Const.MAGISK_LOG}"
.
suRaw
()
.
filter
{
it
.
isNotEmpty
()
}
.
filter
{
it
.
isNotEmpty
()
}
.
map
{
Timber
.
i
(
it
.
toString
());
it
}
.
map
{
Timber
.
i
(
it
.
toString
());
it
}
...
...
app/src/main/java/com/topjohnwu/magisk/di/NetworkingModule.kt
View file @
4b30b224
...
@@ -3,7 +3,7 @@ package com.topjohnwu.magisk.di
...
@@ -3,7 +3,7 @@ package com.topjohnwu.magisk.di
import
com.squareup.moshi.JsonAdapter
import
com.squareup.moshi.JsonAdapter
import
com.squareup.moshi.Moshi
import
com.squareup.moshi.Moshi
import
com.topjohnwu.magisk.BuildConfig
import
com.topjohnwu.magisk.BuildConfig
import
com.topjohnwu.magisk.Const
ants
import
com.topjohnwu.magisk.Const
import
com.topjohnwu.magisk.data.network.GithubRawApiServices
import
com.topjohnwu.magisk.data.network.GithubRawApiServices
import
okhttp3.OkHttpClient
import
okhttp3.OkHttpClient
import
okhttp3.logging.HttpLoggingInterceptor
import
okhttp3.logging.HttpLoggingInterceptor
...
@@ -20,7 +20,7 @@ val networkingModule = module {
...
@@ -20,7 +20,7 @@ val networkingModule = module {
single
{
createConverterFactory
()
}
single
{
createConverterFactory
()
}
single
{
createCallAdapterFactory
()
}
single
{
createCallAdapterFactory
()
}
single
{
createRetrofit
(
get
(),
get
(),
get
())
}
single
{
createRetrofit
(
get
(),
get
(),
get
())
}
single
{
createApiService
<
GithubRawApiServices
>(
get
(),
Const
ants
.
GITHUB_RAW_API_URL
)
}
single
{
createApiService
<
GithubRawApiServices
>(
get
(),
Const
.
Url
.
GITHUB_RAW_API_URL
)
}
}
}
fun
createOkHttpClient
():
OkHttpClient
{
fun
createOkHttpClient
():
OkHttpClient
{
...
...
app/src/main/java/com/topjohnwu/magisk/model/entity/MagiskModule.kt
View file @
4b30b224
...
@@ -6,7 +6,7 @@ import androidx.annotation.NonNull
...
@@ -6,7 +6,7 @@ import androidx.annotation.NonNull
import
androidx.annotation.WorkerThread
import
androidx.annotation.WorkerThread
import
androidx.room.Entity
import
androidx.room.Entity
import
androidx.room.PrimaryKey
import
androidx.room.PrimaryKey
import
com.topjohnwu.magisk.Const
ants
import
com.topjohnwu.magisk.Const
import
com.topjohnwu.magisk.data.database.base.su
import
com.topjohnwu.magisk.data.database.base.su
import
io.reactivex.Single
import
io.reactivex.Single
import
kotlinx.android.parcel.Parcelize
import
kotlinx.android.parcel.Parcelize
...
@@ -48,7 +48,7 @@ data class Module(
...
@@ -48,7 +48,7 @@ data class Module(
@AnyThread
@AnyThread
fun
File
.
toModule
():
Single
<
Module
>
{
fun
File
.
toModule
():
Single
<
Module
>
{
val
path
=
"${Const
ants
.MAGISK_PATH}/$name"
val
path
=
"${Const.MAGISK_PATH}/$name"
return
"dos2unix < $path/module.prop"
.
su
()
return
"dos2unix < $path/module.prop"
.
su
()
.
map
{
it
.
first
().
toModule
(
path
)
}
.
map
{
it
.
first
().
toModule
(
path
)
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/utils/FingerprintHelper.java
View file @
4b30b224
...
@@ -25,6 +25,7 @@ public abstract class FingerprintHelper {
...
@@ -25,6 +25,7 @@ public abstract class FingerprintHelper {
private
FingerprintManager
manager
;
private
FingerprintManager
manager
;
private
Cipher
cipher
;
private
Cipher
cipher
;
private
CancellationSignal
cancel
;
private
CancellationSignal
cancel
;
private
static
final
String
SU_KEYSTORE_KEY
=
"su_key"
;
public
static
boolean
useFingerprint
()
{
public
static
boolean
useFingerprint
()
{
boolean
fp
=
Config
.
get
(
Config
.
Key
.
SU_FINGERPRINT
);
boolean
fp
=
Config
.
get
(
Config
.
Key
.
SU_FINGERPRINT
);
...
@@ -50,7 +51,7 @@ public abstract class FingerprintHelper {
...
@@ -50,7 +51,7 @@ public abstract class FingerprintHelper {
+
KeyProperties
.
BLOCK_MODE_CBC
+
"/"
+
KeyProperties
.
BLOCK_MODE_CBC
+
"/"
+
KeyProperties
.
ENCRYPTION_PADDING_PKCS7
);
+
KeyProperties
.
ENCRYPTION_PADDING_PKCS7
);
keyStore
.
load
(
null
);
keyStore
.
load
(
null
);
SecretKey
key
=
(
SecretKey
)
keyStore
.
getKey
(
Const
.
SU_KEYSTORE_KEY
,
null
);
SecretKey
key
=
(
SecretKey
)
keyStore
.
getKey
(
SU_KEYSTORE_KEY
,
null
);
if
(
key
==
null
)
{
if
(
key
==
null
)
{
key
=
generateKey
();
key
=
generateKey
();
}
}
...
@@ -86,7 +87,7 @@ public abstract class FingerprintHelper {
...
@@ -86,7 +87,7 @@ public abstract class FingerprintHelper {
KeyGenerator
keygen
=
KeyGenerator
KeyGenerator
keygen
=
KeyGenerator
.
getInstance
(
KeyProperties
.
KEY_ALGORITHM_AES
,
"AndroidKeyStore"
);
.
getInstance
(
KeyProperties
.
KEY_ALGORITHM_AES
,
"AndroidKeyStore"
);
KeyGenParameterSpec
.
Builder
builder
=
new
KeyGenParameterSpec
.
Builder
(
KeyGenParameterSpec
.
Builder
builder
=
new
KeyGenParameterSpec
.
Builder
(
Const
.
SU_KEYSTORE_KEY
,
SU_KEYSTORE_KEY
,
KeyProperties
.
PURPOSE_ENCRYPT
|
KeyProperties
.
PURPOSE_DECRYPT
)
KeyProperties
.
PURPOSE_ENCRYPT
|
KeyProperties
.
PURPOSE_DECRYPT
)
.
setBlockModes
(
KeyProperties
.
BLOCK_MODE_CBC
)
.
setBlockModes
(
KeyProperties
.
BLOCK_MODE_CBC
)
.
setUserAuthenticationRequired
(
true
)
.
setUserAuthenticationRequired
(
true
)
...
...
build.gradle
View file @
4b30b224
...
@@ -15,7 +15,7 @@ buildscript {
...
@@ -15,7 +15,7 @@ buildscript {
maven
{
url
'https://kotlin.bintray.com/kotlinx'
}
maven
{
url
'https://kotlin.bintray.com/kotlinx'
}
}
}
dependencies
{
dependencies
{
classpath
'com.android.tools.build:gradle:3.5.0-beta0
3
'
classpath
'com.android.tools.build:gradle:3.5.0-beta0
4
'
classpath
"org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.31"
classpath
"org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.31"
...
...
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