fuser-invent

Android TabletUI Smali Hack

Feb 6th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.28 KB | None | 0 0
  1. If anyone is interested in how I changed the fake TabletUI to a real TabletUI in my Crystal Clear ROM:
  2. Ainol's way of making their firmware TabletUI was to keep it as a PhoneUI, hide the top bar and move the actions in the top bar to the bottom. So everything looks like TabletUI but when you opened an app like YouTube it recognized the tablet as a phone and launched its PhoneUI instead of the tablet one. Another side effect was that it broke notifications and they just didn't show up. I found this method in this post. If you take a look at that thread you can see the section describing the following:
  3.  
  4. phone: if shortSizeDp>600 goto phablet
  5. ...code for phone...
  6. phablet: if shortSizeDp>720 goto tablet
  7. ...code for phablet...
  8. tablet: ...code for tablet...
  9.  
  10. to:
  11.  
  12. phone: goto phablet
  13. ...code for phone...
  14. phablet: goto tablet
  15. ...code for phablet...
  16. tablet: ...code for tablet...
  17.  
  18. Most of the threads I found around didn't work because they didn't describe what you were actually doing and involved changing a lot more code than this method. You'll to edit PhoneWindowManager.smali (from android.policy.jar) and WindowManagerService.smali (from services.jar).
  19.  
  20. The dirty way to make the change, which I did is to edit each of the lines in PhoneWindowManager.smali so that every line says "go to TabletUI." You need to find out your "cond_##" because its probably not going to be the same as that tutorial. If you change all the lines to "go to TabletUI" though, if someone changes the DPI in the build.prop it will not change the UI.
  21.  
  22. Search for "const/16 v9, 0x258" in PhoneWindowManager.smali and you'll see a line below that with the "if-ge v8, v9, :cond_5" command. 0x258 hexidecimal = 600 decimal - It's saying "if the tablet's shortSizedp is less than 600 then use the TabletUI." "cond_5" in this instance means "TabletUI."
  23.  
  24. Next search for "const/16 v9, 0x2d0" 0x2d0 hexidecimal = 720 decimal. If you look directly below you will see something like "if-ge v8, v9, :cond_6" where "cond_6" is Phone or PhabletUI. If you change "cond_6" to "cond_5" then for any dpi setting the tablet will use TabletUI.
  25.  
  26. If you can't find these lines with the above searches then you can use "shortSizeDp:I" or "DENSITY_DEVICE" depending on how your smali is written and look for similar lines with those hexidecimal numbers.
  27.  
  28. If you need to convert hexidecimals like 0x2d0 to decimals (what we think of as standard numbers) like 720, you can use google. Just type into the search bar "0x2d0 to decimal" and a calculator will pop up with the answer in it.
  29.  
  30. -----
  31.  
  32. Here is a quick explaination of the shortSizeDP. In this example the tablet is 1280x800, so you have to figure out what values will trigger the different UI settings and then see if they are all present in the code. You figure out what dpi to set by doing this:
  33.  
  34. 800 (the short side of your tablet) * 160 (this is a constant value) / 213 (LCD Density that you usually set in your build.prop) = 600.938
  35. Here it is again but just the equation - 800 * 160 / 213 = 600.938
  36.  
  37. So if you set your dpi to 213 you will get a shortSizeDP of 600.938 which is greater than 600, so the device will trigger PhoneUI.
  38. Most tablets and some phones use the following:
  39.  
  40. shortSizeDP < 600 = Phone UI
  41. 601 < shortSizeDP < 719 = Phablet UI
  42. shortSizeDP > 720 = Tablet UI
  43.  
  44. That is why if you set your DPI to 160 instead of 213 you get TabletUI. 800 * 160 / 160 = 800. Since 800 is greater than 720 the device will trigger TabletUI.
  45.  
  46. -----
  47.  
  48. The next step is to change this line or something similar in the windowsmanagerservice.smali in the services.jar:
  49.  
  50. iget v1, p0, Lcom/android/server/wm/WindowManagerService;->mSmallestDisplayWidth:I
  51.  
  52. int-to-float v1, v1
  53.  
  54. div-float v1, v1, p4
  55.  
  56. float-to-int v1, v1
  57.  
  58. move-object/from16 v0, p5
  59.  
  60. iput v1, v0, Landroid/content/res/Configuration;->smallestScreenWidthDp:I
  61.  
  62. to:
  63.  
  64. const/16 v1, 0x2d1
  65.  
  66. move-object/from16 v0, p5
  67.  
  68. iput v1, v0, Landroid/content/res/Configuration;->smallestScreenWidthDp:I
  69.  
  70. Again it might differ slightly so if it doesn't show up exactly the same you can search for "WindowManagerService;->mSmallestDisplayWidth:I" and find the line with code that looks similar below it. 0x2d1 hexidecimal = 721 decimal. So you are again setting a value to change to TabletUI if DPI is above 720.
Add Comment
Please, Sign In to add comment