Skip to content
Menu
Open World News Open World News
  • Privacy Policy
Open World News Open World News

How to use the F-Droid libraries, like CalyxOS

Posted on May 3, 2023 by Michael G

Author: grote
Source

When we built the next-generation F-Droid client, we rewrote
our code to fit into re-usable libraries, so other projects can make use of
F-Droid technology with minimal hassle.

The libraries

So far, we have published three libraries. Two of them are written in
Kotlin multi-platform, so they can be used outside Android as well. For
example, you could use them to write a command line or even an iOS client.

Check out their
README

for how to include them in your project.

Download library

This library includes everything you need to download F-Droid repositories
and the APKs and images included in them. It handles resuming of downloads,
repository mirrors and takes care of the special HTTP cases that an F-Droid
client can encounter.

The Android version of the library also takes care of rejecting TLS older
than 1.2 as well as weak ciphers. It prevents DNS leaks when using Tor as a
proxy and uses a short TLS session timeout to prevent tracking and key
re-use. If you use Glide as an image loader, it also comes with a special
ModelLoader to be used with Glide.

Please see the API
docs
for details.
Check how F-Droid switched to the download
library
for
an example.

Index library

The multi-platform index library gives you everything you need to handle
F-Droid repository indexes. Of course, there’s a parser for reading and
representing the indexes internally. For version 1 indexes, there is also a
creator which F-Droid uses to create its own nearby swap repositories. Both
versions have a signature verifier, so you can always make sure that the
repository is properly signed before working with its data.

Apart from these basics, the library also has many useful classes that help
you to choose the best translation based on the user’s locale, to check if
an app is compatible with the current device, and to check if an app has an
update available in the repository index. There are classes for processing
streams of index data, so you don’t need to load the entire index into
memory which can be an issue on devices with little RAM. If you prefer to
work only with the version 2 format internally, the library features an
index converter which can convert version 1 format into version 2.

F-Droid clients wishing to make use of version 2 delta updates, also find
helpful classes for this, so they don’t have to re-invent the wheel
themselves.

Please see the API docs
for details. Check how F-Droid switched to the index
library
for
an example.

Database library

In case you need to persist F-Droid repository information in your Android
app, this library is for you. It stores F-Droid related information such as
repositories, apps and their versions. Then allows you to query and search
for them. Under the hood, it uses a Room database which in turn uses
sqlite.

Besides database related classes, this library currently also includes
classes related to updating repositories, so that information fetched from
the internet (using the downloader library) can be streamed directly into
the database.

Please see the API
docs
for details.
Check how F-Droid switched to the database
library
for
an example.

CalyxOS

The first known user of these new libraries is CalyxOS which is already
using them in two of their apps. Thanks to the libraries, they can focus
their development effort on the apps themselves and don’t need to
re-implement the F-Droid related bits.

The first app is used as part of their setup wizard that shows up after
initial install. It allows the user to install additional apps on an opt-in
basis, so they don’t need to ship as non-removable system apps. The benefit
for CalyxOS is that they can load these apps from an F-Droid repository in
the internet without needing to ship APKs as part of their ROM keeping its
size minimal.

This is their
method

to get an index representation from a file, making use of the index library:

fun getIndex(file: File): IndexV2 = file.inputStream().use { inputStream ->
    IndexParser.parseV2(inputStream)
}

The second app uses F-Droid to keep its own essential apps up to date. With
a minimal UI, its main purpose is to regularly check for updates and install
them in the background, once available.

The app makes use of the UpdateChecker of the index library to check if
updates are available:

private fun getUpdate(packageName: String, packageVersions: List<PackageVersionV2>): PackageVersionV2? {
    val packageInfo = packageManager.getPackageInfo(packageName, GET_SIGNATURES)
    return updateChecker.getUpdate(packageVersions, packageInfo)
}

(Full code
example
)

Both of these
apps
don’t need
to persist any data, so they only use the download and the index library.

The library work was funded by the FFDW-DVD grant

Read more

Related Posts:

  • Palantir: DrupalCon Pittsburgh Preview
    Palantir: DrupalCon Pittsburgh Preview
  • www @ Savannah: An interview with Alexandre Oliva, lead developer of Linux-libre at FSFLA
    www @ Savannah: An interview with Alexandre Oliva, lead…
  • Envato Tuts+: Top 20 Most Usable Content Management Systems
    Envato Tuts+: Top 20 Most Usable Content Management Systems
  • Andy Wingo: a world to win: webassembly for the rest of us
    Andy Wingo: a world to win: webassembly for the rest of us
  • Dries Buytaert: A Composable Digital Experience Manifesto
    Dries Buytaert: A Composable Digital Experience Manifesto
  • Andy Wingo: structure and interpretation of ark
    Andy Wingo: structure and interpretation of ark

Recent Posts

  • 0942 – Punjabi Comedy Short Videos https://www.dailymotion.com/dm_hasaymakhol123…
  • “جامع كرات” وظيفة هالاند الجديدة
  • Kran Tutorial
  • Minister Malla Reddy Warns Mohan Reddy Grand Daughter | Mahabubnagar | V6 News
  • DP Rigathi Gachagua presides over the ground-breaking of the Menengai geothermal project in Nakuru-

Categories

  • Android
  • Linux
  • News
  • Open Source
©2023 Open World News | Powered by WordPress & Superb Themes
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT