From f06e0801be0113cf80be0bd9d179942e3335d22c Mon Sep 17 00:00:00 2001 From: Max Baumann Date: Tue, 25 Jan 2022 16:25:56 +0100 Subject: [PATCH] auth seems to work, playback does not though --- mod/app/src/main/java/bttv/WatchParties.java | 33 ++----------------- .../src/main/java/bttv/api/WatchParties.java | 1 - ....auth.device.CompatibilityUtil.smali.patch | 12 +++++++ ...uth.device.appid.APIKeyDecoder.smali.patch | 18 ++++++++++ ...horization.AuthorizationHelper.smali.patch | 15 ++++++++- 5 files changed, 47 insertions(+), 32 deletions(-) create mode 100644 patches/watchparties/com.amazon.identity.auth.device.CompatibilityUtil.smali.patch diff --git a/mod/app/src/main/java/bttv/WatchParties.java b/mod/app/src/main/java/bttv/WatchParties.java index 37673496..138872d7 100644 --- a/mod/app/src/main/java/bttv/WatchParties.java +++ b/mod/app/src/main/java/bttv/WatchParties.java @@ -1,11 +1,8 @@ package bttv; -import android.annotation.SuppressLint; -import android.app.AlertDialog; import android.content.Context; import android.content.ContextWrapper; import android.content.pm.PackageManager; -import android.util.Log; public class WatchParties { public static class CustomContext extends ContextWrapper { @@ -18,34 +15,10 @@ public CustomContext(Context base) { public String getPackageName() { return "tv.twitch.android.app"; } - } - - private static boolean checkedBefore = false; - @SuppressLint("PackageManagerGetSignatures") - public static void checkIfTwitchInstalledOrNotifyUser(Context context) { - if (checkedBefore) return; - checkedBefore = true; - - PackageManager pm = context.getPackageManager(); - if (pm == null) { - Log.w("LBTTVWatchParties", "context.getPackageManager() returned null!! This will cause WatchParties not to work!"); - return; - } - try { - pm.getPackageInfo("tv.twitch.android.app", PackageManager.GET_SIGNATURES); - } catch (PackageManager.NameNotFoundException e) { - notifyUserAboutMissingTwitch(context); + @Override + public PackageManager getPackageManager() { + return super.getPackageManager(); } } - - private static void notifyUserAboutMissingTwitch(Context context) { - AlertDialog.Builder builder = new AlertDialog.Builder(context); - builder - .setTitle("bttv_android") - .setMessage(ResUtil.getLocaleString(context, "bttv_watchparty_twitch_missing")) - .setPositiveButton(ResUtil.getLocaleString(context, "ok_confirmation"), null) - .setCancelable(true); - builder.show(); - } } diff --git a/mod/app/src/main/java/bttv/api/WatchParties.java b/mod/app/src/main/java/bttv/api/WatchParties.java index eda939ae..544cb50b 100644 --- a/mod/app/src/main/java/bttv/api/WatchParties.java +++ b/mod/app/src/main/java/bttv/api/WatchParties.java @@ -8,7 +8,6 @@ public class WatchParties { public static Context wrap(Context context) { try { - bttv.WatchParties.checkIfTwitchInstalledOrNotifyUser(context); return new bttv.WatchParties.CustomContext(context); } catch (Throwable t) { Log.e(TAG, "wrap: ", t); diff --git a/patches/watchparties/com.amazon.identity.auth.device.CompatibilityUtil.smali.patch b/patches/watchparties/com.amazon.identity.auth.device.CompatibilityUtil.smali.patch new file mode 100644 index 00000000..df34e9d0 --- /dev/null +++ b/patches/watchparties/com.amazon.identity.auth.device.CompatibilityUtil.smali.patch @@ -0,0 +1,12 @@ +diff --git a/smali_classes3/com/amazon/identity/auth/device/CompatibilityUtil.smali b/smali_classes3/com/amazon/identity/auth/device/CompatibilityUtil.smali +--- a/smali_classes3/com/amazon/identity/auth/device/CompatibilityUtil.smali ++++ b/smali_classes3/com/amazon/identity/auth/device/CompatibilityUtil.smali +@@ -59,6 +59,8 @@ + .method static assertCorrectManifestIntegration(ZZ)V + .locals 0 + ++ goto :goto_1 # BTTV skip this ++ + if-eqz p0, :cond_1 + + if-nez p1, :cond_0 diff --git a/patches/watchparties/com.amazon.identity.auth.device.appid.APIKeyDecoder.smali.patch b/patches/watchparties/com.amazon.identity.auth.device.appid.APIKeyDecoder.smali.patch index 6a3f9a98..d4b8788e 100644 --- a/patches/watchparties/com.amazon.identity.auth.device.appid.APIKeyDecoder.smali.patch +++ b/patches/watchparties/com.amazon.identity.auth.device.appid.APIKeyDecoder.smali.patch @@ -12,3 +12,21 @@ diff --git a/smali_classes3/com/amazon/identity/auth/device/appid/APIKeyDecoder. .line 216 sget-object v0, Lcom/amazon/identity/auth/device/appid/APIKeyDecoder;->LOG_TAG:Ljava/lang/String; +@@ -732,8 +736,6 @@ + .line 232 + sget-object v2, Lcom/amazon/identity/auth/device/utils/HashAlgorithm;->MD5:Lcom/amazon/identity/auth/device/utils/HashAlgorithm; + +- invoke-static {v1, p0, v2, p2}, Lcom/amazon/identity/auth/device/appid/APIKeyDecoder;->verifySignature(Ljava/lang/String;Ljava/lang/String;Lcom/amazon/identity/auth/device/utils/HashAlgorithm;Landroid/content/Context;)V +- + :cond_2 + const-string v1, "appsigSha256" + +@@ -767,8 +769,6 @@ + .line 239 + sget-object v0, Lcom/amazon/identity/auth/device/utils/HashAlgorithm;->SHA_256:Lcom/amazon/identity/auth/device/utils/HashAlgorithm; + +- invoke-static {p1, p0, v0, p2}, Lcom/amazon/identity/auth/device/appid/APIKeyDecoder;->verifySignature(Ljava/lang/String;Ljava/lang/String;Lcom/amazon/identity/auth/device/utils/HashAlgorithm;Landroid/content/Context;)V +- + :cond_3 + return-void + diff --git a/patches/watchparties/com.amazon.identity.auth.device.authorization.AuthorizationHelper.smali.patch b/patches/watchparties/com.amazon.identity.auth.device.authorization.AuthorizationHelper.smali.patch index 10fbd64e..9690a4c8 100644 --- a/patches/watchparties/com.amazon.identity.auth.device.authorization.AuthorizationHelper.smali.patch +++ b/patches/watchparties/com.amazon.identity.auth.device.authorization.AuthorizationHelper.smali.patch @@ -1,7 +1,20 @@ diff --git a/smali_classes3/com/amazon/identity/auth/device/authorization/AuthorizationHelper.smali b/smali_classes3/com/amazon/identity/auth/device/authorization/AuthorizationHelper.smali --- a/smali_classes3/com/amazon/identity/auth/device/authorization/AuthorizationHelper.smali +++ b/smali_classes3/com/amazon/identity/auth/device/authorization/AuthorizationHelper.smali -@@ -1397,6 +1397,11 @@ +@@ -47,6 +47,12 @@ + .method private static getAppIdentifierBlob(Landroid/content/Context;Ljava/lang/String;)Ljava/lang/String; + .locals 8 + ++ # BTTV ++ # b64 of {"package":"tv.twitch.android.app","MD5":["551ae28730c6b69565c56ce7a42e582e"],"SHA-256":["1338f9b049893cc70b78432a177582f90bd4bc6296ea4ed35bcc7df59687ac53"]} ++ const-string v0, "eyJwYWNrYWdlIjoidHYudHdpdGNoLmFuZHJvaWQuYXBwIiwiTUQ1IjpbIjU1MWFlMjg3MzBjNmI2OTU2NWM1NmNlN2E0MmU1ODJlIl0sIlNIQS0yNTYiOlsiMTMzOGY5YjA0OTg5M2NjNzBiNzg0MzJhMTc3NTgyZjkwYmQ0YmM2Mjk2ZWE0ZWQzNWJjYzdkZjU5Njg3YWM1MyJdfQ==" ++ return-object v0 ++ # /BTTV ++ + .line 362 + new-instance v0, Lorg/json/JSONObject; + +@@ -1397,6 +1403,11 @@ move-object/from16 v2, p10