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.
18 using System.Runtime.InteropServices;
19 using Tizen.Applications;
21 internal static partial class Interop
23 internal static partial class PackageManager
25 [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
26 internal delegate void PackageManagerEventCallback(string type, string packageId, EventType eventType, PackageEventState eventState, int progress, ErrorCode error, IntPtr userData);
28 [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
29 internal delegate bool PackageManagerPackageInfoCallback(IntPtr handle, IntPtr userData);
31 [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
32 internal delegate void PackageManagerSizeInfoCallback(string packageId, IntPtr sizeInfoHandle, IntPtr userData);
34 [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
35 internal delegate void PackageManagerTotalSizeInfoCallback(IntPtr sizeInfoHandle, IntPtr userData);
37 [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
38 internal delegate void PackageManagerRequestEventCallback(int requestId, string type, string packageId, EventType eventType, PackageEventState eventState, int progress, ErrorCode error, IntPtr userData);
40 // Any change here might require changes in Tizen.Applications.PackageManagerEventError enum
41 internal enum ErrorCode
43 None = Tizen.Internals.Errors.ErrorCode.None,
44 InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
45 OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
46 IoError = Tizen.Internals.Errors.ErrorCode.IoError,
47 NoSuchPackage = -0x01150000 | 0x71,
48 SystemError = -0x01150000 | 0x72,
49 PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied
52 // Any change here might require changes in Tizen.Applications.PackageEventState enum
53 internal enum PackageEventState
62 internal enum EventStatus
73 internal enum EventType
82 internal enum CertCompareResultType
91 internal enum PackageManagerPermissionType
98 // Any change here might require changes in Tizen.Applications.StorageType enum
99 internal enum StorageType
105 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_create")]
106 internal static extern ErrorCode PackageManagerCreate(out SafePackageManagerHandle managerHandle);
108 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_destroy")]
109 internal static extern ErrorCode PackageManagerDestroy(IntPtr managerHandle);
111 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_set_event_status")]
112 internal static extern ErrorCode PackageManagerSetEvenStatus(SafePackageManagerHandle managerHandle, EventStatus eventStatus);
114 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_set_event_cb")]
115 internal static extern ErrorCode PackageManagerSetEvent(SafePackageManagerHandle managerHandle, PackageManagerEventCallback callback, IntPtr userData);
117 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_unset_event_cb")]
118 internal static extern ErrorCode PackageManagerUnsetEvent(SafePackageManagerHandle managerHandle);
120 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_foreach_package_info")]
121 internal static extern ErrorCode PackageManagerForeachPackageInfo(PackageManagerPackageInfoCallback callback, IntPtr userData);
123 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_get_package_size_info")]
124 internal static extern ErrorCode PackageManagerGetSizeInfo(string packageId, PackageManagerSizeInfoCallback callback, IntPtr userData);
126 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_get_total_package_size_info")]
127 internal static extern ErrorCode PackageManagerGetTotalSizeInfo(PackageManagerTotalSizeInfoCallback callback, IntPtr userData);
129 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_get_package_id_by_app_id")]
130 internal static extern ErrorCode PackageManageGetPackageIdByAppId(string app_id, out string package_id);
132 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_get_package_info")]
133 internal static extern ErrorCode PackageManagerGetPackageInfo(string packageId, out IntPtr packageInfoHandle);
135 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_clear_cache_dir")]
136 internal static extern ErrorCode PackageManagerClearCacheDir(string packageId);
138 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_clear_all_cache_dir")]
139 internal static extern ErrorCode PackageManagerClearAllCacheDir();
141 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_clear_data_dir")]
142 internal static extern ErrorCode PackageManagerClearDataDir(string packageId);
144 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_filter_create")]
145 internal static extern ErrorCode PackageManagerFilterCreate(out IntPtr handle);
147 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_filter_destroy")]
148 internal static extern ErrorCode PackageManagerFilterDestroy(IntPtr handle);
150 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_filter_add_bool")]
151 internal static extern ErrorCode PackageManagerFilterAdd(IntPtr handle, string property, bool value);
153 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_filter_foreach_package_info")]
154 internal static extern ErrorCode PackageManagerFilterForeachPackageInfo(IntPtr handle, PackageManagerPackageInfoCallback callback, IntPtr userData);
156 [DllImport(Libraries.PackageManager, EntryPoint = "package_size_info_get_data_size")]
157 internal static extern ErrorCode PackageSizeInfoGetDataSize(IntPtr handle, out long dataSize);
159 [DllImport(Libraries.PackageManager, EntryPoint = "package_size_info_get_cache_size")]
160 internal static extern ErrorCode PackageSizeInfoGetCacheSize(IntPtr handle, out long cacheSize);
162 [DllImport(Libraries.PackageManager, EntryPoint = "package_size_info_get_app_size")]
163 internal static extern ErrorCode PackageSizeInfoGetAppSize(IntPtr handle, out long appSize);
165 [DllImport(Libraries.PackageManager, EntryPoint = "package_size_info_get_external_data_size")]
166 internal static extern ErrorCode PackageSizeInfoGetExtDataSize(IntPtr handle, out long extDataSize);
168 [DllImport(Libraries.PackageManager, EntryPoint = "package_size_info_get_external_cache_size")]
169 internal static extern ErrorCode PackageSizeInfoGetExtCacheSize(IntPtr handle, out long extCacheSize);
171 [DllImport(Libraries.PackageManager, EntryPoint = "package_size_info_get_external_app_size")]
172 internal static extern ErrorCode PackageSizeInfoGetExtAppSize(IntPtr handle, out long extAppSize);
174 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_create")]
175 internal static extern ErrorCode PackageManagerRequestCreate(out SafePackageManagerRequestHandle requestHandle);
177 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_destroy")]
178 internal static extern ErrorCode PackageManagerRequestDestroy(IntPtr requestHandle);
180 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_set_type")]
181 internal static extern ErrorCode PackageManagerRequestSetType(SafePackageManagerRequestHandle requestHandle, string type);
183 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_set_tep")]
184 internal static extern ErrorCode PackageManagerRequestSetTepPath(SafePackageManagerRequestHandle requestHandle, string tepPath);
186 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_install")]
187 internal static extern ErrorCode PackageManagerRequestInstall(SafePackageManagerRequestHandle requestHandle, string path, out int id);
189 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_mount_install")]
190 internal static extern ErrorCode PackageManagerRequestMountInstall(SafePackageManagerRequestHandle requestHandle, string path, out int id);
192 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_uninstall")]
193 internal static extern ErrorCode PackageManagerRequestUninstall(SafePackageManagerRequestHandle requestHandle, string name, out int id);
195 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_move")]
196 internal static extern ErrorCode PackageManagerRequestMove(SafePackageManagerRequestHandle requestHandle, string name, StorageType moveToStorageType);
198 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_compare_package_cert_info")]
199 internal static extern ErrorCode PackageManagerCompareCertInfo(string lhsPackageId, string rhsPackageId, out CertCompareResultType CompareResult);
201 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_compare_app_cert_info")]
202 internal static extern ErrorCode PackageManagerCompareCertInfoByApplicationId(string lhsPackageId, string rhsPackageId, out CertCompareResultType CompareResult);
204 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_is_preload_package_by_app_id")]
205 internal static extern ErrorCode PackageManagerIsPreloadPackageByApplicationId(string ApplicationId, out bool IsPreload);
207 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_get_permission_type")]
208 internal static extern ErrorCode PackageManagerGetPermissionType(string ApplicationId, out PackageManagerPermissionType PermissionType);
210 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_drm_generate_license_request")]
211 internal static extern ErrorCode PackageManagerDrmGenerateLicenseRequest(string responseData, out string requestData, out string licenseUrl);
213 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_drm_register_license")]
214 internal static extern ErrorCode PackageManagerDrmRegisterLicense(string responseData);
216 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_drm_decrypt_package")]
217 internal static extern ErrorCode PackageManagerDrmDecryptPackage(string drmFilePath, string decryptedFilePath);
219 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_install_with_cb")]
220 internal static extern ErrorCode PackageManagerRequestInstallWithCB(SafePackageManagerRequestHandle requestHandle, string path, PackageManagerRequestEventCallback callback, IntPtr userData, out int id);
222 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_mount_install_with_cb")]
223 internal static extern ErrorCode PackageManagerRequestMountInstallWithCB(SafePackageManagerRequestHandle requestHandle, string path, PackageManagerRequestEventCallback callback, IntPtr userData, out int id);
225 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_uninstall_with_cb")]
226 internal static extern ErrorCode PackageManagerRequestUninstallWithCB(SafePackageManagerRequestHandle requestHandle, string name, PackageManagerRequestEventCallback callback, IntPtr userData, out int id);
228 [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_move_with_cb")]
229 internal static extern ErrorCode PackageManagerRequestMoveWithCB(SafePackageManagerRequestHandle requestHandle, string name, StorageType moveToStorageType, PackageManagerRequestEventCallback callback, IntPtr userData, out int id);