@@ -31,13 +31,18 @@ public class PythonService extends Service implements Runnable {
3131 private String serviceEntrypoint ;
3232 private String pythonServiceArgument ;
3333
34- protected boolean autoRestartService = false ;
35- protected boolean startForeground = true ;
36-
37- public int startType () {
34+ public int getStartType () {
3835 return START_NOT_STICKY ;
3936 }
4037
38+ public boolean getStartForeground () {
39+ return false ;
40+ }
41+
42+ public boolean getAutoRestart () {
43+ return false ;
44+ }
45+
4146 /**
4247 * {@inheritDoc}
4348 */
@@ -81,11 +86,11 @@ public int onStartCommand(Intent intent, int flags, int startId) {
8186 pythonThread = new Thread (this );
8287 pythonThread .start ();
8388
84- if (startForeground ) {
89+ if (getStartForeground () ) {
8590 doStartForeground (extras );
8691 }
8792
88- return startType ();
93+ return getStartType ();
8994 }
9095
9196 protected void doStartForeground (Bundle extras ) {
@@ -118,7 +123,7 @@ protected void doStartForeground(Bundle extras) {
118123 public void onDestroy () {
119124 super .onDestroy ();
120125 pythonThread = null ;
121- if (autoRestartService && startIntent != null ) {
126+ if (getAutoRestart () && startIntent != null ) {
122127 Log .v (TAG , "Service restart requested" );
123128 startService (startIntent );
124129 }
@@ -131,8 +136,8 @@ public void onDestroy() {
131136 @ Override
132137 public void run () {
133138 PythonUtil .loadLibraries (getFilesDir ());
134- nativeStart (androidPrivate , androidArgument , serviceEntrypoint ,
135- pythonName , pythonHome , pythonPath , pythonServiceArgument );
139+ nativeStart (androidPrivate , androidArgument , serviceEntrypoint , pythonName , pythonHome ,
140+ pythonPath , pythonServiceArgument );
136141 stopSelf ();
137142 }
138143
@@ -145,8 +150,8 @@ public void run() {
145150 * @param pythonPath Python path
146151 * @param pythonServiceArgument Argument to pass to Python code
147152 */
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 ,
151156 String pythonServiceArgument );
152157}
0 commit comments