From 8b5f42706e17b600aef15c017d38137f6ae16b08 Mon Sep 17 00:00:00 2001 From: huyufei Date: Thu, 30 May 2024 09:41:22 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E6=B7=BB=E5=8A=A0=20Adjust=20preinst?= =?UTF-8?q?all=20Tracker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --story=1020232 --user=yufei.hu 【中台】【SDK】添加 Adjust Preinstall Tracker 功能 https://www.tapd.cn/33527076/s/1147510 --- .../GuruManager/Helper/AndroidManifestDoc.cs | 52 +++++++++++++++++++ .../GuruManager/Helper/AndroidManifestMod.cs | 9 +++- 2 files changed, 60 insertions(+), 1 deletion(-) 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(); }