Class POBCacheManager
-
- All Implemented Interfaces:
public class POBCacheManagerImplementation of the cache manager class, responsible for caching Profile Config, requesting service script for OM SDK, etc.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfacePOBCacheManager.UserAgentListenerInterface definition to notify about the result of user agent fetch.
public interfacePOBCacheManager.ProfileResultListenerInterface definition to notify about the result of profile fetch.
-
Field Summary
Fields Modifier and Type Field Description public StringpublisherId
-
Constructor Summary
Constructors Constructor Description POBCacheManager(Context context, POBNetworkHandler networkHandler)Constructor
-
Method Summary
Modifier and Type Method Description StringgetPublisherId()Return the cached publisher id. voidloadAssets()Loads assets required by OW SDK voidloadInternalServiceJS(@NonNull() POBMeasurementProvider.POBScriptListener listener)Loads the local omid.js from the assets and stores it inside OMID_JS_CONTENT, function uses loadLocalOmidScript internally to load the omid. booleanverifyCrashAnalyticsStatus()Check CrashAnalytics status for all the profiles. booleangetAppInstallStatus()Check app install status for all the profiles. voidloadMraidJs()To read mraid. voidloadOpenWrapJs()To read openwrap. JSONObjectgetAppStatusSchemes()Returns the last successfully loaded appInstallStatus.androidfor MRAID app status usage (e.g.StringgetMraidJs()To read mraid. StringgetOpenWrapJs()To read openwrap. voidgenerateUserAgent(@NonNull() POBCacheManager.UserAgentListener listener)This method fetch the user agent from WebSettings and save it for future reference. StringfetchUserAgent()voidfetchSdkConfigs(@NonNull() Context context, @NonNull() OpenWrapSDKConfig sdkConfig)Loads Publisher and Profile configuration for given OpenWrapSDKConfig. voidfetchSdkConfigs(@NonNull() Context context, @NonNull() String publisherId, int profileId)Fetches profile, publisher, and remote SDK ( sdkconfig.json) configurations.voidfetchSdkConfigsUsingCache(@NonNull() Context context)Fetches profile, publisher, and remote SDK configurations using ids cached during SDK initialization. POBPublisherConfiggetPublisherConfig()Returns the cached publisher-level config if it exists. POBProfileConfiggetProfileConfig(@NonNull() String profileConfigKey)Function is used to return the cached profileConfig associated with the profileConfigKey voidsaveReceivedBid(@NonNull() JSONObject rawBidJson)Save the raw bid json in received bids queue. voidsaveRenderedBid(@NonNull() JSONObject rawBidJson)Save the raw bid json in rendered bids queue. JSONArraygetCachedBidResponses()static longgetSDKFirstLaunchTimeMillis(@NonNull() Context context)Returns the persisted OpenWrap SDK first-initialization timestamp for this install (ms since Unix epoch), or records currentTimeMillis once if missing. -
-
Constructor Detail
-
POBCacheManager
POBCacheManager(Context context, POBNetworkHandler networkHandler)
Constructor- Parameters:
context- Context
-
-
Method Detail
-
getPublisherId
@Nullable() String getPublisherId()
Return the cached publisher id.
- Returns:
Publisher Id.
-
loadAssets
void loadAssets()
Loads assets required by OW SDK
-
loadInternalServiceJS
void loadInternalServiceJS(@NonNull() POBMeasurementProvider.POBScriptListener listener)
Loads the local omid.js from the assets and stores it inside OMID_JS_CONTENT, function uses loadLocalOmidScript internally to load the omid.js script
- Parameters:
listener- Instance of POBMeasurementProvider.POBScriptListener which is used to give scriptReceived callback
-
verifyCrashAnalyticsStatus
boolean verifyCrashAnalyticsStatus()
Check CrashAnalytics status for all the profiles.
- Returns:
true if CrashAnalytics is enabled for all the profiles, false otherwise.
-
getAppInstallStatus
boolean getAppInstallStatus()
Check app install status for all the profiles. If any profile disables the feature, we disable it for all the profiles. Uses cached value when profiles have been fetched/updated; otherwise computes from current profile map (e.g. before first profile fetch, or in tests).
- Returns:
true if app install status is enabled for all profiles, false otherwise.
-
loadMraidJs
void loadMraidJs()
To read mraid.js content from the assets folder and store it into mraidJsContent
-
loadOpenWrapJs
void loadOpenWrapJs()
To read openwrap.js content from the assets folder and store it into openWrapJsContent
-
getAppStatusSchemes
@Nullable() JSONObject getAppStatusSchemes()
Returns the last successfully loaded
appInstallStatus.androidfor MRAID app status usage (e.g. bidimp.ext.owsdkand app-install status checks in the web rendering module). Does not trigger a network request; refreshes are driven by loadSDKConfig from fetchSdkConfigs entry points on SDK init or ad load.
-
getMraidJs
@Nullable() String getMraidJs()
To read mraid.js content from the assets folder and store it into mraidJsContent
- Returns:
POB_MRAID_JS content.
-
getOpenWrapJs
@Nullable() String getOpenWrapJs()
To read openwrap.js content from the assets folder and store it into openWrapJsContent
- Returns:
OPENWRAP_JS content.
-
generateUserAgent
void generateUserAgent(@NonNull() POBCacheManager.UserAgentListener listener)
This method fetch the user agent from WebSettings and save it for future reference. And return the callback. If not found then just return user-agent using System.getProperty("http.agent"). It will return empty string in case unable to fetch the user-agent at all.
-
fetchUserAgent
@NonNull()@WorkerThread() String fetchUserAgent()
-
fetchSdkConfigs
void fetchSdkConfigs(@NonNull() Context context, @NonNull() OpenWrapSDKConfig sdkConfig)
Loads Publisher and Profile configuration for given OpenWrapSDKConfig.
- Parameters:
context- Application context.sdkConfig- Publisher and profile ids from the SDK configuration.
-
fetchSdkConfigs
void fetchSdkConfigs(@NonNull() Context context, @NonNull() String publisherId, int profileId)
Fetches profile, publisher, and remote SDK (
sdkconfig.json) configurations.This method is intended to use from no ad server flow when publisherId and profileId is available in the POBRequest.
- Parameters:
context- ContextpublisherId- Publisher IdprofileId- Profile Id
-
fetchSdkConfigsUsingCache
void fetchSdkConfigsUsingCache(@NonNull() Context context)
Fetches profile, publisher, and remote SDK configurations using ids cached during SDK initialization. Used by external bidding
loadAd(bidResponse, …)flows.Profile and publisher refreshes require cached init ids;
sdkconfig.jsonis refreshed whenever this method runs (it does not depend on publisher/profile ids).
-
getPublisherConfig
@Nullable() POBPublisherConfig getPublisherConfig()
Returns the cached publisher-level config if it exists.
- Returns:
the cached POBPublisherConfig
-
getProfileConfig
@Nullable() POBProfileConfig getProfileConfig(@NonNull() String profileConfigKey)
Function is used to return the cached profileConfig associated with the profileConfigKey
- Parameters:
profileConfigKey- The profileConfig key associated with the profile and the version- Returns:
The POBProfileConfig associated with the profileConfigKey
-
saveReceivedBid
void saveReceivedBid(@NonNull() JSONObject rawBidJson)
Save the raw bid json in received bids queue. Remove the oldest one if size of queue is 3.
- Parameters:
rawBidJson- of ad response.
-
saveRenderedBid
void saveRenderedBid(@NonNull() JSONObject rawBidJson)
Save the raw bid json in rendered bids queue. Remove the oldest one if size of queue is 3.
- Parameters:
rawBidJson- of ad response.
-
getCachedBidResponses
@NonNull() JSONArray getCachedBidResponses()
- Returns:
the JSONArray consisting of receivedBids and renderedBids.
-
getSDKFirstLaunchTimeMillis
static long getSDKFirstLaunchTimeMillis(@NonNull() Context context)
Returns the persisted OpenWrap SDK first-initialization timestamp for this install (ms since Unix epoch), or records currentTimeMillis once if missing. Values are stored in app-private SharedPreferences keyed by POB_FIRST_LAUNCH_STORAGE. Used for OpenRTB
app.ext.first_launch_time(e.g. on first successful init or first ORTB merge).The resolved value is cached for the process after the first load (thread-safe lazy init via double-checked locking). getApplicationContext is used for storage scope.
- Parameters:
context- any context; getApplicationContext is used for storage scope- Returns:
epoch milliseconds, or
0Lif a value could not be established
-
-
-
-