GithubHelp home page GithubHelp logo

bartoszwitkowski11 / temperaturemeasurement Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 5.18 MB

App had been made especially for master thesis purpose where I was measuring how hot can mobile devices can get. It reads values from temperature sensors built-in the Android devices and saves them into Room Database which later can be exported to .csv file. It was really difficult to omit security which are implemented in newer Android

Kotlin 100.00%
android androidcoroutines androidstudio database kotlin room sensor temperature

temperaturemeasurement's Introduction

TemperatureMeasurement for Android

TL;DR: App reads temperature values from sensors built-in the device.

Functions description

On the main screen:

Thread - turning on this option creates a thread for recording method. It may help with measuring in the background.

Displaying - displays data on the app main screen

Wakelock - suspends cpu from falling asleep while screen is off. It may help with measuring in the background.

Interval - changes intervals between temperatures readings. Format of the input should be in milliseconds (1000 ms = 15)

In settings that are hidden under three dots at the top of the screen:

Export db to .csv file - exports readings to csv. file. Typical location is Android/data/com.example.temperaturemeasurement/files.

Scan available sensors - It scans available sensors and methods.

Delete database - as name says, it deletes the entire database.

Battery Optimization - opens up battery optimization settings.

How does the app work?

There are implemented two different approaches to read temperatures from your device. Some devices have direct access to system files that stores temperatures. These devices are using something I call Direct Read Method. It reads temps from files and put them into database. As the device might have many sensors (or many places where data from sensors are stored, sometimes even the same parameters) that are not needed, there is implemented way to turn on and off reading from some sensors.

Other way to read temperatures is to use special command which is normally accessible on your device from Android Debug Bridge (ADB) in your computer. The purpose of the app is to be free from any other devices and additional cables etc. So I have developed another way of reading temps. I call it Alternative Read Method. It uses command dumpsys thermalservice which returns temperatures values from the most important sensors in the device. It returns them in string, so the app is searching in the string only for the data I am interested in, such as sensor name and temperature value. This way I am able to get temp readings from all devices that I am going to use for testing. It is possible that some devices won't work with both methods.

Unfortunately, there is a catch with the second method. It is needed to do steps below to achieve successful working.

  1. Install ADB (https://developer.android.com/studio/releases /platform-tools) and then plug your device through USB cable. More explanation here: https://www.xda-developers.com/install-adb -windows-macos-linux/
  2. Turn on debugging mode in Android device. If you don't know how to do it, look it up on the internet.
  3. Open command line on Windows or Terminal on Linux/macOS.
  4. Copy location to your adb.exe, for example: C\Users\bartosz witkowski\desktop\adb\platform-tools\adb.exe
  5. Paste it in command line and add devices, and then press enter.
  6. If you get respond with numbers and letters, it means your phone is connected to the computer correctly
  7. Repeat step 4 and also paste this: shell pm grant com.example.temperaturemeasurement android.permission.DUMP, and then press enter.
  8. The second method should now work properly. For precaution, you should scan again sensors in the app.

Is it safe? Yes!

Is there any risk to damage my phone? No! There is 0 chance to damage your device. The above steps are not modifying software on your device in any way! Moreover, commands and software that are used there are intended for collecting data about cpu workload, temperatures, and also checking stability of new devices and apps.

What is the line dumpsys thermalservice doing? You can check by yourself! Just input into your command line path to adb.exe and shell dumpsys thermalservice. Briefly, this command returns info about all parameter that are connected with thermal control of the device, for example temperatures of crucial sensors.

But what is the line from point 7? It is needed to grant application proper permission that are not accessible in the System for third-party apps in Android. It means that system apps can use this permission, but apps that are not installed by the vendor can't. Fortunately, it is possible to grant that permission one-time only through the above method. The app is using it ONLY for accessing above command dumpsys thermalservice and nothing more.

Created by Bartosz Witkowski, Poznan University of Technology 2023

temperaturemeasurement's People

Contributors

bartoszwitkowski11 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.