/// <summary>
 /// Add all the entries from an existing <see cref="ExpansionZipFile"/>
 /// </summary>
 /// <param name="merge">
 /// The ExpansionZipFile to use.
 /// </param>
 public void MergeZipFile(ExpansionZipFile merge)
 {
     foreach (var entry in merge.files)
     {
         if (this.files.ContainsKey(entry.Key))
         {
             this.files[entry.Key] = entry.Value;
         }
         else
         {
             this.files.Add(entry.Key, entry.Value);
         }
     }
 }
        /// <summary>
        /// The init if necessary.
        /// </summary>
        private void InitIfNecessary()
        {
            if (!this.initialized)
            {
                Context        ctx      = this.Context;
                PackageManager pm       = ctx.PackageManager;
                ProviderInfo   pi       = pm.ResolveContentProvider(this.Authority, PackageInfoFlags.MetaData);
                PackageInfo    packInfo = null;

                try
                {
                    packInfo = pm.GetPackageInfo(ctx.PackageName, 0);
                }
                catch (PackageManager.NameNotFoundException e1)
                {
                    System.Console.WriteLine(e1.ToString());
                    System.Console.Write(e1.StackTrace);
                }

                if (packInfo != null)
                {
                    int patchFileVersion;
                    int mainFileVersion;
                    int appVersionCode = packInfo.VersionCode;
                    if (null != pi.MetaData)
                    {
                        mainFileVersion  = pi.MetaData.GetInt(MetaData.MainVersion, appVersionCode);
                        patchFileVersion = pi.MetaData.GetInt(MetaData.PatchVersion, appVersionCode);
                    }
                    else
                    {
                        mainFileVersion = patchFileVersion = appVersionCode;
                    }

                    try
                    {
                        this.apkExtensionFile = ApkExpansionSupport.GetApkExpansionZipFile(
                            ctx, mainFileVersion, patchFileVersion);

                        this.initialized = true;
                    }
                    catch (IOException e)
                    {
                        System.Console.WriteLine(e.ToString());
                        System.Console.Write(e.StackTrace);
                    }
                }
            }
        }
        /// <summary>
        /// The init if necessary.
        /// </summary>
        private void InitIfNecessary()
        {
            if (!this.initialized)
            {
                Context ctx = this.Context;
                PackageManager pm = ctx.PackageManager;
                ProviderInfo pi = pm.ResolveContentProvider(this.Authority, PackageInfoFlags.MetaData);
                PackageInfo packInfo = null;

                try
                {
                    packInfo = pm.GetPackageInfo(ctx.PackageName, 0);
                }
                catch (PackageManager.NameNotFoundException e1)
                {
                    Console.WriteLine(e1.ToString());
                    Console.Write(e1.StackTrace);
                }

                if (packInfo != null)
                {
                    int patchFileVersion;
                    int mainFileVersion;
                    int appVersionCode = packInfo.VersionCode;
                    if (null != pi.MetaData)
                    {
                        mainFileVersion = pi.MetaData.GetInt("mainVersion", appVersionCode);
                        patchFileVersion = pi.MetaData.GetInt("patchVersion", appVersionCode);
                    }
                    else
                    {
                        mainFileVersion = patchFileVersion = appVersionCode;
                    }

                    try
                    {
                        this.apkExtensionFile = ApkExpansionSupport.GetApkExpansionZipFile(
                            ctx, mainFileVersion, patchFileVersion);

                        this.initialized = true;
                    }
                    catch (IOException e)
                    {
                        Console.WriteLine(e.ToString());
                        Console.Write(e.StackTrace);
                    }
                }
            }
        }
 /// <summary>
 /// Add all the entries from an existing <see cref="ExpansionZipFile"/>
 /// </summary>
 /// <param name="merge">
 /// The ExpansionZipFile to use.
 /// </param>
 public void MergeZipFile(ExpansionZipFile merge)
 {
     foreach (var entry in merge.files)
     {
         if (this.files.ContainsKey(entry.Key))
         {
             this.files[entry.Key] = entry.Value;
         }
         else
         {
             this.files.Add(entry.Key, entry.Value);
         }
     }
 }
Exemple #5
0
            protected internal OBBAssetHelper(Context ctx, int mainVersion, int patchVersion)
                : base(ctx)
            {
                expansionZipFile = ApkExpansionSupport.GetApkExpansionZipFile(ctx, mainVersion, patchVersion);

                filePaths = new List<string>();
                foreach (var zipFileEntry in expansionZipFile.GetAllEntries())
                {
                    filePaths.Add(zipFileEntry.FilenameInZip);
                }
            }