List of usage examples for android.os SystemClock elapsedRealtime
@CriticalNative native public static long elapsedRealtime();
From source file:ai.eve.volley.Request.java
/** * Adds an event to this request's event log; for debugging. *//* ww w . jav a2s.c o m*/ public void addMarker(String tag) { if (MarkerLog.ENABLED) { mEventLog.add(tag, Thread.currentThread().getId()); } else if (mRequestBirthTime == 0) { mRequestBirthTime = SystemClock.elapsedRealtime(); } }
From source file:com.cyanogenmod.eleven.provider.LocalizedStore.java
private void rebuildLocaleData(LocaleSet locales) { if (DEBUG) {/*ww w. j av a 2s. com*/ Log.d(TAG, "Locale has changed, rebuilding sorting data"); } final long start = SystemClock.elapsedRealtime(); final SQLiteDatabase db = mMusicDatabase.getWritableDatabase(); db.beginTransaction(); try { db.execSQL("DELETE FROM " + SongSortColumns.TABLE_NAME); db.execSQL("DELETE FROM " + AlbumSortColumns.TABLE_NAME); db.execSQL("DELETE FROM " + ArtistSortColumns.TABLE_NAME); // prep the localization classes mLocaleSetManager.updateLocaleSet(locales); updateLocalizedStore(db, null); // Update the ICU version used to generate the locale derived data // so we can tell when we need to rebuild with new ICU versions. PropertiesStore.getInstance(mContext).storeProperty(PropertiesStore.DbProperties.ICU_VERSION, ICU.getIcuVersion()); PropertiesStore.getInstance(mContext).storeProperty(PropertiesStore.DbProperties.LOCALE, locales.toString()); db.setTransactionSuccessful(); } finally { db.endTransaction(); } if (DEBUG) { Log.i(TAG, "Locale change completed in " + (SystemClock.elapsedRealtime() - start) + "ms"); } }
From source file:de.hero.vertretungsplan.MainActivity.java
public static void setNewAlarm(Context context, boolean set, String interval) { Intent i = new Intent(context, de.hero.vertretungsplan.CheckForUpdates.class); PendingIntent pi = PendingIntent.getService(context, 0, i, 0); AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); am.cancel(pi); // cancel any existing alarms Log.d("MainActivity", "cancelAlarm"); if (set) {/*www. jav a 2s .c om*/ long lngInterval; switch (interval) { case "1/2": lngInterval = AlarmManager.INTERVAL_HALF_HOUR; break; case "1": lngInterval = AlarmManager.INTERVAL_HOUR; break; case "6": lngInterval = AlarmManager.INTERVAL_HALF_DAY / 2; break; case "3": default: lngInterval = AlarmManager.INTERVAL_HOUR * 3; break; } Log.d("MainActivity", "setAlarm " + interval + " Stunden"); am.setInexactRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + AlarmManager.INTERVAL_HALF_HOUR / 3, lngInterval, pi); // For debugging after 10 seconds // am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, // SystemClock.elapsedRealtime() + 25000 , // AlarmManager.INTERVAL_HOUR , pi); } }
From source file:com.directsiding.android.WebActivity.java
@Override protected void onResume() { super.onResume(); // Si la actividad estubo inactiva mas de dos horas, el SIDING deslogea automaticamente al usuario, // entonces para que no pase eso, iniciamos la InitActivity para que se autologee if (SystemClock.elapsedRealtime() - lastTimeStamp > LOGOUT_MILI_TIME) { startActivity(new Intent(this, InitActivity.class)); finish();/*from w w w . ja v a 2 s. co m*/ } }
From source file:com.directsiding.android.WebActivity.java
@Override protected void onPause() { super.onPause(); // guardamos el tiempo en el que salio de la actividad lastTimeStamp = SystemClock.elapsedRealtime(); }
From source file:com.todoroo.astrid.timers.TimerControlSet.java
private void updateChronometer() { timerButton.setImageResource(timerActive() ? R.drawable.ic_pause_24dp : R.drawable.ic_play_arrow_24dp); long elapsed = this.elapsed.getTimeDurationInSeconds() * 1000L; if (timerActive()) { chronometer.setVisibility(View.VISIBLE); elapsed += DateUtilities.now() - timerStarted; chronometer.setBase(SystemClock.elapsedRealtime() - elapsed); if (elapsed > DateUtilities.ONE_DAY) { chronometer.setOnChronometerTickListener(cArg -> { long t = SystemClock.elapsedRealtime() - cArg.getBase(); cArg.setText(DateFormat.format("d'd' h:mm", t)); //$NON-NLS-1$ });// w ww . j a v a 2 s. c o m } chronometer.start(); } else { chronometer.setVisibility(View.GONE); chronometer.stop(); } }
From source file:com.android.cts.verifier.sensors.SignificantMotionTestActivity.java
@SuppressWarnings("unused") public String testAPWakeUpOnSMDTrigger() throws Throwable { SensorTestLogger logger = getTestLogger(); logger.logInstructions(R.string.snsr_significant_motion_ap_suspend); waitForUserToBegin();//from w ww.jav a 2s .c om mVerifier = new TriggerVerifier(); mSensorManager.requestTriggerSensor(mVerifier, mSensorSignificantMotion); long testStartTimeNs = SystemClock.elapsedRealtimeNanos(); Handler handler = new Handler(Looper.getMainLooper()); SuspendStateMonitor suspendStateMonitor = new SuspendStateMonitor(); Intent intent = new Intent(this, AlarmReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0); AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); am.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + ALARM_WAKE_TIME_DELAY_MS, pendingIntent); try { // Wait for the first event to trigger. Device is expected to go into suspend here. mVerifier.verifyEventTriggered(); long eventTimeStampNs = mVerifier.getTimeStampForTriggerEvent(); long endTimeNs = SystemClock.elapsedRealtimeNanos(); long lastWakeupTimeNs = TimeUnit.MILLISECONDS.toNanos(suspendStateMonitor.getLastWakeUpTime()); Assert.assertTrue(getString(R.string.snsr_device_did_not_go_into_suspend), testStartTimeNs < lastWakeupTimeNs && lastWakeupTimeNs < endTimeNs); long timestampDelta = Math.abs(lastWakeupTimeNs - eventTimeStampNs); Assert.assertTrue( String.format(getString(R.string.snsr_device_did_not_wake_up_at_trigger), TimeUnit.NANOSECONDS.toMillis(lastWakeupTimeNs), TimeUnit.NANOSECONDS.toMillis(eventTimeStampNs)), timestampDelta < MAX_ACCEPTABLE_DELAY_EVENT_AP_WAKE_UP_NS); } finally { am.cancel(pendingIntent); suspendStateMonitor.cancel(); mScreenManipulator.turnScreenOn(); playSound(); } return null; }
From source file:com.andrew.apollo.ui.activities.AudioPlayerActivity.java
/** * {@inheritDoc}/* w w w . j a va2 s .c o m*/ */ @Override public void onProgressChanged(final SeekBar bar, final int progress, final boolean fromuser) { if (!fromuser || mService == null) { return; } final long now = SystemClock.elapsedRealtime(); if (now - mLastSeekEventTime > 250) { mLastSeekEventTime = now; mPosOverride = MusicUtils.duration() * progress / 1000; MusicUtils.seek(mPosOverride); if (!mFromTouch) { // refreshCurrentTime(); mPosOverride = -1; } } }
From source file:ai.eve.volley.toolbox.BasicNetwork.java
protected void logError(String what, String url, long start) { long now = SystemClock.elapsedRealtime(); NetroidLog.v("HTTP ERROR(%s) %d ms to fetch %s", what, (now - start), url); }
From source file:com.autonavi.gxdtaojin.toolbox.volley.Request.java
/** * Notifies the request queue that this request has finished (successfully or with error). * <p>/*ww w . ja va 2s . c o m*/ * Also dumps all events from this request's event log; for debugging. * </p> */ void finish(final String tag) { if (mRequestQueue != null) { mRequestQueue.finish(this); } if (MarkerLog.ENABLED) { final long threadId = Thread.currentThread().getId(); if (Looper.myLooper() != Looper.getMainLooper()) { // If we finish marking off of the main thread, we need to // actually do it on the main thread to ensure correct ordering. Handler mainThread = new Handler(Looper.getMainLooper()); mainThread.post(new Runnable() { @Override public void run() { mEventLog.add(tag, threadId); mEventLog.finish(this.toString()); } }); return; } mEventLog.add(tag, threadId); mEventLog.finish(this.toString()); } else { long requestTime = SystemClock.elapsedRealtime() - mRequestBirthTime; if (requestTime >= SLOW_REQUEST_THRESHOLD_MS) { VolleyLog.d("%d ms: %s", requestTime, this.toString()); } } }