code: private static String fixTracePath(String tracePath) {
      String defaultTraceBody = "dmtrace";
      String defaultTraceExtension = ".trace";
  
      if (tracePath == null || tracePath.charAt(0) != '/') {
        final File dir = RuntimeEnvironment.application.getExternalFilesDir(null);
        if (tracePath == null) {
          tracePath = new File(dir, defaultTraceBody).getAbsolutePath();
        } else {
          tracePath = new File(dir, tracePath).getAbsolutePath();
        }
      }
      if (!tracePath.endsWith(defaultTraceExtension)) {
        tracePath += defaultTraceExtension;
      }
      return tracePath;
    }
docs: Forked from android.os.Debug