When the OS needs to display a permission prompt, our current activity is paused
and onSaveInstanceState gets called, however the activity isn't stopped yet.
When the permission handling then returns with the results to us, we display
the file picker using the current activity as retrieved from the GeckoActivity-
Monitor.
The problem is that in bug 1437382, our application-background handling was
changed such that it would already be triggered by the preparatory onSave-
InstanceState call. This had the side effect that the current activity would
be cleared from the GeckoActivityMonitor at that point already. Therefore, in
our case showing the file picker would fail because the GAM would have cleared
the current activity already after the runtime permission prompt caused our
previous activity to save its state.
To fix this, we change the behaviour of the GeckoActivityMonitor such that it
will continue to trigger our application-background handling during onSave-
InstanceState if possible, but will only clear the current activity when it is
stopping for real.
Differential Revision: https://phabricator.services.mozilla.com/D5304
That way, we only add that notification channel if the updater really is active,
i.e. not if we've been installed from the Play Store.
Unfortunately, using the UpdateServiceHelper requires a Context, so adding/re-
moving the UPDATER_CHANNEL_TAG cannot be done during variable initialisation.
Differential Revision: https://phabricator.services.mozilla.com/D4890
Also, if entering PIP fails will make sure that upon restarting the activity
it's orientation will match device's.
Differential Revision: https://phabricator.services.mozilla.com/D5035
In my opinion this is an altogether nicer way of setting and resetting temporary
StrictMode exceptions. The only fly in the ointment is that this causes a
warning about a technically unused variable that subsequently needs suppressing.
Differential Revision: https://phabricator.services.mozilla.com/D4889
That way, we only add that notification channel if the updater really is active,
i.e. not if we've been installed from the Play Store.
Unfortunately, using the UpdateServiceHelper requires a Context, so adding/re-
moving the UPDATER_CHANNEL_TAG cannot be done during variable initialisation.
Differential Revision: https://phabricator.services.mozilla.com/D4890
Previously, most of our notifications were silent, so we adopt a default
priority of IMPORTANCE_LOW instead of IMPORTANCE_DEFAULT.
Since we cannot change the priority setting for existing users on Nightly any
more, we technically have to retire the old default channel and replace it by
a new channel with a different ID. While in a way this is circumventing Google's
API design and destroys any existing customisation users have set for that
channel, we are only using this exceptionally to *lower* the initial priority of
our default notification channel, which we accidentally set too high. Besides,
it is unlikely that there are many users who really want to receive all kinds of
random Firefox notifications with a high priority.
Differential Revision: https://phabricator.services.mozilla.com/D4364
Added a default channel for Leanplum push notifications as fallback to cover the cases where we receive
push notifications from server with an invalid channel and the case where there are no channels configured
on server.
Provided a valid default icon for push notifications in Leanplum required for fallback strategy.
Differential Revision: https://phabricator.services.mozilla.com/D4704
Instead of stopping the foreground service whenever ACTION_PAUSE was triggered,
I created a new event where we notify the service to clear its foreground state.
Cleared usages of the NotificationManager and the onGoing attribute of the
MediaNotification because they are redundant. As of Android 4.3 a service in the
foreground state will always force the notification to be persistent and callling
stopForeground(false) will clear the onGoing flag while maintaining the notification.
Differential Revision: https://phabricator.services.mozilla.com/D4567
From the PIP window the user can either return to the fullscreen app or exit
it entirely.
Fullscreen and subsequently hiding the status bar should only be done if the
user is returning to the app.
Differential Revision: https://phabricator.services.mozilla.com/D4676
To avoid cluttering our notification settings on builds not using the built-in
updater, we only add that channel when required.
Passing a null channelId to the system NotificationManager, which can then
happen if someone attempts to use the UPDATER channel anyway, even though
MOZ_UPDATER is false, is safe. It just means that the NotificationManager will
return the system's default channel, which will silently swallow any
notifications posted to it from apps targeting Android O or above.
Differential Revision: https://phabricator.services.mozilla.com/D4584
The fragment is also used to handle intents launched through GeckoAppShell.
openUriExternal(), such as e.g. when launching downloaded files from
about:downloads.
The synchronous code path when not in private browsing is already covered by the
code added in bug 1450449, but the async path through the fragment when in
private browsing needs to be handled separately.
Differential Revision: https://phabricator.services.mozilla.com/D3916
Make a distinction between a session being active (i.e. being visible)
and it being focused. More than one session may be active at a time, but
only one session is focused at a time. This means the focused session is
always active, but an active session may not be focused.
Also, manage setting of active/focused states in GeckoView itself, so
consumers don't generally have to worry about these states.
Differential Revision: https://phabricator.services.mozilla.com/D3251
Make a distinction between a session being active (i.e. being visible)
and it being focused. More than one session may be active at a time, but
only one session is focused at a time. This means the focused session is
always active, but an active session may not be focused.
Also, manage setting of active/focused states in GeckoView itself, so
consumers don't generally have to worry about these states.
Differential Revision: https://phabricator.services.mozilla.com/D3251
The previous implementation attempted to delete files from /res/fonts (i.e.
root). I don't believe this was intended either:
https://bugzilla.mozilla.org/show_bug.cgi?id=878674#c0 indicates the fonts
directory should be inside the data dir of the application. The crash occurs
when the /res/fonts directory exists (only some devices) but the user doesn't
have read access. If the user has write access, our code may actually delete
these system files: uh oh!
My fix is to change the deletion from /res/fonts to <dir>/res/fonts. I verified
this fix worked by creating a clean profile, adding dummy files to the
res/fonts dir, and making sure only the correct ones were deleted (in zsh):
export DIR=/data/data/org.mozilla.fennec_mcomella; \
adb shell pm clear org.mozilla.fennec_mcomella && \
adb shell mkdir -p $DIR/res/fonts && \
for i in touch.ttf lol.rdf; do adb shell touch $DIR/res/fonts/$i; done && \
adb shell ls $DIR/res/fonts
MozReview-Commit-ID: 8atpcjYjGu0
Previously, this wasn't noticeable since adding/removing a PageAction would call
refreshPageActionIcons(), which would do the correct thing, but now a newly
created PageActionLayout can start with an already pre-populated mPageAction-
List, which means that the subsequently arriving call to setPrivateMode() will
erroneously activate the private mode tinting for all PageActions that support
it.
MozReview-Commit-ID: EvNx1Q9vwZ5
When a PageActions:Remove message arrives and we cannot simply forward it, we
need to remove not just pending PageActions:Add messages, but also any already
present PageActions objects that a former PageActionLayout had handed to us.
MozReview-Commit-ID: 3jnGsmMuVfa
Despite its name and the original purpose for which it was added, that function
generically checks for duplicates among all PageActions, not just the PWA badge.
MozReview-Commit-ID: Ae6FsLb9F3S
Since converting a PageAction message into an actual PageAction object also en-
tails parsing the image data URL into a drawable, we leave that task to the
PageActionLayout.
This means that the PageAction cache needs to operate slightly differently than
the MenuItem cache. First, we store all PageAction BundleEvent messages that
arrive while no PageActionLayout is ready and then forward them en masse when
one becomes available. Secondly, if the PageActionLayout is going away again,
we then also take a list of already parsed PageAction objects for safekeeping.
MozReview-Commit-ID: AcPPONXqe46
Since all related EventDispatcher messages use UUIDs, it makes sense to store
our MenuItemInfos in a Map, so we can access them directly by UUID instead of
having to iterate over them until we've found the desired one.
Since we want to preserve the order in which MenuItemInfos were added, we use a
LinkedHashMap.
MozReview-Commit-ID: BEtJ59tX59m
The small savings in initialising this on demand the first time a menu item is
added, are not worth the additional complexity in null checks and the like.
MozReview-Commit-ID: Lcz09Ds8NxJ
Bug 832990 solved the issue of us losing the menu item cache if BrowserApp was
destroyed, however the issue remains that we'll miss any Menu:... messages that
are sent while BrowserApp doesn't exist, e.g. if Gecko is initially loaded
through a GeckoView-based activity.
Therefore we now move the menu item cache and the listener for those messages
into a separate class, whose lifetime better matches that of Gecko.
Apart from any necessary changes, we move the existing code as is. The only
additional change is that we make addAddonMenuItemToMenu() static, because we
can.
MozReview-Commit-ID: BJleonLnjmo
As a final step, these can be merged as well. The same reasoning as in the
previous patch applies with regards to additional functionality that isn't
(yet) used by webextensions.
MozReview-Commit-ID: Ezx2mQY0s85
The original add-on functions have some additional capabilities regarding e.g.
checkboxes, disabling the menu, etc. that right now aren't required for
Webextensions (yet?), but in that case they will simply not be used - in any
case BrowserActions.jsm controls what functionality is actually exposed to
add-ons.
MozReview-Commit-ID: DPT8gV2gb6q
Now that the UI code for handling both the old NativeWindow API and Web-
extensions is more or less the same and both are using the same MenuItemInfo
class, there's no longer any real need to keep items added through the two APIs
in separate lists - in fact doing so makes it harder to preserve the ordering
of menu items if the activity and its menu are destroyed and need to be re-
created later on from the stored lists of MenuItemInfos.
MozReview-Commit-ID: KlJdvO9WhhY
Now that both Webextensions and the NativeWindow API manage their onClick call-
back handling by UUID, we can start using the same EventDispatcher message for
both.
MozReview-Commit-ID: J3RRXrwPdTI
Since the NativeWindow API now only uses UUIDs as well when dealing with its
consumers, we can leave generation of the menu to the Android UI code of
Firefox.
MozReview-Commit-ID: 1qDLDnePfFE
At the moment, the code for handling of JS-created main menu items is more or
less duplicated between the old NativeWindow API and Webextensions, with the
only real difference being that the former communicates directly via menu item
IDs, while the latter uses UUIDs for messaging between Gecko and the UI.
By switching the NativeWindow API to using UUIDs as well, we will be able to
start unifying this code again.
As for backward compatibility
- the return value of NativeWindow.menu.add is valid for the current session
only, so no migration is necessary
- the return value of NativeWindow.menu add was already effectively only an
opaque value which only had real meaning for subsequent calls to menu.add,
menu.update and menu.remove, so it shouldn't really matter whether we return
a plain numeric ID or an UUID in string form
- old-style add-ons are now unsupported for better or for worse and our one in-
tree caller won't have any problems with this change
MozReview-Commit-ID: HdRNhrx1pu7
Now that GeckoScreenOrientation generally offers notifications of screen
orientation changes, the PromptService no longer needs to do its own orientation
tracking and require to be fed orientation changes from each activity using it.
MozReview-Commit-ID: K7KbDsQip7b
By moving the calls to GeckoScreenOrientation.update() into GeckoView, any app
using a GeckoView will automatically update the screen orientation in Gecko,
too, without any further action being required by the embedding app.
The synchronisation around GeckoScreenOrientation.update()/(un)lock() is
required for the following scenario:
If (un)locking of the screen orientation as requested by Gecko caused the
actual screen orientation of the app to change, there are two ways in which this
will cause our internal screen orientation to be updated:
1. Either the call to delegate.setRequestedOrientationForCurrentActivity
(happening on the Gecko thread if the original request to (un)lock came from
Gecko) returns first and update() is subsequently first called from the Gecko
thread, too, meaning the onOrientationChange notification to Gecko can occur
synchronously as well. In that case, as soon as (un)lock returns to Gecko,
querying our internal screen orientation will return the correct value.
2. Or else the GeckoView.onConfigurationChanged() call resulting from the screen
rotation manages to call GeckoScreenOrientation.update() first and does so
from the Android UI thread. This means that the onOrientationChange
notification will be redispatched asynchronously to the Gecko thread, while
the Gecko thread's call to GeckoScreenOrientation.update() will return early
without doing any work, as the screen orientation had already been previously
updated by the UI thread.
As a result,there will be a period of time between the Gecko thread returning
from GeckoScreenOrientation.(un)lock() and the onOrientationChange
notification finally executing where querying the internal screen
orientation will not yet return the new orientation. This can cause problems
for Gecko (test) code that expects to (un)lock the orientation and then be
able to immediately query the new, changed orientation after the call to
(un)lock returns.
Without additional measures in place, there are no guarantees at what point
the GeckoView will receive the onConfigurationChanged() call in relation to the
request to change the activity's orientation making its way back to (un)lock().
Therefore, we add synchronisation such that no other thread will be able to up-
date the screen orientation in GeckoScreenOrientation while another thread is
still busy (un)locking the screen orientation.
MozReview-Commit-ID: 5s5NEJcuS0p
Once responsibility for notifying GeckoScreenOrientation of potentially changed
screen orientations moves from GeckoApp into GeckoView, the former will no
longer be able to benefit from the return value of calling GeckoScreen-
Orientation.update(), indicating whether the orientation actually changed or in
fact remained the same.
GeckoApp however requires that information in order to reset/refresh parts of
the UI when the orientation changes, and since GeckoScreenOrientation is already
doing all the work of tracking screen orientation changes, we don't want to have
to partially duplicate those efforts again in GeckoApp.
Instead, we introduce a mechanism for GeckoScreenOrientation to notify
interested parties on the Android app side as well.
The GeckoScreenOrientation.update() call in GeckoApp.onResume() is removed
completely (as opposed to merely removing the refreshChrome() bit) at this stage
already because it is unnecessary. If any screen rotation happened while the
activity was in background, it will receive an onConfigurationChanged() call
anyway before being resumed again.
MozReview-Commit-ID: Ila1evcj8Ud