Beispiel #1
0
        private string PatchManifest(PostProcessorContext context, string manifest)
        {
            BuildTarget platform = context.Get <BuildTarget>("BuildTarget");

            string[]        components  = new string[] { this._stagingArea, "assets", "bin" };
            string          str         = Paths.Combine(components);
            AndroidManifest manifestXML = new AndroidManifest(manifest);
            string          location    = this.PreferredInstallLocationAsString();

            manifestXML.SetInstallLocation(location);
            manifestXML.SetDebuggable(this._developmentPlayer || Unsupported.IsDeveloperBuild());
            int    minSdkVersion = (int)PlayerSettings.Android.minSdkVersion;
            string glEsVersion   = "0x00020000";

            GraphicsDeviceType[] graphicsAPIs = PlayerSettings.GetGraphicsAPIs(platform);
            if (graphicsAPIs.Contains <GraphicsDeviceType>(GraphicsDeviceType.OpenGLES3) && (minSdkVersion >= 0x12))
            {
                glEsVersion = "0x00030000";
            }
            if (graphicsAPIs.Contains <GraphicsDeviceType>(GraphicsDeviceType.OpenGLES2))
            {
                glEsVersion = "0x00020000";
            }
            if ((glEsVersion == "0x00030000") && (PlayerSettings.openGLRequireES31 || PlayerSettings.openGLRequireES31AEP))
            {
                glEsVersion = "0x00030001";
            }
            manifestXML.AddGLESVersion(glEsVersion);
            if ((glEsVersion == "0x00030001") && PlayerSettings.openGLRequireES31AEP)
            {
                manifestXML.AddUsesFeature("android.hardware.opengles.aep", true);
            }
            if (EditorUserBuildSettings.androidBuildSubtarget != MobileTextureSubtarget.Generic)
            {
                this.CreateSupportsTextureElem(manifestXML, EditorUserBuildSettings.androidBuildSubtarget);
            }
            HashSet <string> set = new HashSet <string>(this.GetActivitiesWithMetadata(manifestXML, "unityplayer.UnityActivity", "true"));

            string[] other = new string[] { "com.unity3d.player.UnityPlayerNativeActivity", "com.unity3d.player.UnityPlayerActivity", "com.unity3d.player.UnityPlayerProxyActivity" };
            set.UnionWith(other);
            string orientationAttr = this.GetOrientationAttr();
            bool   flag            = false;

            foreach (string str5 in set)
            {
                flag = manifestXML.SetOrientation(str5, orientationAttr) || flag;
                flag = manifestXML.SetLaunchMode(str5, "singleTask") || flag;
                flag = manifestXML.SetConfigChanges(str5, AndroidManifest.AndroidConfigChanges) || flag;
            }
            if (!flag)
            {
                Debug.LogWarning($"Unable to find unity activity in manifest. You need to make sure orientation attribute is set to {orientationAttr} manually.");
            }
            manifestXML.SetApplicationFlag("isGame", PlayerSettings.Android.androidIsGame);
            if (PlayerSettings.Android.androidBannerEnabled)
            {
                manifestXML.SetApplicationBanner("@drawable/app_banner");
            }
            if ((PlayerSettings.Android.androidTVCompatibility && !manifestXML.HasLeanbackLauncherActivity()) && !manifestXML.AddLeanbackLauncherActivity())
            {
                Debug.LogWarning("No activity with LEANBACK_LAUNCHER or LAUNCHER categories found.\nThe build may not be compatible with Android TV. Specify an activity with LEANBACK_LAUNCHER or LAUNCHER category in the manifest, or disable Android TV compatibility in Player Settings.");
            }
            switch (PlayerSettings.Android.androidGamepadSupportLevel)
            {
            case AndroidGamepadSupportLevel.SupportsGamepad:
                manifestXML.AddUsesFeature("android.hardware.gamepad", false);
                break;

            case AndroidGamepadSupportLevel.RequiresGamepad:
                manifestXML.AddUsesFeature("android.hardware.gamepad", true);
                break;
            }
            if (PlayerSettings.virtualRealitySupported)
            {
                manifestXML.OverrideTheme("@android:style/Theme.Black.NoTitleBar.Fullscreen");
                int num2 = context.Get <int>("GearVRMinSdkVersion");
                if (PlayerSettings.Android.minSdkVersion < num2)
                {
                    Debug.LogWarning("GearVR requires Minimum API Level of 19");
                }
            }
            AssemblyReferenceChecker checker = new AssemblyReferenceChecker();
            bool collectMethods   = true;
            bool ignoreSystemDlls = true;

            string[] textArray3 = new string[] { str, "Data", "Managed" };
            string   path       = Paths.Combine(textArray3);

            checker.CollectReferences(path, collectMethods, 0f, ignoreSystemDlls);
            this.SetPermissionAttributes(context, manifestXML, checker);
            manifestXML.StripUnityLibEntryForNativeActitivy();
            manifestXML.SaveAs(manifest);
            return(manifestXML.packageName);
        }
        private string PatchManifest(PostProcessorContext context, string manifest)
        {
            BuildTarget platform = context.Get<BuildTarget>("BuildTarget");
            string[] components = new string[] { this._stagingArea, "assets", "bin" };
            string str = Paths.Combine(components);
            AndroidManifest manifestXML = new AndroidManifest(manifest);
            string location = this.PreferredInstallLocationAsString();
            manifestXML.SetInstallLocation(location);
            manifestXML.SetDebuggable(this._developmentPlayer || Unsupported.IsDeveloperBuild());
            int minSdkVersion = (int) PlayerSettings.Android.minSdkVersion;
            string glEsVersion = "0x00020000";
            GraphicsDeviceType[] graphicsAPIs = PlayerSettings.GetGraphicsAPIs(platform);
            if (Enumerable.Contains<GraphicsDeviceType>(graphicsAPIs, GraphicsDeviceType.OpenGLES3) && (minSdkVersion >= 0x12))
            {
                glEsVersion = "0x00030000";
            }
            if (Enumerable.Contains<GraphicsDeviceType>(graphicsAPIs, GraphicsDeviceType.OpenGLES2))
            {
                glEsVersion = "0x00020000";
            }
            if ((glEsVersion == "0x00030000") && (PlayerSettings.openGLRequireES31 || PlayerSettings.openGLRequireES31AEP))
            {
                glEsVersion = "0x00030001";
            }
            manifestXML.AddGLESVersion(glEsVersion);
            if ((glEsVersion == "0x00030001") && PlayerSettings.openGLRequireES31AEP)
            {
                manifestXML.AddUsesFeature("android.hardware.opengles.aep", true);
            }
            if (EditorUserBuildSettings.androidBuildSubtarget != MobileTextureSubtarget.Generic)
            {
                this.CreateSupportsTextureElem(manifestXML, EditorUserBuildSettings.androidBuildSubtarget);
            }
            HashSet<string> set = new HashSet<string>(this.GetActivitiesWithMetadata(manifestXML, "unityplayer.UnityActivity", "true"));
            string[] other = new string[] { "com.unity3d.player.UnityPlayerNativeActivity", "com.unity3d.player.UnityPlayerActivity", "com.unity3d.player.UnityPlayerProxyActivity" };
            set.UnionWith(other);
            string orientationAttr = this.GetOrientationAttr();
            bool flag = false;
            foreach (string str5 in set)
            {
                flag = manifestXML.SetOrientation(str5, orientationAttr) || flag;
                flag = manifestXML.SetLaunchMode(str5, "singleTask") || flag;
                flag = manifestXML.SetConfigChanges(str5, AndroidManifest.AndroidConfigChanges) || flag;
            }
            if (!flag)
            {
                Debug.LogWarning(string.Format("Unable to find unity activity in manifest. You need to make sure orientation attribute is set to {0} manually.", orientationAttr));
            }
            manifestXML.SetApplicationFlag("isGame", PlayerSettings.Android.androidIsGame);
            if (PlayerSettings.Android.androidBannerEnabled)
            {
                manifestXML.SetApplicationBanner("@drawable/app_banner");
            }
            if ((PlayerSettings.Android.androidTVCompatibility && !manifestXML.HasLeanbackLauncherActivity()) && !manifestXML.AddLeanbackLauncherActivity())
            {
                Debug.LogWarning("No activity with LEANBACK_LAUNCHER or LAUNCHER categories found.\nThe build may not be compatible with Android TV. Specify an activity with LEANBACK_LAUNCHER or LAUNCHER category in the manifest, or disable Android TV compatibility in Player Settings.");
            }
            switch (PlayerSettings.Android.androidGamepadSupportLevel)
            {
                case AndroidGamepadSupportLevel.SupportsGamepad:
                    manifestXML.AddUsesFeature("android.hardware.gamepad", false);
                    break;

                case AndroidGamepadSupportLevel.RequiresGamepad:
                    manifestXML.AddUsesFeature("android.hardware.gamepad", true);
                    break;
            }
            if (PlayerSettings.virtualRealitySupported)
            {
                manifestXML.OverrideTheme("@android:style/Theme.Black.NoTitleBar.Fullscreen");
                int num2 = context.Get<int>("GearVRMinSdkVersion");
                if (PlayerSettings.Android.minSdkVersion < num2)
                {
                    Debug.LogWarning("GearVR requires Minimum API Level of 19");
                }
            }
            AssemblyReferenceChecker checker = new AssemblyReferenceChecker();
            bool collectMethods = true;
            bool ignoreSystemDlls = true;
            string[] textArray3 = new string[] { str, "Data", "Managed" };
            string path = Paths.Combine(textArray3);
            checker.CollectReferences(path, collectMethods, 0f, ignoreSystemDlls);
            this.SetPermissionAttributes(context, manifestXML, checker);
            manifestXML.StripUnityLibEntryForNativeActitivy();
            manifestXML.SaveAs(manifest);
            return manifestXML.packageName;
        }