This commit is contained in:
2023-10-19 18:00:10 +08:00
parent eb03d003b6
commit cf96fb8457
16 changed files with 92 additions and 114 deletions

View File

@@ -23,14 +23,17 @@ namespace Topon_Adapter.Editor
{
#if UNITY_2019_3_OR_NEWER
var manifestPath = Path.Combine(path, "src/main/AndroidManifest.xml");
var launcherManifestPath = Path.Combine(path, "../launcher/src/main/AndroidManifest.xml");
#else
var manifestPath = Path.Combine(path, "unityLibrary/src/main/AndroidManifest.xml");
#endif
// var manifestPath = Path.Combine(path, "src/main/AndroidManifest.xml");
XDocument manifest;
XDocument launcherManifest;
try
{
manifest = XDocument.Load(manifestPath);
manifest = XDocument.Load(manifestPath);
launcherManifest = XDocument.Load (launcherManifestPath);
}
#pragma warning disable 0168
catch (IOException exception)
@@ -55,11 +58,19 @@ namespace Topon_Adapter.Editor
return;
}
elementManifest.Add(CreateQueries());
var queries = CreateQueries();
elementManifest.Add(queries);
elementApplication.Add(CreateActivityXML());
var elementlauncherManifest = launcherManifest.Element("manifest");
var elementlauncherApplication = elementlauncherManifest.Element("application");
//增加穿山甲配置
elementlauncherApplication.Add (CreateCSJGromore ());
// Save the updated manifest file.
manifest.Save(manifestPath);
launcherManifest.Save (launcherManifestPath);
}
/// <summary>
@@ -87,6 +98,37 @@ namespace Topon_Adapter.Editor
return metaData;
}
public static XElement CreateCSJGromore ()
{
// ReSharper disable once InvalidXmlDocComment
/**
*<provider
android:name="com.bytedance.sdk.openadsdk.TTFileProvider"
android:authorities="${applicationId}.TTFileProvider"
android:exported="false"
android:grantUriPermissions="true"
tools:replace="android:authorities">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/alex_tt_file_path" />
</provider>
*
*/
var providerData = new XElement("provider");
providerData.Add (new XAttribute (AndroidNamespace + "name" , "com.bytedance.sdk.openadsdk.TTFileProvider"));
providerData.Add (new XAttribute (AndroidNamespace + "authorities" , "${applicationId}.TTFileProvider"));
providerData.Add (new XAttribute (AndroidNamespace + "exported" , "false"));
providerData.Add (new XAttribute (AndroidNamespace + "grantUriPermissions" , "true"));
providerData.Add (new XAttribute (ToolsNamespace + "replace" , "android:authorities"));
var metaData = new XElement("meta-data");
metaData.Add (new XAttribute (AndroidNamespace+"name" , "android.support.FILE_PROVIDER_PATHS"));
metaData.Add (new XAttribute (AndroidNamespace+"resource" , "@xml/alex_tt_file_path"));
providerData.Add (metaData);
return providerData;
}
public int callbackOrder { get; }
}
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<dependencies>
<androidPackages>
<repositories>
<repository>https://jfrog.anythinktech.com/artifactory/debugger</repository>
</repositories>
<androidPackage spec="com.anythink.sdk:debugger-ui:1.0.0"/>
</androidPackages>
</dependencies>

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a130901ed98e40898c3917a08e126996
timeCreated: 1697702311

View File

@@ -1,6 +1,7 @@
using System;
using AnyThinkAds.Api;
using Runtime.ADAggregator;
using UnityEngine;
public class ToponAdController : IAdController
{
@@ -14,8 +15,13 @@ public class ToponAdController : IAdController
_adConfig = adConfig;
// ATSdkUtil.
ATSDKAPI.setChannel(args[0].ToString());
ATSDKAPI.setLogDebug(args.Length > 1 && (bool)args[1]);
var isDebug = args.Length > 1 && (bool)args[1];
ATSDKAPI.setLogDebug(isDebug);
ATSDKAPI.initSDK(adConfig.Id , adConfig.Key);
if (isDebug)
{
ShowAndroidTest ();
}
}
public void SetListener(Action<bool> adMaskAction ,Action<string, string> logEventAction)
@@ -49,4 +55,25 @@ public class ToponAdController : IAdController
{
_maskAction?.Invoke(isOpen);
}
private void ShowAndroidTest ()
{
// com.anythink.debug.api.ATDebuggerUITest.showDebuggerUI(this);
#if UNITY_EDITOR
return;
#elif UNITY_ANDROID
//获取Unity的Activity Class
using (AndroidJavaClass activityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
{
//获取对应的实例化对象,这两句都是固定写法
using (AndroidJavaObject activityContext = activityClass.GetStatic<AndroidJavaObject>("currentActivity"))
{
//拿到我自己的工具类并实例化
var testUtils = new AndroidJavaClass("com.anythink.debug.api.ATDebuggerUITest");
//向工具类里的Init方法传入Unity的activity对象用于初始化工具类
testUtils.CallStatic("showDebuggerUI", activityContext);
}
}
#endif
}
}