[HELP] Automatic Vibrate App based on light and G sensor - Windows Mobile Development and Hacking General

I should have asked this before starting work on my program but I should ask it before I work too long. Has someone made a program that monitors the light sensor and g sensor and based on that set vibrate?
I am working on a program for my Touch Pro that will do that following before setting vibrate but I could use some help. I am not too great of a programmer!
1) make sure it is dark
2) make sure the device hasn't been moved for x number of seconds
3) make sure device is plugged into AC power
I am making it in C# in Visual Studio
I have 1 and 2 nailed. I am having problems with number 3 though.
I can not get a reliable way to make sure the device is plugged in. Anyone know how to do it? I tried p/invoke GetSystemPowerStatusEx2 but that doesn't seem to work correctly, it still says AC when it is on battery and battery when it is on AC for quite some time after it is changed.
I am using a combination of that, whether the device is charging or not, and whether battery is at 100% (it seems the p/invoke switches to AC from battery when the battery reaches 100%) to determine if the program should poll the light and g sensors.
I would love a method which can tell me accurately if the device is plugged in or not and also has an event it can call so that I can enable/disable polling quickly and efficiently.
Another problem I am having is I need to make sure this program sets the device to unattended mode but only when it is in AC power. Is it possible for the device to come out of suspended and into unattended mode without the user turning the phone on first so that my program can run?
Thanks to anyone who can help.

Related

Toggle USB Charging

Hi All,
can anyone make a software to toggle usb charging? half the time my phone is connected to the usb for syncing but i dont want it to stuff up the battery since it charges it to full in about 3 hrs and i stay in office longer than that. would be good for the battery to be able to switch it off once in a while.
thank you
I know there's a reg key that can do what you said, depending on your device. I guess an app would be as simple as toggling that reg key. You can do it in mortscript or skschema.
But if you got a phone like Trinity that I own, then you are out of luck

help with battery power

