5
5
import android .content .res .AssetManager ;
6
6
import android .content .SharedPreferences ;
7
7
import android .preference .PreferenceManager ;
8
+ import android .widget .Toast ;
8
9
import java .io .*;
9
10
import java .util .ArrayList ;
10
11
import java .util .List ;
14
15
15
16
public class PkTriggerCord extends Application {
16
17
public static final String TAG = "PkTriggerCord" ;
17
- private static final String CLI_HOME = "/data/local/" ;
18
- private static final String CLI_DIR = "pktriggercord" ;
18
+ private String cliHome ;
19
+ // private static final String CLI_DIR = "pktriggercord";
19
20
private static final int MARK_LIMIT = 1000000 ;
20
21
private Process p ;
21
22
private SharedPreferences prefs ;
22
23
23
24
@ Override
24
25
public void onCreate () {
25
26
super .onCreate ();
27
+
28
+ cliHome = getApplicationContext ().getFilesDir ().getAbsolutePath ();
29
+
26
30
PreferenceManager .setDefaultValues (this , R .xml .prefs , false );
27
31
prefs = PreferenceManager .getDefaultSharedPreferences (this );
28
32
Log .v ( TAG , "Before installCli" );
@@ -42,7 +46,7 @@ public String getSaveDir() {
42
46
private void startCli () {
43
47
try {
44
48
p = new ProcessBuilder ()
45
- .command ("su" , "-c" , CLI_HOME + CLI_DIR +"/pktriggercord-cli --servermode" )
49
+ .command ("su" , "-c" , cliHome +"/pktriggercord-cli --servermode" )
46
50
.start ();
47
51
SystemClock .sleep (1000 );
48
52
} catch ( Exception e ) {
@@ -137,7 +141,7 @@ private void copyAsset(String fileName) throws Exception {
137
141
boolean needCliInstall ;
138
142
AssetManager assetManager = getAssets ();
139
143
InputStream in = assetManager .open (fileName );
140
- String fullFileName = CLI_HOME + CLI_DIR + "/" + fileName ;
144
+ String fullFileName = cliHome + "/" + fileName ;
141
145
142
146
try {
143
147
FileInputStream fis = new FileInputStream (fullFileName );
@@ -157,9 +161,9 @@ private void copyAsset(String fileName) throws Exception {
157
161
final int myUid = android .os .Process .myUid ();
158
162
Log .v ( TAG , "myUid:" +myUid );
159
163
simpleSudoWrapper ( new ArrayList <String >() {{
160
- add ("mkdir -p " +CLI_HOME + CLI_DIR );
161
- add ("chown " +myUid +" " +CLI_HOME + CLI_DIR );
162
- add ("chmod 777 " +CLI_HOME + CLI_DIR );
164
+ add ("mkdir -p " +cliHome );
165
+ add ("chown " +myUid +" " +cliHome );
166
+ add ("chmod 777 " +cliHome );
163
167
}});
164
168
Log .v ( TAG , "After first simpleSudoWrapper" );
165
169
simpleSudoWrapper ("rm -f " +fullFileName );
0 commit comments