Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions manager/src/main/java/org/lsposed/lspatch/Patcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ object Patcher {
.permissions(addedPermissions)
.injectDocumentsProvider(injectDocumentsProvider)
.gmsReplacementPackage(gmsReplacementPackage)
.keepPushWithGms(gmsReplacementPackage != null && keepPushWithGms)
.declareFakeSignature(declareFakeSignature)
.build()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ data class PatchRequest(
// The replacement to redirect Google Play services to, or null to leave it alone. A package name
// rather than a flag because the patch bakes that name into the manifest. Recorded for the same reason.
val gmsReplacementPackage: String? = null,
// Keep pushes with Google Play services while the rest goes to the replacement. Recorded for the same reason.
val keepPushWithGms: Boolean = false,
// Declare the original signature as fake-signature for ROM signature spoofing. Recorded for the same reason.
val declareFakeSignature: Boolean = false,
val origin: PatchOrigin = PatchOrigin.New,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ object PatchReport {
)
add("Docs provider ${request.injectDocumentsProvider}")
add("GMS target ${request.gmsReplacementPackage ?: "none"}")
add("Push to GMS ${request.keepPushWithGms}")
add("Fake sig ${request.declareFakeSignature}")
add("Keystore ${if (MyKeyStore.useDefault) "built-in" else "custom (${MyKeyStore.file.name})"}")
add("Verbose ${Configs.detailPatchLogs}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.material.icons.automirrored.rounded.KeyboardArrowRight
import androidx.compose.material.icons.rounded.ArrowDropDown
import androidx.compose.material.icons.rounded.ArrowDropUp
import androidx.compose.material.icons.rounded.CloudSync
import androidx.compose.material.icons.rounded.NotificationsActive
import androidx.compose.material.icons.rounded.SwapHoriz
import androidx.compose.material.icons.rounded.VerifiedUser
import androidx.compose.material3.ExperimentalMaterial3Api
Expand Down Expand Up @@ -45,6 +46,7 @@ import org.lsposed.lspatch.share.Constants
import org.lsposed.lspatch.util.GmsReplacements
import org.matrix.vector.ui.AppIcon
import org.matrix.vector.ui.PackageRow
import org.matrix.vector.ui.ToggleRow
import org.lsposed.lspatch.ui.component.SheetBody
import org.matrix.vector.ui.sheetRowColors

Expand All @@ -66,8 +68,10 @@ import org.matrix.vector.ui.sheetRowColors
fun GmsSetting(
replacement: String?,
declareFakeSignature: Boolean,
keepPushWithGms: Boolean,
needsPackageVisibility: Boolean,
onChange: (replacement: String?, fake: Boolean) -> Unit,
onKeepPushWithGms: (Boolean) -> Unit,
onAddPackageVisibility: () -> Unit,
) {
var showSheet by remember { mutableStateOf(false) }
Expand Down Expand Up @@ -98,8 +102,10 @@ fun GmsSetting(
GmsSheet(
replacement = replacement,
declareFakeSignature = declareFakeSignature,
keepPushWithGms = keepPushWithGms,
needsPackageVisibility = needsPackageVisibility,
onChange = onChange,
onKeepPushWithGms = onKeepPushWithGms,
onAddPackageVisibility = onAddPackageVisibility,
onDismiss = { showSheet = false },
)
Expand All @@ -111,8 +117,10 @@ fun GmsSetting(
private fun GmsSheet(
replacement: String?,
declareFakeSignature: Boolean,
keepPushWithGms: Boolean,
needsPackageVisibility: Boolean,
onChange: (replacement: String?, fake: Boolean) -> Unit,
onKeepPushWithGms: (Boolean) -> Unit,
onAddPackageVisibility: () -> Unit,
onDismiss: () -> Unit,
) {
Expand Down Expand Up @@ -209,6 +217,16 @@ private fun GmsSheet(
}
}

// Only once there is a replacement: with none, every push already stays with Google Play services.
AnimatedVisibility(visible = redirecting && replacement != null) {
ToggleRow(
title = stringResource(R.string.patch_gms_keep_push),
icon = Icons.Rounded.NotificationsActive,
subtitle = stringResource(R.string.patch_gms_keep_push_desc),
checked = keepPushWithGms,
onCheckedChange = onKeepPushWithGms,
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,12 @@ fun AppDetailScreen(navigator: Navigator, packageName: String) {
stringResource(R.string.patch_gms_unchanged)
},
)
if (config?.gmsReplacementPackage != null) {
InfoRow(
stringResource(R.string.patch_gms_keep_push),
yesNo(config.keepPushWithGms),
)
}
// Manifest attributes, read from the installed manifest rather than the patch
// config: they are baked into the manifest at patch time and are not carried in the
// runtime config, so this reflects the app's actual manifest. Grouped and ordered to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import androidx.compose.material.icons.rounded.MoreVert
import androidx.compose.material.icons.rounded.RemoveModerator
import androidx.compose.material.icons.rounded.Share
import androidx.compose.material.icons.rounded.Smartphone
import androidx.compose.material.icons.rounded.NotificationsActive
import androidx.compose.material.icons.rounded.SwapHoriz
import androidx.compose.material.icons.rounded.Terminal
import androidx.compose.material.icons.rounded.Tune
Expand Down Expand Up @@ -346,6 +347,7 @@ fun NewPatchScreen(navigator: Navigator, token: String) {
onInjectDocumentsProvider = viewModel::setInjectDocumentsProvider,
onSelectGmsReplacement = viewModel::setGmsReplacementPackage,
onDeclareFakeSignature = viewModel::setDeclareFakeSignature,
onKeepPushWithGms = viewModel::setKeepPushWithGms,
)
else ->
Column(
Expand Down Expand Up @@ -395,6 +397,7 @@ private fun ConfigureBody(
onInjectDocumentsProvider: (Boolean) -> Unit,
onSelectGmsReplacement: (String?) -> Unit,
onDeclareFakeSignature: (Boolean) -> Unit,
onKeepPushWithGms: (Boolean) -> Unit,
) {
val scope = rememberCoroutineScope()
val snackbarHost = LocalSnackbarHost.current
Expand Down Expand Up @@ -531,12 +534,14 @@ private fun ConfigureBody(
GmsSetting(
replacement = request.gmsReplacementPackage,
declareFakeSignature = request.declareFakeSignature,
keepPushWithGms = request.keepPushWithGms,
needsPackageVisibility =
!request.mode.useManager && QUERY_ALL_PACKAGES !in request.addedPermissions,
onChange = { replacement, fake ->
onSelectGmsReplacement(replacement)
onDeclareFakeSignature(fake)
},
onKeepPushWithGms = onKeepPushWithGms,
onAddPackageVisibility = { onAddPermission(QUERY_ALL_PACKAGES) },
)
ToggleRow(
Expand Down Expand Up @@ -807,6 +812,9 @@ private fun advancedChips(request: PatchRequest): List<OptionChipData> = buildLi
)
)
}
if (request.gmsReplacementPackage != null && request.keepPushWithGms) {
add(OptionChipData(stringResource(R.string.patch_gms_keep_push), true, Icons.Rounded.NotificationsActive))
}
if (request.declareFakeSignature) {
add(OptionChipData(stringResource(R.string.patch_gms_declare_only), true, Icons.Rounded.VerifiedUser))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ suspend fun rePatchRequestFor(
addedPermissions = config?.addedPermissions?.toList() ?: emptyList(),
injectDocumentsProvider = config?.injectDocumentsProvider ?: false,
gmsReplacementPackage = config?.gmsReplacementPackage,
keepPushWithGms = config?.keepPushWithGms ?: false,
declareFakeSignature = config?.declareFakeSignature ?: false,
sigBypassLevel = config?.sigBypassLevel ?: 2,
injectDex = config?.injectDex ?: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@ class NewPatchViewModel(private val token: String) : ViewModel() {

fun setInjectDocumentsProvider(value: Boolean) = mutate { it.copy(injectDocumentsProvider = value) }

fun setGmsReplacementPackage(value: String?) = mutate { it.copy(gmsReplacementPackage = value) }
// Keeping pushes with Google Play services only means something while the rest goes to a replacement.
fun setGmsReplacementPackage(value: String?) = mutate {
it.copy(gmsReplacementPackage = value, keepPushWithGms = value != null && it.keepPushWithGms)
}

fun setKeepPushWithGms(value: Boolean) = mutate { it.copy(keepPushWithGms = value) }

fun setDeclareFakeSignature(value: Boolean) = mutate { it.copy(declareFakeSignature = value) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ object LocalAppsUpdater {
.permissions(config.addedPermissions?.toList() ?: emptyList())
.injectDocumentsProvider(config.injectDocumentsProvider)
.gmsReplacementPackage(config.gmsReplacementPackage)
.keepPushWithGms(config.gmsReplacementPackage != null && config.keepPushWithGms)
.declareFakeSignature(config.declareFakeSignature)
.build()
)
Expand Down
2 changes: 2 additions & 0 deletions manager/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@
<string name="patch_gms_redirect">转向替代实现</string>
<string name="patch_gms_redirect_desc">运行时改写应用对 Google 的调用,永久改写清单中的推送名称,并向替代实现声明原始证书。</string>
<string name="patch_gms_redirect_to">转向 %1$s</string>
<string name="patch_gms_keep_push">推送留给 Google Play 服务</string>
<string name="patch_gms_keep_push_desc">不改写清单中的推送名称,推送交给 Google Play 服务而不是替代实现。设备上须安装 Google Play 服务。</string>
<string name="patch_gms_declare_only">仅声明证书</string>
<string name="patch_gms_declare_only_desc">不转向,也不改推送名称 —— 适用于以 Google Play 服务自身包名安装的替代实现,由支持签名伪装的 ROM 上报证书。</string>
<string name="patch_gms_pick">转向到哪个替代实现</string>
Expand Down
2 changes: 2 additions & 0 deletions manager/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@
<string name="patch_gms_redirect">轉向替代實作</string>
<string name="patch_gms_redirect_desc">執行時改寫應用對 Google 的呼叫,永久改寫清單中的推播名稱,並向替代實作宣告原始憑證。</string>
<string name="patch_gms_redirect_to">轉向 %1$s</string>
<string name="patch_gms_keep_push">推播留給 Google Play 服務</string>
<string name="patch_gms_keep_push_desc">不改寫清單中的推播名稱,推播交給 Google Play 服務而不是替代實作。裝置上須安裝 Google Play 服務。</string>
<string name="patch_gms_declare_only">僅宣告憑證</string>
<string name="patch_gms_declare_only_desc">不轉向,也不改推播名稱 —— 適用於以 Google Play 服務自身套件名安裝的替代實作,由支援簽章偽裝的 ROM 回報憑證。</string>
<string name="patch_gms_pick">轉向到哪個替代實作</string>
Expand Down
2 changes: 2 additions & 0 deletions manager/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@
<string name="patch_gms_redirect">Send to a replacement</string>
<string name="patch_gms_redirect_desc">Rewrites the app’s Google calls at run time, renames its push names in the manifest for good, and declares the original certificate to the replacement.</string>
<string name="patch_gms_redirect_to">Sent to %1$s</string>
<string name="patch_gms_keep_push">Keep pushes with Google Play services</string>
<string name="patch_gms_keep_push_desc">Leaves the push names in the manifest and sends pushes to Google Play services instead of the replacement. Google Play services must be installed.</string>
<string name="patch_gms_declare_only">Declare certificate only</string>
<string name="patch_gms_declare_only_desc">No redirect and no push rename — for a replacement installed as Google Play services itself, where a ROM with signature spoofing reports the certificate.</string>
<string name="patch_gms_pick">Replacement to send to</string>
Expand Down
Loading
Loading