Hello to you all,
My new XDA Exec has developed a fault. It works OK when plugged in to the USB on my laptop or charger but when running on battery will only do so for a short time. In fact a matter of a few minutes.
The battery indicator shows the battery at 100% when charged but the phone turns off variously at 95 - 98%. I tried a soft reset and not change.
I tried discharging the battery using small lamp then recharging in the phone. The battery indicator did show a lower %age 80 ish but not as low as I would have thought. Subsequent charging made no difference and the problem persists. Has anyone seen this before? Any bright suggestions?
Many thanks to you all for you time.
Cheers
Piran
Piran Bassett said:
Hello to you all,
My new XDA Exec has developed a fault. It works OK when plugged in to the USB on my laptop or charger but when running on battery will only do so for a short time. In fact a matter of a few minutes.
The battery indicator shows the battery at 100% when charged but the phone turns off variously at 95 - 98%. I tried a soft reset and not change.
I tried discharging the battery using small lamp then recharging in the phone. The battery indicator did show a lower %age 80 ish but not as low as I would have thought. Subsequent charging made no difference and the problem persists. Has anyone seen this before? Any bright suggestions?
Many thanks to you all for you time.
Cheers
Piran
Click to expand...
Click to collapse
You battery is dead therefore you would need to change. You are not unique with this problem. That is common issue for Universal (exec) batteries. For your new battery: dont charge with the USB cable and charge when is completely drained.
Hi Bulldog,
thanks for the reply and the info. Regarding charging the unit from the USB port. Does the unit not begin charging as soon as it's plugged in to a USB port? Is there a way to prevent this that you know of? My phone was normally charged for about half it's life from the charger, half from USB.
From what I understand the LI ion batteries don't have a charge memory due to milisecond pulse charging so pardon me for asking but what does the total discharge do for the battery? Obviously it does something but what? (Not doubting you but I'm curious). Is there a away to ressurect a defective battery such as the one I have currently or is it a lost cause. I know some batteries can improve with either heating or cooling by about 20 - 40°C from normal operating temeprature, have you any experience with this?
Do you know if some makes of batteries are better than others?
Please pardon the inquisition but as I spend a lot of time in remote areas it's often quite handy to be able to bodge rig stuff in order to effect a temporary fix and it seems any bits of knowledge help!
Once again many thanks
Piran
Piran Bassett said:
Hi Bulldog,
thanks for the reply and the info. Regarding charging the unit from the USB port. Does the unit not begin charging as soon as it's plugged in to a USB port? Is there a way to prevent this that you know of? My phone was normally charged for about half it's life from the charger, half from USB.
From what I understand the LI ion batteries don't have a charge memory due to milisecond pulse charging so pardon me for asking but what does the total discharge do for the battery? Obviously it does something but what? (Not doubting you but I'm curious). Is there a away to ressurect a defective battery such as the one I have currently or is it a lost cause. I know some batteries can improve with either heating or cooling by about 20 - 40°C from normal operating temeprature, have you any experience with this?
Do you know if some makes of batteries are better than others?
Please pardon the inquisition but as I spend a lot of time in remote areas it's often quite handy to be able to bodge rig stuff in order to effect a temporary fix and it seems any bits of knowledge help!
Once again many thanks
Piran
Click to expand...
Click to collapse
Hi, I have the exact same problem...works fine when usb or mains connected but only for a few minutes when on the battery. Usually when I give it some heavy task stuff it will suddenly just blank out the acreen and die.
I'm going to try and do what's suggested on the wiki page about masking off the charge indicator contact with tape - run the thing down and charge up again.
otherwise it's a new battery - not expensive - and plenty about on ebay.
fanger
Hi Piran,
Be Frank I am not battery specialist. Therefore I cant give a deep explanation what makes the Universal Battery having so many problems with USB charging. For my understanding it is the slow charge which leads to Battery overheat. Therefore All the post here regarding the Battery problems suggest not keeping the universal charged with USB. Just search for Post for "battery problems" and you will find few "explanations"
In Regards whether you could reverse your battery issue. From my previous experience I would say the max the you can get back is some 10-15%. However in your case the issue seams more severe as you device turns off by 90-100% therefore I think you would need to order new Battery.
following procedure I follow to drain my battery:
1) Turn off You Phone Radio (important)
2) disable the "Turn off Backlight" and put your device brightness to "full"
3) let your device drain the battery by him self( prevent doing anything with your device during this time. I found starting application, touching screen etc. leads that the device request a pick of power which the battery is not able to provide and turns the device off.
4) after certain time your battery will be to weak to keep the device on.
5) push the "power button + backlight button + reset pin" to put your device in to bootloader mode. (your screen will be almost off just some info like SERIAL or Bootloader Version will be visible)
6) again keep the device in this mode to drain as much you can until you cant see anything on the screen.
7) repeat this point6 few times as sometimes the device turns of but after trying again the button combination you can put it back to bootloader.
With above the aim is to drain the battery much as possible. After that you charge your device with power connection for min.12 hours. I guess you will gain few % however repeat the draining and charging procedure for next couple charging cycle to see how much max you will get back.
Good Luck.
I faced the same problem with my battery on Universal.
After a complete drain, the battery wont recharge:
1) Connecting the power cord it starts the boot process, after few seconds the power led ligths in red once, the screen blanks and the boot restarts again and again.
2) Using the usb cord the power led flashes in red without further actions.
I have to throw away the battery, I guess.
Thanks for any comment.
Cesare said:
I faced the same problem with my battery on Universal.
After a complete drain, the battery wont recharge:
1) Connecting the power cord it starts the boot process, after few seconds the power led ligths in red once, the screen blanks and the boot restarts again and again.
2) Using the usb cord the power led flashes in red without further actions.
I have to throw away the battery, I guess.
Thanks for any comment.
Click to expand...
Click to collapse
Cesare, One thing you could try before given up on your battery. Try to Use your power connection to charge for while before starting up your device.
How much is a new battery?
Bulldog said:
Cesare, One thing you could try before given up on your battery. Try to Use your power connection to charge for while before starting up your device.
Click to expand...
Click to collapse
Bulldog, many thanks for your replay.
When I connect the power cord the start up begins automatically.
There is a way to avoid the starting up?
Cesare said:
Bulldog, many thanks for your replay.
When I connect the power cord the start up begins automatically.
There is a way to avoid the starting up?
Click to expand...
Click to collapse
Cesare, you right when you plug in the device it will boot up. However after while (ca.10-15) when the first initialization complete you could go and switch off the screen(with power button) which takes allot power. Anyhow in your case it is really strange as your device behaves like it has no battery at all. there could be 2 things leading to that.
1) your battery is completely dead ( check with a voltmeter to confirm)
2) or something wrong with your Connection clips (battery and device) you could again check with a voltmeter whether you get any juice on those clips.
Bulldog said:
Cesare, you right when you plug in the device it will boot up. However after while (ca.10-15) when the first initialization complete you could go and switch off the screen(with power button) which takes allot power. Anyhow in your case it is really strange as your device behaves like it has no battery at all. there could be 2 things leading to that.
1) your battery is completely dead ( check with a voltmeter to confirm)
2) or something wrong with your Connection clips (battery and device) you could again check with a voltmeter whether you get any juice on those clips.
Click to expand...
Click to collapse
Hi Bulldog.
I think that the 1st one is the rigth hypothesis. I'll check with a voltmeter.
The connection clips are ok because the backup battery works perfectly.
To drain that battery I connected an optical usb mouse until the mouse ligth went off. Do you think that this action is the reason of the death?
Many thanks again
Cesare said:
Hi Bulldog.
I think that the 1st one is the rigth hypothesis. I'll check with a voltmeter.
The connection clips are ok because the backup battery works perfectly.
To drain that battery I connected an optical usb mouse until the mouse ligth went off. Do you think that this action is the reason of the death?
Many thanks again
Click to expand...
Click to collapse
Cesare, your battery my not complete dead but it is to weak to lighten up your Universal. Said that leads to bad thing which is: you can only start to charge battery when the universal has come out of bootloader mode.
I had such case ones, after not using my device for very long time the battery was completely drained, And as you described the device keep booting after plugging to the power. However after certain time ( I think some 15-30min trying) suddenly I was able to start up. I am not sure whether that would help to overcome the booting mode with less power but you could try to take out your sim card and memory card and try booting. ( again not sure it will help)
Guys - a quick update from my previous post.
I was suffering a sudden power outage at about 75%-85% battery power - just a blank screen - power gone. Didn't happen when mains connected, only on battery.
Well, first things first, I thought...dodgy ROM for WM 6 - so I tried a few of them - Ivans, Ranju's and Beastys - no change - still this power out.
Read the posts on this forum and thought - gotta be the battery's fried.
Sooo,
I ordered a new Genuine JasJar battery and installed it - (let it charge for 8 hours) - since then...no problems - no crashes, stalls or blank outs.
I'm running Ranju's 7.4 with spb pocket plus - htc home, etc,
As a point of interest my old battery stated 3.9Volts when I put my meter across it BUT - a voltmeter isn't drawing as much as the universal - when 'under load' from power intensive apps - hence you think you've got a battery putting out the requisite power when you haven't.
This was a real niggly problem to sort out with potential culprits all over the place:
Bad battery?
Bad ROM?
PCB crack?
Hardware Fault?
At the end of the day it's good to have spent £32 or so and simply got rid of the problem totally.
I'd say to anyone who's getting outs or blank outs at 80% power or below - your battery stuffed and no amount of mucking about with ROM swaps, Freezers, charging/ discharging is going to stop it blanking out on you.
I'd also like to say how appreciative I am of this forum with a great deal of knowledge available from so many users across a very broad spectrum of skills and experience. Nice one!
Hope this helps,
fanger

