Commit Graph
36 Commits
Author SHA1 Message Date
Jan Henning f9dcd71f39 Bug 1336734 - Part 2 - Don't stop the GeckoNetworkManager unless we're really backgrounded. r=sebastian
Launching a new activity within our app triggers both onActivityPause() (the current activity) and onActivityResume() (the new activity) in GeckoApplication. The most prominent example at the moment are probably our preferences - entering/exiting/navigating within them always triggers a pause/resume combo. This means that currently each time this happens, the network manager is stopped only to be immediately restarted.

To prevent this, we now stop the network manager only when Gecko is actually being paused. In order to avoid unmatched start/stop calls, we need to treat the calls to start() similarly and provide an additional code path for the initial call to start() immediately after startup.

Since the BatteryManager is only started and currently never stopped, we can use this for its startup, too, so as to avoid duplicated calls to its start() method.

MozReview-Commit-ID: 6NdScT5cLYL
2017-02-05 15:47:51 +01:00
Wes Kocher 2c09640198 Backed out 3 changesets (bug 1336734) for android build bustage a=backout
Backed out changeset a7f9815aeec1 (bug 1336734)
Backed out changeset fa9cca3e321c (bug 1336734)
Backed out changeset a2b69382c9ad (bug 1336734)

MozReview-Commit-ID: FMKZ88jlEZ0
2017-02-10 12:52:33 -08:00
Jan Henning 6bb37e1b1e Bug 1336734 - Part 3 - Don't stop the GeckoNetworkManager unless we're really backgrounded. r=sebastian
Launching a new activity within our app triggers both onActivityPause() (the current activity) and onActivityResume() (the new activity) in GeckoApplication. The most prominent example at the moment are probably our preferences - entering/exiting/navigating within them always triggers a pause/resume combo. This means that currently each time this happens, the network manager is stopped only to be immediately restarted.

To prevent this, we now stop the network manager only when Gecko is actually being paused. In order to avoid unmatched start/stop calls, we need to treat the calls to start() similarly and provide an additional code path for the initial call to start() immediately after startup.

Since the BatteryManager is only started and currently never stopped, we can use this for its startup, too, so as to avoid duplicated calls to its start() method.

MozReview-Commit-ID: 6NdScT5cLYL
2017-02-05 15:47:51 +01:00
Sebastian Kaspari b07d54df7e Bug 1334562 - DLC: Start study action from BrowserApp.onCreate() and never in automation. r=ahunt
Previously we started the DLC service from GeckoApplication. The reason for that was that we wanted to
download content like fonts as early as possible so that they are available the next time we display
a website.

However we do not know whether we are running in automation until the BrowserApp activity is launched.
This patch will start the service from BrowserApp.onCreate() now if we are not running in automation.

MozReview-Commit-ID: C3Ob6S3yve4
2017-01-30 17:41:38 +01:00
Eugen Sawin 41fdce8093 Bug 1323429 - [2.1] Remove the context reference from Clipboard. r=jchen 2017-01-26 15:52:21 +01:00
Shan 7d1bbb428a Bug 1316021 - Remove unnecessary static fields; r=sebastian 2016-12-19 17:37:33 +01:00
Nick Alexander cc437a6158 Bug 1255914 - Part 2: mostly back out multiDex (changeset 6972bef6693c). r=sebastian
Since we're Proguarding the automation build now, we shouldn't need to
multiDex anymore -- even in beta.

MozReview-Commit-ID: 6Yc73Vi9Fhd
2016-11-13 14:43:00 -08:00
Jim Chen 0f80faec13 Bug 1307820 - Implement per-GeckoView messaging; r=snorp r=sebastian
Bug 1307820 - 1a. Move GeckoApp EventDispatcher to GeckoView; r=snorp

Make it a GeckoView-specific EventDispatcher instead of
GeckoApp-specific, so that GeckoView consumers can benefit from a
per-view EventDispatcher. In addition, a few events like Gecko:Ready are
moved back to the global EventDispatcher because that makes more sense.

Bug 1307820 - 1b. Don't use GeckoApp EventDispatcher during inflation; r=snorp

During layout inflation, we don't yet have GeckoView and therefore the
GeckoView EventDispatcher, so we should not register events until later,
typically during onAttachedToWindow.

Bug 1307820 - 2. Introduce GeckoBundle; r=snorp

The Android Bundle class has several disadvantages when used for holding
structured data from JS.

The most obvious one is the differentiation between int and double,
which doesn't exist in JS. So when a JS number is converted to either a
Bundle int or double, we run the risk of making a wrong conversion,
resulting in a type mismatch exception when Java uses the Bundle. This
extends to number arrays from JS.

There is one more gotcha when using arrays. When we receive an empty
array from JS, there is no way for us to determine the type of the
array, because even empty arrays in Java have types. We are forced to
pick an arbitrary type like boolean[], which can easily result in a type
mismatch exception when using the array on the Java side.

In addition, Bundle is fairly cumbersome, and we cannot access the inner
structures of Bundle from Java or JNI, making it harder to use.

With these factors in mind, this patch introduces GeckoBundle as a
better choice for Gecko/Java communication. It is almost fully
API-compatible with the Android Bundle; only the Bundle array methods
are different. It resolves the numbers problem by performing conversions
if necessary, and it is a lot more lightweight than Bundle.

Bug 1307820 - 3. Convert BundleEventListener to use GeckoBundle; r=snorp

Convert BundleEventListener from using Bundle to using GeckoBundle.
Because NativeJSContainer still only supports Bundle, we do an extra
conversion when sending Bundle messages, but eventually, as we eliminate
the use of NativeJSContainer, that will go away as well.

Bug 1307820 - 4. Introduce EventDispatcher interfaces; r=snorp

Introduce several new XPCOM interfaces for the new EventDispatcher API,
these interfaces are mostly mirrored after their Java counterparts.

* nsIAndroidEventDispatcher is the main interface for
  registering/unregistering listeners and for dispatching events from
  JS/C++.

* nsIAndroidEventListener is the interface that JS/C++ clients implement
  to receive events.

* nsIAndroidEventCallback is the interface that JS/C++ clients implement
  to receive responses from dispatched events.

* nsIAndroidView is the new interface that every window receives
  that is specific to the window/GeckoView pair. It is passed to chrome
  scripts through window arguments.

Bug 1307820 - 5. Remove EventDispatcher references from gfx code; r=snorp

EventDispatcher was used for JPZC, but NPZC doesn't use it anymore.

Bug 1307820 - 6. General JNI template improvements; r=snorp

This patch includes several improvements to the JNI templates.

* Context::RawClassRef is removed to avoid misuse, as Context::ClassRef
  should be used instead.

* Fix a compile error, in certain usages, in the DisposeNative overload
  in NativeStub.

* Add Ref::IsInstanceOf and Context::IsInstanceOf to mirror the
  JNIEnv::IsInstanceOf call.

* Add Ref::operator* and Context::operator* to provide an easy way to
  get a Context object.

* Add built-in declarations for boxed Java objects (e.g. Boolean,
  Integer, etc).

* Add ObjectArray::New for creating new object arrays of specific types.

