 My name is Mike. I'm from the Android Wear Frameworks team. And today I'm here to talk to you about how you squeeze the most out of your smartwatch's battery life. So smartwatches come in all sorts of shapes and sizes. But really, they're all kind of pretty similar. So to get a rough idea of their performance, we can sort of abstract it a little. You have a little smartwatch with a round screen and a button. And they're kind of like smartphones. A low-end one from about two years ago. And to sort of get a rough idea of what we've got to work with, you take about 90% of battery capacity away. And you get a good approximation of what sort of hardware you get in a smartwatch today. So the basics in order to get good battery life starts pretty simple. So let's take the display, one of the biggest strains of battery life on your phone. Same on the watch. You'll display a watch face all the time on your watch. But if you have a screen technology like OLED screens, having each pixel on costs a lot of battery, lots of power. Unlike LCDs, which if they're on, they just turn a big backlight on. OLEDs can individually turn off each and every pixel. So you want a dark screen. Except if you keep the screen on all the time, what will happen is that OLEDs actually will sort of deteriorate over time. So you start having that ghosting situation you get when you have old CRTs. It's not a problem in your phone, because your phone lasts for about two to three years. And then you kind of just forget the screen exists. But on a watch, if you have it on 24-7, you will start leaving marks. So what you do is you just sort of create an outline on it, and you sort of shift a little outline around. And that sort of removes that problem kind of, not really. But hey, two years down the line, you won't remember this. So the other thing, the other sort of basics in terms of optimizing your battery life is the application processor. That's like the big chip on the device that does all the work. Or rather, you don't want to really use that application processor if you can. You want to use it as little as possible. So things that uses the application processor, rendering graphics will do it. And I mean drawing anything on the screen will use the application processor. Trying to access any sensors at all will use the application processor. But the nice thing about sensors is that we just get somebody else to handle. You have a little tiny chip in the device that you can just tell to read the sensors. And then you can go to sleep. But when I say using the application processor and like animations do it, I mean like anything. Like whoop, uh, I don't want to load. But this kind of proves my point. If you have a spinner that just keeps spinning, it doesn't matter how tiny the spinner is, like literally that's just an animation of a spinner. So story time, once upon a time we had a little spinner that goes on your screen every time you get an OTA. Your watch would flash itself and then it'll have the Android is preparing applications and it'll have like 50 applications you need to optimize and get really annoyed by it. So we put a little spinner in the screen to tell you that oh we're still working, it's not frozen. And eventually we figured out that there were watches that would never finish this step. What was happening was that the spinner would cause the application processor to keep running, which would cause a much higher battery life drain to the point where it starts heating up and then it goes into thermal shutdown, then it turns itself off. And then like a couple seconds they would turn itself back on and it starts that again. And your watch will just burn through your battery life like this. So yeah, but that doesn't mean you shouldn't use any animation whatsoever. If you have animate a little and make it stop, it actually saves a lot of battery life. If all we did was shove one second in between each revolution, it turns out that just drops a battery life usage by a lot, like 30%, which is what we did. So moving on. So all this is sort of like basics. When we're trying to hunt for bugs, we have a couple tools under our belts. What we get spammed with all the time though is bug reports. So we have a couple tools. One is called Battle Historian. It's actually online. We open source it and it works with your phone. So if you work with Android phones and you want to see which app is draining your battery life, you should use this tool. What it gives you, it gives you a nice little chart. It means absolutely, it shows you absolutely everything that gets used on your phone. And so it can show you pretty nifty things, like if an application decides you just use a big chunk of your watch battery life, you can sort of see that on the screen right there. And in the wake lock, it just keeps the application processor on. It can show you heavy network usage. And this one shows you the mobile signal strength. So if you have shift the cell network, it would just drain your battery life as well. Speaking of network usage, networks tend to be really bad on your phone. But they're far worse for your watch. Because again, 10% of battery life, you don't really have much to work with here when compared to a smartphone. So network abuse really is one of the worst things, especially when an application in your watch decides to check the network for alerts all the time. Or even more fun is when they have a giant 10 megapixel photograph for your tiny 400 by 400 pixel watch screen. Not exactly the greatest, but you can't do anything. You can't do a lot without any network data. Oftentimes, you have a lot of little pieces being sent over to network data, which isn't so great because every time you send even one byte, it causes the Bluetooth radio to wake up, send the data, go back to sleep, and it just does that over and over again. So if you match it up, it would actually save you a lot of time and energy. Speaking of Bluetooth, we have both Bluetooth and Wi-Fi now on watches. And the use of them is sort of subtle. Bluetooth, when it's idling, is great. It doesn't take much power. Wi-Fi, when idling, takes a lot of power. So naturally, you want to use Bluetooth, right? Except every byte that you send over Bluetooth takes a lot of energy. So you only have small snippets of data occasionally. Sending it over Bluetooth is OK and pretty great. But if you need to send a lot of data, you want to turn on your Wi-Fi, send the Wi-Fi data, and then please, please, please shut it down because otherwise, your battery life will disappear. So bug reports are great, except if you look at the graphs, they're not exactly really granular. You don't get much granular data. What you can do instead when you need very, very granular data, you can use a device called a power monitor, which is a white box about the size of a paperback. And it's got these banana plugs in the front. And there's a whole bunch of USB ports that I was too lazy to draw, so you're not getting that. But these things get you current data around a maximum of 5 kilohertz, which is pretty great, except somehow I have to connect this sucker to a watch. So here's the steps that you need to do in order to do this. You crack the watch open, and then you cut the battery wires. You get a black box from that acts like a battery, but not really, and you sort of install it in. You glue everything back together, and then you kind of reassemble it and pray it works and plug it in. So this is actually pretty easy if you're a person that's like you're a maker, you've got an EE degree, or like you've worked with electronics before. But if you're trying to send this packet of stuff to your coworkers overseas that's never really touched a soldering iron before, you will get a reply back that goes along the lines of, I feel like I'm preparing open heart surgery and a baby that would explode if I breathe at it wrong. Paraphrase, not exactly a quote, but it turns out if you send them the completed unit, they would still have trouble using it, because wires are scary. If you look at it and you're like this is like five in existence and the wires are really flimsy, can I not have to do this? So teaching people to use electronics devices can be difficult if somebody isn't actually well versed in how electronics actually work. But enough of that, let's actually look at what it gives you. So it gives you a chart kind of like this. It gives you a bit of current data, and it gets you a lot of, it can generate a lot of data over time. You can keep it running indefinitely, which is great. If you zoom in on a data, sometimes you get something like this, and if you are like some of my coworkers, you look at this and go, oh, I know what that is, that's Wi-Fi. You can see like the front of it, that's like the Wi-Fi starting up and it's scanning and it sees it and it's sending data and then it shuts itself back down. You go, you nod and go, yes, that's exactly what that would look like. And having a high frequency like five kilohertz is actually pretty great because if you try to get it through some other means, it would sort of look like this and we also stare at it and squint at it and go, it's using power somehow. Sometimes you're given idle data like this, so this would be what you would normally see when the watch isn't doing anything and then you'll see somebody ask you, hey, so like I did this thing with the watch, I upgraded the kernel and the graph sort of looks like this. What's happening? You squint and you go, oh, I have no idea. So those of you who've ever done sort of signal processing at all, there's this wonderful thing called a Fourier transform which will sort of convert time data into frequency data and which I'll be honest, I don't completely understand but I do remember enough that it exists and that I can use libraries. So it can get you data like this and it turns out in this instance that there was a peak at 60 hertz and then I ran around the office and asking people, so if I said 60 hertz to you, what would that mean? And at the time, I'm like, it has to be something to do with the timekeeping, right? So that's really accurate and then some guy looked at me and goes, are you thinking about the display? Turns out there was a button to display drivers. So there we are. So a quick note on like this sort of data, the data that we usually get, we sort of express it in terms of milliwatts and milliamps. And if you're not familiar or work with these numbers every day, a lot of people, if you tell somebody like, oh, this thing drains X amount of milliamps, they'll just sort of look at you funny. And if you tell somebody, hey, you can't, this new feature, we've sort of tested it and like you use like a couple of milliamps more and you sort of get this in response. So the trick to sort of get people to understand and for you to really understand intuitively is sort of convert them to hours. So if you look at something, go, so that new feature that you want to add this animation in, we're expecting it to drain maybe an extra two hours of your battery life during the day. This is their face. So to sort of, but these are all sort of tools to sort of bandage, these are bandages on top, they're not exactly stopping the problem that's happening in the first place. These are all reactive tools. And in order to sort of stop all these things from happening, you can automate all these tools, you can run all these tests on a daily basis, they'll catch regressions. But the other thing that's probably more important is you want to teach everybody to sort of use these tools. Getting developers to sort of understand bug reports, understand how to interpret them, getting my coworkers to learn how to use the power monitor in order to understand and in order to use them as opposed to you sort of mothballing them in a corner and when you go and visit them, they go, oh, we've, yeah, we had to go in, it's under somebody's desk somewhere and teaching them to use the tool is much, much more important because otherwise, you know, you have limited resources. And most of all, we have to talk to everybody, get feedback, it's an ongoing process, all the ideas in corporate news slides are things that were sort of developed over two years and we're only done through lots and lots of multi sort of purpose collaboration. And that's it.