com.squareup.leakcanary.internal.DisplayLeakActivity Java Examples

The following examples show how to use com.squareup.leakcanary.internal.DisplayLeakActivity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AndroidRefWatcherBuilder.java    From DoraemonKit with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a {@link RefWatcher} instance and makes it available through {@link
 * LeakCanary#installedRefWatcher()}.
 *
 * Also starts watching activity references if {@link #watchActivities(boolean)} was set to true.
 *
 * @throws UnsupportedOperationException if called more than once per Android process.
 */
public @NonNull
RefWatcher buildAndInstall() {
  if (LeakCanaryInternals.installedRefWatcher != null) {
    throw new UnsupportedOperationException("buildAndInstall() should only be called once.");
  }
  RefWatcher refWatcher = build();
  if (refWatcher != RefWatcher.DISABLED) {
    if (enableDisplayLeakActivity) {
      LeakCanaryInternals.setEnabledAsync(context, DisplayLeakActivity.class, true);
    }
    if (watchActivities) {
      ActivityRefWatcher.install(context, refWatcher);
    }
    if (watchFragments) {
      FragmentRefWatcher.Helper.install(context, refWatcher);
    }
  }
  LeakCanaryInternals.installedRefWatcher = refWatcher;
  return refWatcher;
}
 
Example #2
Source File: LeakCanaryKit.java    From DoraemonKit with Apache License 2.0 4 votes vote down vote up
@Override
public void onClick(Context context) {
    Intent intent = new Intent(context, DisplayLeakActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}
 
Example #3
Source File: DisplayLeakService.java    From DoraemonKit with Apache License 2.0 4 votes vote down vote up
@Override
protected final void onHeapAnalyzed(@NonNull AnalyzedHeap analyzedHeap) {

    HeapDump heapDump = analyzedHeap.heapDump;
    AnalysisResult result = analyzedHeap.result;



    String leakInfo = leakInfo(this, heapDump, result, true);
    CanaryLog.d("%s", leakInfo);

    heapDump = renameHeapdump(heapDump);
    boolean resultSaved = saveResult(heapDump, result);

    String contentTitle;
    if (resultSaved) {
        PendingIntent pendingIntent =
                DisplayLeakActivity.createPendingIntent(this, heapDump.referenceKey);
        if (result.failure != null) {
            contentTitle = getString(R.string.leak_canary_analysis_failed);
        } else {
            String className = LeakCanaryInternals.classSimpleName(result.className);
            if (result.leakFound) {
                if (result.retainedHeapSize == AnalysisResult.RETAINED_HEAP_SKIPPED) {
                    if (result.excludedLeak) {
                        contentTitle = getString(R.string.leak_canary_leak_excluded, className);
                    } else {
                        contentTitle = getString(R.string.leak_canary_class_has_leaked, className);
                    }
                } else {
                    String size = formatShortFileSize(this, result.retainedHeapSize);
                    if (result.excludedLeak) {
                        contentTitle =
                                getString(R.string.leak_canary_leak_excluded_retaining, className, size);
                    } else {
                        contentTitle =
                                getString(R.string.leak_canary_class_has_leaked_retaining, className, size);
                    }
                }
            } else {
                contentTitle = getString(R.string.leak_canary_class_no_leak, className);
            }
        }
        String contentText = getString(R.string.leak_canary_notification_message);
        showNotification(pendingIntent, contentTitle, contentText);
    } else {
        onAnalysisResultFailure(getString(R.string.leak_canary_could_not_save_text));
    }

    afterDefaultHandling(heapDump, result, leakInfo);
}
 
Example #4
Source File: LeakCanary.java    From leakcanary-for-eclipse with MIT License 4 votes vote down vote up
public static void enableDisplayLeakActivity(Context context) {
  setEnabled(context, DisplayLeakActivity.class, true);
}
 
Example #5
Source File: DebugView.java    From u2020-mvp with Apache License 2.0 4 votes vote down vote up
@OnClick(R.id.debug_leaks_show)
void showLeaks() {
    Intent intent = new Intent(getContext(), DisplayLeakActivity.class);
    getContext().startActivity(intent);
}
 
Example #6
Source File: DebugView.java    From u2020 with Apache License 2.0 4 votes vote down vote up
@OnClick(R.id.debug_leaks_show) void showLeaks() {
  Intent intent = new Intent(getContext(), DisplayLeakActivity.class);
  getContext().startActivity(intent);
}
 
Example #7
Source File: LeakCanary.java    From DoraemonKit with Apache License 2.0 2 votes vote down vote up
/**
 * Blocking inter process call that enables the {@link DisplayLeakActivity}. When you first
 * install the app, {@link DisplayLeakActivity} is enabled by default if LeakCanary is configured
 * to use {@link DisplayLeakService}. You can call this method to enable
 * {@link DisplayLeakActivity} manually.
 */
public static void enableDisplayLeakActivity(@NonNull Context context) {
    LeakCanaryInternals.setEnabledBlocking(context, DisplayLeakActivity.class, true);
}