Core - Integrate KeyStore fallback message

This commit is contained in:
Jorge Martin 2022-02-07 16:18:56 +00:00 committed by Davide Giuseppe Farella
parent 4fe0208f7a
commit 9f31f7d3d8
14 changed files with 55 additions and 22 deletions

View File

@ -294,6 +294,7 @@ dependencies {
`Proton-shared-preferences`,
`Proton-work-manager`,
`Proton-crypto`,
`Proton-crypto-validator`,
`Proton-auth`,
`Proton-account`,
`Proton-account-manager`,

View File

@ -36,6 +36,8 @@
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
@ -81,12 +83,18 @@
android:authorities="${applicationId}.androidx-startup"
android:exported="false"
tools:node="merge">
<!-- Disable default WorkManagerInitializer for use Hilt injection -->
<meta-data
android:name="androidx.work.WorkManagerInitializer"
android:value="androidx.startup"
tools:node="remove" />
<meta-data
android:name="me.proton.core.crypto.validator.presentation.init.CryptoValidatorInitializer"
android:value="androidx.startup"
tools:node="remove"/>
<meta-data
android:name="ch.protonmail.android.security.presentation.SecurityManagerInitializer"
android:value="androidx.startup"
@ -121,20 +129,23 @@
</service>
<receiver
android:name=".receivers.OnBootReceiver"
android:enabled="false">
android:enabled="false"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<receiver android:name=".api.segments.event.AlarmReceiver" />
<receiver android:name=".receivers.NotificationReceiver">
<receiver android:name=".receivers.NotificationReceiver"
android:exported="false">
<intent-filter>
<action android:name="protonmail_notif_action_archive" />
<action android:name="protonmail_notif_action_delete" />
<action android:name="protonmail_notif_action_trash" />
</intent-filter>
</receiver>
<receiver android:name=".receivers.TimeChangedReceiver">
<receiver android:name=".receivers.TimeChangedReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.TIME_SET" />
</intent-filter>
@ -191,7 +202,8 @@
android:name=".activities.composeMessage.ComposeMessageActivity"
android:configChanges="orientation|screenSize"
android:parentActivityName=".mailbox.presentation.MailboxActivity"
android:windowSoftInputMode="adjustResize|stateAlwaysVisible">
android:windowSoftInputMode="adjustResize|stateAlwaysVisible"
android:exported="false">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".mailbox.presentation.MailboxActivity" />
@ -405,6 +417,9 @@
<activity
android:name="me.proton.core.auth.presentation.ui.SecondFactorActivity"
android:windowSoftInputMode="adjustResize" />
<activity
android:name="me.proton.core.crypto.validator.presentation.ui.CryptoValidatorErrorDialogActivity"
android:theme="@style/ProtonTheme.Transparent" />
</application>
</manifest>

View File

@ -51,7 +51,7 @@ public class AlarmReceiver extends WakefulBroadcastReceiver {
public void setAlarm(Context context, boolean immediate) {
alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(context, AlarmReceiver.class);
alarmIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
alarmIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
int secondsUntilNextCheck = 30; // default
if (AppUtil.isAppInBackground()) {

View File

@ -108,6 +108,7 @@ import io.sentry.Sentry;
import io.sentry.android.AndroidSentryClientFactory;
import me.proton.core.accountmanager.data.AccountStateHandler;
import me.proton.core.accountmanager.domain.AccountManager;
import me.proton.core.crypto.validator.presentation.init.CryptoValidatorInitializer;
import me.proton.core.domain.entity.UserId;
import me.proton.core.util.kotlin.CoreLogger;
import studio.forface.viewstatestore.ViewStateStoreConfig;
@ -227,8 +228,9 @@ public class ProtonMailApplication extends Application implements androidx.work.
applyAppThemeFromSettings.blocking();
AppInitializer.getInstance(this)
.initializeComponent(SecurityManagerInitializer.class);
AppInitializer appInitializer = AppInitializer.getInstance(this);
appInitializer.initializeComponent(CryptoValidatorInitializer.class);
appInitializer.initializeComponent(SecurityManagerInitializer.class);
accountManagerUserIdMigration.blocking();
coreAccountManagerMigration.migrateBlocking();
@ -237,6 +239,8 @@ public class ProtonMailApplication extends Application implements androidx.work.
accountStateHandler.start();
checkForUpdateAndClearCache();
AppInitializer.getInstance(this).initializeComponent(CryptoValidatorInitializer.class);
}
private void upgradeTlsProviderIfNeeded() {

View File

@ -27,6 +27,7 @@ import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import me.proton.core.accountmanager.domain.AccountManager
import me.proton.core.auth.data.MissingScopeListenerImpl
import me.proton.core.auth.data.repository.AuthRepositoryImpl
import me.proton.core.auth.domain.repository.AuthRepository
import me.proton.core.auth.domain.usecase.PostLoginAccountSetup
@ -34,6 +35,7 @@ import me.proton.core.auth.presentation.AuthOrchestrator
import me.proton.core.crypto.android.srp.GOpenPGPSrpCrypto
import me.proton.core.crypto.common.srp.SrpCrypto
import me.proton.core.network.data.ApiProvider
import me.proton.core.network.domain.scopes.MissingScopeListener
import me.proton.core.user.domain.UserManager
import javax.inject.Singleton
@ -63,4 +65,10 @@ object CoreAuthModule {
userManager: UserManager,
oldUserManager: ch.protonmail.android.core.UserManager,
): PostLoginAccountSetup.UserCheck = SetupAccountUserCheck(context, accountManager, userManager, oldUserManager)
// region missing scopes
@Provides
@Singleton
fun provideMissingScopeListener(): MissingScopeListener = MissingScopeListenerImpl()
// endregion
}

View File

@ -29,6 +29,7 @@ import me.proton.core.network.domain.client.ClientIdProvider
import me.proton.core.network.domain.client.ExtraHeaderProvider
import me.proton.core.network.domain.humanverification.HumanVerificationListener
import me.proton.core.network.domain.humanverification.HumanVerificationProvider
import me.proton.core.network.domain.scopes.MissingScopeListener
import me.proton.core.network.domain.server.ServerTimeListener
import me.proton.core.network.domain.session.SessionListener
import me.proton.core.network.domain.session.SessionProvider
@ -66,6 +67,7 @@ object NetworkModule {
sessionListener: SessionListener,
humanVerificationProvider: HumanVerificationProvider,
humanVerificationListener: HumanVerificationListener,
missingScopeListener: MissingScopeListener,
@DefaultApiPins defaultApiPins: Array<String>,
@AlternativeApiPins alternativeApiPins: List<String>,
@BaseUrl baseUrl: String
@ -80,6 +82,7 @@ object NetworkModule {
sessionListener,
humanVerificationProvider,
humanVerificationListener,
missingScopeListener,
protonCookieStore,
CoroutineScope(Job() + Dispatchers.Default),
defaultApiPins,
@ -124,7 +127,8 @@ object NetworkModule {
}
@Provides
fun provideNetworkRequestOverrider(): NetworkRequestOverrider = NetworkRequestOverriderImpl(OkHttpClient())
fun provideNetworkRequestOverrider(@ApplicationContext context: Context): NetworkRequestOverrider =
NetworkRequestOverriderImpl(OkHttpClient(), context)
}
@Module

View File

@ -234,7 +234,7 @@ class NotificationServer @Inject constructor(
context,
System.currentTimeMillis().toInt(),
intent,
0
PendingIntent.FLAG_IMMUTABLE
)
builder.setContentIntent(viewAttachmentIntent)
if (intent.resolveActivity(context.packageManager) != null) {
@ -272,7 +272,7 @@ class NotificationServer @Inject constructor(
val deleteIntent = Intent(context.getString(R.string.notification_action_delete))
.putExtra(EXTRA_NOTIFICATION_DELETE_MESSAGE, NOTIFICATION_GROUP_ID_EMAIL)
val deletePendingIntent =
PendingIntent.getBroadcast(context, 0, deleteIntent, PendingIntent.FLAG_UPDATE_CURRENT)
PendingIntent.getBroadcast(context, 0, deleteIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
// Set Notification's colors
val mainColor = context.getColor(R.color.ocean_blue)
@ -364,7 +364,7 @@ class NotificationServer @Inject constructor(
context,
messageId.hashCode(),
arrayOf(backIntent, contentIntent),
PendingIntent.FLAG_UPDATE_CURRENT
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
// Create Action Intent's
@ -524,7 +524,7 @@ class NotificationServer @Inject constructor(
// Create content Intent for open MailboxActivity
val contentIntent = context.getMailboxActivityIntent(UserId(loggedInUserId.id))
val requestCode = System.currentTimeMillis().toInt()
return PendingIntent.getActivity(context, requestCode, contentIntent, 0)
return PendingIntent.getActivity(context, requestCode, contentIntent, PendingIntent.FLAG_IMMUTABLE)
}
/** @return [Spannable] a single line [Spannable] where [title] is [BOLD] */
@ -550,7 +550,7 @@ class NotificationServer @Inject constructor(
val contentPendingIntent = stackBuilder.getPendingIntent(
userId.hashCode() + NOTIFICATION_ID_SENDING_FAILED,
PendingIntent.FLAG_UPDATE_CURRENT
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
// Set Notification's colors

View File

@ -33,7 +33,7 @@ fun Context.buildArchiveIntent(messageId: String): PendingIntent {
val intent = Intent(getString(R.string.notification_action_archive))
intent.putExtra(EXTRA_NOTIFICATION_ARCHIVE_MESSAGE, messageId)
intent.setClass(this, NotificationReceiver::class.java)
return PendingIntent.getBroadcast(this, System.currentTimeMillis().toInt(), intent, 0)
return PendingIntent.getBroadcast(this, System.currentTimeMillis().toInt(), intent, PendingIntent.FLAG_IMMUTABLE)
}
// TODO move to GCMService
@ -41,5 +41,5 @@ fun Context.buildTrashIntent(messageId: String): PendingIntent {
val intent = Intent(getString(R.string.notification_action_trash))
intent.putExtra(EXTRA_NOTIFICATION_TRASH_MESSAGE, messageId)
intent.setClass(this, NotificationReceiver::class.java)
return PendingIntent.getBroadcast(this, System.currentTimeMillis().toInt(), intent, 0)
return PendingIntent.getBroadcast(this, System.currentTimeMillis().toInt(), intent, PendingIntent.FLAG_IMMUTABLE)
}

View File

@ -58,7 +58,7 @@ along with ProtonMail. If not, see https://www.gnu.org/licenses/.
android:layout_weight="1"
android:gravity="center"
android:text="@string/cancel"
android:textColor="@color/interaction_weak_selector" />
android:textColor="@color/btn_secondary_background_selector" />
<Button
android:id="@+id/apply"

View File

@ -21,7 +21,7 @@ package ch.protonmail.android.uitests.testsHelper
import android.util.Log
import me.proton.core.test.android.instrumented.ProtonTest
import me.proton.core.test.android.instrumented.utils.FileUtils
import me.proton.core.test.android.instrumented.utils.Shell
import java.util.concurrent.TimeoutException
fun waitForCondition(
@ -45,6 +45,6 @@ fun waitForCondition(
Thread.sleep(watchInterval)
}
Log.d(ProtonTest.testTag, "Test \"${ProtonTest.testName.methodName}\" failed. Saving screenshot")
FileUtils.takeScreenshot()
Shell.takeScreenshot()
throw throwable
}

View File

@ -26,6 +26,6 @@ object ProtonMail {
const val versionName = "1.15.1"
const val versionCode = 828
const val targetSdk = 30
const val targetSdk = 31
const val minSdk = 23
}

View File

@ -36,6 +36,7 @@ val DependencyHandler.`Proton-auth` get() = proton("auth
val DependencyHandler.`Proton-contact` get() = proton("contact") version `Proton-core version`
val DependencyHandler.`Proton-country` get() = proton("country") version `Proton-core version`
val DependencyHandler.`Proton-crypto` get() = proton("crypto") version `Proton-core version`
val DependencyHandler.`Proton-crypto-validator` get() = proton("crypto-validator") version `Proton-core version`
val DependencyHandler.`Proton-data` get() = proton("data") version `Proton-core version`
val DependencyHandler.`Proton-data-room` get() = proton("data-room") version `Proton-core version`
val DependencyHandler.`Proton-domain` get() = proton("domain") version `Proton-core version`

View File

@ -43,7 +43,7 @@ fun initVersions() {
`material version` = "1.4.0" // Released: Jul 04, 2021
`android-paging version` = "2.1.0" // Released: Jan 26, 2019
`android-room version` = "2.3.0" // Released: Apr 21, 2021
`android-work version` = "2.6.0" // Released: Sep 01, 2021
`android-work version` = "2.7.1" // Released: Nov 17, 2021
`android-test version` = "1.4.0-beta01" // Released: May 15, 2021
// endregion
@ -62,7 +62,7 @@ fun initVersions() {
}
// Proton Core
const val `Proton-core version` = "4.1.0"
const val `Proton-core version` = "5.2.0"
// Test
const val `aerogear version` = "1.0.0" // Released: Mar 23, 2013

View File

@ -30,7 +30,7 @@ along with ProtonMail. If not, see https://www.gnu.org/licenses/.
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".TokenActivity">
<activity android:name=".TokenActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />