summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2018-02-26 16:54:41 +0900
committerHwanKyu Jhun <h.jhun@samsung.com>2018-02-26 10:03:10 +0000
commitfa4a9b90a7a626d0e1da5ae43d9215c2d7b0360f (patch)
tree41414d695d3154472adfce49ee66324fcd80fb09 /src
parenta3a65d1b9ec6f163f891ac7da53296f19af99871 (diff)
downloadapp-core-fa4a9b90a7a626d0e1da5ae43d9215c2d7b0360f.tar.gz
app-core-fa4a9b90a7a626d0e1da5ae43d9215c2d7b0360f.tar.bz2
app-core-fa4a9b90a7a626d0e1da5ae43d9215c2d7b0360f.zip
Add charger status check feature
In the wearable profile, an application shouldn't use auto rotation feature unless the battery status is charging. Change-Id: I5db7ae47d24be371101c0356b3d492d65cf6274d Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
Diffstat (limited to 'src')
-rw-r--r--src/base/appcore_base.c72
-rw-r--r--src/base/appcore_base_private.h2
2 files changed, 63 insertions, 11 deletions
diff --git a/src/base/appcore_base.c b/src/base/appcore_base.c
index 34d9278..1754f07 100644
--- a/src/base/appcore_base.c
+++ b/src/base/appcore_base.c
@@ -70,6 +70,8 @@ typedef struct _appcore_base_rotation {
int lock;
int ref;
enum appcore_base_rm rm;
+ int charger_status;
+ bool initialized;
} appcore_base_rotation;
struct lang_info_s {
@@ -243,13 +245,9 @@ static void __auto_rotation_changed_cb(sensor_t sensor, unsigned int event_type,
__invoke_callback((void *)&__rotation.rm, APPCORE_BASE_EVENT_DEVICE_ORIENTATION_CHANGED);
}
-static void __unregister_rotation_changed_event(void)
+static void __fini_rotation(void)
{
- if (!__rotation.ref)
- return;
-
- __rotation.ref--;
- if (__rotation.ref > 1)
+ if (!__rotation.initialized)
return;
vconf_ignore_key_changed(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, __lock_cb);
@@ -258,19 +256,17 @@ static void __unregister_rotation_changed_event(void)
sensord_disconnect(__rotation.conn);
__rotation.lock = 0;
- __rotation.ref = 0;
+ __rotation.initialized = false;
}
-static void __register_rotation_changed_event(void)
+static void __init_rotation(void)
{
sensor_t sensor;
int lock;
bool r;
- if (__rotation.ref) {
- __rotation.ref++;
+ if (__rotation.initialized)
return;
- }
sensor = sensord_get_sensor(AUTO_ROTATION_SENSOR);
__rotation.conn = sensord_connect(sensor);
@@ -300,6 +296,60 @@ static void __register_rotation_changed_event(void)
vconf_notify_key_changed(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, __lock_cb, NULL);
__rotation.lock = !lock;
+ __rotation.initialized = true;
+}
+
+static void __charger_status_changed_cb(keynode_t *keynode, void *user_data)
+{
+ if (TIZEN_FEATURE_CHARGER_STATUS) {
+ __rotation.charger_status = vconf_keynode_get_int(keynode);
+ if (__rotation.charger_status) {
+ if (__rotation.ref)
+ __init_rotation();
+ } else {
+ if (__rotation.ref)
+ __fini_rotation();
+ }
+ _DBG("charger status(%d)", __rotation.charger_status);
+ }
+}
+
+static void __unregister_rotation_changed_event(void)
+{
+ if (!__rotation.ref)
+ return;
+
+ __rotation.ref--;
+ if (__rotation.ref > 1)
+ return;
+
+ __fini_rotation();
+ if (TIZEN_FEATURE_CHARGER_STATUS) {
+ vconf_ignore_key_changed(VCONFKEY_SYSMAN_CHARGER_STATUS,
+ __charger_status_changed_cb);
+ }
+
+ __rotation.ref = 0;
+}
+
+static void __register_rotation_changed_event(void)
+{
+ if (__rotation.ref) {
+ __rotation.ref++;
+ return;
+ }
+
+ if (TIZEN_FEATURE_CHARGER_STATUS) {
+ vconf_get_int(VCONFKEY_SYSMAN_CHARGER_STATUS,
+ &__rotation.charger_status);
+ vconf_notify_key_changed(VCONFKEY_SYSMAN_CHARGER_STATUS,
+ __charger_status_changed_cb, NULL);
+ if (__rotation.charger_status)
+ __init_rotation();
+ } else {
+ __init_rotation();
+ }
+
__rotation.ref++;
}
diff --git a/src/base/appcore_base_private.h b/src/base/appcore_base_private.h
index 6c4b95d..003e747 100644
--- a/src/base/appcore_base_private.h
+++ b/src/base/appcore_base_private.h
@@ -94,6 +94,8 @@ appcore_base_tizen_profile_t appcore_base_get_tizen_profile(void);
#define TIZEN_FEATURE_BACKGROUND_MANAGEMENT \
(!(appcore_base_get_tizen_profile() & TIZEN_PROFILE_TV))
+#define TIZEN_FEATURE_CHARGER_STATUS \
+ (appcore_base_get_tizen_profile() & TIZEN_PROFILE_WEARABLE)
extern void aul_finalize();