Пример #1
0
        private void AddAndroidPermissions(string apkFilename, List <string> permissions)
        {
            if (permissions == null || permissions.Count < 1)
            {
                throw new ArgumentException("At least one permission must be specified to add.");
            }
            try
            {
                using (var apk = new ZipFileProvider(apkFilename, FileCacheMode.None, false, QuestomAssets.Utils.FileUtils.GetTempDirectory()))
                {
                    byte[]     manifest = apk.Read("AndroidManifest.xml");
                    AxmlWriter writer   = new WritePermissionAxmlWriter(permissions);
                    AxmlReader reader   = new AxmlReader(manifest);

                    reader.Accept(writer);
                    var outData = writer.ToByteArray();
                    apk.Write("AndroidManifest.xml", outData, true);
                    apk.Save();
                }
            }
            catch (Exception ex)
            {
                Log.LogErr("Exception trying to add permissions to AndroidManifest.xml", ex);
                throw;
            }
        }
Пример #2
0
 private void AddTagFileToApk(string apkFilename)
 {
     using (var apk = new ZipFileProvider(apkFilename, FileCacheMode.None, false, QuestomAssets.Utils.FileUtils.GetTempDirectory()))
     {
         if (apk.FileExists(MOD_TAG_FILE))
         {
             Log.LogMsg("APK file already had the mod's tag file.");
             return;
         }
         apk.Write(MOD_TAG_FILE, new byte[1], true, false);
         apk.Save();
     }
 }