android.util.proto.ProtoOutputStream Java Examples

The following examples show how to use android.util.proto.ProtoOutputStream. 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: StorageController.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public void dumpControllerStateLocked(ProtoOutputStream proto, long fieldId,
        Predicate<JobStatus> predicate) {
    final long token = proto.start(fieldId);
    final long mToken = proto.start(StateControllerProto.STORAGE);

    proto.write(StateControllerProto.StorageController.IS_STORAGE_NOT_LOW,
            mStorageTracker.isStorageNotLow());
    proto.write(StateControllerProto.StorageController.LAST_BROADCAST_SEQUENCE_NUMBER,
            mStorageTracker.getSeq());

    for (int i = 0; i < mTrackedTasks.size(); i++) {
        final JobStatus js = mTrackedTasks.valueAt(i);
        if (!predicate.test(js)) {
            continue;
        }
        final long jsToken = proto.start(StateControllerProto.StorageController.TRACKED_JOBS);
        js.writeToShortProto(proto, StateControllerProto.StorageController.TrackedJob.INFO);
        proto.write(StateControllerProto.StorageController.TrackedJob.SOURCE_UID,
                js.getSourceUid());
        proto.end(jsToken);
    }

    proto.end(mToken);
    proto.end(token);
}
 
Example #2
Source File: ConnectionRecord.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public void writeToProto(ProtoOutputStream proto, long fieldId) {
    if (binding == null) return; // if binding is null, don't write data, something is wrong.
    long token = proto.start(fieldId);
    proto.write(ConnectionRecordProto.HEX_HASH,
            Integer.toHexString(System.identityHashCode(this)));
    if (binding.client != null) {
        proto.write(ConnectionRecordProto.USER_ID, binding.client.userId);
    }
    ProtoUtils.writeBitWiseFlagsToProtoEnum(proto, ConnectionRecordProto.FLAGS,
            flags, BIND_ORIG_ENUMS, BIND_PROTO_ENUMS);
    if (serviceDead) {
        proto.write(ConnectionRecordProto.FLAGS, ConnectionRecordProto.DEAD);
    }
    if (binding.service != null) {
        proto.write(ConnectionRecordProto.SERVICE_NAME, binding.service.shortName);
    }
    proto.end(token);
}
 
Example #3
Source File: NotificationRecord.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
void dump(ProtoOutputStream proto, long fieldId, boolean redact, int state) {
    final long token = proto.start(fieldId);

    proto.write(NotificationRecordProto.KEY, sbn.getKey());
    proto.write(NotificationRecordProto.STATE, state);
    if (getChannel() != null) {
        proto.write(NotificationRecordProto.CHANNEL_ID, getChannel().getId());
    }
    proto.write(NotificationRecordProto.CAN_SHOW_LIGHT, getLight() != null);
    proto.write(NotificationRecordProto.CAN_VIBRATE, getVibration() != null);
    proto.write(NotificationRecordProto.FLAGS, sbn.getNotification().flags);
    proto.write(NotificationRecordProto.GROUP_KEY, getGroupKey());
    proto.write(NotificationRecordProto.IMPORTANCE, getImportance());
    if (getSound() != null) {
        proto.write(NotificationRecordProto.SOUND, getSound().toString());
    }
    if (getAudioAttributes() != null) {
        getAudioAttributes().writeToProto(proto, NotificationRecordProto.AUDIO_ATTRIBUTES);
    }

    proto.end(token);
}
 
Example #4
Source File: ClipData.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/** @hide */
public void writeToProto(ProtoOutputStream proto, long fieldId) {
    final long token = proto.start(fieldId);

    if (mClipDescription != null) {
        mClipDescription.writeToProto(proto, ClipDataProto.DESCRIPTION);
    }
    if (mIcon != null) {
        final long iToken = proto.start(ClipDataProto.ICON);
        proto.write(ClipDataProto.Icon.WIDTH, mIcon.getWidth());
        proto.write(ClipDataProto.Icon.HEIGHT, mIcon.getHeight());
        proto.end(iToken);
    }
    for (int i = 0; i < mItems.size(); i++) {
        mItems.get(i).writeToProto(proto, ClipDataProto.ITEMS);
    }

    proto.end(token);
}
 
