android.util.TimeUtils Java Examples

The following examples show how to use android.util.TimeUtils. 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 Project: android_9.0.0_r45   Author: lulululbj   File: JobServiceContext.java    License: Apache License 2.0 6 votes vote down vote up
@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 #2
Source Project: android_9.0.0_r45   Author: lulululbj   File: JobSchedulerService.java    License: Apache License 2.0 6 votes vote down vote up
void setNextHeartbeatAlarm() {
    final long heartbeatLength;
    synchronized (mLock) {
        heartbeatLength = mConstants.STANDBY_HEARTBEAT_TIME;
    }
    final long now = sElapsedRealtimeClock.millis();
    final long nextBeatOrdinal = (now + heartbeatLength) / heartbeatLength;
    final long nextHeartbeat = nextBeatOrdinal * heartbeatLength;
    if (DEBUG_STANDBY) {
        Slog.i(TAG, "Setting heartbeat alarm for " + nextHeartbeat
                + " = " + TimeUtils.formatDuration(nextHeartbeat - now));
    }
    AlarmManager am = (AlarmManager) getContext().getSystemService(Context.ALARM_SERVICE);
    am.setExact(AlarmManager.ELAPSED_REALTIME, nextHeartbeat,
            HEARTBEAT_TAG, mHeartbeatAlarm, mHandler);
}
 
Example #3
Source Project: android_9.0.0_r45   Author: lulululbj   File: WirelessChargerDetector.java    License: Apache License 2.0 6 votes vote down vote up
public void dump(PrintWriter pw) {
    synchronized (mLock) {
        pw.println();
        pw.println("Wireless Charger Detector State:");
        pw.println("  mGravitySensor=" + mGravitySensor);
        pw.println("  mPoweredWirelessly=" + mPoweredWirelessly);
        pw.println("  mAtRest=" + mAtRest);
        pw.println("  mRestX=" + mRestX + ", mRestY=" + mRestY + ", mRestZ=" + mRestZ);
        pw.println("  mDetectionInProgress=" + mDetectionInProgress);
        pw.println("  mDetectionStartTime=" + (mDetectionStartTime == 0 ? "0 (never)"
                : TimeUtils.formatUptime(mDetectionStartTime)));
        pw.println("  mMustUpdateRestPosition=" + mMustUpdateRestPosition);
        pw.println("  mTotalSamples=" + mTotalSamples);
        pw.println("  mMovingSamples=" + mMovingSamples);
        pw.println("  mFirstSampleX=" + mFirstSampleX
                + ", mFirstSampleY=" + mFirstSampleY + ", mFirstSampleZ=" + mFirstSampleZ);
        pw.println("  mLastSampleX=" + mLastSampleX
                + ", mLastSampleY=" + mLastSampleY + ", mLastSampleZ=" + mLastSampleZ);
    }
}
 
Example #4
Source Project: android_9.0.0_r45   Author: lulululbj   File: DeviceIdleController.java    License: Apache License 2.0 6 votes vote down vote up
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 #5
Source Project: android_9.0.0_r45   Author: lulululbj   File: DeviceIdleController.java    License: Apache License 2.0 6 votes vote down vote up
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 #6
Source Project: android_9.0.0_r45   Author: lulululbj   File: MediaRouterService.java    License: Apache License 2.0 6 votes vote down vote up
public void dump(PrintWriter pw, String prefix) {
    pw.println(prefix + "Handler");

    final String indent = prefix + "  ";
    pw.println(indent + "mRunning=" + mRunning);
    pw.println(indent + "mDiscoveryMode=" + mDiscoveryMode);
    pw.println(indent + "mSelectedRouteRecord=" + mSelectedRouteRecord);
    pw.println(indent + "mConnectionPhase=" + mConnectionPhase);
    pw.println(indent + "mConnectionTimeoutReason=" + mConnectionTimeoutReason);
    pw.println(indent + "mConnectionTimeoutStartTime=" + (mConnectionTimeoutReason != 0 ?
            TimeUtils.formatUptime(mConnectionTimeoutStartTime) : "<n/a>"));

    mWatcher.dump(pw, prefix);

    final int providerCount = mProviderRecords.size();
    if (providerCount != 0) {
        for (int i = 0; i < providerCount; i++) {
            mProviderRecords.get(i).dump(pw, prefix);
        }
    } else {
        pw.println(indent + "<no providers>");
    }
}
 
