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

Commit

Permalink
Bug 1876481 - Updated HomeActivity variables & funcs with the neces…
Browse files Browse the repository at this point in the history
…sary visibility modifiers to enforce constraints.
  • Loading branch information
t-p-white committed Jan 25, 2024
1 parent aa64798 commit 08556f4
Showing 1 changed file with 18 additions and 15 deletions.
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 @@ -524,7 +524,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 @@ -544,7 +544,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 @@ -600,6 +600,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
outContent?.webUri = currentTabUrl?.let { Uri.parse(it) }
}

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

Expand All @@ -623,7 +624,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 @@ -633,7 +634,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 @@ -718,12 +719,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 @@ -790,7 +791,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 @@ -851,6 +852,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 @@ -903,7 +905,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 @@ -918,7 +920,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 @@ -1101,13 +1103,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 @@ -1121,7 +1123,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 @@ -1138,7 +1140,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
}
}

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

Expand Down Expand Up @@ -1189,7 +1191,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 @@ -1269,6 +1272,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
}
}

0 comments on commit 08556f4

Please sign in to comment.