Example #5
Source File: ProcessStatsService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void dumpProto(FileDescriptor fd) {
    final ProtoOutputStream proto = new ProtoOutputStream(fd);

    // dump current procstats
    long now;
    synchronized (mAm) {
        now = SystemClock.uptimeMillis();
        mProcessStats.writeToProto(proto,ProcessStatsServiceDumpProto.PROCSTATS_NOW, now);
    }

    // aggregated over last 3 hours procstats
    dumpAggregatedStats(proto, ProcessStatsServiceDumpProto.PROCSTATS_OVER_3HRS, 3, now);

    // aggregated over last 24 hours procstats
    dumpAggregatedStats(proto, ProcessStatsServiceDumpProto.PROCSTATS_OVER_24HRS, 24, now);

    proto.flush();
}
 
Example #6
Source File: Configuration.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Write full {@link android.content.ResourcesConfigurationProto} to protocol buffer output
 * stream.
 *
 * @param protoOutputStream Stream to write the Configuration object to.
 * @param fieldId           Field Id of the Configuration as defined in the parent message
 * @param metrics           Current display information
 * @hide
 */
public void writeResConfigToProto(ProtoOutputStream protoOutputStream, long fieldId,
        DisplayMetrics metrics) {
    final int width, height;
    if (metrics.widthPixels >= metrics.heightPixels) {
        width = metrics.widthPixels;
        height = metrics.heightPixels;
    } else {
        //noinspection SuspiciousNameCombination
        width = metrics.heightPixels;
        //noinspection SuspiciousNameCombination
        height = metrics.widthPixels;
    }

    final long token = protoOutputStream.start(fieldId);
    writeToProto(protoOutputStream, CONFIGURATION);
    protoOutputStream.write(SDK_VERSION, Build.VERSION.RESOURCES_SDK_INT);
    protoOutputStream.write(SCREEN_WIDTH_PX, width);
    protoOutputStream.write(SCREEN_HEIGHT_PX, height);
    protoOutputStream.end(token);
}
 
Example #7
Source File: ZenModeHelper.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
void dump(ProtoOutputStream proto) {
    proto.write(ZenModeProto.ZEN_MODE, mZenMode);
    synchronized (mConfig) {
        if (mConfig.manualRule != null) {
            mConfig.manualRule.writeToProto(proto, ZenModeProto.ENABLED_ACTIVE_CONDITIONS);
        }
        for (ZenRule rule : mConfig.automaticRules.values()) {
            if (rule.enabled && rule.condition.state == Condition.STATE_TRUE
                    && !rule.snoozing) {
                rule.writeToProto(proto, ZenModeProto.ENABLED_ACTIVE_CONDITIONS);
            }
        }
        mConfig.toNotificationPolicy().writeToProto(proto, ZenModeProto.POLICY);
        proto.write(ZenModeProto.SUPPRESSED_EFFECTS, mSuppressedEffects);
    }
}
 
Example #8
Source File: RootWindowContainer.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@CallSuper
@Override
public void writeToProto(ProtoOutputStream proto, long fieldId, boolean trim) {
    final long token = proto.start(fieldId);
    super.writeToProto(proto, WINDOW_CONTAINER, trim);
    if (mService.mDisplayReady) {
        final int count = mChildren.size();
        for (int i = 0; i < count; ++i) {
            final DisplayContent displayContent = mChildren.get(i);
            displayContent.writeToProto(proto, DISPLAYS, trim);
        }
    }
    if (!trim) {
        forAllWindows((w) -> {
            w.writeIdentifierToProto(proto, WINDOWS);
        }, true);
    }
    proto.end(token);
}
 
Example #9
Source File: NetworkStatsCollection.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public void writeToProto(ProtoOutputStream proto, long tag) {
    final long start = proto.start(tag);

    for (Key key : getSortedKeys()) {
        final long startStats = proto.start(NetworkStatsCollectionProto.STATS);

        // Key
        final long startKey = proto.start(NetworkStatsCollectionStatsProto.KEY);
        key.ident.writeToProto(proto, NetworkStatsCollectionKeyProto.IDENTITY);
        proto.write(NetworkStatsCollectionKeyProto.UID, key.uid);
        proto.write(NetworkStatsCollectionKeyProto.SET, key.set);
        proto.write(NetworkStatsCollectionKeyProto.TAG, key.tag);
        proto.end(startKey);

        // Value
        final NetworkStatsHistory history = mStats.get(key);
        history.writeToProto(proto, NetworkStatsCollectionStatsProto.HISTORY);
        proto.end(startStats);
    }

    proto.end(start);
}
 
Example #10
Source File: SettingsProtoDumpUtil.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
static void dumpProtoLocked(SettingsProvider.SettingsRegistry settingsRegistry,
        ProtoOutputStream proto) {
    // Global settings
    SettingsState globalSettings = settingsRegistry.getSettingsLocked(
            SettingsProvider.SETTINGS_TYPE_GLOBAL, UserHandle.USER_SYSTEM);
    long globalSettingsToken = proto.start(SettingsServiceDumpProto.GLOBAL_SETTINGS);
    dumpProtoGlobalSettingsLocked(globalSettings, proto);
    proto.end(globalSettingsToken);

    // Per-user settings
    SparseBooleanArray users = settingsRegistry.getKnownUsersLocked();
    final int userCount = users.size();
    for (int i = 0; i < userCount; i++) {
        long userSettingsToken = proto.start(SettingsServiceDumpProto.USER_SETTINGS);
        dumpProtoUserSettingsLocked(
                settingsRegistry, UserHandle.of(users.keyAt(i)), proto);
        proto.end(userSettingsToken);
    }
}
 
Example #11
Source File: Configuration.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Write to a protocol buffer output stream.
 * Protocol buffer message definition at {@link android.content.ConfigurationProto}
 *
 * @param protoOutputStream Stream to write the Configuration object to.
 * @param fieldId           Field Id of the Configuration as defined in the parent message
 * @hide
 */
public void writeToProto(ProtoOutputStream protoOutputStream, long fieldId) {
    final long token = protoOutputStream.start(fieldId);
    protoOutputStream.write(FONT_SCALE, fontScale);
    protoOutputStream.write(MCC, mcc);
    protoOutputStream.write(MNC, mnc);
    mLocaleList.writeToProto(protoOutputStream, LOCALES);
    protoOutputStream.write(SCREEN_LAYOUT, screenLayout);
    protoOutputStream.write(COLOR_MODE, colorMode);
    protoOutputStream.write(TOUCHSCREEN, touchscreen);
    protoOutputStream.write(KEYBOARD, keyboard);
    protoOutputStream.write(KEYBOARD_HIDDEN, keyboardHidden);
    protoOutputStream.write(HARD_KEYBOARD_HIDDEN, hardKeyboardHidden);
    protoOutputStream.write(NAVIGATION, navigation);
    protoOutputStream.write(NAVIGATION_HIDDEN, navigationHidden);
    protoOutputStream.write(ORIENTATION, orientation);
    protoOutputStream.write(UI_MODE, uiMode);
    protoOutputStream.write(SCREEN_WIDTH_DP, screenWidthDp);
    protoOutputStream.write(SCREEN_HEIGHT_DP, screenHeightDp);
    protoOutputStream.write(SMALLEST_SCREEN_WIDTH_DP, smallestScreenWidthDp);
    protoOutputStream.write(DENSITY_DPI, densityDpi);
    windowConfiguration.writeToProto(protoOutputStream, WINDOW_CONFIGURATION);
    protoOutputStream.end(token);
}
 
Example #12
Source File: UidRecord.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
void writeToProto(ProtoOutputStream proto, long fieldId) {
    long token = proto.start(fieldId);
    proto.write(UidRecordProto.UID, uid);
    proto.write(UidRecordProto.CURRENT, ProcessList.makeProcStateProtoEnum(curProcState));
    proto.write(UidRecordProto.EPHEMERAL, ephemeral);
    proto.write(UidRecordProto.FG_SERVICES, foregroundServices);
    proto.write(UidRecordProto.WHILELIST, curWhitelist);
    ProtoUtils.toDuration(proto, UidRecordProto.LAST_BACKGROUND_TIME,
            lastBackgroundTime, SystemClock.elapsedRealtime());
    proto.write(UidRecordProto.IDLE, idle);
    if (lastReportedChange != 0) {
        ProtoUtils.writeBitWiseFlagsToProtoEnum(proto, UidRecordProto.LAST_REPORTED_CHANGES,
                lastReportedChange, ORIG_ENUMS, PROTO_ENUMS);
    }
    proto.write(UidRecordProto.NUM_PROCS, numProcs);

    long seqToken = proto.start(UidRecordProto.NETWORK_STATE_UPDATE);
    proto.write(UidRecordProto.ProcStateSequence.CURURENT, curProcStateSeq);
    proto.write(UidRecordProto.ProcStateSequence.LAST_NETWORK_UPDATED,
            lastNetworkUpdatedProcStateSeq);
    proto.write(UidRecordProto.ProcStateSequence.LAST_DISPATCHED, lastDispatchedProcStateSeq);
    proto.end(seqToken);

    proto.end(token);
}
 
