// Signature format: 2.0
package android {

  public static final class Manifest.permission {
    field public static final String ACTIVITY_EMBEDDING = "android.permission.ACTIVITY_EMBEDDING";
    field public static final String BRIGHTNESS_SLIDER_USAGE = "android.permission.BRIGHTNESS_SLIDER_USAGE";
    field public static final String CONFIGURE_DISPLAY_BRIGHTNESS = "android.permission.CONFIGURE_DISPLAY_BRIGHTNESS";
    field public static final String MANAGE_ACTIVITY_STACKS = "android.permission.MANAGE_ACTIVITY_STACKS";
  }

}

package android.animation {

  public class ValueAnimator extends android.animation.Animator {
    method public static float getDurationScale();
    method public static void setDurationScale(float);
  }

}

package android.app {

  public class ActivityManager {
    method @RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS) public void addOnUidImportanceListener(android.app.ActivityManager.OnUidImportanceListener, int);
    method public void alwaysShowUnsupportedCompileSdkWarning(android.content.ComponentName);
    method @RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS) public int getPackageImportance(String);
    method public long getTotalRam();
    method @RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS) public int getUidImportance(int);
    method @RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS) public void removeOnUidImportanceListener(android.app.ActivityManager.OnUidImportanceListener);
    method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) public void removeStacksInWindowingModes(int[]) throws java.lang.SecurityException;
    method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) public void removeStacksWithActivityTypes(int[]) throws java.lang.SecurityException;
    method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) public void resizeStack(int, android.graphics.Rect) throws java.lang.SecurityException;
    method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) public void setTaskWindowingMode(int, int, boolean) throws java.lang.SecurityException;
    method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) public void setTaskWindowingModeSplitScreenPrimary(int, int, boolean, boolean, android.graphics.Rect, boolean) throws java.lang.SecurityException;
    method public static boolean supportsMultiWindow(android.content.Context);
    method public static boolean supportsSplitScreenMultiWindow(android.content.Context);
    field public static final int SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT = 1; // 0x1
    field public static final int SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT = 0; // 0x0
  }

  public static interface ActivityManager.OnUidImportanceListener {
    method public void onUidImportance(int, int);
  }

  public static class ActivityManager.StackId {
    field public static final int INVALID_STACK_ID = -1; // 0xffffffff
  }

  public static class ActivityManager.TaskDescription implements android.os.Parcelable {
    method public String getIconFilename();
    method public int getIconResource();
  }

  public class ActivityOptions {
    method public void setLaunchActivityType(int);
    method public void setLaunchTaskId(int);
    method public void setLaunchWindowingMode(int);
    method public void setTaskOverlay(boolean, boolean);
  }

  public class AppOpsManager {
    method public static String[] getOpStrs();
    method public boolean isOperationActive(int, int, String);
    method @RequiresPermission("android.permission.MANAGE_APP_OPS_MODES") public void setMode(int, int, String, int);
    method public void startWatchingActive(@NonNull int[], @NonNull android.app.AppOpsManager.OnOpActiveChangedListener);
    method public void stopWatchingActive(@NonNull android.app.AppOpsManager.OnOpActiveChangedListener);
    field public static final String OPSTR_ACCEPT_HANDOVER = "android:accept_handover";
    field public static final String OPSTR_ACCESS_NOTIFICATIONS = "android:access_notifications";
    field public static final String OPSTR_ACTIVATE_VPN = "android:activate_vpn";
    field public static final String OPSTR_ASSIST_SCREENSHOT = "android:assist_screenshot";
    field public static final String OPSTR_ASSIST_STRUCTURE = "android:assist_structure";
    field public static final String OPSTR_AUDIO_ACCESSIBILITY_VOLUME = "android:audio_accessibility_volume";
    field public static final String OPSTR_AUDIO_ALARM_VOLUME = "android:audio_alarm_volume";
    field public static final String OPSTR_AUDIO_BLUETOOTH_VOLUME = "android:audio_bluetooth_volume";
    field public static final String OPSTR_AUDIO_MASTER_VOLUME = "android:audio_master_volume";
    field public static final String OPSTR_AUDIO_MEDIA_VOLUME = "android:audio_media_volume";
    field public static final String OPSTR_AUDIO_NOTIFICATION_VOLUME = "android:audio_notification_volume";
    field public static final String OPSTR_AUDIO_RING_VOLUME = "android:audio_ring_volume";
    field public static final String OPSTR_AUDIO_VOICE_VOLUME = "android:audio_voice_volume";
    field public static final String OPSTR_BIND_ACCESSIBILITY_SERVICE = "android:bind_accessibility_service";
    field public static final String OPSTR_CHANGE_WIFI_STATE = "android:change_wifi_state";
    field public static final String OPSTR_GET_ACCOUNTS = "android:get_accounts";
    field public static final String OPSTR_GPS = "android:gps";
    field public static final String OPSTR_INSTANT_APP_START_FOREGROUND = "android:instant_app_start_foreground";
    field public static final String OPSTR_MANAGE_IPSEC_TUNNELS = "android:manage_ipsec_tunnels";
    field public static final String OPSTR_MUTE_MICROPHONE = "android:mute_microphone";
    field public static final String OPSTR_NEIGHBORING_CELLS = "android:neighboring_cells";
    field public static final String OPSTR_PLAY_AUDIO = "android:play_audio";
    field public static final String OPSTR_POST_NOTIFICATION = "android:post_notification";
    field public static final String OPSTR_PROJECT_MEDIA = "android:project_media";
    field public static final String OPSTR_READ_CLIPBOARD = "android:read_clipboard";
    field public static final String OPSTR_READ_ICC_SMS = "android:read_icc_sms";
    field public static final String OPSTR_RECEIVE_EMERGENCY_BROADCAST = "android:receive_emergency_broadcast";
    field public static final String OPSTR_REQUEST_DELETE_PACKAGES = "android:request_delete_packages";
    field public static final String OPSTR_REQUEST_INSTALL_PACKAGES = "android:request_install_packages";
    field public static final String OPSTR_RUN_ANY_IN_BACKGROUND = "android:run_any_in_background";
    field public static final String OPSTR_RUN_IN_BACKGROUND = "android:run_in_background";
    field public static final String OPSTR_START_FOREGROUND = "android:start_foreground";
    field public static final String OPSTR_TAKE_AUDIO_FOCUS = "android:take_audio_focus";
    field public static final String OPSTR_TAKE_MEDIA_BUTTONS = "android:take_media_buttons";
    field public static final String OPSTR_TOAST_WINDOW = "android:toast_window";
    field public static final String OPSTR_TURN_SCREEN_ON = "android:turn_screen_on";
    field public static final String OPSTR_VIBRATE = "android:vibrate";
    field public static final String OPSTR_WAKE_LOCK = "android:wake_lock";
    field public static final String OPSTR_WIFI_SCAN = "android:wifi_scan";
    field public static final String OPSTR_WRITE_CLIPBOARD = "android:write_clipboard";
    field public static final String OPSTR_WRITE_ICC_SMS = "android:write_icc_sms";
    field public static final String OPSTR_WRITE_SMS = "android:write_sms";
    field public static final String OPSTR_WRITE_WALLPAPER = "android:write_wallpaper";
    field public static final int OP_RECORD_AUDIO = 27; // 0x1b
    field public static final int OP_SYSTEM_ALERT_WINDOW = 24; // 0x18
  }

  public static interface AppOpsManager.OnOpActiveChangedListener {
    method public void onOpActiveChanged(int, int, String, boolean);
  }

  public final class NotificationChannelGroup implements android.os.Parcelable {
    method public void setBlocked(boolean);
  }

  public class NotificationManager {
    method public android.content.ComponentName getEffectsSuppressor();
  }

  public class TimePickerDialog extends android.app.AlertDialog implements android.content.DialogInterface.OnClickListener android.widget.TimePicker.OnTimeChangedListener {
    method public android.widget.TimePicker getTimePicker();
  }

  public final class UiAutomation {
    method public void destroy();
    method public android.os.ParcelFileDescriptor[] executeShellCommandRw(String);
    method @Deprecated public boolean grantRuntimePermission(String, String, android.os.UserHandle);
    method @Deprecated public boolean revokeRuntimePermission(String, String, android.os.UserHandle);
  }

  public class UiModeManager {
    method public boolean isNightModeLocked();
    method public boolean isUiModeLocked();
  }

  public class WindowConfiguration implements java.lang.Comparable<android.app.WindowConfiguration> android.os.Parcelable {
    ctor public WindowConfiguration();
    method public int compareTo(android.app.WindowConfiguration);
    method public int describeContents();
    method public int getActivityType();
    method public android.graphics.Rect getAppBounds();
    method public android.graphics.Rect getBounds();
    method public int getWindowingMode();
    method public void setActivityType(int);
    method public void setAppBounds(android.graphics.Rect);
    method public void setBounds(android.graphics.Rect);
    method public void setTo(android.app.WindowConfiguration);
    method public void setWindowingMode(int);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final int ACTIVITY_TYPE_ASSISTANT = 4; // 0x4
    field public static final int ACTIVITY_TYPE_HOME = 2; // 0x2
    field public static final int ACTIVITY_TYPE_RECENTS = 3; // 0x3
    field public static final int ACTIVITY_TYPE_STANDARD = 1; // 0x1
    field public static final int ACTIVITY_TYPE_UNDEFINED = 0; // 0x0
    field public static final int WINDOWING_MODE_FREEFORM = 5; // 0x5
    field public static final int WINDOWING_MODE_FULLSCREEN = 1; // 0x1
    field public static final int WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY = 4; // 0x4
    field public static final int WINDOWING_MODE_PINNED = 2; // 0x2
    field public static final int WINDOWING_MODE_SPLIT_SCREEN_PRIMARY = 3; // 0x3
    field public static final int WINDOWING_MODE_SPLIT_SCREEN_SECONDARY = 4; // 0x4
    field public static final int WINDOWING_MODE_UNDEFINED = 0; // 0x0
  }

}

package android.app.admin {

  public class DevicePolicyManager {
    method @Nullable public CharSequence getDeviceOwnerOrganizationName();
    method public long getLastBugReportRequestTime();
    method public long getLastNetworkLogRetrievalTime();
    method public long getLastSecurityLogRetrievalTime();
    method public java.util.List<java.lang.String> getOwnerInstalledCaCerts(@NonNull android.os.UserHandle);
    method public boolean isCurrentInputMethodSetByOwner();
    method public boolean isDeviceManaged();
    field public static final String ACCOUNT_FEATURE_DEVICE_OR_PROFILE_OWNER_ALLOWED = "android.account.DEVICE_OR_PROFILE_OWNER_ALLOWED";
    field public static final String ACCOUNT_FEATURE_DEVICE_OR_PROFILE_OWNER_DISALLOWED = "android.account.DEVICE_OR_PROFILE_OWNER_DISALLOWED";
    field public static final String ACTION_DATA_SHARING_RESTRICTION_APPLIED = "android.app.action.DATA_SHARING_RESTRICTION_APPLIED";
    field public static final String EXTRA_RESTRICTION = "android.app.extra.RESTRICTION";
  }

  public static final class SecurityLog.SecurityEvent implements android.os.Parcelable {
    ctor public SecurityLog.SecurityEvent(long, byte[]);
  }

}

package android.app.backup {

  public class BackupManager {
    method @RequiresPermission("android.permission.BACKUP") public android.content.Intent getConfigurationIntent(String);
    method @RequiresPermission("android.permission.BACKUP") public android.content.Intent getDataManagementIntent(String);
    method @RequiresPermission("android.permission.BACKUP") public String getDataManagementLabel(String);
    method @RequiresPermission("android.permission.BACKUP") public String getDestinationString(String);
  }

}

package android.app.usage {

  public class NetworkStatsManager {
    method public void setPollForce(boolean);
  }

  public class StorageStatsManager {
    method public boolean isQuotaSupported(@NonNull java.util.UUID);
    method public boolean isReservedSupported(@NonNull java.util.UUID);
  }

}

