Java Code Examples for android.util.TimeUtils#formatDuration()
The following examples show how to use
android.util.TimeUtils#formatDuration() .
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: ActivityMetricsLogger.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private void logAppDisplayed(WindowingModeTransitionInfoSnapshot info) { if (info.type != TYPE_TRANSITION_WARM_LAUNCH && info.type != TYPE_TRANSITION_COLD_LAUNCH) { return; } EventLog.writeEvent(AM_ACTIVITY_LAUNCH_TIME, info.userId, info.activityRecordIdHashCode, info.launchedActivityShortComponentName, info.windowsDrawnDelayMs); StringBuilder sb = mStringBuilder; sb.setLength(0); sb.append("Displayed "); sb.append(info.launchedActivityShortComponentName); sb.append(": "); TimeUtils.formatDuration(info.windowsDrawnDelayMs, sb); Log.i(TAG, sb.toString()); }
Example 2
Source File: ContentProviderConnection.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
public void toClientString(StringBuilder sb) { sb.append(client.toShortString()); sb.append(" s"); sb.append(stableCount); sb.append("/"); sb.append(numStableIncs); sb.append(" u"); sb.append(unstableCount); sb.append("/"); sb.append(numUnstableIncs); if (waiting) { sb.append(" WAITING"); } if (dead) { sb.append(" DEAD"); } long nowReal = SystemClock.elapsedRealtime(); sb.append(" "); TimeUtils.formatDuration(nowReal-createTime, sb); }
Example 3
Source File: PersistentConnection.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
public void dump(String prefix, PrintWriter pw) { synchronized (mLock) { pw.print(prefix); pw.print(mComponentName.flattenToShortString()); pw.print(mBound ? " [bound]" : " [not bound]"); pw.print(mIsConnected ? " [connected]" : " [not connected]"); if (mRebindScheduled) { pw.print(" reconnect in "); TimeUtils.formatDuration((mReconnectTime - injectUptimeMillis()), pw); } pw.println(); pw.print(prefix); pw.print(" Next backoff(sec): "); pw.print(mNextBackoffMs / 1000); } }
Example 4
Source File: JobServiceContext.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@Override public void handleMessage(Message message) { switch (message.what) { case MSG_TIMEOUT: synchronized (mLock) { if (message.obj == mRunningCallback) { handleOpTimeoutLocked(); } else { JobCallback jc = (JobCallback)message.obj; StringBuilder sb = new StringBuilder(128); sb.append("Ignoring timeout of no longer active job"); if (jc.mStoppedReason != null) { sb.append(", stopped "); TimeUtils.formatDuration(sElapsedRealtimeClock.millis() - jc.mStoppedTime, sb); sb.append(" because: "); sb.append(jc.mStoppedReason); } Slog.w(TAG, sb.toString()); } } break; default: Slog.e(TAG, "Unrecognised message: " + message); } }
Example 5
Source File: AsyncTaskLoader.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@Override public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) { super.dump(prefix, fd, writer, args); if (mTask != null) { writer.print(prefix); writer.print("mTask="); writer.print(mTask); writer.print(" waiting="); writer.println(mTask.waiting); } if (mCancellingTask != null) { writer.print(prefix); writer.print("mCancellingTask="); writer.print(mCancellingTask); writer.print(" waiting="); writer.println(mCancellingTask.waiting); } if (mUpdateThrottle != 0) { writer.print(prefix); writer.print("mUpdateThrottle="); TimeUtils.formatDuration(mUpdateThrottle, writer); writer.print(" mLastLoadCompleteTime="); TimeUtils.formatDuration(mLastLoadCompleteTime, SystemClock.uptimeMillis(), writer); writer.println(); } }
Example 6
Source File: PreloadsFileCacheExpirationJobService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
public static void schedule(Context context) { int keepPreloadsMinDays = Resources.getSystem().getInteger( R.integer.config_keepPreloadsMinDays); // Default is 1 week long keepPreloadsMinTimeoutMs = DEBUG ? TimeUnit.MINUTES.toMillis(2) : TimeUnit.DAYS.toMillis(keepPreloadsMinDays); long keepPreloadsMaxTimeoutMs = DEBUG ? TimeUnit.MINUTES.toMillis(3) : TimeUnit.DAYS.toMillis(keepPreloadsMinDays + 1); if (DEBUG) { StringBuilder sb = new StringBuilder("Scheduling expiration job to run in "); TimeUtils.formatDuration(keepPreloadsMinTimeoutMs, sb); Slog.i(TAG, sb.toString()); } JobInfo expirationJob = new JobInfo.Builder(JOB_ID, new ComponentName(context, PreloadsFileCacheExpirationJobService.class)) .setPersisted(true) .setMinimumLatency(keepPreloadsMinTimeoutMs) .setOverrideDeadline(keepPreloadsMaxTimeoutMs) .build(); JobScheduler jobScheduler = context.getSystemService(JobScheduler.class); jobScheduler.schedule(expirationJob); }
Example 7
Source File: PendingIntentRecord.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
public String toString() { if (stringName != null) { return stringName; } StringBuilder sb = new StringBuilder(128); sb.append("PendingIntentRecord{"); sb.append(Integer.toHexString(System.identityHashCode(this))); sb.append(' '); sb.append(key.packageName); sb.append(' '); sb.append(key.typeName()); if (whitelistDuration != null) { sb.append( " (whitelist: "); for (int i = 0; i < whitelistDuration.size(); i++) { if (i != 0) { sb.append(","); } sb.append(Integer.toHexString(System.identityHashCode(whitelistDuration.keyAt(i)))); sb.append(":"); TimeUtils.formatDuration(whitelistDuration.valueAt(i), sb); } sb.append(")"); } sb.append('}'); return stringName = sb.toString(); }
Example 8
Source File: AppTimeTracker.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
public void dump(PrintWriter pw, String prefix, boolean details) { pw.print(prefix); pw.print("mReceiver="); pw.println(mReceiver); pw.print(prefix); pw.print("mTotalTime="); TimeUtils.formatDuration(mTotalTime, pw); pw.println(); for (int i = 0; i < mPackageTimes.size(); i++) { pw.print(prefix); pw.print("mPackageTime:"); pw.print(mPackageTimes.keyAt(i)); pw.print("="); TimeUtils.formatDuration(mPackageTimes.valueAt(i).value, pw); pw.println(); } if (details && mStartedTime != 0) { pw.print(prefix); pw.print("mStartedTime="); TimeUtils.formatDuration(SystemClock.elapsedRealtime(), mStartedTime, pw); pw.println(); pw.print(prefix); pw.print("mStartedPackage="); pw.println(mStartedPackage); } }
Example 9
Source File: DeviceIdleController.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
void exitMaintenanceEarlyIfNeededLocked() { if (mState == STATE_IDLE_MAINTENANCE || mLightState == LIGHT_STATE_IDLE_MAINTENANCE || mLightState == LIGHT_STATE_PRE_IDLE) { if (isOpsInactiveLocked()) { final long now = SystemClock.elapsedRealtime(); if (DEBUG) { StringBuilder sb = new StringBuilder(); sb.append("Exit: start="); TimeUtils.formatDuration(mMaintenanceStartTime, sb); sb.append(" now="); TimeUtils.formatDuration(now, sb); Slog.d(TAG, sb.toString()); } if (mState == STATE_IDLE_MAINTENANCE) { stepIdleStateLocked("s:early"); } else if (mLightState == LIGHT_STATE_PRE_IDLE) { stepLightIdleStateLocked("s:predone"); } else { stepLightIdleStateLocked("s:early"); } } } }
Example 10
Source File: DeviceIdleController.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
void dumpTempWhitelistSchedule(PrintWriter pw, boolean printTitle) { final int size = mTempWhitelistAppIdEndTimes.size(); if (size > 0) { String prefix = ""; if (printTitle) { pw.println(" Temp whitelist schedule:"); prefix = " "; } final long timeNow = SystemClock.elapsedRealtime(); for (int i = 0; i < size; i++) { pw.print(prefix); pw.print("UID="); pw.print(mTempWhitelistAppIdEndTimes.keyAt(i)); pw.print(": "); Pair<MutableLong, String> entry = mTempWhitelistAppIdEndTimes.valueAt(i); TimeUtils.formatDuration(entry.first.value, timeNow, pw); pw.print(" - "); pw.println(entry.second); } } }
Example 11
Source File: PowerManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(getLockLevelString()); sb.append(" '"); sb.append(mTag); sb.append("'"); sb.append(getLockFlagsString()); if (mDisabled) { sb.append(" DISABLED"); } if (mNotifiedAcquired) { sb.append(" ACQ="); TimeUtils.formatDuration(mAcquireTime-SystemClock.uptimeMillis(), sb); } if (mNotifiedLong) { sb.append(" LONG"); } sb.append(" (uid="); sb.append(mOwnerUid); if (mOwnerPid != 0) { sb.append(" pid="); sb.append(mOwnerPid); } if (mWorkSource != null) { sb.append(" ws="); sb.append(mWorkSource); } sb.append(")"); return sb.toString(); }
Example 12
Source File: ServiceRecord.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
void dumpStartList(PrintWriter pw, String prefix, List<StartItem> list, long now) { final int N = list.size(); for (int i=0; i<N; i++) { StartItem si = list.get(i); pw.print(prefix); pw.print("#"); pw.print(i); pw.print(" id="); pw.print(si.id); if (now != 0) { pw.print(" dur="); TimeUtils.formatDuration(si.deliveredTime, now, pw); } if (si.deliveryCount != 0) { pw.print(" dc="); pw.print(si.deliveryCount); } if (si.doneExecutingCount != 0) { pw.print(" dxc="); pw.print(si.doneExecutingCount); } pw.println(""); pw.print(prefix); pw.print(" intent="); if (si.intent != null) pw.println(si.intent.toString()); else pw.println("null"); if (si.neededGrants != null) { pw.print(prefix); pw.print(" neededGrants="); pw.println(si.neededGrants); } if (si.uriPermissions != null) { si.uriPermissions.dump(pw, prefix); } } }
Example 13
Source File: NetworkTimeUpdateService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return; pw.print("PollingIntervalMs: "); TimeUtils.formatDuration(mPollingIntervalMs, pw); pw.print("\nPollingIntervalShorterMs: "); TimeUtils.formatDuration(mPollingIntervalShorterMs, pw); pw.println("\nTryAgainTimesMax: " + mTryAgainTimesMax); pw.print("TimeErrorThresholdMs: "); TimeUtils.formatDuration(mTimeErrorThresholdMs, pw); pw.println("\nTryAgainCounter: " + mTryAgainCounter); pw.println("NTP cache age: " + mTime.getCacheAge()); pw.println("NTP cache certainty: " + mTime.getCacheCertainty()); pw.println(); }
Example 14
Source File: Message.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
String toString(long now) { StringBuilder b = new StringBuilder(); b.append("{ when="); TimeUtils.formatDuration(when - now, b); if (target != null) { if (callback != null) { b.append(" callback="); b.append(callback.getClass().getName()); } else { b.append(" what="); b.append(what); } if (arg1 != 0) { b.append(" arg1="); b.append(arg1); } if (arg2 != 0) { b.append(" arg2="); b.append(arg2); } if (obj != null) { b.append(" obj="); b.append(obj); } b.append(" target="); b.append(target.getClass().getName()); } else { b.append(" barrier="); b.append(arg1); } b.append(" }"); return b.toString(); }
Example 15
Source File: JobStatus.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void formatRunTime(PrintWriter pw, long runtime, long defaultValue, long now) { if (runtime == defaultValue) { pw.print("none"); } else { TimeUtils.formatDuration(runtime - now, pw); } }
Example 16
Source File: ActiveServices.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void dumpServiceLocalLocked(ServiceRecord r) { dumpUserHeaderLocked(r.userId); pw.print(" * "); pw.println(r); if (dumpAll) { r.dump(pw, " "); needSep = true; } else { pw.print(" app="); pw.println(r.app); pw.print(" created="); TimeUtils.formatDuration(r.createRealTime, nowReal, pw); pw.print(" started="); pw.print(r.startRequested); pw.print(" connections="); pw.println(r.connections.size()); if (r.connections.size() > 0) { pw.println(" Connections:"); for (int conni=0; conni<r.connections.size(); conni++) { ArrayList<ConnectionRecord> clist = r.connections.valueAt(conni); for (int i = 0; i < clist.size(); i++) { ConnectionRecord conn = clist.get(i); pw.print(" "); pw.print(conn.binding.intent.intent.getIntent() .toShortString(false, false, false, false)); pw.print(" -> "); ProcessRecord proc = conn.binding.client; pw.println(proc != null ? proc.toShortString() : "null"); } } } } }
Example 17
Source File: AlarmManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
public void dump(PrintWriter pw, String prefix, long nowELAPSED, long nowRTC, SimpleDateFormat sdf) { final boolean isRtc = (type == RTC || type == RTC_WAKEUP); pw.print(prefix); pw.print("tag="); pw.println(statsTag); pw.print(prefix); pw.print("type="); pw.print(type); pw.print(" expectedWhenElapsed="); TimeUtils.formatDuration( expectedWhenElapsed, nowELAPSED, pw); pw.print(" expectedMaxWhenElapsed="); TimeUtils.formatDuration( expectedMaxWhenElapsed, nowELAPSED, pw); pw.print(" whenElapsed="); TimeUtils.formatDuration(whenElapsed, nowELAPSED, pw); pw.print(" maxWhenElapsed="); TimeUtils.formatDuration(maxWhenElapsed, nowELAPSED, pw); pw.print(" when="); if (isRtc) { pw.print(sdf.format(new Date(when))); } else { TimeUtils.formatDuration(when, nowELAPSED, pw); } pw.println(); pw.print(prefix); pw.print("window="); TimeUtils.formatDuration(windowLength, pw); pw.print(" repeatInterval="); pw.print(repeatInterval); pw.print(" count="); pw.print(count); pw.print(" flags=0x"); pw.println(Integer.toHexString(flags)); if (alarmClock != null) { pw.print(prefix); pw.println("Alarm clock:"); pw.print(prefix); pw.print(" triggerTime="); pw.println(sdf.format(new Date(alarmClock.getTriggerTime()))); pw.print(prefix); pw.print(" showIntent="); pw.println(alarmClock.getShowIntent()); } pw.print(prefix); pw.print("operation="); pw.println(operation); if (listener != null) { pw.print(prefix); pw.print("listener="); pw.println(listener.asBinder()); } }
Example 18
Source File: JobPackageTracker.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
public boolean dumpHistory(PrintWriter pw, String prefix, int filterUid) { final int size = mEventIndices.size(); if (size <= 0) { return false; } pw.println(" Job history:"); final long now = sElapsedRealtimeClock.millis(); for (int i=0; i<size; i++) { final int index = mEventIndices.indexOf(i); final int uid = mEventUids[index]; if (filterUid != -1 && filterUid != UserHandle.getAppId(uid)) { continue; } final int cmd = mEventCmds[index] & EVENT_CMD_MASK; if (cmd == EVENT_NULL) { continue; } final String label; switch (cmd) { case EVENT_START_JOB: label = " START"; break; case EVENT_STOP_JOB: label = " STOP"; break; case EVENT_START_PERIODIC_JOB: label = "START-P"; break; case EVENT_STOP_PERIODIC_JOB: label = " STOP-P"; break; default: label = " ??"; break; } pw.print(prefix); TimeUtils.formatDuration(mEventTimes[index]-now, pw, TimeUtils.HUNDRED_DAY_FIELD_LEN); pw.print(" "); pw.print(label); pw.print(": #"); UserHandle.formatUid(pw, uid); pw.print("/"); pw.print(mEventJobIds[index]); pw.print(" "); pw.print(mEventTags[index]); if (cmd == EVENT_STOP_JOB || cmd == EVENT_STOP_PERIODIC_JOB) { pw.print(" "); final String reason = mEventReasons[index]; if (reason != null) { pw.print(mEventReasons[index]); } else { pw.print(JobParameters.getReasonName((mEventCmds[index] & EVENT_STOP_REASON_MASK) >> EVENT_STOP_REASON_SHIFT)); } } pw.println(); } return true; }
Example 19
Source File: JobPackageTracker.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
void dump(PrintWriter pw, String header, String prefix, long now, long nowElapsed, int filterUid) { final long period = getTotalTime(now); pw.print(prefix); pw.print(header); pw.print(" at "); pw.print(DateFormat.format("yyyy-MM-dd-HH-mm-ss", mStartClockTime).toString()); pw.print(" ("); TimeUtils.formatDuration(mStartElapsedTime, nowElapsed, pw); pw.print(") over "); TimeUtils.formatDuration(period, pw); pw.println(":"); final int NE = mEntries.size(); for (int i = 0; i < NE; i++) { int uid = mEntries.keyAt(i); if (filterUid != -1 && filterUid != UserHandle.getAppId(uid)) { continue; } ArrayMap<String, PackageEntry> uidMap = mEntries.valueAt(i); final int NP = uidMap.size(); for (int j = 0; j < NP; j++) { PackageEntry pe = uidMap.valueAt(j); pw.print(prefix); pw.print(" "); UserHandle.formatUid(pw, uid); pw.print(" / "); pw.print(uidMap.keyAt(j)); pw.println(":"); pw.print(prefix); pw.print(" "); printDuration(pw, period, pe.getPendingTime(now), pe.pendingCount, "pending"); printDuration(pw, period, pe.getActiveTime(now), pe.activeCount, "active"); printDuration(pw, period, pe.getActiveTopTime(now), pe.activeTopCount, "active-top"); if (pe.pendingNesting > 0 || pe.hadPending) { pw.print(" (pending)"); } if (pe.activeNesting > 0 || pe.hadActive) { pw.print(" (active)"); } if (pe.activeTopNesting > 0 || pe.hadActiveTop) { pw.print(" (active-top)"); } pw.println(); if (pe.stopReasons.size() > 0) { pw.print(prefix); pw.print(" "); for (int k = 0; k < pe.stopReasons.size(); k++) { if (k > 0) { pw.print(", "); } pw.print(pe.stopReasons.valueAt(k)); pw.print("x "); pw.print(JobParameters.getReasonName(pe.stopReasons.keyAt(k))); } pw.println(); } } } pw.print(prefix); pw.print(" Max concurrency: "); pw.print(mMaxTotalActive); pw.print(" total, "); pw.print(mMaxFgActive); pw.println(" foreground"); }
Example 20
Source File: BroadcastStats.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
public boolean dumpStats(PrintWriter pw, String prefix, String dumpPackage) { boolean printedSomething = false; ArrayList<ActionEntry> actions = new ArrayList<>(mActions.size()); for (int i=mActions.size()-1; i>=0; i--) { actions.add(mActions.valueAt(i)); } Collections.sort(actions, ACTIONS_COMPARATOR); for (int i=actions.size()-1; i>=0; i--) { ActionEntry ae = actions.get(i); if (dumpPackage != null && !ae.mPackages.containsKey(dumpPackage)) { continue; } printedSomething = true; pw.print(prefix); pw.print(ae.mAction); pw.println(":"); pw.print(prefix); pw.print(" Number received: "); pw.print(ae.mReceiveCount); pw.print(", skipped: "); pw.println(ae.mSkipCount); pw.print(prefix); pw.print(" Total dispatch time: "); TimeUtils.formatDuration(ae.mTotalDispatchTime, pw); pw.print(", max: "); TimeUtils.formatDuration(ae.mMaxDispatchTime, pw); pw.println(); for (int j=ae.mPackages.size()-1; j>=0; j--) { pw.print(prefix); pw.print(" Package "); pw.print(ae.mPackages.keyAt(j)); pw.print(": "); PackageEntry pe = ae.mPackages.valueAt(j); pw.print(pe.mSendCount); pw.println(" times"); } for (int j=ae.mBackgroundCheckViolations.size()-1; j>=0; j--) { pw.print(prefix); pw.print(" Bg Check Violation "); pw.print(ae.mBackgroundCheckViolations.keyAt(j)); pw.print(": "); ViolationEntry ve = ae.mBackgroundCheckViolations.valueAt(j); pw.print(ve.mCount); pw.println(" times"); } } return printedSomething; }