diff options
author | Joey Grover <joeygrover@gmail.com> | 2016-05-25 16:37:41 -0400 |
---|---|---|
committer | Joey Grover <joeygrover@gmail.com> | 2016-05-25 16:37:41 -0400 |
commit | f65e3db9e839094cd23997fef2f8b3140363d396 (patch) | |
tree | cc1d44719e4966e7795d4c7c99b800a6c3791645 | |
parent | 803c2722c66b46c754bd432774fafe4e1f7e6225 (diff) | |
download | sdl_android-f65e3db9e839094cd23997fef2f8b3140363d396.tar.gz |
Created app store enum and added more trusted app stores. Optimized logic.
Also updated Url for trusted routers
-rw-r--r-- | sdl_android_lib/src/com/smartdevicelink/transport/RouterServiceValidator.java | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/sdl_android_lib/src/com/smartdevicelink/transport/RouterServiceValidator.java b/sdl_android_lib/src/com/smartdevicelink/transport/RouterServiceValidator.java index ab60c65fa..3cdeb3628 100644 --- a/sdl_android_lib/src/com/smartdevicelink/transport/RouterServiceValidator.java +++ b/sdl_android_lib/src/com/smartdevicelink/transport/RouterServiceValidator.java @@ -38,7 +38,7 @@ public class RouterServiceValidator { private static final String TAG = "PackageCheckUtl"; public static final String ROUTER_SERVICE_PACKAGE = "com.sdl.router"; - private static final String REQUEST_PREFIX = "https://woprjr.smartdevicelink.org/api/1/applications/queryTrustedRouters"; + private static final String REQUEST_PREFIX = "https://woprjr.smartdevicelink.com/api/1/applications/queryTrustedRouters"; private static final String DEFAULT_APP_LIST = "{\"response\": {\"com.livio.sdl\" : { \"versionBlacklist\":[] }, \"com.lexus.tcapp\" : { \"versionBlacklist\":[] }, \"com.toyota.tcapp\" : { \"versionBlacklist\": [] } , \"com.sdl.router\":{\"versionBlacklist\": [] } }}"; @@ -241,13 +241,13 @@ public class RouterServiceValidator { try { final ApplicationInfo applicationInfo = packageManager.getApplicationInfo(packageName, 0); //TODO might want to try to get version with this packageManager.getPackageInfo(packageName, 0).versionCode; - if ("com.android.vending".equals(packageManager.getInstallerPackageName(applicationInfo.packageName)) - || "com.amazon.venezia".equals(packageManager.getInstallerPackageName(applicationInfo.packageName))) { - // App was installed by Play Store + if(TrustedAppStore.isTrustedStore(packageManager.getInstallerPackageName(applicationInfo.packageName))){ + // App was installed by trusted app store return true; } } catch (final NameNotFoundException e) { e.printStackTrace(); + return false; } return false; } @@ -535,6 +535,41 @@ public class RouterServiceValidator { } } + public static enum TrustedAppStore{ + PLAY_STORE("com.android.vending"), + AMAZON("com.amazon.venezia"), + XIAOMI("com.xiaomi.market"), + SAMSUNG("com.sec.android.app.samsungapps"), + WANDOUJIA("com.wandoujia.phoenix2"), + BAIDU_APP_SEARCH("com.baidu.appsearch"), + HIAPK("com.hiapk.marketpho"), + ; + + String packageString; + private TrustedAppStore(String packageString){ + this.packageString = packageString; + } + + /** + * Test if the supplied store package is one of the trusted app stores + * @param packageString + * @return + */ + public static boolean isTrustedStore(String packageString){ + if(packageString == null){ + return false; + } + TrustedAppStore[] stores = TrustedAppStore.values(); + for(int i =0; i<stores.length; i++){ + if(packageString.equalsIgnoreCase(stores[i].packageString)){ + return true; + } + } + return false; + } + + } + } |