@Test public void rewriteUrl_whenPlayServicesNotPresent_shouldUseDeviceValue() throws Exception { when(methodBuilder.setStatic(any(Class.class))).thenReturn(methodBuilder); when(methodBuilder.addParam(any(Class.class), any())).thenReturn(methodBuilder); when(methodBuilder.execute()).thenReturn(GpsHelper.GOOGLE_PLAY_SUCCESS_CODE + 1); assertThat(subject.rewriteUrl("http: .isEqualToIgnoringCase("http: }
@Override public String rewriteUrl(final String url) { if (!url.contains(UDID_TEMPLATE) && !url.contains(DO_NOT_TRACK_TEMPLATE)) { return url; } String prefix = ""; GpsHelper.AdvertisingInfo advertisingInfo = new GpsHelper.AdvertisingInfo(deviceIdentifier, false); if (GpsHelper.isPlayServicesAvailable(applicationContext)) { GpsHelper.AdvertisingInfo playServicesAdInfo = GpsHelper.fetchAdvertisingInfoSync(applicationContext); if (playServicesAdInfo != null) { prefix = IFA_PREFIX; advertisingInfo = playServicesAdInfo; } } String toReturn = url.replace(UDID_TEMPLATE, Uri.encode(prefix + advertisingInfo.advertisingId)); toReturn = toReturn.replace(DO_NOT_TRACK_TEMPLATE, advertisingInfo.limitAdTracking ? "1" : "0"); return toReturn; }
PlayServicesUrlRewriter implements HurlStack.UrlRewriter { @Override public String rewriteUrl(final String url) { if (!url.contains(UDID_TEMPLATE) && !url.contains(DO_NOT_TRACK_TEMPLATE)) { return url; } String prefix = ""; GpsHelper.AdvertisingInfo advertisingInfo = new GpsHelper.AdvertisingInfo(deviceIdentifier, false); if (GpsHelper.isPlayServicesAvailable(applicationContext)) { GpsHelper.AdvertisingInfo playServicesAdInfo = GpsHelper.fetchAdvertisingInfoSync(applicationContext); if (playServicesAdInfo != null) { prefix = IFA_PREFIX; advertisingInfo = playServicesAdInfo; } } String toReturn = url.replace(UDID_TEMPLATE, Uri.encode(prefix + advertisingInfo.advertisingId)); toReturn = toReturn.replace(DO_NOT_TRACK_TEMPLATE, advertisingInfo.limitAdTracking ? "1" : "0"); return toReturn; } }
PlayServicesUrlRewriter implements HurlStack.UrlRewriter { @Override public String rewriteUrl(final String url) { if (!url.contains(UDID_TEMPLATE) && !url.contains(DO_NOT_TRACK_TEMPLATE)) { return url; } String prefix = ""; GpsHelper.AdvertisingInfo advertisingInfo = new GpsHelper.AdvertisingInfo(deviceIdentifier, false); if (GpsHelper.isPlayServicesAvailable(applicationContext)) { GpsHelper.AdvertisingInfo playServicesAdInfo = GpsHelper.fetchAdvertisingInfoSync(applicationContext); if (playServicesAdInfo != null) { prefix = IFA_PREFIX; advertisingInfo = playServicesAdInfo; } } String toReturn = url.replace(UDID_TEMPLATE, Uri.encode(prefix + advertisingInfo.advertisingId)); toReturn = toReturn.replace(DO_NOT_TRACK_TEMPLATE, advertisingInfo.limitAdTracking ? "1" : "0"); return toReturn; } PlayServicesUrlRewriter(String deviceId, Context context); }
PlayServicesUrlRewriter implements HurlStack.UrlRewriter { @Override public String rewriteUrl(final String url) { if (!url.contains(UDID_TEMPLATE) && !url.contains(DO_NOT_TRACK_TEMPLATE)) { return url; } String prefix = ""; GpsHelper.AdvertisingInfo advertisingInfo = new GpsHelper.AdvertisingInfo(deviceIdentifier, false); if (GpsHelper.isPlayServicesAvailable(applicationContext)) { GpsHelper.AdvertisingInfo playServicesAdInfo = GpsHelper.fetchAdvertisingInfoSync(applicationContext); if (playServicesAdInfo != null) { prefix = IFA_PREFIX; advertisingInfo = playServicesAdInfo; } } String toReturn = url.replace(UDID_TEMPLATE, Uri.encode(prefix + advertisingInfo.advertisingId)); toReturn = toReturn.replace(DO_NOT_TRACK_TEMPLATE, advertisingInfo.limitAdTracking ? "1" : "0"); return toReturn; } PlayServicesUrlRewriter(String deviceId, Context context); @Override String rewriteUrl(final String url); }
PlayServicesUrlRewriter implements HurlStack.UrlRewriter { @Override public String rewriteUrl(final String url) { if (!url.contains(UDID_TEMPLATE) && !url.contains(DO_NOT_TRACK_TEMPLATE)) { return url; } String prefix = ""; GpsHelper.AdvertisingInfo advertisingInfo = new GpsHelper.AdvertisingInfo(deviceIdentifier, false); if (GpsHelper.isPlayServicesAvailable(applicationContext)) { GpsHelper.AdvertisingInfo playServicesAdInfo = GpsHelper.fetchAdvertisingInfoSync(applicationContext); if (playServicesAdInfo != null) { prefix = IFA_PREFIX; advertisingInfo = playServicesAdInfo; } } String toReturn = url.replace(UDID_TEMPLATE, Uri.encode(prefix + advertisingInfo.advertisingId)); toReturn = toReturn.replace(DO_NOT_TRACK_TEMPLATE, advertisingInfo.limitAdTracking ? "1" : "0"); return toReturn; } PlayServicesUrlRewriter(String deviceId, Context context); @Override String rewriteUrl(final String url); static final String UDID_TEMPLATE; static final String DO_NOT_TRACK_TEMPLATE; }