Example #13
Source File: NetworkCapabilities.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/** @hide */
public void writeToProto(ProtoOutputStream proto, long fieldId) {
    final long token = proto.start(fieldId);

    for (int transport : getTransportTypes()) {
        proto.write(NetworkCapabilitiesProto.TRANSPORTS, transport);
    }

    for (int capability : getCapabilities()) {
        proto.write(NetworkCapabilitiesProto.CAPABILITIES, capability);
    }

    proto.write(NetworkCapabilitiesProto.LINK_UP_BANDWIDTH_KBPS, mLinkUpBandwidthKbps);
    proto.write(NetworkCapabilitiesProto.LINK_DOWN_BANDWIDTH_KBPS, mLinkDownBandwidthKbps);

    if (mNetworkSpecifier != null) {
        proto.write(NetworkCapabilitiesProto.NETWORK_SPECIFIER, mNetworkSpecifier.toString());
    }

    proto.write(NetworkCapabilitiesProto.CAN_REPORT_SIGNAL_STRENGTH, hasSignalStrength());
    proto.write(NetworkCapabilitiesProto.SIGNAL_STRENGTH, mSignalStrength);

    proto.end(token);
}
 
Example #14
Source File: PowerManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public void writeToProto(ProtoOutputStream proto, long fieldId) {
    final long wakeLockToken = proto.start(fieldId);
    proto.write(WakeLockProto.LOCK_LEVEL, (mFlags & PowerManager.WAKE_LOCK_LEVEL_MASK));
    proto.write(WakeLockProto.TAG, mTag);

    final long wakeLockFlagsToken = proto.start(WakeLockProto.FLAGS);
    proto.write(WakeLockProto.WakeLockFlagsProto.IS_ACQUIRE_CAUSES_WAKEUP,
            (mFlags & PowerManager.ACQUIRE_CAUSES_WAKEUP)!=0);
    proto.write(WakeLockProto.WakeLockFlagsProto.IS_ON_AFTER_RELEASE,
            (mFlags & PowerManager.ON_AFTER_RELEASE)!=0);
    proto.end(wakeLockFlagsToken);

    proto.write(WakeLockProto.IS_DISABLED, mDisabled);
    if (mNotifiedAcquired) {
        proto.write(WakeLockProto.ACQ_MS, mAcquireTime);
    }
    proto.write(WakeLockProto.IS_NOTIFIED_LONG, mNotifiedLong);
    proto.write(WakeLockProto.UID, mOwnerUid);
    proto.write(WakeLockProto.PID, mOwnerPid);

    if (mWorkSource != null) {
        mWorkSource.writeToProto(proto, WakeLockProto.WORK_SOURCE);
    }
    proto.end(wakeLockToken);
}
 
Example #15
Source File: ClipData.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/** @hide */
public void writeToProto(ProtoOutputStream proto, long fieldId) {
    final long token = proto.start(fieldId);

    if (mHtmlText != null) {
        proto.write(ClipDataProto.Item.HTML_TEXT, mHtmlText);
    } else if (mText != null) {
        proto.write(ClipDataProto.Item.TEXT, mText.toString());
    } else if (mUri != null) {
        proto.write(ClipDataProto.Item.URI, mUri.toString());
    } else if (mIntent != null) {
        mIntent.writeToProto(proto, ClipDataProto.Item.INTENT, true, true, true, true);
    } else {
        proto.write(ClipDataProto.Item.NOTHING, true);
    }

    proto.end(token);
}
 
Example #16
Source File: GrantedUriPermissions.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public void dump(ProtoOutputStream proto, long fieldId) {
    final long token = proto.start(fieldId);

    proto.write(GrantedUriPermissionsDumpProto.FLAGS, mGrantFlags);
    proto.write(GrantedUriPermissionsDumpProto.SOURCE_USER_ID, mSourceUserId);
    proto.write(GrantedUriPermissionsDumpProto.TAG, mTag);
    proto.write(GrantedUriPermissionsDumpProto.PERMISSION_OWNER, mPermissionOwner.toString());
    for (int i = 0; i < mUris.size(); i++) {
        Uri u = mUris.get(i);
        if (u != null) {
            proto.write(GrantedUriPermissionsDumpProto.URIS, u.toString());
        }
    }

    proto.end(token);
}
 
Example #17
Source File: AlarmManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public void writeToProto(ProtoOutputStream proto, long fieldId) {
    final long token = proto.start(fieldId);

    proto.write(InFlightProto.UID, mUid);
    proto.write(InFlightProto.TAG, mTag);
    proto.write(InFlightProto.WHEN_ELAPSED_MS, mWhenElapsed);
    proto.write(InFlightProto.ALARM_TYPE, mAlarmType);
    if (mPendingIntent != null) {
        mPendingIntent.writeToProto(proto, InFlightProto.PENDING_INTENT);
    }
    if (mBroadcastStats != null) {
        mBroadcastStats.writeToProto(proto, InFlightProto.BROADCAST_STATS);
    }
    if (mFilterStats != null) {
        mFilterStats.writeToProto(proto, InFlightProto.FILTER_STATS);
    }
    if (mWorkSource != null) {
        mWorkSource.writeToProto(proto, InFlightProto.WORK_SOURCE);
    }

    proto.end(token);
}
 
Example #18
Source File: ActiveInstrumentation.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
void writeToProto(ProtoOutputStream proto, long fieldId) {
    long token = proto.start(fieldId);
    mClass.writeToProto(proto, ActiveInstrumentationProto.CLASS);
    proto.write(ActiveInstrumentationProto.FINISHED, mFinished);
    for (int i=0; i<mRunningProcesses.size(); i++) {
        mRunningProcesses.get(i).writeToProto(proto,
                ActiveInstrumentationProto.RUNNING_PROCESSES);
    }
    for (String p : mTargetProcesses) {
        proto.write(ActiveInstrumentationProto.TARGET_PROCESSES, p);
    }
    if (mTargetInfo != null) {
        mTargetInfo.writeToProto(proto, ActiveInstrumentationProto.TARGET_INFO);
    }
    proto.write(ActiveInstrumentationProto.PROFILE_FILE, mProfileFile);
    proto.write(ActiveInstrumentationProto.WATCHER, mWatcher.toString());
    proto.write(ActiveInstrumentationProto.UI_AUTOMATION_CONNECTION,
            mUiAutomationConnection.toString());
    proto.write(ActiveInstrumentationProto.ARGUMENTS, mArguments.toString());
    proto.end(token);
}
 
Example #19
Source File: IdleController.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public void dumpControllerStateLocked(ProtoOutputStream proto, long fieldId,
        Predicate<JobStatus> predicate) {
    final long token = proto.start(fieldId);
    final long mToken = proto.start(StateControllerProto.IDLE);

    proto.write(StateControllerProto.IdleController.IS_IDLE, mIdleTracker.isIdle());

    for (int i = 0; i < mTrackedTasks.size(); i++) {
        final JobStatus js = mTrackedTasks.valueAt(i);
        if (!predicate.test(js)) {
            continue;
        }
        final long jsToken = proto.start(StateControllerProto.IdleController.TRACKED_JOBS);
        js.writeToShortProto(proto, StateControllerProto.IdleController.TrackedJob.INFO);
        proto.write(StateControllerProto.IdleController.TrackedJob.SOURCE_UID,
                js.getSourceUid());
        proto.end(jsToken);
    }

    proto.end(mToken);
    proto.end(token);
}
 
Example #20
Source File: ClipDescription.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/** @hide */
public void writeToProto(ProtoOutputStream proto, long fieldId) {
    final long token = proto.start(fieldId);

    final int size = mMimeTypes.size();
    for (int i = 0; i < size; i++) {
        proto.write(ClipDescriptionProto.MIME_TYPES, mMimeTypes.get(i));
    }

    if (mLabel != null) {
        proto.write(ClipDescriptionProto.LABEL, mLabel.toString());
    }
    if (mExtras != null) {
        mExtras.writeToProto(proto, ClipDescriptionProto.EXTRAS);
    }
    if (mTimeStamp > 0) {
        proto.write(ClipDescriptionProto.TIMESTAMP_MS, mTimeStamp);
    }

    proto.end(token);
}
 
