Beispiel #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");
     }
 }
 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");
     }
 }
Beispiel #3
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;
        }