Search in sources :

Example 6 with DeviceInfoManager

use of org.prebid.mobile.rendering.sdk.deviceData.managers.DeviceInfoManager in project prebid-mobile-android by prebid.

the class Requester method makeAdRequest.

protected void makeAdRequest() {
    // Check if app has internet permissions
    DeviceInfoManager deviceManager = ManagersResolver.getInstance().getDeviceManager();
    if (deviceManager == null || !deviceManager.isPermissionGranted("android.permission.INTERNET")) {
        sendAdException("Either Prebid DeviceManager is not initialized or android.permission.INTERNET is not specified. Please check", "Internet permission not granted");
        return;
    }
    // Check if device is connected to the internet
    ConnectionInfoManager connectionInfoManager = ManagersResolver.getInstance().getNetworkManager();
    if (connectionInfoManager == null || connectionInfoManager.getConnectionType() == UserParameters.ConnectionType.OFFLINE) {
        sendAdException("Either Prebid networkManager is not initialized or Device is offline. Please check the internet connection", "No internet connection detected");
        return;
    }
    // Send ad request
    URLComponents jsonUrlComponents = buildUrlComponent();
    sendAdRequest(jsonUrlComponents);
}
Also used : URLComponents(org.prebid.mobile.rendering.networking.urlBuilder.URLComponents) DeviceInfoManager(org.prebid.mobile.rendering.sdk.deviceData.managers.DeviceInfoManager) ConnectionInfoManager(org.prebid.mobile.rendering.sdk.deviceData.managers.ConnectionInfoManager)

Example 7 with DeviceInfoManager

use of org.prebid.mobile.rendering.sdk.deviceData.managers.DeviceInfoManager in project prebid-mobile-android by prebid.

the class DeviceInfoParameterBuilder method appendBuilderParameters.

@Override
public void appendBuilderParameters(AdRequestInput adRequestInput) {
    DeviceInfoManager deviceManager = ManagersResolver.getInstance().getDeviceManager();
    if (deviceManager != null) {
        int screenWidth = deviceManager.getScreenWidth();
        int screenHeight = deviceManager.getScreenHeight();
        Device device = adRequestInput.getBidRequest().getDevice();
        device.pxratio = Utils.DENSITY;
        if (screenWidth > 0 && screenHeight > 0) {
            device.w = screenWidth;
            device.h = screenHeight;
        }
        String advertisingId = AdIdManager.getAdId();
        if (Utils.isNotBlank(advertisingId)) {
            device.ifa = advertisingId;
        }
        device.make = Build.MANUFACTURER;
        device.model = Build.MODEL;
        device.os = PLATFORM_VALUE;
        device.osv = Build.VERSION.RELEASE;
        device.language = Locale.getDefault().getLanguage();
        device.ua = AppInfoManager.getUserAgent();
        // lmt and APP_ADVERTISING_ID_ENABLED are opposites
        boolean lmt = AdIdManager.isLimitAdTrackingEnabled();
        device.lmt = lmt ? 1 : 0;
        final AdSize minSizePercentage = mAdConfiguration.getMinSizePercentage();
        if (minSizePercentage != null) {
            device.getExt().put("prebid", Prebid.getJsonObjectForDeviceMinSizePerc(minSizePercentage));
        }
    }
}
Also used : Device(org.prebid.mobile.rendering.models.openrtb.bidRequests.Device) AdSize(org.prebid.mobile.rendering.bidding.data.AdSize) DeviceInfoManager(org.prebid.mobile.rendering.sdk.deviceData.managers.DeviceInfoManager)

Example 8 with DeviceInfoManager

use of org.prebid.mobile.rendering.sdk.deviceData.managers.DeviceInfoManager in project prebid-mobile-android by prebid.

the class NetworkParameterBuilder method appendBuilderParameters.

@Override
public void appendBuilderParameters(AdRequestInput adRequestInput) {
    DeviceInfoManager deviceManager = ManagersResolver.getInstance().getDeviceManager();
    if (deviceManager != null) {
        String detectedMccMnc = deviceManager.getMccMnc();
        if (Utils.isNotBlank(detectedMccMnc)) {
            adRequestInput.getBidRequest().getDevice().mccmnc = detectedMccMnc;
        }
        String detectedCarrier = deviceManager.getCarrier();
        if (Utils.isNotBlank(detectedCarrier)) {
            adRequestInput.getBidRequest().getDevice().carrier = detectedCarrier;
        }
    }
    ConnectionInfoManager connectionInfoManager = ManagersResolver.getInstance().getNetworkManager();
    if (connectionInfoManager != null && deviceManager != null) {
        setNetworkParams(adRequestInput, deviceManager, connectionInfoManager);
    }
}
Also used : DeviceInfoManager(org.prebid.mobile.rendering.sdk.deviceData.managers.DeviceInfoManager) ConnectionInfoManager(org.prebid.mobile.rendering.sdk.deviceData.managers.ConnectionInfoManager)

Example 9 with DeviceInfoManager

use of org.prebid.mobile.rendering.sdk.deviceData.managers.DeviceInfoManager in project prebid-mobile-android by prebid.

the class GeoLocationParameterBuilder method appendBuilderParameters.

@Override
public void appendBuilderParameters(AdRequestInput adRequestInput) {
    LocationInfoManager locationInfoManager = ManagersResolver.getInstance().getLocationManager();
    DeviceInfoManager deviceManager = ManagersResolver.getInstance().getDeviceManager();
    // Strictly ignore publisher geo values
    adRequestInput.getBidRequest().getDevice().setGeo(null);
    if (locationInfoManager != null) {
        if (deviceManager != null && deviceManager.isPermissionGranted("android.permission.ACCESS_FINE_LOCATION")) {
            setLocation(adRequestInput, locationInfoManager);
        }
    }
}
Also used : LocationInfoManager(org.prebid.mobile.rendering.sdk.deviceData.managers.LocationInfoManager) DeviceInfoManager(org.prebid.mobile.rendering.sdk.deviceData.managers.DeviceInfoManager)

Aggregations

DeviceInfoManager (org.prebid.mobile.rendering.sdk.deviceData.managers.DeviceInfoManager)9 SuppressLint (android.annotation.SuppressLint)2 JavascriptInterface (android.webkit.JavascriptInterface)2 JSONException (org.json.JSONException)2 JSONObject (org.json.JSONObject)2 ConnectionInfoManager (org.prebid.mobile.rendering.sdk.deviceData.managers.ConnectionInfoManager)2 WindowManager (android.view.WindowManager)1 AdSize (org.prebid.mobile.rendering.bidding.data.AdSize)1 AdException (org.prebid.mobile.rendering.errors.AdException)1 Device (org.prebid.mobile.rendering.models.openrtb.bidRequests.Device)1 URLComponents (org.prebid.mobile.rendering.networking.urlBuilder.URLComponents)1 LocationInfoManager (org.prebid.mobile.rendering.sdk.deviceData.managers.LocationInfoManager)1