Search in sources :

Example 1 with HistoryItem

use of com.asksven.android.common.privateapiproxies.HistoryItem in project BetterBatteryStats by asksven.

the class NewGraphActivity method writeDumpToFile.

/**
 * Dumps relevant data to an output file
 */
void writeDumpToFile() {
    if (!DataStorage.isExternalStorageWritable()) {
        Log.e(TAG, "External storage can not be written");
        Toast.makeText(this, getString(R.string.message_external_storage_write_error), Toast.LENGTH_SHORT).show();
    }
    try {
        // open file for writing
        File root = Environment.getExternalStorageDirectory();
        if (root.canWrite()) {
            String strFilename = "BetterBatteryStats_History-" + DateUtils.now("yyyy-MM-dd_HHmmssSSS") + ".txt";
            File dumpFile = new File(root, strFilename);
            FileWriter fw = new FileWriter(dumpFile);
            BufferedWriter out = new BufferedWriter(fw);
            // write header
            out.write("===================\n");
            out.write("History\n");
            out.write("===================\n");
            PackageInfo pinfo = getPackageManager().getPackageInfo(getPackageName(), 0);
            out.write("BetterBatteryStats version: " + pinfo.versionName + "\n");
            out.write("Creation Date: " + DateUtils.now() + "\n");
            out.write("\n");
            out.write("\n");
            out.write("Time;Battery Level;Charging;" + "Screen On;GPS On;Wifi Running;" + "Wakelock;BT On;In Call;" + "Phone Scanning" + "\n");
            ArrayList<HistoryItem> histList = getHistList();
            for (int i = 0; i < histList.size(); i++) {
                HistoryItem entry = histList.get(i);
                out.write(entry.getNormalizedTime() + ";" + entry.getBatteryLevel() + ";" + entry.getCharging() + ";" + entry.getScreenOn() + ";" + entry.getGpsOn() + ";" + entry.getWifiRunning() + ";" + entry.getWakelock() + ";" + entry.getBluetoothOn() + ";" + entry.getPhoneInCall() + ";" + entry.getPhoneScanning() + "\n");
            }
            // close file
            out.close();
        }
    } catch (Exception e) {
        Log.e(TAG, "Exception: " + e.getMessage());
        Toast.makeText(this, getString(R.string.message_error_writing_dumpfile), Toast.LENGTH_SHORT).show();
    }
}
Also used : PackageInfo(android.content.pm.PackageInfo) FileWriter(java.io.FileWriter) HistoryItem(com.asksven.android.common.privateapiproxies.HistoryItem) File(java.io.File) BufferedWriter(java.io.BufferedWriter)

Example 2 with HistoryItem

use of com.asksven.android.common.privateapiproxies.HistoryItem in project BetterBatteryStats by asksven.

the class HistAdapter method getView.

public View getView(int position, View convertView, ViewGroup viewGroup) {
    HistoryItem entry = m_listData.get(position);
    if (convertView == null) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.hist_row, null);
    }
    TextView tvTime = (TextView) convertView.findViewById(R.id.TextViewTime);
    tvTime.setText(entry.getNormalizedTime());
    TextView tvBatteryPct = (TextView) convertView.findViewById(R.id.TextViewBatteryPct);
    tvBatteryPct.setText(entry.getBatteryLevel());
    TextView tvCharging = (TextView) convertView.findViewById(R.id.TextViewCharing);
    tvCharging.setText(entry.getCharging());
    TextView tvScreenOn = (TextView) convertView.findViewById(R.id.TextViewScreenOn);
    tvScreenOn.setText(entry.getScreenOn());
    TextView tvGpsOn = (TextView) convertView.findViewById(R.id.TextViewGpsOn);
    tvGpsOn.setText(entry.getGpsOn());
    TextView tvWifiOn = (TextView) convertView.findViewById(R.id.TextViewWifiOn);
    tvWifiOn.setText(entry.getWifiRunning());
    TextView tvWakelock = (TextView) convertView.findViewById(R.id.TextViewWakelock);
    tvWakelock.setText(entry.getWakelock());
    TextView tvBtOn = (TextView) convertView.findViewById(R.id.TextViewBtOn);
    tvBtOn.setText(entry.getBluetoothOn());
    TextView tvInCall = (TextView) convertView.findViewById(R.id.TextViewPhoneInCall);
    tvInCall.setText(entry.getPhoneInCall());
    TextView tvPhoneScanning = (TextView) convertView.findViewById(R.id.TextViewPhoneScanning);
    tvPhoneScanning.setText(entry.getPhoneScanning());
    return convertView;
}
Also used : HistoryItem(com.asksven.android.common.privateapiproxies.HistoryItem) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView)

Example 3 with HistoryItem

use of com.asksven.android.common.privateapiproxies.HistoryItem in project BetterBatteryStats by asksven.

the class NewGraphActivity method getHistList.

/**
 * Get the Stat to be displayed
 *
 * @return a List of StatElements sorted (descending)
 */
protected ArrayList<HistoryItem> getHistList() {
    if (AndroidVersion.isFroyo()) {
        Snackbar.make(findViewById(android.R.id.content), R.string.message_no_hist_froyo, Snackbar.LENGTH_LONG).show();
    // Toast.makeText(this, getString(R.string.message_no_hist_froyo), Toast.LENGTH_SHORT).show();
    }
    ArrayList<HistoryItem> myRet = new ArrayList<HistoryItem>();
    BatteryStatsProxy mStats = BatteryStatsProxy.getInstance(this);
    try {
        myRet = mStats.getHistory(this);
    // mStats.dumpHistory(this);
    } catch (Exception e) {
        Log.e(TAG, "An error occured while retrieving history. No result");
    }
    return myRet;
}
Also used : HistoryItem(com.asksven.android.common.privateapiproxies.HistoryItem) ArrayList(java.util.ArrayList) BatteryStatsProxy(com.asksven.android.common.privateapiproxies.BatteryStatsProxy)

Example 4 with HistoryItem

use of com.asksven.android.common.privateapiproxies.HistoryItem in project BetterBatteryStats by asksven.

the class HistActivity method getHistList.

/**
 * Get the Stat to be displayed
 *
 * @return a List of StatElements sorted (descending)
 */
protected ArrayList<HistoryItem> getHistList() {
    if (AndroidVersion.isFroyo()) {
        Snackbar.make(findViewById(android.R.id.content), R.string.message_no_hist_froyo, Snackbar.LENGTH_LONG).show();
    // Toast.makeText(this, getString(R.string.message_no_hist_froyo), Toast.LENGTH_SHORT).show();
    }
    ArrayList<HistoryItem> myRet = new ArrayList<HistoryItem>();
    BatteryStatsProxy mStats = BatteryStatsProxy.getInstance(this);
    try {
        myRet = mStats.getHistory(this);
    // mStats.dumpHistory(this);
    } catch (Exception e) {
        Log.e(TAG, "An error occured while retrieving history. No result");
    }
    return myRet;
}
Also used : HistoryItem(com.asksven.android.common.privateapiproxies.HistoryItem) ArrayList(java.util.ArrayList) BatteryStatsProxy(com.asksven.android.common.privateapiproxies.BatteryStatsProxy)

Example 5 with HistoryItem

use of com.asksven.android.common.privateapiproxies.HistoryItem in project BetterBatteryStats by asksven.

the class GraphActivity method getHistList.

/**
 * Get the Stat to be displayed
 *
 * @return a List of StatElements sorted (descending)
 */
protected ArrayList<HistoryItem> getHistList() {
    if (AndroidVersion.isFroyo()) {
        Snackbar.make(findViewById(android.R.id.content), R.string.message_no_hist_froyo, Snackbar.LENGTH_LONG).show();
    }
    ArrayList<HistoryItem> myRet = new ArrayList<HistoryItem>();
    BatteryStatsProxy mStats = BatteryStatsProxy.getInstance(this);
    try {
        myRet = mStats.getHistory(this);
    } catch (Exception e) {
        Log.e(TAG, "An error occured while retrieving history. No result");
    }
    return myRet;
}
Also used : HistoryItem(com.asksven.android.common.privateapiproxies.HistoryItem) ArrayList(java.util.ArrayList) BatteryStatsProxy(com.asksven.android.common.privateapiproxies.BatteryStatsProxy)

Aggregations

HistoryItem (com.asksven.android.common.privateapiproxies.HistoryItem)5 BatteryStatsProxy (com.asksven.android.common.privateapiproxies.BatteryStatsProxy)3 ArrayList (java.util.ArrayList)3 PackageInfo (android.content.pm.PackageInfo)1 LayoutInflater (android.view.LayoutInflater)1 TextView (android.widget.TextView)1 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1