/// <summary> /// Gets the package size information. /// </summary> /// <returns>Package size information.</returns> /// <privilege>http://tizen.org/privilege/packagemanager.info</privilege> /// <since_tizen> 3 </since_tizen> public async Task <PackageSizeInformation> GetSizeInformationAsync() { TaskCompletionSource <PackageSizeInformation> tcs = new TaskCompletionSource <PackageSizeInformation>(); Interop.PackageManager.PackageManagerSizeInfoCallback sizeInfoCb = (pkgId, sizeInfoHandle, userData) => { if (sizeInfoHandle != IntPtr.Zero && Id == pkgId) { var pkgSizeInfo = PackageSizeInformation.GetPackageSizeInformation(sizeInfoHandle); tcs.TrySetResult(pkgSizeInfo); } lock (_packageManagerSizeInfoCallbackDict) { _packageManagerSizeInfoCallbackDict.Remove(userData); } }; IntPtr callbackId; lock (_packageManagerSizeInfoCallbackDict) { callbackId = (IntPtr)_callbackId++; _packageManagerSizeInfoCallbackDict[callbackId] = sizeInfoCb; } Interop.PackageManager.ErrorCode err = Interop.PackageManager.PackageManagerGetSizeInfo(Id, sizeInfoCb, callbackId); if (err != Interop.PackageManager.ErrorCode.None) { tcs.TrySetException(PackageManagerErrorFactory.GetException(err, "Failed to get total package size info of " + Id)); } return(await tcs.Task.ConfigureAwait(false)); }
internal static PackageType ToPackageType(string type) { if (string.IsNullOrEmpty(type)) { throw PackageManagerErrorFactory.GetException(Interop.PackageManager.ErrorCode.InvalidParameter, "type can't be null or empty"); } string lowerType = type.ToLower(); if (lowerType == "tpk") { return(PackageType.TPK); } else if (lowerType == "wgt") { return(PackageType.WGT); } else if (lowerType == "rpm") { return(PackageType.RPM); } else { throw PackageManagerErrorFactory.GetException(Interop.PackageManager.ErrorCode.InvalidParameter, "type should be tpk or wgt"); } }
internal static Package GetPackage(IntPtr packageInfoHandle) { String packageId; Interop.PackageManager.ErrorCode err = Interop.Package.PackageInfoGetPackage(packageInfoHandle, out packageId); if (err != Interop.PackageManager.ErrorCode.None) { throw PackageManagerErrorFactory.GetException(err, "Failed to get package id for given package handle."); } return(CreatePackage(packageInfoHandle, packageId)); }
/// <summary> /// Compares the certificate information with the given package ID. /// </summary> /// <param name="packageId">ID of the package.</param> /// <returns>Certificate comparison result.</returns> /// <exception cref="ArgumentException">Thrown when a failed input package ID is invalid.</exception> /// <exception cref="System.IO.IOException">Thrown when the method failed due to an internal I/O error.</exception> /// <since_tizen> 3 </since_tizen> public CertCompareResultType CompareCertInfo(string packageId) { Interop.PackageManager.CertCompareResultType compareResult; Interop.PackageManager.ErrorCode err = Interop.PackageManager.PackageManagerCompareCertInfo(Id, packageId, out compareResult); if (err != Interop.PackageManager.ErrorCode.None) { throw PackageManagerErrorFactory.GetException(err, "Failed to compare package cert info"); } return((CertCompareResultType)compareResult); }
internal static PackageDrm GenerateLicenseRequest(string responseData) { string requestData; string licenseUrl; Interop.PackageManager.ErrorCode err = Interop.PackageManager.PackageManagerDrmGenerateLicenseRequest(responseData, out requestData, out licenseUrl); if (err != Interop.PackageManager.ErrorCode.None) { throw PackageManagerErrorFactory.GetException(err, "Failed to generate license request"); } PackageDrm packageDrm = CreateDrmRequest(responseData, requestData, licenseUrl); return(packageDrm); }
internal static Package GetPackage(string packageId) { IntPtr packageInfoHandle; Interop.PackageManager.ErrorCode err = Interop.Package.PackageInfoCreate(packageId, out packageInfoHandle); if (err != Interop.PackageManager.ErrorCode.None) { throw PackageManagerErrorFactory.GetException(err, string.Format("Failed to create native handle for package info of {0}", packageId)); } Package package = CreatePackage(packageInfoHandle, packageId); err = Interop.Package.PackageInfoDestroy(packageInfoHandle); if (err != Interop.PackageManager.ErrorCode.None) { Log.Warn(LogTag, string.Format("Failed to destroy native handle for package info of {0}. err = {1}", packageId, err)); } return(package); }