Skip to content

refatwashere/RefatSpeedMeter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Net Meter

A lightweight Android utility by Refat that displays real-time internet download speed directly in the device status bar using a persistent foreground service and dynamic notification icons.


Table of Contents


Overview

Net Meter works by reading Android's TrafficStats API every second to calculate the bytes downloaded since the last tick, formatting the result into a compact string (e.g. 120K, 1.5M), and drawing it onto a Bitmap that is set as the notification's small icon — causing the speed to appear in the status bar.


Architecture

MainActivity  ──►  NetMeterService (Foreground Service)
                        │
                        ├── TrafficStats (Android API)
                        ├── SpeedFormatter (utils)
                        └── NotificationManager (Android API)
Layer File Responsibility
UI MainActivity.kt Toggle switch, runtime permission request
Service NetMeterService.kt Speed polling loop, notification updates
Utility SpeedFormatter.kt Byte-to-string conversion (KB/s, MB/s)

Project Structure

RefatSpeedMeter/
├── build.gradle.kts
├── settings.gradle.kts
├── README.md
├── CHANGELOG.md
├── DEPLOYMENT.md
└── app/
    ├── build.gradle.kts
    ├── proguard-rules.pro
    └── src/main/
        ├── AndroidManifest.xml
        └── java/com/refat/netmeter/
            ├── MainActivity.kt
            ├── service/
            │   └── NetMeterService.kt
            └── utils/
                └── SpeedFormatter.kt

Requirements

Tool Version
Android Studio Hedgehog (2023.1.1) or newer
Android Gradle Plugin 8.3.0
Kotlin 1.9.23
Java 11
compileSdk 35
minSdk 26 (Android 8.0 Oreo)
targetSdk 35

Setup

  1. Clone or download the repository into a local folder.
  2. Open Android StudioFileOpen → select RefatSpeedMeter/.
  3. Let Gradle sync complete. All dependencies are fetched automatically from Maven Central and Google.
  4. Connect a physical device or start an emulator running API 26+.

Build & Run

Debug build (development)

In Android Studio, press Run ▶ or use the terminal:

./gradlew assembleDebug

The debug APK is output to:

app/build/outputs/apk/debug/app-debug.apk

Install directly to a connected device

./gradlew installDebug

APK Deployment

See DEPLOYMENT.md for the full step-by-step release process including signing, ProGuard, and Google Play submission.


Security Model

Net Meter uses a two-layer security model to prevent unauthorised processes from starting or interacting with NetMeterService:

  1. android:exported="false" — the service is invisible to all other apps at the OS level.
  2. Signature permission (com.refat.netmeter.permission.NET_METER_SERVICE, protectionLevel="signature") — only APKs signed with the same release keystore can hold this permission. The service verifies it explicitly via checkCallingOrSelfPermission in onCreate and checkSelfPermission in MainActivity before any operation is performed.

Known Limitations

  • Status bar space — Android does not guarantee how many notification icons are visible. On heavily customised ROMs (MIUI, One UI), the icon may be hidden by the manufacturer's status bar policy.
  • Battery optimisation — Aggressive battery savers (e.g. Huawei, Xiaomi) may pause the coroutine loop when the screen is off for extended periods. Guide users to exempt the app from battery optimisation in device settings.
  • TrafficStats accuracy — The API measures all network traffic on the device (across all apps). It does not isolate per-app traffic.
  • Upload speed — The current implementation only tracks RxBytes (download). Upload tracking via TxBytes is not yet implemented.

About

A lightweight Android utility by Refat that displays real-time internet download speed directly in the device status bar using a persistent foreground service and dynamic notification icons.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages