private void b() {
   boolean z = 1;
   if (!(this.d == null || !this.d.isConnected() || this.c == null)) {
     AnalyticsPayload payloadList =
         this.c.getPayloadList(
             AnalyticsDatabaseManager.getInstance().getEvents(), InternalSDKUtil.getContext());
     if (payloadList.getCompletePayload() != null) {
       a(payloadList, SessionInfo.getAppId(InternalSDKUtil.getContext()));
       z = false;
     }
   }
   if (i == 0) {
     a.sendEmptyMessageDelayed(MESSAGE_PING, AnalyticsUtils.getTimeinterval());
   } else {
     AnalyticsUtils.setStartHandle(false);
   }
 }
 public boolean handleMessage(Message message) {
   Log.debug(
       AnalyticsUtils.ANALYTICS_LOGGING_TAG, "NetworkManager->handleMessag: msg:" + message);
   if (message.what == 1001) {
     if (AnalyticsInitializer.getConfigParams().getAutomaticCapture().getAutoSessionCapture()
         || AnalyticsEventsWrapper.isEventsUser()) {
       a.this.b();
     } else {
       AnalyticsUtils.setStartHandle(false);
     }
   }
   return true;
 }
 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());
     }
   }
 }