Marketplace/OpenMobile: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(whitespace changes)
(better formatting for code)
Line 17: Line 17:
=== Install Flow ===
=== Install Flow ===


When the user launches their app, the app checks if an ACL is present and if not, calls a ''marketplace-openmobile-acl'' WebActivity to install one.
When the user launches their app, the app checks if an ACL is present and if not, calls a <code>marketplace-openmobile-acl</code> WebActivity to install one.


When the activity is trigged, the package passes down the value of
When the activity is trigged, the package passes down the value of
''getFeature('acl.version')'' to the activity message it sends the iframed code
<code>getFeature('acl.version')</code> to the activity message it sends the iframed code
(necessary because ''getFeature()'' is a privileged API).
(necessary because <code>getFeature()</code> is a privileged API).


The iframed code ([https://github.com/mozilla/fireplace/blob/master/src/media/js/webactivities.js webactivites.js]) then parses the ''acl_version'' parameter that the package sent. It's in the following form:
The iframed code ([https://github.com/mozilla/fireplace/blob/master/src/media/js/webactivities.js webactivites.js]) then parses the <code>acl_version</code> parameter that the package sent. It's in the following form:
''DEVICE;PRODUCT;MODEL;GSL_VERSION;<ACL_VERSION>''
<code>DEVICE;PRODUCT;MODEL;GSL_VERSION;<ACL_VERSION></code>


If ''ACL_VERSION'' exists, then it means an ACL is already installed and the activity returns an error.
If <code>ACL_VERSION</code> exists, then it means an ACL is already installed and the activity returns an error.


Otherwise, it checks ''PRODUCT'' to determine which ACL app to install, and manually triggers the install of the ACL app. Since that means downloading a big package, it shows the ACL app detail page with its install button spinning to make the user wait.
Otherwise, it checks <code>PRODUCT</code> to determine which ACL app to install, and manually triggers the install of the ACL app. Since that means downloading a big package, it shows the ACL app detail page with its install button spinning to make the user wait.


Once the install of the ACL app is done, Marketplace launches the ACL app and let the activity return successfully to its caller.
Once the install of the ACL app is done, Marketplace launches the ACL app and let the activity return successfully to its caller.


The activity also returns an error to its caller if anything goes wrong:
The activity also returns an error to its caller if anything goes wrong:
unknown ''PRODUCT'', install failure, etc.
unknown <code>PRODUCT</code>, install failure, etc.


=== Checking for compatibility ===
=== Checking for compatibility ===


We don't want to show apps requiring an ACL to devices without a GSL - since both components are necessary it would not work. Therefore, we have a feature flag that's enabled when ''getFeature('acl.version')'' returns something. That feature flag is hidden to regular developers but available for admins to change in the devhub.
We don't want to show apps requiring an ACL to devices without a GSL - since both components are necessary it would not work. Therefore, we have a feature flag that's enabled when <code>getFeature('acl.version')</code> returns something. That feature flag is hidden to regular developers but available for admins to change in the devhub.


=== Faking ACL/GSL presence ===
=== Faking ACL/GSL presence ===


Through ''adb shell setprop persist.acl.version'', we can set the value returned in ''getFeature("acl.version")'' calls, allowing us to pretend a GSL and/or an ACL are installed:
Through <code>adb shell setprop persist.acl.version<code>, we can set the value returned in <code>getFeature("acl.version")</code> calls, allowing us to pretend a GSL and/or an ACL are installed:


  # Double quotes are necessary for adb, Single quotes around it are to prevent
  # Double quotes are necessary for adb, Single quotes around it are to prevent
  # your own shell from parsing the double quotes for itself.
  # your own shell from parsing the double quotes for itself.
  $ adb shell setprop persist.acl.version '";P172R12"'
  $ adb shell setprop persist.acl.version '";P172R12"'
  # Check that everything works is correct by doing:
  # Check that everything works is correct by doing:
  $ adb shell getprop persist.acl.version
  $ adb shell getprop persist.acl.version


Remember: when manipulating the string via adb, you need the ''persist.'' prefix, but it's not used when calling ''getFeature()''.
Remember: when manipulating the string via adb, you need the <code>persist.</code> prefix, but it's not used when calling <code>getFeature()</code>.

Revision as of 15:57, 1 September 2015

OpenMobile ACL and Marketplace

Intro

OpenMobile's Application Compatibility Layer (ACL)™ enables Android apps to run on non-Android operating systems. Specifically in our case, Firefox OS.

The flow is unfortunately rather complicated and involves Marketplace. Only specific devices can work with the whole thing, because it needs some code from OpenMobile on the device on top of the code that we install via Marketplace. In addition, some specific gecko patches are required.

There are 3 parts:

  • GSL is the Generic Service Loader. It's the OpenMobile code that lives on compatible devices. It's already installed by the manufacturer.
  • ACL is the Application Compatibility Layer. It's also OpenMobile code, but it is installed dynamically on the devices via Marketplace when an app relying on it is launched. It's an app itself, so the rest of this doc calls it "ACL app" sometimes.
  • The app that the end-user wants to use. It's wrapped into a special kind of webapp that includes the Android APK and some code to download the ACL to make everything work.

Install Flow

When the user launches their app, the app checks if an ACL is present and if not, calls a marketplace-openmobile-acl WebActivity to install one.

When the activity is trigged, the package passes down the value of getFeature('acl.version') to the activity message it sends the iframed code (necessary because getFeature() is a privileged API).

The iframed code (webactivites.js) then parses the acl_version parameter that the package sent. It's in the following form: DEVICE;PRODUCT;MODEL;GSL_VERSION;<ACL_VERSION>

If ACL_VERSION exists, then it means an ACL is already installed and the activity returns an error.

Otherwise, it checks PRODUCT to determine which ACL app to install, and manually triggers the install of the ACL app. Since that means downloading a big package, it shows the ACL app detail page with its install button spinning to make the user wait.

Once the install of the ACL app is done, Marketplace launches the ACL app and let the activity return successfully to its caller.

The activity also returns an error to its caller if anything goes wrong: unknown PRODUCT, install failure, etc.

Checking for compatibility

We don't want to show apps requiring an ACL to devices without a GSL - since both components are necessary it would not work. Therefore, we have a feature flag that's enabled when getFeature('acl.version') returns something. That feature flag is hidden to regular developers but available for admins to change in the devhub.

Faking ACL/GSL presence

Through adb shell setprop persist.acl.version, we can set the value returned in getFeature("acl.version") calls, allowing us to pretend a GSL and/or an ACL are installed:

# Double quotes are necessary for adb, Single quotes around it are to prevent
# your own shell from parsing the double quotes for itself.
$ adb shell setprop persist.acl.version '";P172R12"'

# Check that everything works is correct by doing:
$ adb shell getprop persist.acl.version

Remember: when manipulating the string via adb, you need the persist. prefix, but it's not used when calling getFeature().