Commit Graph
43 Commits
Author SHA1 Message Date
Nevin Chen 6d03f3d0d1 Bug 1386151 - If leanplum is disabled, we skip the message. r=maliu
MozReview-Commit-ID: 2DX2VyFoHFW
2017-08-11 12:27:16 +08:00
Nevin Chen ae94caa5a8 Bug 1386151 - Accept multiple sender ID for MMA. Waiting for Sender ID udpate and API Key request. r=maliu
MozReview-Commit-ID: Ewot0f6iBgk
2017-08-08 14:51:17 +08:00
Edouard Oger 87f243259e Bug 1351805 part 1 - Create a org.mozilla.gecko.fxa.devices package. r=Grisha,nalexander
MozReview-Commit-ID: FjJmRiHlqEg
2017-04-07 11:56:38 -04:00
Wes Kocher e5cf37107d Backed out 3 changesets (bug 1351805) for android Test failures a=backout
Backed out changeset da34da5f310a (bug 1351805)
Backed out changeset 430b56176e04 (bug 1351805)
Backed out changeset a3dfb4b9dc66 (bug 1351805)

MozReview-Commit-ID: AE4RcKV3akz
2017-04-25 12:47:59 -07:00
Edouard Oger bfc7019308 Bug 1351805 part 1 - Create a org.mozilla.gecko.fxa.devices package. r=Grisha,nalexander
MozReview-Commit-ID: FjJmRiHlqEg
2017-04-07 11:56:38 -04:00
Edouard Oger b838bef9e9 Bug 1349299 - Register device on FxA even on Push registration failure. r=Grisha
MozReview-Commit-ID: 3qDkm9iV9C0
2017-04-06 11:30:23 -04:00
Grigory Kruglov c84ce69e9a Bug 1329793 - Re-subscribe for a push channel periodically r=eoger,nalexander
On startup and at the beginning of a sync we check how long it has been since we've subscribed
to a channel for fxa service. If it's been over 21 days, request re-subscription.

MozReview-Commit-ID: GzvPecZ9hTy
2017-03-08 18:14:43 -08:00
Edouard Oger 154bc10d66 Bug 1339681 - PushServiceAndroidGCM: Send strings instead of json in event callbacks. r=Grisha
MozReview-Commit-ID: 29BEjnh1TpT
2017-02-15 18:47:30 +01:00
Shan c8379dcd87 Bug 1316012 - Remove unnecessary boxing/unboxing; r=sebastian
MozReview-Commit-ID: 6k9d86ioK70
2016-11-26 11:24:00 +05:30
Hamel Joshi 0988940be3 Bug 1316017 - Remove redundant nullcheck calls. r=sebastian 2016-11-16 09:12:00 -05: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
Dylan Roeh 81b4f6d5e4 Bug 1306743 - Make PushService use the singleton EventDispatcher. r=jchen 2016-09-30 17:33:56 -05:00
Dylan Roeh 45a079c5d5 Bug 1294821 - De-singletonize EventDispatcher and make it application-specific. r=jchen 2016-09-27 11:07:24 -05: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
Grigory Kruglov 4b78c92d9e Bug 1300230 - Queue up incoming FxA push messages until FxAccountsPush is ready r=nalexander
MozReview-Commit-ID: 8BP7eWfdXte
2016-09-08 14:15:34 -07:00
Edouard Oger 96a6ccff48 Bug 1287643 - FxA Push registration and handling of device disconnection message. r=kitcambridge,nalexander
MozReview-Commit-ID: 8IH3kBivp26
2016-07-20 10:47:04 -07:00
Phil Ringnalda 8d4672233a Backed out 2 changesets (bug 1287643) for xpcshell failures in test_notification_ack.js and friends
Backed out changeset 816516be0183 (bug 1287643)
Backed out changeset e72a4a5ae5ff (bug 1287643)
2016-08-16 21:28:51 -07:00
Edouard Oger fad0fde527 Bug 1287643 - FxA Push registration and handling of device disconnection message. r=nalexander
MozReview-Commit-ID: BYFMeQNgumu=
2016-07-20 10:47:04 -07:00
Jim Chen 69f0978052 Bug 1280446 - Follow-up to fix another possible crash; r=me 2016-07-11 17:16:57 -04:00
Jim Chen ddf3adcdeb Bug 1280446 - Create PushService if needed; r=snorp
If PushService has not been created when getInstance is called, create
the PushService instead of throwing an error. This fixes a possible race
condition between initializing PushService and receiving a push message,
where we can receive a push message first.
2016-07-05 14:34:57 -04:00
Kit Cambridge 67d93f9b81 Bug 1265593 - Forward app server keys to Autopush on Android. r=nalexander
MozReview-Commit-ID: 3J4mM1k0pcY
2016-03-22 12:09:31 -07:00
Jim Chen 58b120f4d4 Bug 1270870 - Check profile when delivering pending push message; r=nalexander
For pending push messages, we used to check for correct profile when the
message is received, but it's better to check for correct profile when
the message is delivered to Gecko.