package android.bluetooth {

  public final class BluetoothClass implements android.os.Parcelable {
    method public int getClassOfDevice();
  }

}

package android.content {

  public abstract class ContentResolver {
    method public static String[] getSyncAdapterPackagesForAuthorityAsUser(String, int);
  }

  public abstract class Context {
    method public android.os.UserHandle getUser();
    method public int getUserId();
    method public void setAutofillCompatibilityEnabled(boolean);
  }

}

package android.content.pm {

  public class ActivityInfo extends android.content.pm.ComponentInfo implements android.os.Parcelable {
    method public static boolean isTranslucentOrFloating(android.content.res.TypedArray);
    field public static final int RESIZE_MODE_RESIZEABLE = 2; // 0x2
  }

  public class ApplicationInfo extends android.content.pm.PackageItemInfo implements android.os.Parcelable {
    method public boolean isPrivilegedApp();
    method public boolean isSystemApp();
  }

  public class LauncherApps {
    ctor public LauncherApps(android.content.Context);
  }

  public abstract class PackageManager {
    method @RequiresPermission("android.permission.INTERACT_ACROSS_USERS_FULL") public abstract String getDefaultBrowserPackageNameAsUser(int);
    method public abstract int getInstallReason(String, @NonNull android.os.UserHandle);
    method public abstract java.util.List<android.content.pm.ApplicationInfo> getInstalledApplicationsAsUser(int, int);
    method @RequiresPermission("android.permission.INTERACT_ACROSS_USERS_FULL") public abstract java.util.List<android.content.pm.PackageInfo> getInstalledPackagesAsUser(int, int);
    method @Nullable public abstract String[] getNamesForUids(int[]);
    method public abstract String getPermissionControllerPackageName();
    method @NonNull public abstract String getServicesSystemSharedLibraryPackageName();
    method @NonNull public abstract String getSharedSystemSharedLibraryPackageName();
    method @RequiresPermission("android.permission.GRANT_RUNTIME_PERMISSIONS") public abstract void grantRuntimePermission(@NonNull String, @NonNull String, @NonNull android.os.UserHandle);
    method public abstract boolean isPermissionReviewModeEnabled();
    method @RequiresPermission("android.permission.REVOKE_RUNTIME_PERMISSIONS") public abstract void revokeRuntimePermission(@NonNull String, @NonNull String, @NonNull android.os.UserHandle);
    field public static final String FEATURE_ADOPTABLE_STORAGE = "android.software.adoptable_storage";
    field public static final String FEATURE_FILE_BASED_ENCRYPTION = "android.software.file_based_encryption";
    field public static final int MATCH_FACTORY_ONLY = 2097152; // 0x200000
    field public static final int MATCH_KNOWN_PACKAGES = 4202496; // 0x402000
  }

  public class PermissionInfo extends android.content.pm.PackageItemInfo implements android.os.Parcelable {
    field public static final int PROTECTION_FLAG_SYSTEM_TEXT_CLASSIFIER = 65536; // 0x10000
    field public static final int PROTECTION_FLAG_VENDOR_PRIVILEGED = 32768; // 0x8000
  }

  public final class ShortcutInfo implements android.os.Parcelable {
    method public boolean isVisibleToPublisher();
  }

  public class ShortcutManager {
    ctor public ShortcutManager(android.content.Context);
  }

}

package android.content.res {

  public final class Configuration implements java.lang.Comparable<android.content.res.Configuration> android.os.Parcelable {
    field public final android.app.WindowConfiguration windowConfiguration;
  }

}

package android.database.sqlite {

  public final class SQLiteDebug {
    method public static void dump(android.util.Printer, String[]);
    method public static android.database.sqlite.SQLiteDebug.PagerStats getDatabaseInfo();
    field public static final boolean DEBUG_SQL_LOG;
    field public static final boolean DEBUG_SQL_STATEMENTS;
    field public static final boolean DEBUG_SQL_TIME;
  }

  public static class SQLiteDebug.DbStats {
    ctor public SQLiteDebug.DbStats(String, long, long, int, int, int, int);
    field public String cache;
    field public String dbName;
    field public long dbSize;
    field public int lookaside;
    field public long pageSize;
  }

  public static class SQLiteDebug.PagerStats {
    ctor public SQLiteDebug.PagerStats();
    field public java.util.ArrayList<android.database.sqlite.SQLiteDebug.DbStats> dbStats;
    field public int largestMemAlloc;
    field public int memoryUsed;
    field public int pageCacheOverflow;
  }

  public final class SQLiteDirectCursorDriver implements android.database.sqlite.SQLiteCursorDriver {
    ctor public SQLiteDirectCursorDriver(android.database.sqlite.SQLiteDatabase, String, String, android.os.CancellationSignal);
    method public void cursorClosed();
    method public void cursorDeactivated();
    method public void cursorRequeried(android.database.Cursor);
    method public android.database.Cursor query(android.database.sqlite.SQLiteDatabase.CursorFactory, String[]);
    method public void setBindArguments(String[]);
  }

  public final class SQLiteGlobal {
    method public static String getDefaultJournalMode();
    method public static int getDefaultPageSize();
    method public static String getDefaultSyncMode();
    method public static int getIdleConnectionTimeout();
    method public static int getJournalSizeLimit();
    method public static int getWALAutoCheckpoint();
    method public static int getWALConnectionPoolSize();
    method public static String getWALSyncMode();
    method public static boolean isCompatibilityWalSupported();
    method public static int releaseMemory();
  }

}

package android.graphics {

  public final class ImageDecoder implements java.lang.AutoCloseable {
    method @AnyThread @NonNull public static android.graphics.ImageDecoder.Source createSource(android.content.res.Resources, java.io.InputStream, int);
  }

}

package android.graphics.drawable {

  public class AdaptiveIconDrawable extends android.graphics.drawable.Drawable implements android.graphics.drawable.Drawable.Callback {
    method public android.graphics.Region getSafeZone();
    field public static final float MASK_SIZE = 100.0f;
  }

  public class ColorDrawable extends android.graphics.drawable.Drawable {
    method public android.graphics.Xfermode getXfermode();
  }

  public abstract class Drawable {
    method public boolean hasFocusStateSpecified();
  }

  public class ShapeDrawable extends android.graphics.drawable.Drawable {
    method public void setXfermode(@Nullable android.graphics.Xfermode);
  }

}

package android.hardware.camera2 {

  public abstract class CameraDevice implements java.lang.AutoCloseable {
    method public abstract void createCustomCaptureSession(android.hardware.camera2.params.InputConfiguration, @NonNull java.util.List<android.hardware.camera2.params.OutputConfiguration>, int, @NonNull android.hardware.camera2.CameraCaptureSession.StateCallback, @Nullable android.os.Handler) throws android.hardware.camera2.CameraAccessException;
    field public static final int SESSION_OPERATION_MODE_CONSTRAINED_HIGH_SPEED = 1; // 0x1
    field public static final int SESSION_OPERATION_MODE_NORMAL = 0; // 0x0
    field public static final int SESSION_OPERATION_MODE_VENDOR_START = 32768; // 0x8000
  }

}

package android.hardware.display {

  public final class AmbientBrightnessDayStats implements android.os.Parcelable {
    method public int describeContents();
    method public float[] getBucketBoundaries();
    method public java.time.LocalDate getLocalDate();
    method public float[] getStats();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.hardware.display.AmbientBrightnessDayStats> CREATOR;
  }

  public final class BrightnessChangeEvent implements android.os.Parcelable {
    method public int describeContents();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.hardware.display.BrightnessChangeEvent> CREATOR;
    field public final float batteryLevel;
    field public final float brightness;
    field public final int colorTemperature;
    field public final boolean isDefaultBrightnessConfig;
    field public final boolean isUserSetBrightness;
    field public final float lastBrightness;
    field public final long[] luxTimestamps;
    field public final float[] luxValues;
    field public final boolean nightMode;
    field public final String packageName;
    field public final float powerBrightnessFactor;
    field public final long timeStamp;
  }

  public final class BrightnessConfiguration implements android.os.Parcelable {
    method public int describeContents();
    method public android.util.Pair<float[],float[]> getCurve();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.hardware.display.BrightnessConfiguration> CREATOR;
  }

  public static class BrightnessConfiguration.Builder {
    ctor public BrightnessConfiguration.Builder(float[], float[]);
    method public android.hardware.display.BrightnessConfiguration build();
    method public android.hardware.display.BrightnessConfiguration.Builder setDescription(@Nullable String);
  }

  public final class DisplayManager {
    method @RequiresPermission("android.permission.ACCESS_AMBIENT_LIGHT_STATS") public java.util.List<android.hardware.display.AmbientBrightnessDayStats> getAmbientBrightnessStats();
    method @RequiresPermission(android.Manifest.permission.CONFIGURE_DISPLAY_BRIGHTNESS) public android.hardware.display.BrightnessConfiguration getBrightnessConfiguration();
    method @RequiresPermission(android.Manifest.permission.BRIGHTNESS_SLIDER_USAGE) public java.util.List<android.hardware.display.BrightnessChangeEvent> getBrightnessEvents();
    method @Nullable @RequiresPermission(android.Manifest.permission.CONFIGURE_DISPLAY_BRIGHTNESS) public android.hardware.display.BrightnessConfiguration getDefaultBrightnessConfiguration();
    method public android.graphics.Point getStableDisplaySize();
    method @RequiresPermission(android.Manifest.permission.CONFIGURE_DISPLAY_BRIGHTNESS) public void setBrightnessConfiguration(android.hardware.display.BrightnessConfiguration);
  }

}

package android.location {

  public final class GnssClock implements android.os.Parcelable {
    ctor public GnssClock();
    method public void reset();
    method public void resetBiasNanos();
    method public void resetBiasUncertaintyNanos();
    method public void resetDriftNanosPerSecond();
    method public void resetDriftUncertaintyNanosPerSecond();
    method public void resetFullBiasNanos();
    method public void resetLeapSecond();
    method public void resetTimeUncertaintyNanos();
    method public void set(android.location.GnssClock);
    method public void setBiasNanos(double);
    method public void setBiasUncertaintyNanos(double);
    method public void setDriftNanosPerSecond(double);
    method public void setDriftUncertaintyNanosPerSecond(double);
    method public void setFullBiasNanos(long);
    method public void setHardwareClockDiscontinuityCount(int);
    method public void setLeapSecond(int);
    method public void setTimeNanos(long);
    method public void setTimeUncertaintyNanos(double);
  }

  public final class GnssMeasurement implements android.os.Parcelable {
    ctor public GnssMeasurement();
    method public void reset();
    method public void resetAutomaticGainControlLevel();
    method @Deprecated public void resetCarrierCycles();
    method public void resetCarrierFrequencyHz();
    method @Deprecated public void resetCarrierPhase();
    method @Deprecated public void resetCarrierPhaseUncertainty();
    method public void resetSnrInDb();
    method public void set(android.location.GnssMeasurement);
    method public void setAccumulatedDeltaRangeMeters(double);
    method public void setAccumulatedDeltaRangeState(int);
    method public void setAccumulatedDeltaRangeUncertaintyMeters(double);
    method public void setAutomaticGainControlLevelInDb(double);
    method @Deprecated public void setCarrierCycles(long);
    method public void setCarrierFrequencyHz(float);
    method @Deprecated public void setCarrierPhase(double);
    method @Deprecated public void setCarrierPhaseUncertainty(double);
    method public void setCn0DbHz(double);
    method public void setConstellationType(int);
    method public void setMultipathIndicator(int);
    method public void setPseudorangeRateMetersPerSecond(double);
    method public void setPseudorangeRateUncertaintyMetersPerSecond(double);
    method public void setReceivedSvTimeNanos(long);
    method public void setReceivedSvTimeUncertaintyNanos(long);
    method public void setSnrInDb(double);
    method public void setState(int);
    method public void setSvid(int);
    method public void setTimeOffsetNanos(double);
    field public static final int ADR_STATE_ALL = 31; // 0x1f
  }

  public final class GnssMeasurementsEvent implements android.os.Parcelable {
    ctor public GnssMeasurementsEvent(android.location.GnssClock, android.location.GnssMeasurement[]);
  }

  public final class GnssNavigationMessage implements android.os.Parcelable {
    ctor public GnssNavigationMessage();
    method public void reset();
    method public void set(android.location.GnssNavigationMessage);
    method public void setData(byte[]);
    method public void setMessageId(int);
    method public void setStatus(int);
    method public void setSubmessageId(int);
    method public void setSvid(int);
    method public void setType(int);
  }

  public class LocationManager {
    method public String[] getBackgroundThrottlingWhitelist();
  }

}

