众所周知,android 是开源的,现在市场上反编译别人的劳动果实的人也不少,所以我们也是有必要学习下smail语言,(就是android工程反编译后出的语法语音),看看改怎么给我们的代码 “埋雷” ,才能更好的保护好我们自己的劳动成果。
接下来就让我们来学习下吧~!(事先声明:本人也是初学smail语言,有介绍不当的地方还请海涵,并请指出,大家一起学习)
package com.example.pushdemo;
import java.io.ByteArrayInputStream;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import android.app.Activity;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
import com.sogou.udp.push.PushManager;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initPush();
initViewId();
getSingInfo();
}
private void initViewId() {
Button btn= (Button) findViewById(R.id.btn);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "hello word", Toast.LENGTH_SHORT).show();
}
});
}
public void btn(View v){
Toast.makeText(this, R.string.app_name, Toast.LENGTH_SHORT).show();
}
public void getSingInfo() {
try {
PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);
Signature[] signs = packageInfo.signatures;
Signature sign = signs[0];
parseSignature(sign.toByteArray());
} catch (Exception e) {
e.printStackTrace();
}
}
public void parseSignature(byte[] signature) {
try {
CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
X509Certificate cert = (X509Certificate) certFactory.generateCertificate(new ByteArrayInputStream(signature));
String pubKey = cert.getPublicKey().toString();
String signNumber = cert.getSerialNumber().toString();
System.out.println("signName:" + cert.getSigAlgName());
System.out.println("pubKey:" + pubKey);
System.out.println("signNumber:" + signNumber);
System.out.println("subjectDN:" + cert.getSubjectDN().toString());
} catch (CertificateException e) {
e.printStackTrace();
}
}
private void initPush() {
PushManager.initialize(this.getApplicationContext());
PushManager.bindPushService(this.getApplicationContext());
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString("lastPath", "/sdcard/android123/cwj/test");
System.out.println("lastPath");
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
String cwjString = savedInstanceState.getString("lastPath");
System.out.println(cwjString);
}
}
--------------------------------上面是java 代码对应下面的smail语法------------------------------------
.class public Lcom/example/pushdemo/MainActivity; 、、在虚拟机中,找到这个MainActivity类文件
.super Landroid/app/Activity; 、、对应的是super.onCreate(savedInstanceState); 在父类中找到Activity这个类
.source "MainActivity.java" 、、资源文件,MainA