\documentclass{beamer}
\usepackage[english]{babel}
\usepackage{color}
\usepackage{graphicx}
\usepackage{ifthen}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\usepackage{xtab}
\usepackage{pdfpages}

\newcommand{\devicespictureframe}[3] {
  {
    \begin{frame}
      \center{#1}
             {\includegraphics[scale=0.5]{../../external_resources/replicant_website/images/supported-devices/#2.png}}
             {\includegraphics[scale=0.5]{../../external_resources/replicant_website/images/supported-devices/#3.png}}
             \hspace*{-\textwidth}
    \end{frame}
  }
}

\newcommand{\outputpicture}[2] {
  {\includegraphics[scale=#1]{output/#2}}
}

\newcommand{\devicepicture}[2] {
  {\includegraphics[scale=#1]{../../external_resources/replicant_website/images/supported-devices/#2.png}}
}

\usetheme{Singapore}

\title{Extending the lifetime of smartphones with Replicant, a fully free Android distribution}
\author{Denis 'GNUtoo' Carikli and David 'dllud' Ludovino}
\date{\today}

\begin{document}

\maketitle

%% \begin{frame}
%%   \begin{itemize}
%%   \item Context
%%   \end{itemize}
%% \end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{frame}
  \center{Replicant:}
  \begin{itemize}
  \item Fully free Android distribution approved by the FSF
  \item But the hardware it runs on is not...
  \item More details on hardware related freedom issues later %% TODO
  \end{itemize}
\end{frame}

\begin{frame}
  \center{Quick Facts}
  \begin{itemize}
  \item Website: replicant.us
  \item Exists since September 2009
  \item Currently based on LineageOS
  \item Android versions:
    \begin{itemize}
    \item Replicant 6: Android 6, last security update: October 2017\cite{last-android-6-update}
    \item Replicant 9: Android 9, work in progress\cite{porting-to-android-9}
    \end{itemize}
  \item Supports $\sim$ 10 devices (smartphones and tablets)
  \item $\sim$ 2 full time equivalent contributors and a big community
  \end{itemize}
\end{frame}

\begin{frame}
  \center{Minimum feature set required to support a device:}
  \begin{itemize}
  \item Display working and graphics fast enough
  \item sound working
  \item Be able to make calls
  \item etc
  \item GPS, Camera, and other non crucial hardware may not work, or work in later releases
  \end{itemize}
\end{frame}

%% \begin{frame}
%%   \center{A very short introduction on hardware}
%%   \begin{itemize}
%%   \item System on a chip
%%   \item Smartphones and the modem
%%   \end{itemize}
%% \end{frame}

\begin{frame}
  \outputpicture{1}{i9300_hardware.png}
\end{frame}

\begin{frame}
  \center{Why Android?}
  \begin{itemize}
  \item Advantages:
    \begin{itemize}
    \item GUI and applications adapted to big fingers
    \item $\rightarrow$ run on devices that:
      \begin{itemize}
      \item lack keyboard
      \item have capacitve touchscreen and no stylus
      \item Have very small displays with very high number of pixel
      \end{itemize}
    \end{itemize}
  \item Issues
    \begin{itemize}
    \item Part of the GNU/Linux software architecture is light years away: Package management and build system, Graphics, audio, etc
    \item Huge unknown code from google
    \item Meant to run proprietary software
    \item Not meant to empower users
    \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}
  \center{Android: From time to market driven architecture to substainability}
  \begin{itemize}
  \item SOCs, WiFi chips, smartphones and tablets
    \begin{itemize}
    \item Write the code that work as fast as possible
    \item Support as many hardware features as possible
    \item $\rightarrow$ Varying code quality
    \item $\rightarrow$ Example: One driver rewritten 3 times %% TODO: reference
    \end{itemize}
  \item Breaking Kernel API and ABI
    \begin{itemize}
    \item It can take time (years) to bring in a new framework in Linux
    \item Example of API breakage: HTC dream audio driver
    \item Solution: Apps$\leftarrow$ $\rightarrow$ Android framework $\leftarrow$ $\rightarrow$ HAL $\leftarrow$ $\rightarrow$  Kernel
    \item Getting better in Android: Trebble and Generic Kernel images
    \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}
  \center{Ugly code is good (for freedom):}
  %% TODO: replace with [blobby from OpenBSD] VS [dirty tux] -> [freedo]
  \begin{itemize}
  \item Having the source code under free software licenses, even if the code quality is bad is crucial for freedom:
    \begin{itemize}
    \item Hardware bringup is often made that way anyway
    \item Things can be improved later:
      always be cleaned up later or if the code quality is too bad, rewritten from scratch
    \item Having the source code under a free software license is very important
    \item Worst case: use the source code as documentation or reverse engineer it (add prints)
    \end{itemize}
  \item $\rightarrow$ We depend on that source code
  \end{itemize}
\end{frame}

%% \begin{frame}
%%   \center{What affect a device lifetime in Replicant?}
%%   \begin{itemize}
%%   \item Upstream support $\leftarrow$ We're working on it
%%   \item Android RAM consumption VS device RAM size $\leftarrow$ Very little leverage from Replicant
%%   \item Removable batteries and developers being able to get the device $\leftarrow$ We don't support devices without removable batteries
%%   \item Freedom issues (Chinese whispers) $\leftarrow$ Conflicting interests
%%   \end{itemize}
%% \end{frame}

\begin{frame}[plain,allowframebreaks]{title}
  \begin{xtabular}{ll}
    \hline
    Device dropping cause & Replicant leverage \\
    \hline
    Upstream support & We're working to improve it \\
    \hline
    Android RAM consumption & negligeable \\
    %% Most device we want to support have similar-ish RAM size
    %% Cannot increase much the device lifetime by choosing devices with bigger RAM size
    %% => We have no impact on it and have to endure it
    \hline
    Lack of removable batteries & don't support devices with non-replacable batteries \\
    \hline
    Freedom issues & Conflicting interests \\
    %% Chinese whispers => Better keeping it simple
    %% We drop the least free devices
    %% Conflicting interest
    \hline
  \end{xtabular}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\devicespictureframe{Replicant phase 1: Quick and dirty hacks}{dream_sapphire}{passion}


\begin{frame}
  %%  \center{Replicant phase 1: Quick and dirty hacks}
  \devicepicture{0.5}{dream_sapphire}
  \hspace*{-\textwidth}
\end{frame}

{
  %% TODO:
  %% - Split the images and the text
  %% - HTC Dream: Make an image with the slider open
  %% - Add both the HTC Dream and passion
  \usebackgroundtemplate{
    \includegraphics[scale=0.5]{../../external_resources/replicant_website/images/supported-devices/dream_sapphire.png}
    \includegraphics[scale=0.5]{../../external_resources/replicant_website/images/supported-devices/passion.png}
  }

  \begin{frame}
    \setbeamercolor{block body}{fg=red}
    \begin{block}
      \center Replicant phase 1: Quick and dirty hacks
      \begin{itemize}
      \item Context: [Replicant 1.5 $\rightarrow$ Replicant 2.2]
      \item Qualcomm:
        \begin{itemize}
        \item MSM7K: The modem controlled:
          \begin{itemize}
          \item The boot, RAM and storage of the device
          \item The audio (and most probably the microphone)
          \end{itemize}
        \item QSD8K: issues:
          \begin{itemize}
          \item Nexus one required nonfree audio firmware for having working calls
          \item The audio (and most probably the microphone)
          \item No strong guarantee about the modem isolation
          \item Too much nonfreee libs
          \item Mainline status
          \item Too much proprietary libs nowadays
          \end{itemize}
        \item We leanred about all that while working on Replicant.
        \end{itemize}
      \end{itemize}
    \end{block}
  \end{frame}
}

%% TODO: Backup slide with list of proprietary libs of a modern qualcomm SOC
\begin{frame}
  \center{Code substainability}
  \begin{itemize}
  \item Required very little maintenance and time (quick and dirty hacks)
  \item Porting to a new Android version:
    \begin{itemize}
    \item 3D acceleration:
      \begin{itemize}
      \item No free driver at the time
      \item We needed to to make graphics fast without 3D acceleration
      \item Lack of 3D acceleration gets less and less supported by Android source code over time
      \item Example: Nexus One
      \end{itemize}
    \item Linux code not upstream $\rightarrow$ Total dependency on Android upstream
    \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}
  \center{Devices substainability}
  \begin{itemize}
  \item Removable batteries
  \item Little RAM
  \item Nightmare-like freedom issues:
    \begin{itemize}
    \item $\rightarrow$ Very strong incentive to discontinue support for them
    \item $\rightarrow$ negligeable freedom gained by installing Replicant
    \item $\rightarrow$ Replicant was still useful as support when better devices were added later
    \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}
  \center{Replicant phase 2: Replicant 2.3 $\rightarrow$ Replicant 4.0}
  \begin{itemize}
  \item More freedom but required more work
    \begin{itemize}
    \item Required to continue reverse engineering the modem protocol (easy but long)
    \item Nonfree libraries to replace varies across devices. Examples: Camera, audio, etc
    \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}
  \center{Devices substainability and freedom blockers}
  \begin{itemize}
  \item Nonfree and signed bootloaders that are very hard or impossible to replace
  \item Devices without modem isolation guarantees %% Have been dropped later
  \item WiFi, Bluetooth, GPS
  \item Enough RAM (1GB or more) on all the supported devices %% TODO: check with tablets
  \end{itemize}
\end{frame}

\begin{frame}
  \center{Code substainability}
  \begin{itemize}
  \item Porting to a new Android version can take quite some time:
    \begin{itemize}
    \item Still need to make it fast without 3D acceleration
    \item Still have Total dependency on Android upstream (Linux code not upstream)
    \end{itemize}
  \end{itemize}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
  \center{Replicant phase 3: GNU/Linux devices on Replicant 4.2}
  \begin{itemize}
  \item The GTA04 from Golden Delicious has a free software bootloader
  \item The Optimus black (p970) from LG has a bootloader that is not signed
  \end{itemize}
\end{frame}

\begin{frame}
  \center{GTA04}
  \begin{itemize}
  \item Some limited Replicant 4.2 support (based on Android 4.2)
  \item Got suspend issues with Replicant 6 (kernel)
  \item Too much work
  \item unfinished
  \end{itemize}
\end{frame}

\begin{frame}
  \center{Optimus black (p970)}
  \begin{itemize}
  \item Required a lot of work by Paul Kocialkowski\cite{freeing-a-phone-from-the-ground-up}
  \item Bootloader: The code is now upstream in u-boot
  \item Linux: Very minimal support upstream
    \begin{itemize}
    \item working: microSD, USB
    \item lacking: No display driver, sound etc
    \end{itemize}
  \item Also unfinished
  \end{itemize}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
  \center{Replicant phase 4: Back to supported devices}
  \begin{itemize}
  \item Android 6 outdated
  \item Samsung devices still supported
  \end{itemize}
\end{frame}

\begin{frame}
  \center{Samsung devices that are or can be supported by Replicant 6.0}
  \begin{itemize}
  \item Exynos or OMAP System on a chip
  \item The modems in it have been customized by samsung use the same vendor-specific protocol
  \item Very large number of unit sold:
    \begin{itemize}
    \item 70 million units for the Galaxy SIII
    \item Easy to find second hand
    \end{itemize}
  \item Isolated modem for currently supported devices
  \item Removable battery for smartphones and somewhat removable for tablets
  \item Nonfree and signed bootloader
  \item WiFi doesn't work out of the box
  \end{itemize}
\end{frame}

\begin{frame}
  \center{Android requirements}
  \begin{itemize}
  \item RAM $\leftarrow$ $\rightarrow$ Display
  \end{itemize}
\end{frame}

\begin{frame}
  \center{Supported Tablets (Replicant 6.0)}
  \begin{itemize}
  \item All have internal batteries (still possible to remove them)
  \end{itemize}
\end{frame}

\begin{frame}
  \center{Images of removable batteries}
\end{frame}

\begin{frame}[plain,allowframebreaks]{title}
  \begin{xtabular}{cccccc}
    \hline
    Device & Unit solds & Launch date & RAM & GPU driver\\
    \hline
    Galaxy S II (I1300) & 40 Millions & 2011 & 1GB & Lima \\
    \hline
    Galaxy S III (I9300) & 70 Millions & 2012 & 1GB & Lima \\
    \hline
    Galaxy Note (N7000)  & 10 Millions & October 2011 & 1GB & Lima \\
    \hline
    Galaxy Note II (N7100)  & 30 Millions & October 2012 & 2GB & Lima \\
    \hline
    Galaxy Nexus (I9250) & ? & October 2011 & 1GB & PowerVR \\
    \hline
  \end{xtabular}
\end{frame}

\begin{frame}
  \center{Supported Tablets (Replicant 6.0)}
  \begin{itemize}
  \item All have removable batteries
  \end{itemize}
\end{frame}

\begin{frame}[plain,allowframebreaks]{title}
  \begin{xtabular}{cccccc}
    \hline
    Device & Unit solds & Launch date & RAM & GPU driver\\
    \hline
    Galaxy Tab 2 7.0 (P3100) & ? & ? & ? & PowerVR \\
    \hline
    Galaxy Tab 2 7.0 WiFi (P3110) & ? & ? & ? & PowerVR \\
    \hline
    Galaxy Tab 2 10.1 (P5100) & ? & ? & ? & PowerVR \\
    \hline
    Galaxy Tab 2 10.1 WiFi (P5110) & ? & ? & ? & PowerVR \\
    \hline
    Galaxy Note 8.0 (N5100) & ? & ? & ? & ? \\
    \hline
    Galaxy Note 8.0 Wi-Fi (N5110) & ? & ? & ? & ? \\
    \hline
  \end{xtabular}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
  \center{Replicant phase 5: Making Replicant substainable: second attempt}
\end{frame}

\begin{frame}
  \center{Making Replicant substainable}
  \begin{itemize}
  \item Got some funding from Handshake and NlNet
  \item $\rightarrow$ Spend the money on making Replicant substainable
  \end{itemize}
\end{frame}

\begin{frame}
  \center{Not out yet:}
  \begin{itemize}
  \item Librem5 from Puri.sm
  \item Pine Phone from Pine64
  \item NC-1 from Necunos
  \end{itemize}
\end{frame}

\begin{frame}
  \center{Other devices}
  \begin{itemize}
  \item GTA04: Not produced anymore
  \item Neo900: Would have needed more funding to start the production
  \end{itemize}
\end{frame}

\begin{frame}
  \center{Let's continue supporting the devices we already support}
  \begin{itemize}
  \item Galaxy SIII (I9300), Galaxy Note II(N7100)
    \begin{itemize}
    \item Good but uncomplete upstream support $\rightarrow$ Let's finish it
    \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}
  \center{Replicant 9}
  \begin{itemize}
  \item Work in progress
  \item Using a kernel closely based on upstream (0 Android patches in it so far)
  \item Modem drivers upstreaming not started yet
  \end{itemize}
\end{frame}

\begin{frame}
  \center{Let's keep 2D acceleration working}
  \begin{itemize}
  \item Let's be caucious and future proof:
    \begin{itemize}
    \item No free drivers for PowerVR GPUs
    \item Free drivers might go away as hardware change
    \item $\rightarrow$ Lima doesn't support
    \end{itemize}
  \item It payed off:
    \begin{itemize}
    \item Good enough speed with 2D acceleration
    \item Mali 400 $\rightarrow$ Lima is not ready yet but accept bugreports
    \item Lima and even Panfrost don't support vulkan yet
    \item Vulkan will be required for new devices shipping with Android 10, unless the device has a low amount of memory
    \item $\rightarrow$ Vulkan will be more and more required
    \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}
\outputpicture{1}{virtuous_circle.png}
\end{frame}

\begin{frame}
  \center{Effects of using Linux upstream}
  \begin{itemize}
  \item Require more time
  \item $\rightarrow$ We cannot support devices with non-replacable batteries
  \item Uses upstream kernel
  \item $\rightarrow$ Not tied to hardware specific vendor libraries
  \item $\rightarrow$ We can share the work with GNU/Linux
  \item $\rightarrow$ We will be able to more easily add support for devices running GNU/Linux    
  \end{itemize}
\end{frame}

\begin{frame}
  \center{We also want to use GNU/Linux userspace hardware support projects}
  \begin{itemize}
  \item Easier to add support for GNU/Linux devices in Replicant
  \item Or to add support for Replicant supported devices in GNU/Linux
  \item Share the maintenance with communities more interested in freedom
  \item GNU/Linux tools and distributions can be used for testing too
  \item People buying GNU/Linux smartphones could also run Android if GNU/Linux is not ready yet for them
  \item People having Replicant compatibles smartphones could also run GNU/Linux on it if it's ready for them
  \end{itemize}
\end{frame}

\begin{frame}
  \center{Fully GNU/Linux free distributions for ARM}
  \begin{itemize}
  \item Guix: armv7h, arm64
  \item Parabola: armv7h, based on Archlinux
  \item PureOS: arm64, based on Debian
  \end{itemize}
\end{frame}

\begin{frame}
  \center{How to not drop devices:}
  \begin{itemize}
  \item Get to the same freedom than future devices:
    \begin{itemize}
    \item Free software bootloader
    \item Free WiFi and Bluetooth firmwares
    \item GPS (library + firmware)
    \end{itemize}
  \item Enough RAM or obtimisations
  \item Hardware documentation and repair guides under a free license
  \end{itemize}
\end{frame}

\begin{frame}
  Licenses:
  \begin{itemize}
  \item The SIM card and BTS pictures comes from \url{https://en.wikipedia.org/wiki/File:Gsm_network.png} and are under the GFDL 1.2 or the Creative commons Attributions-Share ALike 3.0 Unported.
    \begin{itemize}
    \item GSM: \url{http://wiki.openmoko.org/wiki/QtMoko}
    \item SHR pictures: \url{http://wiki.openmoko.org/wiki/SHR_User_Manual}
    \end{itemize}
  \item HTC Dream: \url{https://commons.wikimedia.org/wiki/File:HTC_Dream_opened.jpg}
    Creative Commons Attribution 3.0 Unported
  \item \url{https://creativecommons.org/licenses/by-sa/4.0/} for the rest.
  \end{itemize}
\end{frame}

\begin{thebibliography}{99}
\bibitem{freeing-a-phone-from-the-ground-up}
  \url{https://code.paulk.fr/article20/a-hacker-s-journey-freeing-a-phone-from-the-ground-up-first-part}
  \url{https://code.paulk.fr/article21/a-hacker-s-journey-freeing-a-phone-from-the-ground-up-second-part}
  \url{https://code.paulk.fr/article22/a-hacker-s-journey-freeing-a-phone-from-the-ground-up-third-part}
  \url{https://code.paulk.fr/article23/a-hacker-s-journey-freeing-a-phone-from-the-ground-up-fourth-part}
\bibitem{last-android-6-update}
  \url{https://en.wikipedia.org/wiki/Android Marshmallow}
\bibitem{porting-to-android-9}
  \url{https://redmine.replicant.us/projects/replicant/wiki/PortingToAndroid9}
\end{thebibliography}
\end{document}
