1cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn/*
2cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn * Copyright (C) 2009 The Android Open Source Project
3cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn *
4cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn * Licensed under the Apache License, Version 2.0 (the "License");
5cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn * you may not use this file except in compliance with the License.
6cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn * You may obtain a copy of the License at
7cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn *
8cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn *      http://www.apache.org/licenses/LICENSE-2.0
9cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn *
10cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn * Unless required by applicable law or agreed to in writing, software
11cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn * distributed under the License is distributed on an "AS IS" BASIS,
12cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn * See the License for the specific language governing permissions and
14cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn * limitations under the License.
15cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn */
16cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn
17cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackbornpackage com.android.settings.fuelgauge;
18cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn
1959a48604b5a803fbec6857e07f9fa1adbc6b8bb4Dianne Hackbornimport android.app.Fragment;
20cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackbornimport android.os.Bundle;
21cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackbornimport android.os.Parcel;
2259a48604b5a803fbec6857e07f9fa1adbc6b8bb4Dianne Hackbornimport android.view.LayoutInflater;
2359a48604b5a803fbec6857e07f9fa1adbc6b8bb4Dianne Hackbornimport android.view.View;
2459a48604b5a803fbec6857e07f9fa1adbc6b8bb4Dianne Hackbornimport android.view.ViewGroup;
25cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn
26cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackbornimport com.android.internal.os.BatteryStatsImpl;
27cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackbornimport com.android.settings.R;
28cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn
2959a48604b5a803fbec6857e07f9fa1adbc6b8bb4Dianne Hackbornpublic class BatteryHistoryDetail extends Fragment {
30cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn    public static final String EXTRA_STATS = "stats";
31cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn
32cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn    private BatteryStatsImpl mStats;
33cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn
34cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn    @Override
3559a48604b5a803fbec6857e07f9fa1adbc6b8bb4Dianne Hackborn    public void onCreate(Bundle icicle) {
36cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn        super.onCreate(icicle);
3759a48604b5a803fbec6857e07f9fa1adbc6b8bb4Dianne Hackborn        byte[] data = getArguments().getByteArray(EXTRA_STATS);
38cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn        Parcel parcel = Parcel.obtain();
39cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn        parcel.unmarshall(data, 0, data.length);
40cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn        parcel.setDataPosition(0);
41cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn        mStats = com.android.internal.os.BatteryStatsImpl.CREATOR
42cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn                .createFromParcel(parcel);
4359a48604b5a803fbec6857e07f9fa1adbc6b8bb4Dianne Hackborn    }
4459a48604b5a803fbec6857e07f9fa1adbc6b8bb4Dianne Hackborn
4559a48604b5a803fbec6857e07f9fa1adbc6b8bb4Dianne Hackborn    @Override
4659a48604b5a803fbec6857e07f9fa1adbc6b8bb4Dianne Hackborn    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
4759a48604b5a803fbec6857e07f9fa1adbc6b8bb4Dianne Hackborn        View view = inflater.inflate(R.layout.preference_batteryhistory, null);
4859a48604b5a803fbec6857e07f9fa1adbc6b8bb4Dianne Hackborn        BatteryHistoryChart chart = (BatteryHistoryChart)view.findViewById(
49cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn                R.id.battery_history_chart);
50cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn        chart.setStats(mStats);
5159a48604b5a803fbec6857e07f9fa1adbc6b8bb4Dianne Hackborn        return view;
52cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn    }
53cbaf6ceb8e6b2d36a40589de6380ff93e75335dfDianne Hackborn}
54