return listener.Deregister();
}
-extern "C" int aul_app_lifecycle_update_state(aul_app_lifecycle_state_e state) {
+extern "C" API int aul_app_lifecycle_update_state(
+ aul_app_lifecycle_state_e state) {
tizen_base::Bundle b;
b.Add(AUL_K_STATE, std::to_string(static_cast<int>(state)));
aul::Packet packet(APP_LIFECYCLE_UPDATE_STATE,
return AUL_R_OK;
}
+
+extern "C" API int aul_app_lifecycle_get_state(const char* app_id,
+ aul_app_lifecycle_state_e* state) {
+ if (app_id == nullptr || state == nullptr) {
+ _E("Invalid prameter");
+ return AUL_R_EINVAL;
+ }
+
+ tizen_base::Bundle b;
+ b.Add(AUL_K_APPID, app_id);
+ aul::Packet* recv_pkt = nullptr;
+ aul::Packet packet(APP_LIFECYCLE_GET_STATE, AUL_SOCK_BUNDLE, b);
+ try {
+ aul::Client client(aul::PATH_AMD_SOCK);
+ int ret = client.Send(packet);
+ if (ret < 0)
+ return aul_error_convert(ret);
+
+ ret = client.Recv(&recv_pkt);
+ if (ret < 0)
+ return aul_error_convert(ret);
+ } catch (aul::Exception& e) {
+ _E("Exception(%s) occurs", e.what());
+ return aul_error_convert(e.GetErrorCode());
+ }
+
+ std::unique_ptr<aul::Packet> pkt_auto(recv_pkt);
+ if (recv_pkt->GetCmd() != APP_GET_INFO_OK) {
+ _E("Failed to get app lifecycle state");
+ return AUL_R_ERROR;
+ }
+
+ tizen_base::Bundle res_b = recv_pkt->DataToBundle();
+ std::string val = res_b.GetString(AUL_K_STATE);
+ if (!val.empty())
+ *state = static_cast<aul_app_lifecycle_state_e>(std::stoi(val));
+
+ return AUL_R_OK;
+}
int aul_app_lifecycle_deregister_state_changed_cb(void);
/**
- * @breif Updates the state of the application lifecycle.
+ * @brief Updates the state of the application lifecycle.
* @since_tizen 6.5
* @param[in] state The state of the application lifecycle
* @return @c 0 on success,
*/
int aul_app_lifecycle_update_state(aul_app_lifecycle_state_e state);
+/**
+ * @brief Gets the state of the application lifecycle of the given application ID.
+ * @since_tizen 6.5
+ * @param[in] app_id The application ID
+ * @param[out] state The state of the application lifecycle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @see #aul_app_lifecycle_state_e
+ */
+int aul_app_lifecycle_get_state(const char *app_id, aul_app_lifecycle_state_e *state);
+
#ifdef __cplusplus
}
#endif
APP_GET_APP_CONTROL_DEFAULT_APPS = 157,
APP_GET_APPID_BY_ALIAS_APPID = 158,
APP_GET_APP_CONTROL_DEFAULT_APP = 159,
+ APP_LIFECYCLE_GET_STATE = 160,
APP_CMD_MAX
};
"APP_GET_APP_CONTROL_DEFAULT_APPS",
"APP_GET_APPID_BY_ALIAS_APPID",
"APP_GET_APP_CONTROL_DEFAULT_APP",
+ "APP_LIFECYCLE_GET_STATE",
"CUSTOM_COMMAND"
};
return ret;
}
+static const char *__get_string_from_lifecycle_state(
+ aul_app_lifecycle_state_e state)
+{
+ switch (state) {
+ case AUL_APP_LIFECYCLE_STATE_INITIALIZED:
+ return "INITIALIZED";
+ case AUL_APP_LIFECYCLE_STATE_CREATED:
+ return "CREATED";
+ case AUL_APP_LIFECYCLE_STATE_RESUMED:
+ return "RESUMED";
+ case AUL_APP_LIFECYCLE_STATE_PAUSED:
+ return "PAUSED";
+ case AUL_APP_LIFECYCLE_STATE_DESTROYED:
+ return "DESTROYED";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static int get_app_lifecycle_test(void)
+{
+ aul_app_lifecycle_state_e state;
+ int ret;
+
+ printf("[aul_app_lifecycle_get_state test] %s\n", gargv[2]);
+ ret = aul_app_lifecycle_get_state(gargv[2], &state);
+ printf("result: %d, state: %s\n",
+ ret, __get_string_from_lifecycle_state(state));
+ return ret;
+}
+
static int test_regex()
{
char *token;
"[usage] set_default_app_by_operation <operation> <appid>"},
{"get_default_app", get_default_app_test, "aul_get_default_app",
"[usage] get_default_appid <operation> <uri> <mime>"},
+ {"get_app_lifecycle", get_app_lifecycle_test, "aul_app_lifecycle_get_state",
+ "[usage] get_app_lifecycle <appid>"},
};
int callfunc(char *testname)