Java Code Examples for android.os.Debug#isDebuggerConnected()
The following examples show how to use
android.os.Debug#isDebuggerConnected() .
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: BlockMonitorManager.java From DoraemonKit with Apache License 2.0 | 6 votes |
/** * 通知卡顿 * * @param blockInfo */ void notifyBlockEvent(BlockInfo blockInfo) { blockInfo.concernStackString = BlockCanaryUtils.concernStackString(mContext, blockInfo); blockInfo.time = System.currentTimeMillis(); if (!TextUtils.isEmpty(blockInfo.concernStackString)) { //卡顿 debug模式下会造成卡顿 if (DokitConstant.APP_HEALTH_RUNNING && !Debug.isDebuggerConnected()) { addBlockInfoInAppHealth(blockInfo); } showNotification(blockInfo); if (mBlockInfoList.size() > MAX_SIZE) { mBlockInfoList.remove(0); } mBlockInfoList.add(blockInfo); if (mOnBlockInfoUpdateListener != null) { mOnBlockInfoUpdateListener.onBlockInfoUpdate(blockInfo); } } }
Example 2
Source File: EventProcessor.java From StallBuster with Apache License 2.0 | 6 votes |
@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; }
Example 3
Source File: LooperMonitor.java From AndroidPerformanceMonitor with Apache License 2.0 | 6 votes |
@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(); } }
Example 4
Source File: DebuggerWaiter.java From deagle with Apache License 2.0 | 5 votes |
void doWait() { Log.d(TAG, "Start waiting for debugger..."); mWaitingThread.start(); try { synchronized (mSignal) { mSignal.wait(WAITING_TIMEOUT); } } catch (final InterruptedException ignored) {} if (Debug.isDebuggerConnected()) Log.d(TAG, "Debugger connected."); else Log.d(TAG, "Resume without debugger."); }
Example 5
Source File: StepDefinitions.java From CleanGUITestArchitecture with MIT License | 5 votes |
/** * Wait for the debugger to be manually attached to this running process. * Use this to debug test execution by adding this step to your test scenario and * when the test is running in Android Studio choose menu "Run - Attach debugger to Android process", * finally select the name of your app package from the list of processes displayed. */ @Given("^I wait for manual attachment of the debugger$") public void wait_for_manual_attachment_of_debugger() throws InterruptedException { while (!Debug.isDebuggerConnected()) { Thread.sleep(1000); } }
Example 6
Source File: CCMonitor.java From CC with Apache License 2.0 | 5 votes |
/** * 执行 timeout() * 注意:如果处于程序调试状态和CC.DEBUG是true, * 两个都满足情况下,不执行超时 timeout() * @param cc */ private void executeTimeout(CC cc) { if (!CC.DEBUG) { cc.timeout(); return; } if (!Debug.isDebuggerConnected()) { cc.timeout(); } }
Example 7
Source File: DebuggedCheck.java From jail-monkey with MIT License | 5 votes |
/** * Checks if the device is in debug mode. * * @return <code>true</code> if the device is debug mode, <code>false</code> otherwise. */ public static boolean isDebugged(Context context) { if (Debug.isDebuggerConnected()) { return true; } return (context.getApplicationContext().getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; }
Example 8
Source File: DebugUtils.java From android-utils with Apache License 2.0 | 5 votes |
/** * Keep screen on while debugging. * * @param activity the activity * @param debugging the debugging */ public static void keepScreenOnWhileDebugging(Activity activity, boolean debugging) { if (debugging) { // don't even consider it otherwise if (Debug.isDebuggerConnected()) { Log.d("SCREEN", "Keeping screen on for debugging, detach debugger and force an onResume to turn it off."); activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } else { activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); Log.d("SCREEN", "Keeping screen on for debugging is now deactivated."); } } }
Example 9
Source File: AndroidDebuggerControl.java From leakcanary-for-eclipse with MIT License | 4 votes |
@Override public boolean isDebuggerAttached() { return Debug.isDebuggerConnected(); }
Example 10
Source File: ANRWatchDog.java From sentry-android with MIT License | 4 votes |
@Override public void run() { setName("|ANR-WatchDog|"); long interval = timeoutIntervalMillis; while (!isInterrupted()) { boolean needPost = tick.get() == 0; tick.addAndGet(interval); if (needPost) { uiHandler.post(ticker); } try { Thread.sleep(interval); } catch (InterruptedException e) { Thread.currentThread().interrupt(); logger.log(SentryLevel.WARNING, "Interrupted: %s", e.getMessage()); return; } // If the main thread has not handled ticker, it is blocked. ANR. if (tick.get() != 0 && !reported.get()) { if (!reportInDebug && (Debug.isDebuggerConnected() || Debug.waitingForDebugger())) { logger.log( SentryLevel.DEBUG, "An ANR was detected but ignored because the debugger is connected."); reported.set(true); continue; } // we only raise an ANR event if the process is in ANR state. // if ActivityManager is not available, we'll still be able to send ANRs final ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); if (am != null) { final List<ActivityManager.ProcessErrorStateInfo> processesInErrorState = am.getProcessesInErrorState(); // if list is null, there's no process in ANR state. if (processesInErrorState == null) { continue; } boolean isAnr = false; for (ActivityManager.ProcessErrorStateInfo item : processesInErrorState) { if (item.condition == NOT_RESPONDING) { isAnr = true; break; } } if (!isAnr) { continue; } } logger.log(SentryLevel.INFO, "Raising ANR"); final String message = "Application Not Responding for at least " + timeoutIntervalMillis + " ms."; final ApplicationNotResponding error = new ApplicationNotResponding(message, uiHandler.getThread()); anrListener.onAppNotResponding(error); interval = timeoutIntervalMillis; reported.set(true); } } }
Example 11
Source File: Scene.java From WorldmapLibrary with MIT License | 4 votes |
/** Fill the bitmap with the part of the scene referenced by the viewport Rect */ void update(Viewport viewport){ Bitmap bitmap = null; // If this is null at the bottom, then load from the sample synchronized(this){ switch(getState()){ case UNINITIALIZED: // nothing can be done -- should never get here return; case INITIALIZED: // time to cache some data setState(CacheState.START_UPDATE); cacheThread.interrupt(); break; case START_UPDATE: // I already told the thread to start break; case IN_UPDATE: // Already reading some data, just use the sample break; case SUSPEND: // Loading from cache suspended. break; case READY: // I have some data to show if (bitmapRef==null){ // Start the cache off right if (Debug.isDebuggerConnected()) Log.d(TAG,"bitmapRef is null"); setState(CacheState.START_UPDATE); cacheThread.interrupt(); } else if (!window.contains(viewport.window)){ if (Debug.isDebuggerConnected()) Log.d(TAG,"viewport not in cache"); setState(CacheState.START_UPDATE); cacheThread.interrupt(); } else { // Happy case -- the cache already contains the Viewport bitmap = bitmapRef; } break; } } if (bitmap==null) loadSampleIntoViewport(); else loadBitmapIntoViewport(bitmap); }
Example 12
Source File: Scene.java From WorldmapLibrary with MIT License | 4 votes |
void setState(CacheState newState){ if (Debug.isDebuggerConnected()) Log.i(TAG,String.format("cacheState old=%s new=%s",state.toString(),newState.toString())); state = newState; }
Example 13
Source File: BlockLooper.java From LLApp with Apache License 2.0 | 4 votes |
@Override public void run() { int lastTickNumber; while (!isStop) { lastTickNumber = tickCounter; uiHandler.post(ticker); try { Thread.sleep(frequency); } catch (InterruptedException e) { e.printStackTrace(); break; } if (lastTickNumber == tickCounter) { if (!ignoreDebugger && Debug.isDebuggerConnected()) { Log.w(TAG, "当前由调试模式引起消息阻塞引起ANR,可以通过setIgnoreDebugger(true)来忽略调试模式造成的ANR"); continue; } BlockError blockError; if (!reportAllThreadInfo) { blockError = BlockError.getUiThread(); } else { blockError = BlockError.getAllThread(); } if (onBlockListener != null) { onBlockListener.onBlock(blockError); } if (saveLog) { if (SdCradUtils.isSDCardEnable()) { File logDir = getLogDirectory(); saveLogToSdcard(blockError, logDir); } else { Log.w(TAG, "sdcard is unmounted"); } } } } }
Example 14
Source File: CommonUtils.java From letv with Apache License 2.0 | 4 votes |
public static boolean isDebuggerAttached() { return Debug.isDebuggerConnected() || Debug.waitingForDebugger(); }
Example 15
Source File: BlockLooper.java From AndroidPerformanceTools with Apache License 2.0 | 4 votes |
@Override public void run() { int lastTickNumber; while (!isStop) { lastTickNumber = tickCounter; uiHandler.post(ticker); try { Thread.sleep(frequency); } catch (InterruptedException e) { e.printStackTrace(); break; } if (lastTickNumber == tickCounter) { if (!ignoreDebugger && Debug.isDebuggerConnected()) { Log.w(TAG, "当前由调试模式引起消息阻塞引起ANR,可以通过setIgnoreDebugger(true)来忽略调试模式造成的ANR"); continue; } BlockError blockError; if (!reportAllThreadInfo) { blockError = BlockError.getUiThread(); } else { blockError = BlockError.getAllThread(); } if (onBlockListener != null) { onBlockListener.onBlock(blockError); } if (saveLog) { if (StorageUtils.isMounted()) { File logDir = getLogDirectory(); saveLogToSdcard(blockError, logDir); } else { Log.w(TAG, "sdcard is unmounted"); } } } } }
Example 16
Source File: CommonUtils.java From firebase-android-sdk with Apache License 2.0 | 4 votes |
public static boolean isDebuggerAttached() { return Debug.isDebuggerConnected() || Debug.waitingForDebugger(); }
Example 17
Source File: AndroidDebuggerControl.java From DoraemonKit with Apache License 2.0 | 4 votes |
@Override public boolean isDebuggerAttached() { return Debug.isDebuggerConnected(); }
Example 18
Source File: FindDebugger.java From BlogDemo with Apache License 2.0 | 4 votes |
/** * Believe it or not, there are packers that use this... */ public static boolean isBeingDebugged() { return Debug.isDebuggerConnected(); }
Example 19
Source File: DisableOnAndroidDebug.java From android-test with Apache License 2.0 | 2 votes |
/** * Returns {@code true} if the VM has a debugger connected. This method may be used by test * classes to take additional action to disable code paths that interfere with debugging if * required. * * @return {@code true} if a debugger is connected, {@code false} otherwise */ public boolean isDebugging() { return Debug.isDebuggerConnected(); }
Example 20
Source File: AndroidDebug.java From AndroidGodEye with Apache License 2.0 | 2 votes |
/** * 是否正在debug * * @return */ public static boolean isDebugging() { return Debug.isDebuggerConnected(); }