[Sprint HTC EVO 4G LTE] swagstr:
LONG-PRESS BACK TO KILL THIRD-PARTY APPS

The Mod

By long-pressing the Back capacitive button, any third-party app will be killed. This is very handy for when apps become unresponsive.

Decompile

You gotta figure this one out! Learn how to use apktool, baksmali or VTS. It is HIGHLY recommended that if you are decompiling with apktool or baksmali to add "-b" modifier. If using VTS, uncheck the smali debug code. This will make your smali code MUCH smaller - less system space = MORE RAM.

What needs to Be Changed [The long part]

Using Notepad++ or a similar text editor (ie not Notepad) navigate to \com\android\internal\policy\impl\PhoneWindowManager.smali

SEARCH FOR

.field mAutoMotiveReceiver:Landroid/content/BroadcastReceiver;

ADD TEXT IN GREEN

.field mAutoMotiveReceiver:Landroid/content/BroadcastReceiver;

[COLOR="SeaGreen"].field mBackKeyLongPressed:Z[/COLOR]

.field mBootCompleted:Z

SEARCH FOR

.method private launchAssistLongPressAction()V

SCROLL TO THE END OF THIS METHOD AND ADD NEW METHOD IN GREEN

.end method

[COLOR="SeaGreen"].method private launchBackLongPressAction()V
.locals 18

:try_start_0
invoke-static {}, Landroid/app/ActivityManagerNative;->getDefault()Landroid/app/IActivityManager;

move-result-object v9

invoke-interface {v9}, Landroid/app/IActivityManager;->getRunningAppProcesses()Ljava/util/List;

move-result-object v5

move-object/from16 v0, p0

iget-object v14, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mContext:Landroid/content/Context;

const-string v15, "activity"

invoke-virtual {v14, v15}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

move-result-object v2

check-cast v2, Landroid/app/ActivityManager;

const/4 v14, 0x1

invoke-virtual {v2, v14}, Landroid/app/ActivityManager;->getRunningTasks(I)Ljava/util/List;

move-result-object v12

const/4 v14, 0x0

invoke-interface {v12, v14}, Ljava/util/List;->get(I)Ljava/lang/Object;

move-result-object v14

check-cast v14, Landroid/app/ActivityManager$RunningTaskInfo;

iget-object v6, v14, Landroid/app/ActivityManager$RunningTaskInfo;->topActivity:Landroid/content/ComponentName;

invoke-interface {v5}, Ljava/util/List;->iterator()Ljava/util/Iterator;

move-result-object v14

:cond_26
:goto_26
invoke-interface {v14}, Ljava/util/Iterator;->hasNext()Z

move-result v15

if-nez v15, :cond_2d

:cond_2c
:goto_2c
return-void

:cond_2d
invoke-interface {v14}, Ljava/util/Iterator;->next()Ljava/lang/Object;

move-result-object v3

check-cast v3, Landroid/app/ActivityManager$RunningAppProcessInfo;

iget v13, v3, Landroid/app/ActivityManager$RunningAppProcessInfo;->uid:I

const/16 v15, 0x2710

if-lt v13, v15, :cond_26

const v15, 0x1869f

if-gt v13, v15, :cond_26

iget v15, v3, Landroid/app/ActivityManager$RunningAppProcessInfo;->importance:I

const/16 v16, 0x64

move/from16 v0, v16

if-ne v15, v0, :cond_26

iget-object v15, v3, Landroid/app/ActivityManager$RunningAppProcessInfo;->pkgList:[Ljava/lang/String;

if-eqz v15, :cond_26

invoke-interface {v5}, Ljava/util/List;->size()I

move-result v15

if-lez v15, :cond_26

iget-object v15, v3, Landroid/app/ActivityManager$RunningAppProcessInfo;->processName:Ljava/lang/String;

invoke-virtual {v6}, Landroid/content/ComponentName;->getPackageName()Ljava/lang/String;

move-result-object v16

invoke-virtual/range {v15 .. v16}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

move-result v15

if-eqz v15, :cond_26

new-instance v8, Landroid/content/Intent;

const-string v15, "android.intent.action.MAIN"

invoke-direct {v8, v15}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

const-string v15, "android.intent.category.HOME"

invoke-virtual {v8, v15}, Landroid/content/Intent;->addCategory(Ljava/lang/String;)Landroid/content/Intent;

move-object/from16 v0, p0

iget-object v15, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mContext:Landroid/content/Context;

invoke-virtual {v15}, Landroid/content/Context;->getPackageManager()Landroid/content/pm/PackageManager;

move-result-object v15

const/16 v16, 0x0

move/from16 v0, v16

invoke-virtual {v15, v8, v0}, Landroid/content/pm/PackageManager;->resolveActivity(Landroid/content/Intent;I)Landroid/content/pm/ResolveInfo;

move-result-object v11

iget-object v15, v11, Landroid/content/pm/ResolveInfo;->activityInfo:Landroid/content/pm/ActivityInfo;

iget-object v15, v15, Landroid/content/pm/ActivityInfo;->processName:Ljava/lang/String;

iget-object v0, v3, Landroid/app/ActivityManager$RunningAppProcessInfo;->processName:Ljava/lang/String;

move-object/from16 v16, v0

invoke-virtual/range {v15 .. v16}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

move-result v15

if-nez v15, :cond_2c

move-object/from16 v0, p0

iget-object v15, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mContext:Landroid/content/Context;

invoke-virtual {v15}, Landroid/content/Context;->getPackageManager()Landroid/content/pm/PackageManager;
:try_end_8d
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_8d} :catch_d8

