[Xperia Play Android Development] farenheith:
Instructions to change the framework.jar FOR DEVS

IF YOU WANT EQUIVALENT INSTRUCTIONS TO EDIT JAVA SOURCODE, TAKE A LOOK HERE

VERSION 1.1

CHANGES:

V 1.2 Now, the changes on the View.smali checks if the device is a Xperia PLAY. So, the framework edited can be used on other compatible devices without side effects

V 1.1 Added support to switch the initial pointerId for the touchpad

V 1.0 The implementation follow the Sony framework source code now, but probably we'll not feel any difference on the touchpad support (probably)

V0.6 Created support to the property mod.touchpad.activated to set when the touchpad is always activated and when the game need to activate it. Also, it's offer support to the app TouchpadActvation.apk

V0.5 Touchpad activation implemented

V0.4

The ViewRoot method is not static anymore and return void

The new class ViewRoot is now parent of ViewRootImpl.

The dispatchGenericMotionEvent had been modified on other classes, the verification of BIND_TOUCHPAD_ONTOUCH is removed

First, you need to decompile the framework, I'm using Virtuous Ten studio to do it. This IDE use the apktool to generate the code, so, to everyone using apktool too, the code will be the same.

Now, make the following steps:

INSTRUCTIONS

Copy the ViewRoot.smali from the attachment to the /android/view folder of the decompiled framework.

At the beginning of the ViewRootImpl.smali, insert the line in red:

# interfaces
.implements Landroid/view/ViewParent;
.implements Landroid/view/View$AttachInfo$Callbacks;
.implements Landroid/view/HardwareRenderer$HardwareDrawCallbacks;
[B][COLOR="Red"].implements Landroid/view/ViewRoot;[/COLOR][/B]

Then, still on ViewRootImpl.smali, insert this method at the end of the file

.method public setProcessPositionEvents(Z)V
.locals 1

iget-object v0, p0, Landroid/view/ViewRootImpl;->mView:Landroid/view/View;

if-eqz v0, :cond_9

iget-object v0, p0, Landroid/view/ViewRootImpl;->mView:Landroid/view/View;

invoke-virtual {v0, p1}, Landroid/view/View;->setProcessGenericMotionAsPointer(Z)V

:cond_9
return-void
.end method

Insert this method at the end of the View.smali:

.method public sendTreatAsTouchEvent(Landroid/view/MotionEvent;)I
.locals 6
.parameter "event"

.prologue
const/4 v3, 0x0

const/4 v2, 0x1

const/4 v1, 0x0

const/4 v0, 0x0

sget-object v4, Landroid/os/Build;->BRAND:Ljava/lang/String;

const-string v5, "SEMC"

invoke-virtual {v4, v5}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

move-result v4

if-eqz v4, :cond_3b

sget-object v4, Landroid/os/Build;->MODEL:Ljava/lang/String;

const-string v5, "R800"

invoke-virtual {v4, v5}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

move-result v4

if-eqz v4, :cond_3b

invoke-virtual {p1}, Landroid/view/MotionEvent;->getSource()I

move-result v4

const v5, 0x100008

if-ne v4, v5, :cond_3c

move v0, v2

:goto_22
if-eqz v0, :cond_3b

iget-boolean v0, p0, Landroid/view/View;->mProcessGenericMotionAsPointer:Z

if-nez v0, :cond_32

const-string/jumbo v4, "mod.touchpad.activated"

invoke-static {v4, v3}, Landroid/os/SystemProperties;->getInt(Ljava/lang/String;I)I

move-result v4

if-ne v4, v2, :cond_3e

move v0, v2

:cond_32
:goto_32
if-eqz v0, :cond_3b

invoke-virtual {p0, p1}, Landroid/view/View;->dispatchTouchEvent(Landroid/view/MotionEvent;)Z

move-result v3

if-eqz v3, :cond_40

move v1, v2

:cond_3b
:goto_3b
return v1

:cond_3c
move v0, v3

.line 17967
goto :goto_22

:cond_3e
move v0, v3

goto :goto_32

:cond_40
const/4 v1, 0x2

goto :goto_3b
.end method

.method setProcessGenericMotionAsPointer(Z)V
.locals 0

iput-boolean p1, p0, Landroid/view/View;->mProcessGenericMotionAsPointer:Z

return-void
.end method

Still on View.smali, insert the property in red:

.field private mPerformClick:Landroid/view/View$PerformClick;

[B][COLOR="red"].field private mProcessGenericMotionAsPointer:Z[/COLOR][/B]

.field mPrivateFlags:I

Finnally, insert this lines on the dispatchGenericMotionEvent (in red):

.method public dispatchGenericMotionEvent(Landroid/view/MotionEvent;)Z
.locals 5
.parameter "event"

.prologue
const/4 v3, 0x0

const/4 v2, 0x1

[B][COLOR="red"] invoke-virtual {p0, p1}, Landroid/view/View;->sendTreatAsTouchEvent(Landroid/view/MotionEvent;)I

move-result v1

.line 7184
if-eqz v1, :cond_g

sub-int v2, v1, v2

goto :goto_3b

[COLOR="SeaGreen"]<<<<< ATTENTION, THIS goto MUST BE EXACTLY THE SAME COMMAND OF THE LAST LINE OF THE METHOD[/COLOR]

:cond_g[/COLOR][/B]
.line 5597
iget-object v4, p0, Landroid/view/View;->mInputEventConsistencyVerifier:Landroid/view/InputEventConsistencyVerifier;

... ... ... (THE CODE OF THE METHOD) ... ... ...
.end method

FOR SWITCH THE START POINTER ID FOR THE TOUCHPAD

