mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2026-01-22 18:23:59 +00:00
Compare commits
30 Commits
v5.48.0-de
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e675e6f62 | ||
|
|
421cb2899e | ||
|
|
97e74157fa | ||
|
|
5edd9dccae | ||
|
|
9c18e1e649 | ||
|
|
71ce8230a9 | ||
|
|
156441d3cf | ||
|
|
634f47ef84 | ||
|
|
eeb133325e | ||
|
|
e8d58ca9af | ||
|
|
5b5c50254d | ||
|
|
ef052c0d8f | ||
|
|
d9fa580222 | ||
|
|
182224c79d | ||
|
|
83c0127ebb | ||
|
|
3762f1de08 | ||
|
|
18c0b04f0c | ||
|
|
4c4ba1c78c | ||
|
|
7cef24a5e9 | ||
|
|
8725a49ba3 | ||
|
|
8b6360e34f | ||
|
|
a10c51f160 | ||
|
|
eecc44b956 | ||
|
|
3401467a6d | ||
|
|
87247590de | ||
|
|
41e2590584 | ||
|
|
778d13ce8b | ||
|
|
19f146c01d | ||
|
|
12b819d20e | ||
|
|
004b5908db |
3
.github/workflows/build_pull_request.yml
vendored
3
.github/workflows/build_pull_request.yml
vendored
@@ -25,7 +25,8 @@ jobs:
|
||||
|
||||
- name: Build
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
ORG_GRADLE_PROJECT_githubPackagesUsername: ${{ env.GITHUB_ACTOR }}
|
||||
ORG_GRADLE_PROJECT_githubPackagesPassword: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: ./gradlew :patches:buildAndroid --no-daemon
|
||||
|
||||
- name: Upload artifacts
|
||||
|
||||
2
.github/workflows/pull_strings.yml
vendored
2
.github/workflows/pull_strings.yml
vendored
@@ -2,7 +2,7 @@ name: Pull strings
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 */12 * * *"
|
||||
- cron: "0 0 * * 0"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
|
||||
7
.github/workflows/push_strings.yml
vendored
7
.github/workflows/push_strings.yml
vendored
@@ -16,10 +16,11 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Preprocess strings
|
||||
- name: Process strings
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: ./gradlew clean preprocessCrowdinStrings
|
||||
ORG_GRADLE_PROJECT_githubPackagesUsername: ${{ github.actor }}
|
||||
ORG_GRADLE_PROJECT_githubPackagesPassword: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: ./gradlew processStringsForCrowdin
|
||||
|
||||
- name: Push strings
|
||||
uses: crowdin/github-action@v2
|
||||
|
||||
5
.github/workflows/release.yml
vendored
5
.github/workflows/release.yml
vendored
@@ -31,7 +31,8 @@ jobs:
|
||||
|
||||
- name: Build
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
ORG_GRADLE_PROJECT_githubPackagesUsername: ${{ github.actor }}
|
||||
ORG_GRADLE_PROJECT_githubPackagesPassword: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: ./gradlew :patches:buildAndroid clean
|
||||
|
||||
- name: Setup Node.js
|
||||
@@ -55,6 +56,8 @@ jobs:
|
||||
id: release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
ORG_GRADLE_PROJECT_githubPackagesUsername: ${{ github.actor }}
|
||||
ORG_GRADLE_PROJECT_githubPackagesPassword: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Attest
|
||||
if: steps.release.outputs.new_release_published == 'true'
|
||||
|
||||
100
CHANGELOG.md
100
CHANGELOG.md
@@ -1,3 +1,103 @@
|
||||
# [5.50.0-dev.1](https://github.com/ReVanced/revanced-patches/compare/v5.49.0-dev.1...v5.50.0-dev.1) (2026-01-22)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **Nothing X:** Add `Show K1 token(s)` patch ([#6490](https://github.com/ReVanced/revanced-patches/issues/6490)) ([421cb28](https://github.com/ReVanced/revanced-patches/commit/421cb2899ef5c0f100fb8007bae8b89137d0e41c))
|
||||
* **YouTube Music:** Add `Unlock Android Auto Media Browser` patch ([#6477](https://github.com/ReVanced/revanced-patches/issues/6477)) ([5edd9dc](https://github.com/ReVanced/revanced-patches/commit/5edd9dccae3b1ab4edf19771a771812e3c9ccf80))
|
||||
|
||||
# [5.50.0-dev.1](https://github.com/ReVanced/revanced-patches/compare/v5.48.0...v5.50.0-dev.1) (2026-01-22)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **YouTube Music:** Add `Unlock Android Auto Media Browser` patch ([#6477](https://github.com/ReVanced/revanced-patches/issues/6477)) ([89645dc](https://github.com/ReVanced/revanced-patches/commit/89645dcc2e13603b8f2fedb5e16231cb396e5965))
|
||||
|
||||
# [5.49.0-dev.1](https://github.com/ReVanced/revanced-patches/compare/v5.48.1-dev.1...v5.49.0-dev.1) (2026-01-22)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **YouTube Music:** Add `Hide layout components` patch ([#6365](https://github.com/ReVanced/revanced-patches/issues/6365)) ([71ce823](https://github.com/ReVanced/revanced-patches/commit/71ce8230a959dcaf2d8cd5dad1a4f21b88819aa0))
|
||||
|
||||
## [5.48.1-dev.1](https://github.com/ReVanced/revanced-patches/compare/v5.48.0...v5.48.1-dev.1) (2026-01-21)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Disable `Prevent screenshot detection` by default ([#6511](https://github.com/ReVanced/revanced-patches/issues/6511)) ([5b5c502](https://github.com/ReVanced/revanced-patches/commit/5b5c50254d533faa0e04d542f4859cbef610713e))
|
||||
|
||||
# [5.48.0](https://github.com/ReVanced/revanced-patches/compare/v5.47.0...v5.48.0) (2026-01-19)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **Boost for Reddit - Fix missing audio in video downloads:** Make it work again by reflecting Reddits latest changes ([#6500](https://github.com/ReVanced/revanced-patches/issues/6500)) ([eecc44b](https://github.com/ReVanced/revanced-patches/commit/eecc44b9567bf2ca72ac99e0dafa483a6803c0f9))
|
||||
* **Disney+ - Skip ads:** Remove unsupported package names ([#6422](https://github.com/ReVanced/revanced-patches/issues/6422)) ([44e7dbc](https://github.com/ReVanced/revanced-patches/commit/44e7dbcf4d7eaf94dd0164baba847d3e19250154))
|
||||
* Fix build error introduced in `4046bee` ([#6417](https://github.com/ReVanced/revanced-patches/issues/6417)) ([789f0a5](https://github.com/ReVanced/revanced-patches/commit/789f0a562861825065633d172445ebf35a1ba8d8))
|
||||
* Fix compilation error introduced in `6bb6281` ([#6409](https://github.com/ReVanced/revanced-patches/issues/6409)) ([71c6cb5](https://github.com/ReVanced/revanced-patches/commit/71c6cb569ebf7b93cf73ee391839e5220557ce7c))
|
||||
* Fix compilation error introduced in dc69f243 ([#6392](https://github.com/ReVanced/revanced-patches/issues/6392)) ([a429824](https://github.com/ReVanced/revanced-patches/commit/a429824bb77b49aea14b0b54f2204ae24d5209a1))
|
||||
* **Instagram:** `Sanitize sharing links` ([#6483](https://github.com/ReVanced/revanced-patches/issues/6483)) ([8724759](https://github.com/ReVanced/revanced-patches/commit/87247590de3db74680cb02ba1d87bf683b2269e2))
|
||||
* **YouTube - Hide layout components:** Hide new type of crowdfunding box ([#6380](https://github.com/ReVanced/revanced-patches/issues/6380)) ([dc69f24](https://github.com/ReVanced/revanced-patches/commit/dc69f2433e2650654e2dffdd76b0b0c8a52bf515))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Add `Disable Sentry telemetry` patch ([#6416](https://github.com/ReVanced/revanced-patches/issues/6416)) ([4cc3159](https://github.com/ReVanced/revanced-patches/commit/4cc315952db557c565872de9e8484805f2e42305))
|
||||
* Add `Prevent screenshot detection` patch ([#6482](https://github.com/ReVanced/revanced-patches/issues/6482)) ([83c0127](https://github.com/ReVanced/revanced-patches/commit/83c0127ebb8f53ab8a067758619faaac5596c145))
|
||||
* Disable Play Integrity patch ([#6412](https://github.com/ReVanced/revanced-patches/issues/6412)) ([6312fe8](https://github.com/ReVanced/revanced-patches/commit/6312fe8d60da24465c0c1b0fa4e94ceb79873d9c))
|
||||
* **Instagram - Hides navigation buttons:** Add more buttons to hide ([#6390](https://github.com/ReVanced/revanced-patches/issues/6390)) ([6bb6281](https://github.com/ReVanced/revanced-patches/commit/6bb62811493da04812cc3e392e68d874f95cbef9))
|
||||
* **Instagram:** Add `Hide highlights tray` patch ([#6489](https://github.com/ReVanced/revanced-patches/issues/6489)) ([8725a49](https://github.com/ReVanced/revanced-patches/commit/8725a49ba3a06fee0280ffcf4be62cd960cd301e))
|
||||
* **Instagram:** Add `Remove build expired popup` patch ([#6488](https://github.com/ReVanced/revanced-patches/issues/6488)) ([18c0b04](https://github.com/ReVanced/revanced-patches/commit/18c0b04f0cd1bf8cd78b05af3b8ebe3a6a5f9e48))
|
||||
* **Instagram:** Disable `Disable Reels scrolling` by default ([3401467](https://github.com/ReVanced/revanced-patches/commit/3401467a6d49fc75b6757a15e5c848330c1b7307))
|
||||
* **Letterboxd:** Add `Unlock app icons` patch ([#6415](https://github.com/ReVanced/revanced-patches/issues/6415)) ([d25dcfe](https://github.com/ReVanced/revanced-patches/commit/d25dcfe49ac331c9b3dca739ba0be95dbab669cc))
|
||||
* **ProtonVPN:** Add `Unlock split tunneling` patch ([#6353](https://github.com/ReVanced/revanced-patches/issues/6353)) ([e0f3346](https://github.com/ReVanced/revanced-patches/commit/e0f33468e6e96b9f10cf35ec67622d6488528c90))
|
||||
* **SBS On Demand:** Add `Remove ads` patch ([#6378](https://github.com/ReVanced/revanced-patches/issues/6378)) ([315931c](https://github.com/ReVanced/revanced-patches/commit/315931cbf8f61cd4b3a54ace1ff03685d748614c))
|
||||
* **Strava:** Add `Add 'Give Kudos' button to 'Group Activity'` patch ([#6475](https://github.com/ReVanced/revanced-patches/issues/6475)) ([4c4ba1c](https://github.com/ReVanced/revanced-patches/commit/4c4ba1c78c9f4568a2b572f5c69e9c6c734e1a7f))
|
||||
* **Strava:** Add `Add media download` patch ([#6449](https://github.com/ReVanced/revanced-patches/issues/6449)) ([778d13c](https://github.com/ReVanced/revanced-patches/commit/778d13ce8b28ca6df3a665530320e4a21a27ae44))
|
||||
* **Strava:** Add `Block Snowplow tracking` patch ([#6413](https://github.com/ReVanced/revanced-patches/issues/6413)) ([c47beae](https://github.com/ReVanced/revanced-patches/commit/c47beae21376dd17ab8bc09afe73e9094481bde9))
|
||||
* **Strava:** Add `Disable Quick Edit` patch ([#6452](https://github.com/ReVanced/revanced-patches/issues/6452)) ([f5cbb31](https://github.com/ReVanced/revanced-patches/commit/f5cbb31724d15f7e939b96ee0186fd0a108f9fdc))
|
||||
* **Strava:** Add `Enable password login` patch ([#6396](https://github.com/ReVanced/revanced-patches/issues/6396)) ([8f3f4c9](https://github.com/ReVanced/revanced-patches/commit/8f3f4c95bb8f151fc9a2c272bf7d0e905c2f01fc))
|
||||
* **Strava:** Add `Overwrite media upload parameters` patch ([#6410](https://github.com/ReVanced/revanced-patches/issues/6410)) ([b42ae27](https://github.com/ReVanced/revanced-patches/commit/b42ae27ce66ebad9e9cfc5b70fc121df5bad7567))
|
||||
* **YouTube:** Add `Pause on audio interrupt` patch ([#6464](https://github.com/ReVanced/revanced-patches/issues/6464)) ([19f146c](https://github.com/ReVanced/revanced-patches/commit/19f146c01dc381b3cccd61e61ba4901872ff12d8))
|
||||
|
||||
# [5.48.0-dev.13](https://github.com/ReVanced/revanced-patches/compare/v5.48.0-dev.12...v5.48.0-dev.13) (2026-01-19)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Add `Prevent screenshot detection` patch ([#6482](https://github.com/ReVanced/revanced-patches/issues/6482)) ([83c0127](https://github.com/ReVanced/revanced-patches/commit/83c0127ebb8f53ab8a067758619faaac5596c145))
|
||||
|
||||
# [5.48.0-dev.12](https://github.com/ReVanced/revanced-patches/compare/v5.48.0-dev.11...v5.48.0-dev.12) (2026-01-19)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **Instagram:** Add `Remove build expired popup` patch ([#6488](https://github.com/ReVanced/revanced-patches/issues/6488)) ([18c0b04](https://github.com/ReVanced/revanced-patches/commit/18c0b04f0cd1bf8cd78b05af3b8ebe3a6a5f9e48))
|
||||
* **Strava:** Add `Add 'Give Kudos' button to 'Group Activity'` patch ([#6475](https://github.com/ReVanced/revanced-patches/issues/6475)) ([4c4ba1c](https://github.com/ReVanced/revanced-patches/commit/4c4ba1c78c9f4568a2b572f5c69e9c6c734e1a7f))
|
||||
|
||||
# [5.48.0-dev.11](https://github.com/ReVanced/revanced-patches/compare/v5.48.0-dev.10...v5.48.0-dev.11) (2026-01-19)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **Instagram:** Add `Hide highlights tray` patch ([#6489](https://github.com/ReVanced/revanced-patches/issues/6489)) ([8725a49](https://github.com/ReVanced/revanced-patches/commit/8725a49ba3a06fee0280ffcf4be62cd960cd301e))
|
||||
|
||||
# [5.48.0-dev.10](https://github.com/ReVanced/revanced-patches/compare/v5.48.0-dev.9...v5.48.0-dev.10) (2026-01-19)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **Boost for Reddit - Fix missing audio in video downloads:** Make it work again by reflecting Reddits latest changes ([#6500](https://github.com/ReVanced/revanced-patches/issues/6500)) ([eecc44b](https://github.com/ReVanced/revanced-patches/commit/eecc44b9567bf2ca72ac99e0dafa483a6803c0f9))
|
||||
* **Instagram:** `Sanitize sharing links` ([#6483](https://github.com/ReVanced/revanced-patches/issues/6483)) ([8724759](https://github.com/ReVanced/revanced-patches/commit/87247590de3db74680cb02ba1d87bf683b2269e2))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **Instagram:** Disable `Disable Reels scrolling` by default ([3401467](https://github.com/ReVanced/revanced-patches/commit/3401467a6d49fc75b6757a15e5c848330c1b7307))
|
||||
* **Strava:** Add `Add media download` patch ([#6449](https://github.com/ReVanced/revanced-patches/issues/6449)) ([778d13c](https://github.com/ReVanced/revanced-patches/commit/778d13ce8b28ca6df3a665530320e4a21a27ae44))
|
||||
* **YouTube:** Add `Pause on audio interrupt` patch ([#6464](https://github.com/ReVanced/revanced-patches/issues/6464)) ([19f146c](https://github.com/ReVanced/revanced-patches/commit/19f146c01dc381b3cccd61e61ba4901872ff12d8))
|
||||
|
||||
# [5.48.0-dev.9](https://github.com/ReVanced/revanced-patches/compare/v5.48.0-dev.8...v5.48.0-dev.9) (2026-01-08)
|
||||
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@ import static java.lang.Boolean.FALSE;
|
||||
import static java.lang.Boolean.TRUE;
|
||||
import static app.revanced.extension.shared.settings.Setting.parent;
|
||||
|
||||
import app.revanced.extension.shared.settings.BaseSettings;
|
||||
import app.revanced.extension.shared.settings.YouTubeAndMusicSettings;
|
||||
import app.revanced.extension.shared.settings.BooleanSetting;
|
||||
import app.revanced.extension.shared.settings.EnumSetting;
|
||||
import app.revanced.extension.shared.spoof.ClientType;
|
||||
|
||||
public class Settings extends BaseSettings {
|
||||
public class Settings extends YouTubeAndMusicSettings {
|
||||
|
||||
// Ads
|
||||
public static final BooleanSetting HIDE_VIDEO_ADS = new BooleanSetting("revanced_music_hide_video_ads", TRUE, true);
|
||||
|
||||
15
extensions/nothingx/build.gradle.kts
Normal file
15
extensions/nothingx/build.gradle.kts
Normal file
@@ -0,0 +1,15 @@
|
||||
dependencies {
|
||||
compileOnly(project(":extensions:shared:library"))
|
||||
compileOnly(project(":extensions:nothingx:stub"))
|
||||
}
|
||||
|
||||
android {
|
||||
defaultConfig {
|
||||
minSdk = 26
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
}
|
||||
1
extensions/nothingx/src/main/AndroidManifest.xml
Normal file
1
extensions/nothingx/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1 @@
|
||||
<manifest/>
|
||||
@@ -0,0 +1,590 @@
|
||||
package app.revanced.extension.nothingx.patches;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Application;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Patches to expose the K1 token for Nothing X app to enable pairing with GadgetBridge.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class ShowK1TokensPatch {
|
||||
|
||||
private static final String TAG = "ReVanced";
|
||||
private static final String PACKAGE_NAME = "com.nothing.smartcenter";
|
||||
private static final String EMPTY_MD5 = "d41d8cd98f00b204e9800998ecf8427e";
|
||||
private static final String PREFS_NAME = "revanced_nothingx_prefs";
|
||||
private static final String KEY_DONT_SHOW_DIALOG = "dont_show_k1_dialog";
|
||||
|
||||
// Colors
|
||||
private static final int COLOR_BG = 0xFF1E1E1E;
|
||||
private static final int COLOR_CARD = 0xFF2D2D2D;
|
||||
private static final int COLOR_TEXT_PRIMARY = 0xFFFFFFFF;
|
||||
private static final int COLOR_TEXT_SECONDARY = 0xFFB0B0B0;
|
||||
private static final int COLOR_ACCENT = 0xFFFF9500;
|
||||
private static final int COLOR_TOKEN_BG = 0xFF3A3A3A;
|
||||
private static final int COLOR_BUTTON_POSITIVE = 0xFFFF9500;
|
||||
private static final int COLOR_BUTTON_NEGATIVE = 0xFFFF6B6B;
|
||||
|
||||
// Match standalone K1: k1:, K1:, k1>, etc.
|
||||
private static final Pattern K1_STANDALONE_PATTERN = Pattern.compile("(?i)(?:k1\\s*[:>]\\s*)([0-9a-f]{32})");
|
||||
// Match combined r3+k1: format (64 chars = r3(32) + k1(32))
|
||||
private static final Pattern K1_COMBINED_PATTERN = Pattern.compile("(?i)r3\\+k1\\s*:\\s*([0-9a-f]{64})");
|
||||
|
||||
private static volatile boolean k1Logged = false;
|
||||
private static volatile boolean lifecycleCallbacksRegistered = false;
|
||||
private static Context appContext;
|
||||
|
||||
/**
|
||||
* Get K1 tokens from database and log files.
|
||||
* Call this after the app initializes.
|
||||
*
|
||||
* @param context Application context
|
||||
*/
|
||||
public static void showK1Tokens(Context context) {
|
||||
if (k1Logged) {
|
||||
return;
|
||||
}
|
||||
|
||||
appContext = context.getApplicationContext();
|
||||
|
||||
Set<String> allTokens = new LinkedHashSet<>();
|
||||
|
||||
// First try to get from database.
|
||||
String dbToken = getK1TokensFromDatabase();
|
||||
if (dbToken != null) {
|
||||
allTokens.add(dbToken);
|
||||
}
|
||||
|
||||
// Then get from log files.
|
||||
Set<String> logTokens = getK1TokensFromLogFiles();
|
||||
allTokens.addAll(logTokens);
|
||||
|
||||
if (allTokens.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Log all found tokens.
|
||||
int index = 1;
|
||||
for (String token : allTokens) {
|
||||
Log.i(TAG, "#" + index++ + ": " + token.toUpperCase());
|
||||
}
|
||||
|
||||
// Register lifecycle callbacks to show dialog when an Activity is ready.
|
||||
registerLifecycleCallbacks(allTokens);
|
||||
|
||||
k1Logged = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register ActivityLifecycleCallbacks to show dialog when first Activity resumes.
|
||||
*
|
||||
* @param tokens Set of K1 tokens to display
|
||||
*/
|
||||
private static void registerLifecycleCallbacks(Set<String> tokens) {
|
||||
if (lifecycleCallbacksRegistered || !(appContext instanceof Application)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Application application = (Application) appContext;
|
||||
application.registerActivityLifecycleCallbacks(new Application.ActivityLifecycleCallbacks() {
|
||||
@Override
|
||||
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityStarted(Activity activity) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResumed(Activity activity) {
|
||||
// Check if user chose not to show dialog.
|
||||
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
|
||||
if (prefs.getBoolean(KEY_DONT_SHOW_DIALOG, false)) {
|
||||
application.unregisterActivityLifecycleCallbacks(this);
|
||||
lifecycleCallbacksRegistered = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// Show dialog on first Activity resume.
|
||||
if (tokens != null && !tokens.isEmpty()) {
|
||||
activity.runOnUiThread(() -> showK1TokensDialog(activity, tokens));
|
||||
// Unregister after showing
|
||||
application.unregisterActivityLifecycleCallbacks(this);
|
||||
lifecycleCallbacksRegistered = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityPaused(Activity activity) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityStopped(Activity activity) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityDestroyed(Activity activity) {
|
||||
}
|
||||
});
|
||||
|
||||
lifecycleCallbacksRegistered = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show dialog with K1 tokens.
|
||||
*
|
||||
* @param activity Activity context
|
||||
* @param tokens Set of K1 tokens
|
||||
*/
|
||||
private static void showK1TokensDialog(Activity activity, Set<String> tokens) {
|
||||
try {
|
||||
// Create main container.
|
||||
LinearLayout mainLayout = new LinearLayout(activity);
|
||||
mainLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
mainLayout.setBackgroundColor(COLOR_BG);
|
||||
mainLayout.setPadding(dpToPx(activity, 24), dpToPx(activity, 16),
|
||||
dpToPx(activity, 24), dpToPx(activity, 16));
|
||||
|
||||
// Title.
|
||||
TextView titleView = new TextView(activity);
|
||||
titleView.setText("K1 Token(s) Found");
|
||||
titleView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
|
||||
titleView.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
titleView.setTextColor(COLOR_TEXT_PRIMARY);
|
||||
titleView.setGravity(Gravity.CENTER);
|
||||
mainLayout.addView(titleView, new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
));
|
||||
|
||||
// Subtitle.
|
||||
TextView subtitleView = new TextView(activity);
|
||||
subtitleView.setText(tokens.size() == 1 ? "1 token found • Tap to copy" : tokens.size() + " tokens found • Tap to copy");
|
||||
subtitleView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
|
||||
subtitleView.setTextColor(COLOR_TEXT_SECONDARY);
|
||||
subtitleView.setGravity(Gravity.CENTER);
|
||||
LinearLayout.LayoutParams subtitleParams = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
subtitleParams.topMargin = dpToPx(activity, 4);
|
||||
subtitleParams.bottomMargin = dpToPx(activity, 16);
|
||||
mainLayout.addView(subtitleView, subtitleParams);
|
||||
|
||||
// Scrollable content.
|
||||
ScrollView scrollView = new ScrollView(activity);
|
||||
scrollView.setVerticalScrollBarEnabled(false);
|
||||
LinearLayout.LayoutParams scrollParams = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
0,
|
||||
1.0f
|
||||
);
|
||||
scrollParams.topMargin = dpToPx(activity, 8);
|
||||
scrollParams.bottomMargin = dpToPx(activity, 16);
|
||||
mainLayout.addView(scrollView, scrollParams);
|
||||
|
||||
LinearLayout tokensContainer = new LinearLayout(activity);
|
||||
tokensContainer.setOrientation(LinearLayout.VERTICAL);
|
||||
scrollView.addView(tokensContainer);
|
||||
|
||||
// Add each token as a card.
|
||||
boolean singleToken = tokens.size() == 1;
|
||||
int index = 1;
|
||||
for (String token : tokens) {
|
||||
LinearLayout tokenCard = createTokenCard(activity, token, index++, singleToken);
|
||||
LinearLayout.LayoutParams cardParams = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
cardParams.bottomMargin = dpToPx(activity, 12);
|
||||
tokensContainer.addView(tokenCard, cardParams);
|
||||
}
|
||||
|
||||
// Info text.
|
||||
TextView infoView = new TextView(activity);
|
||||
infoView.setText(tokens.size() == 1 ? "Tap the token to copy it" : "Tap any token to copy it");
|
||||
infoView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
|
||||
infoView.setTextColor(COLOR_TEXT_SECONDARY);
|
||||
infoView.setGravity(Gravity.CENTER);
|
||||
infoView.setAlpha(0.7f);
|
||||
LinearLayout.LayoutParams infoParams = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
infoParams.topMargin = dpToPx(activity, 8);
|
||||
mainLayout.addView(infoView, infoParams);
|
||||
|
||||
// Button row.
|
||||
LinearLayout buttonRow = new LinearLayout(activity);
|
||||
buttonRow.setOrientation(LinearLayout.HORIZONTAL);
|
||||
buttonRow.setGravity(Gravity.END);
|
||||
LinearLayout.LayoutParams buttonRowParams = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
buttonRowParams.topMargin = dpToPx(activity, 16);
|
||||
mainLayout.addView(buttonRow, buttonRowParams);
|
||||
|
||||
// "Don't show again" button.
|
||||
Button dontShowButton = new Button(activity);
|
||||
dontShowButton.setText("Don't show again");
|
||||
dontShowButton.setTextColor(Color.WHITE);
|
||||
dontShowButton.setBackgroundColor(Color.TRANSPARENT);
|
||||
dontShowButton.setAllCaps(false);
|
||||
dontShowButton.setTypeface(Typeface.DEFAULT);
|
||||
dontShowButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
|
||||
dontShowButton.setPadding(dpToPx(activity, 16), dpToPx(activity, 8),
|
||||
dpToPx(activity, 16), dpToPx(activity, 8));
|
||||
LinearLayout.LayoutParams dontShowParams = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
dontShowParams.rightMargin = dpToPx(activity, 8);
|
||||
buttonRow.addView(dontShowButton, dontShowParams);
|
||||
|
||||
// "OK" button.
|
||||
Button okButton = new Button(activity);
|
||||
okButton.setText("OK");
|
||||
okButton.setTextColor(Color.BLACK);
|
||||
okButton.setBackgroundColor(COLOR_BUTTON_POSITIVE);
|
||||
okButton.setAllCaps(false);
|
||||
okButton.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
okButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
|
||||
okButton.setPadding(dpToPx(activity, 24), dpToPx(activity, 12),
|
||||
dpToPx(activity, 24), dpToPx(activity, 12));
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
okButton.setElevation(dpToPx(activity, 4));
|
||||
}
|
||||
buttonRow.addView(okButton, new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
));
|
||||
|
||||
// Build dialog.
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setView(mainLayout);
|
||||
|
||||
final AlertDialog dialog = builder.create();
|
||||
|
||||
// Style the dialog with dark background.
|
||||
if (dialog.getWindow() != null) {
|
||||
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
|
||||
}
|
||||
|
||||
dialog.show();
|
||||
|
||||
// Set button click listeners after dialog is created.
|
||||
dontShowButton.setOnClickListener(v -> {
|
||||
SharedPreferences prefs = activity.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
|
||||
prefs.edit().putBoolean(KEY_DONT_SHOW_DIALOG, true).apply();
|
||||
Toast.makeText(activity, "Dialog disabled. Clear app data to re-enable.",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
okButton.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to show K1 dialog", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a card view for a single token.
|
||||
*/
|
||||
private static LinearLayout createTokenCard(Activity activity, String token, int index, boolean singleToken) {
|
||||
LinearLayout card = new LinearLayout(activity);
|
||||
card.setOrientation(LinearLayout.VERTICAL);
|
||||
card.setBackgroundColor(COLOR_TOKEN_BG);
|
||||
card.setPadding(dpToPx(activity, 16), dpToPx(activity, 12),
|
||||
dpToPx(activity, 16), dpToPx(activity, 12));
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
card.setElevation(dpToPx(activity, 2));
|
||||
}
|
||||
card.setClickable(true);
|
||||
card.setFocusable(true);
|
||||
|
||||
// Token label (only show if multiple tokens).
|
||||
if (!singleToken) {
|
||||
TextView labelView = new TextView(activity);
|
||||
labelView.setText("Token #" + index);
|
||||
labelView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
|
||||
labelView.setTextColor(COLOR_ACCENT);
|
||||
labelView.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
card.addView(labelView);
|
||||
}
|
||||
|
||||
// Token value.
|
||||
TextView tokenView = new TextView(activity);
|
||||
tokenView.setText(token.toUpperCase());
|
||||
tokenView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
|
||||
tokenView.setTextColor(COLOR_TEXT_PRIMARY);
|
||||
tokenView.setTypeface(Typeface.MONOSPACE);
|
||||
tokenView.setLetterSpacing(0.05f);
|
||||
LinearLayout.LayoutParams tokenParams = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
if (!singleToken) {
|
||||
tokenParams.topMargin = dpToPx(activity, 8);
|
||||
}
|
||||
card.addView(tokenView, tokenParams);
|
||||
|
||||
// Click to copy.
|
||||
card.setOnClickListener(v -> {
|
||||
ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
if (clipboard != null) {
|
||||
clipboard.setText(token.toUpperCase());
|
||||
Toast.makeText(activity, "Token copied!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
return card;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert dp to pixels.
|
||||
*/
|
||||
private static int dpToPx(Context context, float dp) {
|
||||
return (int) TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_DIP,
|
||||
dp,
|
||||
context.getResources().getDisplayMetrics()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get K1 tokens from log files.
|
||||
* Prioritizes pairing K1 tokens over reconnect tokens.
|
||||
*/
|
||||
private static Set<String> getK1TokensFromLogFiles() {
|
||||
Set<String> pairingTokens = new LinkedHashSet<>();
|
||||
Set<String> reconnectTokens = new LinkedHashSet<>();
|
||||
try {
|
||||
File logDir = new File("/data/data/" + PACKAGE_NAME + "/files/log");
|
||||
if (!logDir.exists() || !logDir.isDirectory()) {
|
||||
return pairingTokens;
|
||||
}
|
||||
|
||||
File[] logFiles = logDir.listFiles((dir, name) ->
|
||||
name.endsWith(".log") || name.endsWith(".log.") || name.matches(".*\\.log\\.\\d+"));
|
||||
|
||||
if (logFiles == null || logFiles.length == 0) {
|
||||
return pairingTokens;
|
||||
}
|
||||
|
||||
for (File logFile : logFiles) {
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(logFile))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
// Determine if this is a pairing or reconnect context.
|
||||
boolean isPairingContext = line.toLowerCase().contains("watchbind");
|
||||
boolean isReconnectContext = line.toLowerCase().contains("watchreconnect");
|
||||
|
||||
String k1Token = null;
|
||||
|
||||
// First check for combined r3+k1 format (priority).
|
||||
Matcher combinedMatcher = K1_COMBINED_PATTERN.matcher(line);
|
||||
if (combinedMatcher.find()) {
|
||||
String combined = combinedMatcher.group(1);
|
||||
if (combined.length() == 64) {
|
||||
// Second half is the actual K1
|
||||
k1Token = combined.substring(32).toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
// Then check for standalone K1 format (only if not found in combined).
|
||||
if (k1Token == null) {
|
||||
Matcher standaloneMatcher = K1_STANDALONE_PATTERN.matcher(line);
|
||||
if (standaloneMatcher.find()) {
|
||||
String token = standaloneMatcher.group(1);
|
||||
if (token != null && token.length() == 32) {
|
||||
k1Token = token.toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add to appropriate set.
|
||||
if (k1Token != null) {
|
||||
if (isPairingContext && !isReconnectContext) {
|
||||
pairingTokens.add(k1Token);
|
||||
} else {
|
||||
reconnectTokens.add(k1Token);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Skip unreadable files.
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// Fail silently.
|
||||
}
|
||||
|
||||
// Return pairing tokens first, add reconnect tokens if no pairing tokens found.
|
||||
if (!pairingTokens.isEmpty()) {
|
||||
Log.i(TAG, "Found " + pairingTokens.size() + " pairing K1 token(s)");
|
||||
return pairingTokens;
|
||||
}
|
||||
|
||||
if (!reconnectTokens.isEmpty()) {
|
||||
Log.i(TAG, "Found " + reconnectTokens.size() + " reconnect K1 token(s) (may not work for initial pairing)");
|
||||
}
|
||||
return reconnectTokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to get K1 tokens from the database.
|
||||
*/
|
||||
private static String getK1TokensFromDatabase() {
|
||||
try {
|
||||
File dbDir = new File("/data/data/" + PACKAGE_NAME + "/databases");
|
||||
if (!dbDir.exists() || !dbDir.isDirectory()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
File[] dbFiles = dbDir.listFiles((dir, name) ->
|
||||
name.endsWith(".db") && !name.startsWith("google_app_measurement") && !name.contains("firebase"));
|
||||
|
||||
if (dbFiles == null || dbFiles.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (File dbFile : dbFiles) {
|
||||
String token = getK1TokensFromDatabase(dbFile);
|
||||
if (token != null) {
|
||||
return token;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract K1 tokens from a database file.
|
||||
*/
|
||||
private static String getK1TokensFromDatabase(File dbFile) {
|
||||
SQLiteDatabase db = null;
|
||||
try {
|
||||
db = SQLiteDatabase.openDatabase(dbFile.getPath(), null, SQLiteDatabase.OPEN_READONLY);
|
||||
|
||||
// Get all tables.
|
||||
Cursor cursor = db.rawQuery(
|
||||
"SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'",
|
||||
null
|
||||
);
|
||||
|
||||
List<String> tables = new ArrayList<>();
|
||||
while (cursor.moveToNext()) {
|
||||
tables.add(cursor.getString(0));
|
||||
}
|
||||
cursor.close();
|
||||
|
||||
// Scan all columns for 32-char hex strings.
|
||||
for (String table : tables) {
|
||||
Cursor schemaCursor = null;
|
||||
try {
|
||||
schemaCursor = db.rawQuery("PRAGMA table_info(" + table + ")", null);
|
||||
List<String> columns = new ArrayList<>();
|
||||
while (schemaCursor.moveToNext()) {
|
||||
columns.add(schemaCursor.getString(1));
|
||||
}
|
||||
schemaCursor.close();
|
||||
|
||||
for (String column : columns) {
|
||||
Cursor dataCursor = null;
|
||||
try {
|
||||
dataCursor = db.query(table, new String[]{column}, null, null, null, null, null);
|
||||
while (dataCursor.moveToNext()) {
|
||||
String value = dataCursor.getString(0);
|
||||
if (value != null && value.length() == 32 && value.matches("[0-9a-fA-F]{32}")) {
|
||||
// Skip obviously fake tokens (MD5 of empty string).
|
||||
if (!value.equalsIgnoreCase(EMPTY_MD5)) {
|
||||
dataCursor.close();
|
||||
db.close();
|
||||
return value.toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Skip non-string columns.
|
||||
} finally {
|
||||
if (dataCursor != null) {
|
||||
dataCursor.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Continue to next table.
|
||||
} finally {
|
||||
if (schemaCursor != null && !schemaCursor.isClosed()) {
|
||||
schemaCursor.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
} finally {
|
||||
if (db != null && db.isOpen()) {
|
||||
db.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the logged flag (useful for testing or re-pairing).
|
||||
*/
|
||||
public static void resetK1Logged() {
|
||||
k1Logged = false;
|
||||
lifecycleCallbacksRegistered = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the "don't show again" preference.
|
||||
*/
|
||||
public static void resetDontShowPreference() {
|
||||
if (appContext != null) {
|
||||
SharedPreferences prefs = appContext.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
|
||||
prefs.edit().putBoolean(KEY_DONT_SHOW_DIALOG, false).apply();
|
||||
}
|
||||
}
|
||||
}
|
||||
17
extensions/nothingx/stub/build.gradle.kts
Normal file
17
extensions/nothingx/stub/build.gradle.kts
Normal file
@@ -0,0 +1,17 @@
|
||||
plugins {
|
||||
alias(libs.plugins.android.library)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "app.revanced.extension"
|
||||
compileSdk = 34
|
||||
|
||||
defaultConfig {
|
||||
minSdk = 26
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
}
|
||||
1
extensions/nothingx/stub/src/main/AndroidManifest.xml
Normal file
1
extensions/nothingx/stub/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1 @@
|
||||
<manifest/>
|
||||
@@ -311,6 +311,10 @@ public class Utils {
|
||||
return resourceId;
|
||||
}
|
||||
|
||||
public static String getResourceString(int id) throws Resources.NotFoundException {
|
||||
return getContext().getResources().getString(id);
|
||||
}
|
||||
|
||||
public static int getResourceInteger(String resourceIdentifierName) throws Resources.NotFoundException {
|
||||
return getContext().getResources().getInteger(getResourceIdentifierOrThrow(resourceIdentifierName, "integer"));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package app.revanced.extension.youtube.patches.components;
|
||||
package app.revanced.extension.shared.patches.components;
|
||||
|
||||
import static app.revanced.extension.shared.StringRef.str;
|
||||
|
||||
@@ -15,13 +15,15 @@ import java.util.regex.Pattern;
|
||||
import app.revanced.extension.shared.Logger;
|
||||
import app.revanced.extension.shared.Utils;
|
||||
import app.revanced.extension.shared.ByteTrieSearch;
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.StringFilterGroup;
|
||||
import app.revanced.extension.shared.settings.YouTubeAndMusicSettings;
|
||||
import app.revanced.extension.shared.patches.litho.Filter;
|
||||
|
||||
/**
|
||||
* Allows custom filtering using a path and optionally a proto buffer string.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
final class CustomFilter extends Filter {
|
||||
public final class CustomFilter extends Filter {
|
||||
|
||||
private static void showInvalidSyntaxToast(@NonNull String expression) {
|
||||
Utils.showToastLong(str("revanced_custom_filter_toast_invalid_syntax", expression));
|
||||
@@ -45,7 +47,7 @@ final class CustomFilter extends Filter {
|
||||
@NonNull
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
static Collection<CustomFilterGroup> parseCustomFilterGroups() {
|
||||
String rawCustomFilterText = Settings.CUSTOM_FILTER_STRINGS.get();
|
||||
String rawCustomFilterText = YouTubeAndMusicSettings.CUSTOM_FILTER_STRINGS.get();
|
||||
if (rawCustomFilterText.isBlank()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -100,7 +102,7 @@ final class CustomFilter extends Filter {
|
||||
ByteTrieSearch bufferSearch;
|
||||
|
||||
CustomFilterGroup(boolean startsWith, @NonNull String path) {
|
||||
super(Settings.CUSTOM_FILTER, path);
|
||||
super(YouTubeAndMusicSettings.CUSTOM_FILTER, path);
|
||||
this.startsWith = startsWith;
|
||||
}
|
||||
|
||||
@@ -145,7 +147,7 @@ final class CustomFilter extends Filter {
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
public boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
// All callbacks are custom filter groups.
|
||||
CustomFilterGroup custom = (CustomFilterGroup) matchedGroup;
|
||||
@@ -159,4 +161,4 @@ final class CustomFilter extends Filter {
|
||||
|
||||
return custom.bufferSearch.matches(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
package app.revanced.extension.youtube.patches.components;
|
||||
package app.revanced.extension.shared.patches.litho;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.StringFilterGroup;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.ByteArrayFilterGroup;
|
||||
|
||||
/**
|
||||
* Filters litho based components.
|
||||
*
|
||||
@@ -14,11 +17,11 @@ import java.util.List;
|
||||
* either an identifier or a path.
|
||||
* Then inside {@link #isFiltered(String, String, byte[], StringFilterGroup, FilterContentType, int)}
|
||||
* search for the buffer content using either a {@link ByteArrayFilterGroup} (if searching for 1 pattern)
|
||||
* or a {@link ByteArrayFilterGroupList} (if searching for more than 1 pattern).
|
||||
* or a {@link FilterGroupList.ByteArrayFilterGroupList} (if searching for more than 1 pattern).
|
||||
*
|
||||
* All callbacks must be registered before the constructor completes.
|
||||
*/
|
||||
abstract class Filter {
|
||||
public abstract class Filter {
|
||||
|
||||
public enum FilterContentType {
|
||||
IDENTIFIER,
|
||||
@@ -65,7 +68,7 @@ abstract class Filter {
|
||||
* @param contentIndex Matched index of the identifier or path.
|
||||
* @return True if the litho component should be filtered out.
|
||||
*/
|
||||
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
public boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
package app.revanced.extension.shared.patches.litho;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import app.revanced.extension.shared.ByteTrieSearch;
|
||||
import app.revanced.extension.shared.Logger;
|
||||
import app.revanced.extension.shared.settings.BooleanSetting;
|
||||
|
||||
public abstract class FilterGroup<T> {
|
||||
public final static class FilterGroupResult {
|
||||
private BooleanSetting setting;
|
||||
private int matchedIndex;
|
||||
private int matchedLength;
|
||||
// In the future it might be useful to include which pattern matched,
|
||||
// but for now that is not needed.
|
||||
|
||||
FilterGroupResult() {
|
||||
this(null, -1, 0);
|
||||
}
|
||||
|
||||
FilterGroupResult(BooleanSetting setting, int matchedIndex, int matchedLength) {
|
||||
setValues(setting, matchedIndex, matchedLength);
|
||||
}
|
||||
|
||||
public void setValues(BooleanSetting setting, int matchedIndex, int matchedLength) {
|
||||
this.setting = setting;
|
||||
this.matchedIndex = matchedIndex;
|
||||
this.matchedLength = matchedLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* A null value if the group has no setting,
|
||||
* or if no match is returned from {@link FilterGroupList#check(Object)}.
|
||||
*/
|
||||
public BooleanSetting getSetting() {
|
||||
return setting;
|
||||
}
|
||||
|
||||
public boolean isFiltered() {
|
||||
return matchedIndex >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Matched index of first pattern that matched, or -1 if nothing matched.
|
||||
*/
|
||||
public int getMatchedIndex() {
|
||||
return matchedIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Length of the matched filter pattern.
|
||||
*/
|
||||
public int getMatchedLength() {
|
||||
return matchedLength;
|
||||
}
|
||||
}
|
||||
|
||||
protected final BooleanSetting setting;
|
||||
protected final T[] filters;
|
||||
|
||||
/**
|
||||
* Initialize a new filter group.
|
||||
*
|
||||
* @param setting The associated setting.
|
||||
* @param filters The filters.
|
||||
*/
|
||||
@SafeVarargs
|
||||
public FilterGroup(final BooleanSetting setting, final T... filters) {
|
||||
this.setting = setting;
|
||||
this.filters = filters;
|
||||
if (filters.length == 0) {
|
||||
throw new IllegalArgumentException("Must use one or more filter patterns (zero specified)");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return setting == null || setting.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return If {@link FilterGroupList} should include this group when searching.
|
||||
* By default, all filters are included except non enabled settings that require reboot.
|
||||
*/
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
public boolean includeInSearch() {
|
||||
return isEnabled() || !setting.rebootApp;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + ": " + (setting == null ? "(null setting)" : setting);
|
||||
}
|
||||
|
||||
public abstract FilterGroupResult check(final T stack);
|
||||
|
||||
|
||||
public static class StringFilterGroup extends FilterGroup<String> {
|
||||
|
||||
public StringFilterGroup(final BooleanSetting setting, final String... filters) {
|
||||
super(setting, filters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FilterGroupResult check(final String string) {
|
||||
int matchedIndex = -1;
|
||||
int matchedLength = 0;
|
||||
if (isEnabled()) {
|
||||
for (String pattern : filters) {
|
||||
if (!string.isEmpty()) {
|
||||
final int indexOf = string.indexOf(pattern);
|
||||
if (indexOf >= 0) {
|
||||
matchedIndex = indexOf;
|
||||
matchedLength = pattern.length();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return new FilterGroupResult(setting, matchedIndex, matchedLength);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If you have more than 1 filter patterns, then all instances of
|
||||
* this class should filtered using {@link FilterGroupList.ByteArrayFilterGroupList#check(byte[])},
|
||||
* which uses a prefix tree to give better performance.
|
||||
*/
|
||||
public static class ByteArrayFilterGroup extends FilterGroup<byte[]> {
|
||||
|
||||
private volatile int[][] failurePatterns;
|
||||
|
||||
// Modified implementation from https://stackoverflow.com/a/1507813
|
||||
private static int indexOf(final byte[] data, final byte[] pattern, final int[] failure) {
|
||||
// Finds the first occurrence of the pattern in the byte array using
|
||||
// KMP matching algorithm.
|
||||
int patternLength = pattern.length;
|
||||
for (int i = 0, j = 0, dataLength = data.length; i < dataLength; i++) {
|
||||
while (j > 0 && pattern[j] != data[i]) {
|
||||
j = failure[j - 1];
|
||||
}
|
||||
if (pattern[j] == data[i]) {
|
||||
j++;
|
||||
}
|
||||
if (j == patternLength) {
|
||||
return i - patternLength + 1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static int[] createFailurePattern(byte[] pattern) {
|
||||
// Computes the failure function using a boot-strapping process,
|
||||
// where the pattern is matched against itself.
|
||||
final int patternLength = pattern.length;
|
||||
final int[] failure = new int[patternLength];
|
||||
|
||||
for (int i = 1, j = 0; i < patternLength; i++) {
|
||||
while (j > 0 && pattern[j] != pattern[i]) {
|
||||
j = failure[j - 1];
|
||||
}
|
||||
if (pattern[j] == pattern[i]) {
|
||||
j++;
|
||||
}
|
||||
failure[i] = j;
|
||||
}
|
||||
return failure;
|
||||
}
|
||||
|
||||
public ByteArrayFilterGroup(BooleanSetting setting, byte[]... filters) {
|
||||
super(setting, filters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the Strings into byte arrays. Used to search for text in binary data.
|
||||
*/
|
||||
public ByteArrayFilterGroup(BooleanSetting setting, String... filters) {
|
||||
super(setting, ByteTrieSearch.convertStringsToBytes(filters));
|
||||
}
|
||||
|
||||
private synchronized void buildFailurePatterns() {
|
||||
if (failurePatterns != null) return; // Thread race and another thread already initialized the search.
|
||||
Logger.printDebug(() -> "Building failure array for: " + this);
|
||||
int[][] failurePatterns = new int[filters.length][];
|
||||
int i = 0;
|
||||
for (byte[] pattern : filters) {
|
||||
failurePatterns[i++] = createFailurePattern(pattern);
|
||||
}
|
||||
this.failurePatterns = failurePatterns; // Must set after initialization finishes.
|
||||
}
|
||||
|
||||
@Override
|
||||
public FilterGroupResult check(final byte[] bytes) {
|
||||
int matchedLength = 0;
|
||||
int matchedIndex = -1;
|
||||
if (isEnabled()) {
|
||||
int[][] failures = failurePatterns;
|
||||
if (failures == null) {
|
||||
buildFailurePatterns(); // Lazy load.
|
||||
failures = failurePatterns;
|
||||
}
|
||||
for (int i = 0, length = filters.length; i < length; i++) {
|
||||
byte[] filter = filters[i];
|
||||
matchedIndex = indexOf(bytes, filter, failures[i]);
|
||||
if (matchedIndex >= 0) {
|
||||
matchedLength = filter.length;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new FilterGroupResult(setting, matchedIndex, matchedLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,22 @@
|
||||
package app.revanced.extension.youtube.patches.components;
|
||||
package app.revanced.extension.shared.patches.litho;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import app.revanced.extension.shared.ByteTrieSearch;
|
||||
import app.revanced.extension.shared.StringTrieSearch;
|
||||
import app.revanced.extension.shared.TrieSearch;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.ByteArrayFilterGroup;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.StringFilterGroup;
|
||||
|
||||
abstract class FilterGroupList<V, T extends FilterGroup<V>> implements Iterable<T> {
|
||||
public abstract class FilterGroupList<V, T extends FilterGroup<V>> implements Iterable<T> {
|
||||
|
||||
private final List<T> filterGroups = new ArrayList<>();
|
||||
private final TrieSearch<V> search = createSearchGraph();
|
||||
|
||||
@SafeVarargs
|
||||
protected final void addAll(final T... groups) {
|
||||
public final void addAll(final T... groups) {
|
||||
filterGroups.addAll(Arrays.asList(groups));
|
||||
|
||||
for (T group : groups) {
|
||||
@@ -41,18 +42,7 @@ abstract class FilterGroupList<V, T extends FilterGroup<V>> implements Iterable<
|
||||
return filterGroups.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(@NonNull Consumer<? super T> action) {
|
||||
filterGroups.forEach(action);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Spliterator<T> spliterator() {
|
||||
return filterGroups.spliterator();
|
||||
}
|
||||
|
||||
protected FilterGroup.FilterGroupResult check(V stack) {
|
||||
public FilterGroup.FilterGroupResult check(V stack) {
|
||||
FilterGroup.FilterGroupResult result = new FilterGroup.FilterGroupResult();
|
||||
search.matches(stack, result);
|
||||
return result;
|
||||
@@ -60,21 +50,21 @@ abstract class FilterGroupList<V, T extends FilterGroup<V>> implements Iterable<
|
||||
}
|
||||
|
||||
protected abstract TrieSearch<V> createSearchGraph();
|
||||
}
|
||||
|
||||
final class StringFilterGroupList extends FilterGroupList<String, StringFilterGroup> {
|
||||
protected StringTrieSearch createSearchGraph() {
|
||||
return new StringTrieSearch();
|
||||
public static final class StringFilterGroupList extends FilterGroupList<String, StringFilterGroup> {
|
||||
protected StringTrieSearch createSearchGraph() {
|
||||
return new StringTrieSearch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If searching for a single byte pattern, then it is slightly better to use
|
||||
* {@link ByteArrayFilterGroup#check(byte[])} as it uses KMP which is faster
|
||||
* than a prefix tree to search for only 1 pattern.
|
||||
*/
|
||||
final class ByteArrayFilterGroupList extends FilterGroupList<byte[], ByteArrayFilterGroup> {
|
||||
protected ByteTrieSearch createSearchGraph() {
|
||||
return new ByteTrieSearch();
|
||||
/**
|
||||
* If searching for a single byte pattern, then it is slightly better to use
|
||||
* {@link ByteArrayFilterGroup#check(byte[])} as it uses KMP which is faster
|
||||
* than a prefix tree to search for only 1 pattern.
|
||||
*/
|
||||
public static final class ByteArrayFilterGroupList extends FilterGroupList<byte[], ByteArrayFilterGroup> {
|
||||
protected ByteTrieSearch createSearchGraph() {
|
||||
return new ByteTrieSearch();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package app.revanced.extension.youtube.patches.components;
|
||||
package app.revanced.extension.shared.patches.litho;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -7,9 +7,11 @@ import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
|
||||
import app.revanced.extension.shared.Logger;
|
||||
import app.revanced.extension.shared.settings.BaseSettings;
|
||||
import app.revanced.extension.shared.StringTrieSearch;
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
import app.revanced.extension.shared.settings.BaseSettings;
|
||||
import app.revanced.extension.shared.settings.YouTubeAndMusicSettings;
|
||||
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.StringFilterGroup;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class LithoFilterPatch {
|
||||
@@ -36,7 +38,7 @@ public final class LithoFilterPatch {
|
||||
builder.append(identifier);
|
||||
builder.append(" Path: ");
|
||||
builder.append(path);
|
||||
if (Settings.DEBUG_PROTOBUFFER.get()) {
|
||||
if (YouTubeAndMusicSettings.DEBUG_PROTOBUFFER.get()) {
|
||||
builder.append(" BufferStrings: ");
|
||||
findAsciiStrings(builder, buffer);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package app.revanced.extension.shared.settings;
|
||||
|
||||
import static app.revanced.extension.shared.settings.Setting.parent;
|
||||
import static java.lang.Boolean.FALSE;
|
||||
|
||||
public class YouTubeAndMusicSettings extends BaseSettings {
|
||||
// Custom filter
|
||||
public static final BooleanSetting CUSTOM_FILTER = new BooleanSetting("revanced_custom_filter", FALSE);
|
||||
public static final StringSetting CUSTOM_FILTER_STRINGS = new StringSetting("revanced_custom_filter_strings", "", true, parent(CUSTOM_FILTER));
|
||||
|
||||
// Miscellaneous
|
||||
public static final BooleanSetting DEBUG_PROTOBUFFER = new BooleanSetting("revanced_debug_protobuffer", FALSE, false,
|
||||
"revanced_debug_protobuffer_user_dialog_message", parent(BaseSettings.DEBUG));
|
||||
}
|
||||
5
extensions/strava/build.gradle.kts
Normal file
5
extensions/strava/build.gradle.kts
Normal file
@@ -0,0 +1,5 @@
|
||||
dependencies {
|
||||
compileOnly(project(":extensions:shared:library"))
|
||||
compileOnly(project(":extensions:strava:stub"))
|
||||
compileOnly(libs.okhttp)
|
||||
}
|
||||
1
extensions/strava/src/main/AndroidManifest.xml
Normal file
1
extensions/strava/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1 @@
|
||||
<manifest/>
|
||||
@@ -0,0 +1,216 @@
|
||||
package app.revanced.extension.strava;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
import android.webkit.MimeTypeMap;
|
||||
|
||||
import com.strava.core.data.MediaType;
|
||||
import com.strava.photos.data.Media;
|
||||
|
||||
import okhttp3.*;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import app.revanced.extension.shared.Utils;
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public final class AddMediaDownloadPatch {
|
||||
public static final int ACTION_DOWNLOAD = -1;
|
||||
public static final int ACTION_OPEN_LINK = -2;
|
||||
public static final int ACTION_COPY_LINK = -3;
|
||||
|
||||
private static final OkHttpClient client = new OkHttpClient();
|
||||
|
||||
public static boolean handleAction(int actionId, Media media) {
|
||||
String url = getUrl(media);
|
||||
switch (actionId) {
|
||||
case ACTION_DOWNLOAD:
|
||||
String name = media.getId();
|
||||
if (media.getType() == MediaType.VIDEO) {
|
||||
downloadVideo(url, name);
|
||||
} else {
|
||||
downloadPhoto(url, name);
|
||||
}
|
||||
return true;
|
||||
case ACTION_OPEN_LINK:
|
||||
Utils.openLink(url);
|
||||
return true;
|
||||
case ACTION_COPY_LINK:
|
||||
copyLink(url);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void copyLink(CharSequence url) {
|
||||
Utils.setClipboard(url);
|
||||
showInfoToast("link_copied_to_clipboard", "🔗");
|
||||
}
|
||||
|
||||
public static void downloadPhoto(String url, String name) {
|
||||
showInfoToast("loading", "⏳");
|
||||
Utils.runOnBackgroundThread(() -> {
|
||||
try (Response response = fetch(url)) {
|
||||
ResponseBody body = response.body();
|
||||
String mimeType = body.contentType().toString();
|
||||
String extension = MimeTypeMap.getSingleton().getExtensionFromMimeType(mimeType);
|
||||
ContentResolver resolver = Utils.getContext().getContentResolver();
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(MediaStore.Images.Media.DISPLAY_NAME, name + '.' + extension);
|
||||
values.put(MediaStore.Images.Media.IS_PENDING, 1);
|
||||
values.put(MediaStore.Images.Media.MIME_TYPE, mimeType);
|
||||
values.put(MediaStore.Images.Media.RELATIVE_PATH, Environment.DIRECTORY_PICTURES + "/Strava");
|
||||
Uri collection = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
|
||||
? MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL)
|
||||
: MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||
Uri row = resolver.insert(collection, values);
|
||||
try (OutputStream outputStream = resolver.openOutputStream(row)) {
|
||||
transferTo(body.byteStream(), outputStream);
|
||||
} finally {
|
||||
values.clear();
|
||||
values.put(MediaStore.Images.Media.IS_PENDING, 0);
|
||||
resolver.update(row, values, null);
|
||||
}
|
||||
showInfoToast("yis_2024_local_save_image_success", "✔️");
|
||||
} catch (IOException e) {
|
||||
showErrorToast("download_failure", "❌", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads a video in the M3U8 / HLS (HTTP Live Streaming) format.
|
||||
*/
|
||||
public static void downloadVideo(String url, String name) {
|
||||
// The first request yields multiple URLs with different stream options.
|
||||
// In case of Strava, the first one is always of highest quality.
|
||||
// Each stream can consist of multiple chunks.
|
||||
// The second request yields the URLs of all of these chunks.
|
||||
// Fetch all of them concurrently and pipe their streams into the file in order.
|
||||
showInfoToast("loading", "⏳");
|
||||
Utils.runOnBackgroundThread(() -> {
|
||||
try {
|
||||
String highestQualityStreamUrl;
|
||||
try (Response response = fetch(url)) {
|
||||
highestQualityStreamUrl = replaceFileName(url, lines(response).findFirst().get());
|
||||
}
|
||||
List<Future<Response>> futures;
|
||||
try (Response response = fetch(highestQualityStreamUrl)) {
|
||||
futures = lines(response)
|
||||
.map(line -> replaceFileName(highestQualityStreamUrl, line))
|
||||
.map(chunkUrl -> Utils.submitOnBackgroundThread(() -> fetch(chunkUrl)))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
ContentResolver resolver = Utils.getContext().getContentResolver();
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(MediaStore.Video.Media.DISPLAY_NAME, name + '.' + "mp4");
|
||||
values.put(MediaStore.Video.Media.IS_PENDING, 1);
|
||||
values.put(MediaStore.Video.Media.MIME_TYPE, MimeTypeMap.getSingleton().getMimeTypeFromExtension("mp4"));
|
||||
values.put(MediaStore.Video.Media.RELATIVE_PATH, Environment.DIRECTORY_MOVIES + "/Strava");
|
||||
Uri collection = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
|
||||
? MediaStore.Video.Media.getContentUri(MediaStore.VOLUME_EXTERNAL)
|
||||
: MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
|
||||
Uri row = resolver.insert(collection, values);
|
||||
try (OutputStream outputStream = resolver.openOutputStream(row)) {
|
||||
Throwable error = null;
|
||||
for (Future<Response> future : futures) {
|
||||
if (error != null) {
|
||||
if (future.cancel(true)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
try (Response response = future.get()) {
|
||||
if (error == null) {
|
||||
transferTo(response.body().byteStream(), outputStream);
|
||||
}
|
||||
} catch (InterruptedException | IOException e) {
|
||||
error = e;
|
||||
} catch (ExecutionException e) {
|
||||
error = e.getCause();
|
||||
}
|
||||
}
|
||||
if (error != null) {
|
||||
throw new IOException(error);
|
||||
}
|
||||
} finally {
|
||||
values.clear();
|
||||
values.put(MediaStore.Video.Media.IS_PENDING, 0);
|
||||
resolver.update(row, values, null);
|
||||
}
|
||||
showInfoToast("yis_2024_local_save_video_success", "✔️");
|
||||
} catch (IOException e) {
|
||||
showErrorToast("download_failure", "❌", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static String getUrl(Media media) {
|
||||
return media.getType() == MediaType.VIDEO
|
||||
? ((Media.Video) media).getVideoUrl()
|
||||
: media.getLargestUrl();
|
||||
}
|
||||
|
||||
private static String getString(String name, String fallback) {
|
||||
int id = Utils.getResourceIdentifier(name, "string");
|
||||
return id != 0
|
||||
? Utils.getResourceString(id)
|
||||
: fallback;
|
||||
}
|
||||
|
||||
private static void showInfoToast(String resourceName, String fallback) {
|
||||
String text = getString(resourceName, fallback);
|
||||
Utils.showToastShort(text);
|
||||
}
|
||||
|
||||
private static void showErrorToast(String resourceName, String fallback, IOException exception) {
|
||||
String text = getString(resourceName, fallback);
|
||||
Utils.showToastLong(text + ' ' + exception.getLocalizedMessage());
|
||||
}
|
||||
|
||||
private static Response fetch(String url) throws IOException {
|
||||
Request request = new Request.Builder().url(url).build();
|
||||
Response response = client.newCall(request).execute();
|
||||
if (!response.isSuccessful()) {
|
||||
throw new IOException("Got HTTP status code " + response.code());
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code inputStream.transferTo(outputStream)} is "too new".
|
||||
*/
|
||||
private static void transferTo(InputStream in, OutputStream out) throws IOException {
|
||||
byte[] buffer = new byte[1024 * 8];
|
||||
int length;
|
||||
while ((length = in.read(buffer)) != -1) {
|
||||
out.write(buffer, 0, length);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all file names.
|
||||
*/
|
||||
private static Stream<String> lines(Response response) {
|
||||
BufferedReader reader = new BufferedReader(response.body().charStream());
|
||||
return reader.lines().filter(line -> !line.startsWith("#"));
|
||||
}
|
||||
|
||||
private static String replaceFileName(String uri, String newName) {
|
||||
return uri.substring(0, uri.lastIndexOf('/') + 1) + newName;
|
||||
}
|
||||
}
|
||||
12
extensions/strava/stub/build.gradle.kts
Normal file
12
extensions/strava/stub/build.gradle.kts
Normal file
@@ -0,0 +1,12 @@
|
||||
plugins {
|
||||
alias(libs.plugins.android.library)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "app.revanced.extension"
|
||||
compileSdk = 34
|
||||
|
||||
defaultConfig {
|
||||
minSdk = 21
|
||||
}
|
||||
}
|
||||
1
extensions/strava/stub/src/main/AndroidManifest.xml
Normal file
1
extensions/strava/stub/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1 @@
|
||||
<manifest/>
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.strava.core.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public interface MediaContent extends Serializable {
|
||||
String getCaption();
|
||||
|
||||
String getId();
|
||||
|
||||
String getReferenceId();
|
||||
|
||||
MediaType getType();
|
||||
|
||||
void setCaption(String caption);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.strava.core.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public final class MediaDimension implements Comparable<MediaDimension>, Serializable {
|
||||
private final int height;
|
||||
private final int width;
|
||||
|
||||
public MediaDimension(int width, int height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public float getHeightScale() {
|
||||
if (width <= 0 || height <= 0) {
|
||||
return 1f;
|
||||
}
|
||||
return height / width;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public float getWidthScale() {
|
||||
if (width <= 0 || height <= 0) {
|
||||
return 1f;
|
||||
}
|
||||
return width / height;
|
||||
}
|
||||
|
||||
public boolean isLandscape() {
|
||||
return width > 0 && width >= height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(MediaDimension other) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.strava.core.data;
|
||||
|
||||
public enum MediaType {
|
||||
PHOTO(1),
|
||||
VIDEO(2);
|
||||
|
||||
private final int remoteValue;
|
||||
|
||||
private MediaType(int remoteValue) {
|
||||
this.remoteValue = remoteValue;
|
||||
}
|
||||
|
||||
public int getRemoteValue() {
|
||||
return remoteValue;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.strava.core.data;
|
||||
|
||||
import java.util.SortedMap;
|
||||
|
||||
public interface RemoteMediaContent extends MediaContent {
|
||||
MediaDimension getLargestSize();
|
||||
|
||||
String getLargestUrl();
|
||||
|
||||
SortedMap<Integer, MediaDimension> getSizes();
|
||||
|
||||
String getSmallestUrl();
|
||||
|
||||
RemoteMediaStatus getStatus();
|
||||
|
||||
SortedMap<Integer, String> getUrls();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.strava.core.data;
|
||||
|
||||
public enum RemoteMediaStatus {
|
||||
NEW,
|
||||
PENDING,
|
||||
PROCESSED,
|
||||
REPORTED,
|
||||
REINSTATED,
|
||||
DELETED,
|
||||
FAILED
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
package com.strava.photos.data;
|
||||
|
||||
import com.strava.core.data.MediaDimension;
|
||||
import com.strava.core.data.MediaType;
|
||||
import com.strava.core.data.RemoteMediaContent;
|
||||
import com.strava.core.data.RemoteMediaStatus;
|
||||
import java.util.SortedMap;
|
||||
|
||||
public abstract class Media implements RemoteMediaContent {
|
||||
public static final class Photo extends Media {
|
||||
private final Long activityId;
|
||||
private final String activityName;
|
||||
private final long athleteId;
|
||||
private String caption;
|
||||
private final String createdAt;
|
||||
private final String createdAtLocal;
|
||||
private final String cursor;
|
||||
private final String id;
|
||||
private final SortedMap<Integer, MediaDimension> sizes;
|
||||
private final RemoteMediaStatus status;
|
||||
private final String tag;
|
||||
private final MediaType type;
|
||||
private final SortedMap<Integer, String> urls;
|
||||
|
||||
@Override
|
||||
public Long getActivityId() {
|
||||
return activityId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getActivityName() {
|
||||
return activityName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAthleteId() {
|
||||
return athleteId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCaption() {
|
||||
return caption;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCreatedAtLocal() {
|
||||
return createdAtLocal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCursor() {
|
||||
return cursor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<Integer, MediaDimension> getSizes() {
|
||||
return sizes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RemoteMediaStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MediaType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<Integer, String> getUrls() {
|
||||
return urls;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCaption(String caption) {
|
||||
this.caption = caption;
|
||||
}
|
||||
|
||||
public Photo(String id,
|
||||
String caption,
|
||||
SortedMap<Integer, String> urls,
|
||||
SortedMap<Integer, MediaDimension> sizes,
|
||||
long athleteId,
|
||||
String createdAt,
|
||||
String createdAtLocal,
|
||||
Long activityId,
|
||||
String activityName,
|
||||
RemoteMediaStatus status,
|
||||
String tag,
|
||||
String cursor) {
|
||||
this.id = id;
|
||||
this.caption = caption;
|
||||
this.urls = urls;
|
||||
this.sizes = sizes;
|
||||
this.athleteId = athleteId;
|
||||
this.createdAt = createdAt;
|
||||
this.createdAtLocal = createdAtLocal;
|
||||
this.activityId = activityId;
|
||||
this.activityName = activityName;
|
||||
this.status = status;
|
||||
this.tag = tag;
|
||||
this.cursor = cursor;
|
||||
this.type = MediaType.PHOTO;
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Video extends Media {
|
||||
private final Long activityId;
|
||||
private final String activityName;
|
||||
private final long athleteId;
|
||||
private String caption;
|
||||
private final String createdAt;
|
||||
private final String createdAtLocal;
|
||||
private final String cursor;
|
||||
private final Float durationSeconds;
|
||||
private final String id;
|
||||
private final SortedMap<Integer, MediaDimension> sizes;
|
||||
private final RemoteMediaStatus status;
|
||||
private final String tag;
|
||||
private final MediaType type;
|
||||
private final SortedMap<Integer, String> urls;
|
||||
private final String videoUrl;
|
||||
|
||||
@Override
|
||||
public Long getActivityId() {
|
||||
return activityId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getActivityName() {
|
||||
return activityName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAthleteId() {
|
||||
return athleteId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCaption() {
|
||||
return caption;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCreatedAtLocal() {
|
||||
return createdAtLocal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCursor() {
|
||||
return cursor;
|
||||
}
|
||||
|
||||
public final Float getDurationSeconds() {
|
||||
return durationSeconds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<Integer, MediaDimension> getSizes() {
|
||||
return sizes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RemoteMediaStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MediaType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<Integer, String> getUrls() {
|
||||
return urls;
|
||||
}
|
||||
|
||||
public final String getVideoUrl() {
|
||||
return videoUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCaption(String caption) {
|
||||
this.caption = caption;
|
||||
}
|
||||
|
||||
public Video(String id,
|
||||
String caption,
|
||||
SortedMap<Integer, String> urls,
|
||||
SortedMap<Integer, MediaDimension> sizes,
|
||||
long athleteId,
|
||||
String createdAt,
|
||||
String createdAtLocal,
|
||||
Long activityId,
|
||||
String activityName,
|
||||
RemoteMediaStatus status,
|
||||
String videoUrl,
|
||||
Float durationSeconds,
|
||||
String tag,
|
||||
String cursor) {
|
||||
this.id = id;
|
||||
this.caption = caption;
|
||||
this.urls = urls;
|
||||
this.sizes = sizes;
|
||||
this.athleteId = athleteId;
|
||||
this.createdAt = createdAt;
|
||||
this.createdAtLocal = createdAtLocal;
|
||||
this.activityId = activityId;
|
||||
this.activityName = activityName;
|
||||
this.status = status;
|
||||
this.videoUrl = videoUrl;
|
||||
this.durationSeconds = durationSeconds;
|
||||
this.tag = tag;
|
||||
this.cursor = cursor;
|
||||
this.type = MediaType.VIDEO;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract Long getActivityId();
|
||||
|
||||
public abstract String getActivityName();
|
||||
|
||||
public abstract long getAthleteId();
|
||||
|
||||
public abstract String getCreatedAt();
|
||||
|
||||
public abstract String getCreatedAtLocal();
|
||||
|
||||
public abstract String getCursor();
|
||||
|
||||
@Override
|
||||
public MediaDimension getLargestSize() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLargestUrl() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getReferenceId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSmallestUrl() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract String getTag();
|
||||
|
||||
private Media() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package app.revanced.extension.youtube.patches;
|
||||
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class PauseOnAudioInterruptPatch {
|
||||
|
||||
private static final int AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK = -3;
|
||||
private static final int AUDIOFOCUS_LOSS_TRANSIENT = -2;
|
||||
|
||||
/**
|
||||
* Injection point for AudioFocusRequest builder.
|
||||
* Returns true if audio ducking should be disabled (willPauseWhenDucked = true).
|
||||
*/
|
||||
public static boolean shouldPauseOnAudioInterrupt() {
|
||||
return Settings.PAUSE_ON_AUDIO_INTERRUPT.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Injection point for onAudioFocusChange callback.
|
||||
* Converts AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK to AUDIOFOCUS_LOSS_TRANSIENT
|
||||
* when the setting is enabled, causing YouTube to pause instead of ducking.
|
||||
*/
|
||||
public static int overrideAudioFocusChange(int focusChange) {
|
||||
if (Settings.PAUSE_ON_AUDIO_INTERRUPT.get() && focusChange == AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK) {
|
||||
return AUDIOFOCUS_LOSS_TRANSIENT;
|
||||
}
|
||||
return focusChange;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,9 @@ import java.util.List;
|
||||
import app.revanced.extension.shared.Logger;
|
||||
import app.revanced.extension.shared.Utils;
|
||||
import app.revanced.extension.shared.StringTrieSearch;
|
||||
import app.revanced.extension.shared.patches.litho.Filter;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.ByteArrayFilterGroup;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.StringFilterGroup;
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@@ -153,8 +156,8 @@ public final class AdsFilter extends Filter {
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
public boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
if (matchedGroup == playerShoppingShelf) {
|
||||
return contentIndex == 0 && playerShoppingShelfBuffer.check(buffer).isFiltered();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package app.revanced.extension.youtube.patches.components;
|
||||
|
||||
import app.revanced.extension.shared.patches.litho.Filter;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.StringFilterGroup;
|
||||
import app.revanced.extension.youtube.patches.playback.quality.AdvancedVideoQualityMenuPatch;
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
|
||||
@@ -19,7 +21,7 @@ public final class AdvancedVideoQualityMenuFilter extends Filter {
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
public boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
isVideoQualityMenuVisible = true;
|
||||
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package app.revanced.extension.youtube.patches.components;
|
||||
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroupList.ByteArrayFilterGroupList;
|
||||
import app.revanced.extension.shared.patches.litho.Filter;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.ByteArrayFilterGroup;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.StringFilterGroup;
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
final class ButtonsFilter extends Filter {
|
||||
public final class ButtonsFilter extends Filter {
|
||||
private static final String COMPACT_CHANNEL_BAR_PATH_PREFIX = "compact_channel_bar.e";
|
||||
private static final String VIDEO_ACTION_BAR_PATH_PREFIX = "video_action_bar.e";
|
||||
private static final String VIDEO_ACTION_BAR_PATH = "video_action_bar.e";
|
||||
@@ -118,7 +122,7 @@ final class ButtonsFilter extends Filter {
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
public boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
if (matchedGroup == likeSubscribeGlow) {
|
||||
return (path.startsWith(VIDEO_ACTION_BAR_PATH_PREFIX) || path.startsWith(COMPACT_CHANNEL_BAR_PATH_PREFIX))
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package app.revanced.extension.youtube.patches.components;
|
||||
|
||||
import app.revanced.extension.shared.patches.litho.Filter;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.*;
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
import app.revanced.extension.youtube.shared.PlayerType;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
final class CommentsFilter extends Filter {
|
||||
public final class CommentsFilter extends Filter {
|
||||
|
||||
private static final String COMMENT_COMPOSER_PATH = "comment_composer.e";
|
||||
|
||||
@@ -88,8 +90,8 @@ final class CommentsFilter extends Filter {
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
public boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
if (matchedGroup == chipBar) {
|
||||
// Playlist sort button uses same components and must only filter if the player is opened.
|
||||
return PlayerType.getCurrent().isMaximizedOrFullscreen()
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package app.revanced.extension.youtube.patches.components;
|
||||
|
||||
import app.revanced.extension.shared.StringTrieSearch;
|
||||
import app.revanced.extension.shared.patches.litho.Filter;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.*;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroupList.*;
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
import app.revanced.extension.youtube.shared.PlayerType;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
final class DescriptionComponentsFilter extends Filter {
|
||||
public final class DescriptionComponentsFilter extends Filter {
|
||||
|
||||
private static final String INFOCARDS_SECTION_PATH = "infocards_section.e";
|
||||
|
||||
@@ -128,8 +131,8 @@ final class DescriptionComponentsFilter extends Filter {
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
public boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
|
||||
if (matchedGroup == aiGeneratedVideoSummarySection || matchedGroup == hypePoints) {
|
||||
// Only hide if player is open, in case this component is used somewhere else.
|
||||
|
||||
@@ -1,214 +0,0 @@
|
||||
package app.revanced.extension.youtube.patches.components;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import app.revanced.extension.shared.Logger;
|
||||
import app.revanced.extension.shared.settings.BooleanSetting;
|
||||
import app.revanced.extension.shared.ByteTrieSearch;
|
||||
|
||||
abstract class FilterGroup<T> {
|
||||
final static class FilterGroupResult {
|
||||
private BooleanSetting setting;
|
||||
private int matchedIndex;
|
||||
private int matchedLength;
|
||||
// In the future it might be useful to include which pattern matched,
|
||||
// but for now that is not needed.
|
||||
|
||||
FilterGroupResult() {
|
||||
this(null, -1, 0);
|
||||
}
|
||||
|
||||
FilterGroupResult(BooleanSetting setting, int matchedIndex, int matchedLength) {
|
||||
setValues(setting, matchedIndex, matchedLength);
|
||||
}
|
||||
|
||||
public void setValues(BooleanSetting setting, int matchedIndex, int matchedLength) {
|
||||
this.setting = setting;
|
||||
this.matchedIndex = matchedIndex;
|
||||
this.matchedLength = matchedLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* A null value if the group has no setting,
|
||||
* or if no match is returned from {@link FilterGroupList#check(Object)}.
|
||||
*/
|
||||
public BooleanSetting getSetting() {
|
||||
return setting;
|
||||
}
|
||||
|
||||
public boolean isFiltered() {
|
||||
return matchedIndex >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Matched index of first pattern that matched, or -1 if nothing matched.
|
||||
*/
|
||||
public int getMatchedIndex() {
|
||||
return matchedIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Length of the matched filter pattern.
|
||||
*/
|
||||
public int getMatchedLength() {
|
||||
return matchedLength;
|
||||
}
|
||||
}
|
||||
|
||||
protected final BooleanSetting setting;
|
||||
protected final T[] filters;
|
||||
|
||||
/**
|
||||
* Initialize a new filter group.
|
||||
*
|
||||
* @param setting The associated setting.
|
||||
* @param filters The filters.
|
||||
*/
|
||||
@SafeVarargs
|
||||
public FilterGroup(final BooleanSetting setting, final T... filters) {
|
||||
this.setting = setting;
|
||||
this.filters = filters;
|
||||
if (filters.length == 0) {
|
||||
throw new IllegalArgumentException("Must use one or more filter patterns (zero specified)");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return setting == null || setting.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return If {@link FilterGroupList} should include this group when searching.
|
||||
* By default, all filters are included except non enabled settings that require reboot.
|
||||
*/
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
public boolean includeInSearch() {
|
||||
return isEnabled() || !setting.rebootApp;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + ": " + (setting == null ? "(null setting)" : setting);
|
||||
}
|
||||
|
||||
public abstract FilterGroupResult check(final T stack);
|
||||
}
|
||||
|
||||
class StringFilterGroup extends FilterGroup<String> {
|
||||
|
||||
public StringFilterGroup(final BooleanSetting setting, final String... filters) {
|
||||
super(setting, filters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FilterGroupResult check(final String string) {
|
||||
int matchedIndex = -1;
|
||||
int matchedLength = 0;
|
||||
if (isEnabled()) {
|
||||
for (String pattern : filters) {
|
||||
if (!string.isEmpty()) {
|
||||
final int indexOf = string.indexOf(pattern);
|
||||
if (indexOf >= 0) {
|
||||
matchedIndex = indexOf;
|
||||
matchedLength = pattern.length();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return new FilterGroupResult(setting, matchedIndex, matchedLength);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If you have more than 1 filter patterns, then all instances of
|
||||
* this class should filtered using {@link ByteArrayFilterGroupList#check(byte[])},
|
||||
* which uses a prefix tree to give better performance.
|
||||
*/
|
||||
class ByteArrayFilterGroup extends FilterGroup<byte[]> {
|
||||
|
||||
private volatile int[][] failurePatterns;
|
||||
|
||||
// Modified implementation from https://stackoverflow.com/a/1507813
|
||||
private static int indexOf(final byte[] data, final byte[] pattern, final int[] failure) {
|
||||
// Finds the first occurrence of the pattern in the byte array using
|
||||
// KMP matching algorithm.
|
||||
int patternLength = pattern.length;
|
||||
for (int i = 0, j = 0, dataLength = data.length; i < dataLength; i++) {
|
||||
while (j > 0 && pattern[j] != data[i]) {
|
||||
j = failure[j - 1];
|
||||
}
|
||||
if (pattern[j] == data[i]) {
|
||||
j++;
|
||||
}
|
||||
if (j == patternLength) {
|
||||
return i - patternLength + 1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static int[] createFailurePattern(byte[] pattern) {
|
||||
// Computes the failure function using a boot-strapping process,
|
||||
// where the pattern is matched against itself.
|
||||
final int patternLength = pattern.length;
|
||||
final int[] failure = new int[patternLength];
|
||||
|
||||
for (int i = 1, j = 0; i < patternLength; i++) {
|
||||
while (j > 0 && pattern[j] != pattern[i]) {
|
||||
j = failure[j - 1];
|
||||
}
|
||||
if (pattern[j] == pattern[i]) {
|
||||
j++;
|
||||
}
|
||||
failure[i] = j;
|
||||
}
|
||||
return failure;
|
||||
}
|
||||
|
||||
public ByteArrayFilterGroup(BooleanSetting setting, byte[]... filters) {
|
||||
super(setting, filters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the Strings into byte arrays. Used to search for text in binary data.
|
||||
*/
|
||||
public ByteArrayFilterGroup(BooleanSetting setting, String... filters) {
|
||||
super(setting, ByteTrieSearch.convertStringsToBytes(filters));
|
||||
}
|
||||
|
||||
private synchronized void buildFailurePatterns() {
|
||||
if (failurePatterns != null) return; // Thread race and another thread already initialized the search.
|
||||
Logger.printDebug(() -> "Building failure array for: " + this);
|
||||
int[][] failurePatterns = new int[filters.length][];
|
||||
int i = 0;
|
||||
for (byte[] pattern : filters) {
|
||||
failurePatterns[i++] = createFailurePattern(pattern);
|
||||
}
|
||||
this.failurePatterns = failurePatterns; // Must set after initialization finishes.
|
||||
}
|
||||
|
||||
@Override
|
||||
public FilterGroupResult check(final byte[] bytes) {
|
||||
int matchedLength = 0;
|
||||
int matchedIndex = -1;
|
||||
if (isEnabled()) {
|
||||
int[][] failures = failurePatterns;
|
||||
if (failures == null) {
|
||||
buildFailurePatterns(); // Lazy load.
|
||||
failures = failurePatterns;
|
||||
}
|
||||
for (int i = 0, length = filters.length; i < length; i++) {
|
||||
byte[] filter = filters[i];
|
||||
matchedIndex = indexOf(bytes, filter, failures[i]);
|
||||
if (matchedIndex >= 0) {
|
||||
matchedLength = filter.length;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new FilterGroupResult(setting, matchedIndex, matchedLength);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package app.revanced.extension.youtube.patches.components;
|
||||
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
import app.revanced.extension.shared.patches.litho.Filter;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class HideInfoCardsFilter extends Filter {
|
||||
|
||||
@@ -17,6 +17,8 @@ import app.revanced.extension.shared.Utils;
|
||||
import app.revanced.extension.shared.ByteTrieSearch;
|
||||
import app.revanced.extension.shared.StringTrieSearch;
|
||||
import app.revanced.extension.shared.TrieSearch;
|
||||
import app.revanced.extension.shared.patches.litho.Filter;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.*;
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
import app.revanced.extension.youtube.shared.NavigationBar;
|
||||
import app.revanced.extension.youtube.shared.PlayerType;
|
||||
@@ -41,7 +43,7 @@ import app.revanced.extension.youtube.shared.PlayerType;
|
||||
* - When using whole word syntax, some keywords may need additional pluralized variations.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
final class KeywordContentFilter extends Filter {
|
||||
public final class KeywordContentFilter extends Filter {
|
||||
|
||||
/**
|
||||
* Strings found in the buffer for every videos. Full strings should be specified.
|
||||
@@ -554,8 +556,8 @@ final class KeywordContentFilter extends Filter {
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
public boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
if (contentIndex != 0 && matchedGroup == startsWithFilter) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,9 @@ import androidx.annotation.Nullable;
|
||||
import app.revanced.extension.shared.Logger;
|
||||
import app.revanced.extension.shared.Utils;
|
||||
import app.revanced.extension.shared.StringTrieSearch;
|
||||
import app.revanced.extension.shared.patches.litho.Filter;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.*;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroupList.*;
|
||||
import app.revanced.extension.youtube.patches.ChangeHeaderPatch;
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
import app.revanced.extension.youtube.shared.NavigationBar;
|
||||
@@ -342,7 +345,7 @@ public final class LayoutComponentsFilter extends Filter {
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
public boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
// This identifier is used not only in players but also in search results:
|
||||
// https://github.com/ReVanced/revanced-patches/issues/3245
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package app.revanced.extension.youtube.patches.components;
|
||||
|
||||
import app.revanced.extension.shared.patches.litho.Filter;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.*;
|
||||
import app.revanced.extension.youtube.patches.playback.speed.CustomPlaybackSpeedPatch;
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
|
||||
@@ -36,7 +38,7 @@ public final class PlaybackSpeedMenuFilter extends Filter {
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
public boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
if (matchedGroup == oldPlaybackMenuGroup) {
|
||||
isOldPlaybackSpeedMenuVisible = true;
|
||||
|
||||
@@ -3,13 +3,16 @@ package app.revanced.extension.youtube.patches.components;
|
||||
import app.revanced.extension.shared.settings.BaseSettings;
|
||||
import app.revanced.extension.shared.settings.Setting;
|
||||
import app.revanced.extension.shared.spoof.SpoofVideoStreamsPatch;
|
||||
import app.revanced.extension.shared.patches.litho.Filter;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.*;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroupList.*;
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
import app.revanced.extension.youtube.shared.ShortsPlayerState;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class PlayerFlyoutMenuItemsFilter extends Filter {
|
||||
public final class PlayerFlyoutMenuItemsFilter extends Filter {
|
||||
|
||||
public static final class HideAudioFlyoutMenuAvailability implements Setting.Availability {
|
||||
@Override
|
||||
@@ -94,7 +97,7 @@ public class PlayerFlyoutMenuItemsFilter extends Filter {
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
public boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
if (matchedGroup == videoQualityMenuFooter) {
|
||||
return true;
|
||||
|
||||
@@ -13,6 +13,9 @@ import app.revanced.extension.youtube.patches.VideoInformation;
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
import app.revanced.extension.shared.Logger;
|
||||
import app.revanced.extension.shared.TrieSearch;
|
||||
import app.revanced.extension.shared.patches.litho.Filter;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.*;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroupList.*;
|
||||
|
||||
/**
|
||||
* Searches for video id's in the proto buffer of Shorts dislike.
|
||||
@@ -84,13 +87,13 @@ public final class ReturnYouTubeDislikeFilter extends Filter {
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
public boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
if (!Settings.RYD_ENABLED.get() || !Settings.RYD_SHORTS.get()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FilterGroup.FilterGroupResult result = videoIdFilterGroup.check(buffer);
|
||||
FilterGroupResult result = videoIdFilterGroup.check(buffer);
|
||||
if (result.isFiltered()) {
|
||||
String matchedVideoId = findVideoId(buffer);
|
||||
// Matched video will be null if in incognito mode.
|
||||
|
||||
@@ -11,6 +11,9 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import app.revanced.extension.shared.Logger;
|
||||
import app.revanced.extension.shared.patches.litho.Filter;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.*;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroupList.*;
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
import app.revanced.extension.youtube.shared.NavigationBar;
|
||||
import app.revanced.extension.youtube.shared.PlayerType;
|
||||
@@ -339,7 +342,7 @@ public final class ShortsFilter extends Filter {
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
public boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
if (contentType == FilterContentType.PATH) {
|
||||
if (matchedGroup == subscribeButton || matchedGroup == joinButton
|
||||
|
||||
@@ -32,6 +32,7 @@ import android.graphics.Color;
|
||||
|
||||
import app.revanced.extension.shared.Logger;
|
||||
import app.revanced.extension.shared.Utils;
|
||||
import app.revanced.extension.shared.settings.YouTubeAndMusicSettings;
|
||||
import app.revanced.extension.shared.settings.BaseSettings;
|
||||
import app.revanced.extension.shared.settings.BooleanSetting;
|
||||
import app.revanced.extension.shared.settings.EnumSetting;
|
||||
@@ -49,7 +50,7 @@ import app.revanced.extension.youtube.patches.MiniplayerPatch;
|
||||
import app.revanced.extension.youtube.sponsorblock.SponsorBlockSettings;
|
||||
import app.revanced.extension.youtube.swipecontrols.SwipeControlsConfigurationProvider.SwipeOverlayStyle;
|
||||
|
||||
public class Settings extends BaseSettings {
|
||||
public class Settings extends YouTubeAndMusicSettings {
|
||||
// Video
|
||||
public static final BooleanSetting ADVANCED_VIDEO_QUALITY_MENU = new BooleanSetting("revanced_advanced_video_quality_menu", TRUE);
|
||||
public static final BooleanSetting DISABLE_HDR_VIDEO = new BooleanSetting("revanced_disable_hdr_video", FALSE);
|
||||
@@ -274,11 +275,6 @@ public class Settings extends BaseSettings {
|
||||
public static final BooleanSetting CHANGE_START_PAGE_ALWAYS = new BooleanSetting("revanced_change_start_page_always", FALSE, true,
|
||||
new ChangeStartPageTypeAvailability());
|
||||
public static final StringSetting SPOOF_APP_VERSION_TARGET = new StringSetting("revanced_spoof_app_version_target", "19.01.34", true, parent(SPOOF_APP_VERSION));
|
||||
|
||||
// Custom filter
|
||||
public static final BooleanSetting CUSTOM_FILTER = new BooleanSetting("revanced_custom_filter", FALSE);
|
||||
public static final StringSetting CUSTOM_FILTER_STRINGS = new StringSetting("revanced_custom_filter_strings", "", true, parent(CUSTOM_FILTER));
|
||||
|
||||
// Navigation buttons
|
||||
public static final BooleanSetting HIDE_HOME_BUTTON = new BooleanSetting("revanced_hide_home_button", FALSE, true);
|
||||
public static final BooleanSetting HIDE_CREATE_BUTTON = new BooleanSetting("revanced_hide_create_button", TRUE, true);
|
||||
@@ -356,6 +352,7 @@ public class Settings extends BaseSettings {
|
||||
public static final IntegerSetting ANNOUNCEMENT_LAST_ID = new IntegerSetting("revanced_announcement_last_id", -1, false, false);
|
||||
public static final BooleanSetting LOOP_VIDEO = new BooleanSetting("revanced_loop_video", FALSE);
|
||||
public static final BooleanSetting LOOP_VIDEO_BUTTON = new BooleanSetting("revanced_loop_video_button", FALSE);
|
||||
public static final BooleanSetting PAUSE_ON_AUDIO_INTERRUPT = new BooleanSetting("revanced_pause_on_audio_interrupt", FALSE, true);
|
||||
public static final BooleanSetting BYPASS_URL_REDIRECTS = new BooleanSetting("revanced_bypass_url_redirects", TRUE);
|
||||
public static final BooleanSetting DISABLE_HAPTIC_FEEDBACK_CHAPTERS = new BooleanSetting("revanced_disable_haptic_feedback_chapters", FALSE);
|
||||
public static final BooleanSetting DISABLE_HAPTIC_FEEDBACK_PRECISE_SEEKING = new BooleanSetting("revanced_disable_haptic_feedback_precise_seeking", FALSE);
|
||||
@@ -367,8 +364,6 @@ public class Settings extends BaseSettings {
|
||||
public static final EnumSetting<ClientType> SPOOF_VIDEO_STREAMS_CLIENT_TYPE = new EnumSetting<>("revanced_spoof_video_streams_client_type", ClientType.ANDROID_VR_1_43_32, true, parent(SPOOF_VIDEO_STREAMS));
|
||||
public static final BooleanSetting SPOOF_VIDEO_STREAMS_AV1 = new BooleanSetting("revanced_spoof_video_streams_av1", FALSE, true,
|
||||
"revanced_spoof_video_streams_av1_user_dialog_message", new SpoofClientAv1Availability());
|
||||
public static final BooleanSetting DEBUG_PROTOBUFFER = new BooleanSetting("revanced_debug_protobuffer", FALSE, false,
|
||||
"revanced_debug_protobuffer_user_dialog_message", parent(BaseSettings.DEBUG));
|
||||
|
||||
// Swipe controls
|
||||
public static final BooleanSetting SWIPE_CHANGE_VIDEO = new BooleanSetting("revanced_swipe_change_video", FALSE, true);
|
||||
@@ -381,7 +376,7 @@ public class Settings extends BaseSettings {
|
||||
public static final IntegerSetting SWIPE_MAGNITUDE_THRESHOLD = new IntegerSetting("revanced_swipe_threshold", 30, true,
|
||||
parentsAny(SWIPE_BRIGHTNESS, SWIPE_VOLUME));
|
||||
public static final IntegerSetting SWIPE_VOLUME_SENSITIVITY = new IntegerSetting("revanced_swipe_volume_sensitivity", 1, true, parent(SWIPE_VOLUME));
|
||||
public static final EnumSetting<SwipeOverlayStyle> SWIPE_OVERLAY_STYLE = new EnumSetting<>("revanced_swipe_overlay_style", SwipeOverlayStyle.HORIZONTAL,true,
|
||||
public static final EnumSetting<SwipeOverlayStyle> SWIPE_OVERLAY_STYLE = new EnumSetting<>("revanced_swipe_overlay_style", SwipeOverlayStyle.HORIZONTAL, true,
|
||||
parentsAny(SWIPE_BRIGHTNESS, SWIPE_VOLUME));
|
||||
public static final IntegerSetting SWIPE_OVERLAY_TEXT_SIZE = new IntegerSetting("revanced_swipe_text_overlay_size", 14, true,
|
||||
parentsAny(SWIPE_BRIGHTNESS, SWIPE_VOLUME));
|
||||
@@ -410,7 +405,9 @@ public class Settings extends BaseSettings {
|
||||
|
||||
// SponsorBlock
|
||||
public static final BooleanSetting SB_ENABLED = new BooleanSetting("sb_enabled", TRUE);
|
||||
/** Do not use id setting directly. Instead use {@link SponsorBlockSettings}. */
|
||||
/**
|
||||
* Do not use id setting directly. Instead use {@link SponsorBlockSettings}.
|
||||
*/
|
||||
public static final StringSetting SB_PRIVATE_USER_ID = new StringSetting("sb_private_user_id_Do_Not_Share", "", parent(SB_ENABLED));
|
||||
public static final IntegerSetting SB_CREATE_NEW_SEGMENT_STEP = new IntegerSetting("sb_create_new_segment_step", 150, parent(SB_ENABLED));
|
||||
public static final BooleanSetting SB_VOTING_BUTTON = new BooleanSetting("sb_voting_button", FALSE, parent(SB_ENABLED));
|
||||
@@ -459,7 +456,7 @@ public class Settings extends BaseSettings {
|
||||
public static final StringSetting SB_CATEGORY_UNSUBMITTED_COLOR = new StringSetting("sb_unsubmitted_color", "#FFFFFFFF", false, false);
|
||||
|
||||
// Deprecated migrations
|
||||
private static final StringSetting DEPRECATED_SEEKBAR_CUSTOM_COLOR_PRIMARY = new StringSetting("revanced_seekbar_custom_color_value", "#FF0033");
|
||||
private static final StringSetting DEPRECATED_SEEKBAR_CUSTOM_COLOR_PRIMARY = new StringSetting("revanced_seekbar_custom_color_value", "#FF0033");
|
||||
|
||||
private static final FloatSetting DEPRECATED_SB_CATEGORY_SPONSOR_OPACITY = new FloatSetting("sb_sponsor_opacity", 0.8f, false, false);
|
||||
private static final FloatSetting DEPRECATED_SB_CATEGORY_SELF_PROMO_OPACITY = new FloatSetting("sb_selfpromo_opacity", 0.8f, false, false);
|
||||
@@ -511,7 +508,7 @@ public class Settings extends BaseSettings {
|
||||
// or is spoofing to a version the same or newer than this app.
|
||||
if (!SPOOF_APP_VERSION_TARGET.isSetToDefault() &&
|
||||
(SPOOF_APP_VERSION_TARGET.get().compareTo(SPOOF_APP_VERSION_TARGET.defaultValue) < 0
|
||||
|| (Utils.getAppVersionName().compareTo(SPOOF_APP_VERSION_TARGET.get()) <= 0))) {
|
||||
|| (Utils.getAppVersionName().compareTo(SPOOF_APP_VERSION_TARGET.get()) <= 0))) {
|
||||
Logger.printInfo(() -> "Resetting spoof app version");
|
||||
SPOOF_APP_VERSION_TARGET.resetToDefault();
|
||||
SPOOF_APP_VERSION.resetToDefault();
|
||||
|
||||
@@ -3,4 +3,4 @@ org.gradle.jvmargs = -Xms512M -Xmx2048M
|
||||
org.gradle.parallel = true
|
||||
android.useAndroidX = true
|
||||
kotlin.code.style = official
|
||||
version = 5.48.0-dev.9
|
||||
version = 5.50.0-dev.1
|
||||
|
||||
@@ -124,6 +124,10 @@ public final class app/revanced/patches/all/misc/screencapture/RemoveScreenCaptu
|
||||
public static final fun getRemoveScreenCaptureRestrictionPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/all/misc/screenshot/PreventScreenshotDetectionPatchKt {
|
||||
public static final fun getPreventScreenshotDetectionPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/all/misc/screenshot/RemoveScreenshotRestrictionPatchKt {
|
||||
public static final fun getRemoveScreenshotRestrictionPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
@@ -308,6 +312,10 @@ public final class app/revanced/patches/instagram/hide/explore/HideExploreFeedKt
|
||||
public static final fun getHideExploreFeedPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/instagram/hide/highlightsTray/HideHighlightsTrayPatchKt {
|
||||
public static final fun getHideHighlightsTrayPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/instagram/hide/navigation/HideNavigationButtonsKt {
|
||||
public static final fun getHideNavigationButtonsPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
@@ -332,6 +340,10 @@ public final class app/revanced/patches/instagram/misc/links/OpenLinksExternally
|
||||
public static final fun getOpenLinksExternallyPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/instagram/misc/removeBuildExpiredPopup/RemoveBuildExpiredPopupPatchKt {
|
||||
public static final fun getRemoveBuildExpiredPopupPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/instagram/misc/share/domain/ChangeLinkSharingDomainPatchKt {
|
||||
public static final fun getChangeLinkSharingDomainPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
@@ -460,6 +472,10 @@ public final class app/revanced/patches/music/layout/compactheader/HideCategoryB
|
||||
public static final fun getHideCategoryBar ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/music/layout/hide/general/HideLayoutComponentsPatchKt {
|
||||
public static final fun getHideLayoutComponentsPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/music/layout/miniplayercolor/ChangeMiniplayerColorKt {
|
||||
public static final fun getChangeMiniplayerColor ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
@@ -485,6 +501,10 @@ public final class app/revanced/patches/music/misc/androidauto/BypassCertificate
|
||||
public static final fun getBypassCertificateChecksPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/music/misc/androidauto/UnlockAndroidAutoMediaBrowserPatchKt {
|
||||
public static final fun getUnlockAndroidAutoMediaBrowserPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/music/misc/backgroundplayback/BackgroundPlaybackPatchKt {
|
||||
public static final fun getBackgroundPlaybackPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
@@ -509,6 +529,10 @@ public final class app/revanced/patches/music/misc/gms/GmsCoreSupportPatchKt {
|
||||
public static final fun getGmsCoreSupportPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/music/misc/litho/filter/LithoFilterPatchKt {
|
||||
public static final fun getLithoFilterPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/music/misc/privacy/SanitizeSharingLinksPatchKt {
|
||||
public static final fun getSanitizeSharingLinksPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
@@ -565,6 +589,14 @@ public final class app/revanced/patches/nfctoolsse/misc/pro/UnlockProPatchKt {
|
||||
public static final fun getUnlockProPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/nothingx/misc/extension/SharedExtensionPatchKt {
|
||||
public static final fun getSharedExtensionPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/nothingx/misc/logk1token/ShowK1TokenPatchsKt {
|
||||
public static final fun getShowK1TokensPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/nunl/ads/HideAdsPatchKt {
|
||||
public static final fun getHideAdsPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
@@ -920,6 +952,10 @@ public final class app/revanced/patches/shared/misc/hex/Replacement {
|
||||
public final fun getReplacementBytesPadded ()[B
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/shared/misc/litho/filter/LithoFilterPatchKt {
|
||||
public static final fun getAddLithoFilter ()Lkotlin/jvm/functions/Function1;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/shared/misc/mapping/ResourceElement {
|
||||
public final fun component1 ()Ljava/lang/String;
|
||||
public final fun component2 ()Ljava/lang/String;
|
||||
@@ -1200,10 +1236,22 @@ public final class app/revanced/patches/stocard/layout/HideStoryBubblesPatchKt {
|
||||
public static final fun getHideStoryBubblesPatch ()Lapp/revanced/patcher/patch/ResourcePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/strava/mediaupload/OverwriteMediaUploadParametersPatchKt {
|
||||
public final class app/revanced/patches/strava/groupkudos/AddGiveGroupKudosButtonToGroupActivityKt {
|
||||
public static final fun getAddGiveGroupKudosButtonToGroupActivity ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/strava/media/download/AddMediaDownloadPatchKt {
|
||||
public static final fun getAddMediaDownloadPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/strava/media/upload/OverwriteMediaUploadParametersPatchKt {
|
||||
public static final fun getOverwriteMediaUploadParametersPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/strava/misc/extension/SharedExtensionPatchKt {
|
||||
public static final fun getSharedExtensionPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/strava/password/EnablePasswordLoginPatchKt {
|
||||
public static final fun getEnablePasswordLoginPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
@@ -1696,6 +1744,10 @@ public final class app/revanced/patches/youtube/misc/announcements/Announcements
|
||||
public static final fun getAnnouncementsPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/youtube/misc/audiofocus/PauseOnAudioInterruptPatchKt {
|
||||
public static final fun getPauseOnAudioInterruptPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatchKt {
|
||||
public static final fun getAutoRepeatPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
import org.w3c.dom.*
|
||||
import javax.xml.parsers.DocumentBuilderFactory
|
||||
import javax.xml.transform.OutputKeys
|
||||
import javax.xml.transform.TransformerFactory
|
||||
import javax.xml.transform.dom.DOMSource
|
||||
import javax.xml.transform.stream.StreamResult
|
||||
|
||||
group = "app.revanced"
|
||||
|
||||
patches {
|
||||
@@ -22,25 +29,6 @@ dependencies {
|
||||
compileOnly(project(":patches:stub"))
|
||||
}
|
||||
|
||||
tasks {
|
||||
register<JavaExec>("preprocessCrowdinStrings") {
|
||||
description = "Preprocess strings for Crowdin push"
|
||||
|
||||
dependsOn(compileKotlin)
|
||||
|
||||
classpath = sourceSets["main"].runtimeClasspath
|
||||
mainClass.set("app.revanced.util.CrowdinPreprocessorKt")
|
||||
|
||||
args = listOf(
|
||||
"src/main/resources/addresources/values/strings.xml",
|
||||
// Ideally this would use build/tmp/crowdin/strings.xml
|
||||
// But using that does not work with Crowdin pull because
|
||||
// it does not recognize the strings.xml file belongs to this project.
|
||||
"src/main/resources/addresources/values/strings.xml"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
compilerOptions {
|
||||
freeCompilerArgs = listOf("-Xcontext-receivers")
|
||||
@@ -50,12 +38,96 @@ kotlin {
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
name = "GitHubPackages"
|
||||
name = "githubPackages"
|
||||
url = uri("https://maven.pkg.github.com/revanced/revanced-patches")
|
||||
credentials {
|
||||
username = System.getenv("GITHUB_ACTOR")
|
||||
password = System.getenv("GITHUB_TOKEN")
|
||||
}
|
||||
credentials(PasswordCredentials::class)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("processStringsForCrowdin") {
|
||||
description = "Process strings file for Crowdin by commenting out non-standard tags."
|
||||
|
||||
doLast {
|
||||
// Comment out the non-standard tags. Otherwise, Crowdin interprets the file
|
||||
// not as Android but instead a generic xml file where strings are
|
||||
// identified by xml position and not key
|
||||
val stringsXmlFile = project.projectDir.resolve("src/main/resources/addresources/values/strings.xml")
|
||||
|
||||
val builder = DocumentBuilderFactory.newInstance().apply {
|
||||
isIgnoringComments = false
|
||||
isCoalescing = false
|
||||
isNamespaceAware = false
|
||||
}.newDocumentBuilder()
|
||||
|
||||
val document = builder.newDocument()
|
||||
val root = document.createElement("resources").also(document::appendChild)
|
||||
|
||||
fun walk(node: Node, appId: String? = null, patchId: String? = null, insideResources: Boolean = false) {
|
||||
fun walkChildren(el: Element, appId: String?, patchId: String?, insideResources: Boolean) {
|
||||
val children = el.childNodes
|
||||
for (i in 0 until children.length) {
|
||||
walk(children.item(i), appId, patchId, insideResources)
|
||||
}
|
||||
}
|
||||
when (node.nodeType) {
|
||||
Node.COMMENT_NODE -> {
|
||||
val comment = document.createComment(node.nodeValue)
|
||||
if (insideResources) root.appendChild(comment) else document.insertBefore(comment, root)
|
||||
}
|
||||
|
||||
Node.ELEMENT_NODE -> {
|
||||
val element = node as Element
|
||||
|
||||
when (element.tagName) {
|
||||
"resources" -> walkChildren(element, appId, patchId, insideResources = true)
|
||||
|
||||
"app" -> {
|
||||
val newAppId = element.getAttribute("id")
|
||||
|
||||
root.appendChild(document.createComment(" <app id=\"$newAppId\"> "))
|
||||
walkChildren(element, newAppId, patchId, insideResources)
|
||||
root.appendChild(document.createComment(" </app> "))
|
||||
}
|
||||
|
||||
"patch" -> {
|
||||
val newPatchId = element.getAttribute("id")
|
||||
|
||||
root.appendChild(document.createComment(" <patch id=\"$newPatchId\"> "))
|
||||
walkChildren(element, appId, newPatchId, insideResources)
|
||||
root.appendChild(document.createComment(" </patch> "))
|
||||
}
|
||||
|
||||
"string" -> {
|
||||
val name = element.getAttribute("name")
|
||||
val value = element.textContent
|
||||
val fullName = "$appId.$patchId.$name"
|
||||
|
||||
val stringElement = document.createElement("string")
|
||||
stringElement.setAttribute("name", fullName)
|
||||
stringElement.appendChild(document.createTextNode(value))
|
||||
root.appendChild(stringElement)
|
||||
}
|
||||
|
||||
else -> walkChildren(element, appId, patchId, insideResources)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
builder.parse(stringsXmlFile).let {
|
||||
val topLevel = it.childNodes
|
||||
for (i in 0 until topLevel.length) {
|
||||
val node = topLevel.item(i)
|
||||
if (node != it.documentElement) walk(node)
|
||||
}
|
||||
|
||||
walk(it.documentElement)
|
||||
}
|
||||
|
||||
TransformerFactory.newInstance().newTransformer().apply {
|
||||
setOutputProperty(OutputKeys.INDENT, "yes")
|
||||
setOutputProperty(OutputKeys.ENCODING, "utf-8")
|
||||
}.transform(DOMSource(document), StreamResult(stringsXmlFile))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package app.revanced.patches.all.misc.screenshot
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patches.all.misc.transformation.transformInstructionsPatch
|
||||
import app.revanced.util.getReference
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
import com.android.tools.smali.dexlib2.immutable.reference.ImmutableMethodReference
|
||||
import com.android.tools.smali.dexlib2.util.MethodUtil
|
||||
|
||||
private val registerScreenCaptureCallbackMethodReference = ImmutableMethodReference(
|
||||
"Landroid/app/Activity;",
|
||||
"registerScreenCaptureCallback",
|
||||
listOf(
|
||||
"Ljava/util/concurrent/Executor;",
|
||||
"Landroid/app/Activity\$ScreenCaptureCallback;",
|
||||
),
|
||||
"V"
|
||||
)
|
||||
|
||||
private val unregisterScreenCaptureCallbackMethodReference = ImmutableMethodReference(
|
||||
"Landroid/app/Activity;",
|
||||
"unregisterScreenCaptureCallback",
|
||||
listOf(
|
||||
"Landroid/app/Activity\$ScreenCaptureCallback;",
|
||||
),
|
||||
"V"
|
||||
)
|
||||
|
||||
@Suppress("unused")
|
||||
val preventScreenshotDetectionPatch = bytecodePatch(
|
||||
name = "Prevent screenshot detection",
|
||||
description = "Removes the registration of all screen capture callbacks. This prevents the app from detecting screenshots.",
|
||||
use = false
|
||||
) {
|
||||
dependsOn(transformInstructionsPatch(
|
||||
filterMap = { _, _, instruction, instructionIndex ->
|
||||
if (instruction.opcode != Opcode.INVOKE_VIRTUAL) return@transformInstructionsPatch null
|
||||
|
||||
val reference = instruction.getReference<MethodReference>() ?: return@transformInstructionsPatch null
|
||||
|
||||
instructionIndex.takeIf {
|
||||
MethodUtil.methodSignaturesMatch(reference, registerScreenCaptureCallbackMethodReference) ||
|
||||
MethodUtil.methodSignaturesMatch(reference, unregisterScreenCaptureCallbackMethodReference)
|
||||
}
|
||||
},
|
||||
transform = { mutableMethod, instructionIndex ->
|
||||
mutableMethod.removeInstruction(instructionIndex)
|
||||
}
|
||||
))
|
||||
}
|
||||
@@ -1,29 +1,7 @@
|
||||
package app.revanced.patches.instagram.hide.explore
|
||||
|
||||
import app.revanced.patcher.Fingerprint
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatchContext
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
context(BytecodePatchContext)
|
||||
internal fun Fingerprint.replaceJsonFieldWithBogus(
|
||||
key: String,
|
||||
) {
|
||||
val targetStringIndex = stringMatches!!.first { match -> match.string == key }.index
|
||||
val targetStringRegister = method.getInstruction<OneRegisterInstruction>(targetStringIndex).registerA
|
||||
|
||||
/**
|
||||
* Replacing the JSON key we want to skip with a random string that is not a valid JSON key.
|
||||
* This way the feeds array will never be populated.
|
||||
* Received JSON keys that are not handled are simply ignored, so there are no side effects.
|
||||
*/
|
||||
method.replaceInstruction(
|
||||
targetStringIndex,
|
||||
"const-string v$targetStringRegister, \"BOGUS\"",
|
||||
)
|
||||
}
|
||||
import app.revanced.patches.instagram.shared.replaceStringWithBogus
|
||||
|
||||
@Suppress("unused")
|
||||
val hideExploreFeedPatch = bytecodePatch(
|
||||
@@ -34,6 +12,6 @@ val hideExploreFeedPatch = bytecodePatch(
|
||||
compatibleWith("com.instagram.android")
|
||||
|
||||
execute {
|
||||
exploreResponseJsonParserFingerprint.replaceJsonFieldWithBogus(EXPLORE_KEY_TO_BE_HIDDEN)
|
||||
exploreResponseJsonParserFingerprint.replaceStringWithBogus(EXPLORE_KEY_TO_BE_HIDDEN)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package app.revanced.patches.instagram.hide.highlightsTray
|
||||
|
||||
import app.revanced.patcher.fingerprint
|
||||
|
||||
internal const val TARGET_STRING = "highlights_tray"
|
||||
|
||||
internal val highlightsUrlBuilderFingerprint = fingerprint {
|
||||
strings(TARGET_STRING,"X-IG-Accept-Hint")
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package app.revanced.patches.instagram.hide.highlightsTray
|
||||
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patches.instagram.shared.replaceStringWithBogus
|
||||
|
||||
@Suppress("unused")
|
||||
val hideHighlightsTrayPatch = bytecodePatch(
|
||||
name = "Hide highlights tray",
|
||||
description = "Hides the highlights tray in profile section.",
|
||||
use = false
|
||||
) {
|
||||
compatibleWith("com.instagram.android")
|
||||
|
||||
execute {
|
||||
highlightsUrlBuilderFingerprint.replaceStringWithBogus(TARGET_STRING)
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package app.revanced.patches.instagram.hide.suggestions
|
||||
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patches.instagram.hide.explore.replaceJsonFieldWithBogus
|
||||
import app.revanced.patches.instagram.shared.replaceStringWithBogus
|
||||
|
||||
@Suppress("unused")
|
||||
val hideSuggestedContent = bytecodePatch(
|
||||
@@ -13,7 +13,7 @@ val hideSuggestedContent = bytecodePatch(
|
||||
|
||||
execute {
|
||||
FEED_ITEM_KEYS_TO_BE_HIDDEN.forEach { key ->
|
||||
feedItemParseFromJsonFingerprint.replaceJsonFieldWithBogus(key)
|
||||
feedItemParseFromJsonFingerprint.replaceStringWithBogus(key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
package app.revanced.patches.instagram.misc.removeBuildExpiredPopup
|
||||
|
||||
import app.revanced.patcher.fingerprint
|
||||
import app.revanced.util.literal
|
||||
|
||||
internal const val MILLISECOND_IN_A_DAY_LITERAL = 0x5265c00L
|
||||
|
||||
internal val appUpdateLockoutBuilderFingerprint = fingerprint {
|
||||
strings("android.hardware.sensor.hinge_angle")
|
||||
literal { MILLISECOND_IN_A_DAY_LITERAL }
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package app.revanced.patches.instagram.misc.removeBuildExpiredPopup
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.instructions
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
|
||||
@Suppress("unused")
|
||||
val removeBuildExpiredPopupPatch = bytecodePatch(
|
||||
name = "Remove build expired popup",
|
||||
description = "Removes the popup that appears after a while, when the app version ages.",
|
||||
) {
|
||||
compatibleWith("com.instagram.android")
|
||||
|
||||
execute {
|
||||
appUpdateLockoutBuilderFingerprint.method.apply {
|
||||
val longToIntIndex = instructions.first { it.opcode == Opcode.LONG_TO_INT }.location.index
|
||||
val appAgeRegister = getInstruction<TwoRegisterInstruction>(longToIntIndex).registerA
|
||||
|
||||
// Set app age to 0 days old such that the build expired popup doesn't appear.
|
||||
addInstruction(longToIntIndex + 1, "const v$appAgeRegister, 0x0")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ internal val storyUrlResponseJsonParserFingerprint = fingerprint {
|
||||
}
|
||||
|
||||
internal val profileUrlResponseJsonParserFingerprint = fingerprint {
|
||||
strings("profile_to_share_url", "ProfileUrlResponse")
|
||||
strings("profile_to_share_url")
|
||||
custom { method, _ -> method.name == "parseFromJson" }
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ val disableReelsScrollingPatch = bytecodePatch(
|
||||
name = "Disable Reels scrolling",
|
||||
description = "Disables the endless scrolling behavior in Instagram Reels, preventing swiping to the next Reel. " +
|
||||
"Note: On a clean install, the 'Tip' animation may appear but will stop on its own after a few seconds.",
|
||||
use = true
|
||||
use = false
|
||||
) {
|
||||
compatibleWith("com.instagram.android")
|
||||
|
||||
@@ -31,4 +31,4 @@ val disableReelsScrollingPatch = bytecodePatch(
|
||||
// Return false in onInterceptTouchEvent to disable pull-to-refresh.
|
||||
clipsSwipeRefreshLayoutOnInterceptTouchEventFingerprint.method.returnEarly(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package app.revanced.patches.instagram.shared
|
||||
|
||||
import app.revanced.patcher.Fingerprint
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatchContext
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
context(BytecodePatchContext)
|
||||
internal fun Fingerprint.replaceStringWithBogus(
|
||||
targetString: String,
|
||||
) {
|
||||
val targetStringIndex = stringMatches!!.first { match -> match.string == targetString }.index
|
||||
val targetStringRegister = method.getInstruction<OneRegisterInstruction>(targetStringIndex).registerA
|
||||
|
||||
/**
|
||||
* Replaces the 'target string' with 'BOGUS'.
|
||||
* This is usually done when we need to override a JSON key or url,
|
||||
* to skip with a random string that is not a valid JSON key.
|
||||
*/
|
||||
method.replaceInstruction(
|
||||
targetStringIndex,
|
||||
"const-string v$targetStringRegister, \"BOGUS\"",
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package app.revanced.patches.music.layout.hide.general
|
||||
|
||||
import app.revanced.patches.music.misc.litho.filter.lithoFilterPatch
|
||||
import app.revanced.patches.music.misc.settings.settingsPatch
|
||||
import app.revanced.patches.shared.layout.hide.general.hideLayoutComponentsPatch
|
||||
|
||||
val hideLayoutComponentsPatch = hideLayoutComponentsPatch(
|
||||
lithoFilterPatch = lithoFilterPatch,
|
||||
settingsPatch = settingsPatch,
|
||||
filterClasses = setOf("Lapp/revanced/extension/shared/patches/components/CustomFilter;"),
|
||||
compatibleWithPackages = arrayOf("com.google.android.apps.youtube.music" to setOf("7.29.52", "8.10.52"))
|
||||
)
|
||||
@@ -5,24 +5,11 @@ import app.revanced.patches.music.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.music.misc.settings.settingsPatch
|
||||
import app.revanced.util.returnEarly
|
||||
|
||||
@Deprecated("This patch is useless by itself and has been merged into another patch.", ReplaceWith("unlockAndroidAutoMediaBrowserPatch"))
|
||||
|
||||
@Suppress("unused")
|
||||
val bypassCertificateChecksPatch = bytecodePatch(
|
||||
name = "Bypass certificate checks",
|
||||
description = "Bypasses certificate checks which prevent YouTube Music from working on Android Auto.",
|
||||
) {
|
||||
dependsOn(
|
||||
sharedExtensionPatch,
|
||||
settingsPatch
|
||||
)
|
||||
|
||||
compatibleWith(
|
||||
"com.google.android.apps.youtube.music"(
|
||||
"7.29.52",
|
||||
"8.10.52"
|
||||
)
|
||||
)
|
||||
|
||||
execute {
|
||||
checkCertificateFingerprint.method.returnEarly(true)
|
||||
}
|
||||
dependsOn(unlockAndroidAutoMediaBrowserPatch)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package app.revanced.patches.music.misc.androidauto
|
||||
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import app.revanced.patcher.fingerprint
|
||||
|
||||
internal val checkCertificateFingerprint = fingerprint {
|
||||
@@ -10,4 +9,13 @@ internal val checkCertificateFingerprint = fingerprint {
|
||||
"X509",
|
||||
"Failed to get certificate" // Partial String match.
|
||||
)
|
||||
}
|
||||
|
||||
internal val searchMediaItemsConstructorFingerprint = fingerprint {
|
||||
returns("V")
|
||||
strings("ytm_media_browser/search_media_items")
|
||||
}
|
||||
|
||||
internal val searchMediaItemsExecuteFingerprint = fingerprint {
|
||||
parameters()
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package app.revanced.patches.music.misc.androidauto
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.instructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.registersUsed
|
||||
import app.revanced.util.returnEarly
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
||||
|
||||
@Suppress("unused")
|
||||
val unlockAndroidAutoMediaBrowserPatch = bytecodePatch(
|
||||
name = "Unlock Android Auto Media Browser",
|
||||
description = "Unlocks Android Auto Media Browser which enables the search function including speech to text.",
|
||||
) {
|
||||
compatibleWith(
|
||||
"com.google.android.apps.youtube.music"(
|
||||
"7.29.52",
|
||||
"8.10.52"
|
||||
)
|
||||
)
|
||||
|
||||
execute {
|
||||
checkCertificateFingerprint.method.returnEarly(true)
|
||||
|
||||
searchMediaItemsExecuteFingerprint
|
||||
.match(searchMediaItemsConstructorFingerprint.classDef)
|
||||
.method.apply {
|
||||
val targetIndex = instructions.indexOfFirst {
|
||||
it.opcode == Opcode.IGET_OBJECT && it.getReference<FieldReference>()?.type == "Ljava/lang/String;"
|
||||
}
|
||||
|
||||
val register = instructions[targetIndex].registersUsed.first()
|
||||
replaceInstruction(targetIndex, "const-string v$register, \"com.google.android.apps.youtube.music\"")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,20 +7,15 @@ import app.revanced.patches.shared.misc.debugging.enableDebuggingPatch
|
||||
|
||||
@Suppress("unused")
|
||||
val enableDebuggingPatch = enableDebuggingPatch(
|
||||
block = {
|
||||
dependsOn(
|
||||
sharedExtensionPatch,
|
||||
settingsPatch,
|
||||
sharedExtensionPatch = sharedExtensionPatch,
|
||||
settingsPatch = settingsPatch,
|
||||
compatibleWithPackages = arrayOf(
|
||||
"com.google.android.apps.youtube.music" to setOf(
|
||||
"7.29.52",
|
||||
"8.10.52"
|
||||
)
|
||||
|
||||
compatibleWith(
|
||||
"com.google.android.apps.youtube.music"(
|
||||
"7.29.52",
|
||||
"8.10.52"
|
||||
)
|
||||
)
|
||||
},
|
||||
),
|
||||
// String feature flag does not appear to be present with YT Music.
|
||||
hookStringFeatureFlag = false,
|
||||
preferenceScreen = PreferenceScreen.MISC
|
||||
preferenceScreen = PreferenceScreen.MISC,
|
||||
)
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package app.revanced.patches.music.misc.litho.filter
|
||||
|
||||
import app.revanced.patches.music.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.music.shared.conversionContextFingerprintToString
|
||||
import app.revanced.patches.shared.misc.litho.filter.lithoFilterPatch
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
val lithoFilterPatch = lithoFilterPatch(
|
||||
componentCreateInsertionIndex = {
|
||||
// No supported version clobbers p2 so we can just do our things before the return instruction.
|
||||
indexOfFirstInstructionOrThrow(Opcode.RETURN_OBJECT)
|
||||
},
|
||||
conversionContextFingerprintToString = conversionContextFingerprintToString,
|
||||
) {
|
||||
dependsOn(sharedExtensionPatch)
|
||||
}
|
||||
@@ -11,3 +11,19 @@ internal val mainActivityOnCreateFingerprint = fingerprint {
|
||||
method.name == "onCreate" && classDef.type == YOUTUBE_MUSIC_MAIN_ACTIVITY_CLASS_TYPE
|
||||
}
|
||||
}
|
||||
|
||||
internal val conversionContextFingerprintToString = fingerprint {
|
||||
parameters()
|
||||
strings(
|
||||
"ConversionContext{containerInternal=",
|
||||
", gridColumnCount=",
|
||||
", gridColumnIndex=",
|
||||
", templateLoggerFactory=",
|
||||
", rootDisposableContainer=",
|
||||
", elementId=",
|
||||
", identifierProperty="
|
||||
)
|
||||
custom { method, _ ->
|
||||
method.name == "toString"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package app.revanced.patches.nothingx.misc.extension
|
||||
|
||||
import app.revanced.patches.shared.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.shared.misc.extension.extensionHook
|
||||
|
||||
val sharedExtensionPatch = sharedExtensionPatch(
|
||||
extensionName = "nothingx",
|
||||
extensionHook {
|
||||
custom { method, classDef ->
|
||||
method.name == "onCreate" && classDef.contains("BaseApplication")
|
||||
}
|
||||
},
|
||||
)
|
||||
@@ -0,0 +1,16 @@
|
||||
package app.revanced.patches.nothingx.misc.logk1token
|
||||
|
||||
import app.revanced.patcher.fingerprint
|
||||
|
||||
/**
|
||||
* Fingerprint for the Application onCreate method.
|
||||
* This is used to trigger scanning for existing log files on app startup.
|
||||
*/
|
||||
internal val applicationOnCreateFingerprint = fingerprint {
|
||||
returns("V")
|
||||
parameters()
|
||||
custom { method, classDef ->
|
||||
// Match BaseApplication onCreate specifically
|
||||
method.name == "onCreate" && classDef.endsWith("BaseApplication;")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package app.revanced.patches.nothingx.misc.logk1token
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patches.nothingx.misc.extension.sharedExtensionPatch
|
||||
|
||||
private const val EXTENSION_CLASS_DESCRIPTOR =
|
||||
"Lapp/revanced/extension/nothingx/patches/ShowK1TokensPatch;"
|
||||
|
||||
@Suppress("unused")
|
||||
val showK1TokensPatch = bytecodePatch(
|
||||
name = "Show K1 token(s)",
|
||||
description = "Shows the K1 authentication token(s) in a dialog and logs it to logcat " +
|
||||
"for pairing with GadgetBridge without requiring root access. " +
|
||||
"After installing this patch, pair your watch with the Nothing X app and " +
|
||||
"use the token from the dialog or logcat.",
|
||||
) {
|
||||
dependsOn(sharedExtensionPatch)
|
||||
|
||||
compatibleWith("com.nothing.smartcenter"())
|
||||
|
||||
execute {
|
||||
// Hook Application.onCreate to get K1 tokens from database and log files.
|
||||
// This will find K1 tokens that were already written to log files.
|
||||
// p0 is the Application context in onCreate.
|
||||
applicationOnCreateFingerprint.method.addInstruction(
|
||||
0,
|
||||
"invoke-static { p0 }, $EXTENSION_CLASS_DESCRIPTOR->showK1Tokens(Landroid/content/Context;)V",
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -14,8 +14,8 @@ val fixAudioMissingInDownloadsPatch = bytecodePatch(
|
||||
|
||||
execute {
|
||||
val endpointReplacements = mapOf(
|
||||
"/DASH_audio.mp4" to "/DASH_AUDIO_128.mp4",
|
||||
"/audio" to "/DASH_AUDIO_64.mp4",
|
||||
"/DASH_audio.mp4" to "/CMAF_AUDIO_128.mp4",
|
||||
"/audio" to "/CMAF_AUDIO_64.mp4",
|
||||
)
|
||||
|
||||
downloadAudioFingerprint.method.apply {
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package app.revanced.patches.shared.layout.hide.general
|
||||
|
||||
import app.revanced.patcher.patch.BytecodePatchContext
|
||||
import app.revanced.patcher.patch.Patch
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patches.all.misc.resources.addResources
|
||||
import app.revanced.patches.all.misc.resources.addResourcesPatch
|
||||
import app.revanced.patches.music.misc.settings.PreferenceScreen
|
||||
import app.revanced.patches.shared.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.shared.misc.settings.preference.InputType
|
||||
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.TextPreference
|
||||
|
||||
internal fun hideLayoutComponentsPatch(
|
||||
lithoFilterPatch: Patch<*>,
|
||||
settingsPatch: Patch<*>,
|
||||
additionalDependencies: Set<Patch<*>> = emptySet(),
|
||||
filterClasses: Set<String>,
|
||||
vararg compatibleWithPackages: Pair<String, Set<String>?>,
|
||||
executeBlock: BytecodePatchContext.() -> Unit = {},
|
||||
) = bytecodePatch(
|
||||
name = "Hide layout components",
|
||||
description = "Adds options to hide general layout components.",
|
||||
) {
|
||||
dependsOn(
|
||||
lithoFilterPatch,
|
||||
settingsPatch,
|
||||
*additionalDependencies.toTypedArray(),
|
||||
addResourcesPatch,
|
||||
)
|
||||
|
||||
compatibleWith(packages = compatibleWithPackages)
|
||||
|
||||
execute {
|
||||
addResources("shared", "layout.hide.general.hideLayoutComponentsPatch")
|
||||
|
||||
PreferenceScreen.GENERAL.addPreferences(
|
||||
PreferenceScreenPreference(
|
||||
key = "revanced_custom_filter_screen",
|
||||
sorting = PreferenceScreenPreference.Sorting.UNSORTED,
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_custom_filter"),
|
||||
TextPreference("revanced_custom_filter_strings", inputType = InputType.TEXT_MULTI_LINE),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
filterClasses.forEach { className ->
|
||||
addLithoFilter(className)
|
||||
}
|
||||
|
||||
executeBlock()
|
||||
}
|
||||
}
|
||||
@@ -2,23 +2,14 @@ package app.revanced.patches.shared.misc.debugging
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatchBuilder
|
||||
import app.revanced.patcher.patch.BytecodePatchContext
|
||||
import app.revanced.patcher.patch.Patch
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patcher.patch.resourcePatch
|
||||
import app.revanced.patches.all.misc.resources.addResources
|
||||
import app.revanced.patches.all.misc.resources.addResourcesPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.BasePreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.BasePreferenceScreen
|
||||
import app.revanced.patches.shared.misc.settings.preference.NonInteractivePreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.*
|
||||
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference.Sorting
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.util.ResourceGroup
|
||||
import app.revanced.util.copyResources
|
||||
import app.revanced.util.findInstructionIndicesReversedOrThrow
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
||||
import app.revanced.util.*
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@@ -29,23 +20,27 @@ private const val EXTENSION_CLASS_DESCRIPTOR =
|
||||
* Patch shared with YouTube and YT Music.
|
||||
*/
|
||||
internal fun enableDebuggingPatch(
|
||||
block: BytecodePatchBuilder.() -> Unit = {},
|
||||
executeBlock: BytecodePatchContext.() -> Unit = {},
|
||||
sharedExtensionPatch: Patch<*>,
|
||||
settingsPatch: Patch<*>,
|
||||
vararg compatibleWithPackages: Pair<String, Set<String>>,
|
||||
hookStringFeatureFlag: Boolean,
|
||||
preferenceScreen: BasePreferenceScreen.Screen,
|
||||
additionalDebugPreferences: List<BasePreference> = emptyList()
|
||||
) = bytecodePatch(
|
||||
name = "Enable debugging",
|
||||
description = "Adds options for debugging and exporting ReVanced logs to the clipboard.",
|
||||
) {
|
||||
compatibleWith(packages = compatibleWithPackages)
|
||||
|
||||
dependsOn(
|
||||
sharedExtensionPatch,
|
||||
settingsPatch,
|
||||
addResourcesPatch,
|
||||
resourcePatch {
|
||||
execute {
|
||||
copyResources(
|
||||
"settings",
|
||||
ResourceGroup("drawable",
|
||||
ResourceGroup(
|
||||
"drawable",
|
||||
// Action buttons.
|
||||
"revanced_settings_copy_all.xml",
|
||||
"revanced_settings_deselect_all.xml",
|
||||
@@ -61,38 +56,29 @@ internal fun enableDebuggingPatch(
|
||||
}
|
||||
)
|
||||
|
||||
block()
|
||||
|
||||
execute {
|
||||
executeBlock()
|
||||
|
||||
addResources("shared", "misc.debugging.enableDebuggingPatch")
|
||||
|
||||
val preferences = mutableSetOf<BasePreference>(
|
||||
val preferences = setOf(
|
||||
SwitchPreference("revanced_debug"),
|
||||
)
|
||||
|
||||
preferences.addAll(additionalDebugPreferences)
|
||||
|
||||
preferences.addAll(
|
||||
listOf(
|
||||
SwitchPreference("revanced_debug_stacktrace"),
|
||||
SwitchPreference("revanced_debug_toast_on_error"),
|
||||
NonInteractivePreference(
|
||||
"revanced_debug_export_logs_to_clipboard",
|
||||
tag = "app.revanced.extension.shared.settings.preference.ExportLogToClipboardPreference",
|
||||
selectable = true
|
||||
),
|
||||
NonInteractivePreference(
|
||||
"revanced_debug_logs_clear_buffer",
|
||||
tag = "app.revanced.extension.shared.settings.preference.ClearLogBufferPreference",
|
||||
selectable = true
|
||||
),
|
||||
NonInteractivePreference(
|
||||
"revanced_debug_feature_flags_manager",
|
||||
tag = "app.revanced.extension.shared.settings.preference.FeatureFlagsManagerPreference",
|
||||
selectable = true
|
||||
)
|
||||
SwitchPreference("revanced_debug_protobuffer"),
|
||||
SwitchPreference("revanced_debug_stacktrace"),
|
||||
SwitchPreference("revanced_debug_toast_on_error"),
|
||||
NonInteractivePreference(
|
||||
"revanced_debug_export_logs_to_clipboard",
|
||||
tag = "app.revanced.extension.shared.settings.preference.ExportLogToClipboardPreference",
|
||||
selectable = true
|
||||
),
|
||||
NonInteractivePreference(
|
||||
"revanced_debug_logs_clear_buffer",
|
||||
tag = "app.revanced.extension.shared.settings.preference.ClearLogBufferPreference",
|
||||
selectable = true
|
||||
),
|
||||
NonInteractivePreference(
|
||||
"revanced_debug_feature_flags_manager",
|
||||
tag = "app.revanced.extension.shared.settings.preference.FeatureFlagsManagerPreference",
|
||||
selectable = true
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package app.revanced.patches.shared.misc.litho.filter
|
||||
|
||||
import app.revanced.patcher.fingerprint
|
||||
import app.revanced.util.containsLiteralInstruction
|
||||
import app.revanced.util.literal
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
internal val lithoFilterFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.STATIC, AccessFlags.CONSTRUCTOR)
|
||||
custom { _, classDef ->
|
||||
classDef.endsWith("/LithoFilterPatch;")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches a method that use the protobuf of our component.
|
||||
*/
|
||||
internal val protobufBufferReferenceFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||
returns("V")
|
||||
parameters("I", "Ljava/nio/ByteBuffer;")
|
||||
opcodes(
|
||||
Opcode.IPUT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.SUB_INT_2ADDR,
|
||||
)
|
||||
}
|
||||
|
||||
internal val componentContextParserFingerprint = fingerprint {
|
||||
strings("Number of bits must be positive")
|
||||
}
|
||||
|
||||
internal val emptyComponentFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PRIVATE, AccessFlags.CONSTRUCTOR)
|
||||
parameters()
|
||||
strings("EmptyComponent")
|
||||
custom { _, classDef ->
|
||||
classDef.methods.filter { AccessFlags.STATIC.isSet(it.accessFlags) }.size == 1
|
||||
}
|
||||
}
|
||||
|
||||
internal val componentCreateFingerprint = fingerprint {
|
||||
strings(
|
||||
"Element missing correct type extension",
|
||||
"Element missing type"
|
||||
)
|
||||
}
|
||||
|
||||
internal val lithoThreadExecutorFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.CONSTRUCTOR)
|
||||
parameters("I", "I", "I")
|
||||
custom { method, classDef ->
|
||||
classDef.superclass == "Ljava/util/concurrent/ThreadPoolExecutor;" &&
|
||||
method.containsLiteralInstruction(1L) // 1L = default thread timeout.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
@file:Suppress("SpellCheckingInspection")
|
||||
|
||||
package app.revanced.patches.shared.misc.litho.filter
|
||||
|
||||
import app.revanced.patcher.Fingerprint
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatchBuilder
|
||||
import app.revanced.patcher.patch.BytecodePatchContext
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patches.shared.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.util.addInstructionsAtControlFlowLabel
|
||||
import app.revanced.util.findFreeRegister
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.iface.Method
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
||||
|
||||
/**
|
||||
* Used to add a hook point to the extension stub.
|
||||
*/
|
||||
lateinit var addLithoFilter: (String) -> Unit
|
||||
private set
|
||||
|
||||
/**
|
||||
* Counts the number of filters added to the static field array.
|
||||
*/
|
||||
private var filterCount = 0
|
||||
|
||||
private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/shared/patches/litho/LithoFilterPatch;"
|
||||
|
||||
/**
|
||||
* A patch that allows to filter Litho components based on their identifier or path.
|
||||
*
|
||||
* @param componentCreateInsertionIndex The index to insert the filtering code in the component create method.
|
||||
* @param conversionContextFingerprintToString The fingerprint of the conversion context to string method.
|
||||
* @param executeBlock The additional execution block of the patch.
|
||||
* @param block The additional block to build the patch.
|
||||
*/
|
||||
internal fun lithoFilterPatch(
|
||||
componentCreateInsertionIndex: Method.() -> Int,
|
||||
conversionContextFingerprintToString: Fingerprint,
|
||||
executeBlock: BytecodePatchContext.() -> Unit = {},
|
||||
block: BytecodePatchBuilder.() -> Unit = {},
|
||||
) = bytecodePatch(
|
||||
description = "Hooks the method which parses the bytes into a ComponentContext to filter components.",
|
||||
) {
|
||||
dependsOn(
|
||||
sharedExtensionPatch(),
|
||||
)
|
||||
|
||||
/**
|
||||
* The following patch inserts a hook into the method that parses the bytes into a ComponentContext.
|
||||
* This method contains a StringBuilder object that represents the pathBuilder of the component.
|
||||
* The pathBuilder is used to filter components by their path.
|
||||
*
|
||||
* Additionally, the method contains a reference to the component's identifier.
|
||||
* The identifier is used to filter components by their identifier.
|
||||
*
|
||||
* The protobuf buffer is passed along from a different injection point before the filtering occurs.
|
||||
* The buffer is a large byte array that represents the component tree.
|
||||
* This byte array is searched for strings that indicate the current component.
|
||||
*
|
||||
* All modifications done here must allow all the original code to still execute
|
||||
* even when filtering, otherwise memory leaks or poor app performance may occur.
|
||||
*
|
||||
* The following pseudocode shows how this patch works:
|
||||
*
|
||||
* class SomeOtherClass {
|
||||
* // Called before ComponentContextParser.parseComponent() method.
|
||||
* public void someOtherMethod(ByteBuffer byteBuffer) {
|
||||
* ExtensionClass.setProtoBuffer(byteBuffer); // Inserted by this patch.
|
||||
* ...
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* class CreateComponentClass {
|
||||
* public Component createComponent() {
|
||||
* ...
|
||||
*
|
||||
* if (extensionClass.shouldFilter(identifier, path)) { // Inserted by this patch.
|
||||
* return emptyComponent;
|
||||
* }
|
||||
* return originalUnpatchedComponent; // Original code.
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
execute {
|
||||
// Remove dummy filter from extenion static field
|
||||
// and add the filters included during patching.
|
||||
lithoFilterFingerprint.method.apply {
|
||||
removeInstructions(2, 4) // Remove dummy filter.
|
||||
|
||||
addLithoFilter = { classDescriptor ->
|
||||
addInstructions(
|
||||
2,
|
||||
"""
|
||||
new-instance v1, $classDescriptor
|
||||
invoke-direct { v1 }, $classDescriptor-><init>()V
|
||||
const/16 v2, ${filterCount++}
|
||||
aput-object v1, v0, v2
|
||||
""",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Add an interceptor to steal the protobuf of our component.
|
||||
protobufBufferReferenceFingerprint.method.addInstruction(
|
||||
0,
|
||||
"invoke-static { p2 }, $EXTENSION_CLASS_DESCRIPTOR->setProtoBuffer(Ljava/nio/ByteBuffer;)V",
|
||||
)
|
||||
|
||||
|
||||
// Hook the method that parses bytes into a ComponentContext.
|
||||
// Allow the method to run to completion, and override the
|
||||
// return value with an empty component if it should be filtered.
|
||||
// It is important to allow the original code to always run to completion,
|
||||
// otherwise high memory usage and poor app performance can occur.
|
||||
|
||||
// Find the identifier/path fields of the conversion context.
|
||||
val conversionContextIdentifierField = componentContextParserFingerprint.let {
|
||||
// Identifier field is loaded just before the string declaration.
|
||||
val index = it.method.indexOfFirstInstructionReversedOrThrow(
|
||||
it.stringMatches!!.first().index
|
||||
) {
|
||||
// Our instruction reads a String from a field of the ConversionContext class.
|
||||
val reference = getReference<FieldReference>()
|
||||
reference?.definingClass == conversionContextFingerprintToString.originalClassDef.type
|
||||
&& reference.type == "Ljava/lang/String;"
|
||||
}
|
||||
|
||||
it.method.getInstruction<ReferenceInstruction>(index).getReference<FieldReference>()!!
|
||||
}
|
||||
|
||||
val conversionContextPathBuilderField = conversionContextFingerprintToString.originalClassDef
|
||||
.fields.single { field -> field.type == "Ljava/lang/StringBuilder;" }
|
||||
|
||||
// Find class and methods to create an empty component.
|
||||
val builderMethodDescriptor = emptyComponentFingerprint.classDef.methods.single {
|
||||
// The only static method in the class.
|
||||
method ->
|
||||
AccessFlags.STATIC.isSet(method.accessFlags)
|
||||
}
|
||||
|
||||
val emptyComponentField = classBy {
|
||||
// Only one field that matches.
|
||||
it.type == builderMethodDescriptor.returnType
|
||||
}!!.immutableClass.fields.single()
|
||||
|
||||
// Match all component creations methods
|
||||
componentCreateFingerprint.method.apply {
|
||||
val insertIndex = componentCreateInsertionIndex()
|
||||
val freeRegister = findFreeRegister(insertIndex)
|
||||
val identifierRegister = findFreeRegister(insertIndex, freeRegister)
|
||||
val pathRegister = findFreeRegister(insertIndex, freeRegister, identifierRegister)
|
||||
|
||||
addInstructionsAtControlFlowLabel(
|
||||
insertIndex,
|
||||
"""
|
||||
move-object/from16 v$freeRegister, p2 # ConversionContext parameter
|
||||
check-cast v$freeRegister, ${conversionContextFingerprintToString.originalClassDef.type} # Check we got the actual ConversionContext
|
||||
|
||||
# Get identifier and path from ConversionContext
|
||||
iget-object v$identifierRegister, v$freeRegister, $conversionContextIdentifierField
|
||||
iget-object v$pathRegister, v$freeRegister, $conversionContextPathBuilderField
|
||||
|
||||
# Check if the component should be filtered.
|
||||
invoke-static { v$identifierRegister, v$pathRegister }, $EXTENSION_CLASS_DESCRIPTOR->isFiltered(Ljava/lang/String;Ljava/lang/StringBuilder;)Z
|
||||
move-result v$freeRegister
|
||||
if-eqz v$freeRegister, :unfiltered
|
||||
|
||||
# Return an empty component
|
||||
move-object/from16 v$freeRegister, p1
|
||||
invoke-static { v$freeRegister }, $builderMethodDescriptor
|
||||
move-result-object v$freeRegister
|
||||
iget-object v$freeRegister, v$freeRegister, $emptyComponentField
|
||||
return-object v$freeRegister
|
||||
|
||||
:unfiltered
|
||||
nop
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
// TODO: Check if needed in music
|
||||
// Change Litho thread executor to 1 thread to fix layout issue in unpatched YouTube.
|
||||
lithoThreadExecutorFingerprint.method.addInstructions(
|
||||
0,
|
||||
"""
|
||||
invoke-static { p1 }, $EXTENSION_CLASS_DESCRIPTOR->getExecutorCorePoolSize(I)I
|
||||
move-result p1
|
||||
invoke-static { p2 }, $EXTENSION_CLASS_DESCRIPTOR->getExecutorMaxThreads(I)I
|
||||
move-result p2
|
||||
"""
|
||||
)
|
||||
|
||||
executeBlock()
|
||||
}
|
||||
|
||||
finalize {
|
||||
// Save the number of filters added.
|
||||
lithoFilterFingerprint.method.replaceInstruction(0, "const/16 v0, $filterCount")
|
||||
}
|
||||
|
||||
block()
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
package app.revanced.patches.strava.groupkudos
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.instructions
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patcher.patch.resourcePatch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
||||
import app.revanced.util.childElementsSequence
|
||||
import app.revanced.util.findElementByAttributeValueOrThrow
|
||||
import app.revanced.util.getReference
|
||||
import com.android.tools.smali.dexlib2.AccessFlags.*
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation
|
||||
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction11x
|
||||
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21c
|
||||
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction31i
|
||||
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.NarrowLiteralInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.reference.TypeReference
|
||||
import com.android.tools.smali.dexlib2.immutable.ImmutableClassDef
|
||||
import com.android.tools.smali.dexlib2.immutable.ImmutableField
|
||||
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
|
||||
import com.android.tools.smali.dexlib2.immutable.ImmutableMethodParameter
|
||||
import org.w3c.dom.Element
|
||||
|
||||
private const val VIEW_CLASS_DESCRIPTOR = "Landroid/view/View;"
|
||||
private const val ON_CLICK_LISTENER_CLASS_DESCRIPTOR = "Landroid/view/View\$OnClickListener;"
|
||||
|
||||
private var shakeToKudosStringId = -1
|
||||
private var kudosIdId = -1
|
||||
private var leaveIdId = -1
|
||||
|
||||
private val addGiveKudosButtonToLayoutPatch = resourcePatch {
|
||||
fun String.toResourceId() = substring(2).toInt(16)
|
||||
|
||||
execute {
|
||||
document("res/values/public.xml").use { public ->
|
||||
fun Sequence<Element>.firstByName(name: String) = first {
|
||||
it.getAttribute("name") == name
|
||||
}
|
||||
|
||||
val publicElements = public.documentElement.childElementsSequence().filter {
|
||||
it.tagName == "public"
|
||||
}
|
||||
val idElements = publicElements.filter {
|
||||
it.getAttribute("type") == "id"
|
||||
}
|
||||
val stringElements = publicElements.filter {
|
||||
it.getAttribute("type") == "string"
|
||||
}
|
||||
|
||||
shakeToKudosStringId =
|
||||
stringElements.firstByName("shake_to_kudos_dialog_title").getAttribute("id").toResourceId()
|
||||
|
||||
val kudosIdNode = idElements.firstByName("kudos").apply {
|
||||
kudosIdId = getAttribute("id").toResourceId()
|
||||
}
|
||||
|
||||
document("res/layout/grouped_activities_dialog_group_tab.xml").use { layout ->
|
||||
layout.childNodes.findElementByAttributeValueOrThrow("android:id", "@id/leave_group_button_container")
|
||||
.apply {
|
||||
// Change from "FrameLayout".
|
||||
layout.renameNode(this, namespaceURI, "LinearLayout")
|
||||
|
||||
val leaveButton = childElementsSequence().first()
|
||||
// Get "Leave Group" button ID for bytecode matching.
|
||||
val leaveButtonIdName = leaveButton.getAttribute("android:id").substringAfter('/')
|
||||
leaveIdId = idElements.firstByName(leaveButtonIdName).getAttribute("id").toResourceId()
|
||||
|
||||
// Add surrounding padding to offset decrease on buttons.
|
||||
setAttribute("android:paddingHorizontal", "@dimen/space_2xs")
|
||||
|
||||
// Place buttons next to each other with equal width.
|
||||
val kudosButton = leaveButton.apply {
|
||||
setAttribute("android:layout_width", "0dp")
|
||||
setAttribute("android:layout_weight", "1")
|
||||
// Decrease padding between buttons from "@dimen/button_large_padding" ...
|
||||
setAttribute("android:paddingHorizontal", "@dimen/space_xs")
|
||||
}.cloneNode(true) as Element
|
||||
kudosButton.apply {
|
||||
setAttribute("android:id", "@id/${kudosIdNode.getAttribute("name")}")
|
||||
setAttribute("android:text", "@string/kudos_button")
|
||||
}.let(::appendChild)
|
||||
|
||||
// Downgrade emphasis of "Leave Group" button from "primary".
|
||||
leaveButton.setAttribute("app:emphasis", "secondary")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
val addGiveGroupKudosButtonToGroupActivity = bytecodePatch(
|
||||
name = "Add 'Give Kudos' button to 'Group Activity'",
|
||||
description = "Adds a button that triggers the same action as shaking your phone would."
|
||||
) {
|
||||
compatibleWith("com.strava")
|
||||
|
||||
dependsOn(addGiveKudosButtonToLayoutPatch)
|
||||
|
||||
execute {
|
||||
val className = initFingerprint.originalClassDef.type
|
||||
val onClickListenerClassName = "${className.substringBeforeLast(';')}\$GiveKudosOnClickListener;"
|
||||
|
||||
initFingerprint.method.apply {
|
||||
val constLeaveIdInstruction = instructions.filterIsInstance<BuilderInstruction31i>().first {
|
||||
it.narrowLiteral == leaveIdId
|
||||
}
|
||||
val findViewByIdInstruction =
|
||||
getInstruction<BuilderInstruction35c>(constLeaveIdInstruction.location.index + 1)
|
||||
val moveViewInstruction = getInstruction<BuilderInstruction11x>(constLeaveIdInstruction.location.index + 2)
|
||||
val checkCastButtonInstruction =
|
||||
getInstruction<BuilderInstruction21c>(constLeaveIdInstruction.location.index + 3)
|
||||
|
||||
val buttonClassName = checkCastButtonInstruction.getReference<TypeReference>()!!.type
|
||||
|
||||
addInstructions(
|
||||
constLeaveIdInstruction.location.index,
|
||||
"""
|
||||
${constLeaveIdInstruction.opcode.name} v${constLeaveIdInstruction.registerA}, $kudosIdId
|
||||
${findViewByIdInstruction.opcode.name} { v${findViewByIdInstruction.registerC}, v${findViewByIdInstruction.registerD} }, ${findViewByIdInstruction.reference}
|
||||
${moveViewInstruction.opcode.name} v${moveViewInstruction.registerA}
|
||||
${checkCastButtonInstruction.opcode.name} v${checkCastButtonInstruction.registerA}, ${checkCastButtonInstruction.reference}
|
||||
new-instance v0, $onClickListenerClassName
|
||||
invoke-direct { v0, p0 }, $onClickListenerClassName-><init>($className)V
|
||||
invoke-virtual { p3, v0 }, $buttonClassName->setOnClickListener($ON_CLICK_LISTENER_CLASS_DESCRIPTOR)V
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
val actionHandlerMethod = actionHandlerFingerprint.match(initFingerprint.originalClassDef).method
|
||||
val constShakeToKudosStringIndex = actionHandlerMethod.instructions.indexOfFirst {
|
||||
it is NarrowLiteralInstruction && it.narrowLiteral == shakeToKudosStringId
|
||||
}
|
||||
val getSingletonInstruction = actionHandlerMethod.instructions.filterIsInstance<BuilderInstruction21c>().last {
|
||||
it.opcode == Opcode.SGET_OBJECT && it.location.index < constShakeToKudosStringIndex
|
||||
}
|
||||
|
||||
val outerThisField = ImmutableField(
|
||||
onClickListenerClassName,
|
||||
"outerThis",
|
||||
className,
|
||||
PUBLIC.value or FINAL.value or SYNTHETIC.value,
|
||||
null,
|
||||
listOf(),
|
||||
setOf()
|
||||
)
|
||||
|
||||
val initFieldMethod = ImmutableMethod(
|
||||
onClickListenerClassName,
|
||||
"<init>",
|
||||
listOf(ImmutableMethodParameter(className, setOf(), "outerThis")),
|
||||
"V",
|
||||
PUBLIC.value or SYNTHETIC.value or CONSTRUCTOR.value,
|
||||
setOf(),
|
||||
setOf(),
|
||||
MutableMethodImplementation(2)
|
||||
).toMutable().apply {
|
||||
addInstructions(
|
||||
"""
|
||||
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
||||
iput-object p1, p0, $outerThisField
|
||||
return-void
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
val onClickMethod = ImmutableMethod(
|
||||
onClickListenerClassName,
|
||||
"onClick",
|
||||
listOf(ImmutableMethodParameter(VIEW_CLASS_DESCRIPTOR, setOf(), "v")),
|
||||
"V",
|
||||
PUBLIC.value or FINAL.value,
|
||||
setOf(),
|
||||
setOf(),
|
||||
MutableMethodImplementation(2)
|
||||
).toMutable().apply {
|
||||
addInstructions(
|
||||
"""
|
||||
sget-object p1, ${getSingletonInstruction.reference}
|
||||
iget-object p0, p0, $outerThisField
|
||||
invoke-virtual { p0, p1 }, ${actionHandlerFingerprint.method}
|
||||
return-void
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
ImmutableClassDef(
|
||||
onClickListenerClassName,
|
||||
PUBLIC.value or FINAL.value or SYNTHETIC.value,
|
||||
"Ljava/lang/Object;",
|
||||
listOf(ON_CLICK_LISTENER_CLASS_DESCRIPTOR),
|
||||
"ProGuard", // Same as source file name of other classes.
|
||||
listOf(),
|
||||
setOf(outerThisField),
|
||||
setOf(initFieldMethod, onClickMethod)
|
||||
).let(classes::add)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package app.revanced.patches.strava.groupkudos
|
||||
|
||||
import app.revanced.patcher.fingerprint
|
||||
|
||||
internal val initFingerprint = fingerprint {
|
||||
parameters("Lcom/strava/feed/view/modal/GroupTabFragment;" , "Z" , "Landroidx/fragment/app/FragmentManager;")
|
||||
custom { method, _ ->
|
||||
method.name == "<init>"
|
||||
}
|
||||
}
|
||||
|
||||
internal val actionHandlerFingerprint = fingerprint {
|
||||
strings("state")
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package app.revanced.patches.strava.media.download
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.instructions
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.shared.misc.mapping.get
|
||||
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
|
||||
import app.revanced.patches.shared.misc.mapping.resourceMappings
|
||||
import app.revanced.patches.strava.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.writeRegister
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction22c
|
||||
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
||||
import com.android.tools.smali.dexlib2.iface.reference.TypeReference
|
||||
|
||||
private const val ACTION_CLASS_DESCRIPTOR = "Lcom/strava/bottomsheet/Action;"
|
||||
private const val MEDIA_CLASS_DESCRIPTOR = "Lcom/strava/photos/data/Media;"
|
||||
private const val MEDIA_DOWNLOAD_CLASS_DESCRIPTOR = "Lapp/revanced/extension/strava/AddMediaDownloadPatch;"
|
||||
|
||||
@Suppress("unused")
|
||||
val addMediaDownloadPatch = bytecodePatch(
|
||||
name = "Add media download",
|
||||
description = "Extends the full-screen media viewer menu with items to copy or open their URLs or download them directly."
|
||||
) {
|
||||
compatibleWith("com.strava")
|
||||
|
||||
dependsOn(
|
||||
resourceMappingPatch,
|
||||
sharedExtensionPatch
|
||||
)
|
||||
|
||||
execute {
|
||||
val fragmentClass = classBy { it.endsWith("/FullscreenMediaFragment;") }!!.mutableClass
|
||||
|
||||
// region Extend menu of `FullscreenMediaFragment` with actions.
|
||||
|
||||
createAndShowFragmentFingerprint.match(fragmentClass).method.apply {
|
||||
val setTrueIndex = instructions.indexOfFirst { instruction ->
|
||||
instruction.opcode == Opcode.IPUT_BOOLEAN
|
||||
}
|
||||
val actionRegistrarRegister = getInstruction<BuilderInstruction22c>(setTrueIndex).registerB
|
||||
val actionRegister = instructions.first { instruction ->
|
||||
instruction.getReference<TypeReference>()?.type == ACTION_CLASS_DESCRIPTOR
|
||||
}.writeRegister!!
|
||||
|
||||
fun addMenuItem(actionId: String, string: String, color: String, drawable: String) = addInstructions(
|
||||
setTrueIndex + 1,
|
||||
"""
|
||||
new-instance v$actionRegister, $ACTION_CLASS_DESCRIPTOR
|
||||
sget v${actionRegister + 1}, $MEDIA_DOWNLOAD_CLASS_DESCRIPTOR->$actionId:I
|
||||
const v${actionRegister + 2}, 0x0
|
||||
const v${actionRegister + 3}, ${resourceMappings["string", string]}
|
||||
const v${actionRegister + 4}, ${resourceMappings["color", color]}
|
||||
const v${actionRegister + 5}, ${resourceMappings["drawable", drawable]}
|
||||
move/from16 v${actionRegister + 6}, v${actionRegister + 4}
|
||||
invoke-direct/range { v$actionRegister .. v${actionRegister + 7} }, $ACTION_CLASS_DESCRIPTOR-><init>(ILjava/lang/String;IIIILjava/io/Serializable;)V
|
||||
invoke-virtual { v$actionRegistrarRegister, v$actionRegister }, Lcom/strava/bottomsheet/a;->a(Lcom/strava/bottomsheet/BottomSheetItem;)V
|
||||
"""
|
||||
)
|
||||
|
||||
addMenuItem("ACTION_COPY_LINK", "copy_link", "core_o3", "actions_link_normal_xsmall")
|
||||
addMenuItem("ACTION_OPEN_LINK", "fallback_menu_item_open_in_browser", "core_o3", "actions_link_external_normal_xsmall")
|
||||
addMenuItem("ACTION_DOWNLOAD", "download", "core_o3", "actions_download_normal_xsmall")
|
||||
|
||||
// Move media to last parameter of `Action` constructor.
|
||||
val getMediaInstruction = instructions.first { instruction ->
|
||||
instruction.getReference<FieldReference>()?.type == MEDIA_CLASS_DESCRIPTOR
|
||||
}
|
||||
addInstruction(
|
||||
getMediaInstruction.location.index + 1,
|
||||
"move-object/from16 v${actionRegister + 7}, v${getMediaInstruction.writeRegister}"
|
||||
)
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Handle new actions.
|
||||
|
||||
val actionClass = classes.first { clazz ->
|
||||
clazz.type == ACTION_CLASS_DESCRIPTOR
|
||||
}
|
||||
val actionSerializableField = actionClass.instanceFields.first { field ->
|
||||
field.type == "Ljava/io/Serializable;"
|
||||
}
|
||||
|
||||
// Handle "copy link" & "open link" & "download" actions.
|
||||
handleMediaActionFingerprint.match(fragmentClass).method.apply {
|
||||
// Call handler if action ID < 0 (= custom).
|
||||
val moveInstruction = instructions.first { instruction ->
|
||||
instruction.opcode == Opcode.MOVE_RESULT
|
||||
}
|
||||
val indexAfterMoveInstruction = moveInstruction.location.index + 1
|
||||
val actionIdRegister = moveInstruction.writeRegister
|
||||
addInstructionsWithLabels(
|
||||
indexAfterMoveInstruction,
|
||||
"""
|
||||
if-gez v$actionIdRegister, :move
|
||||
check-cast p2, $ACTION_CLASS_DESCRIPTOR
|
||||
iget-object v0, p2, $actionSerializableField
|
||||
check-cast v0, $MEDIA_CLASS_DESCRIPTOR
|
||||
invoke-static { v$actionIdRegister, v0 }, $MEDIA_DOWNLOAD_CLASS_DESCRIPTOR->handleAction(I$MEDIA_CLASS_DESCRIPTOR)Z
|
||||
move-result v0
|
||||
return v0
|
||||
""",
|
||||
ExternalLabel("move", instructions[indexAfterMoveInstruction])
|
||||
)
|
||||
}
|
||||
|
||||
// endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package app.revanced.patches.strava.media.download
|
||||
|
||||
import app.revanced.patcher.fingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
internal val createAndShowFragmentFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||
returns("V")
|
||||
parameters("L")
|
||||
strings("mediaType")
|
||||
}
|
||||
|
||||
internal val handleMediaActionFingerprint = fingerprint {
|
||||
parameters("Landroid/view/View;", "Lcom/strava/bottomsheet/BottomSheetItem;")
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.strava.mediaupload
|
||||
package app.revanced.patches.strava.media.upload
|
||||
|
||||
import app.revanced.patcher.fingerprint
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.strava.mediaupload
|
||||
package app.revanced.patches.strava.media.upload
|
||||
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patcher.patch.intOption
|
||||
@@ -0,0 +1,9 @@
|
||||
package app.revanced.patches.strava.misc.extension
|
||||
|
||||
import app.revanced.patches.shared.misc.extension.extensionHook
|
||||
|
||||
internal val applicationOnCreateHook = extensionHook {
|
||||
custom { method, classDef ->
|
||||
method.name == "onCreate" && classDef.endsWith("/StravaApplication;")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package app.revanced.patches.strava.misc.extension
|
||||
|
||||
import app.revanced.patches.shared.misc.extension.sharedExtensionPatch
|
||||
|
||||
val sharedExtensionPatch = sharedExtensionPatch("strava", applicationOnCreateHook)
|
||||
@@ -7,13 +7,13 @@ import app.revanced.patcher.patch.resourcePatch
|
||||
import app.revanced.patches.all.misc.resources.addResources
|
||||
import app.revanced.patches.all.misc.resources.addResourcesPatch
|
||||
import app.revanced.patches.shared.misc.fix.verticalscroll.verticalScrollPatch
|
||||
import app.revanced.patches.shared.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.shared.misc.mapping.get
|
||||
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
|
||||
import app.revanced.patches.shared.misc.mapping.resourceMappings
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.youtube.ad.getpremium.hideGetPremiumPatch
|
||||
import app.revanced.patches.youtube.misc.fix.backtoexitgesture.fixBackToExitGesturePatch
|
||||
import app.revanced.patches.youtube.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.youtube.misc.litho.filter.lithoFilterPatch
|
||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
||||
|
||||
@@ -6,7 +6,7 @@ import app.revanced.patches.all.misc.resources.addResourcesPatch
|
||||
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.shared.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.youtube.misc.litho.filter.lithoFilterPatch
|
||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||
|
||||
|
||||
@@ -9,34 +9,27 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.instructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patcher.patch.resourcePatch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.all.misc.resources.addResources
|
||||
import app.revanced.patches.all.misc.resources.addResourcesPatch
|
||||
import app.revanced.patches.shared.layout.hide.general.hideLayoutComponentsPatch
|
||||
import app.revanced.patches.shared.misc.mapping.get
|
||||
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
|
||||
import app.revanced.patches.shared.misc.mapping.resourceMappings
|
||||
import app.revanced.patches.shared.misc.settings.preference.*
|
||||
import app.revanced.patches.youtube.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.youtube.misc.litho.filter.lithoFilterPatch
|
||||
import app.revanced.patches.youtube.misc.navigation.navigationBarHookPatch
|
||||
import app.revanced.patches.youtube.misc.playservice.is_20_07_or_greater
|
||||
import app.revanced.patches.youtube.misc.playservice.is_20_09_or_greater
|
||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
||||
import app.revanced.util.findFreeRegister
|
||||
import app.revanced.util.findInstructionIndicesReversedOrThrow
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.indexOfFirstLiteralInstructionOrThrow
|
||||
import app.revanced.util.*
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.Method
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
||||
|
||||
var expandButtonDownId = -1L
|
||||
private set
|
||||
@@ -108,184 +101,170 @@ private const val DESCRIPTION_COMPONENTS_FILTER_CLASS_NAME =
|
||||
private const val COMMENTS_FILTER_CLASS_NAME =
|
||||
"Lapp/revanced/extension/youtube/patches/components/CommentsFilter;"
|
||||
private const val CUSTOM_FILTER_CLASS_NAME =
|
||||
"Lapp/revanced/extension/youtube/patches/components/CustomFilter;"
|
||||
"Lapp/revanced/extension/shared/patches/components/CustomFilter;"
|
||||
private const val KEYWORD_FILTER_CLASS_NAME =
|
||||
"Lapp/revanced/extension/youtube/patches/components/KeywordContentFilter;"
|
||||
|
||||
val hideLayoutComponentsPatch = bytecodePatch(
|
||||
name = "Hide layout components",
|
||||
description = "Adds options to hide general layout components.",
|
||||
|
||||
) {
|
||||
dependsOn(
|
||||
lithoFilterPatch,
|
||||
settingsPatch,
|
||||
addResourcesPatch,
|
||||
val hideLayoutComponentsPatch = hideLayoutComponentsPatch(
|
||||
lithoFilterPatch = lithoFilterPatch,
|
||||
settingsPatch = settingsPatch,
|
||||
additionalDependencies = setOf(
|
||||
hideLayoutComponentsResourcePatch,
|
||||
navigationBarHookPatch,
|
||||
)
|
||||
|
||||
compatibleWith(
|
||||
"com.google.android.youtube"(
|
||||
),
|
||||
filterClasses = setOf(
|
||||
LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR,
|
||||
DESCRIPTION_COMPONENTS_FILTER_CLASS_NAME,
|
||||
COMMENTS_FILTER_CLASS_NAME,
|
||||
KEYWORD_FILTER_CLASS_NAME,
|
||||
CUSTOM_FILTER_CLASS_NAME
|
||||
),
|
||||
compatibleWithPackages = arrayOf(
|
||||
"com.google.android.youtube" to setOf(
|
||||
"19.34.42",
|
||||
"20.07.39",
|
||||
"20.13.41",
|
||||
"20.14.43",
|
||||
)
|
||||
)
|
||||
) {
|
||||
addResources("youtube", "layout.hide.general.hideLayoutComponentsPatch")
|
||||
|
||||
execute {
|
||||
addResources("youtube", "layout.hide.general.hideLayoutComponentsPatch")
|
||||
PreferenceScreen.PLAYER.addPreferences(
|
||||
PreferenceScreenPreference(
|
||||
key = "revanced_hide_description_components_screen",
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_hide_ai_generated_video_summary_section"),
|
||||
SwitchPreference("revanced_hide_ask_section"),
|
||||
SwitchPreference("revanced_hide_attributes_section"),
|
||||
SwitchPreference("revanced_hide_chapters_section"),
|
||||
SwitchPreference("revanced_hide_featured_links_section"),
|
||||
SwitchPreference("revanced_hide_featured_videos_section"),
|
||||
SwitchPreference("revanced_hide_info_cards_section"),
|
||||
SwitchPreference("revanced_hide_how_this_was_made_section"),
|
||||
SwitchPreference("revanced_hide_hype_points"),
|
||||
SwitchPreference("revanced_hide_key_concepts_section"),
|
||||
SwitchPreference("revanced_hide_podcast_section"),
|
||||
SwitchPreference("revanced_hide_subscribe_button"),
|
||||
SwitchPreference("revanced_hide_transcript_section"),
|
||||
),
|
||||
),
|
||||
PreferenceScreenPreference(
|
||||
"revanced_comments_screen",
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_hide_comments_ai_chat_summary"),
|
||||
SwitchPreference("revanced_hide_comments_ai_summary"),
|
||||
SwitchPreference("revanced_hide_comments_channel_guidelines"),
|
||||
SwitchPreference("revanced_hide_comments_by_members_header"),
|
||||
SwitchPreference("revanced_hide_comments_section"),
|
||||
SwitchPreference("revanced_hide_comments_community_guidelines"),
|
||||
SwitchPreference("revanced_hide_comments_create_a_short_button"),
|
||||
SwitchPreference("revanced_hide_comments_emoji_and_timestamp_buttons"),
|
||||
SwitchPreference("revanced_hide_comments_preview_comment"),
|
||||
SwitchPreference("revanced_hide_comments_thanks_button"),
|
||||
),
|
||||
sorting = PreferenceScreenPreference.Sorting.UNSORTED,
|
||||
),
|
||||
SwitchPreference("revanced_hide_channel_bar"),
|
||||
SwitchPreference("revanced_hide_channel_watermark"),
|
||||
SwitchPreference("revanced_hide_crowdfunding_box"),
|
||||
SwitchPreference("revanced_hide_emergency_box"),
|
||||
SwitchPreference("revanced_hide_info_panels"),
|
||||
SwitchPreference("revanced_hide_join_membership_button"),
|
||||
SwitchPreference("revanced_hide_medical_panels"),
|
||||
SwitchPreference("revanced_hide_quick_actions"),
|
||||
SwitchPreference("revanced_hide_related_videos"),
|
||||
SwitchPreference("revanced_hide_subscribers_community_guidelines"),
|
||||
SwitchPreference("revanced_hide_timed_reactions"),
|
||||
)
|
||||
|
||||
PreferenceScreen.PLAYER.addPreferences(
|
||||
PreferenceScreenPreference(
|
||||
key = "revanced_hide_description_components_screen",
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_hide_ai_generated_video_summary_section"),
|
||||
SwitchPreference("revanced_hide_ask_section"),
|
||||
SwitchPreference("revanced_hide_attributes_section"),
|
||||
SwitchPreference("revanced_hide_chapters_section"),
|
||||
SwitchPreference("revanced_hide_featured_links_section"),
|
||||
SwitchPreference("revanced_hide_featured_videos_section"),
|
||||
SwitchPreference("revanced_hide_info_cards_section"),
|
||||
SwitchPreference("revanced_hide_how_this_was_made_section"),
|
||||
SwitchPreference("revanced_hide_hype_points"),
|
||||
SwitchPreference("revanced_hide_key_concepts_section"),
|
||||
SwitchPreference("revanced_hide_podcast_section"),
|
||||
SwitchPreference("revanced_hide_subscribe_button"),
|
||||
SwitchPreference("revanced_hide_transcript_section"),
|
||||
PreferenceScreen.FEED.addPreferences(
|
||||
PreferenceScreenPreference(
|
||||
key = "revanced_hide_keyword_content_screen",
|
||||
sorting = PreferenceScreenPreference.Sorting.UNSORTED,
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_hide_keyword_content_home"),
|
||||
SwitchPreference("revanced_hide_keyword_content_subscriptions"),
|
||||
SwitchPreference("revanced_hide_keyword_content_search"),
|
||||
TextPreference("revanced_hide_keyword_content_phrases", inputType = InputType.TEXT_MULTI_LINE),
|
||||
NonInteractivePreference(
|
||||
key = "revanced_hide_keyword_content_about",
|
||||
tag = "app.revanced.extension.shared.settings.preference.BulletPointPreference"
|
||||
),
|
||||
NonInteractivePreference(
|
||||
key = "revanced_hide_keyword_content_about_whole_words",
|
||||
tag = "app.revanced.extension.youtube.settings.preference.HtmlPreference",
|
||||
),
|
||||
),
|
||||
PreferenceScreenPreference(
|
||||
"revanced_comments_screen",
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_hide_comments_ai_chat_summary"),
|
||||
SwitchPreference("revanced_hide_comments_ai_summary"),
|
||||
SwitchPreference("revanced_hide_comments_channel_guidelines"),
|
||||
SwitchPreference("revanced_hide_comments_by_members_header"),
|
||||
SwitchPreference("revanced_hide_comments_section"),
|
||||
SwitchPreference("revanced_hide_comments_community_guidelines"),
|
||||
SwitchPreference("revanced_hide_comments_create_a_short_button"),
|
||||
SwitchPreference("revanced_hide_comments_emoji_and_timestamp_buttons"),
|
||||
SwitchPreference("revanced_hide_comments_preview_comment"),
|
||||
SwitchPreference("revanced_hide_comments_thanks_button"),
|
||||
),
|
||||
sorting = PreferenceScreenPreference.Sorting.UNSORTED,
|
||||
),
|
||||
PreferenceScreenPreference(
|
||||
key = "revanced_hide_filter_bar_screen",
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_hide_filter_bar_feed_in_feed"),
|
||||
SwitchPreference("revanced_hide_filter_bar_feed_in_related_videos"),
|
||||
SwitchPreference("revanced_hide_filter_bar_feed_in_search"),
|
||||
SwitchPreference("revanced_hide_filter_bar_feed_in_history"),
|
||||
),
|
||||
SwitchPreference("revanced_hide_channel_bar"),
|
||||
SwitchPreference("revanced_hide_channel_watermark"),
|
||||
SwitchPreference("revanced_hide_crowdfunding_box"),
|
||||
SwitchPreference("revanced_hide_emergency_box"),
|
||||
SwitchPreference("revanced_hide_info_panels"),
|
||||
SwitchPreference("revanced_hide_join_membership_button"),
|
||||
SwitchPreference("revanced_hide_medical_panels"),
|
||||
SwitchPreference("revanced_hide_quick_actions"),
|
||||
SwitchPreference("revanced_hide_related_videos"),
|
||||
SwitchPreference("revanced_hide_subscribers_community_guidelines"),
|
||||
SwitchPreference("revanced_hide_timed_reactions"),
|
||||
)
|
||||
|
||||
PreferenceScreen.FEED.addPreferences(
|
||||
PreferenceScreenPreference(
|
||||
key = "revanced_hide_keyword_content_screen",
|
||||
sorting = PreferenceScreenPreference.Sorting.UNSORTED,
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_hide_keyword_content_home"),
|
||||
SwitchPreference("revanced_hide_keyword_content_subscriptions"),
|
||||
SwitchPreference("revanced_hide_keyword_content_search"),
|
||||
TextPreference("revanced_hide_keyword_content_phrases", inputType = InputType.TEXT_MULTI_LINE),
|
||||
NonInteractivePreference(
|
||||
key = "revanced_hide_keyword_content_about",
|
||||
tag = "app.revanced.extension.shared.settings.preference.BulletPointPreference"
|
||||
),
|
||||
NonInteractivePreference(
|
||||
key = "revanced_hide_keyword_content_about_whole_words",
|
||||
tag = "app.revanced.extension.youtube.settings.preference.HtmlPreference",
|
||||
),
|
||||
),
|
||||
),
|
||||
PreferenceScreenPreference(
|
||||
key = "revanced_channel_screen",
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_hide_community_button"),
|
||||
SwitchPreference("revanced_hide_for_you_shelf"),
|
||||
SwitchPreference("revanced_hide_join_button"),
|
||||
SwitchPreference("revanced_hide_links_preview"),
|
||||
SwitchPreference("revanced_hide_members_shelf"),
|
||||
SwitchPreference("revanced_hide_store_button"),
|
||||
SwitchPreference("revanced_hide_subscribe_button_in_channel_page"),
|
||||
),
|
||||
PreferenceScreenPreference(
|
||||
key = "revanced_hide_filter_bar_screen",
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_hide_filter_bar_feed_in_feed"),
|
||||
SwitchPreference("revanced_hide_filter_bar_feed_in_related_videos"),
|
||||
SwitchPreference("revanced_hide_filter_bar_feed_in_search"),
|
||||
SwitchPreference("revanced_hide_filter_bar_feed_in_history"),
|
||||
),
|
||||
),
|
||||
PreferenceScreenPreference(
|
||||
key = "revanced_channel_screen",
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_hide_community_button"),
|
||||
SwitchPreference("revanced_hide_for_you_shelf"),
|
||||
SwitchPreference("revanced_hide_join_button"),
|
||||
SwitchPreference("revanced_hide_links_preview"),
|
||||
SwitchPreference("revanced_hide_members_shelf"),
|
||||
SwitchPreference("revanced_hide_store_button"),
|
||||
SwitchPreference("revanced_hide_subscribe_button_in_channel_page"),
|
||||
),
|
||||
),
|
||||
SwitchPreference("revanced_hide_album_cards"),
|
||||
SwitchPreference("revanced_hide_artist_cards"),
|
||||
SwitchPreference("revanced_hide_chips_shelf"),
|
||||
SwitchPreference("revanced_hide_community_posts"),
|
||||
SwitchPreference("revanced_hide_compact_banner"),
|
||||
SwitchPreference("revanced_hide_expandable_card"),
|
||||
SwitchPreference("revanced_hide_floating_microphone_button"),
|
||||
SwitchPreference(
|
||||
key = "revanced_hide_horizontal_shelves",
|
||||
tag = "app.revanced.extension.shared.settings.preference.BulletPointSwitchPreference"
|
||||
),
|
||||
SwitchPreference("revanced_hide_image_shelf"),
|
||||
SwitchPreference("revanced_hide_latest_posts"),
|
||||
SwitchPreference("revanced_hide_mix_playlists"),
|
||||
SwitchPreference("revanced_hide_movies_section"),
|
||||
SwitchPreference("revanced_hide_notify_me_button"),
|
||||
SwitchPreference("revanced_hide_playables"),
|
||||
SwitchPreference("revanced_hide_show_more_button"),
|
||||
SwitchPreference("revanced_hide_surveys"),
|
||||
SwitchPreference("revanced_hide_ticket_shelf"),
|
||||
SwitchPreference("revanced_hide_upload_time"),
|
||||
SwitchPreference("revanced_hide_video_recommendation_labels"),
|
||||
SwitchPreference("revanced_hide_view_count"),
|
||||
SwitchPreference("revanced_hide_visual_spacer"),
|
||||
SwitchPreference("revanced_hide_doodles"),
|
||||
)
|
||||
),
|
||||
SwitchPreference("revanced_hide_album_cards"),
|
||||
SwitchPreference("revanced_hide_artist_cards"),
|
||||
SwitchPreference("revanced_hide_chips_shelf"),
|
||||
SwitchPreference("revanced_hide_community_posts"),
|
||||
SwitchPreference("revanced_hide_compact_banner"),
|
||||
SwitchPreference("revanced_hide_expandable_card"),
|
||||
SwitchPreference("revanced_hide_floating_microphone_button"),
|
||||
SwitchPreference(
|
||||
key = "revanced_hide_horizontal_shelves",
|
||||
tag = "app.revanced.extension.shared.settings.preference.BulletPointSwitchPreference"
|
||||
),
|
||||
SwitchPreference("revanced_hide_image_shelf"),
|
||||
SwitchPreference("revanced_hide_latest_posts"),
|
||||
SwitchPreference("revanced_hide_mix_playlists"),
|
||||
SwitchPreference("revanced_hide_movies_section"),
|
||||
SwitchPreference("revanced_hide_notify_me_button"),
|
||||
SwitchPreference("revanced_hide_playables"),
|
||||
SwitchPreference("revanced_hide_show_more_button"),
|
||||
SwitchPreference("revanced_hide_surveys"),
|
||||
SwitchPreference("revanced_hide_ticket_shelf"),
|
||||
SwitchPreference("revanced_hide_upload_time"),
|
||||
SwitchPreference("revanced_hide_video_recommendation_labels"),
|
||||
SwitchPreference("revanced_hide_view_count"),
|
||||
SwitchPreference("revanced_hide_visual_spacer"),
|
||||
SwitchPreference("revanced_hide_doodles"),
|
||||
)
|
||||
|
||||
PreferenceScreen.GENERAL_LAYOUT.addPreferences(
|
||||
PreferenceScreenPreference(
|
||||
key = "revanced_custom_filter_screen",
|
||||
sorting = PreferenceScreenPreference.Sorting.UNSORTED,
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_custom_filter"),
|
||||
TextPreference("revanced_custom_filter_strings", inputType = InputType.TEXT_MULTI_LINE),
|
||||
),
|
||||
),
|
||||
)
|
||||
// region Mix playlists
|
||||
|
||||
addLithoFilter(LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR)
|
||||
addLithoFilter(DESCRIPTION_COMPONENTS_FILTER_CLASS_NAME)
|
||||
addLithoFilter(COMMENTS_FILTER_CLASS_NAME)
|
||||
addLithoFilter(KEYWORD_FILTER_CLASS_NAME)
|
||||
addLithoFilter(CUSTOM_FILTER_CLASS_NAME)
|
||||
(if (is_20_09_or_greater) parseElementFromBufferFingerprint
|
||||
else if (is_20_07_or_greater) parseElementFromBufferLegacy2007Fingerprint
|
||||
else parseElementFromBufferLegacy1901Fingerprint).let {
|
||||
it.method.apply {
|
||||
val byteArrayParameter = "p3"
|
||||
val startIndex = it.patternMatch!!.startIndex
|
||||
val conversionContextRegister = getInstruction<TwoRegisterInstruction>(startIndex).registerA
|
||||
val returnEmptyComponentInstruction = instructions.last { it.opcode == Opcode.INVOKE_STATIC }
|
||||
val returnEmptyComponentRegister =
|
||||
(returnEmptyComponentInstruction as FiveRegisterInstruction).registerC
|
||||
val insertIndex = startIndex + 1
|
||||
val freeRegister =
|
||||
findFreeRegister(insertIndex, conversionContextRegister, returnEmptyComponentRegister)
|
||||
|
||||
// region Mix playlists
|
||||
|
||||
(if (is_20_09_or_greater) parseElementFromBufferFingerprint
|
||||
else if (is_20_07_or_greater) parseElementFromBufferLegacy2007Fingerprint
|
||||
else parseElementFromBufferLegacy1901Fingerprint).let {
|
||||
it.method.apply {
|
||||
val byteArrayParameter = "p3"
|
||||
val startIndex = it.patternMatch!!.startIndex
|
||||
val conversionContextRegister = getInstruction<TwoRegisterInstruction>(startIndex).registerA
|
||||
val returnEmptyComponentInstruction = instructions.last { it.opcode == Opcode.INVOKE_STATIC }
|
||||
val returnEmptyComponentRegister = (returnEmptyComponentInstruction as FiveRegisterInstruction).registerC
|
||||
val insertIndex = startIndex + 1
|
||||
val freeRegister = findFreeRegister(insertIndex, conversionContextRegister, returnEmptyComponentRegister)
|
||||
|
||||
addInstructionsWithLabels(
|
||||
insertIndex,
|
||||
"""
|
||||
addInstructionsWithLabels(
|
||||
insertIndex,
|
||||
"""
|
||||
invoke-static { v$conversionContextRegister, $byteArrayParameter }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->filterMixPlaylists(Ljava/lang/Object;[B)Z
|
||||
move-result v$freeRegister
|
||||
if-eqz v$freeRegister, :show
|
||||
@@ -294,193 +273,192 @@ val hideLayoutComponentsPatch = bytecodePatch(
|
||||
:show
|
||||
nop
|
||||
""",
|
||||
ExternalLabel("return_empty_component", returnEmptyComponentInstruction),
|
||||
)
|
||||
}
|
||||
ExternalLabel("return_empty_component", returnEmptyComponentInstruction),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
// endregion
|
||||
|
||||
// region Watermark (legacy code for old versions of YouTube)
|
||||
// region Watermark (legacy code for old versions of YouTube)
|
||||
|
||||
showWatermarkFingerprint.match(
|
||||
playerOverlayFingerprint.originalClassDef,
|
||||
).method.apply {
|
||||
val index = implementation!!.instructions.size - 5
|
||||
showWatermarkFingerprint.match(
|
||||
playerOverlayFingerprint.originalClassDef,
|
||||
).method.apply {
|
||||
val index = implementation!!.instructions.size - 5
|
||||
|
||||
removeInstruction(index)
|
||||
addInstructions(
|
||||
index,
|
||||
"""
|
||||
removeInstruction(index)
|
||||
addInstructions(
|
||||
index,
|
||||
"""
|
||||
invoke-static {}, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->showWatermark()Z
|
||||
move-result p2
|
||||
""",
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// endregion
|
||||
// endregion
|
||||
|
||||
// region Show more button
|
||||
// region Show more button
|
||||
|
||||
hideShowMoreButtonFingerprint.method.apply {
|
||||
val moveRegisterIndex = hideShowMoreButtonFingerprint.patternMatch!!.endIndex
|
||||
val viewRegister = getInstruction<OneRegisterInstruction>(moveRegisterIndex).registerA
|
||||
hideShowMoreButtonFingerprint.method.apply {
|
||||
val moveRegisterIndex = hideShowMoreButtonFingerprint.patternMatch!!.endIndex
|
||||
val viewRegister = getInstruction<OneRegisterInstruction>(moveRegisterIndex).registerA
|
||||
|
||||
val insertIndex = moveRegisterIndex + 1
|
||||
addInstruction(
|
||||
insertIndex,
|
||||
"invoke-static { v$viewRegister }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR" +
|
||||
"->hideShowMoreButton(Landroid/view/View;)V",
|
||||
)
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region crowdfunding box
|
||||
crowdfundingBoxFingerprint.let {
|
||||
it.method.apply {
|
||||
val insertIndex = it.patternMatch!!.endIndex
|
||||
val objectRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
val insertIndex = moveRegisterIndex + 1
|
||||
addInstruction(
|
||||
insertIndex,
|
||||
"invoke-static { v$viewRegister }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR" +
|
||||
"->hideShowMoreButton(Landroid/view/View;)V",
|
||||
"invoke-static {v$objectRegister}, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR" +
|
||||
"->hideCrowdfundingBox(Landroid/view/View;)V",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
// endregion
|
||||
|
||||
// region crowdfunding box
|
||||
crowdfundingBoxFingerprint.let {
|
||||
it.method.apply {
|
||||
val insertIndex = it.patternMatch!!.endIndex
|
||||
val objectRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
|
||||
// region hide album cards
|
||||
|
||||
addInstruction(
|
||||
insertIndex,
|
||||
"invoke-static {v$objectRegister}, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR" +
|
||||
"->hideCrowdfundingBox(Landroid/view/View;)V",
|
||||
)
|
||||
}
|
||||
}
|
||||
albumCardsFingerprint.let {
|
||||
it.method.apply {
|
||||
val checkCastAnchorIndex = it.patternMatch!!.endIndex
|
||||
val insertIndex = checkCastAnchorIndex + 1
|
||||
val register = getInstruction<OneRegisterInstruction>(checkCastAnchorIndex).registerA
|
||||
|
||||
// endregion
|
||||
|
||||
// region hide album cards
|
||||
|
||||
albumCardsFingerprint.let {
|
||||
it.method.apply {
|
||||
val checkCastAnchorIndex = it.patternMatch!!.endIndex
|
||||
val insertIndex = checkCastAnchorIndex + 1
|
||||
val register = getInstruction<OneRegisterInstruction>(checkCastAnchorIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
insertIndex,
|
||||
"invoke-static { v$register }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR" +
|
||||
addInstruction(
|
||||
insertIndex,
|
||||
"invoke-static { v$register }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR" +
|
||||
"->hideAlbumCard(Landroid/view/View;)V",
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
// endregion
|
||||
|
||||
// region hide floating microphone
|
||||
// region hide floating microphone
|
||||
|
||||
showFloatingMicrophoneButtonFingerprint.method.apply {
|
||||
val literalIndex = indexOfFirstLiteralInstructionOrThrow(fabButtonId)
|
||||
val booleanIndex = indexOfFirstInstructionOrThrow(literalIndex, Opcode.IGET_BOOLEAN)
|
||||
val register = getInstruction<TwoRegisterInstruction>(booleanIndex).registerA
|
||||
showFloatingMicrophoneButtonFingerprint.method.apply {
|
||||
val literalIndex = indexOfFirstLiteralInstructionOrThrow(fabButtonId)
|
||||
val booleanIndex = indexOfFirstInstructionOrThrow(literalIndex, Opcode.IGET_BOOLEAN)
|
||||
val register = getInstruction<TwoRegisterInstruction>(booleanIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
booleanIndex + 1,
|
||||
"""
|
||||
addInstructions(
|
||||
booleanIndex + 1,
|
||||
"""
|
||||
invoke-static { v$register }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->hideFloatingMicrophoneButton(Z)Z
|
||||
move-result v$register
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region 'Yoodles'
|
||||
|
||||
yoodlesImageViewFingerprint.method.apply {
|
||||
findInstructionIndicesReversedOrThrow {
|
||||
getReference<MethodReference>()?.name == "setImageDrawable"
|
||||
}.forEach { insertIndex ->
|
||||
val drawableRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerD
|
||||
val imageViewRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerC
|
||||
|
||||
replaceInstruction(
|
||||
insertIndex,
|
||||
"invoke-static { v$imageViewRegister, v$drawableRegister }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->" +
|
||||
"setDoodleDrawable(Landroid/widget/ImageView;Landroid/graphics/drawable/Drawable;)V"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
// endregion
|
||||
|
||||
// region 'Yoodles'
|
||||
|
||||
yoodlesImageViewFingerprint.method.apply {
|
||||
findInstructionIndicesReversedOrThrow {
|
||||
getReference<MethodReference>()?.name == "setImageDrawable"
|
||||
}.forEach { insertIndex ->
|
||||
val drawableRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerD
|
||||
val imageViewRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerC
|
||||
// region hide view count
|
||||
|
||||
replaceInstruction(
|
||||
insertIndex,
|
||||
"invoke-static { v$imageViewRegister, v$drawableRegister }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->" +
|
||||
"setDoodleDrawable(Landroid/widget/ImageView;Landroid/graphics/drawable/Drawable;)V"
|
||||
)
|
||||
}
|
||||
hideViewCountFingerprint.method.apply {
|
||||
val startIndex = hideViewCountFingerprint.patternMatch!!.startIndex
|
||||
var returnStringRegister = getInstruction<OneRegisterInstruction>(startIndex).registerA
|
||||
|
||||
// Find the instruction where the text dimension is retrieved.
|
||||
val applyDimensionIndex = indexOfFirstInstructionReversedOrThrow {
|
||||
val reference = getReference<MethodReference>()
|
||||
opcode == Opcode.INVOKE_STATIC &&
|
||||
reference?.definingClass == "Landroid/util/TypedValue;" &&
|
||||
reference.returnType == "F" &&
|
||||
reference.name == "applyDimension" &&
|
||||
reference.parameterTypes == listOf("I", "F", "Landroid/util/DisplayMetrics;")
|
||||
}
|
||||
|
||||
// endregion
|
||||
// A float value is passed which is used to determine subtitle text size.
|
||||
val floatDimensionRegister = getInstruction<OneRegisterInstruction>(
|
||||
applyDimensionIndex + 1
|
||||
).registerA
|
||||
|
||||
|
||||
// region hide view count
|
||||
|
||||
hideViewCountFingerprint.method.apply {
|
||||
val startIndex = hideViewCountFingerprint.patternMatch!!.startIndex
|
||||
var returnStringRegister = getInstruction<OneRegisterInstruction>(startIndex).registerA
|
||||
|
||||
// Find the instruction where the text dimension is retrieved.
|
||||
val applyDimensionIndex = indexOfFirstInstructionReversedOrThrow {
|
||||
val reference = getReference<MethodReference>()
|
||||
opcode == Opcode.INVOKE_STATIC &&
|
||||
reference?.definingClass == "Landroid/util/TypedValue;" &&
|
||||
reference.returnType == "F" &&
|
||||
reference.name == "applyDimension" &&
|
||||
reference.parameterTypes == listOf("I", "F", "Landroid/util/DisplayMetrics;")
|
||||
}
|
||||
|
||||
// A float value is passed which is used to determine subtitle text size.
|
||||
val floatDimensionRegister = getInstruction<OneRegisterInstruction>(
|
||||
applyDimensionIndex + 1
|
||||
).registerA
|
||||
|
||||
addInstructions(
|
||||
applyDimensionIndex - 1,
|
||||
"""
|
||||
addInstructions(
|
||||
applyDimensionIndex - 1,
|
||||
"""
|
||||
invoke-static { v$returnStringRegister, v$floatDimensionRegister }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->modifyFeedSubtitleSpan(Landroid/text/SpannableString;F)Landroid/text/SpannableString;
|
||||
move-result-object v$returnStringRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// endregion
|
||||
// endregion
|
||||
|
||||
// region hide filter bar
|
||||
// region hide filter bar
|
||||
|
||||
/**
|
||||
* Patch a [Method] with a given [instructions].
|
||||
*
|
||||
* @param RegisterInstruction The type of instruction to get the register from.
|
||||
* @param insertIndexOffset The offset to add to the end index of the [Match.patternMatch].
|
||||
* @param hookRegisterOffset The offset to add to the register of the hook.
|
||||
* @param instructions The instructions to add with the register as a parameter.
|
||||
*/
|
||||
fun <RegisterInstruction : OneRegisterInstruction> Fingerprint.patch(
|
||||
insertIndexOffset: Int = 0,
|
||||
hookRegisterOffset: Int = 0,
|
||||
instructions: (Int) -> String,
|
||||
) = method.apply {
|
||||
val endIndex = patternMatch!!.endIndex
|
||||
/**
|
||||
* Patch a [Method] with a given [instructions].
|
||||
*
|
||||
* @param RegisterInstruction The type of instruction to get the register from.
|
||||
* @param insertIndexOffset The offset to add to the end index of the [Match.patternMatch].
|
||||
* @param hookRegisterOffset The offset to add to the register of the hook.
|
||||
* @param instructions The instructions to add with the register as a parameter.
|
||||
*/
|
||||
fun <RegisterInstruction : OneRegisterInstruction> Fingerprint.patch(
|
||||
insertIndexOffset: Int = 0,
|
||||
hookRegisterOffset: Int = 0,
|
||||
instructions: (Int) -> String,
|
||||
) = method.apply {
|
||||
val endIndex = patternMatch!!.endIndex
|
||||
|
||||
val insertIndex = endIndex + insertIndexOffset
|
||||
val register =
|
||||
getInstruction<RegisterInstruction>(endIndex + hookRegisterOffset).registerA
|
||||
val insertIndex = endIndex + insertIndexOffset
|
||||
val register =
|
||||
getInstruction<RegisterInstruction>(endIndex + hookRegisterOffset).registerA
|
||||
|
||||
addInstructions(insertIndex, instructions(register))
|
||||
}
|
||||
addInstructions(insertIndex, instructions(register))
|
||||
}
|
||||
|
||||
filterBarHeightFingerprint.patch<TwoRegisterInstruction> { register ->
|
||||
"""
|
||||
filterBarHeightFingerprint.patch<TwoRegisterInstruction> { register ->
|
||||
"""
|
||||
invoke-static { v$register }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->hideInFeed(I)I
|
||||
move-result v$register
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
searchResultsChipBarFingerprint.patch<OneRegisterInstruction>(-1, -2) { register ->
|
||||
"""
|
||||
searchResultsChipBarFingerprint.patch<OneRegisterInstruction>(-1, -2) { register ->
|
||||
"""
|
||||
invoke-static { v$register }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->hideInSearch(I)I
|
||||
move-result v$register
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
relatedChipCloudFingerprint.patch<OneRegisterInstruction>(1) { register ->
|
||||
"invoke-static { v$register }, " +
|
||||
relatedChipCloudFingerprint.patch<OneRegisterInstruction>(1) { register ->
|
||||
"invoke-static { v$register }, " +
|
||||
"$LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->hideInRelatedVideos(Landroid/view/View;)V"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
|
||||
import app.revanced.patches.shared.misc.mapping.resourceMappings
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.youtube.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.shared.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.youtube.misc.litho.filter.lithoFilterPatch
|
||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
||||
|
||||
@@ -5,7 +5,7 @@ import app.revanced.patches.all.misc.resources.addResources
|
||||
import app.revanced.patches.all.misc.resources.addResourcesPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.shared.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.youtube.misc.litho.filter.lithoFilterPatch
|
||||
import app.revanced.patches.youtube.misc.playertype.playerTypeHookPatch
|
||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||
|
||||
@@ -14,7 +14,7 @@ import app.revanced.patches.shared.misc.mapping.resourceMappings
|
||||
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.youtube.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.shared.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.youtube.misc.litho.filter.lithoFilterPatch
|
||||
import app.revanced.patches.youtube.misc.navigation.navigationBarHookPatch
|
||||
import app.revanced.patches.youtube.misc.playservice.is_19_41_or_greater
|
||||
|
||||
@@ -11,7 +11,7 @@ import app.revanced.patches.shared.misc.settings.preference.PreferenceCategory
|
||||
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.youtube.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.shared.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.youtube.misc.litho.filter.lithoFilterPatch
|
||||
import app.revanced.patches.youtube.misc.playertype.playerTypeHookPatch
|
||||
import app.revanced.patches.youtube.misc.playservice.is_19_33_or_greater
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package app.revanced.patches.youtube.misc.audiofocus
|
||||
|
||||
import app.revanced.patcher.fingerprint
|
||||
|
||||
internal val audioFocusChangeListenerFingerprint = fingerprint {
|
||||
strings(
|
||||
"AudioFocus DUCK",
|
||||
"AudioFocus loss; Will lower volume",
|
||||
)
|
||||
}
|
||||
|
||||
internal val audioFocusRequestBuilderFingerprint = fingerprint {
|
||||
strings("Can't build an AudioFocusRequestCompat instance without a listener")
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package app.revanced.patches.youtube.misc.audiofocus
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.all.misc.resources.addResources
|
||||
import app.revanced.patches.all.misc.resources.addResourcesPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
||||
|
||||
private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/PauseOnAudioInterruptPatch;"
|
||||
|
||||
val pauseOnAudioInterruptPatch = bytecodePatch(
|
||||
name = "Pause on audio interrupt",
|
||||
description = "Adds an option to pause playback instead of lowering volume when other audio plays.",
|
||||
) {
|
||||
dependsOn(
|
||||
sharedExtensionPatch,
|
||||
settingsPatch,
|
||||
addResourcesPatch,
|
||||
)
|
||||
|
||||
compatibleWith(
|
||||
"com.google.android.youtube"(
|
||||
"20.14.43",
|
||||
)
|
||||
)
|
||||
|
||||
execute {
|
||||
addResources("youtube", "misc.audiofocus.pauseOnAudioInterruptPatch")
|
||||
|
||||
PreferenceScreen.MISC.addPreferences(
|
||||
SwitchPreference("revanced_pause_on_audio_interrupt"),
|
||||
)
|
||||
|
||||
// Hook the builder method that creates AudioFocusRequest.
|
||||
// At the start, set the willPauseWhenDucked field (b) to true if setting is enabled.
|
||||
val builderMethod = audioFocusRequestBuilderFingerprint.method
|
||||
val builderClass = builderMethod.definingClass
|
||||
|
||||
builderMethod.addInstructionsWithLabels(
|
||||
0,
|
||||
"""
|
||||
invoke-static {}, $EXTENSION_CLASS_DESCRIPTOR->shouldPauseOnAudioInterrupt()Z
|
||||
move-result v0
|
||||
if-eqz v0, :skip_override
|
||||
const/4 v0, 0x1
|
||||
iput-boolean v0, p0, $builderClass->b:Z
|
||||
""",
|
||||
ExternalLabel("skip_override", builderMethod.getInstruction(0)),
|
||||
)
|
||||
|
||||
// Also hook the audio focus change listener as a backup.
|
||||
audioFocusChangeListenerFingerprint.method.addInstructions(
|
||||
0,
|
||||
"""
|
||||
invoke-static { p1 }, $EXTENSION_CLASS_DESCRIPTOR->overrideAudioFocusChange(I)I
|
||||
move-result p1
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,33 +1,22 @@
|
||||
package app.revanced.patches.youtube.misc.debugging
|
||||
|
||||
import app.revanced.patches.all.misc.resources.addResources
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch;
|
||||
import app.revanced.patches.shared.misc.debugging.enableDebuggingPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
||||
|
||||
@Suppress("unused")
|
||||
val enableDebuggingPatch = enableDebuggingPatch(
|
||||
block = {
|
||||
dependsOn(
|
||||
sharedExtensionPatch,
|
||||
settingsPatch,
|
||||
sharedExtensionPatch = sharedExtensionPatch,
|
||||
settingsPatch = settingsPatch,
|
||||
compatibleWithPackages = arrayOf(
|
||||
"com.google.android.youtube" to setOf(
|
||||
"19.34.42",
|
||||
"20.07.39",
|
||||
"20.13.41",
|
||||
"20.14.43",
|
||||
)
|
||||
|
||||
compatibleWith(
|
||||
"com.google.android.youtube"(
|
||||
"19.34.42",
|
||||
"20.07.39",
|
||||
"20.13.41",
|
||||
"20.14.43",
|
||||
)
|
||||
)
|
||||
},
|
||||
executeBlock = {
|
||||
addResources("youtube", "misc.debugging.enableDebuggingPatch")
|
||||
},
|
||||
),
|
||||
hookStringFeatureFlag = true,
|
||||
preferenceScreen = PreferenceScreen.MISC,
|
||||
additionalDebugPreferences = listOf(SwitchPreference("revanced_debug_protobuffer"))
|
||||
)
|
||||
|
||||
@@ -1,58 +1,8 @@
|
||||
package app.revanced.patches.youtube.misc.litho.filter
|
||||
|
||||
import app.revanced.patcher.fingerprint
|
||||
import app.revanced.util.containsLiteralInstruction
|
||||
import app.revanced.util.literal
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
internal val componentContextParserFingerprint = fingerprint {
|
||||
strings("Number of bits must be positive")
|
||||
}
|
||||
|
||||
internal val componentCreateFingerprint = fingerprint {
|
||||
strings(
|
||||
"Element missing correct type extension",
|
||||
"Element missing type"
|
||||
)
|
||||
}
|
||||
|
||||
internal val lithoFilterFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.STATIC, AccessFlags.CONSTRUCTOR)
|
||||
custom { _, classDef ->
|
||||
classDef.endsWith("/LithoFilterPatch;")
|
||||
}
|
||||
}
|
||||
|
||||
internal val protobufBufferReferenceFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||
returns("V")
|
||||
parameters("I", "Ljava/nio/ByteBuffer;")
|
||||
opcodes(
|
||||
Opcode.IPUT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.SUB_INT_2ADDR,
|
||||
)
|
||||
}
|
||||
|
||||
internal val emptyComponentFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PRIVATE, AccessFlags.CONSTRUCTOR)
|
||||
parameters()
|
||||
strings("EmptyComponent")
|
||||
custom { _, classDef ->
|
||||
classDef.methods.filter { AccessFlags.STATIC.isSet(it.accessFlags) }.size == 1
|
||||
}
|
||||
}
|
||||
|
||||
internal val lithoThreadExecutorFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.CONSTRUCTOR)
|
||||
parameters("I", "I", "I")
|
||||
custom { method, classDef ->
|
||||
classDef.superclass == "Ljava/util/concurrent/ThreadPoolExecutor;" &&
|
||||
method.containsLiteralInstruction(1L) // 1L = default thread timeout.
|
||||
}
|
||||
}
|
||||
|
||||
internal val lithoComponentNameUpbFeatureFlagFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||
|
||||
@@ -3,225 +3,68 @@
|
||||
package app.revanced.patches.youtube.misc.litho.filter
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patcher.patch.BytecodePatchContext
|
||||
import app.revanced.patches.shared.misc.litho.filter.lithoFilterPatch
|
||||
import app.revanced.patches.youtube.misc.playservice.is_19_17_or_greater
|
||||
import app.revanced.patches.youtube.misc.playservice.is_19_25_or_greater
|
||||
import app.revanced.patches.youtube.misc.playservice.is_20_05_or_greater
|
||||
import app.revanced.patches.youtube.misc.playservice.versionCheckPatch
|
||||
import app.revanced.patches.youtube.shared.conversionContextFingerprintToString
|
||||
import app.revanced.util.addInstructionsAtControlFlowLabel
|
||||
import app.revanced.util.findFreeRegister
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
||||
|
||||
@Deprecated("Use the shared one instead", ReplaceWith("app.revanced.patches.shared.misc.litho.filter.addLithoFilter"))
|
||||
lateinit var addLithoFilter: (String) -> Unit
|
||||
private set
|
||||
|
||||
private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/components/LithoFilterPatch;"
|
||||
|
||||
val lithoFilterPatch = bytecodePatch(
|
||||
description = "Hooks the method which parses the bytes into a ComponentContext to filter components.",
|
||||
val lithoFilterPatch = lithoFilterPatch(
|
||||
componentCreateInsertionIndex = {
|
||||
if (is_19_17_or_greater) {
|
||||
indexOfFirstInstructionOrThrow(Opcode.RETURN_OBJECT)
|
||||
} else {
|
||||
// 19.16 clobbers p2 so must check at start of the method
|
||||
0
|
||||
}
|
||||
},
|
||||
conversionContextFingerprintToString = conversionContextFingerprintToString,
|
||||
executeBlock = BytecodePatchContext::executeBlock,
|
||||
) {
|
||||
dependsOn(
|
||||
sharedExtensionPatch,
|
||||
versionCheckPatch,
|
||||
)
|
||||
|
||||
var filterCount = 0
|
||||
|
||||
/**
|
||||
* The following patch inserts a hook into the method that parses the bytes into a ComponentContext.
|
||||
* This method contains a StringBuilder object that represents the pathBuilder of the component.
|
||||
* The pathBuilder is used to filter components by their path.
|
||||
*
|
||||
* Additionally, the method contains a reference to the component's identifier.
|
||||
* The identifier is used to filter components by their identifier.
|
||||
*
|
||||
* The protobuf buffer is passed along from a different injection point before the filtering occurs.
|
||||
* The buffer is a large byte array that represents the component tree.
|
||||
* This byte array is searched for strings that indicate the current component.
|
||||
*
|
||||
* All modifications done here must allow all the original code to still execute
|
||||
* even when filtering, otherwise memory leaks or poor app performance may occur.
|
||||
*
|
||||
* The following pseudocode shows how this patch works:
|
||||
*
|
||||
* class SomeOtherClass {
|
||||
* // Called before ComponentContextParser.parseComponent() method.
|
||||
* public void someOtherMethod(ByteBuffer byteBuffer) {
|
||||
* ExtensionClass.setProtoBuffer(byteBuffer); // Inserted by this patch.
|
||||
* ...
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* class CreateComponentClass {
|
||||
* public Component createComponent() {
|
||||
* ...
|
||||
*
|
||||
* if (extensionClass.shouldFilter(identifier, path)) { // Inserted by this patch.
|
||||
* return emptyComponent;
|
||||
* }
|
||||
* return originalUnpatchedComponent; // Original code.
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
execute {
|
||||
// Remove dummy filter from extenion static field
|
||||
// and add the filters included during patching.
|
||||
lithoFilterFingerprint.method.apply {
|
||||
removeInstructions(2, 4) // Remove dummy filter.
|
||||
|
||||
addLithoFilter = { classDescriptor ->
|
||||
addInstructions(
|
||||
2,
|
||||
"""
|
||||
new-instance v1, $classDescriptor
|
||||
invoke-direct { v1 }, $classDescriptor-><init>()V
|
||||
const/16 v2, ${filterCount++}
|
||||
aput-object v1, v0, v2
|
||||
""",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// region Pass the buffer into extension.
|
||||
|
||||
protobufBufferReferenceFingerprint.method.addInstruction(
|
||||
0,
|
||||
"invoke-static { p2 }, $EXTENSION_CLASS_DESCRIPTOR->setProtoBuffer(Ljava/nio/ByteBuffer;)V",
|
||||
)
|
||||
|
||||
// endregion
|
||||
|
||||
// region Hook the method that parses bytes into a ComponentContext.
|
||||
|
||||
// Allow the method to run to completion, and override the
|
||||
// return value with an empty component if it should be filtered.
|
||||
// It is important to allow the original code to always run to completion,
|
||||
// otherwise high memory usage and poor app performance can occur.
|
||||
|
||||
// Find the identifier/path fields of the conversion context.
|
||||
val conversionContextIdentifierField = componentContextParserFingerprint.let {
|
||||
// Identifier field is loaded just before the string declaration.
|
||||
val index = it.method.indexOfFirstInstructionReversedOrThrow(
|
||||
it.stringMatches!!.first().index
|
||||
) {
|
||||
val reference = getReference<FieldReference>()
|
||||
reference?.definingClass == conversionContextFingerprintToString.originalClassDef.type
|
||||
&& reference.type == "Ljava/lang/String;"
|
||||
}
|
||||
|
||||
it.method.getInstruction<ReferenceInstruction>(index).getReference<FieldReference>()!!
|
||||
}
|
||||
|
||||
val conversionContextPathBuilderField = conversionContextFingerprintToString.originalClassDef
|
||||
.fields.single { field -> field.type == "Ljava/lang/StringBuilder;" }
|
||||
|
||||
// Find class and methods to create an empty component.
|
||||
val builderMethodDescriptor = emptyComponentFingerprint.classDef.methods.single {
|
||||
// The only static method in the class.
|
||||
method -> AccessFlags.STATIC.isSet(method.accessFlags)
|
||||
}
|
||||
val emptyComponentField = classBy {
|
||||
// Only one field that matches.
|
||||
it.type == builderMethodDescriptor.returnType
|
||||
}!!.immutableClass.fields.single()
|
||||
|
||||
componentCreateFingerprint.method.apply {
|
||||
val insertIndex = if (is_19_17_or_greater) {
|
||||
indexOfFirstInstructionOrThrow(Opcode.RETURN_OBJECT)
|
||||
} else {
|
||||
// 19.16 clobbers p2 so must check at start of the method and not at the return index.
|
||||
0
|
||||
}
|
||||
|
||||
val freeRegister = findFreeRegister(insertIndex)
|
||||
val identifierRegister = findFreeRegister(insertIndex, freeRegister)
|
||||
val pathRegister = findFreeRegister(insertIndex, freeRegister, identifierRegister)
|
||||
|
||||
addInstructionsAtControlFlowLabel(
|
||||
insertIndex,
|
||||
"""
|
||||
move-object/from16 v$freeRegister, p2
|
||||
iget-object v$identifierRegister, v$freeRegister, $conversionContextIdentifierField
|
||||
iget-object v$pathRegister, v$freeRegister, $conversionContextPathBuilderField
|
||||
invoke-static { v$identifierRegister, v$pathRegister }, $EXTENSION_CLASS_DESCRIPTOR->isFiltered(Ljava/lang/String;Ljava/lang/StringBuilder;)Z
|
||||
move-result v$freeRegister
|
||||
if-eqz v$freeRegister, :unfiltered
|
||||
|
||||
# Return an empty component
|
||||
move-object/from16 v$freeRegister, p1
|
||||
invoke-static { v$freeRegister }, $builderMethodDescriptor
|
||||
move-result-object v$freeRegister
|
||||
iget-object v$freeRegister, v$freeRegister, $emptyComponentField
|
||||
return-object v$freeRegister
|
||||
|
||||
:unfiltered
|
||||
nop
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
|
||||
// region Change Litho thread executor to 1 thread to fix layout issue in unpatched YouTube.
|
||||
|
||||
lithoThreadExecutorFingerprint.method.addInstructions(
|
||||
0,
|
||||
"""
|
||||
invoke-static { p1 }, $EXTENSION_CLASS_DESCRIPTOR->getExecutorCorePoolSize(I)I
|
||||
move-result p1
|
||||
invoke-static { p2 }, $EXTENSION_CLASS_DESCRIPTOR->getExecutorMaxThreads(I)I
|
||||
move-result p2
|
||||
"""
|
||||
)
|
||||
|
||||
// endregion
|
||||
|
||||
|
||||
// region A/B test of new Litho native code.
|
||||
|
||||
// Turn off native code that handles litho component names. If this feature is on then nearly
|
||||
// all litho components have a null name and identifier/path filtering is completely broken.
|
||||
//
|
||||
// Flag was removed in 20.05. It appears a new flag might be used instead (45660109L),
|
||||
// but if the flag is forced on then litho filtering still works correctly.
|
||||
if (is_19_25_or_greater && !is_20_05_or_greater) {
|
||||
lithoComponentNameUpbFeatureFlagFingerprint.method.apply {
|
||||
// Don't use return early, so the debug patch logs if this was originally on.
|
||||
val insertIndex = indexOfFirstInstructionOrThrow(Opcode.RETURN)
|
||||
val register = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstruction(insertIndex, "const/4 v$register, 0x0")
|
||||
}
|
||||
}
|
||||
|
||||
// Turn off a feature flag that enables native code of protobuf parsing (Upb protobuf).
|
||||
// If this is enabled, then the litho protobuffer hook will always show an empty buffer
|
||||
// since it's no longer handled by the hooked Java code.
|
||||
lithoConverterBufferUpbFeatureFlagFingerprint.method.apply {
|
||||
val index = indexOfFirstInstructionOrThrow(Opcode.MOVE_RESULT)
|
||||
val register = getInstruction<OneRegisterInstruction>(index).registerA
|
||||
|
||||
addInstruction(index + 1, "const/4 v$register, 0x0")
|
||||
}
|
||||
|
||||
// endregion
|
||||
}
|
||||
|
||||
finalize {
|
||||
lithoFilterFingerprint.method.replaceInstruction(0, "const/16 v0, $filterCount")
|
||||
}
|
||||
dependsOn(versionCheckPatch)
|
||||
}
|
||||
|
||||
private fun BytecodePatchContext.executeBlock() {
|
||||
// region A/B test of new Litho native code.
|
||||
|
||||
// Turn off native code that handles litho component names. If this feature is on then nearly
|
||||
// all litho components have a null name and identifier/path filtering is completely broken.
|
||||
//
|
||||
// Flag was removed in 20.05. It appears a new flag might be used instead (45660109L),
|
||||
// but if the flag is forced on then litho filtering still works correctly.
|
||||
if (is_19_25_or_greater && !is_20_05_or_greater) {
|
||||
lithoComponentNameUpbFeatureFlagFingerprint.method.apply {
|
||||
// Don't use return early, so the debug patch logs if this was originally on.
|
||||
val insertIndex = indexOfFirstInstructionOrThrow(Opcode.RETURN)
|
||||
val register = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstruction(insertIndex, "const/4 v$register, 0x0")
|
||||
}
|
||||
}
|
||||
|
||||
// Turn off a feature flag that enables native code of protobuf parsing (Upb protobuf).
|
||||
// If this is enabled, then the litho protobuffer hook will always show an empty buffer
|
||||
// since it's no longer handled by the hooked Java code.
|
||||
lithoConverterBufferUpbFeatureFlagFingerprint.method.apply {
|
||||
val index = indexOfFirstInstructionOrThrow(Opcode.MOVE_RESULT)
|
||||
val register = getInstruction<OneRegisterInstruction>(index).registerA
|
||||
|
||||
addInstruction(index + 1, "const/4 v$register, 0x0")
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// Set the addLithoFilter function to the one from the shared patch.
|
||||
// This is done for backwards compatibility.
|
||||
addLithoFilter = app.revanced.patches.shared.misc.litho.filter.addLithoFilter
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
|
||||
import app.revanced.patches.shared.misc.mapping.resourceMappings
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.youtube.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.shared.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.youtube.misc.litho.filter.lithoFilterPatch
|
||||
import app.revanced.patches.youtube.misc.recyclerviewtree.hook.addRecyclerViewTreeHook
|
||||
import app.revanced.patches.youtube.misc.recyclerviewtree.hook.recyclerViewTreeHookPatch
|
||||
|
||||
@@ -18,7 +18,7 @@ import app.revanced.patches.shared.misc.settings.preference.InputType
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.TextPreference
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.youtube.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.shared.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.youtube.misc.litho.filter.lithoFilterPatch
|
||||
import app.revanced.patches.youtube.misc.playservice.is_19_25_or_greater
|
||||
import app.revanced.patches.youtube.misc.playservice.versionCheckPatch
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
package app.revanced.util
|
||||
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* Comments out the non-standard <app> and <patch> tags.
|
||||
*
|
||||
* Previously this was done on Crowdin after pushing.
|
||||
* But Crowdin preprocessing has randomly failed but still used the unmodified
|
||||
* strings.xml file, which effectively deletes all patch strings from Crowdin.
|
||||
*/
|
||||
internal fun main(args: Array<String>) {
|
||||
if (args.size != 2) {
|
||||
throw RuntimeException("Exactly two arguments are required: <input_file> <output_file>")
|
||||
}
|
||||
|
||||
val inputFilePath = args[0]
|
||||
val inputFile = File(inputFilePath)
|
||||
if (!inputFile.exists()) {
|
||||
throw RuntimeException(
|
||||
"Input file not found: $inputFilePath currentDirectory: " + File(".").canonicalPath
|
||||
)
|
||||
}
|
||||
|
||||
// Comment out the non-standard tags. Otherwise Crowdin interprets the file
|
||||
// not as Android but instead a generic xml file where strings are
|
||||
// identified by xml position and not key.
|
||||
val content = inputFile.readText()
|
||||
val tagRegex = """((<app\s+.*>)|(</app>)|(<patch\s+.*>)|(</patch>))""".toRegex()
|
||||
val modifiedContent = content.replace(tagRegex, """<!-- $1 -->""")
|
||||
|
||||
// Write modified content to the output file (creates file if it doesn't exist).
|
||||
val outputFilePath = args[1]
|
||||
val outputFile = File(outputFilePath)
|
||||
outputFile.parentFile?.mkdirs()
|
||||
outputFile.writeText(modifiedContent)
|
||||
|
||||
println("Preprocessed strings.xml to: $outputFilePath")
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<!--
|
||||
|
||||
All strings must have a unique path, even if the same string is declared in two different apps.
|
||||
@@ -229,6 +229,8 @@ Second \"item\" text"</string>
|
||||
</patch>
|
||||
<patch id="misc.loopvideo.button.loopVideoButtonPatch">
|
||||
</patch>
|
||||
<patch id="misc.audiofocus.pauseOnAudioInterruptPatch">
|
||||
</patch>
|
||||
<patch id="misc.dimensions.spoof.spoofDeviceDimensionsPatch">
|
||||
</patch>
|
||||
<patch id="misc.hapticfeedback.disableHapticFeedbackPatch">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<!--
|
||||
|
||||
All strings must have a unique path, even if the same string is declared in two different apps.
|
||||
@@ -229,6 +229,8 @@ Second \"item\" text"</string>
|
||||
</patch>
|
||||
<patch id="misc.loopvideo.button.loopVideoButtonPatch">
|
||||
</patch>
|
||||
<patch id="misc.audiofocus.pauseOnAudioInterruptPatch">
|
||||
</patch>
|
||||
<patch id="misc.dimensions.spoof.spoofDeviceDimensionsPatch">
|
||||
</patch>
|
||||
<patch id="misc.hapticfeedback.disableHapticFeedbackPatch">
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<!--
|
||||
|
||||
All strings must have a unique path, even if the same string is declared in two different apps.
|
||||
@@ -224,12 +224,14 @@ Second \"item\" text"</string>
|
||||
<!-- Translations of this should not be longer than the original English text, otherwise the text can be clipped and not entirely shown. -->
|
||||
</patch>
|
||||
<patch id="misc.announcements.announcementsPatch">
|
||||
<string name="revanced_announcements_dialog_dismiss">খাৰিজ কৰক</string>
|
||||
<string name="youtube.misc.announcements.announcementsPatch.revanced_announcements_dialog_dismiss">খাৰিজ কৰক</string>
|
||||
</patch>
|
||||
<patch id="misc.loopvideo.loopVideoPatch">
|
||||
</patch>
|
||||
<patch id="misc.loopvideo.button.loopVideoButtonPatch">
|
||||
</patch>
|
||||
<patch id="misc.audiofocus.pauseOnAudioInterruptPatch">
|
||||
</patch>
|
||||
<patch id="misc.dimensions.spoof.spoofDeviceDimensionsPatch">
|
||||
</patch>
|
||||
<patch id="misc.hapticfeedback.disableHapticFeedbackPatch">
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user