mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 13:47:42 +02:00
feat(Spoof streaming data): Disable PoToken service when is turned on
- Any app clients that use do not need the PoToken generated by DroidGuard - is fetched even when is turned on - DroidGuard VM tries to solve , but some functions are not fully implemented in DroidGuard, resulting in spam logs: https://github.com/microg/GmsCore/issues/2584
This commit is contained in:
@ -4,7 +4,6 @@ import static app.revanced.extension.shared.patches.PatchStatus.SpoofStreamingDa
|
||||
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Base64;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@ -35,9 +34,6 @@ public class SpoofStreamingDataPatch {
|
||||
private static final String UNREACHABLE_HOST_URI_STRING = "https://127.0.0.0";
|
||||
private static final Uri UNREACHABLE_HOST_URI = Uri.parse(UNREACHABLE_HOST_URI_STRING);
|
||||
|
||||
@NonNull
|
||||
private static volatile String droidGuardPoToken = "";
|
||||
|
||||
/**
|
||||
* Key: video id
|
||||
* Value: original video length [streamingData.formats.approxDurationMs]
|
||||
@ -111,6 +107,16 @@ public class SpoofStreamingDataPatch {
|
||||
return SPOOF_STREAMING_DATA;
|
||||
}
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
*/
|
||||
public static Object isSpoofingEnabled(Object original) {
|
||||
if (!SPOOF_STREAMING_DATA) {
|
||||
return original;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
* This method is only invoked when playing a livestream on an iOS client.
|
||||
@ -173,7 +179,7 @@ public class SpoofStreamingDataPatch {
|
||||
if (SPOOF_STREAMING_DATA_MUSIC) {
|
||||
try {
|
||||
if (requestHeader != null) {
|
||||
StreamingDataRequest.fetchRequest(videoId, requestHeader, VISITOR_DATA, PO_TOKEN, droidGuardPoToken);
|
||||
StreamingDataRequest.fetchRequest(videoId, requestHeader, VISITOR_DATA, PO_TOKEN);
|
||||
} else {
|
||||
Logger.printDebug(() -> "Ignoring request with no header.");
|
||||
}
|
||||
@ -212,7 +218,7 @@ public class SpoofStreamingDataPatch {
|
||||
return;
|
||||
}
|
||||
|
||||
StreamingDataRequest.fetchRequest(id, requestHeaders, VISITOR_DATA, PO_TOKEN, droidGuardPoToken);
|
||||
StreamingDataRequest.fetchRequest(id, requestHeaders, VISITOR_DATA, PO_TOKEN);
|
||||
} catch (Exception ex) {
|
||||
Logger.printException(() -> "fetchStreams failure", ex);
|
||||
}
|
||||
@ -335,17 +341,4 @@ public class SpoofStreamingDataPatch {
|
||||
|
||||
return videoFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
*/
|
||||
public static void setDroidGuardPoToken(byte[] bytes) {
|
||||
if (SPOOF_STREAMING_DATA && bytes.length > 20) {
|
||||
final String poToken = Base64.encodeToString(bytes, Base64.URL_SAFE);
|
||||
if (!droidGuardPoToken.equals(poToken)) {
|
||||
Logger.printDebug(() -> "New droidGuardPoToken loaded:\n" + poToken);
|
||||
droidGuardPoToken = poToken;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,8 +33,8 @@ import java.util.concurrent.TimeoutException
|
||||
* did use its own client streams.
|
||||
*/
|
||||
class StreamingDataRequest private constructor(
|
||||
videoId: String, playerHeaders: Map<String, String>, visitorId: String,
|
||||
botGuardPoToken: String, droidGuardPoToken: String
|
||||
videoId: String, playerHeaders: Map<String, String>,
|
||||
visitorId: String, botGuardPoToken: String
|
||||
) {
|
||||
private val videoId: String
|
||||
private val future: Future<ByteBuffer?>
|
||||
@ -47,8 +47,7 @@ class StreamingDataRequest private constructor(
|
||||
videoId,
|
||||
playerHeaders,
|
||||
visitorId,
|
||||
botGuardPoToken,
|
||||
droidGuardPoToken
|
||||
botGuardPoToken
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -136,8 +135,8 @@ class StreamingDataRequest private constructor(
|
||||
|
||||
@JvmStatic
|
||||
fun fetchRequest(
|
||||
videoId: String, fetchHeaders: Map<String, String>, visitorId: String,
|
||||
botGuardPoToken: String, droidGuardPoToken: String
|
||||
videoId: String, fetchHeaders: Map<String, String>,
|
||||
visitorId: String, botGuardPoToken: String
|
||||
) {
|
||||
// Always fetch, even if there is an existing request for the same video.
|
||||
cache[videoId] =
|
||||
@ -145,8 +144,7 @@ class StreamingDataRequest private constructor(
|
||||
videoId,
|
||||
fetchHeaders,
|
||||
visitorId,
|
||||
botGuardPoToken,
|
||||
droidGuardPoToken
|
||||
botGuardPoToken
|
||||
)
|
||||
}
|
||||
|
||||
@ -160,8 +158,11 @@ class StreamingDataRequest private constructor(
|
||||
}
|
||||
|
||||
private fun send(
|
||||
clientType: AppClient.ClientType, videoId: String, playerHeaders: Map<String, String>,
|
||||
visitorId: String, botGuardPoToken: String, droidGuardPoToken: String
|
||||
clientType: AppClient.ClientType,
|
||||
videoId: String,
|
||||
playerHeaders: Map<String, String>,
|
||||
visitorId: String,
|
||||
botGuardPoToken: String
|
||||
): HttpURLConnection? {
|
||||
Objects.requireNonNull(clientType)
|
||||
Objects.requireNonNull(videoId)
|
||||
@ -210,10 +211,7 @@ class StreamingDataRequest private constructor(
|
||||
visitorId = visitorId,
|
||||
setLocale = setLocale
|
||||
)
|
||||
if (droidGuardPoToken.isNotEmpty()) {
|
||||
Logger.printDebug { "Original poToken (droidGuardPoToken):\n$droidGuardPoToken" }
|
||||
}
|
||||
Logger.printDebug { "Replaced poToken (botGuardPoToken):\n$botGuardPoToken" }
|
||||
Logger.printDebug { "Set poToken (botGuardPoToken):\n$botGuardPoToken" }
|
||||
} else {
|
||||
requestBody =
|
||||
createApplicationRequestBody(
|
||||
@ -249,8 +247,8 @@ class StreamingDataRequest private constructor(
|
||||
}
|
||||
|
||||
private fun fetch(
|
||||
videoId: String, playerHeaders: Map<String, String>, visitorId: String,
|
||||
botGuardPoToken: String, droidGuardPoToken: String
|
||||
videoId: String, playerHeaders: Map<String, String>,
|
||||
visitorId: String, botGuardPoToken: String
|
||||
): ByteBuffer? {
|
||||
lastSpoofedClientType = null
|
||||
|
||||
@ -267,8 +265,7 @@ class StreamingDataRequest private constructor(
|
||||
videoId,
|
||||
playerHeaders,
|
||||
visitorId,
|
||||
botGuardPoToken,
|
||||
droidGuardPoToken
|
||||
botGuardPoToken
|
||||
)?.let { connection ->
|
||||
try {
|
||||
// gzip encoding doesn't response with content length (-1),
|
||||
|
Reference in New Issue
Block a user