yashsingh1/xdaforums huggingface dataset:
[Android Apps and Games] chamonix:
GPS enable by program

@nobnut

I took your query for enabling/disabling GPS settings as a pretext to look into the security model and here is what I found:

- to enable GPS by program that program needs the perms android.permission.WRITE_SECURE_SETTINGS (I wrote a Tasker plugin to see if I would be granted those rights but it was a NO)

- those perms are only granted to apps signed with the same keys as the system

There used to be a workaround to that using an unsecure intent of the settings widget but that exploit has been closed: http://xdaforums.com/showthread.php?t=697465

Here is some good reading material about perms and the security model: http://www.krvarma.com/2010/10/security-permissions-in-android/
[Android Apps and Games] azj:
Long term results since yesterday with new tasks: Phone was mostly off & off the charger during the evening, off & on the charger during the night and off & off the charger this morning.

I now have new files:

- batteryinfo: 5500 lines, I know not to worry about this as it should be deleted.

- DeepSleepDetective:

-------------DSD-------------
UPT || 16:49:00 || 0%
DSP || 00:0-795:00 || 0%
-------------DSD-------------

REPORT START
-------------------------
Wed Jul 20 09:06:55 MST 2011

up time: 16:49:38, idle time: 08:52:42, sleep time: 00:00:03

Wakelock Holders
-------------------------
system_server

Historic Wakelock Holders
-------------------------
name expire_count wake_count
"cpcap-irq" 0 135
"wifi_wake" 0 885
"alarm" 0 265
"alarm_rtc" 129 0
"pwrkey" 57 0
"deleted_wake_locks" 883 0
"mmc_delayed_work" 0 92
"bpwake" 1380 50
"omap_serial" 1379 0
"wifi_rx_wake" 8741 0

Active Applications
-------------------------
com.nuance.flext9.input
com.google.process.gapps
net.dinglisch.android.tasker
com.handcent.nextsms
bt.android.elixir
com.google.android.apps.maps:NetworkLocationService
com.mhuang.overclocking
com.google.android.music
com.android.bluetooth
com.fsck.k9
com.aws.android.elite
com.lookout
com.androidlost
com.google.android.apps.gesturesearch
de.elmicha.app.LocaleExecute
com.noshufou.android.su
com.aws.android.locator
com.android.launcher
net.dinglisch.android.ipack.glossysilverhd
android.process.acore

Wakelock Information
-------------------------
-------------
Total partial waklock time: 8d 7h 59m 29s 397ms

Battery Consumption
-------------------------

END OF REPORT
-------------------------

- didtis: null

- dsdwake: pid=1099

Not changed since yesterday (I know I rebooted several times after the time on these files):

- DSD-Bootlog:

.---------------------
---------------------
Date | 7-19-2011 |
Time | 13.06 |
DS against total uptime | 0% |
DS against total DSP time | 0% |
Total Display off time | 144 minutes |
---------------------
---------------------

- DSD Shutdown:

13.57
77191
100
7-19-2011

Not changed since installation on Monday:

- errorlog: null

There are three zip files in the Reports folder from yesterday and one from this morning.

time_in_state:

800000 373263

700000 10903

600000 19465

550000 5721

500000 3160872

250000 412147

125000 0

up time: 17:13:17, idle time: 09:12:00, sleep time: 00:00:02

DSDAdhoc still returns 0% on both lines.
[Android Apps and Games] nobnut:
Thank you Chamonix, I came to a similar conclusion. I will read up on the material.

Regarding your app, shall I post feedback on your blog, or should I send you a pm? I think it's great but 'network usage' appears to be missing some data.

Excellent work though!

