Search in sources :

Example 1 with Device

use of org.prebid.mobile.rendering.models.openrtb.bidRequests.Device in project prebid-mobile-android by prebid.

the class URLComponentsTest method testEncoding.

/**
 * Test urlencoding of keys
 */
@Test
public void testEncoding() throws Exception {
    BidRequest bidRequest = new BidRequest();
    AdRequestInput mockAdRequestInput = new AdRequestInput();
    Device device = new Device();
    device.carrier = "tmobile";
    bidRequest.setId("123");
    bidRequest.setDevice(device);
    mockAdRequestInput.setBidRequest(bidRequest);
    URLComponents urlComponents = new URLComponents("", mockAdRequestInput);
    String expected = "openrtb=%7B%22id%22%3A%22123%22%2C%22device%22%3A%7B%22carrier%22%3A%22tmobile%22%7D%7D";
    assertEquals(expected, urlComponents.getQueryArgString());
}
Also used : AdRequestInput(org.prebid.mobile.rendering.networking.parameters.AdRequestInput) Device(org.prebid.mobile.rendering.models.openrtb.bidRequests.Device) BidRequest(org.prebid.mobile.rendering.models.openrtb.BidRequest) Test(org.junit.Test)

Example 2 with Device

use of org.prebid.mobile.rendering.models.openrtb.bidRequests.Device in project prebid-mobile-android by prebid.

the class BidRequestTest method getJsonObject.

@Test
public void getJsonObject() throws Exception {
    BidRequest bidReq = new BidRequest();
    App app = new App();
    app.id = "auid";
    bidReq.setApp(app);
    Device device = new Device();
    device.h = 1111;
    bidReq.setDevice(device);
    Imp imp = new Imp();
    imp.instl = 0;
    ArrayList<Imp> imps = new ArrayList<>();
    imps.add(imp);
    bidReq.setImp(imps);
    Regs regs = new Regs();
    regs.coppa = 0;
    bidReq.setRegs(regs);
    User user = new User();
    user.keywords = "q, o";
    bidReq.setUser(user);
    JSONObject actualObj = bidReq.getJsonObject();
    String expectedString = "{\"app\":{\"id\":\"auid\"},\"regs\":{\"coppa\":0},\"imp\":[{\"instl\":0}],\"device\":{\"h\":1111},\"user\":{\"keywords\":\"q, o\"}}";
    assertEquals("got: " + actualObj.toString(), expectedString, actualObj.toString());
    bidReq.getJsonObject();
}
Also used : App(org.prebid.mobile.rendering.models.openrtb.bidRequests.App) User(org.prebid.mobile.rendering.models.openrtb.bidRequests.User) JSONObject(org.json.JSONObject) Device(org.prebid.mobile.rendering.models.openrtb.bidRequests.Device) ArrayList(java.util.ArrayList) Regs(org.prebid.mobile.rendering.models.openrtb.bidRequests.Regs) Imp(org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp) Test(org.junit.Test)

Example 3 with Device

use of org.prebid.mobile.rendering.models.openrtb.bidRequests.Device in project prebid-mobile-android by prebid.

the class DeviceInfoParameterBuilderTest method testAppendBuilderParameters.

@Test
public void testAppendBuilderParameters() throws Exception {
    BidRequest expectedBidRequest = new BidRequest();
    final Device expectedBidRequestDevice = expectedBidRequest.getDevice();
    final String ipAddress = "192.168.0.1";
    final String carrier = "carrier";
    AdConfiguration adConfiguration = new AdConfiguration();
    ParameterBuilder builder = new DeviceInfoParameterBuilder(adConfiguration);
    AdRequestInput adRequestInput = new AdRequestInput();
    builder.appendBuilderParameters(adRequestInput);
    expectedBidRequestDevice.os = DeviceInfoParameterBuilder.PLATFORM_VALUE;
    expectedBidRequestDevice.w = SCREEN_WIDTH;
    expectedBidRequestDevice.h = SCREEN_HEIGHT;
    expectedBidRequestDevice.language = Locale.getDefault().getLanguage();
    expectedBidRequestDevice.osv = "4.4";
    expectedBidRequestDevice.os = "Android";
    expectedBidRequestDevice.model = "robolectric";
    expectedBidRequestDevice.make = "unknown";
    expectedBidRequestDevice.pxratio = 1f;
    expectedBidRequestDevice.ua = AppInfoManager.getUserAgent();
    expectedBidRequestDevice.ifa = AdIdManager.getAdId();
    expectedBidRequestDevice.lmt = AdIdManager.isLimitAdTrackingEnabled() ? 1 : 0;
    assertJsonEquals(expectedBidRequest.getJsonObject(), adRequestInput.getBidRequest().getJsonObject());
}
Also used : Device(org.prebid.mobile.rendering.models.openrtb.bidRequests.Device) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) BidRequest(org.prebid.mobile.rendering.models.openrtb.BidRequest) Test(org.junit.Test)

Example 4 with Device

use of org.prebid.mobile.rendering.models.openrtb.bidRequests.Device 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)

Aggregations

Device (org.prebid.mobile.rendering.models.openrtb.bidRequests.Device)4 Test (org.junit.Test)3 BidRequest (org.prebid.mobile.rendering.models.openrtb.BidRequest)2 ArrayList (java.util.ArrayList)1 JSONObject (org.json.JSONObject)1 AdSize (org.prebid.mobile.rendering.bidding.data.AdSize)1 AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)1 App (org.prebid.mobile.rendering.models.openrtb.bidRequests.App)1 Imp (org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp)1 Regs (org.prebid.mobile.rendering.models.openrtb.bidRequests.Regs)1 User (org.prebid.mobile.rendering.models.openrtb.bidRequests.User)1 AdRequestInput (org.prebid.mobile.rendering.networking.parameters.AdRequestInput)1 DeviceInfoManager (org.prebid.mobile.rendering.sdk.deviceData.managers.DeviceInfoManager)1