Battery Qustion???*

i just got the phone nad first charge i charged it whe ni got it and now its dead im charging it battery is very weak compared to nexus one i had.... but is it true that if u discharge it completley and then charge it completey and repeat 3-4 times battery gets good? i also heard over a little time that battery gets way better? any one can relate to this?
Sounds like you could benefit from re-calibrating your battery. It can be done manually through recovery by resetting battery stats, or easily through an app like this one (you must be rooted).
how u do it without rooted and i heard discharging 3 times and fully charging works? any update on that
There's lots of different "methods" floating around about how to calibrate your battery, many of which actually don't make much sense. The ones that do make sense to me involve deleting the batterystats.bin file. That app TeeJay3800 linked to pretty much does just that. For rooted devices, all the ClockworkMod recoveries have an option to delete battery stats in the Advanced menu.
I think this file is located somewhere in /data but I don't know off the top of my head. I also don't know if root is required to delete this file. Maybe try finding it with Terminal Emulator and attempt to delete it. If that doesnt work, then you'll probably have to root the device (or maybe just temproot it).
yea i did it yesturday nad today its still bad about to attept 3rd charge and im waiting till it dies it went from 39% to 19% within an hour wtf is this??? im waitign till ti dies then recharge to fully
i also did this wthich is good but will it mess anything up if the phone is brand new and is charging fine
Connect the phone to the charger with the phone powered on, and allow the phone to charge until the notification LED is green, indicating the device is fully charged.
Disconnect the phone from the charger, and power it off.
Reconnect the phone to the charger with the phone powered off, and allow the phone to charge until the notification LED is green.
Disconnect the phone from the charger and power it on.
Once the phone is powered completely on, power it off again and reconnect it to the charger until the notification LED is green.
Disconnect the phone, power it on, and use it. You need to use this sequence only once.
bigg12x said:
i also did this . . .
Connect the phone to the charger with the phone powered on, and allow the phone to charge until the notification LED is green, indicating the device is fully charged.
Disconnect the phone from the charger, and power it off.
Reconnect the phone to the charger with the phone powered off, and allow the phone to charge until the notification LED is green.
Disconnect the phone from the charger and power it on.
Once the phone is powered completely on, power it off again and reconnect it to the charger until the notification LED is green.
Disconnect the phone, power it on, and use it. You need to use this sequence only once.
Click to expand...
Click to collapse
This is "bump charging" and all it does is try to fill up your battery as much as possible. It's like topping off at the gas station. It won't do much as far as battery calibration. You may see a minor improvement in battery life after a bump charge, but you'll have to do it each time you charge.
Keep in mind that battery life is dependent on many factors, including your usage pattern. Improving battery life is a matter of being mindful and selective about what connections you leave open (bluetooth, GPS, WiFi, account sync) and what apps you let run. Screen usage plays a role as well. Network signal strength also plays a part, but that's not something you can control. Don't use taskillers, they cause more problems than they solve.
I'm assuming you're still on the stock ROM. If that's the case, you should be aware that there's lots of extra stuff on there that runs in the background to support the HTC Sense overlay. The biggest improvement in battery for me was (a) flashing a custom ROM without all that junk on it and (b) flashing a custom kernel which both underclocks the CPU and uses lower voltage settings.
If after all these considerations you still think your battery is borked, head over to a T-Mobile store. They may give just you a new one, otherwise it'll probably cost you not very much.