Sent from my Motorola StarTac using Voodoo
[Android Apps and Games] bgx:
@azj I have the zero problem sometimes too! Nothing changes after last fix! :-(
[Android Apps and Games] brandall:
Back from an impromptu power-nap!! Morning!

DAMN IT!!! :mad: That was looking so promising... For me, those files only populate with the media process ID when the media player is in use... They even stop perfectly at the end of a track if another one isn't queued up... Need to go hunting for where the equivalent files on the SGSII....

In action #15 of DSDDO & DSDAdhoc there is a wait time, currently set to 150 milliseconds. Can you try increasing that to 500 please - and then another reboot! I'm knocking up an errorlog that you can press a button for and it emails me everything I need...

Thanks for the info azj - My advice for you is to change kernel - I think your issue goes deeper than a rouge process. Is there another kernel you can try with the stock ROM you are running? Looking at the data you've posted and the scaling frequency and governor information, something is badly wrong. Let me know your thoughts on this.
[Android Apps and Games] brandall:
@chamonix been testing out your app - it's excellent. No issues to report. It displays data how I want DSD to... What are your plans for it? Are you just going to release it on XDA or is it heading to the market?
[Android Apps and Games] nobnut:
What can I say? Samsung are a bunch of ***** ** **** ** ****** ****s.

Maybe, rather than trying to make DSD be all things to all devices, you should provide a derivative solution? 'If it works on your device, it works. If it doesn't...'.

For an OS, Android has just too many permutations and combinations. An inherent problem associated with an open source OS.

EDIT: After all Google's Ice Cream Sandwich will surely bugger things up, then we will get Beetroot Sorbet, after that Manjuice Souffle. Each Android successor will present one more reason to want to kill dead things when trying to develop for 'all devices'.
[Android Apps and Games] nobnut:
I vote Market. Paid app.
[Android Apps and Games] brandall:
I won't be able to sleep (apart from earlier) until I have solved it... It's in my nature... I know the solution is out there somewhere....

+1
[Android Apps and Games] nobnut:
I hear you brother.

+€1

But I'd like to think that there is possibly some scope for future joint development between both Brandall and Chamonix. Or at least I hope so.
[Android Apps and Games] bgx:
OK changed it and report later when I'm at home; left now work! ;)
[Android Apps and Games] nobnut:
I'm going to bed, I'm not feeling right.

Come on team! Stay motivated! ;)
[Android Apps and Games] brandall:
Fingers crossed!

LOL! I installed a 'testing wake-up alarm' in V10 - so if you hear a siren, you're needed! :eek:

EDIT: Thanks again for your help today
[Android Apps and Games] nobnut:
That's what I liked about you. You do nothing by halves. Most folk would have used a mild vibrate or a gentle beep... you use a bloody great siren!

Hooligan ;)

I'll send the bomb squad.

G'night.

Sent from my HTC Flyer using vodka
[Android Apps and Games] brandall:
:) Laters

Please report for duty at 9am. I will not be here, but that is not the point :eek:
[Android Apps and Games] azj:
I haven't the foggiest on different kernels for the stock ROM. however, since the chances of Motorola/Verizon issuing any more updates are between slim and none I've been toying with the idea of changing my Droid over to CM7. I picked CM7 since I'm running that on the SD card in my Nook color. I'm waiting for the official 7.1 release, which should be fairly soon, before I flash the Nook with that. That might be a good time to do my Droid as well. Thoughts?
[Android Apps and Games] chamonix:
As it suits you, I'm happy about all the feedback I can get. You could also use the "issues" section on github: https://github.com/asksven/BetterBatteryStats

I noticed the lack of volume in networking too this morning but didn't have time to look closer.

Thanks for taking the time!
[Android Apps and Games] chamonix:
Thank you very much for taking the time to have a look and for the feedback.

Well I haven't planned anything yet about releasing but as it's going to stay free I guess I'll make an attempt on Market. If someone looks a little closer and finds out the usage of a non-public API it may no pass though ;)
[Android Apps and Games] chamonix:
If you need some code reading files and displaying it like that just tell me.
[Android Apps and Games] chamonix:
:) sometimes I'm tempted at least to recover the 25$ entry fee google takes for market. Who knows, I may even be able to retire some day and :D
[Android Apps and Games] brandall:
Is it an Eris you have? As far as flashing different ROMs goes, there's little danger in trying them all out! As long as you have a nandroid back-up and you follow the thread closely, you should have no issues - You return to you current ROM by restoring at any moment... Being rooted and running stock is such a waste! There is of course the alternative of a full wipe to see if that resets the behaviour...

Looking at some of the stuff on the app market, I don't think they look too closely! Can you explain what you mean by a non-public API though please...?

You're a gent, thank you - I may well call on you at some point for that...

I think you'd make a few $'s from it! 500,000 new android activations per day... The odds are pretty good! I hope anyway...:eek:

EDIT: I've run out of 'thanks' again chamonix - but will +1 tomorrow!
[Android Apps and Games] azj:
The original Motorola Droid. What thread do I follow? Start by installing Clockworkmod ROM Manager? I can't find Nandroid in the Market. I did do a factory reset not too long ago. So many questions....
[Android Apps and Games] brandall:
I assume this is your device forum ? If so, there's a sticky thread right near the top about nandroid etc.

Is that the right forum?
[Android Apps and Games] azj:
No, that's for the Milestone. I have the Droid which should be here. I'll have to take a look through there.
[Android Apps and Games] pulser_g2:
If it is of interest, my rom for SGS2 is signed with a custom platform key. While I obviously don't distribute it, I will happily sign things for anyone provided it is simply enough that I can see what it does via disassembly (ie. Listens for intent, then does the gps thing) or if they let me see the source if more complex (doesn't need to be open sourced and gets deleted once I've skimmed it for safety)

Dunno if that's of any use given it's totally rom specific.
[Android Apps and Games] nobnut:
Pulser,

Have you seen Chamonix's app? Interesting, filling the gap left by Spare Parts on GB.
[Android Apps and Games] pulser_g2:
No, but I have now... :)

Looks amazing. Are we ok to recommend it to people with poor battery life? This could really help the people with a rogue app get sorted out
[Android Apps and Games] nobnut:
Reading the above, I am not sure at what stage Chamonix is with development. He is talking about a possible Market release (I think he should charge).

I guess he is at the Beta testing phase... he posted it in an open forum...

I think there might be one or two things he is still tweaking right now however...

I am using it alongside Deep Sleep Detective, both for uses sake and also 'testing'.
[Android Apps and Games] nobnut:
I left a small 'issue' on github regarding 'Network Usage' reporting. I hope it helps :)
[Android Apps and Games] nobnut:
I reported here earlier than instructed and thought as you weren't here that I'd make myself useful, so I have been testing v13a. It's working well :p

I've finished that now so will just do some press ups and burpees until you have something else for me. I've got to stay in shape!
[Android Apps and Games] bgx:
Good morning brandall & nobnut ;-)!

Till now the 500ms fix seemed to work. Still testing and report if I had any issues!

Now time to go for a run... ;-)
[Android Apps and Games] nobnut:
Good plan! I'd suggest some sprint work as well as some stamina elements thrown in for good measure.

Don't forget that diet is an important element in every tester's routine. I highly recommend burgers, pizza, or curry. Alcohol (excessive quantities) helps too.

Now GO, GO, GO!!!
[Android Apps and Games] bgx:
Yeah nobnut I know the need for burgers, pizza, alkohol ... smoking I have quit now for 1 year! Good 6 also a good thing to get your head free ... ;-) Had also do a lot of programming but with websites and php and so, not android... here I'm somthing at the moment like a script kiddy ;-) *lol*

So after my run with runtastic, and the musicplayer in the background I get "Time in State Error!"!

First now I take a shower and the to work. Ask I will answer later when I'm at work ...

EDIT:

Now @work: After the Error no problems at the moment! Flashed in the meantime 2 new things with reboot!

If I get an Error again I will let you know! ;-)
[Android Apps and Games] nobnut:
That's good to hear. I don't know what's happened to brandall. I think he might have gone out of his mind on drink and drugs and has gone on a rampage around town with his underpants on his head.
[Android Apps and Games] CekMTL:
That is utterly hilarious, xD

Enviado desde mi GT-I9100 usando Tapatalk
[Android Apps and Games] brandall:
Morning! Thanks for holding the fort Nobut :) Had some real life things to do... stupid real life...

Ok, so, I have another couple of updates to upload shortly - just need to delete the old version and then import the new ones.

@bgx / everyone - Glad the 500 milliseconds is working (most of the time) for you. Your issue simply is that your device isn't returning the time in state data / sleep data from the toolbox uptime command quick enough. It checks/loops 5 times, each time with a 0.5 second wait between, so collectively, 2.5 seconds may still not be sufficient. Perhaps increase it again to 700ms so hopefully 3.5 seconds (total) is enough for the data to be passed every time.

I have a few emails and PMs from users who can't post here due to less than 10 posts - so I'll be back shortly!