move-result-object v10

:try_start_8e
invoke-virtual {v6}, Landroid/content/ComponentName;->getPackageName()Ljava/lang/String;

move-result-object v15

const/16 v16, 0x0

move/from16 v0, v16

invoke-virtual {v10, v15, v0}, Landroid/content/pm/PackageManager;->getApplicationInfo(Ljava/lang/String;I)Landroid/content/pm/ApplicationInfo;
:try_end_99
.catch Ljava/lang/Exception; {:try_start_8e .. :try_end_99} :catch_db

move-result-object v1

:goto_9a
if-eqz v1, :cond_de

:try_start_9c
invoke-virtual {v10, v1}, Landroid/content/pm/PackageManager;->getApplicationLabel(Landroid/content/pm/ApplicationInfo;)Ljava/lang/CharSequence;

move-result-object v4

:goto_a0
check-cast v4, Ljava/lang/String;

invoke-virtual {v6}, Landroid/content/ComponentName;->getPackageName()Ljava/lang/String;

move-result-object v15

invoke-interface {v9, v15}, Landroid/app/IActivityManager;->forceStopPackage(Ljava/lang/String;)V

iget v15, v3, Landroid/app/ActivityManager$RunningAppProcessInfo;->pid:I

invoke-static {v15}, Landroid/os/Process;->killProcess(I)V

move-object/from16 v0, p0

iget-object v15, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mContext:Landroid/content/Context;

new-instance v16, Ljava/lang/StringBuilder;

invoke-static {v4}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

move-result-object v17

invoke-direct/range {v16 .. v17}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

const-string v17, " killed."

invoke-virtual/range {v16 .. v17}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

move-result-object v16

invoke-virtual/range {v16 .. v16}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

move-result-object v16

const-string v0, "lyapota"

move-object/from16 v2, v15

move-object/from16 v3, v16

invoke-static {v0, v3}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

const/4 v4, 0x0

invoke-static {v2, v3, v4}, Landroid/widget/Toast;->makeText(Landroid/content/Context;Ljava/lang/CharSequence;I)Landroid/widget/Toast;

move-result-object v15

invoke-virtual {v15}, Landroid/widget/Toast;->show()V

goto/16 :goto_26

:catch_d8
move-exception v14

goto/16 :goto_2c

:catch_db
move-exception v7

const/4 v1, 0x0

goto :goto_9a

:cond_de
const-string v4, "(unknown)"
:try_end_e0
.catch Ljava/lang/Exception; {:try_start_9c .. :try_end_e0} :catch_d8

goto :goto_a0
.end method[/COLOR]

.method static makeFnState(IIZIZ)V

(To make life easy) SEARCH FOR

const-string v40, "ignore handleLongPressOnHome when hasRingingCall or it\'s in GuestMode"

BELOW THIS, YOU WILL NEED TO REPLACE EVERYTHING UNTIL AND INCLUDING

:pswitch_data_8a4
.packed-switch 0x0
:pswitch_4bd
:pswitch_4c1
:pswitch_4bd
.end packed-switch

:pswitch_data_8ae
.packed-switch 0x1
:pswitch_527
:pswitch_545
.end packed-switch
.end method

NOTE: This last section WILL change with the new data.

THE CODE TO ADD CAN BE FOUND HERE:

http://goo.gl/NA8KI

IT'S TOO BIG FOR XDA

The Final Step

Now that all the smali files have been edited, recompile your .jar, rename your file to android.policy.jar and push to /system/framework/android.policy.jar. Smali files are stored in classes.dex inside of .apks and .jars, I have uploaded some classes.dexs that include the other mods listed here as well as modified/unmodified smalis. Enjoy!

STOCK FILES

PhoneWindowManager.smali

classes.dex

android.policy.jar

BACK-KILL FILES

PhoneWindowManager.smali

classes.dex

android.policy.jar

APM + BACK-KILL FILES

classes.dex

android.policy.jar

APM + VOL-TRACK + BACK-KILL FILES

classes.dex

android.policy.jar

#ASOP