IN SHORT: I need to get instance of PowerManagerService (in order to call its method isScreenBright). However I am unable to do it, after reading Android sources, the closest guess was to get it (via reflection) from android.os.ServiceManager by calling getService. The problem is the resulting class name is BinderProxy (the class name of the object which I get after actual invoke of getService), not PowerManagerService and I am stuck at this point. The types have to match in order to continue working with reflection invoking.
BACKGROUND STORY (safe to skip it): I try to read real brightness of the screen (not the one that should be set, but the real one). All top level brightness readers method return theoretical values (most likely -- from settings), so when phone lowers it automatically, those top level methods get the same result despite, the brightness changed. I figured out, I try isScreenBright method, it should tell me if phone is in normal brightness mode, or in power save mode (source code which sets this mode look promising anyway).
On Sat, Aug 4, 2012 at 3:40 PM, macias <pilichowski.mac...@gmail.com> wrote:
> Hello all,
> IN SHORT:
> I need to get instance of PowerManagerService (in order to call its method
> isScreenBright). However I am unable to do it, after reading Android
> sources, the closest guess was to get it (via reflection) from
> android.os.ServiceManager by calling getService. The problem is the
> resulting class name is BinderProxy (the class name of the object which I
> get after actual invoke of getService), not PowerManagerService and I am
> stuck at this point. The types have to match in order to continue working
> with reflection invoking.
> BACKGROUND STORY (safe to skip it):
> I try to read real brightness of the screen (not the one that should be set,
> but the real one). All top level brightness readers method return
> theoretical values (most likely -- from settings), so when phone lowers it
> automatically, those top level methods get the same result despite, the
> brightness changed. I figured out, I try isScreenBright method, it should
> tell me if phone is in normal brightness mode, or in power save mode (source
> code which sets this mode look promising anyway).
> Thank you in advance.
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
Bad news, but thank you. I wonder how it is possible, that (according to Android sources) what is added to services is PowerManagerService, but what is get is PowerManager (not service) -- when using "legal" methods such as getSystemService.
Anyway, quite easy task -- for learning Android -- as building custom screensaver turned out to be paramount problem :-(
PowerManager is the public API. Context.getSystemService() returns public
APIs.
PowerManagerService is private implementation. More than that, it is
private implementation that does not run in your process, so you can not
directly access in any way.
On Mon, Aug 6, 2012 at 12:20 PM, macias <pilichowski.mac...@gmail.com>wrote:
> Bad news, but thank you. I wonder how it is possible, that (according to
> Android sources) what is added to services is PowerManagerService, but what
> is get is PowerManager (not service) -- when using "legal" methods such as
> getSystemService.
> Anyway, quite easy task -- for learning Android -- as building custom
> screensaver turned out to be paramount problem :-(
> Cheers,
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails. All such
questions should be posted on public forums, where I and others can see and
answer them.