Example #21
Source File: ConnectivityController.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@GuardedBy("mLock")
@Override
public void dumpControllerStateLocked(ProtoOutputStream proto, long fieldId,
        Predicate<JobStatus> predicate) {
    final long token = proto.start(fieldId);
    final long mToken = proto.start(StateControllerProto.CONNECTIVITY);

    for (int i = 0; i < mTrackedJobs.size(); i++) {
        final JobStatus js = mTrackedJobs.valueAt(i);
        if (!predicate.test(js)) {
            continue;
        }
        final long jsToken = proto.start(StateControllerProto.ConnectivityController.TRACKED_JOBS);
        js.writeToShortProto(proto, StateControllerProto.ConnectivityController.TrackedJob.INFO);
        proto.write(StateControllerProto.ConnectivityController.TrackedJob.SOURCE_UID,
                js.getSourceUid());
        NetworkRequest rn = js.getJob().getRequiredNetwork();
        if (rn != null) {
            rn.writeToProto(proto,
                    StateControllerProto.ConnectivityController.TrackedJob.REQUIRED_NETWORK);
        }
        proto.end(jsToken);
    }

    proto.end(mToken);
    proto.end(token);
}
 
Example #22
Source File: TimeController.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void dumpControllerStateLocked(ProtoOutputStream proto, long fieldId,
        Predicate<JobStatus> predicate) {
    final long token = proto.start(fieldId);
    final long mToken = proto.start(StateControllerProto.TIME);

    final long nowElapsed = sElapsedRealtimeClock.millis();
    proto.write(StateControllerProto.TimeController.NOW_ELAPSED_REALTIME, nowElapsed);
    proto.write(StateControllerProto.TimeController.TIME_UNTIL_NEXT_DELAY_ALARM_MS,
            mNextDelayExpiredElapsedMillis - nowElapsed);
    proto.write(StateControllerProto.TimeController.TIME_UNTIL_NEXT_DEADLINE_ALARM_MS,
            mNextJobExpiredElapsedMillis - nowElapsed);

    for (JobStatus ts : mTrackedJobs) {
        if (!predicate.test(ts)) {
            continue;
        }
        final long tsToken = proto.start(StateControllerProto.TimeController.TRACKED_JOBS);
        ts.writeToShortProto(proto, StateControllerProto.TimeController.TrackedJob.INFO);

        proto.write(StateControllerProto.TimeController.TrackedJob.HAS_TIMING_DELAY_CONSTRAINT,
                ts.hasTimingDelayConstraint());
        proto.write(StateControllerProto.TimeController.TrackedJob.DELAY_TIME_REMAINING_MS,
                ts.getEarliestRunTime() - nowElapsed);

        proto.write(StateControllerProto.TimeController.TrackedJob.HAS_DEADLINE_CONSTRAINT,
                ts.hasDeadlineConstraint());
        proto.write(StateControllerProto.TimeController.TrackedJob.TIME_REMAINING_UNTIL_DEADLINE_MS,
                ts.getLatestRunTimeElapsed() - nowElapsed);

        proto.end(tsToken);
    }

    proto.end(mToken);
    proto.end(token);
}
 
Example #23
Source File: DeviceIdleJobsController.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void dumpControllerStateLocked(ProtoOutputStream proto, long fieldId,
        Predicate<JobStatus> predicate) {
    final long token = proto.start(fieldId);
    final long mToken = proto.start(StateControllerProto.DEVICE_IDLE);

    proto.write(StateControllerProto.DeviceIdleJobsController.IS_DEVICE_IDLE_MODE,
            mDeviceIdleMode);
    mService.getJobStore().forEachJob(predicate, (jobStatus) -> {
        final long jsToken =
                proto.start(StateControllerProto.DeviceIdleJobsController.TRACKED_JOBS);

        jobStatus.writeToShortProto(proto, TrackedJob.INFO);
        proto.write(TrackedJob.SOURCE_UID, jobStatus.getSourceUid());
        proto.write(TrackedJob.SOURCE_PACKAGE_NAME, jobStatus.getSourcePackageName());
        proto.write(TrackedJob.ARE_CONSTRAINTS_SATISFIED,
                (jobStatus.satisfiedConstraints &
                    JobStatus.CONSTRAINT_DEVICE_NOT_DOZING) != 0);
        proto.write(TrackedJob.IS_DOZE_WHITELISTED, jobStatus.dozeWhitelisted);
        proto.write(TrackedJob.IS_ALLOWED_IN_DOZE, mAllowInIdleJobs.contains(jobStatus));

        proto.end(jsToken);
    });

    proto.end(mToken);
    proto.end(token);
}
 
