[Android Software Development] gamzekal:
RXS Moonbreakers presents proudly

HOW TO PORT XPERIA Z5 SMALL APPS TO CM12 and CM12.1

XDA PORTAL

Hi

I made this guide that will help you to mod your ROM for support fully Small Apps from Xperia Z3 5.0.2 [Cm12] and Xperia Z5 5.1.1[Cm12.1] (Include taskswitcher plugin mod)..

I know that it is to port very Hard and some users doenst port it easily therefore we will use original Z3 Systemui or Z5 Systemui(Hardest progress) for it. But dont worry!!! .

Small Apps Z3 5.0.2 and Z5 5.1.1 is latest version of Sony, it bring us features like:

-Small Apps support.

-Favorite list (Called taskswitcher plugin view) of small apps and "floatings" widgets on 'Recents Apps' (Taskswitcher).

-Widget floating window supported. (Like if converted homescreen widgets to small apps).

-Multiple windows by default from Z3 and Z5,

-Latest features of small apps ported from Xperia Z3 with Android 5.0.2 and 5.1.1 version.

-And much more to find.

Before flashing this Mod please make a BACKUP

Requiements

-own framework.jar

-own framework-res.apk

-own android.policy.jar

-own services.jar

-Z3 Systemui(cm12) or Z5 Systemui(cm12.1)

Lets Start

For Cm12

1.Framework-res.apk

Decompile framework-res.apk

And open AndroidManifest.xml(framework-res.apk/AndroidManifest.xml)

Find this line "<uses-permission android:name="android.permission.CONFIRM_FULL_BACKUP"/>"

and Paste those lines above this line

Look at screnshoot(if you didnt see anything go to Attachment)

Like this marked in red lines:

<permission android:label= [MENTION=251364]Str[/MENTION]ing/permlab_serialPort" android:name="android.permission.SERIAL_PORT" android:protectionLevel="system|signature" android:description= [MENTION=251364]Str[/MENTION]ing/permdesc_serialPort" />

<permission android:label= [MENTION=251364]Str[/MENTION]ing/permlab_accessContentProvidersExternally" android:name="android.permission.ACCESS_CONTENT_PROVIDERS_EXTERNALLY" android:protectionLevel="signature" android:description= [MENTION=251364]Str[/MENTION]ing/permdesc_accessContentProvidersExternally" />

<permission android:label= [MENTION=251364]Str[/MENTION]ing/permlab_updateLock" android:name="android.permission.UPDATE_LOCK" android:protectionLevel="signatureOrSystem" android:description= [MENTION=251364]Str[/MENTION]ing/permdesc_updateLock" />

<permission android:name="com.sony.smallapp.permission.CONTROL_SMALLAPP" android:protectionLevel="system|signature" />

<permission android:label= [MENTION=251364]Str[/MENTION]ing/permlab_smallapp" android:name="com.sony.smallapp.permission.SMALLAPP" android:protectionLevel="dangerous" android:description= [MENTION=251364]Str[/MENTION]ing/permdesc_smallapp" />

<permission android:label= [MENTION=251364]Str[/MENTION]ing/permlab_taskSwitcherPluginView" android:name="com.sonymobile.permission.TASK_SWITCHER_PLUGIN_VIEW" android:protectionLevel="signatureOrSystem" android:description= [MENTION=251364]Str[/MENTION]ing/permdesc_taskSwitcherPluginView" />

<permission android:name="com.sonymobile.permission.ACCESS_BEACON_MANAGER" android:protectionLevel="system|signature" />

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

<application android:label= [MENTION=251364]Str[/MENTION]ing/android_system_label" android:icon="@drawable/ic_launcher_android" android:allowClearUserData="false" android:hasCode="false" android:persistent="true" android:process="system" android:backupAgent="com.android.server.SystemBackupAgent" android:killAfterRestore="false" android:supportsRtl="true">

<activity android:theme="@style/Theme.Holo.Dialog.Alert" android:name="com.android.internal.app.ChooserActivity" android:multiprocess="true" android:excludeFromRecents="true" android:finishOnCloseSystemDialogs="true">

<intent-filter>

<action android:name="android.intent.action.CHOOSER" />

<category android:name="android.intent.category.DEFAULT" />

</intent-filter>

</activity>

<activity android:theme="@style/Theme.Holo.Dialog" android:label= [MENTION=251364]Str[/MENTION]ing/heavy_weight_switcher_title" android:name="com.android.internal.app.HeavyWeightSwitcherActivity" android:process=":ui" android:excludeFromRecents="true" android:finishOnCloseSystemDialogs="true" />

Then, go to res/values/strings.xml and add these lines at the end:

<string name="permlab_smallapp">Show small apps</string>
<string name="permdesc_smallapp">Allow the application to display small apps 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 recompile it.

2.android.policy.jar

Decompile android.policy.jar

And open smali\com\android\internal\policy\impl\PhoneWindowManager.smali

Find for this words " android.permission.SYSTEM_ALERT_WINDOW":

Like this marked in red:

[I mean after goto:goto_1 add small app lines (in red marked) in your android policy.Line number musst be different from your other line numbers.EX:1793 belongs only to small app ]

.line 1881
:sswitch_2
const-string v0, "android.permission.SYSTEM_ALERT_WINDOW"

.line 1882
const/16 v3, 0x18

aput v3, p2, v2

goto :goto_1

[B][COLOR="Red"] .line 1793
:sswitch_3
const-string v0, "com.sony.smallapp.permission.SMALLAPP"

[B][COLOR="Red"] .line 1794[/COLOR][/B]
goto :goto_1[/COLOR][/B]

[B][COLOR="Red"].line 1862
nop[/COLOR][/B]

