Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permission is only granted to system app, in Manifest

I want to add this permission to my Android manifest:

<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" /> 

But after I paste this permission in my manifest, it tests red underline and says:

permission is only granted to system apps

What can I do?

like image 526
Reza_Rg Avatar asked Nov 28 '12 03:11

Reza_Rg


People also ask

How do I declare permissions in Android manifest?

To declare a permission only on devices that support runtime permissions—that is, devices that run Android 6.0 (API level 23) or higher—include the uses-permission-sdk-23 element instead of the uses-permission element. When using either of these elements, you can set the maxSdkVersion attribute.

What is permissions in manifest?

Allows applications to access information about networks. Marker permission for applications that wish to access notification policy. Allows applications to access information about Wi-Fi networks.

How do I get permission off Android manifest file?

The simple way to remove this type of permission, is by deleting its xml code line from the original Android Manifest file in android/app/src/main .


2 Answers

MODIFY_PHONE_STATE permission is granted to system apps only.

For your information, there are 2 types of Android apps: system & user

User apps are just all your normal app installations through the Google Play Store, Amazon Appstore or sideloading. These go into the /data partition of your Android phone, which is the part of the internal memory made available for user data and apps.

System apps are basically the apps that come pre-installed with your ROM. In a standard Android user environment, the user doesn’t have write access to the /system partition and thus, installing or uninstalling system apps directly isn’t possible.

In order to install an app as a system app on your Android device, your device must either be rooted or have a custom recovery installed (or both).

That being said, that error is actually wrong because you have a valid code and compilation should work. It would be better if it gave a warning instead. In Eclipse you can easily fix it. Just go to:

Window -> Preferences -> Android -> Lint Error Checking.

Find ProtectedPermission from the list and set the severity to something other than error(info for example). This way your project will still compile.

like image 162
Caner Avatar answered Sep 24 '22 12:09

Caner


MODIFY_PHONE_STATE is a system-only permission. System Apps are either pre-installed into a system folder or compiled by a manufacturer using their security certificate.

Hence, if you are trying to do this you are trying to use API which are no longer supported. With Android versions 2.3+ you can monitor incoming calls, but blocking is not allowed (i think from the link you posted thats what you're trying to do).

Android issues if you need to follow: Issue 15022 and Issue 14789

like image 31
gsb Avatar answered Sep 22 '22 12:09

gsb