VFY:修改过的索尼爱立信启动器中的死代码错误

时间:2011-10-13 18:29:29

标签: android dead-code sony

我正在使角落圈在hdpi设备上运行。除了按下“添加”按钮(长按屏幕),然后按应用程序抽屉中的排序样式按钮,一切正常。两者都导致发射器的F / c。奇怪的是它既适用于我的OG Droid,也适用于我的Xoom,但不适用于我的Droid Incredible 2.

Logcat:

     I/ActivityManager(24294): Displayed
     com.sonyericsson.home/.HomeActivity: +1s573ms W/cornerbuttons(26412):
     Customization file not found:
     /etc/customization/settings/com/sonyericsson/home/default_settings_topleftcornerbutton.xml
     W/cornerbuttons(26412): Customization file not found:
     /etc/customization/settings/com/sonyericsson/home/default_settings_toprightcornerbutton.xml
     W/cornerbuttons(26412): Customization file not found:
     /etc/customization/settings/com/sonyericsson/home/default_settings_bottomleftcornerbutton.xml
     W/cornerbuttons(26412): Customization file not found:
     /etc/customization/settings/com/sonyericsson/home/default_settings_bottomrightcornerbutton.xml
     W/app-tray(26412): Customization file not found:
     /etc/customization/settings/com/sonyericsson/home/default_settings_apptray.xml
     I/dalvikvm(26412): Could not find method
     android.app.AlertDialog$Builder.<init>, referenced from method
    com.sonyericsson.home.HomeActivity$AddDialog.createDialog
     D/dalvikvm(26412): VFY: dead code 0x0011-0034 in
     Lcom/sonyericsson/home/HomeActivity$AddDialog;.createDialog
     ()Landroid/app/Dialog; I/ActivityManager(24294): Displayed
     com.sonyericsson.home/.HomeActivity: +1s651ms I/dalvikvm(26442): Could
     not find method android.app.AlertDialog$Builder.<init>, referenced
     from method com.sonyericsson.home.HomeActivity$SortDialog.createDialog
     D/dalvikvm(26442): VFY: dead code 0x0019-0047 in
     Lcom/sonyericsson/home/HomeActivity$SortDialog;.createDialog
     ()Landroid/app/Dialog;
   PS: the f/cs occur even without my modifications  

1 个答案:

答案 0 :(得分:0)

反编译时,你会发现在SortDialog内部类的createDialog()方法中,“ HomeActivity $ SortDialog.smali ”引用了Util类来找出装饰 AlertDialogBu​​ilder with。

SMALI:

 .line 2507
    new-instance v0, Landroid/app/AlertDialog$Builder;

    iget-object v2, p0, Lcom/sonyericsson/home/HomeActivity$SortDialog;->this$0:Lcom/sonyericsson/home/HomeActivity;

    iget-object v3, p0, Lcom/sonyericsson/home/HomeActivity$SortDialog;->this$0:Lcom/sonyericsson/home/HomeActivity;

    invoke-virtual {v3}, Lcom/sonyericsson/home/HomeActivity;->getApplicationContext()Landroid/content/Context;

    move-result-object v3

    invoke-static {v3}, Lcom/sonyericsson/home/bidi/Utils;->getDialogAlertThemeStyle(Landroid/content/Context;)I

    move-result v3

    invoke-direct {v0, v2, v3}, Landroid/app/AlertDialog$Builder;-><init>(Landroid/content/Context;I)V

或在Java中

int i = Utils.getDialogAlertThemeStyle(HomeActivity.this.getApplicationContext());

然后,他们的Utils类检查要应用于SortDialog的已保存主题。由于主题没有设置(我怎么不知道?),它返回一个0或-1的int(不确定)。

public static final int getDialogAlertThemeStyle(Context paramContext)
  {
    if ((sReflectionOk) && (isRtlAlphabet(paramContext)));
    for (int i = sThemeBidiDialogAlert; ; i = sThemeDialogAlert)
      return i;
  }

  public static final boolean isRtlAlphabet(Context paramContext)
  {
    int i = 0;
    if (sReflectionOk);
    try
    {
      Resources localResources = paramContext.getResources();
      int j = **sRtlAlphabetField**;
      boolean bool = localResources.getBoolean(j);
      i = bool;
      return i;
    }
    catch (Resources.NotFoundException localNotFoundException)
    {
      while (true)
        LogUtil.reportError("Bidi", "Get rtl alphabet resource failed", localNotFoundException);
    }
  }

j是正在返回的内容并且 sRtlAlphabetField 未正确初始化我正在猜测

**sRtlAlphabetField** = Class.forName("com.android.internal.R$bool").getField("alphabet_isRtl").getInt(null);

您看到上面的调用是调用alphabet_isRtl的资源ID,该资源ID位于启动器的Android R.java文件中。它必须不能返回有效的资源标识符,因此当Util方法返回-1时为什么?或0它无法使用给定的int参数创建AlertDialog的新实例。在HomeActivity $ SortDialog或Util类中输出i的值的简单日志行将向您显示它尝试用作主题值的内容,无论是哪种方式都可能是gumpf。

这可能是一个很长的镜头,但我很确定这就是为什么会发生这个问题,你可能会在AddToStageDialog,PickActivityDialog,AddDialog和SortDialog“onCreate()方法中出现这个错误。

因为他们都在呼唤同一条线:

int i = Utils.getDialogAlertThemeStyle(HomeActivity.this.getApplicationContext());

我猜解决方案将编辑SMALI类:AddToStageDialog,PickActivityDialog,AddDialog和SortDialog,以便他们使用构造函数创建一个AlertDialog.Builder,该构造函数仅将上下文作为参数。

AlertDialog.Builder localBuilder1 = new AlertDialog.Builder(localHomeActivity);

可能会这样做,但如果没有主题部分,你可能会在这个地方寻找类似这样的电话。

祝你好运!

编辑:我自己测试了这个并且我已经开始工作了,编辑后的smali代码是:

从:

invoke-direct {v0, v2, v3}, Landroid/app/AlertDialog$Builder;-><init>(Landroid/content/Context;I)V

为:

invoke-direct {v0, v2}, Landroid/app/AlertDialog$Builder;-><init>(Landroid/content/Context;)V

在我上面提到的对话框类中执行此操作,它将解决问题:)