Android set Service state - android

I'm trying to turn off the android radio programmatically. I'm trying to use the ServiceState class, but it wont work. I added the permission CHANGE_NETWORK_STATE and MODIFY_PHONE_STATE. Still no luck. any ideas?

Permission MODIFY_PHONE_STATE is a system permission, thus, you cannot use it in your application.
EDIT:
Ok. I'll try to explain. The service method to turn on and turn off radio programatically is protected with MODIFY_PHONE_STATE permission. This permission has signature type, thus, only applications that have the same signature can invoke this method. Thus, so as your application is not signed with the system certificate you cannot use this permission in your application. But without this permission you also cannot change the state of the radio.

Related

I cannot grant the following permission on my app..Kindly suggest any alternative?

<uses-permission android:name="android.permission.CALL_PRIVILEGED"/>
I cannot grant this permission in the android manifest file as it shows the following
error:
Permissions with the protection level signature or signatureOrSystem are only granted to system apps. If an app is a regular non-system app, it will never be able to use these permissions.
So,what should i do now?
Permissions with the protection level signature or signatureOrSystem
are only granted to system apps. If an app is a regular non-system
app, it will never be able to use these permissions.
So,what should i do now?
If your app is expected to run on non-rooted devices, then you're simply doomed - you can do nothing, unless you have platform keys to sign your app with it.
Alternatively, you may narrow your audience to rooted devices only but that would allow you to do what you want incl. using features usually reserved for the platform or system apps ony.
Finally you may rethink your approach. Perhaps what you want to do can be achieved other way, w/o need of elevating app privileges.
For this "CALL_PRIVILEGED" permission , you will need a rooted device and the app must be installed as a system app only.
From the documentation (https://developer.android.com/reference/android/Manifest.permission.html#CALL_PRIVILEGED):
String CALL_PRIVILEGED
Allows an application to call any phone number, including emergency numbers,
without going through the Dialer user interface for the user to confirm the
call being placed.
Not for use by third-party applications.
So, the short answer is that you can't use it. What are you trying to accomplish?

App permissions for services

When an application calls a service through an intent, will the permissions that the app has, hold for the service as well? Do I need to explicitly check if permissions are granted and request permissions separately in the service again? I'm using the Permiso library to handle runtime permissions for me/
You should always Check the permissions before you used it.
if the permission given, Just go forward.
Otherwise, Stop the service (or) Intimate the requirement of permission to the App User.

Security Exception: Permission denial for DEVICE_POWER

I am trying to write a simple android app that switches off my phone screen. When I am runnning this app I get Security Exception: Permission denial app requires android.permission.DEVICE_POWER. I know that this is a protected permission but my phone is rooted. What do I specify that I can use this permission? I have already tried declaring DEVICE_ADMIN permssion along with the DEVICE_POWER permission but it still doesn't work.
Rooting potentially lets you circumvent or modify the android security model, but it doesn't necessarily mean you get special privileges for an android API which enforces it. You cannot ordinarily run an application itself as root, while code in a helper executable which you could start as root will have substantial difficulty interacting with the Android APIs.
What you are trying to do may really not be a very good idea. But if you really want to do it, you would need to either install your own build of Android so that you have a (self generated) key matching that which you used to sign the platform, which you can then use to sign your application, or else try to install your application on the system partition.
If all you want to do is turn the screen off, then why don't you use the PowerManager? According to the documentation, the goToSleep() function will force the device to go to sleep.

Access caller name without READ_CONTACTS permission - android

I have thought about creating a temporary permission or access in some way to the incoming call create screen methods and use their values, but i have no idea how do so.
It is very important for me to not use this permission. Any ideas?
Sorry, but the security model of Android requires you to request the permission. There is no way to work around this unless you're running a custom rom on the device.

PackageManager: Not granting permission

Im trying to force my phone to go to sleep as soon as i turn my screen off, but whenever i install with adb, packagemanager informs me that it wont grant the permission i need, so my service throws an exception. I was able to install another app called power save mode toggle which has the same permission, and it seems to work, so i should be able to get this to work, right?
Without knowing which permissions you did grant, or the AndroidManifest.xml to ensure you placed them in the correct area, try granting these:
DEVICE_POWER
MODIFY_PHONE_STATE

Categories

Resources