Exemple #1
0
 private void SetPermissionAttributes(PostProcessorContext context, AndroidManifest manifestXML, AssemblyReferenceChecker checker)
 {
     if ((this._developmentPlayer || PlayerSettings.Android.forceInternetPermission) || this.doesReferenceNetworkClasses(checker))
     {
         manifestXML.AddUsesPermission("android.permission.INTERNET");
     }
     if (checker.HasReferenceToMethod("UnityEngine.Handheld::Vibrate"))
     {
         manifestXML.AddUsesPermission("android.permission.VIBRATE");
     }
     if (checker.HasReferenceToMethod("UnityEngine.iPhoneSettings::get_internetReachability") || checker.HasReferenceToMethod("UnityEngine.Application::get_internetReachability"))
     {
         manifestXML.AddUsesPermission("android.permission.ACCESS_NETWORK_STATE");
     }
     if (((checker.HasReferenceToMethod("UnityEngine.Input::get_location") || checker.HasReferenceToMethod("UnityEngine.iPhoneInput::get_lastLocation")) || (checker.HasReferenceToMethod("UnityEngine.iPhoneSettings::get_locationServiceStatus") || checker.HasReferenceToMethod("UnityEngine.iPhoneSettings::get_locationServiceEnabledByUser"))) || (checker.HasReferenceToMethod("UnityEngine.iPhoneSettings::StartLocationServiceUpdates") || checker.HasReferenceToMethod("UnityEngine.iPhoneSettings::StopLocationServiceUpdates")))
     {
         manifestXML.AddUsesPermission("android.permission.ACCESS_FINE_LOCATION");
         manifestXML.AddUsesFeature("android.hardware.location.gps", false);
         manifestXML.AddUsesFeature("android.hardware.location", false);
     }
     if (checker.HasReferenceToType("UnityEngine.WebCamTexture"))
     {
         manifestXML.AddUsesPermission("android.permission.CAMERA");
         manifestXML.AddUsesFeature("android.hardware.camera", false);
         manifestXML.AddUsesFeature("android.hardware.camera.autofocus", false);
         manifestXML.AddUsesFeature("android.hardware.camera.front", false);
     }
     if (checker.HasReferenceToType("UnityEngine.Microphone"))
     {
         manifestXML.AddUsesPermission("android.permission.RECORD_AUDIO");
         manifestXML.AddUsesFeature("android.hardware.microphone", false);
     }
     if (PlayerSettings.Android.forceSDCardPermission)
     {
         manifestXML.AddUsesPermission("android.permission.WRITE_EXTERNAL_STORAGE");
     }
     else if (this._developmentPlayer)
     {
         manifestXML.AddUsesPermission("android.permission.WRITE_EXTERNAL_STORAGE", 0x12);
         manifestXML.AddUsesPermission("android.permission.READ_EXTERNAL_STORAGE", 0x12);
     }
     if ((checker.HasReferenceToMethod("UnityEngine.Input::get_acceleration") || checker.HasReferenceToMethod("UnityEngine.Input::GetAccelerationEvent")) || (checker.HasReferenceToMethod("UnityEngine.Input::get_accelerationEvents") || checker.HasReferenceToMethod("UnityEngine.Input::get_accelerationEventCount")))
     {
         manifestXML.AddUsesFeature("android.hardware.sensor.accelerometer", false);
     }
     manifestXML.AddUsesFeature("android.hardware.touchscreen", false);
     if (((checker.HasReferenceToMethod("UnityEngine.Input::get_touches") || checker.HasReferenceToMethod("UnityEngine.Input::GetTouch")) || (checker.HasReferenceToMethod("UnityEngine.Input::get_touchCount") || checker.HasReferenceToMethod("UnityEngine.Input::get_multiTouchEnabled"))) || (((checker.HasReferenceToMethod("UnityEngine.Input::set_multiTouchEnabled") || checker.HasReferenceToMethod("UnityEngine.iPhoneInput::get_touches")) || (checker.HasReferenceToMethod("UnityEngine.iPhoneInput::GetTouch") || checker.HasReferenceToMethod("UnityEngine.iPhoneInput::get_touchCount"))) || (checker.HasReferenceToMethod("UnityEngine.iPhoneInput::get_multiTouchEnabled") || checker.HasReferenceToMethod("UnityEngine.iPhoneInput::set_multiTouchEnabled"))))
     {
         manifestXML.AddUsesFeature("android.hardware.touchscreen.multitouch", false);
         manifestXML.AddUsesFeature("android.hardware.touchscreen.multitouch.distinct", false);
     }
     if ((checker.HasReferenceToMethod("UnityEngine.iPhoneInput::get_acceleration") || checker.HasReferenceToMethod("UnityEngine.iPhoneInput::GetAccelerationEvent")) || (checker.HasReferenceToMethod("UnityEngine.iPhoneInput::get_accelerationEvents") || checker.HasReferenceToMethod("UnityEngine.iPhoneInput::get_accelerationEventCount")))
     {
         manifestXML.AddUsesFeature("android.hardware.sensor.accelerometer", false);
     }
     if (checker.HasReferenceToMethod("UnityEngine.iPhoneUtils::Vibrate"))
     {
         manifestXML.AddUsesPermission("android.permission.VIBRATE");
     }
 }
