[Sony Xperia S, Acro S, Ion] Kevin-0100:
First of all: this guide is based off the guide by [MENTION=4684483]lukakas[/MENTION] found here http://xdaforums.com/showthread.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 [MENTION=4684483]lukakas[/MENTION] 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!

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\PhoneWindowManager.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" android:protectionLevel="system|signature" />

<permission android:label="@string/permlab_smallapp" android:name="com.sony.smallapp.permission.SMALLAPP" android:protectionLevel="dangerous" android:description="@string/permdesc_smallapp" />

<permission android:label="@string/permlab_taskSwitcherPluginView" android:name="com.sonymobile.permission.TASK_SWITCHER_PLUGIN_VIEW" android:protectionLevel="signatureOrSystem" android:description="@string/permdesc_taskSwitcherPluginView" />

<permission android:name="com.sonymobile.permission.ACCESS_BEACON_MANAGER" android:protectionLevel="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_PROVIDER" />

<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.permission.BIND_SMALLAPP_WIDGET_MANAGER" />

<uses-permission android:name="com.sony.smallapp.permission.SMALLAPPMANAGER_CONTROL" />

<uses-permission android:name="com.sony.smallapp.launcher.permission.ACCESS_DATABASE" />

<uses-permission android:name="android.permission.DELETE_PACKAGES" />

<permission android:name="com.sonymobile.permission.TASK_SWITCHER_PLUGIN_VIEW" android:protectionLevel="normal" />

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

<action android:name="com.android.systemui.recent.action.OPEN_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.