public boolean invoke(AppRequestData paramAppRequestData) {
   HttpRequest localHttpRequest =
       applyMultipartDataTo(
           applyHeadersTo(getHttpRequest(), paramAppRequestData), paramAppRequestData);
   Fabric.getLogger().d("Fabric", "Sending app info to " + getUrl());
   if (paramAppRequestData.icon != null) {
     Fabric.getLogger().d("Fabric", "App icon hash is " + paramAppRequestData.icon.hash);
     Fabric.getLogger()
         .d(
             "Fabric",
             "App icon size is "
                 + paramAppRequestData.icon.width
                 + "x"
                 + paramAppRequestData.icon.height);
   }
   int i = localHttpRequest.code();
   if ("POST".equals(localHttpRequest.method())) {}
   for (paramAppRequestData = "Create"; ; paramAppRequestData = "Update") {
     Fabric.getLogger()
         .d(
             "Fabric",
             paramAppRequestData + " app request ID: " + localHttpRequest.header("X-REQUEST-ID"));
     Fabric.getLogger().d("Fabric", "Result was " + i);
     if (ResponseParser.parse(i) != 0) {
       break;
     }
     return true;
   }
   return false;
 }
Example #2
0
 private void attemptUploadWithRetry() {
   Fabric.getLogger()
       .m23d(Fabric.TAG, "Starting report processing in " + this.delay + " second(s)...");
   if (this.delay > 0.0f) {
     try {
       Thread.sleep((long) (this.delay * 1000.0f));
     } catch (InterruptedException e) {
       Thread.currentThread().interrupt();
       return;
     }
   }
   Crashlytics crashlytics = Crashlytics.getInstance();
   CrashlyticsUncaughtExceptionHandler handler = crashlytics.getHandler();
   List<Report> reports = ReportUploader.this.findReports();
   if (!handler.isHandlingException()) {
     if (reports.isEmpty() || crashlytics.canSendWithUserApproval()) {
       int retryCount = 0;
       while (!reports.isEmpty()
           && !Crashlytics.getInstance().getHandler().isHandlingException()) {
         Fabric.getLogger()
             .m23d(Fabric.TAG, "Attempting to send " + reports.size() + " report(s)");
         for (Report report : reports) {
           ReportUploader.this.forceUpload(report);
         }
         reports = ReportUploader.this.findReports();
         if (!reports.isEmpty()) {
           int retryCount2 = retryCount + 1;
           long interval =
               (long)
                   ReportUploader.RETRY_INTERVALS[
                       Math.min(retryCount, ReportUploader.RETRY_INTERVALS.length - 1)];
           Fabric.getLogger()
               .m23d(
                   Fabric.TAG,
                   "Report submisson: scheduling delayed retry in " + interval + " seconds");
           try {
             Thread.sleep(1000 * interval);
             retryCount = retryCount2;
           } catch (InterruptedException e2) {
             Thread.currentThread().interrupt();
             return;
           }
         }
       }
       return;
     }
     Fabric.getLogger()
         .m23d(Fabric.TAG, "User declined to send. Removing " + reports.size() + " Report(s).");
     for (Report report2 : reports) {
       report2.remove();
     }
   }
 }
