Add ode_internal_encryption_is_mounted() API. 86/184086/5
authorseolheui, kim <s414.kim@samsung.com>
Fri, 13 Jul 2018 10:59:24 +0000 (19:59 +0900)
committerJaemin Ryu <jm77.ryu@samsung.com>
Thu, 26 Jul 2018 05:27:37 +0000 (14:27 +0900)
Change-Id: I3da5818cd9e83a641151bb2c287484e59d693520
Signed-off-by: seolheui, kim <s414.kim@samsung.com>
lib/internal-encryption.cpp
lib/internal-encryption.h
lib/ode/internal-encryption.cpp
lib/ode/internal-encryption.h
rmi/internal-encryption.h
server/internal-encryption.cpp
server/internal-encryption.h

index 0ea54f0..fa918ae 100644 (file)
@@ -45,6 +45,15 @@ int InternalEncryptionClient::mount(const std::vector<unsigned char> &mk, unsign
        }
 }
 
+int InternalEncryptionClient::isMounted()
+{
+       try {
+               return context->methodCall<int>("InternalEncryptionServer::isMounted");
+       } catch (runtime::Exception& e) {
+               return error::Unknown;
+       }
+}
+
 int InternalEncryptionClient::umount()
 {
        try {
index 15b76db..ccedd04 100644 (file)
@@ -34,6 +34,7 @@ public:
 
        int mount(const std::vector<unsigned char> &mk, unsigned int options);
        int umount();
+       int isMounted();
 
        int encrypt(const std::string& password, unsigned int options);
        int decrypt(const std::string& password);
index d8b4d55..90c5358 100644 (file)
@@ -57,6 +57,20 @@ int ode_internal_encryption_mount_ex(const unsigned char *mk, unsigned int optio
        return toApiError(internal.mount(key, options));
 }
 
+int ode_internal_encryption_is_mounted(bool *result)
+{
+       ClientContext client;
+       RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
+       InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
+       int ret = internal.isMounted();
+       if (ret < 0)
+               return toApiError(ret);
+
+       *result = ret == 1 ? true : false;
+
+       return ODE_ERROR_NONE;
+}
+
 int ode_internal_encryption_umount()
 {
        ClientContext client;
index 7959644..3c1d074 100644 (file)
@@ -91,6 +91,21 @@ ODE_API int ode_internal_encryption_mount();
 ODE_API int ode_internal_encryption_mount_ex(const unsigned char *mk, unsigned int option);
 
 /**
+ * @brief       Check whether the encrypted internal storage is mounted
+ * @details     Administrator can use this API to get the current mount state
+ *              of encrypted internal storage.
+ * @since_tizen 4.0
+ * @param[out]  result Whether the encrypted internal storage is mounted
+ * @return      #ODE_ERROR_NONE on success, otherwise a negative value
+ * @retval      #ODE_ERROR_NONE Successful
+ * @retval      #ODE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #ODE_ERROR_CONNECTION_REFUSED Connection to the server failed
+ * @retval      #ODE_ERROR_UNKNOWN Unknown error
+ * @see         ode_internal_encryption_mount()
+ */
+ODE_API int ode_internal_encryption_is_mounted(bool *result);
+
+/**
  * @brief       Umount internal storage
  * @details     Administrator can use this API to unmount internal storage.
  * @since_tizen 4.0
index 1260214..b7983ba 100644 (file)
@@ -34,6 +34,7 @@ public:
 
        virtual int mount(const std::vector<unsigned char>& mk, unsigned int options) = 0;
        virtual int umount() = 0;
+       virtual int isMounted() = 0;
 
        virtual int encrypt(const std::string& password, unsigned int options) = 0;
        virtual int decrypt(const std::string& password) = 0;
index 2791620..9ae49e5 100644 (file)
@@ -365,6 +365,7 @@ InternalEncryptionServer::InternalEncryptionServer(ServerContext& srv,
        server.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::setMountPassword)(std::string));
        server.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::mount)(std::vector<unsigned char>, unsigned int));
        server.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::umount)());
+       server.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::isMounted)());
        server.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::encrypt)(std::string, unsigned int));
        server.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::decrypt)(std::string));
        server.expose(this, "", (int)(InternalEncryptionServer::isPasswordInitialized)());
@@ -451,6 +452,18 @@ int InternalEncryptionServer::mount(const std::vector<unsigned char> &mk, unsign
        return error::None;
 }
 
+int InternalEncryptionServer::isMounted()
+{
+       int ret = 0;
+       try {
+               ret = engine->isMounted() ? 1 : 0;
+       } catch (runtime::Exception &e) {
+               ERROR(SINK, "Failed to access the mount flag");
+               return error::Unknown;
+       }
+       return ret;
+}
+
 int InternalEncryptionServer::umount()
 {
        if (getState() != State::Encrypted) {
index 52d4f35..3ad419b 100644 (file)
@@ -38,6 +38,7 @@ public:
 
        int mount(const std::vector<unsigned char> &mk, unsigned int options);
        int umount();
+       int isMounted();
 
        int encrypt(const std::string& password, unsigned int options);
        int decrypt(const std::string& password);