BatteryHistoryDetail.java revision 537a0a82351d9671d14dccde8c9fc2a45c3c4f3a
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.app.Fragment;
20import android.content.Intent;
21import android.os.BatteryStats;
22import android.os.Bundle;
23import android.view.LayoutInflater;
24import android.view.View;
25import android.view.ViewGroup;
26
27import com.android.internal.os.BatteryStatsHelper;
28import com.android.settings.R;
29
30public class BatteryHistoryDetail extends Fragment {
31    public static final String EXTRA_STATS = "stats";
32    public static final String EXTRA_BROADCAST = "broadcast";
33
34    private BatteryStats mStats;
35    private Intent mBatteryBroadcast;
36
37    @Override
38    public void onCreate(Bundle icicle) {
39        super.onCreate(icicle);
40        String histFile = getArguments().getString(EXTRA_STATS);
41        mStats = BatteryStatsHelper.statsFromFile(getActivity(), histFile);
42        mBatteryBroadcast = getArguments().getParcelable(EXTRA_BROADCAST);
43    }
44
45    @Override
46    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
47        View view = inflater.inflate(R.layout.battery_history_chart, null);
48        BatteryHistoryChart chart = (BatteryHistoryChart)view.findViewById(
49                R.id.battery_history_chart);
50        chart.setStats(mStats, mBatteryBroadcast);
51        return view;
52    }
53}
54