parent
75abc82500
commit
6ae05aad01
|
|
@ -1,8 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: 11c5c61708cec45b3886f7c93951d083
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
package="com.guru.unity.sdk.android.res.network.security"
|
|
||||||
android:versionCode="1"
|
|
||||||
android:versionName="1.0">
|
|
||||||
</manifest>
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: 038b314e2834b4b3f80537a3c7832481
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
target=android-9
|
|
||||||
android.library=`true`
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: 3a35ac1e970714224ba4adaae5756f10
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: c6c2e979b6e21424a8c8807754828741
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: 29db8462008d4d8d9220c83bf5dcd6e0
|
|
||||||
timeCreated: 1706057866
|
|
||||||
|
|
@ -65,7 +65,7 @@ namespace Guru.Editor
|
||||||
{
|
{
|
||||||
if (File.Exists(TargetFullPath)) return;
|
if (File.Exists(TargetFullPath)) return;
|
||||||
|
|
||||||
var path = GuruEditorHelper.GetFilePath($"{nameof(AndroidManifestMod)} t:Script");
|
var path = GuruEditorHelper.GetAssetPath(nameof(AndroidManifestMod), "Script", true);
|
||||||
if (!string.IsNullOrEmpty(path))
|
if (!string.IsNullOrEmpty(path))
|
||||||
{
|
{
|
||||||
var from = Path.GetFullPath($"{path}/../../Files/AndroidManifest.txt");
|
var from = Path.GetFullPath($"{path}/../../Files/AndroidManifest.txt");
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ namespace Guru.Editor
|
||||||
|
|
||||||
private static string GetMoveFilePath(string fileName)
|
private static string GetMoveFilePath(string fileName)
|
||||||
{
|
{
|
||||||
var path = GuruEditorHelper.GetFilePath($"{nameof(AndroidProjectMod)} t:Script");
|
var path = GuruEditorHelper.GetAssetPath(nameof(AndroidProjectMod), "Script", true);
|
||||||
var files = Path.GetFullPath($"{path}/../../Files");
|
var files = Path.GetFullPath($"{path}/../../Files");
|
||||||
return $"{files}/{fileName}";
|
return $"{files}/{fileName}";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ namespace Guru.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static bool DeployAllIcons(Texture2D source, Color color)
|
private static bool DeployAllIcons(Texture2D source, Color color)
|
||||||
{
|
{
|
||||||
var dir = AndroidLibHelper.CreateLibRoot(PackageName, LibName);
|
var dir = AndroidLibHelper.CreateLibRoot(PackageName, LibName);
|
||||||
string path = "";
|
string path = "";
|
||||||
|
|
@ -145,6 +145,8 @@ namespace Guru.Editor
|
||||||
doc.SetMetadata("com.google.firebase.messaging.default_notification_channel_id", "@string/default_notification_channel_id");
|
doc.SetMetadata("com.google.firebase.messaging.default_notification_channel_id", "@string/default_notification_channel_id");
|
||||||
doc.Save();
|
doc.Save();
|
||||||
Debug.Log("<color=#88ff00> --- Push Icon Build Success --- </color>");
|
Debug.Log("<color=#88ff00> --- Push Icon Build Success --- </color>");
|
||||||
|
|
||||||
|
AssetDatabase.Refresh();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,38 +6,43 @@ namespace Guru.Editor
|
||||||
|
|
||||||
public class AndroidResMod
|
public class AndroidResMod
|
||||||
{
|
{
|
||||||
private static readonly string ResName = "GuruNetworkSecurity";
|
private static readonly string NetworkSecurityXmlName = "network_security_config.xml";
|
||||||
private static string ResFullPath = Path.Combine(Application.dataPath, $"Plugins/Android/{ResName}.androidlib");
|
private static readonly string LibNetworkSecurity = "GuruNetworkSecurity";
|
||||||
private static string OldSecurityXml = Path.Combine(Application.dataPath, "Plugins/Android/res/xml/network_security_config.xml");
|
private static readonly string LibNetworkSecurityPackageName = "com.guru.unity.sdk.android.res.network.security";
|
||||||
|
private static string OldSecurityXml = Path.Combine(Application.dataPath, $"Plugins/Android/res/xml/{NetworkSecurityXmlName}");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 应用补丁
|
/// 应用补丁
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Apply()
|
public static void Apply()
|
||||||
{
|
{
|
||||||
DeployAndroidRes();
|
DeployNetworkSecurity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
private static void DeployAndroidRes()
|
/// 部署网络安全配置
|
||||||
|
/// </summary>
|
||||||
|
private static void DeployNetworkSecurity()
|
||||||
{
|
{
|
||||||
if(File.Exists(OldSecurityXml)) File.Delete(OldSecurityXml);
|
if(File.Exists(OldSecurityXml)) File.Delete(OldSecurityXml); // 清理旧文件
|
||||||
|
|
||||||
var spath = GuruEditorHelper.GetFilePath($"{nameof(AndroidResMod)} t:Script");
|
if (!AndroidLibHelper.IsEmbeddedAndroidLibExists(LibNetworkSecurity))
|
||||||
if (!string.IsNullOrEmpty(spath))
|
|
||||||
{
|
{
|
||||||
var from = Path.GetFullPath($"{spath}/../../Files/sdk_res");
|
string dir = AndroidLibHelper.CreateLibRoot(LibNetworkSecurityPackageName, LibNetworkSecurity);
|
||||||
if (Directory.Exists(from))
|
var d = GuruEditorHelper.GetAssetPath(nameof(AndroidResMod), "Script", true);
|
||||||
|
if (!string.IsNullOrEmpty(d))
|
||||||
{
|
{
|
||||||
var to = ResFullPath;
|
var from = $"{Directory.GetParent(d)?.FullName ?? ""}/Files/{NetworkSecurityXmlName}";
|
||||||
if (Directory.Exists(to))
|
if (File.Exists(from))
|
||||||
{
|
{
|
||||||
FileUtil.DeleteFileOrDirectory(ResFullPath);
|
string toDir = $"{dir}/res/xml";
|
||||||
|
if(!Directory.Exists(toDir))Directory.CreateDirectory(toDir);
|
||||||
|
string to = $"{toDir}/{NetworkSecurityXmlName}";
|
||||||
|
FileUtil.CopyFileOrDirectory(from, to);
|
||||||
}
|
}
|
||||||
FileUtil.CopyFileOrDirectory(from, to);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,20 +2,35 @@ namespace Guru.Editor
|
||||||
{
|
{
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
public class GuruEditorHelper
|
public class GuruEditorHelper
|
||||||
{
|
{
|
||||||
public static string GetFilePath(string filter)
|
public static string GetAssetPath(string filter, bool useFullPath = false)
|
||||||
{
|
{
|
||||||
var guids = AssetDatabase.FindAssets(filter);
|
var guids = AssetDatabase.FindAssets(filter);
|
||||||
|
string path = "";
|
||||||
|
string fullPath = "";
|
||||||
if (guids != null && guids.Length > 0)
|
if (guids != null && guids.Length > 0)
|
||||||
{
|
{
|
||||||
var path = AssetDatabase.GUIDToAssetPath(guids[0]);
|
path = AssetDatabase.GUIDToAssetPath(guids[0]);
|
||||||
return path;
|
fullPath = path.Replace("Assets", Application.dataPath);
|
||||||
|
if (File.Exists(fullPath))
|
||||||
|
{
|
||||||
|
return useFullPath? fullPath : path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetAssetPath(string fileName, string typeName = "", bool useFullPath = false)
|
||||||
|
{
|
||||||
|
var filter = fileName;
|
||||||
|
if(!string.IsNullOrEmpty(typeName)) filter = $"{fileName} t:{typeName}";
|
||||||
|
return GetAssetPath(filter, useFullPath);
|
||||||
|
}
|
||||||
|
|
||||||
public static void OpenPath(string path)
|
public static void OpenPath(string path)
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR_OSX
|
#if UNITY_EDITOR_OSX
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue