#if UNITY_ANDROID /* * PubMatic Inc. ("PubMatic") CONFIDENTIAL * Unpublished Copyright (c) 2006-2022 PubMatic, All Rights Reserved. * * NOTICE: All information contained herein is, and remains the property of PubMatic. The intellectual and technical concepts contained * herein are proprietary to PubMatic and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or copyright law. * Dissemination of this information or reproduction of this material is strictly forbidden unless prior written permission is obtained * from PubMatic. Access to the source code contained herein is hereby forbidden to anyone except current PubMatic employees, managers or contractors who have executed * Confidentiality and Non-disclosure agreements explicitly covering such access or to such other persons whom are directly authorized by PubMatic to access the source code and are subject to confidentiality and nondisclosure obligations with respect to the source code. * * The copyright notice above does not evidence any actual or intended publication or disclosure of this source code, which includes * information that is confidential and/or proprietary, and is a trade secret, of PubMatic. ANY REPRODUCTION, MODIFICATION, DISTRIBUTION, PUBLIC PERFORMANCE, * OR PUBLIC DISPLAY OF OR THROUGH USE OF THIS SOURCE CODE WITHOUT THE EXPRESS WRITTEN CONSENT OF PUBMATIC IS STRICTLY PROHIBITED, AND IN VIOLATION OF APPLICABLE * LAWS AND INTERNATIONAL TREATIES. THE RECEIPT OR POSSESSION OF THIS SOURCE CODE AND/OR RELATED INFORMATION DOES NOT CONVEY OR IMPLY ANY RIGHTS * TO REPRODUCE, DISCLOSE OR DISTRIBUTE ITS CONTENTS, OR TO MANUFACTURE, USE, OR SELL ANYTHING THAT IT MAY DESCRIBE, IN WHOLE OR IN PART. */ using System.Collections.Generic; using OpenWrapSDK.Common; using UnityEngine; namespace OpenWrapSDK.Android { /// /// Android data provider client to set or get parameters on data provider object. /// internal class POBDataProviderClient : IPOBDataProviderClient { #region Private variables private readonly string Tag = "POBDataProviderClient"; private AndroidJavaObject dataProvider; #endregion #region Constructor/Destructor /// /// Constructor with data provider name /// /// Data provider's name internal POBDataProviderClient(string name) { dataProvider = new AndroidJavaObject(POBConstants.POBDataProviderClassName, name); } /// /// Constructor with data provider identifier & name /// /// Data provider's name /// Data provider's id internal POBDataProviderClient(string name, string identifier) { dataProvider = new AndroidJavaObject(POBConstants.POBDataProviderClassName, name, identifier); } ~POBDataProviderClient() { Destroy(); } #endregion #region IPOBDataProviderClient /// /// segment taxonomy id. Reference: https://github.com/InteractiveAdvertisingBureau/AdCOM/blob/master/AdCOM%20v1.0%20FINAL.md#list--category-taxonomies /// public int SegTax { set { if (dataProvider != null) { dataProvider.Call("setSegTax",value); } } } /// /// RTB extension object for this data /// public Dictionary Extension { set { SetExtensionInNative(value); } } /// /// Adds a segment details to data object /// /// Segment details to be added to data object public void AddSegment(POBSegment segment) { if(dataProvider != null && segment != null && segment.segmentClient != null) { AndroidJavaObject segmentObject = segment.segmentClient.GetNativeObject(); if(segmentObject != null) { POBLog.Info(Tag, POBLogStrings.ClientAddSegmentLog); dataProvider.Call("addSegment", segmentObject); } } else { POBLog.Warning(Tag, POBLogStrings.AddSegmentFailedLog); } } /// /// Removes a segment details from data object /// /// Identifier for which a segment is to be removed public void RemoveSegment(POBSegment segment) { if (dataProvider != null && segment != null) { POBLog.Info(Tag, POBLogStrings.ClientRemoveSegmentLog); dataProvider.Call("removeSegment", segment.Identifier); } else { POBLog.Warning(Tag, POBLogStrings.RemoveSegmentFailedLog); } } /// /// Removes all segments from the data object /// public void RemoveAllSegments() { if(dataProvider != null) { POBLog.Info(Tag, POBLogStrings.ClientRemoveAllSegmentsLog); dataProvider.Call("removeAllSegments"); } } /// /// Cleanup API /// public void Destroy() { POBLog.Info(Tag, POBLogStrings.DestroyMethodLog); dataProvider = null; } /// /// Get reference of Java POBDataProvider instance /// /// AndroidJavaObject of native POBDataProvider Class public AndroidJavaObject GetNativeObject() { return dataProvider; } #endregion #region Private methods /// /// Converting Dictionary to array of values and keys and pass to native /// /// Dictionary of string keys and string values private void SetExtensionInNative(Dictionary extension) { AndroidJavaObject JSONObject = POBAndroidUtils.ConvertDictionaryToJavaJSONObject(extension); if(dataProvider != null) { dataProvider.Call("setExt", JSONObject); } } #endregion } } #endif