static ResTable_config createConfig ( ByteBuffer buffer ) { 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 ) ; }
packed version of tl