:sswitch_data_0
.sparse-switch
0x7d2 -> :sswitch_2
0x7d3 -> :sswitch_2
0x7d5 -> :sswitch_1
0x7d6 -> :sswitch_2
0x7d7 -> :sswitch_2
0x7da -> :sswitch_2
0x7db -> :sswitch_0
0x7dd -> :sswitch_0
0x7e7 -> :sswitch_0
0x7ee -> :sswitch_0
0x7ef -> :sswitch_0
[B][COLOR="Red"] 0xbb5 -> :sswitch_3[/COLOR][/B]
[B][COLOR="Red"] 0xbb6 -> :sswitch_3[/COLOR][/B]
.end sparse-switch
.end method

Save your modifications and recompile it.

3.framework.jar

Decompile framework.jar

Open folder smali2/com/

Download this zip and extract it in there

Recompile it

4.Systemui

Please go to this page and download Systemui flashable.zip or Skip this step and go to 5.step

[You can add Smallapp resources and your frameowork files in this zip and flash it or i have prepared a flashable zip in next step]

5.Flash Section

Download this other Smallapp resources(flashable zip) and add your framework files in framework folder(android.policy.jar,framework-res.apk,framework.jar)

and Flash it.

For Cm12.1

1.Framework-res.apk

Decompile Framework-res.apk

open \framework-res\AndroidManifest.xml

Find this line "<uses-permission android:name="android.permission.CONFIRM_FULL_BACKUP"/>"

and Paste those lines above this line

Look at screnshoot(if you didnt see anything go to Attachment)

open \framework-res\res\values\strings.xml

and add these lines at the end before

</resources>

<string name="permlab_smallapp">Show small apps</string>
<string name="permdesc_smallapp">Allow the application to display small apps 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 recompile it.

2.android.policy.jar

Decompile android.policy.jar

open \android.policy\com\android\internal\policy\impl\PhoneWindowManager.smali

find this "android.permission.SYSTEM_ALERT_WINDOW"

my PhoneWindowManager.smali

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

const/16 v3, 0x18

aput v3, p2, v2

goto :goto_2a

:sswitch_data_42
.sparse-switch
0x7d2 -> :sswitch_3b
0x7d3 -> :sswitch_3b
0x7d5 -> :sswitch_36
0x7d6 -> :sswitch_3b
0x7d7 -> :sswitch_3b
0x7da -> :sswitch_3b
0x7db -> :sswitch_2a
0x7dd -> :sswitch_2a
0x7e7 -> :sswitch_2a
0x7ee -> :sswitch_2a
0x7ef -> :sswitch_2a
0x7f0 -> :sswitch_2a
.end sparse-switch
.end method

Compare and Copy Red lines in your Smali

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

const/16 v3, 0x18

aput v3, p2, v2

goto :goto_2a

[COLOR="red"]	:sswitch_2d
const-string v0, "com.sony.smallapp.permission.SMALLAPP"

goto :goto_2a[/COLOR]

[COLOR="Red"] .line 3300
goto :goto_1

.line 3301
nop	[/COLOR]

:sswitch_data_42
.sparse-switch
0x7d2 -> :sswitch_3b
0x7d3 -> :sswitch_3b
0x7d5 -> :sswitch_36
0x7d6 -> :sswitch_3b
0x7d7 -> :sswitch_3b
0x7da -> :sswitch_3b
0x7db -> :sswitch_2a
0x7dd -> :sswitch_2a
0x7e7 -> :sswitch_2a
0x7ee -> :sswitch_2a
0x7ef -> :sswitch_2a
0x7f0 -> :sswitch_2a
[COLOR="Red"]	0xbb5 -> :sswitch_2d
0xbb6 -> :sswitch_2d[/COLOR]
.end sparse-switch
.end method

notice that the goto: after "com.sony.smallapp.permission.SMALLAPP" is the same goto as a the goto above :sswitch_2d

and that the :sswitch_2d was not in the origonal method if you already have a :sswitch_2d make it something else like :sswitch_3

Look at this line for sswitch_3

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

.line 2202
const/16 v3, 0x18

aput v3, p2, v2

goto :goto_1

[COLOR="Red"] .line 1793
:sswitch_3
const-string v0, "com.sony.smallapp.permission.SMALLAPP"[/COLOR]

[COLOR="Red"] .line 1795
goto :goto_1

.line 1862
nop[/COLOR]

:sswitch_data_0
.sparse-switch
0x7d2 -> :sswitch_2
0x7d3 -> :sswitch_2
0x7d5 -> :sswitch_1
0x7d6 -> :sswitch_2
0x7d7 -> :sswitch_2
0x7da -> :sswitch_2
0x7db -> :sswitch_0
0x7dd -> :sswitch_0
0x7e7 -> :sswitch_0
0x7ee -> :sswitch_0
0x7ef -> :sswitch_0
0x7f0 -> :sswitch_0
[COLOR="Red"] 0xbb5 -> :sswitch_3
0xbb6 -> :sswitch_3[/COLOR]
.end sparse-switch
.end method

Save your modifications and recompile it.

3.framework.jar

Decompile your framework.jar

Download this

Open folder smali2(or smali_classes2)/com/ and extract it there(sony folder)

Recompile it

4.SuperUserMode

Go to this page and follow SuperUserMode instructions

5.Flash Section

Download this and add your edited framework files in >>>>framework folder in Zip

1)android.policy.jar,

2)services.jar(step 4),

3)framework-res.apk,

4)framework.jar)

and Flash it.

Credits

[MENTION=4684483]lukakas[/MENTION]

[MENTION=5127507]Kevin-0100[/MENTION]

[MENTION=4662673]sandy7[/MENTION]

[MENTION=5262839]STRYDER~007[/MENTION]

[MENTION=3877121]slipsystem[/MENTION]
​