mirror of
				https://github.com/ARM-software/devlib.git
				synced 2025-11-04 07:51:21 +00:00 
			
		
		
		
	tagert: factor out the wait_boot_complete code
The connect() method embeds some code to wait for a target to be completely booted. Let's move this code into a dedicated function. Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
This commit is contained in:
		@@ -877,8 +877,16 @@ class AndroidTarget(Target):
 | 
				
			|||||||
            pass
 | 
					            pass
 | 
				
			||||||
        self._connected_as_root = None
 | 
					        self._connected_as_root = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def connect(self, timeout=10, check_boot_completed=True):  # pylint: disable=arguments-differ
 | 
					    def wait_boot_complete(self, timeout=10):
 | 
				
			||||||
        start = time.time()
 | 
					        start = time.time()
 | 
				
			||||||
 | 
					        boot_completed = boolean(self.getprop('sys.boot_completed'))
 | 
				
			||||||
 | 
					        while not boot_completed and timeout >= time.time() - start:
 | 
				
			||||||
 | 
					            time.sleep(5)
 | 
				
			||||||
 | 
					            boot_completed = boolean(self.getprop('sys.boot_completed'))
 | 
				
			||||||
 | 
					        if not boot_completed:
 | 
				
			||||||
 | 
					            raise TargetError('Connected but Android did not fully boot.')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def connect(self, timeout=10, check_boot_completed=True):  # pylint: disable=arguments-differ
 | 
				
			||||||
        device = self.connection_settings.get('device')
 | 
					        device = self.connection_settings.get('device')
 | 
				
			||||||
        if device and ':' in device:
 | 
					        if device and ':' in device:
 | 
				
			||||||
            # ADB does not automatically remove a network device from it's
 | 
					            # ADB does not automatically remove a network device from it's
 | 
				
			||||||
@@ -890,12 +898,7 @@ class AndroidTarget(Target):
 | 
				
			|||||||
        super(AndroidTarget, self).connect(timeout=timeout)
 | 
					        super(AndroidTarget, self).connect(timeout=timeout)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if check_boot_completed:
 | 
					        if check_boot_completed:
 | 
				
			||||||
            boot_completed = boolean(self.getprop('sys.boot_completed'))
 | 
					            self.wait_boot_complete(timeout)
 | 
				
			||||||
            while not boot_completed and timeout >= time.time() - start:
 | 
					 | 
				
			||||||
                time.sleep(5)
 | 
					 | 
				
			||||||
                boot_completed = boolean(self.getprop('sys.boot_completed'))
 | 
					 | 
				
			||||||
            if not boot_completed:
 | 
					 | 
				
			||||||
                raise TargetError('Connected but Android did not fully boot.')
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def setup(self, executables=None):
 | 
					    def setup(self, executables=None):
 | 
				
			||||||
        super(AndroidTarget, self).setup(executables)
 | 
					        super(AndroidTarget, self).setup(executables)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user