Add this methods to the end of the android/view/MotionEvent:

.method public addPointerId(I)I
.locals 2
.parameter "pointerId"

.prologue

move v0, p1

invoke-virtual {p0}, Landroid/view/MotionEvent;->pointerIdStartFrom1Plus()I

move-result v1

if-eqz v1, :cond_1

const/4 v1, 0x1

add-int/2addr v0, v1

:cond_1
return v0
.end method

.method public modPointerId(I)I
.locals 2
.parameter "pointerId"

.prologue

move v0, p1

invoke-virtual {p0}, Landroid/view/MotionEvent;->pointerIdStartFrom1Plus()I

move-result v1

if-eqz v1, :cond_1

const/4 v1, 0x1

invoke-virtual {p0}, Landroid/view/MotionEvent;->getPointerCount()I

move-result v1
if-lt v0, v1, :cond_1

const/4 v0, 0x0

:cond_1
return v0
.end method

.method public subPointerId(I)I
.locals 2
.parameter "pointerId"

.prologue

move v0, p1

if-eqz v0, :cond_1

invoke-virtual {p0}, Landroid/view/MotionEvent;->pointerIdStartFrom1Plus()I

move-result v1

if-eqz v1, :cond_1

const/4 v1, 0x1

sub-int/2addr v0, v1

:cond_1
return v0
.end method

.method public pointerIdStartFrom1Plus()I
.locals 3

.prologue

const/4 v2, 0x0

invoke-virtual {p0}, Landroid/view/MotionEvent;->pointerIdStartFrom1()I

move-result v0

if-eqz v0, :cond_1

sget v0, Landroid/view/InputDevice;->SOURCE_TOUCHPAD:I

invoke-virtual {p0}, Landroid/view/MotionEvent;->getSource()I

move-result v1

if-ne v0, v1, :cond_1

const/4 v2, 0x1

:cond_1
return v2
.end method

.method public pointerIdStartFrom1()I
.locals 2

.prologue

const/4 v0, 0x0

const-string/jumbo v1, "mod.touchpad.startfrom1"

invoke-static {v1, v0}, Landroid/os/SystemProperties;->getInt(Ljava/lang/String;I)I

move-result v0

return v0
.end method

Add (or change) the lines in red to the following methods:

.method public final getPointerId(I)I
.locals 2
.parameter "pointerIndex"

.prologue
.line 1927
iget v0, p0, Landroid/view/MotionEvent;->mNativePtr:I

invoke-static {v0, p1}, Landroid/view/MotionEvent;->nativeGetPointerId(II)I

move-result v0

[COLOR="red"] invoke-virtual {p0, v0}, Landroid/view/MotionEvent;->addPointerId(I)I

move-result v0[/COLOR]

return v0
.end method

... ... ...

.method public final getPointerIdBits()I
.locals 5

.prologue
.line 2786
const/4 v1, 0x0

.line 2787
.local v1, idBits:I
iget v3, p0, Landroid/view/MotionEvent;->mNativePtr:I

invoke-static {v3}, Landroid/view/MotionEvent;->nativeGetPointerCount(I)I

move-result v2

.line 2788
.local v2, pointerCount:I
const/4 v0, 0x0

.local v0, i:I
:goto_0
if-ge v0, v2, :cond_0

.line 2789
[COLOR="red"]
invoke-virtual {p0, v0}, Landroid/view/MotionEvent;->getPointerId(I)I
[/COLOR]
move-result v4

shl-int/2addr v3, v4

or-int/2addr v1, v3

.line 2788
add-int/lit8 v0, v0, 0x1

goto :goto_0

.line 2791
:cond_0
return v1
.end method

... ... ...

.method public final getX(I)F
[COLOR="red"] .locals 4[/COLOR]
.parameter "pointerIndex"

.prologue
.line 1974
[COLOR="red"]invoke-virtual {p0, p1}, Landroid/view/MotionEvent;->modPointerId(I)I

move-result v3[/COLOR]

iget v0, p0, Landroid/view/MotionEvent;->mNativePtr:I

const/4 v1, 0x0

const/high16 v2, -0x8000

invoke-static {v0, v1, [COLOR="red"]v3[/COLOR], v2}, Landroid/view/MotionEvent;->nativeGetAxisValue(IIII)F

move-result v0

return v0
.end method

... ... ...

.method public final getY(I)F
[COLOR="red"] .locals 4[/COLOR]
.parameter "pointerIndex"

.prologue
.line 1989
[COLOR="red"]invoke-virtual {p0, p1}, Landroid/view/MotionEvent;->modPointerId(I)I

move-result v3[/COLOR]

iget v0, p0, Landroid/view/MotionEvent;->mNativePtr:I

const/4 v1, 0x1

const/high16 v2, -0x8000

invoke-static {v0, v1, [COLOR="red"]v3[/COLOR], v2}, Landroid/view/MotionEvent;->nativeGetAxisValue(IIII)F

move-result v0

return v0
.end method

Now, you need to rename the method split to split2, and add this method:

.method public final split(I)Landroid/view/MotionEvent;
.locals 2
.parameter "idBits"

.prologue
move v1, p1
invoke-virtual {p0}, Landroid/view/MotionEvent;->pointerIdStartFrom1Plus()I

move-result v0

if-eqz v0, :cond_1

const v0, 0x1

shr-int/2addr v1, v0

:cond_1
invoke-virtual {p0, v1}, Landroid/view/MotionEvent;->split2(I)Landroid/view/MotionEvent;

move-result-object v0

return-object v0
.end method

IMPORTANT: If you're not using apktool or virtuous ten studio, the best is to decompile the jar and look to the smali changed to see how the code will looks like