Skip to content

Commit

Permalink
Separate annotations to dedicated module.
Browse files Browse the repository at this point in the history
  • Loading branch information
hotchemi committed May 19, 2018
1 parent f0f5519 commit b638ba8
Show file tree
Hide file tree
Showing 14 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions annotation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
4 changes: 4 additions & 0 deletions annotation/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apply plugin: 'java-library'

targetCompatibility = JavaVersion.VERSION_1_6
sourceCompatibility = JavaVersion.VERSION_1_6
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package permissions.dispatcher
import javax.annotation.Nullable

class AndroidJarDependencyExtension {

@Nullable
String directory
}
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ android {
main {
java {
srcDirs = [
'src/main/java',
'src/main/android'
]
}
Expand All @@ -43,6 +42,7 @@ dependencies {
testImplementation "org.powermock:powermock-api-mockito:$POWERMOCK_VERSION"
testImplementation "org.powermock:powermock-module-junit4:$POWERMOCK_VERSION"

api project(path: ':annotation')
lintChecks project(path: ':lint', configuration: 'lintChecks')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
import android.support.v13.app.FragmentCompat;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.AppOpsManagerCompat;
import android.support.v4.content.PermissionChecker;
import android.support.v4.util.SimpleArrayMap;

import static android.support.v4.content.PermissionChecker.checkSelfPermission;

public final class PermissionUtils {
// Map of dangerous permissions introduced in later framework versions.
// Used to conditionally bypass permission-hold checks on older devices.
Expand Down Expand Up @@ -97,7 +96,7 @@ private static boolean hasSelfPermission(Context context, String permission) {
return hasSelfPermissionForXiaomi(context, permission);
}
try {
return checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED;
return PermissionChecker.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED;
} catch (RuntimeException t) {
return false;
}
Expand All @@ -110,7 +109,7 @@ private static boolean hasSelfPermissionForXiaomi(Context context, String permis
return true;
}
int noteOp = AppOpsManagerCompat.noteOp(context, permissionToOp, Process.myUid(), context.getPackageName());
return noteOp == AppOpsManagerCompat.MODE_ALLOWED && checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED;
return noteOp == AppOpsManagerCompat.MODE_ALLOWED && PermissionChecker.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED;
}

/**
Expand Down
1 change: 1 addition & 0 deletions processor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$KOTLIN_VERSION"
compile "com.squareup:javapoet:$JAVAPOET_VERSION"
compile "com.squareup:kotlinpoet:$KOTLINPOET_VERSION"
compile project(path: ':annotation')

testCompile "junit:junit:$JUNIT_VERSION"
testCompile "com.google.testing.compile:compile-testing:$COMPILE_TESTING_VERSION"
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include ':library', ':processor', ':sample', ':lint', ':sample-kotlin', ':test', ':test-v13'
include ':library', ':processor', ':sample', ':lint', ':sample-kotlin', ':test', ':test-v13', ':annotation'

0 comments on commit b638ba8

Please sign in to comment.