Summary:
Executing SwitchBoard.loadConfig() on a background thread is the main purpose
of the AsyncConfigLoader so executing it immediately again in the same thread
is redundant.
Depends on D12031
Reviewers: JanH
Reviewed By: JanH
Bug #: 1505685
Differential Revision: https://phabricator.services.mozilla.com/D12032
Summary:
Executing SwitchBoard.loadConfig() on a background thread is the main purpose
of the AsyncConfigLoader so executing it immediately again in the same thread
is redundant.
Depends on D12031
Reviewers: JanH
Reviewed By: JanH
Bug #: 1505685
Differential Revision: https://phabricator.services.mozilla.com/D12032
Leaving the Fennec process running after a swipe-to-kill puts Fennec in an unrecoverable state; this ensures we kill the process anytime a user swipes-to-kill Fennec and therefore lets us recover as usual.
We're already have some special handling in the Android UI when detecting
MOZ_PROFILER_STARTUP, so we might as well handle MOZ_PROFILER_SHUTDOWN, too.
This means two things:
1. In order to actually quit the app, the "Quit" button needs to be enabled.
2. We need to wait until we're sure that the profile has been dumped to disk
before finishing the activity (and thereby possibly killing our process).
Differential Revision: https://phabricator.services.mozilla.com/D11696
`mExtensionPermissionsHelper` is initialized in BrowserApp's onCreate() and
nullified in it's onDestroy().
GeckoApp's onCreate() can finish after BrowserApp's onDestroy() because it uses
background initialization.
`mExtensionPermissionsHelper` will be checked for null before using it and
if null it's safe to ignore it's method's results as it only can be null if the
app was already closed.
Differential Revision: https://phabricator.services.mozilla.com/D10910
1. The patch from bug 1476710 was nonsense and had the same effect as simply
deleting that line, because the ChildFragmentManager is only of interest if
the TabHistoryFragment loaded further Fragments itself.
2. The issue at hand is that under some circumstances the TabHistoryFragment
will be trying to dismiss itself while its responsible FragmentManager is
already busy transacting some Fragment state changes. More precisely, the
fact that the Fragment is calling popBackStack*Immediately*, which isn't
allowed if the FragmentManager is already handling some other transaction.
3. The dismiss() calls in response to the onClick() handlers are unproblematic,
because they won't trigger any FragmentManager activity through any route
other than the dismiss() call itself.
4. The dismiss() calls in onPause() *are* problematic because the Fragment-
Manager will already be busy pausing the TabHistoryFragment, so triggering a
further synchronous transaction is not allowed (and originally caused
bug 1476710).
5. If the onPause() call happened because some external entity was attempting to
remove the fragment (either BrowserApp directly, or indirectly by forwarding
a back button press to the FragmentManager), then the Fragment trying to
additionally remove itself is unnecessary.
6. If the onPause() call happens because the containing activity itself is being
paused, then the Fragment being dismissed is the desired outcome (see
bug 1093209), however the Fragment won't be able to remove itself because
a) A synchronous transaction is illegal at that point in time.
b) An async transaction would be possible, but might not complete until after
onSaveInstanceState() had subsequently already been called, which again
would be illegal because of state loss.
c) An async transaction allowing state loss would succeed in any case, but
would mean that if BrowserApp was subsequently destroyed while in back-
ground and then later recreated from the savedInstanceState, the Tab-
HistoryFragment would be recreated as well, which is undesired.
7. Therefore, the only way to dismiss the TabHistoryFragment when the containing
activity is pausing is to synchronously dismiss the Fragment from inside the
activity, *before* the onPause() call is forwarded to the FragmentManager.
8. Calling dismiss() in response to onDestroy() is unnecessary, because the
Fragment is already irrevocably being removed as soon as we hit onPause().
9. Because it doesn't make sense to have multiple TabHistoryFragments active at
the same time, we also change the logic such that any attempt to show a new
TabHistoryFragment will now replace the previous fragment.
This is also useful in view of the fact that in order to close the Fragment,
BrowserApp retrieves it by calling findFragmentByTag(), which simply returns
the first matching Fragment, i.e. wouldn't properly handle things if we ever
accidentally ended up with multiple Fragment instances active at the same
time.
Differential Revision: https://phabricator.services.mozilla.com/D8680
Persistent notifications were not properly distinguished from clearable notifications
because they would first start as not persistent and got updated afterwards. Also added
a handle action in BrowserApp's onCreate for whenever the process gets removed.
Differential Revision: https://phabricator.services.mozilla.com/D6815
Added an extra check of bundle size due to some unexpected transactions sizes that exceed the limit.
The bundle gets lighter if the size exceeds the limit by removing the views' state as a last resort.
Differential Revision: https://phabricator.services.mozilla.com/D5682
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
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
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
This Receiver was used for implicit broadcasts and registered statically.
Refactored MmaDelegate() to register it dynamically in the init() method,
called in activity's onCreate and unregister it in activity's onDestroy.
This way we will still get notified immediately if the user installs any of
the apps we are interested in, even though he might not return to Fennec
immediately after. This will help to better asses the impact of suggestions to
install recommended packages.
For the cases in which the user installs the packages without us suggesting to
or if he kills our app before completing the new install, we will trigger a
check for the install status of the packages in MmaDelegate().init().
Also cleaned the code a little.
MozReview-Commit-ID: I00mLS2snzj
Broke the big IntentService into four small JobIntentServices because
the same JobIntentService class cannot be used with multiple JobIds
(https://github.com/aosp-mirror/platform_frameworks_support/blob/b6838fd2d2e834fdd38aab34511d385cb7108f63/compat/src/main/java/android/support/v4/app/JobIntentService.java#L121)
Also:
- will make the code easier to be migrated to WorkManager in the future
- more in line with SRP. It was initially doing too much.
Cleaned the code a little, removed the superfluous creation of new Threads for
DownloadContentCatalog().persistChanges() / .startLoadFromDisk()
as those methods are always called from the background threads
of the new JobIntentServices.
The new DlcHelper helps reducing duplicated code.
MozReview-Commit-ID: G3fsWYOGEbR
This patch also:
Resolves missing resources and api changes
- LeanplumActionBarActivity was removed because Support Library 26 deprecated
ActionBarActivity. Class was already not in use.
- CustomTabsService added two new methods which we need to override.
Tested to make sure that previous functionality was maintained but with the
addition of the two new methods maybe that feature could be improved.
- For checking layout direction we'll use our own new method from ViewUtil
which mimics what the now restricted method from the support library would do.
- Upgraded to use AppCompatResources#getDrawable(..) in place
of the now restricted AppCompatDrawableManager.get().getDrawable(..).
Resolves obscure leaks and crashes after the upgrade
- LoaderManager.destroyLoader(..) was added before the existing call to
LoaderManager.restartLoader(..) to prevent potential Cursor leaks
- Disable website suggestions depending on the address bar inputs when running
in automation to avoid Robocop tests failing (they were entering serially maybe
100 characters in <5 ms which created around that many new Threads,
operation that could cause the Executor to throw a RejectedExecutionException)
At the moment this functionality is not covered by tests anyway and it was the
only fix I could find that would not involve changing the whole implemenation
for address bar suggestions, implementation which in the real world works ok.
MozReview-Commit-ID: 2fX1SBHiSh0
Created LeanPlumVariables to allow LeanPlum overwriting the values used for
populating the OnBoarding screens. By simply adding the @Variable annotation
to it's fields, on the first run of the app, they will appear in "LeanPlum
dashboard - Variables" and will allow overwriting for future runs.
The OnBoarding process will now try to use LeanPlum values if possible.
Because connecting to LeanPlum and downloading the Variables might take
a few seconds we use a delay of up to 3 seconds until starting to show
the Onboarding screens.
The default values will still be used if:
- if the LP experiment is not available
- if no internet connection
- if more than 3 seconds have passed and LP didn't finish it's download
Added two new events that could be tracked to Leanplum
MmaDelegate.ONBOARDING_DEFAULT_VALUES and MmaDelegate.ONBOARDING_REMOTE_VALUES
to inform if showing the Onboarding with server values was possible or not.
Because of the 3 seconds delay until showing the Onboarding panels leaking the
could be possible. Used WeakReferences for both the Activity in
OnboardingHelper and the OnboardingHelper in MmaLeanplumImp to avoid it.
MozReview-Commit-ID: H30e9Ng7jrM
Because Mma cannot work if Health Report is disabled by the user (Settings - Privacy)
we will treat toggling Health Report on/off the same as we treat toggling the new preference from Settings - Notifications.
Toggling Health Report on will inform about the need to start LeanPlum (useful if the user did not explicitly stopped LP notifications but only Health Report which in turn disabled LeanPlum also) but there are other checks made afterwards (BrowserAp() is informed about this which calls GeckoPreferences.isMmaAvailable(..)) to decide if LP can and should be enabled.
Toggling any of these preferences will trigger an event caught by BrowserApp which can either
- immediately initialize LeanPlum (if the toggle was off LP is not running) as it would normally do when the app first starts
- stop LeanPlum reporting to servers, flush the per-session available messages
and resets the LP started status so that it can be restarted in the same app session (like if the user toggles the feature again)
MozReview-Commit-ID: 1SmhN0NucWW
***
With the adding of the new preference that Mma depends on we need to have only one place where all the conditions for considering if Mma is available are checked - GeckoPreferences.isMmaAvailableAndEnabled()
Added only one place from where the availability of the LP experiments should be checked as that currently involves two checks - MmaDelegate.isMmaExperimentEnabled(..)
Also renamed isMmaEnabled() from MmaDelegate() and initSwitchboard from BrowserApp() to better express what those methods do.
MozReview-Commit-ID: BCJqM9b5JbW
***
Fix all Java warnings in the Android codebase except deprecation and
serial warnings, and warnings in third-party code.
There is one required change to exoplayer2 code under thirdparty,
because that code is included directly in the geckoview project, instead
of the thirdparty project. I think I'll just make a pull-request to
upstream the change, instead of separating exoplayer2 into a
gv-thirdparty project.
Fix all Java warnings in the Android codebase except deprecation and
serial warnings, and warnings in third-party code.
There is one required change to exoplayer2 code under thirdparty,
because that code is included directly in the geckoview project, instead
of the thirdparty project. I think I'll just make a pull-request to
upstream the change, instead of separating exoplayer2 into a
gv-thirdparty project.
Use SharedPreference to ensure we won't loose previous state if Fennec is killed, set as default, restarted.
The default browser status will only be set once, when the app is resumed, as it cannot change while the app is in foreground.
We will track "E_Changed_Default_To_Fennec" only if Fennec wasn't previously the default browser.
The method to track the event is safe to be called even before the mma init process is finished as LeanPlum postpones the track operation until it has actually been started.
Refactored MmaDelegate to not use a WeakReference for application context anymore as that should exist for the entire time the app is open, and only in that timeframe the MmaDelegate methods that use that context can be called.
MozReview-Commit-ID: JMJJclWj9fq
We cannot open completely new windows on mobile, but we sort of mimic desktop
by having Ctrl + N/Ctrl + Shift + P always open a new normal/private tab,
whereas for Ctrl + T the kind of tab opened will now depend on the currently
selected tab.
MozReview-Commit-ID: KmPCcnn79OH