android.permission.MODIFY_PHONE_STATE" not worked properly - android

I had already added this permission in my Manifest
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
But it will not give me permission to cut the incoming call, I can receive the call.when I'm try to cut the call it give me
java.lang.SecurityException: Neither user 10037 nor current process has android.permission.MODIFY_PHONE_STATE.
I have gone through so many blogs,but none of work.
In some of the emulator its working fine.

MODIFY_PHONE_STATE is a system-only permission, so you can not access or use this permission in your app,
Check it out!

Place your app in the /system/priv-app folder instead of /system/app, when using Android 4.3 or higher.

Related

How to request permission on Android Things?

I'm trying to write to a value on AT. I've already declared required permission as follow in manifest,
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
And try to request permission at run-time, AT shows windows regarding permission setup. However the switch is not clickable. Regarding AT document
Requesting Permissions at Runtime is not supported because embedded
devices aren't guaranteed to have a UI to accept the runtime dialog.
Declare permissions that you need in your app's manifest file. All
normal and dangerous permissions declared in your app's manifest are
granted at install time.
However Settings.System.canWrite() always returns false.
Are there any special methods to enable permission WRITE_SETTINGS?
Like you said, the documents say:
Declare permissions that you need in your app's manifest file. All normal and dangerous permissions declared in your app's manifest are granted at install time.
Therefore you don't see the normal Android permissions UI.
From the release notes:
Dangerous permissions requested by apps are not granted until the next device reboot. This includes new app installs and new elements in existing apps.
So try powering off and on your Android Things device
After install application with the statement on AndroidManifest.xml as follow
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
It needs to be also run Settings as follow via adb
adb shell am start -S com.android.settings/.Settings
Then click APPS>YOUR_APP, then click permission.
Now the switch is clickable. So AT not granted to permission. It needs to be granted manually.
This permission is having Protection level: signature.Which means this permission is only granted to system apps.
Please find the below screenshot for your reference :

Since Android 6.0 listening to the PhoneStateListener.LISTEN_DATA_CONNECTION_STATE changes seems to no longer require READ_PHONE_STATE permission

I'm applying Android 6.0 runtime permissions into an app which listens to carrier data connection state changes. I first tried to just remove the READ_PHONE_STATE from the manifest to check where the app requires the permission. To my surprise the app didn't crash at all.
After this I've tried the same installation on two pre 6.0 devices which did actually crash on it. To me it seems like Android 6.0 does no longer require the permission. Is there any way to confirm this?
The line below is the one on which the pre 6.0 devices crashes:
tm(TelephonyManager).listen(this, PhoneStateListener.LISTEN_DATA_CONNECTION_STATE);
Is there any way to confirm this?
Yes, this commit removes the request of READ_PHONE_STATE when register the event type LISTEN_CALL_STATE, LISTEN_DATA_ACTIVITY and LISTEN_DATA_CONNECTION_STATE:
Do not enforce PHONE_STATE_PERMISSION to register listener PHONE_STATE_PERMISSION should not be required to register to the following event types:
- PhoneStateListener.LISTEN_CALL_STATE
- PhoneStateListener.LISTEN_DATA_ACTIVITY
- PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
In case of LISTEN_CALL_STATE, an empty string should be passed instead of incomingNumber, when caller has no PHONE_STATE_PERMISSION.
Bug: 21588537 Change-Id: I5b6d0308924f7e4cd13a983b8e0c9b3a5bbb119b
The documentation on developer.android.com was updated and correctly shows that the permission are not required.
If your code doesn't need the permission READ_PHONE_STATE for other reason apart from LISTEN_DATA_CONNECTION_STATE you can change your AndroidManifest.xml adding maxSdkVersion to the uses-permission:
<uses-permission android:name="android.permission.READ_PHONE_STATE" android:maxSdkVersion="22" />
There is no special permission listed for PhoneStateListener.LISTEN_DATA_CONNECTION_STATE in the official android documentation.
http://developer.android.com/reference/android/telephony/PhoneStateListener.html#LISTEN_DATA_CONNECTION_STATE

Error in Manifest.xml when adding PACKAGE_USAGE_STATS [Android Lollipop]

I am trying to use "android.permission.PACKAGE_USAGE_STATS" in my app. Here it says that NOTE: This API requires the permission android.permission.PACKAGE_USAGE_STATS, which is a system-level permission and will not be granted to third-party apps. However, declaring the permission implies intention to use the API and the user of the device can grant permission through the Settings application.
It seems that I will need the user to explicitly give my app the permission to give access to the access the usage stats.
In addition, I used the intent code below to open the screen to allow user to give access to my app, but my app is not in the list.
Code I used:
Intent intent = new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS);
startActivity(intent);
When *startActivity(intent)' is fired (or going to *Settings>Security>Apps with Usage Access), a blank screen below pops up, my app is not part of it.
Bottom line question is -- How to use UsageStatsManager in Android Lollipop? Anyone tried it?
This is what worked for me.
<uses-permission xmlns:tools="http://schemas.android.com/tools"
android:name="android.permission.PACKAGE_USAGE_STATS"
tools:ignore="ProtectedPermissions" />
You can simply make this on the manifest, ignoring just this permission error:
<uses-permission
android:name="android.permission.PACKAGE_USAGE_STATS"
tools:ignore="ProtectedPermissions"/>
The AndroidManifest.xml error can be fixed by disabling lint errors. Specifically
Security - SignatureorSystemPermissions
I guess after that the settings app will show your app.

How to change Airplane Mode programmatically?

I am following this 2 tutorial. Tutorial 1 and Tutorial 2. But When i run thid project in my Moto G phone its unfortunately stop means after 17 api this is not working & give error
Caused by: java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.AIRPLANE_MODE from pid=8675, uid=10233
I set permission in manifest file.
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<protected-broadcast android:name="android.intent.action.AIRPLANE_MODE" />
I am also checking some solution like Permission Link. I am getting still this error. So, how can i resolve it?
Thanks in advance.
This broadcast can (now) only be sent by a system app, not by an installed app.
So unless you can get Motorola to sign your app as a system app, you are out of luck.

exec("su") permission denied?

when I use this code
Runtime.getRuntime().exec("su").
and listen to the ErrorStream it gives me back: Permission denied. However SuperUser successfully grants permissions. Any Ideas?
You need to add to your AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>
My ROM was messed up. I had to reinstall it. Adding a permission should NOT help.
Edit: SuperUser is now giving warning if you don't define the permission, how ever it will still grant su.

Categories

Resources