コード例 #1
0
 public BackupFileInfo()
 {
     version = BackupFileVersion.Version1;
     magic = "ANDROID BACKUP";
     compressed = true;
     algorithm = "none";
     encrytedInformation = new BackupFileEncryptedInformation();
 }
コード例 #2
0
        /// <summary>
        /// Packs the .ab file from the given .tar file
        /// </summary>
        /// <param name="sourceTarFile">The tar file to pack</param>
        /// <param name="targetAbFile">The target ab file</param>
        /// <param name="version">The version of the .ab file. Use <see cref="BackupFileVersion.Version2"/> for Android 4.4.3 or higher</param>
        /// <param name="password">The password used</param>
        /// <returns>True if the process was successful</returns>
        public static bool PackFromTarFile(string sourceTarFile, string targetAbFile, BackupFileVersion version = BackupFileVersion.Version1, string password = "")
        {
            try
            {
                Java.Update();
                string output = Java.RunJarWithOutput(ResourceManager.abePath, new string[] { "-debug", version == BackupFileVersion.Version1 ? "pack" : "pack-kk", "\"" + sourceTarFile + "\"", "\"" + targetAbFile + "\"", password });

                return output.Contains("bytes written to") && System.IO.File.Exists(targetAbFile) && new FileInfo(targetAbFile).Length > 0;
            }
            catch (Exception)
            {
                return false;
            }
        }
コード例 #3
0
        /// <summary>
        /// Packs the .ab file from the given .tar file
        /// </summary>
        /// <param name="sourceTarFile">The tar file to pack</param>
        /// <param name="targetAbFile">The target ab file</param>
        /// <param name="version">The version of the .ab file. Use <see cref="BackupFileVersion.Version2"/> for Android 4.4.3 or higher</param>
        /// <param name="password">The password used</param>
        /// <returns>True if the process was successful</returns>
        public static bool PackFromTarFile(string sourceTarFile, string targetAbFile, BackupFileVersion version = BackupFileVersion.Version1, string password = "")
        {
            try
            {
                Java.Update();
                string output = Java.RunJarWithOutput(ResourceManager.abePath, new string[] { "-debug", version == BackupFileVersion.Version1 ? "pack" : "pack-kk", "\"" + sourceTarFile + "\"", "\"" + targetAbFile + "\"", password });

                return(output.Contains("bytes written to") && System.IO.File.Exists(targetAbFile) && new FileInfo(targetAbFile).Length > 0);
            }
            catch (Exception)
            {
                return(false);
            }
        }