Java 类android.os.Debug 实例源码

项目:GitHub    文件:MainActivity.java   
private void updateStats() {
  final Runtime runtime = Runtime.getRuntime();
  final long heapMemory = runtime.totalMemory() - runtime.freeMemory();
  final StringBuilder sb = new StringBuilder(DEFAULT_MESSAGE_SIZE);
  // When changing format of output below, make sure to sync "run_comparison.py" as well
  sb.append("Heap: ");
  appendSize(sb, heapMemory);
  sb.append(" Java ");
  appendSize(sb, Debug.getNativeHeapSize());
  sb.append(" native\n");
  appendTime(sb, "Avg wait time: ", mPerfListener.getAverageWaitTime(), "\n");
  appendNumber(sb, "Requests: ", mPerfListener.getOutstandingRequests(), " outsdng ");
  appendNumber(sb, "", mPerfListener.getCancelledRequests(), " cncld\n");
  final String message = sb.toString();
  mStatsDisplay.setText(message);
  FLog.i(TAG, message);
}
项目:LuaViewPlayground    文件:LogUtil.java   
/**
 * 统计平均时常
 *
 * @param tag
 * @param msg
 */
public static void avgTimeEnd(String tag, Object... msg) {
    if (LuaViewConfig.isDebug()) {
        Map map = mAvgTime.get(tag);
        if (map != null) {//已经开始
            long lastTime = Long.valueOf(String.valueOf(map.get(LAST_TIME)));
            long totalTime = Long.valueOf(String.valueOf(map.get(TOTAL_TIME))) + Debug.threadCpuTimeNanos() - lastTime;
            map.put(TOTAL_TIME, totalTime);//总时间
            long printInterval = Long.valueOf(String.valueOf(map.get(PRINT_INTERVAL)));
            long times = Long.valueOf(String.valueOf(map.get(TIMES))) + 1;//总次数
            if (times >= printInterval) {//可以打印
                Log.d(DEFAULT_PREFIX, tag + " end " + (double) totalTime / printInterval + " " + getMsg(msg));
                mAvgTime.put(tag, null);
            } else {
                map.put(TIMES, times);//总次数
            }
        }
    }
}
项目:StallBuster    文件:EventProcessor.java   
@Override
public boolean handleMessage(Message msg) {
    // TODO uncomment below code when release
    if (Debug.isDebuggerConnected()) {
        return true;
    }
    Event event = (Event) msg.obj;
    if (event != null) {
        try {
            processEvent(event);
        } catch (Exception e) {
            e.printStackTrace();
        }
        event.recycle();
    }
    // return true, so handler won't process this msg again, since we have event recycled here
    return true;
}
项目:XinFramework    文件:MemoryLog.java   
/**
 * 打印内存信息
 */
public static void memoryApp(String info) {

    if ( !DEBUG_MEMORY) {
        return;
    }

    Debug.MemoryInfo memoryInfo = new Debug.MemoryInfo();
    int dalvikPrivateDirty = memoryInfo.dalvikPrivateDirty;
    int dalvikPss = memoryInfo.dalvikPss;
    int dalvikSharedDirty = memoryInfo.dalvikSharedDirty;
    int nativePrivateDirty = memoryInfo.nativePrivateDirty;
    int nativePss = memoryInfo.nativePss;
    int nativeSharedDirty = memoryInfo.nativeSharedDirty;
    int otherPss = memoryInfo.otherPss;
    int otherSharedDirty = memoryInfo.otherSharedDirty;
    String content =
        info + "-->dalvikPrivateDirty:" + dalvikPrivateDirty + ",dalvikPss:" + dalvikPss + ",dalvikSharedDirty:" + dalvikSharedDirty + ",nativePrivateDirty:" +
                nativePrivateDirty + ",nativePss:" + nativePss + ",nativeSharedDirty:" + nativeSharedDirty + ",otherPss:" + otherPss + ",otherSharedDirty:" + otherSharedDirty +
                "\n";
    Log.d(
        content);
}
项目:Lantern-sdk    文件:MemoryResource.java   
public MemoryResource() {
    memoryInfoList.clear();

    memoryInfoList.add(Runtime.getRuntime().maxMemory());
    memoryInfoList.add(Runtime.getRuntime().totalMemory());
    memoryInfoList.add(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory());
    memoryInfoList.add(Runtime.getRuntime().freeMemory());

    this.natHeapSize = Debug.getNativeHeapSize();
    this.natHeapFreeSize = Debug.getNativeHeapFreeSize();
    this.pss = Debug.getPss();
    this.loadedClassCount = Debug.getLoadedClassCount();

    this.memoryInfo = new Debug.MemoryInfo();
    Debug.getMemoryInfo(memoryInfo);
}
项目:chromium-for-android-56-debug-video    文件:GSAServiceClient.java   
/**
 * Get the PSS used by the process hosting a service.
 *
 * @param packageName Package name of the service to search for.
 * @return the PSS in kB of the process hosting a service, or INVALID_PSS.
 */
