4
4
import android .app .AlertDialog ;
5
5
import android .widget .Toast ;
6
6
7
+ import androidx .documentfile .provider .DocumentFile ;
8
+
7
9
import java .io .BufferedReader ;
8
10
import java .io .File ;
9
11
import java .io .FileOutputStream ;
@@ -28,7 +30,7 @@ public void run() {
28
30
MainActivity .cur_status = MainActivity .status .flashing ;
29
31
((MainActivity ) activity ).update_title ();
30
32
is_error = false ;
31
- file_path = activity .getFilesDir ().getAbsolutePath () + "/anykernel.zip" ;
33
+ file_path = activity .getFilesDir ().getAbsolutePath () + "/" + DocumentFile . fromSingleUri ( activity , uri ). getName () ;
32
34
binary_path = activity .getFilesDir ().getAbsolutePath () + "/META-INF/com/google/android/update-binary" ;
33
35
34
36
try {
@@ -118,7 +120,7 @@ void copy() throws IOException {
118
120
}
119
121
120
122
void getBinary () throws IOException {
121
- runWithNewProcessNoReturn (false , "unzip " + file_path + " \" */update-binary\" -d " + activity .getFilesDir ().getAbsolutePath ());
123
+ runWithNewProcessNoReturn (false , "unzip \" " + file_path + " \ " \" */update-binary\" -d " + activity .getFilesDir ().getAbsolutePath ());
122
124
if (!new File (binary_path ).exists ())
123
125
throw new IOException ();
124
126
}
@@ -135,7 +137,7 @@ void flash(Activity activity) throws IOException {
135
137
OutputStreamWriter outputStreamWriter = new OutputStreamWriter (process .getOutputStream ());
136
138
BufferedReader bufferedReader = new BufferedReader (new InputStreamReader (process .getInputStream ()));
137
139
outputStreamWriter .write ("export POSTINSTALL=" + activity .getFilesDir ().getAbsolutePath () + "\n " );
138
- outputStreamWriter .write ("sh " + (MainActivity .DEBUG ? "-x " : "" ) + binary_path + " 3 1 " + file_path + "&& touch " + activity .getFilesDir ().getAbsolutePath () + "/done\n exit\n " );
140
+ outputStreamWriter .write ("sh " + (MainActivity .DEBUG ? "-x " : "" ) + binary_path + " 3 1 \" " + file_path + " \ " && touch " + activity .getFilesDir ().getAbsolutePath () + "/done\n exit\n " );
139
141
outputStreamWriter .flush ();
140
142
String line ;
141
143
while ((line = bufferedReader .readLine ()) != null )
0 commit comments