[Galaxy Ace S5830 Android Development] Shaaan:
I was working on swipe to remove notifications mod for the past three months and now finally have it working. This tutorial is for all those who have a problem compiling it.

Special thanks to hansip87 and spacecaker for helping me out. The original thread by hansip is here.

This is for ddkq8 but should work with any firmware.

For compiling the right way check the second post. I have attached all the files that have been edited in this guide in the second post. You can use them to compare.

Now lets start the mod.

1. Editing SystemUI.apk

1.1 Editing res/anim

We are registering anim object here, so swipe animation can be done.

Create an anim folder (if it does not exists yet) inside /res folder.

Create 2 file named slide_out_left_basic.xml and slide_out_right_basic.xml inside res/anim folder

For slide_out_left_basic.xml, edit the file and fill with this :

<?xml version="1.0" encoding="utf-8"?>
<translate android:duration="@android:integer/config_mediumAnimTime" android:fromXDelta="0.0" android:toXDelta="-50.0%p"
xmlns:android="http://schemas.android.com/apk/res/android" />

For slide_out_right_basic.xml, edit the file and fill with this :

<?xml version="1.0" encoding="utf-8"?>
<translate android:duration="@android:integer/config_mediumAnimTime" android:fromXDelta="0.0" android:toXDelta="50.0%p"
xmlns:android="http://schemas.android.com/apk/res/android" />

Save both files.

1.2 Editing res/layout/status_bar_latest_event.xml

We are replacing LinearLayout object used in StatusBar with LatestItemContainer here, so notification can be removed. We handle the Styling first by editing this .xml first. Here are the steps:

Change the code from Original code to this (change the bold one):

<?xml version="1.0" encoding="utf-8"?>
<[B]com.android.systemui.statusbar.LatestItemContainer[/B] android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="65.0sp"
xmlns:android="http://schemas.android.com/apk/res/android">
<com.android.systemui.statusbar.LatestItemView android:id="@id/content" android:background="@android:drawable/status_bar_item_background" android:paddingRight="6.0sp" android:focusable="true" android:clickable="true" android:layout_width="fill_parent" android:layout_height="64.0sp" android:shadowColor="#ff000000" android:shadowDx="0.0" android:shadowDy="1.0" android:shadowRadius="2.0" />
<View android:background="@drawable/divider_horizontal_light_opaque" android:layout_width="fill_parent" android:layout_height="wrap_content" />
</[B]com.android.systemui.statusbar.LatestItemContainer[/B]>

Save

1.3 Editing res/values/public.xml

Now some problems arise if you do not assign the correct id for a anim file. So to prevent it we make the use of apktool.

Recompile your apk after step 1.2

Decompile again the resulting apk.

This one is for registering anim file that we made on step 1.1 to be available publicly and to be recognized in .smali program. Here are the steps :

Inside /res/values/public.xml, you'll find something like this (at the end of the file):

<resources>
.
.
.

<public type="anim" name="slide_out_left_basic" id="0x7f0c0000" />
<public type="anim" name="slide_out_right_basic" id="0x7f0c0001" />

</resources>

Remember the ID for both anim lines. This will be applied again on the step 1.4

1.4 Adding smali/com/android/systemui/statusbar/LatestItemContainer$1.smali and smali/com/android/systemui/statusbar/LatestItemContainer.smali

This is the class of LatestItemContainer that will be used to handle the notification list instead of LatestItemView. Here are the steps:

Please download from the attachment

insert the files inside to mentioned folder above

Inside LatestItemContainer$1.smali, there's an id that references the anim from step1.2. Please edit it if you have different id for anim left or anim from previous step.

.line 53
:cond_0
const/high16 v1, 0x7f0a

and

.line 51
const v1, 0x7f0a0001

1.5 Add smali/com/android/systemui/statusbar/StatusBarService$7.smali (or depends on your existing framework numbering, could be $8 or larger)

This is additional function for StatusBarService to handle onClearNotification function. Here are the steps:

