Can I control the android device screen on in the PowerManagerService.java? - android

I have a question on the control of android device's screen on.
What I want to implement on android framework is that:
depend on specific application, I can control the screen to be on or not.
That is to say, if I don't want some application, let's say the AngerBirds, to make the
screen from state off to on, can I do it?
From the source code of PowerManagerService.java:
I found there is one line of code:
`policy.screenTurningOn(mScreenOnListener);`
so, is this the code to turn on the screen?
Then if I add some condition here, such as, if the current command of turnning on the screen is from
the application AngryBird, then I just ignore, and make the screen keep state off.
is this possible?
If possible, then can I get the Application context and the reason of turnning on the screen?

Related

How to mirror android screen/app to a screen programatically?

I am developing an android application and I'm trying to implement a button which initiates a screen mirror to a selected device.
I want it to be as straigth forward as possible, but the best i've been able to do is have it open the cast settings on the Settings app, which isn't a proper solution. It would be ideal to start screen mirroring with a single click.
Problem is i've tried using Googles Cast SDK but that only allows me to build custom HTML cast receivers, which isn't what I want, I just need a screen mirror from the android device to a screen/TV.
Is there any Android module/API that would allow me to do this with a single click, even if I have to use a Chromecast/Miracast device connected to the screen?
No, sorry, this is not an option AFAIK.
At least part of this is privacy/security. You seem to want to be able to start screen mirroring purely from app code ("I'm trying to implement a button", "allow me to do this with a single click"). Your button is the "single click", and so you really want to be able to do this without user involvement at all (since there is nothing forcing that button to exist). Showing the contents of the screen on another screen that might be visible to lots of people is the sort of thing that users need to approve, which is why additional clicks will be required.
In addition, there may be more than one target for screen mirroring within range, and the user needs to be able to choose which one to use, if any.
Combine all that with limited support for wireless displays across the various Android device manufacturers, and there really isn't anything here for what you want.

How do parental control apps lock the screen?

I am developing an app that locks the screen for some time, just like parental control apps do when the screen time runs out. However, I do not really know how they work. I suppose they don't use lockNow because there is that message that shows up telling you that the time has run out. I also don't think they use overlays, because the phone is supposed to detect the use of overlays. So does anybody know what kind of function is used? Also for my app I want to add a button that ends the screen lock, so I am looking for a suitable way to achieve that.

Check if Android is presenting its screen

Does anybody know if there is a generic way to check if the screen is currently being presented, e.g. via Miracast, Chromecast or any other app?
My app runs in the background and shows notifications every now and then. I'd like to avoid that while the screen is visible to others.

Implementing a Lock Screen widget on the Home Screen - Android?

So, a few users have been asking me if I could make a home screen widget that launches my app..
Due to sensitive content, I've made a simple "Enter the password" splash screen. If the pin is correct the user gets access..
I've been getting complaints that it's a little slow and annoying to enter that every single time.
Majority of the requests I'm getting are relating to accessing the app quickly from the home screen itself. Using the simple shortcut icon is literally the same thing, since it will again open up the password screen..so I need something different.
So I need to open the app from the home screen, using a widget. I need the opening process to be say under 3 seconds or so... and I need to confirm the identity of the user.
What I'm thinking is a Lock Screen, or Pin screen widget.
Is there a way to replicate the Android Lock Screen inside a widget ? ... Remember, I need it on the home screen...
I think a 3X3 grid widget should do....
But there's absolutely no mention anywhere on how to do this... Is it possible? If so, how?
I want exact same functionality, the user can say, set a lock screen combination inside the app, disable the pin entering splash screen, put up the widget - and open the app from there.
Again, there's no mention anywhere of anything relating to this.
So, Any ideas on where I can get more help? Or how I might go about accomplishing this ?

Android non-root lock replacement

Let me begin by saying that, yes, I know that the stock Android lock screen can not be programatically replaced without rooting.
Now that that's over with, I want to make an app that contains a custom 'lock' mechanism. There are apps out there that emulate this functionality, namely LockGo. This allows a user to view information from widgets on a 'lock screen' and emulates the slide-to-unlock functionality (or whack-a-mole if the user wants to install that plugin).
Does anyone know what mechanism or Android API functionality they may have used to do this? Is it as simple as hooking into the power button to launch an activity, such as in the link below?
How to hook into the Power button in Android?
Any insight to this would be appreciated.
I've found out while researching this that, while there is currently no way to replace the stock security or keyguard lock (which I knew), it is possible to show an Activity on top of the lock using the following code in the setup for that Activity:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
This can be used with any logic needed to create a faux lock to show screens on top of the system lock(s), though the lock will still be in tact and the user will need to enter the lock to get into the device.

Categories

Resources