Java Code Examples for android.util.proto.ProtoOutputStream#start()

The following examples show how to use android.util.proto.ProtoOutputStream#start() . 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: 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 2
Source File: IntentBindRecord.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) {
    long token = proto.start(fieldId);
    if (intent != null) {
        intent.getIntent().writeToProto(proto,
                IntentBindRecordProto.INTENT, false, true, false, false);
    }
    if (binder != null) {
        proto.write(IntentBindRecordProto.BINDER, binder.toString());
    }
    proto.write(IntentBindRecordProto.AUTO_CREATE,
            (collectFlags()&Context.BIND_AUTO_CREATE) != 0);
    proto.write(IntentBindRecordProto.REQUESTED, requested);
    proto.write(IntentBindRecordProto.RECEIVED, received);
    proto.write(IntentBindRecordProto.HAS_BOUND, hasBound);
    proto.write(IntentBindRecordProto.DO_REBIND, doRebind);

    final int N = apps.size();
    for (int i=0; i<N; i++) {
        AppBindRecord a = apps.valueAt(i);
        if (a != null) {
            a.writeToProto(proto, IntentBindRecordProto.APPS);
        }
    }
    proto.end(token);
}
 
Example 3
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 4
Source File: IntentFilter.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
void writeToProto(ProtoOutputStream proto, long fieldId) {
    long token = proto.start(fieldId);
    // The original host information is already contained in host and wild, no output now.
    proto.write(AuthorityEntryProto.HOST, mHost);
    proto.write(AuthorityEntryProto.WILD, mWild);
    proto.write(AuthorityEntryProto.PORT, mPort);
    proto.end(token);
}
 
Example 5
Source File: PowerManager.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/** @hide */
public void writeToProto(ProtoOutputStream proto, long fieldId) {
    synchronized (mToken) {
        final long token = proto.start(fieldId);
        proto.write(PowerManagerProto.WakeLock.TAG, mTag);
        proto.write(PowerManagerProto.WakeLock.PACKAGE_NAME, mPackageName);
        proto.write(PowerManagerProto.WakeLock.HELD, mHeld);
        proto.write(PowerManagerProto.WakeLock.INTERNAL_COUNT, mInternalCount);
        if (mWorkSource != null) {
            mWorkSource.writeToProto(proto, PowerManagerProto.WakeLock.WORK_SOURCE);
        }
        proto.end(token);
    }
}
 
Example 6
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 7
Source File: NotificationChannelGroup.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/** @hide */
public void writeToProto(ProtoOutputStream proto, long fieldId) {
    final long token = proto.start(fieldId);

    proto.write(NotificationChannelGroupProto.ID, mId);
    proto.write(NotificationChannelGroupProto.NAME, mName.toString());
    proto.write(NotificationChannelGroupProto.DESCRIPTION, mDescription);
    proto.write(NotificationChannelGroupProto.IS_BLOCKED, mBlocked);
    for (NotificationChannel channel : mChannels) {
        channel.writeToProto(proto, NotificationChannelGroupProto.CHANNELS);
    }

    proto.end(token);
}
 
Example 8
Source File: Looper.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/** @hide */
public void writeToProto(ProtoOutputStream proto, long fieldId) {
    final long looperToken = proto.start(fieldId);
    proto.write(LooperProto.THREAD_NAME, mThread.getName());
    proto.write(LooperProto.THREAD_ID, mThread.getId());
    mQueue.writeToProto(proto, LooperProto.QUEUE);
    proto.end(looperToken);
}
 
Example 9
Source File: AlarmManagerService.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(FilterStatsProto.TAG, mTag);
    proto.write(FilterStatsProto.LAST_FLIGHT_TIME_REALTIME, lastTime);
    proto.write(FilterStatsProto.TOTAL_FLIGHT_DURATION_MS, aggregateTime);
    proto.write(FilterStatsProto.COUNT, count);
    proto.write(FilterStatsProto.WAKEUP_COUNT, numWakeup);
    proto.write(FilterStatsProto.START_TIME_REALTIME, startTime);
    proto.write(FilterStatsProto.NESTING, nesting);

    proto.end(token);
}
 
Example 10
Source File: SurfaceAnimator.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Write to a protocol buffer output stream. Protocol buffer message definition is at {@link
 * com.android.server.wm.SurfaceAnimatorProto}.
 *
 * @param proto Stream to write the SurfaceAnimator object to.
 * @param fieldId Field Id of the SurfaceAnimator as defined in the parent message.
 * @hide
 */
void writeToProto(ProtoOutputStream proto, long fieldId) {
    final long token = proto.start(fieldId);
    if (mAnimation != null) {
        mAnimation.writeToProto(proto, ANIMATION_ADAPTER);
    }
    if (mLeash != null){
        mLeash.writeToProto(proto, LEASH);
    }
    proto.write(ANIMATION_START_DELAYED, mAnimationStartDelayed);
    proto.end(token);
}
 
Example 11
Source File: WindowConfiguration.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Write to a protocol buffer output stream.
 * Protocol buffer message definition at {@link android.app.WindowConfigurationProto}
 *
 * @param protoOutputStream Stream to write the WindowConfiguration object to.
 * @param fieldId           Field Id of the WindowConfiguration as defined in the parent message
 * @hide
 */
public void writeToProto(ProtoOutputStream protoOutputStream, long fieldId) {
    final long token = protoOutputStream.start(fieldId);
    if (mAppBounds != null) {
        mAppBounds.writeToProto(protoOutputStream, APP_BOUNDS);
    }
    protoOutputStream.write(WINDOWING_MODE, mWindowingMode);
    protoOutputStream.write(ACTIVITY_TYPE, mActivityType);
    protoOutputStream.end(token);
}
 
Example 12
Source File: AlarmManagerService.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, long nowElapsed,
        long nowRTC) {
    final long token = proto.start(fieldId);

    proto.write(BatchProto.START_REALTIME, start);
    proto.write(BatchProto.END_REALTIME, end);
    proto.write(BatchProto.FLAGS, flags);
    for (Alarm a : alarms) {
        a.writeToProto(proto, BatchProto.ALARMS, nowElapsed, nowRTC);
    }

    proto.end(token);
}
 
Example 13
Source File: RecentsAnimationController.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void writeToProto(ProtoOutputStream proto) {
    final long token = proto.start(REMOTE);
    if (mTarget != null) {
        mTarget.writeToProto(proto, TARGET);
    }
    proto.end(token);
}
 
Example 14
Source File: ManagedServices.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, ManagedServices host) {
    final long token = proto.start(fieldId);
    component.writeToProto(proto, ManagedServiceInfoProto.COMPONENT);
    proto.write(ManagedServiceInfoProto.USER_ID, userid);
    proto.write(ManagedServiceInfoProto.SERVICE, service.getClass().getName());
    proto.write(ManagedServiceInfoProto.IS_SYSTEM, isSystem);
    proto.write(ManagedServiceInfoProto.IS_GUEST, isGuest(host));
    proto.end(token);
}
 
Example 15
Source File: NotificationChannel.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/** @hide */
public void writeToProto(ProtoOutputStream proto, long fieldId) {
    final long token = proto.start(fieldId);

    proto.write(NotificationChannelProto.ID, mId);
    proto.write(NotificationChannelProto.NAME, mName);
    proto.write(NotificationChannelProto.DESCRIPTION, mDesc);
    proto.write(NotificationChannelProto.IMPORTANCE, mImportance);
    proto.write(NotificationChannelProto.CAN_BYPASS_DND, mBypassDnd);
    proto.write(NotificationChannelProto.LOCKSCREEN_VISIBILITY, mLockscreenVisibility);
    if (mSound != null) {
        proto.write(NotificationChannelProto.SOUND, mSound.toString());
    }
    proto.write(NotificationChannelProto.USE_LIGHTS, mLights);
    proto.write(NotificationChannelProto.LIGHT_COLOR, mLightColor);
    if (mVibration != null) {
        for (long v : mVibration) {
            proto.write(NotificationChannelProto.VIBRATION, v);
        }
    }
    proto.write(NotificationChannelProto.USER_LOCKED_FIELDS, mUserLockedFields);
    proto.write(NotificationChannelProto.FG_SERVICE_SHOWN, mFgServiceShown);
    proto.write(NotificationChannelProto.IS_VIBRATION_ENABLED, mVibrationEnabled);
    proto.write(NotificationChannelProto.SHOW_BADGE, mShowBadge);
    proto.write(NotificationChannelProto.IS_DELETED, mDeleted);
    proto.write(NotificationChannelProto.GROUP, mGroup);
    if (mAudioAttributes != null) {
        mAudioAttributes.writeToProto(proto, NotificationChannelProto.AUDIO_ATTRIBUTES);
    }
    proto.write(NotificationChannelProto.IS_BLOCKABLE_SYSTEM, mBlockableSystem);

    proto.end(token);
}
 
Example 16
Source File: IntentResolver.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) {
    long token = proto.start(fieldId);
    writeProtoMap(proto, IntentResolverProto.FULL_MIME_TYPES, mTypeToFilter);
    writeProtoMap(proto, IntentResolverProto.BASE_MIME_TYPES, mBaseTypeToFilter);
    writeProtoMap(proto, IntentResolverProto.WILD_MIME_TYPES, mWildTypeToFilter);
    writeProtoMap(proto, IntentResolverProto.SCHEMES, mSchemeToFilter);
    writeProtoMap(proto, IntentResolverProto.NON_DATA_ACTIONS, mActionToFilter);
    writeProtoMap(proto, IntentResolverProto.MIME_TYPED_ACTIONS, mTypedActionToFilter);
    proto.end(token);
}
 
