signature:
public class ClassInstrumentor { /** * Creates native stub which returns the default return value .
 * @ param mutableClass Class to be instrumented
 * @ param method Method to be instrumented , must be native */
protected void instrumentNativeMethod ( MutableClass mutableClass , MethodNode method ) { } }

implementation: method . access = method . access & ~ Opcodes . ACC_NATIVE ; RobolectricGeneratorAdapter generator = new RobolectricGeneratorAdapter ( method ) ; Type returnType = generator . getReturnType ( ) ; generator . pushDefaultReturnValueToStack ( returnType ) ; generator . returnValue ( ) ;


signature:
public class ClassInstrumentor { /** * todo rename */
private MethodNode redirectorMethod ( MutableClass mutableClass , MethodNode method , String newName ) { } }

implementation: MethodNode redirector = new MethodNode ( Opcodes . ASM4 , newName , method . desc , method . signature , exceptionArray ( method ) ) ; redirector . access = method . access & ~ ( Opcodes . ACC_NATIVE | Opcodes . ACC_ABSTRACT | Opcodes . ACC_FINAL ) ; makeMethodPrivate ( redirector ) ; RobolectricGeneratorAdapter generator = new RobolectricGeneratorAdapter ( redirector ) ; generator . invokeMethod ( mutableClass . internalClassName , method ) ; generator . returnValue ( ) ; return redirector ;


signature:
public class ClassInstrumentor { /** * Filters methods that might need special treatment because of various reasons */
private void rewriteMethodBody ( MutableClass mutableClass , MethodNode callingMethod ) { } }

implementation:
ListIterator < AbstractInsnNode > instructions = callingMethod . instructions . iterator ( ) ; while ( instructions . hasNext ( ) ) { AbstractInsnNode node = instructions . next ( ) ; switch ( node . getOpcode ( ) ) { case Opcodes . NEW : TypeInsnNode newInsnNode = ( TypeInsnNode ) node ; newInsnNode . desc = mutableClass . config . mappedTypeName ( newInsnNode . desc ) ; break ; case Opcodes . GETFIELD : /* falls through */
case Opcodes . PUTFIELD : /* falls through */
case Opcodes . GETSTATIC : /* falls through */
case Opcodes . PUTSTATIC : FieldInsnNode fieldInsnNode = ( FieldInsnNode ) node ; fieldInsnNode . desc = mutableClass . config . mappedTypeName ( fieldInsnNode . desc ) ; // todo test
break ; case Opcodes . INVOKESTATIC : /* falls through */
case Opcodes . INVOKEINTERFACE : /* falls through */
case Opcodes . INVOKESPECIAL : /* falls through */
case Opcodes . INVOKEVIRTUAL : MethodInsnNode targetMethod = ( MethodInsnNode ) node ; targetMethod . desc = mutableClass . config . remapParams ( targetMethod . desc ) ; if ( isGregorianCalendarBooleanConstructor ( targetMethod ) ) { replaceGregorianCalendarBooleanConstructor ( instructions , targetMethod ) ; } else if ( mutableClass . config . shouldIntercept ( targetMethod ) ) { interceptInvokeVirtualMethod ( mutableClass , instructions , targetMethod ) ; } break ; case Opcodes . INVOKEDYNAMIC : /* no unusual behavior */
break ; default : break ; } }


signature:
public class ClassInstrumentor { /** * Verifies if the @ targetMethod is a ` < init > ( boolean ) ` constructor for
 * { @ link java . util . GregorianCalendar } . */
private boolean isGregorianCalendarBooleanConstructor ( MethodInsnNode targetMethod ) { } }

implementation: return targetMethod . owner . equals ( "java/util/GregorianCalendar" ) && targetMethod . name . equals ( "<init>" ) && targetMethod . desc . equals ( "(Z)V" ) ;


signature:
public class ClassInstrumentor { /** * Replaces the void ` < init > ( boolean ) ` constructor for a call to the
 * ` void < init > ( int , int , int ) ` one . */
private void replaceGregorianCalendarBooleanConstructor ( ListIterator < AbstractInsnNode > instructions , MethodInsnNode targetMethod ) { } }

implementation:
// Remove the call to GregorianCalendar ( boolean )
instructions . remove ( ) ; // Discard the already - pushed parameter for GregorianCalendar ( boolean )
instructions . add ( new InsnNode ( Opcodes . POP ) ) ; // Add parameters values for calling GregorianCalendar ( int , int , int )
instructions . add ( new InsnNode ( Opcodes . ICONST_0 ) ) ; instructions . add ( new InsnNode ( Opcodes . ICONST_0 ) ) ; instructions . add ( new InsnNode ( Opcodes . ICONST_0 ) ) ; // Call GregorianCalendar ( int , int , int )
instructions . add ( new MethodInsnNode ( Opcodes . INVOKESPECIAL , targetMethod . owner , targetMethod . name , "(III)V" , targetMethod . itf ) ) ;


signature:
public class ClassInstrumentor { /** * Replaces protected and private class modifiers with public . */
private void makeClassPublic ( ClassNode clazz ) { } }

implementation: clazz . access = ( clazz . access | Opcodes . ACC_PUBLIC ) & ~ ( Opcodes . ACC_PROTECTED | Opcodes . ACC_PRIVATE ) ;


signature:
public class ClassInstrumentor { /** * Replaces protected and private method modifiers with public . */
protected void makeMethodPublic ( MethodNode method ) { } }

implementation: method . access = ( method . access | Opcodes . ACC_PUBLIC ) & ~ ( Opcodes . ACC_PROTECTED | Opcodes . ACC_PRIVATE ) ;


signature:
public class ClassInstrumentor { /** * Replaces protected and public class modifiers with private . */
protected void makeMethodPrivate ( MethodNode method ) { } }

implementation: method . access = ( method . access | Opcodes . ACC_PRIVATE ) & ~ ( Opcodes . ACC_PUBLIC | Opcodes . ACC_PROTECTED ) ;


signature:
public class ShadowAccessibilityNodeInfo { /** * Check for leaked objects that were { @ code obtain } ed but never
 * { @ code recycle } d .
 * @ param printUnrecycledNodesToSystemErr - if true , stack traces of calls
 * to { @ code obtain } that lack matching calls to { @ code recycle } are
 * dumped to System . err .
 * @ return { @ code true } if there are unrecycled nodes */
public static boolean areThereUnrecycledNodes ( boolean printUnrecycledNodesToSystemErr ) { } }

implementation: if ( printUnrecycledNodesToSystemErr ) { for ( final StrictEqualityNodeWrapper wrapper : obtainedInstances . keySet ( ) ) { final ShadowAccessibilityNodeInfo shadow = Shadow . extract ( wrapper . mInfo ) ; System . err . println ( String . format ( "Leaked contentDescription = %s. Stack trace:" , shadow . getContentDescription ( ) ) ) ; for ( final StackTraceElement stackTraceElement : obtainedInstances . get ( wrapper ) ) { System . err . println ( stackTraceElement . toString ( ) ) ; } } } return ( obtainedInstances . size ( ) != 0 ) ;


signature:
public class ShadowAccessibilityNodeInfo { /** * Sets the view whose node is visited after this one in accessibility traversal .
 * This may be useful for configuring traversal order in tests before the corresponding
 * views have been inflated .
 * @ param info The previous node .
 * @ see # getTraversalAfter ( ) */
public void setTraversalAfter ( AccessibilityNodeInfo info ) { } }

implementation: if ( this . traversalAfter != null ) { this . traversalAfter . recycle ( ) ; } this . traversalAfter = obtain ( info ) ;


signature:
public class ShadowAccessibilityNodeInfo { /** * Sets the view before whose node this one should be visited during traversal .
 * This may be useful for configuring traversal order in tests before the corresponding
 * views have been inflated .
 * @ param info The view providing the preceding node .
 * @ see # getTraversalBefore ( ) */
public void setTraversalBefore ( AccessibilityNodeInfo info ) { } }

implementation: if ( this . traversalBefore != null ) { this . traversalBefore . recycle ( ) ; } this . traversalBefore = obtain ( info ) ;


signature:
public class ShadowAccessibilityNodeInfo { /** * Obtain flags for actions supported . Currently only supports { @ link
 * AccessibilityNodeInfo # ACTION _ CLICK } , { @ link AccessibilityNodeInfo # ACTION _ LONG _ CLICK } , { @ link
 * AccessibilityNodeInfo # ACTION _ SCROLL _ FORWARD } , { @ link AccessibilityNodeInfo # ACTION _ PASTE } ,
 * { @ link AccessibilityNodeInfo # ACTION _ FOCUS } , { @ link AccessibilityNodeInfo # ACTION _ SET _ SELECTION } ,
 * { @ link AccessibilityNodeInfo # ACTION _ SCROLL _ BACKWARD } Returned value is derived from the
 * getters .
 * @ return Action mask . 0 if no actions supported . */
@ Implementation protected int getActions ( ) { } }

implementation:
if ( getApiLevel ( ) >= LOLLIPOP ) { int returnValue = 0 ; if ( actionsArray == null ) { return returnValue ; } // Custom actions are only returned by getActionsList
final int actionSize = actionsArray . size ( ) ; for ( int i = 0 ; i < actionSize ; i ++ ) { int actionId = actionsArray . get ( i ) . getId ( ) ; if ( actionId <= getLastLegacyActionFromFrameWork ( ) ) { returnValue |= actionId ; } } return returnValue ; } else { return actionsMask ; }


signature:
public class ShadowAccessibilityNodeInfo { /** * Add a child node to this one . Also initializes the parent field of the
 * child .
 * @ param child The node to be added as a child . */
public void addChild ( AccessibilityNodeInfo child ) { } }

implementation: if ( children == null ) { children = new ArrayList < > ( ) ; } children . add ( child ) ; ShadowAccessibilityNodeInfo shadowAccessibilityNodeInfo = Shadow . extract ( child ) ; shadowAccessibilityNodeInfo . parent = realAccessibilityNodeInfo ;


signature:
public class RobolectricGeneratorAdapter { /** * Forces a return of a default value , depending on the method ' s return type
 * @ param type The method ' s return type */
public void pushDefaultReturnValueToStack ( Type type ) { } }

implementation: if ( type . equals ( Type . BOOLEAN_TYPE ) ) { push ( false ) ; } else if ( type . equals ( Type . INT_TYPE ) || type . equals ( Type . SHORT_TYPE ) || type . equals ( Type . BYTE_TYPE ) || type . equals ( Type . CHAR_TYPE ) ) { push ( 0 ) ; } else if ( type . equals ( Type . LONG_TYPE ) ) { push ( 0L ) ; } else if ( type . equals ( Type . FLOAT_TYPE ) ) { push ( 0f ) ; } else if ( type . equals ( Type . DOUBLE_TYPE ) ) { push ( 0d ) ; } else if ( type . getSort ( ) == ARRAY || type . getSort ( ) == OBJECT ) { loadNull ( ) ; }


signature:
public class ShadowNetworkCapabilities { /** * Updates the transport types for this network capablities to include { @ code transportType } . */
@ HiddenApi @ Implementation public NetworkCapabilities addTransportType ( int transportType ) { } }

implementation: return directlyOn ( realNetworkCapabilities , NetworkCapabilities . class , "addTransportType" , ClassParameter . from ( int . class , transportType ) ) ;


signature:
public class ZipFileRO { /** * / * static */
static ZipFileRO open ( final String zipFileName ) { } }

implementation: final Ref < ZipArchiveHandle > handle = new Ref < > ( null ) ; final int error = OpenArchive ( zipFileName , handle ) ; if ( isTruthy ( error ) ) { ALOGW ( "Error opening archive %s: %s" , zipFileName , ErrorCodeString ( error ) ) ; CloseArchive ( handle . get ( ) ) ; return null ; } return new ZipFileRO ( handle . get ( ) , zipFileName ) ;


signature: public class ZipFileRO { org . robolectric . res . android . ZipFileRO . ZipEntryRO findEntryByName ( final String entryName ) { } }

implementation: ZipEntryRO data = new ZipEntryRO ( ) ; data . name = String ( entryName ) ; final Ref < ZipEntry > zipEntryRef = new Ref < > ( data . entry ) ; final int error = FindEntry ( mHandle , data . name , zipEntryRef ) ; if ( isTruthy ( error ) ) { return null ; } data . entry = zipEntryRef . get ( ) ; return data ;


signature:
public class ZipFileRO { /** * Get the useful fields from the zip entry .
 * Returns " false " if the offsets to the fields or the contents of the fields
 * appear to be bogus . */
boolean getEntryInfo ( org . robolectric . res . android . ZipFileRO . ZipEntryRO entry , Ref < Short > pMethod , final Ref < Long > pUncompLen , Ref < Long > pCompLen , Ref < Long > pOffset , final Ref < Long > pModWhen , Ref < Long > pCrc32 ) { } }

implementation:
final ZipEntryRO zipEntry = /* reinterpret _ cast < ZipEntryRO * > */
( entry ) ; final ZipEntry ze = zipEntry . entry ; if ( pMethod != null ) { pMethod . set ( ( short ) ze . getMethod ( ) ) ; } if ( pUncompLen != null ) { pUncompLen . set ( ze . getSize ( ) ) ; // uncompressed _ length
} if ( pCompLen != null ) { pCompLen . set ( ze . getCompressedSize ( ) ) ; } if ( pOffset != null ) { throw new UnsupportedOperationException ( "Figure out offset" ) ; // pOffset = ze . offset ;
} if ( pModWhen != null ) { // todo pModWhen . set ( ze . getLastModifiedTime ( ) . toMillis ( ) ) ;
} if ( pCrc32 != null ) { pCrc32 . set ( ze . getCrc ( ) ) ; } return true ;


