Add external storage restriction policy 04/72404/1
authorJaemin Ryu <jm77.ryu@samsung.com>
Wed, 1 Jun 2016 00:05:21 +0000 (09:05 +0900)
committerJaemin Ryu <jm77.ryu@samsung.com>
Wed, 1 Jun 2016 00:05:21 +0000 (09:05 +0900)
Change-Id: I8b11f6f504a9b962c74a25b880da4018ec3bec18
Signed-off-by: Jaemin Ryu <jm77.ryu@samsung.com>
server/restriction.cpp

index ee9c233..2e49548 100644 (file)
     "/org/pulseaudio/StreamManager",  \
     "org.pulseaudio.StreamManager"
 
+#define DEVICED_SYSNOTI_INTERFACE           \
+    "org.tizen.system.deviced",             \
+    "/Org/Tizen/System/DeviceD/SysNoti",    \
+    "org.tizen.system.deviced.SysNoti",     \
+    "control"
+
 namespace DevicePolicyManager {
 
 RestrictionPolicy::RestrictionPolicy(PolicyControlContext& ctxt) :
@@ -141,6 +147,18 @@ bool RestrictionPolicy::getUsbTetheringState()
 
 int RestrictionPolicy::setExternalStorageState(int enable)
 {
+    int ret;
+    std::string pid(std::to_string(::getpid()));
+    std::string state(std::to_string(enable));
+
+    dbus::Connection &systemDBus = dbus::Connection::getSystem();
+    systemDBus.methodcall(DEVICED_SYSNOTI_INTERFACE, -1,
+                          "(i)", "(sisss)", "control",
+                          3, pid.c_str(), "2", state.c_str()).get("(i)", &ret);
+    if (ret != 0) {
+        return -1;
+    }
+
     SetPolicyAllowed(context, "external-storage", enable);
     return 0;
 }