Skip to content

Commit

Permalink
Implement reflection clear method
Browse files Browse the repository at this point in the history
  • Loading branch information
shiraji committed Jun 4, 2018
1 parent 66d6f02 commit 32b50d9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ fun overwriteCustomManufacture(manufactureText: String = "Xiaomi") {
manufacture.set(null, manufactureText)
}

fun clearCustomManufacture() {
overwriteCustomManufacture("")
}

fun overwriteCustomSdkInt(sdkInt: Int = 23) {
val modifiersField = Field::class.java.getDeclaredField("modifiers")
modifiersField.isAccessible = true
Expand All @@ -63,6 +67,10 @@ fun overwriteCustomSdkInt(sdkInt: Int = 23) {
field.set(null, sdkInt)
}

fun clearCustomSdkInt() {
overwriteCustomSdkInt()
}

fun testForXiaomi() {
overwriteCustomManufacture()
overwriteCustomSdkInt()
Expand Down
8 changes: 8 additions & 0 deletions test/src/test/java/permissions/dispatcher/test/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ fun overwriteCustomManufacture(manufactureText: String = "Xiaomi") {
manufacture.set(null, manufactureText)
}

fun clearCustomManufacture() {
overwriteCustomManufacture("")
}

fun overwriteCustomSdkInt(sdkInt: Int = 23) {
val modifiersField = Field::class.java.getDeclaredField("modifiers")
modifiersField.isAccessible = true
Expand All @@ -90,6 +94,10 @@ fun overwriteCustomSdkInt(sdkInt: Int = 23) {
field.set(null, sdkInt)
}

fun clearCustomSdkInt() {
overwriteCustomSdkInt()
}

fun testForXiaomi() {
overwriteCustomManufacture()
overwriteCustomSdkInt()
Expand Down

0 comments on commit 32b50d9

Please sign in to comment.