@VisibleForTesting
static int getPssForService(ComponentName componentName) {
    if (componentName == null) return INVALID_PSS;
    Context context = ContextUtils.getApplicationContext();
    ActivityManager activityManager =
            (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    List<ActivityManager.RunningServiceInfo> services =
            activityManager.getRunningServices(1000);
    if (services == null) return INVALID_PSS;
    int pid = -1;
    for (ActivityManager.RunningServiceInfo info : services) {
        if (componentName.equals(info.service)) {
            pid = info.pid;
            break;
        }
    }
    if (pid == -1) return INVALID_PSS;
    Debug.MemoryInfo infos[] = activityManager.getProcessMemoryInfo(new int[] {pid});
    if (infos == null || infos.length == 0) return INVALID_PSS;
    return infos[0].getTotalPss();
}
项目:springreplugin    文件:LogDebug.java   
/**
 * 打印当前内存占用日志,方便外界诊断。注意,这会显著消耗性能(约50ms左右)
 *
 * @param tag Used to identify the source of a log message.  It usually identifies
 *            the class or activity where the log call occurs.
 * @param msg The message you would like logged.
 */
public static int printMemoryStatus(String tag, String msg) {
    if (RePluginInternal.FOR_DEV) {
        Debug.MemoryInfo mi = new Debug.MemoryInfo();
        Debug.getMemoryInfo(mi);

        String mit = "desc=, memory_v_0_0_1, process=, " + IPC.getCurrentProcessName() +
                ", totalPss=, " + mi.getTotalPss() +
                ", dalvikPss=, " + mi.dalvikPss +
                ", nativeSize=, " + mi.nativePss +
                ", otherPss=, " + mi.otherPss + ", ";

        return Log.i(tag + "-MEMORY", mit + msg);
    }
    return -1;
}
项目:springreplugin    文件:LogDebug.java   
/**
 * 打印当前内存占用日志,方便外界诊断。注意,这会显著消耗性能(约50ms左右)
 *
 * @param tag Used to identify the source of a log message.  It usually identifies
 *            the class or activity where the log call occurs.
 * @param msg The message you would like logged.
 */
public static int printMemoryStatus(String tag, String msg) {
    if (RePluginInternal.FOR_DEV) {
        Debug.MemoryInfo mi = new Debug.MemoryInfo();
        Debug.getMemoryInfo(mi);

        String mit = "desc=, memory_v_0_0_1, process=, " + IPC.getCurrentProcessName() +
                ", totalPss=, " + mi.getTotalPss() +
                ", dalvikPss=, " + mi.dalvikPss +
                ", nativeSize=, " + mi.nativePss +
                ", otherPss=, " + mi.otherPss + ", ";

        return Log.i(tag + "-MEMORY", mit + msg);
    }
    return -1;
}
项目: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;
}
项目:Swap    文件:PLA_AbsListView.java   
void start(int initialVelocity) {
    initialVelocity = modifyFlingInitialVelocity(initialVelocity);

    int initialY = initialVelocity < 0 ? Integer.MAX_VALUE : 0;
    mLastFlingY = initialY;
    mScroller.fling(0, initialY, 0, initialVelocity,
            0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE);

    mTouchMode = TOUCH_MODE_FLING;
    post(this);

    if (PROFILE_FLINGING) {
        if (!mFlingProfilingStarted) {
            Debug.startMethodTracing("AbsListViewFling");
            mFlingProfilingStarted = true;
        }
    }
}
项目:CuiMarket    文件:SystemUtils.java   
/** 获取指定包名应用占用的内存,单位为byte */
public static long getUsedMemory(String packageName) {
    Context context = UIUtils.getContext();
    if (context == null) {
        return -1;
    }
    if (StringUtils.isEmpty(packageName)) {
        packageName = context.getPackageName();
    }
    long size = 0;
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    List<ActivityManager.RunningAppProcessInfo> runapps = activityManager.getRunningAppProcesses();
    for (ActivityManager.RunningAppProcessInfo runapp : runapps) { // 遍历运行中的程序
        if (packageName.equals(runapp.processName)) {// 得到程序进程名,进程名一般就是包名,但有些程序的进程名并不对应一个包名
            // 返回指定PID程序的内存信息,可以传递多个PID,返回的也是数组型的信息
            Debug.MemoryInfo[] processMemoryInfo = activityManager.getProcessMemoryInfo(new int[]{runapp.pid});
            // 得到内存信息中已使用的内存,单位是K
            size = processMemoryInfo[0].getTotalPrivateDirty() * 1024;
        }
    }
    return size;
}
项目:AndroidPerformanceMonitor    文件:LooperMonitor.java   
@Override
public void println(String x) {
    if (mStopWhenDebugging && Debug.isDebuggerConnected()) {
        return;
    }
    if (!mPrintingStarted) {
        mStartTimestamp = System.currentTimeMillis();
        mStartThreadTimestamp = SystemClock.currentThreadTimeMillis();
        mPrintingStarted = true;
        startDump();
    } else {
        final long endTime = System.currentTimeMillis();
        mPrintingStarted = false;
        if (isBlock(endTime)) {
            notifyBlockEvent(endTime);
        }
        stopDump();
    }
}
项目:zjdroid    文件:HeapDump.java   
public static void dumpHeap(String filename) {
    try {
        Debug.dumpHprofData(filename);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
项目:KitchenSecret_Android    文件:PLA_AbsListView.java   
void start(int initialVelocity) {
    initialVelocity = modifyFlingInitialVelocity(initialVelocity);

    int initialY = initialVelocity < 0 ? Integer.MAX_VALUE : 0;
    mLastFlingY = initialY;
    mScroller.fling(0, initialY, 0, initialVelocity, 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE);

    if (DEBUG)
        Log.d(TAG, String.format("String Fling: [%d, %d] to [%d]", initialY, initialVelocity, mScroller.getFinalY()));

    mTouchMode = TOUCH_MODE_FLING;
    post(this);

    if (PROFILE_FLINGING) {
        if (!mFlingProfilingStarted) {
            Debug.startMethodTracing("AbsListViewFling");
            mFlingProfilingStarted = true;
        }
    }
}
项目:AndroidChromium    文件:GSAServiceClient.java   
/**
 * Get the PSS used by the process hosting a service.
 *
 * @param packageName Package name of the service to search for.
 * @return the PSS in kB of the process hosting a service, or INVALID_PSS.
 */
@VisibleForTesting
static int getPssForService(ComponentName componentName) {
    if (componentName == null) return INVALID_PSS;
    Context context = ContextUtils.getApplicationContext();
    ActivityManager activityManager =
            (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    List<ActivityManager.RunningServiceInfo> services =
            activityManager.getRunningServices(1000);
    if (services == null) return INVALID_PSS;
    int pid = -1;
    for (ActivityManager.RunningServiceInfo info : services) {
        if (componentName.equals(info.service)) {
            pid = info.pid;
            break;
        }
    }
    if (pid == -1) return INVALID_PSS;
    Debug.MemoryInfo infos[] = activityManager.getProcessMemoryInfo(new int[] {pid});
    if (infos == null || infos.length == 0) return INVALID_PSS;
    return infos[0].getTotalPss();
}
项目:replicaisland    文件:AndouKun.java   
@Override
protected void onPause() {
    super.onPause();
    DebugLog.d("AndouKun", "onPause");

    hidePauseMessage();

    mGame.onPause();
    mGLSurfaceView.onPause();
    mGame.getRenderer().onPause();  // hack!

    if (mMethodTracing) {
        Debug.stopMethodTracing();
        mMethodTracing = false;
    }
    if (mSensorManager != null) {
        mSensorManager.unregisterListener(this);
    }
}
项目:SimplifyReader2    文件:PLAAbsListView.java   
void start(int initialVelocity) {
    initialVelocity = modifyFlingInitialVelocity(initialVelocity);

    int initialY = initialVelocity < 0 ? Integer.MAX_VALUE : 0;
    mLastFlingY = initialY;
    mScroller.fling(0, initialY, 0, initialVelocity,
            0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE);

    mTouchMode = TOUCH_MODE_FLING;
    post(this);

    if (PROFILE_FLINGING) {
        if (!mFlingProfilingStarted) {
            Debug.startMethodTracing("AbsListViewFling");
            mFlingProfilingStarted = true;
        }
    }
}
项目:AppTroy    文件:RedClock.java   
public void antiDebug() {
        try {
//            Debug.isDebuggerConnected();
            Method isDebuggerConnected = Debug.class.getMethod("isDebuggerConnected");
            XposedBridge.hookMethod(isDebuggerConnected, new XC_MethodHook() {
                @Override
                protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                    super.afterHookedMethod(param);
//                    Log.d("cc", "set isDebuggerConnected false");
                    param.setResult(false);
                }
            });
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
    }
项目:offloading-framework-android    文件:ProgramProfiler.java   
public void stopAndCollectExecutionInfoTracking() {
    profilersRunning--;
    mIcount.stopInstructionCounting();
    instructionCount = mIcount.instructionsExecuted;
    methodInvocationCount = mIcount.methodsExecuted;
    threadAllocSize = Debug.getThreadAllocSize() - mStartThreadAllocSize;
    gcThreadInvocationCount = Debug.getThreadGcInvocationCount() - mStartThreadGcInvocationCount;
    gcGlobalInvocationCount = Debug.getGlobalGcInvocationCount() - mStartGlobalGcInvocationCount;

    if (profilersRunning == 0) {
        Debug.stopAllocCounting();
        memAllocTrackerRunning = false;
    }

    threadCpuTime = Debug.threadCpuTimeNanos() - mStartThreadCpuTime;
    execTime = System.nanoTime() - mStartTime;

    Log.d(TAG, methodName + ": Thread Alloc Size - "
            + (Debug.getThreadAllocSize() - mStartThreadAllocSize));
    Log.d(TAG, methodName
            + "Total instructions executed: " + instructionCount
            + " Method invocations: " + methodInvocationCount + "in "
            + execTime / 1000000 + "ms");
}
项目:ksyhttpcache_android    文件:QosThread.java   
@Override
public void run() {
    while(mRunning) {
        mCpuStats.parseTopResults();

        Debug.getMemoryInfo(mi);

        if(mHandler != null) {
            mQosObject.cpuUsage = mCpuStats.getProcessCpuUsage();
            mQosObject.pss = mi.getTotalPss();
            mQosObject.vss = mi.getTotalPrivateDirty();
            mHandler.obtainMessage(VideoPlayerActivity.UPDATE_QOSMESS, mQosObject).sendToTarget();
        }
        try {
            sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
项目:hackerskeyboard    文件:LatinIME.java   
@Override
public void hideWindow() {
    LatinImeLogger.commit();
    onAutoCompletionStateChanged(false);

    if (TRACE)
        Debug.stopMethodTracing();
    if (mOptionsDialog != null && mOptionsDialog.isShowing()) {
        mOptionsDialog.dismiss();
        mOptionsDialog = null;
    }
    mWordToSuggestions.clear();
    mWordHistory.clear();
    super.hideWindow();
    TextEntryState.endSession();
}
项目:adventcalendar_2015_mincomi    文件:SurfaceBitmapView.java   
@Override
public void run() {
    while (!mIsFinished && count < COUNT) {
        Canvas canvas = getHolder().lockCanvas();
        if (canvas == null) {
            return;
        }

        long start = Debug.threadCpuTimeNanos();

        canvas.drawBitmap(mBitmap, 0, 0, PAINT);

        long elapsed = Debug.threadCpuTimeNanos() - start;
        elapsedTime += elapsed;

        getHolder().unlockCanvasAndPost(canvas);

        count++;
    }

    Log.d(TAG, String.format(Locale.US, "elapsedTime:%d, avg:%.2f (ns)", elapsedTime, ((float) elapsedTime / count)));

}
项目:adventcalendar_2015_mincomi    文件:BitmapView.java   
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    long start = Debug.threadCpuTimeNanos();

    canvas.drawBitmap(mBitmap, 0, 0, PAINT);

    long elapsed = Debug.threadCpuTimeNanos() - start;
    elapsedTime += elapsed;

    count++;

    if (count < COUNT) {
        invalidate();
    } else {
        Log.d(TAG, String.format(Locale.US, "elapsedTime:%d, avg:%.2f (ns)", elapsedTime, ((float) elapsedTime / count)));

    }
}
项目:FMTech    文件:gec.java   
public static rgv a(Debug.MemoryInfo paramMemoryInfo)
{
  rgv localrgv = new rgv();
  localrgv.a = Integer.valueOf(paramMemoryInfo.dalvikPss);
  localrgv.b = Integer.valueOf(paramMemoryInfo.nativePss);
  localrgv.c = Integer.valueOf(paramMemoryInfo.otherPss);
  localrgv.d = Integer.valueOf(paramMemoryInfo.dalvikPrivateDirty);
  localrgv.e = Integer.valueOf(paramMemoryInfo.nativePrivateDirty);
  localrgv.f = Integer.valueOf(paramMemoryInfo.otherPrivateDirty);
  if (Build.VERSION.SDK_INT >= 19)
  {
    localrgv.g = Integer.valueOf(paramMemoryInfo.getTotalPrivateClean());
    localrgv.i = Integer.valueOf(paramMemoryInfo.getTotalSwappablePss());
  }
  localrgv.h = Integer.valueOf(paramMemoryInfo.getTotalSharedDirty());
  return localrgv;
}
项目:SimplifyReader    文件:PLAAbsListView.java   
void start(int initialVelocity) {
    initialVelocity = modifyFlingInitialVelocity(initialVelocity);

    int initialY = initialVelocity < 0 ? Integer.MAX_VALUE : 0;
    mLastFlingY = initialY;
    mScroller.fling(0, initialY, 0, initialVelocity,
            0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE);

    mTouchMode = TOUCH_MODE_FLING;
    post(this);

    if (PROFILE_FLINGING) {
        if (!mFlingProfilingStarted) {
            Debug.startMethodTracing("AbsListViewFling");
            mFlingProfilingStarted = true;
        }
    }
}
项目:EasyFrame    文件:PLA_AbsListView.java   
void start(int initialVelocity) {
    initialVelocity = modifyFlingInitialVelocity(initialVelocity);

    int initialY = initialVelocity < 0 ? Integer.MAX_VALUE : 0;
    mLastFlingY = initialY;
    mScroller.fling(0, initialY, 0, initialVelocity,
            0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE);

    mTouchMode = TOUCH_MODE_FLING;
    post(this);

    if (PROFILE_FLINGING) {
        if (!mFlingProfilingStarted) {
            Debug.startMethodTracing("AbsListViewFling");
            mFlingProfilingStarted = true;
        }
    }
}
项目:topodroid    文件:TopoDroidApp.java   
void startupStep2()
{
  // ***** LOG FRAMEWORK
  TDLog.setLogTarget();
  TDLog.loadLogPreferences( mPrefs );

  mData.compileStatements();

  PtCmapActivity.setMap( mPrefs.getString( "DISTOX_PT_CMAP", null ) );

  TDSetting.loadSecondaryPreferences( this, mPrefs );
  checkAutoPairing();

  if ( TDLog.LOG_DEBUG ) {
    isTracing = true;
    Debug.startMethodTracing("DISTOX");
  }

  mPrefs.registerOnSharedPreferenceChangeListener( this );
  // TDLog.Debug("ready");
}
项目:365browser    文件:GSAServiceClient.java   
/**
 * Get the PSS used by the process hosting a service.
 *
 * @param packageName Package name of the service to search for.
 * @return the PSS in kB of the process hosting a service, or INVALID_PSS.
 */
@VisibleForTesting
static int getPssForService(ComponentName componentName) {
    if (componentName == null) return INVALID_PSS;
    Context context = ContextUtils.getApplicationContext();
    ActivityManager activityManager =
            (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    List<ActivityManager.RunningServiceInfo> services =
            activityManager.getRunningServices(1000);
    if (services == null) return INVALID_PSS;
    int pid = -1;
    for (ActivityManager.RunningServiceInfo info : services) {
        if (componentName.equals(info.service)) {
            pid = info.pid;
            break;
        }
    }
    if (pid == -1) return INVALID_PSS;
    Debug.MemoryInfo infos[] = activityManager.getProcessMemoryInfo(new int[] {pid});
    if (infos == null || infos.length == 0) return INVALID_PSS;
    return infos[0].getTotalPss();
}
项目:S1-Go    文件:BlockPrinter.java   
@Override
public void println(String x) {
    this.mStartedPrinting = !this.mStartedPrinting;
    if (this.mStartedPrinting) {
        this.mDebuggerConnected = Debug.isDebuggerConnected();
    }

    if (this.mDebuggerConnected) {
        if (this.mStartedPrinting) {
            this.mStartUpTime = SystemClock.uptimeMillis();
            this.mStartThreadTime = SystemClock.currentThreadTimeMillis();
            this.mLooperLog = x;
            this.beginTrace(this.mStartUpTime);
        } else {
            long costTime = SystemClock.uptimeMillis() - this.mStartUpTime;
            this.endTrace();
            if (this.isBlock(costTime)) {
                this.notifyBlock(costTime);
            }
        }
    }
}
项目:platform-external-replicaisland    文件:AndouKun.java   
@Override
protected void onPause() {
    super.onPause();
    DebugLog.d("AndouKun", "onPause");

    hidePauseMessage();

    mGame.onPause();
    mGLSurfaceView.onPause();
    mGame.getRenderer().onPause();  // hack!

    if (mMethodTracing) {
        Debug.stopMethodTracing();
        mMethodTracing = false;
    }
    if (mSensorManager != null) {
        mSensorManager.unregisterListener(this);
    }
}
项目:iLocker    文件:LockCPicturePatternView.java   
private void handleActionDown(MotionEvent event) {
    resetPattern();
    final float x = event.getX();
    final float y = event.getY();
    final Cell hitCell = detectAndAddHit(x, y);
    if (hitCell != null) {
        mPatternInProgress = true;
        mPatternDisplayMode = DisplayMode.Right;
        notifyPatternStarted();
    } else {
        mPatternInProgress = false;
        notifyPatternCleared();
    }
    if (hitCell != null) {
        invalidate();
    }
    mInProgressX = x;
    mInProgressY = y;
    if (PROFILE_DRAWING) {
        if (!mDrawingProfilingStarted) {
            Debug.startMethodTracing("LockPatternDrawing");
            mDrawingProfilingStarted = true;
        }
    }
}
项目:Lay-s    文件:PLAAbsListView.java   
void start(int initialVelocity) {
    initialVelocity = modifyFlingInitialVelocity(initialVelocity);

    int initialY = initialVelocity < 0 ? Integer.MAX_VALUE : 0;
    mLastFlingY = initialY;
    mScroller.fling(0, initialY, 0, initialVelocity,
            0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE);

    mTouchMode = TOUCH_MODE_FLING;
    post(this);

    if (PROFILE_FLINGING) {
        if (!mFlingProfilingStarted) {
            Debug.startMethodTracing("AbsListViewFling");
            mFlingProfilingStarted = true;
        }
    }
}
项目:GooglePlay    文件:SystemUtils.java   
/** 获取指定包名应用占用的内存,单位为byte */
public static long getUsedMemory(String packageName) {
    Context context = UIUtils.getContext();
    if (context == null) {
        return -1;
    }
    if (StringUtils.isEmpty(packageName)) {
        packageName = context.getPackageName();
    }
    long size = 0;
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    List<ActivityManager.RunningAppProcessInfo> runapps = activityManager.getRunningAppProcesses();
    for (ActivityManager.RunningAppProcessInfo runapp : runapps) { // 遍历运行中的程序
        if (packageName.equals(runapp.processName)) {// 得到程序进程名,进程名一般就是包名,但有些程序的进程名并不对应一个包名
            // 返回指定PID程序的内存信息,可以传递多个PID,返回的也是数组型的信息
            Debug.MemoryInfo[] processMemoryInfo = activityManager.getProcessMemoryInfo(new int[]{runapp.pid});
            // 得到内存信息中已使用的内存,单位是K
            size = processMemoryInfo[0].getTotalPrivateDirty() * 1024;
        }
    }
    return size;
}
项目:fresco    文件:MainActivity.java   
private void updateStats() {
  final Runtime runtime = Runtime.getRuntime();
  final long heapMemory = runtime.totalMemory() - runtime.freeMemory();
  final StringBuilder sb = new StringBuilder(DEFAULT_MESSAGE_SIZE);
  // When changing format of output below, make sure to sync "run_comparison.py" as well
  sb.append("Heap: ");
  appendSize(sb, heapMemory);
  sb.append(" Java ");
  appendSize(sb, Debug.getNativeHeapSize());
  sb.append(" native\n");
  appendTime(sb, "Avg wait time: ", mPerfListener.getAverageWaitTime(), "\n");
  appendNumber(sb, "Requests: ", mPerfListener.getOutstandingRequests(), " outsdng ");
  appendNumber(sb, "", mPerfListener.getCancelledRequests(), " cncld\n");
  final String message = sb.toString();
  mStatsDisplay.setText(message);
  FLog.i(TAG, message);
}
项目:leakcanary-for-eclipse    文件:AndroidHeapDumper.java   
@Override
public File dumpHeap() {
   if (!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.");
     // Heap analysis in progress, let's not put too much pressure on the device.
     return null;
   }
   try {
     Debug.dumpHprofData(heapDumpFile.getAbsolutePath());
     return heapDumpFile;
   } catch (IOException e) {
     cleanup();
     Log.e(TAG, "Could not perform heap dump", e);
     // Abort heap dump
     return null;
   }
 }
项目:GitHub    文件:PerformanceTest.java   
protected void runOneByOneTests(List<T> list, int loadCount, int modifyCount) {
    dao.insertInTx(list);
    List<K> keys = new ArrayList<K>(loadCount);
    for (int i = 0; i < loadCount; i++) {
        keys.add(daoAccess.getKey(list.get(i)));
    }
    clearIdentityScopeIfAny();

    list = runLoadOneByOne(keys, "load-one-by-one-1");
    list = runLoadOneByOne(keys, "load-one-by-one-2");
    Debug.stopMethodTracing();

    dao.deleteAll();

    startClock("insert-one-by-one");
    for (int i = 0; i < modifyCount; i++) {
        dao.insert(list.get(i));
    }
    stopClock();

    startClock("update-one-by-one");
    for (int i = 0; i < modifyCount; i++) {
        dao.update(list.get(i));
    }
    stopClock();

    startClock("delete-one-by-one");
    for (int i = 0; i < modifyCount; i++) {
        dao.delete(list.get(i));
    }
    stopClock();
}
项目:DebugOverlay-Android    文件:MemInfoDataModule.java   
@Override
public void run() {
    ActivityManager.MemoryInfo systemMemInfo = new ActivityManager.MemoryInfo();
    am.getMemoryInfo(systemMemInfo);
    Debug.MemoryInfo processMemInfo = am.getProcessMemoryInfo(new int[]{Process.myPid()})[0];
    memInfo = new MemInfo(systemMemInfo, processMemInfo);
    notifyObservers();
    handler.postDelayed(memInfoQueryRunnable, interval);
}
项目:DebugOverlay-Android    文件:MemInfoViewModule.java   
@Override
public void onDataAvailable(MemInfo data) {
    ActivityManager.MemoryInfo systemMemInfo = data.getSystemMemInfo();
    Debug.MemoryInfo procMemInfo = data.getProcessMemInfo();

    if (DebugOverlay.isDebugLoggingEnabled()) {
        Log.d(TAG, "MemTotal(MB):" + DECIMAL_FORMAT.format(systemMemInfo.totalMem / 1048576f));
        Log.d(TAG, "MemAvail(MB):" + DECIMAL_FORMAT.format(systemMemInfo.availMem / 1048576f));
        Log.d(TAG, "MemThreshold(MB):" + DECIMAL_FORMAT.format(systemMemInfo.threshold / 1048576f));
        Log.d(TAG, "TotalPss(MB):" + DECIMAL_FORMAT.format(procMemInfo.getTotalPss() / 1024f));
        Log.d(TAG, "TotalPrivateDirty(MB):" + DECIMAL_FORMAT.format(procMemInfo.getTotalPrivateDirty() / 1024f));
    }

    if (memInfoTxtView != null) {
        StringBuilder builder = new StringBuilder(HEADER);
        builder.append(DECIMAL_FORMAT.format(systemMemInfo.availMem / 1048576f)).append(" ")
                .append(DECIMAL_FORMAT.format(procMemInfo.getTotalPss() / 1024f)).append(" ")
                .append(DECIMAL_FORMAT.format(procMemInfo.getTotalPrivateDirty() / 1024f));

        SpannableStringBuilder spannableBuilder = new SpannableStringBuilder(builder.toString());
        if (systemMemInfo.lowMemory) {
            spannableBuilder.setSpan(
                    new TextAppearanceSpan(memInfoTxtView.getContext(), R.style.debugoverlay_LowMemoryTextAppearance),
                    HEADER.length(),
                    spannableBuilder.length(),
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
            );
        }
        memInfoTxtView.setText(spannableBuilder);
    }
}
项目:ceji_android    文件:Configuration.java   
public static double getBitmapMemoryUsage() {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            return getMemoryUsage();
        }

        long max = Runtime.getRuntime().maxMemory();
        long used = Debug.getNativeHeapAllocatedSize();

        return (double) used / (double) max;
    }
项目:keepass2android    文件:KP2AKeyboard.java   
@Override
public void hideWindow() {
    LatinImeLogger.commit();
    onAutoCompletionStateChanged(false);

    if (TRACE) Debug.stopMethodTracing();
    if (mOptionsDialog != null && mOptionsDialog.isShowing()) {
        mOptionsDialog.dismiss();
        mOptionsDialog = null;
    }
    mWordToSuggestions.clear();
    mWordHistory.clear();
    super.hideWindow();
    TextEntryState.endSession();
}