Exemple #2
0
        public void Execute(PostProcessorContext context)
        {
            if (this.OnProgress != null)
            {
                this.OnProgress(this, "Copying unity libraries");
            }
            this._stagingArea   = context.Get <string>("StagingArea");
            this._playerPackage = context.Get <string>("PlayerPackage");
            AndroidTargetDevice device = context.Get <AndroidTargetDevice>("TargetDevice");

            switch (device)
            {
            case AndroidTargetDevice.FAT:
            case AndroidTargetDevice.ARMv7:
                this.PrepareNativeUnityLibs(context, "armeabi-v7a");
                break;
            }
            if ((device == AndroidTargetDevice.FAT) || (device == AndroidTargetDevice.x86))
            {
                this.PrepareNativeUnityLibs(context, "x86");
            }
            string[] components = new string[] { this._playerPackage, "Apk", "assets" };
            FileUtil.CopyDirectoryRecursive(Paths.Combine(components), Path.Combine(this._stagingArea, "assets"), true);
            string[] textArray2 = new string[] { this._playerPackage, "Apk", "res" };
            FileUtil.CopyDirectoryRecursive(Paths.Combine(textArray2), Path.Combine(this._stagingArea, "res"), true);
        }
 public void Execute(PostProcessorContext context)
 {
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Processing native plugins");
     }
     this._stagingArea = context.Get<string>("StagingArea");
     string str = context.Get<string>("TargetLibrariesFolder");
     context.Set<bool>("HasJarPlugins", false);
     this._pluginsFolder = Path.Combine(this._stagingArea, "plugins");
     Directory.CreateDirectory(this._pluginsFolder);
     this._aarFolder = Path.Combine(this._stagingArea, "aar");
     Directory.CreateDirectory(this._aarFolder);
     BuildTarget target = context.Get<BuildTarget>("BuildTarget");
     foreach (PluginDesc desc in PluginImporter.GetExtensionPlugins(target))
     {
         string pluginTargetCPU = desc.architecture.ToString();
         this.ProcessPlugin(context, desc.pluginPath, pluginTargetCPU);
     }
     foreach (PluginImporter importer in PluginImporter.GetImporters(target))
     {
         string assetPath = importer.assetPath;
         if (Directory.Exists(assetPath) && AndroidLibraries.IsAndroidLibraryProject(assetPath))
         {
             FileUtil.CopyDirectoryRecursiveForPostprocess(assetPath, Path.Combine(str, Path.GetFileName(assetPath)), true);
         }
         this.UpgradePluginCPU(importer, target);
         string platformData = importer.GetPlatformData(target, "CPU");
         this.ProcessPlugin(context, assetPath, platformData);
     }
 }
        public void Execute(PostProcessorContext context)
        {
            if (this.OnProgress != null)
            {
                this.OnProgress(this, "Setting up target contents directory");
            }
            string      str    = context.Get <string>("StagingArea");
            BuildTarget target = context.Get <BuildTarget>("BuildTarget");
            string      dir    = Path.Combine(str, "android-libraries");

            FileUtil.CreateOrCleanDirectory(dir);
            context.Set <string>("TargetLibrariesFolder", dir);
            Directory.CreateDirectory(Path.Combine(str, "bin"));
            bool useAPKExpansionFiles = PlayerSettings.Android.useAPKExpansionFiles;

            context.Set <bool>("UseObb", useAPKExpansionFiles);
            context.Set <int>("GearVRMinSdkVersion", 0x13);
            string path = Path.Combine(BuildPipeline.GetBuildToolsDirectory(target), "fastzip");

            if (!File.Exists(path))
            {
                path = Path.Combine(BuildPipeline.GetBuildToolsDirectory(target), "fastzip.exe");
            }
            context.Set <string>("FastzipExe", path);
            bool flag2 = File.Exists(path);

            context.Set <bool>("UseFastzip", flag2);
            if (PlayerSettings.Android.androidTVCompatibility && !this.IsOrientationAndroidTVCompatible())
            {
                Debug.LogWarning("The orientation specified is not compatible with Android TV.\nPlease select Landscape or AutoRotation with Landscape enabled orientation, or disable Android TV compatibility in Player Settings.");
            }
        }
        public void Execute(PostProcessorContext context)
        {
            if (this.OnProgress != null)
            {
                this.OnProgress(this, "Processing native plugins");
            }
            this._stagingArea = context.Get <string>("StagingArea");
            string str = context.Get <string>("TargetLibrariesFolder");

            context.Set <bool>("HasJarPlugins", false);
            this._pluginsFolder = Path.Combine(this._stagingArea, "plugins");
            Directory.CreateDirectory(this._pluginsFolder);
            this._aarFolder = Path.Combine(this._stagingArea, "aar");
            Directory.CreateDirectory(this._aarFolder);
            BuildTarget target = context.Get <BuildTarget>("BuildTarget");

            foreach (PluginDesc desc in PluginImporter.GetExtensionPlugins(target))
            {
                string pluginTargetCPU = desc.architecture.ToString();
                this.ProcessPlugin(context, desc.pluginPath, pluginTargetCPU);
            }
            foreach (PluginImporter importer in PluginImporter.GetImporters(target))
            {
                string assetPath = importer.assetPath;
                if (Directory.Exists(assetPath) && AndroidLibraries.IsAndroidLibraryProject(assetPath))
                {
                    FileUtil.CopyDirectoryRecursiveForPostprocess(assetPath, Path.Combine(str, Path.GetFileName(assetPath)), true);
                }
                this.UpgradePluginCPU(importer, target);
                string platformData = importer.GetPlatformData(target, "CPU");
                this.ProcessPlugin(context, assetPath, platformData);
            }
        }
        private void PrepareNonStreamingAssetsForObb(PostProcessorContext context)
        {
            string str = context.Get <string>("StagingArea");

            string[] components = new string[] { str, "assets", "bin" };
            string   path       = Paths.Combine(components);

            FileUtil.CopyDirectoryRecursive(Path.Combine(str, "assets"), Path.Combine(str, "obbassets"));
            string[] textArray2 = new string[] { str, "obbassets", "bin" };
            string   str3       = Paths.Combine(textArray2);

            foreach (string str4 in Directory.GetFiles(str3, "*", SearchOption.AllDirectories))
            {
                if (Regex.IsMatch(str4.Substring(str3.Length + 1).Replace(@"\", "/"), @"^(?:Data/mainData|Data/sharedassets0\.assets(?:\.res[GS]?)?(?:\.split\w+)?|Data/sharedassets0\.resource(?:\.res[GS]?)?(?:\.split\w+)?|Data/level0(?:\.res[GS]?)?(?:\.split\w+)?|Data/globalgamemanagers(?:\.assets)?(?:\.split\w+)?|Data/unity default resources|Data/Resources/unity_builtin_extra|Data/PlayerConnectionConfigFile|Data/Managed/.+\.dll(?:\.mdb)?|Data/.+\.resS)$"))
                {
                    FileUtil.DeleteFileOrDirectory(str4);
                }
            }
            foreach (string str5 in Directory.GetFiles(path, "*", SearchOption.AllDirectories))
            {
                if (!Regex.IsMatch(str5.Substring(path.Length + 1).Replace(@"\", "/"), @"^(?:Data/mainData|Data/sharedassets0\.assets(?:\.res[GS]?)?(?:\.split\w+)?|Data/sharedassets0\.resource(?:\.res[GS]?)?(?:\.split\w+)?|Data/level0(?:\.res[GS]?)?(?:\.split\w+)?|Data/globalgamemanagers(?:\.assets)?(?:\.split\w+)?|Data/unity default resources|Data/Resources/unity_builtin_extra|Data/PlayerConnectionConfigFile|Data/Managed/.+\.dll(?:\.mdb)?|Data/.+\.resS)$"))
                {
                    FileUtil.DeleteFileOrDirectory(str5);
                }
            }
        }
 public void RunAllTasks(PostProcessorContext context)
 {
     int count = this._tasks.Count;
     int num2 = 1;
     try
     {
         foreach (IPostProcessorTask task in this._tasks)
         {
             this._progressValue = ((float) num2++) / ((float) count);
             task.Execute(context);
         }
     }
     catch (CommandInvokationFailure failure)
     {
         foreach (string str in failure.Errors)
         {
             Debug.LogError(str + "\n");
         }
         CancelPostProcess.AbortBuild("Build failure", failure.HighLevelMessage + CancelPostProcess.ConsoleMessage, failure);
     }
     catch (ProcessAbortedException exception)
     {
         Debug.LogWarning("Build process aborted (" + exception.Message + ")\n");
     }
 }
 public void Execute(PostProcessorContext context)
 {
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Copying unity libraries");
     }
     this._stagingArea = context.Get<string>("StagingArea");
     this._playerPackage = context.Get<string>("PlayerPackage");
     AndroidTargetDevice device = context.Get<AndroidTargetDevice>("TargetDevice");
     switch (device)
     {
         case AndroidTargetDevice.FAT:
         case AndroidTargetDevice.ARMv7:
             this.PrepareNativeUnityLibs(context, "armeabi-v7a");
             break;
     }
     if ((device == AndroidTargetDevice.FAT) || (device == AndroidTargetDevice.x86))
     {
         this.PrepareNativeUnityLibs(context, "x86");
     }
     string[] components = new string[] { this._playerPackage, "Apk", "assets" };
     FileUtil.CopyDirectoryRecursive(Paths.Combine(components), Path.Combine(this._stagingArea, "assets"), true);
     string[] textArray2 = new string[] { this._playerPackage, "Apk", "res" };
     FileUtil.CopyDirectoryRecursive(Paths.Combine(textArray2), Path.Combine(this._stagingArea, "res"), true);
 }
 private void MoveFinalAndroidPackage(PostProcessorContext context)
 {
     string path = context.Get<string>("InstallPath");
     if (Directory.Exists(path))
     {
         try
         {
             Directory.Delete(path);
         }
         catch (IOException)
         {
             CancelPostProcess.AbortBuild("Unable to create new apk!", string.Format("Unable to write target apk because {0} is a non-empty directory", path));
         }
     }
     else
     {
         File.Delete(path);
         if (File.Exists(path))
         {
             CancelPostProcess.AbortBuild("Unable to delete old apk!", string.Format("Target apk could not be overwritten: {0}", path));
         }
     }
     FileUtil.MoveFileOrDirectory(Path.Combine(this._stagingArea, "Package.apk"), path);
     if (!File.Exists(path))
     {
         CancelPostProcess.AbortBuild("Unable to create new apk!", string.Format("Unable to move file '{0}' -> '{1}", Path.Combine(this._stagingArea, "Package.apk"), path));
     }
     if (this._useObb && File.Exists(Path.Combine(this._stagingArea, "main.obb")))
     {
         string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path);
         string str3 = Path.Combine(Path.GetDirectoryName(path), string.Format("{0}.main.obb", fileNameWithoutExtension));
         FileUtil.DeleteFileOrDirectory(str3);
         FileUtil.MoveFileOrDirectory(Path.Combine(this._stagingArea, "main.obb"), str3);
     }
 }
 private void PrepareNativePlugin(PostProcessorContext context, string assetPath, string pluginTargetCPU)
 {
     string[] textArray1;
     string str;
     AndroidTargetDevice device = context.Get<AndroidTargetDevice>("TargetDevice");
     if ((device == AndroidTargetDevice.FAT) || device.ToString().Equals(pluginTargetCPU))
     {
         str = "";
         if (pluginTargetCPU != null)
         {
             if (pluginTargetCPU != "ARMv7")
             {
                 if (pluginTargetCPU == "x86")
                 {
                     str = "x86";
                     goto Label_0088;
                 }
             }
             else
             {
                 str = "armeabi-v7a";
                 goto Label_0088;
             }
         }
         Debug.LogWarning(string.Format("Unknown cpu architecture for .so library ({0})", assetPath));
     }
     return;
 Label_0088:
     textArray1 = new string[] { this._stagingArea, "libs", str };
     string path = Paths.Combine(textArray1);
     Directory.CreateDirectory(path);
     FileUtil.UnityFileCopy(assetPath, Path.Combine(path, Path.GetFileName(assetPath)));
 }
Exemple #11
0
        public void Execute(PostProcessorContext context)
        {
            this._developmentPlayer = context.Get <bool>("DevelopmentPlayer");
            this._stagingArea       = context.Get <string>("StagingArea");
            if (this.OnProgress != null)
            {
                this.OnProgress(this, "Merging AndroidManifest.xml files");
            }
            string manifest = this.CopyMainManifest(context, Path.Combine(this._stagingArea, "AndroidManifest-main.xml"));

            this.InjectBundleAndSDKVersion(context, manifest);
            string str2 = this.MergeManifests(context, Path.Combine(this._stagingArea, "AndroidManifest.xml"), manifest);

            context.Set <string>("ManifestName", str2);
            if (this.OnProgress != null)
            {
                this.OnProgress(this, "Patching manifest");
            }
            string str3 = this.PatchManifest(context, str2);

            context.Set <string>("PackageName", str3);
            if (new AndroidManifest(str2).GetActivityWithLaunchIntent().Length == 0)
            {
                Debug.LogWarning("No activity found in the manifest with action MAIN and category LAUNCHER.\nYour application may not start correctly.");
            }
            this.ThrowIfInvalid(str3);
        }
 public static string GetVariationsDirectory(PostProcessorContext context)
 {
     ScriptingImplementation implementation = context.Get<ScriptingImplementation>("ScriptingBackend");
     string str = context.Get<string>("PlayerPackage");
     bool flag = context.Get<bool>("DevelopmentPlayer");
     string[] components = new string[] { str, "Variations", (implementation != ScriptingImplementation.IL2CPP) ? "mono" : "il2cpp", !flag ? "Release" : "Development" };
     return Paths.Combine(components);
 }
 private void CheckUnityLibraryForArchitecture(PostProcessorContext context, string arch)
 {
     string[] components = new string[] { TasksCommon.GetVariationsDirectory(context), "Libs", arch, "libunity.so" };
     string path = Paths.Combine(components);
     if (!File.Exists(path))
     {
         CancelPostProcess.AbortBuild("Unable to package apk", "Unity library missing for the selected architecture '" + arch + " (" + path + ") !");
     }
 }
        public static string GetVariationsDirectory(PostProcessorContext context)
        {
            ScriptingImplementation implementation = context.Get <ScriptingImplementation>("ScriptingBackend");
            string str  = context.Get <string>("PlayerPackage");
            bool   flag = context.Get <bool>("DevelopmentPlayer");

            string[] components = new string[] { str, "Variations", (implementation != ScriptingImplementation.IL2CPP) ? "mono" : "il2cpp", !flag ? "Release" : "Development" };
            return(Paths.Combine(components));
        }
Exemple #15
0
 public void Execute(PostProcessorContext context)
 {
     bool flag = context.Get<bool>("UseFastzip");
     bool flag2 = context.Get<bool>("ExportAndroidProject");
     if (flag && !flag2)
     {
         this.CreatePackagesWithFastzip(context);
     }
 }
        private void CheckUnityLibraryForArchitecture(PostProcessorContext context, string arch)
        {
            string[] components = new string[] { TasksCommon.GetVariationsDirectory(context), "Libs", arch, "libunity.so" };
            string   path       = Paths.Combine(components);

            if (!File.Exists(path))
            {
                CancelPostProcess.AbortBuild("Unable to package apk", "Unity library missing for the selected architecture '" + arch + " (" + path + ") !", null);
            }
        }
Exemple #17
0
        public void Execute(PostProcessorContext context)
        {
            bool flag  = context.Get <bool>("UseFastzip");
            bool flag2 = context.Get <bool>("ExportAndroidProject");

            if (flag && !flag2)
            {
                this.CreatePackagesWithFastzip(context);
            }
        }
 private void GenerateAndroidLibraryWithResources(PostProcessorContext context, string sourceDir, string targetDir)
 {
     int num = context.Get<int>("TargetSDKVersion");
     Directory.CreateDirectory(targetDir);
     string path = Path.Combine(targetDir, "res");
     Directory.CreateDirectory(path);
     File.WriteAllText(Path.Combine(targetDir, AndroidLibraries.ProjectPropertiesFileName), string.Format("android.library=true\n\ntarget=android-{0}", num));
     File.WriteAllText(Path.Combine(targetDir, "AndroidManifest.xml"), string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?><manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" package=\"{0}\"\nandroid:versionCode=\"1\" android:versionName=\"1.0\"></manifest>", PlayerSettings.bundleIdentifier));
     FileUtil.CopyDirectoryRecursiveForPostprocess(sourceDir, path, true);
 }
 public void Execute(PostProcessorContext context)
 {
     if (context.Get <bool>("UseObb"))
     {
         if (this.OnProgress != null)
         {
             this.OnProgress(this, "Preparing expansion assets");
         }
         this.PrepareNonStreamingAssetsForObb(context);
     }
 }
 public void Execute(PostProcessorContext context)
 {
     this._installPath      = context.Get <string>("InstallPath");
     this._installDirectory = Path.GetDirectoryName(this._installPath);
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Moving final Android package");
     }
     this.Clean();
     this.Move(context);
 }
 public void Execute(PostProcessorContext context)
 {
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Adding Android libraries");
     }
     string str = context.Get<string>("TargetLibrariesFolder");
     AndroidLibraries libraries = new AndroidLibraries();
     libraries.FindAndAddLibraryProjects(Path.Combine(str, "*"));
     context.Set<AndroidLibraries>("AndroidLibraries", libraries);
 }
 public void Execute(PostProcessorContext context)
 {
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Starting Android build");
     }
     this.EnsureUnityLibrariesAreAvailable(context);
     if (!context.Get <bool>("ExportAndroidProject") && !this.ArePasswordsProvided())
     {
         CancelPostProcess.AbortBuild("Can not sign application", "Unable to sign application; please provide passwords!", null);
     }
 }
 public void Execute(PostProcessorContext context)
 {
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Building");
     }
     this._playerPackage = context.Get<string>("PlayerPackage");
     string stagingArea = context.Get<string>("StagingArea");
     AndroidLibraries androidLibraries = context.Get<AndroidLibraries>("AndroidLibraries");
     string packageName = context.Get<string>("PackageName");
     bool useObb = context.Get<bool>("UseObb");
     int platformApiLevel = context.Get<int>("PlatformApiLevel");
     int num2 = context.Get<int>("ProjectType");
     string googleBuildTools = context.Get<AndroidSDKTools>("SDKTools").BuildToolsVersion(null);
     if (num2 != 1)
     {
         throw new UnityException("Illegal project type: " + num2);
     }
     string[] components = new string[] { this._playerPackage, "Source" };
     string[] textArray2 = new string[] { TasksCommon.GetClassDirectory(context), "classes.jar" };
     AndroidProjectExport.ExportGradle(Paths.Combine(components), Paths.Combine(textArray2), BuildPipeline.GetBuildToolsDirectory(BuildTarget.Android), stagingArea, androidLibraries, null, packageName, PlayerSettings.productName, platformApiLevel, googleBuildTools, useObb);
     bool flag2 = PlayerSettings.Android.keyaliasName.Length != 0;
     bool flag3 = context.Get<bool>("DevelopmentPlayer");
     string sourceFileName = "";
     string task = "";
     string[] textArray3 = new string[] { stagingArea, "gradleOut" };
     string workingdir = Paths.Combine(textArray3);
     if (flag3)
     {
         task = "assembleDebug";
         string[] textArray4 = new string[] { workingdir, "build", "outputs", "apk", "gradleOut-debug.apk" };
         sourceFileName = Paths.Combine(textArray4);
     }
     else
     {
         if (!flag2)
         {
             CancelPostProcess.AbortBuild("Build Failure", "Release builds have to be signed when using Gradle");
             return;
         }
         task = "assembleRelease";
         string[] textArray5 = new string[] { workingdir, "build", "outputs", "apk", "gradleOut-release.apk" };
         sourceFileName = Paths.Combine(textArray5);
     }
     GradleWrapper.Run(workingdir, task, delegate (string task) {
         if (((this.OnProgress != null) && (task != "")) && (task[0] == ':'))
         {
             this.OnProgress(this, "Task " + task.Substring(1));
         }
     });
     string[] textArray6 = new string[] { stagingArea, "Package.apk" };
     File.Move(sourceFileName, Paths.Combine(textArray6));
 }
 public void Execute(PostProcessorContext context)
 {
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Starting Android build");
     }
     this.EnsureUnityLibrariesAreAvailable(context);
     if (!context.Get<bool>("ExportAndroidProject") && !this.ArePasswordsProvided())
     {
         CancelPostProcess.AbortBuild("Can not sign application", "Unable to sign application; please provide passwords!");
     }
 }