This fixes a crash in headless mode that the previous patches
introduced.
2016-05-24 01:11:16 -04:00
Jim Chen aa1bc3b42a Bug 1267860 - Include "con" parameter in GCM message; r=kitcambridge
Include the content encoding "con" parameter in the message that is
passed from GCM to Gecko, so that the message body can be correctly
decrypted.
2016-04-28 16:07:02 -04:00
Jim Chen ae150c3bdf Bug 1267419 - Move PushRecord.getLastVisit handler to PushService.java; r=nalexander
The Android-specific handler for PushRecord.getLastVisit used to be
implemented in GeckoApp, which is unavailable in headless mode. Moving
the handler to PushService makes background notifications work.
2016-04-26 15:34:17 -04:00
Jim Chen 48eca4c210 Bug 1252650 - Use GeckoService to launch Gecko for incoming push messages; r=nalexander
Use GeckoService to launch Gecko using the correct profile and load push
service, if necessary.
2016-04-20 15:06:13 -04:00
Carsten "Tomcat" Book f2370c758b merge mozilla-inbound to mozilla-central a=merge 2016-04-14 11:38:11 +02:00
Michael Comella 8e357ee7f0 Bug 1258789 - Remove WhitespaceAround tokens filter and fix lcurly issues. r=grisha
Some issues remain.

MozReview-Commit-ID: 3vWQ3z5mnba
2016-04-13 11:17:55 -07:00
William Chen eb5977ffa0 Bug 1260499 - Handle incoming messages before push service is initialized. r=nalexander,jchen 2016-04-13 16:55:25 -07:00
William Chen d8b9703fb8 Backed out changeset 6ccfb75c8926 (bug 1260499) for wrong patch 2016-04-13 15:37:48 -07:00
William Chen 3997f81a84 Bug 1260499 - Handle incoming messages before push service is initialized. r=nalexander,jchen 2016-04-13 14:30:33 -07:00
Nick Alexander a619493435 Bug 1259507 - Add UI Telemetry probes for DOM Push API in Fennec. r=mfinkle
The probes in this patch are annotated with the extra "dom-push-api"
to distinguish from future Fennec-specific push messages.  These
probes allow to determine for each user the difference:

{# sites subscribed to} - {# sites unsubscribed from}.

If we assume the same site is not subscribed to multiple times, this
is a good approximation to the total number of sites the user receives
push messages from.

To test manually:

0) Install Fennec and execute |adb shell setprop log.tag.Telemetry DEBUG|.

1) Subscribe to notifications on a site like serviceworke.rs.

Observe a UI Telemetry SAVE event, like:
D/Telemetry( 7109): SendUIEvent: event = save.1 method = service timestamp = 277456 extras = dom-push-api

