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 static bool EditManifest(AndroidManifest androidManifest)
    {
        var changed = false;

        changed |= androidManifest.AddActivity("com.kuan.sharekit16.GalleryActivity",
                                               attributes: new Dictionary <string, string>());
        changed |= androidManifest.AddUsesPermission("android.permission.WRITE_EXTERNAL_STORAGE");

        var providerName = "androidx.core.content.FileProvider";

        changed |= androidManifest.AddProvider(providerName, attributes: new Dictionary <string, string>
        {
            { "authorities", Application.identifier + ".fileprovider" },
            { "exported", "false" },
            { "grantUriPermissions", "true" },
        });
        changed |= androidManifest.AddMetaData("provider", providerName, "android.support.FILE_PROVIDER_PATHS",
                                               attributes: new Dictionary <string, string>
        {
            { "resource", "@xml/filepaths" },
        });

        return(changed);
    }
 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");
     }
 }