2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <app_control.h>
22 #define KEY_DISPLAY_OVER_LOCKSCREEN "http://tizen.org/lock/window/above"
24 static bool camera_enabled;
25 static int init_count;
27 int LOCKSCREEN_EVENT_CAMERA_STATUS_CHANGED;
29 static void _app_control_reply_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data)
32 case APP_CONTROL_RESULT_APP_STARTED:
33 case APP_CONTROL_RESULT_SUCCEEDED:
34 DBG("Camera application launch succcessed.");
36 case APP_CONTROL_RESULT_FAILED:
37 case APP_CONTROL_RESULT_CANCELED:
38 DBG("Camera application launch failed.");
43 int lockscreen_camera_activate()
45 app_control_h app_ctr;
47 int err = app_control_create(&app_ctr);
48 if (err != APP_CONTROL_ERROR_NONE) {
49 ERR("app_control_create failed: %s", get_error_message(err));
53 err = app_control_set_launch_mode(app_ctr, APP_CONTROL_LAUNCH_MODE_GROUP);
54 if (err != APP_CONTROL_ERROR_NONE) {
55 ERR("app_control_set_launch_mode failed: %s", get_error_message(err));
56 app_control_destroy(app_ctr);
60 /* Send a hint to camera-app to display itself over lockscreen */
61 err = app_control_add_extra_data(app_ctr, KEY_DISPLAY_OVER_LOCKSCREEN, "on");
62 if (err != APP_CONTROL_ERROR_NONE) {
63 ERR("app_control_add_extra_data failed: %s", get_error_message(err));
64 app_control_destroy(app_ctr);
68 /* Send a hint to camera-app to display itself in secure mode*/
69 err = app_control_add_extra_data(app_ctr, "secure_mode", "true");
70 if (err != APP_CONTROL_ERROR_NONE) {
71 ERR("app_control_add_extra_data failed: %s", get_error_message(err));
72 app_control_destroy(app_ctr);
76 err = app_control_set_app_id(app_ctr, "org.tizen.camera-app");
77 if (err != APP_CONTROL_ERROR_NONE) {
78 ERR("app_control_set_app_id failed: %s", get_error_message(err));
79 app_control_destroy(app_ctr);
83 err = app_control_send_launch_request(app_ctr, _app_control_reply_cb, NULL);
84 if (err != APP_CONTROL_ERROR_NONE) {
85 ERR("app_control_send_launch_request failed: %s", get_error_message(err));
86 app_control_destroy(app_ctr);
90 DBG("Launch request send for %s", APP_CONTROL_OPERATION_CREATE_CONTENT);
91 app_control_destroy(app_ctr);
96 int lockscreen_camera_init(void)
99 //FIXME load this from settings
100 camera_enabled = true;
101 LOCKSCREEN_EVENT_CAMERA_STATUS_CHANGED = ecore_event_type_new();
108 void lockscreen_camera_shutdown(void)
115 bool lockscreen_camera_is_on(void)
117 return camera_enabled;