int tracker_get_power_lock_ref(int *count);
/**
+ * @brief Gets the total count of the Power Lock operation
+ * @since_tizen 3.0
+ * @param[out] count The total count of the Power Lock operation
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #TRACKER_ERROR_NONE Successful
+ * @retval #TRACKER_ERROR_INVALID_PARAMETER The input parameter is invalid
+ * @retval #TRACKER_ERROR_PERMISSION_DENIED No permission to use the API
+ */
+int tracker_get_power_lock_total(int *count);
+
+/**
* @brief Start tracking for information of services
* @details The api should be used only in the framework, not in applications
* @since_tizen 3.0
* limitations under the License.
*/
+#include <limits.h>
#include "tracker.h"
#include "tracker_private.h"
-#define POWERLOCK_DEFAULT_REF 0
+#define POWERLOCK_DEFAULT_REF 0
+#define POWERLOCK_DEFAULT_COUNT 0
struct powerlock_ref {
tracker_service_e service;
unsigned int ref;
+ int total;
} lock_refs[] = {
- { TRACKER_SERVICE_DOWNLOAD, POWERLOCK_DEFAULT_REF },
- { TRACKER_SERVICE_MEDIA, POWERLOCK_DEFAULT_REF },
- { TRACKER_SERVICE_NETWORK, POWERLOCK_DEFAULT_REF },
- { TRACKER_SERVICE_LOCATION, POWERLOCK_DEFAULT_REF },
- { TRACKER_SERVICE_SENSOR, POWERLOCK_DEFAULT_REF },
- { TRACKER_SERVICE_IOT, POWERLOCK_DEFAULT_REF },
+ { TRACKER_SERVICE_DOWNLOAD, POWERLOCK_DEFAULT_REF , POWERLOCK_DEFAULT_COUNT },
+ { TRACKER_SERVICE_MEDIA, POWERLOCK_DEFAULT_REF , POWERLOCK_DEFAULT_COUNT },
+ { TRACKER_SERVICE_NETWORK, POWERLOCK_DEFAULT_REF , POWERLOCK_DEFAULT_COUNT },
+ { TRACKER_SERVICE_LOCATION, POWERLOCK_DEFAULT_REF , POWERLOCK_DEFAULT_COUNT },
+ { TRACKER_SERVICE_SENSOR, POWERLOCK_DEFAULT_REF , POWERLOCK_DEFAULT_COUNT },
+ { TRACKER_SERVICE_IOT, POWERLOCK_DEFAULT_REF , POWERLOCK_DEFAULT_COUNT },
};
+#define COUNT_MAX (INT_MAX/ARRAY_SIZE(lock_refs))
+
int get_power_lock_ref(void)
{
int sum = 0, i;
return sum;
}
+int get_power_lock_total(void)
+{
+ int sum = 0, i;
+
+ for (i = 0 ; i < ARRAY_SIZE(lock_refs) ; i++)
+ sum += lock_refs[i].total;
+
+ _I("Total lock count of pid(%d) is (%d)",
+ getpid(), sum);
+
+ return sum;
+}
+
void power_lock_ref(tracker_service_e service)
{
int i;
if (lock_refs[i].service != service)
continue;
lock_refs[i].ref++;
- _I("[%s] pid(%d) increases power lock ref count to (%d)",
+
+ if (lock_refs[i].total == COUNT_MAX)
+ lock_refs[i].total = POWERLOCK_DEFAULT_COUNT;
+ else
+ lock_refs[i].total++;
+
+ _I("[%s] pid(%d) increases power lock ref count to (%d, %d)",
service_name_str(service, buf, sizeof(buf)),
- getpid(), lock_refs[i].ref);
+ getpid(), lock_refs[i].ref, lock_refs[i].total);
break;
}
}