if (oldDevice == null || !equal(oldDevice.getUuid(), newDevice.getUuid())) { ret.setUuid(newDevice.getUuid()); changed = true; if (oldDevice == null || !equal(oldDevice.getOsName(), newDevice.getOsName())) { ret.setOsName(newDevice.getOsName()); changed = true; if (oldDevice == null || !equal(oldDevice.getOsVersion(), newDevice.getOsVersion())) { ret.setOsVersion(newDevice.getOsVersion()); changed = true; if (oldDevice == null || !equal(oldDevice.getOsBuild(), newDevice.getOsBuild())) { ret.setOsBuild(newDevice.getOsBuild()); changed = true; if (oldDevice == null || !equal(oldDevice.getManufacturer(), newDevice.getManufacturer())) { ret.setManufacturer(newDevice.getManufacturer()); changed = true; if (oldDevice == null || !equal(oldDevice.getModel(), newDevice.getModel())) { ret.setModel(newDevice.getModel()); changed = true; if (oldDevice == null || !equal(oldDevice.getBoard(), newDevice.getBoard())) { ret.setBoard(newDevice.getBoard()); changed = true; if (oldDevice == null || !equal(oldDevice.getProduct(), newDevice.getProduct())) {
public HttpJsonRequest createFirstLoginRequest(String token, AppRelease appRelease, Sdk sdk, Device device, HttpRequest.Listener<HttpJsonRequest> listener) { if (token == null) { throw new IllegalArgumentException("Token is null"); } ConversationTokenRequest conversationTokenRequest = new ConversationTokenRequest(); conversationTokenRequest.setSdkAndAppRelease(SdkManager.getPayload(sdk), AppReleaseManager.getPayload(appRelease)); conversationTokenRequest.setDevice(DeviceManager.getDiffPayload(null, device)); try { conversationTokenRequest.put("token", token); } catch (JSONException e) { // Can't happen } HttpJsonRequest request = createJsonRequest(ENDPOINT_LOG_IN_TO_NEW_CONVERSATION, conversationTokenRequest, HttpRequestMethod.POST); request.addListener(listener); return request; }
final Device device = DeviceManager.generateNewDevice(context); final Sdk sdk = SdkManager.generateCurrentSdk(context); final AppRelease appRelease = ApptentiveInternal.getInstance().getAppRelease(); conversationTokenRequest.setDevice(DeviceManager.getDiffPayload(null, device)); conversationTokenRequest.setSdkAndAppRelease(SdkManager.getPayload(sdk), AppReleaseManager.getPayload(appRelease));
final Device device = DeviceManager.generateNewDevice(getContext());
@Test public void queriesAgainstDevice() throws JSONException { String json = loadTextAssetAsString(TEST_DATA_DIR + "testQueriesAgainstDevice.json"); json = json.replace("\"OS_API_LEVEL\"", String.valueOf(Build.VERSION.SDK_INT)); InteractionCriteria criteria = new InteractionCriteria(json); Device device = DeviceManager.generateNewDevice(targetContext); device.getCustomData().put("foo", "bar"); EventData eventData = new EventData(); FieldManager fieldManager = new FieldManager(targetContext, new VersionHistory(), eventData, new Person(), device, new AppRelease()); // 0 assertTrue(criteria.isMet(fieldManager)); // 1 eventData.storeEventForCurrentAppVersion(Util.currentTimeSeconds(), versionCode, versionName, "switch.code.point"); assertTrue(criteria.isMet(fieldManager)); // 2 eventData.storeEventForCurrentAppVersion(Util.currentTimeSeconds(), versionCode, versionName, "switch.code.point"); assertFalse(criteria.isMet(fieldManager)); // 3 eventData.storeEventForCurrentAppVersion(Util.currentTimeSeconds(), versionCode, versionName, "switch.code.point"); assertTrue(criteria.isMet(fieldManager)); // 4 eventData.storeEventForCurrentAppVersion(Util.currentTimeSeconds(), versionCode, versionName, "switch.code.point"); assertTrue(criteria.isMet(fieldManager)); }