refactor: address maintainer feedback
- Move README content into inline KDoc comments to avoid .rvp inclusion - Simplify by directly calling gmsCoreSupportResourcePatch instead of wrapper - Enhanced documentation with usage examples and signature finding guide - Consistent with other inline documentation in the project
This commit is contained in:
parent
c84dd539d2
commit
1be0eb9e96
2 changed files with 48 additions and 98 deletions
|
|
@ -2,9 +2,9 @@ package app.revanced.patches.all.misc.gms
|
||||||
|
|
||||||
import app.revanced.patcher.Fingerprint
|
import app.revanced.patcher.Fingerprint
|
||||||
import app.revanced.patcher.patch.BytecodePatchContext
|
import app.revanced.patcher.patch.BytecodePatchContext
|
||||||
import app.revanced.patcher.patch.Option
|
|
||||||
import app.revanced.patcher.patch.Patch
|
import app.revanced.patcher.patch.Patch
|
||||||
import app.revanced.patches.shared.misc.gms.gmsCoreSupportPatch
|
import app.revanced.patches.shared.misc.gms.gmsCoreSupportPatch
|
||||||
|
import app.revanced.patches.shared.misc.gms.gmsCoreSupportResourcePatch
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builder function to simplify creating GmsCore support patches for Google apps.
|
* Builder function to simplify creating GmsCore support patches for Google apps.
|
||||||
|
|
@ -12,19 +12,13 @@ import app.revanced.patches.shared.misc.gms.gmsCoreSupportPatch
|
||||||
* This condenses the bytecode and resource patches into a single builder call,
|
* This condenses the bytecode and resource patches into a single builder call,
|
||||||
* reducing boilerplate code from ~80 lines to ~15 lines per app.
|
* reducing boilerplate code from ~80 lines to ~15 lines per app.
|
||||||
*
|
*
|
||||||
* @param fromPackageName The original package name of the app
|
* ## Purpose
|
||||||
* @param toPackageName The target ReVanced package name
|
|
||||||
* @param spoofedPackageSignature The app's original signature for spoofing
|
|
||||||
* @param mainActivityOnCreateFingerprint Fingerprint for main activity onCreate method
|
|
||||||
* @param extensionPatch The app's extension patch
|
|
||||||
* @param primeMethodFingerprint Fingerprint for prime method (optional)
|
|
||||||
* @param earlyReturnFingerprints Set of fingerprints for methods that need early returns
|
|
||||||
* @param executeBlock Additional execution block for the bytecode patch
|
|
||||||
* @param block Additional configuration block for the patch
|
|
||||||
*
|
*
|
||||||
* @return A complete GmsCore support patch for the app
|
* This builder eliminates the need to manually create a separate resource patch factory function,
|
||||||
|
* making it easier to add GmsCore support to new apps while maintaining consistency across implementations.
|
||||||
|
*
|
||||||
|
* ## Usage
|
||||||
*
|
*
|
||||||
* Example usage:
|
|
||||||
* ```kotlin
|
* ```kotlin
|
||||||
* val gmsCoreSupportPatch = gmsCoreSupportBuilder(
|
* val gmsCoreSupportPatch = gmsCoreSupportBuilder(
|
||||||
* fromPackageName = PHOTOS_PACKAGE_NAME,
|
* fromPackageName = PHOTOS_PACKAGE_NAME,
|
||||||
|
|
@ -36,6 +30,47 @@ import app.revanced.patches.shared.misc.gms.gmsCoreSupportPatch
|
||||||
* compatibleWith(PHOTOS_PACKAGE_NAME)
|
* compatibleWith(PHOTOS_PACKAGE_NAME)
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
|
*
|
||||||
|
* ## Finding the Signature
|
||||||
|
*
|
||||||
|
* To find an app's signature for the `spoofedPackageSignature` parameter:
|
||||||
|
* 1. Install the original app from Google Play
|
||||||
|
* 2. Run: `apksigner verify --print-certs app.apk | grep SHA1`
|
||||||
|
* 3. Use the SHA1 hash (lowercase, without colons)
|
||||||
|
*
|
||||||
|
* ## Example: Adding GmsCore Support to a New App
|
||||||
|
*
|
||||||
|
* ```kotlin
|
||||||
|
* package app.revanced.patches.myapp.misc.gms
|
||||||
|
*
|
||||||
|
* import app.revanced.patches.all.misc.gms.gmsCoreSupportBuilder
|
||||||
|
* import app.revanced.patches.myapp.misc.extension.extensionPatch
|
||||||
|
*
|
||||||
|
* private const val MY_APP_PACKAGE = "com.google.android.myapp"
|
||||||
|
* private const val REVANCED_MY_APP_PACKAGE = "app.revanced.android.myapp"
|
||||||
|
*
|
||||||
|
* val gmsCoreSupportPatch = gmsCoreSupportBuilder(
|
||||||
|
* fromPackageName = MY_APP_PACKAGE,
|
||||||
|
* toPackageName = REVANCED_MY_APP_PACKAGE,
|
||||||
|
* spoofedPackageSignature = "your_app_signature_here",
|
||||||
|
* mainActivityOnCreateFingerprint = mainActivityOnCreateFingerprint,
|
||||||
|
* extensionPatch = extensionPatch,
|
||||||
|
* ) {
|
||||||
|
* compatibleWith(MY_APP_PACKAGE)
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @param fromPackageName The original package name (e.g., `com.google.android.apps.photos`)
|
||||||
|
* @param toPackageName The ReVanced package name (e.g., `app.revanced.android.apps.photos`)
|
||||||
|
* @param spoofedPackageSignature The app's original signature for GmsCore authentication
|
||||||
|
* @param mainActivityOnCreateFingerprint Fingerprint for the main activity's onCreate method
|
||||||
|
* @param extensionPatch The app's extension patch
|
||||||
|
* @param primeMethodFingerprint (Optional) Fingerprint for the prime method
|
||||||
|
* @param earlyReturnFingerprints (Optional) Set of fingerprints for methods that need early returns
|
||||||
|
* @param executeBlock (Optional) Additional bytecode patch execution logic
|
||||||
|
* @param block (Optional) Additional patch configuration (e.g., `compatibleWith()`)
|
||||||
|
*
|
||||||
|
* @return A complete GmsCore support patch for the app
|
||||||
*/
|
*/
|
||||||
fun gmsCoreSupportBuilder(
|
fun gmsCoreSupportBuilder(
|
||||||
fromPackageName: String,
|
fromPackageName: String,
|
||||||
|
|
@ -55,7 +90,7 @@ fun gmsCoreSupportBuilder(
|
||||||
mainActivityOnCreateFingerprint = mainActivityOnCreateFingerprint,
|
mainActivityOnCreateFingerprint = mainActivityOnCreateFingerprint,
|
||||||
extensionPatch = extensionPatch,
|
extensionPatch = extensionPatch,
|
||||||
gmsCoreSupportResourcePatchFactory = { gmsCoreVendorGroupIdOption ->
|
gmsCoreSupportResourcePatchFactory = { gmsCoreVendorGroupIdOption ->
|
||||||
createGmsCoreSupportResourcePatch(
|
gmsCoreSupportResourcePatch(
|
||||||
fromPackageName = fromPackageName,
|
fromPackageName = fromPackageName,
|
||||||
toPackageName = toPackageName,
|
toPackageName = toPackageName,
|
||||||
spoofedPackageSignature = spoofedPackageSignature,
|
spoofedPackageSignature = spoofedPackageSignature,
|
||||||
|
|
@ -65,18 +100,3 @@ fun gmsCoreSupportBuilder(
|
||||||
executeBlock = executeBlock,
|
executeBlock = executeBlock,
|
||||||
block = block,
|
block = block,
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal helper to create the resource patch.
|
|
||||||
*/
|
|
||||||
private fun createGmsCoreSupportResourcePatch(
|
|
||||||
fromPackageName: String,
|
|
||||||
toPackageName: String,
|
|
||||||
spoofedPackageSignature: String,
|
|
||||||
gmsCoreVendorGroupIdOption: Option<String>,
|
|
||||||
) = app.revanced.patches.shared.misc.gms.gmsCoreSupportResourcePatch(
|
|
||||||
fromPackageName = fromPackageName,
|
|
||||||
toPackageName = toPackageName,
|
|
||||||
spoofedPackageSignature = spoofedPackageSignature,
|
|
||||||
gmsCoreVendorGroupIdOption = gmsCoreVendorGroupIdOption,
|
|
||||||
)
|
|
||||||
|
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
||||||
# GmsCore Support Builder
|
|
||||||
|
|
||||||
A helper function to simplify adding GmsCore support to Google apps.
|
|
||||||
|
|
||||||
## Purpose
|
|
||||||
|
|
||||||
This builder condenses the bytecode and resource patches into a single function call, reducing boilerplate code from ~80 lines to ~15 lines per app.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```kotlin
|
|
||||||
val gmsCoreSupportPatch = gmsCoreSupportBuilder(
|
|
||||||
fromPackageName = PHOTOS_PACKAGE_NAME,
|
|
||||||
toPackageName = REVANCED_PHOTOS_PACKAGE_NAME,
|
|
||||||
spoofedPackageSignature = "24bb24c05e47e0aefa68a58a766179d9b613a600",
|
|
||||||
mainActivityOnCreateFingerprint = homeActivityOnCreateFingerprint,
|
|
||||||
extensionPatch = extensionPatch,
|
|
||||||
) {
|
|
||||||
compatibleWith(PHOTOS_PACKAGE_NAME)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
- `fromPackageName`: The original package name (e.g., `com.google.android.apps.photos`)
|
|
||||||
- `toPackageName`: The ReVanced package name (e.g., `app.revanced.android.apps.photos`)
|
|
||||||
- `spoofedPackageSignature`: The app's original signature for GmsCore authentication
|
|
||||||
- `mainActivityOnCreateFingerprint`: Fingerprint for the main activity's onCreate method
|
|
||||||
- `extensionPatch`: The app's extension patch
|
|
||||||
- `primeMethodFingerprint`: (Optional) Fingerprint for the prime method
|
|
||||||
- `earlyReturnFingerprints`: (Optional) Set of fingerprints for methods that need early returns
|
|
||||||
- `executeBlock`: (Optional) Additional bytecode patch execution logic
|
|
||||||
- `block`: (Optional) Additional patch configuration (e.g., `compatibleWith()`)
|
|
||||||
|
|
||||||
## Finding the Signature
|
|
||||||
|
|
||||||
To find an app's signature:
|
|
||||||
|
|
||||||
1. Install the original app from Google Play
|
|
||||||
2. Run: `apksigner verify --print-certs app.apk | grep SHA1`
|
|
||||||
3. Use the SHA1 hash (lowercase, without colons)
|
|
||||||
|
|
||||||
## Example: Adding GmsCore Support to a New App
|
|
||||||
|
|
||||||
```kotlin
|
|
||||||
package app.revanced.patches.myapp.misc.gms
|
|
||||||
|
|
||||||
import app.revanced.patches.all.misc.gms.gmsCoreSupportBuilder
|
|
||||||
import app.revanced.patches.myapp.misc.extension.extensionPatch
|
|
||||||
|
|
||||||
private const val MY_APP_PACKAGE = "com.google.android.myapp"
|
|
||||||
private const val REVANCED_MY_APP_PACKAGE = "app.revanced.android.myapp"
|
|
||||||
|
|
||||||
val gmsCoreSupportPatch = gmsCoreSupportBuilder(
|
|
||||||
fromPackageName = MY_APP_PACKAGE,
|
|
||||||
toPackageName = REVANCED_MY_APP_PACKAGE,
|
|
||||||
spoofedPackageSignature = "your_app_signature_here",
|
|
||||||
mainActivityOnCreateFingerprint = mainActivityOnCreateFingerprint,
|
|
||||||
extensionPatch = extensionPatch,
|
|
||||||
) {
|
|
||||||
compatibleWith(MY_APP_PACKAGE)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Benefits
|
|
||||||
|
|
||||||
- Reduces code duplication by 85-90%
|
|
||||||
- Consistent API across all apps
|
|
||||||
- Easier maintenance and updates
|
|
||||||
- Simpler to add GmsCore support to new apps
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue