Esempio n. 1
0
        /// <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));
        }
Esempio n. 2
0
        // This method assumes that pass handle is already validated
        internal static PackageSizeInformation GetPackageSizeInformation(IntPtr handle)
        {
            var pkgSizeInfo = new PackageSizeInformation();

            Interop.PackageManager.PackageSizeInfoGetDataSize(handle, out pkgSizeInfo._dataSize);
            Interop.PackageManager.PackageSizeInfoGetCacheSize(handle, out pkgSizeInfo._cacheSize);
            Interop.PackageManager.PackageSizeInfoGetAppSize(handle, out pkgSizeInfo._appSize);
            Interop.PackageManager.PackageSizeInfoGetExtDataSize(handle, out pkgSizeInfo._externalDataSize);
            Interop.PackageManager.PackageSizeInfoGetExtCacheSize(handle, out pkgSizeInfo._externalCacheSize);
            Interop.PackageManager.PackageSizeInfoGetExtAppSize(handle, out pkgSizeInfo._externalAppSize);
            return(pkgSizeInfo);
        }