def test_201_test_foreground_not_sticky_services_are_working(self):
        """
         https://github.com/NativeScript/android-runtime/issues/1347
        """
        Adb.stop_application(self.emulator.id, "org.nativescript.TestApp")
        File.copy(
            os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android',
                         'files', 'android-runtime-1347',
                         'AndroidManifest.xml'),
            os.path.join(TEST_RUN_HOME, APP_NAME, 'app', 'App_Resources',
                         'Android', 'src', 'main', 'AndroidManifest.xml'),
            True)
        File.copy(
            os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android',
                         'files', 'android-runtime-1347', 'not_sticky',
                         'app.js'),
            os.path.join(TEST_RUN_HOME, APP_NAME, 'app', 'app.js'), True)
        File.copy(
            os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android',
                         'files', 'android-runtime-1347',
                         'main-view-model.js'),
            os.path.join(TEST_RUN_HOME, APP_NAME, 'app', 'main-view-model.js'),
            True)
        log = Tns.run_android(APP_NAME,
                              device=self.emulator.id,
                              wait=False,
                              verify=False)
        strings = [
            'Successfully synced application', 'on device', self.emulator.id
        ]
        test_result = Wait.until(lambda: all(string in File.read(log.log_file)
                                             for string in strings),
                                 timeout=240,
                                 period=5)

        assert test_result, "App not build correctly ! Logs: " + File.read(
            log.log_file)
        Device.click(self.emulator, text="TAP", case_sensitive=True)
        time.sleep(5)
        test_result = Wait.until(
            lambda: "Create Foreground Service!" in File.read(log.log_file),
            timeout=30,
            period=5)
        assert test_result, "OnCreate foreground service log not found! Logs: " + File.read(
            log.log_file)

        service_name = "com.nativescript.location.BackgroundService"
        service_info = Adb.get_active_services(self.emulator.id, service_name)
        assert service_name in service_info, "{0} service not found! Logs: {1}".format(
            service_name, service_info)

        pid = Adb.get_process_pid(self.emulator.id, "org.nativescript.TestApp")
        Adb.kill_application(self.emulator.id, "org.nativescript.TestApp", pid)
        service_info = Adb.get_active_services(self.emulator.id, service_name)
        assert service_name not in service_info, "{0} service found! Logs: {1}".format(
            service_name, service_info)
        assert pid not in service_info, "{0} service with id {1} found! Logs: {2}".format(
            service_name, pid, service_info)
 def assert_apk(apk, device, app_id):
     Adb.install(apk, device.id)
     Adb.start_application(device.id, app_id)
     Device.wait_for_text(device, text='Ter Stegen', timeout=90)
     Adb.stop_application(device_id=device.id, app_id=app_id)
     Adb.uninstall(app_id, device.id)