fix(YouTube - Check environment patch): Show if patched apk is too old, if the install source is not Manager or ADB

This commit is contained in:
LisoUseInAIKyrios 2024-09-06 05:39:33 -04:00
parent dffe7f6c34
commit 18048f3324

View File

@ -188,6 +188,7 @@ public final class CheckEnvironmentPatch {
*/ */
long durationBetweenPatchingAndInstallation; long durationBetweenPatchingAndInstallation;
@NonNull
@Override @Override
protected Boolean check() { protected Boolean check() {
try { try {
@ -213,8 +214,7 @@ public final class CheckEnvironmentPatch {
} }
// User installed more than 30 minutes after patching. // User installed more than 30 minutes after patching.
// Don't fail this, to allow adb install of older patched apps. return false;
return null;
} }
@Override @Override
@ -271,34 +271,33 @@ public final class CheckEnvironmentPatch {
failedChecks.add(sameHardware); failedChecks.add(sameHardware);
} }
CheckIsNearPatchTime nearPatchTime = new CheckIsNearPatchTime(); CheckExpectedInstaller installerCheck = new CheckExpectedInstaller();
Boolean timeCheckPassed = nearPatchTime.check(); if (installerCheck.check() && !DEBUG_ALWAYS_SHOW_CHECK_FAILED_DIALOG) {
if (timeCheckPassed != null) { // If the installer package is Manager but this code is reached,
if (timeCheckPassed && !DEBUG_ALWAYS_SHOW_CHECK_FAILED_DIALOG) { // that means it must not be the right Manager otherwise the hardware hash
if (failedChecks.isEmpty()) { // signatures would be present and this check would not have run.
// Recently patched and installed. No further checks are needed. if (installerCheck.installerFound == InstallationType.MANAGER) {
// Stopping here also prevents showing warnings if patching and installing with Termux. failedChecks.add(installerCheck);
Check.disableForever(); // Also could not have been patched on this device.
return; failedChecks.add(sameHardware);
} } else if (failedChecks.isEmpty()) {
} else { // ADB install of CLI build. Allow even if patched a long time ago.
failedChecks.add(nearPatchTime); Check.disableForever();
return;
} }
} else {
failedChecks.add(installerCheck);
} }
CheckExpectedInstaller installerCheck = new CheckExpectedInstaller(); CheckIsNearPatchTime nearPatchTime = new CheckIsNearPatchTime();
// If the installer package is Manager but this code is reached, Boolean timeCheckPassed = nearPatchTime.check();
// that means it must not be the right Manager otherwise the hardware hash if (timeCheckPassed && !DEBUG_ALWAYS_SHOW_CHECK_FAILED_DIALOG) {
// signatures would be present and this check would not have run. // Allow installing recently patched apks,
final boolean isManagerInstall = installerCheck.installerFound == InstallationType.MANAGER; // even if the install source is not Manager or ADB.
if (!installerCheck.check() || isManagerInstall) { Check.disableForever();
failedChecks.add(installerCheck); return;
} else {
if (isManagerInstall) { failedChecks.add(nearPatchTime);
// If using Manager and reached here, then this must
// have been patched on a different device.
failedChecks.add(sameHardware);
}
} }
if (DEBUG_ALWAYS_SHOW_CHECK_FAILED_DIALOG) { if (DEBUG_ALWAYS_SHOW_CHECK_FAILED_DIALOG) {
@ -310,11 +309,6 @@ public final class CheckEnvironmentPatch {
); );
} }
if (failedChecks.isEmpty()) {
Check.disableForever();
return;
}
//noinspection ComparatorCombinators //noinspection ComparatorCombinators
Collections.sort(failedChecks, (o1, o2) -> o1.uiSortingValue() - o2.uiSortingValue()); Collections.sort(failedChecks, (o1, o2) -> o1.uiSortingValue() - o2.uiSortingValue());