From fdf1bf2c890404e1fb4fe67e6d4d8ef765c010a7 Mon Sep 17 00:00:00 2001 From: Jocelyn Liu Date: Mon, 30 Oct 2023 11:40:18 -0700 Subject: [PATCH] [Android] Share the registration of wallet data files component with Desktop - The timing of registration is controlled by core backend - Remove RegisterWalletDataFilesComponentOnDemand in Android - Remove wallet_data_files_installer_android_util Authored by @AlexeyBarabash: - Added Android onboaring page fragment - Removed unused staff around Android's percentage progress while download Wallet component --- android/brave_java_resources.gni | 2 +- android/brave_java_sources.gni | 4 +- .../BraveComponentUpdater.java | 159 ----------------- .../activities/BraveWalletActivity.java | 23 +++ .../CreatingWalletFragment.java | 23 +++ .../DownloadComponentProgressFragment.java | 109 ------------ .../RestoreWalletFragment.java | 168 ++++++++++-------- .../SecurePasswordFragment.java | 5 + .../SetupWalletFragment.java | 2 - .../util/WalletDataFilesInstaller.java | 29 --- .../res/layout/fragment_backup_wallet.xml | 7 - .../res/layout/fragment_creating_wallet.xml | 40 +++++ .../fragment_download_component_progress.xml | 15 -- .../res/layout/fragment_recovery_phrase.xml | 6 - .../res/layout/fragment_restore_wallet.xml | 6 - .../res/layout/fragment_secure_password.xml | 7 - .../fragment_verify_recovery_phrase.xml | 7 - browser/brave_wallet/android/sources.gni | 1 - .../wallet_data_files_installer_android.cc | 54 ------ browser/component_updater/BUILD.gn | 11 -- .../brave_component_updater_android.cc | 82 --------- .../brave_component_updater_android.h | 47 ----- .../android/strings/android_brave_strings.grd | 12 +- build/android/BUILD.gn | 2 - build/android/config.gni | 2 - components/brave_wallet/browser/BUILD.gn | 8 - .../browser/wallet_data_files_installer.cc | 13 -- .../browser/wallet_data_files_installer.h | 4 - ...allet_data_files_installer_android_util.cc | 21 --- ...wallet_data_files_installer_android_util.h | 19 -- 30 files changed, 194 insertions(+), 694 deletions(-) delete mode 100644 android/java/org/chromium/chrome/browser/component_updater/BraveComponentUpdater.java create mode 100644 android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/CreatingWalletFragment.java delete mode 100644 android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/DownloadComponentProgressFragment.java delete mode 100644 android/java/org/chromium/chrome/browser/crypto_wallet/util/WalletDataFilesInstaller.java create mode 100644 android/java/res/layout/fragment_creating_wallet.xml delete mode 100644 android/java/res/layout/fragment_download_component_progress.xml delete mode 100644 browser/brave_wallet/android/wallet_data_files_installer_android.cc delete mode 100644 browser/component_updater/brave_component_updater_android.cc delete mode 100644 browser/component_updater/brave_component_updater_android.h delete mode 100644 components/brave_wallet/browser/wallet_data_files_installer_android_util.cc delete mode 100644 components/brave_wallet/browser/wallet_data_files_installer_android_util.h diff --git a/android/brave_java_resources.gni b/android/brave_java_resources.gni index 7fb6fdd592e7..70f619cd62e1 100644 --- a/android/brave_java_resources.gni +++ b/android/brave_java_resources.gni @@ -881,10 +881,10 @@ brave_java_resources = [ "java/res/layout/fragment_create_account.xml", "java/res/layout/fragment_create_account.xml", "java/res/layout/fragment_create_custom_filters.xml", + "java/res/layout/fragment_creating_wallet.xml", "java/res/layout/fragment_cross_promotional_modal_dialog.xml", "java/res/layout/fragment_dapps_message.xml", "java/res/layout/fragment_dormant_users_engagement_dialog.xml", - "java/res/layout/fragment_download_component_progress.xml", "java/res/layout/fragment_encryption_key.xml", "java/res/layout/fragment_link_subscription_dialog.xml", "java/res/layout/fragment_market.xml", diff --git a/android/brave_java_sources.gni b/android/brave_java_sources.gni index 44de53d2a59a..6cf0b4e3d49e 100644 --- a/android/brave_java_sources.gni +++ b/android/brave_java_sources.gni @@ -90,7 +90,6 @@ brave_java_sources = [ "../../brave/android/java/org/chromium/chrome/browser/brave_news/models/FeedItemsCard.java", "../../brave/android/java/org/chromium/chrome/browser/brave_stats/BraveStatsBottomSheetDialogFragment.java", "../../brave/android/java/org/chromium/chrome/browser/brave_stats/BraveStatsUtil.java", - "../../brave/android/java/org/chromium/chrome/browser/component_updater/BraveComponentUpdater.java", "../../brave/android/java/org/chromium/chrome/browser/contextmenu/BraveChromeContextMenuPopulator.java", "../../brave/android/java/org/chromium/chrome/browser/crash/BravePureJavaExceptionReporter.java", "../../brave/android/java/org/chromium/chrome/browser/crypto_wallet/AssetRatioServiceFactory.java", @@ -158,8 +157,8 @@ brave_java_sources = [ "../../brave/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/dapps/SignTransactionFragment.java", "../../brave/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/dapps/SiweMessageFragment.java", "../../brave/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/BackupWalletFragment.java", + "../../brave/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/CreatingWalletFragment.java", "../../brave/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/CryptoOnboardingFragment.java", - "../../brave/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/DownloadComponentProgressFragment.java", "../../brave/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/RecoveryPhraseFragment.java", "../../brave/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/RestoreWalletFragment.java", "../../brave/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/SecurePasswordFragment.java", @@ -210,7 +209,6 @@ brave_java_sources = [ "../../brave/android/java/org/chromium/chrome/browser/crypto_wallet/util/Utils.java", "../../brave/android/java/org/chromium/chrome/browser/crypto_wallet/util/Validations.java", "../../brave/android/java/org/chromium/chrome/browser/crypto_wallet/util/WalletConstants.java", - "../../brave/android/java/org/chromium/chrome/browser/crypto_wallet/util/WalletDataFilesInstaller.java", "../../brave/android/java/org/chromium/chrome/browser/crypto_wallet/util/WalletDataFilesInstallerUtil.java", "../../brave/android/java/org/chromium/chrome/browser/crypto_wallet/util/WalletNativeUtils.java", "../../brave/android/java/org/chromium/chrome/browser/crypto_wallet/util/WalletUtils.java", diff --git a/android/java/org/chromium/chrome/browser/component_updater/BraveComponentUpdater.java b/android/java/org/chromium/chrome/browser/component_updater/BraveComponentUpdater.java deleted file mode 100644 index c6f47f2e9c56..000000000000 --- a/android/java/org/chromium/chrome/browser/component_updater/BraveComponentUpdater.java +++ /dev/null @@ -1,159 +0,0 @@ -/* Copyright (c) 2023 The Brave Authors. All rights reserved. - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at https://mozilla.org/MPL/2.0/. */ - -package org.chromium.chrome.browser.component_updater; - -import org.json.JSONException; -import org.json.JSONObject; - -import org.chromium.base.Log; -import org.chromium.base.ThreadUtils; -import org.chromium.base.annotations.CalledByNative; -import org.chromium.base.annotations.JNINamespace; -import org.chromium.base.annotations.NativeMethods; - -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; - -/** - * Class for handling progress of component update in Java. - * Basically this is just bridge to native component updater classes at - * brave_component_updater_android.cc. - */ -@JNINamespace("chrome::android") -public class BraveComponentUpdater { - private static final String TAG = "BCU"; - private long mNativeBraveComponentUpdaterAndroid; - private static BraveComponentUpdater sBraveComponentUpdater; - - public static BraveComponentUpdater get() { - ThreadUtils.assertOnUiThread(); - if (sBraveComponentUpdater == null) { - sBraveComponentUpdater = new BraveComponentUpdater(); - } - return sBraveComponentUpdater; - } - - private BraveComponentUpdater() { - init(); - } - - @CalledByNative - private void setNativePtr(long nativePtr) { - assert mNativeBraveComponentUpdaterAndroid == 0; - mNativeBraveComponentUpdaterAndroid = nativePtr; - } - - private void init() { - if (mNativeBraveComponentUpdaterAndroid == 0) { - BraveComponentUpdaterJni.get().init(BraveComponentUpdater.this); - } - } - - @Override - protected void finalize() { - destroy(); - } - - private void destroy() { - if (mNativeBraveComponentUpdaterAndroid != 0) { - BraveComponentUpdaterJni.get().destroy(mNativeBraveComponentUpdaterAndroid); - mNativeBraveComponentUpdaterAndroid = 0; - } - } - - /** - * Listener for the component update changes. - */ - public interface ComponentUpdaterListener { - // Invoked when component update info has changed. - void onComponentUpdateEvent(int event, String id); - } - - private final List mComponentUpdaterListeners = - new CopyOnWriteArrayList<>(); - - public void addComponentUpdateEventListener(ComponentUpdaterListener listener) { - ThreadUtils.assertOnUiThread(); - mComponentUpdaterListeners.add(listener); - } - - public void removeComponentUpdateEventListener(ComponentUpdaterListener listener) { - ThreadUtils.assertOnUiThread(); - mComponentUpdaterListeners.remove(listener); - } - - @CalledByNative - protected void componentStateUpdated(int event, String id) { - for (ComponentUpdaterListener listener : mComponentUpdaterListeners) { - listener.onComponentUpdateEvent(event, id); - } - } - - /** - * Class describing the progress of component download. - */ - public static class CrxUpdateItem { - // From components/update_client/update_client.h - public static final int STATUS_NEW = 0; - public static final int STATUS_CHECKING = 1; - public static final int STATUS_CAN_UPDATE = 2; - public static final int STATUS_DOWNLOADING_DIFF = 3; - public static final int STATUS_DOWNLOADING = 4; - public static final int STATUS_DOWNLOADED = 5; - public static final int STATUS_UPDATING_DIFF = 6; - public static final int STATUS_UPDATING = 7; - public static final int STATUS_UPDATED = 8; - public static final int STATUS_UP_TO_DATE = 9; - public static final int STATUS_UPDATE_ERROR = 10; - public static final int STATUS_UNINSTALLED = 11; - public static final int STATUS_REGISTRATION = 12; - public static final int STATUS_RUN = 13; - public static final int STATUS_LAST_STATUS = 14; - - public String mId; - public long mDownloadedBytes = -1; - public long mTotalBytes = -1; - public int mState = -1; - - public boolean isInProgress() { - return mState == STATUS_DOWNLOADING_DIFF || mState == STATUS_DOWNLOADING - || mState == STATUS_DOWNLOADED || mState == STATUS_UPDATING_DIFF - || mState == STATUS_UPDATING; - } - - public void normalizeZeroProgress() { - if (mState == STATUS_DOWNLOADING && mTotalBytes == -1 && mDownloadedBytes == -1) { - mTotalBytes = 100; - mDownloadedBytes = 0; - } - } - } - - public CrxUpdateItem getUpdateState(String id) { - String json = BraveComponentUpdaterJni.get().getUpdateState( - mNativeBraveComponentUpdaterAndroid, id); - - CrxUpdateItem crxUpdateItem = new CrxUpdateItem(); - try { - JSONObject result = new JSONObject(json); - crxUpdateItem.mId = result.getString("id"); - crxUpdateItem.mDownloadedBytes = (long) result.getDouble("downloaded_bytes"); - crxUpdateItem.mTotalBytes = (long) result.getDouble("total_bytes"); - crxUpdateItem.mState = result.getInt("state"); - } catch (JSONException e) { - Log.e(TAG, "getUpdateState JSONException error ", e); - } - - return crxUpdateItem; - } - - @NativeMethods - interface Natives { - void init(BraveComponentUpdater caller); - void destroy(long nativeBraveComponentUpdaterAndroid); - String getUpdateState(long nativeBraveComponentUpdaterAndroid, String id); - } -} diff --git a/android/java/org/chromium/chrome/browser/crypto_wallet/activities/BraveWalletActivity.java b/android/java/org/chromium/chrome/browser/crypto_wallet/activities/BraveWalletActivity.java index 5ee6b691bdd6..be3044ccb506 100644 --- a/android/java/org/chromium/chrome/browser/crypto_wallet/activities/BraveWalletActivity.java +++ b/android/java/org/chromium/chrome/browser/crypto_wallet/activities/BraveWalletActivity.java @@ -44,6 +44,7 @@ import org.chromium.chrome.browser.crypto_wallet.fragments.PortfolioFragment; import org.chromium.chrome.browser.crypto_wallet.fragments.SwapBottomSheetDialogFragment; import org.chromium.chrome.browser.crypto_wallet.fragments.onboarding_fragments.BackupWalletFragment; +import org.chromium.chrome.browser.crypto_wallet.fragments.onboarding_fragments.CreatingWalletFragment; import org.chromium.chrome.browser.crypto_wallet.fragments.onboarding_fragments.RecoveryPhraseFragment; import org.chromium.chrome.browser.crypto_wallet.fragments.onboarding_fragments.RestoreWalletFragment; import org.chromium.chrome.browser.crypto_wallet.fragments.onboarding_fragments.SecurePasswordFragment; @@ -313,6 +314,15 @@ private void replaceNavigationFragments(int type, boolean doNavigate, boolean is getResources().getString(R.string.restore_crypto_account), restoreWalletFragment), mCryptoWalletOnboardingViewPager.getCurrentItem() + 1); + + CreatingWalletFragment creatingWalletFragment = new CreatingWalletFragment(); + creatingWalletFragment.setOnNextPageListener(this); + mCryptoWalletOnboardingPagerAdapter.replaceWithNavigationItem( + new NavigationItem( + getResources() + .getString(R.string.your_wallet_is_restoring_page_title), + creatingWalletFragment), + mCryptoWalletOnboardingPagerAdapter.getCount()); } else if (type == ONBOARDING_ACTION) { List navigationItems = new ArrayList<>(); SecurePasswordFragment securePasswordFragment = new SecurePasswordFragment(); @@ -320,6 +330,7 @@ private void replaceNavigationFragments(int type, boolean doNavigate, boolean is navigationItems.add( new NavigationItem(getResources().getString(R.string.secure_your_crypto), securePasswordFragment)); + addWalletCreatingPage(navigationItems, true); addBackupWalletSequence(navigationItems, true); mCryptoWalletOnboardingPagerAdapter.replaceWithNavigationItems( navigationItems, mCryptoWalletOnboardingViewPager.getCurrentItem() + 1); @@ -384,12 +395,24 @@ private void addBackupWalletSequence( verifyRecoveryPhraseFragment)); } + private void addWalletCreatingPage(List navigationItems, boolean isOnboarding) { + CreatingWalletFragment creatingWalletFragment = new CreatingWalletFragment(); + creatingWalletFragment.setOnNextPageListener(this); + navigationItems.add( + new NavigationItem( + getResources().getString(R.string.your_wallet_is_creating_page_title), + creatingWalletFragment)); + } + public void showOnboardingLayout() { addRemoveSecureFlag(true); mCryptoOnboardingLayout.setVisibility(View.VISIBLE); mCryptoLayout.setVisibility(View.GONE); List navigationItems = new ArrayList<>(); + // We don't need addWalletCreatingPage here, as showOnboardingLayout + // is invoked only when we didn't back up wallet initially and doing + // it later from `Backup your crypto wallet` bubble. addBackupWalletSequence(navigationItems, false); if (mCryptoWalletOnboardingPagerAdapter != null diff --git a/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/CreatingWalletFragment.java b/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/CreatingWalletFragment.java new file mode 100644 index 000000000000..c33f47940756 --- /dev/null +++ b/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/CreatingWalletFragment.java @@ -0,0 +1,23 @@ +/* Copyright (c) 2023 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +package org.chromium.chrome.browser.crypto_wallet.fragments.onboarding_fragments; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import org.chromium.chrome.R; + +/** Onboarding fragment for Brave Wallet which shows the spinner while wallet is created/restored */ +public class CreatingWalletFragment extends CryptoOnboardingFragment { + @Override + public View onCreateView( + LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_creating_wallet, container, false); + return view; + } +} diff --git a/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/DownloadComponentProgressFragment.java b/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/DownloadComponentProgressFragment.java deleted file mode 100644 index 5a3a0260ed06..000000000000 --- a/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/DownloadComponentProgressFragment.java +++ /dev/null @@ -1,109 +0,0 @@ -/* Copyright (c) 2023 The Brave Authors. All rights reserved. - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at https://mozilla.org/MPL/2.0/. */ - -package org.chromium.chrome.browser.crypto_wallet.fragments.onboarding_fragments; - -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.fragment.app.Fragment; - -import org.chromium.base.TimeUtils.ElapsedRealtimeMillisTimer; -import org.chromium.chrome.R; -import org.chromium.chrome.browser.component_updater.BraveComponentUpdater; -import org.chromium.chrome.browser.crypto_wallet.util.WalletDataFilesInstaller; - -/** - * A fragment to display progress of Brave Wallet data files component - * download. Used on all Brave Wallet Onboarding fragments. - */ -public class DownloadComponentProgressFragment extends Fragment { - private static final String WALLET_COMPONENT_ID = - WalletDataFilesInstaller.getWalletDataFilesComponentId(); - private TextView mComponentDownloadProgress; - private BraveComponentUpdater.ComponentUpdaterListener mComponentUpdaterListener; - private ElapsedRealtimeMillisTimer mGracePeriodNoDisplayTimer; - private static final long GRACE_NO_DISPLAY_MSEC = 1000; - - @Override - public View onCreateView( - LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - return inflater.inflate(R.layout.fragment_download_component_progress, container, false); - } - - @Override - public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - - mComponentDownloadProgress = view.findViewById(R.id.download_progress_text_view); - setupDownloadProgress(); - } - - @Override - public void onDestroyView() { - if (mComponentUpdaterListener != null) { - BraveComponentUpdater.get().removeComponentUpdateEventListener( - mComponentUpdaterListener); - mComponentUpdaterListener = null; - } - super.onDestroyView(); - } - - private void setupDownloadProgress() { - BraveComponentUpdater.CrxUpdateItem updateItem = BraveComponentUpdater.get().getUpdateState( - WalletDataFilesInstaller.getWalletDataFilesComponentId()); - showHideProgressByItem(updateItem); - - mComponentUpdaterListener = (event, id) -> { - if (!WALLET_COMPONENT_ID.equals(id)) { - return; - } - BraveComponentUpdater.CrxUpdateItem crxUpdateItem = - BraveComponentUpdater.get().getUpdateState( - WalletDataFilesInstaller.getWalletDataFilesComponentId()); - showHideProgressByItem(crxUpdateItem); - }; - - BraveComponentUpdater.get().addComponentUpdateEventListener(mComponentUpdaterListener); - } - - private void showHideProgressByItem(BraveComponentUpdater.CrxUpdateItem updateItem) { - assert updateItem.mTotalBytes < (long) Integer.MAX_VALUE; - assert updateItem.mDownloadedBytes < (long) Integer.MAX_VALUE; - - if (updateItem.mTotalBytes > 0 && updateItem.mDownloadedBytes == updateItem.mTotalBytes - || !updateItem.isInProgress()) { - mComponentDownloadProgress.setVisibility(View.GONE); - return; - } - - // On fast internet connection download goes quickly, and the text view can be - // shown for only ~0.3 sec, that doesn't have much sense and may look strange. - // We will use the timer and don't display text view for 1 sec so if it - // complete in 1 sec - we will not show it at all. - if (mGracePeriodNoDisplayTimer == null) { - mGracePeriodNoDisplayTimer = new ElapsedRealtimeMillisTimer(); - } - - if (mGracePeriodNoDisplayTimer.getElapsedMillis() < GRACE_NO_DISPLAY_MSEC) { - return; - } - - updateItem.normalizeZeroProgress(); - - mComponentDownloadProgress.setVisibility(View.VISIBLE); - - assert updateItem.mTotalBytes != 0; - String progressText = String.format(getString(R.string.download_wallet_data_files_progress), - (int) (100 * updateItem.mDownloadedBytes / updateItem.mTotalBytes)); - - mComponentDownloadProgress.setText(progressText); - } -} diff --git a/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/RestoreWalletFragment.java b/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/RestoreWalletFragment.java index 5830102e1367..2d9ad1fdc6d9 100644 --- a/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/RestoreWalletFragment.java +++ b/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/RestoreWalletFragment.java @@ -39,13 +39,13 @@ public class RestoreWalletFragment extends CryptoOnboardingFragment { private static final String IS_ONBOARDING = "is_onboarding"; - private EditText recoveryPhraseText; - private EditText passwordEdittext; - private EditText retypePasswordEdittext; - private CheckBox showRecoveryPhraseCheckbox; - private CheckBox restoreLegacyWalletCheckbox; - private boolean isLegacyWalletRestoreEnable; - private boolean isOnboarding; + private EditText mRecoveryPhraseText; + private EditText mPasswordEdittext; + private EditText mRetypePasswordEdittext; + private CheckBox mShowRecoveryPhraseCheckbox; + private CheckBox mRestoreLegacyWalletCheckbox; + private boolean mIsLegacyWalletRestoreEnable; + private boolean mIsOnboarding; public static RestoreWalletFragment newInstance(boolean isOnboarding) { RestoreWalletFragment fragment = new RestoreWalletFragment(); @@ -67,76 +67,85 @@ private KeyringService getKeyringService() { @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - isOnboarding = getArguments().getBoolean(IS_ONBOARDING); + mIsOnboarding = getArguments().getBoolean(IS_ONBOARDING); return inflater.inflate(R.layout.fragment_restore_wallet, container, false); } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - recoveryPhraseText = view.findViewById(R.id.recovery_phrase_text); - passwordEdittext = view.findViewById(R.id.restore_wallet_password); - retypePasswordEdittext = view.findViewById(R.id.restore_wallet_retype_password); - showRecoveryPhraseCheckbox = view.findViewById(R.id.restore_wallet_checkbox); - restoreLegacyWalletCheckbox = view.findViewById(R.id.restore_legacy_wallet_checkbox); + mRecoveryPhraseText = view.findViewById(R.id.recovery_phrase_text); + mPasswordEdittext = view.findViewById(R.id.restore_wallet_password); + mRetypePasswordEdittext = view.findViewById(R.id.restore_wallet_retype_password); + mShowRecoveryPhraseCheckbox = view.findViewById(R.id.restore_wallet_checkbox); + mRestoreLegacyWalletCheckbox = view.findViewById(R.id.restore_legacy_wallet_checkbox); ImageView restoreWalletCopyImage = view.findViewById(R.id.restore_wallet_copy_image); assert getActivity() != null; restoreWalletCopyImage.setOnClickListener( - v -> recoveryPhraseText.setText(Utils.getTextFromClipboard(getActivity()))); - - showRecoveryPhraseCheckbox.setOnCheckedChangeListener((buttonView, isChecked) -> { - int cursorPos = recoveryPhraseText.getSelectionStart(); - if (isChecked) { - recoveryPhraseText.setTransformationMethod( - HideReturnsTransformationMethod.getInstance()); - } else { - recoveryPhraseText.setTransformationMethod( - PasswordTransformationMethod.getInstance()); - } - recoveryPhraseText.setSelection(cursorPos); - }); - - recoveryPhraseText.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {} - - @Override - public void afterTextChanged(Editable editable) {} - - @Override - public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { - String recoveryPhrase = charSequence.toString().trim(); - - // validate recoveryPhrase contains only string. not JSON and length is 24 - if (recoveryPhrase.matches("[a-zA-Z\\s]+") - && recoveryPhrase.split("\\s+").length == 24) { - restoreLegacyWalletCheckbox.setVisibility(View.VISIBLE); - } else { - restoreLegacyWalletCheckbox.setVisibility(View.GONE); - } - } - }); - - restoreLegacyWalletCheckbox.setOnCheckedChangeListener( - (buttonView, isChecked) -> { isLegacyWalletRestoreEnable = isChecked; }); + v -> mRecoveryPhraseText.setText(Utils.getTextFromClipboard(getActivity()))); + + mShowRecoveryPhraseCheckbox.setOnCheckedChangeListener( + (buttonView, isChecked) -> { + int cursorPos = mRecoveryPhraseText.getSelectionStart(); + if (isChecked) { + mRecoveryPhraseText.setTransformationMethod( + HideReturnsTransformationMethod.getInstance()); + } else { + mRecoveryPhraseText.setTransformationMethod( + PasswordTransformationMethod.getInstance()); + } + mRecoveryPhraseText.setSelection(cursorPos); + }); - Button secureCryptoButton = view.findViewById(R.id.btn_restore_wallet); - secureCryptoButton.setOnClickListener(v -> { - String passwordInput = passwordEdittext.getText().toString(); + mRecoveryPhraseText.addTextChangedListener( + new TextWatcher() { + @Override + public void beforeTextChanged( + CharSequence charSequence, int i, int i1, int i2) {} - KeyringService keyringService = getKeyringService(); - assert keyringService != null; - keyringService.isStrongPassword(passwordInput, result -> { - if (!result) { - passwordEdittext.setError(getResources().getString(R.string.password_text)); + @Override + public void afterTextChanged(Editable editable) {} - return; - } + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + String recoveryPhrase = charSequence.toString().trim(); - proceedWithAStrongPassword(passwordInput, recoveryPhraseText); - }); - }); + // validate recoveryPhrase contains only string. not JSON and length is 24 + if (recoveryPhrase.matches("[a-zA-Z\\s]+") + && recoveryPhrase.split("\\s+").length == 24) { + mRestoreLegacyWalletCheckbox.setVisibility(View.VISIBLE); + } else { + mRestoreLegacyWalletCheckbox.setVisibility(View.GONE); + } + } + }); + + mRestoreLegacyWalletCheckbox.setOnCheckedChangeListener( + (buttonView, isChecked) -> { + mIsLegacyWalletRestoreEnable = isChecked; + }); + + Button secureCryptoButton = view.findViewById(R.id.btn_restore_wallet); + secureCryptoButton.setOnClickListener( + v -> { + String passwordInput = mPasswordEdittext.getText().toString(); + + KeyringService keyringService = getKeyringService(); + assert keyringService != null; + keyringService.isStrongPassword( + passwordInput, + result -> { + if (!result) { + mPasswordEdittext.setError( + getResources().getString(R.string.password_text)); + + return; + } + + proceedWithAStrongPassword(passwordInput, mRecoveryPhraseText); + }); + }); } @RequiresApi(api = Build.VERSION_CODES.P) @@ -172,17 +181,20 @@ public void onAuthenticationError(int errorCode, CharSequence errString) { showFingerprintDialog(authenticationCallback); } - private void proceedWithAStrongPassword(String passwordInput, EditText recoveryPhraseText) { - String retypePasswordInput = retypePasswordEdittext.getText().toString(); + private void proceedWithAStrongPassword(String passwordInput, EditText mRecoveryPhraseText) { + String retypePasswordInput = mRetypePasswordEdittext.getText().toString(); if (!passwordInput.equals(retypePasswordInput)) { - retypePasswordEdittext.setError( + mRetypePasswordEdittext.setError( getResources().getString(R.string.retype_password_error)); } else { KeyringService keyringService = getKeyringService(); assert keyringService != null; - keyringService.restoreWallet(recoveryPhraseText.getText().toString().trim(), - passwordInput, isLegacyWalletRestoreEnable, result -> { + keyringService.restoreWallet( + mRecoveryPhraseText.getText().toString().trim(), + passwordInput, + mIsLegacyWalletRestoreEnable, + result -> { if (result) { Utils.hideKeyboard(getActivity()); keyringService.notifyWalletBackupComplete(); @@ -195,26 +207,30 @@ private void proceedWithAStrongPassword(String passwordInput, EditText recoveryP onNextPage.gotoNextPage(true); } Utils.setCryptoOnboarding(false); - Utils.clearClipboard(recoveryPhraseText.getText().toString().trim(), 0); + Utils.clearClipboard( + mRecoveryPhraseText.getText().toString().trim(), 0); Utils.clearClipboard(passwordInput, 0); Utils.clearClipboard(retypePasswordInput, 0); cleanUp(); } else { - Toast.makeText(getActivity(), R.string.account_recovery_failed, - Toast.LENGTH_SHORT) + Toast.makeText( + getActivity(), + R.string.account_recovery_failed, + Toast.LENGTH_SHORT) .show(); } }); + onNextPage.gotoNextPage(false); } } private void cleanUp() { - recoveryPhraseText.getText().clear(); - passwordEdittext.getText().clear(); - retypePasswordEdittext.getText().clear(); - showRecoveryPhraseCheckbox.setChecked(false); - restoreLegacyWalletCheckbox.setChecked(false); + mRecoveryPhraseText.getText().clear(); + mPasswordEdittext.getText().clear(); + mRetypePasswordEdittext.getText().clear(); + mShowRecoveryPhraseCheckbox.setChecked(false); + mRestoreLegacyWalletCheckbox.setChecked(false); } @RequiresApi(api = Build.VERSION_CODES.P) diff --git a/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/SecurePasswordFragment.java b/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/SecurePasswordFragment.java index 0c14ebaa5caa..d18417c68d61 100644 --- a/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/SecurePasswordFragment.java +++ b/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/SecurePasswordFragment.java @@ -165,6 +165,7 @@ private void goToTheNextPage(String passwordInput) { mOnboardingViewModel.setPassword(passwordInput); onNextPage.gotoNextPage(false); }); + showCreatingWalletPage(); } } @@ -183,4 +184,8 @@ private void showFingerprintDialog( .build() .authenticate(new CancellationSignal(), executor, authenticationCallback); } + + private void showCreatingWalletPage() { + onNextPage.gotoNextPage(false); + } } diff --git a/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/SetupWalletFragment.java b/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/SetupWalletFragment.java index 164b1422e039..fb4f0c70d486 100644 --- a/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/SetupWalletFragment.java +++ b/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/onboarding_fragments/SetupWalletFragment.java @@ -26,7 +26,6 @@ import org.chromium.chrome.browser.app.BraveActivity; import org.chromium.chrome.browser.app.helpers.Api33AndPlusBackPressHelper; import org.chromium.chrome.browser.crypto_wallet.util.Utils; -import org.chromium.chrome.browser.crypto_wallet.util.WalletDataFilesInstaller; /** * Fragment to setup Brave Wallet @@ -80,7 +79,6 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat mRestartSetupAction = false; mRestartRestoreAction = false; }); - WalletDataFilesInstaller.registerWalletDataFilesComponentOnDemand(); } // We need to remove that check and restart once diff --git a/android/java/org/chromium/chrome/browser/crypto_wallet/util/WalletDataFilesInstaller.java b/android/java/org/chromium/chrome/browser/crypto_wallet/util/WalletDataFilesInstaller.java deleted file mode 100644 index f2621aad87d9..000000000000 --- a/android/java/org/chromium/chrome/browser/crypto_wallet/util/WalletDataFilesInstaller.java +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (c) 2023 The Brave Authors. All rights reserved. - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at https://mozilla.org/MPL/2.0/. */ - -package org.chromium.chrome.browser.crypto_wallet.util; - -import org.chromium.base.annotations.JNINamespace; -import org.chromium.base.annotations.NativeMethods; - -/** - * Class for JNI interaction with wallet_data_files_installer_android.cc - */ -@JNINamespace("chrome::android") -public class WalletDataFilesInstaller { - public static void registerWalletDataFilesComponentOnDemand() { - WalletDataFilesInstallerJni.get().registerWalletDataFilesComponentOnDemand(); - } - - public static String getWalletDataFilesComponentId() { - return WalletDataFilesInstallerJni.get().getWalletDataFilesComponentId(); - } - - @NativeMethods - interface Natives { - void registerWalletDataFilesComponentOnDemand(); - String getWalletDataFilesComponentId(); - } -} diff --git a/android/java/res/layout/fragment_backup_wallet.xml b/android/java/res/layout/fragment_backup_wallet.xml index 7b5b559c362d..1d6be80f8ddc 100644 --- a/android/java/res/layout/fragment_backup_wallet.xml +++ b/android/java/res/layout/fragment_backup_wallet.xml @@ -150,13 +150,6 @@ android:textSize="16sp" android:textColor="@color/wallet_text_color"/> - - diff --git a/android/java/res/layout/fragment_creating_wallet.xml b/android/java/res/layout/fragment_creating_wallet.xml new file mode 100644 index 000000000000..11e2f8e57b72 --- /dev/null +++ b/android/java/res/layout/fragment_creating_wallet.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/android/java/res/layout/fragment_download_component_progress.xml b/android/java/res/layout/fragment_download_component_progress.xml deleted file mode 100644 index 75e7ebe9f642..000000000000 --- a/android/java/res/layout/fragment_download_component_progress.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - diff --git a/android/java/res/layout/fragment_recovery_phrase.xml b/android/java/res/layout/fragment_recovery_phrase.xml index 511d666bf5b9..e847c51d20b9 100644 --- a/android/java/res/layout/fragment_recovery_phrase.xml +++ b/android/java/res/layout/fragment_recovery_phrase.xml @@ -144,12 +144,6 @@ android:textSize="16sp" android:textColor="@color/wallet_text_color"/> - diff --git a/android/java/res/layout/fragment_restore_wallet.xml b/android/java/res/layout/fragment_restore_wallet.xml index cd1d71dfaa36..e9fb13b30db4 100644 --- a/android/java/res/layout/fragment_restore_wallet.xml +++ b/android/java/res/layout/fragment_restore_wallet.xml @@ -176,12 +176,6 @@ android:textColor="@android:color/white" style="?android:attr/borderlessButtonStyle"/> - diff --git a/android/java/res/layout/fragment_secure_password.xml b/android/java/res/layout/fragment_secure_password.xml index d3bdd668ec23..70d06c4bd4dd 100644 --- a/android/java/res/layout/fragment_secure_password.xml +++ b/android/java/res/layout/fragment_secure_password.xml @@ -114,13 +114,6 @@ android:layout_marginBottom="8dp" android:textColor="@android:color/white" style="?android:attr/borderlessButtonStyle"/> - - diff --git a/android/java/res/layout/fragment_verify_recovery_phrase.xml b/android/java/res/layout/fragment_verify_recovery_phrase.xml index 6895228b821a..a335430f2903 100644 --- a/android/java/res/layout/fragment_verify_recovery_phrase.xml +++ b/android/java/res/layout/fragment_verify_recovery_phrase.xml @@ -91,13 +91,6 @@ android:textSize="16sp" android:textColor="@color/wallet_text_color"/> - - diff --git a/browser/brave_wallet/android/sources.gni b/browser/brave_wallet/android/sources.gni index 829f7410a755..ca9069d8121a 100644 --- a/browser/brave_wallet/android/sources.gni +++ b/browser/brave_wallet/android/sources.gni @@ -11,7 +11,6 @@ brave_browser_brave_wallet_android_sources = [ "//brave/browser/brave_wallet/android/keyring_service_factory_android.cc", "//brave/browser/brave_wallet/android/swap_service_factory_android.cc", "//brave/browser/brave_wallet/android/tx_service_factory_android.cc", - "//brave/browser/brave_wallet/android/wallet_data_files_installer_android.cc", "//brave/browser/brave_wallet/android/wallet_native_utils_android.cc", "//brave/browser/permissions/brave_dapp_permission_prompt_dialog_controller_android.cc", "//brave/browser/permissions/brave_dapp_permission_prompt_dialog_controller_android.h", diff --git a/browser/brave_wallet/android/wallet_data_files_installer_android.cc b/browser/brave_wallet/android/wallet_data_files_installer_android.cc deleted file mode 100644 index ffe67b805a4c..000000000000 --- a/browser/brave_wallet/android/wallet_data_files_installer_android.cc +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (c) 2023 The Brave Authors. All rights reserved. - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at https://mozilla.org/MPL/2.0/. */ - -#include "base/android/jni_android.h" -#include "base/android/jni_string.h" -#include "base/containers/contains.h" -#include "base/functional/bind.h" -#include "base/task/sequenced_task_runner.h" -#include "brave/build/android/jni_headers/WalletDataFilesInstaller_jni.h" -#include "brave/components/brave_wallet/browser/wallet_data_files_installer.h" -#include "build/build_config.h" -#include "chrome/browser/browser_process.h" -#include "components/component_updater/component_updater_service.h" - -static_assert BUILDFLAG(IS_ANDROID); - -namespace chrome { -namespace android { - -namespace { - -bool IsBraveWalletDataFilesComponentRegistered() { - std::vector registered_ids = - g_browser_process->component_updater()->GetComponentIDs(); - return base::Contains( - registered_ids, - std::string(brave_wallet::GetWalletDataFilesComponentId())); -} - -} // namespace - -static void -JNI_WalletDataFilesInstaller_RegisterWalletDataFilesComponentOnDemand( - JNIEnv* env) { - if (IsBraveWalletDataFilesComponentRegistered()) { - return; - } - - component_updater::ComponentUpdateService* cus = - g_browser_process->component_updater(); - - ::brave_wallet::RegisterWalletDataFilesComponentOnDemand(cus); -} - -static base::android::ScopedJavaLocalRef -JNI_WalletDataFilesInstaller_GetWalletDataFilesComponentId(JNIEnv* env) { - return base::android::ConvertUTF8ToJavaString( - env, ::brave_wallet::GetWalletDataFilesComponentId()); -} - -} // namespace android -} // namespace chrome diff --git a/browser/component_updater/BUILD.gn b/browser/component_updater/BUILD.gn index dedc0dcbc076..21c8458b48eb 100644 --- a/browser/component_updater/BUILD.gn +++ b/browser/component_updater/BUILD.gn @@ -28,15 +28,4 @@ source_set("component_updater") { if (is_win) { deps += [ "//chrome/installer/util:with_no_strings" ] } - - if (is_android) { - sources += [ - "brave_component_updater_android.cc", - "brave_component_updater_android.h", - ] - deps += [ - "//brave/build/android:jni_headers", - "//chrome/browser:browser_process", - ] - } } diff --git a/browser/component_updater/brave_component_updater_android.cc b/browser/component_updater/brave_component_updater_android.cc deleted file mode 100644 index 0be3ae54a497..000000000000 --- a/browser/component_updater/brave_component_updater_android.cc +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright (c) 2023 The Brave Authors. All rights reserved. - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at https://mozilla.org/MPL/2.0/. */ - -#include "brave/browser/component_updater/brave_component_updater_android.h" - -#include "base/android/jni_android.h" -#include "base/android/jni_string.h" -#include "base/json/json_writer.h" -#include "brave/build/android/jni_headers/BraveComponentUpdater_jni.h" -#include "chrome/browser/browser_process.h" -#include "components/update_client/crx_update_item.h" -#include "components/update_client/update_engine.h" - -namespace chrome { -namespace android { - -BraveComponentUpdaterAndroid::BraveComponentUpdaterAndroid( - JNIEnv* env, - const base::android::JavaRef& obj) - : weak_java_brave_sync_worker_(env, obj) { - Java_BraveComponentUpdater_setNativePtr(env, obj, - reinterpret_cast(this)); - - component_updater::ComponentUpdateService* component_updater = - g_browser_process->component_updater(); - DCHECK(component_updater); - - if (component_updater) { - observation_.Observe(component_updater); - } -} - -BraveComponentUpdaterAndroid::~BraveComponentUpdaterAndroid() { - // Observer will be removed by ScopedObservation -} - -void BraveComponentUpdaterAndroid::Destroy(JNIEnv* env) { - delete this; -} - -void BraveComponentUpdaterAndroid::OnEvent(Events event, - const std::string& id) { - // Notify Java code - JNIEnv* env = base::android::AttachCurrentThread(); - Java_BraveComponentUpdater_componentStateUpdated( - env, weak_java_brave_sync_worker_.get(env), static_cast(event), - base::android::ConvertUTF8ToJavaString(env, id)); -} - -base::android::ScopedJavaLocalRef -BraveComponentUpdaterAndroid::GetUpdateState( - JNIEnv* env, - const base::android::JavaParamRef& id) { - std::string json_string; - update_client::CrxUpdateItem item; - - if (g_browser_process->component_updater()->GetComponentDetails( - base::android::ConvertJavaStringToUTF8(id), &item)) { - base::Value::Dict value; - value.Set("id", item.id); - value.Set("downloaded_bytes", static_cast(item.downloaded_bytes)); - value.Set("total_bytes", static_cast(item.total_bytes)); - value.Set("state", static_cast(item.state)); - - if (!base::JSONWriter::Write(value, &json_string)) { - VLOG(1) << "Writing to JSON string failed. Passing empty result to Java " - "code."; - } - } - return base::android::ConvertUTF8ToJavaString(env, json_string); -} - -static void JNI_BraveComponentUpdater_Init( - JNIEnv* env, - const base::android::JavaParamRef& jcaller) { - new BraveComponentUpdaterAndroid(env, jcaller); -} - -} // namespace android -} // namespace chrome diff --git a/browser/component_updater/brave_component_updater_android.h b/browser/component_updater/brave_component_updater_android.h deleted file mode 100644 index 568db6e417c9..000000000000 --- a/browser/component_updater/brave_component_updater_android.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (c) 2023 The Brave Authors. All rights reserved. - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at https://mozilla.org/MPL/2.0/. */ - -#ifndef BRAVE_BROWSER_COMPONENT_UPDATER_BRAVE_COMPONENT_UPDATER_ANDROID_H_ -#define BRAVE_BROWSER_COMPONENT_UPDATER_BRAVE_COMPONENT_UPDATER_ANDROID_H_ - -#include - -#include - -#include "base/android/jni_weak_ref.h" -#include "base/memory/raw_ptr.h" -#include "base/scoped_observation.h" -#include "components/component_updater/component_updater_service.h" - -namespace chrome { -namespace android { - -class BraveComponentUpdaterAndroid : public component_updater::ServiceObserver { - public: - BraveComponentUpdaterAndroid(JNIEnv* env, - const base::android::JavaRef& obj); - ~BraveComponentUpdaterAndroid() override; - - base::android::ScopedJavaLocalRef GetUpdateState( - JNIEnv* env, - const base::android::JavaParamRef& id); - - void Destroy(JNIEnv* env); - - private: - // ServiceObserver implementation. - void OnEvent(Events event, const std::string& id) override; - - base::ScopedObservation - observation_{this}; - - JavaObjectWeakGlobalRef weak_java_brave_sync_worker_; -}; - -} // namespace android -} // namespace chrome - -#endif // BRAVE_BROWSER_COMPONENT_UPDATER_BRAVE_COMPONENT_UPDATER_ANDROID_H_ diff --git a/browser/ui/android/strings/android_brave_strings.grd b/browser/ui/android/strings/android_brave_strings.grd index 2d5135122d91..81c260fc2fe2 100644 --- a/browser/ui/android/strings/android_brave_strings.grd +++ b/browser/ui/android/strings/android_brave_strings.grd @@ -2085,6 +2085,15 @@ Are you sure you want to do this? Verified password did not match + + Creating Wallet... + + + Your wallet is restoring... + + + Your wallet is being created... + 1H @@ -3216,9 +3225,6 @@ If you don't accept this request, VPN will not reconnect and your internet conne Solana - - Downloading wallet data file \u2022 %1$d37\u0025\u0025 - Connected to %1$s diff --git a/build/android/BUILD.gn b/build/android/BUILD.gn index 617ab74a83f0..4dd84a86b4b7 100644 --- a/build/android/BUILD.gn +++ b/build/android/BUILD.gn @@ -214,7 +214,6 @@ generate_jni("jni_headers") { "//brave/android/java/org/chromium/chrome/browser/bookmarks/BraveBookmarkBridge.java", "//brave/android/java/org/chromium/chrome/browser/brave_leo/BraveLeoSettingsLauncherHelper.java", "//brave/android/java/org/chromium/chrome/browser/brave_news/BraveNewsControllerFactory.java", - "//brave/android/java/org/chromium/chrome/browser/component_updater/BraveComponentUpdater.java", "//brave/android/java/org/chromium/chrome/browser/crypto_wallet/AssetRatioServiceFactory.java", "//brave/android/java/org/chromium/chrome/browser/crypto_wallet/BlockchainRegistryFactory.java", "//brave/android/java/org/chromium/chrome/browser/crypto_wallet/BraveWalletProviderDelegateImplHelper.java", @@ -225,7 +224,6 @@ generate_jni("jni_headers") { "//brave/android/java/org/chromium/chrome/browser/crypto_wallet/TxServiceFactory.java", "//brave/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/dapps/ConnectAccountFragment.java", "//brave/android/java/org/chromium/chrome/browser/crypto_wallet/permission/BraveDappPermissionPromptDialog.java", - "//brave/android/java/org/chromium/chrome/browser/crypto_wallet/util/WalletDataFilesInstaller.java", "//brave/android/java/org/chromium/chrome/browser/crypto_wallet/util/WalletDataFilesInstallerUtil.java", "//brave/android/java/org/chromium/chrome/browser/crypto_wallet/util/WalletNativeUtils.java", "//brave/android/java/org/chromium/chrome/browser/informers/BraveSyncAccountDeletedInformer.java", diff --git a/build/android/config.gni b/build/android/config.gni index 310e266b2472..ed470ad4fdc6 100644 --- a/build/android/config.gni +++ b/build/android/config.gni @@ -110,7 +110,6 @@ brave_jni_headers_sources = [ "//brave/android/java/org/chromium/chrome/browser/app/BraveActivity.java", "//brave/android/java/org/chromium/chrome/browser/bookmarks/BraveBookmarkBridge.java", "//brave/android/java/org/chromium/chrome/browser/brave_news/BraveNewsControllerFactory.java", - "//brave/android/java/org/chromium/chrome/browser/component_updater/BraveComponentUpdater.java", "//brave/android/java/org/chromium/chrome/browser/crypto_wallet/AssetRatioServiceFactory.java", "//brave/android/java/org/chromium/chrome/browser/crypto_wallet/BlockchainRegistryFactory.java", "//brave/android/java/org/chromium/chrome/browser/crypto_wallet/BraveWalletProviderDelegateImplHelper.java", @@ -121,7 +120,6 @@ brave_jni_headers_sources = [ "//brave/android/java/org/chromium/chrome/browser/crypto_wallet/TxServiceFactory.java", "//brave/android/java/org/chromium/chrome/browser/crypto_wallet/fragments/dapps/ConnectAccountFragment.java", "//brave/android/java/org/chromium/chrome/browser/crypto_wallet/permission/BraveDappPermissionPromptDialog.java", - "//brave/android/java/org/chromium/chrome/browser/crypto_wallet/util/WalletDataFilesInstaller.java", "//brave/android/java/org/chromium/chrome/browser/crypto_wallet/util/WalletNativeUtils.java", "//brave/android/java/org/chromium/chrome/browser/informers/BraveSyncAccountDeletedInformer.java", "//brave/android/java/org/chromium/chrome/browser/misc_metrics/MiscAndroidMetricsFactory.java", diff --git a/components/brave_wallet/browser/BUILD.gn b/components/brave_wallet/browser/BUILD.gn index b48697e41abf..40f884bc9d0a 100644 --- a/components/brave_wallet/browser/BUILD.gn +++ b/components/brave_wallet/browser/BUILD.gn @@ -282,14 +282,6 @@ static_library("browser") { } configs += [ ":sardine_config" ] - - if (is_android) { - sources += [ - "wallet_data_files_installer_android_util.cc", - "wallet_data_files_installer_android_util.h", - ] - deps += [ "//brave/build/android:jni_headers" ] - } } if (!is_ios) { diff --git a/components/brave_wallet/browser/wallet_data_files_installer.cc b/components/brave_wallet/browser/wallet_data_files_installer.cc index cfd6e900fc1a..e7932862e438 100644 --- a/components/brave_wallet/browser/wallet_data_files_installer.cc +++ b/components/brave_wallet/browser/wallet_data_files_installer.cc @@ -20,15 +20,10 @@ #include "brave/components/brave_wallet/common/brave_wallet.mojom.h" #include "brave/components/brave_wallet/common/common_utils.h" #include "components/component_updater/component_installer.h" -#include "components/component_updater/component_updater_service.h" #include "components/prefs/pref_service.h" #include "crypto/sha2.h" #include "third_party/abseil-cpp/absl/types/optional.h" -#if BUILDFLAG(IS_ANDROID) -#include "brave/components/brave_wallet/browser/wallet_data_files_installer_android_util.h" -#endif - namespace brave_wallet { namespace { @@ -145,10 +140,6 @@ void SetLastInstalledWalletVersionForTest(const base::Version& version) { last_installed_wallet_version = version; } -std::string GetWalletDataFilesComponentId() { - return kComponentId; -} - WalletDataFilesInstaller::WalletDataFilesInstaller() = default; WalletDataFilesInstaller::~WalletDataFilesInstaller() = default; @@ -184,11 +175,7 @@ void WalletDataFilesInstaller::RegisterWalletDataFilesComponentInternal( void WalletDataFilesInstaller::MaybeRegisterWalletDataFilesComponent( component_updater::ComponentUpdateService* cus, PrefService* local_state) { -#if BUILDFLAG(IS_ANDROID) - if (!IsNativeWalletEnabled() || !IsBraveWalletConfiguredOnAndroid()) { -#else if (!IsNativeWalletEnabled() || !HasCreatedWallets(local_state)) { -#endif return; } diff --git a/components/brave_wallet/browser/wallet_data_files_installer.h b/components/brave_wallet/browser/wallet_data_files_installer.h index 16695671777f..c26c0e1ca79f 100644 --- a/components/brave_wallet/browser/wallet_data_files_installer.h +++ b/components/brave_wallet/browser/wallet_data_files_installer.h @@ -44,10 +44,6 @@ class WalletDataFilesInstaller component_updater::ComponentUpdateService* cus, PrefService* local_state); - // TODO(jocelyn): remove this and make Android share the same path - // void RegisterWalletDataFilesComponentOnDemand( - // component_updater::ComponentUpdateService* cus); - using InstallCallback = base::OnceClosure; void MaybeRegisterWalletDataFilesComponentOnDemand( InstallCallback install_callback); diff --git a/components/brave_wallet/browser/wallet_data_files_installer_android_util.cc b/components/brave_wallet/browser/wallet_data_files_installer_android_util.cc deleted file mode 100644 index f62b56c9b455..000000000000 --- a/components/brave_wallet/browser/wallet_data_files_installer_android_util.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright (c) 2023 The Brave Authors. All rights reserved. - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at https://mozilla.org/MPL/2.0/. */ - -#include "brave/components/brave_wallet/browser/wallet_data_files_installer_android_util.h" - -#include - -#include "base/android/jni_android.h" -#include "brave/build/android/jni_headers/WalletDataFilesInstallerUtil_jni.h" - -namespace brave_wallet { - -bool IsBraveWalletConfiguredOnAndroid() { - JNIEnv* env = base::android::AttachCurrentThread(); - return Java_WalletDataFilesInstallerUtil_isBraveWalletConfiguredOnAndroid( - env); -} - -} // namespace brave_wallet diff --git a/components/brave_wallet/browser/wallet_data_files_installer_android_util.h b/components/brave_wallet/browser/wallet_data_files_installer_android_util.h deleted file mode 100644 index 9c6197205887..000000000000 --- a/components/brave_wallet/browser/wallet_data_files_installer_android_util.h +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright (c) 2023 The Brave Authors. All rights reserved. - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at https://mozilla.org/MPL/2.0/. */ - -#ifndef BRAVE_COMPONENTS_BRAVE_WALLET_BROWSER_WALLET_DATA_FILES_INSTALLER_ANDROID_UTIL_H_ -#define BRAVE_COMPONENTS_BRAVE_WALLET_BROWSER_WALLET_DATA_FILES_INSTALLER_ANDROID_UTIL_H_ - -#include "build/build_config.h" - -static_assert BUILDFLAG(IS_ANDROID); - -namespace brave_wallet { - -bool IsBraveWalletConfiguredOnAndroid(); - -} // namespace brave_wallet - -#endif // BRAVE_COMPONENTS_BRAVE_WALLET_BROWSER_WALLET_DATA_FILES_INSTALLER_ANDROID_UTIL_H_