signature:
public class ZipFileRO { /** * Copy the entry ' s filename to the buffer . */
int getEntryFileName ( org . robolectric . res . android . ZipFileRO . ZipEntryRO entry , Ref < String > buffer ) { } }

implementation:
buffer . set ( entry . entry . getName ( ) ) ; // final ZipEntryRO * zipEntry = reinterpret _ cast < ZipEntryRO * > ( entry ) ;
// final uint16 _ t requiredSize = zipEntry . name . name _ length + 1;
// if ( bufLen < requiredSize ) {
// ALOGW ( " Buffer too short , requires % d bytes for entry name " , requiredSize ) ;
// return requiredSize ;
// memcpy ( buffer , zipEntry . name . name , requiredSize - 1 ) ;
// buffer [ requiredSize - 1 ] = ' \ 0 ' ;
return 0 ;


signature:
public class ZipFileRO { /** * Create a new FileMap object that spans the data in " entry " . */
FileMap createEntryFileMap ( ZipEntryRO entry ) { } }

implementation:
// final _ ZipEntryRO * zipEntry = reinterpret _ cast < _ ZipEntryRO * > ( entry ) ;
// const ZipEntry & ze = zipEntry - > entry ;
ZipEntry ze = entry . entry ; // int fd = GetFileDescriptor ( mHandle ) ;
int fd = - 1 ; int actualLen = 0 ; if ( ze . getMethod ( ) == kCompressStored ) { actualLen = toIntExact ( ze . getSize ( ) ) ; } else { actualLen = toIntExact ( ze . getCompressedSize ( ) ) ; } FileMap newMap = new FileMap ( ) ; if ( ! newMap . createFromZip ( mFileName , mHandle . zipFile , entry . entry , actualLen , true ) ) { // delete newMap ;
return null ; } return newMap ;


signature:
public class ZipFileRO { /** * Uncompress an entry , in its entirety , into the provided output buffer .
 * This doesn ' t verify the data ' s CRC , which might be useful for
 * uncompressed data . The caller should be able to manage it . */
boolean uncompressEntry ( org . robolectric . res . android . ZipFileRO . ZipEntryRO entry , Object buffer , int size ) { } }

implementation:
throw new UnsupportedOperationException ( "Implememnt me" ) ; // ZipEntryRO * zipEntry = reinterpret _ cast < ZipEntryRO * > ( entry ) ;
// final int error = ExtractToMemory ( mHandle , & ( zipEntry . entry ) ,
// ( uint8 _ t * ) buffer , size ) ;
// if ( error ) {
// ALOGW ( " ExtractToMemory failed with % s " , ErrorCodeString ( error ) ) ;
// return false ;
// return true ;


signature:
public class ZipFileRO { /** * Uncompress an entry , in its entirety , to an open file descriptor .
 * This doesn ' t verify the data ' s CRC , but probably should . */
boolean uncompressEntry ( org . robolectric . res . android . ZipFileRO . ZipEntryRO entry , int fd ) { } }

implementation:
throw new UnsupportedOperationException ( "Implememnt me" ) ; // ZipEntryRO * zipEntry = reinterpret _ cast < ZipEntryRO * > ( entry ) ;
// final int error = ExtractEntryToFile ( mHandle , & ( zipEntry . entry ) , fd ) ;
// if ( error ) {
// ALOGW ( " ExtractToMemory failed with % s " , ErrorCodeString ( error ) ) ;
// return false ;
// return true ;


signature:
public class OsConstantsValues { /** * Returns the st _ mode for the path . */
public static int getMode ( String path ) { } }

implementation: if ( path == null ) { return 0 ; } File file = new File ( path ) ; if ( file . isDirectory ( ) ) { return S_IFDIR_VALUE ; } if ( file . isFile ( ) ) { return S_IFREG_VALUE ; } if ( ! canonicalize ( path ) . equals ( path ) ) { return S_IFLNK_VALUE ; } return 0 ;


signature:
public class ShadowBluetoothAdapter { /** * Validate a Bluetooth address , such as " 00:43 : A8:23:10 : F0 " Alphabetic characters must be
 * uppercase to be valid .
 * @ param address Bluetooth address as string
 * @ return true if the address is valid , false otherwise */
@ Implementation protected static boolean checkBluetoothAddress ( String address ) { } }

implementation:
if ( address == null || address . length ( ) != ADDRESS_LENGTH ) { return false ; } for ( int i = 0 ; i < ADDRESS_LENGTH ; i ++ ) { char c = address . charAt ( i ) ; switch ( i % 3 ) { case 0 : case 1 : if ( ( c >= '0' && c <= '9' ) || ( c >= 'A' && c <= 'F' ) ) { // hex character , OK
break ; } return false ; case 2 : if ( c == ':' ) { break ; // OK
} return false ; } } return true ;


signature:
public class ShadowBluetoothAdapter { /** * Returns the connection state for the given Bluetooth { @ code profile } , defaulting to { @ link
 * BluetoothProfile . STATE _ DISCONNECTED } if the profile ' s connection state was never set .
 * < p > Set a Bluetooth profile ' s connection state via { @ link # setProfileConnectionState ( int , int ) } . */
@ Implementation protected int getProfileConnectionState ( int profile ) { } }

implementation: Integer state = profileConnectionStateData . get ( profile ) ; if ( state == null ) { return BluetoothProfile . STATE_DISCONNECTED ; } return state ;


signature:
public class ShadowBluetoothAdapter { /** * Sets the active BluetoothProfile { @ code proxy } for the given { @ code profile } . Will always
 * affect behavior of { @ link BluetoothAdapter # getProfileProxy } and { @ link
 * BluetoothAdapter # closeProfileProxy } . Call to { @ link BluetoothAdapter # closeProfileProxy } can
 * remove the set active proxy .
 * @ param proxy can be ' null ' to simulate the situation where { @ link
 * BluetoothAdapter # getProfileProxy } would return ' false ' . This can happen on older Android
 * versions for Bluetooth profiles introduced in later Android versions . */
public void setProfileProxy ( int profile , @ Nullable BluetoothProfile proxy ) { } }

implementation: isOverridingProxyBehavior = true ; if ( proxy != null ) { profileProxies . put ( profile , proxy ) ; }


signature:
public class ShadowBluetoothAdapter { /** * Overrides behavior of { @ link getProfileProxy } if { @ link ShadowBluetoothAdapter # setProfileProxy }
 * has been previously called .
 * If active ( non - null ) proxy has been set by { @ link setProfileProxy } for the given { @ code
 * profile } , { @ link getProfileProxy } will immediately call { @ code onServiceConnected } of the given
 * BluetoothProfile . ServiceListener { @ code listener } .
 * @ return ' true ' if a proxy object has been set by { @ link setProfileProxy } for the given
 * BluetoothProfile { @ code profile } */
@ Implementation protected boolean getProfileProxy ( Context context , BluetoothProfile . ServiceListener listener , int profile ) { } }

implementation: if ( ! isOverridingProxyBehavior ) { return directlyOn ( realAdapter , BluetoothAdapter . class ) . getProfileProxy ( context , listener , profile ) ; } BluetoothProfile proxy = profileProxies . get ( profile ) ; if ( proxy == null ) { return false ; } else { listener . onServiceConnected ( profile , proxy ) ; return true ; }


signature:
public class ShadowBluetoothAdapter { /** * Overrides behavior of { @ link closeProfileProxy } if { @ link
 * ShadowBluetoothAdapter # setProfileProxy } has been previously called .
 * If the given non - null BluetoothProfile { @ code proxy } was previously set for the given { @ code
 * profile } by { @ link ShadowBluetoothAdapter # setProfileProxy } , this proxy will be " deactivated " . */
@ Implementation protected void closeProfileProxy ( int profile , BluetoothProfile proxy ) { } }

implementation: if ( ! isOverridingProxyBehavior ) { directlyOn ( realAdapter , BluetoothAdapter . class ) . closeProfileProxy ( profile , proxy ) ; return ; } if ( proxy != null && proxy . equals ( profileProxies . get ( profile ) ) ) { profileProxies . remove ( profile ) ; }


signature:
public class ActivityController { /** * Calls the same lifecycle methods on the Activity called by Android when an Activity is restored from previously saved state .
 * @ param savedInstanceState Saved instance state .
 * @ return Activity controller instance . */
public ActivityController < T > setup ( Bundle savedInstanceState ) { } }

implementation: return create ( savedInstanceState ) . start ( ) . restoreInstanceState ( savedInstanceState ) . postCreate ( savedInstanceState ) . resume ( ) . visible ( ) ;


signature:
public class ActivityController { /** * Performs a configuration change on the Activity .
 * If the activity is configured to handle changes without being recreated ,
 * { @ link Activity # onConfigurationChanged ( Configuration ) } will be called . Otherwise , the activity
 * is recreated as described [ here ] ( https : / / developer . android . com / guide / topics / resources / runtime - changes . html ) .
 * @ param newConfiguration The new configuration to be set .
 * @ return ActivityController instance */
public ActivityController < T > configurationChange ( final Configuration newConfiguration ) { } }

implementation:
final Configuration currentConfig = component . getResources ( ) . getConfiguration ( ) ; final int changedBits = currentConfig . diff ( newConfiguration ) ; currentConfig . setTo ( newConfiguration ) ; // TODO : throw on changedBits = = 0 since it non - intuitively calls onConfigurationChanged
// Can the activity handle itself ALL configuration changes ?
if ( ( getActivityInfo ( component . getApplication ( ) ) . configChanges & changedBits ) == changedBits ) { shadowMainLooper . runPaused ( ( ) -> component . onConfigurationChanged ( newConfiguration ) ) ; return this ; } else { @ SuppressWarnings ( "unchecked" ) final T recreatedActivity = ( T ) ReflectionHelpers . callConstructor ( component . getClass ( ) ) ; final _Activity_ _recreatedActivity_ = reflector ( _Activity_ . class , recreatedActivity ) ; shadowMainLooper . runPaused ( new Runnable ( ) { @ Override public void run ( ) { // Set flags
ReflectionHelpers . setField ( Activity . class , component , "mChangingConfigurations" , true ) ; ReflectionHelpers . setField ( Activity . class , component , "mConfigChangeFlags" , changedBits ) ; // Perform activity destruction
final Bundle outState = new Bundle ( ) ; // The order of onPause / onStop / onSaveInstanceState is undefined , but is usually :
// onPause - > onSaveInstanceState - > onStop
_component_ . performPause ( ) ; _component_ . performSaveInstanceState ( outState ) ; if ( RuntimeEnvironment . getApiLevel ( ) <= M ) { _component_ . performStop ( ) ; } else if ( RuntimeEnvironment . getApiLevel ( ) <= O_MR1 ) { _component_ . performStop ( true ) ; } else { _component_ . performStop ( true , "configurationChange" ) ; } // This is the true and complete retained state , including loaders and retained
// fragments .
final Object nonConfigInstance = _component_ . retainNonConfigurationInstances ( ) ; // This is the activity ' s " user " state
final Object activityConfigInstance = nonConfigInstance == null ? null // No framework or user state .
: reflector ( _NonConfigurationInstances_ . class , nonConfigInstance ) . getActivity ( ) ; _component_ . performDestroy ( ) ; // Restore theme in case it was set in the test manually .
// This is not technically what happens but is purely to make this easier to use in
// Robolectric .
ShadowContextThemeWrapper shadowContextThemeWrapper = Shadow . extract ( component ) ; int theme = shadowContextThemeWrapper . callGetThemeResId ( ) ; // Setup controller for the new activity
attached = false ; component = recreatedActivity ; _component_ = _recreatedActivity_ ; // TODO : Pass nonConfigurationInstance here instead of setting
// mLastNonConfigurationInstances directly below . This field must be set before
// attach . Since current implementation sets it after attach ( ) , initialization is not
// done correctly . For instance , fragment marked as retained is not retained .
attach ( /* lastNonConfigurationInstances = */
null ) ; if ( theme != 0 ) { recreatedActivity . setTheme ( theme ) ; } // Set saved non config instance
_recreatedActivity_ . setLastNonConfigurationInstances ( nonConfigInstance ) ; ShadowActivity shadowActivity = Shadow . extract ( recreatedActivity ) ; shadowActivity . setLastNonConfigurationInstance ( activityConfigInstance ) ; // Create lifecycle
_recreatedActivity_ . performCreate ( outState ) ; if ( RuntimeEnvironment . getApiLevel ( ) <= O_MR1 ) { _recreatedActivity_ . performStart ( ) ; } else { _recreatedActivity_ . performStart ( "configurationChange" ) ; } _recreatedActivity_ . performRestoreInstanceState ( outState ) ; _recreatedActivity_ . onPostCreate ( outState ) ; if ( RuntimeEnvironment . getApiLevel ( ) <= O_MR1 ) { _recreatedActivity_ . performResume ( ) ; } else { _recreatedActivity_ . performResume ( true , "configurationChange" ) ; } _recreatedActivity_ . onPostResume ( ) ; // TODO : Call visible ( ) too .
} } ) ; } return this ;


signature:
public class ActivityController { /** * Recreates activity instance which is controlled by this ActivityController .
 * NonConfigurationInstances and savedInstanceStateBundle are properly passed into a new instance .
 * After the recreation , it brings back its lifecycle state to the original state . The activity
 * should not be destroyed yet . */
@ SuppressWarnings ( "unchecked" ) public ActivityController < T > recreate ( ) { } }

