{"id":22381888,"url":"https://github.com/googleinterns/sensor-historian","last_synced_at":"2025-07-31T02:33:07.032Z","repository":{"id":57578400,"uuid":"275036512","full_name":"googleinterns/sensor-historian","owner":"googleinterns","description":null,"archived":false,"fork":false,"pushed_at":"2020-08-07T22:29:49.000Z","size":7035,"stargazers_count":6,"open_issues_count":2,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-06-20T12:36:46.553Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/googleinterns.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-25T23:42:00.000Z","updated_at":"2023-01-29T07:26:06.000Z","dependencies_parsed_at":"2022-09-15T19:32:00.490Z","dependency_job_id":null,"html_url":"https://github.com/googleinterns/sensor-historian","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googleinterns%2Fsensor-historian","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googleinterns%2Fsensor-historian/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googleinterns%2Fsensor-historian/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googleinterns%2Fsensor-historian/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/googleinterns","download_url":"https://codeload.github.com/googleinterns/sensor-historian/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228209947,"owners_count":17885595,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-05T00:10:52.609Z","updated_at":"2024-12-05T00:10:53.473Z","avatar_url":"https://github.com/googleinterns.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"This is not an officially supported Google product.\n\n# Sensor Historian\n\nSensor Historian is a tool built upon Battery Historian to inspect sensor related information and subscription history on an Android device running Android 8.0 Oreo and later. It allows developers to visualize sensor subscription events and errors on a timeline with panning and zooming functionality, and select an application and inspect the related sensor activities to the chosen application.\n\n## Getting Started\n\n#### Building from source code\n\nMake sure you have at least Golang version 1.8.1:\n\n* Follow the instructions available at \u003chttp://golang.org/doc/install\u003e for downloading and installing the Go compilers, tools, and libraries.\n* Create a workspace directory according to the instructions at\n  \u003chttp://golang.org/doc/code.html#Organization\u003e.\n* Ensure that `GOPATH` and `GOBIN` environment variables are appropriately set and added to your `$PATH`\n  environment variable. `$GOBIN should be set to $GOPATH/bin`.\n  * For Windows, you may set environment variables through the \"Environment Variables\" button on the\n  \"Advanced\" tab of the \"System\" control panel. Some versions of Windows provide this control panel\n  through the \"Advanced System Settings\" option inside the \"System\" control panel.\n  * For Linux and Mac OS X, you can add the following lines to your ~/.bashrc or\n    ~/.profile files (assuming your workspace is $HOME/work):\n\n      ```\n      export GOPATH=$HOME/work\n      export GOBIN=$GOPATH/bin\n      export PATH=$PATH:$GOBIN\n      ```\n\nNext, install Git from \u003chttps://git-scm.com/downloads\u003e if it's not already installed.\n\nNext, make sure Python 2.7 (NOT Python 3!) is installed. See \u003chttps://python.org/downloads\u003e\nif it isn't, and ensure that python is added to your `$PATH` environment variable.\n\nNext, install Java from \u003chttp://www.oracle.com/technetwork/java/javase/downloads/index.html\u003e.\n\nNext, download the Battery Historian code and its dependencies:\n\n```\n$ go get -d -u github.com/googleinterns/sensor-historian/...\n```\n\nFinally, run Battery Historian!\n\n```\n$ cd $GOPATH/src/github.com/googleinterns/sensor-historian\n\n# Compile Javascript files using the Closure compiler\n$ go run setup.go\n\n# Run Historian on your machine (make sure $PATH contains $GOBIN)\n$ go run cmd/sensor-historian/sensor-historian.go [--port \u003cdefault:9999\u003e]\n```\n\nRemember, you must always run sensor-historian from inside the `$GOPATH/src/github.com/googleinterns/sensor-historian` directory:\n\n```\ncd $GOPATH/src/github.com/googleinterns/sensor-historian\ngo run cmd/sensor-historian/sensor-historian.go [--port \u003cdefault:9999\u003e]\n```\n\n\n#### How to take a bug report\n\nTo take a bug report from your Android device, you will need to enable USB debugging under `Settings \u003e System \u003e Developer Options`. On Android 4.2 and higher, the Developer options screen is hidden by default. You can enable this by following the instructions [here](\u003chttp://developer.android.com/tools/help/adb.html#Enabling\u003e).\n\nTo obtain a bug report from your development device running Android 7.0 and\nhigher:\n\n```\n$ adb bugreport bugreport.zip\n```\n\nFor devices 6.0 and lower:\n\n```\n$ adb bugreport \u003e bugreport.txt\n```\n\n### Start analyzing!\n\nYou are all set now. Run `historian` and visit \u003chttp://localhost:9999\u003e and\nupload the `bugreport.txt` file to start analyzing.\n\n## Screenshots\n\n##### Sensor Historian Tab:\n\n![Sensor Historian Tab](/screenshots/Sensor_Historian.png \"Sensor Subscription History Visualization\")\n\n##### Show Legend Items:\n\n![Show Legend Items](/screenshots/Show_Legend_Items.png \"Show the legend items explaining the color scheme and pattern usage.\")\n\n##### Application Selector:\n\n![Application Selector](/screenshots/Application_Selector.png \"Use application selector to inspect sensors used by the chosen application.\")\n\n##### Sensor Selector:\n\n![Sensor Selector](/screenshots/Sensor_Selector.png \"Use sensor selector to inspect a specific set of sensors.\")\n\n##### Floating Window:\n\n![Floating Window](/screenshots/Zooming_and_error_message.png \"Move the mouse on an event or error to see more information.\")\n\n## Advanced\n\nTo reset aggregated battery stats and history:\n\n```\nadb shell dumpsys batterystats --reset\n```\n\n##### [For Battery Historian] Wakelock analysis\n\nBy default, Android does not record timestamps for application-specific\nuserspace wakelock transitions even though aggregate statistics are maintained\non a running basis. If you want Historian to display detailed information about\neach individual wakelock on the timeline, you should enable full wakelock\nreporting using the following command before starting your experiment:\n\n```\nadb shell dumpsys batterystats --enable full-wake-history\n```\n\nNote that by enabling full wakelock reporting the battery history log overflows\nin a few hours. Use this option for short test runs (3-4 hrs).\n\n##### [For Battery Historian] Kernel trace analysis\n\nTo generate a trace file which logs kernel wakeup source and kernel wakelock\nactivities:\n\nFirst, connect the device to the desktop/laptop and enable kernel trace logging:\n\n```\n$ adb root\n$ adb shell\n\n# Set the events to trace.\n$ echo \"power:wakeup_source_activate\" \u003e\u003e /d/tracing/set_event\n$ echo \"power:wakeup_source_deactivate\" \u003e\u003e /d/tracing/set_event\n\n# The default trace size for most devices is 1MB, which is relatively low and might cause the logs to overflow.\n# 8MB to 10MB should be a decent size for 5-6 hours of logging.\n\n$ echo 8192 \u003e /d/tracing/buffer_size_kb\n\n$ echo 1 \u003e /d/tracing/tracing_on\n```\n\nThen, use the device for intended test case.\n\nFinally, extract the logs:\n\n```\n$ echo 0 \u003e /d/tracing/tracing_on\n$ adb pull /d/tracing/trace \u003csome path\u003e\n\n# Take a bug report at this time.\n$ adb bugreport \u003e bugreport.txt\n```\n\nNote:\n\nHistorian plots and relates events in real time (PST or UTC), whereas kernel\ntrace files logs events in jiffies (seconds since boot time). In order to relate\nthese events there is a script which approximates the jiffies to utc time. The\nscript reads the UTC times logged in the dmesg when the system suspends and\nresumes. The scope of the script is limited to the amount of timestamps present\nin the dmesg. Since the script uses the dmesg log when the system suspends,\nthere are different scripts for each device, with the only difference being\nthe device-specific dmesg log it tries to find. These scripts have been\nintegrated into the Battery Historian tool itself.\n\n##### [For Battery Historian] Power monitor analysis\n\nLines in power monitor files should have one of the following formats, and the\nformat should be consistent throughout the entire file:\n\n```\n\u003ctimestamp in epoch seconds, with a fractional component\u003e \u003camps\u003e \u003coptional_volts\u003e\n```\n\nOR\n\n```\n\u003ctimestamp in epoch milliseconds\u003e \u003cmilliamps\u003e \u003coptional_millivolts\u003e\n```\n\nEntries from the power monitor file will be overlaid on top of the timeline\nplot.\n\nTo ensure the power monitor and bug report timelines are somewhat aligned,\nplease reset the batterystats before running any power monitor logging:\n\n```\nadb shell dumpsys batterystats --reset\n```\n\nAnd take a bug report soon after stopping power monitor logging.\n\nIf using a Monsoon:\n\nDownload the AOSP Monsoon Python script from \u003chttps://android.googlesource.com/platform/cts/+/master/tools/utils/monsoon.py\u003e\n\n```\n# Run the script.\n$ monsoon.py --serialno 2294 --hz 1 --samples 100000 -timestamp | tee monsoon.out\n\n# ...let device run a while...\n\n$ stop monsoon.py\n```\n\n##### Modifying the proto files\n\nIf you want to modify the proto files (pb/\\*/\\*.proto), first download the\nadditional tools necessary:\n\nInstall the standard C++ implementation of protocol buffers from \u003chttps://github.com/google/protobuf/blob/master/src/README.md\u003e\n\nDownload the Go proto compiler:\n\n```\n$ go get -u github.com/golang/protobuf/protoc-gen-go\n```\n\nThe compiler plugin, protoc-gen-go, will be installed in $GOBIN, which must be\nin your $PATH for the protocol compiler, protoc, to find it.\n\nMake your changes to the proto files.\n\nFinally, regenerate the compiled Go proto output files using `regen_proto.sh`.\n\n##### [For Battery Historian] Other command line tools\n\n```\n# System stats\n$ go run cmd/checkin-parse/local_checkin_parse.go --input=bugreport.txt\n\n# Timeline analysis\n$ go run cmd/history-parse/local_history_parse.go --summary=totalTime --input=bugreport.txt\n\n# Diff two bug reports\n$ go run cmd/checkin-delta/local_checkin_delta.go --input=bugreport_1.txt,bugreport_2.txt\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogleinterns%2Fsensor-historian","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoogleinterns%2Fsensor-historian","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogleinterns%2Fsensor-historian/lists"}