WRITE_SETTINGS permission Android - java

I am making a flash light app. So naturally most devices now a days have a built in flash for the camera but when a flash is not present I want to use the screen as the flash light. To make this functionality work I want to adjust the screen brightness so it can act as the flashlight.
To change the brightness I used code from this post. The code works fine and I can change the brightness without issue. As a side note this code I used works on Physical android 8.1, 10 and 11 devices.
My first question comes from a lint warning I get when adding the <uses-permission android:name="android.permission.WRITE_SETTINGS"/> permission. The warning says
"Permission is only granted to system apps". Now I can obviously just suppress this warning, but my worry is when I upload the app to the app store Google will either reject the AAB or the app will no longer be a "System app" once its downloaded from the app store. Will suppressing the error do anything?
My second question is is this a false positive? Looking at the manifest permission docs WRITE_SETTINGS has no special permission besides for having to get the users consent buuuut WRITE_SECURE_SETTINGS definitely does. As per the docs for WRITE_SECURE_SETTINGS "Allows an application to read or write the secure system settings. Not for use by third-party applications." So could this be lint thinking WRITE_SETTINGS is WRITE_SECURE_SETTINGS?

Related

"Display over other apps"

I'm not a regular Android user, but I'm building an Android app and the latest versions of Android now show a pop up when you first install & run an app saying "Display over other apps" with a toggle for several built-in apps and my apps.
I've been googling for a while and haven't been able to find any information as to these basic questions:
What is this?
Does my app need to display over other apps?
If not, can I disable this pop up from coming up?
Any links to documentation would be great.
This happens because your application asks for SYSTEM_ALERT_WINDOW permission! If your app doesn't need it, you can remove following line from your Manifest.xml file:
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
your device OS is above the android veriosn 6.0 and sometimes devices gives as that pop-up when you will ask for permission. You can check this link https://screenoverlaydetected.com/draw-over-other-apps/
better option is format your device as it will show in every apps.

Unable to add window -- permission denied when trying to create floating view

I am currently looking to develop an interface debug tool for Android which would display some system information overlaid on top of whatever app is running underneath. I've look at many different resources online and followed the basic procedure of setting my application to TYPE_APPLICATION_OVERLAY defining the permissions required in my manifest with android.permission.SYSTEM_ALERT_WINDOW, however, when trying to run the application the process, it crashes with the error FATAL EXCEPTION ... Unable to add window android.view.ViewRootImpl$W... -- permission denied for window type 2038.
I tried further investigating what could be causing the problem, and I managed to find out that since a certain version, Android will require for users to explicitly set permissions for apps to draw over other apps via Settings.ACTION_MANAGE_OVERLAY_PERMISSION, however, even after enabling permissions to draw over other apps, the process still resulted in the same error.
I currently have my app setup to check whether draw-over permissions have been granted, and asks the user to set it if not. Once it confirms permissions are enabled by the user, it calls the service where I attempt to create an overlaying view.
I'm relatively new to Android development so I would appreciate any ideas or guidance!
Update: Managed to get it working by setting the window's LayoutParam to use TYPE_PHONE instead of TYPE_APPLICATION_OVERLAY. This is working for Android N, however it may be good to note that this method is deprecated for Android O+
Add this permission in your manifest.
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

Android java set app permissions dynamically

Is it possible to set android app permission dynamically in java, usually it is set in AndroidManifest.xml. But what I want to do is giving my users a choice of what permissions they want my app to give.
thanks in advance!
No, it is not currently possible. Up through Android Lollipop, permissions must be explicitly requested in the app's manifest and must be collectively all granted or denied (not installing the app) by the user at install time.
Android M, however, is changing this. As of Android M, permissions will be granted at runtime instead of at install time, allowing you to give users more control over which permissions they allow your app to use.
See the Android M runtime permissions documentation for more detail.
At the moment it's not possible http://developer.android.com/guide/topics/security/permissions.html
Android has no mechanism for granting permissions dynamically (at run-time) because it complicates the user experience to the detriment of security.
Things may change in new android M release
Nope. App's permissions are declared in AndroidManifest.xml, which is used to tell Android system what permissions are required. App installer will show all permissions to help user judge the app is good or bad.
Thing about that if an malicious app require nothing at install-time and require camera permission at run-time dynamically
It would be against Android policy . The application has or not has the permissions for doing something . It can be a security problem if you can think of it.
It is possible no issue but in mid of app if not get then chances of getting crash in your app...

Android TV app runs on mobile

I want to create app that targets only Android TV. I use this in my manifest
<uses-feature android:name="android.software.leanback"
android:required="true" />
considering on developers.android it says:
If you set the required attribute value to true, your app will run only on devices that use the Leanback UI.
But i can run my app on any device(tablet, phone or TV). Am i doing something wrong? I also added activity with android.intent.category.LEANBACK_LAUNCHER.
Does this only happen in debug mode? And if so, does this allows me to test my TV app on devices like Android mini pc or Kindle Fire?
I found that by setting as you did, it limits the device compatibility on Google Play. But you can still test on other devices using adb (it works OK with 7 and 10 inch tablets, but the UI is too big for my Nexus 4). However, you can only launch through adb. The icon will not show up on non-Android TV devices even though it is installed.
Am i doing something wrong?
Not that I can see.
Does this only happen in debug mode?
It happens when you are not distributing through a distribution channel like the Play Store. Quoting the docs for <uses-feature>:
The purpose of a declaration is to inform any external entity of the set of hardware and software features on which your application depends.
Here, "external entity" primarily is a distribution channel, though in principle it could be anything else that has access to the APK and chooses to examine it.

Modifying installed apps permissions (Android)

I want to develop an application for android to:
List installed applications in the phone.
Show a list of permissions that are granted for each app.
Have the ability to disable any permission granted to a specific app or enable it later on.
Till now I have done the first two points. I searched the web to know how to modify permissions but I couldn't find anything useful.
So can anybody give me a clue on how to implement this ? Because I think it is doable since there some apps that can modify permissions (e.g. Permission Manager).
There are various apps in the Play Store that call themselves Permission Manager so I'm not sure which one you have looked at.
At least one of them works by pulling the installed app apart, and reforming it with a changed AndroidManifest file (and since they don't have access to the original private key, a new signature). To run the reformed app you have to uninstall the old one, and install the new one, which has 2 significant downsides
all the data of the old app is lost
since you now have an effective pirate version of the app, the app will no longer update with new versions from the Play Store.
Other apps that claim to manage app permissions simply expose the hidden App Ops permission screen in Android 4.3, and Google removed this from the later Android 4.4 update.

Categories