permission state with API23 and old version - android

I set my gradle for min API 18 and Tagret API23.
I use the new permission system as need for API23 and also write all the require permission in the manifest as in the old days.
On Device use API23 it is work O.K.
But when I put the APK on device with 5.1.1 also it show me all the require permission during installation and i accept it, it is look that it doesn't get them in the application itself.
I also check in the application setting of this APK on the device and see all the permission are there (there is no checkbox so I assume if it is written it is enable).
Does the new permission system together with the old way (permission in manifest ) has to addapt automaticly to the device API level, or I need to make any check during the application runtime?

I figure it out by myself. For install the new APK I have to remove the older one completely. If I just go to the setting->Application found the app and delete it by “remove completely” it is not enough. I have to go to the actionBar on top in the same window and by the 3 buttons ask to “remove for all users”. Only then it doesn't have any trace and when I install the new APK it gets the right permission automatically.

Related

How to check whether a permissions exists in a particular version of Android?

I am trying to build an app, as a self project, to understand permissions in detail. There are certain permissions, such as 'Bluetooth Connect' that was introduced in Android version 12 (API 31). Now if I am building an app with multiple features, say some of the features were introduced in the first version of Android, but some of them were introduced in the last version, do I have a method to check whether said permission exists in Android? The idea is to remove or restrict those features which are using APIs not defined and still have the app run on all phones.
For example, In my tests, I have noticed the permission when checked, using the ContextCompat.checkSelfPermission method, come back as 'Not granted' for permissions that are supposed to be undefined. Essentially, I want to know if there is a method of knowing whether the permissions are 'undefined'.
Additionally, I have seen some research papers go into the Android system logs and retrieve information. For example - . This is from the paper: Sleeping android: the danger of dormant permissions
I've tried to use ADB logcat to read the log files but not only is it very difficult, it doesn't say anything similar. Am I doing it wrong or was there an update which removed the information?
Even if I can see whether the permission exists or not via logs would be helpful.
Lint is set up to check this for you at compile time. It will force you to check that the SDK version is high enough to check for whichever permission you’re trying to use. For instance, if your minSdkVersion is lower than the version in which a permission constant was introduced, it will be a compile error to use that constant without wrapping it in an if statement that makes sure the SDK version on the device is high enough for it to exist.
I’m not sure how you have defeated this mechanism except that maybe you have compiled the app with Lint disabled.
The paper you linked is absolutely ancient. Lint probably didn’t help you with this back then.

How to get current wallpaper on Android 13?

Seems like getDrawable() of WallpaperManager is useless on Android 13 since users can't get READ_EXTERNAL_STORAGE permission for it.
Is there any way to get current wallpaper on API level 33? I mean without lowering targetSdk level, etc.
For my tiny live wallpaper app (here), I offer to import previous wallpaper, so I need this too. I also need a similar function getWallpaperFile which also needs storage permission.
Currently the only workaround I've found is to use MANAGE_EXTERNAL_STORAGE permission.
However, when I tried to publish my app with this permission, the policy team rejected it. I'm trying to send an appeal after an appeal, and so far it doesn't help.
I hope Google will solve it, or I will have to prepare an app that this is its whole purpose, as a companion to my own app.
You could target API 32 , before this change, but of course this won't be an option when Google will force developers to target API 33...
I also tried to reach the files themselves ( they are on "/data/system/users/0" , named "wallpaper" and "wallpaper_lock"), but sadly I failed to read them without the permission I've mentioned. I could do it with root access, but that's not the same at all...
Because of these terrible changes on Android 13, I've created a new request to have a new permission just to get the current wallpaper information (be it an image from lock/home or a live wallpaper ), here:
https://issuetracker.google.com/issues/263721379
Please consider starring.

Oreo (API 26) - drawOverlay + draw over status bar

