diff --git a/app/src/main/java/foundation/e/apps/data/exodus/ExodusTrackerApi.kt b/app/src/main/java/foundation/e/apps/data/exodus/ExodusTrackerApi.kt index 9c9c35ea56b931ca21e5e32394469abeea675f9b..0865c33694c5e8d674983f165c0c542c70f1d924 100644 --- a/app/src/main/java/foundation/e/apps/data/exodus/ExodusTrackerApi.kt +++ b/app/src/main/java/foundation/e/apps/data/exodus/ExodusTrackerApi.kt @@ -2,6 +2,7 @@ package foundation.e.apps.data.exodus import retrofit2.Response import retrofit2.http.GET +import retrofit2.http.Headers import retrofit2.http.Path import retrofit2.http.Query @@ -9,11 +10,14 @@ interface ExodusTrackerApi { companion object { const val BASE_URL = "https://exodus.ecloud.global/api/" + const val CACHE_DURATION_SECONDS = 86400 // 1 day } + @Headers("Cache-Control: public, max-age=$CACHE_DURATION_SECONDS") @GET("trackers") suspend fun getTrackerList(@Query("date") date: String): Response + @Headers("Cache-Control: public, max-age=$CACHE_DURATION_SECONDS") @GET("search/{appHandle}/details") suspend fun getTrackerInfoOfApp( @Path("appHandle") appHandle: String, diff --git a/app/src/main/java/foundation/e/apps/data/exodus/repositories/AppPrivacyInfoRepositoryImpl.kt b/app/src/main/java/foundation/e/apps/data/exodus/repositories/AppPrivacyInfoRepositoryImpl.kt index d3ba7254820320ec982a53a295ab6d155b31a6e1..4c9b427ef33e4fd731e80dd137ecabc3e83fb029 100644 --- a/app/src/main/java/foundation/e/apps/data/exodus/repositories/AppPrivacyInfoRepositoryImpl.kt +++ b/app/src/main/java/foundation/e/apps/data/exodus/repositories/AppPrivacyInfoRepositoryImpl.kt @@ -56,6 +56,10 @@ class AppPrivacyInfoRepositoryImpl @Inject constructor( return Result.success(appInfo) } + if (application.is_pwa) { + return Result.error("No need to fetch trackers for a PWA app") + } + val appTrackerInfoResult = getResult { exodusTrackerApi.getTrackerInfoOfApp( appHandle, diff --git a/app/src/main/java/foundation/e/apps/di/CommonUtilsModule.kt b/app/src/main/java/foundation/e/apps/di/CommonUtilsModule.kt index bb14ac08de57cc0824c22006ade75a92267d6288..312ed053788c3aedbcf3b5d9e54990ec97be03c2 100644 --- a/app/src/main/java/foundation/e/apps/di/CommonUtilsModule.kt +++ b/app/src/main/java/foundation/e/apps/di/CommonUtilsModule.kt @@ -111,7 +111,7 @@ object CommonUtilsModule { @Singleton @Provides fun provideCache(@ApplicationContext context: Context): Cache { - val cacheSize = (10 * 1024 * 1024).toLong() // 10 MB + val cacheSize = (30 * 1024 * 1024).toLong() // 30 MB return Cache(context.cacheDir, cacheSize) } diff --git a/app/src/test/java/foundation/e/apps/exodus/AppPrivacyInfoRepositoryImplTest.kt b/app/src/test/java/foundation/e/apps/exodus/AppPrivacyInfoRepositoryImplTest.kt index 0658e81693e27f23c60fde9e2d71ea21dabaeab7..21ff0bec3e423b91971d2381a305dddf61cf594b 100644 --- a/app/src/test/java/foundation/e/apps/exodus/AppPrivacyInfoRepositoryImplTest.kt +++ b/app/src/test/java/foundation/e/apps/exodus/AppPrivacyInfoRepositoryImplTest.kt @@ -63,7 +63,7 @@ class AppPrivacyInfoRepositoryImplTest { name = "Demo Three", package_name = "foundation.e.demothree", latest_version_code = 123, - is_pwa = true, + is_pwa = false, ) val result = appPrivacyInfoRepository.getAppPrivacyInfo(application, application.package_name) assertEquals("getAppPrivacyInfo", true, result.isSuccess()) @@ -78,7 +78,7 @@ class AppPrivacyInfoRepositoryImplTest { name = "Demo Three", package_name = "", latest_version_code = 123, - is_pwa = true, + is_pwa = false, ) val result = appPrivacyInfoRepository.getAppPrivacyInfo(application, application.package_name) assertEquals("getAppPrivacyInfo", false, result.isSuccess()) @@ -92,10 +92,25 @@ class AppPrivacyInfoRepositoryImplTest { name = "Demo Three", package_name = "a.b.c", latest_version_code = 123, - is_pwa = true, + is_pwa = false, ) fakeTrackerDao.trackers.clear() val result = appPrivacyInfoRepository.getAppPrivacyInfo(application, application.package_name) assertEquals("getAppPrivacyInfo", 2, result.data?.trackerList?.size) } + + @Test + fun getAppPrivacyInfoWhenIsPwa() = runTest { + val application = Application( + _id = "113", + status = Status.UNAVAILABLE, + name = "Demo Three", + package_name = "a.b.c", + latest_version_code = 123, + is_pwa = true, + ) + val result = appPrivacyInfoRepository.getAppPrivacyInfo(application, application.package_name) + assertEquals(false, result.isSuccess()) + assertEquals("No need to fetch trackers for a PWA app", result.message) + } }