Exemple #25
0
        public void Execute(PostProcessorContext context)
        {
            if (this.OnProgress != null)
            {
                this.OnProgress(this, "Adding Android libraries");
            }
            string           str       = context.Get <string>("TargetLibrariesFolder");
            AndroidLibraries libraries = new AndroidLibraries();

            libraries.FindAndAddLibraryProjects(Path.Combine(str, "*"));
            context.Set <AndroidLibraries>("AndroidLibraries", libraries);
        }
 private string CopyMainManifest(PostProcessorContext context, string target)
 {
     string str = context.Get<string>("AndroidPluginsPath");
     string str2 = context.Get<string>("PlayerPackage");
     string path = Path.Combine(str, "AndroidManifest.xml");
     if (!File.Exists(path))
     {
         string[] components = new string[] { str2, "Apk", "AndroidManifest.xml" };
         path = Paths.Combine(components);
     }
     return new AndroidManifest(path).SaveAs(target);
 }
 public void Execute(PostProcessorContext context)
 {
     if (context.Get <bool>("AutoRunPlayer"))
     {
         AndroidDevice device = null;
         if (this.OnProgress != null)
         {
             this.OnProgress(this, "Getting list of attached devices");
         }
         device = this.FindDevice(context);
         context.Set <AndroidDevice>("AndroidDevice", device);
     }
 }
 public void Execute(PostProcessorContext context)
 {
     this._packageName       = context.Get <string>("PackageName");
     this._installPath       = context.Get <string>("InstallPath");
     this._device            = context.Get <AndroidDevice>("AndroidDevice");
     this._developmentPlayer = context.Get <bool>("DevelopmentPlayer");
     this.UploadAPK(false);
     if (context.Get <bool>("UseObb"))
     {
         this.UploadOBB();
     }
     this.StartApplication(context);
 }
 public void Execute(PostProcessorContext context)
 {
     if (context.Get<bool>("AutoRunPlayer"))
     {
         AndroidDevice device = null;
         if (this.OnProgress != null)
         {
             this.OnProgress(this, "Getting list of attached devices");
         }
         device = this.FindDevice(context);
         context.Set<AndroidDevice>("AndroidDevice", device);
     }
 }