implementation:
Stage originalStage = ActivityLifecycleMonitorRegistry . getInstance ( ) . getLifecycleStageOf ( component ) ; switch ( originalStage ) { case PRE_ON_CREATE : create ( ) ; // fall through
case CREATED : case RESTARTED : start ( ) ; postCreate ( null ) ; // fall through
case STARTED : resume ( ) ; // fall through
case RESUMED : pause ( ) ; // fall through
case PAUSED : stop ( ) ; // fall through
case STOPPED : break ; default : throw new IllegalStateException ( "Cannot recreate activity since it's destroyed already" ) ; } // Activity # mChangingConfigurations flag should be set prior to Activity recreation process
// starts . ActivityThread does set it on real device but here we simulate the Activity
// recreation process on behalf of ActivityThread so set the flag here . Note we don ' t need to
// reset the flag to false because this Activity instance is going to be destroyed and disposed .
// https : / / android . googlesource . com / platform / frameworks / base / + / 55418eada51d4f5e6532ae9517af66c50
// ea495c4 / core / java / android / app / ActivityThread . java # 4806
ReflectionHelpers . setField ( component , "mChangingConfigurations" , true ) ; Bundle outState = new Bundle ( ) ; saveInstanceState ( outState ) ; Object lastNonConfigurationInstances = ReflectionHelpers . callInstanceMethod ( component , "retainNonConfigurationInstances" ) ; destroy ( ) ; component = ( T ) ReflectionHelpers . callConstructor ( component . getClass ( ) ) ; _component_ = reflector ( _Activity_ . class , component ) ; attached = false ; attach ( lastNonConfigurationInstances ) ; create ( outState ) ; start ( ) ; restoreInstanceState ( outState ) ; postCreate ( outState ) ; resume ( ) ; postResume ( ) ; visible ( ) ; windowFocusChanged ( true ) ; // Move back to the original stage . If the original stage was transient stage , it will bring it
// to resumed state to match the on device behavior .
switch ( originalStage ) { case PAUSED : pause ( ) ; return this ; case STOPPED : pause ( ) ; stop ( ) ; return this ; default : return this ; }


signature:
public class ResourceHelper2 { /** * Returns the raw value from the given attribute float - type value string .
 * This object is only valid until the next call on to { @ link ResourceHelper2 } .
 * @ param attribute Attribute name .
 * @ param value Attribute value .
 * @ param requireUnit whether the value is expected to contain a unit .
 * @ return The typed value . */
public static TypedValue getValue ( String attribute , String value , boolean requireUnit ) { } }

implementation: if ( parseFloatAttribute ( attribute , value , mValue , requireUnit ) ) { return mValue ; } return null ;


signature:
public class ConfigMerger { /** * Calculate the { @ link Config } for the given test .
 * @ param testClass the class containing the test
 * @ param method the test method
 * @ param globalConfig global configuration values
 * @ return the effective configuration
 * @ since 3.2 */
public Config getConfig ( Class < ? > testClass , Method method , Config globalConfig ) { } }

implementation: Config config = Config . Builder . defaults ( ) . build ( ) ; config = override ( config , globalConfig ) ; for ( String packageName : reverse ( packageHierarchyOf ( testClass ) ) ) { Config packageConfig = cachedPackageConfig ( packageName ) ; config = override ( config , packageConfig ) ; } for ( Class clazz : reverse ( parentClassesFor ( testClass ) ) ) { Config classConfig = ( Config ) clazz . getAnnotation ( Config . class ) ; config = override ( config , classConfig ) ; } Config methodConfig = method . getAnnotation ( Config . class ) ; config = override ( config , methodConfig ) ; return config ;


signature:
public class ConfigMerger { /** * Generate { @ link Config } for the specified package .
 * More specific packages , test classes , and test method configurations
 * will override values provided here .
 * The default implementation uses properties provided by { @ link # getConfigProperties ( String ) } .
 * The returned object is likely to be reused for many tests .
 * @ param packageName the name of the package , or empty string ( { @ code " " } ) for the top level package
 * @ return { @ link Config } object for the specified package
 * @ since 3.2 */
@ Nullable private Config buildPackageConfig ( String packageName ) { } }

implementation: return Config . Implementation . fromProperties ( getConfigProperties ( packageName ) ) ;


signature:
public class ConfigMerger { /** * Return a { @ link Properties } file for the given package name , or { @ code null } if none is available .
 * @ since 3.2 */
protected Properties getConfigProperties ( String packageName ) { } }

implementation: List < String > packageParts = new ArrayList < > ( Arrays . asList ( packageName . split ( "\\." ) ) ) ; packageParts . add ( RobolectricTestRunner . CONFIG_PROPERTIES ) ; final String resourceName = Join . join ( "/" , packageParts ) ; try ( InputStream resourceAsStream = getResourceAsStream ( resourceName ) ) { if ( resourceAsStream == null ) return null ; Properties properties = new Properties ( ) ; properties . load ( resourceAsStream ) ; return properties ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; }


signature:
public class ShadowTelephonyManager { /** * Sets the current call state with the option to specify an incoming phone number for the
 * CALL _ STATE _ RINGING state . The incoming phone number will be ignored for all other cases . */
public void setCallState ( int callState , String incomingPhoneNumber ) { } }

implementation: if ( callState != CALL_STATE_RINGING ) { incomingPhoneNumber = null ; } this . callState = callState ; this . incomingPhoneNumber = incomingPhoneNumber ; for ( PhoneStateListener listener : getListenersForFlags ( LISTEN_CALL_STATE ) ) { listener . onCallStateChanged ( callState , incomingPhoneNumber ) ; }


signature:
public class ShadowTelephonyManager { /** * Returns { @ code null } by default or the value specified via { @ link
 * # setVoicemailVibrationEnabled ( PhoneAccountHandle , boolean ) } . */
@ Implementation ( minSdk = N ) protected boolean isVoicemailVibrationEnabled ( PhoneAccountHandle handle ) { } }

implementation: Boolean result = voicemailVibrationEnabledMap . get ( handle ) ; return result != null ? result : false ;


signature:
public class ShadowTelephonyManager { /** * Sets the value returned by { @ link
 * TelephonyManager # isVoicemailVibrationEnabled ( PhoneAccountHandle ) } . */
@ Implementation ( minSdk = O ) protected void setVoicemailVibrationEnabled ( PhoneAccountHandle handle , boolean isEnabled ) { } }

implementation: voicemailVibrationEnabledMap . put ( handle , isEnabled ) ;


signature:
public class ShadowTelephonyManager { /** * Returns { @ code null } by default or the value specified via { @ link
 * # setVoicemailRingtoneUri ( PhoneAccountHandle , Uri ) } . */
@ Implementation ( minSdk = N ) protected Uri getVoicemailRingtoneUri ( PhoneAccountHandle handle ) { } }

implementation: return voicemailRingtoneUriMap . get ( handle ) ;


signature:
public class ShadowTelephonyManager { /** * Sets the value returned by { @ link
 * TelephonyManager # getVoicemailRingtoneUri ( PhoneAccountHandle ) } . */
@ Implementation ( minSdk = O ) protected void setVoicemailRingtoneUri ( PhoneAccountHandle handle , Uri uri ) { } }

implementation: voicemailRingtoneUriMap . put ( handle , uri ) ;


signature:
public class ShadowTelephonyManager { /** * Returns { @ code null } by default or the value specified via { @ link
 * # setTelephonyManagerForHandle ( PhoneAccountHandle , TelephonyManager ) } . */
@ Implementation ( minSdk = O ) protected TelephonyManager createForPhoneAccountHandle ( PhoneAccountHandle handle ) { } }

implementation: return phoneAccountToTelephonyManagers . get ( handle ) ;


signature:
public class ShadowTelephonyManager { /** * Sets the value to be returned by { @ link # getSignalStrength ( ) } */
public void setSignalStrength ( SignalStrength signalStrength ) { } }

implementation: this . signalStrength = signalStrength ; for ( PhoneStateListener listener : getListenersForFlags ( PhoneStateListener . LISTEN_SIGNAL_STRENGTHS ) ) { listener . onSignalStrengthsChanged ( signalStrength ) ; }


signature:
public class ShadowTelephonyManager { /** * Cribbed from { @ link android . telephony . PhoneNumberUtils # isEmergencyNumberInternal } .
 * TODO ( b / 122324733 ) need better implementation */
@ Implementation ( minSdk = Build . VERSION_CODES . Q ) protected boolean isCurrentEmergencyNumber ( String number ) { } }

implementation:
if ( number == null ) { return false ; } Context context = ReflectionHelpers . getField ( realTelephonyManager , "mContext" ) ; Locale locale = context == null ? null : context . getResources ( ) . getConfiguration ( ) . locale ; String defaultCountryIso = locale == null ? null : locale . getCountry ( ) ; int slotId = - 1 ; boolean useExactMatch = true ; // retrieve the list of emergency numbers
// check read - write ecclist property first
String ecclist = ( slotId <= 0 ) ? "ril.ecclist" : ( "ril.ecclist" + slotId ) ; String emergencyNumbers = SystemProperties . get ( ecclist , "" ) ; if ( TextUtils . isEmpty ( emergencyNumbers ) ) { // then read - only ecclist property since old RIL only uses this
emergencyNumbers = SystemProperties . get ( "ro.ril.ecclist" ) ; } if ( ! TextUtils . isEmpty ( emergencyNumbers ) ) { // searches through the comma - separated list for a match ,
// return true if one is found .
for ( String emergencyNum : emergencyNumbers . split ( "," ) ) { // It is not possible to append additional digits to an emergency number to dial
// the number in Brazil - it won ' t connect .
if ( useExactMatch || "BR" . equalsIgnoreCase ( defaultCountryIso ) ) { if ( number . equals ( emergencyNum ) ) { return true ; } } else { if ( number . startsWith ( emergencyNum ) ) { return true ; } } } // no matches found against the list !
return false ; } emergencyNumbers = ( ( slotId < 0 ) ? "112,911,000,08,110,118,119,999" : "112,911" ) ; for ( String emergencyNum : emergencyNumbers . split ( "," ) ) { if ( useExactMatch ) { if ( number . equals ( emergencyNum ) ) { return true ; } } else { if ( number . startsWith ( emergencyNum ) ) { return true ; } } } return false ;


signature:
public class ExpectedLogMessagesRule { /** * Adds an expected log statement . If this log is not printed during test execution , the test case
 * will fail . Do not use this to suppress failures . Use this to test that expected error cases in
 * your code cause log messages to be printed . */
public void expectLogMessage ( int level , String tag , String message ) { } }

implementation: checkTag ( tag ) ; expectedLogs . add ( new LogItem ( level , tag , message , null ) ) ;


signature:
public class ExpectedLogMessagesRule { /** * Blanket suppress test failures due to errors from a tag . If this tag is not printed at
 * Log . ERROR during test execution , the test case will fail ( unless { @ link
 * # ignoreMissingLoggedTags ( ) } is used ) .
 * < p > Avoid using this method when possible . Prefer to assert on the presence of a specific
 * message using { @ link # expectLogMessage } in test cases that * intentionally * trigger an error . */
public void expectErrorsForTag ( String tag ) { } }

implementation: checkTag ( tag ) ; if ( UNPREVENTABLE_TAGS . contains ( tag ) ) { throw new AssertionError ( "Tag `" + tag + "` is already suppressed." ) ; } expectedTags . add ( tag ) ;


signature:
public class ShadowCarrierConfigManager { /** * Returns { @ link android . os . PersistableBundle } previously set by { @ link # setConfigForSubId ( int ) } ,
 * or default values for an invalid { @ code subId } . */
@ Implementation protected PersistableBundle getConfigForSubId ( int subId ) { } }

implementation: PersistableBundle persistableBundle = bundles . get ( subId ) ; if ( persistableBundle == null ) { return new PersistableBundle ( ) ; } return persistableBundle ;


signature:
public class ServiceData { /** * Returns whether this service is exported by checking the XML attribute .
 * @ return true if the service is exported */
public boolean isExported ( ) { } }

implementation: boolean defaultValue = ! intentFilters . isEmpty ( ) ; return ( attributes . containsKey ( EXPORTED ) ? Boolean . parseBoolean ( attributes . get ( EXPORTED ) ) : defaultValue ) ;


signature:
public class ContentProviderController { /** * Create and register { @ link ContentProvider } using { @ link ProviderInfo } found from manifest . */
public ContentProviderController < T > create ( ) { } }

implementation: Context baseContext = RuntimeEnvironment . application . getBaseContext ( ) ; ComponentName componentName = createRelative ( baseContext . getPackageName ( ) , contentProvider . getClass ( ) . getName ( ) ) ; ProviderInfo providerInfo = null ; try { providerInfo = baseContext . getPackageManager ( ) . getProviderInfo ( componentName , PackageManager . MATCH_DISABLED_COMPONENTS ) ; } catch ( PackageManager . NameNotFoundException e ) { Logger . strict ( "Unable to find provider info for " + componentName , e ) ; } return create ( providerInfo ) ;


signature:
public class ContentProviderController { /** * Create and register { @ link ContentProvider } using { @ link ProviderInfo } found from manifest .
 * @ param authority the authority to use
 * @ return this { @ link ContentProviderController } */
public ContentProviderController < T > create ( String authority ) { } }

implementation: ProviderInfo providerInfo = new ProviderInfo ( ) ; providerInfo . authority = authority ; return create ( providerInfo ) ;


signature:
public class ContentProviderController { /** * Create and register { @ link ContentProvider } using the given { @ link ProviderInfo } .
 * @ param providerInfo the { @ link ProviderInfo } to use
 * @ return this { @ link ContentProviderController } */
public ContentProviderController < T > create ( ProviderInfo providerInfo ) { } }

implementation:
Context baseContext = RuntimeEnvironment . application . getBaseContext ( ) ; // make sure the component is enabled
ComponentName componentName = createRelative ( baseContext . getPackageName ( ) , contentProvider . getClass ( ) . getName ( ) ) ; baseContext . getPackageManager ( ) . setComponentEnabledSetting ( componentName , PackageManager . COMPONENT_ENABLED_STATE_ENABLED , 0 ) ; contentProvider . attachInfo ( baseContext , providerInfo ) ; if ( providerInfo != null ) { ShadowContentResolver . registerProviderInternal ( providerInfo . authority , contentProvider ) ; } return this ;


signature:
public class CachedPathIteratorFactory { /** * Returns the end point of a given segment
 * @ param type the segment type
 * @ param coords the segment coordinates array
 * @ param point the return array where the point will be stored */
private static void getShapeEndPoint ( int type , float [ ] coords , float [ ] point ) { } }

implementation:
// start index of the end point for the segment type
int pointIndex = ( getNumberOfPoints ( type ) - 1 ) * 2 ; point [ 0 ] = coords [ pointIndex ] ; point [ 1 ] = coords [ pointIndex + 1 ] ;


signature:
public class CachedPathIteratorFactory { /** * Returns the estimated length of a flat path . If the passed path is not flat ( i . e . contains a
 * segment that is not { @ link PathIterator # SEG _ CLOSE } , { @ link PathIterator # SEG _ MOVETO } or { @ link
 * PathIterator # SEG _ LINETO } this method will fail . */
private static float getFlatPathLength ( PathIterator iterator ) { } }

implementation:
float segment [ ] = new float [ 6 ] ; float totalLength = 0 ; float [ ] previousPoint = new float [ 2 ] ; boolean isFirstPoint = true ; while ( ! iterator . isDone ( ) ) { int type = iterator . currentSegment ( segment ) ; assert type == PathIterator . SEG_LINETO || type == PathIterator . SEG_CLOSE || type == PathIterator . SEG_MOVETO ; // MoveTo shouldn ' t affect the length
if ( ! isFirstPoint && type != PathIterator . SEG_MOVETO ) { totalLength += ( float ) Point2D . distance ( previousPoint [ 0 ] , previousPoint [ 1 ] , segment [ 0 ] , segment [ 1 ] ) ; } else { isFirstPoint = false ; } previousPoint [ 0 ] = segment [ 0 ] ; previousPoint [ 1 ] = segment [ 1 ] ; iterator . next ( ) ; } return totalLength ;


signature:
public class CachedPathIteratorFactory { /** * Returns the estimated position along a path of the given length . */
private void getPointAtLength ( int type , float [ ] coords , float lastX , float lastY , float t , float [ ] point ) { } }

implementation:
if ( type == PathIterator . SEG_LINETO ) { point [ 0 ] = lastX + ( coords [ 0 ] - lastX ) * t ; point [ 1 ] = lastY + ( coords [ 1 ] - lastY ) * t ; // Return here , since we do not need a shape to estimate
return ; } float [ ] curve = new float [ 8 ] ; int lastPointIndex = ( getNumberOfPoints ( type ) - 1 ) * 2 ; System . arraycopy ( coords , 0 , curve , 2 , coords . length ) ; curve [ 0 ] = lastX ; curve [ 1 ] = lastY ; if ( type == PathIterator . SEG_CUBICTO ) { cubicCurveSegment ( curve , 0f , t ) ; } else { quadCurveSegment ( curve , 0f , t ) ; } point [ 0 ] = curve [ 2 + lastPointIndex ] ; point [ 1 ] = curve [ 2 + lastPointIndex + 1 ] ;


signature: public class ShadowArscAssetManager9 { @ Implementation protected static void createSystemAssetsInZygoteLocked ( ) { } }

implementation:
_AssetManager28_ _assetManagerStatic_ = reflector ( _AssetManager28_ . class ) ; AssetManager sSystem = _assetManagerStatic_ . getSystem ( ) ; if ( sSystem != null ) { return ; } if ( systemCppAssetManager2 == null ) { // first time ! let the framework create a CppAssetManager2 and an AssetManager , which we ' ll
// hang on to .
directlyOn ( AssetManager . class , "createSystemAssetsInZygoteLocked" ) ; cachedSystemApkAssets = _assetManagerStatic_ . getSystemApkAssets ( ) ; cachedSystemApkAssetsSet = _assetManagerStatic_ . getSystemApkAssetsSet ( ) ; } else { // reuse the shared system CppAssetManager2 ; create a new AssetManager around it .
_assetManagerStatic_ . setSystemApkAssets ( cachedSystemApkAssets ) ; _assetManagerStatic_ . setSystemApkAssetsSet ( cachedSystemApkAssetsSet ) ; sSystem = ReflectionHelpers . callConstructor ( AssetManager . class , ClassParameter . from ( boolean . class , true /* sentinel */
) ) ; sSystem . setApkAssets ( cachedSystemApkAssets , false /* invalidateCaches */
) ; ReflectionHelpers . setStaticField ( AssetManager . class , "sSystem" , sSystem ) ; }


signature: public class ShadowArscAssetManager9 { @ Override Collection < Path > getAllAssetDirs ( ) { } }

implementation: ApkAssets [ ] apkAssetsArray = reflector ( _AssetManager28_ . class , realAssetManager ) . getApkAssets ( ) ; ArrayList < Path > assetDirs = new ArrayList < > ( ) ; for ( ApkAssets apkAssets : apkAssetsArray ) { long apk_assets_native_ptr = ( ( ShadowArscApkAssets9 ) Shadow . extract ( apkAssets ) ) . getNativePtr ( ) ; CppApkAssets cppApkAssets = Registries . NATIVE_APK_ASSETS_REGISTRY . getNativeObject ( apk_assets_native_ptr ) ; if ( new File ( cppApkAssets . GetPath ( ) ) . isFile ( ) ) { assetDirs . add ( Fs . forJar ( Paths . get ( cppApkAssets . GetPath ( ) ) ) . getPath ( "assets" ) ) ; } else { assetDirs . add ( Paths . get ( cppApkAssets . GetPath ( ) ) ) ; } } return assetDirs ;


signature:
public class ShadowArscAssetManager9 { static CppAssetManager2 NdkAssetManagerForJavaObject ( /* JNIEnv * env , */
AssetManager jassetmanager ) { } }

implementation:
// long assetmanager _ handle = env . GetLongField ( jassetmanager , gAssetManagerOffsets . mObject ) ;
long assetmanager_handle = ReflectionHelpers . getField ( jassetmanager , "mObject" ) ; CppAssetManager2 am = Registries . NATIVE_ASSET_MANAGER_REGISTRY . getNativeObject ( assetmanager_handle ) ; if ( am == null ) { throw new IllegalStateException ( "AssetManager has been finalized!" ) ; } return am ;


signature:
public class ShadowArscAssetManager9 { /** * static jobject NativeGetAssetAllocations ( JNIEnv * env , jobject / * clazz */
) { } }

implementation: * / @ Implementation ( minSdk = P ) protected static String getAssetAllocations ( ) { String alloc = Asset . getAssetAllocations ( ) ; if ( alloc . length ( ) <= 0 ) { return null ; } return alloc ;


signature:
public class ShadowArscAssetManager9 { /** * static jlong NativeCreate ( JNIEnv * / * env */
, jclass /* clazz */
) { } }

implementation:
* / @ Implementation ( minSdk = P ) protected static long nativeCreate ( ) { // AssetManager2 needs to be protected by a lock . To avoid cache misses , we allocate the lock and
// AssetManager2 in a contiguous block ( GuardedAssetManager ) .
// return reinterpret _ cast < long > ( new GuardedAssetManager ( ) ) ;
long cppAssetManagerRef ; // we want to share a single instance of the system CppAssetManager2
if ( inNonSystemConstructor ) { CppAssetManager2 appAssetManager = new CppAssetManager2 ( ) ; cppAssetManagerRef = Registries . NATIVE_ASSET_MANAGER_REGISTRY . register ( appAssetManager ) ; } else { if ( systemCppAssetManager2 == null ) { systemCppAssetManager2 = new CppAssetManager2 ( ) ; systemCppAssetManager2Ref = Registries . NATIVE_ASSET_MANAGER_REGISTRY . register ( systemCppAssetManager2 ) ; } cppAssetManagerRef = systemCppAssetManager2Ref ; } return cppAssetManagerRef ;


signature:
public class ShadowArscAssetManager9 { /** * static void NativeDestroy ( JNIEnv * / * env */
, jclass /* clazz */
, jlong ptr ) { } }

implementation:
* / @ Implementation ( minSdk = P ) protected static void nativeDestroy ( long ptr ) { if ( ptr == systemCppAssetManager2Ref ) { // don ' t destroy the shared system CppAssetManager2!
return ; } // delete reinterpret _ cast < GuardedAssetManager * > ( ptr ) ;
Registries . NATIVE_ASSET_MANAGER_REGISTRY . unregister ( ptr ) ;


signature:
public class ShadowArscAssetManager9 { /** * jobjectArray apk _ assets _ array , jboolean invalidate _ caches ) { */
@ Implementation ( minSdk = P ) protected static void nativeSetApkAssets ( long ptr , @ NonNull android . content . res . ApkAssets [ ] apk_assets_array , boolean invalidate_caches ) { } }

implementation:
ATRACE_NAME ( "AssetManager::SetApkAssets" ) ; int apk_assets_len = apk_assets_array . length ; List < CppApkAssets > apk_assets = new ArrayList < > ( ) ; // apk _ assets . reserve ( apk _ assets _ len ) ;
for ( int i = 0 ; i < apk_assets_len ; i ++ ) { android . content . res . ApkAssets apkAssets = apk_assets_array [ i ] ; // env . GetObjectArrayElement ( apk _ assets _ array , i ) ;
if ( apkAssets == null ) { throw new NullPointerException ( String . format ( "ApkAssets at index %d is null" , i ) ) ; } long apk_assets_native_ptr = ( ( ShadowArscApkAssets9 ) Shadow . extract ( apkAssets ) ) . getNativePtr ( ) ; // if ( env . ExceptionCheck ( ) ) {
// return ;
apk_assets . add ( Registries . NATIVE_APK_ASSETS_REGISTRY . getNativeObject ( apk_assets_native_ptr ) ) ; } CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; assetmanager . SetApkAssets ( apk_assets , invalidate_caches ) ;


signature:
public class ShadowArscAssetManager9 { /** * jint color _ mode , jint major _ version ) { */
@ Implementation ( minSdk = P ) protected static void nativeSetConfiguration ( long ptr , int mcc , int mnc , @ Nullable String locale , int orientation , int touchscreen , int density , int keyboard , int keyboard_hidden , int navigation , int screen_width , int screen_height , int smallest_screen_width_dp , int screen_width_dp , int screen_height_dp , int screen_layout , int ui_mode , int color_mode , int major_version ) { } }

implementation:
ATRACE_NAME ( "AssetManager::SetConfiguration" ) ; ResTable_config configuration = new ResTable_config ( ) ; // memset ( & configuration , 0 , sizeof ( configuration ) ) ;
configuration . mcc = ( short ) ( mcc ) ; configuration . mnc = ( short ) ( mnc ) ; configuration . orientation = ( byte ) ( orientation ) ; configuration . touchscreen = ( byte ) ( touchscreen ) ; configuration . density = ( short ) ( density ) ; configuration . keyboard = ( byte ) ( keyboard ) ; configuration . inputFlags = ( byte ) ( keyboard_hidden ) ; configuration . navigation = ( byte ) ( navigation ) ; configuration . screenWidth = ( short ) ( screen_width ) ; configuration . screenHeight = ( short ) ( screen_height ) ; configuration . smallestScreenWidthDp = ( short ) ( smallest_screen_width_dp ) ; configuration . screenWidthDp = ( short ) ( screen_width_dp ) ; configuration . screenHeightDp = ( short ) ( screen_height_dp ) ; configuration . screenLayout = ( byte ) ( screen_layout ) ; configuration . uiMode = ( byte ) ( ui_mode ) ; configuration . colorMode = ( byte ) ( color_mode ) ; configuration . sdkVersion = ( short ) ( major_version ) ; if ( locale != null ) { String locale_utf8 = locale ; CHECK ( locale_utf8 != null ) ; configuration . setBcp47Locale ( locale_utf8 ) ; } // Constants duplicated from Java class android . content . res . Configuration .
int kScreenLayoutRoundMask = 0x300 ; int kScreenLayoutRoundShift = 8 ; // In Java , we use a 32bit integer for screenLayout , while we only use an 8bit integer
// in C + + . We must extract the round qualifier out of the Java screenLayout and put it
// into screenLayout2.
configuration . screenLayout2 = ( byte ) ( ( screen_layout & kScreenLayoutRoundMask ) >> kScreenLayoutRoundShift ) ; CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; assetmanager . SetConfiguration ( configuration ) ;


signature:
public class ShadowArscAssetManager9 { /** * static jobject NativeGetAssignedPackageIdentifiers ( JNIEnv * env , jclass / * clazz */
, jlong ptr ) { } }

implementation:
* / @ Implementation ( minSdk = P ) protected static @ NonNull SparseArray < String > nativeGetAssignedPackageIdentifiers ( long ptr ) { CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; SparseArray < String > sparse_array = new SparseArray < > ( ) ; if ( sparse_array == null ) { // An exception is pending .
return null ; } assetmanager . ForEachPackage ( ( String package_name , byte package_id ) -> { String jpackage_name = package_name ; // env . NewStringUTF ( package _ name ) ;
if ( jpackage_name == null ) { // An exception is pending .
return ; } // env . CallVoidMethod ( sparse _ array , gSparseArrayOffsets . put , ( int ) ( package _ id ) ,
// jpackage _ name ) ;
sparse_array . put ( package_id , jpackage_name ) ; } ) ; return sparse_array ;


signature:
public class ShadowArscAssetManager9 { /** * static jobjectArray NativeList ( JNIEnv * env , jclass / * clazz */
, jlong ptr , jstring path ) { } }

implementation:
* / @ Implementation ( minSdk = P ) protected static @ Nullable String [ ] nativeList ( long ptr , @ NonNull String path ) throws IOException { String path_utf8 = path ; if ( path_utf8 == null ) { // This will throw NPE .
return null ; } CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; AssetDir asset_dir = assetmanager . OpenDir ( path_utf8 ) ; if ( asset_dir == null ) { throw new FileNotFoundException ( path_utf8 ) ; } int file_count = asset_dir . getFileCount ( ) ; String [ ] array = new String [ file_count ] ; // env . NewObjectArray ( file _ count , g _ stringClass , null ) ;
// if ( array = = null ) {
// return null ;
for ( int i = 0 ; i < file_count ; i ++ ) { String java_string = asset_dir . getFileName ( i ) . string ( ) ; // Check for errors creating the strings ( if malformed or no memory ) .
// if ( env . ExceptionCheck ( ) ) {
// return null ;
// env . SetObjectArrayElement ( array , i , java _ string ) ;
array [ i ] = java_string ; // If we have a large amount of string in our array , we might overflow the
// local reference table of the VM .
// env . DeleteLocalRef ( java _ string ) ;
} return array ;


signature:
public class ShadowArscAssetManager9 { /** * jint access _ mode ) { */
@ Implementation ( minSdk = P ) protected static long nativeOpenAsset ( long ptr , @ NonNull String asset_path , int access_mode ) throws FileNotFoundException { } }

implementation:
String asset_path_utf8 = asset_path ; if ( asset_path_utf8 == null ) { // This will throw NPE .
return 0 ; } ATRACE_NAME ( String . format ( "AssetManager::OpenAsset(%s)" , asset_path_utf8 ) ) ; if ( access_mode != Asset . AccessMode . ACCESS_UNKNOWN . mode ( ) && access_mode != Asset . AccessMode . ACCESS_RANDOM . mode ( ) && access_mode != Asset . AccessMode . ACCESS_STREAMING . mode ( ) && access_mode != Asset . AccessMode . ACCESS_BUFFER . mode ( ) ) { throw new IllegalArgumentException ( "Bad access mode" ) ; } CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; Asset asset = assetmanager . Open ( asset_path_utf8 , Asset . AccessMode . fromInt ( access_mode ) ) ; if ( ! isTruthy ( asset ) ) { throw new FileNotFoundException ( asset_path_utf8 ) ; } return Registries . NATIVE_ASSET_REGISTRY . register ( asset ) ;


signature:
public class ShadowArscAssetManager9 { /** * jlongArray out _ offsets ) { */
@ Implementation ( minSdk = P ) protected static ParcelFileDescriptor nativeOpenAssetFd ( long ptr , @ NonNull String asset_path , long [ ] out_offsets ) throws IOException { } }

implementation:
String asset_path_utf8 = asset_path ; if ( asset_path_utf8 == null ) { // This will throw NPE .
return null ; } ATRACE_NAME ( String . format ( "AssetManager::OpenAssetFd(%s)" , asset_path_utf8 ) ) ; CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; Asset asset = assetmanager . Open ( asset_path_utf8 , Asset . AccessMode . ACCESS_RANDOM ) ; if ( ! isTruthy ( asset ) ) { throw new FileNotFoundException ( asset_path_utf8 ) ; } return ReturnParcelFileDescriptor ( asset , out_offsets ) ;


signature:
public class ShadowArscAssetManager9 { /** * jstring asset _ path , jint access _ mode ) { */
@ Implementation ( minSdk = P ) protected static long nativeOpenNonAsset ( long ptr , int jcookie , @ NonNull String asset_path , int access_mode ) throws FileNotFoundException { } }

implementation:
ApkAssetsCookie cookie = JavaCookieToApkAssetsCookie ( jcookie ) ; String asset_path_utf8 = asset_path ; if ( asset_path_utf8 == null ) { // This will throw NPE .
return 0 ; } ATRACE_NAME ( String . format ( "AssetManager::OpenNonAsset(%s)" , asset_path_utf8 ) ) ; if ( access_mode != Asset . AccessMode . ACCESS_UNKNOWN . mode ( ) && access_mode != Asset . AccessMode . ACCESS_RANDOM . mode ( ) && access_mode != Asset . AccessMode . ACCESS_STREAMING . mode ( ) && access_mode != Asset . AccessMode . ACCESS_BUFFER . mode ( ) ) { throw new IllegalArgumentException ( "Bad access mode" ) ; } CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; Asset asset ; if ( cookie . intValue ( ) != kInvalidCookie ) { asset = assetmanager . OpenNonAsset ( asset_path_utf8 , cookie , Asset . AccessMode . fromInt ( access_mode ) ) ; } else { asset = assetmanager . OpenNonAsset ( asset_path_utf8 , Asset . AccessMode . fromInt ( access_mode ) ) ; } if ( ! isTruthy ( asset ) ) { throw new FileNotFoundException ( asset_path_utf8 ) ; } return Registries . NATIVE_ASSET_REGISTRY . register ( asset ) ;


signature:
public class ShadowArscAssetManager9 { /** * jstring asset _ path , jlongArray out _ offsets ) { */
@ Implementation ( minSdk = P ) protected static @ Nullable ParcelFileDescriptor nativeOpenNonAssetFd ( long ptr , int jcookie , @ NonNull String asset_path , @ NonNull long [ ] out_offsets ) throws IOException { } }

implementation:
ApkAssetsCookie cookie = JavaCookieToApkAssetsCookie ( jcookie ) ; String asset_path_utf8 = asset_path ; if ( asset_path_utf8 == null ) { // This will throw NPE .
return null ; } ATRACE_NAME ( String . format ( "AssetManager::OpenNonAssetFd(%s)" , asset_path_utf8 ) ) ; CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; Asset asset ; if ( cookie . intValue ( ) != kInvalidCookie ) { asset = assetmanager . OpenNonAsset ( asset_path_utf8 , cookie , Asset . AccessMode . ACCESS_RANDOM ) ; } else { asset = assetmanager . OpenNonAsset ( asset_path_utf8 , Asset . AccessMode . ACCESS_RANDOM ) ; } if ( ! isTruthy ( asset ) ) { throw new FileNotFoundException ( asset_path_utf8 ) ; } return ReturnParcelFileDescriptor ( asset , out_offsets ) ;


signature:
public class ShadowArscAssetManager9 { /** * jstring asset _ path ) { */
@ Implementation ( minSdk = P ) protected static long nativeOpenXmlAsset ( long ptr , int jcookie , @ NonNull String asset_path ) throws FileNotFoundException { } }

implementation:
ApkAssetsCookie cookie = JavaCookieToApkAssetsCookie ( jcookie ) ; String asset_path_utf8 = asset_path ; if ( asset_path_utf8 == null ) { // This will throw NPE .
return 0 ; } ATRACE_NAME ( String . format ( "AssetManager::OpenXmlAsset(%s)" , asset_path_utf8 ) ) ; CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; Asset asset ; if ( cookie . intValue ( ) != kInvalidCookie ) { asset = assetmanager . OpenNonAsset ( asset_path_utf8 , cookie , Asset . AccessMode . ACCESS_RANDOM ) ; } else { Ref < ApkAssetsCookie > cookieRef = new Ref < > ( cookie ) ; asset = assetmanager . OpenNonAsset ( asset_path_utf8 , Asset . AccessMode . ACCESS_RANDOM , cookieRef ) ; cookie = cookieRef . get ( ) ; } if ( ! isTruthy ( asset ) ) { throw new FileNotFoundException ( asset_path_utf8 ) ; } // May be nullptr .
DynamicRefTable dynamic_ref_table = assetmanager . GetDynamicRefTableForCookie ( cookie ) ; ResXMLTree xml_tree = new ResXMLTree ( dynamic_ref_table ) ; int err = xml_tree . setTo ( asset . getBuffer ( true ) , ( int ) asset . getLength ( ) , true ) ; // asset . reset ( ) ;
if ( err != NO_ERROR ) { throw new FileNotFoundException ( "Corrupt XML binary file" ) ; } return NATIVE_RES_XML_TREES . register ( xml_tree ) ;


signature:
public class ShadowArscAssetManager9 { /** * jboolean resolve _ references ) { */
@ Implementation ( minSdk = P ) protected static int nativeGetResourceValue ( long ptr , @ AnyRes int resid , short density , @ NonNull TypedValue typed_value , boolean resolve_references ) { } }

implementation:
CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; final Ref < Res_value > value = new Ref < > ( null ) ; final Ref < ResTable_config > selected_config = new Ref < > ( null ) ; final Ref < Integer > flags = new Ref < > ( 0 ) ; ApkAssetsCookie cookie = assetmanager . GetResource ( resid , false /* may _ be _ bag */
, ( short ) ( density ) , value , selected_config , flags ) ; if ( cookie . intValue ( ) == kInvalidCookie ) { return ApkAssetsCookieToJavaCookie ( K_INVALID_COOKIE ) ; } final Ref < Integer > ref = new Ref < > ( resid ) ; if ( resolve_references ) { cookie = assetmanager . ResolveReference ( cookie , value , selected_config , flags , ref ) ; if ( cookie . intValue ( ) == kInvalidCookie ) { return ApkAssetsCookieToJavaCookie ( K_INVALID_COOKIE ) ; } } return CopyValue ( cookie , value . get ( ) , ref . get ( ) , flags . get ( ) , selected_config . get ( ) , typed_value ) ;


signature:
public class ShadowArscAssetManager9 { /** * jint bag _ entry _ id , jobject typed _ value ) { */
@ Implementation ( minSdk = P ) protected static int nativeGetResourceBagValue ( long ptr , @ AnyRes int resid , int bag_entry_id , @ NonNull TypedValue typed_value ) { } }

implementation:
CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; ResolvedBag bag = assetmanager . GetBag ( resid ) ; if ( bag == null ) { return ApkAssetsCookieToJavaCookie ( K_INVALID_COOKIE ) ; } final Ref < Integer > type_spec_flags = new Ref < > ( bag . type_spec_flags ) ; ApkAssetsCookie cookie = K_INVALID_COOKIE ; Res_value bag_value = null ; for ( ResolvedBag . Entry entry : bag . entries ) { if ( entry . key == ( int ) ( bag_entry_id ) ) { cookie = entry . cookie ; bag_value = entry . value ; // Keep searching ( the old implementation did that ) .
} } if ( cookie . intValue ( ) == kInvalidCookie ) { return ApkAssetsCookieToJavaCookie ( K_INVALID_COOKIE ) ; } final Ref < Res_value > value = new Ref < > ( bag_value ) ; final Ref < Integer > ref = new Ref < > ( resid ) ; final Ref < ResTable_config > selected_config = new Ref < > ( null ) ; cookie = assetmanager . ResolveReference ( cookie , value , selected_config , type_spec_flags , ref ) ; if ( cookie . intValue ( ) == kInvalidCookie ) { return ApkAssetsCookieToJavaCookie ( K_INVALID_COOKIE ) ; } return CopyValue ( cookie , value . get ( ) , ref . get ( ) , type_spec_flags . get ( ) , null , typed_value ) ;


signature:
public class ShadowArscAssetManager9 { /** * static jintArray NativeGetStyleAttributes ( JNIEnv * env , jclass / * clazz */
, jlong ptr , jint resid ) { } }

implementation:
* / @ Implementation ( minSdk = P ) protected static @ Nullable @ AttrRes int [ ] nativeGetStyleAttributes ( long ptr , @ StyleRes int resid ) { CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; ResolvedBag bag = assetmanager . GetBag ( resid ) ; if ( bag == null ) { return null ; } int [ ] array = new int [ bag . entry_count ] ; // if ( env . ExceptionCheck ( ) ) {
// return null ;
for ( int i = 0 ; i < bag . entry_count ; i ++ ) { int attr_resid = bag . entries [ i ] . key ; // env . SetIntArrayRegion ( array , i , 1 , & attr _ resid ) ;
array [ i ] = attr_resid ; } return array ;


signature:
public class ShadowArscAssetManager9 { /** * jint resid ) { */
@ Implementation ( minSdk = P ) protected static @ Nullable String [ ] nativeGetResourceStringArray ( long ptr , @ ArrayRes int resid ) { } }

implementation:
CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; ResolvedBag bag = assetmanager . GetBag ( resid ) ; if ( bag == null ) { return null ; } String [ ] array = new String [ bag . entry_count ] ; if ( array == null ) { return null ; } for ( int i = 0 ; i < bag . entry_count ; i ++ ) { ResolvedBag . Entry entry = bag . entries [ i ] ; // Resolve any references to their final value .
final Ref < Res_value > value = new Ref < > ( entry . value ) ; final Ref < ResTable_config > selected_config = new Ref < > ( null ) ; final Ref < Integer > flags = new Ref < > ( 0 ) ; final Ref < Integer > ref = new Ref < > ( 0 ) ; ApkAssetsCookie cookie = assetmanager . ResolveReference ( entry . cookie , value , selected_config , flags , ref ) ; if ( cookie . intValue ( ) == kInvalidCookie ) { return null ; } if ( value . get ( ) . dataType == Res_value . TYPE_STRING ) { CppApkAssets apk_assets = assetmanager . GetApkAssets ( ) . get ( cookie . intValue ( ) ) ; ResStringPool pool = apk_assets . GetLoadedArsc ( ) . GetStringPool ( ) ; String java_string = null ; int str_len ; String str_utf8 = pool . stringAt ( value . get ( ) . data ) ; if ( str_utf8 != null ) { java_string = str_utf8 ; } else { String str_utf16 = pool . stringAt ( value . get ( ) . data ) ; java_string = str_utf16 ; } // / / Check for errors creating the strings ( if malformed or no memory ) .
// if ( env . ExceptionCheck ( ) ) {
// return null ;
// env . SetObjectArrayElement ( array , i , java _ string ) ;
array [ i ] = java_string ; // If we have a large amount of string in our array , we might overflow the
// local reference table of the VM .
// env . DeleteLocalRef ( java _ string ) ;
} } return array ;


signature:
public class ShadowArscAssetManager9 { /** * jint resid ) { */
@ Implementation ( minSdk = P ) protected static @ Nullable int [ ] nativeGetResourceStringArrayInfo ( long ptr , @ ArrayRes int resid ) { } }

implementation:
CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; ResolvedBag bag = assetmanager . GetBag ( resid ) ; if ( bag == null ) { return null ; } int [ ] array = new int [ bag . entry_count * 2 ] ; // if ( array = = null ) {
// return null ;
int [ ] buffer = array ; // reinterpret _ cast < int * > ( env . GetPrimitiveArrayCritical ( array , null ) ) ;
// if ( buffer = = null ) {
// return null ;
for ( int i = 0 ; i < bag . entry_count ; i ++ ) { ResolvedBag . Entry entry = bag . entries [ i ] ; final Ref < Res_value > value = new Ref < > ( entry . value ) ; final Ref < ResTable_config > selected_config = new Ref < > ( null ) ; final Ref < Integer > flags = new Ref < > ( 0 ) ; final Ref < Integer > ref = new Ref < > ( 0 ) ; ApkAssetsCookie cookie = assetmanager . ResolveReference ( entry . cookie , value , selected_config , flags , ref ) ; if ( cookie . intValue ( ) == kInvalidCookie ) { // env . ReleasePrimitiveArrayCritical ( array , buffer , JNI _ ABORT ) ;
return null ; } int string_index = - 1 ; if ( value . get ( ) . dataType == Res_value . TYPE_STRING ) { string_index = ( int ) ( value . get ( ) . data ) ; } buffer [ i * 2 ] = ApkAssetsCookieToJavaCookie ( cookie ) ; buffer [ ( i * 2 ) + 1 ] = string_index ; } // env . ReleasePrimitiveArrayCritical ( array , buffer , 0 ) ;
return array ;


signature:
public class ShadowArscAssetManager9 { /** * static jint NativeGetResourceArraySize ( JNIEnv * / * env */
, jclass /* clazz */
, jlong ptr , jint resid ) { } }

implementation: * / @ Implementation ( minSdk = P ) protected static int nativeGetResourceArraySize ( long ptr , @ ArrayRes int resid ) { CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; ResolvedBag bag = assetmanager . GetBag ( resid ) ; if ( bag == null ) { return - 1 ; } return ( int ) ( bag . entry_count ) ;


signature:
public class ShadowArscAssetManager9 { /** * jintArray out _ data ) { */
@ Implementation ( minSdk = P ) protected static int nativeGetResourceArray ( long ptr , @ ArrayRes int resid , @ NonNull int [ ] out_data ) { } }

implementation:
CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; ResolvedBag bag = assetmanager . GetBag ( resid ) ; if ( bag == null ) { return - 1 ; } int out_data_length = out_data . length ; // if ( env . ExceptionCheck ( ) ) {
// return - 1;
if ( ( int ) ( bag . entry_count ) > out_data_length * STYLE_NUM_ENTRIES ) { throw new IllegalArgumentException ( "Input array is not large enough" ) ; } int [ ] buffer = out_data ; // reinterpret _ cast < int * > ( env . GetPrimitiveArrayCritical ( out _ data , null ) ) ;
if ( buffer == null ) { return - 1 ; } int [ ] cursor = buffer ; for ( int i = 0 ; i < bag . entry_count ; i ++ ) { ResolvedBag . Entry entry = bag . entries [ i ] ; final Ref < Res_value > value = new Ref < > ( entry . value ) ; final Ref < ResTable_config > selected_config = new Ref < > ( new ResTable_config ( ) ) ; selected_config . get ( ) . density = 0 ; final Ref < Integer > flags = new Ref < > ( bag . type_spec_flags ) ; final Ref < Integer > ref = new Ref < > ( 0 ) ; ApkAssetsCookie cookie = assetmanager . ResolveReference ( entry . cookie , value , selected_config , flags , ref ) ; if ( cookie . intValue ( ) == kInvalidCookie ) { // env . ReleasePrimitiveArrayCritical ( out _ data , buffer , JNI _ ABORT ) ;
return - 1 ; } // Deal with the special @ null value - - it turns back to TYPE _ NULL .
if ( value . get ( ) . dataType == Res_value . TYPE_REFERENCE && value . get ( ) . data == 0 ) { value . set ( Res_value . NULL_VALUE ) ; } int offset = i * STYLE_NUM_ENTRIES ; cursor [ offset + STYLE_TYPE ] = ( int ) ( value . get ( ) . dataType ) ; cursor [ offset + STYLE_DATA ] = ( int ) ( value . get ( ) . data ) ; cursor [ offset + STYLE_ASSET_COOKIE ] = ApkAssetsCookieToJavaCookie ( cookie ) ; cursor [ offset + STYLE_RESOURCE_ID ] = ( int ) ( ref . get ( ) ) ; cursor [ offset + STYLE_CHANGING_CONFIGURATIONS ] = ( int ) ( flags . get ( ) ) ; cursor [ offset + STYLE_DENSITY ] = ( int ) ( selected_config . get ( ) . density ) ; // cursor + = STYLE _ NUM _ ENTRIES ;
} // env . ReleasePrimitiveArrayCritical ( out _ data , buffer , 0 ) ;
return ( int ) ( bag . entry_count ) ;


signature:
public class ShadowArscAssetManager9 { /** * jstring def _ type , jstring def _ package ) { */
@ Implementation ( minSdk = P ) protected static @ AnyRes int nativeGetResourceIdentifier ( long ptr , @ NonNull String name , @ Nullable String def_type , @ Nullable String def_package ) { } }

implementation:
String name_utf8 = name ; if ( name_utf8 == null ) { // This will throw NPE .
return 0 ; } String type = null ; if ( def_type != null ) { String type_utf8 = def_type ; CHECK ( type_utf8 != null ) ; type = type_utf8 ; } String package_ = null ; if ( def_package != null ) { String package_utf8 = def_package ; CHECK ( package_utf8 != null ) ; package_ = package_utf8 ; } CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; return ( int ) ( assetmanager . GetResourceId ( name_utf8 , type , package_ ) ) ;


signature:
public class ShadowArscAssetManager9 { /** * static jstring NativeGetResourceName ( JNIEnv * env , jclass / * clazz */
, jlong ptr , jint resid ) { } }

implementation:
* / @ Implementation ( minSdk = P ) protected static @ Nullable String nativeGetResourceName ( long ptr , @ AnyRes int resid ) { CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; CppAssetManager2 . ResourceName name = new ResourceName ( ) ; if ( ! assetmanager . GetResourceName ( resid , name ) ) { return null ; } StringBuilder result = new StringBuilder ( ) ; if ( name . package_ != null ) { result . append ( name . package_ /* , name . package _ len */
) ; } if ( name . type != null /* | | name . type16 ! = null */
) { if ( ! ( result . length ( ) == 0 ) ) { result . append ( ":" ) ; } // if ( name . type ! = null ) {
result . append ( name . type /* , name . type _ len */
) ; // } else {
// result . append ( / * util . Utf16ToUtf8 ( StringPiece16 ( * / name . type16 / * , name . type _ len ) ) * / ) ;
} if ( name . entry != null /* | | name . entry16 ! = null */
) { if ( ! ( result . length ( ) == 0 ) ) { result . append ( "/" ) ; } // if ( name . entry ! = null ) {
result . append ( name . entry /* , name . entry _ len */
) ; // } else {
// result . append ( / * util . Utf16ToUtf8 ( StringPiece16 ( * / name . entry16 / * , name . entry _ len ) * / ) ;
} return result . toString ( ) ;


signature:
public class ShadowArscAssetManager9 { /** * static jstring NativeGetResourcePackageName ( JNIEnv * env , jclass / * clazz */
, jlong ptr , jint resid ) { } }

implementation: * / @ Implementation ( minSdk = P ) protected static @ Nullable String nativeGetResourcePackageName ( long ptr , @ AnyRes int resid ) { CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; final ResourceName name = new ResourceName ( ) ; if ( ! assetmanager . GetResourceName ( resid , name ) ) { return null ; } if ( name . package_ != null ) { return name . package_ ; } return null ;


signature:
public class ShadowArscAssetManager9 { /** * static jstring NativeGetResourceTypeName ( JNIEnv * env , jclass / * clazz */
, jlong ptr , jint resid ) { } }

implementation:
* / @ Implementation ( minSdk = P ) protected static @ Nullable String nativeGetResourceTypeName ( long ptr , @ AnyRes int resid ) { CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; final ResourceName name = new ResourceName ( ) ; if ( ! assetmanager . GetResourceName ( resid , name ) ) { return null ; } if ( name . type != null ) { return name . type ; // } else if ( name . get ( ) . type16 ! = null ) {
// return name . get ( ) . type16 ; / / env . NewString ( reinterpret _ cast < jchar * > ( name . type16 ) , name . type _ len ) ;
} return null ;


signature:
public class ShadowArscAssetManager9 { /** * static jstring NativeGetResourceEntryName ( JNIEnv * env , jclass / * clazz */
, jlong ptr , jint resid ) { } }

implementation:
* / @ Implementation ( minSdk = P ) protected static @ Nullable String nativeGetResourceEntryName ( long ptr , @ AnyRes int resid ) { CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; final ResourceName name = new ResourceName ( ) ; if ( ! assetmanager . GetResourceName ( resid , name ) ) { return null ; } if ( name . entry != null ) { return name . entry ; // } else if ( name . entry16 ! = null ) {
// return name . entry16 ; / / env . NewString ( reinterpret _ cast < jchar * > ( name . entry16 ) , name . entry _ len ) ;
} return null ;


signature:
public class ShadowArscAssetManager9 { /** * jboolean exclude _ system ) { */
@ Implementation ( minSdk = P ) protected static @ Nullable String [ ] nativeGetLocales ( long ptr , boolean exclude_system ) { } }

implementation:
CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; Set < String > locales = assetmanager . GetResourceLocales ( exclude_system , true /* merge _ equivalent _ languages */
) ; String [ ] array = new String [ locales . size ( ) ] ; // env . NewObjectArray ( locales . size ( ) , g _ stringClass , null ) ;
// if ( array = = null ) {
// return null ;
int idx = 0 ; for ( String locale : locales ) { String java_string = locale ; if ( java_string == null ) { return null ; } // env . SetObjectArrayElement ( array , idx + + , java _ string ) ;
array [ idx ++ ] = java_string ; // env . DeleteLocalRef ( java _ string ) ;
} return array ;


signature:
public class ShadowArscAssetManager9 { /** * static jobjectArray NativeGetSizeConfigurations ( JNIEnv * env , jclass / * clazz */
, jlong ptr ) { } }

implementation:
* / @ Implementation ( minSdk = P ) protected static @ Nullable Configuration [ ] nativeGetSizeConfigurations ( long ptr ) { CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; Set < ResTable_config > configurations = assetmanager . GetResourceConfigurations ( true /* exclude _ system */
, false /* exclude _ mipmap */
) ; Configuration [ ] array = new Configuration [ configurations . size ( ) ] ; // env . NewObjectArray ( configurations . size ( ) , gConfigurationOffsets . classObject , null ) ;
// if ( array = = null ) {
// return null ;
int idx = 0 ; for ( ResTable_config configuration : configurations ) { Configuration java_configuration = ConstructConfigurationObject ( configuration ) ; // if ( java _ configuration = = null ) {
// return null ;
// env . SetObjectArrayElement ( array , idx + + , java _ configuration ) ;
array [ idx ++ ] = java_configuration ; // env . DeleteLocalRef ( java _ configuration ) ;
} return array ;


signature:
public class ShadowArscAssetManager9 { /** * jintArray java _ attrs , jlong out _ values _ ptr , jlong out _ indices _ ptr ) { */
@ Implementation ( minSdk = P ) protected static void nativeApplyStyle ( long ptr , long theme_ptr , @ AttrRes int def_style_attr , @ StyleRes int def_style_resid , long xml_parser_ptr , @ NonNull int [ ] java_attrs , long out_values_ptr , long out_indices_ptr ) { } }

implementation:
CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; Theme theme = Registries . NATIVE_THEME9_REGISTRY . getNativeObject ( theme_ptr ) ; CHECK ( theme . GetAssetManager ( ) == assetmanager ) ; // ( void ) assetmanager ;
ResXMLParser xml_parser = xml_parser_ptr == 0 ? null : NATIVE_RES_XML_PARSERS . getNativeObject ( xml_parser_ptr ) ; // int [ ] out _ values = reinterpret _ cast < int * > ( out _ values _ ptr ) ;
// int [ ] out _ indices = reinterpret _ cast < int * > ( out _ indices _ ptr ) ;
ShadowVMRuntime shadowVMRuntime = Shadow . extract ( VMRuntime . getRuntime ( ) ) ; int [ ] out_values = ( int [ ] ) shadowVMRuntime . getObjectForAddress ( out_values_ptr ) ; int [ ] out_indices = ( int [ ] ) shadowVMRuntime . getObjectForAddress ( out_indices_ptr ) ; int attrs_len = java_attrs . length ; int [ ] attrs = java_attrs ; // reinterpret _ cast < int * > ( env . GetPrimitiveArrayCritical ( java _ attrs , null ) ) ;
// if ( attrs = = null ) {
// return ;
ApplyStyle ( theme , xml_parser , ( int ) ( def_style_attr ) , ( int ) ( def_style_resid ) , attrs , attrs_len , out_values , out_indices ) ; // env . ReleasePrimitiveArrayCritical ( java _ attrs , attrs , JNI _ ABORT ) ;


signature:
public class ShadowArscAssetManager9 { /** * jintArray out _ java _ indices ) { */
@ Implementation ( minSdk = P ) protected static boolean nativeResolveAttrs ( long ptr , long theme_ptr , @ AttrRes int def_style_attr , @ StyleRes int def_style_resid , @ Nullable int [ ] java_values , @ NonNull int [ ] java_attrs , @ NonNull int [ ] out_java_values , @ NonNull int [ ] out_java_indices ) { } }

implementation:
int attrs_len = java_attrs . length ; int out_values_len = out_java_values . length ; if ( out_values_len < ( attrs_len * STYLE_NUM_ENTRIES ) ) { throw new IndexOutOfBoundsException ( "outValues too small" ) ; } int [ ] attrs = java_attrs ; // reinterpret _ cast < int * > ( env . GetPrimitiveArrayCritical ( java _ attrs , null ) ) ;
if ( attrs == null ) { return JNI_FALSE ; } int [ ] values = null ; int values_len = 0 ; if ( java_values != null ) { values_len = java_values . length ; values = java_values ; // reinterpret _ cast < int * > ( env . GetPrimitiveArrayCritical ( java _ values , null ) ) ;
if ( values == null ) { // env . ReleasePrimitiveArrayCritical ( java _ attrs , attrs , JNI _ ABORT ) ;
return JNI_FALSE ; } } int [ ] out_values = out_java_values ; // reinterpret _ cast < int * > ( env . GetPrimitiveArrayCritical ( out _ java _ values , null ) ) ;
if ( out_values == null ) { // env . ReleasePrimitiveArrayCritical ( java _ attrs , attrs , JNI _ ABORT ) ;
// if ( values ! = null ) {
// env . ReleasePrimitiveArrayCritical ( java _ values , values , JNI _ ABORT ) ;
return JNI_FALSE ; } int [ ] out_indices = null ; if ( out_java_indices != null ) { int out_indices_len = out_java_indices . length ; if ( out_indices_len > attrs_len ) { out_indices = out_java_indices ; // reinterpret _ cast < int * > ( env . GetPrimitiveArrayCritical ( out _ java _ indices , null ) ) ;
if ( out_indices == null ) { // env . ReleasePrimitiveArrayCritical ( java _ attrs , attrs , JNI _ ABORT ) ;
// if ( values ! = null ) {
// env . ReleasePrimitiveArrayCritical ( java _ values , values , JNI _ ABORT ) ;
// env . ReleasePrimitiveArrayCritical ( out _ java _ values , out _ values , JNI _ ABORT ) ;
return JNI_FALSE ; } } } CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; Theme theme = Registries . NATIVE_THEME9_REGISTRY . getNativeObject ( theme_ptr ) ; CHECK ( theme . GetAssetManager ( ) == assetmanager ) ; // ( void ) assetmanager ;
boolean result = ResolveAttrs ( theme , ( int ) ( def_style_attr ) , ( int ) ( def_style_resid ) , values , values_len , attrs , attrs_len , out_values , out_indices ) ; // if ( out _ indices ! = null ) {
// env . ReleasePrimitiveArrayCritical ( out _ java _ indices , out _ indices , 0 ) ;
// env . ReleasePrimitiveArrayCritical ( out _ java _ values , out _ values , 0 ) ;
// if ( values ! = null ) {
// env . ReleasePrimitiveArrayCritical ( java _ values , values , JNI _ ABORT ) ;
// env . ReleasePrimitiveArrayCritical ( java _ attrs , attrs , JNI _ ABORT ) ;
return result ? JNI_TRUE : JNI_FALSE ;


signature:
public class ShadowArscAssetManager9 { /** * jintArray out _ java _ values , jintArray out _ java _ indices ) { */
@ Implementation ( minSdk = P ) protected static boolean nativeRetrieveAttributes ( long ptr , long xml_parser_ptr , @ NonNull int [ ] java_attrs , @ NonNull int [ ] out_java_values , @ NonNull int [ ] out_java_indices ) { } }

implementation:
int attrs_len = java_attrs . length ; int out_values_len = out_java_values . length ; if ( out_values_len < ( attrs_len * STYLE_NUM_ENTRIES ) ) { throw new IndexOutOfBoundsException ( "outValues too small" ) ; } int [ ] attrs = java_attrs ; // reinterpret _ cast < int * > ( env . GetPrimitiveArrayCritical ( java _ attrs , null ) ) ;
if ( attrs == null ) { return JNI_FALSE ; } int [ ] out_values = out_java_values ; // reinterpret _ cast < int * > ( env . GetPrimitiveArrayCritical ( out _ java _ values , null ) ) ;
if ( out_values == null ) { // env . ReleasePrimitiveArrayCritical ( java _ attrs , attrs , JNI _ ABORT ) ;
return JNI_FALSE ; } int [ ] out_indices = null ; if ( out_java_indices != null ) { int out_indices_len = out_java_indices . length ; if ( out_indices_len > attrs_len ) { out_indices = out_java_indices ; // reinterpret _ cast < int * > ( env . GetPrimitiveArrayCritical ( out _ java _ indices , null ) ) ;
if ( out_indices == null ) { // env . ReleasePrimitiveArrayCritical ( java _ attrs , attrs , JNI _ ABORT ) ;
// env . ReleasePrimitiveArrayCritical ( out _ java _ values , out _ values , JNI _ ABORT ) ;
return JNI_FALSE ; } } } CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; ResXMLParser xml_parser = NATIVE_RES_XML_PARSERS . getNativeObject ( xml_parser_ptr ) ; boolean result = RetrieveAttributes ( assetmanager , xml_parser , attrs , attrs_len , out_values , out_indices ) ; // if ( out _ indices ! = null ) {
// env . ReleasePrimitiveArrayCritical ( out _ java _ indices , out _ indices , 0 ) ;
// env . ReleasePrimitiveArrayCritical ( out _ java _ values , out _ values , 0 ) ;
// env . ReleasePrimitiveArrayCritical ( java _ attrs , attrs , JNI _ ABORT ) ;
return result ;


signature:
public class ShadowArscAssetManager9 { /** * static jlong NativeThemeCreate ( JNIEnv * / * env */
, jclass /* clazz */
, jlong ptr ) { } }

implementation: * / @ Implementation ( minSdk = P ) protected static long nativeThemeCreate ( long ptr ) { CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; return Registries . NATIVE_THEME9_REGISTRY . register ( assetmanager . NewTheme ( ) ) ;


signature:
public class ShadowArscAssetManager9 { /** * jint resid , jboolean force ) { */
@ Implementation ( minSdk = P ) protected static void nativeThemeApplyStyle ( long ptr , long theme_ptr , @ StyleRes int resid , boolean force ) { } }

implementation:
// AssetManager is accessed via the theme , so grab an explicit lock here .
CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; Theme theme = Registries . NATIVE_THEME9_REGISTRY . getNativeObject ( theme_ptr ) ; CHECK ( theme . GetAssetManager ( ) == assetmanager ) ; // ( void ) assetmanager ;
theme . ApplyStyle ( resid , force ) ; // TODO ( adamlesinski ) : Consider surfacing exception when result is failure .
// CTS currently expects no exceptions from this method .
// std : : string error _ msg = StringPrintf ( " Failed to apply style 0x % 08x to theme " , resid ) ;
// throw new IllegalArgumentException ( error _ msg . c _ str ( ) ) ;


signature:
public class ShadowArscAssetManager9 { /** * jlong src _ theme _ ptr ) { */
@ Implementation ( minSdk = P , maxSdk = P ) protected static void nativeThemeCopy ( long dst_theme_ptr , long src_theme_ptr ) { } }

implementation: Theme dst_theme = Registries . NATIVE_THEME9_REGISTRY . getNativeObject ( dst_theme_ptr ) ; Theme src_theme = Registries . NATIVE_THEME9_REGISTRY . getNativeObject ( src_theme_ptr ) ; if ( ! dst_theme . SetTo ( src_theme ) ) { throw new IllegalArgumentException ( "Themes are from different AssetManagers" ) ; }


signature:
public class ShadowArscAssetManager9 { /** * jlong dst _ theme _ ptr , jlong src _ asset _ manager _ ptr , jlong src _ theme _ ptr ) { */
@ Implementation ( minSdk = Build . VERSION_CODES . Q ) protected static void nativeThemeCopy ( long dst_asset_manager_ptr , long dst_theme_ptr , long src_asset_manager_ptr , long src_theme_ptr ) { } }

implementation: Theme dst_theme = Registries . NATIVE_THEME9_REGISTRY . getNativeObject ( dst_theme_ptr ) ; Theme src_theme = Registries . NATIVE_THEME9_REGISTRY . getNativeObject ( src_theme_ptr ) ; if ( dst_asset_manager_ptr != src_asset_manager_ptr ) { CppAssetManager2 dst_assetmanager = AssetManagerFromLong ( dst_asset_manager_ptr ) ; CHECK ( dst_theme . GetAssetManager ( ) == dst_assetmanager ) ; CppAssetManager2 src_assetmanager = AssetManagerFromLong ( src_asset_manager_ptr ) ; CHECK ( src_theme . GetAssetManager ( ) == src_assetmanager ) ; dst_theme . SetTo ( src_theme ) ; } else { dst_theme . SetTo ( src_theme ) ; }


signature:
public class ShadowArscAssetManager9 { /** * static void NativeThemeClear ( JNIEnv * / * env */
, jclass /* clazz */
, jlong theme_ptr ) { } }

implementation: * / @ Implementation ( minSdk = P ) protected static void nativeThemeClear ( long themePtr ) { Registries . NATIVE_THEME9_REGISTRY . getNativeObject ( themePtr ) . Clear ( ) ;


signature:
public class ShadowArscAssetManager9 { /** * jboolean resolve _ references ) { */
@ Implementation ( minSdk = P ) protected static int nativeThemeGetAttributeValue ( long ptr , long theme_ptr , @ AttrRes int resid , @ NonNull TypedValue typed_value , boolean resolve_references ) { } }

implementation:
CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; Theme theme = Registries . NATIVE_THEME9_REGISTRY . getNativeObject ( theme_ptr ) ; CHECK ( theme . GetAssetManager ( ) == assetmanager ) ; // ( void ) assetmanager ; / / huh ?
final Ref < Res_value > value = new Ref < > ( null ) ; final Ref < Integer > flags = new Ref < > ( null ) ; ApkAssetsCookie cookie = theme . GetAttribute ( resid , value , flags ) ; if ( cookie . intValue ( ) == kInvalidCookie ) { return ApkAssetsCookieToJavaCookie ( K_INVALID_COOKIE ) ; } final Ref < Integer > ref = new Ref < > ( 0 ) ; if ( resolve_references ) { final Ref < ResTable_config > selected_config = new Ref < > ( null ) ; cookie = theme . GetAssetManager ( ) . ResolveReference ( cookie , value , selected_config , flags , ref ) ; if ( cookie . intValue ( ) == kInvalidCookie ) { return ApkAssetsCookieToJavaCookie ( K_INVALID_COOKIE ) ; } } return CopyValue ( cookie , value . get ( ) , ref . get ( ) , flags . get ( ) , null , typed_value ) ;


signature:
public class ShadowArscAssetManager9 { /** * jint priority , jstring tag , jstring prefix ) { */
@ Implementation ( minSdk = P ) protected static void nativeThemeDump ( long ptr , long theme_ptr , int priority , String tag , String prefix ) { } }

implementation:
CppAssetManager2 assetmanager = AssetManagerFromLong ( ptr ) ; Theme theme = Registries . NATIVE_THEME9_REGISTRY . getNativeObject ( theme_ptr ) ; CHECK ( theme . GetAssetManager ( ) == assetmanager ) ; // ( void ) assetmanager ;
// ( void ) theme ;
// ( void ) priority ;
// ( void ) tag ;
// ( void ) prefix ;


signature:
public class ShadowArscAssetManager9 { /** * jlong theme _ ptr ) { */
@ Implementation ( minSdk = P ) protected static @ NativeConfig int nativeThemeGetChangingConfigurations ( long theme_ptr ) { } }

implementation: Theme theme = Registries . NATIVE_THEME9_REGISTRY . getNativeObject ( theme_ptr ) ; return ( int ) ( theme . GetChangingConfigurations ( ) ) ;


signature:
public class ShadowArscAssetManager9 { /** * static jint NativeAssetReadChar ( JNIEnv * / * env */
, jclass /* clazz */
, jlong asset_ptr ) { } }

implementation: * / @ Implementation ( minSdk = P ) protected static int nativeAssetReadChar ( long asset_ptr ) { Asset asset = Registries . NATIVE_ASSET_REGISTRY . getNativeObject ( asset_ptr ) ; byte [ ] b = new byte [ 1 ] ; int res = asset . read ( b , 1 ) ; return res == 1 ? ( int ) ( b [ 0 ] ) & 0xff : - 1 ;


signature:
public class ShadowArscAssetManager9 { /** * jint offset , jint len ) { */
@ Implementation ( minSdk = P ) protected static int nativeAssetRead ( long asset_ptr , byte [ ] java_buffer , int offset , int len ) throws IOException { } }

implementation:
if ( len == 0 ) { return 0 ; } int buffer_len = java_buffer . length ; if ( offset < 0 || offset >= buffer_len || len < 0 || len > buffer_len || offset > buffer_len - len ) { throw new IndexOutOfBoundsException ( ) ; } // ScopedByteArrayRW byte _ array ( env , java _ buffer ) ;
// if ( byte _ array . get ( ) = = null ) {
// return - 1;
Asset asset = Registries . NATIVE_ASSET_REGISTRY . getNativeObject ( asset_ptr ) ; // sint res = asset . read ( byte _ array . get ( ) + offset , len ) ;
int res = asset . read ( java_buffer , offset , len ) ; if ( res < 0 ) { throw new IOException ( ) ; } return res > 0 ? ( int ) ( res ) : - 1 ;


signature:
public class ShadowArscAssetManager9 { /** * jint whence ) { */
@ Implementation ( minSdk = P ) protected static long nativeAssetSeek ( long asset_ptr , long offset , int whence ) { } }

implementation: Asset asset = Registries . NATIVE_ASSET_REGISTRY . getNativeObject ( asset_ptr ) ; return asset . seek ( ( offset ) , ( whence > 0 ? SEEK_END : ( whence < 0 ? SEEK_SET : SEEK_CUR ) ) ) ;


signature:
public class ShadowArscAssetManager9 { /** * static jlong NativeAssetGetLength ( JNIEnv * / * env */
, jclass /* clazz */
, jlong asset_ptr ) { } }

implementation: * / @ Implementation ( minSdk = P ) protected static long nativeAssetGetLength ( long asset_ptr ) { Asset asset = Registries . NATIVE_ASSET_REGISTRY . getNativeObject ( asset_ptr ) ; return asset . getLength ( ) ;


signature:
public class ShadowArscAssetManager9 { /** * static jlong NativeAssetGetRemainingLength ( JNIEnv * / * env */
, jclass /* clazz */
, jlong asset_ptr ) { } }

implementation: * / @ Implementation ( minSdk = P ) protected static long nativeAssetGetRemainingLength ( long asset_ptr ) { Asset asset = Registries . NATIVE_ASSET_REGISTRY . getNativeObject ( asset_ptr ) ; return asset . getRemainingLength ( ) ;


signature:
public class ResTable_config { /** * packed version of " tl " */
static ResTable_config createConfig ( ByteBuffer buffer ) { } }

implementation:
int startPosition = buffer . position ( ) ; // The starting buffer position to calculate bytes read .
int size = buffer . getInt ( ) ; int mcc = buffer . getShort ( ) & 0xFFFF ; int mnc = buffer . getShort ( ) & 0xFFFF ; byte [ ] language = new byte [ 2 ] ; buffer . get ( language ) ; byte [ ] region = new byte [ 2 ] ; buffer . get ( region ) ; int orientation = UnsignedBytes . toInt ( buffer . get ( ) ) ; int touchscreen = UnsignedBytes . toInt ( buffer . get ( ) ) ; int density = buffer . getShort ( ) & 0xFFFF ; int keyboard = UnsignedBytes . toInt ( buffer . get ( ) ) ; int navigation = UnsignedBytes . toInt ( buffer . get ( ) ) ; int inputFlags = UnsignedBytes . toInt ( buffer . get ( ) ) ; buffer . get ( ) ; // 1 byte of padding
int screenWidth = buffer . getShort ( ) & 0xFFFF ; int screenHeight = buffer . getShort ( ) & 0xFFFF ; int sdkVersion = buffer . getShort ( ) & 0xFFFF ; int minorVersion = buffer . getShort ( ) & 0xFFFF ; // At this point , the configuration ' s size needs to be taken into account as not all
// configurations have all values .
int screenLayout = 0 ; int uiMode = 0 ; int smallestScreenWidthDp = 0 ; int screenWidthDp = 0 ; int screenHeightDp = 0 ; byte [ ] localeScript = new byte [ 4 ] ; byte [ ] localeVariant = new byte [ 8 ] ; byte screenLayout2 = 0 ; byte screenConfigPad1 = 0 ; short screenConfigPad2 = 0 ; if ( size >= SCREEN_CONFIG_MIN_SIZE ) { screenLayout = UnsignedBytes . toInt ( buffer . get ( ) ) ; uiMode = UnsignedBytes . toInt ( buffer . get ( ) ) ; smallestScreenWidthDp = buffer . getShort ( ) & 0xFFFF ; } if ( size >= SCREEN_DP_MIN_SIZE ) { screenWidthDp = buffer . getShort ( ) & 0xFFFF ; screenHeightDp = buffer . getShort ( ) & 0xFFFF ; } if ( size >= LOCALE_MIN_SIZE ) { buffer . get ( localeScript ) ; buffer . get ( localeVariant ) ; } if ( size >= SCREEN_CONFIG_EXTENSION_MIN_SIZE ) { screenLayout2 = ( byte ) UnsignedBytes . toInt ( buffer . get ( ) ) ; screenConfigPad1 = buffer . get ( ) ; // Reserved padding
screenConfigPad2 = buffer . getShort ( ) ; // More reserved padding
} // After parsing everything that ' s known , account for anything that ' s unknown .
int bytesRead = buffer . position ( ) - startPosition ; byte [ ] unknown = new byte [ size - bytesRead ] ; buffer . get ( unknown ) ; return new ResTable_config ( size , mcc , mnc , language , region , orientation , touchscreen , density , keyboard , navigation , inputFlags , screenWidth , screenHeight , sdkVersion , minorVersion , screenLayout , uiMode , smallestScreenWidthDp , screenWidthDp , screenHeightDp , localeScript , localeVariant , screenLayout2 , screenConfigPad1 , screenConfigPad2 , unknown ) ;


signature:
public class ResTable_config { /** * Returns a copy of this resource configuration with a different { @ link # sdkVersion } , or this
 * configuration if the { @ code sdkVersion } is the same .
 * @ param sdkVersion The SDK version of the returned configuration .
 * @ return A copy of this configuration with the only difference being # sdkVersion . */
public final ResTable_config withSdkVersion ( int sdkVersion ) { } }

implementation: if ( sdkVersion == this . sdkVersion ) { return this ; } return new ResTable_config ( size , mcc , mnc , language , country , orientation , touchscreen , density , keyboard , navigation , inputFlags , screenWidth , screenHeight , sdkVersion , minorVersion , screenLayout , uiMode , smallestScreenWidthDp , screenWidthDp , screenHeightDp , localeScript , localeVariant , screenLayout2 , colorMode , screenConfigPad2 , unknown ) ;


signature: public class ResTable_config { @ Nonnull private String unpackLanguageOrRegion ( byte [ ] value , int base ) { } }

implementation: Preconditions . checkState ( value . length == 2 , "Language or country value must be 2 bytes." ) ; if ( value [ 0 ] == 0 && value [ 1 ] == 0 ) { return "" ; } if ( isTruthy ( UnsignedBytes . toInt ( value [ 0 ] ) & 0x80 ) ) { byte [ ] result = new byte [ 3 ] ; result [ 0 ] = ( byte ) ( base + ( value [ 1 ] & 0x1F ) ) ; result [ 1 ] = ( byte ) ( base + ( ( value [ 1 ] & 0xE0 ) >>> 5 ) + ( ( value [ 0 ] & 0x03 ) << 3 ) ) ; result [ 2 ] = ( byte ) ( base + ( ( value [ 0 ] & 0x7C ) >>> 2 ) ) ; return new String ( result , US_ASCII ) ; } return new String ( value , US_ASCII ) ;


signature:
public class ResTable_config { /** * / * static */
void packLanguageOrRegion ( final String in , final byte base , final byte [ ] out ) { } }

implementation: if ( in == null ) { out [ 0 ] = 0 ; out [ 1 ] = 0 ; } else if ( in . length ( ) < 3 || in . charAt ( 2 ) == 0 || in . charAt ( 2 ) == '-' ) { out [ 0 ] = ( byte ) in . charAt ( 0 ) ; out [ 1 ] = ( byte ) in . charAt ( 1 ) ; } else { byte first = ( byte ) ( ( in . charAt ( 0 ) - base ) & 0x007f ) ; byte second = ( byte ) ( ( in . charAt ( 1 ) - base ) & 0x007f ) ; byte third = ( byte ) ( ( in . charAt ( 2 ) - base ) & 0x007f ) ; out [ 0 ] = ( byte ) ( 0x80 | ( third << 2 ) | ( second >> 3 ) ) ; out [ 1 ] = ( byte ) ( ( second << 5 ) | first ) ; }


signature:
public class ResTable_config { /** * void ResTable _ config : : copyFromDtoH ( const ResTable _ config & o ) { */
static ResTable_config fromDtoH ( final ResTable_config o ) { } }

implementation:
return new ResTable_config ( 0 /* sizeof ( ResTable _ config ) */
, dtohs ( ( short ) o . mcc ) , dtohs ( ( short ) o . mnc ) , o . language , o . country , o . orientation , o . touchscreen , dtohl ( o . density ) , o . keyboard , o . navigation , o . inputFlags , dtohs ( ( short ) o . screenWidth ) , dtohs ( ( short ) o . screenHeight ) , dtohs ( ( short ) o . sdkVersion ) , dtohs ( ( short ) o . minorVersion ) , o . screenLayout , o . uiMode , dtohs ( ( short ) o . smallestScreenWidthDp ) , dtohs ( ( short ) o . screenWidthDp ) , dtohs ( ( short ) o . screenHeightDp ) , o . localeScript , o . localeVariant , o . screenLayout2 , o . colorMode , o . screenConfigPad2 , o . unknown ) ;


signature:
public class ResTable_config { /** * that is different . */
int diff ( final ResTable_config o ) { } }

implementation: int diffs = 0 ; if ( mcc != o . mcc ) diffs |= CONFIG_MCC ; if ( mnc != o . mnc ) diffs |= CONFIG_MNC ; if ( orientation != o . orientation ) diffs |= CONFIG_ORIENTATION ; if ( density != o . density ) diffs |= CONFIG_DENSITY ; if ( touchscreen != o . touchscreen ) diffs |= CONFIG_TOUCHSCREEN ; if ( ( ( inputFlags ^ o . inputFlags ) & ( MASK_KEYSHIDDEN | MASK_NAVHIDDEN ) ) != 0 ) diffs |= CONFIG_KEYBOARD_HIDDEN ; if ( keyboard != o . keyboard ) diffs |= CONFIG_KEYBOARD ; if ( navigation != o . navigation ) diffs |= CONFIG_NAVIGATION ; if ( screenSize ( ) != o . screenSize ( ) ) diffs |= CONFIG_SCREEN_SIZE ; if ( version ( ) != o . version ( ) ) diffs |= CONFIG_VERSION ; if ( ( screenLayout & MASK_LAYOUTDIR ) != ( o . screenLayout & MASK_LAYOUTDIR ) ) diffs |= CONFIG_LAYOUTDIR ; if ( ( screenLayout & ~ MASK_LAYOUTDIR ) != ( o . screenLayout & ~ MASK_LAYOUTDIR ) ) diffs |= CONFIG_SCREEN_LAYOUT ; if ( ( screenLayout2 & MASK_SCREENROUND ) != ( o . screenLayout2 & MASK_SCREENROUND ) ) diffs |= CONFIG_SCREEN_ROUND ; if ( ( colorMode & MASK_WIDE_COLOR_GAMUT ) != ( o . colorMode & MASK_WIDE_COLOR_GAMUT ) ) diffs |= CONFIG_COLOR_MODE ; if ( ( colorMode & MASK_HDR ) != ( o . colorMode & MASK_HDR ) ) diffs |= CONFIG_COLOR_MODE ; if ( uiMode != o . uiMode ) diffs |= CONFIG_UI_MODE ; if ( smallestScreenWidthDp != o . smallestScreenWidthDp ) diffs |= CONFIG_SMALLEST_SCREEN_SIZE ; if ( screenSizeDp ( ) != o . screenSizeDp ( ) ) diffs |= CONFIG_SCREEN_SIZE ; int diff = compareLocales ( this , o ) ; if ( isTruthy ( diff ) ) diffs |= CONFIG_LOCALE ; return diffs ;


signature:
public class ResTable_config { /** * Returns true if this is the default " any " configuration . */
public final boolean isDefault ( ) { } }

implementation: return mcc == 0 && mnc == 0 && isZeroes ( language ) && isZeroes ( country ) && orientation == 0 && touchscreen == 0 && density == 0 && keyboard == 0 && navigation == 0 && inputFlags == 0 && screenWidth == 0 && screenHeight == 0 && sdkVersion == 0 && minorVersion == 0 && screenLayout == 0 && uiMode == 0 && smallestScreenWidthDp == 0 && screenWidthDp == 0 && screenHeightDp == 0 && isZeroes ( localeScript ) && isZeroes ( localeVariant ) && screenLayout2 == 0 && colorMode == 0 ;