Oh, also need to shoot up first too... :eek:
[Android Apps and Games] nobnut:
Lovely. Can I stop doing press ups and burpees now?
[Android Apps and Games] brandall:
Well, better out than in so they say.... :eek:
[Android Apps and Games] bgx:
Ok brandall, have increase it to 700ms and look what it did... ;-)
[Android Apps and Games] chamonix:
In the Android SDK there are many "public" classes that you can use as a developer plus a certain number of classes that you are not supposed to use as a developer. Not supposed to use also means that there is no process in place to keep that API stable (or even present) from one version to another.

Now how do the do that?

Quite simple: when you install the SDK you build (compile) your code against "android.jar". Now that android.jar is not the one that runs on the phone but was stripped down to remove all the non-public stuff.

Android code (e.g. Settings) make extensive use of the internal API and those apps can not be built with Eclipse but need to be build with the toolset coming with the source tree.

That would be the first way of using the non-public API as your code access the "right" android.jar at compile-time but using the toolset of the source tree is like using vi as an environment to code as opposed to a plain IDE... nothing for me.

The second way to proceed would be to write stubs for the non-public API (basically empty classes) so that the compiler is happy but remove those stubs from the APK. To do this you have to tweak a few makefiles. That makes code quite simple but the big drawback is the code crashes when something in that API changes and your stubs are not up-to-date. I don't encourage this technique.

And finally there is a really nice construct in Java called reflection. With reflection you can make Java calls using building blocks (parameters) like the class you want to call, the method, the parameters etc. With reflection Java will decide what to do at runtime (as opposed to compile time). Obvisouly you have to spend some effort in making all that safe and resistant against unforseen situations.

I've chosen that method and AndroidCommon contains a proxy to the non-public class IBatteryStats/BatteryStats/BatteryStatsImpl plus some helper code to handle data structures. It's a little more work than the method with the stubs but the advantages are that the error handling is more robust and the proxy plus helper classes can add a certain degree of abstraction that I like to have.
[Android Apps and Games] chamonix:
I'd like to give this a try our of curiosity and for personal use: as nobnut stated in another post on this matter too many apps request fine grained location and obtain it when the GPS settings are on (e.g. Maps). For most apps I don't want to pay the (battery) price for that except for the one app I run when I jog. A tasker profile combining the activation of the GPS and the call to the app's main intent would make me happy (I'm of course a VillainROM user).

I'll polish the plugin when I have some spare time and submit it to you with sources for review. If you feel it's OK I'd be happy to have it signed for my private usage. Beyond that point I leave it up to you to decide if other users may be interested in such a functionality. It is obvious that such a tool will be considered being a security breach as it would offer a hidden possibility for any app to collect fine grained location data... this aspect is not to neglect and the reason why things are built the way they are.
[Android Apps and Games] chamonix:
It is correct the app is in beta and I will be adding some more functionality. Right now I'm looking into the network stats that may be inaccurate but besides that I'm rather thinking of improvements not fixes.

If you feel that the app helps I would be more than happy to see it recommended. I plan a Market release and the app will probably be available for a small amount (granted it passes the QA).

But I would like to provide it for free for xda-dev members as a tool (I believe SetCPU is doing the same) so I guess I'll will start a thread for the app to collect feedback and ideas for new functions. I guess that being is in place is the right structure for pointers.

Feedback is welcome but I believe we should take that conversation to PM.
[Android Apps and Games] pulser_g2:
Cool. If you add a line that checks for your imei and closes if not valid for then I won't even need to look too hard at it whatsoever :)

You are right though that platform keys need to be looked after.

If you fancy testing I can send you a couple of scripts to let you resign the ROM with your own keys :)

That's possibly a better idea, as a malware author could easily abuse a legitimate app like this in order to control gps...
[Android Apps and Games] chamonix:
I agree and I am always happy learning something new so I'd be happy if you could give send me those scripts
[Android Apps and Games] azj:
I wonder if keying off the imei is a wise thing. Doesn't that only apply to phones? What if the user has a tablet instead?
[Android Apps and Games] pulser_g2:
You are right but app would just be for him on his SGS2... So it would be fine as the app shouldn't be on any other device :) and if it was it doesn't matter if it FC's :)
[Android Apps and Games] pulser_g2:
Will send you them tomorrow and a mini guide, as they are pulled out my build system :)
[Android Apps and Games] tommo123:
kinda OT, but not.

