OculusManifestBTFixer.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // using System.Xml;
  2. // using UnityEditor;
  3. // using UnityEditor.Android;
  4. // using UnityEditor.XR.Oculus;
  5. // #if UNITY_ANDROID
  6. // internal class OculusManifestBTFixer : IPostGenerateGradleAndroidProject {
  7. // static readonly string k_AndroidURI = "http://schemas.android.com/apk/res/android";
  8. // static readonly string k_AndroidManifestPath = "/src/main/AndroidManifest.xml";
  9. // void CreateNameValueElementsInTag(XmlDocument doc, string parentPath, string tag,
  10. // string firstName, string firstValue, string secondName = null, string secondValue = null, string thirdName = null, string thirdValue = null) {
  11. // var xmlNodeList = doc.SelectNodes(parentPath + "/" + tag);
  12. // // don't create if the firstValue matches
  13. // foreach (XmlNode node in xmlNodeList) {
  14. // foreach (XmlAttribute attrib in node.Attributes) {
  15. // if (attrib.Value == firstValue) {
  16. // return;
  17. // }
  18. // }
  19. // }
  20. // XmlElement childElement = doc.CreateElement(tag);
  21. // childElement.SetAttribute(firstName, k_AndroidURI, firstValue);
  22. // if (secondValue != null) {
  23. // childElement.SetAttribute(secondName, k_AndroidURI, secondValue);
  24. // }
  25. // if (thirdValue != null) {
  26. // childElement.SetAttribute(thirdName, k_AndroidURI, thirdValue);
  27. // }
  28. // var xmlParentNode = doc.SelectSingleNode(parentPath);
  29. // if (xmlParentNode != null) {
  30. // xmlParentNode.AppendChild(childElement);
  31. // }
  32. // }
  33. // public void OnPostGenerateGradleAndroidProject(string path) {
  34. // if (!OculusBuildTools.OculusLoaderPresentInSettingsForBuildTarget(BuildTargetGroup.Android))
  35. // return;
  36. // var manifestPath = path + k_AndroidManifestPath;
  37. // var manifestDoc = new XmlDocument();
  38. // manifestDoc.Load(manifestPath);
  39. // string nodePath = "/manifest";
  40. // CreateNameValueElementsInTag(manifestDoc, nodePath, "uses-permission", "name", "android.permission.BLUETOOTH");
  41. // CreateNameValueElementsInTag(manifestDoc, nodePath, "uses-permission", "name", "android.permission.BLUETOOTH_CONNECT");
  42. // CreateNameValueElementsInTag(manifestDoc, nodePath, "uses-permission", "name", "android.permission.BLUETOOTH_SCAN");
  43. // manifestDoc.Save(manifestPath);
  44. // }
  45. // public int callbackOrder { get { return 20000; } }
  46. // }
  47. // #endif