From 5adf8bdd67c67502f5bc2912247e1eb1cec8a33d Mon Sep 17 00:00:00 2001
From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com>
Date: Fri, 6 Sep 2024 04:55:33 -0400
Subject: [PATCH] fix(YouTube - Check environment patch): Allow adb installs
 even if patched more than 30 minutes ago

---
 .../shared/checks/CheckEnvironmentPatch.java  | 22 ++++++++++---------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/app/src/main/java/app/revanced/integrations/shared/checks/CheckEnvironmentPatch.java b/app/src/main/java/app/revanced/integrations/shared/checks/CheckEnvironmentPatch.java
index c75beb34f4..0aad321c20 100644
--- a/app/src/main/java/app/revanced/integrations/shared/checks/CheckEnvironmentPatch.java
+++ b/app/src/main/java/app/revanced/integrations/shared/checks/CheckEnvironmentPatch.java
@@ -188,7 +188,6 @@ private static class CheckIsNearPatchTime extends Check {
          */
         long durationBetweenPatchingAndInstallation;
 
-        @NonNull
         @Override
         protected Boolean check() {
             try {
@@ -214,7 +213,8 @@ protected Boolean check() {
             }
 
             // User installed more than 30 minutes after patching.
-            return false;
+            // Don't fail this, to allow adb install of older patched apps.
+            return null;
         }
 
         @Override
@@ -273,15 +273,17 @@ public static void check(Activity context) {
 
                 CheckIsNearPatchTime nearPatchTime = new CheckIsNearPatchTime();
                 Boolean timeCheckPassed = nearPatchTime.check();
-                if (timeCheckPassed && !DEBUG_ALWAYS_SHOW_CHECK_FAILED_DIALOG) {
-                    if (failedChecks.isEmpty()) {
-                        // Recently patched and installed. No further checks are needed.
-                        // Stopping here also prevents showing warnings if patching and installing with Termux.
-                        Check.disableForever();
-                        return;
+                if (timeCheckPassed != null) {
+                    if (timeCheckPassed && !DEBUG_ALWAYS_SHOW_CHECK_FAILED_DIALOG) {
+                        if (failedChecks.isEmpty()) {
+                            // Recently patched and installed. No further checks are needed.
+                            // Stopping here also prevents showing warnings if patching and installing with Termux.
+                            Check.disableForever();
+                            return;
+                        }
+                    } else {
+                        failedChecks.add(nearPatchTime);
                     }
-                } else {
-                    failedChecks.add(nearPatchTime);
                 }
 
                 CheckExpectedInstaller installerCheck = new CheckExpectedInstaller();