2) Send a push notification using the sites' interface.

Observe a UI Telemetry PUSH_RECEIVED_MESSAGE event, like:
D/Telemetry( 7109): SendUIEvent: event = action.1 method = service timestamp = 361795 extras = dom-push-api

3) Unsubscribe to notifications by revoking permission using Site
Settings from the URL bar.

Observe a UI Telemetry PUSH_UNSUBSCRIBED_FROM_SITE event, like:
D/Telemetry( 7109): SendUIEvent: event = unsave.1 method = service timestamp = 393600 extras = dom-push-api

MozReview-Commit-ID: IOCwfXFnowA
2016-03-29 11:39:35 -07:00
Nick Alexander 44716e8289 Bug 1260519 - Support unsubscribing from Push API messages from a site. r=jchen
This was implemented, but never wired up.

I thought long and hard about how to unit test this, and it's quite
difficult.  First, we'd have to chose a layer of testing.  We could
unit test:

* the JS <-> Java message passing;

* the permission prompts <-> JS interface;

* some interactions with the Service Worker interface.

The first is difficult because none of our current testing emulators
have Google Play Services and GCM enabled, so we'd need to allow to
mock or otherwise fake the GCM registration.  Then we'd need to stand
up a mock autopush server (using httpd.js or the Java-side
equivalent), or mock out the autopush client as well.  At this point,
we're testing sendMessage.  This could be done, but I'd rather slide
this fix in before building out quite a bit of test infrastructure.
(For the record, the Java Push Service state machine is thoroughly
tested with Java unit tests, so I have confidence that the unsubscribe
logic works.)

The second is tested via the PushWebSocket tests, which are now
running on Android.  That is, if permissions and the PushService are
interacting badly, we should see it with the existing test suite.
Since PushServiceAndroidGCM is pretty much a pass-through, there's
little value to be added here.

Finally, the third is also tested via the PushWebSocket tests.
There's absolutely nothing GCM specific about the Service Worker
interface to the PushService.

So I'm left manually testing this -- and now we can unsubscribe from
Push messages from sites.

MozReview-Commit-ID: HiRiqasHJ27
2016-03-29 11:59:52 -07:00
Michael Comella b419891759 Bug 1256427 - Backed out changeset 57572ba7a904 for crash on API 15-16.
AtomicFile is only available for API 17+ so we need to use the framework.

MozReview-Commit-ID: HBrLHvp57Uv
2016-03-24 14:10:56 -07:00
Carsten "Tomcat" Book 5e150f1109 merge mozilla-inbound to mozilla-central a=merge 2016-03-24 16:15:30 +01:00
Michael Comella 2be5d5b18e Bug 1256427 - Move to AtomicFile in framework from support lib. r=sebastian
MozReview-Commit-ID: 6DOKydvvSGJ
2016-03-23 10:30:52 -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 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
Nick Alexander 2c4be2c20a Bug 1207714 - Part 3: Implement push manager. r=rnewman
MozReview-Commit-ID: LkUaGFA6YlF
2016-03-02 16:04:02 -08:00
Nick Alexander ee8f6f61cb Bug 1207714 - Part 2: Add storage for App-wide push state. r=rnewman
MozReview-Commit-ID: GOP4F6N2Mht
2016-03-02 15:48:37 -08:00
Jim Chen f08147f4d4 Bug 1257319 - Convert existing broadcast events to calls; r=margaret
Convert existing places where we use broadcast events to use
new GeckoAppShell calls.
2016-03-23 14:42:38 -04:00
Carsten "Tomcat" Book 1e05e48e46 Backed out changeset 3e80b5052d0b (bug 1257319) 2016-03-23 10:55:10 +01:00
Jim Chen 8ca658a8c1 Bug 1257319 - Convert existing broadcast events to calls; r=margaret
Convert existing places where we use broadcast events to use
new GeckoAppShell calls.
2016-03-22 22:24:31 -04:00