How to create application auto reboot device with not rooted device?
I used method reboot in PowerManager with permission
<uses-permission android:name="android.permission.REBOOT" />
so occur error "neither user 10039 nor current process has android.permission.REBOOT"
May be reason is only system applications and applications signed with the same key that was used to sign the firmware will be able to get that permission.
Please suggest me a better way to create application auto reboot.
You cannot do a reboot from an ordinary SDK application. Only applications signed with the system firmware signing key can do this.
Copied from this answer,
Programmatically switching off Android phone
You need the system key to sign your app. See this post for details;
How to compile Android Application with system permissions
Reference and original answer here
Related
I am building an application which needs to understand the reason behind a particular call dropping out. I found this API (https://developer.android.com/reference/android/telephony/PhoneStateListener#onCallDisconnectCauseChanged(int,%20int)) which does exactly what I need it do. However, it requires the Manifest.permission.READ_PRECISE_PHONE_STATE permission which upon further digging here (https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/AndroidManifest.xml) has the protection level signature|privileged and I am unable to grant this permission to my app.
I have rooted the device and used adb to transfer the apk file from the /data folder into /system/priv-app. The app opens fine however, I get a security exception when I try and register the listener. I have followed the advice here (https://source.android.com/docs/core/permissions/perms-allowlist#:~:text=Starting%20in%20Android%208.0%2C%20manufacturers,The%20privapp%2Dpermissions.) and setup a permissions.xml for my app in the /etc/permissions folder but this has had no impact.
I have full control over every device the app will run on so rooting etc is not a problem.
I need to Turn ON/OFF Mobile data programmatically. For this issue I need to use MODIFY_PHONE_STATE permission.
As we know in latest Android versions it's not possible for non-rooted phones unless the app has system rights.
I know that exists some workaround how to sign the app as system app. But as I understand it's not possible to publish such app at the Play Store.
My question is the next - is it possible to get system rights officially? If it is possible which way I have to go to get them?
THe only way to get them is a rooted device, or to build the device image yourself. The idea of system permissions is that only apps which are trusted by the creator of the system (the OEM) can request them. You can also get them by rooting the device, because of how they're granted (its based on the directory the app is installed in, which can be accessed if you have root). But there is no way to do it without root or without creating your own OS image.
MODIFY_PHONE_STATE is a system-only permission so there's no way to get that permission unless you root your phone.
How can I send Intent to shutdown the phone if I have a rooted phone?
I put the app in system/app but this was not good enough. What more do I have to do?
It says in docs about public static final String ACTION_SHUTDOWN:
This is a protected intent that can only be sent by the system.
What does it mean only sent by the system? If I get my app to get correct UID,
can I do it then? Or can it absolutely never be done even on a rooted phone?
The Android source in GrepCode suggests that before Android 4.0 this was a signature-only permission, but is now signature or system. This means that you either have to be signed with the key that was used to sign the platform (usually OEM apps only) or be in the /system/app folder. In more recent versions of Android this folder is /system/priv-app to allow vendors to distribute built-in applications with different levels of trust.
You can run an adb shell command as root to shutdown the device.
I list all permissions of the new installed application on Android device. But I want to detect when an application uses these permission. For example, I installed an app and it uses READ_CALENDAR permission. It is not always read my calendar data. I want to detect the time it reads my calendar data. Is it possible?
No, I don't think this is possible. You would need to be able to monitor each external app, and you don't have the ability to know what they are doing (due to security restrictions on Android). In other words, your app doesn't have the ability to monitor the actions of other apps (not written by you) on the device.
I don't think you have access to the system at the level you would need to perform this (this may be possible on a Rooted phone, but I think that would still be difficult).
When you write an app you have to insert in the android manifest all the possible "uses permissions", for all the functionality that your app will use.
When someone installs your app, before the installation procedure, he can read all the permissions used from the app. If you accept to install it, the app will use all those permissions listed.
How do I prevent my device administration application from being installed? I have created the application and enabled it in location and security, but I can still uninstall it or disable it without asking for a password.
I'm fairly sure that's impossible (fortunately), unless you have complete control of the device and install your own package manager?