generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
261 changed files
with
24,801 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
extensions/remove-screen-capture-restriction/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
extension { | ||
name = "extensions/all/screencapture/remove-screen-capture-restriction.rve" | ||
} | ||
|
||
android { | ||
namespace = "app.revanced.extension" | ||
} | ||
|
||
dependencies { | ||
compileOnly(libs.annotation) | ||
} |
1 change: 1 addition & 0 deletions
1
extensions/remove-screen-capture-restriction/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<manifest/> |
21 changes: 21 additions & 0 deletions
21
...ed/extension/all/screencapture/removerestriction/RemoveScreencaptureRestrictionPatch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package app.revanced.extension.all.screencapture.removerestriction; | ||
|
||
import android.media.AudioAttributes; | ||
import android.os.Build; | ||
|
||
import androidx.annotation.RequiresApi; | ||
|
||
public final class RemoveScreencaptureRestrictionPatch { | ||
// Member of AudioAttributes.Builder | ||
@RequiresApi(api = Build.VERSION_CODES.Q) | ||
public static AudioAttributes.Builder setAllowedCapturePolicy(final AudioAttributes.Builder builder, final int capturePolicy) { | ||
builder.setAllowedCapturePolicy(AudioAttributes.ALLOW_CAPTURE_BY_ALL); | ||
|
||
return builder; | ||
} | ||
|
||
// Member of AudioManager static class | ||
public static void setAllowedCapturePolicy(final int capturePolicy) { | ||
// Ignore request | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
extension { | ||
name = "extensions/all/screenshot/remove-screenshot-restriction.rve" | ||
} | ||
|
||
android { | ||
namespace = "app.revanced.extension" | ||
} |
1 change: 1 addition & 0 deletions
1
extensions/remove-screenshot-restriction/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<manifest/> |
15 changes: 15 additions & 0 deletions
15
...revanced/extension/all/screenshot/removerestriction/RemoveScreenshotRestrictionPatch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package app.revanced.extension.all.screenshot.removerestriction; | ||
|
||
import android.view.Window; | ||
import android.view.WindowManager; | ||
|
||
public class RemoveScreenshotRestrictionPatch { | ||
|
||
public static void addFlags(Window window, int flags) { | ||
window.addFlags(flags & ~WindowManager.LayoutParams.FLAG_SECURE); | ||
} | ||
|
||
public static void setFlags(Window window, int flags, int mask) { | ||
window.setFlags(flags & ~WindowManager.LayoutParams.FLAG_SECURE, mask & ~WindowManager.LayoutParams.FLAG_SECURE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
extension { | ||
name = "extensions/shared.rve" | ||
} | ||
|
||
android { | ||
namespace = "app.revanced.extension" | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = true | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compileOnly(libs.appcompat) | ||
compileOnly(libs.annotation) | ||
compileOnly(libs.okhttp) | ||
compileOnly(libs.retrofit) | ||
|
||
compileOnly(project(":extensions:shared:stub")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
-dontobfuscate | ||
-dontoptimize | ||
-keepattributes * | ||
-keep class app.revanced.** { | ||
*; | ||
} | ||
-keep class com.google.** { | ||
*; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" /> | ||
</manifest> |
24 changes: 24 additions & 0 deletions
24
extensions/shared/src/main/java/app/revanced/extension/boostforreddit/FixSLinksPatch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package app.revanced.extension.boostforreddit; | ||
|
||
import com.rubenmayayo.reddit.ui.activities.WebViewActivity; | ||
|
||
import app.revanced.extension.shared.fixes.slink.BaseFixSLinksPatch; | ||
|
||
/** @noinspection unused*/ | ||
public class FixSLinksPatch extends BaseFixSLinksPatch { | ||
static { | ||
INSTANCE = new FixSLinksPatch(); | ||
} | ||
|
||
private FixSLinksPatch() { | ||
webViewActivityClass = WebViewActivity.class; | ||
} | ||
|
||
public static boolean patchResolveSLink(String link) { | ||
return INSTANCE.resolveSLink(link); | ||
} | ||
|
||
public static void patchSetAccessToken(String accessToken) { | ||
INSTANCE.setAccessToken(accessToken); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
.../shared/src/main/java/app/revanced/extension/reddit/patches/FilterPromotedLinksPatch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package app.revanced.extension.reddit.patches; | ||
|
||
import com.reddit.domain.model.ILink; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public final class FilterPromotedLinksPatch { | ||
/** | ||
* Filters list from promoted links. | ||
**/ | ||
public static List<?> filterChildren(final Iterable<?> links) { | ||
final List<Object> filteredList = new ArrayList<>(); | ||
|
||
for (Object item : links) { | ||
if (item instanceof ILink && ((ILink) item).getPromoted()) continue; | ||
|
||
filteredList.add(item); | ||
} | ||
|
||
return filteredList; | ||
} | ||
} |
158 changes: 158 additions & 0 deletions
158
extensions/shared/src/main/java/app/revanced/extension/shared/GmsCoreSupport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
package app.revanced.extension.shared; | ||
|
||
import static app.revanced.extension.shared.StringRef.str; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.app.Activity; | ||
import android.app.AlertDialog; | ||
import android.app.SearchManager; | ||
import android.content.Context; | ||
import android.content.DialogInterface; | ||
import android.content.Intent; | ||
import android.content.pm.PackageManager; | ||
import android.net.Uri; | ||
import android.os.Build; | ||
import android.os.PowerManager; | ||
import android.provider.Settings; | ||
|
||
import androidx.annotation.RequiresApi; | ||
|
||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
|
||
/** | ||
* @noinspection unused | ||
*/ | ||
public class GmsCoreSupport { | ||
public static final String ORIGINAL_UNPATCHED_PACKAGE_NAME = "com.google.android.youtube"; | ||
private static final String GMS_CORE_PACKAGE_NAME | ||
= getGmsCoreVendorGroupId() + ".android.gms"; | ||
private static final Uri GMS_CORE_PROVIDER | ||
= Uri.parse("content://" + getGmsCoreVendorGroupId() + ".android.gsf.gservices/prefix"); | ||
private static final String DONT_KILL_MY_APP_LINK | ||
= "https://dontkillmyapp.com"; | ||
|
||
private static void open(String queryOrLink) { | ||
Intent intent; | ||
try { | ||
// Check if queryOrLink is a valid URL. | ||
new URL(queryOrLink); | ||
|
||
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(queryOrLink)); | ||
} catch (MalformedURLException e) { | ||
intent = new Intent(Intent.ACTION_WEB_SEARCH); | ||
intent.putExtra(SearchManager.QUERY, queryOrLink); | ||
} | ||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
Utils.getContext().startActivity(intent); | ||
|
||
// Gracefully exit, otherwise the broken app will continue to run. | ||
System.exit(0); | ||
} | ||
|
||
private static void showBatteryOptimizationDialog(Activity context, | ||
String dialogMessageRef, | ||
String positiveButtonStringRef, | ||
DialogInterface.OnClickListener onPositiveClickListener) { | ||
// Do not set cancelable to false, to allow using back button to skip the action, | ||
// just in case the check can never be satisfied. | ||
var dialog = new AlertDialog.Builder(context) | ||
.setIconAttribute(android.R.attr.alertDialogIcon) | ||
.setTitle(str("gms_core_dialog_title")) | ||
.setMessage(str(dialogMessageRef)) | ||
.setPositiveButton(str(positiveButtonStringRef), onPositiveClickListener) | ||
.create(); | ||
Utils.showDialog(context, dialog); | ||
} | ||
|
||
/** | ||
* Injection point. | ||
*/ | ||
@RequiresApi(api = Build.VERSION_CODES.N) | ||
public static void checkGmsCore(Activity context) { | ||
try { | ||
// Verify the user has not included GmsCore for a root installation. | ||
// GmsCore Support changes the package name, but with a mounted installation | ||
// all manifest changes are ignored and the original package name is used. | ||
if (context.getPackageName().equals(ORIGINAL_UNPATCHED_PACKAGE_NAME)) { | ||
Logger.printInfo(() -> "App is mounted with root, but GmsCore patch was included"); | ||
// Cannot use localize text here, since the app will load | ||
// resources from the unpatched app and all patch strings are missing. | ||
Utils.showToastLong("The 'GmsCore support' patch breaks mount installations"); | ||
|
||
// Do not exit. If the app exits before launch completes (and without | ||
// opening another activity), then on some devices such as Pixel phone Android 10 | ||
// no toast will be shown and the app will continually be relaunched | ||
// with the appearance of a hung app. | ||
} | ||
|
||
// Verify GmsCore is installed. | ||
try { | ||
PackageManager manager = context.getPackageManager(); | ||
manager.getPackageInfo(GMS_CORE_PACKAGE_NAME, PackageManager.GET_ACTIVITIES); | ||
} catch (PackageManager.NameNotFoundException exception) { | ||
Logger.printInfo(() -> "GmsCore was not found"); | ||
// Cannot show a dialog and must show a toast, | ||
// because on some installations the app crashes before a dialog can be displayed. | ||
Utils.showToastLong(str("gms_core_toast_not_installed_message")); | ||
open(getGmsCoreDownload()); | ||
return; | ||
} | ||
|
||
// Check if GmsCore is running in the background. | ||
try (var client = context.getContentResolver().acquireContentProviderClient(GMS_CORE_PROVIDER)) { | ||
if (client == null) { | ||
Logger.printInfo(() -> "GmsCore is not running in the background"); | ||
|
||
showBatteryOptimizationDialog(context, | ||
"gms_core_dialog_not_whitelisted_not_allowed_in_background_message", | ||
"gms_core_dialog_open_website_text", | ||
(dialog, id) -> open(DONT_KILL_MY_APP_LINK)); | ||
return; | ||
} | ||
} | ||
|
||
// Check if GmsCore is whitelisted from battery optimizations. | ||
if (batteryOptimizationsEnabled(context)) { | ||
Logger.printInfo(() -> "GmsCore is not whitelisted from battery optimizations"); | ||
showBatteryOptimizationDialog(context, | ||
"gms_core_dialog_not_whitelisted_using_battery_optimizations_message", | ||
"gms_core_dialog_continue_text", | ||
(dialog, id) -> openGmsCoreDisableBatteryOptimizationsIntent(context)); | ||
} | ||
} catch (Exception ex) { | ||
Logger.printException(() -> "checkGmsCore failure", ex); | ||
} | ||
} | ||
|
||
@SuppressLint("BatteryLife") // Permission is part of GmsCore | ||
private static void openGmsCoreDisableBatteryOptimizationsIntent(Activity activity) { | ||
Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); | ||
intent.setData(Uri.fromParts("package", GMS_CORE_PACKAGE_NAME, null)); | ||
activity.startActivityForResult(intent, 0); | ||
} | ||
|
||
/** | ||
* @return If GmsCore is not whitelisted from battery optimizations. | ||
*/ | ||
private static boolean batteryOptimizationsEnabled(Context context) { | ||
var powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); | ||
return !powerManager.isIgnoringBatteryOptimizations(GMS_CORE_PACKAGE_NAME); | ||
} | ||
|
||
private static String getGmsCoreDownload() { | ||
final var vendorGroupId = getGmsCoreVendorGroupId(); | ||
//noinspection SwitchStatementWithTooFewBranches | ||
switch (vendorGroupId) { | ||
case "app.revanced": | ||
return "https://github.com/revanced/gmscore/releases/latest"; | ||
default: | ||
return vendorGroupId + ".android.gms"; | ||
} | ||
} | ||
|
||
// Modified by a patch. Do not touch. | ||
private static String getGmsCoreVendorGroupId() { | ||
return "app.revanced"; | ||
} | ||
} |
Oops, something went wrong.