Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
fix(YouTube - Check environment patch): Show if patched apk is too ol…
Browse files Browse the repository at this point in the history
…d, if the install source is not Manager or ADB
  • Loading branch information
LisoUseInAIKyrios committed Sep 6, 2024
1 parent dffe7f6 commit 18048f3
Showing 1 changed file with 26 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ private static class CheckIsNearPatchTime extends Check {
*/
long durationBetweenPatchingAndInstallation;

@NonNull
@Override
protected Boolean check() {
try {
Expand All @@ -213,8 +214,7 @@ protected Boolean check() {
}

// User installed more than 30 minutes after patching.
// Don't fail this, to allow adb install of older patched apps.
return null;
return false;
}

@Override
Expand Down Expand Up @@ -271,34 +271,33 @@ public static void check(Activity context) {
failedChecks.add(sameHardware);
}

CheckIsNearPatchTime nearPatchTime = new CheckIsNearPatchTime();
Boolean timeCheckPassed = nearPatchTime.check();
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);
}
}

CheckExpectedInstaller installerCheck = new CheckExpectedInstaller();
// If the installer package is Manager but this code is reached,
// that means it must not be the right Manager otherwise the hardware hash
// signatures would be present and this check would not have run.
final boolean isManagerInstall = installerCheck.installerFound == InstallationType.MANAGER;
if (!installerCheck.check() || isManagerInstall) {
failedChecks.add(installerCheck);

if (isManagerInstall) {
// If using Manager and reached here, then this must
// have been patched on a different device.
if (installerCheck.check() && !DEBUG_ALWAYS_SHOW_CHECK_FAILED_DIALOG) {
// If the installer package is Manager but this code is reached,
// that means it must not be the right Manager otherwise the hardware hash
// signatures would be present and this check would not have run.
if (installerCheck.installerFound == InstallationType.MANAGER) {
failedChecks.add(installerCheck);
// Also could not have been patched on this device.
failedChecks.add(sameHardware);
} else if (failedChecks.isEmpty()) {
// ADB install of CLI build. Allow even if patched a long time ago.
Check.disableForever();
return;
}
} else {
failedChecks.add(installerCheck);
}

CheckIsNearPatchTime nearPatchTime = new CheckIsNearPatchTime();
Boolean timeCheckPassed = nearPatchTime.check();
if (timeCheckPassed && !DEBUG_ALWAYS_SHOW_CHECK_FAILED_DIALOG) {
// Allow installing recently patched apks,
// even if the install source is not Manager or ADB.
Check.disableForever();
return;
} else {
failedChecks.add(nearPatchTime);
}

if (DEBUG_ALWAYS_SHOW_CHECK_FAILED_DIALOG) {
Expand All @@ -310,11 +309,6 @@ public static void check(Activity context) {
);
}

if (failedChecks.isEmpty()) {
Check.disableForever();
return;
}

//noinspection ComparatorCombinators
Collections.sort(failedChecks, (o1, o2) -> o1.uiSortingValue() - o2.uiSortingValue());

Expand Down

0 comments on commit 18048f3

Please sign in to comment.