Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,731,947 Members 40,777 Now Online
XDA Developers Android and Mobile Development Forum

[HELP] Forcing Spotify to tablet mode ( Smali patch version )

Tip us?
 
steebro
Old
(Last edited by steebro; 3rd March 2014 at 01:50 PM.)
#1  
Member - OP
Thanks Meter 3
Posts: 41
Join Date: Jan 2013
Default [HELP] Forcing Spotify to tablet mode ( Smali patch version )

Spent last two days trying to edit .smali files in Spotify to force it to tablet mode without any luck. I know there's Xposed module for this but I'd like to achieve the same by edit .smali files, this way no root required and ART compatible, i know many user will appreciate this.


findings so far ( thanks to Xposed module creator @JsChiSurf too ):
Quote:
  • spotify uses getDisplayMetrics() to get pixel height/width/xdpi
  • spotify uses pythagoras to get screen diagonal size
  • spotify reads manufacteur/brand/device type/device id

functions it uses to achieve this are located in com\spotify\mobile\android\util\ab.smali, just did a whole decompiled apk search with jd-gui for "getDisplayMetrics" and this is the only place it access height/width

this is how it looks:
Code:
public static ac h()
  {
    return new ac(Build.MODEL, Build.MODEL, Build.BRAND, Build.MANUFACTURER);
  }
  
  public final double b()
  {
    DisplayMetrics localDisplayMetrics = this.a.getResources().getDisplayMetrics();
    return Math.sqrt(Math.pow(localDisplayMetrics.widthPixels / localDisplayMetrics.xdpi, 2.0D) + Math.pow(localDisplayMetrics.heightPixels / localDisplayMetrics.ydpi, 2.0D));
  }

public final String g()
  {
    return ((TelephonyManager)this.a.getSystemService("phone")).getDeviceId();
  }
now dalvik opcodes:
Code:
# virtual methods
.method public final b()D
    .locals 7

    .prologue
    const-wide/high16 v5, 0x4000

    .line 44
    iget-object v0, p0, Lcom/spotify/mobile/android/util/ab;->a:Landroid/content/Context;

    invoke-virtual {v0}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v0

    invoke-virtual {v0}, Landroid/content/res/Resources;->getDisplayMetrics()Landroid/util/DisplayMetrics;

    move-result-object v0

    .line 45
    iget v1, v0, Landroid/util/DisplayMetrics;->widthPixels:I

    int-to-float v1, v1

    iget v2, v0, Landroid/util/DisplayMetrics;->xdpi:F

    div-float/2addr v1, v2

    float-to-double v1, v1

    invoke-static {v1, v2, v5, v6}, Ljava/lang/Math;->pow(DD)D

    move-result-wide v1

    iget v3, v0, Landroid/util/DisplayMetrics;->heightPixels:I

    int-to-float v3, v3

    iget v0, v0, Landroid/util/DisplayMetrics;->ydpi:F

    div-float v0, v3, v0

    float-to-double v3, v0

    invoke-static {v3, v4, v5, v6}, Ljava/lang/Math;->pow(DD)D

    move-result-wide v3

    add-double v0, v1, v3

    invoke-static {v0, v1}, Ljava/lang/Math;->sqrt(D)D

    move-result-wide v0

    return-wide v0
.end method

what I've tried so far:
Quote:
  • placing some "mul-double v0, v0, v0" before return-wide v0 -> my idea was to mul return value to have a bigger screen diagonal
  • removing sqrt call
  • returning custom values using const opcode
everytime im installing modded apk in bluestacks, nothing changed i can only play shuffle mode aka mobile mode.


my environment:
  • Bluestacks to test app -> I set its screen size to 100*100 this way spotify starts in mobile phone mode and i can test
  • Virtuous Ten Studio to edit spotify apk -> when creating new project DESELECT disassemble resources otherwise when compiling it will fail

to set bluestacks screen size to trigger mobile mode : StacksTweak



Can anyone more experienced contribute/help me? This way user that dont want roor/use ART can use spotify forced in tablet mode
Samsung Galaxy S3
Latest OmniROM with stock omni kernel
Only root and no Xposed framework
All stock
 
steebro
Old
(Last edited by steebro; 3rd March 2014 at 03:31 PM.)
#2  
Member - OP
Thanks Meter 3
Posts: 41
Join Date: Jan 2013
no one?


edit: search in com\spotify\mobile\android for keywords like "screen_size" and "layout_as_tablet" some lines above ther's the call to phytagoras function i described before. File im talking about is MainActivity.smali in com\spotify\mobile\android\ui\activityl folder. Event forcing the check to return true aka im in tablet mode doesnt work


Can some dev explain this?
Samsung Galaxy S3
Latest OmniROM with stock omni kernel
Only root and no Xposed framework
All stock
 
Hirishiolo
Old
#3  
Hirishiolo's Avatar
Senior Member
Thanks Meter 26
Posts: 219
Join Date: Jun 2012
very nice idea, I'm interested in it too... does someone know how to do?
SAMSUNG GALAXY S PLUS (GT-i9001)
ROM: CyanogenMod 11 [ADC Team] - Release 9
KERNEL: K^Kernel 3.4.96 v2.5
GOVERNOR CPU: SmartassV2 (245 - 1401 MHz)
SCHEDULER I/O: Sio
BASEBAND: I9001BUKP7
 
halfdead1993
Old
#4  
Junior Member
Thanks Meter 0
Posts: 4
Join Date: Feb 2012
What the diffrence between the tablet and phone gui of spotify if you guys don't mind me asking..?
 
steebro
Old
#5  
Member - OP
Thanks Meter 3
Posts: 41
Join Date: Jan 2013
I found where it calculates Pythagoras to grab screen diagonal and tried to patch apk then rebuilt it. BTW it doesn't seem to affect apk when executed, so maybe im rebuilding/patching in the wrong way, that's why I posted. Maybe some dev can explain why it doesn't work when executed.
I think it's the right place to patch since it's clearly calculating screen diagonal


With tablet mode you can select which song you want to play, with phone mode only shuffle is enabled, both gui are the same
Samsung Galaxy S3
Latest OmniROM with stock omni kernel
Only root and no Xposed framework
All stock
 
fudduf
Old
#6  
Member
Thanks Meter 9
Posts: 65
Join Date: Jul 2010
I would LOVE a working forced-tablet apk! I have a 9.7" no-name tablet which only runs Spotify in mobile mode. I cannot use the Xposed module because it has not been backported to Gingerbread (Xposed - yes, the module - no).

Spotify never responded to my support ticket, so I would have no guilt using a tweaked app to force tablet mode on my....tablet!
 
steebro
Old
#7  
Member - OP
Thanks Meter 3
Posts: 41
Join Date: Jan 2013
Quote:
Originally Posted by fudduf View Post
I would LOVE a working forced-tablet apk! I have a 9.7" no-name tablet which only runs Spotify in mobile mode. I cannot use the Xposed module because it has not been backported to Gingerbread (Xposed - yes, the module - no).

Spotify never responded to my support ticket, so I would have no guilt using a tweaked app to force tablet mode on my....tablet!
that's why i'd like to patch apk, Xposed is a general way, not specific to Spotify and it requires root, many users dont want it. I think patching apk is the best solution for this problem, as i stated before, i found where patch it's needed, now some devs should help us, but i think they're too busy as none of them replied, maybe just a tip to point me in the right direction and patch it...
Samsung Galaxy S3
Latest OmniROM with stock omni kernel
Only root and no Xposed framework
All stock

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes