/* * Copyright 2015, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef MEDIA_BATTERY_NOTIFIER_H #define MEDIA_BATTERY_NOTIFIER_H #include #include #include #include #include namespace android { /** * Class used for logging battery life events in mediaserver. */ class BatteryNotifier : public Singleton { friend class Singleton; BatteryNotifier(); public: ~BatteryNotifier(); void noteStartVideo(uid_t uid); void noteStopVideo(uid_t uid); void noteResetVideo(); void noteStartAudio(uid_t uid); void noteStopAudio(uid_t uid); void noteResetAudio(); void noteFlashlightOn(const String8& id, uid_t uid); void noteFlashlightOff(const String8& id, uid_t uid); void noteResetFlashlight(); void noteStartCamera(const String8& id, uid_t uid); void noteStopCamera(const String8& id, uid_t uid); void noteResetCamera(); private: void onBatteryStatServiceDied(); class DeathNotifier : public IBinder::DeathRecipient { virtual void binderDied(const wp& /*who*/); }; Mutex mLock; std::map mVideoRefCounts; std::map mAudioRefCounts; std::map, bool> mFlashlightState; std::map, bool> mCameraState; sp mBatteryStatService; sp mDeathNotifier; sp getBatteryService_l(); }; } // namespace android #endif // MEDIA_BATTERY_NOTIFIER_H