修改smali文件,重打包,实现调用第三方SO文件

Java代码:

static{
        // //loadlibary里 要把SO文件名的lib和后缀去掉。libfgma.so --> fgma
        System.loadLibrary("fgma"); 
    }

对应Smali:

# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 15
    const-string v0, "fgma"
    invoke-static {v0}, Ljava/lang/System;->loadLibrary(Ljava/lang/String;)V

    .line 16
    return-void
.end method

 

对so中函数的声明:

public native String GetLocalPort();

对应Smali:

# virtual methods
.method public native GetLocalPort()Ljava/lang/String;
.end method

 

调用:

String str = GetLocalPort();
Toast.makeText(this, str, Toast.LENGTH_LONG).show();    

对应Smali:

.line 23
 invoke-virtual {p0}, Lcom/dit/mobile/android/fgma3/Mary;->GetLocalPort()Ljava/lang/String;
 move-result-object v0

 .line 25
 .local v0, "str":Ljava/lang/String;
 const/4 v1, 0x1

 invoke-static {p0, v0, v1}, Landroid/widget/Toast;->makeText(Landroid/content/Context;Ljava/lang/CharSequence;I)Landroid/widget/Toast;
 move-result-object v1
 invoke-virtual {v1}, Landroid/widget/Toast;->show()V

 

posted on 2015-03-16 17:16  寻步  阅读(1415)  评论(0编辑  收藏  举报