Example #24
Source File: MessageQueue.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
void writeToProto(ProtoOutputStream proto, long fieldId) {
    final long messageQueueToken = proto.start(fieldId);
    synchronized (this) {
        for (Message msg = mMessages; msg != null; msg = msg.next) {
            msg.writeToProto(proto, MessageQueueProto.MESSAGES);
        }
        proto.write(MessageQueueProto.IS_POLLING_LOCKED, isPollingLocked());
        proto.write(MessageQueueProto.IS_QUITTING, mQuitting);
    }
    proto.end(messageQueueToken);
}
 
Example #25
Source File: ManagedServices.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public void dump(ProtoOutputStream proto, DumpFilter filter) {
    proto.write(ManagedServicesProto.CAPTION, getCaption());
    final int N = mApproved.size();
    for (int i = 0 ; i < N; i++) {
        final int userId = mApproved.keyAt(i);
        final ArrayMap<Boolean, ArraySet<String>> approvedByType = mApproved.valueAt(i);
        if (approvedByType != null) {
            final int M = approvedByType.size();
            for (int j = 0; j < M; j++) {
                final boolean isPrimary = approvedByType.keyAt(j);
                final ArraySet<String> approved = approvedByType.valueAt(j);
                if (approvedByType != null && approvedByType.size() > 0) {
                    final long sToken = proto.start(ManagedServicesProto.APPROVED);
                    for (String s : approved) {
                        proto.write(ServiceProto.NAME, s);
                    }
                    proto.write(ServiceProto.USER_ID, userId);
                    proto.write(ServiceProto.IS_PRIMARY, isPrimary);
                    proto.end(sToken);
                }
            }
        }
    }

    for (ComponentName cmpt : mEnabledServicesForCurrentProfiles) {
        if (filter != null && !filter.matches(cmpt)) continue;
        cmpt.writeToProto(proto, ManagedServicesProto.ENABLED);
    }

    for (ManagedServiceInfo info : mServices) {
        if (filter != null && !filter.matches(info.component)) continue;
        info.writeToProto(proto, ManagedServicesProto.LIVE_SERVICES, this);
    }

    for (ComponentName name : mSnoozingForCurrentProfiles) {
        name.writeToProto(proto, ManagedServicesProto.SNOOZED);
    }
}
 
Example #26
Source File: BatteryController.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void dumpControllerStateLocked(ProtoOutputStream proto, long fieldId,
        Predicate<JobStatus> predicate) {
    final long token = proto.start(fieldId);
    final long mToken = proto.start(StateControllerProto.BATTERY);

    proto.write(StateControllerProto.BatteryController.IS_ON_STABLE_POWER,
            mChargeTracker.isOnStablePower());
    proto.write(StateControllerProto.BatteryController.IS_BATTERY_NOT_LOW,
            mChargeTracker.isBatteryNotLow());

    proto.write(StateControllerProto.BatteryController.IS_MONITORING,
            mChargeTracker.isMonitoring());
    proto.write(StateControllerProto.BatteryController.LAST_BROADCAST_SEQUENCE_NUMBER,
            mChargeTracker.getSeq());

    for (int i = 0; i < mTrackedTasks.size(); i++) {
        final JobStatus js = mTrackedTasks.valueAt(i);
        if (!predicate.test(js)) {
            continue;
        }
        final long jsToken = proto.start(StateControllerProto.BatteryController.TRACKED_JOBS);
        js.writeToShortProto(proto, StateControllerProto.BatteryController.TrackedJob.INFO);
        proto.write(StateControllerProto.BatteryController.TrackedJob.SOURCE_UID,
                js.getSourceUid());
        proto.end(jsToken);
    }

    proto.end(mToken);
    proto.end(token);
}
 
