Skip to content

Commit b38e24f

Browse files
authored
feat(Mapy): Unlock premium patch
1 parent 9119987 commit b38e24f

File tree

51 files changed

+5120
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+5120
-4
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build pull request
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches:
7+
- dev
8+
9+
jobs:
10+
release:
11+
name: Build
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Setup Java
20+
uses: actions/setup-java@v4
21+
with:
22+
distribution: "temurin"
23+
java-version: "17"
24+
25+
- name: Cache Gradle
26+
uses: burrunan/gradle-cache-action@v1
27+
28+
- name: Build
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
run: ./gradlew :patches:buildAndroid --no-daemon
32+
33+
- name: Upload artifacts
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: revanced-patches
37+
path: patches/build/libs

patches/api/patches.api

Lines changed: 461 additions & 1 deletion
Large diffs are not rendered by default.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package app.revanced.patches.all.misc.activity.exportall
2+
3+
import app.revanced.patcher.patch.resourcePatch
4+
5+
@Suppress("unused")
6+
val exportAllActivitiesPatch = resourcePatch(
7+
name = "Export all activities",
8+
description = "Makes all app activities exportable.",
9+
use = false,
10+
) {
11+
execute {
12+
val exportedFlag = "android:exported"
13+
14+
document("AndroidManifest.xml").use { document ->
15+
val activities = document.getElementsByTagName("activity")
16+
17+
for (i in 0..activities.length) {
18+
activities.item(i)?.apply {
19+
val exportedAttribute = attributes.getNamedItem(exportedFlag)
20+
21+
if (exportedAttribute != null) {
22+
if (exportedAttribute.nodeValue != "true") {
23+
exportedAttribute.nodeValue = "true"
24+
}
25+
}
26+
// Reason why the attribute is added in the case it does not exist:
27+
// https://github.com/revanced/revanced-patches/pull/1751/files#r1141481604
28+
else {
29+
document.createAttribute(exportedFlag)
30+
.apply { value = "true" }
31+
.let(attributes::setNamedItem)
32+
}
33+
}
34+
}
35+
}
36+
}
37+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
package app.revanced.patches.all.misc.build
2+
3+
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
4+
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
5+
import app.revanced.patcher.patch.bytecodePatch
6+
import app.revanced.patches.all.misc.transformation.transformInstructionsPatch
7+
import app.revanced.util.getReference
8+
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
9+
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
10+
11+
private const val BUILD_CLASS_DESCRIPTOR = "Landroid/os/Build;"
12+
13+
class BuildInfo(
14+
// The build information supported32BitAbis, supported64BitAbis, and supportedAbis are not supported for now,
15+
// because initializing an array in transform is a bit more complex.
16+
val board: String? = null,
17+
val bootloader: String? = null,
18+
val brand: String? = null,
19+
val cpuAbi: String? = null,
20+
val cpuAbi2: String? = null,
21+
val device: String? = null,
22+
val display: String? = null,
23+
val fingerprint: String? = null,
24+
val hardware: String? = null,
25+
val host: String? = null,
26+
val id: String? = null,
27+
val manufacturer: String? = null,
28+
val model: String? = null,
29+
val odmSku: String? = null,
30+
val product: String? = null,
31+
val radio: String? = null,
32+
val serial: String? = null,
33+
val sku: String? = null,
34+
val socManufacturer: String? = null,
35+
val socModel: String? = null,
36+
val tags: String? = null,
37+
val time: Long? = null,
38+
val type: String? = null,
39+
val user: String? = null,
40+
)
41+
42+
fun baseSpoofBuildInfoPatch(buildInfoSupplier: () -> BuildInfo) = bytecodePatch {
43+
// Lazy, so that patch options above are initialized before they are accessed.
44+
val replacements by lazy {
45+
with(buildInfoSupplier()) {
46+
buildMap {
47+
if (board != null) put("BOARD", "const-string" to "\"$board\"")
48+
if (bootloader != null) put("BOOTLOADER", "const-string" to "\"$bootloader\"")
49+
if (brand != null) put("BRAND", "const-string" to "\"$brand\"")
50+
if (cpuAbi != null) put("CPU_ABI", "const-string" to "\"$cpuAbi\"")
51+
if (cpuAbi2 != null) put("CPU_ABI2", "const-string" to "\"$cpuAbi2\"")
52+
if (device != null) put("DEVICE", "const-string" to "\"$device\"")
53+
if (display != null) put("DISPLAY", "const-string" to "\"$display\"")
54+
if (fingerprint != null) put("FINGERPRINT", "const-string" to "\"$fingerprint\"")
55+
if (hardware != null) put("HARDWARE", "const-string" to "\"$hardware\"")
56+
if (host != null) put("HOST", "const-string" to "\"$host\"")
57+
if (id != null) put("ID", "const-string" to "\"$id\"")
58+
if (manufacturer != null) put("MANUFACTURER", "const-string" to "\"$manufacturer\"")
59+
if (model != null) put("MODEL", "const-string" to "\"$model\"")
60+
if (odmSku != null) put("ODM_SKU", "const-string" to "\"$odmSku\"")
61+
if (product != null) put("PRODUCT", "const-string" to "\"$product\"")
62+
if (radio != null) put("RADIO", "const-string" to "\"$radio\"")
63+
if (serial != null) put("SERIAL", "const-string" to "\"$serial\"")
64+
if (sku != null) put("SKU", "const-string" to "\"$sku\"")
65+
if (socManufacturer != null) put("SOC_MANUFACTURER", "const-string" to "\"$socManufacturer\"")
66+
if (socModel != null) put("SOC_MODEL", "const-string" to "\"$socModel\"")
67+
if (tags != null) put("TAGS", "const-string" to "\"$tags\"")
68+
if (time != null) put("TIME", "const-wide" to "$time")
69+
if (type != null) put("TYPE", "const-string" to "\"$type\"")
70+
if (user != null) put("USER", "const-string" to "\"$user\"")
71+
}
72+
}
73+
}
74+
75+
dependsOn(
76+
transformInstructionsPatch(
77+
filterMap = filterMap@{ _, _, instruction, instructionIndex ->
78+
val reference = instruction.getReference<FieldReference>() ?: return@filterMap null
79+
if (reference.definingClass != BUILD_CLASS_DESCRIPTOR) return@filterMap null
80+
81+
return@filterMap replacements[reference.name]?.let { instructionIndex to it }
82+
},
83+
transform = { mutableMethod, entry ->
84+
val (index, replacement) = entry
85+
val (opcode, operand) = replacement
86+
val register = mutableMethod.getInstruction<OneRegisterInstruction>(index).registerA
87+
88+
mutableMethod.replaceInstruction(index, "$opcode v$register, $operand")
89+
},
90+
),
91+
)
92+
}
Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
package app.revanced.patches.all.misc.build
2+
3+
import app.revanced.patcher.patch.bytecodePatch
4+
import app.revanced.patcher.patch.longOption
5+
import app.revanced.patcher.patch.stringOption
6+
7+
@Suppress("unused")
8+
val spoofBuildInfoPatch = bytecodePatch(
9+
name = "Spoof build info",
10+
description = "Spoof the information about the current build.",
11+
use = false,
12+
) {
13+
val board by stringOption(
14+
key = "board",
15+
default = null,
16+
title = "Board",
17+
description = "The name of the underlying board, like \"goldfish\".",
18+
)
19+
20+
val bootloader by stringOption(
21+
key = "bootloader",
22+
default = null,
23+
title = "Bootloader",
24+
description = "The system bootloader version number.",
25+
)
26+
27+
val brand by stringOption(
28+
key = "brand",
29+
default = null,
30+
title = "Brand",
31+
description = "The consumer-visible brand with which the product/hardware will be associated, if any.",
32+
)
33+
34+
val cpuAbi by stringOption(
35+
key = "cpu-abi",
36+
default = null,
37+
title = "CPU ABI",
38+
description = "This field was deprecated in API level 21. Use SUPPORTED_ABIS instead.",
39+
)
40+
41+
val cpuAbi2 by stringOption(
42+
key = "cpu-abi-2",
43+
default = null,
44+
title = "CPU ABI 2",
45+
description = "This field was deprecated in API level 21. Use SUPPORTED_ABIS instead.",
46+
)
47+
48+
val device by stringOption(
49+
key = "device",
50+
default = null,
51+
title = "Device",
52+
description = "The name of the industrial design.",
53+
)
54+
55+
val display by stringOption(
56+
key = "display",
57+
default = null,
58+
title = "Display",
59+
description = "A build ID string meant for displaying to the user.",
60+
)
61+
62+
val fingerprint by stringOption(
63+
key = "fingerprint",
64+
default = null,
65+
title = "Fingerprint",
66+
description = "A string that uniquely identifies this build.",
67+
)
68+
69+
val hardware by stringOption(
70+
key = "hardware",
71+
default = null,
72+
title = "Hardware",
73+
description = "The name of the hardware (from the kernel command line or /proc).",
74+
)
75+
76+
val host by stringOption(
77+
key = "host",
78+
default = null,
79+
title = "Host",
80+
description = "The host.",
81+
)
82+
83+
val id by stringOption(
84+
key = "id",
85+
default = null,
86+
title = "ID",
87+
description = "Either a changelist number, or a label like \"M4-rc20\".",
88+
)
89+
90+
val manufacturer by stringOption(
91+
key = "manufacturer",
92+
default = null,
93+
title = "Manufacturer",
94+
description = "The manufacturer of the product/hardware.",
95+
)
96+
97+
val model by stringOption(
98+
key = "model",
99+
default = null,
100+
title = "Model",
101+
description = "The end-user-visible name for the end product.",
102+
)
103+
104+
val odmSku by stringOption(
105+
key = "odm-sku",
106+
default = null,
107+
title = "ODM SKU",
108+
description = "The SKU of the device as set by the original design manufacturer (ODM).",
109+
)
110+
111+
val product by stringOption(
112+
key = "product",
113+
default = null,
114+
title = "Product",
115+
description = "The name of the overall product.",
116+
)
117+
118+
val radio by stringOption(
119+
key = "radio",
120+
default = null,
121+
title = "Radio",
122+
description = "This field was deprecated in API level 15. " +
123+
"The radio firmware version is frequently not available when this class is initialized, " +
124+
"leading to a blank or \"unknown\" value for this string. Use getRadioVersion() instead.",
125+
)
126+
127+
val serial by stringOption(
128+
key = "serial",
129+
default = null,
130+
title = "Serial",
131+
description = "This field was deprecated in API level 26. Use getSerial() instead.",
132+
)
133+
134+
val sku by stringOption(
135+
key = "sku",
136+
default = null,
137+
title = "SKU",
138+
description = "The SKU of the hardware (from the kernel command line).",
139+
)
140+
141+
val socManufacturer by stringOption(
142+
key = "soc-manufacturer",
143+
default = null,
144+
title = "SOC Manufacturer",
145+
description = "The manufacturer of the device's primary system-on-chip.",
146+
)
147+
148+
val socModel by stringOption(
149+
key = "soc-model",
150+
default = null,
151+
title = "SOC Model",
152+
description = "The model name of the device's primary system-on-chip.",
153+
)
154+
155+
val tags by stringOption(
156+
key = "tags",
157+
default = null,
158+
title = "Tags",
159+
description = "Comma-separated tags describing the build, like \"unsigned,debug\".",
160+
)
161+
162+
val time by longOption(
163+
key = "time",
164+
default = null,
165+
title = "Time",
166+
description = "The time at which the build was produced, given in milliseconds since the UNIX epoch.",
167+
)
168+
169+
val type by stringOption(
170+
key = "type",
171+
default = null,
172+
title = "Type",
173+
description = "The type of build, like \"user\" or \"eng\".",
174+
)
175+
176+
val user by stringOption(
177+
key = "user",
178+
default = null,
179+
title = "User",
180+
description = "The user.",
181+
)
182+
183+
dependsOn(
184+
baseSpoofBuildInfoPatch {
185+
BuildInfo(
186+
board,
187+
bootloader,
188+
brand,
189+
cpuAbi,
190+
cpuAbi2,
191+
device,
192+
display,
193+
fingerprint,
194+
hardware,
195+
host,
196+
id,
197+
manufacturer,
198+
model,
199+
odmSku,
200+
product,
201+
radio,
202+
serial,
203+
sku,
204+
socManufacturer,
205+
socModel,
206+
tags,
207+
time,
208+
type,
209+
user,
210+
)
211+
},
212+
213+
)
214+
}

0 commit comments

Comments
 (0)