Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[CM11][Port][XS]Smallapps/Taskswitcher guide

OP Kevin-0100

23rd April 2014, 10:59 PM   |  #1  
Kevin-0100's Avatar
OP Senior Member
Flag Vlaardingen
Thanks Meter: 62
 
122 posts
Join Date:Joined: Feb 2013
More
First of all: this guide is based off the guide by @lukakas found here http://forum.xda-developers.com/show....php?t=2460877

I tweaked it to get it to work on CM11, comparing the files of the Z2 system dump, the 4.3 resources provided in the guide by @lukakas and compared the difference with CM11 files.

In this guide I am using OPENsemc rom beta 3, wich is CyanogenMod 11 / Android KitKat

Before flashing the files, perform a FULL BACKUP in case something goes wrong!

Code:
I will NOT be held responsible if something happens to your device while or after flashing any of these files! All flashing is done at your OWN RISK.


I recommend using Virtuous Ten Studio for editing the files. It can be downloaded from: http://www.virtuous-ten-studio.com/index.php/downloads

Setting up Virtuous Ten Studio

Click on “File” then on “Open Settings” then proceed to ApkTool, and install Framework-res.apk from the rom you are trying to port SmallApps to by clicking on “Add single framework”




Android.policy.jar

Click on “Open” then on “New Project” and import anroid.policy.jar as shown below:
(note, in properties/settings click on “Smali” and make sure the API is set to 4.4 KitKat)



Now open smali\com\android\internal\policy\impl\PhoneWindow Manager.smali and select checkAddPermission from the dropdown menu



Find and alter the following lines of code: (added code is marked in green)