Extract the StatusBarService$7.smali from attachment.

Put it in the folder smali/com/android/systemui/statusbar/

*MOST IMPORTANT AND DIFFICULT PART*

1.6 Edit smali/com/android/systemui/statusbar/StatusBarService.smali

This is the file that generate NotificationView. Here are the steps :

Open StatusBarService.smali and find this function

.method makeNotificationView(Lcom/android/internal/statusbar/StatusBarNotification;Landroid/view/ViewGroup;)[Landroid/view/View;

Find this code in the makeNotificationView function body:

invoke-virtual {v1, v3, p2, v11}, Landroid/view/LayoutInflater;->inflate(ILandroid/view/ViewGroup;Z)Landroid/view/View;

Insert the bold code below the line

"invoke-virtual {v1, v3, p2, v11}, Landroid/view/LayoutInflater;->inflate(ILandroid/view/ViewGroup;Z)Landroid/view/View;

move-result-object v9"

check-cast v9, Lcom/android/systemui/statusbar/LatestItemContainer;

.local v9, row:Lcom/android/systemui/statusbar/LatestItemContainer;
move-object/from16 v0, v2

iget v0, v0, Landroid/app/Notification;->flags:I

move v4, v0

and-int/lit8 v4, v4, 0x2

if-nez v4, :cond_1

move-object/from16 v0, v2

iget v0, v0, Landroid/app/Notification;->flags:I

move v4, v0

and-int/lit8 v4, v4, 0x20

if-nez v4, :cond_1

new-instance v4, Lcom/android/systemui/statusbar/StatusBarService$7;

move-object v0, v4

move-object/from16 v1, p0

move-object/from16 v7, p1

invoke-direct {v0, v1, v7}, Lcom/android/systemui/statusbar/StatusBarService$7;-><init>(Lcom/android/systemui/statusbar/StatusBarService;Lcom/android/internal/statusbar/StatusBarNotification;)V

move-object/from16 v0, v9

move-object v1, v4

invoke-virtual {v0, v1}, Lcom/android/systemui/statusbar/LatestItemContainer;->setOnSwipeCallback(Ljava/lang/Runnable;)V

.line 735
.line 581
:cond_1

Also insert the following bold code :

const v1, 0x7f090024

[B]invoke-virtual {v9, v1}, Lcom/android/systemui/statusbar/LatestItemContainer;->findViewById(I)Landroid/view/View;[/B]

move-result-object v1

move-object v0, v1

check-cast v0, Landroid/view/ViewGroup;

So it should look something like this :

invoke-virtual {v1, v3, p2, v11}, Landroid/view/LayoutInflater;->inflate(ILandroid/view/ViewGroup;Z)Landroid/view/View;

move-result-object v9

[I][B]check-cast v9, Lcom/android/systemui/statusbar/LatestItemContainer;

.local v9, row:Lcom/android/systemui/statusbar/LatestItemContainer;
move-object/from16 v0, v2

iget v0, v0, Landroid/app/Notification;->flags:I

move v4, v0

and-int/lit8 v4, v4, 0x2

if-nez v4, :cond_1

move-object/from16 v0, v2

iget v0, v0, Landroid/app/Notification;->flags:I

move v4, v0

and-int/lit8 v4, v4, 0x20

if-nez v4, :cond_1

new-instance v4, Lcom/android/systemui/statusbar/StatusBarService$7;

move-object v0, v4

move-object/from16 v1, p0

move-object/from16 v7, p1

invoke-direct {v0, v1, v7}, Lcom/android/systemui/statusbar/StatusBarService$7;-><init>(Lcom/android/systemui/statusbar/StatusBarService;Lcom/android/internal/statusbar/StatusBarNotification;)V

move-object/from16 v0, v9

move-object v1, v4

invoke-virtual {v0, v1}, Lcom/android/systemui/statusbar/LatestItemContainer;->setOnSwipeCallback(Ljava/lang/Runnable;)V

.line 735
.line 581
:cond_1[/B][/I]
const v1, 0x7f090024

[I][B] invoke-virtual {v9, v1}, Lcom/android/systemui/statusbar/LatestItemContainer;->findViewById(I)Landroid/view/View;[/B][/I]

move-result-object v1

move-object v0, v1

check-cast v0, Landroid/view/ViewGroup;

Bold is the inserted code.

Now we are done editing the systemui files. Lets move on to framework.jar

2. Editing framework.jar

2.1 editing smali/com/android/internal/statusbar/IStatusBarService$Stub.smali

Add this code on variable declaration part inside the file :

.field static final TRANSACTION_onClearAllNotifications:I = 0xb

[B].field static final TRANSACTION_onNotificationClear:I = 0xe[/B]

.field static final TRANSACTION_onNotificationClick:I = 0x9

.field static final TRANSACTION_onNotificationError:I = 0xa

Find this code:

.method public onTransact(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z
.registers 14
.parameter "code"
.parameter "data"
.parameter "reply"
.parameter "flags"
.annotation system Ldalvik/annotation/Throws;
value = {
Landroid/os/RemoteException;
}
.end annotation

.prologue
.line 39
sparse-switch p1, :sswitch_data_124

Change it to :

.method public onTransact(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z
.registers 14
.parameter "code"
.parameter "data"
.parameter "reply"
.parameter "flags"
.annotation system Ldalvik/annotation/Throws;
value = {
Landroid/os/RemoteException;
}
.end annotation

.prologue
.line 39
[B] sparse-switch p1, :sswitch_data_15a[/B]

Find and replace this code (it is at the end of the file):

.line 183
const/4 v0, 0x1

goto/16 :goto_7
:sswitch_data_124
.sparse-switch
0x1 -> :sswitch_f
0x2 -> :sswitch_1c
0x3 -> :sswitch_29
0x4 -> :sswitch_42
0x5 -> :sswitch_5f
0x6 -> :sswitch_7b
0x7 -> :sswitch_8d
0x8 -> :sswitch_c7
0x9 -> :sswitch_d5
0xa -> :sswitch_ef
0xb -> :sswitch_116
0x5f4e5446 -> :sswitch_8
.end sparse-switch

Change it to :

.line 183
const/4 v0, 0x1

goto/16 :goto_7
[B]
.line 187
.end local v1 #_arg0:Ljava/lang/String;
.end local v2 #_arg1:Ljava/lang/String;
.end local v3 #_arg2:I
.end local v4 #_arg3:I
.end local v5 #_arg4:I
.end local v6 #_arg5:Ljava/lang/String;
:sswitch_132
const-string v0, "com.android.internal.statusbar.IStatusBarService"

invoke-virtual {p2, v0}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V

.line 188
invoke-virtual {p0}, Lcom/android/internal/statusbar/IStatusBarService$Stub;->onClearAllNotifications()V

.line 189
invoke-virtual {p3}, Landroid/os/Parcel;->writeNoException()V

.line 190
const/4 v0, 0x1

goto/16 :goto_7

.end local v1 #_arg0:Ljava/lang/String;
.end local v2 #_arg1:Ljava/lang/String;
.end local v3 #_arg2:I
:sswitch_140
const-string v0, "com.android.internal.statusbar.IStatusBarService"

invoke-virtual {p2, v0}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V

.line 177
invoke-virtual {p2}, Landroid/os/Parcel;->readString()Ljava/lang/String;

move-result-object v1

.line 178
.restart local v1 #_arg0:Ljava/lang/String;
invoke-virtual {p2}, Landroid/os/Parcel;->readString()Ljava/lang/String;

move-result-object v2

.line 179
.restart local v2 #_arg1:Ljava/lang/String;
invoke-virtual {p2}, Landroid/os/Parcel;->readInt()I

move-result v3

.line 180
.restart local v3 #_arg2:I
invoke-virtual {p0, v1, v2, v3}, Lcom/android/internal/statusbar/IStatusBarService$Stub;->onNotificationClear(Ljava/lang/String;Ljava/lang/String;I)V

.line 181
invoke-virtual {p3}, Landroid/os/Parcel;->writeNoException()V

.line 182
const/4 v0, 0x1

goto/16 :goto_7[/B]

.line 39
:sswitch_data_15a
.sparse-switch
0x1 -> :sswitch_f
0x2 -> :sswitch_1c
0x3 -> :sswitch_29
0x4 -> :sswitch_42
0x5 -> :sswitch_5f
0x6 -> :sswitch_7b
0x7 -> :sswitch_8d
0x8 -> :sswitch_9b
0x9 -> :sswitch_a9
0xa -> :sswitch_e3
0xb -> :sswitch_f1
0xc -> :sswitch_10b
0xd -> :sswitch_132
[B]0xe -> :sswitch_140[/B]
0x5f4e5446 -> :sswitch_8
.end sparse-switch
.end method

2.2 Editing smali/com/android/internal/statusbar/IStatusBarService$Stub$Proxy.smali

Here are the steps:

Insert these function code to the end of the file:

.method public onNotificationClear(Ljava/lang/String;Ljava/lang/String;I)V
.registers 9
.parameter "pkg"
.parameter "tag"
.parameter "id"
.annotation system Ldalvik/annotation/Throws;
value = {
Landroid/os/RemoteException;
}
.end annotation

.prologue
.line 359
invoke-static {}, Landroid/os/Parcel;->obtain()Landroid/os/Parcel;

move-result-object v0

.line 360
.local v0, _data:Landroid/os/Parcel;
invoke-static {}, Landroid/os/Parcel;->obtain()Landroid/os/Parcel;

move-result-object v1

.line 362
.local v1, _reply:Landroid/os/Parcel;
:try_start_8
const-string v2, "com.android.internal.statusbar.IStatusBarService"

invoke-virtual {v0, v2}, Landroid/os/Parcel;->writeInterfaceToken(Ljava/lang/String;)V

.line 363
invoke-virtual {v0, p1}, Landroid/os/Parcel;->writeString(Ljava/lang/String;)V

.line 364
invoke-virtual {v0, p2}, Landroid/os/Parcel;->writeString(Ljava/lang/String;)V

.line 365
invoke-virtual {v0, p3}, Landroid/os/Parcel;->writeInt(I)V

.line 366
iget-object v2, p0, Lcom/android/internal/statusbar/IStatusBarService$Stub$Proxy;->mRemote:Landroid/os/IBinder;

const/16 v3, 0xa

const/4 v4, 0x0

invoke-interface {v2, v3, v0, v1, v4}, Landroid/os/IBinder;->transact(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z

.line 367
invoke-virtual {v1}, Landroid/os/Parcel;->readException()V
:try_end_21
.catchall {:try_start_8 .. :try_end_21} :catchall_28

.line 370
invoke-virtual {v1}, Landroid/os/Parcel;->recycle()V

.line 371
invoke-virtual {v0}, Landroid/os/Parcel;->recycle()V

.line 373
return-void

.line 370
:catchall_28
move-exception v2

invoke-virtual {v1}, Landroid/os/Parcel;->recycle()V

.line 371
invoke-virtual {v0}, Landroid/os/Parcel;->recycle()V

throw v2
.end method

Find this code in the file :

[B]const/16 v3, 0xc

const/4 v4, 0x0[/B]

invoke-interface {v2, v3, v0, v1, v4}, Landroid/os/IBinder;->transact(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z

The bold one must match on one of the switch case value at the end of IStatusBarService$Stub.smali,

Save.

2.3 editing smali/com/android/internal/statusbar/IStatusBarService.smali

Insert this function code to the file.

.method public abstract onNotificationClear(Ljava/lang/String;Ljava/lang/String;I)V
.annotation system Ldalvik/annotation/Throws;
value = {
Landroid/os/RemoteException;
}
.end annotation
.end method

And with this we are done editing the files.

You now have modded the rom that you like to have the swipe to remove notifications.

Cheers..

:)