9
9
import androidx .work .ListenableWorker ;
10
10
import androidx .work .Worker ;
11
11
import androidx .work .WorkerParameters ;
12
+
12
13
import com .google .common .util .concurrent .ListenableFuture ;
14
+
13
15
import java .io .File ;
14
16
17
+ import org .kivy .android .PythonUtil ;
18
+
15
19
public class PythonWorker extends ListenableWorker implements Runnable {
16
20
// Completer for worker notification
17
21
private Completer workCompleter = null ;
@@ -34,11 +38,16 @@ public PythonWorker(
34
38
@ NonNull Context context ,
35
39
@ NonNull WorkerParameters params ) {
36
40
super (context , params );
37
- appRoot = context .getFilesDir ().getAbsolutePath () + "/app" ;
41
+
42
+ appRoot = PythonUtil .getAppRoot (context );
43
+
38
44
androidPrivate = appRoot ;
39
45
androidArgument = appRoot ;
40
46
pythonHome = appRoot ;
41
47
pythonPath = appRoot + ":" + appRoot + "/lib" ;
48
+
49
+ File appRootFile = new File (appRoot );
50
+ PythonUtil .unpackData (context , "private" , appRootFile , false );
42
51
}
43
52
44
53
public void setPythonName (String value ) {
@@ -65,10 +74,10 @@ public ListenableFuture<Result> startWork() {
65
74
66
75
@ Override
67
76
public void run () {
68
- File app_root_file = new File (appRoot );
77
+ File appRootFile = new File (appRoot );
69
78
70
79
PythonUtil .loadLibraries (
71
- app_root_file ,
80
+ appRootFile ,
72
81
new File (getApplicationContext ().getApplicationInfo ().nativeLibraryDir )
73
82
);
74
83
0 commit comments