Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Android library for sending fastboot commands from an Android device to a device running fastboot.

License

Notifications You must be signed in to change notification settings

RohitVerma882/fastboot-android

Repository files navigation

Fastboot Android

Android library for sending fastboot commands from an Android device to a device running fastboot.

Only supports fastboot over USB On-The-Go (OTG) connections.

Original-Source: https://github.com/google/fastboot-mobile

Integration

Add it in your root build.gradle at the end of repositories:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
}

Add the dependency

dependencies {
    implementation 'com.github.RohitVerma882:fastboot-android:<version>'
}

Usage

List Attached Fastboot Devices

// Includes connected devices.
val deviceIds: List<DeviceId> = FastbootDeviceManager.getAttachedDeviceIds()

List Connected Fastboot Devices

val deviceIds: List<DeviceId> = FastbootDeviceManager.getConnectedDeviceIds()

Connect to a Fastboot Device

// typealias DeviceId = String
FastbootDeviceManager.addFastbootDeviceManagerListener(
    object : FastbootDeviceManagerListener() {
        override fun onFastbootDeviceAttached(deviceId: DeviceId) {
            Log.d("Device attached: $deviceId")
        }

        override fun onFastbootDeviceDetached(deviceId: DeviceId) {
            Log.d("Device detached: $deviceId")
        }

        override fun onFastbootDeviceConnected(
            deviceId: DeviceId,
            deviceContext: FastbootDeviceContext
        ) {
            // Do some fastboot stuff...
            val response = deviceContext.sendCommand(FastbootCommand.getVar("current-slot"))
            val bootSlot = response.data
            Log.d("Device $deviceId with slot $bootSlot.")
        }
    })

FastbootDeviceManager.connectToDevice(/* Device Name */ "/dev/bus/usb/001/002")

About

Android library for sending fastboot commands from an Android device to a device running fastboot.

Resources

License

Stars

Watchers

Forks

Languages