Example 17
Source File: AnimationAdapter.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
default void writeToProto(ProtoOutputStream proto, long fieldId) {
    final long token = proto.start(fieldId);
    writeToProto(proto);
    proto.end(token);
}
 
Example 18
Source File: DiskStatsService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private void reportCachedValuesProto(ProtoOutputStream proto) {
    try {
        String jsonString = IoUtils.readFileAsString(DISKSTATS_DUMP_FILE);
        JSONObject json = new JSONObject(jsonString);
        long cachedValuesToken = proto.start(DiskStatsServiceDumpProto.CACHED_FOLDER_SIZES);

        proto.write(DiskStatsCachedValuesProto.AGG_APPS_SIZE_KB,
                json.getLong(DiskStatsFileLogger.APP_SIZE_AGG_KEY));
        proto.write(DiskStatsCachedValuesProto.AGG_APPS_DATA_SIZE_KB,
                json.getLong(DiskStatsFileLogger.APP_DATA_SIZE_AGG_KEY));
        proto.write(DiskStatsCachedValuesProto.AGG_APPS_CACHE_SIZE_KB,
                json.getLong(DiskStatsFileLogger.APP_CACHE_AGG_KEY));
        proto.write(DiskStatsCachedValuesProto.PHOTOS_SIZE_KB,
                json.getLong(DiskStatsFileLogger.PHOTOS_KEY));
        proto.write(DiskStatsCachedValuesProto.VIDEOS_SIZE_KB,
                json.getLong(DiskStatsFileLogger.VIDEOS_KEY));
        proto.write(DiskStatsCachedValuesProto.AUDIO_SIZE_KB,
                json.getLong(DiskStatsFileLogger.AUDIO_KEY));
        proto.write(DiskStatsCachedValuesProto.DOWNLOADS_SIZE_KB,
                json.getLong(DiskStatsFileLogger.DOWNLOADS_KEY));
        proto.write(DiskStatsCachedValuesProto.SYSTEM_SIZE_KB,
                json.getLong(DiskStatsFileLogger.SYSTEM_KEY));
        proto.write(DiskStatsCachedValuesProto.OTHER_SIZE_KB,
                json.getLong(DiskStatsFileLogger.MISC_KEY));

        JSONArray packageNamesArray = json.getJSONArray(DiskStatsFileLogger.PACKAGE_NAMES_KEY);
        JSONArray appSizesArray = json.getJSONArray(DiskStatsFileLogger.APP_SIZES_KEY);
        JSONArray appDataSizesArray = json.getJSONArray(DiskStatsFileLogger.APP_DATA_KEY);
        JSONArray cacheSizesArray = json.getJSONArray(DiskStatsFileLogger.APP_CACHES_KEY);
        final int len = packageNamesArray.length();
        if (len == appSizesArray.length()
                && len == appDataSizesArray.length()
                && len == cacheSizesArray.length()) {
            for (int i = 0; i < len; i++) {
                long packageToken = proto.start(DiskStatsCachedValuesProto.APP_SIZES);

                proto.write(DiskStatsAppSizesProto.PACKAGE_NAME,
                        packageNamesArray.getString(i));
                proto.write(DiskStatsAppSizesProto.APP_SIZE_KB, appSizesArray.getLong(i));
                proto.write(DiskStatsAppSizesProto.APP_DATA_SIZE_KB, appDataSizesArray.getLong(i));
                proto.write(DiskStatsAppSizesProto.CACHE_SIZE_KB, cacheSizesArray.getLong(i));

                proto.end(packageToken);
            }
        } else {
            Slog.wtf(TAG, "Sizes of packageNamesArray, appSizesArray, appDataSizesArray "
                    + " and cacheSizesArray are not the same");
        }

        proto.end(cachedValuesToken);
    } catch (IOException | JSONException e) {
        Log.w(TAG, "exception reading diskstats cache file", e);
    }
}
 
Example 19
Source File: SharedUserSetting.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public void writeToProto(ProtoOutputStream proto, long fieldId) {
    long token = proto.start(fieldId);
    proto.write(PackageServiceDumpProto.SharedUserProto.USER_ID, userId);
    proto.write(PackageServiceDumpProto.SharedUserProto.NAME, name);
    proto.end(token);
}
 
Example 20
Source File: WindowSurfaceController.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
void writeToProto(ProtoOutputStream proto, long fieldId) {
    final long token = proto.start(fieldId);
    proto.write(SHOWN, mSurfaceShown);
    proto.write(LAYER, mSurfaceLayer);
    proto.end(token);
}