-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement hidden api restriction flags
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use crate::raw::uleb128; | ||
|
||
bitflags::bitflags! { | ||
/// For more information, click [here][1]. | ||
/// | ||
/// [1]: https://source.android.com/docs/core/runtime/dex-format#hiddenapi-class-data-item | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
pub struct RestrictionFlag: u64 { | ||
const Whitelist = 0; | ||
const Greylist = 1; | ||
const Blacklist = 2; | ||
const GreylistMaxO = 3; | ||
const GreylistMaxP = 4; | ||
const GreylistMaxQ = 5; | ||
const GreylistMaxR = 6; | ||
} | ||
} | ||
|
||
impl RestrictionFlag { | ||
pub fn try_from_uleb128(src: &[u8], offset: &mut usize) -> Result<Self, scroll::Error> { | ||
let flags = uleb128::read(src, offset)?; | ||
Ok(RestrictionFlag::from_bits_truncate(flags)) | ||
} | ||
|
||
pub fn try_into_uleb128( | ||
&self, | ||
dst: &mut [u8], | ||
offset: &mut usize, | ||
) -> Result<(), scroll::Error> { | ||
uleb128::write(dst, offset, self.bits())?; | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters