OSDN Git Service

Fix issue #16555033: Battery history overflowing too much
[android-x86/packages-apps-Settings.git] / src / com / android / settings / fuelgauge / BatteryHistoryDetail.java
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
17 package com.android.settings.fuelgauge;
18
19 import android.app.Fragment;
20 import android.content.Intent;
21 import android.os.BatteryStats;
22 import android.os.Bundle;
23 import android.view.LayoutInflater;
24 import android.view.View;
25 import android.view.ViewGroup;
26
27 import com.android.internal.os.BatteryStatsHelper;
28 import com.android.settings.R;
29
30 public 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 }