package android.media {

  public final class AudioFocusRequest {
    method @Nullable public android.media.AudioManager.OnAudioFocusChangeListener getOnAudioFocusChangeListener();
  }

  public final class AudioFormat implements android.os.Parcelable {
    method public static int channelCountFromInChannelMask(int);
    method public static int channelCountFromOutChannelMask(int);
    method public static int getBytesPerSample(int);
    method public static boolean isEncodingLinearPcm(int);
  }

  public final class AudioPresentation {
    ctor public AudioPresentation(int, int, @NonNull java.util.Map<java.lang.String,java.lang.String>, @NonNull String, int, boolean, boolean, boolean);
    method public int getPresentationId();
    method public int getProgramId();
  }

  public final class BufferingParams implements android.os.Parcelable {
    method public int describeContents();
    method public int getInitialMarkMs();
    method public int getResumePlaybackMarkMs();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.media.BufferingParams> CREATOR;
  }

  public static class BufferingParams.Builder {
    ctor public BufferingParams.Builder();
    ctor public BufferingParams.Builder(android.media.BufferingParams);
    method public android.media.BufferingParams build();
    method public android.media.BufferingParams.Builder setInitialMarkMs(int);
    method public android.media.BufferingParams.Builder setResumePlaybackMarkMs(int);
  }

  public class MediaPlayer implements android.media.AudioRouting android.media.VolumeAutomation {
    method @NonNull public android.media.BufferingParams getBufferingParams();
    method public void setBufferingParams(@NonNull android.media.BufferingParams);
  }

  public final class PlaybackParams implements android.os.Parcelable {
    method public int getAudioStretchMode();
    method public android.media.PlaybackParams setAudioStretchMode(int);
  }

  public static final class VolumeShaper.Configuration.Builder {
    method @NonNull public android.media.VolumeShaper.Configuration.Builder setOptionFlags(int);
  }

}

package android.media.audiofx {

  public class AudioEffect {
    method public static int byteArrayToInt(byte[]);
    method public static short byteArrayToShort(byte[]);
    method public int getParameter(byte[], byte[]) throws java.lang.IllegalStateException;
    method public int getParameter(int, byte[]) throws java.lang.IllegalStateException;
    method public int getParameter(int, int[]) throws java.lang.IllegalStateException;
    method public int getParameter(int, short[]) throws java.lang.IllegalStateException;
    method public int getParameter(int[], short[]) throws java.lang.IllegalStateException;
    method public static byte[] intToByteArray(int);
    method public static boolean isEffectTypeAvailable(java.util.UUID);
    method public static boolean isError(int);
    method public int setParameter(byte[], byte[]) throws java.lang.IllegalStateException;
    method public int setParameter(int, int) throws java.lang.IllegalStateException;
    method public int setParameter(int, short) throws java.lang.IllegalStateException;
    method public int setParameter(int, byte[]) throws java.lang.IllegalStateException;
    method public int setParameter(int[], int[]) throws java.lang.IllegalStateException;
    method public int setParameter(int[], byte[]) throws java.lang.IllegalStateException;
    method public void setParameterListener(android.media.audiofx.AudioEffect.OnParameterChangeListener);
    method public static byte[] shortToByteArray(short);
    field public static final java.util.UUID EFFECT_TYPE_NULL;
  }

  public static interface AudioEffect.OnParameterChangeListener {
    method public void onParameterChange(android.media.audiofx.AudioEffect, int, byte[], byte[]);
  }

}

package android.net {

  public class CaptivePortal implements android.os.Parcelable {
    ctor public CaptivePortal(android.os.IBinder);
    method public void logEvent(int, String);
    method public void useNetwork();
    field public static final int APP_RETURN_DISMISSED = 0; // 0x0
    field public static final int APP_RETURN_UNWANTED = 1; // 0x1
    field public static final int APP_RETURN_WANTED_AS_IS = 2; // 0x2
  }

  public class ConnectivityManager {
    method @RequiresPermission(android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK) public void startCaptivePortalApp(android.net.Network, android.os.Bundle);
    field public static final String EXTRA_CAPTIVE_PORTAL_PROBE_SPEC = "android.net.extra.CAPTIVE_PORTAL_PROBE_SPEC";
    field public static final String EXTRA_CAPTIVE_PORTAL_USER_AGENT = "android.net.extra.CAPTIVE_PORTAL_USER_AGENT";
  }

  public final class IpPrefix implements android.os.Parcelable {
    ctor public IpPrefix(java.net.InetAddress, int);
    ctor public IpPrefix(String);
  }

  public final class IpSecManager {
    field public static final int INVALID_SECURITY_PARAMETER_INDEX = 0; // 0x0
  }

  public class LinkAddress implements android.os.Parcelable {
    ctor public LinkAddress(java.net.InetAddress, int, int, int);
    ctor public LinkAddress(@NonNull java.net.InetAddress, int);
    ctor public LinkAddress(@NonNull String);
    ctor public LinkAddress(String, int, int);
    method public boolean isGlobalPreferred();
    method public boolean isIPv4();
    method public boolean isIPv6();
    method public boolean isSameAddressAs(android.net.LinkAddress);
  }

  public final class LinkProperties implements android.os.Parcelable {
    ctor public LinkProperties(android.net.LinkProperties);
    method public boolean addDnsServer(java.net.InetAddress);
    method public boolean addLinkAddress(android.net.LinkAddress);
    method @Nullable public android.net.IpPrefix getNat64Prefix();
    method public java.util.List<java.net.InetAddress> getPcscfServers();
    method public String getTcpBufferSizes();
    method public java.util.List<java.net.InetAddress> getValidatedPrivateDnsServers();
    method public boolean hasGlobalIPv6Address();
    method public boolean hasIPv4Address();
    method public boolean hasIPv6DefaultRoute();
    method public boolean isIPv4Provisioned();
    method public boolean isIPv6Provisioned();
    method public boolean isProvisioned();
    method public boolean isReachable(java.net.InetAddress);
    method public boolean removeDnsServer(java.net.InetAddress);
    method public boolean removeLinkAddress(android.net.LinkAddress);
    method public boolean removeRoute(android.net.RouteInfo);
    method public void setNat64Prefix(android.net.IpPrefix);
    method public void setPcscfServers(java.util.Collection<java.net.InetAddress>);
    method public void setPrivateDnsServerName(@Nullable String);
    method public void setTcpBufferSizes(String);
    method public void setUsePrivateDns(boolean);
    method public void setValidatedPrivateDnsServers(java.util.Collection<java.net.InetAddress>);
  }

  public class Network implements android.os.Parcelable {
    ctor public Network(android.net.Network);
    method public android.net.Network getPrivateDnsBypassingCopy();
  }

  public final class NetworkCapabilities implements android.os.Parcelable {
    method public int[] getCapabilities();
    method public int[] getTransportTypes();
    method public boolean satisfiedByNetworkCapabilities(android.net.NetworkCapabilities);
    field public static final int TRANSPORT_TEST = 7; // 0x7
  }

  public class NetworkStack {
    field public static final String PERMISSION_MAINLINE_NETWORK_STACK = "android.permission.MAINLINE_NETWORK_STACK";
  }

  public final class RouteInfo implements android.os.Parcelable {
    ctor public RouteInfo(android.net.IpPrefix, java.net.InetAddress, String, int);
    method public int getType();
    field public static final int RTN_THROW = 9; // 0x9
    field public static final int RTN_UNICAST = 1; // 0x1
    field public static final int RTN_UNREACHABLE = 7; // 0x7
  }

  public final class StaticIpConfiguration implements android.os.Parcelable {
    ctor public StaticIpConfiguration();
    ctor public StaticIpConfiguration(android.net.StaticIpConfiguration);
    method public void addDnsServer(java.net.InetAddress);
    method public void clear();
    method public int describeContents();
    method public java.util.List<java.net.InetAddress> getDnsServers();
    method public String getDomains();
    method public java.net.InetAddress getGateway();
    method public android.net.LinkAddress getIpAddress();
    method public java.util.List<android.net.RouteInfo> getRoutes(String);
    method public void setDomains(String);
    method public void setGateway(java.net.InetAddress);
    method public void setIpAddress(android.net.LinkAddress);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.net.StaticIpConfiguration> CREATOR;
  }

  public class TrafficStats {
    method public static long getLoopbackRxBytes();
    method public static long getLoopbackRxPackets();
    method public static long getLoopbackTxBytes();
    method public static long getLoopbackTxPackets();
    field public static final int TAG_SYSTEM_DHCP = -192; // 0xffffff40
    field public static final int TAG_SYSTEM_DHCP_SERVER = -186; // 0xffffff46
    field public static final int TAG_SYSTEM_PROBE = -190; // 0xffffff42
  }

}

package android.net.apf {

  public class ApfCapabilities {
    ctor public ApfCapabilities(int, int, int);
    method public static boolean getApfDrop8023Frames(android.content.Context);
    method public static int[] getApfEthTypeBlackList(android.content.Context);
    method public boolean hasDataAccess();
    field public final int apfPacketFormat;
    field public final int apfVersionSupported;
    field public final int maximumApfProgramSize;
  }

}

package android.net.captiveportal {

  public final class CaptivePortalProbeResult {
    ctor public CaptivePortalProbeResult(int);
    ctor public CaptivePortalProbeResult(int, String, String);
    ctor public CaptivePortalProbeResult(int, String, String, android.net.captiveportal.CaptivePortalProbeSpec);
    method public boolean isFailed();
    method public boolean isPortal();
    method public boolean isSuccessful();
    field public static final android.net.captiveportal.CaptivePortalProbeResult FAILED;
    field public static final int FAILED_CODE = 599; // 0x257
    field public static final int PORTAL_CODE = 302; // 0x12e
    field public static final android.net.captiveportal.CaptivePortalProbeResult SUCCESS;
    field public static final int SUCCESS_CODE = 204; // 0xcc
    field public final String detectUrl;
    field @Nullable public final android.net.captiveportal.CaptivePortalProbeSpec probeSpec;
    field public final String redirectUrl;
  }

  public abstract class CaptivePortalProbeSpec {
    method public String getEncodedSpec();
    method public abstract android.net.captiveportal.CaptivePortalProbeResult getResult(int, @Nullable String);
    method public java.net.URL getUrl();
    method public static java.util.Collection<android.net.captiveportal.CaptivePortalProbeSpec> parseCaptivePortalProbeSpecs(String);
    method @Nullable public static android.net.captiveportal.CaptivePortalProbeSpec parseSpecOrNull(@Nullable String);
  }

}

package android.net.metrics {

  public final class ApfProgramEvent implements android.net.metrics.IpConnectivityLog.Event {
  }

  public static class ApfProgramEvent.Builder {
    ctor public ApfProgramEvent.Builder();
    method public android.net.metrics.ApfProgramEvent build();
    method public android.net.metrics.ApfProgramEvent.Builder setActualLifetime(long);
    method public android.net.metrics.ApfProgramEvent.Builder setCurrentRas(int);
    method public android.net.metrics.ApfProgramEvent.Builder setFilteredRas(int);
    method public android.net.metrics.ApfProgramEvent.Builder setFlags(boolean, boolean);
    method public android.net.metrics.ApfProgramEvent.Builder setLifetime(long);
    method public android.net.metrics.ApfProgramEvent.Builder setProgramLength(int);
  }

  public final class ApfStats implements android.net.metrics.IpConnectivityLog.Event {
  }

  public static class ApfStats.Builder {
    ctor public ApfStats.Builder();
    method public android.net.metrics.ApfStats build();
    method public android.net.metrics.ApfStats.Builder setDroppedRas(int);
    method public android.net.metrics.ApfStats.Builder setDurationMs(long);
    method public android.net.metrics.ApfStats.Builder setMatchingRas(int);
    method public android.net.metrics.ApfStats.Builder setMaxProgramSize(int);
    method public android.net.metrics.ApfStats.Builder setParseErrors(int);
    method public android.net.metrics.ApfStats.Builder setProgramUpdates(int);
    method public android.net.metrics.ApfStats.Builder setProgramUpdatesAll(int);
    method public android.net.metrics.ApfStats.Builder setProgramUpdatesAllowingMulticast(int);
    method public android.net.metrics.ApfStats.Builder setReceivedRas(int);
    method public android.net.metrics.ApfStats.Builder setZeroLifetimeRas(int);
  }

  public final class DhcpClientEvent implements android.net.metrics.IpConnectivityLog.Event {
  }

  public static class DhcpClientEvent.Builder {
    ctor public DhcpClientEvent.Builder();
    method public android.net.metrics.DhcpClientEvent build();
    method public android.net.metrics.DhcpClientEvent.Builder setDurationMs(int);
    method public android.net.metrics.DhcpClientEvent.Builder setMsg(String);
  }

  public final class DhcpErrorEvent implements android.net.metrics.IpConnectivityLog.Event {
    ctor public DhcpErrorEvent(int);
    method public static int errorCodeWithOption(int, int);
    field public static final int BOOTP_TOO_SHORT;
    field public static final int BUFFER_UNDERFLOW;
    field public static final int DHCP_BAD_MAGIC_COOKIE;
    field public static final int DHCP_ERROR = 4; // 0x4
    field public static final int DHCP_INVALID_OPTION_LENGTH;
    field public static final int DHCP_NO_COOKIE;
    field public static final int DHCP_NO_MSG_TYPE;
    field public static final int DHCP_UNKNOWN_MSG_TYPE;
    field public static final int L2_ERROR = 1; // 0x1
    field public static final int L2_TOO_SHORT;
    field public static final int L2_WRONG_ETH_TYPE;
    field public static final int L3_ERROR = 2; // 0x2
    field public static final int L3_INVALID_IP;
    field public static final int L3_NOT_IPV4;
    field public static final int L3_TOO_SHORT;
    field public static final int L4_ERROR = 3; // 0x3
    field public static final int L4_NOT_UDP;
    field public static final int L4_WRONG_PORT;
    field public static final int MISC_ERROR = 5; // 0x5
    field public static final int PARSING_ERROR;
    field public static final int RECEIVE_ERROR;
  }

  public class IpConnectivityLog {
    ctor public IpConnectivityLog();
    method public boolean log(long, android.net.metrics.IpConnectivityLog.Event);
    method public boolean log(String, android.net.metrics.IpConnectivityLog.Event);
    method public boolean log(android.net.Network, int[], android.net.metrics.IpConnectivityLog.Event);
    method public boolean log(int, int[], android.net.metrics.IpConnectivityLog.Event);
    method public boolean log(android.net.metrics.IpConnectivityLog.Event);
  }

  public static interface IpConnectivityLog.Event extends android.os.Parcelable {
  }

  public final class IpManagerEvent implements android.net.metrics.IpConnectivityLog.Event {
    ctor public IpManagerEvent(int, long);
    field public static final int COMPLETE_LIFECYCLE = 3; // 0x3
    field public static final int ERROR_INTERFACE_NOT_FOUND = 8; // 0x8
    field public static final int ERROR_INVALID_PROVISIONING = 7; // 0x7
    field public static final int ERROR_STARTING_IPREACHABILITYMONITOR = 6; // 0x6
    field public static final int ERROR_STARTING_IPV4 = 4; // 0x4
    field public static final int ERROR_STARTING_IPV6 = 5; // 0x5
    field public static final int PROVISIONING_FAIL = 2; // 0x2
    field public static final int PROVISIONING_OK = 1; // 0x1
  }

  public final class IpReachabilityEvent implements android.net.metrics.IpConnectivityLog.Event {
    ctor public IpReachabilityEvent(int);
    field public static final int NUD_FAILED = 512; // 0x200
    field public static final int NUD_FAILED_ORGANIC = 1024; // 0x400
    field public static final int PROBE = 256; // 0x100
    field public static final int PROVISIONING_LOST = 768; // 0x300
    field public static final int PROVISIONING_LOST_ORGANIC = 1280; // 0x500
  }

  public final class NetworkEvent implements android.net.metrics.IpConnectivityLog.Event {
    ctor public NetworkEvent(int, long);
    ctor public NetworkEvent(int);
    field public static final int NETWORK_CAPTIVE_PORTAL_FOUND = 4; // 0x4
    field public static final int NETWORK_CONNECTED = 1; // 0x1
    field public static final int NETWORK_CONSECUTIVE_DNS_TIMEOUT_FOUND = 12; // 0xc
    field public static final int NETWORK_DISCONNECTED = 7; // 0x7
    field public static final int NETWORK_FIRST_VALIDATION_PORTAL_FOUND = 10; // 0xa
    field public static final int NETWORK_FIRST_VALIDATION_SUCCESS = 8; // 0x8
    field public static final int NETWORK_LINGER = 5; // 0x5
    field public static final int NETWORK_REVALIDATION_PORTAL_FOUND = 11; // 0xb
    field public static final int NETWORK_REVALIDATION_SUCCESS = 9; // 0x9
    field public static final int NETWORK_UNLINGER = 6; // 0x6
    field public static final int NETWORK_VALIDATED = 2; // 0x2
    field public static final int NETWORK_VALIDATION_FAILED = 3; // 0x3
  }

  public final class RaEvent implements android.net.metrics.IpConnectivityLog.Event {
  }

  public static class RaEvent.Builder {
    ctor public RaEvent.Builder();
    method public android.net.metrics.RaEvent build();
    method public android.net.metrics.RaEvent.Builder updateDnsslLifetime(long);
    method public android.net.metrics.RaEvent.Builder updatePrefixPreferredLifetime(long);
    method public android.net.metrics.RaEvent.Builder updatePrefixValidLifetime(long);
    method public android.net.metrics.RaEvent.Builder updateRdnssLifetime(long);
    method public android.net.metrics.RaEvent.Builder updateRouteInfoLifetime(long);
    method public android.net.metrics.RaEvent.Builder updateRouterLifetime(long);
  }

  public final class ValidationProbeEvent implements android.net.metrics.IpConnectivityLog.Event {
    method public static String getProbeName(int);
    field public static final int DNS_FAILURE = 0; // 0x0
    field public static final int DNS_SUCCESS = 1; // 0x1
    field public static final int PROBE_DNS = 0; // 0x0
    field public static final int PROBE_FALLBACK = 4; // 0x4
    field public static final int PROBE_HTTP = 1; // 0x1
    field public static final int PROBE_HTTPS = 2; // 0x2
    field public static final int PROBE_PAC = 3; // 0x3
    field public static final int PROBE_PRIVDNS = 5; // 0x5
  }

  public static class ValidationProbeEvent.Builder {
    ctor public ValidationProbeEvent.Builder();
    method public android.net.metrics.ValidationProbeEvent build();
    method public android.net.metrics.ValidationProbeEvent.Builder setDurationMs(long);
    method public android.net.metrics.ValidationProbeEvent.Builder setProbeType(int, boolean);
    method public android.net.metrics.ValidationProbeEvent.Builder setReturnCode(int);
  }

}

package android.net.util {

  public class SocketUtils {
    method public static void addArpEntry(java.net.Inet4Address, android.net.MacAddress, String, java.io.FileDescriptor) throws java.io.IOException;
    method public static void attachControlPacketFilter(java.io.FileDescriptor, int) throws java.net.SocketException;
    method public static void attachDhcpFilter(java.io.FileDescriptor) throws java.net.SocketException;
    method public static void attachRaFilter(java.io.FileDescriptor, int) throws java.net.SocketException;
    method public static void bindSocket(java.io.FileDescriptor, java.net.SocketAddress) throws android.system.ErrnoException, java.net.SocketException;
    method public static void bindSocketToInterface(java.io.FileDescriptor, String) throws android.system.ErrnoException;
    method public static void closeSocket(java.io.FileDescriptor) throws java.io.IOException;
    method public static void connectSocket(java.io.FileDescriptor, java.net.SocketAddress) throws android.system.ErrnoException, java.net.SocketException;
    method public static java.net.SocketAddress makeNetlinkSocketAddress(int, int);
    method public static java.net.SocketAddress makePacketSocketAddress(short, int);
    method public static java.net.SocketAddress makePacketSocketAddress(int, byte[]);
    method public static void sendTo(java.io.FileDescriptor, byte[], int, int, int, java.net.SocketAddress) throws android.system.ErrnoException, java.net.SocketException;
    method public static void setSocketTimeValueOption(java.io.FileDescriptor, int, int, long) throws android.system.ErrnoException;
  }

}

