mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-06-12 05:07:45 +02:00
feat(Spotify): Add limited support for version 8.6.98.900
(last version that supports Kenwood and Pioneer car stereos) (#4750)
This commit is contained in:

committed by
GitHub

parent
b91285ec20
commit
a3fde874af
@ -3,7 +3,6 @@ package app.revanced.extension.spotify.misc;
|
||||
import static java.lang.Boolean.FALSE;
|
||||
import static java.lang.Boolean.TRUE;
|
||||
|
||||
import com.spotify.remoteconfig.internal.AccountAttribute;
|
||||
import com.spotify.home.evopage.homeapi.proto.Section;
|
||||
|
||||
import java.util.List;
|
||||
@ -15,6 +14,25 @@ import app.revanced.extension.shared.Logger;
|
||||
@SuppressWarnings("unused")
|
||||
public final class UnlockPremiumPatch {
|
||||
|
||||
private static final String SPOTIFY_MAIN_ACTIVITY_LEGACY = "com.spotify.music.MainActivity";
|
||||
|
||||
/**
|
||||
* If the app target is 8.6.98.900.
|
||||
*/
|
||||
private static final boolean IS_SPOTIFY_LEGACY_APP_TARGET;
|
||||
|
||||
static {
|
||||
boolean legacy;
|
||||
try {
|
||||
Class.forName(SPOTIFY_MAIN_ACTIVITY_LEGACY);
|
||||
legacy = true;
|
||||
} catch (ClassNotFoundException ex) {
|
||||
legacy = false;
|
||||
}
|
||||
|
||||
IS_SPOTIFY_LEGACY_APP_TARGET = legacy;
|
||||
}
|
||||
|
||||
private static class OverrideAttribute {
|
||||
/**
|
||||
* Account attribute key.
|
||||
@ -55,8 +73,8 @@ public final class UnlockPremiumPatch {
|
||||
// Make sure playing songs is not disabled remotely and playlists show up.
|
||||
new OverrideAttribute("streaming", TRUE),
|
||||
// Allows adding songs to queue and removes the smart shuffle mode restriction,
|
||||
// allowing to pick any of the other modes.
|
||||
new OverrideAttribute("pick-and-shuffle", FALSE),
|
||||
// allowing to pick any of the other modes. Flag is not present in legacy app target.
|
||||
new OverrideAttribute("pick-and-shuffle", FALSE, !IS_SPOTIFY_LEGACY_APP_TARGET),
|
||||
// Disables shuffle-mode streaming-rule, which forces songs to be played shuffled
|
||||
// and breaks the player when other patches are applied.
|
||||
new OverrideAttribute("streaming-rules", ""),
|
||||
@ -78,7 +96,7 @@ public final class UnlockPremiumPatch {
|
||||
/**
|
||||
* Override attributes injection point.
|
||||
*/
|
||||
public static void overrideAttribute(Map<String, AccountAttribute> attributes) {
|
||||
public static void overrideAttribute(Map<String, /*AccountAttribute*/ Object> attributes) {
|
||||
try {
|
||||
for (var override : OVERRIDES) {
|
||||
var attribute = attributes.get(override.key);
|
||||
@ -87,7 +105,12 @@ public final class UnlockPremiumPatch {
|
||||
Logger.printException(() -> "'" + override.key + "' expected but not found");
|
||||
}
|
||||
} else {
|
||||
attribute.value_ = override.overrideValue;
|
||||
Object overrideValue = override.overrideValue;
|
||||
if (IS_SPOTIFY_LEGACY_APP_TARGET) {
|
||||
((com.spotify.useraccount.v1.AccountAttribute) attribute).value_ = overrideValue;
|
||||
} else {
|
||||
((com.spotify.remoteconfig.internal.AccountAttribute) attribute).value_ = overrideValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
@ -0,0 +1,8 @@
|
||||
package com.spotify.useraccount.v1;
|
||||
|
||||
/**
|
||||
* Used for target 8.6.98.900. Class is still present in newer app targets.
|
||||
*/
|
||||
public class AccountAttribute {
|
||||
public Object value_;
|
||||
}
|
Reference in New Issue
Block a user