From: jongmyeongko Date: Tue, 11 Jul 2017 06:50:22 +0000 (+0900) Subject: Modify the signature of insatll API for mount installation X-Git-Tag: submit/trunk/20170823.075128~121^2~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9c6d87d31b1361bb42bc4ae335be75fd9a678dcd;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git Modify the signature of insatll API for mount installation usage : PackageManager.Install(packagePath, InstallType.Mount); Change-Id: I936f93780167ac68b441f6b73aa11eb03c5a26c2 Signed-off-by: jongmyeongko --- diff --git a/src/Tizen.Applications.PackageManager/Interop/Interop.PackageManager.cs b/src/Tizen.Applications.PackageManager/Interop/Interop.PackageManager.cs old mode 100644 new mode 100755 index e8fac2d..92ad54e --- a/src/Tizen.Applications.PackageManager/Interop/Interop.PackageManager.cs +++ b/src/Tizen.Applications.PackageManager/Interop/Interop.PackageManager.cs @@ -186,6 +186,9 @@ internal static partial class Interop [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_install")] internal static extern ErrorCode PackageManagerRequestInstall(SafePackageManagerRequestHandle requestHandle, string path, out int id); + [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_mount_install")] + internal static extern ErrorCode PackageManagerRequestMountInstall(SafePackageManagerRequestHandle requestHandle, string path, out int id); + [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_uninstall")] internal static extern ErrorCode PackageManagerRequestUninstall(SafePackageManagerRequestHandle requestHandle, string name, out int id); @@ -216,6 +219,9 @@ internal static partial class Interop [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_install_with_cb")] internal static extern ErrorCode PackageManagerRequestInstallWithCB(SafePackageManagerRequestHandle requestHandle, string path, PackageManagerRequestEventCallback callback, IntPtr userData, out int id); + [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_mount_install_with_cb")] + internal static extern ErrorCode PackageManagerRequestMountInstallWithCB(SafePackageManagerRequestHandle requestHandle, string path, PackageManagerRequestEventCallback callback, IntPtr userData, out int id); + [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_uninstall_with_cb")] internal static extern ErrorCode PackageManagerRequestUninstallWithCB(SafePackageManagerRequestHandle requestHandle, string name, PackageManagerRequestEventCallback callback, IntPtr userData, out int id); diff --git a/src/Tizen.Applications.PackageManager/Tizen.Applications/InstallationMode.cs b/src/Tizen.Applications.PackageManager/Tizen.Applications/InstallationMode.cs new file mode 100755 index 0000000..da643db --- /dev/null +++ b/src/Tizen.Applications.PackageManager/Tizen.Applications/InstallationMode.cs @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Tizen.Applications +{ + /// + /// Enumeration for installation mode. + /// + public enum InstallationMode + { + /// + /// Normal Mode. + /// + Normal, + /// + /// Mount Mode. + /// + Mount + } +} diff --git a/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageManager.cs b/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageManager.cs old mode 100644 new mode 100755 index 6b49900..1efd51f --- a/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageManager.cs +++ b/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageManager.cs @@ -55,6 +55,9 @@ namespace Tizen.Applications private static Dictionary RequestCallbacks = new Dictionary(); private static Dictionary RequestHandles = new Dictionary(); + private delegate Interop.PackageManager.ErrorCode InstallMethodWithCallback(SafePackageManagerRequestHandle requestHandle, string pkgPath, Interop.PackageManager.PackageManagerRequestEventCallback requestCallback, IntPtr userData, out int requestID); + private delegate Interop.PackageManager.ErrorCode InstallMethod(SafePackageManagerRequestHandle requestHandle, string pkgPath, out int requestID); + /// /// InstallProgressChanged event. This event is occurred when a package is getting installed and the progress of the request to the package manager changes. /// @@ -387,124 +390,131 @@ namespace Tizen.Applications /// To check the result of installation, the caller should check the progress using InstallProgressChanged event. /// /// http://tizen.org/privilege/packagemanager.admin - public static bool Install(string packagePath) + public static bool Install(string packagePath, InstallationMode installMode = InstallationMode.Normal) { - return Install(packagePath, null, PackageType.UNKNOWN, null); + return Install(packagePath, null, PackageType.UNKNOWN, null, installMode); } /// /// Installs package located at the given path /// /// Absolute path for the package to be installed - /// Optional - The event callback will be invoked only for the current request + /// The event callback will be invoked only for the current request + /// Optional parameter to indicate special installation mode /// Returns true if installtion request is successful, false otherwise. /// /// The 'true' means that just the request of installation is seccessful. /// To check the result of installation, the caller should check the progress using InstallProgressChanged event OR eventCallback. /// /// http://tizen.org/privilege/packagemanager.admin - public static bool Install(string packagePath, RequestEventCallback eventCallback) + public static bool Install(string packagePath, RequestEventCallback eventCallback, InstallationMode installMode = InstallationMode.Normal) { - return Install(packagePath, null, PackageType.UNKNOWN, eventCallback); + return Install(packagePath, null, PackageType.UNKNOWN, eventCallback, installMode); } /// /// Installs package located at the given path /// /// Absolute path for the package to be installed - /// Optional - Package type for the package to be installed + /// Package type for the package to be installed + /// Optional parameter to indicate special installation mode /// Returns true if installtion request is successful, false otherwise. /// /// The 'true' means that just the request of installation is seccessful. /// To check the result of installation, the caller should check the progress using InstallProgressChanged event. /// /// http://tizen.org/privilege/packagemanager.admin - public static bool Install(string packagePath, PackageType type) + public static bool Install(string packagePath, PackageType type, InstallationMode installMode = InstallationMode.Normal) { - return Install(packagePath, null, type, null); + return Install(packagePath, null, type, null, installMode); } /// /// Installs package located at the given path /// /// Absolute path for the package to be installed - /// Optional - Absolute path for the expansion package to be installed + /// Absolute path for the expansion package to be installed + /// Optional parameter to indicate special installation mode /// Returns true if installtion request is successful, false otherwise. /// /// The 'true' means that just the request of installation is seccessful. /// To check the result of installation, the caller should check the progress using InstallProgressChanged event. /// /// http://tizen.org/privilege/packagemanager.admin - public static bool Install(string packagePath, string expansionPackagePath) + public static bool Install(string packagePath, string expansionPackagePath, InstallationMode installMode = InstallationMode.Normal) { - return Install(packagePath, expansionPackagePath, PackageType.UNKNOWN, null); + return Install(packagePath, expansionPackagePath, PackageType.UNKNOWN, null, installMode); } /// /// Installs package located at the given path /// /// Absolute path for the package to be installed - /// Optional - Package type for the package to be installed - /// Optional - The event callback will be invoked only for the current request + /// Package type for the package to be installed + /// The event callback will be invoked only for the current request + /// Optional parameter to indicate special installation mode /// Returns true if installtion request is successful, false otherwise. /// /// The 'true' means that just the request of installation is seccessful. /// To check the result of installation, the caller should check the progress using InstallProgressChanged event OR eventCallback. /// /// http://tizen.org/privilege/packagemanager.admin - public static bool Install(string packagePath, PackageType type, RequestEventCallback eventCallback) + public static bool Install(string packagePath, PackageType type, RequestEventCallback eventCallback, InstallationMode installMode = InstallationMode.Normal) { - return Install(packagePath, null, type, eventCallback); + return Install(packagePath, null, type, eventCallback, installMode); } /// /// Installs package located at the given path /// /// Absolute path for the package to be installed - /// Optional - Absolute path for the expansion package to be installed - /// Optional - The event callback will be invoked only for the current request + /// Absolute path for the expansion package to be installed + /// The event callback will be invoked only for the current request + /// Optional parameter to indicate special installation mode /// Returns true if installtion request is successful, false otherwise. /// /// The 'true' means that just the request of installation is seccessful. /// To check the result of installation, the caller should check the progress using InstallProgressChanged event OR eventCallback. /// /// http://tizen.org/privilege/packagemanager.admin - public static bool Install(string packagePath, string expansionPackagePath, RequestEventCallback eventCallback) + public static bool Install(string packagePath, string expansionPackagePath, RequestEventCallback eventCallback, InstallationMode installMode = InstallationMode.Normal) { - return Install(packagePath, expansionPackagePath, PackageType.UNKNOWN, eventCallback); + return Install(packagePath, expansionPackagePath, PackageType.UNKNOWN, eventCallback, installMode); } /// /// Installs package located at the given path /// /// Absolute path for the package to be installed - /// Optional - Absolute path for the expansion package to be installed - /// Optional - Package type for the package to be installed + /// Absolute path for the expansion package to be installed + /// Package type for the package to be installed + /// Optional parameter to indicate special installation mode /// Returns true if installtion request is successful, false otherwise. /// /// The 'true' means that just the request of installation is seccessful. /// To check the result of installation, the caller should check the progress using InstallProgressChanged event. /// /// http://tizen.org/privilege/packagemanager.admin - public static bool Install(string packagePath, string expansionPackagePath, PackageType type) + public static bool Install(string packagePath, string expansionPackagePath, PackageType type, InstallationMode installMode = InstallationMode.Normal) { - return Install(packagePath, expansionPackagePath, type, null); + return Install(packagePath, expansionPackagePath, type, null, installMode); } /// /// Installs package located at the given path /// /// Absolute path for the package to be installed - /// Optional - Absolute path for the expansion package to be installed - /// Optional - Package type for the package to be installed - /// Optional - The event callback will be invoked only for the current request + /// Absolute path for the expansion package to be installed + /// Package type for the package to be installed + /// The event callback will be invoked only for the current request + /// Optional parameter to indicate special installation mode /// Returns true if installtion request is successful, false otherwise. /// /// The 'true' means that just the request of installation is seccessful. /// To check the result of installation, the caller should check the progress using InstallProgressChanged event OR eventCallback. /// /// http://tizen.org/privilege/packagemanager.admin - public static bool Install(string packagePath, string expansionPackagePath, PackageType type, RequestEventCallback eventCallback) + public static bool Install(string packagePath, string expansionPackagePath, PackageType type, RequestEventCallback eventCallback, InstallationMode installMode = InstallationMode.Normal) { SafePackageManagerRequestHandle RequestHandle; var err = Interop.PackageManager.PackageManagerRequestCreate(out RequestHandle); @@ -541,7 +551,16 @@ namespace Tizen.Applications int requestId; if (eventCallback != null) { - err = Interop.PackageManager.PackageManagerRequestInstallWithCB(RequestHandle, packagePath, internalRequestEventCallback, IntPtr.Zero, out requestId); + InstallMethodWithCallback install; + if (installMode == InstallationMode.Mount) + { + install = Interop.PackageManager.PackageManagerRequestMountInstallWithCB; + } + else + { + install = Interop.PackageManager.PackageManagerRequestInstallWithCB; + } + err = install(RequestHandle, packagePath, internalRequestEventCallback, IntPtr.Zero, out requestId); if (err == Interop.PackageManager.ErrorCode.None) { RequestCallbacks.Add(requestId, eventCallback); @@ -556,7 +575,16 @@ namespace Tizen.Applications } else { - err = Interop.PackageManager.PackageManagerRequestInstall(RequestHandle, packagePath, out requestId); + InstallMethod install; + if (installMode == InstallationMode.Mount) + { + install = Interop.PackageManager.PackageManagerRequestMountInstall; + } + else + { + install = Interop.PackageManager.PackageManagerRequestInstall; + } + err = install(RequestHandle, packagePath, out requestId); if (err != Interop.PackageManager.ErrorCode.None) { Log.Warn(LogTag, string.Format("Failed to install package {0}. err = {1}", packagePath, err));