package android.os {

  public static class Build.VERSION {
    field public static final int FIRST_SDK_INT;
    field public static final int RESOURCES_SDK_INT;
  }

  public class DeviceIdleManager {
    method @NonNull public String[] getSystemPowerWhitelist();
    method @NonNull public String[] getSystemPowerWhitelistExceptIdle();
  }

  public class Environment {
    method public static java.io.File buildPath(java.io.File, java.lang.String...);
  }

  public abstract class HwBinder implements android.os.IHwBinder {
    ctor public HwBinder();
    method public static final void configureRpcThreadpool(long, boolean);
    method public static void enableInstrumentation();
    method public static final android.os.IHwBinder getService(String, String) throws java.util.NoSuchElementException, android.os.RemoteException;
    method public static final android.os.IHwBinder getService(String, String, boolean) throws java.util.NoSuchElementException, android.os.RemoteException;
    method public static final void joinRpcThreadpool();
    method public abstract void onTransact(int, android.os.HwParcel, android.os.HwParcel, int) throws android.os.RemoteException;
    method public final void registerService(String) throws android.os.RemoteException;
    method public final void transact(int, android.os.HwParcel, android.os.HwParcel, int) throws android.os.RemoteException;
  }

  public class HwBlob {
    ctor public HwBlob(int);
    method public final void copyToBoolArray(long, boolean[], int);
    method public final void copyToDoubleArray(long, double[], int);
    method public final void copyToFloatArray(long, float[], int);
    method public final void copyToInt16Array(long, short[], int);
    method public final void copyToInt32Array(long, int[], int);
    method public final void copyToInt64Array(long, long[], int);
    method public final void copyToInt8Array(long, byte[], int);
    method public final boolean getBool(long);
    method public final double getDouble(long);
    method public final float getFloat(long);
    method public final short getInt16(long);
    method public final int getInt32(long);
    method public final long getInt64(long);
    method public final byte getInt8(long);
    method public final String getString(long);
    method public final long handle();
    method public final void putBlob(long, android.os.HwBlob);
    method public final void putBool(long, boolean);
    method public final void putBoolArray(long, boolean[]);
    method public final void putDouble(long, double);
    method public final void putDoubleArray(long, double[]);
    method public final void putFloat(long, float);
    method public final void putFloatArray(long, float[]);
    method public final void putInt16(long, short);
    method public final void putInt16Array(long, short[]);
    method public final void putInt32(long, int);
    method public final void putInt32Array(long, int[]);
    method public final void putInt64(long, long);
    method public final void putInt64Array(long, long[]);
    method public final void putInt8(long, byte);
    method public final void putInt8Array(long, byte[]);
    method public final void putNativeHandle(long, android.os.NativeHandle);
    method public final void putString(long, String);
    method public static Boolean[] wrapArray(@NonNull boolean[]);
    method public static Long[] wrapArray(@NonNull long[]);
    method public static Byte[] wrapArray(@NonNull byte[]);
    method public static Short[] wrapArray(@NonNull short[]);
    method public static Integer[] wrapArray(@NonNull int[]);
    method public static Float[] wrapArray(@NonNull float[]);
    method public static Double[] wrapArray(@NonNull double[]);
  }

  public class HwParcel {
    ctor public HwParcel();
    method public final void enforceInterface(String);
    method public final boolean readBool();
    method public final java.util.ArrayList<java.lang.Boolean> readBoolVector();
    method public final android.os.HwBlob readBuffer(long);
    method public final double readDouble();
    method public final java.util.ArrayList<java.lang.Double> readDoubleVector();
    method public final android.os.HwBlob readEmbeddedBuffer(long, long, long, boolean);
    method public final android.os.NativeHandle readEmbeddedNativeHandle(long, long);
    method public final float readFloat();
    method public final java.util.ArrayList<java.lang.Float> readFloatVector();
    method public final short readInt16();
    method public final java.util.ArrayList<java.lang.Short> readInt16Vector();
    method public final int readInt32();
    method public final java.util.ArrayList<java.lang.Integer> readInt32Vector();
    method public final long readInt64();
    method public final java.util.ArrayList<java.lang.Long> readInt64Vector();
    method public final byte readInt8();
    method public final java.util.ArrayList<java.lang.Byte> readInt8Vector();
    method public final android.os.NativeHandle readNativeHandle();
    method public final java.util.ArrayList<android.os.NativeHandle> readNativeHandleVector();
    method public final String readString();
    method public final java.util.ArrayList<java.lang.String> readStringVector();
    method public final android.os.IHwBinder readStrongBinder();
    method public final void release();
    method public final void releaseTemporaryStorage();
    method public final void send();
    method public final void verifySuccess();
    method public final void writeBool(boolean);
    method public final void writeBoolVector(java.util.ArrayList<java.lang.Boolean>);
    method public final void writeBuffer(android.os.HwBlob);
    method public final void writeDouble(double);
    method public final void writeDoubleVector(java.util.ArrayList<java.lang.Double>);
    method public final void writeFloat(float);
    method public final void writeFloatVector(java.util.ArrayList<java.lang.Float>);
    method public final void writeInt16(short);
    method public final void writeInt16Vector(java.util.ArrayList<java.lang.Short>);
    method public final void writeInt32(int);
    method public final void writeInt32Vector(java.util.ArrayList<java.lang.Integer>);
    method public final void writeInt64(long);
    method public final void writeInt64Vector(java.util.ArrayList<java.lang.Long>);
    method public final void writeInt8(byte);
    method public final void writeInt8Vector(java.util.ArrayList<java.lang.Byte>);
    method public final void writeInterfaceToken(String);
    method public final void writeNativeHandle(android.os.NativeHandle);
    method public final void writeNativeHandleVector(java.util.ArrayList<android.os.NativeHandle>);
    method public final void writeStatus(int);
    method public final void writeString(String);
    method public final void writeStringVector(java.util.ArrayList<java.lang.String>);
    method public final void writeStrongBinder(android.os.IHwBinder);
    field public static final int STATUS_SUCCESS = 0; // 0x0
  }

  @IntDef(prefix={"STATUS_"}, value={android.os.HwParcel.STATUS_SUCCESS}) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) public static @interface HwParcel.Status {
  }

  public interface IHwBinder {
    method public boolean linkToDeath(android.os.IHwBinder.DeathRecipient, long);
    method public android.os.IHwInterface queryLocalInterface(String);
    method public void transact(int, android.os.HwParcel, android.os.HwParcel, int) throws android.os.RemoteException;
    method public boolean unlinkToDeath(android.os.IHwBinder.DeathRecipient);
  }

  public static interface IHwBinder.DeathRecipient {
    method public void serviceDied(long);
  }

  public interface IHwInterface {
    method public android.os.IHwBinder asBinder();
  }

  public class IncidentManager {
    method @RequiresPermission(allOf={android.Manifest.permission.DUMP, android.Manifest.permission.PACKAGE_USAGE_STATS}) public void reportIncident(android.os.IncidentReportArgs);
  }

  public final class IncidentReportArgs implements android.os.Parcelable {
    ctor public IncidentReportArgs();
    ctor public IncidentReportArgs(android.os.Parcel);
    method public void addHeader(byte[]);
    method public void addSection(int);
    method public boolean containsSection(int);
    method public int describeContents();
    method public boolean isAll();
    method public void readFromParcel(android.os.Parcel);
    method public int sectionCount();
    method public void setAll(boolean);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.os.IncidentReportArgs> CREATOR;
  }

  public final class NativeHandle implements java.io.Closeable {
    ctor public NativeHandle();
    ctor public NativeHandle(@NonNull java.io.FileDescriptor, boolean);
    ctor public NativeHandle(@NonNull java.io.FileDescriptor[], @NonNull int[], boolean);
    method public void close() throws java.io.IOException;
    method public android.os.NativeHandle dup() throws java.io.IOException;
    method public java.io.FileDescriptor getFileDescriptor();
    method public java.io.FileDescriptor[] getFileDescriptors();
    method public int[] getInts();
    method public boolean hasSingleFileDescriptor();
  }

  public final class PowerManager {
    method public void nap(long);
  }

  public class Process {
    method public static final int getThreadScheduler(int) throws java.lang.IllegalArgumentException;
  }

  public final class RemoteCallback implements android.os.Parcelable {
    ctor public RemoteCallback(android.os.RemoteCallback.OnResultListener);
    ctor public RemoteCallback(@NonNull android.os.RemoteCallback.OnResultListener, @Nullable android.os.Handler);
    method public int describeContents();
    method public void sendResult(@Nullable android.os.Bundle);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.os.RemoteCallback> CREATOR;
  }

  public static interface RemoteCallback.OnResultListener {
    method public void onResult(android.os.Bundle);
  }

  public final class StrictMode {
    method public static void setViolationLogger(android.os.StrictMode.ViolationLogger);
    field public static final int DETECT_CUSTOM = 8; // 0x8
    field public static final int DETECT_DISK_READ = 2; // 0x2
    field public static final int DETECT_DISK_WRITE = 1; // 0x1
    field public static final int DETECT_NETWORK = 4; // 0x4
    field public static final int DETECT_RESOURCE_MISMATCH = 16; // 0x10
    field public static final int DETECT_UNBUFFERED_IO = 32; // 0x20
    field public static final int DETECT_VM_ACTIVITY_LEAKS = 1024; // 0x400
    field public static final int DETECT_VM_CLEARTEXT_NETWORK = 16384; // 0x4000
    field public static final int DETECT_VM_CLOSABLE_LEAKS = 512; // 0x200
    field public static final int DETECT_VM_CONTENT_URI_WITHOUT_PERMISSION = 32768; // 0x8000
    field public static final int DETECT_VM_CURSOR_LEAKS = 256; // 0x100
    field public static final int DETECT_VM_FILE_URI_EXPOSURE = 8192; // 0x2000
    field public static final int DETECT_VM_INSTANCE_LEAKS = 2048; // 0x800
    field public static final int DETECT_VM_NON_SDK_API_USAGE = 1073741824; // 0x40000000
    field public static final int DETECT_VM_REGISTRATION_LEAKS = 4096; // 0x1000
    field public static final int DETECT_VM_UNTAGGED_SOCKET = -2147483648; // 0x80000000
  }

  public static final class StrictMode.ViolationInfo implements android.os.Parcelable {
    ctor public StrictMode.ViolationInfo(android.os.Parcel);
    ctor public StrictMode.ViolationInfo(android.os.Parcel, boolean);
    method public int describeContents();
    method public void dump(android.util.Printer, String);
    method public int getPolicyMask();
    method public String getStackTrace();
    method public int getViolationBit();
    method public String getViolationDetails();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.os.StrictMode.ViolationInfo> CREATOR;
    field public String broadcastIntentAction;
    field public int durationMillis;
    field public int numAnimationsRunning;
    field public long numInstances;
    field public String[] tags;
    field public int violationNumThisLoop;
    field public long violationUptimeMillis;
  }

  public static interface StrictMode.ViolationLogger {
    method public void log(android.os.StrictMode.ViolationInfo);
  }

  public class SystemProperties {
    method @NonNull public static String get(@NonNull String, @Nullable String);
  }

  public final class UserHandle implements android.os.Parcelable {
    method public static int getAppId(int);
    method public int getIdentifier();
    field public static final android.os.UserHandle ALL;
    field public static final android.os.UserHandle CURRENT;
    field public static final android.os.UserHandle SYSTEM;
  }

  public class UserManager {
    method public static boolean isSplitSystemUser();
    field public static final String ACTION_USER_RESTRICTIONS_CHANGED = "android.os.action.USER_RESTRICTIONS_CHANGED";
  }

}

package android.print {

  public final class PrintJobInfo implements android.os.Parcelable {
    method public float getProgress();
    method @Nullable public CharSequence getStatus(@NonNull android.content.pm.PackageManager);
  }

  public final class PrinterInfo implements android.os.Parcelable {
    method @Nullable public android.graphics.drawable.Drawable loadIcon(@NonNull android.content.Context);
  }

}

package android.provider {

  public final class Settings {
    field public static final String ACTION_ENTERPRISE_PRIVACY_SETTINGS = "android.settings.ENTERPRISE_PRIVACY_SETTINGS";
  }

  public static final class Settings.Global extends android.provider.Settings.NameValueTable {
    field public static final String AUTOFILL_COMPAT_MODE_ALLOWED_PACKAGES = "autofill_compat_mode_allowed_packages";
    field public static final String CAPTIVE_PORTAL_FALLBACK_PROBE_SPECS = "captive_portal_fallback_probe_specs";
    field public static final String CAPTIVE_PORTAL_FALLBACK_URL = "captive_portal_fallback_url";
    field public static final String CAPTIVE_PORTAL_HTTPS_URL = "captive_portal_https_url";
    field public static final String CAPTIVE_PORTAL_HTTP_URL = "captive_portal_http_url";
    field public static final String CAPTIVE_PORTAL_MODE = "captive_portal_mode";
    field public static final int CAPTIVE_PORTAL_MODE_AVOID = 2; // 0x2
    field public static final int CAPTIVE_PORTAL_MODE_IGNORE = 0; // 0x0
    field public static final int CAPTIVE_PORTAL_MODE_PROMPT = 1; // 0x1
    field public static final String CAPTIVE_PORTAL_OTHER_FALLBACK_URLS = "captive_portal_other_fallback_urls";
    field public static final String CAPTIVE_PORTAL_USER_AGENT = "captive_portal_user_agent";
    field public static final String CAPTIVE_PORTAL_USE_HTTPS = "captive_portal_use_https";
    field public static final String DATA_STALL_CONSECUTIVE_DNS_TIMEOUT_THRESHOLD = "data_stall_consecutive_dns_timeout_threshold";
    field public static final String DATA_STALL_EVALUATION_TYPE = "data_stall_evaluation_type";
    field public static final String DATA_STALL_MIN_EVALUATE_INTERVAL = "data_stall_min_evaluate_interval";
    field public static final String DATA_STALL_VALID_DNS_TIME_THRESHOLD = "data_stall_valid_dns_time_threshold";
    field public static final String HIDDEN_API_BLACKLIST_EXEMPTIONS = "hidden_api_blacklist_exemptions";
    field public static final String LOCATION_GLOBAL_KILL_SWITCH = "location_global_kill_switch";
    field public static final String LOW_POWER_MODE = "low_power";
    field public static final String LOW_POWER_MODE_STICKY = "low_power_sticky";
    field public static final String USE_OPEN_WIFI_PACKAGE = "use_open_wifi_package";
  }

  public static final class Settings.Secure extends android.provider.Settings.NameValueTable {
    field public static final String ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED = "accessibility_display_magnification_enabled";
    field public static final String AUTOFILL_FEATURE_FIELD_CLASSIFICATION = "autofill_field_classification";
    field public static final String AUTOFILL_SERVICE = "autofill_service";
    field public static final String AUTOFILL_USER_DATA_MAX_CATEGORY_COUNT = "autofill_user_data_max_category_count";
    field public static final String AUTOFILL_USER_DATA_MAX_FIELD_CLASSIFICATION_IDS_SIZE = "autofill_user_data_max_field_classification_size";
    field public static final String AUTOFILL_USER_DATA_MAX_USER_DATA_SIZE = "autofill_user_data_max_user_data_size";
    field public static final String AUTOFILL_USER_DATA_MAX_VALUE_LENGTH = "autofill_user_data_max_value_length";
    field public static final String AUTOFILL_USER_DATA_MIN_VALUE_LENGTH = "autofill_user_data_min_value_length";
    field public static final String DISABLED_PRINT_SERVICES = "disabled_print_services";
    field @Deprecated public static final String ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES = "enabled_notification_policy_access_packages";
    field @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public static final String SYNC_PARENT_SOUNDS = "sync_parent_sounds";
    field public static final String USER_SETUP_COMPLETE = "user_setup_complete";
    field public static final String VOICE_INTERACTION_SERVICE = "voice_interaction_service";
  }

  public static final class Telephony.Sms.Intents {
    field public static final String SMS_CARRIER_PROVISION_ACTION = "android.provider.Telephony.SMS_CARRIER_PROVISION";
  }

}

