2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/adaptor/common/adaptor-impl.h>
22 #include <app_common.h>
23 #include <system_settings.h>
25 #ifdef APPCORE_WATCH_AVAILABLE
26 #include <screen_connector_provider.h>
30 #include <dali/internal/adaptor/tizen-wayland/dali-ecore-wl2.h>
32 #include <dali/internal/adaptor/tizen-wayland/dali-ecore-wayland.h>
39 #include <dali/devel-api/text-abstraction/font-client.h>
49 static void OnSystemLanguageChanged(system_settings_key_e key, void* data)
52 if(system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale) != SYSTEM_SETTINGS_ERROR_NONE ||
55 DALI_LOG_ERROR("DALI OnSystemLanguageChanged failed ");
59 Adaptor* adaptor = static_cast<Adaptor*>(data);
62 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
63 fontClient.ClearCacheOnLocaleChanged();
64 fontClient.InitDefaultFontDescription();
66 adaptor->SetRootLayoutDirection(locale);
67 adaptor->LocaleChangedSignal().Emit(locale);
75 std::string Adaptor::GetApplicationPackageName()
77 char appname[4096] = {0};
79 aul_app_get_pkgname_bypid(pid, appname, sizeof(appname));
83 void Adaptor::GetResourceStoragePath(std::string& path)
86 char* pathInt = app_get_resource_path();
99 void Adaptor::GetDataStoragePath(std::string& path)
102 char* pathInt = app_get_data_path();
115 void Adaptor::GetAppId(std::string& appId)
132 void Adaptor::SurfaceInitialized()
134 #ifdef APPCORE_WATCH_AVAILABLE
135 if(!mUseRemoteSurface)
142 // Use strdup() in app_get_id(), so need to free memory
145 #ifdef ECORE_WAYLAND2
146 Ecore_Wl2_Window* ecoreWlWindow = AnyCast<Ecore_Wl2_Window*>(mWindows.front()->GetNativeHandle());
147 screen_connector_provider_remote_enable(appId, ecore_wl2_window_surface_get(ecoreWlWindow));
149 Ecore_Wl_Window* ecoreWlWindow = AnyCast<Ecore_Wl_Window*>(mWindows.front()->GetNativeHandle());
150 screen_connector_provider_remote_enable(appId, ecore_wl_window_surface_get(ecoreWlWindow));
157 void Adaptor::SetupSystemInformation()
159 if(system_settings_add_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, OnSystemLanguageChanged, this) != SYSTEM_SETTINGS_ERROR_NONE)
161 DALI_LOG_ERROR("DALI system_settings_add_changed_cb failed.\n");
166 if(system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale) != SYSTEM_SETTINGS_ERROR_NONE ||
169 DALI_LOG_ERROR("DALI OnSystemLanguageChanged failed ");
173 SetRootLayoutDirection(locale);
178 void Adaptor::RemoveSystemInformation()
180 if(system_settings_remove_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, OnSystemLanguageChanged) != SYSTEM_SETTINGS_ERROR_NONE)
182 DALI_LOG_ERROR("DALI system_settings_remove_changed_cb failed.\n");
187 } // namespace Adaptor
189 } // namespace Internal