summaryrefslogtreecommitdiff
path: root/libdexfile/dex/class_accessor.h
diff options
context:
space:
mode:
Diffstat (limited to 'libdexfile/dex/class_accessor.h')
-rw-r--r--libdexfile/dex/class_accessor.h60
1 files changed, 27 insertions, 33 deletions
diff --git a/libdexfile/dex/class_accessor.h b/libdexfile/dex/class_accessor.h
index e9c1a82c54..d40577f31f 100644
--- a/libdexfile/dex/class_accessor.h
+++ b/libdexfile/dex/class_accessor.h
@@ -20,6 +20,7 @@
#include "base/utils.h"
#include "code_item_accessors.h"
#include "dex_file.h"
+#include "hidden_api_access_flags.h"
#include "invoke_type.h"
#include "method_reference.h"
#include "modifiers.h"
@@ -34,20 +35,22 @@ class ClassAccessor {
class BaseItem {
public:
explicit BaseItem(const DexFile& dex_file,
- const uint8_t* ptr_pos,
- const uint8_t* hiddenapi_ptr_pos)
- : dex_file_(dex_file), ptr_pos_(ptr_pos), hiddenapi_ptr_pos_(hiddenapi_ptr_pos) {}
+ const uint8_t* ptr_pos) : dex_file_(dex_file), ptr_pos_(ptr_pos) {}
uint32_t GetIndex() const {
return index_;
}
- uint32_t GetAccessFlags() const {
+ uint32_t GetRawAccessFlags() const {
return access_flags_;
}
- uint32_t GetHiddenapiFlags() const {
- return hiddenapi_flags_;
+ uint32_t GetAccessFlags() const {
+ return HiddenApiAccessFlags::RemoveFromDex(access_flags_);
+ }
+
+ HiddenApiAccessFlags::ApiList DecodeHiddenAccessFlags() const {
+ return HiddenApiAccessFlags::DecodeFromDex(access_flags_);
}
bool IsFinal() const {
@@ -63,21 +66,19 @@ class ClassAccessor {
}
bool MemberIsNative() const {
- return GetAccessFlags() & kAccNative;
+ return GetRawAccessFlags() & kAccNative;
}
bool MemberIsFinal() const {
- return GetAccessFlags() & kAccFinal;
+ return GetRawAccessFlags() & kAccFinal;
}
protected:
// Internal data pointer for reading.
const DexFile& dex_file_;
const uint8_t* ptr_pos_ = nullptr;
- const uint8_t* hiddenapi_ptr_pos_ = nullptr;
uint32_t index_ = 0u;
uint32_t access_flags_ = 0u;
- uint32_t hiddenapi_flags_ = 0u;
};
// A decoded version of the method of a class_data_item.
@@ -106,13 +107,14 @@ class ClassAccessor {
return is_static_or_direct_;
}
+ // Unhide the hidden API access flags at the iterator position. TODO: Deprecate.
+ void UnHideAccessFlags() const;
+
private:
- Method(const DexFile& dex_file,
- const uint8_t* ptr_pos,
- const uint8_t* hiddenapi_ptr_pos = nullptr,
- bool is_static_or_direct = true)
- : BaseItem(dex_file, ptr_pos, hiddenapi_ptr_pos),
- is_static_or_direct_(is_static_or_direct) {}
+ explicit Method(const DexFile& dex_file,
+ const uint8_t* ptr_pos,
+ bool is_static_or_direct = true)
+ : BaseItem(dex_file, ptr_pos), is_static_or_direct_(is_static_or_direct) {}
void Read();
@@ -148,15 +150,16 @@ class ClassAccessor {
// A decoded version of the field of a class_data_item.
class Field : public BaseItem {
public:
- Field(const DexFile& dex_file,
- const uint8_t* ptr_pos,
- const uint8_t* hiddenapi_ptr_pos = nullptr)
- : BaseItem(dex_file, ptr_pos, hiddenapi_ptr_pos) {}
+ explicit Field(const DexFile& dex_file,
+ const uint8_t* ptr_pos) : BaseItem(dex_file, ptr_pos) {}
bool IsStatic() const {
return is_static_;
}
+ // Unhide the hidden API access flags at the iterator position. TODO: Deprecate.
+ void UnHideAccessFlags() const;
+
private:
void Read();
@@ -182,9 +185,8 @@ class ClassAccessor {
uint32_t position,
uint32_t partition_pos,
uint32_t iterator_end,
- const uint8_t* ptr_pos,
- const uint8_t* hiddenapi_ptr_pos)
- : data_(dex_file, ptr_pos, hiddenapi_ptr_pos),
+ const uint8_t* ptr_pos)
+ : data_(dex_file, ptr_pos),
position_(position),
partition_pos_(partition_pos),
iterator_end_(iterator_end) {
@@ -266,16 +268,13 @@ class ClassAccessor {
// Not explicit specifically for range-based loops.
ALWAYS_INLINE ClassAccessor(const ClassIteratorData& data);
- ALWAYS_INLINE ClassAccessor(const DexFile& dex_file,
- const DexFile::ClassDef& class_def,
- bool parse_hiddenapi_class_data = false);
+ ALWAYS_INLINE ClassAccessor(const DexFile& dex_file, const DexFile::ClassDef& class_def);
ALWAYS_INLINE ClassAccessor(const DexFile& dex_file, uint32_t class_def_index);
ClassAccessor(const DexFile& dex_file,
const uint8_t* class_data,
- uint32_t class_def_index = DexFile::kDexNoIndex32,
- bool parse_hiddenapi_class_data = false);
+ uint32_t class_def_index = DexFile::kDexNoIndex32);
// Return the code item for a method.
const DexFile::CodeItem* GetCodeItem(const Method& method) const;
@@ -354,10 +353,6 @@ class ClassAccessor {
return ptr_pos_ != nullptr;
}
- bool HasHiddenapiClassData() const {
- return hiddenapi_ptr_pos_ != nullptr;
- }
-
uint32_t GetClassDefIndex() const {
return class_def_index_;
}
@@ -382,7 +377,6 @@ class ClassAccessor {
const DexFile& dex_file_;
const uint32_t class_def_index_;
const uint8_t* ptr_pos_ = nullptr; // Pointer into stream of class_data_item.
- const uint8_t* hiddenapi_ptr_pos_ = nullptr; // Pointer into stream of hiddenapi_metadata.
const uint32_t num_static_fields_ = 0u;
const uint32_t num_instance_fields_ = 0u;
const uint32_t num_direct_methods_ = 0u;