[Q] Wake device with another button! - Sony Xperia L

Hi my friends!
Anybody know how to wake the Xperia L with another button than the power one? The power button is very weak, and i prefer to unlock it with another. What files must be edited? I know some keylayout related files are in system/usr/keylayout, but i don't know what to edit.
Thanks in advance, and sorry for my english!

Use Auto Screen On frm google play. Works through proximity sensor.
Sent from my C2104 using xda app-developers app

I know about that app, but is there a way to get the feature by editing the layout?
Escrito desde mi Xperia L y weá

Bro... android.policy.jar is the file you need to edit (com\android\internal\policy\impl\PhoneWindowManager.smali)!
All key events are intercepted into interceptKeyBeforeDispatching method. There you will find a switch function that checks all key codes events and do the job. Power key related codes are into 1a hex switch and under its "case" statement sswitch_1e3). See google docs under KEYCODE_POWER
Red is KEYCODE_POWER switch (1a) pointing to its case sswitch_1e3)
Code:
.line 3775
nop
:sswitch_data_338
.sparse-switch
0x5 -> :sswitch_71
0x6 -> :sswitch_199
0x18 -> :sswitch_aa
0x19 -> :sswitch_aa
[COLOR="red"]0x1a -> :sswitch_1e3[/COLOR]
0x1b -> :sswitch_2dd
0x4f -> :sswitch_284
0x55 -> :sswitch_276
0x56 -> :sswitch_284
0x57 -> :sswitch_284
0x58 -> :sswitch_284
0x59 -> :sswitch_284
0x5a -> :sswitch_284
0x5b -> :sswitch_284
0x7e -> :sswitch_276
0x7f -> :sswitch_276
0x82 -> :sswitch_284
0xa4 -> :sswitch_aa
0x400 -> :sswitch_2bd
0x401 -> :sswitch_32a
.end sparse-switch
.end method
All you need to do is to remap related code with key code you want!! It´s not so easy, but totally possible!!

serajr said:
Bro... android.policy.jar is the file you need to edit (com\android\internal\policy\impl\PhoneWindowManager.smali)!
All key events are intercepted into interceptKeyBeforeDispatching method. There you will find a switch function that checks all key codes events and do the job. Power key related codes are into 1a hex switch and under its "case" statement sswitch_1e3). See google docs under KEYCODE_POWER
Red is KEYCODE_POWER switch (1a) pointing to its case sswitch_1e3)
Code:
.line 3775
nop
:sswitch_data_338
.sparse-switch
0x5 -> :sswitch_71
0x6 -> :sswitch_199
0x18 -> :sswitch_aa
0x19 -> :sswitch_aa
[COLOR="red"]0x1a -> :sswitch_1e3[/COLOR]
0x1b -> :sswitch_2dd
0x4f -> :sswitch_284
0x55 -> :sswitch_276
0x56 -> :sswitch_284
0x57 -> :sswitch_284
0x58 -> :sswitch_284
0x59 -> :sswitch_284
0x5a -> :sswitch_284
0x5b -> :sswitch_284
0x7e -> :sswitch_276
0x7f -> :sswitch_276
0x82 -> :sswitch_284
0xa4 -> :sswitch_aa
0x400 -> :sswitch_2bd
0x401 -> :sswitch_32a
.end sparse-switch
.end method
All you need to do is to remap related code with key code you want!! It´s not so easy, but totally possible!!
Click to expand...
Click to collapse
Thanks my friend, i'll take a look!
Escrito desde mi Xperia L y weá

Related

[HOWTO]Implement Swipe to Remove Notification

