Turn your phone into a "cloud phone" with Raspberry Pi, is it possible?
Tags: android, webdev, pwa, ux
Published: 2021-04-23 12:20:28

In recent years, I have been experimenting with a concept that I called the "Device independent cloud computing with cloud first approach". This might sounds like a title of a academic paper (maybe I will write a paper about it one day) and this concept might be new to everyone except those in the [ArozOS](https://github.com/tobychui/arozos) development group. It actually boils down to two really simple concepts.

1. Everything is done on the cloud platform, independent on the device connecting to it
2. No local storage should be used unless it is strictly necessary (aka the "cloud first approach" part)

**Spoiler alert: This is not a technical post. This post investigate and discuss the concept of full cloud powered ecosystem and comparing it with the cloud assists model that we are currently using.**
<sub><sup>No worry, I will put in a bunch of diagrams so it is not that boring to read :P</sup></sup>

## Current Cloud Service
Lets talk about cloud phone. The first things come up to your mind maybe a phone with Google Cloud Services (Drive / Photo etc) or connected to your own NAS through NAS supplier's apps. If you are really into Android phones, you might have heard about a "cloud phone" named "Nextbit Robin". These are the examples what I called the "Cloud Assisted Model". In simple words, they work like this:
![current model](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xxufsbkl5obszhkdctcb.png)
 
They assists the main device that require additional storage or computation power. 

## What has changed?
The current environment is actually best fitted for such a cloud integrated system to exists. The most critical reasons are

1. Many people have now access to acceptably fast internet at home, at work, at university or even outdoor with 5G networks.
2. WebApp integration on native OS / devices are getting better (e.g. Progress Web Apps, mediaSession API)
3. All major platforms already have web browser built-in (Linux, Windows, MacOS, Android, iOS)

So in theory, you can run web application anywhere on any modern devices now, even the device is not owned by you, you can still run / login to your account and do personalized stuffs on it. (Like logging into your Google Drive on your friend's laptop to edit your document)

This is also what happens to the "cloud era" as more and more users started to shift their workload to cloud. However, they still keep part of the works in local device.

![native vs cloud](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4b7pvme7tuen6jedhzs3.png)
 
## Wait, isn't this already exists?
Yes, remote file access protocol exists for ages. I guess most of the user who used a NAS before should know about either SMB, WebDAV or FTP. These are the traditional methods for editing a file on a remote server. These are great but all of them have their own limitation. Furthermore, you still need to have the application installed on your machine in order to access or open the file transferred using that protocol. (e.g. You need an FTP client to access a remote file, or you need a video player to play a remote file serve by smb protocol)

Instead of requiring a specific software on your native machine, pushing the software to the cloud server can further save you some space and dependencies on your local machine. Making your file more accessible on wider range of platforms. 

![ftp vs cloud](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/71zyjv6mozl2xs9sfb25.png)
 

## How "Cloud First" approach could be implemented? 
Since 2016, I have been working on a project called "ArozOS". 
{% github tobychui/arozos %}

It is a tiny cloud system that can run on top of a Raspberry Pi and offer full web desktop experience on any modern portable computational devices. I have written another post for this system. If you haven't read about it, you can take a look at [here](https://dev.to/tobychui/i-write-my-own-web-desktop-os-for-3-years-and-this-is-what-it-looks-like-now-2903).

In this system, I have implemented two of the most important WebApps to testify this concept: The Music and Video module.

To try out the Raspberry Pi powered "cloud phone", I got myself a used Sony XZ1 Compact for testing. It has little RAM and storage, and it was sold really cheap online for less then 50USD. I only install the cloud enabled apps on it and use it for media consumption purpose. 

Using Chrome, I can add both of the application to home screen as an PWA WebApp. The icons and starting path can all be defined in the mainfest.json file. 

![2021-04-23_19-01-21](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o2twxm8rmd8tulnli067.png)

Music WebApp running in fullscreen PWA mode
![DSC_2429](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/psk0l90w614e2as9ijbf.png)

Video WebApp running in standalone PWA mode
![DSC_2431](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oyg7aiorp0ctv2gegxv2.png)

And here are two screenshots directly captured on the Android phone for reference

![Screenshot_20210423-185919](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nt7my6qewb9c1j2wjref.png)
![Screenshot_20210423-185942](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0vpywbzuvpw5w71ziy0b.png)

Looks like a native Android App right?

So you might wonder, how is the experience of using this system compare to some native audio player on Android? For me, there is not much difference between using this player compare to the build in Music player offer by Sony mobile as well as the VLC media player. Powered by the ArozOS file system, everything can be accessed via its File Manager on my desktop's browser so it is very easy to upload new music to the Raspberry Pi (and the "cloud phone") when I got a few new CDs. Compare to the traditional way of using Cloud which require a download and a native application for opening the file, this seems to make my life easier.
![file open process](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/er6862z2z4sunctjo4h1.png)
 

This method of file storage also prevented the creation of duplicated files. Let say you own a few devices and you work on the same file on different devices at different time period. Then this will create a file synchronization problem. (Something like git merge conflict?)
![sync and delay](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4wq0q0r38r4vqhieyfsz.png)
 
I do understand modern synchronization is complex and most likely it can handle something like this. But why make it complex if you can just host the file on a network location that allow editing? 

## The Cons of using cloud first approach
Of course, everything has its pros and cons. The problem with this method of media consumption is 
1. Power hungry, it use up the battery relatively faster than local storage, specially on mobile network. 
2. Large files are loading slow. But with new implementation of the media server in ArozOS, streaming is much faster now then the previous test I have done last month
3. Browser support a less broad types of files. Some files might be unable to play on specific platforms.

## Conclusion
In summary, as internet are getting cheaper (at least in Asia), and with a growing number of devices owned per person, I think this might be the future of how cloud will evolve into. Instead of backing up files and photos to cloud storage, people will just move all their whole workload to the cloud if they started to have many devices to deal with. We are already seeing trends of people using cloud notebooks, office tool sets, cloud video editing / rendering and more services that used to be desktop only.

Finally, if you are interested to try out the PWA experience of Music playback and Video streaming, feel free to get a copy of ArozOS over here.
{% github tobychui/arozos %}

Let me know what you thought. Will PWA be the future of cloud and mobile application? If "cloud phone" reappear on the market in the near future, will you give it a try?