Exemple #30
0
 private void AlignPackage(PostProcessorContext context)
 {
     AndroidSDKTools tools = context.Get<AndroidSDKTools>("SDKTools");
     string errorMsg = "Failed to align APK package.";
     string str2 = Path.Combine(Environment.CurrentDirectory, this._stagingArea);
     string args = string.Format("4 \"{0}/Package_unaligned.apk\" \"{0}/Package.apk\"", str2);
     string message = TasksCommon.Exec(tools.ZIPALIGN, args, this._stagingArea, errorMsg, 0);
     if ((message.Contains("zipalign") || message.Contains("Warning")) || !File.Exists(Path.Combine(str2, "Package.apk")))
     {
         Debug.LogError(message);
         CancelPostProcess.AbortBuildPointToConsole("APK Aligning Failed!", errorMsg);
     }
 }
Exemple #31
0
        private void GenerateAndroidLibraryWithResources(PostProcessorContext context, string sourceDir, string targetDir)
        {
            int num = context.Get<int>("TargetSDKVersion");
            Directory.CreateDirectory(targetDir);
            string path = Path.Combine(targetDir, "res");
            Directory.CreateDirectory(path);
            File.WriteAllText(Path.Combine(targetDir, AndroidLibraries.ProjectPropertiesFileName), $"android.library=true

target=android-{num}");
            File.WriteAllText(Path.Combine(targetDir, "AndroidManifest.xml"), $"<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="{PlayerSettings.bundleIdentifier}.resources"
android:versionCode="1" android:versionName="1.0"></manifest>");
            FileUtil.CopyDirectoryRecursiveForPostprocess(sourceDir, path, true);
        }
Exemple #32
0
        private string CopyMainManifest(PostProcessorContext context, string target)
        {
            string str  = context.Get <string>("AndroidPluginsPath");
            string str2 = context.Get <string>("PlayerPackage");
            string path = Path.Combine(str, "AndroidManifest.xml");

            if (!File.Exists(path))
            {
                string[] components = new string[] { str2, "Apk", "AndroidManifest.xml" };
                path = Paths.Combine(components);
            }
            return(new AndroidManifest(path).SaveAs(target));
        }
Exemple #33
0
        public void Execute(PostProcessorContext context)
        {
            string str = context.Get <string>("StagingArea");

            if (this.OnProgress != null)
            {
                this.OnProgress(this, "Preparing and unpacking AAR plugins");
            }
            string str2 = Path.Combine(str, "aar");
            string path = Path.Combine(str, "android-libraries");

            Directory.CreateDirectory(path);
            string[] strArray = AndroidFileLocator.Find(Path.Combine(str2, "*.aar"));
            foreach (string str4 in strArray)
            {
                string fileName = Path.GetFileName(str4);
                string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(str4);
                string str7 = Path.Combine(path, fileNameWithoutExtension);
                if (Directory.Exists(str7))
                {
                    CancelPostProcess.AbortBuild("Build failure", "Plugin conflict detected for file " + fileName, null);
                }
                Directory.CreateDirectory(str7);
                TasksCommon.Exec(AndroidJavaTools.jarPath, "xf \"" + str4 + "\"", str7, "Error unpacking file " + fileName, 0);
                string str8 = Path.Combine(str7, "libs");
                Directory.CreateDirectory(str8);
                FileUtil.MoveFileOrDirectory(Path.Combine(str7, "classes.jar"), Path.Combine(str8, "classes.jar"));
                string str9 = Path.Combine(str7, "jni");
                if (Directory.Exists(str9))
                {
                    string str10 = Path.Combine(str7, "libs");
                    foreach (string str11 in Directory.GetDirectories(str9, "*"))
                    {
                        string to = Path.Combine(str10, FileUtil.RemovePathPrefix(str11, str9));
                        FileUtil.MoveFileOrDirectory(str11, to);
                    }
                }
                string str13 = Path.Combine(str7, "src");
                if (!Directory.Exists(str13))
                {
                    Directory.CreateDirectory(str13);
                }
                if (!File.Exists(Path.Combine(str7, AndroidLibraries.ProjectPropertiesFileName)))
                {
                    int num3 = context.Get <int>("TargetSDKVersion");
                    File.WriteAllText(Path.Combine(str7, AndroidLibraries.ProjectPropertiesFileName), $"android.library=true

target=android-{num3}");
                }
            }
        }
Exemple #34
0
        private void AlignPackage(PostProcessorContext context)
        {
            AndroidSDKTools tools    = context.Get <AndroidSDKTools>("SDKTools");
            string          errorMsg = "Failed to align APK package.";
            string          str2     = Path.Combine(Environment.CurrentDirectory, this._stagingArea);
            string          args     = string.Format("4 \"{0}/Package_unaligned.apk\" \"{0}/Package.apk\"", str2);
            string          message  = TasksCommon.Exec(tools.ZIPALIGN, args, this._stagingArea, errorMsg, 0);

            if ((message.Contains("zipalign") || message.Contains("Warning")) || !File.Exists(Path.Combine(str2, "Package.apk")))
            {
                Debug.LogError(message);
                CancelPostProcess.AbortBuildPointToConsole("APK Aligning Failed!", errorMsg);
            }
        }
 public void Execute(PostProcessorContext context)
 {
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Splitting large asset files");
     }
     string str = context.Get<string>("StagingArea");
     string[] components = new string[] { str, "assets", "bin", "Data" };
     this.SplitFiles(Paths.Combine(components), "*.assets", 0x100000);
     string[] textArray2 = new string[] { str, "assets", "bin", "Data" };
     this.SplitFiles(Paths.Combine(textArray2), "*.resource", 0x100000);
     string[] textArray3 = new string[] { str, "assets", "bin", "Data" };
     this.SplitFiles(Paths.Combine(textArray3), "level*", 0x100000);
 }
 public void Execute(PostProcessorContext context)
 {
     if (!context.Get<bool>("UseFastzip"))
     {
         bool flag2 = context.Get<bool>("ExportAndroidProject");
         this._stagingArea = context.Get<string>("StagingArea");
         bool flag3 = context.Get<bool>("UseObb");
         if (!flag2)
         {
             if (this.OnProgress != null)
             {
                 this.OnProgress(this, "Building streaming package");
             }
             if (Directory.Exists(Path.Combine(this._stagingArea, "raw")))
             {
                 this.AAPTPack(context, "raw.ap_", "raw", false);
             }
         }
         if (flag3)
         {
             if (this.OnProgress != null)
             {
                 this.OnProgress(this, "Building expansion asset package (OBB)");
             }
             this.AAPTPack(context, "obb.ap_", "obbassets", true);
             if (this.OnProgress != null)
             {
                 this.OnProgress(this, "Building expansion streaming package (OBB)");
             }
             if (Directory.Exists(Path.Combine(this._stagingArea, "rawobb")))
             {
                 this.AAPTPack(context, "rawobb.ap_", "rawobb", false);
             }
             if (this.OnProgress != null)
             {
                 this.OnProgress(this, "Creating APK expansion package (OBB)");
             }
             this.BuildObb(context);
         }
         if (!flag2)
         {
             if (this.OnProgress != null)
             {
                 this.OnProgress(this, "Building asset package");
             }
             this.AAPTPack(context, "assets.ap_", "assets", true);
         }
     }
 }
Exemple #37
0
 public void Execute(PostProcessorContext context)
 {
     if (((ScriptingImplementation)context.Get <ScriptingImplementation>("ScriptingBackend")) == ScriptingImplementation.IL2CPP)
     {
         if (this.OnProgress != null)
         {
             this.OnProgress(this, "Generating native assemblies");
         }
         BuildTarget target          = context.Get <BuildTarget>("BuildTarget");
         string      str             = context.Get <string>("StagingArea");
         string[]    components      = new string[] { str, "assets", "bin", "Data" };
         string      stagingAreaData = Paths.Combine(components);
         string[]    textArray2      = new string[] { BuildPipeline.GetBuildToolsDirectory(target), "AndroidNativeLink.xml" };
         string[]    textArray3      = new string[] { stagingAreaData, "platform_native_link.xml" };
         FileUtil.CopyFileOrDirectory(Paths.Combine(textArray2), Paths.Combine(textArray3));
         AndroidTargetDevice     device     = context.Get <AndroidTargetDevice>("TargetDevice");
         AndroidTargetDeviceType deviceType = new AndroidTargetDeviceARMv7();
         if (device == AndroidTargetDevice.x86)
         {
             deviceType = new AndroidTargetDevicex86();
         }
         if (this.OnProgress != null)
         {
             this.OnProgress(this, "Compiling native assemblies for " + deviceType.Architecture);
         }
         string tempFolder         = Path.Combine(str, "Il2Cpp");
         bool   isDevelopmentBuild = context.Get <bool>("DevelopmentPlayer");
         RuntimeClassRegistry          runtimeClassRegistry = context.Get <RuntimeClassRegistry>("UsedClassRegistry");
         AndroidIl2CppPlatformProvider platformProvider     = new AndroidIl2CppPlatformProvider(target, deviceType, isDevelopmentBuild);
         IL2CPPUtils.RunIl2Cpp(tempFolder, stagingAreaData, platformProvider, null, runtimeClassRegistry, isDevelopmentBuild);
         AndroidTargetDeviceType type2 = null;
         if (device == AndroidTargetDevice.FAT)
         {
             type2 = new AndroidTargetDevicex86();
             if (this.OnProgress != null)
             {
                 this.OnProgress(this, "Compiling native assemblies for " + type2.Architecture);
             }
             platformProvider = new AndroidIl2CppPlatformProvider(target, type2, isDevelopmentBuild);
             IL2CPPUtils.RunCompileAndLink(tempFolder, stagingAreaData, platformProvider, null, runtimeClassRegistry, false);
         }
         this.FinalizeAndCleanup(str, stagingAreaData, tempFolder);
         this.CopySymbolMap(str, stagingAreaData, deviceType);
         if (type2 != null)
         {
             this.CopySymbolMap(str, stagingAreaData, type2);
         }
     }
 }
 public void Execute(PostProcessorContext context)
 {
     if (((ScriptingImplementation) context.Get<ScriptingImplementation>("ScriptingBackend")) == ScriptingImplementation.IL2CPP)
     {
         if (this.OnProgress != null)
         {
             this.OnProgress(this, "Generating native assemblies");
         }
         BuildTarget target = context.Get<BuildTarget>("BuildTarget");
         string str = context.Get<string>("StagingArea");
         string[] components = new string[] { str, "assets", "bin", "Data" };
         string stagingAreaData = Paths.Combine(components);
         string[] textArray2 = new string[] { BuildPipeline.GetBuildToolsDirectory(target), "AndroidNativeLink.xml" };
         string[] textArray3 = new string[] { stagingAreaData, "platform_native_link.xml" };
         FileUtil.CopyFileOrDirectory(Paths.Combine(textArray2), Paths.Combine(textArray3));
         AndroidTargetDevice device = context.Get<AndroidTargetDevice>("TargetDevice");
         AndroidTargetDeviceType deviceType = new AndroidTargetDeviceARMv7();
         if (device == AndroidTargetDevice.x86)
         {
             deviceType = new AndroidTargetDevicex86();
         }
         if (this.OnProgress != null)
         {
             this.OnProgress(this, "Compiling native assemblies for " + deviceType.Architecture);
         }
         string tempFolder = Path.Combine(str, "Il2Cpp");
         bool isDevelopmentBuild = context.Get<bool>("DevelopmentPlayer");
         RuntimeClassRegistry runtimeClassRegistry = context.Get<RuntimeClassRegistry>("UsedClassRegistry");
         AndroidIl2CppPlatformProvider platformProvider = new AndroidIl2CppPlatformProvider(target, deviceType, isDevelopmentBuild);
         IL2CPPUtils.RunIl2Cpp(tempFolder, stagingAreaData, platformProvider, null, runtimeClassRegistry, isDevelopmentBuild);
         AndroidTargetDeviceType type2 = null;
         if (device == AndroidTargetDevice.FAT)
         {
             type2 = new AndroidTargetDevicex86();
             if (this.OnProgress != null)
             {
                 this.OnProgress(this, "Compiling native assemblies for " + type2.Architecture);
             }
             platformProvider = new AndroidIl2CppPlatformProvider(target, type2, isDevelopmentBuild);
             IL2CPPUtils.RunCompileAndLink(tempFolder, stagingAreaData, platformProvider, null, runtimeClassRegistry, isDevelopmentBuild);
         }
         this.FinalizeAndCleanup(str, stagingAreaData, tempFolder);
         this.CopySymbolMap(str, stagingAreaData, deviceType);
         if (type2 != null)
         {
             this.CopySymbolMap(str, stagingAreaData, type2);
         }
     }
 }
 public void Execute(PostProcessorContext context)
 {
     if (!context.Get <bool>("UseFastzip"))
     {
         bool flag2 = context.Get <bool>("ExportAndroidProject");
         this._stagingArea = context.Get <string>("StagingArea");
         bool flag3 = context.Get <bool>("UseObb");
         if (!flag2)
         {
             if (this.OnProgress != null)
             {
                 this.OnProgress(this, "Building streaming package");
             }
             if (Directory.Exists(Path.Combine(this._stagingArea, "raw")))
             {
                 this.AAPTPack(context, "raw.ap_", "raw", false);
             }
         }
         if (flag3)
         {
             if (this.OnProgress != null)
             {
                 this.OnProgress(this, "Building expansion asset package (OBB)");
             }
             this.AAPTPack(context, "obb.ap_", "obbassets", true);
             if (this.OnProgress != null)
             {
                 this.OnProgress(this, "Building expansion streaming package (OBB)");
             }
             if (Directory.Exists(Path.Combine(this._stagingArea, "rawobb")))
             {
                 this.AAPTPack(context, "rawobb.ap_", "rawobb", false);
             }
             if (this.OnProgress != null)
             {
                 this.OnProgress(this, "Creating APK expansion package (OBB)");
             }
             this.BuildObb(context);
         }
         if (!flag2)
         {
             if (this.OnProgress != null)
             {
                 this.OnProgress(this, "Building asset package");
             }
             this.AAPTPack(context, "assets.ap_", "assets", true);
         }
     }
 }
 private void EnsureUnityLibrariesAreAvailable(PostProcessorContext context)
 {
     AndroidTargetDevice device = context.Get<AndroidTargetDevice>("TargetDevice");
     switch (device)
     {
         case AndroidTargetDevice.FAT:
         case AndroidTargetDevice.ARMv7:
             this.CheckUnityLibraryForArchitecture(context, "armeabi-v7a");
             break;
     }
     if ((device == AndroidTargetDevice.FAT) || (device == AndroidTargetDevice.x86))
     {
         this.CheckUnityLibraryForArchitecture(context, "x86");
     }
 }
Exemple #41
0
        private string MergeManifests(PostProcessorContext context, string targetManifest, string mainManifest)
        {
            AndroidSDKTools  tools     = context.Get <AndroidSDKTools>("SDKTools");
            AndroidLibraries libraries = context.Get <AndroidLibraries>("AndroidLibraries");
            bool             flag      = context.Get <bool>("ExportAndroidProject");

            string[] manifestFiles = libraries.GetManifestFiles();
            if (!flag && (manifestFiles.Length > 0))
            {
                tools.MergeManifests(targetManifest, mainManifest, manifestFiles, null);
                return(targetManifest);
            }
            FileUtil.CopyFileOrDirectory(mainManifest, targetManifest);
            return(targetManifest);
        }
        public void Execute(PostProcessorContext context)
        {
            if (this.OnProgress != null)
            {
                this.OnProgress(this, "Splitting large asset files");
            }
            string str = context.Get <string>("StagingArea");

            string[] components = new string[] { str, "assets", "bin", "Data" };
            this.SplitFiles(Paths.Combine(components), "*.assets", 0x100000);
            string[] textArray2 = new string[] { str, "assets", "bin", "Data" };
            this.SplitFiles(Paths.Combine(textArray2), "*.resource", 0x100000);
            string[] textArray3 = new string[] { str, "assets", "bin", "Data" };
            this.SplitFiles(Paths.Combine(textArray3), "level*", 0x100000);
        }
 public void Execute(PostProcessorContext context)
 {
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Processing user-provided Android resources");
     }
     string str = context.Get<string>("AndroidPluginsPath");
     string str2 = context.Get<string>("TargetLibrariesFolder");
     string path = Path.Combine(str, "res");
     if (Directory.Exists(path))
     {
         Debug.LogWarning("OBSOLETE - Providing Android resources in Assets/Plugins/Android/res is deprecated, please move your resources to an Android Library. See \"Building Plugins for Android\" section of the Manual.");
         this.GenerateAndroidLibraryWithResources(context, path, Path.Combine(str2, "unity-android-resources"));
     }
 }
 public void Execute(PostProcessorContext context)
 {
     this._stagingArea = context.Get<string>("StagingArea");
     this._packageName = context.Get<string>("PackageName");
     this._useObb = context.Get<bool>("UseObb");
     if (context.Get<bool>("AutoRunPlayer"))
     {
         this.UploadAndStartPlayer(context, false);
     }
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Moving final Android package");
     }
     this.MoveFinalAndroidPackage(context);
 }
