// Signature format: 2.0
package android.app {

  public class AppOpsManager {
    field public static final String OPSTR_NO_ISOLATED_STORAGE = "android:no_isolated_storage";
  }

  public class NotificationManager {
    method public boolean hasEnabledNotificationListener(@NonNull String, @NonNull android.os.UserHandle);
    field public static final String ACTION_NOTIFICATION_LISTENER_ENABLED_CHANGED = "android.app.action.NOTIFICATION_LISTENER_ENABLED_CHANGED";
  }

}

package android.content.rollback {

  public class RollbackManagerFrameworkInitializer {
    method public static void initialize();
  }

}

package android.graphics {

  public final class Compatibility {
    method public static void setTargetSdkVersion(int);
  }

  public final class ImageDecoder implements java.lang.AutoCloseable {
    method @AnyThread @NonNull public static android.graphics.ImageDecoder.Source createSource(@NonNull android.content.ContentResolver, @NonNull android.net.Uri, @Nullable android.content.res.Resources);
  }

}

package android.media {

  public class AudioManager {
    method public void adjustStreamVolumeForUid(int, int, int, @NonNull String, int, int, int);
    method public void adjustSuggestedStreamVolumeForUid(int, int, int, @NonNull String, int, int, int);
    method public void setStreamVolumeForUid(int, int, int, @NonNull String, int, int, int);
    field public static final int FLAG_FROM_KEY = 4096; // 0x1000
  }

  public static final class MediaMetadata.Builder {
    ctor public MediaMetadata.Builder(@NonNull android.media.MediaMetadata, @IntRange(from=1) int);
  }

}

package android.media.session {

  public static final class MediaController.PlaybackInfo implements android.os.Parcelable {
    ctor public MediaController.PlaybackInfo(int, int, @IntRange(from=0) int, @IntRange(from=0) int, @NonNull android.media.AudioAttributes, @Nullable String);
  }

  public final class MediaSession {
    field public static final int FLAG_EXCLUSIVE_GLOBAL_PRIORITY = 65536; // 0x10000
  }

  public final class MediaSessionManager {
    method public void dispatchMediaKeyEventAsSystemService(@NonNull android.view.KeyEvent);
    method public boolean dispatchMediaKeyEventAsSystemService(@NonNull android.media.session.MediaSession.Token, @NonNull android.view.KeyEvent);
    method public void dispatchVolumeKeyEventAsSystemService(@NonNull android.view.KeyEvent, int);
    method public void dispatchVolumeKeyEventAsSystemService(@NonNull android.media.session.MediaSession.Token, @NonNull android.view.KeyEvent);
  }

}

package android.net {

  public final class TetheringConstants {
    field public static final String EXTRA_ADD_TETHER_TYPE = "extraAddTetherType";
    field public static final String EXTRA_PROVISION_CALLBACK = "extraProvisionCallback";
    field public static final String EXTRA_REM_TETHER_TYPE = "extraRemTetherType";
    field public static final String EXTRA_RUN_PROVISION = "extraRunProvision";
    field public static final String EXTRA_SET_ALARM = "extraSetAlarm";
  }

  public class TetheringManager {
    ctor public TetheringManager(@NonNull android.content.Context, @NonNull java.util.function.Supplier<android.os.IBinder>);
    method public int getLastTetherError(@NonNull String);
    method @NonNull public String[] getTetherableBluetoothRegexs();
    method @NonNull public String[] getTetherableIfaces();
    method @NonNull public String[] getTetherableUsbRegexs();
    method @NonNull public String[] getTetherableWifiRegexs();
    method @NonNull public String[] getTetheredIfaces();
    method @NonNull public String[] getTetheringErroredIfaces();
    method public boolean isTetheringSupported();
    method public boolean isTetheringSupported(@NonNull String);
    method public void requestLatestTetheringEntitlementResult(int, @NonNull android.os.ResultReceiver, boolean);
    method @Deprecated public int setUsbTethering(boolean);
    method @RequiresPermission(anyOf={android.Manifest.permission.TETHER_PRIVILEGED, android.Manifest.permission.WRITE_SETTINGS}) public void startTethering(int, @NonNull java.util.concurrent.Executor, @NonNull android.net.TetheringManager.StartTetheringCallback);
    method @Deprecated public int tether(@NonNull String);
    method @Deprecated public int untether(@NonNull String);
  }

  public static interface TetheringManager.TetheringEventCallback {
    method public default void onTetherableInterfaceRegexpsChanged(@NonNull android.net.TetheringManager.TetheringInterfaceRegexps);
  }

  public static class TetheringManager.TetheringInterfaceRegexps {
    method @NonNull public java.util.List<java.lang.String> getTetherableBluetoothRegexs();
    method @NonNull public java.util.List<java.lang.String> getTetherableUsbRegexs();
    method @NonNull public java.util.List<java.lang.String> getTetherableWifiRegexs();
  }

}

package android.os {

  public class Binder implements android.os.IBinder {
    method public final void markVintfStability();
  }

  public interface Parcelable {
    method public default int getStability();
    field public static final int PARCELABLE_STABILITY_LOCAL = 0; // 0x0
    field public static final int PARCELABLE_STABILITY_VINTF = 1; // 0x1
  }

  public class StatsFrameworkInitializer {
    method public static void registerServiceWrappers();
    method public static void setStatsServiceManager(@NonNull android.os.StatsServiceManager);
  }

  public class StatsServiceManager {
    method @NonNull public android.os.StatsServiceManager.ServiceRegisterer getStatsCompanionServiceRegisterer();
    method @NonNull public android.os.StatsServiceManager.ServiceRegisterer getStatsManagerServiceRegisterer();
    method @NonNull public android.os.StatsServiceManager.ServiceRegisterer getStatsdServiceRegisterer();
  }

  public static class StatsServiceManager.ServiceNotFoundException extends java.lang.Exception {
    ctor public StatsServiceManager.ServiceNotFoundException(@NonNull String);
  }

  public static final class StatsServiceManager.ServiceRegisterer {
    method @Nullable public android.os.IBinder get();
    method @Nullable public android.os.IBinder getOrThrow() throws android.os.StatsServiceManager.ServiceNotFoundException;
  }

}

package android.provider {

  public final class DeviceConfig {
    field public static final String NAMESPACE_DEVICE_IDLE = "device_idle";
  }

}

package android.util {

  public class AtomicFile {
    ctor public AtomicFile(@NonNull java.io.File, @Nullable android.util.SystemConfigFileCommitEventLogger);
  }

  public final class Log {
    method public static int logToRadioBuffer(int, @Nullable String, @Nullable String);
  }

  public class SystemConfigFileCommitEventLogger {
    ctor public SystemConfigFileCommitEventLogger(@NonNull String);
    method public void setStartTime(long);
  }

}

