Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watch Parties: Remove Twitch Dependency #388

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 3 additions & 30 deletions mod/app/src/main/java/bttv/WatchParties.java
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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();
}
}
1 change: 0 additions & 1 deletion mod/app/src/main/java/bttv/api/WatchParties.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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

Original file line number Diff line number Diff line change
@@ -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

Expand Down