// Normalize app data
func normalizeApp(a *bspb.BatteryStats_App, totalTimeHour float64) *bspb.BatteryStats_App {
	if a == nil {
		return nil
	}
	res := proto.Clone(a).(*bspb.BatteryStats_App)

	if norm := normalizeMessage(a.GetForeground(), totalTimeHour); norm != nil {
		res.Foreground = norm.(*bspb.BatteryStats_App_Foreground)
	}
	if norm := normalizeAppApk(a.GetApk(), totalTimeHour); norm != nil {
		res.Apk = norm
	}
	normalizeAppChildren(res.GetChild(), totalTimeHour)
	if norm := normalizeMessage(a.GetNetwork(), totalTimeHour); norm != nil {
		res.Network = norm.(*bspb.BatteryStats_App_Network)
	}
	if norm := normalizeMessage(a.GetPowerUseItem(), totalTimeHour); norm != nil {
		res.PowerUseItem = norm.(*bspb.BatteryStats_App_PowerUseItem)
	}
	if norm := normalizeRepeatedMessage(a.GetProcess(), totalTimeHour).Interface(); norm != nil {
		res.Process = norm.([]*bspb.BatteryStats_App_Process)
	}
	if norm := normalizeRepeatedMessage(a.GetSensor(), totalTimeHour).Interface(); norm != nil {
		res.Sensor = norm.([]*bspb.BatteryStats_App_Sensor)
	}
	if norm := normalizeMessage(a.GetStateTime(), totalTimeHour); norm != nil {
		res.StateTime = norm.(*bspb.BatteryStats_App_StateTime)
	}
	if norm := normalizeMessage(a.GetVibrator(), totalTimeHour); norm != nil {
		res.Vibrator = norm.(*bspb.BatteryStats_App_Vibrator)
	}
	if norm := normalizeRepeatedMessage(a.GetWakelock(), totalTimeHour).Interface(); norm != nil {
		res.Wakelock = norm.([]*bspb.BatteryStats_App_Wakelock)
	}
	if norm := normalizeRepeatedMessage(a.GetWakeupAlarm(), totalTimeHour).Interface(); norm != nil {
		res.WakeupAlarm = norm.([]*bspb.BatteryStats_App_WakeupAlarm)
	}
	if norm := normalizeMessage(a.GetWifi(), totalTimeHour); norm != nil {
		res.Wifi = norm.(*bspb.BatteryStats_App_Wifi)
	}
	if norm := normalizeRepeatedMessage(a.GetUserActivity(), totalTimeHour).Interface(); norm != nil {
		res.UserActivity = norm.([]*bspb.BatteryStats_App_UserActivity)
	}
	if norm := normalizeRepeatedMessage(a.GetScheduledJob(), totalTimeHour).Interface(); norm != nil {
		res.ScheduledJob = norm.([]*bspb.BatteryStats_App_ScheduledJob)
	}
	return res
}