Exemple #45
0
 public void Execute(PostProcessorContext context)
 {
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Processing user-provided Android resources");
     }
     string str = context.Get<string>("AndroidPluginsPath");
     string str2 = context.Get<string>("TargetLibrariesFolder");
     string path = Path.Combine(str, "res");
     if (Directory.Exists(path))
     {
         Debug.LogWarning("OBSOLETE - Providing Android resources in Assets/Plugins/Android/res is deprecated, please move your resources to an Android Library. See \"Building Plugins for Android\" section of the Manual.");
         this.GenerateAndroidLibraryWithResources(context, path, Path.Combine(str2, "unity-android-resources"));
     }
 }
        public void Execute(PostProcessorContext context)
        {
            if (this.OnProgress != null)
            {
                this.OnProgress(this, "Building");
            }
            string str    = context.Get <string>("StagingArea");
            int    system = context.Get <int>("ProjectType");

            if (system != 1)
            {
                throw new UnityException("Illegal project type: " + system);
            }
            AndroidProjectExport.Create(system).Export(context, null);
            bool   flag           = PlayerSettings.Android.keyaliasName.Length != 0;
            bool   flag2          = context.Get <bool>("DevelopmentPlayer");
            string sourceFileName = "";
            string task           = "";

            string[] components = new string[] { "Temp", "gradleOut" };
            string   workingdir = Paths.Combine(components);

            if (flag2 || Unsupported.IsDeveloperBuild())
            {
                task = "assembleDebug";
                string[] textArray2 = new string[] { workingdir, "build", "outputs", "apk", "gradleOut-debug.apk" };
                sourceFileName = Paths.Combine(textArray2);
            }
            else
            {
                if (!flag)
                {
                    CancelPostProcess.AbortBuild("Build Failure", "Release builds have to be signed when using Gradle", null);
                    return;
                }
                task = "assembleRelease";
                string[] textArray3 = new string[] { workingdir, "build", "outputs", "apk", "gradleOut-release.apk" };
                sourceFileName = Paths.Combine(textArray3);
            }
            GradleWrapper.Run(workingdir, task, delegate(string task) {
                if (((this.OnProgress != null) && (task != "")) && (task[0] == ':'))
                {
                    this.OnProgress(this, "Task " + task.Substring(1));
                }
            });
            string[] textArray4 = new string[] { str, "Package.apk" };
            File.Move(sourceFileName, Paths.Combine(textArray4));
        }
