1c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu//
2c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// Copyright (C) 2015 The Android Open Source Project
3c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu//
4c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// Licensed under the Apache License, Version 2.0 (the "License");
5c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// you may not use this file except in compliance with the License.
6c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// You may obtain a copy of the License at
7c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu//
8c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu//      http://www.apache.org/licenses/LICENSE-2.0
9c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu//
10c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// Unless required by applicable law or agreed to in writing, software
11c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// distributed under the License is distributed on an "AS IS" BASIS,
12c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// See the License for the specific language governing permissions and
14c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// limitations under the License.
15c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu//
16f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
17f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu#include "shill/dbus/chromeos_modem_gsm_card_proxy.h"
18f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
19f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu#include <memory>
20f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
21f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu#include <base/bind.h>
22289a5a5e18bb1a676b3dfce111af4c2c00c7776eSamuel Tan#if defined(__ANDROID__)
23289a5a5e18bb1a676b3dfce111af4c2c00c7776eSamuel Tan#include <dbus/service_constants.h>
24289a5a5e18bb1a676b3dfce111af4c2c00c7776eSamuel Tan#else
25f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu#include <chromeos/dbus/service_constants.h>
26289a5a5e18bb1a676b3dfce111af4c2c00c7776eSamuel Tan#endif  // __ANDROID__
27f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
28f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu#include "shill/cellular/cellular_error.h"
29f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu#include "shill/error.h"
30f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu#include "shill/logging.h"
31f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
32f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiuusing std::string;
33f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
34f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiunamespace shill {
35f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
36f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiunamespace Logging {
37f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiustatic auto kModuleLogScope = ScopeLogger::kDBus;
38f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiustatic string ObjectID(const dbus::ObjectPath* p) { return p->value(); }
39f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu}  // namespace Logging
40f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
41f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu// static.
42f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiuconst char ChromeosModemGSMCardProxy::kPropertyEnabledFacilityLocks[] =
43f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu    "EnabledFacilityLocks";
44f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
45f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter QiuChromeosModemGSMCardProxy::PropertySet::PropertySet(
46f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu    dbus::ObjectProxy* object_proxy,
47f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu    const std::string& interface_name,
48f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu    const PropertyChangedCallback& callback)
49f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu    : dbus::PropertySet(object_proxy, interface_name, callback) {
50f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  RegisterProperty(kPropertyEnabledFacilityLocks, &enabled_facility_locks);
51f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu}
52f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
53f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter QiuChromeosModemGSMCardProxy::ChromeosModemGSMCardProxy(
54f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu    const scoped_refptr<dbus::Bus>& bus,
55f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu    const string& path,
56f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu    const string& service)
57f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu    : proxy_(
58f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu        new org::freedesktop::ModemManager::Modem::Gsm::CardProxy(
59f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu            bus, service, dbus::ObjectPath(path))) {
60f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  // Register properties.
61f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  properties_.reset(
62f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu      new PropertySet(
63f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu          proxy_->GetObjectProxy(),
64f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu          cromo::kModemGsmCardInterface,
65f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu          base::Bind(&ChromeosModemGSMCardProxy::OnPropertyChanged,
66f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                     weak_factory_.GetWeakPtr())));
67f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
68f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  // Connect property signals and initialize cached values. Based on
69f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  // recommendations from src/dbus/property.h.
70f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  properties_->ConnectSignals();
71f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  properties_->GetAll();
72f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu}
73f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
74f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter QiuChromeosModemGSMCardProxy::~ChromeosModemGSMCardProxy() {}
75f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
76f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiuvoid ChromeosModemGSMCardProxy::GetIMEI(
77f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu    Error* error, const GSMIdentifierCallback& callback, int timeout) {
78f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  SLOG(&proxy_->GetObjectPath(), 2) << __func__;
79f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  proxy_->GetImeiAsync(
80f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu      base::Bind(&ChromeosModemGSMCardProxy::OnGetGSMIdentifierSuccess,
81f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 weak_factory_.GetWeakPtr(),
82f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 callback,
83f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 "IMEI"),
84f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu      base::Bind(&ChromeosModemGSMCardProxy::OnGetGSMIdentifierFailure,
85f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 weak_factory_.GetWeakPtr(),
86f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 callback,
87f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 "IMEI"));
88f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu}
89f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
90f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiuvoid ChromeosModemGSMCardProxy::GetIMSI(Error* error,
91f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                                        const GSMIdentifierCallback& callback,
92f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                                        int timeout) {
93f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  SLOG(&proxy_->GetObjectPath(), 2) << __func__;
94f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  proxy_->GetImsiAsync(
95f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu      base::Bind(&ChromeosModemGSMCardProxy::OnGetGSMIdentifierSuccess,
96f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 weak_factory_.GetWeakPtr(),
97f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 callback,
98f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 "IMSI"),
99f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu      base::Bind(&ChromeosModemGSMCardProxy::OnGetGSMIdentifierFailure,
100f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 weak_factory_.GetWeakPtr(),
101f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 callback,
102f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 "IMSI"));
103f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu}
104f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
105f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiuvoid ChromeosModemGSMCardProxy::GetSPN(Error* error,
106f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                                       const GSMIdentifierCallback& callback,
107f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                                       int timeout) {
108f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  SLOG(&proxy_->GetObjectPath(), 2) << __func__;
109f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  proxy_->GetSpnAsync(
110f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu      base::Bind(&ChromeosModemGSMCardProxy::OnGetGSMIdentifierSuccess,
111f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 weak_factory_.GetWeakPtr(),
112f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 callback,
113f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 "SPN"),
114f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu      base::Bind(&ChromeosModemGSMCardProxy::OnGetGSMIdentifierFailure,
115f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 weak_factory_.GetWeakPtr(),
116f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 callback,
117f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 "SPN"));
118f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu}
119f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
120f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiuvoid ChromeosModemGSMCardProxy::GetMSISDN(Error* error,
121f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                                          const GSMIdentifierCallback& callback,
122f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                                          int timeout) {
123f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  SLOG(&proxy_->GetObjectPath(), 2) << __func__;
124f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  proxy_->GetMsIsdnAsync(
125f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu      base::Bind(&ChromeosModemGSMCardProxy::OnGetGSMIdentifierSuccess,
126f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 weak_factory_.GetWeakPtr(),
127f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 callback,
128f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 "MSIDN"),
129f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu      base::Bind(&ChromeosModemGSMCardProxy::OnGetGSMIdentifierFailure,
130f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 weak_factory_.GetWeakPtr(),
131f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 callback,
132f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 "MSIDN"));
133f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu}
134f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
135f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiuvoid ChromeosModemGSMCardProxy::EnablePIN(const string& pin, bool enabled,
136f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                                          Error* error,
137f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                                          const ResultCallback& callback,
138f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                                          int timeout) {
139f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  // pin is intentionally not logged.
140f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  SLOG(&proxy_->GetObjectPath(), 2) << __func__ << ": " << enabled;
141f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  proxy_->EnablePinAsync(
142f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu      pin,
143f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu      enabled,
144f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu      base::Bind(&ChromeosModemGSMCardProxy::OnOperationSuccess,
145f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 weak_factory_.GetWeakPtr(),
146f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 callback,
147f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 __func__),
148f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu      base::Bind(&ChromeosModemGSMCardProxy::OnOperationFailure,
149f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 weak_factory_.GetWeakPtr(),
150f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 callback,
151f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 __func__));
152f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu}
153f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
154f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiuvoid ChromeosModemGSMCardProxy::SendPIN(const string& pin,
155f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                                        Error* error,
156f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                                        const ResultCallback& callback,
157f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                                        int timeout) {
158f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  // pin is intentionally not logged.
159f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  SLOG(&proxy_->GetObjectPath(), 2) << __func__;
160f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  proxy_->SendPinAsync(
161f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu      pin,
162f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu      base::Bind(&ChromeosModemGSMCardProxy::OnOperationSuccess,
163f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 weak_factory_.GetWeakPtr(),
164f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 callback,
165f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 __func__),
166f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu      base::Bind(&ChromeosModemGSMCardProxy::OnOperationFailure,
167f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 weak_factory_.GetWeakPtr(),
168f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 callback,
169f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 __func__));
170f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu}
171f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
172f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiuvoid ChromeosModemGSMCardProxy::SendPUK(const string& puk, const string& pin,
173f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                                        Error* error,
174f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                                        const ResultCallback& callback,
175f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                                        int timeout) {
176f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  // pin is intentionally not logged.
177f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  SLOG(&proxy_->GetObjectPath(), 2) << __func__;
178f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  proxy_->SendPukAsync(
179f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu      puk,
180f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu      pin,
181f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu      base::Bind(&ChromeosModemGSMCardProxy::OnOperationSuccess,
182f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 weak_factory_.GetWeakPtr(),
183f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 callback,
184f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 __func__),
185f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu      base::Bind(&ChromeosModemGSMCardProxy::OnOperationFailure,
186f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 weak_factory_.GetWeakPtr(),
187f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 callback,
188f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 __func__));
189f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu}
190f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
191f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiuvoid ChromeosModemGSMCardProxy::ChangePIN(const string& old_pin,
192f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                                          const string& new_pin,
193f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                                          Error* error,
194f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                                          const ResultCallback& callback,
195f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                                          int timeout) {
196f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  // pin is intentionally not logged.
197f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  SLOG(&proxy_->GetObjectPath(), 2) << __func__;
198f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  proxy_->SendPukAsync(
199f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu      old_pin,
200f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu      new_pin,
201f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu      base::Bind(&ChromeosModemGSMCardProxy::OnOperationSuccess,
202f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 weak_factory_.GetWeakPtr(),
203f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 callback,
204f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 __func__),
205f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu      base::Bind(&ChromeosModemGSMCardProxy::OnOperationFailure,
206f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 weak_factory_.GetWeakPtr(),
207f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 callback,
208f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                 __func__));
209f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu}
210f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
211f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiuuint32_t ChromeosModemGSMCardProxy::EnabledFacilityLocks() {
212f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  SLOG(&proxy_->GetObjectPath(), 2) << __func__;
21378904e6625453ef4c58a6161a971cd60cf967db1Peter Qiu  if (!properties_->enabled_facility_locks.GetAndBlock()) {
21478904e6625453ef4c58a6161a971cd60cf967db1Peter Qiu    LOG(ERROR) << "Faild to get EnableFacilityLocks";
21578904e6625453ef4c58a6161a971cd60cf967db1Peter Qiu    return 0;
21678904e6625453ef4c58a6161a971cd60cf967db1Peter Qiu  }
217f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  return properties_->enabled_facility_locks.value();
218f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu}
219f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
220f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiuvoid ChromeosModemGSMCardProxy::OnGetGSMIdentifierSuccess(
221f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu    const GSMIdentifierCallback& callback,
222f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu    const string& identifier_name,
223f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu    const string& identifier_value) {
224f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  SLOG(&proxy_->GetObjectPath(), 2) << __func__ << ": " << identifier_name
225f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu                                    << " " << identifier_value;
226f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  callback.Run(identifier_value, Error());
227f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu}
228f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
229f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiuvoid ChromeosModemGSMCardProxy::OnGetGSMIdentifierFailure(
230f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu    const GSMIdentifierCallback& callback,
231f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu    const string& identifier_name,
23203e6719bae1e0903d94853b896673a033196bcf5Alex Vakulenko    brillo::Error* dbus_error) {
233f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  SLOG(&proxy_->GetObjectPath(), 2) << __func__ << ": " << identifier_name;
234f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  Error error;
235f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  CellularError::FromChromeosDBusError(dbus_error, &error);
236f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  callback.Run("", error);
237f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu}
238f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
239f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiuvoid ChromeosModemGSMCardProxy::OnOperationSuccess(
240f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu    const ResultCallback& callback,
241f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu    const string& operation_name) {
242f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  SLOG(&proxy_->GetObjectPath(), 2) << __func__ << ": " << operation_name;
243f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  callback.Run(Error());
244f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu}
245f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
246f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiuvoid ChromeosModemGSMCardProxy::OnOperationFailure(
247f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu    const ResultCallback& callback,
248f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu    const string& operation_name,
24903e6719bae1e0903d94853b896673a033196bcf5Alex Vakulenko    brillo::Error* dbus_error) {
250f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  SLOG(&proxy_->GetObjectPath(), 2) << __func__ << ": " << operation_name;
251f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  Error error;
252f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  CellularError::FromChromeosDBusError(dbus_error, &error);
253f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  callback.Run(error);
254f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu}
255f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
256f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiuvoid ChromeosModemGSMCardProxy::OnPropertyChanged(
257f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu    const string& property_name) {
258f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu  SLOG(&proxy_->GetObjectPath(), 2) << __func__ << ": " << property_name;
259f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu}
260f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu
261f576f1b61ac8514adffd5ef6d44f8b0aa00ab979Peter Qiu}  // namespace shill
262