Support DPM popup 60/106260/2
authorJeongmo Yang <jm80.yang@samsung.com>
Wed, 21 Dec 2016 07:00:39 +0000 (16:00 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Fri, 6 Jan 2017 07:41:29 +0000 (16:41 +0900)
Send dbus message to show popup related DPM policy restriction

[Version] 0.10.100
[Profile] Common
[Issue Type] Update
[Dependency module] N/A
[Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-3.0-mobile_20161221.1]

Change-Id: Ia710e8bdb97791977fb8f050f01a6272e75769cc
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/libmm-camcorder.spec
src/include/mm_camcorder_util.h
src/mm_camcorder_internal.c
src/mm_camcorder_util.c

index 88d1767..c34b0ae 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-camcorder
 Summary:    Camera and recorder library
-Version:    0.10.99
+Version:    0.10.100
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 4035fe9..b3ba6f8 100644 (file)
@@ -310,6 +310,9 @@ int _mmcamcorder_get_device_flash_brightness(GDBusConnection *conn, int *brightn
 int _mmcamcorder_send_sound_play_message(GDBusConnection *conn, _MMCamcorderGDbusCbInfo *gdbus_info,
        const char *sample_name, const char *stream_role, const char *volume_gain, int sync_play);
 
+/* request to show pop-up related DPM policy */
+void _mmcamcorder_request_dpm_popup(GDBusConnection *conn, const char *restricted_policy);
+
 /* dbus signal emit */
 void _mmcamcorder_emit_dbus_signal(GDBusConnection *conn, const char *object_name,
        const char *interface_name, const char *signal_name, int value);
index 3eb1590..6b07da4 100644 (file)
@@ -1061,6 +1061,9 @@ int _mmcamcorder_realize(MMHandleType handle)
                                if (dpm_camera_state == DPM_DISALLOWED) {
                                        _mmcam_dbg_err("CAMERA DISALLOWED by DPM");
                                        ret = MM_ERROR_POLICY_RESTRICTED;
+
+                                       _mmcamcorder_request_dpm_popup(hcamcorder->gdbus_conn, "camera");
+
                                        goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
                                }
                        } else {
@@ -1749,6 +1752,9 @@ int _mmcamcorder_record(MMHandleType handle)
                        if (dpm_mic_state == DPM_DISALLOWED) {
                                _mmcam_dbg_err("MIC DISALLOWED by DPM");
                                ret = MM_ERROR_COMMON_INVALID_PERMISSION;
+
+                               _mmcamcorder_request_dpm_popup(hcamcorder->gdbus_conn, "microphone");
+
                                goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
                        }
                } else {
@@ -3196,9 +3202,9 @@ GstBusSyncReply _mmcamcorder_encode_pipeline_bus_sync_callback(GstBus *bus, GstM
 
                                _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
                        }
-               }
 
-               goto DROP_MESSAGE;
+                       goto DROP_MESSAGE;
+               }
        }
 
        if (err) {
@@ -3423,6 +3429,8 @@ void _mmcamcorder_dpm_camera_policy_changed_cb(const char *name, const char *val
                hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_NORMAL;
 
                _MMCAMCORDER_UNLOCK_ASM(hcamcorder);
+
+               _mmcamcorder_request_dpm_popup(hcamcorder->gdbus_conn, "camera");
        }
 
        _mmcam_dbg_warn("done");
@@ -4019,6 +4027,8 @@ static gint __mmcamcorder_gst_handle_resource_error(MMHandleType handle, int cod
 
                        _MMCAMCORDER_UNLOCK_ASM(hcamcorder);
 
+                       _mmcamcorder_request_dpm_popup(hcamcorder->gdbus_conn, "microphone");
+
                        return MM_ERROR_POLICY_RESTRICTED;
                }
        }
index 6f342c6..b490600 100644 (file)
@@ -820,7 +820,8 @@ int _mmcamcorder_send_sound_play_message(GDBusConnection *conn, _MMCamcorderGDbu
 {
        int get_value = 0;
        int ret = MM_ERROR_NONE;
-       GVariant *params = NULL, *result = NULL;
+       GVariant *params = NULL;
+       GVariant *result = NULL;
        guint subs_id = 0;
 
        if (!conn || !gdbus_info) {
@@ -876,6 +877,42 @@ int _mmcamcorder_send_sound_play_message(GDBusConnection *conn, _MMCamcorderGDbu
 }
 
 
+void _mmcamcorder_request_dpm_popup(GDBusConnection *conn, const char *restricted_policy)
+{
+       int ret = MM_ERROR_NONE;
+       gboolean get_value = 0;
+       GVariant *params = NULL;
+       GVariant *result = NULL;
+
+       if (!conn || !restricted_policy) {
+               _mmcam_dbg_err("Invalid parameter %p %p", conn, restricted_policy);
+               return;
+       }
+
+       params = g_variant_new("(s)", restricted_policy);
+       result = g_variant_new("(b)", get_value);
+
+       ret = __gdbus_method_call_sync(conn,
+               "org.tizen.DevicePolicyManager",
+               "/org/tizen/DevicePolicyManager/Syspopup",
+               "org.tizen.DevicePolicyManager.Syspopup",
+               "show", params, &result, TRUE);
+       if (ret != MM_ERROR_NONE) {
+               _mmcam_dbg_err("Dbus Call on Client Error 0x%x", ret);
+               return;
+       }
+
+       if (result) {
+               g_variant_get(result, "(b)", &get_value);
+               _mmcam_dbg_log("request result : %d", get_value);
+       } else {
+               _mmcam_dbg_err("replied result is null");
+       }
+
+       return;
+}
+
+
 int _mmcamcorder_get_file_size(const char *filename, guint64 *size)
 {
        struct stat buf;