本文整理汇总了Java中com.squareup.leakcanary.internal.LeakCanaryInternals类的典型用法代码示例。如果您正苦于以下问题:Java LeakCanaryInternals类的具体用法?Java LeakCanaryInternals怎么用?Java LeakCanaryInternals使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LeakCanaryInternals类属于com.squareup.leakcanary.internal包,在下文中一共展示了LeakCanaryInternals类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dumpHeap
import com.squareup.leakcanary.internal.LeakCanaryInternals; //导入依赖的package包/类
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;
}
示例2: cleanup
import com.squareup.leakcanary.internal.LeakCanaryInternals; //导入依赖的package包/类
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();
}
}
});
}
示例3: cleanup
import com.squareup.leakcanary.internal.LeakCanaryInternals; //导入依赖的package包/类
/**
* 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());
}
}
}
});
}
示例4: ServiceHeapDumpListener
import com.squareup.leakcanary.internal.LeakCanaryInternals; //导入依赖的package包/类
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();
}
示例5: setIconBadge
import com.squareup.leakcanary.internal.LeakCanaryInternals; //导入依赖的package包/类
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();
}
}
示例6: enableDisplayLeakActivity
import com.squareup.leakcanary.internal.LeakCanaryInternals; //导入依赖的package包/类
public static void enableDisplayLeakActivity(Context context) {
LeakCanaryInternals.setEnabled(context, DisplayLeakActivity.class, true);
}
示例7: isInAnalyzerProcess
import com.squareup.leakcanary.internal.LeakCanaryInternals; //导入依赖的package包/类
public static boolean isInAnalyzerProcess(Context context) {
return LeakCanaryInternals.isInServiceProcess(context, HeapAnalyzerService.class);
}
示例8: getHeapDumpFile
import com.squareup.leakcanary.internal.LeakCanaryInternals; //导入依赖的package包/类
private File getHeapDumpFile() {
return new File(LeakCanaryInternals.storageDirectory(), "suspected_leak_heapdump.hprof");
}