{"id":21070702,"url":"https://github.com/microbit-foundation/android-partial-flashing-lib","last_synced_at":"2025-06-26T08:32:48.432Z","repository":{"id":52463708,"uuid":"180851900","full_name":"microbit-foundation/android-partial-flashing-lib","owner":"microbit-foundation","description":"An Android Java library that implements the partial flashing service","archived":false,"fork":false,"pushed_at":"2024-07-24T15:14:53.000Z","size":102,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-16T05:37:27.731Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/microbit-foundation.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-11T18:13:58.000Z","updated_at":"2025-02-18T16:56:00.000Z","dependencies_parsed_at":"2024-04-09T21:34:17.274Z","dependency_job_id":"d2c9e829-53c9-40a7-b736-4ff8a68193ef","html_url":"https://github.com/microbit-foundation/android-partial-flashing-lib","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/microbit-foundation/android-partial-flashing-lib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microbit-foundation%2Fandroid-partial-flashing-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microbit-foundation%2Fandroid-partial-flashing-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microbit-foundation%2Fandroid-partial-flashing-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microbit-foundation%2Fandroid-partial-flashing-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microbit-foundation","download_url":"https://codeload.github.com/microbit-foundation/android-partial-flashing-lib/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microbit-foundation%2Fandroid-partial-flashing-lib/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262030224,"owners_count":23247613,"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-11-19T18:47:53.253Z","updated_at":"2025-06-26T08:32:48.412Z","avatar_url":"https://github.com/microbit-foundation.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# micro:bit Partial Flashing Library for Android\n\nThis library provides partial flashing capabilities to an Android application.\n\nIt will process a hex file created in MakeCode or the Python Editor and flash only the user script.\nTo modularize the code, information is passed to and from the library using Intents.\n\n## Including the lib in an application\n\nCreate a class that extends the base service:\n\n```\npackage com.microbitreactnative.pf;\n\nimport android.app.Activity;\n\nimport org.microbit.android.partialflashing.PartialFlashingBaseService;\n\nimport com.microbitreactnative.NotificationActivity;\n\npublic class PartialFlashingService extends PartialFlashingBaseService {\n\n    @Override\n    protected Class\u003c? extends Activity\u003e getNotificationTarget() {\n        return NotificationActivity.class;\n    }\n}\n``` \n\n## To start a partial flash\n\nSend an Intent with the micro:bit's device address (scanning and bonding is not handled by this library) and the file path of the hex file to flash.\n\n```\n    MainApplication application = MainApplication.getApp();\n\n    Log.v(\"MicrobitDFU\", \"Start Partial Flash\");\n\n    // final Intent service = new Intent(application, PartialFlashingService.class);\n    final Intent service = new Intent(application, PartialFlashingService.class);\n    service.putExtra(\"deviceAddress\", deviceAddress);\n    service.putExtra(\"filepath\", filePath); // a path or URI must be provided.\n\n    application.startService(service);\n```\n\n## Receiving progress updates\n\nCurrently the library only sends progress as percentage updates (0-100%). These are broadcast during the flashing process and can be obtained using a LocalBroadcastManager.\n\nAn example that forwards the information to a React Native app:\n\n```\n...\n  public static final String BROADCAST_PROGRESS = \"org.microbit.android.partialflashing.broadcast.BROADCAST_PROGRESS\";\n  public static final String BROADCAST_START = \"org.microbit.android.partialflashing.broadcast.BROADCAST_START\";\n  public static final String BROADCAST_COMPLETE = \"org.microbit.android.partialflashing.broadcast.BROADCAST_COMPLETE\";\n  public static final String EXTRA_PROGRESS = \"org.microbit.android.partialflashing.extra.EXTRA_PROGRESS\";\n  public static final String BROADCAST_PF_FAILED = \"org.microbit.android.partialflashing.broadcast.BROADCAST_PF_FAILED\";\n\n  private ReactContext mReactContext;\n  private LocalBroadcastReceiver  mLocalBroadcastReceiver;\n\n  public MicrobitDFUModule(ReactApplicationContext reactContext) {\n    super(reactContext);\n    this.mReactContext = reactContext;\n    this.mLocalBroadcastReceiver = new LocalBroadcastReceiver();\n    LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(reactContext);\n    localBroadcastManager.registerReceiver(mLocalBroadcastReceiver, new IntentFilter(BROADCAST_PROGRESS_PF));\n  }\n\n  public class LocalBroadcastReceiver extends BroadcastReceiver {\n         @Override\n         public void onReceive(Context context, Intent intent) {\n               // Doesn't need to be precise so using int\n               int percentage = intent.getIntExtra(EXTRA_PROGRESS_PF, 0);\n\n               mReactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)\n                      .emit(\"flashingProgress\", percentage);\n         }\n  }\n\n...\n```\n\n## Partial Flashing Algorithm\n\nMore information on the partial flashing algorithm can be found [here](https://github.com/lancaster-university/codal-microbit-v2/blob/master/docs/MemoryMap.md).\n\n## Code of Conduct\n\nTrust, partnership, simplicity and passion are our core values we live and breathe in our daily work life and within our projects. Our open-source projects are no exception. We have an active community which spans the globe and we welcome and encourage participation and contributions to our projects by everyone. We work to foster a positive, open, inclusive and supportive environment and trust that our community respects the micro:bit code of conduct. Please see our [code of conduct](https://microbit.org/safeguarding/) which outlines our expectations for all those that participate in our community and details on how to report any concerns and what would happen should breaches occur.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrobit-foundation%2Fandroid-partial-flashing-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicrobit-foundation%2Fandroid-partial-flashing-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrobit-foundation%2Fandroid-partial-flashing-lib/lists"}