diff --git a/Editor/GuruManager/Helper/AndroidManifestDoc.cs b/Editor/GuruManager/Helper/AndroidManifestDoc.cs index 6a5f28e..63b13cf 100644 --- a/Editor/GuruManager/Helper/AndroidManifestDoc.cs +++ b/Editor/GuruManager/Helper/AndroidManifestDoc.cs @@ -32,6 +32,7 @@ namespace Guru.Editor private XmlElement _manifestNode; private XmlElement _applicationNode; + private XmlElement _queriesNode; #region Initiallize @@ -103,6 +104,8 @@ namespace Guru.Editor // --- Root Nodes --- _manifestNode = _doc.SelectSingleNode("manifest") as XmlElement; _applicationNode = _doc.SelectSingleNode("manifest/application") as XmlElement; + _queriesNode = _doc.SelectSingleNode("manifest/queries") as XmlElement; + AddXmlnsAndroid(); AddXmlnsTools(); @@ -270,6 +273,44 @@ namespace Guru.Editor return false; } + /// + /// 添加 Queries Intent + /// + /// + /// + /// + public void AddQueriesIntent(string value, string keyName = "name") + { + if (_queriesNode == null) + { + _queriesNode = _doc.CreateElement("queries"); + _manifestNode?.AppendChild(_queriesNode); + } + + var intentList = _queriesNode.SelectNodes("intent"); + if (intentList != null) + { + foreach (XmlElement intent in intentList) + { + var action = intent?.SelectSingleNode("action") as XmlElement; + + if (action != null + && action.GetAttribute(keyName, NamespaceAndroid) == value) + { + return; // Has injected,skip ... + } + } + } + + // Inject new intent node + XmlElement intentNode = _doc.CreateElement("intent"); + _queriesNode.AppendChild(intentNode); + XmlElement actionNode = _doc.CreateElement("action"); + intentNode.AppendChild(actionNode); + actionNode.SetAttribute(keyName, NamespaceAndroid, value); + } + + #endregion #region Data Opration @@ -319,6 +360,17 @@ namespace Guru.Editor return false; } + public bool TryRootNode(string nodeName, out XmlElement node) + { + node = null; + if (_doc != null) + { + node = _doc.SelectSingleNode(nodeName) as XmlElement; + return node != null; + } + return false; + } + #endregion #region Output diff --git a/Editor/GuruManager/Helper/AndroidManifestMod.cs b/Editor/GuruManager/Helper/AndroidManifestMod.cs index 3a4583c..2a65123 100644 --- a/Editor/GuruManager/Helper/AndroidManifestMod.cs +++ b/Editor/GuruManager/Helper/AndroidManifestMod.cs @@ -22,13 +22,17 @@ namespace Guru.Editor private const string PermissionReadLogs = "android.permission.READ_LOGS"; private const string NetworkSecurityConfig = "networkSecurityConfig"; private const string NetworkSecurityConfigValue = "@xml/network_security_config"; + private const string PermissionAdjustReadPermission = "com.adjust.preinstall.READ_PERMISSION"; // Adjust permission + private const string AdjustQueriesActionValue = "com.attribution.REFERRAL_PROVIDER"; // Adjust action - + // Add Permissions private static string[] addPermissions = new[] { PermissionReadPostNotifications, + PermissionAdjustReadPermission, }; + // Remove Permissions private static string[] removePermissions = new[] { PermissionReadPhoneState, @@ -82,6 +86,9 @@ namespace Guru.Editor // --- Bundle Id --- doc.SetPackageName(PlayerSettings.applicationIdentifier); + // --- Adjust Preinstall (Content provider) --- + doc.AddQueriesIntent(AdjustQueriesActionValue); + doc.Save(); }