Last active
October 12, 2018 09:12
-
-
Save wanzismail/5b69012e516a3b54db0c547e98698f6b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
private fun isMockSettingsOn(): Boolean { | |
return currentLocation?.isFromMockProvider ?: false | |
} | |
private fun areThereMockPermissionApps(context: Context): Boolean { | |
var count = 0 | |
val pm = context.packageManager | |
val packages = pm.getInstalledApplications(PackageManager.GET_META_DATA) | |
for (applicationInfo in packages) { | |
try { | |
val packageInfo = pm.getPackageInfo(applicationInfo.packageName, | |
PackageManager.GET_PERMISSIONS) | |
// Get Permissions | |
val requestedPermissions = packageInfo.requestedPermissions | |
if (requestedPermissions != null) { | |
for (i in requestedPermissions.indices) { | |
if (requestedPermissions[i] == "android.permission.ACCESS_MOCK_LOCATION" && applicationInfo.packageName != context.packageName) { | |
count++ | |
} | |
} | |
} | |
} catch (e: PackageManager.NameNotFoundException) { | |
Log.e("Got exception ", "Message> " + e.message) | |
} | |
} | |
return count > 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment