OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chromeos/dbus/fake_bluetooth_device_client.h" | 5 #include "chromeos/dbus/fake_bluetooth_device_client.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <unistd.h> | 8 #include <unistd.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 if (agent_service_provider == NULL) { | 411 if (agent_service_provider == NULL) { |
412 error_callback.Run(kNoResponseError, "Missing agent"); | 412 error_callback.Run(kNoResponseError, "Missing agent"); |
413 return; | 413 return; |
414 } | 414 } |
415 | 415 |
416 if (object_path == dbus::ObjectPath(kAppleMousePath) || | 416 if (object_path == dbus::ObjectPath(kAppleMousePath) || |
417 object_path == dbus::ObjectPath(kMicrosoftMousePath) || | 417 object_path == dbus::ObjectPath(kMicrosoftMousePath) || |
418 object_path == dbus::ObjectPath(kUnconnectableDevicePath)) { | 418 object_path == dbus::ObjectPath(kUnconnectableDevicePath)) { |
419 // No need to call anything on the pairing delegate, just wait 3 times | 419 // No need to call anything on the pairing delegate, just wait 3 times |
420 // the interval before acting as if the other end accepted it. | 420 // the interval before acting as if the other end accepted it. |
421 MessageLoop::current()->PostDelayedTask( | 421 base::MessageLoop::current()->PostDelayedTask( |
422 FROM_HERE, | 422 FROM_HERE, |
423 base::Bind(&FakeBluetoothDeviceClient::CompleteSimulatedPairing, | 423 base::Bind(&FakeBluetoothDeviceClient::CompleteSimulatedPairing, |
424 base::Unretained(this), | 424 base::Unretained(this), |
425 object_path, callback, error_callback), | 425 object_path, callback, error_callback), |
426 base::TimeDelta::FromMilliseconds(3 * simulation_interval_ms_)); | 426 base::TimeDelta::FromMilliseconds(3 * simulation_interval_ms_)); |
427 | 427 |
428 } else if (object_path == dbus::ObjectPath(kAppleKeyboardPath)) { | 428 } else if (object_path == dbus::ObjectPath(kAppleKeyboardPath)) { |
429 // Display a Pincode, and wait 7 times the interval before acting as | 429 // Display a Pincode, and wait 7 times the interval before acting as |
430 // if the other end accepted it. | 430 // if the other end accepted it. |
431 agent_service_provider->DisplayPinCode(object_path, "123456"); | 431 agent_service_provider->DisplayPinCode(object_path, "123456"); |
432 | 432 |
433 MessageLoop::current()->PostDelayedTask( | 433 base::MessageLoop::current()->PostDelayedTask( |
434 FROM_HERE, | 434 FROM_HERE, |
435 base::Bind(&FakeBluetoothDeviceClient::CompleteSimulatedPairing, | 435 base::Bind(&FakeBluetoothDeviceClient::CompleteSimulatedPairing, |
436 base::Unretained(this), | 436 base::Unretained(this), |
437 object_path, callback, error_callback), | 437 object_path, callback, error_callback), |
438 base::TimeDelta::FromMilliseconds(7 * simulation_interval_ms_)); | 438 base::TimeDelta::FromMilliseconds(7 * simulation_interval_ms_)); |
439 | 439 |
440 } else if (object_path == dbus::ObjectPath(kVanishingDevicePath)) { | 440 } else if (object_path == dbus::ObjectPath(kVanishingDevicePath)) { |
441 // The vanishing device simulates being too far away, and thus times out. | 441 // The vanishing device simulates being too far away, and thus times out. |
442 MessageLoop::current()->PostDelayedTask( | 442 base::MessageLoop::current()->PostDelayedTask( |
443 FROM_HERE, | 443 FROM_HERE, |
444 base::Bind(&FakeBluetoothDeviceClient::TimeoutSimulatedPairing, | 444 base::Bind(&FakeBluetoothDeviceClient::TimeoutSimulatedPairing, |
445 base::Unretained(this), | 445 base::Unretained(this), |
446 object_path, error_callback), | 446 object_path, error_callback), |
447 base::TimeDelta::FromMilliseconds(4 * simulation_interval_ms_)); | 447 base::TimeDelta::FromMilliseconds(4 * simulation_interval_ms_)); |
448 | 448 |
449 } else if (object_path == dbus::ObjectPath(kMotorolaKeyboardPath)) { | 449 } else if (object_path == dbus::ObjectPath(kMotorolaKeyboardPath)) { |
450 // Display a passkey, and each interval act as if another key was entered | 450 // Display a passkey, and each interval act as if another key was entered |
451 // for it. | 451 // for it. |
452 agent_service_provider->DisplayPasskey(object_path, 123456, 0); | 452 agent_service_provider->DisplayPasskey(object_path, 123456, 0); |
453 | 453 |
454 MessageLoop::current()->PostDelayedTask( | 454 base::MessageLoop::current()->PostDelayedTask( |
455 FROM_HERE, | 455 FROM_HERE, |
456 base::Bind(&FakeBluetoothDeviceClient::SimulateKeypress, | 456 base::Bind(&FakeBluetoothDeviceClient::SimulateKeypress, |
457 base::Unretained(this), | 457 base::Unretained(this), |
458 1, object_path, callback, error_callback), | 458 1, object_path, callback, error_callback), |
459 base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); | 459 base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); |
460 | 460 |
461 } else if (object_path == dbus::ObjectPath(kSonyHeadphonesPath)) { | 461 } else if (object_path == dbus::ObjectPath(kSonyHeadphonesPath)) { |
462 // Request a Pincode. | 462 // Request a Pincode. |
463 agent_service_provider->RequestPinCode( | 463 agent_service_provider->RequestPinCode( |
464 object_path, | 464 object_path, |
(...skipping 18 matching lines...) Expand all Loading... |
483 agent_service_provider->RequestPasskey( | 483 agent_service_provider->RequestPasskey( |
484 object_path, | 484 object_path, |
485 base::Bind(&FakeBluetoothDeviceClient::PasskeyCallback, | 485 base::Bind(&FakeBluetoothDeviceClient::PasskeyCallback, |
486 base::Unretained(this), | 486 base::Unretained(this), |
487 object_path, | 487 object_path, |
488 callback, | 488 callback, |
489 error_callback)); | 489 error_callback)); |
490 | 490 |
491 } else if (object_path == dbus::ObjectPath(kUnpairableDevicePath)) { | 491 } else if (object_path == dbus::ObjectPath(kUnpairableDevicePath)) { |
492 // Fails the pairing with an org.bluez.Error.Failed error. | 492 // Fails the pairing with an org.bluez.Error.Failed error. |
493 MessageLoop::current()->PostDelayedTask( | 493 base::MessageLoop::current()->PostDelayedTask( |
494 FROM_HERE, | 494 FROM_HERE, |
495 base::Bind(&FakeBluetoothDeviceClient::FailSimulatedPairing, | 495 base::Bind(&FakeBluetoothDeviceClient::FailSimulatedPairing, |
496 base::Unretained(this), | 496 base::Unretained(this), |
497 object_path, error_callback), | 497 object_path, error_callback), |
498 base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); | 498 base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); |
499 | 499 |
500 } else { | 500 } else { |
501 error_callback.Run(kNoResponseError, "No pairing fake"); | 501 error_callback.Run(kNoResponseError, "No pairing fake"); |
502 } | 502 } |
503 } | 503 } |
504 | 504 |
505 void FakeBluetoothDeviceClient::CancelPairing( | 505 void FakeBluetoothDeviceClient::CancelPairing( |
506 const dbus::ObjectPath& object_path, | 506 const dbus::ObjectPath& object_path, |
507 const base::Closure& callback, | 507 const base::Closure& callback, |
508 const ErrorCallback& error_callback) { | 508 const ErrorCallback& error_callback) { |
509 VLOG(1) << "CancelPairing: " << object_path.value(); | 509 VLOG(1) << "CancelPairing: " << object_path.value(); |
510 pairing_cancelled_ = true; | 510 pairing_cancelled_ = true; |
511 callback.Run(); | 511 callback.Run(); |
512 } | 512 } |
513 | 513 |
514 | 514 |
515 void FakeBluetoothDeviceClient::BeginDiscoverySimulation( | 515 void FakeBluetoothDeviceClient::BeginDiscoverySimulation( |
516 const dbus::ObjectPath& adapter_path) { | 516 const dbus::ObjectPath& adapter_path) { |
517 VLOG(1) << "starting discovery simulation"; | 517 VLOG(1) << "starting discovery simulation"; |
518 | 518 |
519 discovery_simulation_step_ = 1; | 519 discovery_simulation_step_ = 1; |
520 | 520 |
521 MessageLoop::current()->PostDelayedTask( | 521 base::MessageLoop::current()->PostDelayedTask( |
522 FROM_HERE, | 522 FROM_HERE, |
523 base::Bind(&FakeBluetoothDeviceClient::DiscoverySimulationTimer, | 523 base::Bind(&FakeBluetoothDeviceClient::DiscoverySimulationTimer, |
524 base::Unretained(this)), | 524 base::Unretained(this)), |
525 base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); | 525 base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); |
526 } | 526 } |
527 | 527 |
528 void FakeBluetoothDeviceClient::EndDiscoverySimulation( | 528 void FakeBluetoothDeviceClient::EndDiscoverySimulation( |
529 const dbus::ObjectPath& adapter_path) { | 529 const dbus::ObjectPath& adapter_path) { |
530 VLOG(1) << "stopping discovery simulation"; | 530 VLOG(1) << "stopping discovery simulation"; |
531 discovery_simulation_step_ = 0; | 531 discovery_simulation_step_ = 0; |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 } else if (discovery_simulation_step_ == 13) { | 801 } else if (discovery_simulation_step_ == 13) { |
802 RemoveDevice(dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 802 RemoveDevice(dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
803 dbus::ObjectPath(kVanishingDevicePath)); | 803 dbus::ObjectPath(kVanishingDevicePath)); |
804 | 804 |
805 } else if (discovery_simulation_step_ == 14) { | 805 } else if (discovery_simulation_step_ == 14) { |
806 return; | 806 return; |
807 | 807 |
808 } | 808 } |
809 | 809 |
810 ++discovery_simulation_step_; | 810 ++discovery_simulation_step_; |
811 MessageLoop::current()->PostDelayedTask( | 811 base::MessageLoop::current()->PostDelayedTask( |
812 FROM_HERE, | 812 FROM_HERE, |
813 base::Bind(&FakeBluetoothDeviceClient::DiscoverySimulationTimer, | 813 base::Bind(&FakeBluetoothDeviceClient::DiscoverySimulationTimer, |
814 base::Unretained(this)), | 814 base::Unretained(this)), |
815 base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); | 815 base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); |
816 } | 816 } |
817 | 817 |
818 | 818 |
819 void FakeBluetoothDeviceClient::CompleteSimulatedPairing( | 819 void FakeBluetoothDeviceClient::CompleteSimulatedPairing( |
820 const dbus::ObjectPath& object_path, | 820 const dbus::ObjectPath& object_path, |
821 const base::Closure& callback, | 821 const base::Closure& callback, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 | 886 |
887 void FakeBluetoothDeviceClient::PinCodeCallback( | 887 void FakeBluetoothDeviceClient::PinCodeCallback( |
888 const dbus::ObjectPath& object_path, | 888 const dbus::ObjectPath& object_path, |
889 const base::Closure& callback, | 889 const base::Closure& callback, |
890 const ErrorCallback& error_callback, | 890 const ErrorCallback& error_callback, |
891 ExperimentalBluetoothAgentServiceProvider::Delegate::Status status, | 891 ExperimentalBluetoothAgentServiceProvider::Delegate::Status status, |
892 const std::string& pincode) { | 892 const std::string& pincode) { |
893 VLOG(1) << "PinCodeCallback: " << object_path.value(); | 893 VLOG(1) << "PinCodeCallback: " << object_path.value(); |
894 | 894 |
895 if (status == ExperimentalBluetoothAgentServiceProvider::Delegate::SUCCESS) { | 895 if (status == ExperimentalBluetoothAgentServiceProvider::Delegate::SUCCESS) { |
896 MessageLoop::current()->PostDelayedTask( | 896 base::MessageLoop::current()->PostDelayedTask( |
897 FROM_HERE, | 897 FROM_HERE, |
898 base::Bind(&FakeBluetoothDeviceClient::CompleteSimulatedPairing, | 898 base::Bind(&FakeBluetoothDeviceClient::CompleteSimulatedPairing, |
899 base::Unretained(this), | 899 base::Unretained(this), |
900 object_path, callback, error_callback), | 900 object_path, callback, error_callback), |
901 base::TimeDelta::FromMilliseconds(3 * simulation_interval_ms_)); | 901 base::TimeDelta::FromMilliseconds(3 * simulation_interval_ms_)); |
902 | 902 |
903 } else if (status == | 903 } else if (status == |
904 ExperimentalBluetoothAgentServiceProvider::Delegate::CANCELLED) { | 904 ExperimentalBluetoothAgentServiceProvider::Delegate::CANCELLED) { |
905 MessageLoop::current()->PostDelayedTask( | 905 base::MessageLoop::current()->PostDelayedTask( |
906 FROM_HERE, | 906 FROM_HERE, |
907 base::Bind(&FakeBluetoothDeviceClient::CancelSimulatedPairing, | 907 base::Bind(&FakeBluetoothDeviceClient::CancelSimulatedPairing, |
908 base::Unretained(this), | 908 base::Unretained(this), |
909 object_path, error_callback), | 909 object_path, error_callback), |
910 base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); | 910 base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); |
911 | 911 |
912 } else if (status == | 912 } else if (status == |
913 ExperimentalBluetoothAgentServiceProvider::Delegate::REJECTED) { | 913 ExperimentalBluetoothAgentServiceProvider::Delegate::REJECTED) { |
914 MessageLoop::current()->PostDelayedTask( | 914 base::MessageLoop::current()->PostDelayedTask( |
915 FROM_HERE, | 915 FROM_HERE, |
916 base::Bind(&FakeBluetoothDeviceClient::RejectSimulatedPairing, | 916 base::Bind(&FakeBluetoothDeviceClient::RejectSimulatedPairing, |
917 base::Unretained(this), | 917 base::Unretained(this), |
918 object_path, error_callback), | 918 object_path, error_callback), |
919 base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); | 919 base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); |
920 | 920 |
921 } | 921 } |
922 } | 922 } |
923 | 923 |
924 void FakeBluetoothDeviceClient::PasskeyCallback( | 924 void FakeBluetoothDeviceClient::PasskeyCallback( |
925 const dbus::ObjectPath& object_path, | 925 const dbus::ObjectPath& object_path, |
926 const base::Closure& callback, | 926 const base::Closure& callback, |
927 const ErrorCallback& error_callback, | 927 const ErrorCallback& error_callback, |
928 ExperimentalBluetoothAgentServiceProvider::Delegate::Status status, | 928 ExperimentalBluetoothAgentServiceProvider::Delegate::Status status, |
929 uint32 passkey) { | 929 uint32 passkey) { |
930 VLOG(1) << "PasskeyCallback: " << object_path.value(); | 930 VLOG(1) << "PasskeyCallback: " << object_path.value(); |
931 | 931 |
932 if (status == ExperimentalBluetoothAgentServiceProvider::Delegate::SUCCESS) { | 932 if (status == ExperimentalBluetoothAgentServiceProvider::Delegate::SUCCESS) { |
933 MessageLoop::current()->PostDelayedTask( | 933 base::MessageLoop::current()->PostDelayedTask( |
934 FROM_HERE, | 934 FROM_HERE, |
935 base::Bind(&FakeBluetoothDeviceClient::CompleteSimulatedPairing, | 935 base::Bind(&FakeBluetoothDeviceClient::CompleteSimulatedPairing, |
936 base::Unretained(this), | 936 base::Unretained(this), |
937 object_path, callback, error_callback), | 937 object_path, callback, error_callback), |
938 base::TimeDelta::FromMilliseconds(3 * simulation_interval_ms_)); | 938 base::TimeDelta::FromMilliseconds(3 * simulation_interval_ms_)); |
939 | 939 |
940 } else if (status == | 940 } else if (status == |
941 ExperimentalBluetoothAgentServiceProvider::Delegate::CANCELLED) { | 941 ExperimentalBluetoothAgentServiceProvider::Delegate::CANCELLED) { |
942 MessageLoop::current()->PostDelayedTask( | 942 base::MessageLoop::current()->PostDelayedTask( |
943 FROM_HERE, | 943 FROM_HERE, |
944 base::Bind(&FakeBluetoothDeviceClient::CancelSimulatedPairing, | 944 base::Bind(&FakeBluetoothDeviceClient::CancelSimulatedPairing, |
945 base::Unretained(this), | 945 base::Unretained(this), |
946 object_path, error_callback), | 946 object_path, error_callback), |
947 base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); | 947 base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); |
948 | 948 |
949 } else if (status == | 949 } else if (status == |
950 ExperimentalBluetoothAgentServiceProvider::Delegate::REJECTED) { | 950 ExperimentalBluetoothAgentServiceProvider::Delegate::REJECTED) { |
951 MessageLoop::current()->PostDelayedTask( | 951 base::MessageLoop::current()->PostDelayedTask( |
952 FROM_HERE, | 952 FROM_HERE, |
953 base::Bind(&FakeBluetoothDeviceClient::RejectSimulatedPairing, | 953 base::Bind(&FakeBluetoothDeviceClient::RejectSimulatedPairing, |
954 base::Unretained(this), | 954 base::Unretained(this), |
955 object_path, error_callback), | 955 object_path, error_callback), |
956 base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); | 956 base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); |
957 | 957 |
958 } | 958 } |
959 } | 959 } |
960 | 960 |
961 void FakeBluetoothDeviceClient::ConfirmationCallback( | 961 void FakeBluetoothDeviceClient::ConfirmationCallback( |
962 const dbus::ObjectPath& object_path, | 962 const dbus::ObjectPath& object_path, |
963 const base::Closure& callback, | 963 const base::Closure& callback, |
964 const ErrorCallback& error_callback, | 964 const ErrorCallback& error_callback, |
965 ExperimentalBluetoothAgentServiceProvider::Delegate::Status status) { | 965 ExperimentalBluetoothAgentServiceProvider::Delegate::Status status) { |
966 VLOG(1) << "ConfirmationCallback: " << object_path.value(); | 966 VLOG(1) << "ConfirmationCallback: " << object_path.value(); |
967 | 967 |
968 if (status == ExperimentalBluetoothAgentServiceProvider::Delegate::SUCCESS) { | 968 if (status == ExperimentalBluetoothAgentServiceProvider::Delegate::SUCCESS) { |
969 MessageLoop::current()->PostDelayedTask( | 969 base::MessageLoop::current()->PostDelayedTask( |
970 FROM_HERE, | 970 FROM_HERE, |
971 base::Bind(&FakeBluetoothDeviceClient::CompleteSimulatedPairing, | 971 base::Bind(&FakeBluetoothDeviceClient::CompleteSimulatedPairing, |
972 base::Unretained(this), | 972 base::Unretained(this), |
973 object_path, callback, error_callback), | 973 object_path, callback, error_callback), |
974 base::TimeDelta::FromMilliseconds(3 * simulation_interval_ms_)); | 974 base::TimeDelta::FromMilliseconds(3 * simulation_interval_ms_)); |
975 | 975 |
976 } else if (status == | 976 } else if (status == |
977 ExperimentalBluetoothAgentServiceProvider::Delegate::CANCELLED) { | 977 ExperimentalBluetoothAgentServiceProvider::Delegate::CANCELLED) { |
978 MessageLoop::current()->PostDelayedTask( | 978 base::MessageLoop::current()->PostDelayedTask( |
979 FROM_HERE, | 979 FROM_HERE, |
980 base::Bind(&FakeBluetoothDeviceClient::CancelSimulatedPairing, | 980 base::Bind(&FakeBluetoothDeviceClient::CancelSimulatedPairing, |
981 base::Unretained(this), | 981 base::Unretained(this), |
982 object_path, error_callback), | 982 object_path, error_callback), |
983 base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); | 983 base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); |
984 | 984 |
985 } else if (status == | 985 } else if (status == |
986 ExperimentalBluetoothAgentServiceProvider::Delegate::REJECTED) { | 986 ExperimentalBluetoothAgentServiceProvider::Delegate::REJECTED) { |
987 MessageLoop::current()->PostDelayedTask( | 987 base::MessageLoop::current()->PostDelayedTask( |
988 FROM_HERE, | 988 FROM_HERE, |
989 base::Bind(&FakeBluetoothDeviceClient::RejectSimulatedPairing, | 989 base::Bind(&FakeBluetoothDeviceClient::RejectSimulatedPairing, |
990 base::Unretained(this), | 990 base::Unretained(this), |
991 object_path, error_callback), | 991 object_path, error_callback), |
992 base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); | 992 base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); |
993 | 993 |
994 } | 994 } |
995 } | 995 } |
996 | 996 |
997 void FakeBluetoothDeviceClient::SimulateKeypress( | 997 void FakeBluetoothDeviceClient::SimulateKeypress( |
998 uint16 entered, | 998 uint16 entered, |
999 const dbus::ObjectPath& object_path, | 999 const dbus::ObjectPath& object_path, |
1000 const base::Closure& callback, | 1000 const base::Closure& callback, |
1001 const ErrorCallback& error_callback) { | 1001 const ErrorCallback& error_callback) { |
1002 VLOG(1) << "SimulateKeypress " << entered << ": " << object_path.value(); | 1002 VLOG(1) << "SimulateKeypress " << entered << ": " << object_path.value(); |
1003 | 1003 |
1004 FakeBluetoothAgentManagerClient* fake_bluetooth_agent_manager_client = | 1004 FakeBluetoothAgentManagerClient* fake_bluetooth_agent_manager_client = |
1005 static_cast<FakeBluetoothAgentManagerClient*>( | 1005 static_cast<FakeBluetoothAgentManagerClient*>( |
1006 DBusThreadManager::Get()-> | 1006 DBusThreadManager::Get()-> |
1007 GetExperimentalBluetoothAgentManagerClient()); | 1007 GetExperimentalBluetoothAgentManagerClient()); |
1008 FakeBluetoothAgentServiceProvider* agent_service_provider = | 1008 FakeBluetoothAgentServiceProvider* agent_service_provider = |
1009 fake_bluetooth_agent_manager_client->GetAgentServiceProvider(); | 1009 fake_bluetooth_agent_manager_client->GetAgentServiceProvider(); |
1010 agent_service_provider->DisplayPasskey(object_path, 123456, entered); | 1010 agent_service_provider->DisplayPasskey(object_path, 123456, entered); |
1011 | 1011 |
1012 if (entered < 7) { | 1012 if (entered < 7) { |
1013 MessageLoop::current()->PostDelayedTask( | 1013 base::MessageLoop::current()->PostDelayedTask( |
1014 FROM_HERE, | 1014 FROM_HERE, |
1015 base::Bind(&FakeBluetoothDeviceClient::SimulateKeypress, | 1015 base::Bind(&FakeBluetoothDeviceClient::SimulateKeypress, |
1016 base::Unretained(this), | 1016 base::Unretained(this), |
1017 entered + 1, object_path, callback, error_callback), | 1017 entered + 1, object_path, callback, error_callback), |
1018 base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); | 1018 base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); |
1019 | 1019 |
1020 } else { | 1020 } else { |
1021 MessageLoop::current()->PostDelayedTask( | 1021 base::MessageLoop::current()->PostDelayedTask( |
1022 FROM_HERE, | 1022 FROM_HERE, |
1023 base::Bind(&FakeBluetoothDeviceClient::CompleteSimulatedPairing, | 1023 base::Bind(&FakeBluetoothDeviceClient::CompleteSimulatedPairing, |
1024 base::Unretained(this), | 1024 base::Unretained(this), |
1025 object_path, callback, error_callback), | 1025 object_path, callback, error_callback), |
1026 base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); | 1026 base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); |
1027 | 1027 |
1028 } | 1028 } |
1029 } | 1029 } |
1030 | 1030 |
1031 void FakeBluetoothDeviceClient::ConnectionCallback( | 1031 void FakeBluetoothDeviceClient::ConnectionCallback( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 } else if (status == | 1063 } else if (status == |
1064 ExperimentalBluetoothProfileServiceProvider::Delegate::CANCELLED) { | 1064 ExperimentalBluetoothProfileServiceProvider::Delegate::CANCELLED) { |
1065 error_callback.Run(bluetooth_adapter::kErrorFailed, "Canceled"); | 1065 error_callback.Run(bluetooth_adapter::kErrorFailed, "Canceled"); |
1066 } else if (status == | 1066 } else if (status == |
1067 ExperimentalBluetoothProfileServiceProvider::Delegate::REJECTED) { | 1067 ExperimentalBluetoothProfileServiceProvider::Delegate::REJECTED) { |
1068 error_callback.Run(bluetooth_adapter::kErrorFailed, "Rejected"); | 1068 error_callback.Run(bluetooth_adapter::kErrorFailed, "Rejected"); |
1069 } | 1069 } |
1070 } | 1070 } |
1071 | 1071 |
1072 } // namespace chromeos | 1072 } // namespace chromeos |
OLD | NEW |