google / battery-historian

Battery Historian is a tool to analyze battery consumers using Android "bugreport" files.
Other
5.32k stars 959 forks source link

Battery Historian Error on Samsung Galaxy s8+ #145

Open dmohnen opened 7 years ago

dmohnen commented 7 years ago

Steps to reproduce.

  1. Samsung Galaxy s8+ with android version 7.0
  2. Run adb bugreport > bugreport.zip
  3. Upload bugreport.zip to battery historian
  4. I get screen print and fails to load.
    screen shot 2017-12-02 at 8 37 43 am
colbysadams commented 6 years ago

I have the same problem (same exact steps 1-4). This is the error message:

image

vkyt commented 6 years ago

I'm having the same issue with Samsung S8, S8+ and Note 8.

On Samsung GS7 edge the graph is not showing but the system stats are loading.

vkyt commented 6 years ago

I've tried the solution suggested in https://github.com/google/battery-historian/issues/111 on the S8 bugreport file but no luck. It fixed my GS7 Edge issue with graph not loading up but all the 8 series phones battery stat are still not working.

What I did was I unzipped the file, modified the bugreport txt tile in there with this command: LC_CTYPE=C sed '/^9,hsp.*/ {s/|//g;}' bugreport-2018-01-26-12-54-41.txt >edited.txt And then changed the file name, zipped the folder, uploaded to battery historian.

Still couldn't get the graph or any battery stat. Any help or suggestions would be greatly appreciated.

rutvijkumarshah commented 6 years ago

@vkyt thanks for saving so much time.

ArsenyLL commented 5 years ago
#!/bin/bash

# set -ex

if [ "$#" -lt 1 ]; then
    echo "Zip file (bugreport) path must be provided as argument"
    exit 1
fi

ARG_FILE_PATH=$1

if [ ! -f "${ARG_FILE_PATH}" ]; then 
    echo "arguemnt zip file does not exist"
fi

lines_to_remove[0]="^9,h.*Pss=5"
lines_to_remove[1]="^9,0,l,kwl,800f000"
lines_to_remove[2]="^9,h.*SubsystemPowerState"

TMP_DIR_NAME=$(uuidgen)
UNZIPPED_BASE_DIR="/tmp/${TMP_DIR_NAME}"

#### unzip the file
unzip -d "${UNZIPPED_BASE_DIR}" "${ARG_FILE_PATH}" > /dev/null

BUREGPORT_TXT_FILE=$(find "${UNZIPPED_BASE_DIR}" | grep "txt" | grep "bugreport")

cd "${UNZIPPED_BASE_DIR}"

# remove lines matching bad patterns
for ptrn in "${lines_to_remove[@]}"; do
    awk "!/${ptrn}/" "${BUREGPORT_TXT_FILE}" > ./tmp62774.tmp
    mv ./tmp62.tmp "${BUREGPORT_TXT_FILE}"
done

# https://github.com/google/battery-historian/issues/145#issuecomment-360929532
LC_CTYPE=C
sed "/^9,hsp.*/ {s/|//g;}" "${BUREGPORT_TXT_FILE}" > ./tmp62774.tmp
mv ./tmp62774.tmp "${BUREGPORT_TXT_FILE}"

OUTPUT_ZIP_FILENAME="${ARG_FILE_PATH}.fixed.zip"
zip -r "${OUTPUT_ZIP_FILENAME}" ./*  > /dev/null
cd -
rm -rf "${UNZIPPED_BASE_DIR}"
echo "fixed file: ${OUTPUT_ZIP_FILENAME}"

My ugly small script that removes unrecognized items and repacks into zip again :) (tested only on macOS)