Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0b30fd4c authored by Chong Zhang's avatar Chong Zhang
Browse files

reset battery stats when media player service is started

Bug: 12979595
Change-Id: Ia800de3e65ed4dec8334c6fde566edab12d23c42
parent 4730fa07
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@

#include <utils/misc.h>

#include <binder/IBatteryStats.h>
#include <binder/IPCThreadState.h>
#include <binder/IServiceManager.h>
#include <binder/MemoryHeapBase.h>
@@ -275,6 +276,20 @@ MediaPlayerService::MediaPlayerService()
    // speaker is on by default
    mBatteryAudio.deviceOn[SPEAKER] = 1;

    // reset battery stats
    // if the mediaserver has crashed, battery stats could be left
    // in bad state, reset the state upon service start.
    const sp<IServiceManager> sm(defaultServiceManager());
    if (sm != NULL) {
        const String16 name("batterystats");
        sp<IBatteryStats> batteryStats =
                interface_cast<IBatteryStats>(sm->getService(name));
        if (batteryStats != NULL) {
            batteryStats->noteResetVideo();
            batteryStats->noteResetAudio();
        }
    }

    MediaPlayerFactory::registerBuiltinFactories();
}