.method public checkAddPermission(Landroid/view/WindowManager$LayoutParams;[I)I

(Lines of code not needed in the part of the tutorial has been cut, do not delete them though)
:cond_1
const/4 v0, 0x0

.line 1609
.local v0, permission:Ljava/lang/String;
sparse-switch v1, :sswitch_data_0

(Lines of code not needed in the part of the tutorial has been cut, do not delete them though)

:sswitch_1
const-string v0, "android.permission.SYSTEM_ALERT_WINDOW"

.line 1627
const/16 v3, 0x18

aput v3, p2, v2

goto :goto_1

.line 1397 - This number should be a new number and should not be found elsewhere in this document
:sswitch_2
const-string v0, "com.sony.smallapp.permission.SMALLAPP"


.line 1398 - This number should be a new number and should not be found elsewhere in this document
goto :goto_1


.line 1609 - This number must match the number above the line.local v0, permission:Ljava/lang/String;
nop

:sswitch_data_0
.sparse-switch
0x7d2 -> :sswitch_1
0x7d3 -> :sswitch_1
0x7d5 -> :sswitch_0
0x7d6 -> :sswitch_1
0x7d7 -> :sswitch_1
0x7da -> :sswitch_1
0x7db -> :sswitch_0
0x7dd -> :sswitch_0
0x7e7 -> :sswitch_0
0xbb5 -> :sswitch_2
0xbb6 -> :sswitch_2

.end sparse-switch
.end method

Press control s to save the document and recompile it: (use right click on android.policy and click “Build project”


Framework2.jar

For this step, import and decompile Framework2.jar like in steps show above. Right click on “framework2” and select “Open in windows explorer”

In the explorer screen, navigate to Data/smali/com, copy and paste the “sony” folder provided in the resources zip. Once done, right click on “framework2” and select “Reload project”

Once the project has reloaded, right click on “framework2” and select “Build project”

Framework-res.apk

Import framework-res.apk into the project.
Note: make sure before importing that in the Apk-Tool section you select “Use newest ApkTool” and that you select the Framework tag. (Remember you installed framework-res.apk earlier?)

Once framework-res.apk has imported, open AndroidManifest.XML
Add the lines marked in green like below.

<permission android:name="com.sony.smallapp.permission.CONTROL _SMALLAPP" androidrotectionLevel="system|signature" />
<permission android:label="@string/permlab_smallapp" android:name="com.sony.smallapp.permission.SMALLAP P" androidrotectionLevel="dangerous" android:description="@string/permdesc_smallapp" />
<permission android:label="@string/permlab_taskSwitcherPluginView" android:name="com.sonymobile.permission.TASK_SWITC HER_PLUGIN_VIEW" androidrotectionLevel="signatureOrSystem" android:description="@string/permdesc_taskSwitcherPluginView" />
<permission android:name="com.sonymobile.permission.ACCESS_BEA CON_MANAGER" androidrotectionLevel="system|signature" />




Don’t forget to save the modifications you just made.

Next up: open res/values/ and open “strings.xml”

At the end of the file, copy the green lines:

<string name="permlab_smallapp">Small application overlay</string>
<string name="permdesc_smallapp">Allows running movable small applications on top of other applications.</string>
<string name="permlab_taskSwitcherPluginView">Provide plugin-view to the task-switcher</string>
<string name="permdesc_taskSwitcherPluginView">Allows the application to provide a plugin-view to the task-switcher</string>




Save your modifications and and “Build project”

SystemUI.apk

This part can be the trickiest and can cause a lot of headache. Import SystemUI.apk and open AndroidManifest.xml

Note: make sure before importing that in the Apk-Tool section you select “Use newest ApkTool” and that you select the Framework tag.

Add the lines marked in green like below.

<uses-permission android:name="com.sonymobile.permission.XSSM_PROVI DER" />
<uses-permission android:name="com.sonymobile.permission.XSSM" />
<uses-permission android:name="android.permission.BIND_APPWIDGET" />
<uses-permission android:name="com.sony.smallapp.app.widget.permiss ion.BIND_SMALLAPP_WIDGET_MANAGER" />
<uses-permission android:name="com.sony.smallapp.permission.SMALLAP PMANAGER_CONTROL" />
<uses-permission android:name="com.sony.smallapp.launcher.permissio n.ACCESS_DATABASE" />
<uses-permission android:name="android.permission.DELETE_PACKAGES" />
<permission android:name="com.sonymobile.permission.TASK_SWITC HER_PLUGIN_VIEW" androidrotectionLevel="normal" />




Add the lines marked in green like below. (in Recents Activity)

<action android:name="com.android.systemui.recent.action.O PEN_RECENTS_INTENT_FROM_SMALL_APP_LAUNCHER" />




Now navigate to res/values/ and open “attrs.xml”

Add the line marked in green at the end of the file:

<attr name="lookupKey" format="string" />






Now navigate to res/values/ and open “ids.xml”

Add the line marked in green at the end of the file:

<item type="id" name="recent_wipe_app">false</item>
<item type="id" name="recents_inject_custom_view">false</item>
<item type="id" name="recents_layout">false</item>
<item type="id" name="recents_pluginview_container">false</item>




Now navigate to res/values/ and open “public.xml”

Since we will be working with hex id’s, a word of advice.

Always create a new hex id in this file. Duplicating other hex number will result in a fail when trying to recompile


As an example:

<public type="attr" name="maxSize" id="0x7f010008" />
<public type="attr" name="holdTime" id="0x7f010009" />
<public type="attr" name="decayTime" id="0x7f01000a" />
<public type="attr" name="orientation" id="0x7f01000b" />
<public type="attr" name="singleRow" id="0x7f01000c" />
<public type="attr" name="lookupKey" id="0x7f01000d" />

Notice that all the hex number are sequential? All these numbers are only found once in the entire document. If I were to add another line below LookupKey it would look like this:


<public type="attr" name="Tutorial" id="0x7f01000e" />

When in doubt as to if the number you assigned to a line, just copy the hex number and use control f to search for it. When you can’t find another line with that number, you know that your hex number is one of a kind.

Let’s get started shall we.

First of all locate the last “attr” line and add the line below marked in green:

<public type="attr" name="lookupKey" id="PUT_HEX_HERE" />




Locate the last “layout” line (like where you put LookupKey in the example above) and add line below marked in green:

<public type="layout" name="plugin_view" id="PUT_HEX_HERE" />

Locate the last “id” line and do the same with the line below

<public type="id" name="recents_inject_custom_view" id=" PUT_HEX_HERE" " />
<public type="id" name="recents_layout" id=" PUT_HEX_HERE" " />
<public type="id" name="recents_pluginview_container" id=" PUT_HEX_HERE" " />


Now copy and paste (and overwrite) the files in the resources to res/layout and res/layout-land.

Now copy and paste (and overwrite) the .smali files in the resources to com/android/systemui and com/android/systemui/recent

Before going any further, don’t forget to save ALL the modifications you made and after that you need to right click on “SystemUI” and click on “Reload project”

Now open up RecentsActivity.smali

Virtuous Ten Studio helps you in which lines you need to alter. Every line that has an hex id will be marked by a little blue box



In the example above, 0x7f07007f represents “recents_pluginview_container” you need to change that hex number to the number you assigned to it earlier in “public.xml”

You need to change every hex number in this file to match the hex numbers you assigned earlier.

These are:

recents_pluginview_container
recents_layout
plugin_view
status_bar_recent_panel
recents_root
config_recent_item_min_alpha
recents_pluginview_container
recents_return_to_launcher_enter
recents_return_to_launcher_exit

Note that the list above is in the same order as the lines containing the hex numbers in RecentsActivity.smali. This means that “recents_pluginview_container” represents the first hex number, “recents_layout” the second, “plugin_view” the third etc. etc.

Once that is done, save the file and open R$styleable.smali.

Find line: sput-object v0, Lcom/android/systemui/R$styleable;->RecentsPanelView:[I



Change that hex id to match the id for LookupKey, you added that in “public.xml”.

Save all modifications and build your project.

Zip up all the files in a flashable zip and start flashing

These are all the steps I made to get it working, I hope this guide will help others to port SmallApps/Taskswitcher.
Attached Thumbnails
Click image for larger version

Name:	Screenshot_2014-04-23-22-44-00.jpg
Views:	1510
Size:	39.8 KB
ID:	2704682   Click image for larger version

Name:	Screenshot_2014-04-23-22-44-11.png
Views:	1319
Size:	141.0 KB
ID:	2704683   Click image for larger version

Name:	Screenshot_2014-04-23-22-44-21.png
Views:	1221
Size:	223.4 KB
ID:	2704684  
Attached Files
File Type: zip Xperia-SmallApps+TaskSwitcherv2.zip - [Click for QR Code] (19.99 MB, 1179 views)
File Type: zip CM-11-Resources.zip - [Click for QR Code] (8.94 MB, 772 views)
Last edited by Kevin-0100; 10th May 2014 at 11:33 AM. Reason: added flashable zip | added updated Resources zip
The Following 17 Users Say Thank You to Kevin-0100 For This Useful Post: [ View ]
23rd April 2014, 11:43 PM   |  #2  
carlito-lt26i's Avatar
Senior Member
Thanks Meter: 299
 
128 posts
Join Date:Joined: Nov 2012
nice i will try when i come home.

thanks the guide

Sent from my LT26i using xda app-developers app
24th April 2014, 01:58 AM   |  #3  
Senior Member
Flag São Paulo - SP
Thanks Meter: 391
 
441 posts
Join Date:Joined: Jun 2012
More
Well done!
24th April 2014, 11:15 AM   |  #4  
slink722's Avatar
Senior Member
Flag San Fernando City
Thanks Meter: 1,311
 
996 posts
Join Date:Joined: May 2012
More
@Kevin-0100, mate where to find Recent Activity? is it in the " smali\com\android\systemui\recent " ??

EDIT: found it already :3


@Kevin-0100

EDIT: im having these errors while doing the last step mate. pls help
Last edited by slink722; 24th April 2014 at 11:47 AM.
24th April 2014, 12:13 PM   |  #5  
Kevin-0100's Avatar
OP Senior Member
Flag Vlaardingen
Thanks Meter: 62
 
122 posts
Join Date:Joined: Feb 2013
More
In the top bar in VTS, click on view log. There you will find which lines are causing the build error. Are you trying to port it tot OmniRom? If so you should not copy and paste the .smali files in my resources as they come from another ROM (opensemc). Try using the .smali files from the OmniRom

Sent from my Xperia S using XDA Premium 4 mobile app
The Following User Says Thank You to Kevin-0100 For This Useful Post: [ View ]
24th April 2014, 03:46 PM   |  #6  
slink722's Avatar
Senior Member
Flag San Fernando City
Thanks Meter: 1,311
 
996 posts
Join Date:Joined: May 2012
More
Ohh ok tnx mate

Sent from my LT26ii using xda premium
27th April 2014, 06:42 PM   |  #7  
Junior Member
Thanks Meter: 16
 
23 posts
Join Date:Joined: Aug 2010
Error on

\res\layout\status_bar_recent_panel.xml:11: error: Error: No resource found that matches the given name (at 'id' with value '@id/recents_clear').'
\res\layout-land\status_bar_recent_panel.xml:11: error: Error: No resource found that matches the given name (at 'id' with value '@id/recents_clear').'

what should I do

Using Beanstalk ROM
I found similar error and fix by find some similar picture
I already change @drawable/ic_recents_clear to @drawable/ic_notify_clear_normal in both status_bar_recent_panel.xml
Last edited by nut27455; 27th April 2014 at 06:46 PM.
27th April 2014, 07:14 PM   |  #8  
Chocklety Boyee's Avatar
Senior Member
Kathmandu,Nepal
Thanks Meter: 337
 
1,029 posts
Join Date:Joined: Sep 2013
More
@MaDMaT80 can you add this taskswitcher and small apps to your 4.4 kitkat rom..it would be awsome..

Sent from my LT28h using Tapatalk
27th April 2014, 08:28 PM   |  #9  
Kevin-0100's Avatar
OP Senior Member
Flag Vlaardingen
Thanks Meter: 62
 
122 posts
Join Date:Joined: Feb 2013
More
Quote:
Originally Posted by nut27455

Error on

\res\layout\status_bar_recent_panel.xml:11: error: Error: No resource found that matches the given name (at 'id' with value '@id/recents_clear').'
\res\layout-land\status_bar_recent_panel.xml:11: error: Error: No resource found that matches the given name (at 'id' with value '@id/recents_clear').'

what should I do

Using Beanstalk ROM
I found similar error and fix by find some similar picture
I already change @drawable/ic_recents_clear to @drawable/ic_notify_clear_normal in both status_bar_recent_panel.xml

You need to go to res/values/ids and make a new value for recents_clear. That should fix it

Sent from my C1905 using XDA Premium 4 mobile app
The Following 2 Users Say Thank You to Kevin-0100 For This Useful Post: [ View ]
28th April 2014, 05:24 AM   |  #10  
Junior Member
Thanks Meter: 16
 
23 posts
Join Date:Joined: Aug 2010
Quote:
Originally Posted by Kevin-0100

You need to go to res/values/ids and make a new value for recents_clear. That should fix it

Sent from my C1905 using XDA Premium 4 mobile app

Thank you it work for build.
But FC when open recent in phone.

Anyway thank you for sharing this.

Post Reply Subscribe to Thread

Tags
apps, port, small
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes