1HiddenApi 2========= 3 4This tool iterates over all class members inside given DEX files and modifies 5their access flags if their signatures appear on one of two lists - unsupported and 6blocklist - provided as text file inputs. These access flags denote to the 7runtime that the marked methods/fields should be treated as internal APIs with 8access restricted only to platform code. Methods/fields not mentioned on the two 9lists are assumed to be part of the SDK and left accessible by all code. 10 11API signatures 12============== 13 14The methods/fields to be marked are specified in two text files (unsupported, 15blocklist) provided an input. Only one signature per line is allowed. 16 17Types are expected in their DEX format - class descriptors are to be provided in 18"slash" form, e.g. "Ljava/lang/Object;", primitive types in their shorty form, 19e.g. "I" for "int", and a "[" prefix denotes an array type. Lists of types do 20not use any separators, e.g. "ILxyz;F" for "int, xyz, float". 21 22Methods are encoded as: 23 `class_descriptor->method_name(parameter_types)return_type` 24 25Fields are encoded as: 26 `class_descriptor->field_name:field_type` 27 28Bit encoding 29============ 30 31Two bits of information are encoded in the DEX access flags. These are encoded 32as unsigned LEB128 values in DEX and so as to not increase the size of the DEX, 33different modifiers were chosen for different kinds of methods/fields. 34 35First bit is encoded as the inversion of visibility access flags (bits 2:0). 36At most one of these flags can be set at any given time. Inverting these bits 37therefore produces a value where at least two bits are set and there is never 38any loss of information. 39 40Second bit is encoded differently for each given type of class member as there 41is no single unused bit such that setting it would not increase the size of the 42LEB128 encoding. The following bits are used: 43 44 * bit 5 for fields as it carries no other meaning 45 * bit 5 for non-native methods, as `synchronized` can only be set on native 46 methods (the Java `synchronized` modifier is bit 17) 47 * bit 9 for native methods, as it carries no meaning and bit 8 (`native`) will 48 make the LEB128 encoding at least two bytes long 49 50Two following bit encoding is used to denote the membership of a method/field: 51 52 * sdk: `false`, `false` 53 * unsupported: `true`, `false` 54 * blocklist: `true`, `true` 55