Hi there, I want to share this tutorial for implementing Swipe-to-Remove Notification feature found in CyanogenMod to stock ROM (Gingerbread or earlier ROM). Sure it will be available on ICS but for those who like to add one to their custom ROM here's how Currently i don't know to whom should i give credit to, if anybody knows please post below and i'll add the link for the original modder. Thanks to:
1. like-p for help showing me what files to be edited
2. LeoMar75 for some info on how to control Stub switch case
This mod is based on Sony Ericsson Xperia Ray, so take care when adding to another device, some code might be different though so no direct copy paste, please learn some of the line first.
PS: For Froyo mod, please follow Jason-EX here
Requirement:
1. decompiled Framework.jar with Baksmali manager
2. decompiled SystemUI.apk with APK Multi Tool
3. Some Basic understanding about editing xml file and smali code.
4. WinMerge or other comparison tool (to better editing and comparing with my sample file)
5. Backup the framework.jar and SystemUI.apk first!
Files to be edited:
in SystemUI.apk
res/anim/
res/layout/status_bar_latest_event.xml
res/values/public.xml
smali/com/android/systemui/statusbar/LatestItemContainer$1.smali
smali/com/android/systemui/statusbar/LatestItemContainer.smali
smali/com/android/systemui/statusbar/StatusBarService$7.smali (or depends on your numbering, could be $8 or larger)
smali/com/android/systemui/statusbar/StatusBarService.smali
in framework.jar:
smali/com/android/internal/statusbar/IStatusBarService$Stub$Proxy.smali
smali/com/android/internal/statusbar/IStatusBarService$Stub.smali
smali/com/android/internal/statusbar/IStatusBarService.smali
UPDATE: This is the additional guide for other device when editing StatusBarService.smali. See here:
1. HTC based
2. Samsung based
Alright, let's mod one by one
1. Editing SystemUI.apk
1.1 Editing res/anim
We are registering anim object here, so swipe animation can be done.
Create folder anim (if 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
Code:
<?xml version="1.0" encoding="utf-8"?>
<translate android:duration="@android:integer/config_mediumAnimTime" android:fromXDelta="0.0" android:toXDelta="-100.0%p"
xmlns:android="http://schemas.android.com/apk/res/android" />
for slide_out_right_basic.xml, edit the file and fill with this
Code:
<?xml version="1.0" encoding="utf-8"?>
<translate android:duration="@android:integer/config_mediumAnimTime" android:fromXDelta="0.0" android:toXDelta="100.0%p"
xmlns:android="http://schemas.android.com/apk/res/android" />
Save both
Update: Mirko ddd (&shoman94 have pointed that out before but i have no idea where to change, sorry mate) have given me the tip to improve the gesture. read his post here Thanks mate, both of you!
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)
Code:
<?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
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:
Recompile your apk after putting anim file into /res folder
Decompile again the resulting apk
Inside /res/values/public.xml, you'll found something like this:
Code:
<resources>
.
.
.
[B]
<public type="anim" name="slide_out_left_basic" id="0x7f0c0000" />
<public type="anim" name="slide_out_right_basic" id="0x7f0c0001" />
[/B]
</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.
Code:
.line 53
:cond_0
const/high16 v1, [B]0x7f0c[/B]
and
Code:
.line 51
const v1, [B]0x7f0c0001[/B]
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
If StatusBarService$7.smali does not exist before, just place it inside, if not, skip this step.
If StatusBarService$7.smali exists, Please rename the file to StatusBarService$8.smali (or whatever higher number that is unused) and rename all the line inside the file from
Code:
StatusBarService$7
to
Code:
StatusBarService$8
1.6 Edit smali/com/android/systemui/statusbar/StatusBarService.smali
UPDATE: This is the additional guide for other device when editing StatusBarService.smali. See here:
1. Generic java readout
2. HTC based
3. Samsung based
This is the file that generate NotificationView. Please take care of the changes here more carefully because there might be some differences between vendors in this file. Here are the steps:
Open StatusBarService.smali and find this function
Code:
.method makeNotificationView(Lcom/android/internal/statusbar/StatusBarNotification;Landroid/view/ViewGroup;)[Landroid/view/View;
Find this code in the makeNotificationView function body:
Code:
invoke-virtual {v0, v1, v2, v3}, Landroid/view/LayoutInflater;->inflate(ILandroid/view/ViewGroup;Z)Landroid/view/View;
move-result-object v18
const v4, 0x7f0b0014
move-object/from16 v0, v18
move v1, v4
invoke-virtual {v0, v1}, Landroid/view/View;->findViewById(I)Landroid/view/View;
move-result-object v10
Insert the bold code below between the existing code:
Code:
invoke-virtual {v0, v1, v2, v3}, Landroid/view/LayoutInflater;->inflate(ILandroid/view/ViewGroup;Z)Landroid/view/View;
move-result-object v18
[B] check-cast v18, Lcom/android/systemui/statusbar/LatestItemContainer;
.line 516
.local v18, row:Lcom/android/systemui/statusbar/LatestItemContainer;
move-object/from16 v0, v16
iget v0, v0, Landroid/app/Notification;->flags:I
move v4, v0
and-int/lit8 v4, v4, 0x2
if-nez v4, :cond_swno
move-object/from16 v0, v16
iget v0, v0, Landroid/app/Notification;->flags:I
move v4, v0
and-int/lit8 v4, v4, 0x20
if-nez v4, :cond_swno
new-instance v4, Lcom/android/systemui/statusbar/StatusBarService$7;
move-object v0, v4
move-object/from16 v1, p0
move-object/from16 v2, p1
invoke-direct {v0, v1, v2}, Lcom/android/systemui/statusbar/StatusBarService$7;-><init>(Lcom/android/systemui/statusbar/StatusBarService;Lcom/android/internal/statusbar/StatusBarNotification;)V
move-object/from16 v0, v18
move-object v1, v4
invoke-virtual {v0, v1}, Lcom/android/systemui/statusbar/LatestItemContainer;->setOnSwipeCallback(Ljava/lang/Runnable;)V
.line 735
:cond_swno[/B]
const v4, 0x7f0b0014
move-object/from16 v0, v18
move v1, v4
[B] invoke-virtual {v0, v1}, Lcom/android/systemui/statusbar/LatestItemContainer;->findViewById(I)Landroid/view/View;[/B]
move-result-object v10
Once again, change
Code:
StatusBarService$7
to
Code:
StatusBarService$8
line if you happened to have StatusBarService$8.smali as the result of renaming on the previous step.
IMPORTANT LOGIC TO BE UNDERSTOOD: This step tells the function to:
1. cast the already made View Object to LatestItemContainer instead of using LatestView class.
2. Filter if the Notification is removable or not
3. the LatestItemContainer object (v18) is assigned with onSwipeCallback(new StatusBarService$7)
Change the following (still on the same function body):
Code:
move v1, v4
invoke-virtual {v0, v1}, Landroid/view/View;->setDrawingCacheEnabled(Z)V
.line 542
const/4 v4, 0x3
to
Code:
move v1, v4
[B] invoke-virtual {v0, v1}, Lcom/android/systemui/statusbar/LatestItemContainer;->setDrawingCacheEnabled(Z)V
[/B]
.line 542
const/4 v4, 0x3
Please note:
StatusBarService.smali might be different between vendor, so please adapt with your .smali to implement the above coding.
2. Editing framework.jar
2.1 editing smali/com/android/internal/statusbar/IStatusBarService$Stub.smali
Here are the steps:
Add this code on variable declaration part inside the file
Code:
.field static final TRANSACTION_onClearAllNotifications:I = 0xb
[B].field static final TRANSACTION_onNotificationClear:I = 0xc[/B]
.field static final TRANSACTION_onNotificationClick:I = 0x9
.field static final TRANSACTION_onNotificationError:I = 0xa
If the 0xc is already used on another static value, you must change it so it remains unique.
Find this code:
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 to
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
[B]sparse-switch p1, :sswitch_data_13e[/B]
Insert/replace this code (it is at the end of the file):
Code:
.line 176
const/4 v0, 0x1
goto/16 :goto_7
.line 39
: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
to
Code:
[B]
.line 176
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_124
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_13e
.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
[B]0xc -> :sswitch_124[/B]
0x5f4e5446 -> :sswitch_8
.end sparse-switch
it's important to note this
Code:
[B]0xc -> :sswitch_124[/B]
If you rename the static at the previous steps, please change the 0xc accordingly.
2.2 Editing smali/com/android/internal/statusbar/IStatusBarService$Stub$Proxy.smali
Here are the steps:
Insert these function code to the file:
Code:
.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
Please inspect the code for this part:
Code:
[B]const/16 v3, 0xa[/B]
const/4 v4, 0x0
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,
in my phone actually the valid one is the TRANSACTION_onNotificationError (0xa) so if your NotificationError is not 0xa but 0xb for example, please change the bold one to 0xb
Save
2.3 editing smali/com/android/internal/statusbar/IStatusBarService.smali
Insert this function code to the file. Here are the steps:
Insert these function code to the file:
Code:
.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
Save
There you have it AFAIK, the files that you need to take care more than others are:
1. smali/com/android/systemui/statusbar/StatusBarService.smali
2. res/values/public.xml
The rest can be applied from the attachment below directly. Ok that's all, after you are done, compile both SystemUI.apk and Framework.jar.
How to Compile the right way?
1. SystemUI.apk ->
Compile with APK Multi Tool, press y and y twice with all the requested input,
delete modified file from keep folder, and after that continue compiling.
Copy from original APK the META-INF and AndroidManifest.xml to the unsignedSystemUI.apk
rename unsignedSystemUI.apk to signedSystemUI.apk
select Zipalign from APK Multi Tool to optimize apk.
Rename to SystemUI.apk (move the original one just in case)
2. framework.jar ->
Smali inside Baksmali Manager
Replace classes.dex inside framework.jar with the generated one.
and apply on your phone.
Hope this helps you (programmer ofc, not end user ) to implement on your device.
G'day!
Mate, thank you so much for this - I have been trying to figure it out for our ROM for weeks LOL I'm going to give it a try this evening and I'll let you know if I get it! Thanks again
Dunc001 said:
Mate, thank you so much for this - I have been trying to figure it out for our ROM for weeks LOL I'm going to give it a try this evening and I'll let you know if I get it! Thanks again
Click to expand...
Click to collapse
Ok let me know mate
ill try it on my SGY
Looks fun! great post
tommytomatoe said:
Looks fun! great post
Click to expand...
Click to collapse
Updated step, to give you some warning about StatusBarService$7 naming convention
definitely gonna give this a try!!
great akaka.try it soon.
did u know how to port ICS layout to stock rom? can u write a tut?
this will be great!!
nvt992 said:
great akaka.try it soon.
did u know how to port have ICS layout to stock rom? can u write a tut?
this will be great!!
Click to expand...
Click to collapse
What layout? Do you mean ICS launcher layout or..?
no.see my attach
nvt992 said:
no.see my attach
Click to expand...
Click to collapse
Well do you have the original link? First, i know nothing about that, so i should learn first. and secondly, it's more about theme editing, so i think it's more about editing XML inside SystemUI.apk rather than coding a .smali like above. Thirdly, the shortcut for setting in ICS IMHO is not as efficient as Power Widget Status Bar.
hansip87 said:
Well do you have the original link? First, i know nothing about that, so i should learn first. and secondly, it's more about theme editing, so i think it's more about editing XML inside SystemUI.apk rather than coding a .smali like above. Thirdly, the shortcut for setting in ICS IMHO is not as efficient as Power Widget Status Bar.
Click to expand...
Click to collapse
this is for cm7
patch http://forum.xda-developers.com/showthread.php?t=1324924
or original theme
http://forum.xda-developers.com/showthread.php?t=1334922
hope u can do it
nvt992 said:
this is for cm7
patch http://forum.xda-developers.com/showthread.php?t=1324924
or original theme
http://forum.xda-developers.com/showthread.php?t=1334922
hope u can do it
Click to expand...
Click to collapse
Well ok thanks but don't count on me ok because i am currently researching for 2G/3G toggle button for PowerWidget, this one is not that high on my list, but you never know..
ok thank you
where can i get Baksmali manager?
lasmaty07 said:
where can i get Baksmali manager?
Click to expand...
Click to collapse
Check back later mate, just uploading right now because of on the original link, it's dead. I'll upload it for us all to share
EDIT: Uploaded. Click Baksmali Manager link on the first page to download. APK Multi Tool can be found on the same parent thread (Hacking General)
Done, but get this error when recompiling .apk
Code:
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\me\Desktop\folder>apktool.bat b -f -d out
I: Smaling...
Exception in thread "main" brut.androlib.AndrolibException: Could not smali file
: [email protected]
at brut.androlib.src.DexFileBuilder.addSmaliFile(Unknown Source)
at brut.androlib.src.DexFileBuilder.addSmaliFile(Unknown Source)
at brut.androlib.src.SmaliBuilder.buildFile(Unknown Source)
at brut.androlib.src.SmaliBuilder.build(Unknown Source)
at brut.androlib.src.SmaliBuilder.build(Unknown Source)
at brut.androlib.Androlib.buildSourcesSmali(Unknown Source)
at brut.androlib.Androlib.buildSources(Unknown Source)
at brut.androlib.Androlib.build(Unknown Source)
at brut.androlib.Androlib.build(Unknown Source)
at brut.apktool.Main.cmdBuild(Unknown Source)
at brut.apktool.Main.main(Unknown Source)
Tried to do it manually like this and using apk multitool, but same error in log.
even tried to compile just after decompiling but that's no help.. same error
Any help?
jaggyjags said:
Done, but get this error when recompiling .apk
Code:
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\me\Desktop\folder>apktool.bat b -f -d out
I: Smaling...
Exception in thread "main" brut.androlib.AndrolibException: Could not smali file
: [email protected]
at brut.androlib.src.DexFileBuilder.addSmaliFile(Unknown Source)
at brut.androlib.src.DexFileBuilder.addSmaliFile(Unknown Source)
at brut.androlib.src.SmaliBuilder.buildFile(Unknown Source)
at brut.androlib.src.SmaliBuilder.build(Unknown Source)
at brut.androlib.src.SmaliBuilder.build(Unknown Source)
at brut.androlib.Androlib.buildSourcesSmali(Unknown Source)
at brut.androlib.Androlib.buildSources(Unknown Source)
at brut.androlib.Androlib.build(Unknown Source)
at brut.androlib.Androlib.build(Unknown Source)
at brut.apktool.Main.cmdBuild(Unknown Source)
at brut.apktool.Main.main(Unknown Source)
Tried to do it manually like this and using apk multitool, but same error in log.
even tried to compile just after decompiling but that's no help.. same error
Any help?
Click to expand...
Click to collapse
APKTools is a bit outdated and i'm afraid some incompatibilites with Google SDK might be the source of the problem. search APK Multi Tools and use that one instead with SDK release 16 and up.
Hello, and thanks for the how-to!
Sadly I couldn't get it to work on my phone (Motorola Atrix 2). Some of the smali files were pretty different... I tried my best but there were definitely moments when I wasn't sure if I was doing the correct thing... SystemUI won't compile.
Hi, all. Seems the statusbarservice.smali is very different from each other. So to help you all, this is the java code that should give you a better understanding. Please read here https://github.com/nadlabak/android...m/android/server/status/StatusBarService.java
Sent from my ST18i using XDA App

[TUT]How to have Auto Rotate Home

Hi Guys, have you ever loved the stock launcher (like i did with SE stock launcher ) but wishes that it would auto rotate on your keyboard-less phone and you don't want any extra launcher? Have you ever popped out to your home launcher (after running an app) and finding the layout is rotated but soon to be set as portrait, and you want that landscape mode? Well you can actually
This is the requirement:
Home.apk of your phone
AutoAPKTool or APKMultiTool to decompile and recompile
Google SDK
Any editing and searching program (e.g. Notepad++ and WinGrep)
The steps are:
Backup your Home.apk
Decompile and Find the HomeActivity.smali
Change the Orientation Flag
Compile back and apply to the phone
The following sample is taken from my Modified Home.apk in Sony Ericsson, but should be comparable to all Launcher
These are the steps:
1. Backup your Home.apk
This is to prevent some unwanted behaviour since a home.apk is essentially your gateway to all apps so please make sure to backup (and create flashable zip to make it easier to revert back)
2. Decompile and Find the HomeActivity.smali
The idea is to find the Main Activity Class of Home Launcher (Activity is, in easier language, is the display of the active app on the screen)
Decompile the Home.apk first and find the Home Activity class.
In my sample from SE ICS Beta ROM, the file that needs to be edited is named smali\com\sonyericsson\home\HomeActivity.smali
3. Change Orientation Flag
If you have found it on the previous page, open it and find any line that contains this function
Code:
iget v6, p0, Lcom/sonyericsson/home/HomeActivity;->mDefaultOrientation:I
invoke-virtual {p0, v6}, Lcom/sonyericsson/home/HomeActivity;->[B]setRequestedOrientation(I)V[/B]
The Bold line is the essential function that determine your preferred orientation of home.apk.
After you found it, you must find the variable that used as the default orientation. From my sample above, it can be read as
Code:
[I]//this, in smali code, is p0[/I]
[B]
v6 = this.mDefaultOrientation;
this.setRequestedOrientation(v6);
[/B]
So the variable used here is the v6, which is stored before as this.mDefaultOrientation. Now your task is to find out what variable name that is used to store your Orientation Flag, and then later you need to watch for it if that variable get changed in the line.
My sample code is like this:
Code:
.method public constructor <init>()V
.
.
const v0, 0x5
iput v0, p0, Lcom/sonyericsson/home/HomeActivity;->mDefaultOrientation:I
.
.
.end method
.method public onCreate(Landroid/os/Bundle;)V
const v13, 0x4
.
.
const v10, 0x5
iput v10, p0, Lcom/sonyericsson/home/HomeActivity;->mDefaultOrientation:I
.
.
:goto_1
iget v6, p0, Lcom/sonyericsson/home/HomeActivity;->mDefaultOrientation:I
invoke-virtual {p0, v6}, Lcom/sonyericsson/home/HomeActivity;->setRequestedOrientation(I)V
.
.
.local v5, uiModeManager:Landroid/app/UiModeManager;
invoke-virtual {v5}, Landroid/app/UiModeManager;->getCurrentModeType()I
move-result v6
if-ne v6, v7, :cond_b
.line 580
const v6, 0x5
iput v6, p0, Lcom/sonyericsson/home/HomeActivity;->mDefaultOrientation:I
goto/16 :goto_1
.line 582
:cond_b
iput v13, p0, Lcom/sonyericsson/home/HomeActivity;->mDefaultOrientation:I
goto/16 :goto_1
.
.
.end method
As you see:
1. the init and OnCreate function assigns the default value to mDefaultOrientation of the Object and evaluates it if you have a docking function on the phone cond_b above).
2. The flag used above is set at 0x5 value, which is value of ActivityInfo.SCREEN_ORIENTATION_NOSENSOR (No sensor data will be applied to change orientation of the phone). To modify it, we need to modify that value to ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED which means it will follow device autoRotate settings.
3. In Sony Ericsson where there are docking accessories, they implement them as 0x4 (ActivityInfo.SCREEN_ORIENTATION_SENSOR) which means the device will always change the home orientation even though we turn off auto Rotate.
So, based on that info i changed the above lines to the following
Code:
.method public constructor <init>()V
.
.
[B]const v0, -0x1[/B]
iput v0, p0, Lcom/sonyericsson/home/HomeActivity;->mDefaultOrientation:I
.
.
.end method
.method public onCreate(Landroid/os/Bundle;)V
const v13, 0x4
.
.
[B]const v10, -0x1[/B]
iput v10, p0, Lcom/sonyericsson/home/HomeActivity;->mDefaultOrientation:I
.
.
:goto_1
iget v6, p0, Lcom/sonyericsson/home/HomeActivity;->mDefaultOrientation:I
invoke-virtual {p0, v6}, Lcom/sonyericsson/home/HomeActivity;->setRequestedOrientation(I)V
.
.
.local v5, uiModeManager:Landroid/app/UiModeManager;
invoke-virtual {v5}, Landroid/app/UiModeManager;->getCurrentModeType()I
move-result v6
if-ne v6, v7, :cond_b
.line 580
[B]const v6, -0x1[/B]
iput v6, p0, Lcom/sonyericsson/home/HomeActivity;->mDefaultOrientation:I
goto/16 :goto_1
.line 582
:cond_b //I keep this line to have 0x4 flag since it doesn't have to be taken care of.
iput v13, p0, Lcom/sonyericsson/home/HomeActivity;->mDefaultOrientation:I
goto/16 :goto_1
.
.
.end method
4. Compile back and Apply
Compile the Home.apk and don't forget to put the original MANIFEST Folder from original Home.apk so the Home.apk is signed
Voila, my Home Launcher is auto rotated now
CAUTION: Some error may occur at the first time you apply this mod (Possibly because of some unfit widgets on home when auto rotated). If it gives you error, please flash the stock one you backed up before and the home will be reset and then reapply the modded home. It should work
For further references, You can go to:
http://developer.android.com/reference/android/content/pm/ActivityInfo.html - For any kind of Orientation flag info
http://forum.xda-developers.com/showthread.php?t=1511730 - How-to of decompile and recompile APK (especially ICS)
Any question, please feel free to ask
G'day!
I couldn't get why 0x5 changed to -0x1, does that make the value to 0x4?
Sorry new in smali
fundre said:
I couldn't get why 0x5 changed to -0x1, does that make the value to 0x4?
Sorry new in smali
Click to expand...
Click to collapse
Please refer to google sdk link that i gave on the op. 0x5 is for no sensor behaviour. -0x1 means the orientation behaviour relies on device setting.
sent from my white ray using XDA App
Help please
brov please help me out, i dnt seem to understand anything when i open it with notepad+++
have attached my home.apk.....
I was very confused, because in my code a lot of orientation variable , please check
this is the source code from jd-gui
Code:
public void onCreate(Bundle paramBundle)
{
Context localContext = getApplicationContext();
this.mPackageLoader = ((HomeApplication)getApplication()).getPackageLoader();
this.mInfoGroupManager = ((HomeApplication)getApplication()).getInfoGroupManager();
MyInstanceState localMyInstanceState = (MyInstanceState)getLastNonConfigurationInstance();
label91: boolean bool;
label222: Object localObject1;
if (localMyInstanceState != null)
{
this.mResourceLoader = localMyInstanceState.resourceLoader;
this.mAdapterHelper = localMyInstanceState.adapterHelper;
this.mStatistics = localMyInstanceState.statistics;
this.mLandscapeModeEnabled = true;
this.mThemeOptionEnabled = true;
if (this.mLandscapeModeEnabled)
break label990;
this.mDefaultOrientation = 1;
setRequestedOrientation(this.mDefaultOrientation);
this.mDeskStandListener = new DeskStandListener(null);
this.mStartupMap = new LinkedHashMap();
this.mStartupMap.put("Application", roundToNearest100(((HomeApplication)getApplication()).getApplicationCreateDuration()) + "");
this.mOnCreateStartTime = SystemClock.uptimeMillis();
super.onCreate(paramBundle);
setContentView((ViewGroup)LayoutInflater.from(this).inflate(2130903060, null));
getWindow().setSoftInputMode(3);
if (getResources().getConfiguration().orientation != 2)
break label1033;
bool = true;
this.mOrientationLandscape = bool;
this.mDisplayMetrics = getResources().getDisplayMetrics();
this.mFullScreenEffectPlaceholder = ((ViewGroup)findViewById(2131624002));
this.mFadeView = ((BackgroundFadeSrcXferView)findViewById(2131623998));
setWallpaperDimensions();
this.mTransferView = ((TransferView)findViewById(2131623997));
setupTransferView(this.mTransferView);
this.mSwitchButtonHideAnim = AnimationUtils.loadAnimation(this, 2130968638);
this.mSwitchButtonShowAnim = AnimationUtils.loadAnimation(this, 2130968639);
this.mNetworkNameManager = new NetworkNameManager((NetworkNameView)findViewById(2131624004));
this.mSwitchButtonHideAnim.setInterpolator(new DecelerateInterpolator());
setDefaultKeyMode(4);
this.mAppTrayButton = findViewById(2131623964);
this.mAppTrayButton.setOnClickListener(new View.OnClickListener()
{
public void onClick(View paramView)
{
HomeActivity.this.hideDesktopAndOpenApptay(true);
}
});
this.mHomeButton = findViewById(2131623949);
this.mAppTrayButton.requestFocus();
this.mHomeButton.setOnClickListener(new View.OnClickListener()
{
public void onClick(View paramView)
{
if (HomeActivity.this.mStageController != null)
HomeActivity.this.mStageController.sparkle();
HomeActivity.this.closeApptrayAndShowDesktop(true);
}
});
createActivityFlow();
this.mOnTouchModeChangeListener = new ViewTreeObserver.OnTouchModeChangeListener()
{
public void onTouchModeChanged(boolean paramBoolean)
{
if ((!paramBoolean) && (HomeActivity.this.mStealFocusNextModeChange))
HomeActivity.this.mTransferView.setDescendantFocusability(393216);
HomeActivity.access$402(HomeActivity.this, true);
}
};
this.mInfoGroupManager.setInfoListener(new InfoGroupManager.InfoListener()
{
public void onInfoRemoved(Info paramInfo)
{
HomeActivity.this.removeInfo(paramInfo);
}
});
this.mInfoGroupManager.bind(this, this.mResourceLoader);
this.mWidgetManager = new WidgetManager(localContext, AppWidgetManager.getInstance(localContext), new HomeAppWidgetHost(localContext, 171808569));
this.mAdvWidgetManager = new AdvWidgetManager(this, this.mAdvWidgetHost, this.mPackageLoader);
createDesktop();
if (localMyInstanceState == null)
break label1039;
localObject1 = localMyInstanceState.stageModel;
label518: createStage(localObject1);
createCornerButtons();
if (localMyInstanceState == null)
break label1045;
}
label1025: label1033: label1039: label1045: for (Object localObject2 = localMyInstanceState.apptrayModel; ; localObject2 = null)
{
while (true)
{
createAppTray(localObject2);
createFolderLayer();
createAppShareDropZone();
createTrashcan();
if (localMyInstanceState != null)
{
if (localMyInstanceState.apptrayIsOpen)
{
hideDesktopAndOpenApptay(false);
this.mAppTrayController.moveToPane(localMyInstanceState.apptrayPane);
if (localMyInstanceState.apptrayIsEditing)
this.mAppTrayController.enterEditMode();
}
if (localMyInstanceState.isInOverview)
{
this.mDesktopController.setOverviewProgress(localMyInstanceState.overviewProgress);
if (this.mCornerController != null)
this.mCornerController.hide(false);
}
if (localMyInstanceState.isFolderOpen)
{
openFolder(localMyInstanceState.openFolder, localMyInstanceState.openFolderSourceLayer, localMyInstanceState.openFolderSourceLocation, false);
if (localMyInstanceState.openFolderRenaming)
this.mFolderController.setRenamingFolder(true);
}
if ((this.mStageController != null) && (localMyInstanceState.stageCreatingFolder))
{
this.mStageController.setCreatingFolder(true);
this.mStageController.setDroppedAtInfo(localMyInstanceState.stageDroppedAtInfo);
this.mStageController.setSavedPickedUpInfo(localMyInstanceState.stageSavedPickedUpInfo);
this.mStageController.setHintLocation(localMyInstanceState.stageHintLocation);
}
if ((this.mCornerController != null) && (localMyInstanceState.openCorner != -1))
this.mCornerController.expandCorner(localMyInstanceState.openCorner, false);
this.mSavedFolderText = localMyInstanceState.savedFolderText;
this.mAddingFolder = localMyInstanceState.addingFolder;
this.mRenamingFolder = localMyInstanceState.openFolderRenaming;
this.mAddTo = localMyInstanceState.addTo;
this.mDesktopLongPressLocation = localMyInstanceState.addFolderToDesktopLocation;
this.mStageLocation = localMyInstanceState.addFolderToStageLocation;
this.mAppTrayController.setButtonsDisabled(localMyInstanceState.apptrayDisableDuringSortDialog);
}
createBadgeBroadcastReceiver();
this.mStartupMap.put("onCreate", roundToNearest100(SystemClock.uptimeMillis() - this.mOnCreateStartTime) + "");
setupSmartSlider();
Configuration localConfiguration = getResources().getConfiguration();
this.mCurrentMcc = localConfiguration.mcc;
this.mCurrentMnc = localConfiguration.mnc;
if (this.mAddingFolder)
this.mActivityFlow.addFolder(this.mAddFolderListener, this.mSavedFolderText);
if (this.mRenamingFolder)
this.mFolderController.onCreate();
return;
this.mResourceLoader = new ResourceLoader(localContext, this.mPackageLoader, this.mInfoGroupManager, ((HomeApplication)getApplication()).getBadgeManager());
this.mAdapterHelper = new AdapterHelper(localContext, this.mResourceLoader);
this.mStatistics = new Statistics(localContext, this.mPackageLoader);
break;
try
{
label990: if (((UiModeManager)getSystemService("uimode")).getCurrentModeType() != 1)
break label1025;
this.mDefaultOrientation = 5;
}
catch (NoClassDefFoundError localNoClassDefFoundError)
{
this.mDefaultOrientation = 5;
}
}
break label91;
this.mDefaultOrientation = 4;
break label91;
bool = false;
break label222;
localObject1 = null;
break label518;
}
}
this is on smali code
Code:
.method public constructor <init>()V
.locals 1
.prologue
.line 137
invoke-direct {p0}, Landroid/app/Activity;-><init>()V
.line 332
[B]const/4 v0, -0x1[/B]
iput v0, p0, Lcom/sonyericsson/home/HomeActivity;->mDefaultOrientation:I
thanks...
Thank you very much. I won't use auto rotate, but you have helped me understand smali (a pretty weird language) well enough to do something else: disable themes in Home.apk (disable the menu item and the button in the long-press menu).
To make myself helpful, if someone wants to do that (themes are pretty useless if you don't have a real xperia S, because they only change the background), here's how I did it. It's very similar to the auto-rotate thing, you just need to flip a flag.
I changed this in HomeActivity.smali (line 3156 in version 2.2.A.0.14):
Code:
.line 571
const/4 v7, 0x1
iput-boolean v7, p0, Lcom/sonyericsson/home/HomeActivity;->mThemeOptionEnabled:Z
to this (the change is underlined):
Code:
.line 571
const/4 v7, [B][U]0x0[/U][/B]
iput-boolean v7, p0, Lcom/sonyericsson/home/HomeActivity;->mThemeOptionEnabled:Z
It didnt work!
i tool a stock HOME.APK... changed all the values like you did and nothing :\
and my xperia xro used to do it a few days ago by itself even when the keyboard is not out... than it rotated only when the charger was in... and now... nothing :\
any tips?
rmeker said:
It didnt work!
i tool a stock HOME.APK... changed all the values like you did and nothing :\
and my xperia xro used to do it a few days ago by itself even when the keyboard is not out... than it rotated only when the charger was in... and now... nothing :\
any tips?
Click to expand...
Click to collapse
Try downloading Rotation Locker and that'll be able to rotate any app or part of your device you'd like.
I'm a product of the system I was born to destroy!
KidCarter93 said:
Try downloading and that'll be able to rotte any app or part of your device you'd like.
a
I'm a product of the system I was born to destroy!
Click to expand...
Click to collapse
i know that there are tons of apps that do it... i want it to be integrated in the HOME.APK like it used to be...
ok new update... i was able to do it... but the home.apk doesnt work... which means i cant see anything besides my wallpaper... but the wallpaper is autorotating... now what should i do about the non working apk? :\ (I already flashed the old home.apk without the auto-rotate... but i want that feature!!!)

[HOW-TO] Samsung Galaxy S II Plus - Modding Guides

Hello everyone, here, I'll be writing a few guides on how to setup some XML/SMALI mods to aid people on ROM/MOD development. I will try to make everything as simple as possible. However, there will be different difficulty levels for each tutorial, which are [VERY EASY, EASY, MODERATE, HARD, VERY HARD]
GRAB YOUR TOOLS
​Below is a list of essential programs or tools for any sort of modding, which also applies to the guides below.
APKTOOL
Here's how to setup apktool and use it
Notepad++
7zip
Brain
GUIDES
​ADD MORE TOGGLES TO THE NAVIGATION PANEL
Difficulty level: [EASY]
Special thanks to @MalekoUK
​
Decompile SystemUI.apk
Go to \res\values\arrays.xml (Open using Notepad++)
You will see a list similar to this:
Code:
<string-array name="QuickSettingButtonAttribute">
<item>Wifi</item>
<item>Location</item>
<item>SilentMode</item>
<item>AutoRotate</item>
<item>Bluetooth</item>
<item>MobileData</item>
<item>DormantMode</item>
<item>PowerSaving</item>
<item>Sync</item>
</string-array>
This represents the order in which the toggles are placed in the navigation panel.
You can add a toggle for a few stuff which Samsung have disabled by default, here are the available toggles that can be added:
Code:
<item>AirplaneMode</item> - Airplane mode
<item>DoNotDisturb</item> - Disable/enable notifications toggle
<item>DrivingMode</item> - Driving mode
<item>NfcP2p</item> - NFC
<item>SBeam</item> - S Beam
<item>SmartStay</item> - Smart Stay
So if for example we add Smart Stay, just after Power Saving, the new code portion will look like this:
Code:
<string-array name="QuickSettingButtonAttribute">
<item>Wifi</item>
<item>Location</item>
<item>SilentMode</item>
<item>AutoRotate</item>
<item>Bluetooth</item>
<item>MobileData</item>
<item>DormantMode</item>
<item>PowerSaving</item>
[B][COLOR=Red] <item>SmartStay</item>[/COLOR][/B]
<item>Sync</item>
</string-array>
Save and recompile the APK
HOW TO CHANGE THE TOGGLE LABELS (TEXT UNDER TOGGLES)
This is an additional step and you may or may not do it. It is recommended for one weirdly named toggle though, the NFC one, so this is the one we'll be renaming.
Navigate to \res\values\strings.xml (Open using Notepad++)
Use CTRL+F to bring up the search box and enter quickpanel_nfc_text... You will see this line of code:
Code:
<string name="quickpanel_nfc_text">"R/W
P2P"</string>
Change it to:
Code:
<string name="quickpanel_nfc_text">"NFC"</string>
Save and recompile the APK.
INCREASE LOCKSCREEN SHORTCUTS NUMBER TO 4
Difficulty level: [VERY EASY]
Special thanks to @majdinj
Decompile SecSettings.apk
Navigate to \smali\com\android\settings\lockscreenshortcut\LockscreenShortcutSettings.smali
Look for this code
Code:
# direct methods
.method static constructor <clinit>()V
.locals 2
.prologue
const/4 v1, 0x0
.line 79
const/4 v0, 0x3
Change it to this
Code:
# direct methods
.method static constructor <clinit>()V
.locals 2
.prologue
const/4 v1, 0x0
.line 79
const/4 v0, 0x2
Save the file and decompile SecSettings.apk
ENABLE SMART ROTATION
Difficulty level: [VERY EASY]
Special thanks to @majdinj again
Decompile SecSettings.apk
Navigate to \smali\com\android\settings\DisplaySettings.smali
Search for this code portion:
Code:
invoke-virtual {p0}, Lcom/android/settings/DisplaySettings;->getPreferenceScreen()Landroid/preference/PreferenceScreen;
move-result-object v10
iget-object v11, p0, Lcom/android/settings/DisplaySettings;->mSmartRotation:Landroid/preference/CheckBoxPreference;
invoke-virtual {v10, v11}, Landroid/preference/PreferenceScreen;->removePreference(Landroid/preference/Preference;)Z
Delete the 4 lines.
Save the file and recompile SecSettings.apk
More to come...
​
POWER BUTTON AS CAMERA SHUTTER
Difficulty level: [EASY]
Special thanks to @klurosu
His guide
Decompile SamsungCamera.apk
Navigate to \smali\com\sec\android\app\camera and open Camera.smali
As you can see, codes go under specific "methods", like categories, wrapped around .method and .end method tags... So the "category" we'll be going for is:
Code:
.method public onKeyDown(ILandroid/view/KeyEvent;)Z
Scroll down ( a lot, but not too much, just before the .end method of the method we went to) to the following code portion:
Code:
.line 1884
:sswitch_data_0
.sparse-switch
0x4 -> :sswitch_1
0x17 -> :sswitch_4
0x18 -> :sswitch_5
0x19 -> :sswitch_5
[B][COLOR=Blue]0x1a -> :sswitch_1[/COLOR][/B]
0x1b -> :sswitch_4
0x42 -> :sswitch_4
0x45 -> :sswitch_5
0x46 -> :sswitch_5
0x50 -> :sswitch_3
0x52 -> :sswitch_0
0x55 -> :sswitch_2
0x59 -> :sswitch_2
0x5a -> :sswitch_2
0x9c -> :sswitch_5
0x9d -> :sswitch_5
.end sparse-switch
A few things need to be noted here. First, the switch name (sswitch_x) is not always the same as you might have, but the id (0x##) is always the same. Here 0x17 is the shutter key on the screen, and 0x1a is the power button... we need to reroute the power button's switch to the shutter key's switch. So we'll be focusing on the blue line.
Change the code to the following if you haven't already figured it out.
Code:
.line 1884
:sswitch_data_0
.sparse-switch
0x4 -> :sswitch_1
0x17 -> :sswitch_4
0x18 -> :sswitch_5
0x19 -> :sswitch_5
[B][COLOR=Red]0x1a -> :sswitch_4[/COLOR][/B]
0x1b -> :sswitch_4
0x42 -> :sswitch_4
0x45 -> :sswitch_5
0x46 -> :sswitch_5
0x50 -> :sswitch_3
0x52 -> :sswitch_0
0x55 -> :sswitch_2
0x59 -> :sswitch_2
0x5a -> :sswitch_2
0x9c -> :sswitch_5
0x9d -> :sswitch_5
.end sparse-switch
No we're not done yet lazy! The next method is just under the .end method of the previous one, which we were already at, but if you saved and closed the smali out of sheer excitement, reopen it and go to this method:
Code:
.method public onKeyUp(ILandroid/view/KeyEvent;)Z
Now scroll down (a lot, but not too much, right before the .end method tag) to the following code portion:
Code:
:sswitch_data_0
.sparse-switch
0x3 -> :sswitch_5
0x4 -> :sswitch_0
0x17 -> :sswitch_2
0x18 -> :sswitch_3
0x19 -> :sswitch_3
[B][COLOR=Blue]0x1a -> :sswitch_3[/COLOR][/B]
0x1b -> :sswitch_2
0x42 -> :sswitch_2
0x50 -> :sswitch_4
0x52 -> :sswitch_1
.end sparse-switch
Again the switch names might not be the same and we'll focus on the 0x1a switch (blue line), as the previous step, and reroute it to 0x17.
Again, if you haven't figured it out yourself, edit the code to the following:
Code:
:sswitch_data_0
.sparse-switch
0x3 -> :sswitch_5
0x4 -> :sswitch_0
0x17 -> :sswitch_2
0x18 -> :sswitch_3
0x19 -> :sswitch_3
[COLOR=Blue] [COLOR=Red][B]0x1a -> :sswitch_2[/B][/COLOR][/COLOR]
0x1b -> :sswitch_2
0x42 -> :sswitch_2
0x50 -> :sswitch_4
0x52 -> :sswitch_1
.end sparse-switch
Save the file and recompile the APK
CRT-OFF EFFECT
Difficulty level: [EASY]
@Special thanks to @klurosu and @majdinj
klurosu's guide
NEW TOOL MUST BE DOWNLOADED: Classes.dex compiler/decompiler
Download the tool and extract it to a location of your liking and let's begin.
Take services.jar from framework folder and open it with 7zip.
Copy classes.dex from services.jar (opened with 7zip) to the input folder in the folder of the tool we extracted initially.
Run Script.bat and choose "decompile classes.dex"
Navigate to the decompiled folder in the tool folder and go to \com\android\server and openPowerManagerService$ScreenBrightnessAnimator.smali file
Look for the following portion of code:
Code:
.line 3064
.end local v0 #delta:I
:cond_60
:goto_60
iget-object v7, p0, Lcom/android/server/PowerManagerService$ScreenBrightnessAnimator;->this$0:Lcom/android/server/PowerManagerService;
#getter for: Lcom/android/server/PowerManagerService;->mScreenBrightnessHandler:Landroid/os/Handler;
invoke-static {v7}, Lcom/android/server/PowerManagerService;->access$7200(Lcom/android/server/PowerManagerService;)Landroid/os/Handler;
move-result-object v7
const/16 v9, 0xa
invoke-virtual {v7, v9}, Landroid/os/Handler;->removeMessages(I)V
Change it to this: ( add the red lines )
Code:
.line 3064
.end local v0 #delta:I
:cond_60
:goto_60
iget-object v7, p0, Lcom/android/server/PowerManagerService$ScreenBrightnessAnimator;->this$0:Lcom/android/server/PowerManagerService;
#getter for: Lcom/android/server/PowerManagerService;->mScreenBrightnessHandler:Landroid/os/Handler;
invoke-static {v7}, Lcom/android/server/PowerManagerService;->access$7200(Lcom/android/server/PowerManagerService;)Landroid/os/Handler;
move-result-object v7
[B][COLOR=Red]if-eqz p2, :cond_maj
const/16 v9, 0xb
const/4 v10, 0x0
const v2, 0x10
invoke-virtual {v7, v9, v2, v10}, Landroid/os/Handler;->obtainMessage(III)Landroid/os/Message;
move-result-object v9
invoke-virtual {v9}, Landroid/os/Message;->sendToTarget()V
:cond_maj[/COLOR][/B]
const/16 v9, 0xa
invoke-virtual {v7, v9}, Landroid/os/Handler;->removeMessages(I)V
Reserved 2
Reserved 3
I am currently trying to get the power button to work as a camera shutter key... Will post a tutorial if I succeed.
panda00 said:
I am currently trying to get the power button to work as a camera shutter key... Will post a tutorial if I succeed.
Click to expand...
Click to collapse
Very easy...told ya tomorrow (i'm in bed)
Enviado desde mi GT-I9105P usando Tapatalk 2
klurosu said:
Very easy...told ya tomorrow (i'm in bed)
Enviado desde mi GT-I9105P usando Tapatalk 2
Click to expand...
Click to collapse
That's great. Thanks. Was just about to start some testing but I guess that won't be necessary LOL.
The power button as camera shutter is, in my opinion, the most necessary thing here, at least for me, as the phone works great out of the box!!
Thank you very much for that!!
daruu92 said:
The power button as camera shutter is, in my opinion, the most necessary thing here, at least for me, as the phone works great out of the box!!
Thank you very much for that!!
Click to expand...
Click to collapse
It's actually gonna go in the very easy category lol... so pretty much anyone would be able to do it.
Sent from my GT-I9105P using xda app-developers app
Well, I'm total noobish, actually I bought the phone yesterday in Amazon, and the only thing that I didn't like was the absence of shutter button in camera.
The camera of this phone is so great
Thank you again
I'm yet to see a Samsung Android phone with a shutter key...
Tonight panda and me will post the how to tutorial dudes
Just hold on a little more
From I9105P hipervitaminated
Just gave it a shot... bootloop. I don't understand, even if I did something wrong (which I'm sure I didn't!)... The camera shouldn't be able to bootloop me, unless the apk wasn't signed, but it is... any suggestions @klurosu?
panda00 said:
Just gave it a shot... bootloop. I don't understand, even if I did something wrong (which I'm sure I didn't!)... The camera shouldn't be able to bootloop me, unless the apk wasn't signed, but it is... any suggestions @klurosu?
Click to expand...
Click to collapse
I rwturn home 'bout 22:00 (local time) at 22:30 aprox. I'll uplpad the camera mod with power button as shoot.
P.s
Don't understand ypur bootloops panda... i'm sure your right with yours comps/decomps
From I9105P hipervitaminated
klurosu said:
I rwturn home 'bout 22:00 (local time) at 22:30 aprox. I'll uplpad the camera mod with power button as shoot.
P.s
Don't understand ypur bootloops panda... i'm sure your right with yours comps/decomps
From I9105P hipervitaminated
Click to expand...
Click to collapse
I'm sure as well
Sent from my GT-I9105P using xda app-developers app
Good night buddys!
panda00 and me are proud to present:
I9105P Camera MOD (power button shutter)
The mod works fine, the camera works fine.
The only mod is... power button as shutter (you must press long time button power to take pic.. the shutdown menu appears but the pic saved is ok)
I can upload Camera focus sound disabled, flash in low battery state & Shutter Sound On/Off" option in Camera Menu
klurosu said:
Good night buddys!
panda00 and me are proud to present:
I9105P Camera MOD (power button shutter)
The mod works fine, the camera works fine.
The only mod is... power button as shutter (you must press long time button power to take pic.. the shutdown menu appears but the pic saved is ok)
I can upload Camera focus sound disabled, flash in low battery state & Shutter Sound On/Off" option in Camera Menu
greetings from spain
Click to expand...
Click to collapse
I basically did nothing here. I'm going to post a tutorial though... full thanks n credit to klurosu!
Sent from my GT-I9105P using xda app-developers app
panda00 said:
I basically did nothing here. I'm going to post a tutorial though... full thanks n credit to klurosu!
Sent from my GT-I9105P using xda app-developers app
Click to expand...
Click to collapse
Don't be modest man.. your ideas and support makes the diference.
New guide thanks to @klurosu
Hi, do this camera mod works with CM10.1 too? Thanks

[GT-I9105/P] Samsung Galaxy S II Plus - Camera Mod

I9105P HOW TO CAMERA MOD (power button shutter)
---Decompile "SamsungCamera.apk"---
1. Go to com\sec\android\app\camera\ folder and open Camera.smali file.
2. Search for "
.method public onKeyDown(ILandroid/view/KeyEventZ
Click to expand...
Click to collapse
" and look for ".sparse-switch".
3. Here you will see a lot of :sswitch definitions... see the one for 0x17 (it's the touch shutter button and is defined as :sswitch_e4).
We need to make :sswitch that are defined to power button for read the same as the one defined to the touch shutter button. ( 0x1a is for power button)
4. So now change that :sswitch for these button to read as same as that for the touch shutter button.
for example:
Antes…(before)
:line 1884
:sswitch_data_28c
.sparse-switch
0x4 -> :sswitch_85
0x17 -> :sswitch_e4 <!—Boton de disparo (normal shutter)
0x18 -> :sswitch_225 <!—Volumen+ (zoom in)
0x19 -> :sswitch_225 <!—Volumen- (zoom out)
0x1a -> :sswitch_85 <!—Boton de Power (power button)
0x1b -> :sswitch_e4
0x42 -> :sswitch_e4
0x45 -> :sswitch_225
0x46 -> :sswitch_225
0x50 -> :sswitch_89
0x52 -> :sswitch_83
0x55 -> :sswitch_87
0x59 -> :sswitch_87
0x5a -> :sswitch_87
0x9c -> :sswitch_225
0x9d -> :sswitch_225
.end sparse-switch
.end method
Click to expand...
Click to collapse
Despues... (after)
: line 1884
:sswitch_data_28c
.sparse-switch
0x4 -> :sswitch_85
0x17 -> :sswitch_e4 <!—Boton de disparo (normal shutter)
0x18 -> :sswitch_225 <!—Volumen+ (zoom in)
0x19 -> :sswitch_225 <!—Volumen- (zoom out)
0x1a -> :sswitch_e4 <!—Boton de Power (power button)
0x1b -> :sswitch_e4
0x42 -> :sswitch_e4
0x45 -> :sswitch_225
0x46 -> :sswitch_225
0x50 -> :sswitch_89
0x52 -> :sswitch_83
0x55 -> :sswitch_87
0x59 -> :sswitch_87
0x5a -> :sswitch_87
0x9c -> :sswitch_225
0x9d -> :sswitch_225
.end sparse-switch
.end method
Click to expand...
Click to collapse
5. Now search for "
.method public onKeyUp(ILandroid/view/KeyEventZ
Click to expand...
Click to collapse
" and look for ".sparse-switch".
6. Again you will see several :sswitch definitions... see the one for 0x17, it's the touch shutter button and is defined as :sswitch_10d. (0x1a is for power button)
7. So now change that :sswitch for these button to read as same as that for the touch shutter button. See example bellow:
Code:
.line 2172
.sparse-switch
0x3 -> :sswitch_24e
0x4 -> :sswitch_50
0x17 -> :sswitch_10d <!—Boton de disparo (normal shutter)
0x18 -> :sswitch_1f8 <!—Boton Vol+ (zoom in)
0x19 -> :sswitch_1f8 <!—Boton Vol- (zoom out)
0x1a -> :sswitch_1f8 <!-Boton Power (power button)
0x1b -> :sswitch_10d
0x42 -> :sswitch_10d
0x50 -> :sswitch_1fb
0x52 -> :sswitch_d4
.end sparse-switch
Click to expand...
Click to collapse
After:
.line 2172
.sparse-switch
0x3 -> :sswitch_25f
0x4 -> :sswitch_60
0x17 -> :sswitch_10d <!—Boton de disparo (normal shutter)
0x18 -> :sswitch_1f8 <!—Boton Vol+ (zoom in)
0x19 -> :sswitch_1f8 <!—Boton Vol- (zoom out)
0x1a -> :sswitch_10d <!-Boton Power (power button)
0x1b -> :sswitch_10d
0x42 -> :sswitch_10d
0x50 -> :sswitch_2fb
0x52 -> :sswitch_d4
.end sparse-switch
Click to expand...
Click to collapse
greetings from spain
N/A.
Will this work with 4.2.2?
OT: @klurosu what happened to you, mate? You've gone quiet for 2 months
Sent from my GT-I9105 using xda app-developers app
corduroy84 said:
Will this work with 4.2.2?
OT: @klurosu what happened to you, mate? You've gone quiet for 2 months
Sent from my GT-I9105 using xda app-developers app
Click to expand...
Click to collapse
Hi dude
No, this only works 100% on 4.1
P.S I have been promoted in my job so now ain't got much time and actually I'm working in S4 (I9505)
Grretings from spain

[GUIDE][NEWBIE] Disable Signature Check

FAQ's
[*]Why Disable Signature?
- So that the rom will recognize the app that you mod
- So that you will not do the extraction method
- So that your life will be easy
Requirements:
Apktool(PC or Mobile) 1.5.2 or 2.0
Rootexplorer(Mobile)
Text Editor
Instructions:
- Decompile services.jar
- Go to > smali > com > android > server > pm > PackageManagerService
- Search this code:
.method static compareSignatures([Landroid/content/pm/Signature;[Landroid/content/pm/SignatureI
- Select the whole method(.method to .end method of the given method) and replace it with this code:
.method static compareSignatures([Landroid/content/pm/Signature;[Landroid/content/pm/SignatureI
.locals 7
const-string p0, "DSA:"
const-string p1, "Skip signatures check"
invoke-static {p0, p1}, Landroid/util/Log;->v(Ljava/lang/String;Ljava/lang/StringI
const/4 v6, 0x0
return v6
.end method
Note: Make sure there is a space between .end method and .method
- Recompile > Sign > Push or Flash
#WeAreTeamPussy
Credits:
Bang Bangger Files
Material Modding Team
Underground
MAAaD
MAAaDR
Android Pie compatible?
Will this method work on Pie?

Categories

Resources