Example #27
Source File: JobPackageTracker.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void printPackageEntryState(ProtoOutputStream proto, long fieldId,
        long duration, int count) {
    final long token = proto.start(fieldId);
    proto.write(DataSetProto.PackageEntryProto.State.DURATION_MS, duration);
    proto.write(DataSetProto.PackageEntryProto.State.COUNT, count);
    proto.end(token);
}
 
Example #28
Source File: LocaleList.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Helper to write LocaleList to a protocol buffer output stream.  Assumes the parent
 * protobuf has declared the locale as repeated.
 *
 * @param protoOutputStream Stream to write the locale to.
 * @param fieldId Field Id of the Locale as defined in the parent message.
 * @hide
 */
public void writeToProto(ProtoOutputStream protoOutputStream, long fieldId) {
    for (int i = 0; i < mList.length; i++) {
        final Locale locale = mList[i];
        final long token = protoOutputStream.start(fieldId);
        protoOutputStream.write(LocaleProto.LANGUAGE, locale.getLanguage());
        protoOutputStream.write(LocaleProto.COUNTRY, locale.getCountry());
        protoOutputStream.write(LocaleProto.VARIANT, locale.getVariant());
        protoOutputStream.end(token);
    }
}
 
Example #29
Source File: RemoteAnimationTarget.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public void writeToProto(ProtoOutputStream proto, long fieldId) {
    final long token = proto.start(fieldId);
    proto.write(TASK_ID, taskId);
    proto.write(MODE, mode);
    leash.writeToProto(proto, LEASH);
    proto.write(IS_TRANSLUCENT, isTranslucent);
    clipRect.writeToProto(proto, CLIP_RECT);
    contentInsets.writeToProto(proto, CONTENT_INSETS);
    proto.write(PREFIX_ORDER_INDEX, prefixOrderIndex);
    position.writeToProto(proto, POSITION);
    sourceContainerBounds.writeToProto(proto, SOURCE_CONTAINER_BOUNDS);
    windowConfiguration.writeToProto(proto, WINDOW_CONFIGURATION);
    proto.end(token);
}
 
Example #30
Source File: BatteryService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void dumpProto(FileDescriptor fd) {
    final ProtoOutputStream proto = new ProtoOutputStream(fd);

    synchronized (mLock) {
        proto.write(BatteryServiceDumpProto.ARE_UPDATES_STOPPED, mUpdatesStopped);
        int batteryPluggedValue = OsProtoEnums.BATTERY_PLUGGED_NONE;
        if (mHealthInfo.chargerAcOnline) {
            batteryPluggedValue = OsProtoEnums.BATTERY_PLUGGED_AC;
        } else if (mHealthInfo.chargerUsbOnline) {
            batteryPluggedValue = OsProtoEnums.BATTERY_PLUGGED_USB;
        } else if (mHealthInfo.chargerWirelessOnline) {
            batteryPluggedValue = OsProtoEnums.BATTERY_PLUGGED_WIRELESS;
        }
        proto.write(BatteryServiceDumpProto.PLUGGED, batteryPluggedValue);
        proto.write(BatteryServiceDumpProto.MAX_CHARGING_CURRENT, mHealthInfo.maxChargingCurrent);
        proto.write(BatteryServiceDumpProto.MAX_CHARGING_VOLTAGE, mHealthInfo.maxChargingVoltage);
        proto.write(BatteryServiceDumpProto.CHARGE_COUNTER, mHealthInfo.batteryChargeCounter);
        proto.write(BatteryServiceDumpProto.STATUS, mHealthInfo.batteryStatus);
        proto.write(BatteryServiceDumpProto.HEALTH, mHealthInfo.batteryHealth);
        proto.write(BatteryServiceDumpProto.IS_PRESENT, mHealthInfo.batteryPresent);
        proto.write(BatteryServiceDumpProto.LEVEL, mHealthInfo.batteryLevel);
        proto.write(BatteryServiceDumpProto.SCALE, BATTERY_SCALE);
        proto.write(BatteryServiceDumpProto.VOLTAGE, mHealthInfo.batteryVoltage);
        proto.write(BatteryServiceDumpProto.TEMPERATURE, mHealthInfo.batteryTemperature);
        proto.write(BatteryServiceDumpProto.TECHNOLOGY, mHealthInfo.batteryTechnology);
    }
    proto.flush();
}