package android.security {

  public class KeyStoreException extends java.lang.Exception {
    ctor public KeyStoreException(int, String);
    method public int getErrorCode();
  }

}

package android.security.keystore {

  public abstract class AttestationUtils {
    method @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") @NonNull public static java.security.cert.X509Certificate[] attestDeviceIds(android.content.Context, @NonNull int[], @NonNull byte[]) throws android.security.keystore.DeviceIdAttestationException;
    field public static final int ID_TYPE_IMEI = 2; // 0x2
    field public static final int ID_TYPE_MEID = 3; // 0x3
    field public static final int ID_TYPE_SERIAL = 1; // 0x1
  }

  public class DeviceIdAttestationException extends java.lang.Exception {
    ctor public DeviceIdAttestationException(String);
    ctor public DeviceIdAttestationException(String, Throwable);
  }

  public static final class KeyGenParameterSpec.Builder {
    method @NonNull public android.security.keystore.KeyGenParameterSpec.Builder setUniqueIdIncluded(boolean);
  }

  public final class KeyProtection implements java.security.KeyStore.ProtectionParameter {
    method public long getBoundToSpecificSecureUserId();
  }

  public static final class KeyProtection.Builder {
    method public android.security.keystore.KeyProtection.Builder setBoundToSpecificSecureUserId(long);
  }

}

package android.service.autofill {

  public final class CharSequenceTransformation extends android.service.autofill.InternalTransformation implements android.os.Parcelable android.service.autofill.Transformation {
    method public void apply(@NonNull android.service.autofill.ValueFinder, @NonNull android.widget.RemoteViews, int) throws java.lang.Exception;
  }

  public final class DateTransformation extends android.service.autofill.InternalTransformation implements android.os.Parcelable android.service.autofill.Transformation {
    method public void apply(@NonNull android.service.autofill.ValueFinder, @NonNull android.widget.RemoteViews, int) throws java.lang.Exception;
  }

  public final class DateValueSanitizer extends android.service.autofill.InternalSanitizer implements android.os.Parcelable android.service.autofill.Sanitizer {
    method @Nullable public android.view.autofill.AutofillValue sanitize(@NonNull android.view.autofill.AutofillValue);
  }

  public final class FillResponse implements android.os.Parcelable {
    method public int getFlags();
  }

  public final class ImageTransformation extends android.service.autofill.InternalTransformation implements android.os.Parcelable android.service.autofill.Transformation {
    method public void apply(@NonNull android.service.autofill.ValueFinder, @NonNull android.widget.RemoteViews, int) throws java.lang.Exception;
  }

  public abstract class InternalSanitizer implements android.os.Parcelable android.service.autofill.Sanitizer {
    ctor public InternalSanitizer();
  }

  public abstract class InternalTransformation implements android.os.Parcelable android.service.autofill.Transformation {
    ctor public InternalTransformation();
  }

  public abstract class InternalValidator implements android.os.Parcelable android.service.autofill.Validator {
    ctor public InternalValidator();
    method public abstract boolean isValid(@NonNull android.service.autofill.ValueFinder);
  }

  public final class LuhnChecksumValidator extends android.service.autofill.InternalValidator implements android.os.Parcelable android.service.autofill.Validator {
    method public boolean isValid(@NonNull android.service.autofill.ValueFinder);
  }

  public final class RegexValidator extends android.service.autofill.InternalValidator implements android.os.Parcelable android.service.autofill.Validator {
    method public boolean isValid(@NonNull android.service.autofill.ValueFinder);
  }

  public final class TextValueSanitizer extends android.service.autofill.InternalSanitizer implements android.os.Parcelable android.service.autofill.Sanitizer {
    method @Nullable public android.view.autofill.AutofillValue sanitize(@NonNull android.view.autofill.AutofillValue);
  }

  public interface ValueFinder {
    method @Nullable public default String findByAutofillId(@NonNull android.view.autofill.AutofillId);
    method @Nullable public android.view.autofill.AutofillValue findRawValueByAutofillId(@NonNull android.view.autofill.AutofillId);
  }

}

package android.service.notification {

  public final class Adjustment implements android.os.Parcelable {
    ctor public Adjustment(String, String, android.os.Bundle, CharSequence, int);
    ctor protected Adjustment(android.os.Parcel);
    method public int describeContents();
    method public CharSequence getExplanation();
    method public String getKey();
    method public String getPackage();
    method public android.os.Bundle getSignals();
    method public int getUser();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.service.notification.Adjustment> CREATOR;
    field public static final String KEY_PEOPLE = "key_people";
    field public static final String KEY_SNOOZE_CRITERIA = "key_snooze_criteria";
    field public static final String KEY_USER_SENTIMENT = "key_user_sentiment";
  }

  public abstract class ConditionProviderService extends android.app.Service {
    method public boolean isBound();
  }

  public abstract class NotificationAssistantService extends android.service.notification.NotificationListenerService {
    ctor public NotificationAssistantService();
    method public final void adjustNotification(android.service.notification.Adjustment);
    method public final void adjustNotifications(java.util.List<android.service.notification.Adjustment>);
    method public final android.os.IBinder onBind(android.content.Intent);
    method public abstract android.service.notification.Adjustment onNotificationEnqueued(android.service.notification.StatusBarNotification);
    method public abstract void onNotificationSnoozedUntilContext(android.service.notification.StatusBarNotification, String);
    method public final void unsnoozeNotification(String);
    field public static final String SERVICE_INTERFACE = "android.service.notification.NotificationAssistantService";
  }

  public abstract class NotificationListenerService extends android.app.Service {
    method public void onNotificationRemoved(android.service.notification.StatusBarNotification, android.service.notification.NotificationListenerService.RankingMap, android.service.notification.NotificationStats, int);
  }

  public final class NotificationStats implements android.os.Parcelable {
    ctor public NotificationStats();
    ctor protected NotificationStats(android.os.Parcel);
    method public int describeContents();
    method public int getDismissalSurface();
    method public boolean hasDirectReplied();
    method public boolean hasExpanded();
    method public boolean hasInteracted();
    method public boolean hasSeen();
    method public boolean hasSnoozed();
    method public boolean hasViewedSettings();
    method public void setDirectReplied();
    method public void setDismissalSurface(int);
    method public void setExpanded();
    method public void setSeen();
    method public void setSnoozed();
    method public void setViewedSettings();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.service.notification.NotificationStats> CREATOR;
    field public static final int DISMISSAL_AOD = 2; // 0x2
    field public static final int DISMISSAL_NOT_DISMISSED = -1; // 0xffffffff
    field public static final int DISMISSAL_OTHER = 0; // 0x0
    field public static final int DISMISSAL_PEEK = 1; // 0x1
    field public static final int DISMISSAL_SHADE = 3; // 0x3
  }

  public final class SnoozeCriterion implements android.os.Parcelable {
    ctor public SnoozeCriterion(String, CharSequence, CharSequence);
    ctor protected SnoozeCriterion(android.os.Parcel);
    method public int describeContents();
    method public CharSequence getConfirmation();
    method public CharSequence getExplanation();
    method public String getId();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.service.notification.SnoozeCriterion> CREATOR;
  }

}

package android.service.quicksettings {

  public class TileService extends android.app.Service {
    method public static boolean isQuickSettingsSupported();
  }

}

package android.telecom {

  public final class CallAudioState implements android.os.Parcelable {
    ctor public CallAudioState(boolean, int, int, @Nullable android.bluetooth.BluetoothDevice, @NonNull java.util.Collection<android.bluetooth.BluetoothDevice>);
  }

  public final class PhoneAccountSuggestion implements android.os.Parcelable {
    ctor public PhoneAccountSuggestion(@NonNull android.telecom.PhoneAccountHandle, int, boolean);
  }

  public class PhoneAccountSuggestionService extends android.app.Service {
    ctor public PhoneAccountSuggestionService();
    method public void onAccountSuggestionRequest(@NonNull String);
    method public android.os.IBinder onBind(android.content.Intent);
    method public final void suggestPhoneAccounts(@NonNull String, @NonNull java.util.List<android.telecom.PhoneAccountSuggestion>);
    field public static final String SERVICE_INTERFACE = "android.telecom.PhoneAccountSuggestionService";
  }

}

package android.telephony {

  public class CarrierConfigManager {
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void overrideConfig(int, @Nullable android.os.PersistableBundle);
  }

  public class MbmsDownloadSession implements java.lang.AutoCloseable {
    field public static final String MBMS_DOWNLOAD_SERVICE_OVERRIDE_METADATA = "mbms-download-service-override";
  }

  public class MbmsGroupCallSession implements java.lang.AutoCloseable {
    field public static final String MBMS_GROUP_CALL_SERVICE_OVERRIDE_METADATA = "mbms-group-call-service-override";
  }

  public class MbmsStreamingSession implements java.lang.AutoCloseable {
    field public static final String MBMS_STREAMING_SERVICE_OVERRIDE_METADATA = "mbms-streaming-service-override";
  }

  public class ServiceState implements android.os.Parcelable {
    method public void setCdmaSystemAndNetworkId(int, int);
    method public void setCellBandwidths(int[]);
    method public void setChannelNumber(int);
    method public void setRilDataRadioTechnology(int);
    method public void setRilVoiceRadioTechnology(int);
  }

  public class TelephonyManager {
    method public int getCarrierIdListVersion();
    method public android.util.Pair<java.lang.Integer,java.lang.Integer> getRadioHalVersion();
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void refreshUiccProfile();
    method public void setCarrierTestOverride(String, String, String, String, String, String, String);
    field public static final int UNKNOWN_CARRIER_ID_LIST_VERSION = -1; // 0xffffffff
  }

}

package android.telephony.mbms {

  public static class DownloadRequest.Builder {
    method public android.telephony.mbms.DownloadRequest.Builder setServiceId(String);
  }

  public final class FileInfo implements android.os.Parcelable {
    ctor public FileInfo(android.net.Uri, String);
  }

  public final class FileServiceInfo extends android.telephony.mbms.ServiceInfo implements android.os.Parcelable {
    ctor public FileServiceInfo(java.util.Map<java.util.Locale,java.lang.String>, String, java.util.List<java.util.Locale>, String, java.util.Date, java.util.Date, java.util.List<android.telephony.mbms.FileInfo>);
  }

  public final class StreamingServiceInfo extends android.telephony.mbms.ServiceInfo implements android.os.Parcelable {
    ctor public StreamingServiceInfo(java.util.Map<java.util.Locale,java.lang.String>, String, java.util.List<java.util.Locale>, String, java.util.Date, java.util.Date);
  }

  public final class UriPathPair implements android.os.Parcelable {
    method public int describeContents();
    method public android.net.Uri getContentUri();
    method public android.net.Uri getFilePathUri();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.telephony.mbms.UriPathPair> CREATOR;
  }

}