In android oreo, I can't use WindowManager.LayoutParams.TYPE_SYSTEM_ERROR anymore and must use WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY instead. The drawback is, that this mode does not draw over the statusbar.
Is there anyway to achieve the old behaviour and be able to draw over the statusbar as well? I've a sidebar app and until now, I allowed the user to have trigger areas on top of the screen as well, which does not work anymore now, because the status bar is overlapping the touchable region on top now...
I'm interested in ANY solution, even if it's only for some devices, like rooted devices for example... As I think there is not normal solution for this problem because the android system does not allow this anymore as stated in the docs (https://developer.android.com/about/versions/oreo/android-8.0-changes.html#o-apps). Still, this does not necessary mean that there is no alternative solution...
Unfortunately, this is no longer possible...
Developers that utilize this feature have opened bug reports on Android’s Issue Tracker (#260787 and #36574245) to protest the change and ask for an alternative API, but a Googler commented on the tracker with the following statement:
Status: Won’t Fix (Intended Behavior)
We have followed up with the product and engineering team and got suggestion that developers can use SHOW_WHEN_LOCKED activities to show
when the device is locked, but it is intentionally no longer possible
to show over the lockscreen / over the notification shade
and there is only solution for this that you set your target sdk as 25
The docs says that the flag is deprecated for non-system apps. Have you tried making the app a system app?
This constant was deprecated in API level 26. for non-system apps.
Here is how with ES File Explorer:
Configure ES File Explorer by doing the following steps:
Launch ES File Explorer.
Select Menu and choose Settings.
Under Settings, enable the options for Up to root and Root Explorer. A message will appear, requiring you to confirm your action. You will also need to confirm Superuser access.
Enable Mount File System.
Go back to the app’s main menu.
Get a copy of the APK (Android Package) of the app that you want to save as a system file by doing the following steps (skip to step 3 if you already have the app’s APK file):
Install an app from the Google Play Store. For this guide, we will be using the app BioRhythms as an example.
Launch ES File Explorer and navigate to /data/app.
Locate the APK file that you want to install as a system app. If you don’t know the APK’s filename, simply go to the Google Play Store link of your chosen app. View the link and take note of the words after “?id=”. This will be your APK’s filename. For instance, the BioRhythms app link is https://play.google.com/store/apps/details?id=app.biorhythms. The BioRhythms’ APK is app.biorhythms-1.apk.
Create a backup of the chosen APK by copying it to the phone’s SD Card.
After creating a backup, long tap on the APK file and a menu will appear. Choose Cut. A blue arrow will appear at the bottom of the screen.
Go back to the main menu and navigate to /system/app/.
Drag the little arrow at the bottom of the screen. It will bring up the icon of the APK file.
Tap the APK file and it will be transferred to /system/app/.
Find the APK file in /system/app/. Press and hold it and a menu will appear.
Select Properties on the menu. The dialog properties will show up.
Tap Change and it will show the permissions dialog box.
Check the boxes for the following permissions in the dialog box:
User: Read and Write
Group: Read
Other: Read
Select OK once the required settings have been made.
Reboot your device.
I m afraid you cant do that in android oreo as google stopped support for that to draw over notification line till date. May be in future they might think to implement that too as many developers are protesting against that.
For more details visit links below:
https://www.androidauthority.com/android-o-draw-over-system-763178/
https://www.reddit.com/r/Android/comments/64ffk1/android_o_is_breaking_apps_that_overlay_on_top_of/

cordova : android 23 need "MODIFY_AUDIO_SETTINGS" permission at runtime

Im using WebRTC with cordova and I made the huge mistake of upgrading the version of android in the play store from 22 to 23. (apparently no way to revert this situation)
Now I must ask for the permissions at runtime. Everything is ok for now, but for WebRTC communication my app needs this particular permission "MODIFY_AUDIO_SETTINGS". For camera, microphone and location permissions I use cordova-diagnostic-plugin using those methods : requestCameraAuthorization, requestMicrophoneAuthorization and requestLocationAuthorization.
I tried requestRuntimePermission method with this as argument cordova.plugins.diagnostic.permission.MODIFY_AUDIO_SETTINGS but its not working since cordova.plugins.diagnostic.permission doesnt contain 'MODIFY_AUDIO_SETTINGS' permission. Here is the list of available permissions :
Im pretty much sur that the problem is the lack of 'MODIFY_AUDIO_SETTINGS' permission, since I had the same problem with android 22 (no audio) because I was not including it in the config. see this old SO post of mine
Thanks.
MODIFY_AUDIO_SETTINGS is not a "dangerous" permission that can be requested at run-time on Android: see here the full list of "dangerous" permissions which need to be requested at run-time.

Where to check for Android Permissions?

We are moving our app to SDK 23 and realize that we need to explicitly handle permissions in the code.
Instead of going through the entire code base, is there a best practice (or an IDE shortcut) that would help us determine all the places where we may need to use 'ContextCompat.checkSelfPermission' for each permission in the app?
If you are using Android Studio try this:
1- Click on Hector the Inspector (the small icon of a man with a moustache at the very bottom-right of Android Studio). This will show up an option to Configure inspections.
2- Type 'Permissions' into the searchbar, and ensure that "Constant and Resource Type Mismatches" is checked.
3- Run Analyse > Inspect Code.
You need to check for permission each time you use the functionnality who requires it, because you do not know witch path the user will follow in your app.
Remove all permissions node in Manifest, test your app and identify every time you get a permission denied error.
In Android studio 2.2 a new feature is implemented to make it easier to move your app to SDK 23. It is still work in progress howerver.
It is shown here. It adds an option to the refactor menu, which automatically implements the necessary permission checks.

Categories

Resources