BatteryHistoryDetail.java revision 8a963babe2e36b7a41f77b8d2598c97658196e58
1/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.settings.fuelgauge;
18
19import android.content.Intent;
20import android.os.BatteryStats;
21import android.os.Bundle;
22import android.view.LayoutInflater;
23import android.view.View;
24import android.view.ViewGroup;
25
26import com.android.internal.logging.MetricsLogger;
27import com.android.internal.os.BatteryStatsHelper;
28import com.android.settings.InstrumentedFragment;
29import com.android.settings.R;
30
31public class BatteryHistoryDetail extends InstrumentedFragment {
32    public static final String EXTRA_STATS = "stats";
33    public static final String EXTRA_BROADCAST = "broadcast";
34
35    private BatteryStats mStats;
36    private Intent mBatteryBroadcast;
37
38    @Override
39    public void onCreate(Bundle icicle) {
40        super.onCreate(icicle);
41        String histFile = getArguments().getString(EXTRA_STATS);
42        mStats = BatteryStatsHelper.statsFromFile(getActivity(), histFile);
43        mBatteryBroadcast = getArguments().getParcelable(EXTRA_BROADCAST);
44    }
45
46    @Override
47    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
48        View view = inflater.inflate(R.layout.battery_history_chart, null);
49        BatteryHistoryChart chart = (BatteryHistoryChart)view.findViewById(
50                R.id.battery_history_chart);
51        chart.setStats(mStats, mBatteryBroadcast);
52        return view;
53    }
54
55    @Override
56    protected int getMetricsCategory() {
57        return MetricsLogger.FUELGAUGE_BATTERY_HISTORY_DETAIL;
58    }
59}
60