summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKartik Tidke <kr.tidke@samsung.com>2018-08-16 20:29:15 +0530
committerKartik Tidke <kr.tidke@samsung.com>2018-08-17 23:58:54 +0530
commitabb558384a0d83118eed9b71861f4863b2072347 (patch)
treeb0fc3ed8ea16524190705ac8e860aed7f48a4ea2
parent2a7a6c29158b6aba9d970bb06381b04551bc9076 (diff)
downloadanalog-watch-abb558384a0d83118eed9b71861f4863b2072347.tar.gz
analog-watch-abb558384a0d83118eed9b71861f4863b2072347.tar.bz2
analog-watch-abb558384a0d83118eed9b71861f4863b2072347.zip
Complication provider updated
Change-Id: I77eba1d02201775c61cbc9ac82d5533618debd62 Signed-off-by: Kartik Tidke <kr.tidke@samsung.com>
-rw-r--r--.cproject22
-rwxr-xr-xcomplication-provider/.cproject10
-rw-r--r--complication-provider/src/complication-provider.c44
-rwxr-xr-xcomplication-provider/tizen-manifest.xml13
-rw-r--r--inc/battery-data.h43
-rw-r--r--project_def.prop2
-rw-r--r--src/battery-data.c81
-rw-r--r--src/comp-manager.c23
-rw-r--r--src/view.c1
-rw-r--r--tizen-manifest.xml1
10 files changed, 84 insertions, 156 deletions
diff --git a/.cproject b/.cproject
index 773c965..6ac5504 100644
--- a/.cproject
+++ b/.cproject
@@ -16,7 +16,7 @@
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
- <configuration artifactName="analog-watch" buildArtefactType="org.tizen.nativecore.buildArtefactType.app" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.tizen.nativecore.buildArtefactType.app,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" id="org.tizen.nativecore.config.sbi.gcc45.app.debug.1635604740" name="Debug" parent="org.tizen.nativecore.config.sbi.gcc45.app.debug">
+ <configuration artifactName="complication-provider" buildArtefactType="org.tizen.nativecore.buildArtefactType.app" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.tizen.nativecore.buildArtefactType.app,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" id="org.tizen.nativecore.config.sbi.gcc45.app.debug.1635604740" name="Debug" parent="org.tizen.nativecore.config.sbi.gcc45.app.debug">
<folderInfo id="org.tizen.nativecore.config.sbi.gcc45.app.debug.1635604740." name="/" resourcePath="">
<toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.app.debug.1510450360" name="Tizen Native Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.app.debug">
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.355922757" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
@@ -27,7 +27,7 @@
<option defaultValue="gnu.cpp.compiler.debugging.level.max" id="sbi.gnu.cpp.compiler.option.debugging.level.core.653151688" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core" valueType="enumerated"/>
<option defaultValue="false" id="sbi.gnu.cpp.compiler.option.misc.pic.core.454828969" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/>
<option id="sbi.gnu.cpp.compiler.option.2066349202" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
- <listOptionValue builtIn="false" value="wearable-5.0-emulator.core.private.20180724_3_llvm40.i386"/>
+ <listOptionValue builtIn="false" value="wearable-5.0-emulator.core.private.20180813_2_llvm40.i386"/>
</option>
<option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.1400785047" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
@@ -156,7 +156,7 @@
<option defaultValue="gnu.c.debugging.level.max" id="sbi.gnu.c.compiler.option.debugging.level.core.2050546718" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core" valueType="enumerated"/>
<option defaultValue="false" id="sbi.gnu.c.compiler.option.misc.pic.core.1469084232" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/>
<option id="sbi.gnu.c.compiler.option.212028038" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
- <listOptionValue builtIn="false" value="wearable-5.0-emulator.core.private.20180724_3_llvm40.i386"/>
+ <listOptionValue builtIn="false" value="wearable-5.0-emulator.core.private.20180813_2_llvm40.i386"/>
</option>
<option id="sbi.gnu.c.compiler.option.frameworks_inc.core.2081322027" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
@@ -262,10 +262,10 @@
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/glib-2.0/include&quot;"/>
</option>
<option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.1567266628" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.core" useByScannerDiscovery="false" valueType="stringList">
- <listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/>
- <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
+ <listOptionValue builtIn="false" value="$(TC_COMPILER_MISC)"/>
+ <listOptionValue builtIn="false" value="$(RS_COMPILER_MISC)"/>
<listOptionValue builtIn="false" value=" -fPIE"/>
- <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
+ <listOptionValue builtIn="false" value="--sysroot=&quot;$(SBI_SYSROOT)&quot;"/>
</option>
<option id="gnu.c.compiler.option.include.paths.808536886" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
@@ -286,12 +286,12 @@
<option defaultValue="false" id="sbi.gnu.cpp.linker.option.shared_flag.core.1629520054" name="Linker.Shared" superClass="sbi.gnu.cpp.linker.option.shared_flag.core" valueType="boolean"/>
<option defaultValue="false" id="sbi.gnu.cpp.linker.option.noundefined.core.1450444335" name="Report unresolved symbol references (-Wl,--no-undefined)" superClass="sbi.gnu.cpp.linker.option.noundefined.core" valueType="boolean"/>
<option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.1660737816" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" useByScannerDiscovery="false" valueType="stringList">
- <listOptionValue builtIn="false" value="${TC_LINKER_MISC}"/>
- <listOptionValue builtIn="false" value="${RS_LINKER_MISC}"/>
+ <listOptionValue builtIn="false" value="$(TC_LINKER_MISC)"/>
+ <listOptionValue builtIn="false" value="$(RS_LINKER_MISC)"/>
<listOptionValue builtIn="false" value="-pie -lpthread "/>
- <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
- <listOptionValue builtIn="false" value="-Xlinker --version-script=&quot;${PROJ_PATH}/.exportMap&quot;"/>
- <listOptionValue builtIn="false" value="-L&quot;${SBI_SYSROOT}/usr/lib&quot;"/>
+ <listOptionValue builtIn="false" value="--sysroot=&quot;$(SBI_SYSROOT)&quot;"/>
+ <listOptionValue builtIn="false" value="-Xlinker --version-script=&quot;$(PROJ_PATH)/.exportMap&quot;"/>
+ <listOptionValue builtIn="false" value="-L&quot;$(SBI_SYSROOT)/usr/lib&quot;"/>
<listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/>
</option>
<option id="gnu.cpp.link.option.paths.1044065461" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
diff --git a/complication-provider/.cproject b/complication-provider/.cproject
index 48c74f8..0f1f7c5 100755
--- a/complication-provider/.cproject
+++ b/complication-provider/.cproject
@@ -21,13 +21,13 @@
<toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.app.debug.652220719" name="Tizen Native Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.app.debug">
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.114402787" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
<builder autoBuildTarget="all" buildPath="${workspace_loc:/complication-provider}/Debug" enableAutoBuild="true" id="org.tizen.nativecore.target.sbi.gnu.builder.445293514" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/>
- <tool command="arm-linux-gnueabi-ar.exe" id="org.tizen.nativecore.tool.sbi.gnu.archiver.1075687502" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/>
+ <tool command="i586-linux-gnueabi-ar.exe" id="org.tizen.nativecore.tool.sbi.gnu.archiver.1075687502" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/>
<tool command="clang++.exe" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.381282949" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
<option id="gnu.cpp.compiler.option.optimization.level.230430717" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option defaultValue="gnu.cpp.compiler.debugging.level.max" id="sbi.gnu.cpp.compiler.option.debugging.level.core.528078622" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core" valueType="enumerated"/>
<option defaultValue="false" id="sbi.gnu.cpp.compiler.option.misc.pic.core.959745419" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/>
<option id="sbi.gnu.cpp.compiler.option.372682793" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
- <listOptionValue builtIn="false" value="wearable-5.0-device.core.private.20180528_1_llvm40.armel"/>
+ <listOptionValue builtIn="false" value="wearable-5.0-emulator.core.private.20180813_2_llvm40.i386"/>
</option>
<option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.302507258" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
@@ -118,7 +118,6 @@
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/tzsh&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ug-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ui&quot;"/>
- <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/unicode&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/vconf&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/vulkan&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/watch-control&quot;"/>
@@ -138,7 +137,6 @@
<listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
<listOptionValue builtIn="false" value=" -fPIE"/>
<listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
- <listOptionValue builtIn="false" value="-mthumb"/>
</option>
<option id="gnu.cpp.compiler.option.include.paths.2085983105" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
@@ -158,7 +156,7 @@
<option defaultValue="gnu.c.debugging.level.max" id="sbi.gnu.c.compiler.option.debugging.level.core.1162616707" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core" valueType="enumerated"/>
<option defaultValue="false" id="sbi.gnu.c.compiler.option.misc.pic.core.722981029" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/>
<option id="sbi.gnu.c.compiler.option.1545234841" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
- <listOptionValue builtIn="false" value="wearable-5.0-device.core.private.20180528_1_llvm40.armel"/>
+ <listOptionValue builtIn="false" value="wearable-5.0-emulator.core.private.20180813_2_llvm40.i386"/>
</option>
<option id="sbi.gnu.c.compiler.option.frameworks_inc.core.562199907" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
@@ -249,7 +247,6 @@
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/tzsh&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ug-1&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ui&quot;"/>
- <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/unicode&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/vconf&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/vulkan&quot;"/>
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/watch-control&quot;"/>
@@ -269,7 +266,6 @@
<listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
<listOptionValue builtIn="false" value=" -fPIE"/>
<listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
- <listOptionValue builtIn="false" value="-mthumb"/>
</option>
<option id="gnu.c.compiler.option.include.paths.189860316" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
diff --git a/complication-provider/src/complication-provider.c b/complication-provider/src/complication-provider.c
index 7f4d0c3..d7fdcd6 100644
--- a/complication-provider/src/complication-provider.c
+++ b/complication-provider/src/complication-provider.c
@@ -14,8 +14,42 @@
* limitations under the License.
*/
+#include <stdio.h>
#include "complication-provider.h"
#include <service_app.h>
+#include <watchface-complication-provider.h>
+#include <bundle.h>
+#include <device/battery.h>
+#include <device/callback.h>
+
+
+#define BATTERY_PROVIDER_ID "org.tizen.complication-provider/battery"
+
+void battery_changed_cb(device_callback_e type, void *value, void *user_data)
+{
+ watchface_complication_provider_notify_update(BATTERY_PROVIDER_ID);
+}
+
+void __on_update_request(const char *provider_id, const char *req_appid,
+ watchface_complication_type_e type, const bundle *context, bundle *shared_data,
+ void *user_data) {
+ char num_str[128] = { 0, };
+ int ret;
+ int pct = 0;
+
+ ret = device_battery_get_percent(&pct);
+ if (ret != DEVICE_ERROR_NONE)
+ dlog_print(DLOG_ERROR, LOG_TAG, "failed to get battery percent : %d", ret);
+
+ watchface_complication_provider_data_set_type(shared_data, type);
+
+ if (type == WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT) {
+ snprintf(num_str, sizeof(num_str), "%d", pct);
+ watchface_complication_provider_data_set_short_text(shared_data, num_str);
+ } else if (type == WATCHFACE_COMPLICATION_TYPE_RANGED_VALUE) {
+ watchface_complication_provider_data_set_ranged_value(shared_data, (double)pct, 0.0, 100.0);
+ }
+}
static bool
app_create(void *data)
@@ -24,8 +58,12 @@ app_create(void *data)
Initialize UI resources and application's data
If this function returns true, the main loop of application starts
If this function returns false, the application is terminated */
-/* It is a dummy service for providing battery complications.
-Later on we may add more complications and update this file*/
+ watchface_complication_provider_add_update_requested_cb(
+ BATTERY_PROVIDER_ID, __on_update_request, NULL);
+
+ device_add_callback(DEVICE_CALLBACK_BATTERY_CAPACITY,
+ battery_changed_cb, NULL);
+
return true;
}
@@ -40,6 +78,8 @@ static void
app_terminate(void *data)
{
/* Release all resources. */
+
+ device_remove_callback(DEVICE_CALLBACK_BATTERY_CAPACITY, battery_changed_cb);
}
int
diff --git a/complication-provider/tizen-manifest.xml b/complication-provider/tizen-manifest.xml
index 03df84b..a2b8a2e 100755
--- a/complication-provider/tizen-manifest.xml
+++ b/complication-provider/tizen-manifest.xml
@@ -7,16 +7,20 @@
<complication provider-id="org.tizen.complication-provider/battery">
<support-type>
<short-text-type>
- <default-shorttext>10</default-shorttext>
+ <default-short-text>10</default-short-text>
</short-text-type>
<long-text-type>
- <default-longtext>Battery</default-longtext>
+ <default-long-text>Battery</default-long-text>
</long-text-type>
<ranged-value-type>
- <default-rangedvalue>100</default-rangedvalue>
+ <default-min>0</default-min>
+ <default-max>100</default-max>
+ <default-value>75</default-value>
</ranged-value-type>
<time-type>
- <default-time>100</default-time>
+ <default-hour>23</default-hour>
+ <default-minute>50</default-minute>
+ <default-second>50</default-second>
</time-type>
<icon-type>
<default-icon>iconicon</default-icon>
@@ -33,6 +37,7 @@
<privileges>
<privilege>http://tizen.org/privilege/alarm.get</privilege>
<privilege>http://tizen.org/privilege/alarm.set</privilege>
+ <privilege>http://tizen.org/privilege/datasharing</privilege>
</privileges>
</complication>
</service-application>
diff --git a/inc/battery-data.h b/inc/battery-data.h
deleted file mode 100644
index da7eb07..0000000
--- a/inc/battery-data.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef _BATTERY_DATA_H_
-#define _BATTERY_DATA_H_
-
-#include <device/callback.h>
-
-typedef void (*battery_changed_cb)(int value, void *user_data);
-
-
-/*
- * @brief provide the battery level
- * return battery level
- */
-int battery_get_status();
-
-/*
- * @brief Adds a callback to the observing device state.
- * @param callback The callback function to add
- * @param user data
- */
-void battery_add_status_changed_cb(battery_changed_cb callback,
- void *user_data);
-
-/*
- * @brief removes the callback registered
- * @param function pointer to callback function
- */
-void battery_remove_status_changed_cb(battery_changed_cb callback);
-#endif /* BATTERY_DATA_H_ */
diff --git a/project_def.prop b/project_def.prop
index 2c34bd2..d15b0ac 100644
--- a/project_def.prop
+++ b/project_def.prop
@@ -8,7 +8,7 @@ type = app
profile = wearable-5.0
# C/CPP Sources
-USER_SRCS = src/main.c src/view.c src/data-provider.c src/comp-manager.c src/utils.c src/battery-data.c
+USER_SRCS = src/main.c src/view.c src/data-provider.c src/comp-manager.c src/utils.c
# EDC Sources
USER_EDCS =
diff --git a/src/battery-data.c b/src/battery-data.c
deleted file mode 100644
index 8d3319d..0000000
--- a/src/battery-data.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "battery-data.h"
-#include <device/battery.h>
-#include "app-log.h"
-
-battery_changed_cb battery_cb;
-
-/*
- * @brief provide the battery level
- * return battery level
- */
-int battery_get_status()
-{
- int battery_level = 0;
- int ret = device_battery_get_percent(&battery_level);
- if (ret != DEVICE_ERROR_NONE) {
- __E("device_battery_get_percentage error : %d", ret);
- }
- __D("%s", __func__);
- return battery_level;
-}
-
-/*
- * @brief Called when a device status is changed.
- * @param Enumeration for the device state callback.
- * @param value of the changed value
- * @param user data
- */
-static void _battery_state_changed_cb(device_callback_e type, void *value, void *user_data)
-{
- int battery_level = 0;
- if (DEVICE_CALLBACK_BATTERY_CAPACITY == type) {
- battery_level = (int)value;
- }
- if (battery_cb) {
- __D("battery_cb called");
- battery_cb(battery_level, user_data);
- }
-}
-
-/*
- * @brief Adds a callback to the observing device state.
- * @param callback The callback function to add
- * @param user data
- */
-void battery_add_status_changed_cb(battery_changed_cb callback,
- void *user_data){
- battery_cb = callback;
- __D("%s", __func__);
- device_add_callback(DEVICE_CALLBACK_BATTERY_CAPACITY,
- _battery_state_changed_cb, user_data);
-}
-
-/*
- * @brief removes the callback registered
- * @param function pointer to callback function
- */
-void battery_remove_status_changed_cb(battery_changed_cb callback)
-{
- battery_cb = NULL;
- device_remove_callback(DEVICE_CALLBACK_BATTERY_CAPACITY, _battery_state_changed_cb);
-}
-
-
-
-
diff --git a/src/comp-manager.c b/src/comp-manager.c
index 18909a1..147cadf 100644
--- a/src/comp-manager.c
+++ b/src/comp-manager.c
@@ -19,7 +19,8 @@
#include "app-log.h"
#include "comp-manager.h"
#include "view.h"
-#include "battery-data.h"
+#include <device/battery.h>
+#include <watchface-complication-provider.h>
static void _comp_draw_dial(bundle*);
static void _comp_draw_hand(bundle*);
@@ -29,7 +30,7 @@ static void _comp_on_complication_update(int, const char*, watchface_complicatio
static void _comp_on_ready_for_edit_cb(watchface_editable_container_h, const char*, void*);
static void _comp_init_editable();
static void _comp_init_complication();
-static void _comp_battery_status_changed_cb(int level, void* user_data);
+static int _comp_battery_get_status();
static complication_h _comp;
@@ -50,9 +51,19 @@ char _dial_styles[DIAL_NUM][5] = {
};
-void _comp_battery_status_changed_cb(int level, void* user_data)
+/*
+ * @brief provide the battery level
+ * return battery level
+ */
+static int _comp_battery_get_status()
{
- view_set_battery_status(level, user_data);
+ int battery_level = 0;
+ int ret = device_battery_get_percent(&battery_level);
+ if (ret != DEVICE_ERROR_NONE) {
+ __E("device_battery_get_percentage error : %d", ret);
+ }
+ __D("%s", __func__);
+ return battery_level;
}
/*
@@ -69,7 +80,7 @@ void _comp_draw_complication(watchface_complication_type_e type)
msg.val = type;
edje_object_message_send(elm_layout_edje_get(watchface_layout), EDJE_MESSAGE_INT, MSG_ID_SET_BATTERY_COMP, &msg);
- percent = battery_get_status();
+ percent = _comp_battery_get_status();
__D("_battery_state_changed_cb %d", percent);
msg.val = percent;
@@ -130,12 +141,12 @@ void _comp_init_complication()
if (ret == WATCHFACE_COMPLICATION_ERROR_NONE) {
watchface_complication_get_current_type(_comp, &cur_type);
__D("watchface_complication_get_current_type %d", cur_type);
+ watchface_complication_send_update_request(_comp);
_comp_draw_complication(cur_type);
free(current_comp_id);
} else {
_comp_draw_complication(WATCHFACE_COMPLICATION_TYPE_NO_DATA);
}
- battery_add_status_changed_cb(_comp_battery_status_changed_cb, NULL);
}
/*
diff --git a/src/view.c b/src/view.c
index 50a9577..578a1c1 100644
--- a/src/view.c
+++ b/src/view.c
@@ -20,7 +20,6 @@
#include "app-log.h"
#include "view.h"
#include "utils.h"
-#include "battery-data.h"
static void _view_create_base_gui(int, int);
static void _view_destroy_base_gui(void);
diff --git a/tizen-manifest.xml b/tizen-manifest.xml
index a4df77d..e91526b 100644
--- a/tizen-manifest.xml
+++ b/tizen-manifest.xml
@@ -9,6 +9,7 @@
<privileges>
<privilege>http://tizen.org/privilege/appmanager.launch</privilege>
<privilege>http://tizen.org/privilege/display</privilege>
+ <privilege>http://tizen.org/privilege/alarm.get</privilege>
<privilege>http://tizen.org/privilege/alarm.set</privilege>
<privilege>http://tizen.org/privilege/datasharing</privilege>
</privileges>