Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 449e7d62 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Implement activity --proto --processes"

parents 192e0870 148d7f42
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.os.Parcel;
import android.os.ParcelFileDescriptor;
import android.os.Parcelable;
import android.util.Slog;
import android.util.proto.ProtoOutputStream;

import java.io.IOException;
import java.util.Objects;
@@ -124,6 +125,20 @@ public class ProfilerInfo implements Parcelable {
        out.writeBoolean(attachAgentDuringBind);
    }

    /** @hide */
    public void writeToProto(ProtoOutputStream proto, long fieldId) {
        final long token = proto.start(fieldId);
        proto.write(ProfilerInfoProto.PROFILE_FILE, profileFile);
        if (profileFd != null) {
            proto.write(ProfilerInfoProto.PROFILE_FD, profileFd.getFd());
        }
        proto.write(ProfilerInfoProto.SAMPLING_INTERVAL, samplingInterval);
        proto.write(ProfilerInfoProto.AUTO_STOP_PROFILER, autoStopProfiler);
        proto.write(ProfilerInfoProto.STREAMING_OUTPUT, streamingOutput);
        proto.write(ProfilerInfoProto.AGENT, agent);
        proto.end(token);
    }

    public static final Parcelable.Creator<ProfilerInfo> CREATOR =
            new Parcelable.Creator<ProfilerInfo>() {
                @Override
+100 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.os.storage.StorageManager;
import android.text.TextUtils;
import android.util.Printer;
import android.util.SparseArray;
import android.util.proto.ProtoOutputStream;

import com.android.internal.util.ArrayUtils;

@@ -1183,6 +1184,105 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        super.dumpBack(pw, prefix);
    }

    /** {@hide} */
    public void writeToProto(ProtoOutputStream proto, long fieldId, int dumpFlags) {
        long token = proto.start(fieldId);
        super.writeToProto(proto, ApplicationInfoProto.PACKAGE);
        proto.write(ApplicationInfoProto.PERMISSION, permission);
        proto.write(ApplicationInfoProto.PROCESS_NAME, processName);
        proto.write(ApplicationInfoProto.UID, uid);
        proto.write(ApplicationInfoProto.FLAGS, flags);
        proto.write(ApplicationInfoProto.PRIVATE_FLAGS, privateFlags);
        proto.write(ApplicationInfoProto.THEME, theme);
        proto.write(ApplicationInfoProto.SOURCE_DIR, sourceDir);
        if (!Objects.equals(sourceDir, publicSourceDir)) {
            proto.write(ApplicationInfoProto.PUBLIC_SOURCE_DIR, publicSourceDir);
        }
        if (!ArrayUtils.isEmpty(splitSourceDirs)) {
            for (String dir : splitSourceDirs) {
                proto.write(ApplicationInfoProto.SPLIT_SOURCE_DIRS, dir);
            }
        }
        if (!ArrayUtils.isEmpty(splitPublicSourceDirs)
                && !Arrays.equals(splitSourceDirs, splitPublicSourceDirs)) {
            for (String dir : splitPublicSourceDirs) {
                proto.write(ApplicationInfoProto.SPLIT_PUBLIC_SOURCE_DIRS, dir);
            }
        }
        if (resourceDirs != null) {
            for (String dir : resourceDirs) {
                proto.write(ApplicationInfoProto.RESOURCE_DIRS, dir);
            }
        }
        proto.write(ApplicationInfoProto.DATA_DIR, dataDir);
        proto.write(ApplicationInfoProto.CLASS_LOADER_NAME, classLoaderName);
        if (!ArrayUtils.isEmpty(splitClassLoaderNames)) {
            for (String name : splitClassLoaderNames) {
                proto.write(ApplicationInfoProto.SPLIT_CLASS_LOADER_NAMES, name);
            }
        }

        long versionToken = proto.start(ApplicationInfoProto.VERSION);
        proto.write(ApplicationInfoProto.Version.ENABLED, enabled);
        proto.write(ApplicationInfoProto.Version.MIN_SDK_VERSION, minSdkVersion);
        proto.write(ApplicationInfoProto.Version.TARGET_SDK_VERSION, targetSdkVersion);
        proto.write(ApplicationInfoProto.Version.VERSION_CODE, versionCode);
        proto.write(ApplicationInfoProto.Version.TARGET_SANDBOX_VERSION, targetSandboxVersion);
        proto.end(versionToken);

        if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
            long detailToken = proto.start(ApplicationInfoProto.DETAIL);
            if (className != null) {
                proto.write(ApplicationInfoProto.Detail.CLASS_NAME, className);
            }
            proto.write(ApplicationInfoProto.Detail.TASK_AFFINITY, taskAffinity);
            proto.write(ApplicationInfoProto.Detail.REQUIRES_SMALLEST_WIDTH_DP,
                    requiresSmallestWidthDp);
            proto.write(ApplicationInfoProto.Detail.COMPATIBLE_WIDTH_LIMIT_DP,
                    compatibleWidthLimitDp);
            proto.write(ApplicationInfoProto.Detail.LARGEST_WIDTH_LIMIT_DP,
                    largestWidthLimitDp);
            if (seInfo != null) {
                proto.write(ApplicationInfoProto.Detail.SEINFO, seInfo);
                proto.write(ApplicationInfoProto.Detail.SEINFO_USER, seInfoUser);
            }
            proto.write(ApplicationInfoProto.Detail.DEVICE_PROTECTED_DATA_DIR,
                    deviceProtectedDataDir);
            proto.write(ApplicationInfoProto.Detail.CREDENTIAL_PROTECTED_DATA_DIR,
                    credentialProtectedDataDir);
            if (sharedLibraryFiles != null) {
                for (String f : sharedLibraryFiles) {
                    proto.write(ApplicationInfoProto.Detail.SHARED_LIBRARY_FILES, f);
                }
            }
            if (manageSpaceActivityName != null) {
                proto.write(ApplicationInfoProto.Detail.MANAGE_SPACE_ACTIVITY_NAME,
                        manageSpaceActivityName);
            }
            if (descriptionRes != 0) {
                proto.write(ApplicationInfoProto.Detail.DESCRIPTION_RES, descriptionRes);
            }
            if (uiOptions != 0) {
                proto.write(ApplicationInfoProto.Detail.UI_OPTIONS, uiOptions);
            }
            proto.write(ApplicationInfoProto.Detail.SUPPORTS_RTL, hasRtlSupport());
            if (fullBackupContent > 0) {
                proto.write(ApplicationInfoProto.Detail.CONTENT, "@xml/" + fullBackupContent);
            } else {
                proto.write(ApplicationInfoProto.Detail.IS_FULL_BACKUP, fullBackupContent == 0);
            }
            if (networkSecurityConfigRes != 0) {
                proto.write(ApplicationInfoProto.Detail.NETWORK_SECURITY_CONFIG_RES,
                        networkSecurityConfigRes);
            }
            if (category != CATEGORY_UNDEFINED) {
                proto.write(ApplicationInfoProto.Detail.CATEGORY, category);
            }
            proto.end(detailToken);
        }
        proto.end(token);
    }

    /**
     * @return true if "supportsRtl" has been set to true in the AndroidManifest
     * @hide
+20 −1
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package android.content.pm;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.content.res.XmlResourceParser;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Parcel;
@@ -28,6 +27,8 @@ import android.text.Html;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.Printer;
import android.util.proto.ProtoOutputStream;

import java.text.Collator;
import java.util.Comparator;

@@ -386,6 +387,24 @@ public class PackageItemInfo {
        dest.writeInt(showUserIcon);
    }

    /**
     * @hide
     */
    public void writeToProto(ProtoOutputStream proto, long fieldId) {
        long token = proto.start(fieldId);
        if (name != null) {
            proto.write(PackageItemInfoProto.NAME, name);
        }
        proto.write(PackageItemInfoProto.PACKAGE_NAME, packageName);
        if (labelRes != 0 || nonLocalizedLabel != null || icon != 0 || banner != 0) {
            proto.write(PackageItemInfoProto.LABEL_RES, labelRes);
            proto.write(PackageItemInfoProto.NON_LOCALIZED_LABEL, nonLocalizedLabel.toString());
            proto.write(PackageItemInfoProto.ICON, icon);
            proto.write(PackageItemInfoProto.BANNER, banner);
        }
        proto.end(token);
    }

    protected PackageItemInfo(Parcel source) {
        name = source.readString();
        packageName = source.readString();
+16 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.content.Context;
import android.util.Log;
import android.util.proto.ProtoOutputStream;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -1652,6 +1653,21 @@ public final class PowerManager {
            }
        }

        /** @hide */
        public void writeToProto(ProtoOutputStream proto, long fieldId) {
            synchronized (mToken) {
                final long token = proto.start(fieldId);
                proto.write(PowerManagerProto.WakeLockProto.HEX_STRING,
                        Integer.toHexString(System.identityHashCode(this)));
                proto.write(PowerManagerProto.WakeLockProto.HELD, mHeld);
                proto.write(PowerManagerProto.WakeLockProto.INTERNAL_COUNT, mInternalCount);
                if (mWorkSource != null) {
                    mWorkSource.writeToProto(proto, PowerManagerProto.WakeLockProto.WORK_SOURCE);
                }
                proto.end(token);
            }
        }

        /**
         * Wraps a Runnable such that this method immediately acquires the wake lock and then
         * once the Runnable is done the wake lock is released.
+18 −0
Original line number Diff line number Diff line
@@ -70,6 +70,24 @@ public abstract class PowerManagerInternal {
        }
    }

    /**
     * Converts platform constants to proto enums.
     */
    public static int wakefulnessToProtoEnum(int wakefulness) {
        switch (wakefulness) {
            case WAKEFULNESS_ASLEEP:
                return PowerManagerInternalProto.WAKEFULNESS_ASLEEP;
            case WAKEFULNESS_AWAKE:
                return PowerManagerInternalProto.WAKEFULNESS_AWAKE;
            case WAKEFULNESS_DREAMING:
                return PowerManagerInternalProto.WAKEFULNESS_DREAMING;
            case WAKEFULNESS_DOZING:
                return PowerManagerInternalProto.WAKEFULNESS_DOZING;
            default:
                return wakefulness;
        }
    }

    /**
     * Returns true if the wakefulness state represents an interactive state
     * as defined by {@link android.os.PowerManager#isInteractive}.
Loading