Skip to content

Commit

Permalink
feat: get device info
Browse files Browse the repository at this point in the history
  • Loading branch information
omg-xtao committed Oct 1, 2023
1 parent 17d23f4 commit 452240a
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 9 deletions.
Binary file added .github/paigram.jks
Binary file not shown.
2 changes: 1 addition & 1 deletion .github/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const axios = require("axios").create({
maxBodyLength: Infinity
})

const repo = "HolographicHat/GetToken"
const repo = "PaiGramTeam/GetToken"
const token = process.env.GHP_TOKEN

const getAppVersion = async () => {
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
workflow_dispatch:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:

Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: Update Check

on:
schedule:
- cron: '0 12 * * *'
workflow_dispatch: ~

jobs:

Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
local.properties
.idea
api-82-sources.jar
restart.cmd
restart.cmd
app/release/
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ android {

signingConfigs {
release {
storeFile file('../.github/signkey.jks')
storeFile file('../.github/paigram.jks')
keyAlias System.getenv("SIGNING_KEY_ALIAS")
keyPassword System.getenv("SIGNING_KEY_PASSWORD")
storePassword System.getenv("SIGNING_KEY_PASSWORD")
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/hat/holo/token/LoaderActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class LoaderActivity : Activity() {
val zActivity = loader.loadClass("hat.holo.token.TokenActivity")
val actIntent = Intent(this, zActivity)
actIntent.putExtra("accountInfo", intent.getSerializableExtra("accountInfo"))
actIntent.putExtra("deviceInfo", intent.getSerializableExtra("deviceInfo"))
startActivityForResult(actIntent, 1234)
}

Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/hat/holo/token/ModuleMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class ModuleMain : IXposedHookLoadPackage, IXposedHookZygoteInit {
AppUtils.init(classLoader)
AccountManager.init(classLoader)
val app = p.args[0] as Application
DeviceUtils.init(app.applicationContext)
appendToClassPath(app.applicationContext)
}
})
Expand All @@ -74,11 +75,13 @@ class ModuleMain : IXposedHookLoadPackage, IXposedHookZygoteInit {
val intent = Intent(ctx, LoaderActivity::class.java)
intent.putExtra("accountInfo", AccountManager.accountInfo)
intent.putExtra("dexPath", modulePath)
intent.putExtra("deviceInfo", DeviceUtils.deviceInfo)
ctx.startActivity(intent)
} else {
val intent = Intent()
intent.setClassName("hat.holo.token", "hat.holo.token.TokenActivity")
intent.putExtra("accountInfo", AccountManager.accountInfo)
intent.putExtra("deviceInfo", DeviceUtils.deviceInfo)
ctx.startActivity(intent)
}
} else {
Expand Down
20 changes: 18 additions & 2 deletions app/src/main/java/hat/holo/token/TokenActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import androidx.constraintlayout.compose.ConstraintLayout
import androidx.core.content.getSystemService
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import hat.holo.token.models.AccountInfo
import hat.holo.token.models.DeviceInfo
import kotlinx.coroutines.delay

val textColor = Color(0xFF424242)
Expand All @@ -45,6 +46,7 @@ class TokenActivity : ComponentActivity() {
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
setTheme(androidx.appcompat.R.style.Theme_AppCompat_Light_NoActionBar)
val accountInfo = intent.getSerializableExtra("accountInfo") as AccountInfo
val deviceInfo = intent.getSerializableExtra("deviceInfo") as DeviceInfo
setContent {
rememberSystemUiController().setStatusBarColor(Color.White)
MaterialTheme(
Expand All @@ -53,7 +55,7 @@ class TokenActivity : ComponentActivity() {
),
content = {
Surface {
Content(accountInfo)
Content(accountInfo, deviceInfo)
}
}
)
Expand All @@ -70,7 +72,7 @@ private fun TokenActivity.showDialog(msg: String) = runOnUiThread {
}

@Composable
private fun TokenActivity.Content(accountInfo: AccountInfo) = Column(
private fun TokenActivity.Content(accountInfo: AccountInfo, deviceInfo: DeviceInfo) = Column(
modifier = Modifier.fillMaxSize()
) {
TopAppBar()
Expand All @@ -79,6 +81,7 @@ private fun TokenActivity.Content(accountInfo: AccountInfo) = Column(
) {
var grantSToken by remember { mutableStateOf(false) }
var showDoneIcon by remember { mutableStateOf(false) }
var getDeviceInfo by remember { mutableStateOf(false) }
CustomCheckBox(
checked = true,
onCheckedChange = {},
Expand All @@ -100,6 +103,15 @@ private fun TokenActivity.Content(accountInfo: AccountInfo) = Column(
appendLine(" · 其它可以通过米游社APP完成的操作")
} // TODO: More description
)
CustomCheckBox(
checked = getDeviceInfo,
onCheckedChange = { v -> getDeviceInfo = v },
name = "Device",
permissions = buildAnnotatedString {
appendLine("此信息可以用于:")
appendLine(" · 一定程度下绕过风控")
}
)
Divider()
Row(
modifier = Modifier.fillMaxWidth(),
Expand All @@ -116,6 +128,10 @@ private fun TokenActivity.Content(accountInfo: AccountInfo) = Column(
put("mid", accountInfo.mid)
put("stoken", accountInfo.sToken)
}
if (getDeviceInfo) {
put("x-rpc-device_id", deviceInfo.id)
put("x-rpc-device_fp", deviceInfo.fp)
}
}.map { (k, v) -> "$k=$v" }.joinToString(";")
val clip = ClipData.newPlainText(null, authStr)
getSystemService<ClipboardManager>()!!.setPrimaryClip(clip)
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/hat/holo/token/models/DeviceInfo.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package hat.holo.token.models

data class DeviceInfo(
val id: String,
val fp: String,
) : java.io.Serializable
21 changes: 21 additions & 0 deletions app/src/main/java/hat/holo/token/utils/DeviceUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package hat.holo.token.utils

import android.content.Context
import hat.holo.token.models.DeviceInfo


@Suppress("MemberVisibilityCanBePrivate", "unused")
object DeviceUtils {

private lateinit var id: String
private lateinit var fp: String
lateinit var deviceInfo: DeviceInfo

fun init(ctx: Context) {
val preDevice = ctx.getSharedPreferences("pre_device.xml", 0)
id = preDevice.getString("device_id", "").toString()
val comboDeviceFingerprint = ctx.getSharedPreferences("combo_device_fingerprint", 0)
fp = comboDeviceFingerprint.getString("fp", "").toString()
deviceInfo = DeviceInfo(id, fp)
}
}

0 comments on commit 452240a

Please sign in to comment.