Java 类com.squareup.leakcanary.internal.LeakCanaryInternals 实例源码

项目:boohee_v5.6    文件:AndroidHeapDumper.java   
public File dumpHeap() {
    if (!LeakCanaryInternals.isExternalStorageWritable()) {
        Log.d(TAG, "Could not dump heap, external storage not mounted.");
    }
    File heapDumpFile = getHeapDumpFile();
    if (heapDumpFile.exists()) {
        Log.d(TAG, "Could not dump heap, previous analysis still is in progress.");
        return NO_DUMP;
    }
    FutureResult<Toast> waitingForToast = new FutureResult();
    showToast(waitingForToast);
    if (waitingForToast.wait(5, TimeUnit.SECONDS)) {
        Toast toast = (Toast) waitingForToast.get();
        try {
            Debug.dumpHprofData(heapDumpFile.getAbsolutePath());
            cancelToast(toast);
            return heapDumpFile;
        } catch (IOException e) {
            cleanup();
            Log.e(TAG, "Could not perform heap dump", e);
            return NO_DUMP;
        }
    }
    Log.d(TAG, "Did not dump heap, too much time waiting for Toast.");
    return NO_DUMP;
}
项目:boohee_v5.6    文件:AndroidHeapDumper.java   
public void cleanup() {
    LeakCanaryInternals.executeOnFileIoThread(new Runnable() {
        public void run() {
            if (LeakCanaryInternals.isExternalStorageWritable()) {
                Log.d(AndroidHeapDumper.TAG, "Could not attempt cleanup, external storage not" +
                        " mounted.");
            }
            File heapDumpFile = AndroidHeapDumper.this.getHeapDumpFile();
            if (heapDumpFile.exists()) {
                Log.d(AndroidHeapDumper.TAG, "Previous analysis did not complete correctly, " +
                        "cleaning: " + heapDumpFile);
                heapDumpFile.delete();
            }
        }
    });
}
项目:leakcannary    文件:AndroidHeapDumper.java   
/**
 * Call this on app startup to clean up all heap dump files that had not been handled yet when
 * the app process was killed.
 */
public void cleanup() {
  LeakCanaryInternals.executeOnFileIoThread(new Runnable() {
    @Override public void run() {
      if (!leakDirectoryProvider.isLeakStorageWritable()) {
        CanaryLog.d("Could not attempt cleanup, leak storage not writable.");
        return;
      }
      File heapDumpFile = getHeapDumpFile();
      if (heapDumpFile.exists()) {
        CanaryLog.d("Previous analysis did not complete correctly, cleaning: %s", heapDumpFile);
        boolean success = heapDumpFile.delete();
        if (!success) {
          CanaryLog.d("Could not delete file %s", heapDumpFile.getPath());
        }
      }
    }
  });
}
项目:LeakCanary4Eclipse    文件:AndroidHeapDumper.java   
/**
 * Call this on app startup to clean up all heap dump files that had not been handled yet when
 * the app process was killed.
 */
public void cleanup() {
  LeakCanaryInternals.executeOnFileIoThread(new Runnable() {
    @Override public void run() {
      if (!leakDirectoryProvider.isLeakStorageWritable()) {
        CanaryLog.d("Could not attempt cleanup, leak storage not writable.");
        return;
      }
      File heapDumpFile = getHeapDumpFile();
      if (heapDumpFile.exists()) {
        CanaryLog.d("Previous analysis did not complete correctly, cleaning: %s", heapDumpFile);
        boolean success = heapDumpFile.delete();
        if (!success) {
          CanaryLog.d("Could not delete file %s", heapDumpFile.getPath());
        }
      }
    }
  });
}
项目:boohee_v5.6    文件:ServiceHeapDumpListener.java   
public ServiceHeapDumpListener(Context context, Class<? extends
        AbstractAnalysisResultService> listenerServiceClass) {
    LeakCanaryInternals.setEnabled(context, listenerServiceClass, true);
    LeakCanaryInternals.setEnabled(context, HeapAnalyzerService.class, true);
    this.listenerServiceClass = (Class) Preconditions.checkNotNull(listenerServiceClass,
            "listenerServiceClass");
    this.context = ((Context) Preconditions.checkNotNull(context, "context"))
            .getApplicationContext();
}
项目:boohee_v5.6    文件:BadgeUtils.java   
public static void setIconBadge(Context context, int count) {
    try {
        if (!Build.MANUFACTURER.equalsIgnoreCase(MiBandHelper.KEY_DATA_SOURCE)) {
            if (Build.MANUFACTURER.equalsIgnoreCase(LeakCanaryInternals.SAMSUNG)) {
                setToSamsumg(context, count);
            } else if (Build.MANUFACTURER.toLowerCase().contains("sony")) {
                setToSony(context, count);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:boohee_v5.6    文件:LeakCanary.java   
public static void enableDisplayLeakActivity(Context context) {
    LeakCanaryInternals.setEnabled(context, DisplayLeakActivity.class, true);
}
项目:boohee_v5.6    文件:LeakCanary.java   
public static boolean isInAnalyzerProcess(Context context) {
    return LeakCanaryInternals.isInServiceProcess(context, HeapAnalyzerService.class);
}
项目:boohee_v5.6    文件:AndroidHeapDumper.java   
private File getHeapDumpFile() {
    return new File(LeakCanaryInternals.storageDirectory(), "suspected_leak_heapdump.hprof");
}