package android.telephony.mbms.vendor {

  public class MbmsDownloadServiceBase extends android.os.Binder {
    ctor public MbmsDownloadServiceBase();
    method public int addProgressListener(android.telephony.mbms.DownloadRequest, android.telephony.mbms.DownloadProgressListener) throws android.os.RemoteException;
    method public int addStatusListener(android.telephony.mbms.DownloadRequest, android.telephony.mbms.DownloadStatusListener) throws android.os.RemoteException;
    method public android.os.IBinder asBinder();
    method public int cancelDownload(android.telephony.mbms.DownloadRequest) throws android.os.RemoteException;
    method public void dispose(int) throws android.os.RemoteException;
    method public int download(android.telephony.mbms.DownloadRequest) throws android.os.RemoteException;
    method public static String getDefaultTransactionName(int);
    method public String getTransactionName(int);
    method public int initialize(int, android.telephony.mbms.MbmsDownloadSessionCallback) throws android.os.RemoteException;
    method @NonNull public java.util.List<android.telephony.mbms.DownloadRequest> listPendingDownloads(int) throws android.os.RemoteException;
    method public void onAppCallbackDied(int, int);
    method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException;
    method public int removeProgressListener(android.telephony.mbms.DownloadRequest, android.telephony.mbms.DownloadProgressListener) throws android.os.RemoteException;
    method public int removeStatusListener(android.telephony.mbms.DownloadRequest, android.telephony.mbms.DownloadStatusListener) throws android.os.RemoteException;
    method public int requestDownloadState(android.telephony.mbms.DownloadRequest, android.telephony.mbms.FileInfo) throws android.os.RemoteException;
    method public int requestUpdateFileServices(int, java.util.List<java.lang.String>) throws android.os.RemoteException;
    method public int resetDownloadKnowledge(android.telephony.mbms.DownloadRequest) throws android.os.RemoteException;
    method public int setTempFileRootDirectory(int, String) throws android.os.RemoteException;
  }

  public class MbmsGroupCallServiceBase extends android.app.Service {
    ctor public MbmsGroupCallServiceBase();
    method public void dispose(int) throws android.os.RemoteException;
    method public int initialize(@NonNull android.telephony.mbms.MbmsGroupCallSessionCallback, int) throws android.os.RemoteException;
    method public void onAppCallbackDied(int, int);
    method public android.os.IBinder onBind(android.content.Intent);
    method public int startGroupCall(int, long, @NonNull java.util.List<java.lang.Integer>, @NonNull java.util.List<java.lang.Integer>, @NonNull android.telephony.mbms.GroupCallCallback);
    method public void stopGroupCall(int, long);
    method public void updateGroupCall(int, long, @NonNull java.util.List<java.lang.Integer>, @NonNull java.util.List<java.lang.Integer>);
  }

  public class MbmsStreamingServiceBase extends android.os.Binder {
    ctor public MbmsStreamingServiceBase();
    method public android.os.IBinder asBinder();
    method public void dispose(int) throws android.os.RemoteException;
    method public static String getDefaultTransactionName(int);
    method @Nullable public android.net.Uri getPlaybackUri(int, String) throws android.os.RemoteException;
    method public String getTransactionName(int);
    method public int initialize(android.telephony.mbms.MbmsStreamingSessionCallback, int) throws android.os.RemoteException;
    method public void onAppCallbackDied(int, int);
    method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException;
    method public int requestUpdateStreamingServices(int, java.util.List<java.lang.String>) throws android.os.RemoteException;
    method public int startStreaming(int, String, android.telephony.mbms.StreamingServiceCallback) throws android.os.RemoteException;
    method public void stopStreaming(int, String) throws android.os.RemoteException;
  }

  public class VendorUtils {
    ctor public VendorUtils();
    method public static android.content.ComponentName getAppReceiverFromPackageName(android.content.Context, String);
    field public static final String ACTION_CLEANUP = "android.telephony.mbms.action.CLEANUP";
    field public static final String ACTION_DOWNLOAD_RESULT_INTERNAL = "android.telephony.mbms.action.DOWNLOAD_RESULT_INTERNAL";
    field public static final String ACTION_FILE_DESCRIPTOR_REQUEST = "android.telephony.mbms.action.FILE_DESCRIPTOR_REQUEST";
    field public static final String EXTRA_FD_COUNT = "android.telephony.mbms.extra.FD_COUNT";
    field public static final String EXTRA_FINAL_URI = "android.telephony.mbms.extra.FINAL_URI";
    field public static final String EXTRA_FREE_URI_LIST = "android.telephony.mbms.extra.FREE_URI_LIST";
    field public static final String EXTRA_PAUSED_LIST = "android.telephony.mbms.extra.PAUSED_LIST";
    field public static final String EXTRA_PAUSED_URI_LIST = "android.telephony.mbms.extra.PAUSED_URI_LIST";
    field public static final String EXTRA_SERVICE_ID = "android.telephony.mbms.extra.SERVICE_ID";
    field public static final String EXTRA_TEMP_FILES_IN_USE = "android.telephony.mbms.extra.TEMP_FILES_IN_USE";
    field public static final String EXTRA_TEMP_FILE_ROOT = "android.telephony.mbms.extra.TEMP_FILE_ROOT";
    field public static final String EXTRA_TEMP_LIST = "android.telephony.mbms.extra.TEMP_LIST";
  }

}

package android.text {

  public static final class Selection.MemoryTextWatcher implements android.text.TextWatcher {
    ctor public Selection.MemoryTextWatcher();
    method public void afterTextChanged(android.text.Editable);
    method public void beforeTextChanged(CharSequence, int, int, int);
    method public void onTextChanged(CharSequence, int, int, int);
  }

}

package android.transition {

  public class TransitionManager {
    method public android.transition.Transition getTransition(android.transition.Scene);
  }

}

package android.util.proto {

  public final class EncodedBuffer {
    ctor public EncodedBuffer();
    ctor public EncodedBuffer(int);
    method public void dumpBuffers(String);
    method public static void dumpByteString(String, String, byte[]);
    method public void editRawFixed32(int, int);
    method public byte[] getBytes(int);
    method public int getChunkCount();
    method public String getDebugString();
    method public int getRawFixed32At(int);
    method public static int getRawVarint32Size(int);
    method public static int getRawVarint64Size(long);
    method public static int getRawZigZag32Size(int);
    method public static int getRawZigZag64Size(long);
    method public int getReadPos();
    method public int getReadableSize();
    method public int getWriteBufIndex();
    method public int getWriteIndex();
    method public int getWritePos();
    method public byte readRawByte();
    method public int readRawFixed32();
    method public long readRawUnsigned();
    method public void rewindRead();
    method public void rewindWriteTo(int);
    method public void skipRead(int);
    method public void startEditing();
    method public void writeFromThisBuffer(int, int);
    method public void writeRawBuffer(byte[]);
    method public void writeRawBuffer(byte[], int, int);
    method public void writeRawByte(byte);
    method public void writeRawFixed32(int);
    method public void writeRawFixed64(long);
    method public void writeRawVarint32(int);
    method public void writeRawVarint64(long);
    method public void writeRawZigZag32(int);
    method public void writeRawZigZag64(long);
  }

  public final class ProtoOutputStream {
    ctor public ProtoOutputStream();
    ctor public ProtoOutputStream(int);
    ctor public ProtoOutputStream(java.io.OutputStream);
    ctor public ProtoOutputStream(java.io.FileDescriptor);
    method public static int checkFieldId(long, long);
    method public static int convertObjectIdToOrdinal(int);
    method public void dump(String);
    method public void end(long);
    method @Deprecated public void endObject(long);
    method @Deprecated public void endRepeatedObject(long);
    method public void flush();
    method public byte[] getBytes();
    method public static int getDepthFromToken(long);
    method public static int getObjectIdFromToken(long);
    method public static boolean getRepeatedFromToken(long);
    method public static int getSizePosFromToken(long);
    method public static int getTagSizeFromToken(long);
    method public static long makeFieldId(int, long);
    method public static long makeToken(int, boolean, int, int, int);
    method public long start(long);
    method @Deprecated public long startObject(long);
    method @Deprecated public long startRepeatedObject(long);
    method public static String token2String(long);
    method public void write(long, double);
    method public void write(long, float);
    method public void write(long, int);
    method public void write(long, long);
    method public void write(long, boolean);
    method public void write(long, String);
    method public void write(long, byte[]);
    method @Deprecated public void writeBool(long, boolean);
    method @Deprecated public void writeBytes(long, byte[]);
    method @Deprecated public void writeDouble(long, double);
    method @Deprecated public void writeEnum(long, int);
    method @Deprecated public void writeFixed32(long, int);
    method @Deprecated public void writeFixed64(long, long);
    method @Deprecated public void writeFloat(long, float);
    method @Deprecated public void writeInt32(long, int);
    method @Deprecated public void writeInt64(long, long);
    method @Deprecated public void writeObject(long, byte[]);
    method @Deprecated public void writePackedBool(long, boolean[]);
    method @Deprecated public void writePackedDouble(long, double[]);
    method @Deprecated public void writePackedEnum(long, int[]);
    method @Deprecated public void writePackedFixed32(long, int[]);
    method @Deprecated public void writePackedFixed64(long, long[]);
    method @Deprecated public void writePackedFloat(long, float[]);
    method @Deprecated public void writePackedInt32(long, int[]);
    method @Deprecated public void writePackedInt64(long, long[]);
    method @Deprecated public void writePackedSFixed32(long, int[]);
    method @Deprecated public void writePackedSFixed64(long, long[]);
    method @Deprecated public void writePackedSInt32(long, int[]);
    method @Deprecated public void writePackedSInt64(long, long[]);
    method @Deprecated public void writePackedUInt32(long, int[]);
    method @Deprecated public void writePackedUInt64(long, long[]);
    method @Deprecated public void writeRepeatedBool(long, boolean);
    method @Deprecated public void writeRepeatedBytes(long, byte[]);
    method @Deprecated public void writeRepeatedDouble(long, double);
    method @Deprecated public void writeRepeatedEnum(long, int);
    method @Deprecated public void writeRepeatedFixed32(long, int);
    method @Deprecated public void writeRepeatedFixed64(long, long);
    method @Deprecated public void writeRepeatedFloat(long, float);
    method @Deprecated public void writeRepeatedInt32(long, int);
    method @Deprecated public void writeRepeatedInt64(long, long);
    method @Deprecated public void writeRepeatedObject(long, byte[]);
    method @Deprecated public void writeRepeatedSFixed32(long, int);
    method @Deprecated public void writeRepeatedSFixed64(long, long);
    method @Deprecated public void writeRepeatedSInt32(long, int);
    method @Deprecated public void writeRepeatedSInt64(long, long);
    method @Deprecated public void writeRepeatedString(long, String);
    method @Deprecated public void writeRepeatedUInt32(long, int);
    method @Deprecated public void writeRepeatedUInt64(long, long);
    method @Deprecated public void writeSFixed32(long, int);
    method @Deprecated public void writeSFixed64(long, long);
    method @Deprecated public void writeSInt32(long, int);
    method @Deprecated public void writeSInt64(long, long);
    method @Deprecated public void writeString(long, String);
    method public void writeTag(int, int);
    method @Deprecated public void writeUInt32(long, int);
    method @Deprecated public void writeUInt64(long, long);
    field public static final long FIELD_COUNT_MASK = 16492674416640L; // 0xf0000000000L
    field public static final long FIELD_COUNT_PACKED = 5497558138880L; // 0x50000000000L
    field public static final long FIELD_COUNT_REPEATED = 2199023255552L; // 0x20000000000L
    field public static final int FIELD_COUNT_SHIFT = 40; // 0x28
    field public static final long FIELD_COUNT_SINGLE = 1099511627776L; // 0x10000000000L
    field public static final long FIELD_COUNT_UNKNOWN = 0L; // 0x0L
    field public static final int FIELD_ID_MASK = -8; // 0xfffffff8
    field public static final int FIELD_ID_SHIFT = 3; // 0x3
    field public static final long FIELD_TYPE_BOOL = 34359738368L; // 0x800000000L
    field public static final long FIELD_TYPE_BYTES = 51539607552L; // 0xc00000000L
    field public static final long FIELD_TYPE_DOUBLE = 4294967296L; // 0x100000000L
    field public static final long FIELD_TYPE_ENUM = 60129542144L; // 0xe00000000L
    field public static final long FIELD_TYPE_FIXED32 = 30064771072L; // 0x700000000L
    field public static final long FIELD_TYPE_FIXED64 = 25769803776L; // 0x600000000L
    field public static final long FIELD_TYPE_FLOAT = 8589934592L; // 0x200000000L
    field public static final long FIELD_TYPE_INT32 = 21474836480L; // 0x500000000L
    field public static final long FIELD_TYPE_INT64 = 12884901888L; // 0x300000000L
    field public static final long FIELD_TYPE_MASK = 1095216660480L; // 0xff00000000L
    field public static final long FIELD_TYPE_MESSAGE = 47244640256L; // 0xb00000000L
    field public static final long FIELD_TYPE_SFIXED32 = 64424509440L; // 0xf00000000L
    field public static final long FIELD_TYPE_SFIXED64 = 68719476736L; // 0x1000000000L
    field public static final int FIELD_TYPE_SHIFT = 32; // 0x20
    field public static final long FIELD_TYPE_SINT32 = 73014444032L; // 0x1100000000L
    field public static final long FIELD_TYPE_SINT64 = 77309411328L; // 0x1200000000L
    field public static final long FIELD_TYPE_STRING = 38654705664L; // 0x900000000L
    field public static final long FIELD_TYPE_UINT32 = 55834574848L; // 0xd00000000L
    field public static final long FIELD_TYPE_UINT64 = 17179869184L; // 0x400000000L
    field public static final long FIELD_TYPE_UNKNOWN = 0L; // 0x0L
    field public static final String TAG = "ProtoOutputStream";
    field public static final int WIRE_TYPE_END_GROUP = 4; // 0x4
    field public static final int WIRE_TYPE_FIXED32 = 5; // 0x5
    field public static final int WIRE_TYPE_FIXED64 = 1; // 0x1
    field public static final int WIRE_TYPE_LENGTH_DELIMITED = 2; // 0x2
    field public static final int WIRE_TYPE_MASK = 7; // 0x7
    field public static final int WIRE_TYPE_START_GROUP = 3; // 0x3
    field public static final int WIRE_TYPE_VARINT = 0; // 0x0
  }

  public class ProtoParseException extends java.lang.RuntimeException {
    ctor public ProtoParseException(String);
  }

}

