There are a few apps (battery widgets and the like) that estimate time remaining before the battery runs out. I'd guess they take current battery level and try to work out current drain based on processor usage, backlight level etc. In my experience they aren't too accurate but in principle if you get the algorithm right it should be possible.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…