Lines Matching refs:self

118   def __init_socket_port(self):  argument
135 raise error_util.CameraItsError(self._device_id,
157 0] == self._device_id and remote_p == ItsSession.REMOTE_PORT:
167 if self.check_port_availability(p, used_ports):
172 raise error_util.CameraItsError(self._device_id,
179 self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
180 self.sock.connect((self.IPADDR, port))
181 self.sock.settimeout(self.SOCK_TIMEOUT)
183 def check_port_availability(self, check_port, used_ports): argument
196 (self.adb, check_port, self.REMOTE_PORT)
207 def __wait_for_service(self): argument
221 _run('%s reboot' % (self.adb))
222 _run('%s wait-for-device' % (self.adb))
228 _run('%s logcat -c' % (self.adb))
231 _run('%s shell am force-stop --user 0 %s' % (self.adb, self.PACKAGE))
233 '-a %s') % (self.adb, self.INTENT_START))
237 self.adb.split() + ['logcat'], stdout=subprocess.PIPE)
246 def __init__(self, device_id=None, camera_id=None, hidden_physical_id=None): argument
247 self._camera_id = camera_id
248 self._device_id = device_id
249 self._hidden_physical_id = hidden_physical_id
252 self.adb = 'adb -s ' + self._device_id
253 self.__wait_for_service()
254 self.__init_socket_port()
256 def __enter__(self): argument
257 self.__close_camera()
258 self.__open_camera()
259 return self
261 def __exit__(self, exec_type, exec_value, exec_traceback): argument
262 if hasattr(self, 'sock') and self.sock:
263 self.__close_camera()
264 self.sock.close()
267 def override_with_hidden_physical_camera_props(self, props): argument
280 if self._hidden_physical_id:
285 if self._hidden_physical_id not in physical_ids:
288 props = self.get_camera_properties_by_id(self._hidden_physical_id)
289 self.props = props
292 def get_camera_properties(self): argument
300 self.sock.send(json.dumps(cmd).encode() + '\n'.encode())
301 data, _ = self.__read_response_from_socket()
304 self.props = data['objValue']['cameraProperties']
307 def get_camera_properties_by_id(self, camera_id): argument
320 self.sock.send(json.dumps(cmd).encode() + '\n'.encode())
321 data, _ = self.__read_response_from_socket()
326 def __read_response_from_socket(self): argument
334 ch = self.sock.recv(1).decode('utf-8')
348 nbytes = self.sock.recv_into(view, n)
354 def __open_camera(self): argument
364 if not self._camera_id:
365 self._camera_id = 0
371 self._camera_id = camera_id_combos[0].id
372 self._hidden_physical_id = camera_id_combos[0].sub_id
374 logging.debug('Opening camera: %s', self._camera_id)
375 cmd = {'cmdName': 'open', 'cameraId': self._camera_id}
376 self.sock.send(json.dumps(cmd).encode() + '\n'.encode())
377 data, _ = self.__read_response_from_socket()
381 def __close_camera(self): argument
383 self.sock.send(json.dumps(cmd).encode() + '\n'.encode())
384 data, _ = self.__read_response_from_socket()
388 def get_sensors(self): argument
396 self.sock.send(json.dumps(cmd).encode() + '\n'.encode())
397 data, _ = self.__read_response_from_socket()
403 def start_sensor_events(self): argument
413 self.sock.send(json.dumps(cmd).encode() + '\n'.encode())
414 data, _ = self.__read_response_from_socket()
419 def get_sensor_events(self): argument
442 self.sock.send(json.dumps(cmd).encode() + '\n'.encode())
443 timeout = self.SOCK_TIMEOUT + self.EXTRA_SOCK_TIMEOUT
444 self.sock.settimeout(timeout)
445 data, _ = self.__read_response_from_socket()
449 self.sock.settimeout(self.SOCK_TIMEOUT)
452 def do_capture(self, argument
635 'yuv', self.props)[0]
650 if self._hidden_physical_id:
651 s['physicalCamera'] = self._hidden_physical_id
656 cam_id = self._camera_id
672 if cam_id == self._camera_id:
698 if self.props is None:
701 'yuv', self.props)[0]
737 extended_timeout = longest_exp_time // self.SEC_TO_NSEC + self.SOCK_TIMEOUT
739 extended_timeout += self.EXTRA_SOCK_TIMEOUT
740 self.sock.settimeout(extended_timeout)
745 self.sock.send(json.dumps(cmd).encode() + '\n'.encode())
757 json_obj, buf = self.__read_response_from_socket()
760 bufs[self._camera_id][fmt].append(buf)
764 yuv_bufs[self._camera_id][buf_size].append(buf)
796 cam_id = self._camera_id
803 if cam_id == self._camera_id:
818 self.sock.settimeout(self.SOCK_TIMEOUT)
825 def do_vibrate(self, pattern): argument
843 self.sock.send(json.dumps(cmd).encode() + '\n'.encode())
844 data, _ = self.__read_response_from_socket()
849 def set_audio_restriction(self, mode): argument
861 self.sock.send(json.dumps(cmd).encode() + '\n'.encode())
862 data, _ = self.__read_response_from_socket()
868 def do_3a(self, argument
933 if self._hidden_physical_id:
934 cmd['physicalId'] = self._hidden_physical_id
935 self.sock.send(json.dumps(cmd).encode() + '\n'.encode())
945 data, _ = self.__read_response_from_socket()
970 def calc_camera_fov(self, props): argument
983 cap = self.do_capture(capture_request_utils.auto_capture_request())
997 def get_file_name_to_load(self, chart_distance, camera_fov, scene): argument
1046 def is_stream_combination_supported(self, out_surfaces): argument
1069 self.sock.send(json.dumps(cmd).encode() + '\n'.encode())
1071 data, _ = self.__read_response_from_socket()
1077 def is_camera_privacy_mode_supported(self): argument
1088 self.sock.send(json.dumps(cmd).encode() + '\n'.encode())
1090 data, _ = self.__read_response_from_socket()
1096 def is_performance_class_primary_camera(self): argument
1107 cmd['cameraId'] = self._camera_id
1108 self.sock.send(json.dumps(cmd).encode() + '\n'.encode())
1110 data, _ = self.__read_response_from_socket()
1116 def measure_camera_launch_ms(self): argument
1124 cmd['cameraId'] = self._camera_id
1125 self.sock.send(json.dumps(cmd).encode() + '\n'.encode())
1127 data, _ = self.__read_response_from_socket()
1132 def measure_camera_1080p_jpeg_capture_ms(self): argument
1140 cmd['cameraId'] = self._camera_id
1141 self.sock.send(json.dumps(cmd).encode() + '\n'.encode())
1143 data, _ = self.__read_response_from_socket()
1298 def _generate_test_image(self, brightness): argument
1307 test_image = numpy.zeros((self._TEST_IMG_W, self._TEST_IMG_H, 1),
1312 def test_validate_lighting(self): argument
1315 for brightness in self._BRIGHTNESS_CHECKS:
1318 test_image = self._generate_test_image(brightness)
1321 self.assertRaises(
1324 self.assertTrue(validate_lighting(test_image, 'unittest'),