my app requires more permissions than needs - java

I have these permissions in my manifest.xml
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="dea.gov.ge.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
But in google play my app requires more permissions:
Identity
find accounts on the device;
Contacts
find accounts on the device;
Location
approximate location (network-based);
precise location (GPS and network-based);
Phone
read phone status and identity;
Photos/Media/Files
modify or delete the contents of your USB storage;
read the contents of your USB storage;
Storage
modify or delete the contents of your USB storage;
read the contents of your USB storage;
Wi-Fi connection information
view Wi-Fi connections;
Device ID & call information;
read phone status and identity
Other
receive data from Internet;
full network access;
read Google service configuration;
view network connections;
use accounts on the device;
I have google maps where i'm inserting some markers from xml file. and getting IMEI code.
But why does it needs contacts, photo/media files, storage etc.?

Related

Unable to read device phone numbers despite meeting two of the listed requirements in Android 10 and above

I am trying to use the TelephonyManager class to read the line1Number and the IMEI of the Sim card in the respective slots. I have also tried using TelecomManager class to achieve the same with zero success. I headed over to the official documentation of the c;class on Google documentation and did find out that the methods TelephonyManager.GetLine1Number() or TelephonyManager.GetImei() can only be used if one of the following conditions is met.
If the calling app has been granted the READ_PRIVILEGED_PHONE_STATE permission; this is a privileged permission that can only be granted to apps preloaded on the device.
If the calling app is the device owner of a fully-managed device, a profile owner of an organization-owned device, or their delegates (see DevicePolicyManager.getEnrollmentSpecificId()).
If the calling app has been granted the Manifest.permission#USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER permission.
If the calling app is the default SMS role holder (see RoleManager.isRoleHeld(java.lang.String)).
If the calling app has been granted the READ_PRIVILEGED_PHONE_STATE permission; this is a privileged permission that can only be granted to apps preloaded on the device.
I am aware that as from Android 10 accessing device identifiers is kind of technical so because they said if one of the requirements above is met then a method like TelephonyManager.GetImei() should work when invoked. I did try to use a method from an app with device administration privileges like mentioned in the second requirement from the list above, the exception user 10711 does not meet the requirements to read device identifiers is thrown. I also tried the other requirement to declare the permission <uses-permission android:name="android.permission.USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER"/> in my manifest and then tried to request for the permission at runtime from the user like below
if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.UseIccAuthWithDeviceIdentifier) !=
Permission.Granted)
{
RequestPermissions(new string[]{Manifest.Permission.UseIccAuthWithDeviceIdentifier},682);
}
Meeting that permission requirement also does not make the invocation of the TelephonyManager.GetImei() work. How do I write code that will make devices running Android 10 and above return the IMEI and lineNumber without the exception does not meet the requirements to access device identifiers being thrown?
My manifest file looks like this
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0"
package="LockScreenAPI.LockScreenAPI">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.BIND_DEVICE_ADMIN"/>
<uses-permission android:name="android.permission.PREVENT_POWER_KEY" />
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.READ_SMS"/>
<uses-permission android:name="android.permission.USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER"/>
<application android:allowBackup="true" android:label="#string/app_name" android:supportsRtl="true" android:theme="#style/AppTheme">
</application>
</manifest>
An answer in Android Java is accepted because I use it as the blueprint to implement in a Xamarin Android app, Thank You.

Allow Background Activity for this App in Foreground Service Android

I am running a foreground service in android 10 and 11. But I have issue in my Oppo android 11. Issue is that the execution of any process is stopped after some time because the Allow Background Activity is not enabled for this app in setting. If I allow it then the foreground service works fine. I don't know how to check that if the Allow background activity is enabled or not and how to move to that specific intent. I have search alot but didn't found any solution.
The picture of the app setting is here.
The picture of the app setting is here
The Android Manifest file permissions are here.
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />

MQTT with Android

I'm trying to publish a message via MQTT. So I created a blank Android app and added the Paho MQTT library to it.
This is the line of code I execute first:
MqttClient client = new MqttClient("tcp://192.168.178.34", "Foo");
This throws an "MqttException" which contains no message, no error code, no nothing. So currently I have no idea what's going wrong.
I also added the following permissions to my app:
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Can anyone give me a hint what I could be doing wrong here?
In the code, The activated class is the TCPNetworkModule class which is using connect method of the socket class directly(see the start method of the class).
I think the exception might be the NetworkOnMainThreadException
attempting to use blocking IO.
That's why we use MqttAndroidClient instead.

how to turn ON or OFF the internet connectivity from app of an android device? [duplicate]

This question already has answers here:
Android: How to Enable/Disable Wifi or Internet Connection Programmatically
(10 answers)
Closed 5 years ago.
I am new in Android developer community. I just want to ask if there is a way to turn ON or OFF the internet connectivity of android device through app.
Is there any permission for that so that app can disconnect the device from internet? Any suggestion will be helpful.
add your manifest this permissions
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.UPDATE_DEVICE_STATS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
then you can enable or disable your wifi
WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
wifi.setWifiEnabled(true);
or
wifi.setWifiEnabled(false);

Old app can't get WiFi scan results on android N

I wrote an app that detects wifi networks and when I press on a network it gives me detailed info about that network. Now the problem is that I wrote it 3 years ago when Android KitKat did not require the popup permission from the user and now when I run it on android N and I press scan it neither scans nor gives me the pop-up permission.
I have not programmed android for a long time and I don't know the changes in Android app coding requirements . Any ideas why this happens?
Current permissions used by the app:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
In order to get WiFi scan results on Marshmallow and later, your app will need to request the ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission, and the Location Mode setting must be enabled as well.
From the documentation for getScanResults():
the list of access points found in the most recent scan. An app must
hold ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission in
order to get valid results
This change was made due to the fact that location can be determined from WiFi scan results.
As an extra security measure, apps now need to request the Location permission in order to see WiFi scan results, and additionally if the user sets their Location Mode to off, no app can see scan results when running in the background.
So, at a bare minimum, add the ACCESS_COARSE_LOCATION permission to your manifest in order to get WiFi scan results:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
If you keep your target API version lower than 23, you can't request permissions at runtime. In this case, your app will continue to request all permissions at install time.
If you update your app to target API version 23 or later, you will need to request all dangerous permissions at runtime. See here for an example of requesting the Location permission at runtime.

Categories

Resources