@@ -31,13 +31,18 @@ public class PythonService extends Service implements Runnable {
31
31
private String serviceEntrypoint ;
32
32
private String pythonServiceArgument ;
33
33
34
- protected boolean autoRestartService = false ;
35
- protected boolean startForeground = true ;
36
-
37
- public int startType () {
34
+ public int getStartType () {
38
35
return START_NOT_STICKY ;
39
36
}
40
37
38
+ public boolean getStartForeground () {
39
+ return false ;
40
+ }
41
+
42
+ public boolean getAutoRestart () {
43
+ return false ;
44
+ }
45
+
41
46
/**
42
47
* {@inheritDoc}
43
48
*/
@@ -81,11 +86,11 @@ public int onStartCommand(Intent intent, int flags, int startId) {
81
86
pythonThread = new Thread (this );
82
87
pythonThread .start ();
83
88
84
- if (startForeground ) {
89
+ if (getStartForeground () ) {
85
90
doStartForeground (extras );
86
91
}
87
92
88
- return startType ();
93
+ return getStartType ();
89
94
}
90
95
91
96
protected void doStartForeground (Bundle extras ) {
@@ -118,7 +123,7 @@ protected void doStartForeground(Bundle extras) {
118
123
public void onDestroy () {
119
124
super .onDestroy ();
120
125
pythonThread = null ;
121
- if (autoRestartService && startIntent != null ) {
126
+ if (getAutoRestart () && startIntent != null ) {
122
127
Log .v (TAG , "Service restart requested" );
123
128
startService (startIntent );
124
129
}
@@ -131,8 +136,8 @@ public void onDestroy() {
131
136
@ Override
132
137
public void run () {
133
138
PythonUtil .loadLibraries (getFilesDir ());
134
- nativeStart (androidPrivate , androidArgument , serviceEntrypoint ,
135
- pythonName , pythonHome , pythonPath , pythonServiceArgument );
139
+ nativeStart (androidPrivate , androidArgument , serviceEntrypoint , pythonName , pythonHome ,
140
+ pythonPath , pythonServiceArgument );
136
141
stopSelf ();
137
142
}
138
143
@@ -145,8 +150,8 @@ public void run() {
145
150
* @param pythonPath Python path
146
151
* @param pythonServiceArgument Argument to pass to Python code
147
152
*/
148
- public static native void nativeStart (String androidPrivate ,
149
- String androidArgument , String serviceEntrypoint ,
150
- String pythonName , String pythonHome , String pythonPath ,
153
+ public static native void nativeStart (String androidPrivate , String androidArgument ,
154
+ String serviceEntrypoint , String pythonName ,
155
+ String pythonHome , String pythonPath ,
151
156
String pythonServiceArgument );
152
157
}
0 commit comments