We can't use File.canWrite() on files that do not exist yet. After all we are
going to create the file in a folder that we just created. So it is very
unlikely that writing to that folder is going to fail.
We don't expect to access any providers cross-package. (At one time
the android-sync repository did, but those days are long past.) Not
exporting these content providers may also avoid some bugs we've seen
that look like content providers from Aurora being loaded into
Nightly's process or vice versa.
DONTBUILD NPOTB on a CLOSED TREE
The patch is horrific, but it's just find-and-replace of the test
runner class name, followed by organizing the imports (in the way that
IntelliJ likes them.)
This exports the buildDir to Robolectric via an Android-Gradle
buildConfigField, and then lightly massages the existing test runner
to use the exported value.
This gets us a limited version of AAR support: we can consume static
AAR libraries, where here static does not refer to linking, but to
static assets that are fixed at build-backend time and not modified
(or produced) during the build. This lets us pin our dependencies
(and move to Google's versioned Maven repository packages, away from
Google's unversioned ad-hoc packages).
By restricting to static AAR libraries, we avoid having to handle
truly complicated dependency trees, as changing parts of generated AAR
files require delicate rebuilding of the APKs (and internal libraries)
that depend on the AAR files.
It is possible that we will generate AARs in the tree at some time.
Right now, we don't do that, even for GeckoView: the AARs produced are
assembled as artifacts at package time and are intended for external
consumption. We might want this for GeckoView and Fennec at some
time; we should consider using Gradle everywhere at that point.
The patch itself does the simplest possible thing (which has precedent
from Gradle and other build systems): it simply "explodes" the AAR
into the object directory and uses existing mechanisms to refer to the
exploded pieces.
AARs have both required and optional components. Each component is
defined with an expected and required flag. If a component is expected
and not present, or not expected and is present, an error is raised.
If the component is expected and present, autoconf's ifelse() macro is
used to define the relevant AAR_* component variables. If the
component is not expected and not present, no action is taken. A
consuming build backend therefore can guard all AAR_* component
variables with just the top-level AAR variable.
Many AAR files have empty assets/ directories. This patch doesn't
explode empty assets/ directories, protecting against trivial changes
to AAR files that don't impact the build.
There's a lot not to like in this approach, including:
* We need to manually reference internal AAR libs;
* I haven't separated the pinned version numbers out of configure.in.
However, it's closer to what we want than what we have!
This commit is us getting out of our own way. We were specifying
-classpath twice, once in $(JAVAC) and once in java-build.mk. Only
the latter of these is active. This a problem for ANDROID_EXTRA_JARS
-- those JARs should be on the classpath and input to $(DX) -- and
JARs that should be on the classpath but *not* input to $(DX). This
commit removes the global flags to $(JAVAC) and adds
JAVA_{BOOT}CLASSPATH_JARS. This required some hijinkery moving
wildcards to moz.build files, but everything seems to work.
As well as clarifying some parts of the build, part 2 uses this work
to modify the classpath.
This paves the way for defining additional Android packages in
moz.build, which is a step toward moving the special
mobile/android/base/Makefile.in aapt invocations into the generic
java-build.mk framework.
The new variables are both passthru variables for now: in the future,
we'll roll them into some aggregate Android APK definition.
It's worth noting that references to the variables in Makefile.in
files are only defined after including rules.mk (and thereby
backend.mk). This only required a few changes in the tree but it
confused me for some time.
This is just cruft; I didn't want to think about it when working on
the other parts. Bug 1196367 tracks removing the AndroidEclipse build
backend that consumed these definitions entirely.
This is a reasonable-sized refactoring underneath a small feature-patch.
The refactor reworks what information we maintain (and pickle) about
"enabled" services. We've moved from a boolean "Sync enabled" flag to a
map of Android authorities (which map to services like Firefox Sync and
reading list) and boolean flags indicating whether each authority is
"automatically synced". The checkboxes in the status activity
correspond directly to whether the authority (service) is automatically
synced.
The set of authorities we care about is determined by the DEFAULT_* map.
Said map is interrogated and written to the pickle file at Sync time.
When the pickle file is un-pickled, only the set of known authorities is
acted upon. What that means is that both writing and reading a pickle
file with different sets of authorities should work across upgrades: if
a known authority is missing, the default value will be used; if an
unknown authority is present, it will be ignored. This lets us alter
the set of known authorities via the build flag.
I have tested and Android maintains the "sync automatically" state for
an authority even when the authority is not present in the list of sync
checkboxes.
All in all, I'm not concerned about toggling the build flag multiple
times in the future. (If we backed out the updated pickling code, we
would need to handle pickle downgrades, but we already needed to handle
that.)
========
https://github.com/mozilla-services/android-sync/commit/fc8936549a7ae77213736540f8701a561f73de4f
Author: Nick Alexander <[email protected]>
Date: Wed Feb 11 10:37:34 2015 -0800
Bug 1123107 - Part 3: Include Reading List checkbox during account creation.
We are careful to show the checkbox only when the reading list service
is enabled.
========
https://github.com/mozilla-services/android-sync/commit/c90ea353cc4e4426ba5ba24b3dda21e0032c4b01
Author: Nick Alexander <[email protected]>
Date: Wed Feb 11 10:31:15 2015 -0800
Bug 1123107 - Part 2: Thread authorities to sync automatically through sign up/sign in flow.
========
https://github.com/mozilla-services/android-sync/commit/e0c4d2074431ef1647ed9ae6ea5578316a1e5707
Author: Nick Alexander <[email protected]>
Date: Mon Feb 9 12:35:15 2015 -0800
Bug 1123107 - Part 1: Manage map of automatically synced authorities.
========
https://github.com/mozilla-services/android-sync/commit/7f7e308190f792a47dbb640dd6e0acdb0b08212e
Author: Nick Alexander <[email protected]>
Date: Mon Feb 9 11:54:54 2015 -0800
Bug 1123107 - Part 0: Remove "account needs to be enabled" warning in status activity.
As we move Sync to a model where a status checkbox sets whether a single
ContentProvider is synced, it no longer makes sense to message when the
"account" is not automatically syncing.
========
https://github.com/mozilla-services/android-sync/commit/5dec5a7929c418153846ea1dce3dc00a4ef75cb6
Author: Nick Alexander <[email protected]>
Date: Wed Dec 17 18:03:44 2014 -0800
Bug 956444 - Post: Persist fetch timestamp on 404.
I imported and modified your old code; this looks like an oversight from
there, but I want to call it out. If we don't persist the timestamp,
then the stamp persisted to config is always -1, meaning we GET (and
404) the credentials on every sync. You have code to compare
info/collections against the fetched timestamp so I think we should
persist even on 404.
========
https://github.com/mozilla-services/android-sync/commit/520341ce660c332626064087c0d8a6de0f36b8ce
Author: Richard Newman <[email protected]>
Date: Thu Jan 2 20:44:58 2014 -0800
Bug 956444 - Part 2: Fetch and process meta/fxa_credentials migration sentinel.
This adds a Sync stage that tries to create a new Firefox Account in the
MigratedFromSync11 state when a known migration sentinel is seen.
========
https://github.com/mozilla-services/android-sync/commit/2f4ea5c14b96c95564f0cc4a0d7241767bf0c15b
Author: Nick Alexander <[email protected]>
Date: Fri Dec 12 16:44:25 2014 -0800
Bug 956444 - Part 1: Add informMigrated callback.
GlobalSession and Sync stages don't have access to the Android Account
object. This callback maintains the existing information hiding.
========
https://github.com/mozilla-services/android-sync/commit/11a8f6c1ef23580e6a61759bda909e86b588c040
Author: Nick Alexander <[email protected]>
Date: Fri Dec 12 16:26:02 2014 -0800
Bug 956444 - Pre: Unpickle accounts during package upgrade.
This makes it a little easier to test: you can |adb push| or |adb shell
echo ''| a known sync.accounts.json file onto device and then re-install
the package to restore a known Sync Account.
These manifests are special in that they don't package their test files
into the test package. Each test listed in an instrumentation manifest
serves as an identifier rather than a file.
========
https://github.com/mozilla-services/android-sync/commit/3cd96669bc109c0e381dd52e3e289b251d3eef31
Author: Nick Alexander <[email protected]>
Date: Mon Aug 18 17:43:24 2014 -0700
Bug 1026005 - Review comments.
========
https://github.com/mozilla-services/android-sync/commit/5aefe1f716fdc54155c121beb4aa0d3da6196c0e
Author: Nick Alexander <[email protected]>
Date: Mon Jun 16 11:16:16 2014 -0700
Bug 1026005 - Part 2: Add AccountLoader.
========
https://github.com/mozilla-services/android-sync/commit/61bc36bd7df7342b04bc21eb388c46345cf1ee0e
Author: Nick Alexander <[email protected]>
Date: Mon Jun 16 11:12:37 2014 -0700
Bug 1026005 - Part 1: Add and broadcast ACCOUNT_STATE_CHANGED_ACTION.
========
https://github.com/mozilla-services/android-sync/commit/9d80df0aa74c8c9ec0e107e41696f8af6273938d
Author: Nick Alexander <[email protected]>
Date: Mon Aug 18 17:42:11 2014 -0700
Bug 1026005 - Pre: Allow testing with |mvn integration-test|.
This avoids errors like:
W dalvikvm(24082) Class resolved by unexpected DEX: Lorg/mozilla/gecko/fxa/AccountLoader;(0x42c13358):0x75440000 ref [Landroid/support/v4/content/AsyncTaskLoader;] Landroid/support/v4/content/AsyncTaskLoader;(0x42c13358):0x74a71000
W dalvikvm(24082) (Lorg/mozilla/gecko/fxa/AccountLoader; had used a different Landroid/support/v4/content/AsyncTaskLoader; during pre-verification)
W dalvikvm(24082) Unable to resolve superclass of Lorg/mozilla/gecko/fxa/AccountLoader; (247)
W dalvikvm(24082) Link of class 'Lorg/mozilla/gecko/fxa/AccountLoader;' failed
E dalvikvm(24082) Could not find class 'org.mozilla.gecko.fxa.AccountLoader', referenced from method org.mozilla.gecko.background.fxa.TestAccountLoader.testInitialLoad
W dalvikvm(24082) VFY: unable to resolve new-instance 1299 (Lorg/mozilla/gecko/fxa/AccountLoader;) in Lorg/mozilla/gecko/background/fxa/TestAccountLoader;
D dalvikvm(24082) VFY: replacing opcode 0x22 at 0x0005
W dalvikvm(24082) Class resolved by unexpected DEX: Lorg/mozilla/gecko/fxa/AccountLoader;(0x42c13358):0x75440000 ref [Landroid/support/v4/content/AsyncTaskLoader;] Landroid/support/v4/content/AsyncTaskLoader;(0x42c13358):0x74a71000
W dalvikvm(24082) (Lorg/mozilla/gecko/fxa/AccountLoader; had used a different Landroid/support/v4/content/AsyncTaskLoader; during pre-verification)
W dalvikvm(24082) Unable to resolve superclass of Lorg/mozilla/gecko/fxa/AccountLoader; (247)
W dalvikvm(24082) Link of class 'Lorg/mozilla/gecko/fxa/AccountLoader;' failed
D dalvikvm(24082) DexOpt: unable to opt direct call 0x1df8 at 0x07 in Lorg/mozilla/gecko/background/fxa/TestAccountLoader;.testInitialLoad
I TestRunner(24082) started: testInitialLoad(org.mozilla.gecko.background.fxa.TestAccountLoader)
I TestRunner(24082) failed: testInitialLoad(org.mozilla.gecko.background.fxa.TestAccountLoader)
I TestRunner(24082) ----- begin exception -----
I TestRunner(24082)
I TestRunner(24082) java.lang.NoClassDefFoundError: org.mozilla.gecko.fxa.AccountLoader
I TestRunner(24082) at org.mozilla.gecko.background.fxa.TestAccountLoader.testInitialLoad(TestAccountLoader.java:145)
I TestRunner(24082) at java.lang.reflect.Method.invokeNative(Native Method)
I TestRunner(24082) at java.lang.reflect.Method.invoke(Method.java:525)
I TestRunner(24082) at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
I TestRunner(24082) at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
I TestRunner(24082) at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)
I TestRunner(24082) at junit.framework.TestCase.runBare(TestCase.java:134)
I TestRunner(24082) at junit.framework.TestResult$1.protect(TestResult.java:115)
I TestRunner(24082) at junit.framework.TestResult.runProtected(TestResult.java:133)
I TestRunner(24082) at junit.framework.TestResult.run(TestResult.java:118)
I TestRunner(24082) at junit.framework.TestCase.run(TestCase.java:124)
I TestRunner(24082) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
I TestRunner(24082) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
I TestRunner(24082) at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
I TestRunner(24082) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1738)
I TestRunner(24082) ----- end exception -----
I TestRunner(24082) finished: testInitialLoad(org.mozilla.gecko.background.fxa.TestAccountLoader)
This is the expedient thing to do. The right thing to do is to
deprecate Sync's clients database in favour of Fennec's clients table,
but that's a good chunk of work for a small gain.