This commit is contained in:
2023-11-28 11:38:59 +05:30
commit ce059d4bf6
2742 changed files with 618089 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 719ae09d6be753e46845c9b349912e3e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,76 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* Licensed under the Oculus SDK License Agreement (the "License");
* you may not use the Oculus SDK except in compliance with the License,
* which is provided at the time of installation or download, or which
* otherwise accompanies this software in either electronic or hard copy form.
*
* You may obtain a copy of the License at
*
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Oculus SDK
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using Oculus.Voice.Core.Bindings.Interfaces;
using UnityEngine;
namespace Oculus.Voice.Core.Bindings.Android
{
public class AndroidServiceConnection : IConnection
{
private AndroidJavaObject mAssistantServiceConnection;
private string serviceFragmentClass;
private string serviceGetter;
public bool IsConnected => null != mAssistantServiceConnection;
public AndroidJavaObject AssistantServiceConnection => mAssistantServiceConnection;
/// <summary>
/// Creates a connection manager of the given type
/// </summary>
/// <param name="serviceFragmentClassName">The fully qualified class name of the service fragment that will manage this connection</param>
/// <param name="serviceGetterMethodName">The name of the method that will return an instance of the service</param>
/// TODO: We should make the getBlahService simply getService() within each fragment implementation.
public AndroidServiceConnection(string serviceFragmentClassName, string serviceGetterMethodName)
{
serviceFragmentClass = serviceFragmentClassName;
serviceGetter = serviceGetterMethodName;
}
public void Connect(string version)
{
if (null == mAssistantServiceConnection)
{
AndroidJNIHelper.debug = true;
AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject activity = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity");
using (AndroidJavaClass assistantBackgroundFragment = new AndroidJavaClass(serviceFragmentClass))
{
mAssistantServiceConnection =
assistantBackgroundFragment.CallStatic<AndroidJavaObject>("createAndAttach", activity, version);
}
}
}
public void Disconnect()
{
mAssistantServiceConnection.Call("detach");
}
public AndroidJavaObject GetService()
{
return mAssistantServiceConnection.Call<AndroidJavaObject>(serviceGetter);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 85f4ff04745e1ab459e49eb38bc288b9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,78 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* Licensed under the Oculus SDK License Agreement (the "License");
* you may not use the Oculus SDK except in compliance with the License,
* which is provided at the time of installation or download, or which
* otherwise accompanies this software in either electronic or hard copy form.
*
* You may obtain a copy of the License at
*
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Oculus SDK
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using UnityEngine;
namespace Oculus.Voice.Core.Bindings.Android
{
public class BaseAndroidConnectionImpl<T> where T : BaseServiceBinding
{
private string fragmentClassName;
protected T service;
protected readonly AndroidServiceConnection serviceConnection;
public bool IsConnected => serviceConnection.IsConnected;
public BaseAndroidConnectionImpl(string className)
{
fragmentClassName = className;
serviceConnection = new AndroidServiceConnection(className, "getService");
}
#region Service Connection
public virtual void Connect(string version)
{
serviceConnection.Connect(version);
var serviceInstance = serviceConnection.GetService();
if (null == serviceInstance)
{
throw new Exception("Unable to get service connection from " + fragmentClassName);
}
service = (T) Activator.CreateInstance(typeof(T), serviceInstance);
}
public virtual void Disconnect()
{
service.Shutdown();
serviceConnection.Disconnect();
service = null;
}
#endregion
}
public class BaseServiceBinding
{
protected AndroidJavaObject binding;
protected BaseServiceBinding(AndroidJavaObject sdkInstance)
{
binding = sdkInstance;
}
public void Shutdown()
{
binding.Call("shutdown");
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: aa5e9cb2d6b763f4c983b82092bb192d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9e17b7500d9de2e4fbb25afa6264094e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,84 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* Licensed under the Oculus SDK License Agreement (the "License");
* you may not use the Oculus SDK except in compliance with the License,
* which is provided at the time of installation or download, or which
* otherwise accompanies this software in either electronic or hard copy form.
*
* You may obtain a copy of the License at
*
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Oculus SDK
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using Oculus.Voice.Core.Bindings.Interfaces;
using Oculus.Voice.Core.Utilities;
using UnityEngine;
using Debug = UnityEngine.Debug;
namespace Oculus.Voice.Core.Bindings.Android.PlatformLogger
{
public class VoiceSDKConsoleLoggerImpl : IVoiceSDKLogger
{
public bool IsUsingPlatformIntegration { get; set; }
public string WitApplication { get; set; }
public bool ShouldLogToConsole { get; set; }
private static readonly string TAG = "VoiceSDKConsoleLogger";
private bool loggedFirstTranscriptionTime = false;
public void LogInteractionStart(string requestId, string witApi)
{
if (!ShouldLogToConsole) return;
loggedFirstTranscriptionTime = false;
Debug.Log($"{TAG}: Interaction started with request ID: " + requestId);
Debug.Log($"{TAG}: WitApi: " + witApi);
Debug.Log($"{TAG}: request_start_time: " + DateTimeUtility.ElapsedMilliseconds.ToString());
Debug.Log($"{TAG}: WitAppID: " + WitApplication);
Debug.Log($"{TAG}: PackageName: " + Application.identifier);
}
public void LogInteractionEndSuccess()
{
if (!ShouldLogToConsole) return;
Debug.Log($"{TAG}: Interaction finished successfully");
Debug.Log($"{TAG}: request_end_time: " + DateTimeUtility.ElapsedMilliseconds.ToString());
}
public void LogInteractionEndFailure(string errorMessage)
{
if (!ShouldLogToConsole) return;
Debug.Log($"{TAG}: Interaction finished with error: " + errorMessage);
Debug.Log($"{TAG}: request_end_time: " + DateTimeUtility.ElapsedMilliseconds.ToString());
}
public void LogInteractionPoint(string interactionPoint)
{
if (!ShouldLogToConsole) return;
Debug.Log($"{TAG}: Interaction point: " + interactionPoint);
Debug.Log($"{TAG}: {interactionPoint}_start_time: " + DateTimeUtility.ElapsedMilliseconds.ToString());
}
public void LogAnnotation(string annotationKey, string annotationValue)
{
if (!ShouldLogToConsole) return;
Debug.Log($"{TAG}: Logging key-value pair: {annotationKey}::{annotationValue}");
}
public void LogFirstTranscriptionTime()
{
if (!loggedFirstTranscriptionTime)
{
loggedFirstTranscriptionTime = true;
LogInteractionPoint("firstPartialTranscriptionTime");
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cbb89bbe77dad204f9e4a1322943320d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,60 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* Licensed under the Oculus SDK License Agreement (the "License");
* you may not use the Oculus SDK except in compliance with the License,
* which is provided at the time of installation or download, or which
* otherwise accompanies this software in either electronic or hard copy form.
*
* You may obtain a copy of the License at
*
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Oculus SDK
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using UnityEngine;
namespace Oculus.Voice.Core.Bindings.Android.PlatformLogger
{
public class VoiceSDKLoggerBinding : BaseServiceBinding
{
[UnityEngine.Scripting.Preserve]
public VoiceSDKLoggerBinding(AndroidJavaObject loggerInstance) : base(loggerInstance) {}
public void Connect()
{
binding.Call<bool>("connect");
}
public void LogInteractionStart(string requestId, string startTime)
{
binding.Call("logInteractionStart", requestId, startTime);
}
public void LogInteractionEndSuccess(string endTime)
{
binding.Call("logInteractionEndSuccess", endTime);
}
public void LogInteractionEndFailure(string endTime, string errorMessage)
{
binding.Call("logInteractionEndFailure", endTime, errorMessage);
}
public void LogInteractionPoint(string interactionPoint, string time)
{
binding.Call("logInteractionPoint", interactionPoint, time);
}
public void LogAnnotation(string annotationKey, string annotationValue)
{
binding.Call("logAnnotation", annotationKey, annotationValue);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 02f219e3a02e4055b3df9be4f5786e5a
timeCreated: 1652919643

View File

@@ -0,0 +1,103 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* Licensed under the Oculus SDK License Agreement (the "License");
* you may not use the Oculus SDK except in compliance with the License,
* which is provided at the time of installation or download, or which
* otherwise accompanies this software in either electronic or hard copy form.
*
* You may obtain a copy of the License at
*
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Oculus SDK
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using Oculus.Voice.Core.Bindings.Interfaces;
using Oculus.Voice.Core.Utilities;
using UnityEngine;
using Debug = UnityEngine.Debug;
namespace Oculus.Voice.Core.Bindings.Android.PlatformLogger
{
public class VoiceSDKPlatformLoggerImpl : BaseAndroidConnectionImpl<VoiceSDKLoggerBinding>, IVoiceSDKLogger
{
public bool IsUsingPlatformIntegration { get; set; }
public string WitApplication { get; set; }
public bool ShouldLogToConsole
{
get => consoleLoggerImpl.ShouldLogToConsole;
set => consoleLoggerImpl.ShouldLogToConsole = value;
}
private VoiceSDKConsoleLoggerImpl consoleLoggerImpl = new VoiceSDKConsoleLoggerImpl();
public VoiceSDKPlatformLoggerImpl() : base(
"com.oculus.assistant.api.unity.logging.UnityPlatformLoggerServiceFragment")
{
}
private bool loggedFirstTranscriptionTime = false;
public override void Connect(string version)
{
base.Connect(version);
service.Connect();
Debug.Log(
$"Logging Platform integration initialization complete.");
}
public override void Disconnect()
{
Debug.Log("Logging Platform integration shutdown");
base.Disconnect();
}
public void LogInteractionStart(string requestId, string witApi)
{
loggedFirstTranscriptionTime = false;
consoleLoggerImpl.LogInteractionStart(requestId, witApi);
service.LogInteractionStart(requestId, DateTimeUtility.ElapsedMilliseconds.ToString());
LogAnnotation("isUsingPlatform", IsUsingPlatformIntegration.ToString());
LogAnnotation("witApi", witApi);
LogAnnotation("witAppId", WitApplication);
LogAnnotation("package", Application.identifier);
}
public void LogInteractionEndSuccess()
{
consoleLoggerImpl.LogInteractionEndSuccess();
service.LogInteractionEndSuccess(DateTimeUtility.ElapsedMilliseconds.ToString());
}
public void LogInteractionEndFailure(string errorMessage)
{
consoleLoggerImpl.LogInteractionEndFailure(errorMessage);
service.LogInteractionEndFailure(DateTimeUtility.ElapsedMilliseconds.ToString(), errorMessage);
}
public void LogInteractionPoint(string interactionPoint)
{
consoleLoggerImpl.LogInteractionPoint(interactionPoint);
service.LogInteractionPoint(interactionPoint, DateTimeUtility.ElapsedMilliseconds.ToString());
}
public void LogAnnotation(string annotationKey, string annotationValue)
{
consoleLoggerImpl.LogAnnotation(annotationKey, annotationValue);
service.LogAnnotation(annotationKey, annotationValue);
}
public void LogFirstTranscriptionTime()
{
if (!loggedFirstTranscriptionTime)
{
loggedFirstTranscriptionTime = true;
LogInteractionPoint("firstPartialTranscriptionTime");
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: eee6ea0d8b185f54b8cba025115dea67
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,3 @@
{
"name": "AssistantCoreSDKRuntime"
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a7c32ded21d3b9b42a71cdf39f2ed8da
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5a116b0921542354a9d57799cba768bd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,30 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* Licensed under the Oculus SDK License Agreement (the "License");
* you may not use the Oculus SDK except in compliance with the License,
* which is provided at the time of installation or download, or which
* otherwise accompanies this software in either electronic or hard copy form.
*
* You may obtain a copy of the License at
*
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Oculus SDK
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace Oculus.Voice.Core.Bindings.Interfaces
{
public interface IConnection
{
void Connect(string version);
void Disconnect();
bool IsConnected { get; }
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0a8340504b2574441afe16939acde7ae
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,35 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* Licensed under the Oculus SDK License Agreement (the "License");
* you may not use the Oculus SDK except in compliance with the License,
* which is provided at the time of installation or download, or which
* otherwise accompanies this software in either electronic or hard copy form.
*
* You may obtain a copy of the License at
*
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Oculus SDK
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace Oculus.Voice.Core.Bindings.Interfaces
{
public interface IVoiceSDKLogger
{
bool IsUsingPlatformIntegration { get; set; }
bool ShouldLogToConsole { get; set; }
string WitApplication { get; set; }
void LogInteractionStart(string requestId, string witApi);
void LogInteractionEndSuccess();
void LogInteractionEndFailure(string errorMessage);
void LogInteractionPoint(string interactionPoint);
void LogAnnotation(string annotationKey, string annotationValue);
void LogFirstTranscriptionTime();
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e1120ad58e6347809f136d52caa7638f
timeCreated: 1652979217

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 48dd050ce4e9b904fa2888ae3c2724d2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,38 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* Licensed under the Oculus SDK License Agreement (the "License");
* you may not use the Oculus SDK except in compliance with the License,
* which is provided at the time of installation or download, or which
* otherwise accompanies this software in either electronic or hard copy form.
*
* You may obtain a copy of the License at
*
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Oculus SDK
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Based off Unity forum post https://forum.unity.com/threads/how-to-change-the-name-of-list-elements-in-the-inspector.448910/
using UnityEngine;
namespace Oculus.Voice.Core.Utilities
{
public class ArrayElementTitleAttribute : PropertyAttribute
{
public string varname;
public string fallbackName;
public ArrayElementTitleAttribute(string elementTitleVar = null, string fallbackName = null)
{
varname = elementTitleVar;
this.fallbackName = fallbackName;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cd85a8631126f474f8d69375b5cc2bf4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,25 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
namespace Oculus.Voice.Core.Utilities
{
public class DateTimeUtility
{
public static DateTime UtcNow
{
get => DateTime.UtcNow;
}
public static long ElapsedMilliseconds
{
get => UtcNow.Ticks / TimeSpan.TicksPerMillisecond;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 572733f79a0d4ca698f549719e65df51
timeCreated: 1653065378