summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Grover <joeygrover@gmail.com>2017-02-07 16:48:07 -0500
committerJoey Grover <joeygrover@gmail.com>2017-02-07 16:48:07 -0500
commit927c0aebd9305a4bb847a34fb6531328fc579bfc (patch)
tree6f711d6deaca6653c01234b68b322fe80ca07c62
parentc57e2995d389faba0b3f163a4453673a6efa7ce1 (diff)
downloadsdl_android-927c0aebd9305a4bb847a34fb6531328fc579bfc.tar.gz
Revert compile version and add better checking method for lower version of SDK
-rw-r--r--build.gradle2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/transport/SdlRouterService.java31
2 files changed, 15 insertions, 18 deletions
diff --git a/build.gradle b/build.gradle
index aa62ab091..241c951c6 100644
--- a/build.gradle
+++ b/build.gradle
@@ -13,7 +13,7 @@ dependencies {
}
android {
- compileSdkVersion 23
+ compileSdkVersion 18
buildToolsVersion "23.0.2"
lintOptions {
diff --git a/sdl_android_lib/src/com/smartdevicelink/transport/SdlRouterService.java b/sdl_android_lib/src/com/smartdevicelink/transport/SdlRouterService.java
index ce5af5806..cd7ceae5a 100644
--- a/sdl_android_lib/src/com/smartdevicelink/transport/SdlRouterService.java
+++ b/sdl_android_lib/src/com/smartdevicelink/transport/SdlRouterService.java
@@ -772,34 +772,31 @@ public class SdlRouterService extends Service{
return false;
}
+
+ private boolean permissionCheck(String permissionToCheck){
+ if(permissionToCheck == null){
+ throw new IllegalArgumentException("permission is null");
+ }
+ return PackageManager.PERMISSION_GRANTED == getBaseContext().checkPermission(permissionToCheck, android.os.Process.myPid(), android.os.Process.myUid());
+ }
- // Runs several checks. Returns false if any fail, true if all pass.
+ /**
+ * Runs several checks to ensure this router service has the correct conditions to run properly
+ * @return true if this service is set up correctly
+ */
private boolean initCheck(){
if(!processCheck()){
Log.e(TAG, "Not using correct process. Shutting down");
wrongProcess = true;
return false;
}
- if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
- if(getApplicationContext().checkSelfPermission(Manifest.permission.BLUETOOTH) != PackageManager.PERMISSION_GRANTED){
- Log.e(TAG, "Bluetooth Permission is not granted. Shutting down");
- return false;
- }
- }else{
- try{
- if (false){ // Placeholder for android.support.v4.content.ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH) != PackageManager.PERMISSION_GRANTED
- Log.e(TAG, "Bluetooth Permission is not granted. Shutting down");
- return false;
- }
- }catch(Exception e) {
- Log.e(TAG, "Android Support Library not available, not checking for BT permission.");
- }
+ if(!permissionCheck(Manifest.permission.BLUETOOTH)){
+ Log.e(TAG, "Bluetooth Permission is not granted. Shutting down");
+ return false;
}
if(!AndroidTools.isServiceExported(this, new ComponentName(this, this.getClass()))){ //We want to check to see if our service is actually exported
Log.e(TAG, "Service isn't exported. Shutting down");
return false;
- } else {
- Log.d(TAG, "We are in the correct process");
}
return true;
}