* Add lvalue qualifiers to LocalRef::operator= and GlobalRef::operator=,
  to prevent accidentally assigning to rvalues. (e.g.
  `objectArray->GetElement(0) = newObject;`, which won't work as intended.)

Bug 1307820 - 7. Support ownership through RefPtr for native JNI objects; r=snorp

In addition to direct ownership and weak pointer ownership, add a third
ownership model where a native JNI object owns a RefPtr that holds a
strong reference to the actual C++ object. This ownership model works
well with ref-counted objects such as XPCOM objects, and is activated
through the presence of public members AddRef() and Release() in the C++
object.

Bug 1307820 - 8. Implement Gecko-side EventDispatcher; r=snorp

Add a skeletal implementation of EventDispatcher on the Gecko side.
Each widget::EventDispatcher will be associated with a Java
EventDispatcher, so events can be dispatched from Gecko to Java and vice
versa. AndroidBridge and nsWindow will implement
nsIAndroidEventDispatcher through widget::EventDispatcher.

Other patches will add more complete functionality such as
GeckoBundle/JSObject translation and support for callbacks.

Bug 1307820 - 9. Implement dispatching between Gecko/Java; r=snorp

Implement translation between JSObject and GeckoBundle, and use that for
dispatching events from Gecko to Java and vice versa.

Bug 1307820 - 10. Implement callback support; r=snorp

Implement callback support for both Gecko-to-Java events and
Java-to-Gecko events.

For Gecko-to-Java, we translate nsIAndroidEventCallback to a Java
EventCallback through NativeCallbackDelegate and pass it to the Java
listener.

For Java-to-Gecko, we translate EventCallback to a
nsIAndroidEventCallback through JavaCallbackDelegate and pass it to the
Gecko listener.  There is another JavaCallbackDelegate on the Java side
that redirects the callback to a particular thread. For example, if the
event was dispatched from the UI thread, we make sure the callback
happens on the UI thread as well.

Bug 1307820 - 11. Add BundleEventListener support for Gecko thread; r=snorp

Add support for BundleEventListener on the Gecko thread, so that we can
use it to replace any existing GeckoEventListener or NativeEventListener
implementations that require the listener be run synchronously on the
Gecko thread.

Bug 1307820 - 12. Add global EventDispatcher in AndroidBridge; r=snorp

Add an instance of EventDispatcher to AndroidBridge to act as a global
event dispatcher.

Bug 1307820 - 13. Add per-nsWindow EventDispatcher; r=snorp

Add an instance of EventDispatcher to each nsWindow through an
AndroidView object, which implements nsIAndroidView. The nsIAndroidView
is passed to the chrome script through the window argument when opening
the window.

Bug 1307820 - 14. Update auto-generated bindings; r=me

Bug 1307820 - 15. Update testEventDispatcher; r=snorp

Update testEventDispatcher to include new functionalities in
EventDisptcher.

* Add tests for dispatching events to UI/background thread through
  nsIAndroidEventDispatcher::dispatch.

* Add tests for dispatching events to UI/background thread through
  EventDispatcher.dispatch.

* Add tests for dispatching events to Gecko thread through
  EventDispatcher.dispatch.

Each kind of test exercises both the global EventDispatcher through
EventDispatcher.getInstance() and the per-GeckoView EventDispatcher
through GeckoApp.getEventDispatcher().
2016-11-14 21:29:50 +08:00
Grisha Kruglov 3dd6f6d61a Bug 1301717 - Limit what we extract, store incoming page metadata r=sebastian
We only extract metadata that we'd want to store. For now this is just image_url.

In case we try to store page metadata before corresponding history record has been inserted,
we queue up metadata and wait for an event from GlobalHistory letting us know that history
record is now available, at which point we try inserting metadata again.

MozReview-Commit-ID: 2FpIqc6uHMb
2016-11-04 13:39:50 -07:00
Jim Chen 0044906898 Bug 1305498 - Refactor notification code to be more concise; r=sebastian
Bug 1305498 - 1. Remove NotificationClient task queue; r=sebastian

Not sure why we needed a task queue for NotificationClient actions. The
actions all go through IPC and are non-blocking, so it's perfectly fine
to perform them off of whatever thread we're on.

Bug 1305498 - 2. Integrate NotificationHandler et al into NotificationCllient; r=sebastian

There's no reason to have NotificationHandler, AppNotificationClient,
and ServiceNotificationClient all separate from the base
NotificationClient class. This patch adds the functionality of
those three classes to NotificationClient.

The notifications hash map is changed from a ConcurrentHashMap to a
regular HashMap with synchronization because I think the use case here
doesn't warrant the added performance and overhead of ConcurrentHashMap.

NotificationService is changed to match the new NotificationClient. Now
the only job for NotificationService is to set a notification as
foreground, rather than to manage all notifications like before.

NotificationHandler, AppNotificationClient, and
ServiceNotificationClient will be removed in a later patch.

Bug 1305498 - 3. Set NotificationListener in GeckoApplication; r=sebastian

Set NotificationListener once in GeckoApplication.onCreate, instead of
spreading it out in GeckoApp, BrowserApp, and GeckoService. This is
possible because there's no longer a distinction between
AppNotificationClient and ServiceNotificationClient in the new,
consolidated NotificationClient.

Bug 1305498 - 4. Remove obsolete notification classes; r=sebastian

Remove AppNotificationClient, ServiceNotificationClient, and
NotificationHandler, now that they've all been replaced by the new,
consolidated NotificationClient.

Bug 1305498 - 5. Use NotificationReceiver for web notification callbacks; r=sebastian

Previously, web notification callbacks went to GeckoApp directly, but
that presented some problems such as not being able to implement the
on-close callback, because we don't want to launch GeckoApp when the
notification is closed by swiping. This patch makes us use
NotificationReceiver for callbacks, and let NotificationReceiver launch
GeckoApp if necessary.

Bug 1305498 - 6. Don't keep notification cookie in native code; r=sebastian

Keep the notification cookie a single location (in the notification
intent itself), and simplify the native notification handling code.

Bug 1305498 - 7. Use NotificationReceiver for persistent notifications; r=sebastian

Currently, persistent notification callbacks go through a different code
path, but it'd be more consistent and correct to let persistent
notification callbacks go through NotificationReceiver as well.

This takes care of some housekeeping work that was missing for
persistent notifications, such as deleting the mNotifications entry when
the notification is closed.
2016-10-05 21:52:32 -04:00
Jim Chen 6f4df53375 Bug 1304145 - 2. Change GeckoAppShell's notification interface; r=nalexander
Instead of using NotificationClient directly from GeckoAppShell, add a
NotificationListener interface, which NotificationClient would
implement. This isolates NotificationClient (and the notification
package) from GeckoAppShell and lets us move the notification package to
Fennec. It also makes a cleaner interface for GeckoView consumers to
implement notification support.
2016-09-22 16:38:19 -04:00
Jim Chen 44870b81a5 Bug 1291384 - 2. Convert GeckoProfile.getDB calls to BrowserDB.from calls; r=nalexander
Mass convert GeckoProfile.getDB() calls to BrowserDB.from() calls,
whether using Context or GeckoProfile.
2016-09-14 12:46:50 -04:00
Jim Chen 63a4d33265 Bug 1291384 - 1. Take BrowserDB out of GeckoProfile; r=nalexander
Remove references to BrowserDB and its factory from GeckoProfile.
Instead of keeping the DB in mDB, GeckoProfile now keeps an arbitrary
object in mData. Using a data object lets us avoid needing another map
to map profiles to DBs. This feature could be very useful for GeckoView
consumers as well.

The new way to get a BrowserDB from a profile/context is through
BrowserDB.from(Context) or BrowserDB.from(GeckoProfile), which takes
care of creating a local DB if necessary and associating the DB with the
profile.
2016-09-14 12:46:50 -04:00
Jim Chen e33a95701e Bug 1291383 - Move Distribution initialization out of GeckoProfile; r=nalexander
Move Distribution initialization (on profile directory creation) from
GeckoProfile to GeckoApplication, by listening to the Profile:Create
event.
2016-09-02 16:49:11 -04:00
Jim Chen 16a8900d5d Bug 1298161 - d. Use application context to prevent BrowserApp leaks; r=sebastian
Use application context for delayed callbacks to prevent leaking the
BrowserApp instance. Also, use application context for accessing
Distribution, to prevent leaking old BrowserApp instances, and to avoid
using a destroyed Context. Finally, attach AudioFocusAgent to the
application context instead of the BrowserApp context to avoid leaking
BrowserApp.
2016-08-30 14:49:38 -04:00
Jim Chen 6a4c58908e Bug 1298161 - a. Fix BrowserApp leak in GeckoAccessibility; r=sebastian
Move registration of AccessibilityManager listeners to GeckoApplication,
and change all Context references to the application context, so that
GeckoAccessibility doesn't leak old BrowserApp instances as new
BrowserApp instances are created.
2016-08-30 14:49:38 -04:00
Broderick Stadden 587ef6788c Bug 1279301 - Move notification classes to notification folder. r=jonalmeida
Moved notification classes to notification folder.  Refactored uses which added
imports to some Gecko classes as well as the Notification classes.  Added getter
to GeckoAppShell for access to static NotificationClient. Changed paths in
AndroidManifest.xml.in to reflect changes.

MozReview-Commit-ID: 2CUJa0YsV1V
2016-07-27 13:57:22 -10:00
Grigory Kruglov b473f8a4ef Bug 1277333 - Keep track of a reference to GeckoApplication to eliminate "no context NPE" crashes r=sebastian
MozReview-Commit-ID: 7jzOflrIcLZ
2016-07-26 10:40:57 -07:00
Michael Comella 9d83dd72a4 Bug 1285511 - Add multidex support to automation builds. r=sebastian
I initially tested my code with a branch around the multidex dependency:

if (mozconfig.substs.MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE) {
  compile ...multidex...
}

I removed it because it seemed unnecessary - the code shouldn't be
included if it's not referenced.

I tested:
 * Locally with a build that did not exceed the method limit, pre-Lollipop
 * On try, with fx-team
 * On try, with beta

MozReview-Commit-ID: APaOdlKd3QF
2016-07-20 13:06:40 -07:00
Kannan Vijayan afe71cc3f0 Bug 1272101 - Fix nsINetworkInfoService implementation on Android to use Linux C APIs instead of Android Java APIs. r=snorp 2016-06-02 16:42:36 -04:00
Kannan Vijayan 8ce9202ed6 Bug 1272101 - Changes in preparation for FlyWeb landing. Add nsINetworkInfoService and implementation for various platforms. r=hurley 2016-06-01 16:16:40 -04:00
Jim Chen bbdd84d17d Bug 1272557 - Delay initializing PushService and DLC; r=snorp
Delay initialization of PushService and DLC in GeckoApplication to after
the Gecko:Ready message. That way, hopefully they give up some CPU time
to other initialization tasks.
2016-05-27 14:29:46 -04:00
Grigory Kruglov 3196212ad2 Bug 1271318 - Don't keep context in GeckoNetworkManager, and get it from GeckoAppShell r=mcomella
MozReview-Commit-ID: DX4GOca5IoO
2016-05-16 14:41:09 -07:00
Shatur 723ff2e162 Bug 1250387 - Kill GckoConnectivityReceiver.java and improve GeckoNetworkManager.java r=grisha 2016-04-19 06:31:17 +05:30
Michael Comella fb562480f3 Bug 1258794 - Add trailing whitespace checkstyle check & fix issues. r=nalexander
MozReview-Commit-ID: IUslNabcTHO
2016-04-06 10:08:46 -07:00
Jim Chen f9326bedaf Bug 1260243 - Convert backgrounding/foregrounding GeckoEvent to native calls; r=snorp
Convert APP_BACKGROUNDING and APP_FOREGROUNDING events in GeckoEvent to
native calls onPause and onResume in GeckoThread, respectively.
2016-04-05 21:43:41 -04:00
Sebastian Kaspari 34635b0d34 Bug 1257941 - Use LeakCanary to watch for fragment leaks. r=ahunt
MozReview-Commit-ID: GhqcSH1SML
2016-03-18 20:00:49 +01:00
Andrzej Hunt 50b9514eb0 Bug 1257667 - Pre: Allow retrieving GeckoApplication's RefWatcher for leak-spotting r=sebastian
MozReview-Commit-ID: GmGxDt72ljq
2016-03-18 11:33:27 -07:00
Nick Alexander eee789a5df Bug 1252666 - Part 2: Use reflection to start PushService. r=margaret
The alternative is to define an interface and two conditional
implementations, and then build only one depending on MOZ_ANDROID_GCM.
That's what we did for Adjust, and it works; but it's awkward here
because the the PushService code is truly part of the browser, and the
conditional code is compiled very early (much earlier than the
browser).  (The Adjust library was built even earlier than the
existing conditional code, so this wasn't an issue.)  To work around
this, we'd want to add conditional code to the main browser, which
complicates the build.  This is expedient until we get to a proper
dependency injection scheme (for example, Dagger).

MozReview-Commit-ID: 18usWz8oC3B
2016-03-07 14:37:57 -08:00
Nick Alexander 52d47336a1 Bug 1253876 - Back out PushService integration to not burn aurora. r=me
Sadly, this needs to be conditional to not burn builds where
MOZ_ANDROID_GCM is not defined -- such as aurora.  As uplift is soon,
this will have to be relanded behind a conditional abstraction (just
like Adjust).

MozReview-Commit-ID: 80gBojadDic
2016-03-06 20:43:22 -08:00
Nick Alexander 58afa5ce22 Bug 1214338 - Implement Android GCM-based PushService protocol. r=rnewman r=kitcambridge
MozReview-Commit-ID: 1KV7CZBuosx
2016-03-04 15:48:09 -08:00
Nick Alexander 44b9523c00 Bug 1207714 - Part 4: Add singleton PushService. r=rnewman
MozReview-Commit-ID: CFSINSP7uFp
2016-03-02 16:44:23 -08:00
Brendan Dahl 7707991b68 Bug 1235869 - Remove web runtime from android. r=myk 2016-02-29 10:31:00 +01:00
Sebastian Kaspari 6b54d9dcbf Bug 1238066 - Add LeakCanary to local (gradle) builds. r=nalexander
This patch adds LeakCanary to gradle builds and the no-op library to
mach-based builds.
2016-01-21 12:35:21 +01:00
James Willcox f09f1577e3 Bug 1214810 - Print a timestamp when Fennec is started r=esawin 2015-12-18 13:45:42 -06:00
Nick Alexander c682759005 Bug 1107811 - Part 1: Move Java code. r=mfinkle
#!/bin/bash
set -x
pushd mobile/android/base
# Can't be present in glob below.
rm -rf java/org/mozilla/gecko
for i in */ ; do
# But is necessary to copy into.
mkdir -p java/org/mozilla/gecko
hg mv $i java/org/mozilla/gecko ;
done
hg mv *.java java/org/mozilla/gecko
# Move back stuff we didn't want to move.
hg mv java/org/mozilla/gecko/crashreporter crashreporter
hg mv java/org/mozilla/gecko/docs docs
hg mv java/org/mozilla/gecko/locales locales
hg mv java/org/mozilla/gecko/resources resources
popd
2015-12-04 11:51:34 -08:00