update battery status for audio/video

Bug: 12979595

Change-Id: Ic8e8d625becc6d1050f840ad63b7423f388eeba3
This commit is contained in:
Chong Zhang 2014-07-22 09:12:21 -07:00
parent 7b3f48d2ef
commit bd42d38b16
2 changed files with 64 additions and 0 deletions

View File

@ -30,10 +30,18 @@ public:
virtual void noteStartSensor(int uid, int sensor) = 0; virtual void noteStartSensor(int uid, int sensor) = 0;
virtual void noteStopSensor(int uid, int sensor) = 0; virtual void noteStopSensor(int uid, int sensor) = 0;
virtual void noteStartVideo(int uid) = 0;
virtual void noteStopVideo(int uid) = 0;
virtual void noteStartAudio(int uid) = 0;
virtual void noteStopAudio(int uid) = 0;
enum { enum {
NOTE_START_SENSOR_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, NOTE_START_SENSOR_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION,
NOTE_STOP_SENSOR_TRANSACTION, NOTE_STOP_SENSOR_TRANSACTION,
NOTE_START_VIDEO_TRANSACTION,
NOTE_STOP_VIDEO_TRANSACTION,
NOTE_START_AUDIO_TRANSACTION,
NOTE_STOP_AUDIO_TRANSACTION,
}; };
}; };

View File

@ -49,6 +49,34 @@ public:
data.writeInt32(sensor); data.writeInt32(sensor);
remote()->transact(NOTE_STOP_SENSOR_TRANSACTION, data, &reply); remote()->transact(NOTE_STOP_SENSOR_TRANSACTION, data, &reply);
} }
virtual void noteStartVideo(int uid) {
Parcel data, reply;
data.writeInterfaceToken(IBatteryStats::getInterfaceDescriptor());
data.writeInt32(uid);
remote()->transact(NOTE_START_VIDEO_TRANSACTION, data, &reply);
}
virtual void noteStopVideo(int uid) {
Parcel data, reply;
data.writeInterfaceToken(IBatteryStats::getInterfaceDescriptor());
data.writeInt32(uid);
remote()->transact(NOTE_STOP_VIDEO_TRANSACTION, data, &reply);
}
virtual void noteStartAudio(int uid) {
Parcel data, reply;
data.writeInterfaceToken(IBatteryStats::getInterfaceDescriptor());
data.writeInt32(uid);
remote()->transact(NOTE_START_AUDIO_TRANSACTION, data, &reply);
}
virtual void noteStopAudio(int uid) {
Parcel data, reply;
data.writeInterfaceToken(IBatteryStats::getInterfaceDescriptor());
data.writeInt32(uid);
remote()->transact(NOTE_STOP_AUDIO_TRANSACTION, data, &reply);
}
}; };
IMPLEMENT_META_INTERFACE(BatteryStats, "com.android.internal.app.IBatteryStats"); IMPLEMENT_META_INTERFACE(BatteryStats, "com.android.internal.app.IBatteryStats");
@ -75,6 +103,34 @@ status_t BnBatteryStats::onTransact(
reply->writeNoException(); reply->writeNoException();
return NO_ERROR; return NO_ERROR;
} break; } break;
case NOTE_START_VIDEO_TRANSACTION: {
CHECK_INTERFACE(IBatteryStats, data, reply);
int uid = data.readInt32();
noteStartVideo(uid);
reply->writeNoException();
return NO_ERROR;
} break;
case NOTE_STOP_VIDEO_TRANSACTION: {
CHECK_INTERFACE(IBatteryStats, data, reply);
int uid = data.readInt32();
noteStopVideo(uid);
reply->writeNoException();
return NO_ERROR;
} break;
case NOTE_START_AUDIO_TRANSACTION: {
CHECK_INTERFACE(IBatteryStats, data, reply);
int uid = data.readInt32();
noteStartAudio(uid);
reply->writeNoException();
return NO_ERROR;
} break;
case NOTE_STOP_AUDIO_TRANSACTION: {
CHECK_INTERFACE(IBatteryStats, data, reply);
int uid = data.readInt32();
noteStopAudio(uid);
reply->writeNoException();
return NO_ERROR;
} break;
default: default:
return BBinder::onTransact(code, data, reply, flags); return BBinder::onTransact(code, data, reply, flags);
} }