private String a(String str, String str2, boolean z) {
   StringBuilder stringBuilder = new StringBuilder();
   String toString = Integer.toString(new Random().nextInt());
   Map map = null;
   Long lTVId = AnalyticsInitializer.getConfigParams().getLTVId();
   if (str != null) {
     stringBuilder.append("payload=");
     stringBuilder.append(AnalyticsCommon.getURLEncoded(str));
   }
   if (str2 != null) {
     stringBuilder.append("&mk-siteid=");
     stringBuilder.append(str2);
   }
   stringBuilder.append("&c=");
   if (z) {
     stringBuilder.append(1);
   } else {
     stringBuilder.append(0);
   }
   if (lTVId != null) {
     map = new HashMap();
     map.put(UID.KEY_LTVID, lTVId + AdTrackerConstants.BLANK);
   }
   String uidMap = AnalyticsInitializer.getConfigParams().getUID().getUidMap(1, toString, map);
   stringBuilder.append("&u-id-map=");
   stringBuilder.append(AnalyticsCommon.getURLEncoded(uidMap));
   stringBuilder.append("&u-id-key=");
   stringBuilder.append(toString);
   stringBuilder.append("&u-key-ver=");
   stringBuilder.append(UIDHelper.getRSAKeyVersion());
   uidMap =
       "pr-SAND-"
           + InternalSDKUtil.getInMobiInternalVersion(Constants.MEDIATION_SDK_VERSION)
           + "-"
           + InternalSDKUtil.INMOBI_SDK_RELEASE_DATE;
   stringBuilder.append("&mk-version=");
   stringBuilder.append(uidMap);
   stringBuilder.append("&u-id-adt=");
   if (InternalSDKUtil.isLimitAdTrackingEnabled()) {
     stringBuilder.append(1);
   } else {
     stringBuilder.append(0);
   }
   return stringBuilder.toString();
 }
 private void a(AnalyticsPayload analyticsPayload, String str) {
   boolean z = false;
   try {
     boolean z2;
     int responseCode;
     Closeable bufferedReader;
     Log.internal(
         AnalyticsUtils.ANALYTICS_LOGGING_TAG, "Ping URL: " + AnalyticsUtils.getEventUrl());
     String completePayload = analyticsPayload.getCompletePayload();
     int minEventsToCompress = AnalyticsInitializer.getConfigParams().getMinEventsToCompress();
     Log.internal(AnalyticsUtils.ANALYTICS_LOGGING_TAG, "Post body: " + completePayload);
     if (analyticsPayload.getPayloadSize() < minEventsToCompress || VERSION.SDK_INT < 8) {
       z2 = z;
     } else {
       Log.debug(AnalyticsUtils.ANALYTICS_LOGGING_TAG, "Compressing the payload");
       z2 = true;
       completePayload = AnalyticsUtils.compressPayload(completePayload);
     }
     int maxAppIdLength = AnalyticsInitializer.getConfigParams().getMaxAppIdLength();
     if (str.length() > maxAppIdLength) {
       str = str.substring(0, maxAppIdLength);
     }
     completePayload = a(completePayload, str, z2);
     Log.debug(AnalyticsUtils.ANALYTICS_LOGGING_TAG, "Post body: " + completePayload);
     AnalyticsCommon analyticsCommon = new AnalyticsCommon();
     HttpURLConnection httpURLConnection =
         analyticsCommon.setupConnection(AnalyticsUtils.getEventUrl());
     analyticsCommon.postData(httpURLConnection, completePayload);
     try {
       responseCode = httpURLConnection.getResponseCode();
     } catch (IOException e) {
       responseCode = 401;
     }
     Log.debug(AnalyticsUtils.ANALYTICS_LOGGING_TAG, "Http Status Code: " + responseCode);
     if (responseCode == 200) {
       this.e = 0;
       AnalyticsDatabaseManager.getInstance().deleteEvents(analyticsPayload.getTableIdList());
     } else {
       this.e++;
       if (this.e >= AnalyticsUtils.getMaxRetryBeforeDiscard()) {
         this.e = 0;
         AnalyticsDatabaseManager.getInstance().deleteEvents(analyticsPayload.getTableIdList());
       }
     }
     try {
       bufferedReader =
           new BufferedReader(
               new InputStreamReader(
                   httpURLConnection.getInputStream(), HTMLEncoder.ENCODE_NAME_DEFAULT));
     } catch (Exception e2) {
       try {
         bufferedReader =
             new BufferedReader(
                 new InputStreamReader(
                     httpURLConnection.getErrorStream(), HTMLEncoder.ENCODE_NAME_DEFAULT));
       } catch (Exception e3) {
         bufferedReader = null;
       }
     }
     try {
       StringBuilder stringBuilder = new StringBuilder();
       while (true) {
         String readLine = bufferedReader.readLine();
         if (readLine != null) {
           stringBuilder.append(readLine).append(com.admarvel.android.ads.Constants.FORMATTER);
         } else {
           Log.debug(
               AnalyticsUtils.ANALYTICS_LOGGING_TAG, "Ping Response: " + stringBuilder.toString());
           httpURLConnection.disconnect();
           analyticsCommon.closeResource(bufferedReader);
           return;
         }
       }
     } catch (Exception e4) {
       Log.internal(AnalyticsUtils.ANALYTICS_LOGGING_TAG, "Unable to read from stream");
     }
   } catch (Exception e5) {
     Log.debug(AnalyticsUtils.ANALYTICS_LOGGING_TAG, "Exception Pinging", e5);
     this.e++;
     if (this.e >= AnalyticsUtils.getMaxRetryBeforeDiscard()) {
       this.e = z;
       AnalyticsDatabaseManager.getInstance().deleteEvents(analyticsPayload.getTableIdList());
     }
   }
 }