Example #3
0
 List<Report> findReports() {
   Fabric.getLogger().m23d(Fabric.TAG, "Checking for crash reports...");
   synchronized (this.fileAccessLock) {
     File[] clsFiles = Crashlytics.getInstance().getSdkDirectory().listFiles(crashFileFilter);
   }
   List<Report> reports = new LinkedList();
   for (File file : clsFiles) {
     Fabric.getLogger().m23d(Fabric.TAG, "Found crash report " + file.getPath());
     reports.add(new SessionReport(file));
   }
   if (reports.isEmpty()) {
     Fabric.getLogger().m23d(Fabric.TAG, "No reports found.");
   }
   return reports;
 }
 private HttpRequest applyMultipartDataTo(
     HttpRequest paramHttpRequest, AppRequestData paramAppRequestData) {
   HttpRequest localHttpRequest =
       paramHttpRequest
           .part("app[identifier]", paramAppRequestData.appId)
           .part("app[name]", paramAppRequestData.name)
           .part("app[display_version]", paramAppRequestData.displayVersion)
           .part("app[build_version]", paramAppRequestData.buildVersion)
           .part("app[source]", Integer.valueOf(paramAppRequestData.source))
           .part("app[minimum_sdk_version]", paramAppRequestData.minSdkVersion)
           .part("app[built_sdk_version]", paramAppRequestData.builtSdkVersion);
   if (!CommonUtils.isNullOrEmpty(paramAppRequestData.instanceIdentifier)) {
     localHttpRequest.part("app[instance_identifier]", paramAppRequestData.instanceIdentifier);
   }
   Object localObject;
   if (paramAppRequestData.icon != null) {
     localObject = null;
     paramHttpRequest = null;
   }
   try {
     InputStream localInputStream =
         this.kit
             .getContext()
             .getResources()
             .openRawResource(paramAppRequestData.icon.iconResourceId);
     paramHttpRequest = localInputStream;
     localObject = localInputStream;
     localHttpRequest
         .part("app[icon][hash]", paramAppRequestData.icon.hash)
         .part("app[icon][data]", "icon.png", "application/octet-stream", localInputStream)
         .part("app[icon][width]", Integer.valueOf(paramAppRequestData.icon.width))
         .part("app[icon][height]", Integer.valueOf(paramAppRequestData.icon.height));
     CommonUtils.closeOrLog(localInputStream, "Failed to close app icon InputStream.");
   } catch (Resources.NotFoundException localNotFoundException) {
     for (; ; ) {
       localObject = paramHttpRequest;
       Fabric.getLogger()
           .e(
               "Fabric",
               "Failed to find app icon with resource ID: "
                   + paramAppRequestData.icon.iconResourceId,
               localNotFoundException);
       CommonUtils.closeOrLog(paramHttpRequest, "Failed to close app icon InputStream.");
     }
   } finally {
     CommonUtils.closeOrLog((Closeable) localObject, "Failed to close app icon InputStream.");
   }
   if (paramAppRequestData.sdkKits != null) {
     paramHttpRequest = paramAppRequestData.sdkKits.iterator();
     while (paramHttpRequest.hasNext()) {
       paramAppRequestData = (KitInfo) paramHttpRequest.next();
       localHttpRequest.part(
           getKitVersionKey(paramAppRequestData), paramAppRequestData.getVersion());
       localHttpRequest.part(
           getKitBuildTypeKey(paramAppRequestData), paramAppRequestData.getBuildType());
     }
   }
   return localHttpRequest;
 }
 public boolean invoke(CreateReportRequest createreportrequest) {
   createreportrequest =
       applyMultipartDataTo(
           applyHeadersTo(getHttpRequest(), createreportrequest), createreportrequest);
   Fabric.getLogger()
       .d(
           "CrashlyticsCore",
           (new StringBuilder()).append("Sending report to: ").append(getUrl()).toString());
   int i = createreportrequest.code();
   Fabric.getLogger()
       .d(
           "CrashlyticsCore",
           (new StringBuilder())
               .append("Create report request ID: ")
               .append(createreportrequest.header("X-REQUEST-ID"))
               .toString());
   Fabric.getLogger()
       .d("CrashlyticsCore", (new StringBuilder()).append("Result was: ").append(i).toString());
   return ResponseParser.parse(i) == 0;
 }
 @Override
 public AppSession deserialize(String serializedSession) {
   if (!TextUtils.isEmpty(serializedSession)) {
     try {
       return gson.fromJson(serializedSession, AppSession.class);
     } catch (Exception e) {
       Fabric.getLogger().d(TwitterCore.TAG, "Failed to deserialize session " + e.getMessage());
     }
   }
   return null;
 }
 @Override
 public String serialize(AppSession session) {
   if (session != null && session.getAuthToken() != null) {
     try {
       return gson.toJson(session);
     } catch (Exception e) {
       Fabric.getLogger().d(TwitterCore.TAG, "Failed to serialize session " + e.getMessage());
     }
   }
   return "";
 }
Example #8
0
 public void onRun() {
   try {
     attemptUploadWithRetry();
   } catch (Exception e) {
     Fabric.getLogger()
         .m26e(
             Fabric.TAG,
             "An unexpected error occurred while attempting to upload crash reports.",
             e);
   }
   ReportUploader.this.uploadThread = null;
 }
Example #9
0
 boolean forceUpload(Report report) {
   boolean removed = false;
   synchronized (this.fileAccessLock) {
     try {
       boolean sent =
           this.createReportCall.invoke(
               new CreateReportRequest(
                   new ApiKey().getValue(Crashlytics.getInstance().getContext()), report));
       Fabric.getLogger()
           .m27i(
               Fabric.TAG,
               "Crashlytics report upload "
                   + (sent ? "complete: " : "FAILED: ")
                   + report.getFileName());
       if (sent) {
         report.remove();
         removed = true;
       }
     } catch (Exception e) {
       Fabric.getLogger().m26e(Fabric.TAG, "Error occurred sending report " + report, e);
     }
   }
   return removed;
 }