1414
1515import java .io .BufferedReader ;
1616import java .io .IOException ;
17- import java .io .InputStreamReader ;
17+ import java .io .* ;
1818import java .io .OutputStream ;
1919
2020import java .util .Map ;
@@ -281,16 +281,14 @@ private void isProcessRunning(String pid, CallbackContext callbackContext) {
281281 }
282282 }
283283
284-
285- private void cleanupCallback (String id ) {
286- callbackContextMap .remove (id );
287- }
288-
289- @ Override
290- public void onDestroy () {
291- super .onDestroy ();
292- Intent serviceIntent = new Intent (context , KeepAliveService .class );
293- context .stopService (serviceIntent );
284+ private void streamOutput (InputStream inputStream , String pid , String streamType ) {
285+ try (BufferedReader reader = new BufferedReader (new InputStreamReader (inputStream ))) {
286+ String line ;
287+ while ((line = reader .readLine ()) != null ) {
288+ sendPluginMessage (pid , streamType + ":" + line );
289+ }
290+ } catch (IOException ignored ) {
291+ }
294292 }
295293
296294 private void sendPluginMessage (String pid , String message ) {
@@ -302,9 +300,16 @@ private void sendPluginMessage(String pid, String message) {
302300 }
303301 }
304302
303+ @ Override
304+ public void onDestroy () {
305+ super .onDestroy ();
306+ //Intent serviceIntent = new Intent(context, KeepAliveService.class);
307+ //context.stopService(serviceIntent);
308+ }
309+
305310 private void cleanup (String pid ) {
306311 processes .remove (pid );
307312 processInputs .remove (pid );
308313 processCallbacks .remove (pid );
309314 }
310- }
315+ }
0 commit comments