Example #7
Source Project: android_9.0.0_r45   Author: lulululbj   File: PreloadsFileCacheExpirationJobService.java    License: Apache License 2.0 6 votes vote down vote up
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 #8
Source Project: android_9.0.0_r45   Author: lulululbj   File: ActivityMetricsLogger.java    License: Apache License 2.0 6 votes vote down vote up
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 #9
Source Project: android_9.0.0_r45   Author: lulululbj   File: PendingIntentRecord.java    License: Apache License 2.0 6 votes vote down vote up
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 #10
Source Project: android_9.0.0_r45   Author: lulululbj   File: ContentProviderConnection.java    License: Apache License 2.0 6 votes vote down vote up
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 #11
Source Project: android_9.0.0_r45   Author: lulululbj   File: PersistentConnection.java    License: Apache License 2.0 6 votes vote down vote up
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 #12
Source Project: android_9.0.0_r45   Author: lulululbj   File: AppTimeTracker.java    License: Apache License 2.0 6 votes vote down vote up
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 #13
Source Project: android_9.0.0_r45   Author: lulululbj   File: VolumeRecord.java    License: Apache License 2.0 6 votes vote down vote up
public void dump(IndentingPrintWriter pw) {
    pw.println("VolumeRecord:");
    pw.increaseIndent();
    pw.printPair("type", DebugUtils.valueToString(VolumeInfo.class, "TYPE_", type));
    pw.printPair("fsUuid", fsUuid);
    pw.printPair("partGuid", partGuid);
    pw.println();
    pw.printPair("nickname", nickname);
    pw.printPair("userFlags",
            DebugUtils.flagsToString(VolumeRecord.class, "USER_FLAG_", userFlags));
    pw.println();
    pw.printPair("createdMillis", TimeUtils.formatForLogging(createdMillis));
    pw.printPair("lastTrimMillis", TimeUtils.formatForLogging(lastTrimMillis));
    pw.printPair("lastBenchMillis", TimeUtils.formatForLogging(lastBenchMillis));
    pw.decreaseIndent();
    pw.println();
}
 
Example #14
Source Project: android_9.0.0_r45   Author: lulululbj   File: AsyncTaskLoader.java    License: Apache License 2.0 6 votes vote down vote up
@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 #15
Source Project: android_9.0.0_r45   Author: lulululbj   File: PersistentDataStore.java    License: Apache License 2.0 5 votes vote down vote up
public void dump(final PrintWriter pw, final String prefix) {
    for (int i = 0; i < mConfigurations.size(); i++) {
        final int userSerial = mConfigurations.keyAt(i);
        long time = mTimeStamps.get(userSerial, -1);
        String packageName = mPackageNames.get(userSerial);
        pw.println(prefix + "User " + userSerial + ":");
        if (time != -1) {
            pw.println(prefix + "  set at: " + TimeUtils.formatForLogging(time));
        }
        if (packageName != null) {
            pw.println(prefix + "  set by: " + packageName);
        }
        pw.println(prefix + "  " + mConfigurations.valueAt(i));
    }
}
 
Example #16
Source Project: android_9.0.0_r45   Author: lulululbj   File: WindowAnimator.java    License: Apache License 2.0 5 votes vote down vote up
public void dumpLocked(PrintWriter pw, String prefix, boolean dumpAll) {
    final String subPrefix = "  " + prefix;
    final String subSubPrefix = "  " + subPrefix;

    for (int i = 0; i < mDisplayContentsAnimators.size(); i++) {
        pw.print(prefix); pw.print("DisplayContentsAnimator #");
                pw.print(mDisplayContentsAnimators.keyAt(i));
                pw.println(":");
        final DisplayContentsAnimator displayAnimator = mDisplayContentsAnimators.valueAt(i);
        final DisplayContent dc =
                mService.mRoot.getDisplayContent(mDisplayContentsAnimators.keyAt(i));
        dc.dumpWindowAnimators(pw, subPrefix);
        if (displayAnimator.mScreenRotationAnimation != null) {
            pw.print(subPrefix); pw.println("mScreenRotationAnimation:");
            displayAnimator.mScreenRotationAnimation.printTo(subSubPrefix, pw);
        } else if (dumpAll) {
            pw.print(subPrefix); pw.println("no ScreenRotationAnimation ");
        }
        pw.println();
    }

    pw.println();

    if (dumpAll) {
        pw.print(prefix); pw.print("mAnimTransactionSequence=");
                pw.print(mAnimTransactionSequence);
        pw.print(prefix); pw.print("mCurrentTime=");
                pw.println(TimeUtils.formatUptime(mCurrentTime));
    }
    if (mBulkUpdateParams != 0) {
        pw.print(prefix); pw.print("mBulkUpdateParams=0x");
                pw.print(Integer.toHexString(mBulkUpdateParams));
                pw.println(bulkUpdateParamsToString(mBulkUpdateParams));
    }
    if (mWindowDetachedWallpaper != null) {
        pw.print(prefix); pw.print("mWindowDetachedWallpaper=");
            pw.println(mWindowDetachedWallpaper);
    }
}
 
