forked from modbrin/libchanger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainActivity.java
72 lines (59 loc) · 2.16 KB
/
MainActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package modbrin.libchanger;
import java.io.DataOutputStream;
import java.io.IOException;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends Activity {
TextView text;
Button btnInst;
Button btnRest;
String[] inst = {"cp /system/lib/libmmcamera_imx179.so /sdcard/LC-Cache/backup/backup.so", "mount -o remount,rw /system", "install -m644 /sdcard/LC-Cache/mod.so /system/lib/libmmcamera_imx179.so", "mount -o remount,ro /system","killall mm-qcamera-daemon mediaserver", "killall pkmx.lcamera"};
String[] rest = {"mount -o remount,rw /system", "install -m644 /sdcard/LC-Cache/orig.so /system/lib/libmmcamera_imx179.so", "mount -o remount,ro /system","killall mm-qcamera-daemon mediaserver", "killall pkmx.lcamera"};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
text = (TextView) findViewById(R.id.text);
btnInst = (Button) findViewById(R.id.btnInst);
btnRest = (Button) findViewById(R.id.btnRest);
//Process of restoring to original
OnClickListener oclBtnRest = new OnClickListener() {
@Override
public void onClick(View v){
try {
SuRun(rest);
} catch (IOException e) {
e.printStackTrace();
};
text.setText("Restored To Normal");
}
};
btnRest.setOnClickListener(oclBtnRest);
//Process of installing the modification
OnClickListener oclBtnInst = new OnClickListener() {
@Override
public void onClick(View v){
try {
SuRun(inst);
} catch (IOException e) {
e.printStackTrace();
};
text.setText("Installed Modified Lib");
}
};
btnInst.setOnClickListener(oclBtnInst);
}
public void SuRun(String[] cmds) throws IOException{
Process p = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(p.getOutputStream());
for (String tmpCmd : cmds) {
os.writeBytes(tmpCmd+"\n");
}
os.writeBytes("exit\n");
os.flush();
}
}