summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheScarastic <warabhishek@e.email>2022-06-16 18:02:37 +0530
committerTheScarastic <warabhishek@e.email>2022-06-16 18:03:30 +0530
commitcf15469947491ac61cdf857f22cadc21e57c38a7 (patch)
tree6c736aa4b010d6ee6ee1072e52e1fe595b243aae
parent69f501bcc3fabdcc24cf65d063753ba345425996 (diff)
advanced-privacy: fix leaks found via leakcanary
-rw-r--r--app/build.gradle1
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt21
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFragment.kt11
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt10
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersFragment.kt28
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/AppTrackersFragment.kt11
6 files changed, 62 insertions, 20 deletions
diff --git a/app/build.gradle b/app/build.gradle
index 89559fc..f6fecd2 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -135,6 +135,7 @@ dependencies {
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
+ debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'
}
static def log(Object val) {
diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt
index 398a594..323f1bb 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt
@@ -73,8 +73,10 @@ class DashboardFragment :
viewModelProviderFactoryOf { dependencyContainer.dashBoardViewModelFactory.create() }
}
- private lateinit var graphHolder: GraphHolder
- private lateinit var binding: FragmentDashboardBinding
+ private var graphHolder: GraphHolder? = null
+
+ private var _binding: FragmentDashboardBinding? = null
+ private val binding get() = _binding!!
private var qpDisabledSnackbar: Snackbar? = null
@@ -142,7 +144,7 @@ class DashboardFragment :
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
- binding = FragmentDashboardBinding.bind(view)
+ _binding = FragmentDashboardBinding.bind(view)
graphHolder = GraphHolder(binding.graph, requireContext())
@@ -265,8 +267,8 @@ class DashboardFragment :
binding.graphLegend.isVisible = true
binding.leakingAppButton.isVisible = true
binding.graphEmpty.isVisible = false
- state.dayStatistics?.let { graphHolder.data = it }
- state.dayLabels?.let { graphHolder.labels = it }
+ state.dayStatistics?.let { graphHolder?.data = it }
+ state.dayLabels?.let { graphHolder?.labels = it }
binding.graphLegend.text = Html.fromHtml(
getString(
@@ -278,7 +280,7 @@ class DashboardFragment :
highlightIndexOnStart?.let {
binding.graph.post {
- graphHolder.highlightIndex(it)
+ graphHolder?.highlightIndex(it)
}
highlightIndexOnStart = null
}
@@ -307,4 +309,11 @@ class DashboardFragment :
}
override fun actions(): Flow<DashboardFeature.Action> = viewModel.actions
+
+ override fun onDestroyView() {
+ super.onDestroyView()
+ qpDisabledSnackbar = null
+ graphHolder = null
+ _binding = null
+ }
}
diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFragment.kt
index 2452d33..59d30c8 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFragment.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/features/internetprivacy/InternetPrivacyFragment.kt
@@ -56,7 +56,8 @@ class InternetPrivacyFragment :
viewModelProviderFactoryOf { dependencyContainer.internetPrivacyViewModelFactory.create() }
}
- private lateinit var binding: FragmentInternetActivityPolicyBinding
+ private var _binding: FragmentInternetActivityPolicyBinding? = null
+ private val binding get() = _binding!!
private var qpDisabledSnackbar: Snackbar? = null
@@ -93,7 +94,7 @@ class InternetPrivacyFragment :
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
- binding = FragmentInternetActivityPolicyBinding.bind(view)
+ _binding = FragmentInternetActivityPolicyBinding.bind(view)
binding.apps.apply {
layoutManager = LinearLayoutManager(requireContext())
@@ -200,4 +201,10 @@ class InternetPrivacyFragment :
}
override fun actions(): Flow<InternetPrivacyFeature.Action> = viewModel.actions
+
+ override fun onDestroyView() {
+ super.onDestroyView()
+ qpDisabledSnackbar = null
+ _binding = null
+ }
}
diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt
index fa26dd0..284a223 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt
@@ -75,7 +75,8 @@ class FakeLocationFragment :
viewModelProviderFactoryOf { dependencyContainer.fakeLocationViewModelFactory.create() }
}
- private lateinit var binding: FragmentFakeLocationBinding
+ private var _binding: FragmentFakeLocationBinding? = null
+ private val binding get() = _binding!!
private var mapboxMap: MapboxMap? = null
private var locationComponent: LocationComponent? = null
@@ -122,7 +123,7 @@ class FakeLocationFragment :
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
- binding = FragmentFakeLocationBinding.bind(view)
+ _binding = FragmentFakeLocationBinding.bind(view)
binding.mapView.setup(savedInstanceState) { mapboxMap ->
this.mapboxMap = mapboxMap
@@ -346,5 +347,10 @@ class FakeLocationFragment :
override fun onDestroyView() {
super.onDestroyView()
binding.mapView.onDestroy()
+ qpDisabledSnackbar = null
+ mapboxMap = null
+ locationComponent = null
+ inputJob = null
+ _binding = null
}
}
diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersFragment.kt
index 21a90bc..f6a031b 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersFragment.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/TrackersFragment.kt
@@ -55,10 +55,12 @@ class TrackersFragment :
viewModelProviderFactoryOf { dependencyContainer.trackersViewModelFactory.create() }
}
- private lateinit var binding: FragmentTrackersBinding
- private lateinit var dayGraphHolder: GraphHolder
- private lateinit var monthGraphHolder: GraphHolder
- private lateinit var yearGraphHolder: GraphHolder
+ private var _binding: FragmentTrackersBinding? = null
+ private val binding get() = _binding!!
+
+ private var dayGraphHolder: GraphHolder? = null
+ private var monthGraphHolder: GraphHolder? = null
+ private var yearGraphHolder: GraphHolder? = null
private var qpDisabledSnackbar: Snackbar? = null
override fun onCreate(savedInstanceState: Bundle?) {
@@ -99,7 +101,7 @@ class TrackersFragment :
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
- binding = FragmentTrackersBinding.bind(view)
+ _binding = FragmentTrackersBinding.bind(view)
dayGraphHolder = GraphHolder(binding.graphDay.graph, requireContext(), false)
monthGraphHolder = GraphHolder(binding.graphMonth.graph, requireContext(), false)
@@ -131,9 +133,9 @@ class TrackersFragment :
if (state.showQuickPrivacyDisabledMessage) qpDisabledSnackbar?.show()
else qpDisabledSnackbar?.dismiss()
- state.dayStatistics?.let { renderGraph(it, dayGraphHolder, binding.graphDay) }
- state.monthStatistics?.let { renderGraph(it, monthGraphHolder, binding.graphMonth) }
- state.yearStatistics?.let { renderGraph(it, yearGraphHolder, binding.graphYear) }
+ state.dayStatistics?.let { renderGraph(it, dayGraphHolder!!, binding.graphDay) }
+ state.monthStatistics?.let { renderGraph(it, monthGraphHolder!!, binding.graphMonth) }
+ state.yearStatistics?.let { renderGraph(it, yearGraphHolder!!, binding.graphYear) }
state.apps?.let {
binding.apps.post {
@@ -161,4 +163,14 @@ class TrackersFragment :
}
override fun actions(): Flow<TrackersFeature.Action> = viewModel.actions
+
+ override fun onDestroyView() {
+ super.onDestroyView()
+ qpDisabledSnackbar = null
+ dayGraphHolder = null
+ monthGraphHolder = null
+ yearGraphHolder = null
+ _binding = null
+
+ }
}
diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/AppTrackersFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/AppTrackersFragment.kt
index 406d26c..efce9ff 100644
--- a/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/AppTrackersFragment.kt
+++ b/app/src/main/java/foundation/e/privacycentralapp/features/trackers/apptrackers/AppTrackersFragment.kt
@@ -65,7 +65,8 @@ class AppTrackersFragment :
}
}
- private lateinit var binding: ApptrackersFragmentBinding
+ private var _binding: ApptrackersFragmentBinding? = null
+ private val binding get() = _binding!!
private var qpDisabledSnackbar: Snackbar? = null
@@ -107,7 +108,7 @@ class AppTrackersFragment :
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
- binding = ApptrackersFragmentBinding.bind(view)
+ _binding = ApptrackersFragmentBinding.bind(view)
binding.blockAllToggle.setOnClickListener {
viewModel.submitAction(Action.BlockAllToggleAction(binding.blockAllToggle.isChecked))
@@ -174,4 +175,10 @@ class AppTrackersFragment :
}
override fun actions(): Flow<Action> = viewModel.actions
+
+ override fun onDestroyView() {
+ super.onDestroyView()
+ qpDisabledSnackbar = null
+ _binding = null
+ }
}