Example #17
Source Project: android_9.0.0_r45   Author: lulululbj   File: AlarmManagerService.java    License: Apache License 2.0 5 votes vote down vote up
void dump(PrintWriter pw) {
    pw.println("  Settings:");

    pw.print("    "); pw.print(KEY_MIN_FUTURITY); pw.print("=");
    TimeUtils.formatDuration(MIN_FUTURITY, pw);
    pw.println();

    pw.print("    "); pw.print(KEY_MIN_INTERVAL); pw.print("=");
    TimeUtils.formatDuration(MIN_INTERVAL, pw);
    pw.println();

    pw.print("    "); pw.print(KEY_MAX_INTERVAL); pw.print("=");
    TimeUtils.formatDuration(MAX_INTERVAL, pw);
    pw.println();

    pw.print("    "); pw.print(KEY_LISTENER_TIMEOUT); pw.print("=");
    TimeUtils.formatDuration(LISTENER_TIMEOUT, pw);
    pw.println();

    pw.print("    "); pw.print(KEY_ALLOW_WHILE_IDLE_SHORT_TIME); pw.print("=");
    TimeUtils.formatDuration(ALLOW_WHILE_IDLE_SHORT_TIME, pw);
    pw.println();

    pw.print("    "); pw.print(KEY_ALLOW_WHILE_IDLE_LONG_TIME); pw.print("=");
    TimeUtils.formatDuration(ALLOW_WHILE_IDLE_LONG_TIME, pw);
    pw.println();

    pw.print("    "); pw.print(KEY_ALLOW_WHILE_IDLE_WHITELIST_DURATION); pw.print("=");
    TimeUtils.formatDuration(ALLOW_WHILE_IDLE_WHITELIST_DURATION, pw);
    pw.println();

    for (int i = 0; i < KEYS_APP_STANDBY_DELAY.length; i++) {
        pw.print("    "); pw.print(KEYS_APP_STANDBY_DELAY[i]); pw.print("=");
        TimeUtils.formatDuration(APP_STANDBY_MIN_DELAYS[i], pw);
        pw.println();
    }
}
 
Example #18
Source Project: android_9.0.0_r45   Author: lulululbj   File: AlarmManagerService.java    License: Apache License 2.0 5 votes vote down vote up
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 #19
Source Project: android_9.0.0_r45   Author: lulululbj   File: JobServiceContext.java    License: Apache License 2.0 5 votes vote down vote up
private void assertCallerLocked(JobCallback cb) {
    if (!verifyCallerLocked(cb)) {
        StringBuilder sb = new StringBuilder(128);
        sb.append("Caller no longer running");
        if (cb.mStoppedReason != null) {
            sb.append(", last stopped ");
            TimeUtils.formatDuration(sElapsedRealtimeClock.millis() - cb.mStoppedTime, sb);
            sb.append(" because: ");
            sb.append(cb.mStoppedReason);
        }
        throw new SecurityException(sb.toString());
    }
}
 
Example #20
Source Project: android_9.0.0_r45   Author: lulululbj   File: JobStatus.java    License: Apache License 2.0 5 votes vote down vote up
private void formatRunTime(PrintWriter pw, long runtime, long  defaultValue, long now) {
    if (runtime == defaultValue) {
        pw.print("none");
    } else {
        TimeUtils.formatDuration(runtime - now, pw);
    }
}
 
Example #21
Source Project: android_9.0.0_r45   Author: lulululbj   File: JobStatus.java    License: Apache License 2.0 5 votes vote down vote up
private void formatRunTime(StringBuilder sb, long runtime, long  defaultValue, long now) {
    if (runtime == defaultValue) {
        sb.append("none");
    } else {
        TimeUtils.formatDuration(runtime - now, sb);
    }
}
 
