I developed an app and copied it to /system/priv-app in a rooted Android device to make my app a system app and It works But still when I try to run below code I get an exception that only system can broadcast this.
val newIntent = Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
newIntent.putExtra("state", false)
sendBroadcast(newIntent)
My Android version is 7.1.1 is there any workaround for this? I want to broadcast this after changing the airplane mode with this code
Settings.System.putInt(contentResolver, Settings.System.AIRPLANE_MODE_ON, 0)
Your app has to be signed by the platform key and also assigned the system user (specified in the manifest.) Placing the app in /system/priv-app does not grant it any special functionality.
Related
I am developing a KIOSK Mode stand alone application for Wear OS(Samsung Watch 4, Wear OS 3.5). For KIOSK mode I am using device owner permission using ADB and used device [DevicePolicyManager][1] class to handle hardware button and status bar etc.
My Issue is, I am not able to open System WIFI settings which navigate to outside of KIOSK mode.
Just for your information I can open system bluetooth settings without disabling KIOSK mode. One more information: case 3 code work perfectly if your KIOSK mode is disable
I tried:
Case1.
context.startActivity(Intent("com.google.android.clockwork.settings.connectivity.wifi.ADD_NETWORK_SETTINGS"))
I can see something gets opened and closed automatically.
Case 2.
val intent = Intent(Settings.ACTION_WIFI_SETTINGS)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
intent.addCategory(Intent.CATEGORY_LAUNCHER)
startActivity(intent)
Case 3.
startActivity(Intent(Settings.ACTION_WIFI_SETTINGS))
If any one have any idea or workaround. Much appreciate your inputs!
Finally I achieved it by whitelisted packagename.
devicePolicyManager!!.setLockTaskPackages(deviceAdmin, arrayOf("our.own.package.name","com.google.android.apps.wearable.settings"))
After whitelisted in KIOSK mode. now it will work!
startActivity(Intent(Settings.ACTION_WIFI_SETTINGS))
I am trying to reboot Android device through a activity. I'm using following code.
public void reboot(){
PowerManager pm=(PowerManager)getSystemService(Context.Power_Service);
pm.reboot(null)
}
And I have given Manifest permission too.
android:name="android.permission.REBOOT
Error::java.lang.SecurityException: Neither user 10098 nor current
process has android.permission.REBOOT.
Only applications signed with the system firmware signing key are allowed to do these operations.
More information can be found in the links below
How to compile Android Application with system permissions
Programmatically switching off Android phone
I developed a custom watch face (Android Wear 5), works perfectly during testing. Uploaded to Google Play and download to test, but it does not show up in the Android Wear app, nor the paired watch itself (running Android Wear 5.0.1)!
I uploaded the mobile apk (similar to my other Android Wear apps), and also have the same permissions for both mobile and wear.
Anybody encountered similar problem? Here's the Watch Face if anybody wanted to test it out: https://play.google.com/store/apps/details?id=com.virtualgs.retrowatch
Are you sure you received an update to your watch face already? You will only see the new watch faces after an update.
If you do have an updated watch, try going to the Android Wear app on your phone, Settings -> Resync apps.
EDIT:
I looked into the logcat of the watch and I saw an attempt to install your watch package:
I/WearablePkgInstaller( 582): Sending install intent to PackageInstaller Intent { act=com.google.android.clockwork.packagemanager.INSTALL_PACKAGE dat=content://com.google.android.clockwork.home.provider/host/com.virtualgs.retrowatch/wearable/com.virtualgs.retrowatch/apk typ=vnd.android.cursor.item/wearable_apk pkg=com.google.android.clockwork.packageinstaller (has extras) }
W/WearablePkgInstaller( 1859): Wearable com.virtualgs.retrowatch has a permission "android.permission.PROVIDE_BACKGROUND" that is not granted in the host application.
You forgot to add PROVIDE_BACKGROUND permission to you phone app (wearable permission set has to be subset of the phone permission set). Remember, that you also need wake lock permission, in case you didn't add it.
EDIT2:
You are declaring wrong permission for providing background. This is the correct one:
com.google.android.permission.PROVIDE_BACKGROUND
I'm facing a problem in android version 4.3 to control airplane mode by code.For this I converted the user app into system using system/ app mover application available in google play.Once the user enables the airplane mode, the background service have the control to check the airplane mode and reset it to off state and send the broadcast changes to the device.Below the snippet I implemented in my code to keep the airplane mode state in off.But it fails in android version 4.3. It throws an exception called "permission denied". Let me know is these any additional permission need to added in manifest or else let me know your suggestions on these issue to fixed.
try {
Settings.Global.putInt(context.getContentResolver(),
"airplane_mode_on", 0);
isAirplaneModeOn = isAirplaneModeOn(context);
Intent localIntent2 = new Intent(
"android.intent.action.AIRPLANE_MODE");
localIntent2.putExtra("state", isAirplaneModeOn);
context.sendBroadcast(localIntent2);
} catch (Exception e) {
Log.v("TAG",
e.toString() + "\n" + e.getMessage());
}
Moving an App into the /system/app folder does not turn it into a System App - it simply makes the App uninstallable because /system is normally mounted read-only.
What you are trying to do requires full System App privileges. You can only get these by signing your app with the same key used to sign the original firmware Apps - the platform key. In other words, you need access to whoever built the version of Android you are running on and get them to sign your APK.
Actually you cannot do it starting from Android 4.2. Because that settings was relocated here from either Settings.System or Settings.Secure. But on previous vesions it works fine.
http://developer.android.com/about/versions/android-4.2.html
If your app is currently making changes to settings previously defined
in Settings.System (such as AIRPLANE_MODE_ON), then you should expect
that doing so will no longer work on a device running Android 4.2 or
higher if those settings were moved to Settings.Global.
Related question on StackOverflow
What's Intent I can make my app open Settings for enabled and disabled Data Package?
I try ACTION_DATA_ROAMING_SETTINGS but I'm wrong, because don't make the that I want.
I need just enabled and disabled data package...
The mobile that I use is motorola defy, and the Intent that I find that make the that I want is: com.motorola.blur.datamanager.app.DataManagerAppPreferenceActivity. But I need of native Intent of Android, because my app will run in device others.