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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface() | 102 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface() |
103 ->SetServiceProperty(service_path, | 103 ->SetServiceProperty(service_path, |
104 shill::kStateProperty, | 104 shill::kStateProperty, |
105 base::StringValue(shill::kStatePortal)); | 105 base::StringValue(shill::kStatePortal)); |
106 } | 106 } |
107 | 107 |
108 const char* kTechnologyUnavailable = "unavailable"; | 108 const char* kTechnologyUnavailable = "unavailable"; |
109 const char* kNetworkActivated = "activated"; | 109 const char* kNetworkActivated = "activated"; |
110 const char* kNetworkDisabled = "disabled"; | 110 const char* kNetworkDisabled = "disabled"; |
111 const char* kCellularServicePath = "/service/cellular1"; | 111 const char* kCellularServicePath = "/service/cellular1"; |
112 const char* kRoamingRequired = "required"; | |
armansito
2015/02/24 03:05:03
nit: The commit message calls this state "always",
stevenjb
2015/02/24 16:31:17
Yes, this is only for the fake implementation. Cha
| |
112 | 113 |
113 } // namespace | 114 } // namespace |
114 | 115 |
115 // static | 116 // static |
116 const char FakeShillManagerClient::kFakeEthernetNetworkGuid[] = "eth1_guid"; | 117 const char FakeShillManagerClient::kFakeEthernetNetworkGuid[] = "eth1_guid"; |
117 | 118 |
118 FakeShillManagerClient::FakeShillManagerClient() | 119 FakeShillManagerClient::FakeShillManagerClient() |
119 : interactive_delay_(0), | 120 : interactive_delay_(0), |
120 weak_ptr_factory_(this) { | 121 weak_ptr_factory_(this) { |
121 ParseCommandLineSwitch(); | 122 ParseCommandLineSwitch(); |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
762 "/device/cellular1", shill::kTypeCellular, "stub_cellular_device1"); | 763 "/device/cellular1", shill::kTypeCellular, "stub_cellular_device1"); |
763 devices->SetDeviceProperty("/device/cellular1", | 764 devices->SetDeviceProperty("/device/cellular1", |
764 shill::kCarrierProperty, | 765 shill::kCarrierProperty, |
765 base::StringValue(shill::kCarrierSprint)); | 766 base::StringValue(shill::kCarrierSprint)); |
766 base::ListValue carrier_list; | 767 base::ListValue carrier_list; |
767 carrier_list.AppendString(shill::kCarrierSprint); | 768 carrier_list.AppendString(shill::kCarrierSprint); |
768 carrier_list.AppendString(shill::kCarrierGenericUMTS); | 769 carrier_list.AppendString(shill::kCarrierGenericUMTS); |
769 devices->SetDeviceProperty("/device/cellular1", | 770 devices->SetDeviceProperty("/device/cellular1", |
770 shill::kSupportedCarriersProperty, | 771 shill::kSupportedCarriersProperty, |
771 carrier_list); | 772 carrier_list); |
773 if (roaming_state_ == kRoamingRequired) { | |
774 devices->SetDeviceProperty("/device/cellular1", | |
775 shill::kProviderRequiresRoamingProperty, | |
776 base::FundamentalValue(true)); | |
777 } | |
772 | 778 |
773 services->AddService(kCellularServicePath, | 779 services->AddService(kCellularServicePath, |
774 "cellular1_guid", | 780 "cellular1_guid", |
775 "cellular1" /* name */, | 781 "cellular1" /* name */, |
776 shill::kTypeCellular, | 782 shill::kTypeCellular, |
777 state, | 783 state, |
778 add_to_visible); | 784 add_to_visible); |
779 base::StringValue technology_value(shill::kNetworkTechnologyGsm); | 785 base::StringValue technology_value(shill::kNetworkTechnologyGsm); |
780 devices->SetDeviceProperty("/device/cellular1", | 786 devices->SetDeviceProperty("/device/cellular1", |
781 shill::kTechnologyFamilyProperty, | 787 shill::kTechnologyFamilyProperty, |
(...skipping 10 matching lines...) Expand all Loading... | |
792 services->SetServiceProperty(kCellularServicePath, | 798 services->SetServiceProperty(kCellularServicePath, |
793 shill::kConnectableProperty, | 799 shill::kConnectableProperty, |
794 base::FundamentalValue(true)); | 800 base::FundamentalValue(true)); |
795 } else { | 801 } else { |
796 services->SetServiceProperty( | 802 services->SetServiceProperty( |
797 kCellularServicePath, | 803 kCellularServicePath, |
798 shill::kActivationStateProperty, | 804 shill::kActivationStateProperty, |
799 base::StringValue(shill::kActivationStateNotActivated)); | 805 base::StringValue(shill::kActivationStateNotActivated)); |
800 } | 806 } |
801 | 807 |
808 std::string roaming_state; | |
809 if (roaming_state_ == kRoamingRequired) | |
810 roaming_state = shill::kRoamingStateRoaming; | |
811 else if (roaming_state_.empty()) | |
812 roaming_state = shill::kRoamingStateHome; | |
813 else | |
814 roaming_state = roaming_state_; | |
armansito
2015/02/24 03:05:03
I would add a comment above saying that values of
stevenjb
2015/02/24 16:31:17
Done.
| |
802 services->SetServiceProperty(kCellularServicePath, | 815 services->SetServiceProperty(kCellularServicePath, |
803 shill::kRoamingStateProperty, | 816 shill::kRoamingStateProperty, |
804 base::StringValue(shill::kRoamingStateHome)); | 817 base::StringValue(roaming_state)); |
805 profiles->AddService(shared_profile, kCellularServicePath); | 818 profiles->AddService(shared_profile, kCellularServicePath); |
806 } | 819 } |
807 | 820 |
808 // VPN | 821 // VPN |
809 state = GetInitialStateForType(shill::kTypeVPN, &enabled); | 822 state = GetInitialStateForType(shill::kTypeVPN, &enabled); |
810 if (state != kTechnologyUnavailable) { | 823 if (state != kTechnologyUnavailable) { |
811 // Set the "Provider" dictionary properties. Note: when setting these in | 824 // Set the "Provider" dictionary properties. Note: when setting these in |
812 // Shill, "Provider.Type", etc keys are used, but when reading the values | 825 // Shill, "Provider.Type", etc keys are used, but when reading the values |
813 // "Provider" . "Type", etc keys are used. Here we are setting the values | 826 // "Provider" . "Type", etc keys are used. Here we are setting the values |
814 // that will be read (by the UI, tests, etc). | 827 // that will be read (by the UI, tests, etc). |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1041 shill_device_property_map_ | 1054 shill_device_property_map_ |
1042 [shill::kTypeCellular][shill::kTechnologyFamilyProperty] = | 1055 [shill::kTypeCellular][shill::kTechnologyFamilyProperty] = |
1043 new base::StringValue(shill::kNetworkTechnologyGsm); | 1056 new base::StringValue(shill::kNetworkTechnologyGsm); |
1044 return true; | 1057 return true; |
1045 } else if (arg0 == "tdls_busy") { | 1058 } else if (arg0 == "tdls_busy") { |
1046 if (!arg1.empty()) | 1059 if (!arg1.empty()) |
1047 base::StringToInt(arg1, &s_tdls_busy_count); | 1060 base::StringToInt(arg1, &s_tdls_busy_count); |
1048 else | 1061 else |
1049 s_tdls_busy_count = 1; | 1062 s_tdls_busy_count = 1; |
1050 return true; | 1063 return true; |
1064 } else if (arg0 == "roaming") { | |
1065 // "home", "roaming", or "required" | |
1066 roaming_state_ = arg1; | |
1067 return true; | |
1051 } | 1068 } |
1052 return SetInitialNetworkState(arg0, arg1); | 1069 return SetInitialNetworkState(arg0, arg1); |
1053 } | 1070 } |
1054 | 1071 |
1055 bool FakeShillManagerClient::SetInitialNetworkState(std::string type_arg, | 1072 bool FakeShillManagerClient::SetInitialNetworkState(std::string type_arg, |
1056 std::string state_arg) { | 1073 std::string state_arg) { |
1057 std::string state; | 1074 std::string state; |
1058 state_arg = base::StringToLowerASCII(state_arg); | 1075 state_arg = base::StringToLowerASCII(state_arg); |
1059 if (state_arg.empty() || state_arg == "1" || state_arg == "on" || | 1076 if (state_arg.empty() || state_arg == "1" || state_arg == "on" || |
1060 state_arg == "enabled" || state_arg == "connected" || | 1077 state_arg == "enabled" || state_arg == "connected" || |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1129 *enabled = true; | 1146 *enabled = true; |
1130 if ((state == shill::kStatePortal && type != shill::kTypeWifi) || | 1147 if ((state == shill::kStatePortal && type != shill::kTypeWifi) || |
1131 (state == kNetworkActivated && type != shill::kTypeCellular)) { | 1148 (state == kNetworkActivated && type != shill::kTypeCellular)) { |
1132 LOG(WARNING) << "Invalid state: " << state << " for " << type; | 1149 LOG(WARNING) << "Invalid state: " << state << " for " << type; |
1133 return shill::kStateIdle; | 1150 return shill::kStateIdle; |
1134 } | 1151 } |
1135 return state; | 1152 return state; |
1136 } | 1153 } |
1137 | 1154 |
1138 } // namespace chromeos | 1155 } // namespace chromeos |
OLD | NEW |