Skip to content

Commit

Permalink
Upgrade Android dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Songlin Jiang <sjiang@igalia.com>
  • Loading branch information
HollowMan6 committed Jul 7, 2023
1 parent 24e7eb4 commit 2541d56
Show file tree
Hide file tree
Showing 37 changed files with 156 additions and 105 deletions.
1 change: 1 addition & 0 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.4.1)
project(wolvic)
set(CMAKE_CXX_STANDARD 17)

# Creates and names a library, sets it as either STATIC
Expand Down
23 changes: 13 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if (getGradle().getStartParameter().getTaskRequests().toString() =~ /(h|H)vr/) {
apply plugin: 'com.huawei.agconnect'
}

deps.telemetry.glean_unittests = "org.mozilla.telemetry:glean-forUnitTests:$project.ext.glean_version"
deps.telemetry.glean_unittests = "org.mozilla.telemetry:glean-native-forUnitTests:$project.ext.glean_version"

def getGitHash = { ->
def stdout = new ByteArrayOutputStream()
Expand Down Expand Up @@ -152,6 +152,7 @@ android {
packagingOptions {
jniLibs {
useLegacyPackaging = true
pickFirsts += ['**/libxul.so']
}
}

Expand All @@ -177,13 +178,11 @@ android {

externalNativeBuild {
cmake {
version "3.10.2"
path "CMakeLists.txt"
}
}

lintOptions {
disable "ExtraTranslation"
}

flavorDimensions "platform", "abi", "backend", "store"

Expand Down Expand Up @@ -503,7 +502,14 @@ android {
unitTests.includeAndroidResources = true
}

aaptOptions {

buildFeatures {
viewBinding true
prefab true // enable prefab support for various SDK AAR
dataBinding true
}
namespace 'com.igalia.wolvic'
androidResources {
noCompress 'ja'
// TODO: This statement should be moved under 'chromium' dimension or removed. So far, these
// options are affected to every variants when`isChromiumAvailable()` is true.
Expand All @@ -513,11 +519,8 @@ android {
noCompress 'pak'
}
}

buildFeatures {
viewBinding true
prefab true // enable prefab support for various SDK AAR
dataBinding true
lint {
disable 'ExtraTranslation'
}
}

Expand Down
3 changes: 2 additions & 1 deletion app/src/aosp/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.igalia.wolvic" xmlns:tools="http://schemas.android.com/tools">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-feature android:glEsVersion="0x00030001"/>
<uses-feature android:name="android.hardware.vr.headtracking" android:version="1" android:required="true" />
<uses-permission android:name="android.permission.CAMERA"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import mozilla.components.concept.storage.Login
import mozilla.components.concept.storage.LoginEntry
import mozilla.components.concept.storage.LoginsStorage
import mozilla.components.service.sync.logins.GeckoLoginStorageDelegate
import org.mozilla.geckoview.Autocomplete
Expand All @@ -13,7 +14,7 @@ class GeckoAutocompleteDelegateWrapper(private val storageDelegate: GeckoLoginSt
Autocomplete.StorageDelegate {

override fun onLoginSave(login: Autocomplete.LoginEntry) {
storageDelegate.onLoginSave(login.toLogin())
storageDelegate.onLoginSave(login.toLoginEntry())
}

override fun onLoginFetch(domain: String): GeckoResult<Array<Autocomplete.LoginEntry>>? {
Expand All @@ -33,16 +34,15 @@ class GeckoAutocompleteDelegateWrapper(private val storageDelegate: GeckoLoginSt
}

override fun onLoginUsed(login: Autocomplete.LoginEntry, useFields: Int) {
storageDelegate.onLoginSave(login.toLogin())
storageDelegate.onLoginSave(login.toLoginEntry())
}

companion object {
/**
* Converts a GeckoView [LoginStorage.LoginEntry] to an Android Components [Login]
*/
@JvmStatic
fun Autocomplete.LoginEntry.toLogin() = Login(
guid = guid,
fun Autocomplete.LoginEntry.toLoginEntry() = LoginEntry(
origin = origin.orEmpty(),
formActionOrigin = formActionOrigin,
httpRealm = httpRealm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import org.mozilla.geckoview.GeckoSession;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;

Expand Down Expand Up @@ -46,7 +47,19 @@ public String text() {
@Nullable
@Override
public RectF clientRect() {
return mSelection.clientRect;
Class<?> clazz = mSelection.getClass();
String[] fieldNames = {"screenRect", "clientRect"};

for (String fieldName : fieldNames) {
try {
Field field = clazz.getDeclaredField(fieldName);
field.setAccessible(true); // Allow access to private fields
return (RectF) field.get(mSelection);
} catch (NoSuchFieldException | IllegalAccessException e) {
// Field not found, continue to the next field name
}
}
return null;
}

@NonNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ class Accounts constructor(val context: Context) {

fun updateProfileAsync(): CompletableFuture<Profile?>? {
return CoroutineScope(Dispatchers.Main).future {
services.accountManager.fetchProfile()
services.accountManager.accountProfile()
}
}

Expand Down
3 changes: 2 additions & 1 deletion app/src/common/shared/com/igalia/wolvic/browser/Addons.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import mozilla.components.feature.addons.update.AddonUpdater
import mozilla.components.feature.addons.update.DefaultAddonUpdater
import mozilla.components.feature.addons.update.GlobalAddonDependencyProvider
import mozilla.components.support.base.log.logger.Logger
import mozilla.components.support.base.worker.Frequency
import mozilla.components.support.webextensions.WebExtensionSupport
import mozilla.components.support.webextensions.WebExtensionSupport.installedExtensions
import java.util.concurrent.CompletableFuture
Expand Down Expand Up @@ -66,7 +67,7 @@ class Addons(val context: Context, private val sessionStore: SessionStore) {

@Suppress("MagicNumber")
private val addonUpdater by lazy {
DefaultAddonUpdater(context, AddonUpdater.Frequency(12, TimeUnit.HOURS))
DefaultAddonUpdater(context, Frequency(12, TimeUnit.HOURS))
}

private val addonManager by lazy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ class BookmarksStore constructor(val context: Context) {
title = titles[DESKTOP_ROOT],
children = emptyList(),
position = null,
url = null
url = null,
dateAdded = java.util.Date().time
)
)
// Append all of the bookmarks in the mobile root.
Expand Down
26 changes: 13 additions & 13 deletions app/src/common/shared/com/igalia/wolvic/browser/LoginStorage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.future.future
import kotlinx.coroutines.launch
import mozilla.appservices.logins.InvalidKeyException
import mozilla.components.concept.storage.Login
import mozilla.components.service.fxa.SyncEngine
import mozilla.components.service.fxa.sync.GlobalSyncableStoreProvider
Expand All @@ -23,17 +22,18 @@ class LoginStorage(
init {
EngineProvider.getOrCreateRuntime(context).setUpLoginPersistence(places.logins)
GlobalScope.launch(Dispatchers.IO) {
try {
storage.value.warmUp()
} catch (e: InvalidKeyException) {
// Login database sometimes gets corrupted for unknown reasons. This has been reported
// to mozilla components in the past (https://github.com/mozilla-mobile/android-components/issues/6681
// or https://github.com/mozilla-mobile/fenix/issues/15597) but it was never really
// fixed so clients have to deal with that. The only thing we could do is to delete
// the database file. We cannot just use wipe()/wipeLocal() because those calls also
// try to use the connection to the DB and thus they'll crash as well.
places.clearLoginsDatabaseUglyHack()
}
storage.value.warmUp()
// try {
// storage.value.warmUp()
// } catch (e: InvalidKeyException) {
// // Login database sometimes gets corrupted for unknown reasons. This has been reported
// // to mozilla components in the past (https://github.com/mozilla-mobile/android-components/issues/6681
// // or https://github.com/mozilla-mobile/fenix/issues/15597) but it was never really
// // fixed so clients have to deal with that. The only thing we could do is to delete
// // the database file. We cannot just use wipe()/wipeLocal() because those calls also
// // try to use the connection to the DB and thus they'll crash as well.
// places.clearLoginsDatabaseUglyHack()
// }
}

GlobalSyncableStoreProvider.configureStore(SyncEngine.Passwords to storage)
Expand All @@ -52,7 +52,7 @@ class LoginStorage(
}

fun update(login: Login) = GlobalScope.future {
storage.value.update(login);
storage.value.update(login.guid!!, login.toEntry());
}

}
1 change: 1 addition & 0 deletions app/src/common/shared/com/igalia/wolvic/browser/Places.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class Places(var context: Context) {
SettingsStore.getInstance(context).recordPasswordsEncryptionKeyGenerated()
getSecureAbove22Preferences().putString(PASSWORDS_KEY, it)
}
lazy { getSecureAbove22Preferences() }
}

var bookmarks = PlacesBookmarksStorage(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class LoginDelegateWrapper {
*/
@JvmStatic
fun WAutocomplete.LoginEntry.toLogin() = Login(
guid = guid,
guid = guid.orEmpty(),
origin = origin.orEmpty(),
formActionOrigin = formActionOrigin,
httpRealm = httpRealm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ class WolvicEngineSession(
override fun exitFullScreenMode() = Unit
override fun findAll(text: String) = Unit
override fun findNext(forward: Boolean) = Unit
override fun goBack() = Unit
override fun goForward() = Unit
override fun goBack(userInteraction: Boolean) = Unit
override fun goForward(userInteraction: Boolean) = Unit
override fun goToHistoryIndex(index: Int) = Unit
override fun loadData(data: String, mimeType: String, encoding: String) = Unit
override fun reload(flags: LoadUrlFlags) = Unit
override fun requestPdfToDownload() = Unit
override fun restoreState(state: EngineSessionState) = true
override fun stopLoading() = Unit
override fun toggleDesktopMode(enable: Boolean, reload: Boolean) = Unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ public void onTrackingProtectionLevelUpdated(int level) {
WebCompatFeature.INSTANCE.install(mWebExtensionRuntime);
WebCompatReporterFeature.INSTANCE.install(mWebExtensionRuntime, context.getString(R.string.app_name));
mWebChannelsFeature = new FxaWebChannelFeature(
mContext,
null,
mWebExtensionRuntime,
ComponentsAdapter.get().getStore(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public Bookmark(@NonNull BookmarkNode node, int level, boolean isExpanded) {
mTitle = node.getTitle();
mURL = node.getUrl();
mGuid = node.getGuid();
mPosition = node.getPosition() != null ? node.getPosition() : 0;
mPosition = 0;
// mPosition = node.getPosition() != null ? node.getPosition() : 0;
mHasChildren = node.getChildren() != null;

switch (node.getType()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ private Unit domainAutocompleteFilter(String text) {
mBinding.urlEditText.applyAutocompleteResult(new InlineAutocompleteEditText.AutocompleteResult(
result.getText(),
result.getSource(),
result.getTotalItems(),
null));
result.getTotalItems()));
} else {
mBinding.urlEditText.noAutocompleteResult();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,11 @@ private void updateSyncBindings(boolean isSyncing) {

private AccountObserver mAccountListener = new AccountObserver() {

@Override
public void onReady(@Nullable OAuthAccount oAuthAccount) {

}

@Override
public void onAuthenticated(@NonNull OAuthAccount oAuthAccount, @NonNull AuthType authType) {
mBinding.setIsSignedIn(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ private void updateSyncBindings(boolean isSyncing) {

private AccountObserver mAccountListener = new AccountObserver() {

@Override
public void onReady(@Nullable OAuthAccount oAuthAccount) {

}

@Override
public void onAuthenticated(@NonNull OAuthAccount oAuthAccount, @NonNull AuthType authType) {
mBinding.setIsSignedIn(true);
Expand Down Expand Up @@ -406,7 +411,9 @@ private void addSection(final @NonNull List<VisitInfo> items, @NonNull String se
section,
section,
rangeStart,
VisitType.NOT_A_VISIT
VisitType.NOT_A_VISIT,
null,
false
));
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1922,7 +1922,7 @@ public void reject() {
public void onHistoryStateChange(@NonNull WSession session, @NonNull HistoryList historyList) {
if (!mSession.isPrivateMode()) {
for (HistoryItem item : historyList.getItems()) {
SessionStore.get().getHistoryStore().recordObservation(item.getUri(), new PageObservation(item.getTitle()));
SessionStore.get().getHistoryStore().recordObservation(item.getUri(), new PageObservation(item.getTitle(), null));
}
}
}
Expand Down Expand Up @@ -1976,11 +1976,11 @@ public WResult<Boolean> onVisited(@NonNull WSession session, @NonNull String url
redirectSource = RedirectSource.TEMPORARY;

} else {
redirectSource = RedirectSource.NOT_A_SOURCE;
redirectSource = null;
}

SessionStore.get().getHistoryStore().recordVisit(url, new PageVisit(visitType, redirectSource));
SessionStore.get().getHistoryStore().recordObservation(url, new PageObservation(url));
SessionStore.get().getHistoryStore().recordObservation(url, new PageObservation(url, null));

return WResult.fromValue(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,11 @@ public void exitResizeMode() {
}

private AccountObserver mAccountObserver = new AccountObserver() {
@Override
public void onReady(@Nullable OAuthAccount oAuthAccount) {

}

@Override
public void onLoggedOut() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,9 @@ public void onFlowError(@NotNull AuthFlowError authFlowError) {
hide(KEEP_WIDGET);
}
}

@Override
public void onReady(@Nullable OAuthAccount oAuthAccount) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ private void signOut(View view) {

private AccountObserver mAccountListener = new AccountObserver() {

@Override
public void onReady(@Nullable OAuthAccount oAuthAccount) {

}

@Override
public void onAuthenticated(@NonNull OAuthAccount oAuthAccount, @NonNull AuthType authType) {
mBinding.signButton.setButtonText(R.string.settings_fxa_account_sign_out);
Expand Down
Loading

0 comments on commit 2541d56

Please sign in to comment.