Java Code Examples for android.util.proto.ProtoOutputStream#write()
The following examples show how to use
android.util.proto.ProtoOutputStream#write() .
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: AlarmManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
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 2
Source File: SettingsProtoDumpUtil.java From Study_Android_Demo with Apache License 2.0 | 6 votes |
/** * Dump all settings of a user as a proto buf. * * @param settingsRegistry * @param user The user the settings should be dumped for * @param proto The proto buf stream to dump to */ private static void dumpProtoUserSettingsLocked( SettingsProvider.SettingsRegistry settingsRegistry, @NonNull UserHandle user, @NonNull ProtoOutputStream proto) { proto.write(UserSettingsProto.USER_ID, user.getIdentifier()); SettingsState secureSettings = settingsRegistry.getSettingsLocked( SettingsProvider.SETTINGS_TYPE_SECURE, user.getIdentifier()); long secureSettingsToken = proto.start(UserSettingsProto.SECURE_SETTINGS); dumpProtoSecureSettingsLocked(secureSettings, proto); proto.end(secureSettingsToken); SettingsState systemSettings = settingsRegistry.getSettingsLocked( SettingsProvider.SETTINGS_TYPE_SYSTEM, user.getIdentifier()); long systemSettingsToken = proto.start(UserSettingsProto.SYSTEM_SETTINGS); dumpProtoSystemSettingsLocked(systemSettings, proto); proto.end(systemSettingsToken); }
Example 3
Source File: ServiceRecord.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
public void writeToProto(ProtoOutputStream proto, long fieldId, long now) { long token = proto.start(fieldId); proto.write(ServiceRecordProto.StartItem.ID, id); ProtoUtils.toDuration(proto, ServiceRecordProto.StartItem.DURATION, deliveredTime, now); proto.write(ServiceRecordProto.StartItem.DELIVERY_COUNT, deliveryCount); proto.write(ServiceRecordProto.StartItem.DONE_EXECUTING_COUNT, doneExecutingCount); if (intent != null) { intent.writeToProto(proto, ServiceRecordProto.StartItem.INTENT, true, true, true, false); } if (neededGrants != null) { neededGrants.writeToProto(proto, ServiceRecordProto.StartItem.NEEDED_GRANTS); } if (uriPermissions != null) { uriPermissions.writeToProto(proto, ServiceRecordProto.StartItem.URI_PERMISSIONS); } proto.end(token); }
Example 4
Source File: ReceiverList.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
void writeToProto(ProtoOutputStream proto, long fieldId) { long token = proto.start(fieldId); app.writeToProto(proto, ReceiverListProto.APP); proto.write(ReceiverListProto.PID, pid); proto.write(ReceiverListProto.UID, uid); proto.write(ReceiverListProto.USER, userId); if (curBroadcast != null) { curBroadcast.writeToProto(proto, ReceiverListProto.CURRENT); } proto.write(ReceiverListProto.LINKED_TO_DEATH, linkedToDeath); final int N = size(); for (int i=0; i<N; i++) { BroadcastFilter bf = get(i); bf.writeToProto(proto, ReceiverListProto.FILTERS); } proto.write(ReceiverListProto.HEX_HASH, Integer.toHexString(System.identityHashCode(this))); proto.end(token); }
Example 5
Source File: WindowTracing.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
void startTrace(@Nullable PrintWriter pw) throws IOException { if (IS_USER){ logAndPrintln(pw, "Error: Tracing is not supported on user builds."); return; } synchronized (mLock) { logAndPrintln(pw, "Start tracing to " + mTraceFile + "."); mWriteQueue.clear(); mTraceFile.delete(); try (OutputStream os = new FileOutputStream(mTraceFile)) { mTraceFile.setReadable(true, false); ProtoOutputStream proto = new ProtoOutputStream(os); proto.write(MAGIC_NUMBER, MAGIC_NUMBER_VALUE); proto.flush(); } mEnabled = mEnabledLockFree = true; } }
Example 6
Source File: ActivityRecord.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
void writeIdentifierToProto(ProtoOutputStream proto, long fieldId) { final long token = proto.start(fieldId); proto.write(HASH_CODE, System.identityHashCode(this)); proto.write(USER_ID, userId); proto.write(TITLE, intent.getComponent().flattenToShortString()); proto.end(token); }
Example 7
Source File: AlarmManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
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 8
Source File: WindowContainer.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Write to a protocol buffer output stream. Protocol buffer message definition is at * {@link com.android.server.wm.WindowContainerProto}. * * @param proto Stream to write the WindowContainer object to. * @param fieldId Field Id of the WindowContainer as defined in the parent message. * @param trim If true, reduce the amount of data written. * @hide */ @CallSuper @Override public void writeToProto(ProtoOutputStream proto, long fieldId, boolean trim) { final long token = proto.start(fieldId); super.writeToProto(proto, CONFIGURATION_CONTAINER, trim); proto.write(ORIENTATION, mOrientation); proto.write(VISIBLE, isVisible()); mSurfaceAnimator.writeToProto(proto, SURFACE_ANIMATOR); proto.end(token); }
Example 9
Source File: ManagedServices.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
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 10
Source File: Condition.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** @hide */ public void writeToProto(ProtoOutputStream proto, long fieldId) { final long token = proto.start(fieldId); // id is guarantreed not to be null. proto.write(ConditionProto.ID, id.toString()); proto.write(ConditionProto.SUMMARY, summary); proto.write(ConditionProto.LINE_1, line1); proto.write(ConditionProto.LINE_2, line2); proto.write(ConditionProto.ICON, icon); proto.write(ConditionProto.STATE, state); proto.write(ConditionProto.FLAGS, flags); proto.end(token); }
Example 11
Source File: AppBindRecord.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
void writeToProto(ProtoOutputStream proto, long fieldId) { long token = proto.start(fieldId); proto.write(AppBindRecordProto.SERVICE_NAME, service.shortName); proto.write(AppBindRecordProto.CLIENT_PROC_NAME, client.processName); final int N = connections.size(); for (int i=0; i<N; i++) { ConnectionRecord conn = connections.valueAt(i); proto.write(AppBindRecordProto.CONNECTIONS, Integer.toHexString(System.identityHashCode(conn))); } proto.end(token); }
Example 12
Source File: BatteryService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
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(); }
Example 13
Source File: IntentResolver.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
void writeProtoMap(ProtoOutputStream proto, long fieldId, ArrayMap<String, F[]> map) { int N = map.size(); for (int mapi = 0; mapi < N; mapi++) { long token = proto.start(fieldId); proto.write(IntentResolverProto.ArrayMapEntry.KEY, map.keyAt(mapi)); for (F f : map.valueAt(mapi)) { if (f != null) { proto.write(IntentResolverProto.ArrayMapEntry.VALUES, f.toString()); } } proto.end(token); } }
Example 14
Source File: JobPackageTracker.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
public void dumpHistory(ProtoOutputStream proto, long fieldId, int filterUid) { final int size = mEventIndices.size(); if (size == 0) { return; } final long token = proto.start(fieldId); 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 long heToken = proto.start(JobPackageHistoryProto.HISTORY_EVENT); proto.write(JobPackageHistoryProto.HistoryEvent.EVENT, cmd); proto.write(JobPackageHistoryProto.HistoryEvent.TIME_SINCE_EVENT_MS, now - mEventTimes[index]); proto.write(JobPackageHistoryProto.HistoryEvent.UID, uid); proto.write(JobPackageHistoryProto.HistoryEvent.JOB_ID, mEventJobIds[index]); proto.write(JobPackageHistoryProto.HistoryEvent.TAG, mEventTags[index]); if (cmd == EVENT_STOP_JOB || cmd == EVENT_STOP_PERIODIC_JOB) { proto.write(JobPackageHistoryProto.HistoryEvent.STOP_REASON, (mEventCmds[index] & EVENT_STOP_REASON_MASK) >> EVENT_STOP_REASON_SHIFT); } proto.end(heToken); } proto.end(token); }
Example 15
Source File: JobStatus.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Convenience function to dump data that identifies a job uniquely to proto. This is intended * to mimic {@link #toShortString}. */ public void writeToShortProto(ProtoOutputStream proto, long fieldId) { final long token = proto.start(fieldId); proto.write(JobStatusShortInfoProto.CALLING_UID, callingUid); proto.write(JobStatusShortInfoProto.JOB_ID, job.getId()); proto.write(JobStatusShortInfoProto.BATTERY_NAME, batteryName); proto.end(token); }
Example 16
Source File: BatteryController.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@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 17
Source File: ActivityRecord.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
public void writeToProto(ProtoOutputStream proto, long fieldId) { final long token = proto.start(fieldId); super.writeToProto(proto, CONFIGURATION_CONTAINER, false /* trim */); writeIdentifierToProto(proto, IDENTIFIER); proto.write(STATE, mState.toString()); proto.write(VISIBLE, visible); proto.write(FRONT_OF_TASK, frontOfTask); if (app != null) { proto.write(PROC_ID, app.pid); } proto.write(TRANSLUCENT, !fullscreen); proto.end(token); }
Example 18
Source File: UserState.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
void writeToProto(ProtoOutputStream proto, long fieldId) { final long token = proto.start(fieldId); proto.write(UserStateProto.STATE, stateToProtoEnum(state)); proto.write(UserStateProto.SWITCHING, switching); proto.end(token); }
Example 19
Source File: WindowSurfaceController.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
void writeToProto(ProtoOutputStream proto, long fieldId) { final long token = proto.start(fieldId); proto.write(SHOWN, mSurfaceShown); proto.write(LAYER, mSurfaceLayer); proto.end(token); }
Example 20
Source File: DiskStatsService.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
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); } }