├── .editorconfig
├── .gitignore
├── .ruby-version
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── ar
│ └── AndroidManifest.xml
│ └── main
│ ├── AndroidManifest.xml
│ ├── ic_launcher-playstore.png
│ ├── java
│ └── com
│ │ └── unity3d
│ │ └── ads
│ │ └── example
│ │ ├── UnityAdsTestApp.java
│ │ └── ui
│ │ └── main
│ │ ├── SectionsPagerAdapter.java
│ │ └── UnityAdsFragment.java
│ └── res
│ ├── drawable
│ ├── ic_launcher_background.xml
│ ├── ic_launcher_foreground.xml
│ ├── unityads_example_background.xml
│ └── unityads_logo.png
│ ├── layout
│ ├── activity_unity_ads_test_app.xml
│ └── fragment_unity_ads.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── dokka.gradle
├── fatAar.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── nexusPublishing.gradle
├── qodana.yml
├── settings.gradle
├── unity-ads
├── .gitignore
├── artifactory.gradle
├── build.gradle
├── proguard-rules.pro
├── publishing.gradle
└── src
│ ├── androidTest
│ ├── AndroidManifest.xml
│ └── java
│ │ └── com
│ │ └── unity3d
│ │ ├── ads
│ │ └── test
│ │ │ ├── EnvironmentTestSuite.java
│ │ │ ├── HybridTestSuite.java
│ │ │ ├── InstrumentationTestSuite.java
│ │ │ ├── IntegrationTestSuite.java
│ │ │ ├── LegacyTestSuite.java
│ │ │ ├── TestUtilities.java
│ │ │ ├── environment
│ │ │ └── EnvironmentTest.java
│ │ │ ├── hybrid
│ │ │ ├── HybridTest.java
│ │ │ ├── HybridTestActivity.java
│ │ │ └── HybridTestModuleConfiguration.java
│ │ │ ├── instrumentation
│ │ │ ├── InstrumentationTestActivity.java
│ │ │ └── services
│ │ │ │ ├── ads
│ │ │ │ ├── gmascar
│ │ │ │ │ ├── GMAScarAdapterBridgeTest.java
│ │ │ │ │ ├── GmaScarTestSuite.java
│ │ │ │ │ ├── adapters
│ │ │ │ │ │ └── ScarAdapterFactoryTest.java
│ │ │ │ │ ├── bridges
│ │ │ │ │ │ ├── AdapterStatusBridgeTest.java
│ │ │ │ │ │ ├── InitializationStatusBridgeTest.java
│ │ │ │ │ │ ├── InitializeListenerBridgeTest.java
│ │ │ │ │ │ ├── MobileAdsBridgeLegacyTest.java
│ │ │ │ │ │ └── MobileAdsBridgeTest.java
│ │ │ │ │ ├── finder
│ │ │ │ │ │ ├── GMAInitializerTest.java
│ │ │ │ │ │ ├── PresenceDetectorTest.java
│ │ │ │ │ │ └── ScarVersionFinderTest.java
│ │ │ │ │ ├── handlers
│ │ │ │ │ │ ├── BiddingSignalsHandlerTest.java
│ │ │ │ │ │ ├── ScarBannerAdHandlerTest.java
│ │ │ │ │ │ ├── ScarInterstitialAdHandlerTest.java
│ │ │ │ │ │ └── ScarRewardedAdHandlerTest.java
│ │ │ │ │ └── managers
│ │ │ │ │ │ ├── BiddingBaseManagerTest.java
│ │ │ │ │ │ └── BiddingEagerManagerTest.java
│ │ │ │ ├── operation
│ │ │ │ │ ├── AdOperationTests.java
│ │ │ │ │ ├── BaseLoadModuleTests.java
│ │ │ │ │ ├── LoadBannerModuleTests.java
│ │ │ │ │ ├── LoadModuleDecoratorInitializationBufferTests.java
│ │ │ │ │ ├── LoadModuleDecoratorTests.java
│ │ │ │ │ ├── LoadModuleDecoratorTimeoutTests.java
│ │ │ │ │ ├── LoadModuleTests.java
│ │ │ │ │ ├── LoadOperationTests.java
│ │ │ │ │ ├── OperationTestUtilities.java
│ │ │ │ │ ├── ShowModuleDecoratorTimeoutTests.java
│ │ │ │ │ └── ShowModuleTests.java
│ │ │ │ └── webplayer
│ │ │ │ │ ├── WebPlayerViewCacheTest.java
│ │ │ │ │ └── WebPlayerViewSettingsCacheTest.java
│ │ │ │ ├── banners
│ │ │ │ ├── BannerErrorInfoTest.java
│ │ │ │ └── BannerViewCacheTests.java
│ │ │ │ ├── core
│ │ │ │ ├── configuration
│ │ │ │ │ └── InitializationNotificationCenterTest.java
│ │ │ │ ├── device
│ │ │ │ │ ├── DeviceInfoDataFactoryTest.java
│ │ │ │ │ ├── DeviceInfoReaderBuilderTest.java
│ │ │ │ │ ├── DeviceInfoReaderCompressorTest.java
│ │ │ │ │ ├── DeviceInfoReaderExtendedTest.java
│ │ │ │ │ ├── DeviceInfoReaderFilterProviderTest.java
│ │ │ │ │ ├── DeviceInfoReaderPrivacyBuilderTest.java
│ │ │ │ │ ├── DeviceInfoReaderWithExtrasTest.java
│ │ │ │ │ ├── DeviceInfoReaderWithFilterTest.java
│ │ │ │ │ ├── DeviceInfoReaderWithNonBehavioralFlagTest.java
│ │ │ │ │ ├── DeviceInfoReaderWithPrivacyTest.java
│ │ │ │ │ ├── DeviceInfoReaderWithRequestTypeTest.java
│ │ │ │ │ ├── DeviceInfoReaderWithSessionIdTest.java
│ │ │ │ │ ├── DeviceInfoReaderWithStorageInfoTest.java
│ │ │ │ │ ├── GameSessionIdReaderTest.java
│ │ │ │ │ ├── InMemoryAsyncTokenStorageTest.java
│ │ │ │ │ ├── MinimalDeviceInfoReaderTest.java
│ │ │ │ │ ├── NativeTokenGeneratorTest.java
│ │ │ │ │ └── NativeTokenGeneratorWithPrivacyAwaitTest.java
│ │ │ │ ├── misc
│ │ │ │ │ └── IntervalTimerTest.java
│ │ │ │ └── webview
│ │ │ │ │ ├── WebViewUrlBuilderTest.java
│ │ │ │ │ └── bridge
│ │ │ │ │ ├── WebViewBridgeSharedObjectTests.java
│ │ │ │ │ └── invocation
│ │ │ │ │ └── WebViewBridgeInvocationRunnableTests.java
│ │ │ │ └── store
│ │ │ │ └── gpbl
│ │ │ │ └── bridges
│ │ │ │ └── PurchasesResultBridgeTest.java
│ │ │ ├── integration
│ │ │ ├── SDKMetricsTest.java
│ │ │ └── banner
│ │ │ │ └── BannerIntegrationTest.java
│ │ │ └── legacy
│ │ │ ├── AdUnitActivityTest.java
│ │ │ ├── AdUnitActivityTestBaseClass.java
│ │ │ ├── AdvertisingIdentifierTest.java
│ │ │ ├── BroadcastTest.java
│ │ │ ├── CacheTest.java
│ │ │ ├── ClientPropertiesTest.java
│ │ │ ├── ConfigurationTest.java
│ │ │ ├── ConnectivityTest.java
│ │ │ ├── DeviceTest.java
│ │ │ ├── EnvironmentCheckTest.java
│ │ │ ├── EventIdTest.java
│ │ │ ├── InMemoryTokenStorageTest.java
│ │ │ ├── InitializeThreadTest.java
│ │ │ ├── InvocationTest.java
│ │ │ ├── LifecycleListenerTest.java
│ │ │ ├── LifecycleListenerTestActivity.java
│ │ │ ├── LifecycleListenerTestBaseActivity.java
│ │ │ ├── MetaDataTest.java
│ │ │ ├── NativeCallbackTest.java
│ │ │ ├── OpenAdvertisingIdentifierTest.java
│ │ │ ├── PreferencesTest.java
│ │ │ ├── PublicApiTest.java
│ │ │ ├── RequestTest.java
│ │ │ ├── SdkPropertiesTest.java
│ │ │ ├── SensorInfoTest.java
│ │ │ ├── StorageDiskTest.java
│ │ │ ├── StorageGeneralTest.java
│ │ │ ├── StorageMemoryTest.java
│ │ │ ├── TestActivity.java
│ │ │ ├── UtilitiesTest.java
│ │ │ ├── VideoViewTest.java
│ │ │ ├── VolumeChangeContentObserverTest.java
│ │ │ ├── WebPlayerViewTest.java
│ │ │ ├── WebRequestThreadPoolTest.java
│ │ │ ├── WebViewAppTest.java
│ │ │ ├── WebViewBridgeInterfaceTest.java
│ │ │ ├── WebViewBridgeTest.java
│ │ │ └── WebViewCallbackTest.java
│ │ └── services
│ │ ├── analytics
│ │ ├── AcquisitionTypeTest.java
│ │ ├── UnityAnalyticsTest.java
│ │ └── mocks
│ │ │ └── UnityAnalyticsMock.java
│ │ └── core
│ │ ├── request
│ │ └── metrics
│ │ │ └── MetricCommonTagsTest.java
│ │ └── timer
│ │ └── BaseTimerTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ └── java
│ │ └── com
│ │ └── unity3d
│ │ ├── ads
│ │ ├── IUnityAdsInitializationListener.java
│ │ ├── IUnityAdsLoadListener.java
│ │ ├── IUnityAdsShowListener.java
│ │ ├── IUnityAdsTokenListener.java
│ │ ├── UnityAds.java
│ │ ├── UnityAdsBaseOptions.java
│ │ ├── UnityAdsLoadOptions.java
│ │ ├── UnityAdsShowOptions.java
│ │ └── metadata
│ │ │ ├── InAppPurchaseMetaData.java
│ │ │ ├── MediationMetaData.java
│ │ │ ├── MetaData.java
│ │ │ └── PlayerMetaData.java
│ │ └── services
│ │ ├── SDKErrorHandler.kt
│ │ ├── UnityAdsSDK.kt
│ │ ├── UnityServices.kt
│ │ ├── ads
│ │ ├── IUnityAds.java
│ │ ├── UnityAdsImplementation.java
│ │ ├── adunit
│ │ │ ├── AdUnitActivity.java
│ │ │ ├── AdUnitActivityController.java
│ │ │ ├── AdUnitError.java
│ │ │ ├── AdUnitEvent.java
│ │ │ ├── AdUnitMotionEvent.java
│ │ │ ├── AdUnitOpen.java
│ │ │ ├── AdUnitRelativeLayout.java
│ │ │ ├── AdUnitSoftwareActivity.java
│ │ │ ├── AdUnitTransparentActivity.java
│ │ │ ├── AdUnitTransparentActivityController.java
│ │ │ ├── AdUnitTransparentSoftwareActivity.java
│ │ │ ├── AdUnitViewHandlerFactory.java
│ │ │ ├── IAdUnitActivity.java
│ │ │ ├── IAdUnitViewHandler.java
│ │ │ ├── IAdUnitViewHandlerFactory.java
│ │ │ ├── PermissionsEvent.java
│ │ │ ├── VideoPlayerHandler.java
│ │ │ ├── WebPlayerHandler.java
│ │ │ └── WebViewHandler.java
│ │ ├── api
│ │ │ ├── AdUnit.java
│ │ │ ├── GMAScar.java
│ │ │ ├── Load.java
│ │ │ ├── Measurements.java
│ │ │ ├── Show.java
│ │ │ ├── Token.java
│ │ │ ├── Topics.java
│ │ │ ├── VideoPlayer.java
│ │ │ └── WebPlayer.java
│ │ ├── configuration
│ │ │ ├── AdsModuleConfiguration.java
│ │ │ └── IAdsModuleConfiguration.java
│ │ ├── gmascar
│ │ │ ├── GMA.java
│ │ │ ├── GMAScarAdapterBridge.java
│ │ │ ├── adapters
│ │ │ │ └── ScarAdapterFactory.java
│ │ │ ├── bridges
│ │ │ │ ├── AdapterStatusBridge.java
│ │ │ │ ├── AdapterStatusStateBridge.java
│ │ │ │ ├── InitializationStatusBridge.java
│ │ │ │ ├── InitializeListenerBridge.java
│ │ │ │ └── mobileads
│ │ │ │ │ ├── IMobileAdsBridge.java
│ │ │ │ │ ├── MobileAdsBridge.java
│ │ │ │ │ ├── MobileAdsBridgeBase.java
│ │ │ │ │ ├── MobileAdsBridgeFactory.java
│ │ │ │ │ └── MobileAdsBridgeLegacy.java
│ │ │ ├── finder
│ │ │ │ ├── GMAInitializer.java
│ │ │ │ ├── PresenceDetector.java
│ │ │ │ ├── ScarAdapterVersion.java
│ │ │ │ └── ScarVersionFinder.java
│ │ │ ├── handlers
│ │ │ │ ├── BiddingSignalsHandler.java
│ │ │ │ ├── ScarAdHandlerBase.java
│ │ │ │ ├── ScarBannerAdHandler.java
│ │ │ │ ├── ScarInterstitialAdHandler.java
│ │ │ │ ├── ScarRewardedAdHandler.java
│ │ │ │ ├── SignalsHandler.java
│ │ │ │ └── WebViewErrorHandler.java
│ │ │ ├── listeners
│ │ │ │ ├── IBiddingSignalsListener.java
│ │ │ │ └── IInitializationStatusListener.java
│ │ │ ├── managers
│ │ │ │ ├── BiddingBaseManager.java
│ │ │ │ ├── BiddingDisabledManager.java
│ │ │ │ ├── BiddingEagerManager.java
│ │ │ │ ├── BiddingManagerFactory.java
│ │ │ │ └── IBiddingManager.java
│ │ │ ├── models
│ │ │ │ └── BiddingSignals.java
│ │ │ └── utils
│ │ │ │ ├── GMAEventSender.java
│ │ │ │ ├── ScarConstants.java
│ │ │ │ └── ScarRequestHandler.java
│ │ ├── measurements
│ │ │ ├── MeasurementErrors.kt
│ │ │ ├── MeasurementEvents.kt
│ │ │ ├── MeasurementsReceiver.kt
│ │ │ ├── MeasurementsService.kt
│ │ │ └── MeasurementsStatusReceiver.kt
│ │ ├── operation
│ │ │ ├── AdModule.java
│ │ │ ├── AdOperation.java
│ │ │ ├── IAdModule.java
│ │ │ ├── IAdOperation.java
│ │ │ ├── OperationState.java
│ │ │ ├── load
│ │ │ │ ├── BaseLoadModule.java
│ │ │ │ ├── ILoadModule.java
│ │ │ │ ├── ILoadOperation.java
│ │ │ │ ├── LoadBannerModule.java
│ │ │ │ ├── LoadBannerOperationState.java
│ │ │ │ ├── LoadModule.java
│ │ │ │ ├── LoadModuleDecorator.java
│ │ │ │ ├── LoadModuleDecoratorInitializationBuffer.java
│ │ │ │ ├── LoadModuleDecoratorTimeout.java
│ │ │ │ ├── LoadOperation.java
│ │ │ │ └── LoadOperationState.java
│ │ │ └── show
│ │ │ │ ├── IShowModule.java
│ │ │ │ ├── IShowOperation.java
│ │ │ │ ├── ShowModule.java
│ │ │ │ ├── ShowModuleDecorator.java
│ │ │ │ ├── ShowModuleDecoratorTimeout.java
│ │ │ │ ├── ShowOperation.java
│ │ │ │ └── ShowOperationState.java
│ │ ├── token
│ │ │ ├── AsyncTokenStorage.kt
│ │ │ ├── INativeTokenGenerator.java
│ │ │ ├── INativeTokenGeneratorListener.java
│ │ │ ├── InMemoryAsyncTokenStorage.java
│ │ │ ├── InMemoryTokenStorage.kt
│ │ │ ├── NativeTokenGenerator.java
│ │ │ ├── NativeTokenGeneratorWithPrivacyAwait.java
│ │ │ ├── TokenError.java
│ │ │ ├── TokenEvent.java
│ │ │ └── TokenStorage.kt
│ │ ├── topics
│ │ │ ├── TopicsErrors.kt
│ │ │ ├── TopicsEvents.kt
│ │ │ ├── TopicsReceiver.kt
│ │ │ ├── TopicsService.kt
│ │ │ └── TopicsStatus.kt
│ │ ├── video
│ │ │ ├── VideoPlayerError.java
│ │ │ ├── VideoPlayerEvent.java
│ │ │ └── VideoPlayerView.java
│ │ └── webplayer
│ │ │ ├── WebPlayerBridgeInterface.java
│ │ │ ├── WebPlayerError.java
│ │ │ ├── WebPlayerEvent.java
│ │ │ ├── WebPlayerEventBridge.java
│ │ │ ├── WebPlayerSettingsCache.java
│ │ │ ├── WebPlayerView.java
│ │ │ └── WebPlayerViewCache.java
│ │ ├── analytics
│ │ ├── AcquisitionType.java
│ │ ├── UnityAnalytics.java
│ │ ├── core
│ │ │ ├── api
│ │ │ │ └── Analytics.java
│ │ │ └── configuration
│ │ │ │ └── AnalyticsModuleConfiguration.java
│ │ └── interfaces
│ │ │ ├── Analytics.java
│ │ │ ├── AnalyticsError.java
│ │ │ └── IAnalytics.java
│ │ ├── banners
│ │ ├── BannerErrorCode.java
│ │ ├── BannerErrorInfo.java
│ │ ├── BannerView.java
│ │ ├── BannerViewCache.java
│ │ ├── IUnityBannerListener.java
│ │ ├── UnityBannerSize.kt
│ │ ├── UnityBanners.java
│ │ ├── api
│ │ │ ├── Banner.java
│ │ │ └── BannerListener.java
│ │ ├── bridge
│ │ │ └── BannerBridge.java
│ │ ├── configuration
│ │ │ └── BannersModuleConfiguration.java
│ │ ├── properties
│ │ │ └── BannerRefreshInfo.java
│ │ └── view
│ │ │ ├── BannerPosition.java
│ │ │ ├── BannerWebPlayerContainer.java
│ │ │ └── ScarBannerContainer.java
│ │ ├── core
│ │ ├── api
│ │ │ ├── Broadcast.java
│ │ │ ├── Cache.java
│ │ │ ├── ClassDetection.java
│ │ │ ├── Connectivity.java
│ │ │ ├── DeviceInfo.java
│ │ │ ├── DownloadLatestWebViewStatus.java
│ │ │ ├── Intent.java
│ │ │ ├── Lifecycle.java
│ │ │ ├── Permissions.java
│ │ │ ├── Preferences.java
│ │ │ ├── Request.java
│ │ │ ├── Resolve.java
│ │ │ ├── Sdk.java
│ │ │ ├── SensorInfo.java
│ │ │ └── Storage.java
│ │ ├── broadcast
│ │ │ ├── BroadcastError.java
│ │ │ ├── BroadcastEvent.java
│ │ │ ├── BroadcastEventReceiver.java
│ │ │ └── BroadcastMonitor.java
│ │ ├── cache
│ │ │ ├── CacheDirectory.java
│ │ │ ├── CacheDirectoryType.java
│ │ │ ├── CacheError.java
│ │ │ ├── CacheEvent.java
│ │ │ ├── CacheEventSender.kt
│ │ │ ├── CacheThread.java
│ │ │ └── CacheThreadHandler.java
│ │ ├── configuration
│ │ │ ├── AdsSdkInitializer.kt
│ │ │ ├── Configuration.java
│ │ │ ├── ConfigurationFailure.java
│ │ │ ├── ConfigurationLoader.java
│ │ │ ├── ConfigurationReader.java
│ │ │ ├── ConfigurationRequestFactory.java
│ │ │ ├── CoreModuleConfiguration.java
│ │ │ ├── EnvironmentCheck.java
│ │ │ ├── ErrorState.java
│ │ │ ├── ExperimentAppliedRule.java
│ │ │ ├── ExperimentObject.java
│ │ │ ├── ExperimentObjects.java
│ │ │ ├── Experiments.java
│ │ │ ├── ExperimentsBase.java
│ │ │ ├── ExperimentsReader.java
│ │ │ ├── IConfigurationLoader.java
│ │ │ ├── IConfigurationLoaderListener.java
│ │ │ ├── IExperiments.java
│ │ │ ├── IInitializationListener.java
│ │ │ ├── IInitializationNotificationCenter.java
│ │ │ ├── IInitializeEventsMetricSender.java
│ │ │ ├── IModuleConfiguration.java
│ │ │ ├── IPrivacyConfigurationListener.java
│ │ │ ├── InitRequestType.java
│ │ │ ├── InitializationNotificationCenter.java
│ │ │ ├── InitializeEventsMetricSender.java
│ │ │ ├── InitializeThread.java
│ │ │ ├── PrivacyCallError.kt
│ │ │ ├── PrivacyConfig.java
│ │ │ ├── PrivacyConfigStatus.java
│ │ │ ├── PrivacyConfigStorage.java
│ │ │ └── PrivacyConfigurationLoader.java
│ │ ├── connectivity
│ │ │ ├── ConnectivityChangeReceiver.java
│ │ │ ├── ConnectivityEvent.java
│ │ │ ├── ConnectivityMonitor.java
│ │ │ ├── ConnectivityNetworkCallback.java
│ │ │ └── IConnectivityListener.java
│ │ ├── device
│ │ │ ├── AdvertisingId.java
│ │ │ ├── Device.java
│ │ │ ├── DeviceError.java
│ │ │ ├── DeviceInfoEvent.kt
│ │ │ ├── MimeTypes.java
│ │ │ ├── OpenAdvertisingId.java
│ │ │ ├── Storage.java
│ │ │ ├── StorageError.java
│ │ │ ├── StorageEvent.java
│ │ │ ├── StorageManager.java
│ │ │ ├── TokenType.java
│ │ │ ├── VolumeChange.kt
│ │ │ ├── VolumeChangeContentObserver.kt
│ │ │ ├── VolumeChangeListener.kt
│ │ │ ├── VolumeChangeMonitor.kt
│ │ │ └── reader
│ │ │ │ ├── DeviceInfoDataFactory.java
│ │ │ │ ├── DeviceInfoReaderCompressor.java
│ │ │ │ ├── DeviceInfoReaderCompressorWithMetrics.java
│ │ │ │ ├── DeviceInfoReaderExtended.java
│ │ │ │ ├── DeviceInfoReaderFilterProvider.java
│ │ │ │ ├── DeviceInfoReaderWithAuid.kt
│ │ │ │ ├── DeviceInfoReaderWithBehavioralFlag.java
│ │ │ │ ├── DeviceInfoReaderWithExtras.java
│ │ │ │ ├── DeviceInfoReaderWithFilter.java
│ │ │ │ ├── DeviceInfoReaderWithLifecycle.java
│ │ │ │ ├── DeviceInfoReaderWithMetrics.java
│ │ │ │ ├── DeviceInfoReaderWithPrivacy.java
│ │ │ │ ├── DeviceInfoReaderWithRequestType.java
│ │ │ │ ├── DeviceInfoReaderWithSessionId.java
│ │ │ │ ├── DeviceInfoReaderWithStorageInfo.java
│ │ │ │ ├── GameSessionIdReader.java
│ │ │ │ ├── HdrInfoReader.java
│ │ │ │ ├── IDeviceInfoDataCompressor.java
│ │ │ │ ├── IDeviceInfoDataContainer.java
│ │ │ │ ├── IDeviceInfoReader.java
│ │ │ │ ├── IGameSessionIdReader.java
│ │ │ │ ├── IHdrInfoReader.java
│ │ │ │ ├── JsonStorageKeyNames.java
│ │ │ │ ├── MinimalDeviceInfoReader.java
│ │ │ │ ├── builder
│ │ │ │ ├── DeviceInfoReaderBuilder.java
│ │ │ │ ├── DeviceInfoReaderBuilderWithExtras.java
│ │ │ │ └── DeviceInfoReaderPrivacyBuilder.java
│ │ │ │ └── pii
│ │ │ │ ├── NonBehavioralFlag.kt
│ │ │ │ ├── NonBehavioralFlagReader.kt
│ │ │ │ ├── PiiDataProvider.java
│ │ │ │ ├── PiiPrivacyMode.java
│ │ │ │ └── PiiTrackingStatusReader.java
│ │ ├── di
│ │ │ ├── IServiceComponent.kt
│ │ │ ├── IServiceProvider.kt
│ │ │ ├── IServicesRegistry.kt
│ │ │ ├── ServiceComponent.kt
│ │ │ ├── ServiceFactory.kt
│ │ │ ├── ServiceKey.kt
│ │ │ ├── ServiceProvider.kt
│ │ │ └── ServicesRegistry.kt
│ │ ├── domain
│ │ │ ├── ISDKDispatchers.kt
│ │ │ ├── ResultExtensions.kt
│ │ │ ├── SDKDispatchers.kt
│ │ │ └── task
│ │ │ │ ├── BaseParams.kt
│ │ │ │ ├── BaseTask.kt
│ │ │ │ ├── ConfigFileFromLocalStorage.kt
│ │ │ │ ├── EmptyParams.kt
│ │ │ │ ├── InitializationException.kt
│ │ │ │ ├── InitializeSDK.kt
│ │ │ │ ├── InitializeStateComplete.kt
│ │ │ │ ├── InitializeStateConfig.kt
│ │ │ │ ├── InitializeStateConfigWithLoader.kt
│ │ │ │ ├── InitializeStateCreate.kt
│ │ │ │ ├── InitializeStateCreateWithRemote.kt
│ │ │ │ ├── InitializeStateError.kt
│ │ │ │ ├── InitializeStateLoadCache.kt
│ │ │ │ ├── InitializeStateLoadWeb.kt
│ │ │ │ ├── InitializeStateNetworkError.kt
│ │ │ │ ├── InitializeStateReset.kt
│ │ │ │ └── MetricTask.kt
│ │ ├── extensions
│ │ │ ├── CoroutineExtensions.kt
│ │ │ └── TaskExtensions.kt
│ │ ├── lifecycle
│ │ │ ├── CachedLifecycle.java
│ │ │ ├── IAppActiveListener.java
│ │ │ ├── IAppEventListener.java
│ │ │ ├── LifecycleCache.java
│ │ │ ├── LifecycleError.java
│ │ │ ├── LifecycleEvent.java
│ │ │ └── LifecycleListener.java
│ │ ├── log
│ │ │ ├── DeviceLog.java
│ │ │ ├── DeviceLogEntry.java
│ │ │ └── DeviceLogLevel.java
│ │ ├── misc
│ │ │ ├── EventSubject.java
│ │ │ ├── IEventListener.java
│ │ │ ├── IJsonStorageReader.java
│ │ │ ├── IObserver.java
│ │ │ ├── JsonFlattener.java
│ │ │ ├── JsonFlattenerRules.java
│ │ │ ├── JsonStorage.java
│ │ │ ├── JsonStorageAggregator.java
│ │ │ ├── Observable.java
│ │ │ ├── Utilities.java
│ │ │ └── ViewUtilities.java
│ │ ├── network
│ │ │ ├── core
│ │ │ │ ├── CronetInitializer.kt
│ │ │ │ ├── HttpClient.kt
│ │ │ │ ├── LegacyHttpClient.kt
│ │ │ │ └── OkHttp3Client.kt
│ │ │ ├── mapper
│ │ │ │ ├── HttpRequestToOkHttpRequest.kt
│ │ │ │ ├── HttpRequestToWebRequest.kt
│ │ │ │ └── WebRequestToHttpRequest.kt
│ │ │ └── model
│ │ │ │ ├── BodyType.kt
│ │ │ │ ├── HttpRequest.kt
│ │ │ │ ├── HttpResponse.kt
│ │ │ │ └── RequestType.kt
│ │ ├── preferences
│ │ │ ├── AndroidPreferences.java
│ │ │ └── PreferencesError.java
│ │ ├── properties
│ │ │ ├── ClientProperties.java
│ │ │ ├── InitializationStatusReader.java
│ │ │ ├── MadeWithUnityDetector.java
│ │ │ ├── SdkProperties.java
│ │ │ ├── Session.kt
│ │ │ └── SessionIdReader.kt
│ │ ├── reflection
│ │ │ ├── GenericBridge.java
│ │ │ └── GenericListenerProxy.java
│ │ ├── request
│ │ │ ├── CancelableThreadPoolExecutor.java
│ │ │ ├── IResolveHostListener.java
│ │ │ ├── IWebRequestListener.java
│ │ │ ├── IWebRequestProgressListener.java
│ │ │ ├── NetworkIOException.java
│ │ │ ├── ResolveHostError.java
│ │ │ ├── ResolveHostEvent.java
│ │ │ ├── WebRequest.java
│ │ │ ├── WebRequestError.java
│ │ │ ├── WebRequestEvent.java
│ │ │ ├── WebRequestRunnable.java
│ │ │ ├── WebRequestThread.java
│ │ │ └── metrics
│ │ │ │ ├── AdOperationError.java
│ │ │ │ ├── AdOperationMetric.java
│ │ │ │ ├── InitMetric.java
│ │ │ │ ├── Metric.kt
│ │ │ │ ├── MetricCommonTags.java
│ │ │ │ ├── MetricSender.kt
│ │ │ │ ├── MetricSenderBase.kt
│ │ │ │ ├── MetricSenderWithBatch.kt
│ │ │ │ ├── MetricsContainer.kt
│ │ │ │ ├── SDKMetrics.java
│ │ │ │ ├── SDKMetricsSender.kt
│ │ │ │ ├── ScarMetric.java
│ │ │ │ └── TSIMetric.java
│ │ ├── sensorinfo
│ │ │ ├── SensorInfoError.java
│ │ │ └── SensorInfoListener.java
│ │ ├── timer
│ │ │ ├── BaseTimer.java
│ │ │ ├── DefaultIntervalTimerFactory.java
│ │ │ ├── IBaseTimer.java
│ │ │ ├── IIntervalTimer.java
│ │ │ ├── IIntervalTimerFactory.java
│ │ │ ├── IIntervalTimerListener.java
│ │ │ ├── ITimerListener.java
│ │ │ └── IntervalTimer.java
│ │ └── webview
│ │ │ ├── WebView.kt
│ │ │ ├── WebViewApp.java
│ │ │ ├── WebViewEventCategory.java
│ │ │ ├── WebViewMetric.kt
│ │ │ ├── WebViewUrlBuilder.java
│ │ │ ├── WebViewWithCache.java
│ │ │ └── bridge
│ │ │ ├── CallbackStatus.java
│ │ │ ├── IEventSender.kt
│ │ │ ├── IInvocationCallbackInvoker.kt
│ │ │ ├── INativeCallbackSubject.kt
│ │ │ ├── IWebViewBridge.kt
│ │ │ ├── IWebViewBridgeInvoker.java
│ │ │ ├── IWebViewBridgeSharedObjectStore.java
│ │ │ ├── IWebViewSharedObject.java
│ │ │ ├── Invocation.java
│ │ │ ├── NativeCallback.java
│ │ │ ├── SharedInstances.kt
│ │ │ ├── WebViewBridge.java
│ │ │ ├── WebViewBridgeError.java
│ │ │ ├── WebViewBridgeInterface.kt
│ │ │ ├── WebViewBridgeInvoker.java
│ │ │ ├── WebViewBridgeSharedObjectStore.java
│ │ │ ├── WebViewCallback.java
│ │ │ ├── WebViewExposed.java
│ │ │ └── invocation
│ │ │ ├── IWebViewBridgeInvocation.java
│ │ │ ├── IWebViewBridgeInvocationCallback.java
│ │ │ ├── WebViewBridgeInvocation.java
│ │ │ ├── WebViewBridgeInvocationRunnable.java
│ │ │ └── WebViewBridgeInvocationSingleThreadedExecutor.java
│ │ └── store
│ │ ├── StoreError.java
│ │ ├── StoreEvent.java
│ │ ├── StoreMonitor.java
│ │ ├── core
│ │ ├── StoreExceptionHandler.java
│ │ ├── StoreLifecycleListener.java
│ │ ├── StoreWebViewError.java
│ │ ├── api
│ │ │ └── Store.java
│ │ └── configuration
│ │ │ └── StoreModuleConfiguration.java
│ │ ├── gpbl
│ │ ├── BillingResultResponseCode.java
│ │ ├── IBillingClientStateListener.java
│ │ ├── IBillingResponse.java
│ │ ├── StoreBilling.java
│ │ ├── bridges
│ │ │ ├── BillingResultBridge.java
│ │ │ ├── CommonJsonResponseBridge.java
│ │ │ ├── PurchaseBridge.java
│ │ │ ├── PurchaseHistoryRecordBridge.java
│ │ │ ├── PurchasesResultBridge.java
│ │ │ ├── SkuDetailsBridge.java
│ │ │ ├── SkuDetailsParamsBridge.java
│ │ │ └── billingclient
│ │ │ │ ├── BillingClientBuilderFactory.java
│ │ │ │ ├── IBillingClient.java
│ │ │ │ ├── IBillingClientBuilderBridge.java
│ │ │ │ ├── common
│ │ │ │ ├── BillingClientBridgeCommon.java
│ │ │ │ └── BillingClientBuilderBridgeCommon.java
│ │ │ │ ├── v3
│ │ │ │ └── BillingClientBridge.java
│ │ │ │ └── v4
│ │ │ │ └── BillingClientBridge.java
│ │ └── proxies
│ │ │ ├── BillingClientStateListenerProxy.java
│ │ │ ├── PurchaseHistoryResponseListenerProxy.java
│ │ │ ├── PurchaseUpdatedListenerProxy.java
│ │ │ ├── PurchasesResponseListenerProxy.java
│ │ │ └── SkuDetailsResponseListenerProxy.java
│ │ └── listeners
│ │ ├── IBillingDataResponseListener.java
│ │ ├── IPurchaseHistoryResponseListener.java
│ │ ├── IPurchaseUpdatedResponseListener.java
│ │ ├── IPurchasesResponseListener.java
│ │ ├── ISkuDetailsResponseListener.java
│ │ └── PurchasesResponseListener.java
│ └── test
│ └── java
│ ├── android
│ ├── text
│ │ └── TextUtils.java
│ └── util
│ │ └── Log.java
│ └── com
│ └── unity3d
│ ├── ads
│ ├── UnityAdsLoadOptionsTest.java
│ └── UnityAdsShowOptionsTest.java
│ ├── services
│ ├── SDKErrorHandlerTest.kt
│ ├── ads
│ │ ├── gmascar
│ │ │ └── managers
│ │ │ │ └── BiddingManagerFactoryTest.kt
│ │ └── topics
│ │ │ ├── TopicsReceiverTest.kt
│ │ │ └── TopicsServiceTest.kt
│ ├── banners
│ │ └── UnityBannerSizeTest.kt
│ ├── core
│ │ ├── UnityServicesTest.kt
│ │ ├── cache
│ │ │ └── CacheDirectoryTest.kt
│ │ ├── configuration
│ │ │ ├── AdsSdkInitializerTest.kt
│ │ │ ├── ConfigurationRequestFactoryTest.java
│ │ │ ├── ExperimentObjectTest.java
│ │ │ ├── ExperimentObjectsTest.java
│ │ │ ├── ExperimentsReaderTest.java
│ │ │ ├── ExperimentsTest.java
│ │ │ ├── InitializeEventsMetricSenderTest.java
│ │ │ ├── PrivacyConfigStatusTest.java
│ │ │ ├── PrivacyConfigStorageTest.java
│ │ │ ├── PrivacyConfigTest.java
│ │ │ └── PrivacyConfigurationLoaderTest.java
│ │ ├── device
│ │ │ ├── DeviceInfoReaderWithAuidTest.kt
│ │ │ ├── DeviceTest.kt
│ │ │ └── pii
│ │ │ │ ├── NonBehavioralFlagReaderTest.kt
│ │ │ │ ├── NonBehavioralFlagTest.kt
│ │ │ │ └── PiiTrackingStatusReaderTest.java
│ │ ├── di
│ │ │ └── ServicesRegistryTest.kt
│ │ ├── domain
│ │ │ ├── ResultExtensionsKtTest.kt
│ │ │ └── task
│ │ │ │ ├── ConfigFileFromLocalStorageTest.kt
│ │ │ │ ├── InitializeSDKTest.kt
│ │ │ │ ├── InitializeStateCompleteTest.kt
│ │ │ │ ├── InitializeStateConfigTest.kt
│ │ │ │ ├── InitializeStateConfigWithLoaderTest.kt
│ │ │ │ ├── InitializeStateCreateTest.kt
│ │ │ │ ├── InitializeStateCreateWithRemoteTest.kt
│ │ │ │ ├── InitializeStateErrorTest.kt
│ │ │ │ ├── InitializeStateLoadCacheTest.kt
│ │ │ │ ├── InitializeStateLoadWebTest.kt
│ │ │ │ ├── InitializeStateNetworkErrorTest.kt
│ │ │ │ ├── InitializeStateResetTest.kt
│ │ │ │ └── TestSDKDispatchers.kt
│ │ ├── extensions
│ │ │ └── TaskExtensionsTest.kt
│ │ ├── measurements
│ │ │ └── MeasurementsServiceTest.kt
│ │ ├── misc
│ │ │ ├── EventSubjectTest.java
│ │ │ ├── JsonFlattenerTest.java
│ │ │ ├── JsonStorageAggregatorTest.java
│ │ │ └── UtilitiesTest.kt
│ │ ├── network
│ │ │ ├── core
│ │ │ │ └── OkHttp3ClientTest.kt
│ │ │ └── mapper
│ │ │ │ └── HttpRequestToOkHttpRequestKtTest.kt
│ │ ├── properties
│ │ │ ├── SessionIdReaderTest.kt
│ │ │ └── SessionTest.kt
│ │ ├── request
│ │ │ └── metrics
│ │ │ │ ├── MetricSenderWithBatchTest.java
│ │ │ │ └── MetricsContainerTest.java
│ │ └── webview
│ │ │ ├── InvocationTest.kt
│ │ │ ├── NativeCallbackTests.kt
│ │ │ └── bridge
│ │ │ └── invocation
│ │ │ └── WebViewBridgeInvocationTests.java
│ └── store
│ │ ├── core
│ │ ├── StoreExceptionHandlerMatcher.java
│ │ └── StoreExceptionHandlerTest.java
│ │ └── gpbl
│ │ └── proxies
│ │ ├── PurchaseHistoryResponseListenerProxyTest.java
│ │ ├── PurchaseUpdatedListenerProxyTest.java
│ │ ├── PurchasesResponseListenerProxyTest.java
│ │ └── SkuDetailsResponseListenerProxyTest.java
│ └── utils
│ └── corountine
│ └── CoroutineNameUsed.kt
├── unity-scaradapter-2000
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ ├── AndroidManifest.xml
│ └── java
│ │ └── com
│ │ └── unity3d
│ │ ├── ads
│ │ └── test
│ │ │ └── InstrumentationTestSuite.java
│ │ └── scar
│ │ └── adapter
│ │ └── v2000
│ │ ├── Constants.java
│ │ ├── ScarAdapterTest.java
│ │ └── signals
│ │ ├── QueryInfoCallbackTest.java
│ │ └── SignalsCollectorTest.java
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── unity3d
│ └── scar
│ └── adapter
│ └── v2000
│ ├── ScarAdapter.java
│ ├── scarads
│ ├── ScarAdBase.java
│ ├── ScarAdListener.java
│ ├── ScarBannerAd.java
│ ├── ScarBannerAdListener.java
│ ├── ScarInterstitialAd.java
│ ├── ScarInterstitialAdListener.java
│ ├── ScarRewardedAd.java
│ └── ScarRewardedAdListener.java
│ └── signals
│ ├── QueryInfoCallback.java
│ └── SignalsCollector.java
├── unity-scaradapter-2100
├── .gitignore
├── build.gradle
├── consumer-rules.pro
├── proguard-rules.pro
└── src
│ ├── androidTest
│ ├── AndroidManifest.xml
│ └── java
│ │ └── com
│ │ └── unity3d
│ │ ├── ads
│ │ └── test
│ │ │ └── InstrumentationTestSuite.java
│ │ └── scar
│ │ └── adapter
│ │ └── v2100
│ │ ├── ScarAdapterTest.java
│ │ └── signals
│ │ ├── QueryInfoCallbackTest.java
│ │ └── SignalsCollectorTest.java
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── unity3d
│ └── scar
│ └── adapter
│ └── v2100
│ ├── ScarAdapter.java
│ ├── requests
│ └── AdRequestFactory.java
│ ├── scarads
│ ├── ScarAdBase.java
│ ├── ScarAdListener.java
│ ├── ScarBannerAd.java
│ ├── ScarBannerAdListener.java
│ ├── ScarInterstitialAd.java
│ ├── ScarInterstitialAdListener.java
│ ├── ScarRewardedAd.java
│ └── ScarRewardedAdListener.java
│ └── signals
│ ├── QueryInfoCallback.java
│ └── SignalsCollector.java
└── unity-scaradapter-common
├── .gitignore
├── build.gradle
├── consumer-rules.pro
├── proguard-rules.pro
└── src
├── main
├── AndroidManifest.xml
└── java
│ └── com
│ └── unity3d
│ └── scar
│ └── adapter
│ └── common
│ ├── DispatchGroup.java
│ ├── GMAAdsError.java
│ ├── GMAEvent.java
│ ├── IAdsErrorHandler.java
│ ├── IScarAdListenerWrapper.java
│ ├── IScarAdapter.java
│ ├── IScarBannerAdListenerWrapper.java
│ ├── IScarInterstitialAdListenerWrapper.java
│ ├── IScarRewardedAdListenerWrapper.java
│ ├── IUnityAdsError.java
│ ├── ScarAdapterBase.java
│ ├── Utils.java
│ ├── WebViewAdsError.java
│ ├── requests
│ └── RequestExtras.java
│ ├── scarads
│ ├── IScarAd.java
│ ├── IScarFullScreenAd.java
│ ├── IScarLoadListener.java
│ ├── ScarAdMetadata.java
│ └── UnityAdFormat.java
│ └── signals
│ ├── ISignalCallbackListener.java
│ ├── ISignalCollectionListener.java
│ ├── ISignalsCollector.java
│ ├── SignalCallbackListener.java
│ ├── SignalsCollectorBase.java
│ ├── SignalsResult.java
│ └── SignalsStorage.java
└── test
└── java
└── com
└── unity3d
└── scar
└── adapter
└── common
├── DispatchGroupTest.java
├── GMAAdsErrorTest.java
├── SignalCallbackListenerTest.java
└── SignalsStorageTest.java
/.editorconfig:
--------------------------------------------------------------------------------
1 | [*]
2 | charset=utf-8
3 | end_of_line=lf
4 | insert_final_newline=false
5 | indent_style=space
6 | indent_size=4
7 |
8 | [*.java]
9 | indent_style=tab
10 | tab_width=4
11 |
12 | [{*.yml,*.yaml}]
13 | indent_style=space
14 | indent_size=2
15 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | local.properties
3 | .idea
4 | .DS_Store
5 | build
6 | captures
7 | testServerAddress.txt
8 | app/bin
9 | unity-ads/bin
10 | libs
11 | javadoc
12 | .settings
13 | .project
14 | .vscode
15 | .classpath
16 | *.iml
17 | fastlane/report.xml
18 |
--------------------------------------------------------------------------------
/.ruby-version:
--------------------------------------------------------------------------------
1 | 2.3.1
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Unity Advertisements copyright © 2023 Unity Technologies.
2 | This software is subject to, and made available under, the terms of service for Operate Solutions (see https://unity3d.com/legal/one-operate-services-terms-of-service), and is an "Operate Service" as defined therein.
3 |
4 | Your use of the Services constitutes your acceptance of such terms. Unless expressly provided otherwise, the software under this license is made available strictly on an "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. Please review the terms of service for details on these and other terms and conditions.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Unity Ads Android Release Repository
2 |
3 | Welcome to the Unity Ads Android SDK Repository.
4 |
5 | ## Binaries
6 |
7 | Binaries can be found in the [releases tab](https://github.com/Unity-Technologies/unity-ads-android/releases).
8 |
9 | ## Integration Guide
10 |
11 | Integration guide can be found [here](https://unityads.unity3d.com/help/android/integration-guide-android).
12 |
13 | ## API Reference
14 |
15 | API Reference can be found [here](https://unityads.unity3d.com/help/android/api-android)
16 |
17 | ## License
18 | The license can be viewed [here](LICENSE)
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 33
5 |
6 | defaultConfig {
7 | applicationId "com.unity3d.ads.example"
8 | minSdkVersion 19
9 | targetSdkVersion 33
10 | versionCode = 4910
11 | versionName = "4.9.1"
12 | }
13 |
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | implementation "com.google.android.material:material:1.3.0"
24 | implementation "androidx.appcompat:appcompat:1.3.0"
25 | implementation "androidx.coordinatorlayout:coordinatorlayout:1.1.0"
26 | implementation 'androidx.transition:transition:1.4.1'
27 | implementation project(':unity-ads')
28 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/rikshot/adt-bundle-mac-x86_64/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/ar/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-playstore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Unity-Technologies/unity-ads-android/6bdba8b1d4f510a0d5b047dce7049368c0d6f307/app/src/main/ic_launcher-playstore.png
--------------------------------------------------------------------------------
/app/src/main/java/com/unity3d/ads/example/UnityAdsTestApp.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads.example;
2 |
3 | import android.os.Bundle;
4 | import androidx.viewpager.widget.ViewPager;
5 | import androidx.appcompat.app.AppCompatActivity;
6 | import com.google.android.material.tabs.TabLayout;
7 | import com.unity3d.ads.example.ui.main.SectionsPagerAdapter;
8 |
9 | public class UnityAdsTestApp extends AppCompatActivity {
10 |
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 | setContentView(R.layout.activity_unity_ads_test_app);
15 | SectionsPagerAdapter sectionsPagerAdapter = new SectionsPagerAdapter(this, getSupportFragmentManager());
16 | ViewPager viewPager = findViewById(R.id.view_pager);
17 | viewPager.setAdapter(sectionsPagerAdapter);
18 | TabLayout tabs = findViewById(R.id.tabs);
19 | tabs.setupWithViewPager(viewPager);
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/unity3d/ads/example/ui/main/SectionsPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads.example.ui.main;
2 |
3 | import android.content.Context;
4 | import androidx.annotation.Nullable;
5 | import androidx.fragment.app.Fragment;
6 | import androidx.fragment.app.FragmentManager;
7 | import androidx.fragment.app.FragmentPagerAdapter;
8 |
9 | /**
10 | * A [FragmentPagerAdapter] that returns a fragment corresponding to
11 | * one of the sections/tabs/pages.
12 | */
13 | public class SectionsPagerAdapter extends FragmentPagerAdapter {
14 |
15 | private final Context mContext;
16 |
17 | public SectionsPagerAdapter(Context context, FragmentManager fm) {
18 | super(fm);
19 | mContext = context;
20 | }
21 |
22 | @Override
23 | public Fragment getItem(int position) {
24 | // getItem is called to instantiate the fragment for the given page.
25 | // Return a UnityAdsFragment (defined as a static inner class below).
26 | return UnityAdsFragment.newInstance(position);
27 | }
28 |
29 | @Nullable
30 | @Override
31 | public CharSequence getPageTitle(int position) {
32 | return null;
33 | }
34 |
35 | @Override
36 | public int getCount() {
37 | // Show 1 total pages.
38 | return 1;
39 | }
40 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/unityads_example_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/unityads_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Unity-Technologies/unity-ads-android/6bdba8b1d4f510a0d5b047dce7049368c0d6f307/app/src/main/res/drawable/unityads_logo.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Unity-Technologies/unity-ads-android/6bdba8b1d4f510a0d5b047dce7049368c0d6f307/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Unity-Technologies/unity-ads-android/6bdba8b1d4f510a0d5b047dce7049368c0d6f307/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Unity-Technologies/unity-ads-android/6bdba8b1d4f510a0d5b047dce7049368c0d6f307/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Unity-Technologies/unity-ads-android/6bdba8b1d4f510a0d5b047dce7049368c0d6f307/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Unity-Technologies/unity-ads-android/6bdba8b1d4f510a0d5b047dce7049368c0d6f307/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Unity-Technologies/unity-ads-android/6bdba8b1d4f510a0d5b047dce7049368c0d6f307/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Unity-Technologies/unity-ads-android/6bdba8b1d4f510a0d5b047dce7049368c0d6f307/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Unity-Technologies/unity-ads-android/6bdba8b1d4f510a0d5b047dce7049368c0d6f307/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Unity-Technologies/unity-ads-android/6bdba8b1d4f510a0d5b047dce7049368c0d6f307/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Unity-Technologies/unity-ads-android/6bdba8b1d4f510a0d5b047dce7049368c0d6f307/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 | 16dp
7 | 8dp
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | UnityAds 2.0
3 | Initialize
4 | Interstitial:
5 | Rewarded:
6 | Banner:
7 | Load
8 | Show
9 | Hide
10 | UnityAdsTestApp
11 | Unity Ads Test App
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | allprojects {
2 | repositories {
3 | google()
4 | mavenCentral()
5 | }
6 | }
7 |
8 | buildscript {
9 | ext {
10 | kotlin_version = '1.8.10'
11 | coroutines_version = '1.6.4'
12 | dokka_version = '1.6.10'
13 | startup_runtime_version = '1.1.1'
14 | unity_identifiers_version = '1.0.0'
15 | lifecycle_version = '2.5.1'
16 | okhttp_version = '3.12.13' // 3.13+ requires Java8 / Android5+(21)
17 | androidx_webkit = '1.6.1'
18 | androidx_core = '1.9.0'
19 | play_services_cronet = '18.0.1'
20 | }
21 |
22 | repositories {
23 | gradlePluginPortal()
24 | google()
25 | }
26 |
27 | dependencies {
28 | classpath 'com.android.tools.build:gradle:7.4.2'
29 | classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.23.4'
30 | classpath 'io.github.gradle-nexus:publish-plugin:1.1.0'
31 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
32 | classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
33 | }
34 | }
35 |
36 | apply from: 'nexusPublishing.gradle'
37 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 | android.useAndroidX=true
20 | android.disableAutomaticComponentCreation=true
21 |
22 | signing.keyId=34500891
23 | signing.secretKeyRingFile=../gpg-private-key.gpg
24 |
25 | # https://kotlinlang.org/docs/whatsnew18.html#usage-of-the-latest-kotlin-stdlib-version-in-transitive-dependencies
26 | kotlin.stdlib.jdk.variants.version.alignment=false
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Unity-Technologies/unity-ads-android/6bdba8b1d4f510a0d5b047dce7049368c0d6f307/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
4 | networkTimeout=10000
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/nexusPublishing.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'io.github.gradle-nexus.publish-plugin'
2 |
3 | Properties properties = new Properties()
4 | if (project.rootProject.file('local.properties').exists()) {
5 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
6 | }
7 |
8 | nexusPublishing {
9 | repositories {
10 | sonatype {
11 | stagingProfileId = properties.getProperty("NEXUS_PROFILE_ID")
12 | username = properties.getProperty("NEXUS_USERNAME")
13 | password = properties.getProperty("NEXUS_PASSWORD")
14 | // Add these lines if using new Sonatype infra
15 | nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
16 | snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/qodana.yml:
--------------------------------------------------------------------------------
1 | version: 1.0
2 | linter: jetbrains/qodana-jvm-android:2023.1-eap
3 | exclude:
4 | - name: All
5 | paths:
6 | - app
7 | - unity-scaradapter-1920
8 | - unity-scaradapter-1950
9 | - unity-scaradapter-2000
10 | - unity-scaradapter-2100
11 | - unity-scaradapter-common
12 | include:
13 | - name: SizeReplaceableByIsEmpty
14 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':unity-scaradapter-2000'
2 | include ':unity-scaradapter-2100'
3 | include ':unity-scaradapter-common'
4 | include ':app', ':unity-ads'
--------------------------------------------------------------------------------
/unity-ads/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/unity-ads/artifactory.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.jfrog.artifactory'
2 |
3 | Properties properties = new Properties()
4 | if (project.rootProject.file('local.properties').exists()) {
5 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
6 | }
7 |
8 | artifactory {
9 | contextUrl = 'https://unity3ddist.jfrog.io/artifactory'
10 | publish {
11 | repository {
12 | repoKey = properties.getProperty("artifactory.repokey")
13 | username = properties.getProperty("artifactory.username")
14 | password = properties.getProperty("artifactory.apikey")
15 | }
16 | defaults {
17 | // Tell the Artifactory Plugin which artifacts should be published to Artifactory.
18 | publications('release')
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/unity-ads/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Keep filenames and line numbers for stack traces
2 | -keepattributes SourceFile,LineNumberTable
3 |
4 | # Keep JavascriptInterface for WebView bridge
5 | -keepattributes JavascriptInterface
6 |
7 | # Sometimes keepattributes is not enough to keep annotations
8 | -keep class android.webkit.JavascriptInterface {
9 | *;
10 | }
11 |
12 | # Keep all classes in Unity Ads package
13 | -keep class com.unity3d.ads.** {
14 | *;
15 | }
16 |
17 | # Keep all classes in Unity Services package
18 | -keep class com.unity3d.services.** {
19 | *;
20 | }
21 |
22 | -keep class com.google.android.gms.ads.initialization.** {
23 | *;
24 | }
25 |
26 | -keep class com.google.android.gms.ads.MobileAds {
27 | *;
28 | }
29 |
30 | -dontwarn com.google.ads.mediation.admob.*
31 | -dontwarn com.google.android.gms.ads.**
--------------------------------------------------------------------------------
/unity-ads/src/androidTest/java/com/unity3d/ads/test/EnvironmentTestSuite.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads.test;
2 |
3 | import com.unity3d.ads.test.environment.*;
4 |
5 | import org.junit.runner.RunWith;
6 | import org.junit.runners.Suite;
7 |
8 | @RunWith(Suite.class)
9 | @Suite.SuiteClasses({
10 | EnvironmentTest.class
11 | })
12 | public class EnvironmentTestSuite {}
13 |
--------------------------------------------------------------------------------
/unity-ads/src/androidTest/java/com/unity3d/ads/test/HybridTestSuite.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads.test;
2 |
3 | import com.unity3d.ads.test.hybrid.HybridTest;
4 |
5 | import org.junit.runner.RunWith;
6 | import org.junit.runners.Suite;
7 |
8 | @RunWith(Suite.class)
9 | @Suite.SuiteClasses({
10 | HybridTest.class
11 | })
12 | public class HybridTestSuite {}
13 |
--------------------------------------------------------------------------------
/unity-ads/src/androidTest/java/com/unity3d/ads/test/IntegrationTestSuite.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads.test;
2 |
3 | import com.unity3d.ads.test.integration.banner.BannerIntegrationTest;
4 | import com.unity3d.ads.test.integration.SDKMetricsTest;
5 |
6 | import org.junit.runner.RunWith;
7 | import org.junit.runners.Suite;
8 |
9 | @RunWith(Suite.class)
10 | @Suite.SuiteClasses({
11 | BannerIntegrationTest.class,
12 | SDKMetricsTest.class
13 | })
14 | public class IntegrationTestSuite {
15 | }
16 |
--------------------------------------------------------------------------------
/unity-ads/src/androidTest/java/com/unity3d/ads/test/hybrid/HybridTestActivity.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads.test.hybrid;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 |
6 | public class HybridTestActivity extends Activity {
7 | @Override
8 | protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); }
9 | }
10 |
--------------------------------------------------------------------------------
/unity-ads/src/androidTest/java/com/unity3d/ads/test/hybrid/HybridTestModuleConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads.test.hybrid;
2 |
3 | import com.unity3d.services.core.configuration.Configuration;
4 | import com.unity3d.services.core.configuration.ErrorState;
5 | import com.unity3d.services.core.configuration.IModuleConfiguration;
6 |
7 | public class HybridTestModuleConfiguration implements IModuleConfiguration {
8 | public Class[] getWebAppApiClassList() {
9 | Class[] apiClassList = {
10 | com.unity3d.ads.test.hybrid.HybridTest.class
11 | };
12 | return apiClassList;
13 | }
14 | public boolean resetState(Configuration configuration) {
15 | return true;
16 | }
17 | public boolean initErrorState(Configuration configuration, ErrorState state, String message) {
18 | return true;
19 | }
20 | public boolean initCompleteState(Configuration configuration) {
21 | return true;
22 | }
23 | }
--------------------------------------------------------------------------------
/unity-ads/src/androidTest/java/com/unity3d/ads/test/instrumentation/InstrumentationTestActivity.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads.test.instrumentation;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 |
6 |
7 | public class InstrumentationTestActivity extends Activity {
8 | @Override
9 | protected void onCreate(Bundle savedInstanceState) {
10 | super.onCreate(savedInstanceState);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/unity-ads/src/androidTest/java/com/unity3d/ads/test/instrumentation/services/ads/gmascar/bridges/AdapterStatusBridgeTest.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads.test.instrumentation.services.ads.gmascar.bridges;
2 |
3 | import com.google.android.gms.ads.initialization.AdapterStatus;
4 | import com.unity3d.services.ads.gmascar.bridges.AdapterStatusBridge;
5 |
6 | import org.junit.Assert;
7 | import org.junit.Test;
8 |
9 | public class AdapterStatusBridgeTest {
10 |
11 | @Test
12 | public void testAdapterStatusBridge() {
13 | AdapterStatusBridge adapterStatusBridge = new AdapterStatusBridge();
14 | Object[] statesEnum = adapterStatusBridge.getAdapterStatesEnum();
15 | Assert.assertEquals(AdapterStatus.State.values().length, statesEnum.length);
16 | Assert.assertEquals(AdapterStatus.State.NOT_READY, statesEnum[0]);
17 | Assert.assertEquals(AdapterStatus.State.READY, statesEnum[1]);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/unity-ads/src/androidTest/java/com/unity3d/ads/test/instrumentation/services/ads/gmascar/bridges/InitializationStatusBridgeTest.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads.test.instrumentation.services.ads.gmascar.bridges;
2 |
3 | import com.unity3d.services.ads.gmascar.bridges.InitializationStatusBridge;
4 |
5 | import org.junit.Assert;
6 | import org.junit.Test;
7 |
8 | import java.util.Map;
9 |
10 | public class InitializationStatusBridgeTest {
11 |
12 | @Test
13 | public void testInitializationStatusBridgeNotInitialized() {
14 | InitializationStatusBridge initializationStatusBridge = new InitializationStatusBridge();
15 | Map adapterStatusMap = initializationStatusBridge.getAdapterStatusMap(new Object());
16 | Assert.assertNull(adapterStatusMap);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/unity-ads/src/androidTest/java/com/unity3d/ads/test/instrumentation/services/ads/gmascar/bridges/InitializeListenerBridgeTest.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads.test.instrumentation.services.ads.gmascar.bridges;
2 |
3 | import com.unity3d.services.ads.gmascar.bridges.InitializeListenerBridge;
4 |
5 | import org.junit.Assert;
6 | import org.junit.Test;
7 |
8 | public class InitializeListenerBridgeTest {
9 |
10 | @Test
11 | public void testInitializeListenerBridge() {
12 | InitializeListenerBridge initializeListenerBridge = new InitializeListenerBridge();
13 | Object listenerProxy = initializeListenerBridge.createInitializeListenerProxy();
14 | Assert.assertNotNull(listenerProxy);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/unity-ads/src/androidTest/java/com/unity3d/ads/test/legacy/AdvertisingIdentifierTest.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads.test.legacy;
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry;
4 | import androidx.test.ext.junit.runners.AndroidJUnit4;
5 |
6 | import com.unity3d.services.core.device.AdvertisingId;
7 |
8 | import org.junit.BeforeClass;
9 | import org.junit.Ignore;
10 | import org.junit.Test;
11 | import org.junit.runner.RunWith;
12 |
13 | import static org.junit.Assert.assertEquals;
14 | import static org.junit.Assert.assertNotNull;
15 |
16 | @RunWith(AndroidJUnit4.class)
17 | public class AdvertisingIdentifierTest {
18 |
19 | @BeforeClass
20 | public static void setupAdvertisingIdentifier() {
21 | AdvertisingId.init(InstrumentationRegistry.getInstrumentation().getTargetContext());
22 | }
23 |
24 | @Test
25 | @Ignore
26 | public void testAdvertisingIdentifier() {
27 | assertNotNull(AdvertisingId.getAdvertisingTrackingId());
28 | }
29 |
30 | @Test
31 | @Ignore
32 | public void testLimitedAdTracking() {
33 | assertEquals(false, AdvertisingId.getLimitedAdTracking());
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/unity-ads/src/androidTest/java/com/unity3d/ads/test/legacy/EnvironmentCheckTest.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads.test.legacy;
2 |
3 | import androidx.test.ext.junit.runners.AndroidJUnit4;
4 |
5 | import com.unity3d.services.core.configuration.EnvironmentCheck;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.assertFalse;
11 | import static org.junit.Assert.assertTrue;
12 |
13 | @RunWith(AndroidJUnit4.class)
14 | public class EnvironmentCheckTest {
15 | @Test
16 | public void testIsEnvironmentCheckOk() {
17 | assertTrue("Environment check failed, SDK will fail init", EnvironmentCheck.isEnvironmentOk());
18 | }
19 |
20 | @Test
21 | public void testProGuardTest() {
22 | assertTrue("Environment check for ProGuard failed", EnvironmentCheck.testProGuard());
23 | }
24 |
25 | @Test
26 | public void testCacheDirectory() {
27 | assertTrue("Environment check for cache directory failed", EnvironmentCheck.testCacheDirectory());
28 | }
29 | }
--------------------------------------------------------------------------------
/unity-ads/src/androidTest/java/com/unity3d/ads/test/legacy/LifecycleListenerTestActivity.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads.test.legacy;
2 |
3 | import android.app.Activity;
4 |
5 | public class LifecycleListenerTestActivity extends Activity {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/unity-ads/src/androidTest/java/com/unity3d/ads/test/legacy/LifecycleListenerTestBaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads.test.legacy;
2 |
3 | import android.app.Activity;
4 |
5 | public class LifecycleListenerTestBaseActivity extends Activity {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/unity-ads/src/androidTest/java/com/unity3d/ads/test/legacy/PublicApiTest.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads.test.legacy;
2 |
3 | import androidx.test.ext.junit.runners.AndroidJUnit4;
4 |
5 | import com.unity3d.ads.UnityAds;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.assertFalse;
11 | import static org.junit.Assert.assertTrue;
12 |
13 | @RunWith(AndroidJUnit4.class)
14 | public class PublicApiTest {
15 | @Test
16 | public void testIsSupported() {
17 | assertTrue("Public API isSupported did not return true", UnityAds.isSupported());
18 | }
19 |
20 | @Test
21 | public void testSDKVersion() {
22 | assertTrue("Public API SDK version is null", UnityAds.getVersion() != null);
23 | }
24 |
25 | @Test
26 | public void testDebugMode() {
27 | UnityAds.setDebugMode(false);
28 |
29 | assertFalse("Public API does not allow disabling debug mode", UnityAds.getDebugMode());
30 |
31 | UnityAds.setDebugMode(true);
32 |
33 | assertTrue("Public API does not allow enabling debug mode", UnityAds.getDebugMode());
34 | }
35 | }
--------------------------------------------------------------------------------
/unity-ads/src/androidTest/java/com/unity3d/ads/test/legacy/TestActivity.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads.test.legacy;
2 |
3 | import android.app.Activity;
4 |
5 | public class TestActivity extends Activity {
6 |
7 | public TestActivity() {
8 | super();
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/unity-ads/src/androidTest/java/com/unity3d/services/analytics/AcquisitionTypeTest.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.analytics;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.assertEquals;
6 |
7 | public class AcquisitionTypeTest {
8 |
9 | @Test
10 | public void testToString() {
11 | assertEquals("premium", AcquisitionType.PREMIUM.toString());
12 | assertEquals("soft", AcquisitionType.SOFT.toString());
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/unity-ads/src/androidTest/java/com/unity3d/services/analytics/mocks/UnityAnalyticsMock.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.analytics.mocks;
2 |
3 | import com.unity3d.services.analytics.UnityAnalytics;
4 |
5 | import org.json.JSONArray;
6 |
7 | public class UnityAnalyticsMock extends UnityAnalytics {
8 | public static JSONArray getEventQueue() {
9 | return UnityAnalytics.eventQueue;
10 | }
11 |
12 | public static void clearEventQueue() {
13 | eventQueue = new JSONArray();
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/ads/IUnityAdsInitializationListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads;
2 |
3 | public interface IUnityAdsInitializationListener {
4 | /**
5 | * Callback which notifies UnityAds has been successfully initialized.
6 | */
7 | void onInitializationComplete();
8 |
9 | /**
10 | * Callback which notifies UnityAds has failed initialization
11 | * with error message and error category.
12 | *
13 | * @param message Human-readable error message
14 | * @param error If UnityAdsInitializationError.INTERNAL_ERROR, initialization failed due to environment or internal services
15 | * If UnityAdsInitializationError.INVALID_ARGUMENT, initialization failed due to invalid argument(e.g. game ID)
16 | * If UnityAdsInitializationError.AD_BLOCKER_DETECTED, initialization failed due to url being blocked
17 | */
18 | void onInitializationFailed(UnityAds.UnityAdsInitializationError error, String message);
19 | }
20 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/ads/IUnityAdsLoadListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads;
2 |
3 | public interface IUnityAdsLoadListener {
4 | /**
5 | * Callback triggered when a load request has successfully filled the specified placementId with an ad that is ready to show.
6 | *
7 | * @param placementId Placement, as defined in Unity Ads admin tools
8 | */
9 | void onUnityAdsAdLoaded(String placementId);
10 |
11 | /**
12 | * Callback triggered when load request has failed to load an ad for a requested placement.
13 | *
14 | * @param placementId Placement, as defined in Unity Ads admin tools
15 | * @param error Error code related to the error See: {@link com.unity3d.ads.UnityAds.UnityAdsLoadError}
16 | * @param message Human-readable error message
17 | */
18 | void onUnityAdsFailedToLoad(String placementId, UnityAds.UnityAdsLoadError error, String message);
19 | }
20 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/ads/IUnityAdsTokenListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads;
2 |
3 | public interface IUnityAdsTokenListener {
4 | /**
5 | * Callback triggered when a Header Bidding token is available.
6 | *
7 | * @param token A Header Bidding token
8 | */
9 | void onUnityAdsTokenReady(String token);
10 | }
11 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/ads/UnityAdsBaseOptions.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads;
2 |
3 | import com.unity3d.services.core.log.DeviceLog;
4 |
5 | import org.json.JSONException;
6 | import org.json.JSONObject;
7 |
8 | public class UnityAdsBaseOptions {
9 | private JSONObject _data;
10 | private String OBJECT_ID = "objectId";
11 |
12 | public UnityAdsBaseOptions() {
13 | _data = new JSONObject();
14 | }
15 |
16 | public void set(String key, String value) {
17 | if(key != null && value != null) {
18 | try {
19 | _data.put(key, value);
20 | } catch (JSONException e) {
21 | DeviceLog.exception("Failed to set Unity Ads options", e);
22 | }
23 | }
24 | }
25 |
26 | public void setObjectId(String objectId) {
27 | set(OBJECT_ID, objectId);
28 | }
29 |
30 | public JSONObject getData() {
31 | return _data;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/ads/UnityAdsLoadOptions.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads;
2 |
3 | public class UnityAdsLoadOptions extends UnityAdsBaseOptions {
4 | private String AD_MARKUP = "adMarkup";
5 |
6 | public UnityAdsLoadOptions() {
7 | super();
8 | }
9 |
10 | public void setAdMarkup(String adMarkup) {
11 | set(AD_MARKUP, adMarkup);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/ads/UnityAdsShowOptions.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads;
2 |
3 | public class UnityAdsShowOptions extends UnityAdsBaseOptions {
4 | public UnityAdsShowOptions() {
5 | super();
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/ads/metadata/MediationMetaData.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads.metadata;
2 |
3 | import android.content.Context;
4 |
5 | public class MediationMetaData extends MetaData {
6 | public final static String KEY_ORDINAL = "ordinal";
7 | public final static String KEY_MISSED_IMPRESSION_ORDINAL = "missedImpressionOrdinal";
8 | public final static String KEY_NAME = "name";
9 | public final static String KEY_VERSION = "version";
10 |
11 | public MediationMetaData(Context context) {
12 | super(context);
13 | setCategory("mediation");
14 | }
15 |
16 | public void setOrdinal(int ordinal) {
17 | set(KEY_ORDINAL, ordinal);
18 | }
19 |
20 | public void setMissedImpressionOrdinal(int ordinal) {
21 | set(KEY_MISSED_IMPRESSION_ORDINAL, ordinal);
22 | }
23 |
24 | public void setName (String mediationNetworkName) {
25 | set(KEY_NAME, mediationNetworkName);
26 | }
27 |
28 | public void setVersion (String mediationSdkVersion) {
29 | set(KEY_VERSION, mediationSdkVersion);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/ads/metadata/PlayerMetaData.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads.metadata;
2 |
3 | import android.content.Context;
4 |
5 | public class PlayerMetaData extends MetaData {
6 | public static final String KEY_SERVER_ID = "server_id";
7 |
8 | public PlayerMetaData (Context context) {
9 | super(context);
10 | setCategory("player");
11 | }
12 |
13 | public void setServerId (String serverId) {
14 | set(KEY_SERVER_ID, serverId);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/UnityAdsSDK.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services
2 |
3 | import com.unity3d.services.core.di.IServiceComponent
4 | import com.unity3d.services.core.di.ServiceProvider.NAMED_SDK
5 | import com.unity3d.services.core.di.inject
6 | import com.unity3d.services.core.domain.task.EmptyParams
7 | import com.unity3d.services.core.domain.task.InitializeSDK
8 | import kotlinx.coroutines.CoroutineScope
9 | import kotlinx.coroutines.launch
10 |
11 | /**
12 | * SDK Kotlin entry point
13 | */
14 | object UnityAdsSDK : IServiceComponent {
15 |
16 | private val sdkScope: CoroutineScope by inject(NAMED_SDK)
17 | private val initializeSDK: InitializeSDK by inject()
18 |
19 | /**
20 | * Initialize the SDK
21 | */
22 | fun initialize() = sdkScope.launch {
23 | initializeSDK(EmptyParams)
24 | }
25 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/IUnityAds.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 |
6 | import com.unity3d.ads.IUnityAdsInitializationListener;
7 | import com.unity3d.ads.IUnityAdsLoadListener;
8 | import com.unity3d.ads.IUnityAdsShowListener;
9 | import com.unity3d.ads.IUnityAdsTokenListener;
10 | import com.unity3d.ads.UnityAdsLoadOptions;
11 | import com.unity3d.ads.UnityAdsShowOptions;
12 |
13 | public interface IUnityAds {
14 | void initialize(Context context, String gameId, boolean testMode, IUnityAdsInitializationListener initializationListener);
15 |
16 | boolean isInitialized();
17 |
18 | boolean isSupported();
19 |
20 | String getVersion();
21 |
22 | void show(Activity activity, String placementId, UnityAdsShowOptions showOptions, IUnityAdsShowListener showListener);
23 |
24 | void setDebugMode(boolean debugMode);
25 |
26 | boolean getDebugMode();
27 |
28 | void load(String placementId, UnityAdsLoadOptions loadOptions, IUnityAdsLoadListener listener);
29 |
30 | String getToken();
31 |
32 | void getToken(IUnityAdsTokenListener listener);
33 | }
34 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/adunit/AdUnitError.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.adunit;
2 |
3 | public enum AdUnitError {
4 | ADUNIT_NULL,
5 | ACTIVITY_ID,
6 | GENERIC,
7 | ORIENTATION,
8 | SCREENVISIBILITY,
9 | CORRUPTED_VIEWLIST,
10 | CORRUPTED_KEYEVENTLIST,
11 | SYSTEM_UI_VISIBILITY,
12 | UNKNOWN_VIEW,
13 | LAYOUT_NULL,
14 | MAX_MOTION_EVENT_COUNT_REACHED,
15 | API_LEVEL_ERROR,
16 | NO_DISPLAY_CUTOUT_AVAILABLE,
17 | DISPLAY_CUTOUT_METHOD_NOT_AVAILABLE,
18 | DISPLAY_CUTOUT_JSON_ERROR,
19 | DISPLAY_CUTOUT_INVOKE_FAILED
20 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/adunit/AdUnitEvent.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.adunit;
2 |
3 | public enum AdUnitEvent {
4 | ON_START,
5 | ON_CREATE,
6 | ON_RESUME,
7 | ON_DESTROY,
8 | ON_PAUSE,
9 | KEY_DOWN,
10 | ON_RESTORE,
11 | ON_STOP,
12 | ON_FOCUS_GAINED,
13 | ON_FOCUS_LOST
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/adunit/AdUnitSoftwareActivity.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.adunit;
2 |
3 |
4 | public class AdUnitSoftwareActivity extends AdUnitActivity {
5 | // inherit all functionality from AdUnitActivity
6 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/adunit/AdUnitTransparentActivity.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.adunit;
2 |
3 |
4 | import android.graphics.Color;
5 | import android.graphics.drawable.ColorDrawable;
6 | import android.os.Bundle;
7 |
8 | import com.unity3d.services.core.misc.ViewUtilities;
9 | import com.unity3d.services.core.webview.bridge.SharedInstances;
10 |
11 | public class AdUnitTransparentActivity extends AdUnitActivity {
12 | @Override
13 | protected void onCreate(Bundle savedInstanceState) {
14 | super.onCreate(savedInstanceState);
15 | ViewUtilities.setBackground(super._controller._layout, new ColorDrawable(Color.TRANSPARENT));
16 | }
17 |
18 | @Override
19 | protected AdUnitActivityController createController() {
20 | return new AdUnitTransparentActivityController(this, SharedInstances.INSTANCE.getWebViewEventSender(), new AdUnitViewHandlerFactory());
21 | }
22 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/adunit/AdUnitTransparentActivityController.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.adunit;
2 |
3 | import android.graphics.Color;
4 | import android.graphics.drawable.ColorDrawable;
5 |
6 | import com.unity3d.services.core.misc.ViewUtilities;
7 | import com.unity3d.services.core.webview.bridge.IEventSender;
8 |
9 | public class AdUnitTransparentActivityController extends AdUnitActivityController {
10 | public AdUnitTransparentActivityController(IAdUnitActivity activity, IEventSender eventSender, IAdUnitViewHandlerFactory adUnitViewHandlerFactory) {
11 | super(activity, eventSender, adUnitViewHandlerFactory);
12 | }
13 |
14 | @Override
15 | protected void createLayout() {
16 | super.createLayout();
17 | ViewUtilities.setBackground(_layout, new ColorDrawable(Color.TRANSPARENT));
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/adunit/AdUnitTransparentSoftwareActivity.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.adunit;
2 |
3 |
4 | public class AdUnitTransparentSoftwareActivity extends AdUnitTransparentActivity {
5 | // inherit all functionality from AdUnitActivity
6 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/adunit/IAdUnitViewHandler.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.adunit;
2 |
3 | import android.os.Bundle;
4 | import android.view.View;
5 |
6 | public interface IAdUnitViewHandler {
7 | boolean create(IAdUnitActivity activity);
8 | boolean destroy();
9 | View getView();
10 |
11 | void onCreate(IAdUnitActivity activity, Bundle savedInstanceState);
12 | void onStart(IAdUnitActivity activity);
13 | void onStop(IAdUnitActivity activity);
14 | void onResume(IAdUnitActivity activity);
15 | void onPause(IAdUnitActivity activity);
16 | void onDestroy(IAdUnitActivity activity);
17 | }
18 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/adunit/IAdUnitViewHandlerFactory.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.adunit;
2 |
3 | public interface IAdUnitViewHandlerFactory {
4 | IAdUnitViewHandler createViewHandler(String name);
5 | }
6 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/adunit/PermissionsEvent.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.adunit;
2 |
3 | public enum PermissionsEvent {
4 | PERMISSIONS_RESULT,
5 | PERMISSIONS_ERROR
6 | }
7 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/api/Load.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.api;
2 |
3 | import com.unity3d.ads.UnityAds;
4 | import com.unity3d.services.ads.operation.load.LoadModule;
5 | import com.unity3d.services.core.webview.bridge.WebViewCallback;
6 | import com.unity3d.services.core.webview.bridge.WebViewExposed;
7 |
8 | public class Load {
9 | @WebViewExposed
10 | public static void sendAdLoaded(final String placementId, final String listenerId, WebViewCallback callback) {
11 | LoadModule.getInstance().onUnityAdsAdLoaded(listenerId);
12 | callback.invoke();
13 | }
14 |
15 | @WebViewExposed
16 | public static void sendAdFailedToLoad(final String placementId, final String listenerId, final String error, final String message, WebViewCallback callback) {
17 | LoadModule.getInstance().onUnityAdsFailedToLoad(listenerId, UnityAds.UnityAdsLoadError.valueOf(error), message);
18 | callback.invoke();
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/api/Topics.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.api;
2 |
3 | import com.unity3d.services.ads.topics.TopicsService;
4 | import com.unity3d.services.core.misc.Utilities;
5 | import com.unity3d.services.core.webview.bridge.WebViewCallback;
6 | import com.unity3d.services.core.webview.bridge.WebViewExposed;
7 |
8 | public class Topics {
9 | private static final TopicsService topicsService = Utilities.getService(TopicsService.class);
10 |
11 | @WebViewExposed
12 | public static void checkAvailability(WebViewCallback callback) {
13 | callback.invoke(topicsService.checkAvailability());
14 | }
15 |
16 | @WebViewExposed
17 | public static void getTopics(String adsSdkName, Boolean shouldRecordObservation, WebViewCallback callback) {
18 | topicsService.getTopics(adsSdkName, shouldRecordObservation);
19 | callback.invoke();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/configuration/IAdsModuleConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.configuration;
2 |
3 | import com.unity3d.services.core.configuration.IModuleConfiguration;
4 |
5 | import java.util.Map;
6 |
7 | public interface IAdsModuleConfiguration extends IModuleConfiguration {
8 | Map getAdUnitViewHandlers();
9 | }
10 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/gmascar/bridges/AdapterStatusStateBridge.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.gmascar.bridges;
2 |
3 | public class AdapterStatusStateBridge {
4 |
5 | public AdapterStatusStateBridge() {};
6 |
7 | public String getClassName() {
8 | return "com.google.android.gms.ads.initialization.AdapterStatus$State";
9 | }
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/gmascar/bridges/InitializationStatusBridge.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.gmascar.bridges;
2 |
3 | import com.unity3d.services.core.reflection.GenericBridge;
4 |
5 | import java.util.HashMap;
6 | import java.util.Map;
7 |
8 | public class InitializationStatusBridge extends GenericBridge {
9 | private static final String adapterStatusMapMethodName = "getAdapterStatusMap";
10 |
11 | public InitializationStatusBridge() {
12 | super(new HashMap[]>() {{
13 | put(adapterStatusMapMethodName, new Class[]{});
14 | }});
15 | }
16 |
17 | public String getClassName() {
18 | return "com.google.android.gms.ads.initialization.InitializationStatus";
19 | }
20 |
21 | public Map getAdapterStatusMap(Object initStatusObj) {
22 | return (Map) callNonVoidMethod(adapterStatusMapMethodName,
23 | initStatusObj, new Object[]{});
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/gmascar/bridges/mobileads/IMobileAdsBridge.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.gmascar.bridges.mobileads;
2 |
3 | import android.content.Context;
4 |
5 | import com.unity3d.services.ads.gmascar.finder.ScarAdapterVersion;
6 |
7 | public interface IMobileAdsBridge {
8 | void initialize(Context context, Object initializeListener);
9 | Object getInitializationStatus();
10 | String getVersionMethodName();
11 | int getVersionCodeIndex();
12 | ScarAdapterVersion getAdapterVersion(int versionCode);
13 | boolean shouldInitialize();
14 | String getVersionString();
15 | }
16 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/gmascar/bridges/mobileads/MobileAdsBridgeFactory.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.gmascar.bridges.mobileads;
2 |
3 | public class MobileAdsBridgeFactory {
4 |
5 | public MobileAdsBridgeBase createMobileAdsBridge() {
6 | MobileAdsBridgeBase _mobileAdsBridge = new MobileAdsBridge();
7 | if (_mobileAdsBridge.exists()) {
8 | return _mobileAdsBridge;
9 | }
10 |
11 | MobileAdsBridgeLegacy _mobileAdsBridgeLegacy = new MobileAdsBridgeLegacy();
12 | if (_mobileAdsBridgeLegacy.exists()) {
13 | return _mobileAdsBridgeLegacy;
14 | }
15 |
16 | return null;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/gmascar/finder/ScarAdapterVersion.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.gmascar.finder;
2 |
3 | public enum ScarAdapterVersion {
4 | V20,
5 | V21,
6 | NA
7 | }
8 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/gmascar/handlers/SignalsHandler.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.gmascar.handlers;
2 |
3 | import com.unity3d.scar.adapter.common.signals.ISignalCollectionListener;
4 | import com.unity3d.scar.adapter.common.GMAEvent;
5 | import com.unity3d.services.ads.gmascar.utils.GMAEventSender;
6 |
7 | public class SignalsHandler implements ISignalCollectionListener {
8 |
9 | private GMAEventSender _gmaEventSender;
10 |
11 | public SignalsHandler(GMAEventSender gmaEventSender) {
12 | _gmaEventSender = gmaEventSender;
13 | }
14 |
15 | @Override
16 | public void onSignalsCollected(String signalsMap) {
17 | _gmaEventSender.send(GMAEvent.SIGNALS, signalsMap);
18 | }
19 |
20 | @Override
21 | public void onSignalsCollectionFailed(String errorMsg) {
22 | _gmaEventSender.send(GMAEvent.SIGNALS_ERROR, errorMsg);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/gmascar/handlers/WebViewErrorHandler.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.gmascar.handlers;
2 |
3 | import com.unity3d.scar.adapter.common.IAdsErrorHandler;
4 | import com.unity3d.scar.adapter.common.WebViewAdsError;
5 | import com.unity3d.services.core.webview.WebViewEventCategory;
6 | import com.unity3d.services.core.webview.bridge.IEventSender;
7 | import com.unity3d.services.core.webview.bridge.SharedInstances;
8 |
9 | public class WebViewErrorHandler implements IAdsErrorHandler {
10 |
11 | private final IEventSender _eventSender;
12 |
13 | public WebViewErrorHandler() {
14 | this(SharedInstances.INSTANCE.getWebViewEventSender());
15 | }
16 |
17 | public WebViewErrorHandler(IEventSender eventSender) {
18 | _eventSender = eventSender;
19 | }
20 | @Override
21 | public void handleError(WebViewAdsError webViewAdsError) {
22 | WebViewEventCategory category = WebViewEventCategory.valueOf(webViewAdsError.getDomain());
23 | _eventSender.sendEvent(category, webViewAdsError.getErrorCategory(), webViewAdsError.getErrorArguments());
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/gmascar/listeners/IBiddingSignalsListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.gmascar.listeners;
2 |
3 | import com.unity3d.services.ads.gmascar.models.BiddingSignals;
4 |
5 | import org.jetbrains.annotations.Nullable;
6 |
7 | /**
8 | * Interface to notify sender when GMA Bidding Signals are ready.
9 | */
10 | public interface IBiddingSignalsListener {
11 |
12 | /**
13 | * Success callback.
14 | *
15 | * @param signals {@link BiddingSignals} retrieved GMA SCAR bidding signals.
16 | */
17 | void onSignalsReady(@Nullable BiddingSignals signals);
18 |
19 | /**
20 | * Fail callback.
21 | *
22 | * @param msg error msg.
23 | */
24 | void onSignalsFailure(String msg);
25 | }
26 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/gmascar/listeners/IInitializationStatusListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.gmascar.listeners;
2 |
3 | public interface IInitializationStatusListener {
4 | void onInitializationComplete(Object initStatus);
5 | }
6 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/gmascar/managers/BiddingDisabledManager.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.gmascar.managers;
2 |
3 | import com.unity3d.ads.IUnityAdsTokenListener;
4 |
5 | public class BiddingDisabledManager extends BiddingBaseManager {
6 |
7 | public BiddingDisabledManager(IUnityAdsTokenListener unityAdsTokenListener) {
8 | super(false, unityAdsTokenListener);
9 | }
10 |
11 | @Override
12 | public String getTokenIdentifier() {
13 | // SCAR bidding signals collection should be blocked.
14 | return null;
15 | }
16 |
17 | @Override
18 | public void start() {
19 | // SCAR bidding signals collection should be blocked.
20 | }
21 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/gmascar/managers/BiddingEagerManager.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.gmascar.managers;
2 |
3 | import com.unity3d.ads.IUnityAdsTokenListener;
4 |
5 | public class BiddingEagerManager extends BiddingBaseManager {
6 |
7 | public BiddingEagerManager(boolean isBannerEnabled, IUnityAdsTokenListener unityAdsTokenListener) {
8 | super(isBannerEnabled, unityAdsTokenListener);
9 | }
10 |
11 | @Override
12 | public void start() {
13 | permitSignalsUpload();
14 | fetchSignals();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/gmascar/managers/BiddingManagerFactory.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.gmascar.managers;
2 |
3 | import com.unity3d.ads.IUnityAdsTokenListener;
4 | import com.unity3d.services.ads.gmascar.GMA;
5 |
6 | import com.unity3d.services.core.configuration.IExperiments;
7 |
8 | public class BiddingManagerFactory {
9 |
10 | private static BiddingManagerFactory instance;
11 |
12 | private BiddingManagerFactory() {}
13 |
14 | public static BiddingManagerFactory getInstance() {
15 | if (instance == null) {
16 | instance = new BiddingManagerFactory();
17 | }
18 | return instance;
19 | }
20 |
21 | public BiddingBaseManager createManager(IUnityAdsTokenListener unityAdsTokenListener,
22 | IExperiments experiments) {
23 | if (GMA.getInstance().hasSCARBiddingSupport()) {
24 | boolean isBannerEnabled = experiments != null && experiments.isScarBannerHbEnabled();
25 | return new BiddingEagerManager(isBannerEnabled, unityAdsTokenListener);
26 | }
27 |
28 | return new BiddingDisabledManager(unityAdsTokenListener);
29 | }
30 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/gmascar/managers/IBiddingManager.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.gmascar.managers;
2 |
3 | import com.unity3d.ads.IUnityAdsTokenListener;
4 |
5 | public interface IBiddingManager extends IUnityAdsTokenListener {
6 | String getTokenIdentifier();
7 | String getFormattedToken(String unityToken);
8 | }
9 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/gmascar/utils/GMAEventSender.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.gmascar.utils;
2 |
3 | import com.unity3d.scar.adapter.common.GMAEvent;
4 | import com.unity3d.services.core.webview.WebViewEventCategory;
5 | import com.unity3d.services.core.webview.bridge.IEventSender;
6 | import com.unity3d.services.core.webview.bridge.SharedInstances;
7 |
8 | public class GMAEventSender {
9 | private final IEventSender _eventSender;
10 |
11 | public GMAEventSender() {
12 | this(SharedInstances.INSTANCE.getWebViewEventSender());
13 | }
14 |
15 | public GMAEventSender(IEventSender eventSender) {
16 | _eventSender = eventSender;
17 | }
18 |
19 | public void send(GMAEvent event, Object... params) {
20 | _eventSender.sendEvent(WebViewEventCategory.GMA, event, params);
21 | }
22 |
23 | public void sendVersion(String version) {
24 | _eventSender.sendEvent(WebViewEventCategory.INIT_GMA, GMAEvent.VERSION, version);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/gmascar/utils/ScarConstants.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.gmascar.utils;
2 |
3 | public class ScarConstants {
4 | public static final String SCAR_PRD_BIDDING_ENDPOINT = "https://scar.unityads.unity3d.com/v1/capture-scar-signals";
5 | public static final String IDFI_KEY = "idfi";
6 | public static final String TOKEN_ID_KEY = "tid";
7 | public static final String RV_SIGNAL_KEY = "rv";
8 | public static final String IN_SIGNAL_KEY = "in";
9 | public static final String BN_SIGNAL_KEY = "bn";
10 |
11 | public static final String SCAR_TOKEN_IDENTIFIER_KEY = "scarId";
12 | public static final String TOKEN_WITH_SCAR_FORMAT = "%s:%s";
13 | }
14 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/measurements/MeasurementErrors.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.measurements
2 |
3 | enum class MeasurementsErrors {
4 | ERROR_AD_SERVICES_DISABLED,
5 | ERROR_EXTENSION_BELOW_4,
6 | ERROR_API_BELOW_33,
7 | ERROR_MANAGER_NULL,
8 | ERROR_EXCEPTION,
9 | ERROR_AD_UNIT_NULL,
10 | ERROR_LAYOUT_NULL,
11 | ERROR_LAST_INPUT_EVENT_NULL,
12 | }
13 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/measurements/MeasurementEvents.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.measurements
2 |
3 | enum class MeasurementsEvents {
4 | NOT_AVAILABLE,
5 | AVAILABLE,
6 | VIEW_SUCCESSFUL,
7 | VIEW_ERROR,
8 | CLICK_SUCCESSFUL,
9 | CLICK_ERROR,
10 | }
11 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/measurements/MeasurementsReceiver.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.measurements
2 |
3 | import android.annotation.SuppressLint
4 | import android.os.OutcomeReceiver
5 | import com.unity3d.services.core.webview.WebViewEventCategory
6 | import com.unity3d.services.core.webview.bridge.IEventSender
7 |
8 | @SuppressLint("NewApi", "MissingPermission")
9 | class MeasurementsReceiver(
10 | private val eventSender: IEventSender,
11 | private val successEvent: MeasurementsEvents,
12 | private val errorEvent: MeasurementsEvents,
13 | ): OutcomeReceiver {
14 | override fun onResult(p0: Any) {
15 | eventSender.sendEvent(WebViewEventCategory.MEASUREMENTS, successEvent)
16 | }
17 |
18 | override fun onError(error: Exception) {
19 | eventSender.sendEvent(WebViewEventCategory.MEASUREMENTS, errorEvent, error.toString())
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/measurements/MeasurementsStatusReceiver.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.measurements
2 |
3 | import android.annotation.SuppressLint
4 | import android.os.OutcomeReceiver
5 | import com.unity3d.services.core.webview.WebViewEventCategory
6 | import com.unity3d.services.core.webview.bridge.IEventSender
7 |
8 | @SuppressLint("NewApi", "MissingPermission")
9 | class MeasurementsStatusReceiver(private val eventSender: IEventSender) : OutcomeReceiver {
10 | override fun onResult(status: Int) {
11 | eventSender.sendEvent(WebViewEventCategory.MEASUREMENTS, MeasurementsEvents.AVAILABLE, status)
12 | }
13 |
14 | override fun onError(error: Exception) {
15 | eventSender.sendEvent(WebViewEventCategory.MEASUREMENTS, MeasurementsEvents.NOT_AVAILABLE, MeasurementsErrors.ERROR_EXCEPTION, error.toString())
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/operation/AdModule.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.operation;
2 |
3 | import com.unity3d.services.core.request.metrics.SDKMetricsSender;
4 | import com.unity3d.services.core.webview.bridge.IWebViewSharedObject;
5 | import com.unity3d.services.core.webview.bridge.WebViewBridgeSharedObjectStore;
6 | import com.unity3d.services.core.webview.bridge.invocation.WebViewBridgeInvocationSingleThreadedExecutor;
7 |
8 | import java.util.concurrent.ExecutorService;
9 |
10 | public abstract class AdModule extends WebViewBridgeSharedObjectStore implements IAdModule {
11 | protected SDKMetricsSender _sdkMetrics;
12 | protected ExecutorService _executorService;
13 |
14 | protected AdModule(SDKMetricsSender sdkMetrics) {
15 | super();
16 | _sdkMetrics = sdkMetrics;
17 | _executorService = WebViewBridgeInvocationSingleThreadedExecutor.getInstance().getExecutorService();
18 | }
19 |
20 | public SDKMetricsSender getMetricSender() {
21 | return _sdkMetrics;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/operation/AdOperation.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.operation;
2 |
3 | import com.unity3d.services.core.webview.bridge.invocation.IWebViewBridgeInvocation;
4 |
5 | public abstract class AdOperation implements IAdOperation {
6 | private static String invocationClassName = "webview";
7 |
8 | private IWebViewBridgeInvocation _webViewBridgeInvocation;
9 | private String _invocationMethodName;
10 |
11 | protected AdOperation(IWebViewBridgeInvocation webViewBridgeInvocation, String invocationMethodName) throws NullPointerException {
12 | _invocationMethodName = invocationMethodName;
13 | if (_invocationMethodName == null || _invocationMethodName.isEmpty()) {
14 | throw new IllegalArgumentException("invocationMethodName cannot be null");
15 | }
16 |
17 | _webViewBridgeInvocation = webViewBridgeInvocation;
18 | if (_webViewBridgeInvocation == null) {
19 | throw new IllegalArgumentException("webViewBridgeInvocation cannot be null");
20 | }
21 | }
22 |
23 | @Override
24 | public void invoke(final int timeout, final Object... invocationParameters) {
25 | _webViewBridgeInvocation.invoke(invocationClassName, _invocationMethodName, timeout, invocationParameters);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/operation/IAdModule.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.operation;
2 |
3 | import com.unity3d.services.core.request.metrics.SDKMetricsSender;
4 | import com.unity3d.services.core.webview.bridge.IWebViewBridgeInvoker;
5 | import com.unity3d.services.core.webview.bridge.IWebViewBridgeSharedObjectStore;
6 | import com.unity3d.services.core.webview.bridge.IWebViewSharedObject;
7 |
8 | public interface IAdModule extends IWebViewBridgeSharedObjectStore {
9 | void executeAdOperation(final IWebViewBridgeInvoker webViewBridgeInvoker, final T2 state);
10 | SDKMetricsSender getMetricSender();
11 | }
12 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/operation/IAdOperation.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.operation;
2 |
3 | import com.unity3d.services.core.webview.bridge.IWebViewSharedObject;
4 |
5 | public interface IAdOperation extends IWebViewSharedObject {
6 | void invoke(final int timeout, final Object...invocationParameters);
7 | }
8 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/operation/OperationState.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.operation;
2 |
3 |
4 | import com.unity3d.services.core.configuration.Configuration;
5 | import com.unity3d.services.core.timer.BaseTimer;
6 | import com.unity3d.services.core.webview.bridge.IWebViewSharedObject;
7 |
8 | import java.util.UUID;
9 | import java.util.concurrent.TimeUnit;
10 |
11 | public class OperationState implements IWebViewSharedObject {
12 | private static String _emptyPlacementId = "";
13 |
14 | public String id;
15 | public String placementId;
16 | public Configuration configuration;
17 | public long startTime;
18 | public BaseTimer timeoutTimer;
19 |
20 | public OperationState(String placementId, Configuration configuration) {
21 | this.placementId = placementId == null ? _emptyPlacementId : placementId;
22 | this.configuration = configuration;
23 | id = UUID.randomUUID().toString();
24 | }
25 |
26 | @Override
27 | public String getId() {
28 | return id;
29 | }
30 |
31 | public void start() {
32 | startTime = System.nanoTime();
33 | }
34 |
35 | public long duration() {
36 | return TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime);
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/operation/load/ILoadModule.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.operation.load;
2 |
3 | import com.unity3d.ads.UnityAds;
4 | import com.unity3d.services.ads.operation.IAdModule;
5 |
6 | public interface ILoadModule extends IAdModule {
7 | void onUnityAdsAdLoaded(String operationId);
8 | void onUnityAdsFailedToLoad(String operationId, UnityAds.UnityAdsLoadError error, String message);
9 | }
10 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/operation/load/ILoadOperation.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.operation.load;
2 |
3 | import com.unity3d.ads.IUnityAdsLoadListener;
4 | import com.unity3d.services.ads.operation.IAdOperation;
5 |
6 | public interface ILoadOperation extends IAdOperation, IUnityAdsLoadListener {
7 | LoadOperationState getLoadOperationState();
8 | }
9 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/operation/show/IShowModule.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.operation.show;
2 |
3 | import com.unity3d.ads.UnityAds;
4 | import com.unity3d.services.ads.operation.IAdModule;
5 |
6 | public interface IShowModule extends IAdModule {
7 | void onUnityAdsShowFailure(String id, UnityAds.UnityAdsShowError error, String message);
8 | void onUnityAdsShowConsent(String id);
9 | void onUnityAdsShowStart(String id);
10 | void onUnityAdsShowClick(String id);
11 | void onUnityAdsShowComplete(String id, UnityAds.UnityAdsShowCompletionState state);
12 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/operation/show/IShowOperation.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.operation.show;
2 |
3 | import com.unity3d.ads.IUnityAdsShowListener;
4 | import com.unity3d.services.ads.operation.IAdOperation;
5 |
6 | public interface IShowOperation extends IAdOperation, IUnityAdsShowListener {
7 | ShowOperationState getShowOperationState();
8 | }
9 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/token/AsyncTokenStorage.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.token
2 |
3 | import com.unity3d.services.ads.gmascar.managers.IBiddingManager
4 | import com.unity3d.services.core.configuration.Configuration
5 |
6 | interface AsyncTokenStorage {
7 | fun setConfiguration(configuration: Configuration?)
8 | fun onTokenAvailable()
9 | fun getToken(biddingManager: IBiddingManager?)
10 | }
11 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/token/INativeTokenGenerator.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.token;
2 |
3 | public interface INativeTokenGenerator {
4 | void generateToken(final INativeTokenGeneratorListener callback);
5 | }
6 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/token/INativeTokenGeneratorListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.token;
2 |
3 | public interface INativeTokenGeneratorListener {
4 | void onReady(String token);
5 | }
6 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/token/TokenError.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.token;
2 |
3 | public enum TokenError {
4 | JSON_EXCEPTION
5 | }
6 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/token/TokenEvent.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.token;
2 |
3 | public enum TokenEvent {
4 | TOKEN_ACCESS,
5 | QUEUE_EMPTY,
6 | TOKEN_NATIVE_DATA
7 | }
8 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/token/TokenStorage.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.token
2 |
3 | import org.json.JSONArray
4 | import org.json.JSONException
5 |
6 | interface TokenStorage {
7 | val token: String?
8 | val nativeGeneratedToken: Unit
9 |
10 | @Throws(JSONException::class)
11 | fun createTokens(tokens: JSONArray)
12 | @Throws(JSONException::class)
13 | fun appendTokens(tokens: JSONArray)
14 | fun deleteTokens()
15 | fun setInitToken(value: String?)
16 | }
17 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/topics/TopicsErrors.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.topics
2 |
3 | enum class TopicsErrors {
4 | ERROR_EXCEPTION,
5 | }
6 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/topics/TopicsEvents.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.topics
2 |
3 | enum class TopicsEvents {
4 | NOT_AVAILABLE,
5 | TOPICS_AVAILABLE,
6 | }
7 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/topics/TopicsStatus.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.topics
2 |
3 | enum class TopicsStatus {
4 | TOPICS_AVAILABLE,
5 | ERROR_TOPICSMANAGER_NULL,
6 | ERROR_API_BELOW_33,
7 | ERROR_EXTENSION_BELOW_4,
8 | ERROR_AD_SERVICES_DISABLED,
9 | }
10 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/video/VideoPlayerError.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.video;
2 |
3 | public enum VideoPlayerError {
4 | VIDEOVIEW_NULL,
5 | PREPARE,
6 | API_LEVEL_ERROR
7 | }
8 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/video/VideoPlayerEvent.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.video;
2 |
3 | public enum VideoPlayerEvent {
4 | GENERIC_ERROR,
5 | PROGRESS,
6 | INFO,
7 | COMPLETED,
8 | PREPARED,
9 | PREPARE_ERROR,
10 | PREPARE_TIMEOUT,
11 | PLAY,
12 | PAUSE_ERROR,
13 | PAUSE,
14 | SEEKTO_ERROR,
15 | SEEKTO,
16 | STOP,
17 | ILLEGAL_STATE
18 | }
19 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/webplayer/WebPlayerBridgeInterface.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.webplayer;
2 |
3 | import android.webkit.JavascriptInterface;
4 |
5 | import com.unity3d.services.core.webview.WebViewApp;
6 | import com.unity3d.services.core.webview.WebViewEventCategory;
7 |
8 | public class WebPlayerBridgeInterface {
9 | private final String viewId;
10 |
11 | public WebPlayerBridgeInterface(String viewId) {
12 | this.viewId = viewId;
13 | }
14 |
15 | @JavascriptInterface
16 | public void handleEvent(String data) {
17 | if (WebViewApp.getCurrentApp() != null) {
18 | WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.WEBPLAYER_EVENT, data, viewId);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/webplayer/WebPlayerError.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.webplayer;
2 |
3 | public enum WebPlayerError {
4 | WEBPLAYER_NULL
5 | }
6 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/webplayer/WebPlayerEvent.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.webplayer;
2 |
3 | public enum WebPlayerEvent {
4 | PAGE_STARTED,
5 | PAGE_FINISHED,
6 | ERROR,
7 | HTTP_ERROR,
8 | PERMISSION_REQUEST,
9 | LOAD_RESOUCE,
10 | SSL_ERROR,
11 | CLIENT_CERT_REQUEST,
12 | HTTP_AUTH_REQUEST,
13 | SCALE_CHANGED,
14 | LOGIN_REQUEST,
15 | PROGRESS_CHANGED,
16 | RECEIVED_TITLE,
17 | RECEIVED_ICON,
18 | RECEIVED_TOUCH_ICON_URL,
19 | SHOW_CUSTOM_VIEW,
20 | HIDE_CUSTOM_VIEW,
21 | CREATE_WINDOW,
22 | CLOSE_WINDOW,
23 | REQUEST_FOCUS,
24 | JS_ALERT,
25 | JS_CONFIRM,
26 | JS_PROMPT,
27 | CONSOLE_MESSAGE,
28 | SHOW_FILE_CHOOSER,
29 | GEOLOCATION_PERMISSIONS_SHOW,
30 | DOWNLOAD_START,
31 | SHOULD_OVERRIDE_URL_LOADING,
32 | SHOULD_OVERRIDE_KEY_EVENT,
33 | PAGE_COMMIT_VISIBLE,
34 | FORM_RESUBMISSION,
35 | UNHANDLED_KEY_EVENT,
36 | WEBPLAYER_EVENT,
37 | SHOULD_INTERCEPT_REQUEST,
38 | FRAME_UPDATE,
39 | GET_FRAME_RESPONSE
40 | }
41 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/ads/webplayer/WebPlayerViewCache.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.ads.webplayer;
2 |
3 | import java.util.HashMap;
4 |
5 | public class WebPlayerViewCache {
6 |
7 | private static WebPlayerViewCache instance;
8 |
9 | public static WebPlayerViewCache getInstance() {
10 | if (instance == null) {
11 | instance = new WebPlayerViewCache();
12 | }
13 | return instance;
14 | }
15 |
16 | private HashMap _webPlayerMap;
17 |
18 | public WebPlayerViewCache() {
19 | _webPlayerMap = new HashMap<>();
20 | }
21 |
22 | public synchronized void addWebPlayer(String viewId, WebPlayerView webPlayerView) {
23 | _webPlayerMap.put(viewId, webPlayerView);
24 | }
25 |
26 | public synchronized void removeWebPlayer(String viewId) {
27 | if (_webPlayerMap.containsKey(viewId)) {
28 | _webPlayerMap.remove(viewId);
29 | }
30 | }
31 |
32 | public synchronized WebPlayerView getWebPlayer(String viewId) {
33 | if (_webPlayerMap.containsKey(viewId)) {
34 | return _webPlayerMap.get(viewId);
35 | } else {
36 | return null;
37 | }
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/analytics/AcquisitionType.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.analytics;
2 |
3 | public enum AcquisitionType {
4 | SOFT,
5 | PREMIUM;
6 |
7 | @Override
8 | public String toString() {
9 | switch (this) {
10 | case SOFT:
11 | return "soft";
12 | case PREMIUM:
13 | return "premium";
14 | default:
15 | return "";
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/analytics/core/api/Analytics.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.analytics.core.api;
2 |
3 | import com.unity3d.services.analytics.interfaces.AnalyticsError;
4 | import com.unity3d.services.analytics.interfaces.IAnalytics;
5 | import com.unity3d.services.core.misc.Utilities;
6 | import com.unity3d.services.core.webview.bridge.WebViewCallback;
7 | import com.unity3d.services.core.webview.bridge.WebViewExposed;
8 |
9 | public class Analytics {
10 |
11 | public static IAnalytics analyticsInterface = null;
12 |
13 | public static void setAnalyticsInterface(IAnalytics analytics) {
14 | analyticsInterface = analytics;
15 | }
16 |
17 | @WebViewExposed
18 | public static void addExtras(final String extras, WebViewCallback callback) {
19 | if (analyticsInterface != null) {
20 | Utilities.runOnUiThread(new Runnable() {
21 | @Override
22 | public void run() {
23 | analyticsInterface.onAddExtras(extras);
24 | }
25 | });
26 | callback.invoke();
27 | } else {
28 | callback.error(AnalyticsError.API_NOT_FOUND, extras);
29 | }
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/analytics/core/configuration/AnalyticsModuleConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.analytics.core.configuration;
2 |
3 | import com.unity3d.services.analytics.core.api.Analytics;
4 | import com.unity3d.services.core.configuration.Configuration;
5 | import com.unity3d.services.core.configuration.ErrorState;
6 | import com.unity3d.services.core.configuration.IModuleConfiguration;
7 |
8 | public class AnalyticsModuleConfiguration implements IModuleConfiguration {
9 |
10 | private static final Class[] WEB_APP_API_CLASS_LIST = new Class[] {
11 | Analytics.class
12 | };
13 |
14 | @Override
15 | public Class[] getWebAppApiClassList() {
16 | return WEB_APP_API_CLASS_LIST;
17 | }
18 |
19 | @Override
20 | public boolean resetState(Configuration configuration) {
21 | return true;
22 | }
23 |
24 | @Override
25 | public boolean initErrorState(Configuration configuration, ErrorState state, String message) {
26 | return true;
27 | }
28 |
29 | @Override
30 | public boolean initCompleteState(Configuration configuration) {
31 | return true;
32 | }
33 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/analytics/interfaces/Analytics.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.analytics.interfaces;
2 |
3 | public class Analytics {
4 | /*
5 | * Set from c# layer
6 | */
7 | public static void initialize(IAnalytics analyticsInterfaces) {
8 | com.unity3d.services.analytics.core.api.Analytics.setAnalyticsInterface(analyticsInterfaces);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/analytics/interfaces/AnalyticsError.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.analytics.interfaces;
2 |
3 | public enum AnalyticsError {
4 | API_NOT_FOUND
5 | }
6 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/analytics/interfaces/IAnalytics.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.analytics.interfaces;
2 |
3 | public interface IAnalytics {
4 | void onAddExtras(String extras);
5 | }
6 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/banners/BannerErrorCode.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.banners;
2 |
3 | public enum BannerErrorCode {
4 | UNKNOWN,
5 | NATIVE_ERROR,
6 | WEBVIEW_ERROR,
7 | NO_FILL
8 | }
9 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/banners/configuration/BannersModuleConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.banners.configuration;
2 |
3 | import com.unity3d.services.banners.api.Banner;
4 | import com.unity3d.services.banners.api.BannerListener;
5 | import com.unity3d.services.core.configuration.Configuration;
6 | import com.unity3d.services.core.configuration.ErrorState;
7 | import com.unity3d.services.core.configuration.IModuleConfiguration;
8 |
9 | public class BannersModuleConfiguration implements IModuleConfiguration {
10 | private static final Class[] WEB_APP_API_CLASS_LIST = {
11 | Banner.class,
12 | BannerListener.class
13 | };
14 |
15 | @Override
16 | public Class[] getWebAppApiClassList() {
17 | return WEB_APP_API_CLASS_LIST;
18 | }
19 |
20 | @Override
21 | public boolean resetState(Configuration configuration) {
22 | return true;
23 | }
24 |
25 | @Override
26 | public boolean initErrorState(Configuration configuration, ErrorState state, String message) {
27 | return true;
28 | }
29 |
30 | @Override
31 | public boolean initCompleteState(Configuration configuration) {
32 | return true;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/banners/properties/BannerRefreshInfo.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.banners.properties;
2 |
3 | import java.util.HashMap;
4 |
5 | public class BannerRefreshInfo {
6 |
7 | private static BannerRefreshInfo instance;
8 |
9 | public static BannerRefreshInfo getInstance() {
10 | if (instance == null) {
11 | instance = new BannerRefreshInfo();
12 | }
13 | return instance;
14 | }
15 |
16 | private HashMap _refreshRateMap;
17 |
18 | public BannerRefreshInfo() {
19 | _refreshRateMap = new HashMap<>();
20 | }
21 |
22 | public synchronized void setRefreshRate(String placementId, Integer rate) {
23 | _refreshRateMap.put(placementId, rate);
24 | }
25 |
26 | public synchronized Integer getRefreshRate(String placementId) {
27 | return _refreshRateMap.get(placementId);
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/banners/view/ScarBannerContainer.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.banners.view;
2 |
3 | import android.content.Context;
4 | import android.view.ViewGroup;
5 | import android.view.ViewParent;
6 | import android.widget.RelativeLayout;
7 |
8 | import com.unity3d.services.banners.bridge.BannerBridge;
9 | import com.unity3d.services.core.misc.Utilities;
10 |
11 | public class ScarBannerContainer extends RelativeLayout {
12 |
13 | private String _bannerAdId;
14 |
15 | public ScarBannerContainer(Context context, String bannerAdId) {
16 | super(context);
17 | _bannerAdId = bannerAdId;
18 | }
19 |
20 | public void destroy() {
21 | final ScarBannerContainer self = this;
22 | Utilities.runOnUiThread(() -> {
23 | self.removeAllViews();
24 | ViewParent parent = self.getParent();
25 | if (parent instanceof ViewGroup) {
26 | ((ViewGroup) parent).removeView(self);
27 | }
28 | });
29 | }
30 |
31 | @Override
32 | protected void onAttachedToWindow() {
33 | super.onAttachedToWindow();
34 | BannerBridge.didAttachScarBanner(_bannerAdId);
35 | }
36 |
37 | @Override
38 | protected void onDetachedFromWindow() {
39 | super.onDetachedFromWindow();
40 | BannerBridge.didDetachScarBanner(_bannerAdId);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/api/ClassDetection.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.api;
2 |
3 | import com.unity3d.services.core.properties.MadeWithUnityDetector;
4 | import com.unity3d.services.core.webview.bridge.WebViewCallback;
5 | import com.unity3d.services.core.webview.bridge.WebViewExposed;
6 |
7 | public class ClassDetection {
8 | @WebViewExposed
9 | public static void isMadeWithUnity(WebViewCallback callback) {
10 | callback.invoke(MadeWithUnityDetector.isMadeWithUnity());
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/api/Connectivity.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.api;
2 |
3 | import com.unity3d.services.core.connectivity.ConnectivityMonitor;
4 | import com.unity3d.services.core.webview.bridge.WebViewCallback;
5 | import com.unity3d.services.core.webview.bridge.WebViewExposed;
6 |
7 | public class Connectivity {
8 |
9 | @WebViewExposed
10 | public static void setConnectionMonitoring(Boolean monitoring, WebViewCallback callback) {
11 | ConnectivityMonitor.setConnectionMonitoring(monitoring);
12 | callback.invoke();
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/api/DownloadLatestWebViewStatus.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.api;
2 |
3 | public enum DownloadLatestWebViewStatus {
4 | INIT_QUEUE_NULL(0),
5 | INIT_QUEUE_NOT_EMPTY(1),
6 | MISSING_LATEST_CONFIG(2),
7 | BACKGROUND_DOWNLOAD_STARTED(3);
8 |
9 | private final int value;
10 |
11 | DownloadLatestWebViewStatus(int value) {
12 | this.value = value;
13 | }
14 |
15 | public int getValue() {
16 | return value;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/broadcast/BroadcastError.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.broadcast;
2 |
3 | public enum BroadcastError {
4 | JSON_ERROR
5 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/broadcast/BroadcastEvent.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.broadcast;
2 |
3 | public enum BroadcastEvent {
4 | ACTION
5 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/cache/CacheDirectoryType.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.cache;
2 |
3 | public enum CacheDirectoryType {
4 | EXTERNAL,
5 | INTERNAL
6 | }
7 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/cache/CacheError.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.cache;
2 |
3 | public enum CacheError {
4 | FILE_IO_ERROR,
5 | FILE_NOT_FOUND,
6 | FILE_ALREADY_CACHING,
7 | NOT_CACHING,
8 | JSON_ERROR,
9 | NO_INTERNET,
10 | MALFORMED_URL,
11 | NETWORK_ERROR,
12 | ILLEGAL_STATE,
13 | INVALID_ARGUMENT,
14 | UNSUPPORTED_ENCODING,
15 | FILE_STATE_WRONG,
16 | CACHE_DIRECTORY_NULL,
17 | CACHE_DIRECTORY_TYPE_NULL,
18 | CACHE_DIRECTORY_EXISTS,
19 | CACHE_DIRECTORY_DOESNT_EXIST,
20 | UNKNOWN_ERROR
21 | }
22 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/cache/CacheEvent.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.cache;
2 |
3 | public enum CacheEvent {
4 | DOWNLOAD_STARTED,
5 | DOWNLOAD_PROGRESS,
6 | DOWNLOAD_END,
7 | DOWNLOAD_STOPPED,
8 | DOWNLOAD_ERROR
9 | }
10 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/cache/CacheEventSender.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.cache
2 |
3 | import com.unity3d.services.core.webview.WebViewEventCategory
4 | import com.unity3d.services.core.webview.bridge.IEventSender
5 | import java.io.Serializable
6 |
7 | class CacheEventSender(private val eventSender: IEventSender) : Serializable {
8 | fun sendEvent(eventId: CacheEvent, vararg params: Any): Boolean {
9 | return eventSender.sendEvent(WebViewEventCategory.CACHE, eventId, *params)
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/configuration/AdsSdkInitializer.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.configuration
2 |
3 | import android.content.Context
4 | import androidx.startup.Initializer
5 | import com.unity3d.services.core.properties.ClientProperties
6 |
7 | /**
8 | * Unity SDK Initializer implementation of Androidx.Startup - Initializer interface.
9 | */
10 | class AdsSdkInitializer : Initializer {
11 | override fun create(context: Context) {
12 | ClientProperties.setApplicationContext(context.applicationContext)
13 | }
14 |
15 | override fun dependencies(): List>> {
16 | // No dependencies on other libraries.
17 | return emptyList()
18 | }
19 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/configuration/ConfigurationFailure.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.configuration;
2 |
3 | public enum ConfigurationFailure {
4 | NETWORK_FAILURE, INVALID_DATA
5 | }
6 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/configuration/ErrorState.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.configuration;
2 |
3 | public enum ErrorState {
4 | CreateWebApp("create_webapp"),
5 | NetworkConfigRequest("network_config"),
6 | NetworkWebviewRequest("network_webview"),
7 | InvalidHash("invalid_hash"),
8 | CreateWebview("create_webview"),
9 | MalformedWebviewRequest("malformed_webview"),
10 | ResetWebApp("reset_webapp"),
11 | LoadCache("load_cache"),
12 | InitModules("init_modules"),
13 | CreateWebviewTimeout("create_webview_timeout"),
14 | CreateWebviewGameIdDisabled("create_webview_game_id_disabled"),
15 | CreateWebviewConfigError("create_webview_config_error"),
16 | CreateWebviewInvalidArgument("create_webview_invalid_arg");
17 |
18 | private String _stateMetricName;
19 |
20 | ErrorState(String stateMetricName) {
21 | _stateMetricName = stateMetricName;
22 | }
23 |
24 | public String getMetricName() {
25 | return _stateMetricName;
26 | }
27 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/configuration/ExperimentAppliedRule.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.configuration;
2 |
3 | public enum ExperimentAppliedRule {
4 | NEXT,
5 | IMMEDIATE
6 | }
7 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/configuration/ExperimentsBase.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.configuration;
2 |
3 | public abstract class ExperimentsBase implements IExperiments {
4 | static final String TSI_TAG_NATIVE_TOKEN_AWAIT_PRIVACY = "tsi_prw";
5 | static final String EXP_TAG_NATIVE_WEBVIEW_CACHE = "nwc";
6 | static final String EXP_TAG_WEB_AD_ASSET_CACHING = "wac";
7 | static final String EXP_TAG_WEB_GESTURE_NOT_REQUIRED = "wgr";
8 | static final String EXP_TAG_SCAR_INIT = "scar_init";
9 | static final String EXP_TAG_JETPACK_LIFECYCLE = "gjl";
10 | static final String EXP_TAG_OK_HTTP = "okhttp";
11 | static final String EXP_TAG_WEB_MESSAGE = "jwm";
12 | static final String EXP_TAG_WEBVIEW_ASYNC_DOWNLOAD = "wad";
13 | static final String EXP_TAG_CRONET_CHECK = "cce";
14 | static final String EXP_TAG_SHOW_TIMEOUT_DISABLED = "nstd";
15 | static final String EXP_TAG_LOAD_TIMEOUT_DISABLED = "nltd";
16 | static final String EXP_TAG_HDR_CAPABILITIES = "hdrc";
17 | static final String EXP_TAG_SCAR_HB_BN = "scar_bn";
18 | static final String EXP_TAG_IS_PC_CHECK_ENABLED = "pc_check";
19 | static final boolean EXP_DEFAULT_VALUE = false;
20 | }
21 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/configuration/IConfigurationLoader.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.configuration;
2 |
3 | public interface IConfigurationLoader {
4 | void loadConfiguration(IConfigurationLoaderListener configurationLoaderListener) throws Exception;
5 | Configuration getLocalConfiguration();
6 | }
7 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/configuration/IConfigurationLoaderListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.configuration;
2 |
3 | public interface IConfigurationLoaderListener {
4 | void onSuccess(Configuration configuration);
5 | void onError(String errorMsg);
6 | }
7 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/configuration/IExperiments.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.configuration;
2 |
3 | import org.json.JSONObject;
4 |
5 | import java.util.Map;
6 |
7 | public interface IExperiments {
8 | boolean shouldNativeTokenAwaitPrivacy();
9 | boolean isNativeWebViewCacheEnabled();
10 | boolean isWebAssetAdCaching();
11 | boolean isWebGestureNotRequired();
12 | boolean isScarInitEnabled();
13 | boolean isJetpackLifecycle();
14 | boolean isOkHttpEnabled();
15 | boolean isWebMessageEnabled();
16 | boolean isWebViewAsyncDownloadEnabled();
17 | boolean isCronetCheckEnabled();
18 | boolean isNativeShowTimeoutDisabled();
19 | boolean isNativeLoadTimeoutDisabled();
20 | boolean isCaptureHDRCapabilitiesEnabled();
21 | boolean isScarBannerHbEnabled();
22 | boolean isPCCheckEnabled();
23 |
24 | JSONObject getCurrentSessionExperiments();
25 | JSONObject getNextSessionExperiments();
26 | JSONObject getExperimentsAsJson();
27 | Map getExperimentTags();
28 | }
29 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/configuration/IInitializationListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.configuration;
2 |
3 | public interface IInitializationListener {
4 |
5 | void onSdkInitialized();
6 |
7 | void onSdkInitializationFailed(String message, ErrorState errorState, int code);
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/configuration/IInitializationNotificationCenter.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.configuration;
2 |
3 | public interface IInitializationNotificationCenter {
4 |
5 | void addListener(IInitializationListener listener);
6 |
7 | void removeListener(IInitializationListener listener);
8 |
9 | void triggerOnSdkInitialized();
10 |
11 | void triggerOnSdkInitializationFailed(String message, ErrorState errorState, int code);
12 | }
13 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/configuration/IInitializeEventsMetricSender.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.configuration;
2 |
3 | import com.unity3d.services.core.request.metrics.Metric;
4 |
5 | import java.util.Map;
6 |
7 | public interface IInitializeEventsMetricSender {
8 |
9 | void didInitStart();
10 |
11 | void didConfigRequestStart();
12 |
13 | void didConfigRequestEnd(boolean success);
14 |
15 | void didPrivacyConfigRequestStart();
16 |
17 | void didPrivacyConfigRequestEnd(boolean success);
18 |
19 | void sdkDidInitialize();
20 |
21 | void onRetryConfig();
22 |
23 | void onRetryWebview();
24 |
25 | Long initializationStartTimeStamp();
26 |
27 | void sdkInitializeFailed(String message, ErrorState errorState);
28 |
29 | void sdkTokenDidBecomeAvailableWithConfig(boolean withConfig);
30 |
31 | Long duration();
32 |
33 | Long tokenDuration();
34 |
35 | Long privacyConfigDuration();
36 |
37 | Long configRequestDuration();
38 |
39 | Map getRetryTags();
40 |
41 | void sendMetric(Metric metric);
42 | }
43 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/configuration/IModuleConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.configuration;
2 |
3 | public interface IModuleConfiguration {
4 | Class[] getWebAppApiClassList();
5 | boolean resetState(Configuration configuration);
6 | boolean initErrorState(Configuration configuration, ErrorState state, String message);
7 | boolean initCompleteState(Configuration configuration);
8 | }
9 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/configuration/IPrivacyConfigurationListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.configuration;
2 |
3 | public interface IPrivacyConfigurationListener {
4 | void onSuccess(PrivacyConfig privacyConfig);
5 | void onError(PrivacyCallError privacyCallError, String errorMsg);
6 | }
7 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/configuration/InitRequestType.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.configuration;
2 |
3 | public enum InitRequestType {
4 | PRIVACY("privacy"),
5 | TOKEN("token_srr");
6 |
7 | InitRequestType(String callType) { _callType = callType;}
8 |
9 | private String _callType;
10 | public String getCallType() { return _callType; }
11 | }
12 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/configuration/PrivacyCallError.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.configuration
2 |
3 | enum class PrivacyCallError {
4 | NETWORK_ISSUE,
5 | LOCKED_423;
6 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/configuration/PrivacyConfig.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.configuration;
2 |
3 | import org.json.JSONObject;
4 |
5 | public class PrivacyConfig {
6 | private PrivacyConfigStatus _privacyConfigStatus;
7 | private boolean _shouldSendNonBehavioral;
8 |
9 | public PrivacyConfig() {
10 | this(PrivacyConfigStatus.UNKNOWN);
11 | }
12 |
13 | public PrivacyConfig(JSONObject privacyResponse) {
14 | parsePrivacyResponse(privacyResponse);
15 | }
16 |
17 | public PrivacyConfig(PrivacyConfigStatus privacyConfigStatus) {
18 | _privacyConfigStatus = privacyConfigStatus;
19 | _shouldSendNonBehavioral = false;
20 | }
21 |
22 | public boolean allowedToSendPii() {
23 | return _privacyConfigStatus.equals(PrivacyConfigStatus.ALLOWED);
24 | }
25 |
26 | public boolean shouldSendNonBehavioral() {
27 | return _shouldSendNonBehavioral;
28 | }
29 |
30 | public PrivacyConfigStatus getPrivacyStatus() {
31 | return _privacyConfigStatus;
32 | }
33 |
34 | private void parsePrivacyResponse(JSONObject privacyResponse) {
35 | _privacyConfigStatus = privacyResponse.optBoolean("pas", false) ? PrivacyConfigStatus.ALLOWED : PrivacyConfigStatus.DENIED;
36 | _shouldSendNonBehavioral = privacyResponse.optBoolean("snb", false);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/configuration/PrivacyConfigStatus.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.configuration;
2 |
3 | public enum PrivacyConfigStatus {
4 | UNKNOWN,
5 | ALLOWED,
6 | DENIED;
7 |
8 | public String toLowerCase() {
9 | return name().toLowerCase();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/configuration/PrivacyConfigStorage.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.configuration;
2 |
3 | import com.unity3d.services.core.misc.IObserver;
4 | import com.unity3d.services.core.misc.Observable;
5 |
6 | public class PrivacyConfigStorage extends Observable {
7 | private static PrivacyConfigStorage _instance;
8 | private PrivacyConfig _privacyConfig;
9 |
10 | private PrivacyConfigStorage() {
11 | _privacyConfig = new PrivacyConfig();
12 | }
13 |
14 | public static PrivacyConfigStorage getInstance() {
15 | if (_instance == null) {
16 | _instance = new PrivacyConfigStorage();
17 | }
18 | return _instance;
19 | }
20 |
21 | public synchronized PrivacyConfig getPrivacyConfig() {
22 | return _privacyConfig;
23 | }
24 |
25 | @Override
26 | public synchronized void registerObserver(IObserver observer) {
27 | super.registerObserver(observer);
28 | // Trigger this observer if privacy config was previously set
29 | if (_privacyConfig.getPrivacyStatus() != PrivacyConfigStatus.UNKNOWN) {
30 | observer.updated(_privacyConfig);
31 | }
32 | }
33 |
34 | public synchronized void setPrivacyConfig(PrivacyConfig privacyConfig) {
35 | _privacyConfig = privacyConfig;
36 | notifyObservers(privacyConfig);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/connectivity/ConnectivityEvent.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.connectivity;
2 |
3 | public enum ConnectivityEvent {
4 | CONNECTED, DISCONNECTED, NETWORK_CHANGE
5 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/connectivity/IConnectivityListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.connectivity;
2 |
3 | public interface IConnectivityListener {
4 | public void onConnected();
5 | public void onDisconnected();
6 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/device/DeviceError.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.device;
2 |
3 | public enum DeviceError {
4 | APPLICATION_CONTEXT_NULL,
5 | APPLICATION_INFO_NOT_AVAILABLE,
6 | AUDIOMANAGER_NULL,
7 | INVALID_STORAGETYPE,
8 | COULDNT_GET_STORAGE_LOCATION,
9 | COULDNT_GET_GL_VERSION,
10 | JSON_ERROR,
11 | COULDNT_GET_DIGEST,
12 | COULDNT_GET_FINGERPRINT,
13 | COULDNT_GET_ADB_STATUS
14 | }
15 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/device/DeviceInfoEvent.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.device
2 |
3 | enum class DeviceInfoEvent {
4 | VOLUME_CHANGED
5 | }
6 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/device/MimeTypes.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.device;
2 |
3 | public class MimeTypes {
4 | public static final String BASE_TYPE_VIDEO = "video";
5 | public static final String BASE_TYPE_AUDIO = "audio";
6 |
7 | public static final String VIDEO_WEBM = BASE_TYPE_VIDEO + "/webm";
8 | public static final String VIDEO_H264 = BASE_TYPE_VIDEO + "/avc";
9 | public static final String VIDEO_H265 = BASE_TYPE_VIDEO + "/hevc";
10 | public static final String VIDEO_AV1 = BASE_TYPE_VIDEO + "/av01";
11 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/device/StorageError.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.device;
2 |
3 | public enum StorageError {
4 | COULDNT_SET_VALUE,
5 | COULDNT_GET_VALUE,
6 | COULDNT_WRITE_STORAGE_TO_CACHE,
7 | COULDNT_CLEAR_STORAGE,
8 | COULDNT_GET_STORAGE,
9 | COULDNT_DELETE_VALUE
10 | }
11 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/device/StorageEvent.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.device;
2 |
3 | public enum StorageEvent {
4 | SET,
5 | DELETE,
6 | CLEAR,
7 | WRITE,
8 | READ,
9 | INIT
10 | }
11 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/device/TokenType.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.device;
2 |
3 | public enum TokenType {
4 | TOKEN_NATIVE,
5 | TOKEN_REMOTE
6 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/device/VolumeChange.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.device
2 |
3 | interface VolumeChange {
4 | fun startObserving()
5 | fun stopObserving()
6 | fun registerListener(volumeChangeListener: VolumeChangeListener)
7 | fun unregisterListener(volumeChangeListener: VolumeChangeListener)
8 | fun clearAllListeners()
9 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/device/VolumeChangeListener.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.device
2 |
3 | interface VolumeChangeListener {
4 | fun onVolumeChanged(volume: Int)
5 | fun getStreamType(): Int
6 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/device/reader/DeviceInfoReaderWithAuid.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.device.reader
2 |
3 | import com.unity3d.services.core.device.Device
4 |
5 | class DeviceInfoReaderWithAuid(
6 | private val _deviceInfoReader: IDeviceInfoReader
7 | ) : IDeviceInfoReader {
8 | override fun getDeviceInfoData(): Map {
9 | val originalData: MutableMap = _deviceInfoReader.deviceInfoData
10 | Device.getAuid()?.let { originalData[JsonStorageKeyNames.AUID_ID_KEY] = it }
11 | return originalData
12 | }
13 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/device/reader/DeviceInfoReaderWithExtras.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.device.reader;
2 |
3 | import java.util.Map;
4 |
5 | public class DeviceInfoReaderWithExtras implements IDeviceInfoReader {
6 |
7 | private final IDeviceInfoReader _deviceInfoReader;
8 | private final Map _extras;
9 |
10 | public DeviceInfoReaderWithExtras(IDeviceInfoReader deviceInfoReader, Map extras) {
11 | _deviceInfoReader = deviceInfoReader;
12 | _extras = extras;
13 | }
14 |
15 | @Override
16 | public Map getDeviceInfoData() {
17 | Map deviceInfoData = _deviceInfoReader.getDeviceInfoData();
18 | if (deviceInfoData != null && _extras != null) {
19 | deviceInfoData.putAll(_extras);
20 | }
21 | return deviceInfoData;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/device/reader/DeviceInfoReaderWithFilter.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.device.reader;
2 |
3 | import java.util.List;
4 | import java.util.Map;
5 |
6 | public class DeviceInfoReaderWithFilter implements IDeviceInfoReader {
7 | IDeviceInfoReader _deviceInfoReader;
8 | List _keysToExclude;
9 |
10 | public DeviceInfoReaderWithFilter(IDeviceInfoReader deviceInfoReader, List keysToExclude) {
11 | _deviceInfoReader = deviceInfoReader;
12 | _keysToExclude = keysToExclude;
13 | }
14 |
15 | @Override
16 | public Map getDeviceInfoData() {
17 | Map filteredDeviceInfoData = _deviceInfoReader.getDeviceInfoData();
18 | if (_keysToExclude != null) {
19 | for (String keyToExclude : _keysToExclude) {
20 | filteredDeviceInfoData.remove(keyToExclude);
21 | }
22 | }
23 | return filteredDeviceInfoData;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/device/reader/DeviceInfoReaderWithLifecycle.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.device.reader;
2 |
3 |
4 | import com.unity3d.services.core.lifecycle.LifecycleCache;
5 |
6 | import java.util.Map;
7 |
8 | public class DeviceInfoReaderWithLifecycle implements IDeviceInfoReader {
9 |
10 | private final IDeviceInfoReader _deviceInfoReader;
11 | private final LifecycleCache _lifecycleCache;
12 |
13 | public DeviceInfoReaderWithLifecycle(IDeviceInfoReader deviceInfoReader, LifecycleCache lifecycleCache) {
14 | _deviceInfoReader = deviceInfoReader;
15 | _lifecycleCache = lifecycleCache;
16 | }
17 |
18 | @Override
19 | public Map getDeviceInfoData() {
20 | Map deviceInfoData = _deviceInfoReader.getDeviceInfoData();
21 | deviceInfoData.put("appActive", _lifecycleCache.isAppActive());
22 | return deviceInfoData;
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/device/reader/DeviceInfoReaderWithRequestType.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.device.reader;
2 |
3 | import com.unity3d.services.core.configuration.InitRequestType;
4 |
5 | import java.util.Map;
6 |
7 | public class DeviceInfoReaderWithRequestType implements IDeviceInfoReader {
8 | private final IDeviceInfoReader _deviceInfoReader;
9 | private final InitRequestType _initRequestType;
10 |
11 | public DeviceInfoReaderWithRequestType(IDeviceInfoReader deviceInfoReader, InitRequestType initRequestType) {
12 | _deviceInfoReader = deviceInfoReader;
13 | _initRequestType = initRequestType;
14 | }
15 |
16 | @Override
17 | public Map getDeviceInfoData() {
18 | Map originalData = _deviceInfoReader.getDeviceInfoData();
19 | if (_initRequestType != null) {
20 | originalData.put("callType", _initRequestType.toString().toLowerCase());
21 | }
22 | return originalData;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/device/reader/DeviceInfoReaderWithSessionId.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.device.reader;
2 |
3 | import static com.unity3d.services.core.device.reader.JsonStorageKeyNames.SESSION_ID_KEY;
4 |
5 | import com.unity3d.services.core.properties.Session;
6 |
7 | import java.util.Map;
8 |
9 | public class DeviceInfoReaderWithSessionId implements IDeviceInfoReader {
10 | private final IDeviceInfoReader _deviceInfoReader;
11 | private final Session _session;
12 |
13 | public DeviceInfoReaderWithSessionId(IDeviceInfoReader deviceInfoReader, Session sessionId) {
14 | _deviceInfoReader = deviceInfoReader;
15 | _session = sessionId;
16 | }
17 |
18 | @Override
19 | public Map getDeviceInfoData() {
20 | Map originalData = _deviceInfoReader.getDeviceInfoData();
21 | originalData.put(SESSION_ID_KEY, _session.getId());
22 | return originalData;
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/device/reader/IDeviceInfoDataCompressor.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.device.reader;
2 |
3 | import java.util.Map;
4 |
5 | public interface IDeviceInfoDataCompressor extends IDeviceInfoDataContainer{
6 | byte[] compressDeviceInfo(Map deviceData);
7 | }
8 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/device/reader/IDeviceInfoDataContainer.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.device.reader;
2 |
3 | import java.util.Map;
4 |
5 | public interface IDeviceInfoDataContainer {
6 | byte[] getDeviceData();
7 | Map getDeviceInfo();
8 | }
9 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/device/reader/IDeviceInfoReader.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.device.reader;
2 |
3 | import java.util.Map;
4 |
5 | public interface IDeviceInfoReader {
6 | Map getDeviceInfoData();
7 | }
8 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/device/reader/IGameSessionIdReader.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.device.reader;
2 |
3 | public interface IGameSessionIdReader {
4 | Long getGameSessionId();
5 | Long getGameSessionIdAndStore();
6 | }
7 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/device/reader/IHdrInfoReader.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.device.reader;
2 |
3 | import android.app.Activity;
4 |
5 | import com.unity3d.services.core.configuration.ExperimentsReader;
6 |
7 | public interface IHdrInfoReader {
8 | void captureHDRCapabilityMetrics(Activity activity, ExperimentsReader experimentsReader);
9 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/device/reader/builder/DeviceInfoReaderBuilderWithExtras.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.device.reader.builder;
2 |
3 | import com.unity3d.services.core.configuration.ConfigurationReader;
4 | import com.unity3d.services.core.configuration.PrivacyConfigStorage;
5 | import com.unity3d.services.core.device.reader.DeviceInfoReaderWithExtras;
6 | import com.unity3d.services.core.device.reader.IDeviceInfoReader;
7 | import com.unity3d.services.core.device.reader.IGameSessionIdReader;
8 |
9 | import java.util.Map;
10 |
11 | public class DeviceInfoReaderBuilderWithExtras extends DeviceInfoReaderBuilder {
12 |
13 | private Map _extras;
14 |
15 | public DeviceInfoReaderBuilderWithExtras(ConfigurationReader configurationReader, PrivacyConfigStorage privacyConfigStorage, IGameSessionIdReader gameSessionIdReader) {
16 | super(configurationReader, privacyConfigStorage, gameSessionIdReader);
17 | }
18 |
19 | public void setExtras(Map extras) {
20 | _extras = extras;
21 | }
22 |
23 | @Override
24 | public IDeviceInfoReader build() {
25 | if (_extras == null) {
26 | return super.build();
27 | }
28 | return new DeviceInfoReaderWithExtras(super.build(), _extras);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/device/reader/pii/NonBehavioralFlag.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.device.reader.pii
2 |
3 | enum class NonBehavioralFlag {
4 | UNKNOWN,
5 | TRUE,
6 | FALSE;
7 |
8 | companion object {
9 | fun fromString(value: String): NonBehavioralFlag =
10 | runCatching { valueOf(value.uppercase()) }.getOrDefault(UNKNOWN)
11 | }
12 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/device/reader/pii/NonBehavioralFlagReader.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.device.reader.pii
2 |
3 | import com.unity3d.services.core.device.reader.JsonStorageKeyNames
4 | import com.unity3d.services.core.misc.IJsonStorageReader
5 |
6 | open class NonBehavioralFlagReader(private val jsonStorageReader: IJsonStorageReader) {
7 | open fun getUserNonBehavioralFlag(): NonBehavioralFlag {
8 | val privacyModeObj: Any? = jsonStorageReader.get(JsonStorageKeyNames.USER_NON_BEHAVIORAL_VALUE_KEY)
9 | ?: jsonStorageReader.get(JsonStorageKeyNames.USER_NON_BEHAVIORAL_VALUE_ALT_KEY)
10 |
11 | return NonBehavioralFlag.fromString(privacyModeObj.toString())
12 | }
13 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/device/reader/pii/PiiDataProvider.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.device.reader.pii;
2 |
3 | import com.unity3d.services.core.device.Device;
4 |
5 | public class PiiDataProvider {
6 |
7 | public String getAdvertisingTrackingId() {
8 | return Device.getAdvertisingTrackingId();
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/device/reader/pii/PiiPrivacyMode.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.device.reader.pii;
2 |
3 | import java.util.Locale;
4 |
5 | public enum PiiPrivacyMode {
6 | APP,
7 | NONE,
8 | MIXED,
9 | UNDEFINED,
10 | NULL;
11 |
12 | public static PiiPrivacyMode getPiiPrivacyMode(String privacyModeStr) {
13 | if (privacyModeStr == null) return NULL;
14 | PiiPrivacyMode piiPrivacyMode = UNDEFINED;
15 | try {
16 | piiPrivacyMode = valueOf(privacyModeStr.toUpperCase(Locale.ROOT));
17 | } catch (IllegalArgumentException ex) {
18 | // If it can't find the value, it will default to UNDEFINED.
19 | }
20 | return piiPrivacyMode;
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/di/IServiceComponent.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.di
2 |
3 | /**
4 | * Base interface to extend to facilitate access to [ServiceProvider]
5 | */
6 | interface IServiceComponent {
7 | fun getServiceProvider(): IServiceProvider = ServiceProvider
8 | }
9 |
10 | /**
11 | * Get instance from the ServiceProvider
12 | * @param named if a specific instance is required
13 | *
14 | * @return instance of type T
15 | */
16 | inline fun IServiceComponent.get(
17 | named: String = ""
18 | ): T {
19 | return getServiceProvider().getRegistry().getService(named, instance = T::class)
20 | }
21 |
22 | /**
23 | * Lazy inject instance from the ServiceProvider
24 | * @param named if a specific instance is required
25 | * @param mode to define a specific [LazyThreadSafetyMode]
26 | *
27 | * @return [Lazy] instance of type T
28 | */
29 | inline fun IServiceComponent.inject(
30 | named: String = "",
31 | mode: LazyThreadSafetyMode = LazyThreadSafetyMode.NONE,
32 | ): Lazy =
33 | lazy(mode) { get(named) }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/di/IServiceProvider.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.di
2 |
3 | /**
4 | * Service provider based on Koin Apis
5 | */
6 | interface IServiceProvider {
7 |
8 | fun initialize(): IServicesRegistry
9 |
10 | fun getRegistry(): IServicesRegistry
11 |
12 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/di/IServicesRegistry.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.di
2 |
3 | import kotlin.reflect.KClass
4 |
5 | /**
6 | * Class responsible for instantiating and containment of instances
7 | */
8 | interface IServicesRegistry {
9 |
10 | val services: Map>
11 |
12 | fun updateService(key: ServiceKey, instance: Lazy)
13 |
14 | fun resolveService(key: ServiceKey): T
15 |
16 | fun resolveServiceOrNull(key: ServiceKey): T?
17 |
18 | fun getService(named: String = "", instance: KClass<*>): T
19 |
20 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/di/ServiceComponent.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.di
2 |
3 | /**
4 | * Base interface to extend to facilitate access to [ServiceProvider]
5 | */
6 | interface ServiceComponent {
7 | fun getServiceProvider(): ServiceProvider
8 | }
9 |
10 | /**
11 | * Get instance from the ServiceProvider
12 | * @param named if a specific instance is required
13 | *
14 | * @return instance of type T
15 | */
16 | inline fun ServiceComponent.get(
17 | named: String = ""
18 | ): T {
19 | return getServiceProvider().getRegistry().getService(named, instance = T::class)
20 | }
21 |
22 | /**
23 | * Lazy inject instance from the ServiceProvider
24 | * @param named if a specific instance is required
25 | * @param mode to define a specific [LazyThreadSafetyMode]
26 | *
27 | * @return [Lazy] instance of type T
28 | */
29 | inline fun ServiceComponent.inject(
30 | named: String = "",
31 | mode: LazyThreadSafetyMode = LazyThreadSafetyMode.NONE,
32 | ): Lazy =
33 | lazy(mode) { get(named) }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/di/ServiceFactory.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.di
2 |
3 | private class Factory internal constructor(private val initializer: () -> T) : Lazy {
4 |
5 | override val value: T
6 | get() {
7 | return initializer()
8 | }
9 |
10 | override fun isInitialized(): Boolean = false
11 | }
12 |
13 | fun factoryOf(initializer: () -> T): Lazy = Factory(initializer)
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/di/ServiceKey.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.di
2 |
3 | import kotlin.reflect.KClass
4 |
5 | data class ServiceKey(
6 | val named: String = "",
7 | val instanceClass: KClass<*>,
8 | )
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/domain/ISDKDispatchers.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.domain
2 |
3 | import kotlinx.coroutines.CoroutineDispatcher
4 |
5 | interface ISDKDispatchers {
6 | val io: CoroutineDispatcher
7 | val default: CoroutineDispatcher
8 | val main: CoroutineDispatcher
9 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/domain/SDKDispatchers.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.domain
2 |
3 | import kotlinx.coroutines.CoroutineDispatcher
4 | import kotlinx.coroutines.Dispatchers
5 |
6 | /**
7 | * A wrapper class for common coroutine dispatchers.
8 | * An instance of this can be injected to classes which are concerned about executing code
9 | * on different threads, but they don't need to know about the underlying implementation.
10 | */
11 | class SDKDispatchers: ISDKDispatchers {
12 | /**
13 | * Dispatcher for IO-bound work
14 | */
15 | override val io: CoroutineDispatcher = Dispatchers.IO
16 |
17 | /**
18 | * Dispatcher for standard work
19 | */
20 | override val default: CoroutineDispatcher = Dispatchers.Default
21 |
22 | /**
23 | * Dispatcher for main thread
24 | */
25 | override val main: CoroutineDispatcher = Dispatchers.Main
26 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/domain/task/BaseParams.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.domain.task
2 |
3 | /**
4 | * Interface representing params to be passed in for each interactor.
5 | * Implement this for each interactor that requires specific params.
6 | */
7 | interface BaseParams
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/domain/task/BaseTask.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.domain.task
2 |
3 | import com.unity3d.services.core.di.IServiceComponent
4 |
5 | /**
6 | * A task represents an execution unit of asynchronous work.
7 | * A [BaseTask] returns a single response through a suspend function.
8 | */
9 | interface BaseTask: IServiceComponent {
10 |
11 | suspend operator fun invoke(params: P): Result = doWork(params)
12 |
13 | suspend fun doWork(params: P): Result
14 |
15 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/domain/task/EmptyParams.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.domain.task
2 |
3 | /**
4 | * A special [BaseParams] representing empty params.
5 | * Use this when the interactor requires no params.
6 | */
7 | object EmptyParams : BaseParams
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/domain/task/InitializationException.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.domain.task
2 |
3 | import com.unity3d.services.core.configuration.Configuration
4 | import com.unity3d.services.core.configuration.ErrorState
5 |
6 | data class InitializationException(val errorState: ErrorState, val originalException: Exception, val config: Configuration): Exception(originalException)
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/domain/task/InitializeStateComplete.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.domain.task
2 |
3 | import com.unity3d.services.core.configuration.Configuration
4 | import com.unity3d.services.core.domain.ISDKDispatchers
5 | import com.unity3d.services.core.extensions.runReturnSuspendCatching
6 | import kotlinx.coroutines.withContext
7 |
8 | class InitializeStateComplete(
9 | private val dispatchers: ISDKDispatchers,
10 | ) : MetricTask() {
11 |
12 | override fun getMetricName(): String {
13 | return getMetricNameForInitializeTask("completion")
14 | }
15 |
16 | override suspend fun doWork(params: Params): Result = withContext(dispatchers.default) {
17 | runReturnSuspendCatching {
18 | for (moduleName in params.config.moduleConfigurationList) {
19 | params.config.getModuleConfiguration(moduleName)?.initCompleteState(params.config)
20 | }
21 | }
22 | }
23 |
24 | data class Params(val config: Configuration) : BaseParams
25 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/extensions/CoroutineExtensions.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.extensions
2 |
3 | import kotlin.coroutines.cancellation.CancellationException
4 |
5 | /**
6 | * Stops runCatching from swallowing [CancellationException] and messing up structured concurrency
7 | */
8 | inline fun runSuspendCatching(block: () -> R): Result {
9 | return try {
10 | Result.success(block())
11 | } catch (c: CancellationException) {
12 | throw c
13 | } catch (e: Throwable) {
14 | Result.failure(e)
15 | }
16 | }
17 |
18 | inline fun runReturnSuspendCatching(block: () -> R): Result {
19 | return runSuspendCatching(block)
20 | .onSuccess { return Result.success(it) }
21 | .onFailure { return Result.failure(it) }
22 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/lifecycle/CachedLifecycle.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.lifecycle;
2 |
3 | import android.annotation.TargetApi;
4 |
5 | import com.unity3d.services.core.configuration.ConfigurationReader;
6 | import com.unity3d.services.core.properties.ClientProperties;
7 |
8 | public class CachedLifecycle {
9 |
10 | private static LifecycleCache _listener;
11 |
12 | public static void register() {
13 | if (ClientProperties.getApplication() != null) {
14 | if (getLifecycleListener() == null) {
15 | setLifecycleListener(new LifecycleCache(new ConfigurationReader()));
16 | ClientProperties.getApplication().registerActivityLifecycleCallbacks(getLifecycleListener());
17 | }
18 | }
19 | }
20 |
21 | public static void unregister() {
22 | if (ClientProperties.getApplication() != null) {
23 | if (getLifecycleListener() != null) {
24 | ClientProperties.getApplication().unregisterActivityLifecycleCallbacks(getLifecycleListener());
25 | setLifecycleListener(null);
26 | }
27 | }
28 | }
29 |
30 | public static LifecycleCache getLifecycleListener () {
31 | return _listener;
32 | }
33 |
34 | public static void setLifecycleListener (LifecycleCache listener) {
35 | _listener = listener;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/lifecycle/IAppActiveListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.lifecycle;
2 |
3 | public interface IAppActiveListener {
4 | void onAppStateChanged(boolean isAppActive);
5 | }
6 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/lifecycle/IAppEventListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.lifecycle;
2 |
3 | public interface IAppEventListener {
4 | void onLifecycleEvent(LifecycleEvent event);
5 | }
6 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/lifecycle/LifecycleError.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.lifecycle;
2 |
3 | public enum LifecycleError {
4 | APPLICATION_NULL,
5 | LISTENER_NOT_NULL,
6 | JSON_ERROR
7 | }
8 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/lifecycle/LifecycleEvent.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.lifecycle;
2 |
3 | public enum LifecycleEvent {
4 | CREATED,
5 | STARTED,
6 | RESUMED,
7 | PAUSED,
8 | STOPPED,
9 | SAVE_INSTANCE_STATE,
10 | DESTROYED
11 | }
12 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/log/DeviceLogLevel.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.log;
2 |
3 | public class DeviceLogLevel {
4 |
5 | private String _receivingMethodName = null;
6 | private static final String LOG_TAG = "UnityAds";
7 |
8 | public DeviceLogLevel(String receivingMethodName) {
9 | _receivingMethodName = receivingMethodName;
10 | }
11 |
12 | public String getLogTag () {
13 | return LOG_TAG;
14 | }
15 |
16 | public String getReceivingMethodName () {
17 | return _receivingMethodName;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/misc/IEventListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.misc;
2 |
3 | public interface IEventListener {
4 | void onNextEvent(T nextEvent);
5 | }
6 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/misc/IJsonStorageReader.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.misc;
2 |
3 | import org.json.JSONObject;
4 |
5 | public interface IJsonStorageReader {
6 | JSONObject getData();
7 | Object get(String key);
8 | }
9 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/misc/IObserver.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.misc;
2 |
3 | public interface IObserver {
4 | void updated(T value);
5 | }
6 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/misc/JsonFlattenerRules.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.misc;
2 |
3 | import java.util.List;
4 |
5 | public class JsonFlattenerRules {
6 | List _topLevelToInclude;
7 | List _reduceKeys;
8 | List _skipKeys;
9 |
10 | public JsonFlattenerRules(List topLevelToInclude, List reduceKeys, List skipKeys) {
11 | _topLevelToInclude = topLevelToInclude;
12 | _reduceKeys = reduceKeys;
13 | _skipKeys = skipKeys;
14 | }
15 |
16 | public List getTopLevelToInclude() {
17 | return _topLevelToInclude;
18 | }
19 |
20 | public List getReduceKeys() {
21 | return _reduceKeys;
22 | }
23 |
24 | public List getSkipKeys() {
25 | return _skipKeys;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/misc/Observable.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.misc;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | public abstract class Observable {
7 | private final List> _observers;
8 |
9 | public Observable() {
10 | _observers = new ArrayList<>();
11 | }
12 |
13 | public synchronized void registerObserver(IObserver observer) {
14 | if (_observers.contains(observer)) return;
15 | _observers.add(observer);
16 | }
17 |
18 | public synchronized void unregisterObserver(IObserver observer) {
19 | if (_observers.contains(observer)) {
20 | _observers.remove(observer);
21 | }
22 | }
23 |
24 | protected synchronized void notifyObservers(T value) {
25 | for (IObserver observer : _observers) {
26 | observer.updated(value);
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/network/core/HttpClient.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.network.core
2 |
3 | import com.unity3d.services.core.network.model.HttpRequest
4 | import com.unity3d.services.core.network.model.HttpResponse
5 |
6 | /**
7 | * Abstraction to be able to swap out different http client implementations
8 | */
9 | interface HttpClient {
10 | @Throws(Exception::class)
11 | fun executeBlocking(request: HttpRequest): HttpResponse
12 | suspend fun execute(request: HttpRequest): HttpResponse
13 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/network/mapper/HttpRequestToOkHttpRequest.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.network.mapper
2 |
3 | import com.unity3d.services.core.network.model.BodyType
4 | import com.unity3d.services.core.network.model.HttpRequest
5 | import okhttp3.Headers
6 | import okhttp3.MediaType
7 | import okhttp3.Request
8 | import okhttp3.RequestBody
9 |
10 | private fun generateOkHttpBody(body: Any?): RequestBody = when(body) {
11 | is ByteArray -> RequestBody.create(MediaType.parse("text/plain;charset=utf-8"), body)
12 | is String -> RequestBody.create(MediaType.parse("text/plain;charset=utf-8"), body)
13 | else -> RequestBody.create(MediaType.parse("text/plain;charset=utf-8"), "")
14 | }
15 |
16 | private fun HttpRequest.generateOkHttpHeaders(): Headers = Headers.Builder()
17 | .also { headers.forEach { (key, value) -> it.add(key, value.joinToString(",")) } }
18 | .build()
19 |
20 | fun HttpRequest.toOkHttpRequest(): Request = Request.Builder()
21 | .url("${baseURL.trim('/')}/${path.trim('/')}".removeSuffix("/"))
22 | .method(method.toString(), body?.let(::generateOkHttpBody))
23 | .headers(generateOkHttpHeaders())
24 | .build()
25 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/network/mapper/HttpRequestToWebRequest.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.network.mapper
2 |
3 | import com.unity3d.services.core.network.model.HttpRequest
4 | import com.unity3d.services.core.request.WebRequest
5 |
6 | fun HttpRequest.toWebRequest(): WebRequest =
7 | WebRequest(
8 | baseURL,
9 | method.toString(),
10 | headers,
11 | connectTimeout,
12 | readTimeout,
13 | ).also {
14 | when (body) {
15 | is String -> it.setBody(body)
16 | is ByteArray -> it.body = body
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/network/mapper/WebRequestToHttpRequest.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.network.mapper
2 |
3 | import com.unity3d.services.core.network.model.HttpRequest
4 | import com.unity3d.services.core.network.model.RequestType
5 | import com.unity3d.services.core.request.WebRequest
6 |
7 | fun WebRequest.toHttpRequest(): HttpRequest =
8 | HttpRequest(
9 | baseURL = url.toString(),
10 | method = RequestType.valueOf(requestType),
11 | headers = headers,
12 | body = body,
13 | )
14 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/network/model/BodyType.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.network.model
2 |
3 | /**
4 | * Indicated the class type of a body in [HttpRequest]
5 | */
6 | enum class BodyType {
7 | UNKNOWN,
8 | STRING,
9 | }
10 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/network/model/HttpRequest.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.network.model
2 |
3 | /**
4 | * Data class representing a generic http request
5 | */
6 |
7 | data class HttpRequest @JvmOverloads constructor(
8 | val baseURL: String,
9 | val path: String = "",
10 | val method: RequestType = RequestType.GET,
11 | val body: Any? = null,
12 | val headers: Map> = emptyMap(),
13 | val parameters: Map = emptyMap(),
14 | val bodyType: BodyType = BodyType.UNKNOWN,
15 | val scheme: String = DEFAULT_SCHEME,
16 | val port: Int? = null,
17 | val connectTimeout: Int = DEFAULT_TIMEOUT,
18 | val readTimeout: Int = DEFAULT_TIMEOUT,
19 | val writeTimeout: Int = DEFAULT_TIMEOUT,
20 | val callTimeout: Int = DEFAULT_TIMEOUT,
21 | ) {
22 | companion object {
23 | private const val DEFAULT_TIMEOUT: Int = 30_000 // seconds
24 | private const val DEFAULT_SCHEME: String = "https"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/network/model/HttpResponse.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.network.model
2 |
3 | /**
4 | * Data class representing a generic http response
5 | */
6 | data class HttpResponse @JvmOverloads constructor(
7 | val body: Any,
8 | val statusCode: Int = 200,
9 | val headers: Map = emptyMap(),
10 | val urlString: String = "",
11 | )
12 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/network/model/RequestType.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.network.model
2 |
3 | /**
4 | * Defines the request type for an [HttpRequest]
5 | */
6 | enum class RequestType {
7 | POST,
8 | GET,
9 | HEAD
10 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/preferences/PreferencesError.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.preferences;
2 |
3 | public enum PreferencesError {
4 | COULDNT_GET_VALUE
5 | }
6 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/properties/InitializationStatusReader.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.properties;
2 |
3 | public class InitializationStatusReader {
4 |
5 | private static final String STATE_NOT_INITIALIZED = "not_initialized";
6 | private static final String STATE_INITIALIZING = "initializing";
7 | private static final String STATE_INITIALIZED_SUCCESSFULLY = "initialized_successfully";
8 | private static final String STATE_INITIALIZED_FAILED = "initialized_failed";
9 |
10 | public String getInitializationStateString(SdkProperties.InitializationState state) {
11 | switch (state) {
12 | case NOT_INITIALIZED:
13 | return STATE_NOT_INITIALIZED;
14 | case INITIALIZING:
15 | return STATE_INITIALIZING;
16 | case INITIALIZED_SUCCESSFULLY:
17 | return STATE_INITIALIZED_SUCCESSFULLY;
18 | case INITIALIZED_FAILED:
19 | return STATE_INITIALIZED_FAILED;
20 | default:
21 | return null;
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/properties/MadeWithUnityDetector.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.properties;
2 |
3 | import com.unity3d.services.core.log.DeviceLog;
4 |
5 | public class MadeWithUnityDetector {
6 |
7 | // This class should be present in an application made with Unity
8 | public static final String UNITY_PLAYER_CLASS_NAME = "com.unity3d.player.UnityPlayer";
9 |
10 | public MadeWithUnityDetector() {}
11 |
12 | public static boolean isMadeWithUnity() {
13 | try {
14 | Class.forName(UNITY_PLAYER_CLASS_NAME);
15 | return true;
16 | } catch(ClassNotFoundException e) {
17 | // Do nothing
18 | }
19 | return false;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/properties/Session.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.properties
2 |
3 | interface Session {
4 | val id: String
5 |
6 | companion object Default : Session {
7 | override val id: String = SessionIdReader.sessionId
8 | }
9 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/properties/SessionIdReader.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.properties
2 |
3 | import java.util.UUID
4 |
5 | object SessionIdReader {
6 | val sessionId = UUID.randomUUID().toString()
7 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/reflection/GenericListenerProxy.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.reflection;
2 |
3 | import java.lang.reflect.InvocationHandler;
4 | import java.lang.reflect.Method;
5 | import java.lang.reflect.Proxy;
6 |
7 | /**
8 | * Abstract class used to enable proxy invocation callbacks to any methods called reflectively.
9 | */
10 | public abstract class GenericListenerProxy implements InvocationHandler {
11 |
12 | public abstract Class> getProxyClass() throws ClassNotFoundException;
13 |
14 | public Object getProxyInstance() throws ClassNotFoundException {
15 | return Proxy.newProxyInstance(getProxyClass().getClassLoader(), new Class>[]{getProxyClass()}, this);
16 | }
17 |
18 | @Override
19 | public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {
20 | // Fallback to just calling method in case proxy method is from Object (for example equals, etc.)
21 | return m.invoke(this, args);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/request/CancelableThreadPoolExecutor.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.request;
2 |
3 | import java.util.LinkedList;
4 | import java.util.List;
5 | import java.util.concurrent.LinkedBlockingQueue;
6 | import java.util.concurrent.ThreadPoolExecutor;
7 | import java.util.concurrent.TimeUnit;
8 |
9 | public class CancelableThreadPoolExecutor extends ThreadPoolExecutor {
10 |
11 | private final List _activeRunnable;
12 |
13 | public CancelableThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, LinkedBlockingQueue queue) {
14 | super(corePoolSize, maximumPoolSize, keepAliveTime, unit,queue);
15 | _activeRunnable = new LinkedList<>();
16 | }
17 |
18 | @Override
19 | protected synchronized void beforeExecute(Thread t, Runnable r) {
20 | super.beforeExecute(t, r);
21 | _activeRunnable.add(r);
22 | }
23 |
24 | @Override
25 | protected synchronized void afterExecute(Runnable r, Throwable t) {
26 | super.afterExecute(r, t);
27 | _activeRunnable.remove(r);
28 | }
29 |
30 | public synchronized void cancel() {
31 | for(Runnable r : _activeRunnable) {
32 | if (r instanceof WebRequestRunnable) {
33 | ((WebRequestRunnable)r).setCancelStatus(true);
34 | }
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/request/IResolveHostListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.request;
2 |
3 | public interface IResolveHostListener {
4 | void onResolve(String host, String address);
5 | void onFailed(String host, ResolveHostError error, String errorMessage);
6 | }
7 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/request/IWebRequestListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.request;
2 |
3 | import java.util.List;
4 | import java.util.Map;
5 |
6 | public interface IWebRequestListener {
7 | void onComplete(String url, String response, int responseCode, Map> headers);
8 | void onFailed(String url, String error);
9 | }
10 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/request/IWebRequestProgressListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.request;
2 |
3 | import java.util.List;
4 | import java.util.Map;
5 |
6 | public interface IWebRequestProgressListener {
7 | void onRequestStart(String url, long total, int responseCode, Map> headers);
8 | void onRequestProgress(String url, long bytes, long total);
9 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/request/NetworkIOException.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.request;
2 |
3 | public class NetworkIOException extends Exception {
4 | public NetworkIOException (String message) {
5 | super(message);
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/request/ResolveHostError.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.request;
2 |
3 | public enum ResolveHostError {
4 | INVALID_HOST,
5 | UNKNOWN_HOST,
6 | UNEXPECTED_EXCEPTION,
7 | TIMEOUT
8 | }
9 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/request/ResolveHostEvent.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.request;
2 |
3 | public enum ResolveHostEvent {
4 | COMPLETE,
5 | FAILED
6 | }
7 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/request/WebRequestError.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.request;
2 |
3 | public enum WebRequestError {
4 | MAPPING_HEADERS_FAILED
5 | }
6 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/request/WebRequestEvent.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.request;
2 |
3 | public enum WebRequestEvent {
4 | COMPLETE,
5 | FAILED
6 | }
7 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/request/metrics/AdOperationError.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.request.metrics;
2 |
3 | public enum AdOperationError {
4 | init_failed,
5 | internal,
6 | invalid,
7 | no_fill,
8 | timeout,
9 | not_ready,
10 | player,
11 | no_connection,
12 | already_showing,
13 | callback_error,
14 | callback_timeout
15 | }
16 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/request/metrics/InitMetric.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.request.metrics;
2 |
3 | public class InitMetric {
4 |
5 | private static final String INIT_METRIC_DIFF_PARAMS = "native_init_diff_params";
6 |
7 | private static final String INIT_METRIC_SAME_PARAMS = "native_init_same_params";
8 |
9 | public static Metric newInitDiffParams() {
10 | return new Metric(
11 | INIT_METRIC_DIFF_PARAMS,
12 | null);
13 | }
14 |
15 | public static Metric newInitSameParams() {
16 | return new Metric(
17 | INIT_METRIC_SAME_PARAMS,
18 | null);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/request/metrics/Metric.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.request.metrics
2 |
3 | data class Metric @JvmOverloads constructor(val name: String?, val value: Any? = null, val tags: Map = emptyMap()) {
4 | fun toMap(): Map {
5 | return buildMap {
6 | if (name != null) {
7 | put(METRIC_NAME, name)
8 | }
9 | if (value != null) {
10 | put(METRIC_VALUE, value)
11 | }
12 | if (tags.isNotEmpty()) {
13 | put(METRIC_TAGS, tags)
14 | }
15 | }
16 | }
17 |
18 | companion object {
19 | private const val METRIC_NAME = "n"
20 | private const val METRIC_VALUE = "v"
21 | private const val METRIC_TAGS = "t"
22 | }
23 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/request/metrics/MetricSenderBase.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.request.metrics
2 |
3 | import com.unity3d.services.core.properties.InitializationStatusReader
4 | import com.unity3d.services.core.properties.SdkProperties
5 |
6 | abstract class MetricSenderBase(private val _initStatusReader: InitializationStatusReader) :
7 | SDKMetricsSender {
8 | override fun sendMetricWithInitState(metric: Metric) {
9 | val extraTags = mapOf(AdOperationMetric.INIT_STATE to
10 | _initStatusReader.getInitializationStateString(SdkProperties.getCurrentInitializationState()))
11 | val updatedMetric = metric.copy(tags = metric.tags + extraTags)
12 | sendMetric(updatedMetric)
13 | }
14 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/request/metrics/SDKMetricsSender.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.request.metrics
2 |
3 | interface SDKMetricsSender {
4 | fun sendEvent(event: String) = sendEvent(event, null)
5 | fun sendEvent(event: String, value: String? = null, tags: Map = emptyMap())
6 | fun sendMetric(metric: Metric)
7 | fun sendMetrics(metrics: List)
8 | fun sendMetricWithInitState(metric: Metric)
9 | val metricEndPoint: String?
10 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/sensorinfo/SensorInfoError.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.sensorinfo;
2 |
3 | public enum SensorInfoError {
4 | ACCELEROMETER_DATA_NOT_AVAILABLE
5 | }
6 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/timer/DefaultIntervalTimerFactory.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.timer;
2 |
3 | import com.unity3d.services.core.lifecycle.CachedLifecycle;
4 |
5 | public class DefaultIntervalTimerFactory implements IIntervalTimerFactory {
6 | @Override
7 | public IIntervalTimer createTimer(final Integer totalDurationMs, final Integer totalIntervals, final IIntervalTimerListener timerListener) {
8 | return new IntervalTimer(totalDurationMs, totalIntervals, timerListener, CachedLifecycle.getLifecycleListener());
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/timer/IBaseTimer.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.timer;
2 |
3 | import java.util.concurrent.ScheduledExecutorService;
4 |
5 | public interface IBaseTimer {
6 | void start(ScheduledExecutorService timerService);
7 | void stop();
8 | boolean pause();
9 | boolean resume();
10 | void kill();
11 | }
12 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/timer/IIntervalTimer.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.timer;
2 |
3 | public interface IIntervalTimer extends IBaseTimer{
4 | void onNextInterval();
5 | }
6 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/timer/IIntervalTimerFactory.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.timer;
2 |
3 | public interface IIntervalTimerFactory {
4 | IIntervalTimer createTimer(final Integer totalDurationMs, final Integer totalIntervals, final IIntervalTimerListener timerListener);
5 | }
6 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/timer/IIntervalTimerListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.timer;
2 |
3 | public interface IIntervalTimerListener {
4 | void onNextIntervalTriggered();
5 | }
6 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/timer/ITimerListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.timer;
2 |
3 | public interface ITimerListener {
4 | void onTimerFinished();
5 | }
6 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/webview/WebViewEventCategory.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.webview;
2 |
3 | public enum WebViewEventCategory {
4 | ADUNIT,
5 | BANNER,
6 | VIDEOPLAYER,
7 | REQUEST,
8 | RESOLVE,
9 | CACHE,
10 | CONNECTIVITY,
11 | STORAGE,
12 | BROADCAST,
13 | LIFECYCLE,
14 | DEVICEINFO,
15 | WEBPLAYER,
16 | PURCHASING,
17 | ANALYTICS,
18 | PERMISSIONS,
19 | STORE,
20 | LOAD_API,
21 | TOKEN,
22 | INIT_GMA,
23 | GMA,
24 | MEASUREMENTS,
25 | TOPICS
26 | }
27 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/webview/WebViewMetric.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.webview
2 |
3 | import com.unity3d.services.core.request.metrics.Metric
4 |
5 | fun webMessageListenerSupportedMetric() = Metric("web_message_listener_supported")
6 | fun webMessageListenerUnsupportedMetric() = Metric("web_message_listener_unsupported")
7 | fun webMessageListenerDisabledMetric() = Metric("web_message_listener_disabled")
8 | fun webMessageListenerEnabledMetric() = Metric("web_message_listener_enabled")
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/webview/bridge/CallbackStatus.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.webview.bridge;
2 |
3 | public enum CallbackStatus {
4 | OK,
5 | ERROR
6 | }
7 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/webview/bridge/IEventSender.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.webview.bridge
2 |
3 | interface IEventSender {
4 | fun sendEvent(eventCategory: Enum<*>, eventId: Enum<*>, vararg params: Any): Boolean
5 | fun canSend(): Boolean
6 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/webview/bridge/IInvocationCallbackInvoker.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.webview.bridge
2 |
3 | fun interface IInvocationCallbackInvoker {
4 | fun invokeCallback(invocation: Invocation)
5 | }
6 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/webview/bridge/INativeCallbackSubject.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.webview.bridge
2 |
3 | interface INativeCallbackSubject {
4 | fun remove(callback: NativeCallback)
5 | fun getCallback(callbackId: String): NativeCallback
6 | }
7 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/webview/bridge/IWebViewBridge.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.webview.bridge
2 |
3 | interface IWebViewBridge {
4 | @Throws(Exception::class)
5 | fun handleInvocation(
6 | className: String?,
7 | methodName: String?,
8 | parameters: Array?,
9 | callback: WebViewCallback?
10 | )
11 |
12 | @Throws(Exception::class)
13 | fun handleCallback(callbackId: String?, callbackStatus: String?, parameters: Array?)
14 | }
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/webview/bridge/IWebViewBridgeInvoker.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.webview.bridge;
2 |
3 | import java.lang.reflect.Method;
4 |
5 | public interface IWebViewBridgeInvoker {
6 | boolean invokeMethod(String className, String methodName, Method callbackMethod, Object...options);
7 | }
8 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/webview/bridge/IWebViewBridgeSharedObjectStore.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.webview.bridge;
2 |
3 | public interface IWebViewBridgeSharedObjectStore {
4 | T get(String id);
5 | void set(T sharedObject);
6 | void remove(String id);
7 | }
8 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/webview/bridge/IWebViewSharedObject.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.webview.bridge;
2 |
3 | public interface IWebViewSharedObject {
4 | String getId();
5 | }
6 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/webview/bridge/WebViewBridgeError.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.webview.bridge;
2 |
3 | public enum WebViewBridgeError {
4 | CLASS_NOT_FOUND,
5 | CLASS_NOT_EXPOSED,
6 | GETALLOWEDMETHODS_NOT_FOUND,
7 | GETALLOWEDMETHODS_INVOCATION_FAILED,
8 | METHOD_NOT_FOUND,
9 | METHOD_UNALLOWED,
10 | DATA_JSON_PARSE_FAILED,
11 | DATA_GET_PARAMETER_VALUE_FAILED,
12 | DATA_PARAMETER_NULL,
13 | INVOCATION_FAILED
14 | }
15 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/webview/bridge/WebViewBridgeInvoker.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.webview.bridge;
2 |
3 | import com.unity3d.services.core.webview.WebViewApp;
4 |
5 | import java.lang.reflect.Method;
6 |
7 | public class WebViewBridgeInvoker implements IWebViewBridgeInvoker {
8 | @Override
9 | public boolean invokeMethod(String className, String methodName, Method callbackMethod, Object... options) {
10 | return WebViewApp.getCurrentApp().invokeMethod(className, methodName, callbackMethod, options);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/webview/bridge/WebViewBridgeSharedObjectStore.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.webview.bridge;
2 |
3 | import java.util.concurrent.ConcurrentHashMap;
4 |
5 | public abstract class WebViewBridgeSharedObjectStore implements IWebViewBridgeSharedObjectStore {
6 | private ConcurrentHashMap _sharedObjects = new ConcurrentHashMap<>();
7 |
8 | public T get(String id) {
9 | if (id == null) return null;
10 | return _sharedObjects.get(id);
11 | }
12 |
13 | public void set(T sharedObject) {
14 | if (sharedObject == null) return;
15 | _sharedObjects.put(sharedObject.getId(), sharedObject);
16 | }
17 |
18 | public void remove(T sharedObject) {
19 | if (sharedObject == null) return;
20 | remove(sharedObject.getId());
21 | }
22 |
23 | public void remove(String id) {
24 | _sharedObjects.remove(id);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/webview/bridge/WebViewExposed.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.webview.bridge;
2 |
3 | import java.lang.annotation.Retention;
4 | import java.lang.annotation.RetentionPolicy;
5 | import java.lang.annotation.Target;
6 | import java.lang.annotation.ElementType;
7 |
8 | @Target(ElementType.METHOD)
9 | @Retention(RetentionPolicy.RUNTIME)
10 | public @interface WebViewExposed {}
11 |
12 |
13 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/webview/bridge/invocation/IWebViewBridgeInvocation.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.webview.bridge.invocation;
2 |
3 | public interface IWebViewBridgeInvocation {
4 | void invoke(String className, String methodName, int timeoutLengthInMilliSeconds, Object...invocationParameters);
5 | }
6 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/webview/bridge/invocation/IWebViewBridgeInvocationCallback.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.webview.bridge.invocation;
2 |
3 | import com.unity3d.services.core.webview.bridge.CallbackStatus;
4 |
5 | public interface IWebViewBridgeInvocationCallback {
6 | void onSuccess();
7 | void onFailure(String message, CallbackStatus callbackStatus);
8 | void onTimeout();
9 | }
10 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/core/webview/bridge/invocation/WebViewBridgeInvocationSingleThreadedExecutor.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.webview.bridge.invocation;
2 |
3 | import java.util.concurrent.ExecutorService;
4 | import java.util.concurrent.Executors;
5 |
6 | public class WebViewBridgeInvocationSingleThreadedExecutor {
7 | private static WebViewBridgeInvocationSingleThreadedExecutor instance;
8 | private ExecutorService _ExecutorService;
9 |
10 | public static WebViewBridgeInvocationSingleThreadedExecutor getInstance() {
11 | if (instance == null) {
12 | instance = new WebViewBridgeInvocationSingleThreadedExecutor();
13 | }
14 | return instance;
15 | }
16 |
17 | private WebViewBridgeInvocationSingleThreadedExecutor() {
18 | _ExecutorService = Executors.newSingleThreadExecutor();
19 | }
20 |
21 | public ExecutorService getExecutorService() {
22 | return _ExecutorService;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/store/StoreError.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.store;
2 |
3 | public enum StoreError {
4 | NOT_INITIALIZED,
5 | CLASS_NOT_FOUND,
6 | NO_SUCH_METHOD,
7 | INVOCATION_TARGET,
8 | ILLEGAL_ACCESS,
9 | JSON_ERROR,
10 | STORE_ERROR,
11 | UNKNOWN_ERROR
12 | }
13 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/store/StoreEvent.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.store;
2 |
3 | public enum StoreEvent {
4 | INITIALIZATION_REQUEST_RESULT,
5 | INITIALIZATION_REQUEST_FAILED,
6 | DISCONNECTED_RESULT,
7 | PURCHASES_ON_RESUME_RESULT,
8 | PURCHASES_ON_RESUME_ERROR,
9 | PURCHASES_UPDATED_RESULT,
10 | PURCHASES_UPDATED_ERROR,
11 | PURCHASES_REQUEST_RESULT,
12 | PURCHASES_REQUEST_ERROR,
13 | PURCHASE_HISTORY_LIST_REQUEST_RESULT,
14 | PURCHASE_HISTORY_LIST_REQUEST_ERROR,
15 | SKU_DETAILS_LIST_REQUEST_RESULT,
16 | SKU_DETAILS_LIST_REQUEST_ERROR,
17 | IS_FEATURE_SUPPORTED_REQUEST_RESULT,
18 | IS_FEATURE_SUPPORTED_REQUEST_ERROR
19 | }
20 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/store/core/StoreWebViewError.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.store.core;
2 |
3 | import com.unity3d.scar.adapter.common.WebViewAdsError;
4 | import com.unity3d.services.core.webview.WebViewEventCategory;
5 |
6 | public class StoreWebViewError extends WebViewAdsError {
7 | public StoreWebViewError(Enum> errorCategory, String description, Object... errorArguments) {
8 | super(errorCategory, description, errorArguments);
9 | }
10 |
11 | @Override
12 | public String getDomain() {
13 | return WebViewEventCategory.STORE.name();
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/store/core/configuration/StoreModuleConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.store.core.configuration;
2 |
3 | import com.unity3d.services.core.configuration.Configuration;
4 | import com.unity3d.services.core.configuration.ErrorState;
5 | import com.unity3d.services.core.configuration.IModuleConfiguration;
6 | import com.unity3d.services.store.core.api.Store;
7 |
8 | public class StoreModuleConfiguration implements IModuleConfiguration {
9 | private static final Class[] WEB_APP_API_CLASS_LIST = {
10 | Store.class,
11 | };
12 |
13 | @Override
14 | public Class[] getWebAppApiClassList() {
15 | return WEB_APP_API_CLASS_LIST;
16 | }
17 |
18 | @Override
19 | public boolean resetState(Configuration configuration) {
20 | return true;
21 | }
22 |
23 | @Override
24 | public boolean initErrorState(Configuration configuration, ErrorState state, String message) {
25 | return true;
26 | }
27 |
28 | @Override
29 | public boolean initCompleteState(Configuration configuration) {
30 | return true;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/store/gpbl/BillingResultResponseCode.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.store.gpbl;
2 |
3 | public enum BillingResultResponseCode {
4 | SERVICE_TIMEOUT(-3),
5 | FEATURE_NOT_SUPPORTED(-2),
6 | SERVICE_DISCONNECTED(-1),
7 | OK(0),
8 | USER_CANCELED(1),
9 | SERVICE_UNAVAILABLE(2),
10 | BILLING_UNAVAILABLE(3),
11 | ITEM_UNAVAILABLE(4),
12 | DEVELOPER_ERROR(5),
13 | ERROR(6),
14 | ITEM_ALREADY_OWNED(7),
15 | ITEM_NOT_OWNED(8);
16 |
17 | private final int _responseCode;
18 |
19 | BillingResultResponseCode(int responseCode) {
20 | _responseCode = responseCode;
21 | }
22 |
23 | public int getResponseCode() {
24 | return _responseCode;
25 | }
26 |
27 | public static BillingResultResponseCode fromResponseCode(int responseCode) {
28 | for (BillingResultResponseCode billingResultResponseCode : values()) {
29 | if (billingResultResponseCode.getResponseCode() == responseCode) {
30 | return billingResultResponseCode;
31 | }
32 | }
33 | return null;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/store/gpbl/IBillingClientStateListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.store.gpbl;
2 |
3 | import com.unity3d.services.store.gpbl.bridges.BillingResultBridge;
4 |
5 | public interface IBillingClientStateListener {
6 | void onBillingSetupFinished(BillingResultBridge billingResult);
7 | void onBillingServiceDisconnected();
8 | }
9 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/store/gpbl/IBillingResponse.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.store.gpbl;
2 |
3 | import org.json.JSONObject;
4 |
5 | public interface IBillingResponse {
6 | JSONObject getOriginalJson();
7 | }
8 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/store/gpbl/bridges/BillingResultBridge.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.store.gpbl.bridges;
2 |
3 | import com.unity3d.services.core.reflection.GenericBridge;
4 | import com.unity3d.services.store.gpbl.BillingResultResponseCode;
5 |
6 | import java.util.HashMap;
7 |
8 | public class BillingResultBridge extends GenericBridge {
9 | private static final String getResponseCodeMethodName = "getResponseCode";
10 | private final Object _billingResult;
11 |
12 | public BillingResultBridge(Object billingResult) {
13 | super(new HashMap[]>() {{
14 | put(getResponseCodeMethodName, new Class[]{});
15 | }});
16 | _billingResult = billingResult;
17 | }
18 |
19 | @Override
20 | protected String getClassName() {
21 | return "com.android.billingclient.api.BillingResult";
22 | }
23 |
24 | public BillingResultResponseCode getResponseCode() {
25 | int responseCode = callNonVoidMethod(getResponseCodeMethodName, _billingResult);
26 | return BillingResultResponseCode.fromResponseCode(responseCode);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/store/gpbl/bridges/PurchaseHistoryRecordBridge.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.store.gpbl.bridges;
2 |
3 | public class PurchaseHistoryRecordBridge extends CommonJsonResponseBridge {
4 |
5 | public PurchaseHistoryRecordBridge(Object purchaseHistoryRecord) {
6 | super(purchaseHistoryRecord);
7 | }
8 |
9 | @Override
10 | protected String getClassName() {
11 | return "com.android.billingclient.api.PurchaseHistoryRecord";
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/store/gpbl/bridges/SkuDetailsBridge.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.store.gpbl.bridges;
2 |
3 | public class SkuDetailsBridge extends CommonJsonResponseBridge {
4 |
5 | public SkuDetailsBridge(Object skuDetails) {
6 | super(skuDetails);
7 | }
8 |
9 | @Override
10 | protected String getClassName() {
11 | return "com.android.billingclient.api.SkuDetails";
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/store/gpbl/bridges/billingclient/BillingClientBuilderFactory.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.store.gpbl.bridges.billingclient;
2 |
3 | import android.content.Context;
4 |
5 | import java.lang.reflect.InvocationTargetException;
6 |
7 | public class BillingClientBuilderFactory {
8 | public static IBillingClientBuilderBridge getBillingClientBuilder(Context context) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
9 | if (com.unity3d.services.store.gpbl.bridges.billingclient.v4.BillingClientBridge.isAvailable()) {
10 | return com.unity3d.services.store.gpbl.bridges.billingclient.v4.BillingClientBridge.newBuilder(context);
11 | } else {
12 | // Fallback to V3 implementation
13 | return com.unity3d.services.store.gpbl.bridges.billingclient.v3.BillingClientBridge.newBuilder(context);
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/store/gpbl/bridges/billingclient/IBillingClientBuilderBridge.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.store.gpbl.bridges.billingclient;
2 |
3 | import com.unity3d.services.store.gpbl.proxies.PurchaseUpdatedListenerProxy;
4 |
5 | import java.lang.reflect.InvocationTargetException;
6 |
7 | public interface IBillingClientBuilderBridge {
8 | IBillingClientBuilderBridge setListener(PurchaseUpdatedListenerProxy purchaseUpdatedListenerProxy) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException;
9 | IBillingClientBuilderBridge enablePendingPurchases();
10 | IBillingClient build() throws ClassNotFoundException;
11 | }
12 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/store/listeners/IBillingDataResponseListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.store.listeners;
2 |
3 | import com.unity3d.services.store.gpbl.IBillingResponse;
4 | import com.unity3d.services.store.gpbl.bridges.BillingResultBridge;
5 |
6 | import java.util.List;
7 |
8 | public interface IBillingDataResponseListener {
9 | void onBillingResponse(BillingResultBridge billingResult, List billingDataList);
10 | }
11 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/store/listeners/IPurchaseHistoryResponseListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.store.listeners;
2 |
3 | import com.unity3d.services.store.gpbl.bridges.BillingResultBridge;
4 | import com.unity3d.services.store.gpbl.bridges.PurchaseHistoryRecordBridge;
5 |
6 | import java.util.List;
7 |
8 | public interface IPurchaseHistoryResponseListener extends IBillingDataResponseListener {
9 | void onBillingResponse(BillingResultBridge billingResult, List purchaseHistoryRecordList);
10 | }
11 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/store/listeners/IPurchaseUpdatedResponseListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.store.listeners;
2 |
3 | import com.unity3d.services.store.gpbl.bridges.BillingResultBridge;
4 | import com.unity3d.services.store.gpbl.bridges.PurchaseBridge;
5 |
6 | import java.util.List;
7 |
8 | public interface IPurchaseUpdatedResponseListener extends IBillingDataResponseListener {
9 | void onBillingResponse(BillingResultBridge billingResult, List purchases);
10 | }
11 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/store/listeners/IPurchasesResponseListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.store.listeners;
2 |
3 | import com.unity3d.services.store.gpbl.bridges.BillingResultBridge;
4 | import com.unity3d.services.store.gpbl.bridges.PurchaseBridge;
5 |
6 | import java.util.List;
7 |
8 | public interface IPurchasesResponseListener extends IBillingDataResponseListener {
9 | void onBillingResponse(BillingResultBridge billingResult, List purchases);
10 | }
11 |
--------------------------------------------------------------------------------
/unity-ads/src/main/java/com/unity3d/services/store/listeners/ISkuDetailsResponseListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.store.listeners;
2 |
3 | import com.unity3d.services.store.gpbl.bridges.BillingResultBridge;
4 | import com.unity3d.services.store.gpbl.bridges.SkuDetailsBridge;
5 |
6 | import java.util.List;
7 |
8 | public interface ISkuDetailsResponseListener extends IBillingDataResponseListener {
9 | void onBillingResponse(BillingResultBridge billingResult, List skuDetailsList);
10 | }
11 |
--------------------------------------------------------------------------------
/unity-ads/src/test/java/android/text/TextUtils.java:
--------------------------------------------------------------------------------
1 | package android.text;
2 |
3 |
4 | public class TextUtils {
5 | public static boolean isEmpty(CharSequence str) {
6 | return str == null || str.length() == 0;
7 | }
8 | }
--------------------------------------------------------------------------------
/unity-ads/src/test/java/android/util/Log.java:
--------------------------------------------------------------------------------
1 | package android.util;
2 |
3 | public class Log {
4 | public static int d(String tag, String msg) {
5 | System.out.println("DEBUG: " + tag + ": " + msg);
6 | return 0;
7 | }
8 |
9 | public static int i(String tag, String msg) {
10 | System.out.println("INFO: " + tag + ": " + msg);
11 | return 0;
12 | }
13 |
14 | public static int w(String tag, String msg) {
15 | System.out.println("WARN: " + tag + ": " + msg);
16 | return 0;
17 | }
18 |
19 | public static int e(String tag, String msg) {
20 | System.out.println("ERROR: " + tag + ": " + msg);
21 | return 0;
22 | }
23 |
24 | }
--------------------------------------------------------------------------------
/unity-ads/src/test/java/com/unity3d/services/core/cache/CacheDirectoryTest.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.cache
2 |
3 | import junit.framework.TestCase.assertNull
4 | import org.junit.Test
5 |
6 | class CacheDirectoryTest {
7 | @Test
8 | fun getCacheDirectory_nullContext_nullFile() {
9 | // given
10 | val testContext = null
11 |
12 | // when
13 | val cacheDirectory = CacheDirectory("")
14 | val cacheDirectoryFile = cacheDirectory.getCacheDirectory(testContext)
15 |
16 | // then
17 | assertNull(cacheDirectoryFile)
18 | }
19 | }
--------------------------------------------------------------------------------
/unity-ads/src/test/java/com/unity3d/services/core/configuration/PrivacyConfigStatusTest.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.configuration;
2 |
3 | import org.junit.Assert;
4 | import org.junit.Test;
5 |
6 | public class PrivacyConfigStatusTest {
7 |
8 | @Test
9 | public void testPrivacyConfigStatusToLower() {
10 | Assert.assertEquals("unknown", PrivacyConfigStatus.UNKNOWN.toLowerCase());
11 | Assert.assertEquals("allowed", PrivacyConfigStatus.ALLOWED.toLowerCase());
12 | Assert.assertEquals("denied", PrivacyConfigStatus.DENIED.toLowerCase());
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/unity-ads/src/test/java/com/unity3d/services/core/device/pii/NonBehavioralFlagTest.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.device.pii
2 |
3 | import com.unity3d.services.core.device.reader.pii.NonBehavioralFlag
4 | import org.junit.Assert
5 | import org.junit.Test
6 |
7 | class NonBehavioralFlagTest {
8 | @Test
9 | fun fromString_trueString_behavioralTrue() {
10 | // given
11 | // when
12 | val nonBehavioralFlag = NonBehavioralFlag.fromString("true")
13 | // then
14 | Assert.assertEquals(NonBehavioralFlag.TRUE, nonBehavioralFlag)
15 | }
16 |
17 | @Test
18 | fun fromString_falseString_behavioralFalse() {
19 | // given
20 | // when
21 | val nonBehavioralFlag = NonBehavioralFlag.fromString("false")
22 | // then
23 | Assert.assertEquals(NonBehavioralFlag.FALSE, nonBehavioralFlag)
24 | }
25 |
26 | @Test
27 | fun fromString_invalidString_behavioralUnknown() {
28 | // given
29 | // when
30 | val nonBehavioralFlag = NonBehavioralFlag.fromString("invalid")
31 | // then
32 | Assert.assertEquals(NonBehavioralFlag.UNKNOWN, nonBehavioralFlag)
33 | }
34 | }
--------------------------------------------------------------------------------
/unity-ads/src/test/java/com/unity3d/services/core/domain/task/TestSDKDispatchers.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.domain.task
2 |
3 | import com.unity3d.services.core.domain.ISDKDispatchers
4 | import kotlinx.coroutines.CoroutineDispatcher
5 | import kotlinx.coroutines.ExperimentalCoroutinesApi
6 | import kotlinx.coroutines.test.StandardTestDispatcher
7 | import kotlinx.coroutines.test.TestCoroutineScheduler
8 |
9 | @OptIn(ExperimentalCoroutinesApi::class)
10 | class TestSDKDispatchers(
11 | testCoroutineScheduler: TestCoroutineScheduler = TestCoroutineScheduler(),
12 | ioDispatcher: CoroutineDispatcher = StandardTestDispatcher(testCoroutineScheduler, "io"),
13 | defaultDispatcher: CoroutineDispatcher = StandardTestDispatcher(testCoroutineScheduler, "default"),
14 | mainDispatcher: CoroutineDispatcher = StandardTestDispatcher(testCoroutineScheduler, "main")
15 | ) : ISDKDispatchers {
16 | /**
17 | * Dispatcher for IO-bound work
18 | */
19 | override val io: CoroutineDispatcher = ioDispatcher
20 |
21 | /**
22 | * Dispatcher for standard work
23 | */
24 | override val default: CoroutineDispatcher = defaultDispatcher
25 |
26 | /**
27 | * Dispatcher for main thread
28 | */
29 | override val main: CoroutineDispatcher = mainDispatcher
30 | }
--------------------------------------------------------------------------------
/unity-ads/src/test/java/com/unity3d/services/core/properties/SessionIdReaderTest.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.properties
2 |
3 | import org.junit.Assert
4 | import org.junit.Test
5 |
6 | class SessionIdReaderTest {
7 |
8 | @Test
9 | fun getId_normalDefaultCall_receiveUuid() {
10 | // given
11 | // when
12 | val sessionId = SessionIdReader.sessionId
13 |
14 | // then
15 | Assert.assertEquals(36, sessionId.length)
16 | }
17 |
18 | @Test
19 | fun getId_normalCallMoreThanOnce_receiveUuidWithoutChanges() {
20 | // given
21 | // when
22 | val sessionIdFirstCall = SessionIdReader.sessionId
23 | val sessionIdSecondCall = SessionIdReader.sessionId
24 |
25 | // then
26 | Assert.assertEquals(36, sessionIdFirstCall.length)
27 | Assert.assertEquals(36, sessionIdSecondCall.length)
28 | Assert.assertEquals(sessionIdFirstCall, sessionIdSecondCall)
29 |
30 | }
31 | }
--------------------------------------------------------------------------------
/unity-ads/src/test/java/com/unity3d/services/core/properties/SessionTest.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.core.properties
2 |
3 | import org.junit.Assert
4 | import org.junit.Test
5 |
6 | class SessionTest {
7 |
8 | @Test
9 | fun getId_normalDefaultCall_receiveUuid() {
10 | // given
11 | // when
12 | val sessionId = Session.Default.id
13 |
14 | // then
15 | Assert.assertEquals(36, sessionId.length)
16 | }
17 | }
--------------------------------------------------------------------------------
/unity-ads/src/test/java/com/unity3d/services/store/core/StoreExceptionHandlerMatcher.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.services.store.core;
2 |
3 | import com.unity3d.scar.adapter.common.WebViewAdsError;
4 | import com.unity3d.services.store.StoreEvent;
5 |
6 | import org.mockito.ArgumentMatcher;
7 |
8 | public class StoreExceptionHandlerMatcher implements ArgumentMatcher {
9 | private final WebViewAdsError _webViewAdsError;
10 |
11 | public StoreExceptionHandlerMatcher(StoreEvent storeEvent, String description, Object... errorArguments) {
12 | _webViewAdsError = new StoreWebViewError(storeEvent, description, errorArguments);
13 | }
14 |
15 | @Override
16 | public boolean matches(WebViewAdsError argument) {
17 | int argIndex = 0;
18 | boolean argsEquals = true;
19 | for (Object errorArg : _webViewAdsError.getErrorArguments()) {
20 | if(!errorArg.equals(argument.getErrorArguments()[argIndex])){
21 | argsEquals = false;
22 | }
23 | argIndex++;
24 | }
25 | return _webViewAdsError.getDomain().equals(argument.getDomain()) &&
26 | _webViewAdsError.getDescription().equals(argument.getDescription()) &&
27 | argsEquals;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/unity-ads/src/test/java/com/unity3d/utils/corountine/CoroutineNameUsed.kt:
--------------------------------------------------------------------------------
1 | package com.unity3d.utils.corountine
2 |
3 | import kotlinx.coroutines.CoroutineName
4 | import kotlinx.coroutines.ThreadContextElement
5 | import kotlin.coroutines.AbstractCoroutineContextElement
6 | import kotlin.coroutines.CoroutineContext
7 | import kotlin.coroutines.coroutineContext
8 |
9 | class CoroutineNameUsed(
10 | val name: String
11 | ) : ThreadContextElement, AbstractCoroutineContextElement(Key) {
12 |
13 | companion object Key : CoroutineContext.Key
14 |
15 | override val key = Key
16 |
17 | var isUsed = false
18 |
19 | override fun updateThreadContext(context: CoroutineContext): Boolean {
20 | val contextName = context[CoroutineName.Key]
21 | if (contextName?.name.equals(name)) {
22 | isUsed = true
23 | }
24 | return isUsed
25 | }
26 |
27 | override fun restoreThreadContext(context: CoroutineContext, oldState: Boolean) {
28 | return
29 | }
30 | }
31 |
32 | suspend fun coroutineNameIsUsed(): Boolean {
33 | return coroutineContext[CoroutineNameUsed]?.isUsed ?: false
34 | }
--------------------------------------------------------------------------------
/unity-scaradapter-2000/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/unity-scaradapter-2000/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/unity-scaradapter-2000/src/androidTest/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 | >
3 |
4 |
5 |
8 |
9 |
--------------------------------------------------------------------------------
/unity-scaradapter-2000/src/androidTest/java/com/unity3d/ads/test/InstrumentationTestSuite.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads.test;
2 |
3 | import com.unity3d.scar.adapter.v2000.signals.SignalsCollectorTest;
4 |
5 | import org.junit.runner.RunWith;
6 | import org.junit.runners.Suite;
7 |
8 | @RunWith(Suite.class)
9 | @Suite.SuiteClasses({
10 | SignalsCollectorTest.class
11 | })
12 | public class InstrumentationTestSuite {
13 | }
14 |
--------------------------------------------------------------------------------
/unity-scaradapter-2000/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/unity-scaradapter-2000/src/main/java/com/unity3d/scar/adapter/v2000/scarads/ScarAdListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.v2000.scarads;
2 |
3 | import com.unity3d.scar.adapter.common.scarads.IScarLoadListener;
4 |
5 | public class ScarAdListener {
6 | protected IScarLoadListener _loadListener;
7 |
8 | public void setLoadListener(IScarLoadListener loadListener) {
9 | _loadListener = loadListener;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/unity-scaradapter-2000/src/main/java/com/unity3d/scar/adapter/v2000/signals/QueryInfoCallback.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.v2000.signals;
2 |
3 | import com.google.android.gms.ads.query.QueryInfo;
4 | import com.google.android.gms.ads.query.QueryInfoGenerationCallback;
5 | import com.unity3d.scar.adapter.common.signals.ISignalCallbackListener;
6 |
7 | public class QueryInfoCallback extends QueryInfoGenerationCallback {
8 |
9 | private String _placementId;
10 | private ISignalCallbackListener _signalCallbackListener;
11 |
12 | public QueryInfoCallback(final String placementId, final ISignalCallbackListener signalCallbackListener) {
13 | _placementId = placementId;
14 | _signalCallbackListener = signalCallbackListener;
15 | }
16 |
17 | @Override
18 | public void onSuccess(final QueryInfo queryInfo) {
19 | _signalCallbackListener.onSuccess(_placementId, queryInfo.getQuery(), queryInfo);
20 | }
21 |
22 | @Override
23 | public void onFailure(String errorMessage) {
24 | _signalCallbackListener.onFailure(errorMessage);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/unity-scaradapter-2100/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/unity-scaradapter-2100/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Unity-Technologies/unity-ads-android/6bdba8b1d4f510a0d5b047dce7049368c0d6f307/unity-scaradapter-2100/consumer-rules.pro
--------------------------------------------------------------------------------
/unity-scaradapter-2100/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/unity-scaradapter-2100/src/androidTest/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/unity-scaradapter-2100/src/androidTest/java/com/unity3d/ads/test/InstrumentationTestSuite.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.ads.test;
2 |
3 | import com.unity3d.scar.adapter.v2100.ScarAdapterTest;
4 | import com.unity3d.scar.adapter.v2100.signals.QueryInfoCallbackTest;
5 | import com.unity3d.scar.adapter.v2100.signals.SignalsCollectorTest;
6 |
7 | import org.junit.runner.RunWith;
8 | import org.junit.runners.Suite;
9 |
10 | @RunWith(Suite.class)
11 | @Suite.SuiteClasses({
12 | SignalsCollectorTest.class,
13 | QueryInfoCallbackTest.class,
14 | ScarAdapterTest.class
15 | })
16 | public class InstrumentationTestSuite {
17 | }
18 |
--------------------------------------------------------------------------------
/unity-scaradapter-2100/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/unity-scaradapter-2100/src/main/java/com/unity3d/scar/adapter/v2100/requests/AdRequestFactory.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.v2100.requests;
2 |
3 | import com.google.ads.mediation.admob.AdMobAdapter;
4 | import com.google.android.gms.ads.AdRequest;
5 | import com.unity3d.scar.adapter.common.requests.RequestExtras;
6 |
7 | public class AdRequestFactory {
8 |
9 | private RequestExtras _requestExtras;
10 |
11 | public AdRequestFactory(RequestExtras requestExtras) {
12 | _requestExtras = requestExtras;
13 | }
14 |
15 | public AdRequest.Builder getAdRequest() {
16 | return new AdRequest.Builder()
17 | .setRequestAgent(_requestExtras.getVersionName())
18 | .addNetworkExtrasBundle(AdMobAdapter.class, _requestExtras.getExtras());
19 | }
20 |
21 | public AdRequest buildAdRequest() {
22 | return getAdRequest().build();
23 | }
24 |
25 | public AdRequest buildAdRequestWithAdString(String adString) {
26 | return getAdRequest().setAdString(adString).build();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/unity-scaradapter-2100/src/main/java/com/unity3d/scar/adapter/v2100/scarads/ScarAdListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.v2100.scarads;
2 |
3 | import com.unity3d.scar.adapter.common.scarads.IScarLoadListener;
4 |
5 | public class ScarAdListener {
6 | protected IScarLoadListener _loadListener;
7 |
8 | public void setLoadListener(IScarLoadListener loadListener) {
9 | _loadListener = loadListener;
10 | }
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/unity-scaradapter-2100/src/main/java/com/unity3d/scar/adapter/v2100/signals/QueryInfoCallback.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.v2100.signals;
2 |
3 | import com.google.android.gms.ads.query.QueryInfo;
4 | import com.google.android.gms.ads.query.QueryInfoGenerationCallback;
5 | import com.unity3d.scar.adapter.common.signals.ISignalCallbackListener;
6 |
7 | public class QueryInfoCallback extends QueryInfoGenerationCallback {
8 |
9 | private String _placementId;
10 | private ISignalCallbackListener _signalCallbackListener;
11 |
12 | public QueryInfoCallback(final String placementId, final ISignalCallbackListener signalCallbackListener) {
13 | _placementId = placementId;
14 | _signalCallbackListener = signalCallbackListener;
15 | }
16 |
17 | @Override
18 | public void onSuccess(final QueryInfo queryInfo) {
19 | _signalCallbackListener.onSuccess(_placementId, queryInfo.getQuery(), queryInfo);
20 | }
21 |
22 | @Override
23 | public void onFailure(String errorMessage) {
24 | _signalCallbackListener.onFailure(errorMessage);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/unity-scaradapter-common/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/unity-scaradapter-common/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | }
4 |
5 | android {
6 | compileSdkVersion 30
7 |
8 | defaultConfig {
9 | minSdkVersion 16
10 | targetSdkVersion 30
11 |
12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
13 | consumerProguardFiles "consumer-rules.pro"
14 | multiDexEnabled true
15 | }
16 |
17 | compileOptions {
18 | sourceCompatibility JavaVersion.VERSION_1_7
19 | targetCompatibility JavaVersion.VERSION_1_7
20 | }
21 |
22 | buildTypes {
23 | release {
24 | minifyEnabled false
25 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
26 | }
27 | }
28 | }
29 |
30 | dependencies {
31 |
32 | testImplementation 'junit:junit:4.13.2'
33 | testImplementation 'org.mockito:mockito-core:2.28.2'
34 | androidTestImplementation 'androidx.test.ext:junit:1.1.2'
35 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
36 | }
37 |
38 | apply from: '../fatAar.gradle'
--------------------------------------------------------------------------------
/unity-scaradapter-common/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Unity-Technologies/unity-ads-android/6bdba8b1d4f510a0d5b047dce7049368c0d6f307/unity-scaradapter-common/consumer-rules.pro
--------------------------------------------------------------------------------
/unity-scaradapter-common/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/unity-scaradapter-common/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/unity-scaradapter-common/src/main/java/com/unity3d/scar/adapter/common/DispatchGroup.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.common;
2 |
3 | /**
4 | * Utility class to {@link #enter} multiple thread and await for all of them to {@link #leave} to run a specific task.
5 | */
6 | public class DispatchGroup {
7 |
8 | private int _threadCount = 0;
9 | private Runnable _runnable;
10 |
11 | public DispatchGroup() {
12 | _threadCount = 0;
13 | }
14 |
15 | public synchronized void enter() {
16 | _threadCount++;
17 | }
18 |
19 | public synchronized void leave() {
20 | _threadCount--;
21 | notifyGroup();
22 | }
23 |
24 | public void notify(Runnable r) {
25 | _runnable = r;
26 | notifyGroup();
27 | }
28 |
29 | private void notifyGroup() {
30 | if (_threadCount <=0 && _runnable !=null) {
31 | _runnable.run();
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/unity-scaradapter-common/src/main/java/com/unity3d/scar/adapter/common/GMAEvent.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.common;
2 |
3 | public enum GMAEvent {
4 | SCAR_PRESENT,
5 | SCAR_NOT_PRESENT,
6 | ALREADY_INITIALIZED,
7 | INIT_SUCCESS,
8 | INIT_ERROR,
9 | VERSION,
10 | SCAR_UNSUPPORTED,
11 | SIGNALS,
12 | SIGNALS_ERROR,
13 | INTERNAL_SIGNALS_ERROR,
14 | AD_LOADED,
15 | INTERSTITIAL_IMPRESSION_RECORDED,
16 | REWARDED_IMPRESSION_RECORDED,
17 | INTERNAL_LOAD_ERROR,
18 | QUERY_NOT_FOUND_ERROR,
19 | LOAD_ERROR,
20 | NO_AD_ERROR,
21 | AD_STARTED,
22 | INTERNAL_SHOW_ERROR,
23 | AD_NOT_LOADED_ERROR,
24 | REWARDED_SHOW_ERROR,
25 | INTERSTITIAL_SHOW_ERROR,
26 | FIRST_QUARTILE,
27 | MIDPOINT,
28 | THIRD_QUARTILE,
29 | LAST_QUARTILE,
30 | AD_EARNED_REWARD,
31 | AD_CLICKED,
32 | AD_SKIPPED,
33 | AD_LEFT_APPLICATION,
34 | AD_CLOSED,
35 | METHOD_ERROR
36 | }
37 |
--------------------------------------------------------------------------------
/unity-scaradapter-common/src/main/java/com/unity3d/scar/adapter/common/IAdsErrorHandler.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.common;
2 |
3 | public interface IAdsErrorHandler {
4 | void handleError(T unityError);
5 | }
6 |
--------------------------------------------------------------------------------
/unity-scaradapter-common/src/main/java/com/unity3d/scar/adapter/common/IScarAdListenerWrapper.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.common;
2 |
3 | public interface IScarAdListenerWrapper {
4 |
5 | /**
6 | * Called when an ad is loaded.
7 | */
8 | void onAdLoaded();
9 |
10 | /**
11 | * Called when an ad request failed to load.
12 | */
13 | void onAdFailedToLoad(int errorCode, String errorString);
14 |
15 | /**
16 | * Called when an ad opens.
17 | */
18 | void onAdOpened();
19 |
20 | /**
21 | * Called when a click is recorded for an ad.
22 | */
23 | void onAdClicked();
24 |
25 | /**
26 | * Called when an ad is closed.
27 | */
28 | void onAdClosed();
29 | }
30 |
--------------------------------------------------------------------------------
/unity-scaradapter-common/src/main/java/com/unity3d/scar/adapter/common/IScarAdapter.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.common;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 |
6 | import android.widget.RelativeLayout;
7 | import com.unity3d.scar.adapter.common.scarads.ScarAdMetadata;
8 | import com.unity3d.scar.adapter.common.scarads.UnityAdFormat;
9 | import com.unity3d.scar.adapter.common.signals.ISignalCollectionListener;
10 |
11 | public interface IScarAdapter {
12 | void getSCARSignal(Context context, String placementId, UnityAdFormat adFormat, ISignalCollectionListener signalCompletionListener);
13 | void getSCARBiddingSignals(Context context, boolean isBannerEnabled, ISignalCollectionListener signalCompletionListener);
14 | void loadInterstitialAd(Context context, ScarAdMetadata scarAdMetadata, IScarInterstitialAdListenerWrapper adListener);
15 | void loadRewardedAd(Context context, ScarAdMetadata scarAdMetadata, IScarRewardedAdListenerWrapper adListener);
16 | void loadBannerAd(Context context, RelativeLayout bannerView, ScarAdMetadata scarAdMetadata, int width, int height, IScarBannerAdListenerWrapper adListener);
17 | void show(Activity activity, String queryId, String placementId);
18 | }
19 |
--------------------------------------------------------------------------------
/unity-scaradapter-common/src/main/java/com/unity3d/scar/adapter/common/IScarBannerAdListenerWrapper.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.common;
2 |
3 | public interface IScarBannerAdListenerWrapper extends IScarAdListenerWrapper {
4 |
5 | /**
6 | * Called when an impression is recorded for an ad.
7 | */
8 | void onAdImpression();
9 | }
10 |
--------------------------------------------------------------------------------
/unity-scaradapter-common/src/main/java/com/unity3d/scar/adapter/common/IScarInterstitialAdListenerWrapper.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.common;
2 |
3 | /**
4 | * A listener for receiving notifications during the lifecycle of an ad.
5 | */
6 | public interface IScarInterstitialAdListenerWrapper extends IScarAdListenerWrapper {
7 |
8 | /**
9 | * Called when an ad failed to show on screen.
10 | */
11 | void onAdFailedToShow(int errorCode, String errorString);
12 |
13 | /**
14 | * Called when the user has left the app.
15 | */
16 | void onAdLeftApplication();
17 |
18 | /**
19 | * Called when an impression is recorded for an ad.
20 | */
21 | void onAdImpression();
22 |
23 | /**
24 | * Called when the user does not watch the ad to completion.
25 | */
26 | void onAdSkipped();
27 | }
28 |
--------------------------------------------------------------------------------
/unity-scaradapter-common/src/main/java/com/unity3d/scar/adapter/common/IScarRewardedAdListenerWrapper.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.common;
2 |
3 | /**
4 | * A listener for receiving notifications during the lifecycle of an ad.
5 | */
6 | public interface IScarRewardedAdListenerWrapper extends IScarAdListenerWrapper {
7 |
8 | /**
9 | * Called when an ad failed to show on screen.
10 | */
11 | void onAdFailedToShow(int errorCode, String errorString);
12 |
13 | /**
14 | * Called when a user earned a reward for watching the ad.
15 | */
16 | void onUserEarnedReward();
17 |
18 | /**
19 | * Called when an impression is recorded for an ad.
20 | */
21 | void onAdImpression();
22 |
23 | /**
24 | * Called when the user does not watch the ad to completion.
25 | */
26 | void onAdSkipped();
27 | }
28 |
--------------------------------------------------------------------------------
/unity-scaradapter-common/src/main/java/com/unity3d/scar/adapter/common/IUnityAdsError.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.common;
2 |
3 | public interface IUnityAdsError {
4 | String getDomain();//domain to represent a custom error or a class
5 | String getDescription(); // description of the error, localized message
6 | int getCode();// unique code per domain
7 | }
8 |
--------------------------------------------------------------------------------
/unity-scaradapter-common/src/main/java/com/unity3d/scar/adapter/common/Utils.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.common;
2 |
3 | import android.os.Handler;
4 | import android.os.Looper;
5 |
6 | public class Utils {
7 |
8 | public static void runOnUiThread(Runnable runnable) {
9 | runOnUiThread(runnable, 0);
10 | }
11 |
12 | public static void runOnUiThread(Runnable runnable, long delay) {
13 | Handler handler = new Handler(Looper.getMainLooper());
14 | handler.postDelayed(runnable, delay);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/unity-scaradapter-common/src/main/java/com/unity3d/scar/adapter/common/WebViewAdsError.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.common;
2 |
3 | public class WebViewAdsError implements IUnityAdsError {
4 | protected String _description;
5 | private Enum _errorCategory;
6 | protected Object[] _errorArguments;
7 |
8 | public WebViewAdsError(Enum> errorCategory, String description, Object... errorArguments) {
9 | _errorCategory = errorCategory;
10 | _description = description;
11 | _errorArguments = errorArguments;
12 | }
13 |
14 | @Override
15 | public String getDomain() {
16 | return null;
17 | }
18 |
19 | @Override
20 | public String getDescription() {
21 | return _description;
22 | }
23 |
24 | @Override
25 | public int getCode() {
26 | return -1;
27 | }
28 |
29 | public Enum> getErrorCategory() {
30 | return _errorCategory;
31 | }
32 |
33 | public Object[] getErrorArguments() { return _errorArguments; }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/unity-scaradapter-common/src/main/java/com/unity3d/scar/adapter/common/requests/RequestExtras.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.common.requests;
2 |
3 | import android.os.Bundle;
4 |
5 | public class RequestExtras {
6 |
7 | public static String QUERY_INFO_TYPE = "query_info_type";
8 | public static String REQUESTER_TYPE = "requester_type_5";
9 | public static String VERSION_PREFIX = "UnityScar";
10 |
11 | private String _versionName;
12 |
13 | public RequestExtras(String unityVersion) {
14 | _versionName = new StringBuilder(VERSION_PREFIX).append(unityVersion).toString();
15 | }
16 |
17 | public Bundle getExtras() {
18 | Bundle extras = new Bundle();
19 | extras.putString(QUERY_INFO_TYPE, REQUESTER_TYPE);
20 | return extras;
21 | }
22 |
23 | public String getVersionName() {
24 | return _versionName;
25 | }
26 | }
--------------------------------------------------------------------------------
/unity-scaradapter-common/src/main/java/com/unity3d/scar/adapter/common/scarads/IScarAd.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.common.scarads;
2 |
3 | import android.app.Activity;
4 |
5 | public interface IScarAd {
6 | void loadAd(IScarLoadListener loadListener);
7 | }
8 |
--------------------------------------------------------------------------------
/unity-scaradapter-common/src/main/java/com/unity3d/scar/adapter/common/scarads/IScarFullScreenAd.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.common.scarads;
2 |
3 | import android.app.Activity;
4 |
5 | public interface IScarFullScreenAd extends IScarAd {
6 | void show(Activity activity);
7 | }
8 |
--------------------------------------------------------------------------------
/unity-scaradapter-common/src/main/java/com/unity3d/scar/adapter/common/scarads/IScarLoadListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.common.scarads;
2 |
3 | public interface IScarLoadListener {
4 | void onAdLoaded();
5 | }
6 |
--------------------------------------------------------------------------------
/unity-scaradapter-common/src/main/java/com/unity3d/scar/adapter/common/scarads/ScarAdMetadata.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.common.scarads;
2 |
3 | public class ScarAdMetadata {
4 |
5 | private String _placementId;
6 | private String _queryId;
7 | private String _adUnitId;
8 | private String _adString;
9 | private Integer _videoLengthMs;
10 |
11 | public ScarAdMetadata(String placementId, String queryId) {
12 | this(placementId, queryId, null, null, null);
13 | }
14 |
15 | public ScarAdMetadata(String placementId, String queryId, String adUnitId, String adString, Integer videoLengthMs) {
16 | _placementId = placementId;
17 | _queryId = queryId;
18 | _adUnitId = adUnitId;
19 | _adString = adString;
20 | _videoLengthMs = videoLengthMs;
21 | }
22 |
23 | public String getPlacementId() {
24 | return _placementId;
25 | }
26 |
27 | public String getQueryId() {
28 | return _queryId;
29 | }
30 |
31 | public String getAdUnitId() {
32 | return _adUnitId;
33 | }
34 |
35 | public String getAdString() {
36 | return _adString;
37 | }
38 |
39 | public Integer getVideoLengthMs() {
40 | return _videoLengthMs;
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/unity-scaradapter-common/src/main/java/com/unity3d/scar/adapter/common/scarads/UnityAdFormat.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.common.scarads;
2 |
3 | public enum UnityAdFormat {
4 | INTERSTITIAL,
5 | REWARDED,
6 | BANNER
7 | }
8 |
--------------------------------------------------------------------------------
/unity-scaradapter-common/src/main/java/com/unity3d/scar/adapter/common/signals/ISignalCallbackListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.common.signals;
2 |
3 | public interface ISignalCallbackListener {
4 | void onSuccess(String placementId, String signal, T queryInfo);
5 | void onFailure(String errorMessage);
6 | }
7 |
--------------------------------------------------------------------------------
/unity-scaradapter-common/src/main/java/com/unity3d/scar/adapter/common/signals/ISignalCollectionListener.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.common.signals;
2 |
3 | public interface ISignalCollectionListener {
4 | void onSignalsCollected(String signalsMap);
5 | void onSignalsCollectionFailed(String errorMsg);
6 | }
7 |
--------------------------------------------------------------------------------
/unity-scaradapter-common/src/main/java/com/unity3d/scar/adapter/common/signals/ISignalsCollector.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.common.signals;
2 |
3 | import android.content.Context;
4 |
5 | import com.unity3d.scar.adapter.common.DispatchGroup;
6 | import com.unity3d.scar.adapter.common.scarads.UnityAdFormat;
7 |
8 | public interface ISignalsCollector {
9 | void getSCARSignal(Context context, String placementId, UnityAdFormat adFormat,
10 | ISignalCollectionListener signalCompletionListener);
11 | void getSCARSignal(Context context, String placementId, UnityAdFormat adFormat, final DispatchGroup dispatchGroup,
12 | final SignalsResult signalsResult);
13 | void getSCARSignalForHB(Context context, UnityAdFormat adFormat, final DispatchGroup dispatchGroup,
14 | final SignalsResult signalsResult);
15 | void getSCARBiddingSignals(Context context, boolean isBannerEnabled, ISignalCollectionListener signalCompletionListener);
16 | }
17 |
--------------------------------------------------------------------------------
/unity-scaradapter-common/src/main/java/com/unity3d/scar/adapter/common/signals/SignalsResult.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.common.signals;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 |
6 | public class SignalsResult {
7 |
8 | private Map _signalsMap;
9 | private String _errorMessage;
10 |
11 | public SignalsResult() {
12 | _signalsMap = new HashMap<>();
13 | _errorMessage = null;
14 | }
15 |
16 | public void addToSignalsMap(String placementId, String signal) {
17 | _signalsMap.put(placementId, signal);
18 | }
19 |
20 | public Map getSignalsMap() {
21 | return _signalsMap;
22 | }
23 |
24 | public void setErrorMessage(String errorMessage) {
25 | _errorMessage = errorMessage;
26 | }
27 |
28 | public String getErrorMessage() {
29 | return _errorMessage;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/unity-scaradapter-common/src/main/java/com/unity3d/scar/adapter/common/signals/SignalsStorage.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.common.signals;
2 |
3 | import java.util.Map;
4 | import java.util.concurrent.ConcurrentHashMap;
5 |
6 | public class SignalsStorage {
7 |
8 | private final Map _queryInfoMap = new ConcurrentHashMap<>();
9 |
10 | public T getQueryInfo(String placementId) {
11 | return _queryInfoMap.get(placementId);
12 | }
13 |
14 | public void put(String key, T value) {
15 | _queryInfoMap.put(key, value);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/unity-scaradapter-common/src/test/java/com/unity3d/scar/adapter/common/SignalsStorageTest.java:
--------------------------------------------------------------------------------
1 | package com.unity3d.scar.adapter.common;
2 |
3 | import com.unity3d.scar.adapter.common.signals.SignalsStorage;
4 |
5 | import org.junit.Assert;
6 | import org.junit.Test;
7 | import org.mockito.Mockito;
8 |
9 | public class SignalsStorageTest {
10 | private static final String TEST_PLACEMENTID = "placementId";
11 |
12 | // We cannot access QueryInfo from the common module
13 | private Object objectMock = Mockito.mock(Object.class);
14 |
15 | @Test
16 | public void testSignalStorage() {
17 | SignalsStorage signalsStorage = new SignalsStorage();
18 | signalsStorage.put(TEST_PLACEMENTID, objectMock);
19 | Object storedInfo = signalsStorage.getQueryInfo(TEST_PLACEMENTID);
20 | Assert.assertEquals(storedInfo, objectMock);
21 | }
22 |
23 | @Test
24 | public void testSignalStorageDuplicatePlacements() {
25 | SignalsStorage signalsStorage = new SignalsStorage();
26 | signalsStorage.put(TEST_PLACEMENTID, objectMock);
27 | signalsStorage.put(TEST_PLACEMENTID, objectMock);
28 | Object queryInfo = signalsStorage.getQueryInfo(TEST_PLACEMENTID);
29 | Assert.assertEquals(queryInfo, objectMock);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------