Mock Locations on Android 12 - android

I am testing an app that uses geofencing and I need to be able to specify mock locations. In my research I found old posts (5 years) talking about using Allow Mock Locations in developer options but that seems to only be in older versions of Android. Now I see a place to specify a mock location app but no way to specify one. I looked at code samples to create a mock location app but the permission that has to be set (ACCESS_MOCK_LOCATION) appears to be only valid for system apps. Is there no way to do this anymore without rooting?

Firstly, the apps that acquire ACCESS_MOCK_LOCATION appear in developer options, which means you will be able to select your app as a mock location app when you add-in manifest
Secondly, ACCESS_MOCK_LOCATION is not a system app permission. So there is no need for rooting the device or marking your app as a system app etc.

Related

How can I setup a custom WiFi AP or Hotspot with WEP security on Android?

I need to setup a WiFi AP with WEP security on an Android Phone or Tablet and I set out to build an App for this purpose.
Disclaimer: I am well aware of WEP shortcomings but I still need this. My app is only intended for a handful of people and clearly not meant to be published on Google Play or any other store.
Before I can set it, I tried reading the current configuration using the following piece of code but it fails with the exception:
java.lang.SecurityException: App not allowed to read or update stored
WiFi Ap config
private fun getCurrentConfig(conf: WifiConfiguration) {
val mGetWifiConfig = wifiManager.javaClass.getDeclaredMethod("getWifiApConfiguration")
return mGetWifiConfig.invoke(wifiManager)
}
I have tried adding <uses-permission android:name="android.permission.OVERRIDE_WIFI_CONFIG" tools:ignore="ProtectedPermissions"/> to AndroidManifest.xml to no avail.
My current understanding is that the App needs to be either system or privileged to be eligible to the relevant permission but I have no clue how to achieve either.
I am using Android Studio Dolphin (2021.3.1) an currently targeting Api 28, although this it not a requirement and I am flexible here. I'd like my App to be easily installed on reasonably current devices but I'm willing to compromise here as well but I don't want to rely on finding specific vintage devices either.
android.permission.OVERRIDE_WIFI_CONFIG is a system-level permission, meaning that your app has to be signed by a platform key (you would have to create a custom ROM, and sign your app with the same key). Alternatively, you would need to have a rooted phone, and move your app to the system partition.

Releasing app that uses different permissions for different Android versions on the Google Play store?

Our app is trying to follow the new Designed for Children policy, which requires not requesting location permissions: https://support.google.com/googleplay/android-developer/answer/9893335?hl=en
We require bluetooth, and request location permissions in order to connect to bluetooth. In order to not have our app removed from the play store, we are supposed to remove the location permission request and switch to CompanionDeviceManager. However, CompanionDeviceManager is only available in API 26+, and we have many users on older versions.
Is there a way for us to release a different APK for phones on 25- vs on 26+? Does the Play store have any support for this, or would we have to basically maintain 2 separate apps on the play store? I know that you can usually branch in the source code based on version, but I haven't seen that it's possible to branch on what permissions are in the manifest.
I'm not entirely certain how this interacts with the Designed for Children policy, but there's actually a much easier way to target permissions to specific SDK versions than creating multiple APKs: the android:maxSdkVersion property on the <uses-permission> tag. You could simply set android:maxSdkVersion="25" on the location permission, and your app should no longer ask for that permission on API 26+.

Criteria for passing SafetyNet Verify Apps API

I created an app that uses the SafetyNet Verify Apps API. The app is working without any error and in all the devices that I tested it, it said no harmful apps were found. I would like to know if what are the criteria for an app to pass the SafetyNet test. If I know that I will create an app that will fail the test to verify if the feature is working correctly. I tried to read through Google's documentation but I was unable to find anything in this matter.
Is there such an app? What feature must my app have to fail the SafetyNet test?
An app will fail the check if it is determined by Google to be "malicious".
Think of Verify Apps as something similar to an antivirus. It will catch what the developers define as a malicious app. The definition is opaque, and might change from app to app.
So if you want to see Verify Apps catching something, how about you get a test device with nothing important in it, or emulator, and then try finding some malware and install it into the device? Doing this may in the worst case, damage your device, so do it at your own risk.

Strategy to implement an "optional" location permission

I'm developing an app that would benefit from coarse location data, but the nature of this app is such that many users would have privacy concerns if location permission would be mandatory
I'm hoping to find a way to provide both options (with and without location perms).
AFAIK there is no way to enable location perms programmatically in Android.
All I can think of is to publish two separate app versions in Google Play but I'm not very excited about "splitting" the download and rating stats between them and the potential development overhead.
Do you have any ideas to handle this another way or how to make the separate app option as painless as possible?
For future reference:
It is now possible with the new Android M runtime permissions.
The permissions still have to be defined in manifest, so, to avoid enforcing the permission for users with older android versions, use the new <uses-permission-sdk23 /> element

How to prevent a user from installing applications which uses some specific permissions

What is the best way to prevent a user from downloading and installing applications which uses some specific permissions like location and sms.
Is it programatically possible to parse the manifest of an application from the market before it get installed and look for the specific permissions and alert the user?
What is the best way to prevent a user from downloading and installing applications which uses some specific permissions like location and sms.
Write your own firmware, where you replace the normal installer mechanism with one that enforces your desired criteria.
Android SDK applications cannot interfere with application installation.
Is it programatically possible to parse the manifest of an application from the market before it get installed and look for the specific permissions and alert the user?
No, sorry.
However, you can listen for ACTION_PACKAGE_ADDED and examine the newly-installed package via PackageManager, and alert the user at that point. Since nothing of the installed package can run immediately upon the install, I would think that there is a decent chance that your alert will appear before the user tries to use the newly-installed app.
In the future this would be probably something you could do trough Device Administration, but right now limiting application installation based on its requested permission is not included.
One option is this snippet that decompress the apk and extracts the AndroidManifest.xml.
By the way the aapt tool for android runs on the Android OS too. You can get this information using this port

Categories

Resources