From 92b7d69c6cca56a4a3488e44b41d94c9200c3a3b Mon Sep 17 00:00:00 2001 From: evermind Date: Tue, 6 Jun 2023 21:17:54 +0200 Subject: [PATCH] Revert "BraveNewPipe: handle alternative urls array into data.json to promote conscrypt build on Kitkat" This reverts commit e251e33a1e6ff04a08aec48326b45fdd1d4eefb0. -> we no longer support KitKat --- app/build.gradle | 1 - .../org/schabi/newpipe/NewVersionWorker.kt | 6 +- .../newpipe/brave/NewVersionHelper.java | 48 ---------------- .../newpipe/brave/NewVersionHelperTest.java | 56 ------------------- 4 files changed, 1 insertion(+), 110 deletions(-) delete mode 100644 app/src/main/java/org/schabi/newpipe/brave/NewVersionHelper.java delete mode 100644 app/src/test/java/org/schabi/newpipe/brave/NewVersionHelperTest.java diff --git a/app/build.gradle b/app/build.gradle index dc6f8929fe7..0e8c5a1079f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -323,7 +323,6 @@ dependencies { testImplementation 'junit:junit:4.13.2' testImplementation "org.mockito:mockito-core:${mockitoVersion}" testImplementation "org.mockito:mockito-inline:${mockitoVersion}" - testImplementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751' androidTestImplementation "androidx.test.ext:junit:1.1.3" androidTestImplementation "androidx.test:runner:1.4.0" diff --git a/app/src/main/java/org/schabi/newpipe/NewVersionWorker.kt b/app/src/main/java/org/schabi/newpipe/NewVersionWorker.kt index 0196a9dbbf3..0549aaf2a6f 100644 --- a/app/src/main/java/org/schabi/newpipe/NewVersionWorker.kt +++ b/app/src/main/java/org/schabi/newpipe/NewVersionWorker.kt @@ -17,7 +17,6 @@ import androidx.work.WorkerParameters import androidx.work.workDataOf import com.grack.nanojson.JsonParser import com.grack.nanojson.JsonParserException -import org.schabi.newpipe.brave.NewVersionHelper import org.schabi.newpipe.extractor.downloader.Response import org.schabi.newpipe.extractor.exceptions.ReCaptchaException import org.schabi.newpipe.util.PendingIntentCompat @@ -127,10 +126,7 @@ class NewVersionWorker( val versionName = githubStableObject.getString("version") val versionCode = githubStableObject.getInt("version_code") - var apkLocationUrl = githubStableObject.getString("apk") - apkLocationUrl = NewVersionHelper.getAlternativeUrlOnKitkat( - githubStableObject, apkLocationUrl - ) + val apkLocationUrl = githubStableObject.getString("apk") compareAppVersionAndShowNotification(versionName, apkLocationUrl, versionCode) } catch (e: JsonParserException) { // Most likely something is wrong in data received from NEWPIPE_API_URL. diff --git a/app/src/main/java/org/schabi/newpipe/brave/NewVersionHelper.java b/app/src/main/java/org/schabi/newpipe/brave/NewVersionHelper.java deleted file mode 100644 index 33b3982c6de..00000000000 --- a/app/src/main/java/org/schabi/newpipe/brave/NewVersionHelper.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.schabi.newpipe.brave; - -import android.os.Build; - -import com.grack.nanojson.JsonArray; -import com.grack.nanojson.JsonObject; - -public final class NewVersionHelper { - private NewVersionHelper() { } - - public static String checkForAlternativeApkUrl(final JsonObject githubStableObject, - final String apkLocationUrl) { - - if (githubStableObject.has("alternative_apks")) { - final JsonArray alternativeUrls = githubStableObject.getArray("alternative_apks"); - for (final Object object: alternativeUrls) { - final JsonObject alternativeUrlObject = (JsonObject) object; - - if (alternativeUrlObject.has("alternative") - && "conscrypt".equals(alternativeUrlObject.get("alternative"))) { - return alternativeUrlObject.getString("url"); - } - } - } - return apkLocationUrl; - } - - private static boolean isKitKat() { - return Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT; - } - - /** - * check if an alternative Url is given for KitKat users. If not return - * apkLocationUrl. - * - * @param githubStableObject - * @param apkLocationUrl - * @return returns url that points to the best release for this device - */ - public static String getAlternativeUrlOnKitkat(final JsonObject githubStableObject, - final String apkLocationUrl) { - if (isKitKat()) { - return checkForAlternativeApkUrl(githubStableObject, apkLocationUrl); - } else { - return apkLocationUrl; - } - } -} diff --git a/app/src/test/java/org/schabi/newpipe/brave/NewVersionHelperTest.java b/app/src/test/java/org/schabi/newpipe/brave/NewVersionHelperTest.java deleted file mode 100644 index 1607c714ecf..00000000000 --- a/app/src/test/java/org/schabi/newpipe/brave/NewVersionHelperTest.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.schabi.newpipe.brave; - -import com.grack.nanojson.JsonObject; -import com.grack.nanojson.JsonParser; -import com.grack.nanojson.JsonParserException; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - - -public class NewVersionHelperTest { - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @SuppressWarnings({"checkstyle:LineLength", "checkstyle:MethodName"}) - @Test - public void checkJsonConfigWith_alternative_apks() throws JsonParserException { - final String stdUrl = "stdUrl"; - final String expectedAltUrl = "altUrl"; - - final String altConfig = "{\"flavors\":{\"github\":{\"stable\":{\"apk\":\"" + stdUrl + "\"," - + "\"alternative_apks\":[{\"alternative\":\"conscrypt\",\"url\":\"" + expectedAltUrl + "\"}]," - + "\"version\":\"1\",\"version_code\":1}}}}"; - - final JsonObject obj = JsonParser.object().from(altConfig).getObject("flavors") - .getObject("github").getObject("stable"); - final String result = NewVersionHelper.checkForAlternativeApkUrl(obj, stdUrl); - - assertEquals(expectedAltUrl, result); - } - - @SuppressWarnings({"checkstyle:LineLength", "checkstyle:MethodName"}) - @Test - public void checkJsonConfigWithout_alternative_apks() throws JsonParserException { - final String stdUrl = "stdUrl"; - final String expectedStdUrl = stdUrl; - - final String altConfig = "{\"flavors\":{\"github\":{\"stable\":{\"apk\":\"" + stdUrl + "\"," - + "\"version\":\"1\",\"version_code\":1}}}}"; - - final JsonObject obj = JsonParser.object().from(altConfig).getObject("flavors") - .getObject("github").getObject("stable"); - final String result = NewVersionHelper.checkForAlternativeApkUrl(obj, stdUrl); - - assertEquals(expectedStdUrl, result); - } -}