OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_shill_manager_client.h" | 5 #include "chromeos/dbus/fake_shill_manager_client.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 const std::string& error_message) { | 104 const std::string& error_message) { |
105 LOG(ERROR) << error_name << ": " << error_message; | 105 LOG(ERROR) << error_name << ": " << error_message; |
106 } | 106 } |
107 | 107 |
108 bool IsConnectedState(const std::string& state) { | 108 bool IsConnectedState(const std::string& state) { |
109 return state == shill::kStateOnline || state == shill::kStatePortal || | 109 return state == shill::kStateOnline || state == shill::kStatePortal || |
110 state == shill::kStateReady; | 110 state == shill::kStateReady; |
111 } | 111 } |
112 | 112 |
113 void UpdatePortaledWifiState(const std::string& service_path) { | 113 void UpdatePortaledWifiState(const std::string& service_path) { |
114 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface() | 114 DBusThreadManager::Get() |
115 ->SetServiceProperty(service_path, | 115 ->GetShillServiceClient() |
116 shill::kStateProperty, | 116 ->GetTestInterface() |
117 base::StringValue(shill::kStatePortal)); | 117 ->SetServiceProperty(service_path, shill::kStateProperty, |
| 118 base::Value(shill::kStatePortal)); |
118 } | 119 } |
119 | 120 |
120 bool IsCellularTechnology(const std::string& type) { | 121 bool IsCellularTechnology(const std::string& type) { |
121 return (type == shill::kNetworkTechnology1Xrtt || | 122 return (type == shill::kNetworkTechnology1Xrtt || |
122 type == shill::kNetworkTechnologyEvdo || | 123 type == shill::kNetworkTechnologyEvdo || |
123 type == shill::kNetworkTechnologyGsm || | 124 type == shill::kNetworkTechnologyGsm || |
124 type == shill::kNetworkTechnologyGprs || | 125 type == shill::kNetworkTechnologyGprs || |
125 type == shill::kNetworkTechnologyEdge || | 126 type == shill::kNetworkTechnologyEdge || |
126 type == shill::kNetworkTechnologyUmts || | 127 type == shill::kNetworkTechnologyUmts || |
127 type == shill::kNetworkTechnologyHspa || | 128 type == shill::kNetworkTechnologyHspa || |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 } | 377 } |
377 | 378 |
378 ShillManagerClient::TestInterface* FakeShillManagerClient::GetTestInterface() { | 379 ShillManagerClient::TestInterface* FakeShillManagerClient::GetTestInterface() { |
379 return this; | 380 return this; |
380 } | 381 } |
381 | 382 |
382 // ShillManagerClient::TestInterface overrides. | 383 // ShillManagerClient::TestInterface overrides. |
383 | 384 |
384 void FakeShillManagerClient::AddDevice(const std::string& device_path) { | 385 void FakeShillManagerClient::AddDevice(const std::string& device_path) { |
385 if (GetListProperty(shill::kDevicesProperty) | 386 if (GetListProperty(shill::kDevicesProperty) |
386 ->AppendIfNotPresent( | 387 ->AppendIfNotPresent(base::MakeUnique<base::Value>(device_path))) { |
387 base::MakeUnique<base::StringValue>(device_path))) { | |
388 CallNotifyObserversPropertyChanged(shill::kDevicesProperty); | 388 CallNotifyObserversPropertyChanged(shill::kDevicesProperty); |
389 } | 389 } |
390 } | 390 } |
391 | 391 |
392 void FakeShillManagerClient::RemoveDevice(const std::string& device_path) { | 392 void FakeShillManagerClient::RemoveDevice(const std::string& device_path) { |
393 base::StringValue device_path_value(device_path); | 393 base::Value device_path_value(device_path); |
394 if (GetListProperty(shill::kDevicesProperty)->Remove( | 394 if (GetListProperty(shill::kDevicesProperty)->Remove( |
395 device_path_value, NULL)) { | 395 device_path_value, NULL)) { |
396 CallNotifyObserversPropertyChanged(shill::kDevicesProperty); | 396 CallNotifyObserversPropertyChanged(shill::kDevicesProperty); |
397 } | 397 } |
398 } | 398 } |
399 | 399 |
400 void FakeShillManagerClient::ClearDevices() { | 400 void FakeShillManagerClient::ClearDevices() { |
401 GetListProperty(shill::kDevicesProperty)->Clear(); | 401 GetListProperty(shill::kDevicesProperty)->Clear(); |
402 CallNotifyObserversPropertyChanged(shill::kDevicesProperty); | 402 CallNotifyObserversPropertyChanged(shill::kDevicesProperty); |
403 } | 403 } |
404 | 404 |
405 void FakeShillManagerClient::AddTechnology(const std::string& type, | 405 void FakeShillManagerClient::AddTechnology(const std::string& type, |
406 bool enabled) { | 406 bool enabled) { |
407 if (GetListProperty(shill::kAvailableTechnologiesProperty) | 407 if (GetListProperty(shill::kAvailableTechnologiesProperty) |
408 ->AppendIfNotPresent(base::MakeUnique<base::StringValue>(type))) { | 408 ->AppendIfNotPresent(base::MakeUnique<base::Value>(type))) { |
409 CallNotifyObserversPropertyChanged( | 409 CallNotifyObserversPropertyChanged( |
410 shill::kAvailableTechnologiesProperty); | 410 shill::kAvailableTechnologiesProperty); |
411 } | 411 } |
412 if (enabled && | 412 if (enabled && |
413 GetListProperty(shill::kEnabledTechnologiesProperty) | 413 GetListProperty(shill::kEnabledTechnologiesProperty) |
414 ->AppendIfNotPresent(base::MakeUnique<base::StringValue>(type))) { | 414 ->AppendIfNotPresent(base::MakeUnique<base::Value>(type))) { |
415 CallNotifyObserversPropertyChanged( | 415 CallNotifyObserversPropertyChanged( |
416 shill::kEnabledTechnologiesProperty); | 416 shill::kEnabledTechnologiesProperty); |
417 } | 417 } |
418 } | 418 } |
419 | 419 |
420 void FakeShillManagerClient::RemoveTechnology(const std::string& type) { | 420 void FakeShillManagerClient::RemoveTechnology(const std::string& type) { |
421 base::StringValue type_value(type); | 421 base::Value type_value(type); |
422 if (GetListProperty(shill::kAvailableTechnologiesProperty)->Remove( | 422 if (GetListProperty(shill::kAvailableTechnologiesProperty)->Remove( |
423 type_value, NULL)) { | 423 type_value, NULL)) { |
424 CallNotifyObserversPropertyChanged( | 424 CallNotifyObserversPropertyChanged( |
425 shill::kAvailableTechnologiesProperty); | 425 shill::kAvailableTechnologiesProperty); |
426 } | 426 } |
427 if (GetListProperty(shill::kEnabledTechnologiesProperty)->Remove( | 427 if (GetListProperty(shill::kEnabledTechnologiesProperty)->Remove( |
428 type_value, NULL)) { | 428 type_value, NULL)) { |
429 CallNotifyObserversPropertyChanged( | 429 CallNotifyObserversPropertyChanged( |
430 shill::kEnabledTechnologiesProperty); | 430 shill::kEnabledTechnologiesProperty); |
431 } | 431 } |
432 } | 432 } |
433 | 433 |
434 void FakeShillManagerClient::SetTechnologyInitializing(const std::string& type, | 434 void FakeShillManagerClient::SetTechnologyInitializing(const std::string& type, |
435 bool initializing) { | 435 bool initializing) { |
436 if (initializing) { | 436 if (initializing) { |
437 if (GetListProperty(shill::kUninitializedTechnologiesProperty) | 437 if (GetListProperty(shill::kUninitializedTechnologiesProperty) |
438 ->AppendIfNotPresent(base::MakeUnique<base::StringValue>(type))) { | 438 ->AppendIfNotPresent(base::MakeUnique<base::Value>(type))) { |
439 CallNotifyObserversPropertyChanged( | 439 CallNotifyObserversPropertyChanged( |
440 shill::kUninitializedTechnologiesProperty); | 440 shill::kUninitializedTechnologiesProperty); |
441 } | 441 } |
442 } else { | 442 } else { |
443 if (GetListProperty(shill::kUninitializedTechnologiesProperty)->Remove( | 443 if (GetListProperty(shill::kUninitializedTechnologiesProperty) |
444 base::StringValue(type), NULL)) { | 444 ->Remove(base::Value(type), NULL)) { |
445 CallNotifyObserversPropertyChanged( | 445 CallNotifyObserversPropertyChanged( |
446 shill::kUninitializedTechnologiesProperty); | 446 shill::kUninitializedTechnologiesProperty); |
447 } | 447 } |
448 } | 448 } |
449 } | 449 } |
450 | 450 |
451 void FakeShillManagerClient::AddGeoNetwork( | 451 void FakeShillManagerClient::AddGeoNetwork( |
452 const std::string& technology, | 452 const std::string& technology, |
453 const base::DictionaryValue& network) { | 453 const base::DictionaryValue& network) { |
454 base::ListValue* list_value = NULL; | 454 base::ListValue* list_value = NULL; |
455 if (!stub_geo_networks_.GetListWithoutPathExpansion(technology, | 455 if (!stub_geo_networks_.GetListWithoutPathExpansion(technology, |
456 &list_value)) { | 456 &list_value)) { |
457 list_value = new base::ListValue; | 457 list_value = new base::ListValue; |
458 stub_geo_networks_.SetWithoutPathExpansion(technology, list_value); | 458 stub_geo_networks_.SetWithoutPathExpansion(technology, list_value); |
459 } | 459 } |
460 list_value->Append(network.CreateDeepCopy()); | 460 list_value->Append(network.CreateDeepCopy()); |
461 } | 461 } |
462 | 462 |
463 void FakeShillManagerClient::AddProfile(const std::string& profile_path) { | 463 void FakeShillManagerClient::AddProfile(const std::string& profile_path) { |
464 const char* key = shill::kProfilesProperty; | 464 const char* key = shill::kProfilesProperty; |
465 if (GetListProperty(key)->AppendIfNotPresent( | 465 if (GetListProperty(key)->AppendIfNotPresent( |
466 base::MakeUnique<base::StringValue>(profile_path))) { | 466 base::MakeUnique<base::Value>(profile_path))) { |
467 CallNotifyObserversPropertyChanged(key); | 467 CallNotifyObserversPropertyChanged(key); |
468 } | 468 } |
469 } | 469 } |
470 | 470 |
471 void FakeShillManagerClient::ClearProperties() { | 471 void FakeShillManagerClient::ClearProperties() { |
472 stub_properties_.Clear(); | 472 stub_properties_.Clear(); |
473 } | 473 } |
474 | 474 |
475 void FakeShillManagerClient::SetManagerProperty(const std::string& key, | 475 void FakeShillManagerClient::SetManagerProperty(const std::string& key, |
476 const base::Value& value) { | 476 const base::Value& value) { |
477 SetProperty(key, value, | 477 SetProperty(key, value, |
478 base::Bind(&base::DoNothing), base::Bind(&LogErrorCallback)); | 478 base::Bind(&base::DoNothing), base::Bind(&LogErrorCallback)); |
479 } | 479 } |
480 | 480 |
481 void FakeShillManagerClient::AddManagerService( | 481 void FakeShillManagerClient::AddManagerService( |
482 const std::string& service_path, | 482 const std::string& service_path, |
483 bool notify_observers) { | 483 bool notify_observers) { |
484 VLOG(2) << "AddManagerService: " << service_path; | 484 VLOG(2) << "AddManagerService: " << service_path; |
485 GetListProperty(shill::kServiceCompleteListProperty) | 485 GetListProperty(shill::kServiceCompleteListProperty) |
486 ->AppendIfNotPresent(base::MakeUnique<base::StringValue>(service_path)); | 486 ->AppendIfNotPresent(base::MakeUnique<base::Value>(service_path)); |
487 SortManagerServices(false); | 487 SortManagerServices(false); |
488 if (notify_observers) | 488 if (notify_observers) |
489 CallNotifyObserversPropertyChanged(shill::kServiceCompleteListProperty); | 489 CallNotifyObserversPropertyChanged(shill::kServiceCompleteListProperty); |
490 } | 490 } |
491 | 491 |
492 void FakeShillManagerClient::RemoveManagerService( | 492 void FakeShillManagerClient::RemoveManagerService( |
493 const std::string& service_path) { | 493 const std::string& service_path) { |
494 VLOG(2) << "RemoveManagerService: " << service_path; | 494 VLOG(2) << "RemoveManagerService: " << service_path; |
495 base::StringValue service_path_value(service_path); | 495 base::Value service_path_value(service_path); |
496 GetListProperty(shill::kServiceCompleteListProperty)->Remove( | 496 GetListProperty(shill::kServiceCompleteListProperty)->Remove( |
497 service_path_value, NULL); | 497 service_path_value, NULL); |
498 CallNotifyObserversPropertyChanged(shill::kServiceCompleteListProperty); | 498 CallNotifyObserversPropertyChanged(shill::kServiceCompleteListProperty); |
499 } | 499 } |
500 | 500 |
501 void FakeShillManagerClient::ClearManagerServices() { | 501 void FakeShillManagerClient::ClearManagerServices() { |
502 VLOG(1) << "ClearManagerServices"; | 502 VLOG(1) << "ClearManagerServices"; |
503 GetListProperty(shill::kServiceCompleteListProperty)->Clear(); | 503 GetListProperty(shill::kServiceCompleteListProperty)->Clear(); |
504 CallNotifyObserversPropertyChanged(shill::kServiceCompleteListProperty); | 504 CallNotifyObserversPropertyChanged(shill::kServiceCompleteListProperty); |
505 } | 505 } |
506 | 506 |
507 void FakeShillManagerClient::ServiceStateChanged( | 507 void FakeShillManagerClient::ServiceStateChanged( |
508 const std::string& service_path, | 508 const std::string& service_path, |
509 const std::string& state) { | 509 const std::string& state) { |
510 if (service_path == default_service_ && !IsConnectedState(state)) { | 510 if (service_path == default_service_ && !IsConnectedState(state)) { |
511 // Default service is no longer connected; clear. | 511 // Default service is no longer connected; clear. |
512 default_service_.clear(); | 512 default_service_.clear(); |
513 base::StringValue default_service_value(default_service_); | 513 base::Value default_service_value(default_service_); |
514 SetManagerProperty(shill::kDefaultServiceProperty, default_service_value); | 514 SetManagerProperty(shill::kDefaultServiceProperty, default_service_value); |
515 } | 515 } |
516 } | 516 } |
517 | 517 |
518 void FakeShillManagerClient::SortManagerServices(bool notify) { | 518 void FakeShillManagerClient::SortManagerServices(bool notify) { |
519 VLOG(1) << "SortManagerServices"; | 519 VLOG(1) << "SortManagerServices"; |
520 static const char* ordered_types[] = {shill::kTypeEthernet, | 520 static const char* ordered_types[] = {shill::kTypeEthernet, |
521 shill::kTypeEthernetEap, | 521 shill::kTypeEthernetEap, |
522 shill::kTypeWifi, | 522 shill::kTypeWifi, |
523 shill::kTypeCellular, | 523 shill::kTypeCellular, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 LOG(ERROR) << "Properties not found for service: " << service_path; | 565 LOG(ERROR) << "Properties not found for service: " << service_path; |
566 } else { | 566 } else { |
567 std::string state; | 567 std::string state; |
568 properties->GetString(shill::kStateProperty, &state); | 568 properties->GetString(shill::kStateProperty, &state); |
569 if (IsConnectedState(state)) | 569 if (IsConnectedState(state)) |
570 new_default_service = service_path; | 570 new_default_service = service_path; |
571 } | 571 } |
572 } | 572 } |
573 if (default_service_ != new_default_service) { | 573 if (default_service_ != new_default_service) { |
574 default_service_ = new_default_service; | 574 default_service_ = new_default_service; |
575 base::StringValue default_service_value(default_service_); | 575 base::Value default_service_value(default_service_); |
576 SetManagerProperty(shill::kDefaultServiceProperty, default_service_value); | 576 SetManagerProperty(shill::kDefaultServiceProperty, default_service_value); |
577 } | 577 } |
578 } | 578 } |
579 | 579 |
580 int FakeShillManagerClient::GetInteractiveDelay() const { | 580 int FakeShillManagerClient::GetInteractiveDelay() const { |
581 return interactive_delay_; | 581 return interactive_delay_; |
582 } | 582 } |
583 | 583 |
584 void FakeShillManagerClient::SetBestServiceToConnect( | 584 void FakeShillManagerClient::SetBestServiceToConnect( |
585 const std::string& service_path) { | 585 const std::string& service_path) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 | 640 |
641 bool enabled; | 641 bool enabled; |
642 std::string state; | 642 std::string state; |
643 | 643 |
644 // Ethernet | 644 // Ethernet |
645 state = GetInitialStateForType(shill::kTypeEthernet, &enabled); | 645 state = GetInitialStateForType(shill::kTypeEthernet, &enabled); |
646 if (state == shill::kStateOnline || state == shill::kStateIdle) { | 646 if (state == shill::kStateOnline || state == shill::kStateIdle) { |
647 AddTechnology(shill::kTypeEthernet, enabled); | 647 AddTechnology(shill::kTypeEthernet, enabled); |
648 devices->AddDevice( | 648 devices->AddDevice( |
649 "/device/eth1", shill::kTypeEthernet, "stub_eth_device1"); | 649 "/device/eth1", shill::kTypeEthernet, "stub_eth_device1"); |
650 devices->SetDeviceProperty("/device/eth1", | 650 devices->SetDeviceProperty("/device/eth1", shill::kAddressProperty, |
651 shill::kAddressProperty, | 651 base::Value("0123456789ab")); |
652 base::StringValue("0123456789ab")); | |
653 base::ListValue eth_ip_configs; | 652 base::ListValue eth_ip_configs; |
654 eth_ip_configs.AppendString("ipconfig_v4_path"); | 653 eth_ip_configs.AppendString("ipconfig_v4_path"); |
655 eth_ip_configs.AppendString("ipconfig_v6_path"); | 654 eth_ip_configs.AppendString("ipconfig_v6_path"); |
656 devices->SetDeviceProperty("/device/eth1", | 655 devices->SetDeviceProperty("/device/eth1", |
657 shill::kIPConfigsProperty, | 656 shill::kIPConfigsProperty, |
658 eth_ip_configs); | 657 eth_ip_configs); |
659 const std::string kFakeEthernetNetworkPath = "/service/eth1"; | 658 const std::string kFakeEthernetNetworkPath = "/service/eth1"; |
660 services->AddService(kFakeEthernetNetworkPath, | 659 services->AddService(kFakeEthernetNetworkPath, |
661 kFakeEthernetNetworkGuid, | 660 kFakeEthernetNetworkGuid, |
662 "eth1" /* name */, | 661 "eth1" /* name */, |
(...skipping 13 matching lines...) Expand all Loading... |
676 | 675 |
677 state = GetInitialStateForType(shill::kTypeWifi, &enabled); | 676 state = GetInitialStateForType(shill::kTypeWifi, &enabled); |
678 if (state != kTechnologyUnavailable) { | 677 if (state != kTechnologyUnavailable) { |
679 bool portaled = false; | 678 bool portaled = false; |
680 if (state == shill::kStatePortal) { | 679 if (state == shill::kStatePortal) { |
681 portaled = true; | 680 portaled = true; |
682 state = shill::kStateIdle; | 681 state = shill::kStateIdle; |
683 } | 682 } |
684 AddTechnology(shill::kTypeWifi, enabled); | 683 AddTechnology(shill::kTypeWifi, enabled); |
685 devices->AddDevice("/device/wifi1", shill::kTypeWifi, "stub_wifi_device1"); | 684 devices->AddDevice("/device/wifi1", shill::kTypeWifi, "stub_wifi_device1"); |
686 devices->SetDeviceProperty("/device/wifi1", | 685 devices->SetDeviceProperty("/device/wifi1", shill::kAddressProperty, |
687 shill::kAddressProperty, | 686 base::Value("23456789abcd")); |
688 base::StringValue("23456789abcd")); | |
689 base::ListValue wifi_ip_configs; | 687 base::ListValue wifi_ip_configs; |
690 wifi_ip_configs.AppendString("ipconfig_v4_path"); | 688 wifi_ip_configs.AppendString("ipconfig_v4_path"); |
691 wifi_ip_configs.AppendString("ipconfig_v6_path"); | 689 wifi_ip_configs.AppendString("ipconfig_v6_path"); |
692 devices->SetDeviceProperty("/device/wifi1", | 690 devices->SetDeviceProperty("/device/wifi1", |
693 shill::kIPConfigsProperty, | 691 shill::kIPConfigsProperty, |
694 wifi_ip_configs); | 692 wifi_ip_configs); |
695 | 693 |
696 const std::string kWifi1Path = "/service/wifi1"; | 694 const std::string kWifi1Path = "/service/wifi1"; |
697 services->AddService(kWifi1Path, | 695 services->AddService(kWifi1Path, |
698 "wifi1_guid", | 696 "wifi1_guid", |
699 "wifi1" /* name */, | 697 "wifi1" /* name */, |
700 shill::kTypeWifi, | 698 shill::kTypeWifi, |
701 state, | 699 state, |
702 add_to_visible); | 700 add_to_visible); |
703 services->SetServiceProperty(kWifi1Path, | 701 services->SetServiceProperty(kWifi1Path, shill::kSecurityClassProperty, |
704 shill::kSecurityClassProperty, | 702 base::Value(shill::kSecurityWep)); |
705 base::StringValue(shill::kSecurityWep)); | |
706 services->SetServiceProperty(kWifi1Path, shill::kConnectableProperty, | 703 services->SetServiceProperty(kWifi1Path, shill::kConnectableProperty, |
707 base::Value(true)); | 704 base::Value(true)); |
708 profiles->AddService(shared_profile, kWifi1Path); | 705 profiles->AddService(shared_profile, kWifi1Path); |
709 | 706 |
710 const std::string kWifi2Path = "/service/wifi2"; | 707 const std::string kWifi2Path = "/service/wifi2"; |
711 services->AddService(kWifi2Path, "wifi2_guid", | 708 services->AddService(kWifi2Path, "wifi2_guid", |
712 s_dynamic_wep ? "wifi2_WEP" : "wifi2_PSK" /* name */, | 709 s_dynamic_wep ? "wifi2_WEP" : "wifi2_PSK" /* name */, |
713 shill::kTypeWifi, shill::kStateIdle, add_to_visible); | 710 shill::kTypeWifi, shill::kStateIdle, add_to_visible); |
714 if (s_dynamic_wep) { | 711 if (s_dynamic_wep) { |
715 services->SetServiceProperty(kWifi2Path, shill::kSecurityClassProperty, | 712 services->SetServiceProperty(kWifi2Path, shill::kSecurityClassProperty, |
716 base::StringValue(shill::kSecurityWep)); | 713 base::Value(shill::kSecurityWep)); |
717 services->SetServiceProperty( | 714 services->SetServiceProperty(kWifi2Path, shill::kEapKeyMgmtProperty, |
718 kWifi2Path, shill::kEapKeyMgmtProperty, | 715 base::Value(shill::kKeyManagementIEEE8021X)); |
719 base::StringValue(shill::kKeyManagementIEEE8021X)); | |
720 services->SetServiceProperty(kWifi2Path, shill::kEapMethodProperty, | 716 services->SetServiceProperty(kWifi2Path, shill::kEapMethodProperty, |
721 base::StringValue(shill::kEapMethodPEAP)); | 717 base::Value(shill::kEapMethodPEAP)); |
722 services->SetServiceProperty(kWifi2Path, shill::kEapIdentityProperty, | 718 services->SetServiceProperty(kWifi2Path, shill::kEapIdentityProperty, |
723 base::StringValue("John Doe")); | 719 base::Value("John Doe")); |
724 } else { | 720 } else { |
725 services->SetServiceProperty(kWifi2Path, shill::kSecurityClassProperty, | 721 services->SetServiceProperty(kWifi2Path, shill::kSecurityClassProperty, |
726 base::StringValue(shill::kSecurityPsk)); | 722 base::Value(shill::kSecurityPsk)); |
727 } | 723 } |
728 services->SetServiceProperty(kWifi2Path, shill::kSignalStrengthProperty, | 724 services->SetServiceProperty(kWifi2Path, shill::kSignalStrengthProperty, |
729 base::Value(80)); | 725 base::Value(80)); |
730 profiles->AddService(shared_profile, kWifi2Path); | 726 profiles->AddService(shared_profile, kWifi2Path); |
731 | 727 |
732 const std::string kWifi3Path = "/service/wifi3"; | 728 const std::string kWifi3Path = "/service/wifi3"; |
733 services->AddService(kWifi3Path, | 729 services->AddService(kWifi3Path, |
734 "", /* empty GUID */ | 730 "", /* empty GUID */ |
735 "wifi3" /* name */, | 731 "wifi3" /* name */, |
736 shill::kTypeWifi, | 732 shill::kTypeWifi, |
737 shill::kStateIdle, | 733 shill::kStateIdle, |
738 add_to_visible); | 734 add_to_visible); |
739 services->SetServiceProperty(kWifi3Path, shill::kSignalStrengthProperty, | 735 services->SetServiceProperty(kWifi3Path, shill::kSignalStrengthProperty, |
740 base::Value(40)); | 736 base::Value(40)); |
741 | 737 |
742 if (portaled) { | 738 if (portaled) { |
743 const std::string kPortaledWifiPath = "/service/portaled_wifi"; | 739 const std::string kPortaledWifiPath = "/service/portaled_wifi"; |
744 services->AddService(kPortaledWifiPath, "portaled_wifi_guid", | 740 services->AddService(kPortaledWifiPath, "portaled_wifi_guid", |
745 "Portaled Wifi" /* name */, shill::kTypeWifi, | 741 "Portaled Wifi" /* name */, shill::kTypeWifi, |
746 shill::kStateIdle, add_to_visible); | 742 shill::kStateIdle, add_to_visible); |
747 services->SetServiceProperty(kPortaledWifiPath, | 743 services->SetServiceProperty(kPortaledWifiPath, |
748 shill::kSecurityClassProperty, | 744 shill::kSecurityClassProperty, |
749 base::StringValue(shill::kSecurityNone)); | 745 base::Value(shill::kSecurityNone)); |
750 services->SetConnectBehavior( | 746 services->SetConnectBehavior( |
751 kPortaledWifiPath, | 747 kPortaledWifiPath, |
752 base::Bind(&UpdatePortaledWifiState, kPortaledWifiPath)); | 748 base::Bind(&UpdatePortaledWifiState, kPortaledWifiPath)); |
753 services->SetServiceProperty( | 749 services->SetServiceProperty( |
754 kPortaledWifiPath, shill::kConnectableProperty, base::Value(true)); | 750 kPortaledWifiPath, shill::kConnectableProperty, base::Value(true)); |
755 profiles->AddService(shared_profile, kPortaledWifiPath); | 751 profiles->AddService(shared_profile, kPortaledWifiPath); |
756 } | 752 } |
757 | 753 |
758 for (int i = 0; i < s_extra_wifi_networks; ++i) { | 754 for (int i = 0; i < s_extra_wifi_networks; ++i) { |
759 int id = 4 + i; | 755 int id = 4 + i; |
(...skipping 27 matching lines...) Expand all Loading... |
787 state = GetInitialStateForType(shill::kTypeCellular, &enabled); | 783 state = GetInitialStateForType(shill::kTypeCellular, &enabled); |
788 if (state != kTechnologyUnavailable) { | 784 if (state != kTechnologyUnavailable) { |
789 bool activated = false; | 785 bool activated = false; |
790 if (state == kNetworkActivated) { | 786 if (state == kNetworkActivated) { |
791 activated = true; | 787 activated = true; |
792 state = shill::kStateOnline; | 788 state = shill::kStateOnline; |
793 } | 789 } |
794 AddTechnology(shill::kTypeCellular, enabled); | 790 AddTechnology(shill::kTypeCellular, enabled); |
795 devices->AddDevice( | 791 devices->AddDevice( |
796 "/device/cellular1", shill::kTypeCellular, "stub_cellular_device1"); | 792 "/device/cellular1", shill::kTypeCellular, "stub_cellular_device1"); |
797 devices->SetDeviceProperty("/device/cellular1", | 793 devices->SetDeviceProperty("/device/cellular1", shill::kCarrierProperty, |
798 shill::kCarrierProperty, | 794 base::Value(shill::kCarrierSprint)); |
799 base::StringValue(shill::kCarrierSprint)); | |
800 base::ListValue carrier_list; | 795 base::ListValue carrier_list; |
801 carrier_list.AppendString(shill::kCarrierSprint); | 796 carrier_list.AppendString(shill::kCarrierSprint); |
802 carrier_list.AppendString(shill::kCarrierGenericUMTS); | 797 carrier_list.AppendString(shill::kCarrierGenericUMTS); |
803 devices->SetDeviceProperty("/device/cellular1", | 798 devices->SetDeviceProperty("/device/cellular1", |
804 shill::kSupportedCarriersProperty, | 799 shill::kSupportedCarriersProperty, |
805 carrier_list); | 800 carrier_list); |
806 devices->SetDeviceProperty("/device/cellular1", | 801 devices->SetDeviceProperty("/device/cellular1", |
807 shill::kSupportNetworkScanProperty, | 802 shill::kSupportNetworkScanProperty, |
808 base::Value(true)); | 803 base::Value(true)); |
809 if (roaming_state_ == kRoamingRequired) { | 804 if (roaming_state_ == kRoamingRequired) { |
810 devices->SetDeviceProperty("/device/cellular1", | 805 devices->SetDeviceProperty("/device/cellular1", |
811 shill::kProviderRequiresRoamingProperty, | 806 shill::kProviderRequiresRoamingProperty, |
812 base::Value(true)); | 807 base::Value(true)); |
813 } | 808 } |
814 if (cellular_technology_ == shill::kNetworkTechnologyGsm) { | 809 if (cellular_technology_ == shill::kNetworkTechnologyGsm) { |
815 devices->SetDeviceProperty("/device/cellular1", | 810 devices->SetDeviceProperty("/device/cellular1", |
816 shill::kSIMPresentProperty, base::Value(true)); | 811 shill::kSIMPresentProperty, base::Value(true)); |
817 devices->SetSimLocked("/device/cellular1", false); | 812 devices->SetSimLocked("/device/cellular1", false); |
818 } | 813 } |
819 | 814 |
820 services->AddService(kCellularServicePath, | 815 services->AddService(kCellularServicePath, |
821 "cellular1_guid", | 816 "cellular1_guid", |
822 "cellular1" /* name */, | 817 "cellular1" /* name */, |
823 shill::kTypeCellular, | 818 shill::kTypeCellular, |
824 state, | 819 state, |
825 add_to_visible); | 820 add_to_visible); |
826 base::StringValue technology_value(cellular_technology_); | 821 base::Value technology_value(cellular_technology_); |
827 devices->SetDeviceProperty("/device/cellular1", | 822 devices->SetDeviceProperty("/device/cellular1", |
828 shill::kTechnologyFamilyProperty, | 823 shill::kTechnologyFamilyProperty, |
829 technology_value); | 824 technology_value); |
830 services->SetServiceProperty(kCellularServicePath, | 825 services->SetServiceProperty(kCellularServicePath, |
831 shill::kNetworkTechnologyProperty, | 826 shill::kNetworkTechnologyProperty, |
832 technology_value); | 827 technology_value); |
833 base::Value strength_value(50); | 828 base::Value strength_value(50); |
834 services->SetServiceProperty( | 829 services->SetServiceProperty( |
835 kCellularServicePath, shill::kSignalStrengthProperty, strength_value); | 830 kCellularServicePath, shill::kSignalStrengthProperty, strength_value); |
836 | 831 |
837 if (activated) { | 832 if (activated) { |
838 services->SetServiceProperty( | 833 services->SetServiceProperty( |
839 kCellularServicePath, | 834 kCellularServicePath, shill::kActivationStateProperty, |
840 shill::kActivationStateProperty, | 835 base::Value(shill::kActivationStateActivated)); |
841 base::StringValue(shill::kActivationStateActivated)); | |
842 services->SetServiceProperty( | 836 services->SetServiceProperty( |
843 kCellularServicePath, shill::kConnectableProperty, base::Value(true)); | 837 kCellularServicePath, shill::kConnectableProperty, base::Value(true)); |
844 } else { | 838 } else { |
845 services->SetServiceProperty( | 839 services->SetServiceProperty( |
846 kCellularServicePath, | 840 kCellularServicePath, shill::kActivationStateProperty, |
847 shill::kActivationStateProperty, | 841 base::Value(shill::kActivationStateNotActivated)); |
848 base::StringValue(shill::kActivationStateNotActivated)); | |
849 } | 842 } |
850 | 843 |
851 std::string shill_roaming_state; | 844 std::string shill_roaming_state; |
852 if (roaming_state_ == kRoamingRequired) | 845 if (roaming_state_ == kRoamingRequired) |
853 shill_roaming_state = shill::kRoamingStateRoaming; | 846 shill_roaming_state = shill::kRoamingStateRoaming; |
854 else if (roaming_state_.empty()) | 847 else if (roaming_state_.empty()) |
855 shill_roaming_state = shill::kRoamingStateHome; | 848 shill_roaming_state = shill::kRoamingStateHome; |
856 else // |roaming_state_| is expected to be a valid Shill state. | 849 else // |roaming_state_| is expected to be a valid Shill state. |
857 shill_roaming_state = roaming_state_; | 850 shill_roaming_state = roaming_state_; |
858 services->SetServiceProperty(kCellularServicePath, | 851 services->SetServiceProperty(kCellularServicePath, |
859 shill::kRoamingStateProperty, | 852 shill::kRoamingStateProperty, |
860 base::StringValue(shill_roaming_state)); | 853 base::Value(shill_roaming_state)); |
861 | 854 |
862 base::DictionaryValue apn; | 855 base::DictionaryValue apn; |
863 apn.SetStringWithoutPathExpansion(shill::kApnProperty, "testapn"); | 856 apn.SetStringWithoutPathExpansion(shill::kApnProperty, "testapn"); |
864 apn.SetStringWithoutPathExpansion(shill::kApnNameProperty, "Test APN"); | 857 apn.SetStringWithoutPathExpansion(shill::kApnNameProperty, "Test APN"); |
865 apn.SetStringWithoutPathExpansion(shill::kApnLocalizedNameProperty, | 858 apn.SetStringWithoutPathExpansion(shill::kApnLocalizedNameProperty, |
866 "Localized Test APN"); | 859 "Localized Test APN"); |
867 apn.SetStringWithoutPathExpansion(shill::kApnUsernameProperty, "User1"); | 860 apn.SetStringWithoutPathExpansion(shill::kApnUsernameProperty, "User1"); |
868 apn.SetStringWithoutPathExpansion(shill::kApnPasswordProperty, "password"); | 861 apn.SetStringWithoutPathExpansion(shill::kApnPasswordProperty, "password"); |
869 base::DictionaryValue apn2; | 862 base::DictionaryValue apn2; |
870 apn2.SetStringWithoutPathExpansion(shill::kApnProperty, "testapn2"); | 863 apn2.SetStringWithoutPathExpansion(shill::kApnProperty, "testapn2"); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 | 986 |
994 bool FakeShillManagerClient::TechnologyEnabled(const std::string& type) const { | 987 bool FakeShillManagerClient::TechnologyEnabled(const std::string& type) const { |
995 if (type == shill::kTypeVPN) | 988 if (type == shill::kTypeVPN) |
996 return true; // VPN is always "enabled" since there is no associated device | 989 return true; // VPN is always "enabled" since there is no associated device |
997 if (type == shill::kTypeEthernetEap) | 990 if (type == shill::kTypeEthernetEap) |
998 return true; | 991 return true; |
999 bool enabled = false; | 992 bool enabled = false; |
1000 const base::ListValue* technologies; | 993 const base::ListValue* technologies; |
1001 if (stub_properties_.GetListWithoutPathExpansion( | 994 if (stub_properties_.GetListWithoutPathExpansion( |
1002 shill::kEnabledTechnologiesProperty, &technologies)) { | 995 shill::kEnabledTechnologiesProperty, &technologies)) { |
1003 base::StringValue type_value(type); | 996 base::Value type_value(type); |
1004 if (technologies->Find(type_value) != technologies->end()) | 997 if (technologies->Find(type_value) != technologies->end()) |
1005 enabled = true; | 998 enabled = true; |
1006 } | 999 } |
1007 return enabled; | 1000 return enabled; |
1008 } | 1001 } |
1009 | 1002 |
1010 void FakeShillManagerClient::SetTechnologyEnabled( | 1003 void FakeShillManagerClient::SetTechnologyEnabled( |
1011 const std::string& type, | 1004 const std::string& type, |
1012 const base::Closure& callback, | 1005 const base::Closure& callback, |
1013 bool enabled) { | 1006 bool enabled) { |
1014 base::ListValue* enabled_list = | 1007 base::ListValue* enabled_list = |
1015 GetListProperty(shill::kEnabledTechnologiesProperty); | 1008 GetListProperty(shill::kEnabledTechnologiesProperty); |
1016 if (enabled) | 1009 if (enabled) |
1017 enabled_list->AppendIfNotPresent(base::MakeUnique<base::StringValue>(type)); | 1010 enabled_list->AppendIfNotPresent(base::MakeUnique<base::Value>(type)); |
1018 else | 1011 else |
1019 enabled_list->Remove(base::StringValue(type), NULL); | 1012 enabled_list->Remove(base::Value(type), NULL); |
1020 CallNotifyObserversPropertyChanged( | 1013 CallNotifyObserversPropertyChanged( |
1021 shill::kEnabledTechnologiesProperty); | 1014 shill::kEnabledTechnologiesProperty); |
1022 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); | 1015 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); |
1023 // May affect available services. | 1016 // May affect available services. |
1024 SortManagerServices(true); | 1017 SortManagerServices(true); |
1025 } | 1018 } |
1026 | 1019 |
1027 base::ListValue* FakeShillManagerClient::GetEnabledServiceList( | 1020 base::ListValue* FakeShillManagerClient::GetEnabledServiceList( |
1028 const std::string& property) const { | 1021 const std::string& property) const { |
1029 base::ListValue* new_service_list = new base::ListValue; | 1022 base::ListValue* new_service_list = new base::ListValue; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 base::DictionaryValue* simlock_dict = new base::DictionaryValue; | 1098 base::DictionaryValue* simlock_dict = new base::DictionaryValue; |
1106 simlock_dict->SetBoolean(shill::kSIMLockEnabledProperty, true); | 1099 simlock_dict->SetBoolean(shill::kSIMLockEnabledProperty, true); |
1107 std::string lock_type = locked ? shill::kSIMLockPin : ""; | 1100 std::string lock_type = locked ? shill::kSIMLockPin : ""; |
1108 simlock_dict->SetString(shill::kSIMLockTypeProperty, lock_type); | 1101 simlock_dict->SetString(shill::kSIMLockTypeProperty, lock_type); |
1109 if (locked) { | 1102 if (locked) { |
1110 simlock_dict->SetInteger(shill::kSIMLockRetriesLeftProperty, | 1103 simlock_dict->SetInteger(shill::kSIMLockRetriesLeftProperty, |
1111 FakeShillDeviceClient::kSimPinRetryCount); | 1104 FakeShillDeviceClient::kSimPinRetryCount); |
1112 } | 1105 } |
1113 shill_device_property_map_[shill::kTypeCellular] | 1106 shill_device_property_map_[shill::kTypeCellular] |
1114 [shill::kSIMLockStatusProperty] = simlock_dict; | 1107 [shill::kSIMLockStatusProperty] = simlock_dict; |
1115 shill_device_property_map_ | 1108 shill_device_property_map_[shill::kTypeCellular] |
1116 [shill::kTypeCellular][shill::kTechnologyFamilyProperty] = | 1109 [shill::kTechnologyFamilyProperty] = |
1117 new base::StringValue(shill::kNetworkTechnologyGsm); | 1110 new base::Value(shill::kNetworkTechnologyGsm); |
1118 return true; | 1111 return true; |
1119 } else if (arg0 == "sim_present") { | 1112 } else if (arg0 == "sim_present") { |
1120 bool present = (arg1 == "1"); | 1113 bool present = (arg1 == "1"); |
1121 base::Value* sim_present = new base::Value(present); | 1114 base::Value* sim_present = new base::Value(present); |
1122 shill_device_property_map_[shill::kTypeCellular] | 1115 shill_device_property_map_[shill::kTypeCellular] |
1123 [shill::kSIMPresentProperty] = sim_present; | 1116 [shill::kSIMPresentProperty] = sim_present; |
1124 return true; | 1117 return true; |
1125 } else if (arg0 == "tdls_busy") { | 1118 } else if (arg0 == "tdls_busy") { |
1126 if (!arg1.empty()) | 1119 if (!arg1.empty()) |
1127 base::StringToInt(arg1, &s_tdls_busy_count); | 1120 base::StringToInt(arg1, &s_tdls_busy_count); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 LOG(WARNING) << "Invalid state: " << state << " for " << type; | 1228 LOG(WARNING) << "Invalid state: " << state << " for " << type; |
1236 result = shill::kStateIdle; | 1229 result = shill::kStateIdle; |
1237 } | 1230 } |
1238 } | 1231 } |
1239 VLOG(1) << "Initial state for: " << type << " = " << result | 1232 VLOG(1) << "Initial state for: " << type << " = " << result |
1240 << " Enabled: " << *enabled; | 1233 << " Enabled: " << *enabled; |
1241 return result; | 1234 return result; |
1242 } | 1235 } |
1243 | 1236 |
1244 } // namespace chromeos | 1237 } // namespace chromeos |
OLD | NEW |