|
24 | 24 | #endif
|
25 | 25 |
|
26 | 26 | #if defined(__Fuchsia__)
|
27 |
| -#include <fidl/fuchsia.intl/cpp/fidl.h> |
| 27 | +#include <fuchsia/intl/cpp/fidl.h> |
28 | 28 | #include <lib/async-loop/cpp/loop.h>
|
29 | 29 | #include <lib/fdio/directory.h>
|
30 | 30 | #include <zircon/types.h>
|
@@ -218,31 +218,32 @@ time_zone local_time_zone() {
|
218 | 218 | // Note: We can't use the synchronous FIDL API here because it doesn't
|
219 | 219 | // allow timeouts; if the FIDL call failed, local_time_zone() would never
|
220 | 220 | // return.
|
| 221 | + |
221 | 222 | const zx::duration kTimeout = zx::msec(500);
|
222 | 223 |
|
223 | 224 | // Don't attach to the thread because otherwise the thread's dispatcher
|
224 | 225 | // would be set to null when the loop is destroyed, causing any other FIDL
|
225 | 226 | // code running on the same thread to crash.
|
226 | 227 | async::Loop loop(&kAsyncLoopConfigNeverAttachToThread);
|
227 |
| - auto endpoints = |
228 |
| - fidl::Endpoints<fuchsia_intl::PropertyProvider>::Create(); |
| 228 | + |
| 229 | + fuchsia::intl::PropertyProviderHandle handle; |
229 | 230 | zx_status_t status = fdio_service_connect_by_name(
|
230 |
| - fidl::DiscoverableProtocolName<fuchsia_intl::PropertyProvider>, |
231 |
| - endpoints.server.TakeChannel().release()); |
| 231 | + fuchsia::intl::PropertyProvider::Name_, |
| 232 | + handle.NewRequest().TakeChannel().release()); |
232 | 233 | if (status != ZX_OK) {
|
233 | 234 | return;
|
234 | 235 | }
|
235 |
| - fidl::Client intl_provider( |
236 |
| - std::move(endpoints.client), loop.dispatcher()); |
237 |
| - |
238 |
| - // Attempt to initialize the time zone only once, and fail quietly. |
239 |
| - // The end result of an error is an empty time zone string. |
240 |
| - intl_provider->GetProfile().Then( |
241 |
| - [&loop, &primary_tz]( |
242 |
| - fidl::Result<fuchsia_intl::PropertyProvider::GetProfile>& result) { |
243 |
| - if (result.is_ok()) { |
244 |
| - const auto& response = result.value(); |
245 |
| - primary_tz = response.profile().time_zones().value()[0].id(); |
| 236 | + |
| 237 | + fuchsia::intl::PropertyProviderPtr intl_provider; |
| 238 | + status = intl_provider.Bind(std::move(handle), loop.dispatcher()); |
| 239 | + if (status != ZX_OK) { |
| 240 | + return; |
| 241 | + } |
| 242 | + |
| 243 | + intl_provider->GetProfile( |
| 244 | + [&loop, &primary_tz](fuchsia::intl::Profile profile) { |
| 245 | + if (!profile.time_zones().empty()) { |
| 246 | + primary_tz = profile.time_zones()[0].id; |
246 | 247 | }
|
247 | 248 | loop.Quit();
|
248 | 249 | });
|
|
0 commit comments