# Ravenwood "policy" file for framework-minus-apex.

# The "no-pta" marker is used to exclude the lines from "ravenhelper pta",
# which tries to convert policies to annotations.

# To avoid VerifyError on nano proto files (b/324063814), we rename nano proto classes.
# Note: The "rename" directive must use slashes (/) as a package name separator.
rename com/.*/nano/   devicenano/
rename android/.*/nano/   devicenano/

# StatsD auto-generated
class com.android.internal.util.FrameworkStatsLog keepclass  # no-pta

# Auto generated
class android.content.AttributionSourceState keepclass # no-pta

# Included in module-utils; cannot use annotations
class com.android.internal.util.FastXmlSerializer keepclass  # no-pta

# From modules-utils; cannot use annotations
class com.android.internal.util.Preconditions keepclass  # no-pta
class com.android.internal.logging.InstanceId keepclass  # no-pta
class com.android.internal.logging.InstanceIdSequence keepclass  # no-pta
class com.android.internal.logging.UiEvent keepclass  # no-pta
class com.android.internal.logging.UiEventLogger keepclass  # no-pta

# From modules-utils; cannot use annotations
class com.android.modules.utils.BinaryXmlPullParser keepclass  # no-pta
class com.android.modules.utils.BinaryXmlSerializer keepclass  # no-pta
class com.android.modules.utils.FastDataInput keepclass  # no-pta
class com.android.modules.utils.FastDataOutput keepclass  # no-pta
class com.android.modules.utils.ModifiedUtf8 keepclass  # no-pta
class com.android.modules.utils.TypedXmlPullParser keepclass  # no-pta
class com.android.modules.utils.TypedXmlSerializer keepclass  # no-pta

# Uri
class android.net.Uri keepclass  # no-pta
class android.net.UriCodec keepclass  # no-pta

# Telephony
class android.telephony.PinResult keepclass  # no-pta

# Just enough to support mocking, no further functionality
class android.content.BroadcastReceiver allow-annotation
    method <init> ()V allow-annotation
class android.content.Context  # no-pta
    method <init> ()V keep
class android.text.ClipboardManager keep  # no-pta
    method <init> ()V keep

# For testing experimental API
class com.android.internal.ravenwood.RavenwoodHelperBridge
    method forExperimentalApiTest exp

# Enable all the classes in the following packages as "experimental".
package android.animation exp
package android.app exp
package android.graphics.drawable exp
package android.hardware exp
package android.tracing exp
package android.transition exp
package android.util exp
package android.view exp
package android.widget exp
package android.window exp
package com.android.internal exp

# The above package-level policies won't overide class or method level
# annotations. In order to override these annotations, we need to
# set "exp" to individual classes and methods.
class android.app.ContextImpl exp
    method checkPermission @android.app.ContextImpl_ravenwood.checkPermission

class android.content.Context exp

class android.app.ActivityThread exp
class android.app.Instrumentation exp
class android.app.LoadedApk exp
class android.hardware.display.DisplayManagerGlobal exp

class android.provider.Settings
    method parseIntSettingWithDefault exp

class android.provider.Settings$Global
    method getString         i # just return null
    method getStringForUser  i # just return null
    method getInt            exp # fallback to the default value

class android.view.animation.AnimationUtils exp

class android.view.Display exp

# This one is tricky:
# ResourceManger would be unhappy if DisplayManagerGlobal.getInstance()
# throws, so we make it to return null. But if experimental APIs are
# are enabled, we want this to work.
# This one is tricky.
# It officially has a "@RavenwoodIgnore", so it needs to have "allow-annotation".
# But we actually internally keep is with this policy.
# However, the method will still return null, as long as
# ServiceManager.getService(Context.DISPLAY_SERVICE) returns null, which
# would return an instance when experimental APIs are enabled.
# We keep the @RavenwoodIgnore annotation is just for documentation purposes.
# (and it's okay for the same method to have a "regular" policy such as "keep",
# with "allow-annotation", because "allow-annotation" is handled differently.)
class android.hardware.display.DisplayManagerGlobal allow-annotation
   method getInstance ()Landroid/hardware/display/DisplayManagerGlobal; allow-annotation
   method getInstance keep

## Prevent <clinit> from throwing...
#class android.app.ActivityManager
#    method <clinit> ignore

class android.os.UserManager exp
class android.os.UserManagerCache exp
class android.os.GraphicsEnvironment exp
class android.os.StrictMode
    method trackActivity exp
    method assertConfigurationContext exp

class android.os.StrictMode$InstanceTracker exp

class android.content.Context
    method getNextAutofillId exp

class android.content.res.AssetManager
    method getLoaders exp # let it return an empty loader

class android.view.SurfaceControl
    method nativeGetNativeSurfaceControlFinalizer i #exprimental -- ignore native methods
    method nativeGetNativeTransactionFinalizer i #exprimental -- ignore native methods
    method nativeCreateTransaction i #exprimental -- ignore native methods

class android.graphics.HardwareRenderer exp
    method nSetHighContrastText i #exprimental -- ignore native methods
    method preInitBufferAllocator i #exprimental -- ignore native methods

class android.hardware.input.InputSettings
    method isStylusPointerIconEnabled exp

class android.view.InputChannel
    method nativeGetFinalizer i #exprimental -- ignore native methods

class android.tracing.perfetto.DataSource exp
    method nativeCreate i #exprimental -- ignore native methods

class android.view.InputEventReceiver exp
    method nativeInit i #exprimental -- ignore native methods

class android.tracing.perfetto.DataSource exp
    method nativeRegisterDataSource i #exprimental -- ignore native methods

class android.tracing.perfetto.Producer exp
    method nativePerfettoProducerInit i #exprimental -- ignore native methods

class android.view.SurfaceControl exp
    method nativeSetTransformHint i #exprimental -- ignore native methods

# Experimental APIs
class android.app.Instrumentation
    method startActivitySync (Landroid/content/Intent)V exp
    method startActivitySync @android.app.Instrumentation_ravenwood.startActivitySync