Example #22
Source Project: android_9.0.0_r45   Author: lulululbj   File: TimeController.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void dumpControllerStateLocked(IndentingPrintWriter pw,
        Predicate<JobStatus> predicate) {
    final long nowElapsed = sElapsedRealtimeClock.millis();
    pw.println("Elapsed clock: " + nowElapsed);

    pw.print("Next delay alarm in ");
    TimeUtils.formatDuration(mNextDelayExpiredElapsedMillis, nowElapsed, pw);
    pw.println();
    pw.print("Next deadline alarm in ");
    TimeUtils.formatDuration(mNextJobExpiredElapsedMillis, nowElapsed, pw);
    pw.println();
    pw.println();

    for (JobStatus ts : mTrackedJobs) {
        if (!predicate.test(ts)) {
            continue;
        }
        pw.print("#");
        ts.printUniqueId(pw);
        pw.print(" from ");
        UserHandle.formatUid(pw, ts.getSourceUid());
        pw.print(": Delay=");
        if (ts.hasTimingDelayConstraint()) {
            TimeUtils.formatDuration(ts.getEarliestRunTime(), nowElapsed, pw);
        } else {
            pw.print("N/A");
        }
        pw.print(", Deadline=");
        if (ts.hasDeadlineConstraint()) {
            TimeUtils.formatDuration(ts.getLatestRunTimeElapsed(), nowElapsed, pw);
        } else {
            pw.print("N/A");
        }
        pw.println();
    }
}
 
Example #23
Source Project: android_9.0.0_r45   Author: lulululbj   File: PowerManagerService.java    License: Apache License 2.0 5 votes vote down vote up
@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 #24
Source Project: android_9.0.0_r45   Author: lulululbj   File: UserManagerService.java    License: Apache License 2.0 5 votes vote down vote up
private static void dumpTimeAgo(PrintWriter pw, StringBuilder sb, long nowTime, long time) {
    if (time == 0) {
        pw.println("<unknown>");
    } else {
        sb.setLength(0);
        TimeUtils.formatDuration(nowTime - time, sb);
        sb.append(" ago");
        pw.println(sb);
    }
}
 
Example #25
Source Project: android_9.0.0_r45   Author: lulululbj   File: NetworkTimeUpdateService.java    License: Apache License 2.0 5 votes vote down vote up
@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 #26
Source Project: android_9.0.0_r45   Author: lulululbj   File: AppOpsService.java    License: Apache License 2.0 5 votes vote down vote up
void dump(PrintWriter pw) {
    pw.println("  Settings:");

    pw.print("    "); pw.print(KEY_TOP_STATE_SETTLE_TIME); pw.print("=");
    TimeUtils.formatDuration(TOP_STATE_SETTLE_TIME, pw);
    pw.println();
    pw.print("    "); pw.print(KEY_FG_SERVICE_STATE_SETTLE_TIME); pw.print("=");
    TimeUtils.formatDuration(FG_SERVICE_STATE_SETTLE_TIME, pw);
    pw.println();
    pw.print("    "); pw.print(KEY_BG_STATE_SETTLE_TIME); pw.print("=");
    TimeUtils.formatDuration(BG_STATE_SETTLE_TIME, pw);
    pw.println();
}
 
Example #27
Source Project: android_9.0.0_r45   Author: lulululbj   File: AppOpsService.java    License: Apache License 2.0 5 votes vote down vote up
private void dumpTimesLocked(PrintWriter pw, String firstPrefix, String prefix, long[] times,
        long now, SimpleDateFormat sdf, Date date) {
    boolean hasTime = false;
    for (int i = 0; i < _NUM_UID_STATE; i++) {
        if (times[i] != 0) {
            hasTime = true;
            break;
        }
    }
    if (!hasTime) {
        return;
    }
    boolean first = true;
    for (int i = 0; i < _NUM_UID_STATE; i++) {
        if (times[i] != 0) {
            pw.print(first ? firstPrefix : prefix);
            first = false;
            pw.print(UID_STATE_NAMES[i]);
            pw.print(" = ");
            date.setTime(times[i]);
            pw.print(sdf.format(date));
            pw.print(" (");
            TimeUtils.formatDuration(times[i]-now, pw);
            pw.println(")");
        }
    }
}
 
Example #28
Source Project: android_9.0.0_r45   Author: lulululbj   File: ActivityMetricsLogger.java    License: Apache License 2.0 5 votes vote down vote up
private void logAppFullyDrawn(WindowingModeTransitionInfoSnapshot info) {
    if (info.type != TYPE_TRANSITION_WARM_LAUNCH && info.type != TYPE_TRANSITION_COLD_LAUNCH) {
        return;
    }

    StringBuilder sb = mStringBuilder;
    sb.setLength(0);
    sb.append("Fully drawn ");
    sb.append(info.launchedActivityShortComponentName);
    sb.append(": ");
    TimeUtils.formatDuration(info.windowsFullyDrawnDelayMs, sb);
    Log.i(TAG, sb.toString());
}
 
Example #29
Source Project: android_9.0.0_r45   Author: lulululbj   File: ActiveServices.java    License: Apache License 2.0 5 votes vote down vote up
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 #30
Source Project: android_9.0.0_r45   Author: lulululbj   File: ServiceRecord.java    License: Apache License 2.0 5 votes vote down vote up
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);
        }
    }
}