Exemple #47
0
        public void Execute(PostProcessorContext context)
        {
            if (this.OnProgress != null)
            {
                this.OnProgress(this, "Checking Android libraries for conflicts");
            }
            string           str       = context.Get <string>("StagingArea");
            AndroidLibraries libraries = context.Get <AndroidLibraries>("AndroidLibraries");

            foreach (string str2 in libraries.GetPackageNames())
            {
                string   path      = Path.Combine(str, "gen");
                char[]   separator = new char[] { '.' };
                string[] strArray2 = str2.Split(separator);
                for (int i = 0; i < strArray2.Length; i++)
                {
        private void EnsureUnityLibrariesAreAvailable(PostProcessorContext context)
        {
            AndroidTargetDevice device = context.Get <AndroidTargetDevice>("TargetDevice");

            switch (device)
            {
            case AndroidTargetDevice.FAT:
            case AndroidTargetDevice.ARMv7:
                this.CheckUnityLibraryForArchitecture(context, "armeabi-v7a");
                break;
            }
            if ((device == AndroidTargetDevice.FAT) || (device == AndroidTargetDevice.x86))
            {
                this.CheckUnityLibraryForArchitecture(context, "x86");
            }
        }
 public void Execute(PostProcessorContext context)
 {
     string str = context.Get<string>("StagingArea");
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Preparing and unpacking AAR plugins");
     }
     string str2 = Path.Combine(str, "aar");
     string path = Path.Combine(str, "android-libraries");
     Directory.CreateDirectory(path);
     string[] strArray = AndroidFileLocator.Find(Path.Combine(str2, "*.aar"));
     foreach (string str4 in strArray)
     {
         string fileName = Path.GetFileName(str4);
         string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(str4);
         string str7 = Path.Combine(path, fileNameWithoutExtension);
         if (Directory.Exists(str7))
         {
             CancelPostProcess.AbortBuild("Build failure", "Plugin conflict detected for file " + fileName);
         }
         Directory.CreateDirectory(str7);
         TasksCommon.Exec(AndroidJavaTools.jarPath, "xf \"" + str4 + "\"", str7, "Error unpacking file " + fileName, 0);
         string str8 = Path.Combine(str7, "libs");
         Directory.CreateDirectory(str8);
         FileUtil.MoveFileOrDirectory(Path.Combine(str7, "classes.jar"), Path.Combine(str8, "classes.jar"));
         string str9 = Path.Combine(str7, "jni");
         if (Directory.Exists(str9))
         {
             string str10 = Path.Combine(str7, "libs");
             foreach (string str11 in Directory.GetDirectories(str9, "*"))
             {
                 string to = Path.Combine(str10, FileUtil.RemovePathPrefix(str11, str9));
                 FileUtil.MoveFileOrDirectory(str11, to);
             }
         }
         string str13 = Path.Combine(str7, "src");
         if (!Directory.Exists(str13))
         {
             Directory.CreateDirectory(str13);
         }
         if (!File.Exists(Path.Combine(str7, AndroidLibraries.ProjectPropertiesFileName)))
         {
             int num3 = context.Get<int>("TargetSDKVersion");
             File.WriteAllText(Path.Combine(str7, AndroidLibraries.ProjectPropertiesFileName), string.Format("android.library=true\n\ntarget=android-{0}", num3));
         }
     }
 }
Exemple #50
0
        /// <summary>
        /// Executes the current component in the pipeline.
        /// </summary>
        /// <param name="request">The request to <see cref="IMediator"/>.</param>
        /// <param name="nextAsync">The request handler.</param>
        /// <param name="cancellationToken">
        /// A cancellation token that should be used to cancel the work.
        /// </param>
        /// <returns>A task that represents a pipeline step.</returns>
        public async Task <TResult> ExecuteAsync(
            TQuery request,
            Func <Task <TResult> > nextAsync,
            CancellationToken cancellationToken)
        {
            var context = new PostProcessorContext <TResult>
            {
                Result = await nextAsync().ConfigureAwait(false)
            };

            foreach (var processor in _processors)
            {
                await processor.ProcessAsync(request, context, cancellationToken).ConfigureAwait(false);
            }

            return(context.Result);
        }
        public void Execute(PostProcessorContext context)
        {
            if (this.OnProgress != null)
            {
                this.OnProgress(this, "Copying streaming assets");
            }
            bool   flag = context.Get <bool>("UseObb");
            string str  = context.Get <string>("StagingArea");

            string[] components = new string[] { str, "assets", "bin" };
            string   str2       = Paths.Combine(components);

            string[] textArray2 = new string[] { str2, "Data" };
            string   path       = Paths.Combine(textArray2);

            string[] textArray3 = new string[] { str, "raw", "bin", "Data" };
            string   str4       = Paths.Combine(textArray3);

            string[] textArray4 = new string[] { str, "rawobb", "bin", "Data" };
            string   str5       = Paths.Combine(textArray4);
            string   strB       = ".resS";

            string[] fileSystemEntries = Directory.GetFileSystemEntries(path);
            foreach (string str7 in fileSystemEntries)
            {
                if (string.Compare(Path.GetExtension(str7), strB, true) == 0)
                {
                    string str8     = str4;
                    string fileName = Path.GetFileName(str7);
                    if ((flag && (string.Compare(fileName, "level0.resS", true) != 0)) && (string.Compare(fileName, "sharedassets0.assets.resS", true) != 0))
                    {
                        str8 = str5;
                    }
                    if (!Directory.Exists(str8))
                    {
                        Directory.CreateDirectory(str8);
                    }
                    string destFileName = Path.Combine(str8, fileName);
                    File.Move(str7, destFileName);
                }
            }
            if (Directory.Exists("Assets/StreamingAssets"))
            {
                FileUtil.CopyDirectoryRecursiveForPostprocess("Assets/StreamingAssets", Path.Combine(str, !flag ? "raw" : "rawobb"), true);
            }
        }
Exemple #52
0
 public void Execute(PostProcessorContext context)
 {
     if (!context.Get<bool>("UseFastzip"))
     {
         this._stagingArea = context.Get<string>("StagingArea");
         if (this.OnProgress != null)
         {
             this.OnProgress(this, "Building target package from assets archive and pre-built binaries");
         }
         this.BuildApk(context);
         if (this.OnProgress != null)
         {
             this.OnProgress(this, "Optimizing target package alignment");
         }
         this.AlignPackage(context);
     }
 }
 private void AAPTPack(PostProcessorContext context, string apkName, string directory, bool compress)
 {
     AndroidSDKTools tools = context.Get<AndroidSDKTools>("SDKTools");
     string str = "";
     if (!compress)
     {
         str = " -0 \"\"";
     }
     string str2 = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~";
     string args = string.Format("package -v -f -F {0} -A {1}{2} --ignore-assets \"{3}\"", new object[] { apkName, directory, str, str2 });
     string str4 = TasksCommon.Exec(tools.AAPT, args, this._stagingArea, "Android Asset Packaging Tool failed.", 3);
     if (!str4.Contains("Found 0 custom asset files") && (!str4.Contains("Done!") || !File.Exists(Path.Combine(this._stagingArea, apkName))))
     {
         Debug.LogError(string.Format("Android Asset Packaging Tool failed: {0} {1} \n {2}", tools.AAPT, args, str4));
         CancelPostProcess.AbortBuildPointToConsole("AAPT Failed!", "Android Asset Packaging Tool failed.");
     }
 }
Exemple #54
0
 public void Execute(PostProcessorContext context)
 {
     if (!context.Get <bool>("UseFastzip"))
     {
         this._stagingArea = context.Get <string>("StagingArea");
         if (this.OnProgress != null)
         {
             this.OnProgress(this, "Building target package from assets archive and pre-built binaries");
         }
         this.BuildApk(context);
         if (this.OnProgress != null)
         {
             this.OnProgress(this, "Optimizing target package alignment");
         }
         this.AlignPackage(context);
     }
 }
 public void Execute(PostProcessorContext context)
 {
     this._stagingArea = context.Get<string>("StagingArea");
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Updating resources with player settings");
     }
     this.ReplaceIconResources();
     if (!context.Get<bool>("ExportAndroidProject"))
     {
         if (this.OnProgress != null)
         {
             this.OnProgress(this, "Repackaging and recompiling resources");
         }
         this.CompileResources(context);
     }
 }
 private void PrepareNativeUnityLibs(PostProcessorContext context, string abi)
 {
     string pluginSourceFolder = context.Get<string>("AndroidPluginsPath");
     string[] components = new string[] { this._stagingArea, "libs", abi };
     string to = Paths.Combine(components);
     string[] textArray2 = new string[] { TasksCommon.GetVariationsDirectory(context), "Libs" };
     string str3 = Paths.Combine(textArray2);
     string[] textArray3 = new string[] { this._stagingArea, "libs" };
     Directory.CreateDirectory(Paths.Combine(textArray3));
     string[] textArray4 = new string[] { str3, abi };
     FileUtil.CopyFileOrDirectory(Paths.Combine(textArray4), to);
     string[] textArray5 = new string[] { pluginSourceFolder, "libs", abi };
     string str4 = Paths.Combine(textArray5);
     string[] textArray6 = new string[] { to, "gdbserver" };
     if (!File.Exists(Paths.Combine(textArray6)) && !PostprocessBuildPlayer.InstallPluginsByExtension(pluginSourceFolder, "gdbserver", string.Empty, to, false))
     {
         PostprocessBuildPlayer.InstallPluginsByExtension(str4, "gdbserver", string.Empty, to, false);
     }
 }
Exemple #57
0
 private void BuildApk(PostProcessorContext context)
 {
     bool flag = context.Get<bool>("DevelopmentPlayer");
     AndroidLibraries libraries = context.Get<AndroidLibraries>("AndroidLibraries");
     bool flag2 = PlayerSettings.Android.keyaliasName.Length != 0;
     string str = Path.Combine(Environment.CurrentDirectory, this._stagingArea);
     string[] first = new string[] { "apk", string.Format("{0}/Package_unaligned.apk", str), "-z", string.Format("{0}/assets.ap_", str), "-z", string.Format("{0}/bin/resources.ap_", str), "-nf", string.Format("{0}/libs", str), "-f", string.Format("{0}/bin/classes.dex", str), "-v" };
     foreach (string str2 in libraries.GetLibraryDirectories())
     {
         string[] second = new string[] { "-nf", str2 };
         first = Enumerable.ToArray<string>(Enumerable.Concat<string>(first, second));
     }
     foreach (string str3 in libraries.GetAssetsDirectories())
     {
         string[] textArray3 = new string[] { "-A", str3 };
         first = Enumerable.ToArray<string>(Enumerable.Concat<string>(first, textArray3));
     }
     if (flag2)
     {
         string str4 = !Path.IsPathRooted(PlayerSettings.Android.keystoreName) ? Path.Combine(Directory.GetCurrentDirectory(), PlayerSettings.Android.keystoreName) : PlayerSettings.Android.keystoreName;
         string[] textArray4 = new string[] { "-k", str4, "-kp", PlayerSettings.Android.keystorePass, "-kk", PlayerSettings.Android.keyaliasName, "-kkp", PlayerSettings.Android.keyaliasPass };
         first = Enumerable.ToArray<string>(Enumerable.Concat<string>(first, textArray4));
     }
     if (flag || Unsupported.IsDeveloperBuild())
     {
         string[] textArray5 = new string[] { "-d" };
         first = Enumerable.ToArray<string>(Enumerable.Concat<string>(first, textArray5));
     }
     if (File.Exists(Path.Combine(this._stagingArea, "raw.ap_")))
     {
         string[] textArray6 = new string[] { "-z", string.Format("{0}/raw.ap_", str) };
         first = Enumerable.ToArray<string>(Enumerable.Concat<string>(first, textArray6));
     }
     string message = TasksCommon.SDKTool(context, first, this._stagingArea, "Failed to build apk.");
     string fileName = Path.Combine(this._stagingArea, "Package_unaligned.apk");
     FileInfo info = new FileInfo(fileName);
     if (!File.Exists(fileName) || (info.Length == 0L))
     {
         Debug.LogError(message);
         CancelPostProcess.AbortBuildPointToConsole("APK Builder Failed!", "Failed to build APK package.");
     }
 }
 public void Execute(PostProcessorContext context)
 {
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Copying streaming assets");
     }
     bool flag = context.Get<bool>("UseObb");
     string str = context.Get<string>("StagingArea");
     string[] components = new string[] { str, "assets", "bin" };
     string str2 = Paths.Combine(components);
     string[] textArray2 = new string[] { str2, "Data" };
     string path = Paths.Combine(textArray2);
     string[] textArray3 = new string[] { str, "raw", "bin", "Data" };
     string str4 = Paths.Combine(textArray3);
     string[] textArray4 = new string[] { str, "rawobb", "bin", "Data" };
     string str5 = Paths.Combine(textArray4);
     string strB = ".resS";
     string[] fileSystemEntries = Directory.GetFileSystemEntries(path);
     foreach (string str7 in fileSystemEntries)
     {
         if (string.Compare(Path.GetExtension(str7), strB, true) == 0)
         {
             string str8 = str4;
             string fileName = Path.GetFileName(str7);
             if ((flag && (string.Compare(fileName, "level0.resS", true) != 0)) && (string.Compare(fileName, "sharedassets0.assets.resS", true) != 0))
             {
                 str8 = str5;
             }
             if (!Directory.Exists(str8))
             {
                 Directory.CreateDirectory(str8);
             }
             string destFileName = Path.Combine(str8, fileName);
             File.Move(str7, destFileName);
         }
     }
     if (Directory.Exists("Assets/StreamingAssets"))
     {
         FileUtil.CopyDirectoryRecursiveForPostprocess("Assets/StreamingAssets", Path.Combine(str, !flag ? "raw" : "rawobb"), true);
     }
 }
 private void CompileResources(PostProcessorContext context)
 {
     AndroidLibraries libraries = context.Get<AndroidLibraries>("AndroidLibraries");
     string str = context.Get<string>("AndroidJarPath");
     AndroidSDKTools tools = context.Get<AndroidSDKTools>("SDKTools");
     string str2 = "gen";
     string fullName = Directory.CreateDirectory(Path.Combine(this._stagingArea, str2)).FullName;
     string args = string.Format("package --auto-add-overlay -v -f -m -J \"{0}\" -M \"{1}\" -S \"{2}\" -I \"{3}\" -F {4}", new object[] { str2, "AndroidManifest.xml", "res", str, "bin/resources.ap_" });
     if (libraries.Count > 0)
     {
         args = args + string.Format(" --extra-packages {0}", string.Join(":", libraries.GetPackageNames()));
         foreach (string str5 in libraries.GetResourceDirectories())
         {
             args = args + string.Format(" -S \"{0}\"", str5);
         }
     }
     string errorMsg = "Failed to re-package resources.";
     string str7 = TasksCommon.Exec(tools.AAPT, args, this._stagingArea, errorMsg, 3);
     if (!str7.Contains("Done!") || !File.Exists(Path.Combine(this._stagingArea, "bin/resources.ap_")))
     {
         Debug.LogError("Failed to re-package resources with the following parameters:\n" + args + "\n" + str7);
         CancelPostProcess.AbortBuildPointToConsole("Resource re-package failed!", errorMsg);
     }
     if (libraries.Count > 0)
     {
         List<string> list = new List<string>();
         foreach (string str8 in Directory.GetFiles(fullName, "*.java", SearchOption.AllDirectories))
         {
             list.Add(str8.Substring(fullName.Length + 1));
         }
         string str9 = Directory.CreateDirectory(Path.Combine(this._stagingArea, "bin/classes")).FullName;
         string str10 = string.Format("-bootclasspath \"{0}\" -d \"{1}\" -source 1.6 -target 1.6 -encoding UTF-8 \"{2}\"", str, str9, string.Join("\" \"", list.ToArray()));
         string str11 = "Failed to recompile android resource files.";
         string str12 = TasksCommon.Exec(AndroidJavaTools.javacPath, str10, fullName, str11, 0);
         if (str12.Trim().Length > 0)
         {
             Debug.LogError("Failed to compile resources with the following parameters:\n" + str10 + "\n" + str12);
             CancelPostProcess.AbortBuildPointToConsole("Resource compilation failed!", str11);
         }
     }
 }
 public void Execute(PostProcessorContext context)
 {
     if (this.OnProgress != null)
     {
         this.OnProgress(this, "Patching settings file");
     }
     this._stagingArea = context.Get<string>("StagingArea");
     bool flag = context.Get<bool>("UseObb");
     string str = context.Get<string>("AndroidPluginsPath");
     if (Directory.Exists(Path.Combine(str, "assets")))
     {
         FileUtil.CopyDirectoryRecursiveForPostprocess(Path.Combine(str, "assets"), Path.Combine(this._stagingArea, "assets"), true);
     }
     this.PatchStringsXml();
     int num = !PlayerSettings.advancedLicense ? 0 : ((int) PlayerSettings.Android.splashScreenScale);
     AndroidXmlDocument document = new AndroidXmlDocument(Path.Combine(this._stagingArea, "assets/bin/Data/settings.xml"));
     document.PatchStringRes("integer", "splash_mode", num.ToString());
     document.PatchStringRes("bool", "useObb", flag.ToString());
     context.Set<AndroidXmlDocument>("SettingsXml", document);
     document.Save();
 }