package android.view {

  public abstract class ActionMode {
    method public boolean isUiFocusable();
  }

  public final class Choreographer {
    method public static long getFrameDelay();
    method public void postCallback(int, Runnable, Object);
    method public void postCallbackDelayed(int, Runnable, Object, long);
    method public void removeCallbacks(int, Runnable, Object);
    method public static void setFrameDelay(long);
    field public static final int CALLBACK_ANIMATION = 1; // 0x1
  }

  public class FocusFinder {
    method public static void sort(android.view.View[], int, int, android.view.ViewGroup, boolean);
  }

  public final class InputDevice implements android.os.Parcelable {
    method @RequiresPermission("android.permission.DISABLE_INPUT_DEVICE") public void disable();
    method @RequiresPermission("android.permission.DISABLE_INPUT_DEVICE") public void enable();
  }

  public final class KeyboardShortcutGroup implements android.os.Parcelable {
    ctor public KeyboardShortcutGroup(@Nullable CharSequence, @NonNull java.util.List<android.view.KeyboardShortcutInfo>, boolean);
    ctor public KeyboardShortcutGroup(@Nullable CharSequence, boolean);
    method public boolean isSystemGroup();
  }

  public abstract class LayoutInflater {
    method public void setPrecompiledLayoutsEnabledForTesting(boolean);
  }

  public final class MotionEvent extends android.view.InputEvent implements android.os.Parcelable {
    method public void setActionButton(int);
    method public void setButtonState(int);
  }

  @UiThread public class View implements android.view.accessibility.AccessibilityEventSource android.graphics.drawable.Drawable.Callback android.view.KeyEvent.Callback {
    method public android.view.View getTooltipView();
    method public static boolean isDefaultFocusHighlightEnabled();
    method public boolean isDefaultFocusHighlightNeeded(android.graphics.drawable.Drawable, android.graphics.drawable.Drawable);
    method public boolean restoreFocusInCluster(int);
    method public boolean restoreFocusNotInCluster();
    method public void setAutofilled(boolean);
    method public final void setFocusedInCluster();
  }

  public class ViewConfiguration {
    method public static int getHoverTooltipHideShortTimeout();
    method public static int getHoverTooltipHideTimeout();
    method public static int getHoverTooltipShowTimeout();
    method public static int getLongPressTooltipHideTimeout();
  }

  public static class WindowManager.LayoutParams extends android.view.ViewGroup.LayoutParams implements android.os.Parcelable {
    field public static final int ACCESSIBILITY_TITLE_CHANGED = 33554432; // 0x2000000
    field public static final int PRIVATE_FLAG_NO_MOVE_ANIMATION = 64; // 0x40
    field public CharSequence accessibilityTitle;
    field @android.view.ViewDebug.ExportedProperty(flagMapping={@android.view.ViewDebug.FlagToString(mask=0x1, equals=0x1, name="FAKE_HARDWARE_ACCELERATED"), @android.view.ViewDebug.FlagToString(mask=0x2, equals=0x2, name="FORCE_HARDWARE_ACCELERATED"), @android.view.ViewDebug.FlagToString(mask=0x4, equals=0x4, name="WANTS_OFFSET_NOTIFICATIONS"), @android.view.ViewDebug.FlagToString(mask=0x10, equals=0x10, name="SHOW_FOR_ALL_USERS"), @android.view.ViewDebug.FlagToString(mask=android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION, equals=android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION, name="NO_MOVE_ANIMATION"), @android.view.ViewDebug.FlagToString(mask=0x80, equals=0x80, name="COMPATIBLE_WINDOW"), @android.view.ViewDebug.FlagToString(mask=0x100, equals=0x100, name="SYSTEM_ERROR"), @android.view.ViewDebug.FlagToString(mask=0x200, equals=0x200, name="INHERIT_TRANSLUCENT_DECOR"), @android.view.ViewDebug.FlagToString(mask=0x400, equals=0x400, name="KEYGUARD"), @android.view.ViewDebug.FlagToString(mask=0x800, equals=0x800, name="DISABLE_WALLPAPER_TOUCH_EVENTS"), @android.view.ViewDebug.FlagToString(mask=0x1000, equals=0x1000, name="FORCE_STATUS_BAR_VISIBLE_TRANSPARENT"), @android.view.ViewDebug.FlagToString(mask=0x2000, equals=0x2000, name="PRESERVE_GEOMETRY"), @android.view.ViewDebug.FlagToString(mask=0x4000, equals=0x4000, name="FORCE_DECOR_VIEW_VISIBILITY"), @android.view.ViewDebug.FlagToString(mask=0x8000, equals=0x8000, name="WILL_NOT_REPLACE_ON_RELAUNCH"), @android.view.ViewDebug.FlagToString(mask=0x10000, equals=0x10000, name="LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME"), @android.view.ViewDebug.FlagToString(mask=0x20000, equals=0x20000, name="FORCE_DRAW_STATUS_BAR_BACKGROUND"), @android.view.ViewDebug.FlagToString(mask=0x40000, equals=0x40000, name="SUSTAINED_PERFORMANCE_MODE"), @android.view.ViewDebug.FlagToString(mask=0x80000, equals=0x80000, name="HIDE_NON_SYSTEM_OVERLAY_WINDOWS"), @android.view.ViewDebug.FlagToString(mask=0x100000, equals=0x100000, name="IS_ROUNDED_CORNERS_OVERLAY"), @android.view.ViewDebug.FlagToString(mask=0x200000, equals=0x200000, name="ACQUIRES_SLEEP_TOKEN"), @android.view.ViewDebug.FlagToString(mask=0x400000, equals=0x400000, name="IS_SCREEN_DECOR"), @android.view.ViewDebug.FlagToString(mask=0x800000, equals=0x800000, name="STATUS_BAR_EXPANDED")}) public int privateFlags;
  }

}

package android.view.accessibility {

  public class AccessibilityNodeInfo implements android.os.Parcelable {
    method public static void setNumInstancesInUseCounter(java.util.concurrent.atomic.AtomicInteger);
    method public void writeToParcelNoRecycle(android.os.Parcel, int);
  }

  public final class AccessibilityWindowInfo implements android.os.Parcelable {
    method public static void setNumInstancesInUseCounter(java.util.concurrent.atomic.AtomicInteger);
  }

}

package android.view.animation {

  public class AnimationUtils {
    method public static void lockAnimationClock(long);
    method public static void unlockAnimationClock();
  }

}

package android.view.autofill {

  public final class AutofillId implements android.os.Parcelable {
    ctor public AutofillId(int);
    ctor public AutofillId(android.view.autofill.AutofillId, int);
  }

}

package android.view.inputmethod {

  public final class InputMethodManager {
    method public boolean isInputMethodPickerShown();
  }

}

package android.widget {

  public abstract class AbsListView extends android.widget.AdapterView<android.widget.ListAdapter> implements android.widget.Filter.FilterListener android.text.TextWatcher android.view.ViewTreeObserver.OnGlobalLayoutListener android.view.ViewTreeObserver.OnTouchModeChangeListener {
    method public final boolean shouldDrawSelector();
  }

  public class CalendarView extends android.widget.FrameLayout {
    method public boolean getBoundsForDate(long, android.graphics.Rect);
  }

  public class DatePicker extends android.widget.FrameLayout {
    method public int getMode();
    field public static final int MODE_CALENDAR = 2; // 0x2
    field public static final int MODE_SPINNER = 1; // 0x1
  }

  @UiThread public final class Magnifier {
    method @Nullable public android.graphics.Bitmap getContent();
    method public static android.graphics.PointF getMagnifierDefaultSize();
    method public android.graphics.Rect getWindowPositionOnScreen();
    method public void setOnOperationCompleteCallback(android.widget.Magnifier.Callback);
  }

  public static interface Magnifier.Callback {
    method public void onOperationComplete();
  }

  public class NumberPicker extends android.widget.LinearLayout {
    method public CharSequence getDisplayedValueForCurrentSelection();
  }

  public class PopupMenu {
    method public android.widget.ListView getMenuListView();
  }

  public class Spinner extends android.widget.AbsSpinner implements android.content.DialogInterface.OnClickListener {
    method public boolean isPopupShowing();
  }

  @android.widget.RemoteViews.RemoteView public class TextClock extends android.widget.TextView {
    method public void disableClockTick();
  }

  public class TimePicker extends android.widget.FrameLayout {
    method public android.view.View getAmView();
    method public android.view.View getHourView();
    method public android.view.View getMinuteView();
    method public int getMode();
    method public android.view.View getPmView();
    field public static final int MODE_CLOCK = 2; // 0x2
    field public static final int MODE_SPINNER = 1; // 0x1
  }

  public class Toolbar extends android.view.ViewGroup {
    method @Nullable public android.view.View getNavigationView();
  }

}

