Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Bug 1876481 - Updated HomeActivity variables & funcs with the necessary visibility modifiers to enforce constraints. #5291

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions fenix/app/src/main/java/org/mozilla/fenix/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
components.core.store.dispatch(SearchAction.RefreshSearchEnginesAction)
}

override fun onStart() {
final override fun onStart() {
// DO NOT MOVE ANYTHING ABOVE THIS getProfilerTime CALL.
val startProfilerTime = components.core.engine.profiler?.getProfilerTime()

Expand All @@ -537,7 +537,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
) // DO NOT MOVE ANYTHING BELOW THIS addMarker CALL.
}

override fun onStop() {
final override fun onStop() {
super.onStop()

// Diagnostic breadcrumb for "Display already aquired" crash:
Expand Down Expand Up @@ -593,6 +593,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
outContent?.webUri = currentTabUrl?.let { Uri.parse(it) }
}

@CallSuper
override fun onDestroy() {
super.onDestroy()

Expand All @@ -616,7 +617,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
}
}

override fun onConfigurationChanged(newConfig: Configuration) {
final override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)

// Diagnostic breadcrumb for "Display already aquired" crash:
Expand All @@ -626,7 +627,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
)
}

override fun recreate() {
final override fun recreate() {
// Diagnostic breadcrumb for "Display already aquired" crash:
// https://github.com/mozilla-mobile/android-components/issues/7960
breadcrumb(
Expand Down Expand Up @@ -711,12 +712,12 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
else -> super.onCreateView(parent, name, context, attrs)
}

override fun onActionModeStarted(mode: ActionMode?) {
final override fun onActionModeStarted(mode: ActionMode?) {
actionMode = mode
super.onActionModeStarted(mode)
}

override fun onActionModeFinished(mode: ActionMode?) {
final override fun onActionModeFinished(mode: ActionMode?) {
actionMode = null
super.onActionModeFinished(mode)
}
Expand Down Expand Up @@ -783,7 +784,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
return false
}

override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
final override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
ProfilerMarkers.addForDispatchTouchEvent(components.core.engine.profiler, ev)
return super.dispatchTouchEvent(ev)
}
Expand Down Expand Up @@ -844,6 +845,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
* private mode directly before the content view is created. Returns the mode set by the intent
* otherwise falls back to the last known mode.
*/
@VisibleForTesting
internal fun getModeFromIntentOrLastKnown(intent: Intent?): BrowsingMode {
intent?.toSafeIntent()?.let {
if (it.hasExtra(PRIVATE_BROWSING_MODE)) {
Expand Down Expand Up @@ -896,7 +898,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
* Returns the [supportActionBar], inflating it if necessary.
* Everyone should call this instead of supportActionBar.
*/
override fun getSupportActionBarAndInflateIfNecessary(): ActionBar {
final override fun getSupportActionBarAndInflateIfNecessary(): ActionBar {
if (!isToolbarInflated) {
navigationToolbar = binding.navigationToolbarStub.inflate() as Toolbar

Expand All @@ -911,7 +913,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
}

@Suppress("SpreadOperator")
fun setupNavigationToolbar(vararg topLevelDestinationIds: Int) {
private fun setupNavigationToolbar(vararg topLevelDestinationIds: Int) {
NavigationUI.setupWithNavController(
navigationToolbar,
navHost.navController,
Expand Down Expand Up @@ -1094,13 +1096,13 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
navController.navigate(NavGraphDirections.actionStartupHome())
}

override fun attachBaseContext(base: Context) {
final override fun attachBaseContext(base: Context) {
base.components.strictMode.resetAfter(StrictMode.allowThreadDiskReads()) {
super.attachBaseContext(base)
}
}

override fun getSystemService(name: String): Any? {
final override fun getSystemService(name: String): Any? {
// Issue #17759 had a crash with the PerformanceInflater.kt on Android 5.0 and 5.1
// when using the TimePicker. Since the inflater was created for performance monitoring
// purposes and that we test on new android versions, this means that any difference in
Expand All @@ -1114,7 +1116,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
return super.getSystemService(name)
}

protected open fun createBrowsingModeManager(initialMode: BrowsingMode): BrowsingModeManager {
private fun createBrowsingModeManager(initialMode: BrowsingMode): BrowsingModeManager {
return DefaultBrowsingModeManager(initialMode, components.settings) { newMode ->
updateSecureWindowFlags(newMode)
themeManager.currentTheme = newMode
Expand All @@ -1131,7 +1133,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
}
}

protected open fun createThemeManager(): ThemeManager {
private fun createThemeManager(): ThemeManager {
return DefaultThemeManager(browsingModeManager.mode, this)
}

Expand Down Expand Up @@ -1182,7 +1184,8 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
* Indicates if the user should be redirected to the [BrowserFragment] or to the [HomeFragment],
* links from an external apps should always opened in the [BrowserFragment].
*/
fun shouldStartOnHome(intent: Intent? = this.intent): Boolean {
@VisibleForTesting
internal fun shouldStartOnHome(intent: Intent? = this.intent): Boolean {
return components.strictMode.resetAfter(StrictMode.allowThreadDiskReads()) {
// We only want to open on home when users tap the app,
// we want to ignore other cases when the app gets open by users clicking on links.
Expand Down Expand Up @@ -1262,6 +1265,6 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {

// PWA must have been used within last 30 days to be considered "recently used" for the
// telemetry purposes.
const val PWA_RECENTLY_USED_THRESHOLD = DateUtils.DAY_IN_MILLIS * 30L
private const val PWA_RECENTLY_USED_THRESHOLD = DateUtils.DAY_IN_MILLIS * 30L
}
}
Loading