Lines Matching refs:t
100 void handle_online(atransport *t) in handle_online() argument
103 t->online = 1; in handle_online()
104 t->SetConnectionEstablished(true); in handle_online()
107 void handle_offline(atransport *t) in handle_offline() argument
109 if (t->GetConnectionState() == kCsOffline) { in handle_offline()
110 LOG(INFO) << t->serial_name() << ": already offline"; in handle_offline()
114 LOG(INFO) << t->serial_name() << ": offline"; in handle_offline()
116 t->SetConnectionState(kCsOffline); in handle_offline()
119 t->online = 0; in handle_offline()
123 close_all_sockets(t); in handle_offline()
125 t->RunDisconnects(); in handle_offline()
168 static void send_ready(unsigned local, unsigned remote, atransport *t) in send_ready() argument
175 send_packet(p, t); in send_ready()
178 static void send_close(unsigned local, unsigned remote, atransport *t) in send_close() argument
185 send_packet(p, t); in send_close()
212 void send_connect(atransport* t) { in send_connect() argument
220 cp->msg.arg1 = t->get_max_payload(); in send_connect()
233 send_packet(cp, t); in send_connect()
236 void parse_banner(const std::string& banner, atransport* t) { in parse_banner() argument
245 t->SetFeatures(""); in parse_banner()
259 t->product = value; in parse_banner()
261 t->model = value; in parse_banner()
263 t->device = value; in parse_banner()
265 t->SetFeatures(value); in parse_banner()
273 t->SetConnectionState(kCsBootloader); in parse_banner()
276 t->SetConnectionState(kCsDevice); in parse_banner()
279 t->SetConnectionState(kCsRecovery); in parse_banner()
282 t->SetConnectionState(kCsSideload); in parse_banner()
285 t->SetConnectionState(kCsRescue); in parse_banner()
288 t->SetConnectionState(kCsHost); in parse_banner()
292 static void handle_new_connection(atransport* t, apacket* p) { in handle_new_connection() argument
293 handle_offline(t); in handle_new_connection()
295 t->update_version(p->msg.arg0, p->msg.arg1); in handle_new_connection()
297 parse_banner(banner, t); in handle_new_connection()
300 handle_online(t); in handle_new_connection()
303 handle_online(t); in handle_new_connection()
304 send_connect(t); in handle_new_connection()
306 send_auth_request(t); in handle_new_connection()
313 void handle_packet(apacket *p, atransport *t) in handle_packet() argument
324 handle_new_connection(t, p); in handle_packet()
331 if (t->GetConnectionState() != kCsAuthorizing) { in handle_packet()
332 t->SetConnectionState(kCsAuthorizing); in handle_packet()
334 send_auth_response(p->payload.data(), p->msg.data_length, t); in handle_packet()
341 if (adbd_auth_verify(t->token, sizeof(t->token), signature, &auth_key)) { in handle_packet()
342 adbd_auth_verified(t); in handle_packet()
343 t->failed_auth_attempts = 0; in handle_packet()
344 t->auth_key = auth_key; in handle_packet()
345 adbd_notify_framework_connected_key(t); in handle_packet()
347 if (t->failed_auth_attempts++ > 256) std::this_thread::sleep_for(1s); in handle_packet()
348 send_auth_request(t); in handle_packet()
354 t->auth_key = std::string(p->payload.data()); in handle_packet()
355 adbd_auth_confirm_key(t); in handle_packet()
359 t->SetConnectionState(kCsOffline); in handle_packet()
360 handle_offline(t); in handle_packet()
366 if (t->online && p->msg.arg0 != 0 && p->msg.arg1 == 0) { in handle_packet()
374 asocket* s = create_local_service_socket(address, t); in handle_packet()
376 send_close(0, p->msg.arg0, t); in handle_packet()
378 s->peer = create_remote_socket(p->msg.arg0, t); in handle_packet()
380 send_ready(s->id, s->peer->id, t); in handle_packet()
387 if (t->online && p->msg.arg0 != 0 && p->msg.arg1 != 0) { in handle_packet()
392 s->peer = create_remote_socket(p->msg.arg0, t); in handle_packet()
400 p->msg.arg1, s->peer->id, p->msg.arg1, t->serial.c_str()); in handle_packet()
406 send_close(p->msg.arg1, p->msg.arg0, t); in handle_packet()
412 if (t->online && p->msg.arg1 != 0) { in handle_packet()
425 if (p->msg.arg0 == 0 && s->peer && s->peer->transport != t) { in handle_packet()
427 t->serial.c_str(), s->peer->transport->serial.c_str()); in handle_packet()
436 if (t->online && p->msg.arg0 != 0 && p->msg.arg1 != 0) { in handle_packet()
442 send_ready(s->id, rid, t); in handle_packet()
1089 atransport* t = acquire_one_transport(type, serial, transport_id, nullptr, &error); in handle_host_request() local
1090 if (t != nullptr) { in handle_host_request()
1091 s->transport = t; in handle_host_request()
1096 WriteFdExactly(reply_fd, &t->id, sizeof(t->id)); in handle_host_request()
1134 atransport* t = acquire_one_transport(type, serial, transport_id, nullptr, &error); in handle_host_request() local
1135 if (t != nullptr) { in handle_host_request()
1136 SendOkay(reply_fd, FeatureSetToString(t->features())); in handle_host_request()
1174 atransport* t = find_transport(serial.c_str()); in handle_host_request() local
1175 if (t == nullptr) { in handle_host_request()
1179 kick_transport(t); in handle_host_request()
1193 atransport* t = acquire_one_transport(type, serial, transport_id, nullptr, &error); in handle_host_request() local
1194 if (t) { in handle_host_request()
1195 SendOkay(reply_fd, !t->serial.empty() ? t->serial : "unknown"); in handle_host_request()
1203 atransport* t = acquire_one_transport(type, serial, transport_id, nullptr, &error); in handle_host_request() local
1204 if (t) { in handle_host_request()
1205 SendOkay(reply_fd, !t->devpath.empty() ? t->devpath : "unknown"); in handle_host_request()
1213 atransport* t = acquire_one_transport(type, serial, transport_id, nullptr, &error); in handle_host_request() local
1214 if (t) { in handle_host_request()
1215 SendOkay(reply_fd, t->connection_state_name()); in handle_host_request()
1237 atransport* t = acquire_one_transport(type, serial, transport_id, nullptr, &response, true); in handle_host_request() local
1238 if (t != nullptr) { in handle_host_request()
1239 kick_transport(t, true); in handle_host_request()
1241 "reconnecting " + t->serial_name() + " [" + t->connection_state_name() + "]\n"; in handle_host_request()
1267 bool result = iterate_transports([](const atransport* t) { in update_transport_status() argument
1268 if (t->type == kTransportUsb && t->online != 1) { in update_transport_status()