Image sharing currently only works when sharing to an app but not when
using the Android Direct Share feature, where it fails with a
SecurityException.
"Direct Share" is what Android calls the app created shortcuts,
i.e. individual chats from a messaging application.
The code pretty much already does the right thing (i.e. setting
the FLAG_GRANT_READ_URI_PERMISSION on the target intent as well as the
Chooser action, as described in ACTION_CHOOSE Api docs[1]) but there's
some platform internals that seem to go wrong here but we can work
around it with this patch.
https://issuetracker.google.com/issues/151386328 describes a similar
Problem, especially https://github.com/mozilla-mobile/android-components/issues/12 in there offers a similar workaround and an
explanation:
The underlying problem is that ACTION_SEND is using EXTRA_STREAM for the
content URI. But the FLAG_GRANT_*_URI_PERMISSION mechanism only works
with URIs in Intent.data and Intent.clipData. The framework contains
some code that tries to work around this limitation. But it doesn't
handle this particular case. Intent.createChooser() migrates the flags
and data/clipData from the target Intent, but it does so before the
framework had a chance to fix up the target Intent via Intent.migrateExtraStreamToClipData().
And indeed moving the clipData into the inner intent makes Direct Share
work and preserves the image preview in the Intent.
[1] file:///<SDK-DIR>/docs/reference/android/content/Intent.html#ACTION_CHOOSER
If you need to grant URI permissions through a chooser, you must specify
the permissions to be granted on the ACTION_CHOOSER Intent in addition to
the EXTRA_INTENT inside. This means using setClipData(ClipData) to
specify the URIs to be granted as well as FLAG_GRANT_READ_URI_PERMISSION
and/or FLAG_GRANT_WRITE_URI_PERMISSION as appropriate.
Adds support for Save to PDF from the GeckoSession by plugging the
API into `onExternalResponse` to provide the same flow as a typical
file download experience would be.
Co-authored-by: Olivia Hall <ohall@mozilla.com>
* For https://github.com/mozilla-mobile/android-components/issues/12544: Allow screen to turn off after media is paused/stopped
This fix allows the device to sleep when the media being played is paused/stopped after the system screen timeout is passed
Co-Authored-By: Mugurell <Mugurell@users.noreply.github.com>
Co-Authored-By: Mihai Adrian Carare <48995920+mcarare@users.noreply.github.com>
* For https://github.com/mozilla-mobile/android-components/issues/12544: Allow screen to turn off after media is paused/stopped
This fix allows the device to sleep when the media being played is paused/stopped after the system screen timeout is passed
Co-Authored-By: Mugurell <Mugurell@users.noreply.github.com>
Co-Authored-By: Mihai Adrian Carare <48995920+mcarare@users.noreply.github.com>
Co-authored-by: Mugurell <Mugurell@users.noreply.github.com>
Co-authored-by: Mihai Adrian Carare <48995920+mcarare@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
A change in AS v93.6.0 made it so the underlying function
`LoginsStore.import_multiple` no longer returns the metrics as a JSON
string string. Instead it just encodes the unit struct. This was a
breaking change, but it's not listed properly in the CHANGELOG.
The fix is pretty simple: just assume that no logins failed to import.
- Added new component that hooks into the new app-services error
reporter and listens for events. When it sees an event it submits it
to the crash reporter.
- Added support for customizing crash reports for these errors.
Moved the tests for string preferences to a new file where we can use
Robolectric for just this preferences type and test the actual behavior without
relying on mocking which would prevent full testing the change because of the
two readings using a `null` default.
Used `runTestOnMain` where `MainCoroutineRule` was used or needed to be used,
`runTest` elsewhere.
Extra effort for removing all `runBlocking` occurrences in unit tests.
`kotlinx.coroutines.test.runTest` is a test specific API that seems like a more
appropriate way for running tests in a coroutine than the general
`kotlinx.coroutines.runBlocking` api.
- Refactor out all usages of TestCoroutineDispatcher and TestCoroutineScope
- Refactor MainCoroutineRule to now use UnconfinedTestDispatcher by default.
This dispatcher will eagerly enter all launch or async blocks being more suited
to our codebase.
- Introduces `CreditCardValidationDelegate` and a default implementation in `DefaultCreditCardValidationDelegate`
- Implements `onCreditCardSave` in `GeckoCreditCardsAddressesStorageDelegate`
- Refactors `CreditCard` from concept-engine to `CreditCardEntry` in concept-storage so that it can validated with the `CreditCardValidationDelegate`
Added support for branch-build settings in `local.properties`:
- If `branchBuild.android-components.version` is set, then we
set the android-components version to that exact string.
- If `branchBuild.application-services.dir` is set, then run
`build-scripts/substitute-local-appservices.gradle` script, like we
do with `autoPublish`. However, in this case, that script expects
the app-services packages to be be built ahead of time with a
specific version name specified by
`branchBuild.application-services.version`.
- Added support for the absolute paths when running the substutition
scripts.
- Updated `substitute-local-ac.gradle` to check the
`localProperties.branchBuild.android-components.version`.
The plan is to use this feature to build/test fenix using a particular
checkout of application-services and androd-components, with the
versions set to the git commit ID.
This also required updating room to >= 2.4.0.
This new version adds a deprecation of the `MigrationTestHelper` api used in
`LoginExceptionStorageTest` that is to be later fixed in https://github.com/mozilla-mobile/android-components/issues/11765.
`activity_compose` was also update to the latest stable version to ensure a
better match with the latest stable version for compose.
Used 1.6.10 for Kotlin although 1.6.20 is available to prevent any issues with
Compose 1.1.1 reported as an error at compile time:
"e: This version (1.1.1) of the Compose Compiler requires Kotlin version 1.6.10
but you appear to be using Kotlin version 1.6.20 which is not known to be
compatible. Please fix your configuration (or
`suppressKotlinVersionCompatibilityCheck` but don't say I didn't warn you!)."
This also required updating room to >= 2.4.0.
This new version adds a deprecation of the `MigrationTestHelper` api used in
`LoginExceptionStorageTest` that is to be later fixed in https://github.com/mozilla-mobile/android-components/issues/11765.
activity_compose was also update to the latest stable version to ensure a
better match with the latest stable version for compose.
This change splits out tab-specific data from RecoverableTab data class
into a separate TabState (so, it doesn't have the EngineSessionState).
Then, once we have the simplified TabState, everything that touches RecentlyClosedTabs
is converted to use that instead of its more expensive sibling.
This way we avoid having to eagerly process EngineSessionState simply to populate BrowserState.closedTabs.
This saves us from having to hit disk (where the EngineSessionState is persisted) on initializing BrowserState (so, startup in most cases).
It also saves us from having to parse/rehydrate that persisted state.
At the point we actually need the EngineSessionState for a tab we'd like to restore, we can read/process it.
* fixup the VisitObservation, HistoryVisitInfo APIs based on changes in a-s
* Uniffi top frecent site info (https://github.com/mozilla-mobile/android-components/issues/3)
* uses VisitTransition in HistoryVisitInfo (https://github.com/mozilla-mobile/android-components/issues/4)
* fixup the VisitObservation, HistoryVisitInfo APIs based on changes in a-s
* updated based on bookmarks being uniffied
* fix issues with how we are rethrowing places exceptions
* bump appservices version
* fix ktlint lexiographic and ununsed import errors
* updated fennec migration code
Co-authored-by: Tarik Eshaq <tarikeshaq@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
There was a race between how insets are applied when entering immersive mode
and enabling immersive mode restore by setting an insets listener which is now
resolved by ensuring the decor view has the time needed to process the incoming
insets, solution recommended on issuetracker
https://issuetracker.google.com/u/2/issues/214012501 .
Removed the onWindowFocusChangeListener extension property since by having to
offer it through a getter the current implementation would always leak the old
one.
Fenix wasn't using it when this APIs allowed Fenix to pass such a listener and
there was no issue observed so there should be no observable negative impact.
Previously we'd allow a listener being passed in and we'd hope it will
correctly handle restoring immersive mode.
Now we are handling focus changes and restoring immersive mode on ourselves
also allowing for a simpler public API.
Copied the crypto code from autofill and adapted it for logins. At some
point it would be nice to combine the common parts here, but I figure
that can be a later issue.
Added code to migrate from a SQLCipher database to the new plaintext
ones. Choose the unimaginative "logins2.db" filename, feel free to pick
a different one.
Fixed some linter errors.
Updated FennecLoginsMigration to use the a-c `Login` class rather than
`ServerPassword` (AKA the a-s `Login` class). They're hold exactly the
same data, this prevents an extra conversion.
We observed via Sentry that we were hitting a bunch of 'url without
base' exceptions coming out of metadata observation API. One of these
cases where we'll end-up trying to process a URL without a base (e.g.
without a scheme) is when we're processing external intent and see
something like "example.com", instead of "https://example.com".
In our toolbar, we use String.toNormalizedUrl to handle this case.
In this patch, we now do the same for URLs we encounter in external
intents, as well.
Previously the call to `PerformLoad()` was shielded by mutable state (hasStartedLoading). When this state
was changed then the `PerformLoad()` composable would leave the composition and the coroutine scope
performing the load gets cancelled. This can cause loads to not happen.
It turns out `hasStartedLoading` is not needed at all: The key we pass to LaunchedEffect already guards
against multiple loads and will only perform a reload if the URL changes.
Mainly, does two things:
- refactors SessionState.Source into a richer form (splitting sources
into Internal and External, where External ones track information
about originating package)
- adds persistence of External sources into tab session state; we don't
want to persist Internal sources as that was explicitly removed before
for causing various issues (e.g. UI behaving incorrectly after
restoring tabs with various internal sources set)
These follow a few more simple patterns I was able to find:
- the testDispatcher is not used anywhere else: remove it
- the testDispatcher is used to set a main dispatcher: this is redundant
to the test rule so remove it both the dispatcher & the main dispatcher
- the testDispatcher is actually used elsewhere: for simplicity, change
the reference to point at the MainCoroutineRule.
This is redundant to the built-in TestCoroutineDispatcher() method.
TestCoroutineDispatcher is also preferred because it has enhanced
testing functionality including defining a context-specific
`runBlockingTest` function, the ability to control `delay` timings, etc.
Now that Fenix and Focus have migrated to using search functionality from the state in
BrowserStore (provided by feature-search), we can remove browser-search. The client
for search suggestions and the assets still lived in browser-search and this patch
moves those to feature-search too.
On newer AndroidX versions of lifecycle library, interactions with a lifecycle registry,
by default, must happen on the main thread. While in this code we don't control how lifecycle
registries are created, and so we can't be sure if this default behaviour is present, it's likely
safe to assume that our consumers won't create custom lifecycle registries with non-main thread interactions
allowed.
* Ignore for intermittent test failure
* Wait for store to finish before verifying in middleware test
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Add locale to our browser state. Create an action for updating this state.
* Observe changes to locale in the service and dispatch changes in the locale manager
* Separate the building of the notification so it can be reused
* Create a use case for local updates to be used in the locale manager
Add channel id so that the existing notification can be accessed and updated
Send notification id instead of tag
Locale use cases test
Put locale action in sealed action class
Test locale scope
* Add refresh functionality to the service
Add locale actions and reducer for restoring state
Restore state for locale use case. Make getters for ids in notification service
Test locale use case notification in the locale manager
Test covering all locale use cases
* Add locale middleware to handle restore from disk
* Middleware tests for locale
* Locale action tests
* Locale state reducer tests
* Changelog
* Lint and cleanup
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Speculative fix (cannot reproduce the issue) for crashes where based on the
stacktrace the download's mime type was empty.
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Once we link an `EngineSession` to a `Session` we track the time.
* The separate `BrowserAction` allows us to write a Middleware for this event.
* I was unhappy with SystemClock requiring the Android stdlib and therefore making mocking a pain, or
requiring the slow Robolectric test runner. I ended up with this wrapper class, that seems to work
well in Fenix when writing unit tests.
The next step is to write a Middleware in Fenix that looks at those events and records metrics in Glean.
I will open a PR for that soon.
After discussing with Sebastian, we decided it might be good to add
Profiler markers via Facts rather than the main alternative which was
calling the Profiler API directly. We thought so for the following
reasons:
1. we don't know what profiler markers are useful so we want to be able
to iterate quickly. Adding dependencies on the Profiler and landing
these changes across two repos hinders that
2. we want to instrument the code as close to specific method calls as
possible (e.g. GeckoSession.loadUrl) but it's not always easy to do so
(e.g. in the previous example, passing a Profiler reference to
GeckoEngineSession is difficult because GES is not a global dependency)
3. we can only add Profiler markers from the main thread so adding
markers will become more difficult if we have to understand the
threading needs of each Profiler call site
An additional benefit with having this infrastructure is that it's easy
to add Profiler markers for local debugging.
The downside with the Fact approach is that it's less explicit and our
tools would be less effective at modifying that code (e.g. refactors).
That being said, if we find a location where it would be valuable to
have a long term Profiler marker, we should consider instrumenting it
via the Profiler API.
Prior to this when the user selected to share an image from the contextual menu
the apps would only share the URL, not the actual resource.
This patch adds a new `ShareDownloadFeature` that will listen for
`AddShareAction` and download, cache locally and then share the Internet
resource contained in Action's state.
Giving the time needed to actually download these resources this feature is
only used for image sharing, not for other types of potentially bigger
resource types.
This is a breaking change with clients expected to create and register a new
instance of the this new feature otherwise the "Share image" from the
browser contextual menu will do nothing.
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
The reason we did this is mentioned in
https://github.com/mozilla-mobile/android-components/pull/9451#issuecomment-763747148
as:
> To limit the options to an accepted subset. (We also did not add the
> ASSERT level).
For a satisfying answer, I think we'd need to ask "Why?" again. However,
I don't want to spend more time on this so I didn't follow up on it. This
is why I didn't mention any reasoning for this in the code comment.
Interested clients can overwrite "mozac_url_schemes_blocklist" with a custom
list of uri schemes that will be recursively removed from the front of the uri.
* For `PurgeHistoryUseCase` I decided to not introduce a "tab ID" parameter and instead have
it purge the history of all tabs. It seems like this is what we need and individual tab
history removal is not needed for now.
* Some tabs may not have an `EngineSession` assigned. Creating one just to call purgeHistory()
seems excessive. Instead I am dropping an attached `EngineSessionState` which will cause
those tabs to just reload the URL with not back/forward history when they get restored.
Multiple things are happening in this patch:
* `TabsUseCases` now returns the ID of new tabs instead of `Session` instances.
* `SearchUseCases` now delegates to a `TabsUseCases` instance to create tabs instead of using `SessionManager`
* Search terms have been removed from `Session` and are now only accessible on `ContentState`
* `CaptureActionsMiddleware` is a new helper to inspect actions dispatched on a `Store` in unit tests.
Running ./gradlew ktlint locally reports a lot of stuff like:
/home/emilio/src/moz/android-components/components/support/migration/src/test/java/mozilla/components/support/migration/MigrationIntentProcessorTest.kt:1:1: File must end with a newline (\n)
This fixes it with:
for f in $(cat files | cut -d : -f 1); do echo "" >> $f; done
Making ./gradlew ktlint pass.
This adds a new Nimbus component that will act as a wrapper around the uniffi generated Kotlin code from mozilla/nimbus-sdk, as well as be a point of Glean integration, at least initially.
- Integrate service-nimbus with samples-glean for testing
- Set up default endpoint for debug and release, debug pointing at the dev Kinto endpoint and release at the production endpoint.
- Adds the documentation on how to set up the Kinto dev endpoint.
- Updates samples-glean README with Nimbus wording
Revert "Address even more lint errors."
This reverts commit e98ee991b34d318e671c644d63daec53902e68ff.
Revert "Update to Gradle 6.6.1."
This reverts commit cdda701c8f2be6c0486ddf1494885accf78aab00.
Revert "Address lint errors."
This reverts commit 26cb5b27bc2be672c89e7e0c63eeeda9f64c0d08.
Revert "Move JNA configuration to root project."
This reverts commit 694ef37cc30e727f3ec5d275c0e9583385980a43.
Revert "Issue https://github.com/mozilla-mobile/android-components/issues/8319: Update to Kotlin 1.4, Coroutines 1.3.9 and Android lint 27.0.1."
This reverts commit ad675c35e794050dbf8514a2d2fe7506ce0c546c.
Revert "Update Glean to 33.0.4."
This reverts commit 4731c4e2fa52d40f4062a47f02078ca0c85de632.
Revert "Update Glean to 33.0.0."
This reverts commit 352cf88a4d4bad64330d0ec997814fd8b13928c2.
Revert "Update Gradle to 6.1.1."
This reverts commit 18e88aa1a2528b10f7d81ff9dbf1df094071b6ce.
Revert "Update Android Gradle Plugin to 4.0.1."
This reverts commit f915a3b47b0f5584889ff62a80c9642bccfa36ce.