I am trying to disable one of the app from my app. I have created a launcher app and trying to use following method of package manager
pm.setApplicationEnabledSetting(packageInfo.packageName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
But I'm getting SecurityException as
SecurityException: Permission Denial: attempt to change component state from pid=20217, uid=10066, package uid=10067
Note: Somewhere I found the solution to this is to mention below permission in manifest
But I'm getting a warning in this permission that this permission is only granted to system apps.
In order to disable/enable other apps your app must have system privileges. To achieve privileges you should do these steps.
Add this line to your manifest header android:sharedUserId="android.uid.system"
Add this permission to the manifest "android.permission.CHANGE_COMPONENT_ENABLED_STATE"
Sign your app with a system key.
I checked it in my launcher app.
Related
enter image description here
I am getting the following error during security audit of the app.
1.Broadcast Receiver (com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver) is not Protected.
An intent-filter exists.
Activity (com.google.firebase.auth.internal.GenericIdpActivity) is not Protected.
[android:exported=true]
Activity (com.google.firebase.auth.internal.RecaptchaActivity) is not Protected.
[android:exported=true]
Service (androidx.work.impl.background.systemjob.SystemJobService) is Protected by a permission, but the protection level of the permission should be checked.
Permission: android.permission.BIND_JOB_SERVICE
[android:exported=true]
I am getting:
java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.TIME_SET from pid=xxxxx, uid=xxxxx
for:
Intent timeChanged = new Intent(Intent.ACTION_TIME_CHANGED);
sendBroadcast(timeChanged);
even when I have put my app in /system/app folder. Please help me out to know why this is happening?
Try putting the app in the priv-app folder in the system partition,
and adding the app to the privapp-permissions.xml file on the same partition, with the TIME_SET permission.
Please come here: Permission Denial of android.intent.action.REBOOT for APP in /system/priv-app. To get the most recent version of the code, just replace "android-5.1.1_r20" with "master").
It seems the app must be a persistent app, which can be done by setting the persistent flag to true on the Application tag of the Manifest. Either that, or have a UserId whitelisted, which is also on the code (though, sharedUserId is deprecated as of API 29, so might not be a good idea to use that way).
Can't use android.permission.WRITE_SETTINGS in android manifest. im trying to turn on airplane mode by programatticaly and I can't add this permission in manifest.
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
The Android docs says:
Note: If the app targets API level 23 or higher, the app user must explicitly grant this permission to the app through a permission management screen. The app requests the user's approval by sending an intent with action ACTION_MANAGE_WRITE_SETTINGS. The app can check whether it has this authorization by calling Settings.System.canWrite().
So you have to request the user's approval explicitly by sending an intent with action ACTION_MANAGE_WRITE_SETTINGS.
What is the error message that you are getting? Is the app crashing when you try to open it or set the airplane settings? If you are targetting >API 23, you need to explicitly ask for permissions during runtime, this is a change from earlier versions when the permission was granted once at install time.
This link talks abou this:
https://developer.android.com/reference/android/Manifest.permission.html#WRITE_SETTINGS
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 :
On a tablet I installed a apk develloped in Eclipse under Ubuntu. The App works on the AVD and is already installed on a phone and working.
The installation of the apk gives no error, however when starting the App it gives a "not installed" toast message.
In the aLogCat output I see a Permission denial message of the Launcher for WRITE_EXTERNAL_STORAGE. Note that the USB connection is not connected when I started the App.
Furthermore I noticed the following line in aLogCat and I noted that the "-1" was added to the package name.
New package installed in /data/app/com.company.AppName-1.apk
In the manifest the lines
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" />
are in the manifest block and
<android:permission="android.permission.WRITE_EXTERNAL_STORAGE">
in the application block.
Why is this working on a Android 2.3 phone and in a Android 4.0.3 AVD, but not on a Android 4.0.3 tablet?
Platform info: Eclipse 3.7.2, Tablet: Yarvik TAB461EUK; Installed with "ES File Explorer"
Try removing the permission from the application block. I dont know for sure but from personal experience ICS do not support permission attribute in application block which has already been defined in the main block. It inherits from the main block. Please tell if that solves the problem.
I dont know why it works on the AVD, may be because AVD do not have any external storage.
Related documentation:
http://developer.android.com/guide/topics/manifest/manifest-intro.html describes the permission element only for the main manifest block (now)
Changes per version states:
HONEYCOMB: When an application requires a permission to access one of its components (activity, receiver, service, provider), this permission is no longer enforced when the application wants to access its own component. This means it can require a permission on a component that it does not itself hold and still access that component.
Activity states:
The name of a permission that clients must have to launch the activity or otherwise get it to respond to an intent. If a caller of startActivity() or startActivityForResult() has not been granted the specified permission, its intent will not be delivered to the activity.
If this attribute is not set, the permission set by the element's permission attribute applies to the activity. If neither attribute is set, the activity is not protected by a permission.
Not very clear to me