Charging led "broken" while phone phone is turned off

I have report on Jira the following issue.
The led in our OnePlus One doesn't lit when the phone is turned off and we try to charge it, it will affect most if not 100% OnePlus One user, the bug is reported by me using their official rom but happens almost in every rom I've tested(radio issue if you ask me).
Check it here: https://jira.cyanogenmod.org/browse/BACON-4187
The assigned person on this actually told me to stay quite about this and I'm like why??? and to be exact and not lying about it, he said: " I'm not going to advertise the issue (and I would rather you not either)". They want to hide this for some reason.
Some might say but why charge it while it's turned off? well if you are in a hurry every juice is needed, also why not have a "proper" phone? even Chinese no-name brands have this, it's basic function.
Please spread this and make an upvote so this would be solved asap(sure it's not life threating issue but surely I'd like to have it because why not?)
Can't say I have ever turned my phone off to charge it. Nor can I be bothered to even to test it.
I don't really see the issue, if you are turning it off to quick charge then you are in a rush and not fully charging it anyway.
Won;t the LED draw power and slow down charging *jk*
Just out of interest, does the power drain on startup of the phone not offset the tiny amount of power saved that the phone would be using when in deep sleep
indesisiv said:
Can't say I have ever turned my phone off to charge it. Nor can I be bothered to even to test it.
I don't really see the issue, if you are turning it off to quick charge then you are in a rush and not fully charging it anyway.
Won;t the LED draw power and slow down charging *jk*
Just out of interest, does the power drain on startup of the phone not offset the tiny amount of power saved that the phone would be using when in deep sleep
Click to expand...
Click to collapse
If you plug the cable how would you know it's actually charging? ..to verify you need to press the power button once to check the battery level in the screen. People don't mind have problematic devices fine by me they deserve this
Me on the other hand? why not fix this, even if I rarely use it ..it's not rocket science and it was working when I got the device in the first place
P.S. "Just out of interest, does the power drain on startup of the phone not offset the tiny amount of power saved that the phone would be using when in deep sleep" Lets say you have 30 minutes to spend and you need to leave ASAP, turning off the phone will charge more than having the phone turned on in "deep sleep" ..phone still uses energy and some apps do run in the backround that you probably forget to close(we're only humans)

s4 power cycle diagnosing/logging

Greetings,
I have an extra S4 mainboard laying around so I decided to use it to turn one of my non-smart TVs to a motion controlled TV (Will use front and back cameras together for 3D triangulation and IR blaster for manipulating the TV). Anyway I bought one 5V to 3.7V step down board ([ aliexpress ]/item/18650-lithium-battery-protection-board-3-7v-3-6V-4-2V-lithium-battery-charging-board-1A/32804861065.html) and connected it instead of the battery and everything worked fine for a while. Then the phone entered into a boot loop. After wiping cache partition in safe mode it has turned on properly only to start looping in 30secs.
So I want to diagnose what the problem is, I have checked the logs in the safe mode but they were all huge and did not know where to look at.
In this regard I have couple of questions:
1) Does this sound like a temperature problem or power management problem? How to distinguish them other than feeling around ICs with my finger (and no they were not extremely hot)? Or how to determine the cause for the arbitrary looking power cycles.
2) How can I transfer logs to my PC, even though it power cycles. Fortunately USB debugging is enabled
3) How can I detect power cycle related entries in the logs? If I share can you guys help me?
4) S4 battery has 4 contact points 1st being V+ and 3rd being GND. I thought others were `Not Connect`, was I right?
5) Assuming I can sort this problem out, is there a way to make phone turn on as soon as I feed power through battery connectors (without pushing the on button, I can add a capacitor and connect incoming power to switch by soldering but I would prefer a SW solution if possible.).
I do not believe the problem has to do with the step down board as I have measured its output as 3.9V and it has a current limiter in it.
I would extremely appreciate any input/help/comment, thank you all

Categories

Resources