so chamonix has a way of allowing tasker to control gps for specific apps like in ye olde days?

i have my phone under control (mostly) when it comes to my phone waking now, but would love to get this ability back in taskers dirty little hands
[Android Apps and Games] nobnut:
Unfortunately not. This still isn't possible on Android 2.3+.

Tasker can get your location but not toggle GPS on and off.
[Android Apps and Games] brandall:
Thanks for the explanation chamonix :) I may not have understood it all, but what is crystal clear is you certainly know your sh*t! I aspire to have the same knowledge.

I may not be around much over the next couple of days much, but V11 will be up when I return, with more reporting tools, that are more user-friendly in their format and a complete restructure to avoid some of the 0% issues that are being reported. Ad hoc error logging too, so I don't keep having to ask users to do this and that and the other to diagnose a problem - A script will run that does it all and populates an email...

That should keep me busy!
[Android Apps and Games] chamonix:
No I don't know of any other way than using the permissions model. That means that an app can do that when being granted specific rights that are reserved for apps signed with the same keys as the system was signed with.
[Android Apps and Games] nobnut:
Have a good weekend. Thanks for your work.
[Android Apps and Games] tommo123:
aww, thanks though guys :)
[Android Apps and Games] bgx:
Hi brandall had the zero issue in the meantime once again! Nice if you have solved with v11 ;-)

Another question, I had a prevent deep sleep notification and how you see on my screenshots the battery went down and the phone was awake, but in the logs I can't find what's this issue triggered!

Perhabs you can help me to read the log?

EDIT: Have fixed the permissions of the photos!
[Android Apps and Games] brandall:
Can't view the images - have you put them somewhere 'private' ? Working on the zero issue :)

You too, although I'm sure I shall disturb you at some point :eek:
[Android Apps and Games] brandall:
Media Context/Issue/Annoyance/B*STARD!

Hi folks, your collective thoughts and bright ideas would be helpful...

Currently, not being able to record a start/stop time for the media playing unless the device is turned off whilst the application is in the foreground, is a big problem for me. Despite the ultimate goal of catching rouge wakelocks, the detective work and reporting of sleep time against DSP and Uptime is a major part of the 'app' and probably adds to its appeal as well as making it a longer time 'monitoring app' rather than an intermittent problem solving one.

So, I really have Google'd the arse-hole out of this and have drawn a blank when it comes down to the tools that are available to Tasker and its plugins. A solution that works for me, I'll post below, but unfortunately, it didn't work for the chief inhouse tester nobut...

In the terminal:

fuser /dev/msm*

returns the PID of the media server when media starts. If I switch the display off and let the track finish, the PID is no longer detailed - so for me, perfect... The exact file is

/dev/msm_pcm_out

To identify your media server PID:

ps | grep 'mediaserver'

If the above worked for everyone, I could extract the unique (device to device (ROM to ROM?)) PID on set-up and then populate the script to periodically search/loop the file looking for the associated PID.

It was suggested that other files

/dev/snd* or /dev/dsp*

could contain this information instead, but alas, nobut confirmed it was not the case for the SGSII...

If anyone could confirm if the above works for them it would be appreciated, so I can get an idea as to if I'm dealing with a device/ROM in isolation. Thanks in advance.

Also, if anyone else has any bright ideas for a command to track where the PID is active, that would be a great help - I've drawn a blank on that too :mad:

Finally, if anyone else has any other suggestions that are within the limitations of Tasker and shell I have wide open ears and a thanks meter with 3 remaining in the next 24 hours!

muchas gracias in advancios :eek:

Credit : Matthieu Berthomé for his Google post
[Android Apps and Games] bgx:
This is a thing I also had headache about... Couldn't find a solution for this problem so far. If I find something I let you know!

@brandall have fixed the permissions of my previous post!
[Android Apps and Games] nobnut:
I know it's not something you want to hear, but I still don't see the relevance of 'excluding' results when media is using system resources. In my (small) mind it is possible to have no media actually playing but for a media related app to be causing wake 'without permission'.

It is the latter which is key. If a user starts a process intentionally, then they know it will cause wake - no grounds for complaint therefore. There are some media related apps however which may start a sneaky beaky service in the background without 'permission'. It is these that may cause wake and therefore battery drain which the user may not know about but may want to know about.