#define RESOURCED_FREEZER_PATH "/Org/Tizen/Resourced/Freezer"
#define RESOURCED_FREEZER_INTERFACE "org.tizen.resourced.freezer"
#define RESOURCED_FREEZER_SIGNAL "FreezerState"
+#define SQLITE_FLUSH_MAX (1024 * 1024)
typedef struct _appcore_base_context {
appcore_base_ops ops;
int lock;
int ref;
enum appcore_base_rm rm;
+ int charger_status;
+ bool initialized;
} appcore_base_rotation;
struct lang_info_s {
__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);
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);
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++;
}
EXPORT_API int appcore_base_flush_memory(void)
{
+ int (*sqlite3_free_heap_memory)(int);
+ void (*elm_free_all_cache)(void);
+
+ elm_free_all_cache = dlsym(RTLD_DEFAULT, "elm_cache_all_flush");
+ if (elm_free_all_cache)
+ elm_free_all_cache();
+
+ sqlite3_free_heap_memory = dlsym(RTLD_DEFAULT,
+ "sqlite3_release_memory");
+ if (sqlite3_free_heap_memory)
+ sqlite3_free_heap_memory(SQLITE_FLUSH_MAX);
+
malloc_trim(0);
return 0;
}