mirror of
https://github.com/micahflee/TM-SGNL-Android.git
synced 2025-08-04 19:08:33 +00:00
Merge branch 'suspend-branch' into 'master'
Suspend branch See merge request client/Android/signalarchiver!30
This commit is contained in:
commit
6203c5e51c
28 changed files with 725 additions and 653 deletions
|
@ -24,9 +24,9 @@ plugins {
|
|||
apply(from = "static-ips.gradle.kts")
|
||||
|
||||
//**TM_SA**//Start - Change the version code and version name upon the current version
|
||||
val canonicalVersionCode = 1337
|
||||
val canonicalVersionName = "6.44.2.0"
|
||||
val signal_teleMessage_version = "6.44.2.0"//Change this param in Jenkins builder and delete it.
|
||||
val canonicalVersionCode = 1338
|
||||
val canonicalVersionName = "6.44.3.0"
|
||||
val signal_teleMessage_version = "6.44.3.0"//Change this param in Jenkins builder and delete it.
|
||||
//**TM_SA**//end
|
||||
|
||||
/*val canonicalVersionCode = 1376
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -4,7 +4,7 @@ import android.app.Activity
|
|||
import android.app.AlertDialog
|
||||
import com.tm.authenticatorsdk.mamsdk.MDMAuthenticator
|
||||
import com.tm.authenticatorsdk.selfAuthenticator.IAuthenticationStatus
|
||||
import com.tm.logger.Log
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.tm.archive.R
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright 2024 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.selfAuthentication
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import androidx.loader.app.LoaderManager
|
||||
import androidx.loader.content.Loader
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.core.util.logging.Log.tag
|
||||
import org.tm.archive.BaseActivity
|
||||
import org.tm.archive.database.loaders.DeviceListLoader
|
||||
import org.tm.archive.dependencies.ApplicationDependencies
|
||||
import org.tm.archive.devicelist.Device
|
||||
|
||||
val TAG = tag(DevicesDisconnector::class.java)
|
||||
class DevicesDisconnector(val activity : BaseActivity) : LoaderManager.LoaderCallbacks<MutableList<Device>> {
|
||||
val accountManager = ApplicationDependencies.getSignalServiceAccountManager()
|
||||
|
||||
init {
|
||||
val loaderManager = LoaderManager.getInstance(activity)
|
||||
loaderManager.initLoader(0, null, this)
|
||||
}
|
||||
override fun onCreateLoader(id: Int, args: Bundle?): Loader<MutableList<Device>> {
|
||||
Log.d(TAG, "onCreateLoader")
|
||||
return DeviceListLoader(activity, accountManager)
|
||||
}
|
||||
|
||||
override fun onLoaderReset(loader: Loader<MutableList<Device>>) {
|
||||
// TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun onLoadFinished(loader: Loader<MutableList<Device>>, data: MutableList<Device>?) {
|
||||
if (data == null) {
|
||||
Log.d(TAG, "no devices to remove")
|
||||
return
|
||||
}
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
data.forEach { device ->
|
||||
accountManager.removeDevice(device.id)
|
||||
Log.d(TAG, "device.id: ${device.id} removed")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,245 +1,63 @@
|
|||
package com.tm.authenticatorsdk.selfAuthenticator
|
||||
package org.selfAuthentication
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.AlertDialog
|
||||
import android.app.Dialog
|
||||
import android.content.DialogInterface
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.view.View
|
||||
import com.tm.androidcopysdk.AndroidCopySDK
|
||||
import com.tm.androidcopysdk.ISendLogCallback
|
||||
import com.tm.androidcopysdk.utils.PrefManager
|
||||
import com.tm.logger.Log
|
||||
import org.archiver.ArchiveConstants
|
||||
import org.archiver.ArchivePreferenceConstants
|
||||
import org.selfAuthentication.AuthenticationUtils
|
||||
import org.selfAuthentication.ProgressDialog
|
||||
import org.selfAuthentication.SelfAuthenticatorManager
|
||||
import org.tm.archive.R
|
||||
import java.util.Calendar
|
||||
|
||||
|
||||
class SelfAuthenticationDialogBuilder : ISendLogCallback{
|
||||
|
||||
lateinit var mFirstFailureWarningAlertDialog : AlertDialog
|
||||
lateinit var mFirstFailureWarningLogsSent : AlertDialog
|
||||
lateinit var mFirstFailureSecondFailureWarning : AlertDialog
|
||||
lateinit var mLogsSentContext : Activity
|
||||
lateinit var mProgressDialog : Dialog
|
||||
lateinit var mProgressDialog : View
|
||||
|
||||
companion object{
|
||||
val TEXT_MESSAGE_FOR_SENDING_LOGS = "Signal signup failure for " + org.tm.archive.BuildConfig.signal_teleMessage_version + " authentication version – could not locate the TeleMessage account. Please help."
|
||||
}
|
||||
fun doSendLogsClicked(context: Activity, view : View) {
|
||||
mLogsSentContext = context
|
||||
val builder = AlertDialog.Builder(context)
|
||||
mProgressDialog = view
|
||||
|
||||
builder.setTitle(R.string.not_activated_user_dialog_title)
|
||||
builder.setMessage(context.getString(R.string.not_activated_user_dialog_message))
|
||||
|
||||
fun showSelfAuthenticationFirstFailureWarning(
|
||||
context: Activity
|
||||
) {
|
||||
if(!::mFirstFailureWarningAlertDialog.isInitialized || !mFirstFailureWarningAlertDialog.isShowing) {
|
||||
initFirstAuthenticationFailureMessageDialog(context)
|
||||
}
|
||||
builder.setPositiveButton(R.string.DebugSendLogs) { dialog, which ->
|
||||
|
||||
if(!mFirstFailureWarningAlertDialog.isShowing){
|
||||
if(!context.isFinishing){
|
||||
mFirstFailureWarningAlertDialog.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun showSelfAuthenticationFirstFailureWarningLogsSent(context: Activity) {
|
||||
if(!::mFirstFailureWarningLogsSent.isInitialized || !mFirstFailureWarningLogsSent.isShowing) {
|
||||
initAuthenticationFailureLogsSentMessageDialog(context)
|
||||
}
|
||||
|
||||
if(!mFirstFailureWarningLogsSent.isShowing){
|
||||
if(!context.isFinishing){
|
||||
mFirstFailureWarningLogsSent.show()
|
||||
}
|
||||
// showDialogInTheActivity(context, mFirstFailureWarningLogsSent)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun checkIfNeedToCloseTheAppOrJustDismissTheDialog(context: Activity, dialog: DialogInterface?) {
|
||||
if (SelfAuthenticatorManager.isAppValidationTimePassed(context)) {
|
||||
AuthenticationUtils.forceCloseApplication(context)
|
||||
} else {
|
||||
dialog?.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun showSelfAuthenticationSecondFailureWarning(
|
||||
context: Activity
|
||||
) {
|
||||
Log.d("SelfAuthenticatorProcess", "${!::mFirstFailureSecondFailureWarning.isInitialized}")
|
||||
if(::mFirstFailureSecondFailureWarning.isInitialized){
|
||||
Log.d("SelfAuthenticatorProcess", "---> ${!mFirstFailureSecondFailureWarning.isShowing}")
|
||||
}
|
||||
if (!::mFirstFailureSecondFailureWarning.isInitialized || !mFirstFailureSecondFailureWarning.isShowing) {
|
||||
initSecondAuthenticationFailureMessageDialog(context)
|
||||
}else {
|
||||
Log.d("SelfAuthenticatorProcess", "else to -- > !::mFirstFailureSecondFailureWarning.isInitialized || !mFirstFailureSecondFailureWarning.isShowing")
|
||||
if(!context.isFinishing){
|
||||
mFirstFailureSecondFailureWarning.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun initFirstAuthenticationFailureMessageDialog(context: Activity) {
|
||||
val mFirstFailureWarningDialogBuilder = AlertDialog.Builder(context)
|
||||
|
||||
// set message of alert dialog
|
||||
mFirstFailureWarningDialogBuilder.setMessage(context.resources.getString(R.string.get_self_authentication_first_warning_message_step_1))
|
||||
// if the dialog is cancelable
|
||||
.setCancelable(false)
|
||||
// positive button text and action
|
||||
.setNegativeButton(
|
||||
context.resources.getString(R.string.get_self_authentication_first_warning_message_step_1_dismiss),
|
||||
DialogInterface.OnClickListener { dialog, id ->
|
||||
checkIfNeedToCloseTheAppOrJustDismissTheDialog(context, dialog)
|
||||
})
|
||||
.setPositiveButton(
|
||||
context.resources.getString(R.string.get_self_authentication_failure_contact_us),
|
||||
DialogInterface.OnClickListener { dialog, id ->
|
||||
onTeleMessageSendLogsToSupportClicked(context)
|
||||
if (!context.isFinishing) {
|
||||
getAuthenticationProgressDialog(context).show()
|
||||
}
|
||||
dialog.dismiss()
|
||||
})
|
||||
|
||||
mFirstFailureWarningAlertDialog = mFirstFailureWarningDialogBuilder.create()
|
||||
}
|
||||
|
||||
private fun initSecondAuthenticationFailureMessageDialog(context: Activity) {
|
||||
val dialogBuilder = AlertDialog.Builder(context)
|
||||
Log.d(
|
||||
"SelfAuthenticatorProcess",
|
||||
"!::mFirstFailureSecondFailureWarning.isInitialized || !mFirstFailureSecondFailureWarning.isShowing"
|
||||
)
|
||||
// set message of alert dialog
|
||||
dialogBuilder.setMessage(context.resources.getString(R.string.get_self_authentication_second_warning_message_step_2))
|
||||
// if the dialog is cancelable
|
||||
.setCancelable(false)
|
||||
// positive button text and action
|
||||
.setNegativeButton(
|
||||
context.resources.getString(R.string.get_self_authentication_failure_message_close),
|
||||
DialogInterface.OnClickListener { dialog, id ->
|
||||
checkIfNeedToCloseTheAppOrJustDismissTheDialog(context, dialog)
|
||||
})
|
||||
.setPositiveButton(
|
||||
context.resources.getString(R.string.get_self_authentication_failure_contact_us),
|
||||
DialogInterface.OnClickListener { dialog, id ->
|
||||
onTeleMessageSendLogsToSupportClicked(context)
|
||||
if (!context.isFinishing) {
|
||||
getAuthenticationProgressDialog(context).show()
|
||||
}
|
||||
})
|
||||
|
||||
mFirstFailureSecondFailureWarning = dialogBuilder.create()
|
||||
if (!context.isFinishing) {
|
||||
mFirstFailureSecondFailureWarning.show()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun initAuthenticationFailureLogsSentMessageDialog(context: Activity) {
|
||||
val dialogBuilder = AlertDialog.Builder(context)
|
||||
// set message of alert dialog
|
||||
dialogBuilder.setMessage(context.resources.getString(R.string.get_self_authentication_contact_us_sent))
|
||||
// if the dialog is cancelable
|
||||
.setCancelable(false)
|
||||
// positive button text and action
|
||||
.setNegativeButton(
|
||||
context.resources.getString(R.string.get_self_authentication_failure_message_close),
|
||||
DialogInterface.OnClickListener { dialog, id ->
|
||||
checkIfNeedToCloseTheAppOrJustDismissTheDialog(context, dialog)
|
||||
})
|
||||
// create dialog box
|
||||
mFirstFailureWarningLogsSent = dialogBuilder.create()
|
||||
}
|
||||
|
||||
|
||||
fun onTeleMessageSendLogsToSupportClicked(context: Activity) {
|
||||
Log.d("SelfAuthenticatorProcess", "onTeleMessageSendLogsToSupportClicked started")
|
||||
mLogsSentContext = context
|
||||
val name = PrefManager.getStringPref(context, ArchivePreferenceConstants.PREF_KEY_DEVICE_NAME, "")
|
||||
val freeText = TEXT_MESSAGE_FOR_SENDING_LOGS
|
||||
// mProgressDialog.show()
|
||||
mProgressDialog.visibility = View.VISIBLE
|
||||
AndroidCopySDK.getInstance(context).sentLogs(
|
||||
context,
|
||||
this,
|
||||
PrefManager.getStringPref(context, ArchivePreferenceConstants.PREF_KEY_DEVICE_PHONE_NUMBER, ""),
|
||||
"Signal logs - " + Calendar.getInstance().time.toString(),
|
||||
name,
|
||||
freeText,
|
||||
"Signal Archiver logs",
|
||||
PrefManager.getStringPref(context, ArchivePreferenceConstants.PREF_KEY_DEVICE_NAME, ""),
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
ArchiveConstants.GENERATE_TOK_NAME,
|
||||
ArchiveConstants.GENERATE_TOK_PASS
|
||||
"",
|
||||
ArchivePreferenceConstants.GENERATE_TOK_NAME,
|
||||
ArchivePreferenceConstants.GENERATE_TOK_PASS
|
||||
)
|
||||
}
|
||||
builder.setNegativeButton(R.string.OK, null)
|
||||
builder.show()
|
||||
|
||||
fun showDialogInTheActivity(activity: Activity, dialog: AlertDialog){
|
||||
Log.d("SelfAuthenticatorProcess", "showDialogInTheActivity ")
|
||||
if(!activity.isFinishing){
|
||||
Log.d("SelfAuthenticatorProcess", "showDialogInTheActivity !activity.isFinishing")
|
||||
//dialog.show()
|
||||
val handler = Handler(Looper.getMainLooper())
|
||||
handler.postDelayed({
|
||||
dialog.show()
|
||||
}, 100)
|
||||
}
|
||||
}
|
||||
|
||||
fun getAuthenticationProgressDialog(activity: Activity): Dialog {
|
||||
if(!::mProgressDialog.isInitialized || (mProgressDialog.ownerActivity != null && mProgressDialog.ownerActivity!!.localClassName != activity.localClassName)){
|
||||
mProgressDialog = ProgressDialog.progressDialog(activity)
|
||||
}
|
||||
|
||||
return mProgressDialog
|
||||
}
|
||||
|
||||
fun isOneOfTheAuthenticationDialogIsShowing(): Boolean{
|
||||
return ::mFirstFailureWarningAlertDialog.isInitialized && mFirstFailureWarningAlertDialog.isShowing ||
|
||||
::mFirstFailureWarningLogsSent.isInitialized && mFirstFailureWarningLogsSent.isShowing ||
|
||||
::mFirstFailureSecondFailureWarning.isInitialized && mFirstFailureSecondFailureWarning.isShowing ||
|
||||
::mProgressDialog.isInitialized && mProgressDialog.isShowing
|
||||
}
|
||||
}
|
||||
|
||||
override fun sendLogFailure() {
|
||||
if(::mProgressDialog.isInitialized) {
|
||||
mProgressDialog.dismiss()
|
||||
// mProgressDialog.dismiss()
|
||||
mProgressDialog.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
override fun sendLogSucceed() {
|
||||
if(::mProgressDialog.isInitialized) {
|
||||
mProgressDialog.dismiss()
|
||||
}
|
||||
SelfAuthenticatorManager.showLogSentIfNeeded(mLogsSentContext)
|
||||
}
|
||||
|
||||
fun showProgressDialog(activity: Activity) {
|
||||
if(!::mProgressDialog.isInitialized || (mProgressDialog.ownerActivity != null && mProgressDialog.ownerActivity!!.localClassName != activity.localClassName)){
|
||||
mProgressDialog = AlertDialog.Builder(activity).setCancelable(false).create()
|
||||
}
|
||||
|
||||
val handler = Handler(Looper.getMainLooper())
|
||||
handler.postDelayed({
|
||||
mProgressDialog.show()
|
||||
}, 1)
|
||||
|
||||
}
|
||||
|
||||
fun hideProgressDialog() {
|
||||
if(::mProgressDialog.isInitialized) {
|
||||
Handler(Looper.getMainLooper()).post(Runnable {
|
||||
mProgressDialog.hide()
|
||||
})
|
||||
|
||||
// mProgressDialog.dismiss()
|
||||
mProgressDialog.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,125 +1,77 @@
|
|||
package org.selfAuthentication
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import com.tm.authenticatorsdk.selfAuthenticator.*
|
||||
|
||||
import com.tm.authenticatorsdk.selfAuthenticator.AuthenticationAppType
|
||||
import com.tm.authenticatorsdk.selfAuthenticator.IAuthenticationStatus
|
||||
import com.tm.authenticatorsdk.selfAuthenticator.SelfAuthenticator
|
||||
import com.tm.logger.Log
|
||||
import org.archive.selfAuthentication.SelfAuthenticatorConstants
|
||||
import org.tm.archive.ApplicationContext
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.tm.archive.BaseActivity
|
||||
import org.tm.archive.BuildConfig
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
//In order to change the environment base url call to this method:
|
||||
//ApiUtil.Companion.selectServerEnvironment(Context)
|
||||
//The default environment is charlieProduction = https://rest.telemessage.com
|
||||
|
||||
object SelfAuthenticatorManager {
|
||||
|
||||
|
||||
const val SELF_AUTHENTICATION_PREFERENCE_NAME = "SelfAuthenticatorPref"
|
||||
const val SELF_AUTHENRICATION_PREF_FIRST_TIME_TRYING_KEY = "firstTimeTrying"
|
||||
val SELF_AUTHENRICATION_WHEN_TO_SHOW_FIRST_WARNNING_IN_HOURS = 2 * 24
|
||||
val SELF_AUTHENRICATION_WHEN_TO_SHOW_SECOND_WARNNING_IN_HOURS = 7 * 24
|
||||
|
||||
|
||||
var mProgressDialogVisibility = true
|
||||
var mSuspendDialogVisibility = false
|
||||
init {
|
||||
Log.d("SelfAuthenticatorProcess","class SelfAuthenticatorManager started.")
|
||||
Log.d("SelfAuthenticatorManager","class SelfAuthenticatorManager started")
|
||||
}
|
||||
|
||||
lateinit var selfAuthenticator: SelfAuthenticator
|
||||
val mSelfAuthenticationDialogBuilder = SelfAuthenticationDialogBuilder()
|
||||
lateinit var selfAuthenticator: SelfAuthenticator
|
||||
|
||||
|
||||
fun initAuthenticator(phoneNumber: String) {
|
||||
|
||||
selfAuthenticator = SelfAuthenticator
|
||||
Log.d("SelfAuthenticatorProcess", "initAuthenticator - The phone number is: $phoneNumber")
|
||||
Log.d("SelfAuthenticatorManager", "initAuthenticator - The phone number is: $phoneNumber")
|
||||
selfAuthenticator.initSelfAuthenticator(
|
||||
AuthenticationAppType.SIGNAL,
|
||||
phoneNumber,
|
||||
BuildConfig.VERSION_NAME
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
fun startAuthentication(context: Context, aIAuthenticationStatus: IAuthenticationStatus) {
|
||||
if (!isSelfAuthenticationAlreadyStarted(context)) {
|
||||
saveSelfAuthenticationFirstTimeTryingTime(context)
|
||||
}
|
||||
fun removeLinkedDevices(baseActivity: BaseActivity) {
|
||||
DevicesDisconnector(baseActivity)
|
||||
}
|
||||
|
||||
fun startAuthentication(aIAuthenticationStatus: IAuthenticationStatus) {
|
||||
selfAuthenticator.startSelfAuthentication(aIAuthenticationStatus)
|
||||
}
|
||||
|
||||
fun isSelfAuthenticationAlreadyStarted(context: Context): Boolean {
|
||||
return getSelfAuthenticationFirstTimeTryingInHours(context) != -1
|
||||
fun startAuthenticationProcess(context: Context,
|
||||
phone: String?, aIAuthenticationStatus: IAuthenticationStatus) {
|
||||
Log.d("SelfAuthenticatorManager","startAuthenticationProcess")
|
||||
// createAndShowAuthProgressDialog(context, true)
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
initAuthenticator(phone!!)
|
||||
selfAuthenticator.startSelfAuthentication(aIAuthenticationStatus)
|
||||
}
|
||||
}
|
||||
|
||||
fun saveSelfAuthenticationFirstTimeTryingTime(context: Context) {
|
||||
if (!isSelfAuthenticationAlreadyStarted(context)) {
|
||||
context.getSharedPreferences(SELF_AUTHENTICATION_PREFERENCE_NAME, Context.MODE_PRIVATE).apply {
|
||||
edit().apply {
|
||||
putLong(
|
||||
SELF_AUTHENRICATION_PREF_FIRST_TIME_TRYING_KEY,
|
||||
System.currentTimeMillis()
|
||||
)
|
||||
apply()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*fun isEndAuthenticationDialog() {
|
||||
if (!mProgressDialogVisibility && mSuspendDialogVisibility) {
|
||||
endAuthDialog()
|
||||
mProgressDialogVisibility = true
|
||||
mSuspendDialogVisibility = false
|
||||
}
|
||||
}
|
||||
|
||||
fun getSelfAuthenticationFirstTimeTryingInHours(context: Context): Int {
|
||||
val sharedPreferences = context.getSharedPreferences(SELF_AUTHENTICATION_PREFERENCE_NAME, Context.MODE_PRIVATE)
|
||||
val firstTimeInstallInMill = sharedPreferences.getLong(SELF_AUTHENRICATION_PREF_FIRST_TIME_TRYING_KEY, -1)
|
||||
if(firstTimeInstallInMill != (-1).toLong()){
|
||||
Log.d("SelfAuthenticatorProcess", "hourDifferenceFromNow() = " + (hourDifferenceFromNow(firstTimeInstallInMill)).toInt())
|
||||
return (hourDifferenceFromNow(firstTimeInstallInMill)).toInt()
|
||||
}
|
||||
Log.d("SelfAuthenticatorProcess", "hourDifferenceFromNow() = " + -1)
|
||||
return -1
|
||||
}
|
||||
|
||||
private fun hourDifferenceFromNow(millisTime: Long): Long {
|
||||
val now = System.currentTimeMillis()
|
||||
return TimeUnit.MILLISECONDS.toHours(now - millisTime)
|
||||
}
|
||||
|
||||
fun showTheRelevantDialogIfNeeded(
|
||||
aContext: Activity
|
||||
) {
|
||||
|
||||
Log.d("SelfAuthenticatorProcess", "getSelfAuthenticationFirstTimeTryingInHours() = " + getSelfAuthenticationFirstTimeTryingInHours(aContext))
|
||||
Log.d("SelfAuthenticatorProcess", "getSelfAuthenticationFirstTimeTryingInHours() > SELF_AUTHENRICATION_WHEN_TO_SHOW_FIRST_WARNNING_IN_DAYS = " + (getSelfAuthenticationFirstTimeTryingInHours(aContext) > SELF_AUTHENRICATION_WHEN_TO_SHOW_FIRST_WARNNING_IN_HOURS))
|
||||
Log.d("SelfAuthenticatorProcess", "isAppValidationTimePassed() = " + isAppValidationTimePassed(aContext))
|
||||
|
||||
if (getSelfAuthenticationFirstTimeTryingInHours(aContext) > SELF_AUTHENRICATION_WHEN_TO_SHOW_FIRST_WARNNING_IN_HOURS) {
|
||||
if (!isAppValidationTimePassed(aContext)) {
|
||||
mSelfAuthenticationDialogBuilder.showSelfAuthenticationFirstFailureWarning(aContext)
|
||||
} else {
|
||||
mSelfAuthenticationDialogBuilder.showSelfAuthenticationSecondFailureWarning(aContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun isAppValidationTimePassed(aContext: Context): Boolean{
|
||||
return getSelfAuthenticationFirstTimeTryingInHours(aContext) > SELF_AUTHENRICATION_WHEN_TO_SHOW_SECOND_WARNNING_IN_HOURS
|
||||
}
|
||||
|
||||
fun showLogSentIfNeeded(
|
||||
aContext: Activity
|
||||
){
|
||||
mSelfAuthenticationDialogBuilder.showSelfAuthenticationFirstFailureWarningLogsSent(aContext)
|
||||
}
|
||||
|
||||
fun isOneOfTheAuthenticationDialogIsShowing(): Boolean{
|
||||
return mSelfAuthenticationDialogBuilder.isOneOfTheAuthenticationDialogIsShowing()
|
||||
}
|
||||
|
||||
fun showProgressDialog(activity: Activity){
|
||||
mSelfAuthenticationDialogBuilder.showProgressDialog(activity)
|
||||
}
|
||||
|
||||
fun hideProgressDialog(){
|
||||
mSelfAuthenticationDialogBuilder.hideProgressDialog()
|
||||
}
|
||||
fun setProgressDialogVisibility(isShown : Boolean){
|
||||
mProgressDialogVisibility = isShown
|
||||
isEndAuthenticationDialog()
|
||||
}
|
||||
fun setSuspendDialogVisibility(isShown : Boolean){
|
||||
mSuspendDialogVisibility = isShown
|
||||
isEndAuthenticationDialog()
|
||||
}*/
|
||||
|
||||
|
||||
}
|
|
@ -2,6 +2,7 @@ package org.tm.archive;
|
|||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
|
@ -13,15 +14,22 @@ import android.view.ViewTreeObserver;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.tm.androidcopysdk.network.appSettings.UpdateEvent;
|
||||
import com.tm.androidcopysdk.network.appSettings.WorkerIntentService;
|
||||
import com.tm.androidcopysdk.utils.PrefManager;
|
||||
import com.tm.logger.Log;
|
||||
|
||||
import org.archiver.ArchivePreferenceConstants;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
import org.selfAuthentication.SelfAuthenticatorManager;
|
||||
import org.signal.core.util.concurrent.LifecycleDisposable;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.signal.donations.StripeApi;
|
||||
import org.tm.archive.components.DebugLogsPromptDialogFragment;
|
||||
import org.tm.archive.components.PromptBatterySaverDialogFragment;
|
||||
|
@ -55,6 +63,7 @@ public class MainActivity extends PassphraseRequiredActivity implements VoiceNot
|
|||
private ConversationListTabsViewModel conversationListTabsViewModel;
|
||||
private VitalsViewModel vitalsViewModel;
|
||||
|
||||
|
||||
private final LifecycleDisposable lifecycleDisposable = new LifecycleDisposable();
|
||||
|
||||
private boolean onFirstRender = false;
|
||||
|
@ -113,6 +122,8 @@ public class MainActivity extends PassphraseRequiredActivity implements VoiceNot
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private void presentVitalsState(VitalsViewModel.State state) {
|
||||
switch (state) {
|
||||
|
@ -173,33 +184,8 @@ public class MainActivity extends PassphraseRequiredActivity implements VoiceNot
|
|||
updateTabVisibility();
|
||||
|
||||
vitalsViewModel.checkSlowNotificationHeuristics();
|
||||
//**TM_SA**// start
|
||||
notifyMessageIfNeeded();
|
||||
}
|
||||
|
||||
private void notifyMessageIfNeeded() {
|
||||
boolean isAlreadyRestarted = PrefManager.getBooleanPref(this, ArchivePreferenceConstants.PREF_KEY_MAIN_ACTIVITY_RESTART, false);
|
||||
|
||||
if(!isAlreadyRestarted){
|
||||
PrefManager.setBooleanPref(this, ArchivePreferenceConstants.PREF_KEY_MAIN_ACTIVITY_RESTART, true);
|
||||
|
||||
final Handler handler = new Handler(Looper.getMainLooper());
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
notifyMessage();
|
||||
}
|
||||
}, 4000);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void notifyMessage(){
|
||||
synchronized (ApplicationDependencies.getIncomingMessageObserver()) {
|
||||
ApplicationDependencies.getIncomingMessageObserver().notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
//**TM_SA**// End
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
|
|
|
@ -27,8 +27,8 @@ import java.util.Objects;
|
|||
* Instead, they should extend {@link PassphraseRequiredActivity} so they're protected by
|
||||
* screen lock.
|
||||
*/
|
||||
public abstract class BaseActivity extends AppCompatActivity {
|
||||
private static final String TAG = Log.tag(BaseActivity.class);
|
||||
public abstract class SignalBaseActivity extends AppCompatActivity {//*TM_SA*/change BaseActivity to SignalBaseActivity
|
||||
private static final String TAG = Log.tag(SignalBaseActivity.class);
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
|
@ -17,6 +17,7 @@ import org.greenrobot.eventbus.EventBus
|
|||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
import org.selfAuthentication.ProgressDialog
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.tm.archive.R
|
||||
import org.tm.archive.badges.BadgeImageView
|
||||
import org.tm.archive.components.AvatarImageView
|
||||
|
@ -324,12 +325,12 @@ class AppSettingsFragment : DSLSettingsFragment(
|
|||
|
||||
override fun sendLogSucceed() {
|
||||
mProgressDialog.hide()
|
||||
com.tm.logger.Log.d("sendLog", "sendLogSucceed")
|
||||
Log.d("sendLog", "sendLogSucceed")
|
||||
}
|
||||
|
||||
override fun sendLogFailure() {
|
||||
mProgressDialog.hide()
|
||||
com.tm.logger.Log.d("sendLog", "sendLogFailure")
|
||||
Log.d("sendLog", "sendLogFailure")
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -32,8 +32,6 @@ import android.net.Uri;
|
|||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
|
@ -53,7 +51,6 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.PluralsRes;
|
||||
import androidx.annotation.WorkerThread;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.appcompat.view.ActionMode;
|
||||
|
@ -76,13 +73,14 @@ import com.google.android.material.appbar.AppBarLayout;
|
|||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.tm.androidcopysdk.MessageEvent;
|
||||
import com.tm.androidcopysdk.CommonUtils;
|
||||
import com.tm.androidcopysdk.network.appSettings.UpdateEvent;
|
||||
import com.tm.androidcopysdk.network.appSettings.WorkerIntentService;
|
||||
import com.tm.androidcopysdk.utils.PrefManager;
|
||||
import com.tm.authenticatorsdk.mamsdk.IMDMAuthenticator;
|
||||
import com.tm.authenticatorsdk.mamsdk.MDMAuthenticator;
|
||||
import com.tm.authenticatorsdk.selfAuthenticator.IAuthenticationStatus;
|
||||
|
||||
import org.archive.selfAuthentication.SelfAuthenticatorConstants;
|
||||
import org.archiver.ArchivePreferenceConstants;
|
||||
import org.archiver.ArchiveUtil;
|
||||
import org.archiver.FCMConnector;
|
||||
|
@ -218,17 +216,17 @@ import static android.app.Activity.RESULT_CANCELED;
|
|||
import static android.app.Activity.RESULT_OK;
|
||||
|
||||
|
||||
public class ConversationListFragment extends MainFragment implements ActionMode.Callback,
|
||||
public class SignalConversationListFragment extends MainFragment implements ActionMode.Callback,//*TM_SA*/change ConversationListFragment to SignalConversationListFragment
|
||||
ConversationListAdapter.OnConversationClickListener,
|
||||
MegaphoneActionController, ClearFilterViewHolder.OnClearFilterClickListener,
|
||||
IAuthenticationStatus, IMDMAuthenticator /*TM_SA*/
|
||||
MegaphoneActionController, ClearFilterViewHolder.OnClearFilterClickListener
|
||||
|
||||
{
|
||||
public static final short MESSAGE_REQUESTS_REQUEST_CODE_CREATE_NAME = 32562;
|
||||
public static final short SMS_ROLE_REQUEST_CODE = 32563;
|
||||
|
||||
private static final int LIST_SMOOTH_SCROLL_TO_TOP_THRESHOLD = 25;
|
||||
|
||||
private static final String TAG = Log.tag(ConversationListFragment.class);
|
||||
private static final String TAG = Log.tag(SignalConversationListFragment.class);
|
||||
|
||||
private static final int MAXIMUM_PINNED_CONVERSATIONS = 4;
|
||||
private static final int MAX_CHATS_ABOVE_FOLD = 7;
|
||||
|
@ -263,12 +261,6 @@ public class ConversationListFragment extends MainFragment implements ActionMode
|
|||
private Stopwatch startupStopwatch;
|
||||
private ConversationListTabsViewModel conversationListTabsViewModel;
|
||||
private ContactSearchMediator contactSearchMediator;
|
||||
|
||||
//**TM_SA**// Start
|
||||
private AlertDialog.Builder mAuthenticationProgressAlertDialogBuilder;
|
||||
private AlertDialog mAuthenticationProgressAlertDialog;
|
||||
public static boolean mIsAuthenticationIsInProgress = false;
|
||||
//**TM_SA**// End
|
||||
public static ConversationListFragment newInstance() {
|
||||
return new ConversationListFragment();
|
||||
}
|
||||
|
@ -287,14 +279,9 @@ public class ConversationListFragment extends MainFragment implements ActionMode
|
|||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
Log.d("ConversationListFragment", "onCreate");
|
||||
setHasOptionsMenu(true);
|
||||
startupStopwatch = new Stopwatch("startup");
|
||||
|
||||
//**TM_SA**//
|
||||
if(!EventBus.getDefault().isRegistered(this)) {
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
//**TM_SA**//
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -446,7 +433,7 @@ public class ConversationListFragment extends MainFragment implements ActionMode
|
|||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
if (!closeSearchIfOpen()) {
|
||||
if (!NavHostFragment.findNavController(ConversationListFragment.this).popBackStack()) {
|
||||
if (!NavHostFragment.findNavController(SignalConversationListFragment.this).popBackStack()) {
|
||||
requireActivity().finish();
|
||||
}
|
||||
}
|
||||
|
@ -468,55 +455,8 @@ public class ConversationListFragment extends MainFragment implements ActionMode
|
|||
}));
|
||||
|
||||
requireCallback().bindScrollHelper(list);
|
||||
|
||||
//**TM_SA**//Start
|
||||
com.tm.logger.Log.d("ConversationListFragment", "BuildConfig.APPLICATION_ID: " + BuildConfig.APPLICATION_ID);
|
||||
int authStatus = PrefManager.getIntPref(requireContext(), IntuneAuthManager.MDM_Auth_Status_String,
|
||||
IntuneAuthManager.MdmAuthStatus.START_SELF_AUTH.ordinal());
|
||||
com.tm.logger.Log.d("ConversationListFragment",
|
||||
"onCreate -> authStatus = " + authStatus + ". (0-signed, 1 -should intune auth, 2-self auth)");
|
||||
FCMConnector.initTeleMessageSignalFirebaseAccount(requireContext(), null, true);
|
||||
if(MDMAuthenticator.INSTANCE.isMDM(requireContext()) && authStatus == IntuneAuthManager.MdmAuthStatus.START_INTUNE_AUTH.ordinal()) { //if intune managed device, start MDM auth
|
||||
startIntuneAuth();
|
||||
} else { // else self auth
|
||||
startSelfAuth();
|
||||
}
|
||||
}
|
||||
|
||||
private void startIntuneAuth() {
|
||||
com.tm.logger.Log.d("ConversationListFragment", "startIntuneAuth");
|
||||
startMdm();
|
||||
}
|
||||
|
||||
public void startSelfAuth() {
|
||||
createAuthenticationProgressAlertDialogIfNotExist(true);
|
||||
|
||||
boolean isAlreadyDoneSelfAuthentication = PrefManager.getBooleanPref(getContext(), "isAlreadyDoneSelfAuthentication", false);
|
||||
com.tm.logger.Log.d(TAG, "SelfAuthenticatorProcess -> onCreate = isAlreadyDoneSelfAuthentication = " + isAlreadyDoneSelfAuthentication);
|
||||
|
||||
if(!isAlreadyDoneSelfAuthentication/* && !SelfAuthenticatorConstants.Companion.isAuthenticationProcessOpened()*/){
|
||||
startAuthenticationProcess(getContext(), ArchiveUtil.getPhoneNumberInTestMode(getContext()));
|
||||
}
|
||||
}
|
||||
|
||||
public void startAuthenticationProcess(Context context,
|
||||
String phone){
|
||||
mIsAuthenticationIsInProgress = true;
|
||||
SelfAuthenticatorManager.INSTANCE.initAuthenticator(phone);
|
||||
SelfAuthenticatorManager.INSTANCE.startAuthentication(context, this);
|
||||
createAuthenticationProgressAlertDialogIfNotExist(true);
|
||||
mAuthenticationProgressAlertDialog = mAuthenticationProgressAlertDialogBuilder.create();
|
||||
mAuthenticationProgressAlertDialog.show();
|
||||
}
|
||||
|
||||
private void createAuthenticationProgressAlertDialogIfNotExist(boolean isCanCancel) {
|
||||
if (mAuthenticationProgressAlertDialogBuilder == null) {
|
||||
mAuthenticationProgressAlertDialogBuilder = new AlertDialog.Builder(getContext(), 0);
|
||||
mAuthenticationProgressAlertDialogBuilder.setCancelable(isCanCancel);
|
||||
}
|
||||
}
|
||||
//**TM_SA**//END
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
coordinator = null;
|
||||
|
@ -540,14 +480,10 @@ public class ConversationListFragment extends MainFragment implements ActionMode
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
Log.d("ConversationListFragment", "onResume");
|
||||
initializeSearchListener();
|
||||
updateReminders();
|
||||
//**TM_SA**//Start. probably should delete from on create
|
||||
if(!EventBus.getDefault().isRegistered(this)) {
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
//**TM_SA**//End
|
||||
|
||||
itemAnimator.disable();
|
||||
SpoilerAnnotation.resetRevealedSpoilers();
|
||||
|
||||
|
@ -616,7 +552,6 @@ public class ConversationListFragment extends MainFragment implements ActionMode
|
|||
requireCallback().getSearchAction().setOnClickListener(null);
|
||||
fab.stopPulse();
|
||||
cameraFab.stopPulse();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -625,6 +560,8 @@ public class ConversationListFragment extends MainFragment implements ActionMode
|
|||
ApplicationDependencies.getAppForegroundObserver().removeListener(appForegroundObserver);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
menu.clear();
|
||||
|
@ -977,7 +914,7 @@ public class ConversationListFragment extends MainFragment implements ActionMode
|
|||
@Override
|
||||
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
||||
list.removeOnLayoutChangeListener(this);
|
||||
list.post(ConversationListFragment.this::onFirstRender);
|
||||
list.post(SignalConversationListFragment.this::onFirstRender);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1416,7 +1353,7 @@ public class ConversationListFragment extends MainFragment implements ActionMode
|
|||
}
|
||||
|
||||
private void startActionMode() {
|
||||
actionMode = ((AppCompatActivity) getActivity()).startSupportActionMode(ConversationListFragment.this);
|
||||
actionMode = ((AppCompatActivity) getActivity()).startSupportActionMode(SignalConversationListFragment.this);
|
||||
ViewUtil.animateIn(bottomActionBar, bottomActionBar.getEnterAnimation());
|
||||
ViewUtil.fadeOut(fab, 250);
|
||||
ViewUtil.fadeOut(cameraFab, 250);
|
||||
|
@ -1894,7 +1831,7 @@ public class ConversationListFragment extends MainFragment implements ActionMode
|
|||
}
|
||||
}
|
||||
|
||||
private final class VoiceNotePlayerViewListener implements VoiceNotePlayerView.Listener {
|
||||
public final class VoiceNotePlayerViewListener implements VoiceNotePlayerView.Listener {//**TM_SA**//public
|
||||
|
||||
@Override
|
||||
public void onCloseRequested(@NonNull Uri uri) {
|
||||
|
@ -1924,64 +1861,9 @@ public class ConversationListFragment extends MainFragment implements ActionMode
|
|||
}
|
||||
}
|
||||
|
||||
//**TM_SA**//Start
|
||||
@Subscribe(threadMode = ThreadMode.BACKGROUND)
|
||||
public void onMessageEvent(MessageEvent event) {
|
||||
if(event.message != null){
|
||||
com.tm.logger.Log.d("ConversationListFragment", "SelfAuthenticatorProcess -> event.message = " + event.message);
|
||||
}else{
|
||||
com.tm.logger.Log.d("ConversationListFragment", "SelfAuthenticatorProcess event.message = null");
|
||||
}
|
||||
|
||||
//check if listener is valid
|
||||
if (event.message != null && (event.message.equals(SelfAuthenticatorConstants.Companion.getSelfAuthenticationSucceed()) ||
|
||||
event.message.equals(SelfAuthenticatorConstants.Companion.getSelfAuthenticationFailed()))) {
|
||||
|
||||
if (mAuthenticationProgressAlertDialog != null) {
|
||||
mAuthenticationProgressAlertDialog.dismiss();
|
||||
}
|
||||
|
||||
|
||||
com.tm.logger.Log.d("ConversationListFragment", "SelfAuthenticatorProcess -> event.message 2 = " + event.message);
|
||||
if (SelfAuthenticatorConstants.Companion.getSelfAuthenticationSucceed().equals(event.message)) {
|
||||
updatedSelfAuthenticatorPreference();
|
||||
com.tm.logger.Log.d("ConversationListFragment","SelfAuthenticatorProcess -> SelfAuthenticationSucceed ");
|
||||
} else {
|
||||
com.tm.logger.Log.d("ConversationListFragment", "SelfAuthenticatorProcess -> getSelfAuthenticationFailure = " + event.message);
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mIsAuthenticationIsInProgress = false;
|
||||
SelfAuthenticatorManager.INSTANCE.showTheRelevantDialogIfNeeded(getActivity());
|
||||
}
|
||||
}, 20);
|
||||
}
|
||||
|
||||
com.tm.logger.Log.d("ConversationListFragment", "SelfAuthenticator -> initOfficialSignalFirebaseAccount!!! ");
|
||||
FCMConnector.initOfficialSignalFirebaseAccount(getContext());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void updatedSelfAuthenticatorPreference() {
|
||||
PrefManager.setBooleanPref(
|
||||
getContext(),
|
||||
"isAlreadyDoneSelfAuthentication", true
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void authenticationProcessMessage(@NotNull String message) {
|
||||
com.tm.logger.Log.d("ConversationListFragment", "SelfAuthenticatorProcess -> authenticationProcessMessage = " + message);
|
||||
if (!message.isEmpty()) {
|
||||
EventBus.getDefault().post(new MessageEvent(SelfAuthenticatorConstants.Companion.getSelfAuthenticationFailed()));
|
||||
}
|
||||
}
|
||||
|
||||
//**TM_SA**//End
|
||||
|
||||
private class ContactSearchClickCallbacks implements ConversationListSearchAdapter.ConversationListSearchClickCallbacks {
|
||||
public class ContactSearchClickCallbacks implements ConversationListSearchAdapter.ConversationListSearchClickCallbacks {//**TM_SA**//public
|
||||
|
||||
private final ContactSearchAdapter.ClickCallbacks delegate;
|
||||
|
||||
|
@ -1996,7 +1878,7 @@ public class ConversationListFragment extends MainFragment implements ActionMode
|
|||
|
||||
@Override
|
||||
public void onMessageClicked(@NonNull View view, @NonNull ContactSearchData.Message thread, boolean isSelected) {
|
||||
ConversationListFragment.this.onMessageClicked(thread.getMessageResult());
|
||||
SignalConversationListFragment.this.onMessageClicked(thread.getMessageResult());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2030,52 +1912,7 @@ public class ConversationListFragment extends MainFragment implements ActionMode
|
|||
}
|
||||
}
|
||||
|
||||
//**TM_SA**//START
|
||||
|
||||
void startMdm() {
|
||||
MDMAuthenticator.INSTANCE.startMDMAuthenticator(requireActivity(),
|
||||
ArchiveUtil.getPhoneNumberInTestMode(requireContext()), BuildConfig.signal_teleMessage_version, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failureMDMAuth(String reason) {
|
||||
final String onCancel = "onCancel";
|
||||
com.tm.logger.Log.d("ConversationListFragment", "failureMDMAuth, reason: " + reason);
|
||||
//MDMAuthenticator.INSTANCE.signOutUser(requireActivity());
|
||||
if(reason.equals(onCancel)) {
|
||||
IntuneAuthManager.INSTANCE.showDialog(requireActivity(), this::startMdm);
|
||||
//update app that intune signed failed: two cases. 1. try intune auth again 2. move to self auth
|
||||
}else if(reason.contains("server") || reason.contains("Authentication failed")
|
||||
/*|| reason.contains("managerID")*/) { //try intune auth again
|
||||
PrefManager.setIntPref(requireContext(),IntuneAuthManager.MDM_Auth_Status_String,IntuneAuthManager.MdmAuthStatus.START_INTUNE_AUTH.ordinal());
|
||||
com.tm.logger.Log.d("ConversationListFragment", "status auth is 1");
|
||||
}else { //this case should pass to self-auth
|
||||
PrefManager.setIntPref(requireContext(),IntuneAuthManager.MDM_Auth_Status_String,IntuneAuthManager.MdmAuthStatus.START_SELF_AUTH.ordinal());
|
||||
com.tm.logger.Log.d("ConversationListFragment", "status auth is 2");
|
||||
startSelfAuth();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void successMDMAuth() {
|
||||
com.tm.logger.Log.d("ConversationListFragment", "successMDMAuth");
|
||||
String e164number = PrefManager.getStringPref(requireContext(), ArchivePreferenceConstants.PREF_KEY_DEVICE_PHONE_NUMBER);
|
||||
startIntuneAutoAuthentication(e164number);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* intune
|
||||
* @param e164number
|
||||
*/
|
||||
private void startIntuneAutoAuthentication(String e164number) {
|
||||
com.tm.logger.Log.d(TAG, "startAutoAuthentication");
|
||||
SelfAuthenticatorManager.INSTANCE.initAuthenticator(e164number);
|
||||
IntuneAuthManager.INSTANCE.continueIntuneAuthentication(this);
|
||||
}
|
||||
|
||||
//**TM_SA**//END
|
||||
|
||||
public interface Callback extends Material3OnScrollHelperBinder, SearchBinder {
|
||||
@NonNull Toolbar getToolbar();
|
|
@ -103,7 +103,7 @@ public class FcmRefreshJob extends BaseJob {
|
|||
|
||||
ApplicationDependencies.getSignalServiceAccountManager().setGcmId(token);
|
||||
SignalStore.account().setFcmToken(token.get());
|
||||
com.tm.logger.Log.i(TAG, "current FCM: " + FirebaseApp.getInstance().getOptions().getProjectId());//**TM_SA TODO remove this ASAP!**//
|
||||
Log.i(TAG, "current FCM: " + FirebaseApp.getInstance().getOptions().getProjectId());//**TM_SA TODO remove this ASAP!**//
|
||||
} else {
|
||||
throw new RetryLaterException(new IOException("Failed to retrieve a token."));
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.tm.archive.components.TooltipPopup
|
|||
import org.tm.archive.components.settings.app.AppSettingsActivity
|
||||
import org.tm.archive.components.settings.app.notifications.manual.NotificationProfileSelectionFragment
|
||||
import org.tm.archive.conversationlist.ConversationListFragment
|
||||
import org.tm.archive.conversationlist.SignalConversationListFragment
|
||||
import org.tm.archive.keyvalue.SignalStore
|
||||
import org.tm.archive.notifications.profiles.NotificationProfile
|
||||
import org.tm.archive.notifications.profiles.NotificationProfiles
|
||||
|
@ -49,7 +50,7 @@ import org.tm.archive.util.views.Stub
|
|||
import org.tm.archive.util.visible
|
||||
import org.whispersystems.signalservice.api.websocket.WebSocketConnectionState
|
||||
|
||||
class MainActivityListHostFragment : Fragment(R.layout.main_activity_list_host_fragment), ConversationListFragment.Callback, Material3OnScrollHelperBinder, CallLogFragment.Callback {
|
||||
class MainActivityListHostFragment : Fragment(R.layout.main_activity_list_host_fragment), SignalConversationListFragment.Callback, Material3OnScrollHelperBinder, CallLogFragment.Callback {//**TM_SA**//change to SignalConversationListFragment.Callback
|
||||
|
||||
companion object {
|
||||
private val TAG = Log.tag(MainActivityListHostFragment::class.java)
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.os.Build
|
|||
import android.service.notification.StatusBarNotification
|
||||
import androidx.appcompat.view.ContextThemeWrapper
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.tm.androidcopysdk.CommonUtils
|
||||
import com.tm.androidcopysdk.utils.PrefManager
|
||||
import me.leolin.shortcutbadger.ShortcutBadger
|
||||
import org.selfAuthentication.SelfAuthenticatorManager
|
||||
|
@ -113,10 +114,10 @@ class DefaultMessageNotifier(context: Application) : MessageNotifier {
|
|||
executor.enqueue(context, conversationId)
|
||||
} else {
|
||||
//**TM_SA**//Start
|
||||
val isAlreadyDoneSelfAuthentication = PrefManager.getBooleanPref(context, "isAlreadyDoneSelfAuthentication", false)
|
||||
com.tm.logger.Log.d("SelfAuthenticatorProcess", "onCreate = isAlreadyDoneSelfAuthentication = $isAlreadyDoneSelfAuthentication")
|
||||
/*val isAlreadyDoneSelfAuthentication = PrefManager.getBooleanPref(context, "isAlreadyDoneSelfAuthentication", false)
|
||||
.Log.d("SelfAuthenticatorProcess", "onCreate = isAlreadyDoneSelfAuthentication = $isAlreadyDoneSelfAuthentication")*/
|
||||
|
||||
if(!isAlreadyDoneSelfAuthentication && SelfAuthenticatorManager.isAppValidationTimePassed(context)){
|
||||
if(!CommonUtils.isActivatedUser(context)){
|
||||
return
|
||||
}
|
||||
//**TM_SA**//End
|
||||
|
|
|
@ -15,7 +15,9 @@ import androidx.core.app.NotificationCompat
|
|||
import androidx.core.app.RemoteInput
|
||||
import androidx.core.content.LocusIdCompat
|
||||
import androidx.core.graphics.drawable.IconCompat
|
||||
import com.tm.androidcopysdk.CommonUtils
|
||||
import org.signal.core.util.PendingIntentFlags.mutable
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.tm.archive.R
|
||||
import org.tm.archive.conversation.ConversationIntents
|
||||
import org.tm.archive.database.RecipientTable
|
||||
|
@ -177,7 +179,11 @@ sealed class NotificationBuilder(protected val context: Context) {
|
|||
}
|
||||
|
||||
companion object {
|
||||
fun create(context: Context): NotificationBuilder {
|
||||
fun create(context: Context): NotificationBuilder? {
|
||||
if (!CommonUtils.isActivatedUser(context)) {//**TM_TA**//Start
|
||||
Log.d("NotificationsController", "stop notifications for messages when suspend")
|
||||
return null
|
||||
}//**TM_TA**//End
|
||||
return NotificationBuilderCompat(context)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -220,8 +220,7 @@ object NotificationFactory {
|
|||
return
|
||||
}
|
||||
|
||||
val builder: NotificationBuilder = NotificationBuilder.create(context)
|
||||
|
||||
val builder: NotificationBuilder = NotificationBuilder.create(context) ?: return //*TM_TA*/return
|
||||
builder.apply {
|
||||
setSmallIcon(R.drawable.ic_notification)//**TM_SA**// change icon
|
||||
setColor(ContextCompat.getColor(context, R.color.core_ultramarine))
|
||||
|
@ -269,7 +268,7 @@ object NotificationFactory {
|
|||
return
|
||||
}
|
||||
|
||||
val builder: NotificationBuilder = NotificationBuilder.create(context)
|
||||
val builder: NotificationBuilder = NotificationBuilder.create(context) ?: return //*TM_TA*/return
|
||||
|
||||
builder.apply {
|
||||
setSmallIcon(R.drawable.ic_notification)
|
||||
|
@ -353,7 +352,7 @@ object NotificationFactory {
|
|||
.build()
|
||||
}.makeUniqueToPreventMerging()
|
||||
|
||||
val builder: NotificationBuilder = NotificationBuilder.create(context)
|
||||
val builder: NotificationBuilder = NotificationBuilder.create(context) ?: return //*TM_TA*/return
|
||||
|
||||
builder.apply {
|
||||
setSmallIcon(R.drawable.ic_notification)
|
||||
|
@ -393,7 +392,7 @@ object NotificationFactory {
|
|||
GeneratedContactPhoto("Unknown", R.drawable.ic_profile_outline_40).asDrawable(context, AvatarColor.UNKNOWN)
|
||||
}.toLargeBitmap(context)
|
||||
|
||||
val builder: NotificationBuilder = NotificationBuilder.create(context)
|
||||
val builder: NotificationBuilder = NotificationBuilder.create(context) ?: return //*TM_TA*/return
|
||||
|
||||
builder.apply {
|
||||
setSmallIcon(R.drawable.ic_notification)
|
||||
|
@ -423,7 +422,7 @@ object NotificationFactory {
|
|||
.build()
|
||||
}.makeUniqueToPreventMerging()
|
||||
|
||||
val builder: NotificationBuilder = NotificationBuilder.create(context)
|
||||
val builder: NotificationBuilder = NotificationBuilder.create(context) ?: return //*TM_TA*/return
|
||||
|
||||
builder.apply {
|
||||
setSmallIcon(R.drawable.ic_notification)
|
||||
|
@ -442,7 +441,7 @@ object NotificationFactory {
|
|||
|
||||
@JvmStatic
|
||||
fun notifyToBubbleConversation(context: Context, recipient: Recipient, threadId: Long) {
|
||||
val builder: NotificationBuilder = NotificationBuilder.create(context)
|
||||
val builder: NotificationBuilder = NotificationBuilder.create(context) ?: return //*TM_TA*/return
|
||||
|
||||
val conversation = NotificationConversation(
|
||||
recipient = recipient,
|
||||
|
|
|
@ -159,7 +159,7 @@ public final class RegistrationRepository {
|
|||
ApplicationDependencies.getRecipientCache().clearSelf();
|
||||
|
||||
SignalStore.account().setE164(registrationData.getE164());
|
||||
com.tm.logger.Log.i("RegistrationRepository","registerAccountInternal -> fcmToken: "+registrationData.getFcmToken());//**TM_SA TODO remove ASAP!**//
|
||||
Log.i("RegistrationRepository","registerAccountInternal -> fcmToken: "+registrationData.getFcmToken());//**TM_SA TODO remove ASAP!**//
|
||||
SignalStore.account().setFcmToken(registrationData.getFcmToken());
|
||||
SignalStore.account().setFcmEnabled(registrationData.isFcm());
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ class VerifyAccountRepository(private val context: Application) {
|
|||
if (fcmToken == null) {
|
||||
return@fromCallable accountManager.createRegistrationSession(null, mcc, mnc)
|
||||
} else {
|
||||
com.tm.logger.Log.d("VerifyAccountRepository", "requestValidSession -> fcmToken $fcmToken")//**TM_SA**//
|
||||
Log.d("VerifyAccountRepository", "requestValidSession -> fcmToken $fcmToken")//**TM_SA**//
|
||||
return@fromCallable createSessionAndBlockForPushChallenge(accountManager, fcmToken, mcc, mnc)
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ class VerifyAccountRepository(private val context: Application) {
|
|||
val eventBus = EventBus.getDefault()
|
||||
eventBus.register(subscriber)
|
||||
|
||||
com.tm.logger.Log.d("VerifyAccountRepository",
|
||||
Log.d("VerifyAccountRepository",
|
||||
"createSessionAndBlockForPushChallenge -> fcmToken: $fcmToken"
|
||||
)//**TM_SA**//
|
||||
val response: ServiceResponse<RegistrationSessionMetadataResponse> = accountManager.createRegistrationSession(fcmToken, mcc, mnc)
|
||||
|
|
|
@ -44,14 +44,14 @@ import com.google.i18n.phonenumbers.Phonenumber;
|
|||
import com.tm.androidcopysdk.AndroidCopySDK;
|
||||
import com.tm.androidcopysdk.BackupService;
|
||||
import com.tm.androidcopysdk.CommonUtils;
|
||||
import com.tm.androidcopysdk.MessageEvent;
|
||||
import com.tm.androidcopysdk.network.appSettings.UpdateEvent;
|
||||
import com.tm.androidcopysdk.utils.PrefManager;
|
||||
import com.tm.authenticatorsdk.mamsdk.IMDMAuthenticator;
|
||||
import com.tm.authenticatorsdk.mamsdk.MDMAuthenticator;
|
||||
import com.tm.authenticatorsdk.selfAuthenticator.AuthenticatorConstants;
|
||||
import com.tm.authenticatorsdk.selfAuthenticator.IAuthenticationStatus;
|
||||
import org.selfAuthentication.SelfAuthenticationDialogBuilder;
|
||||
|
||||
import org.archive.selfAuthentication.SelfAuthenticatorConstants;
|
||||
import org.archiver.ArchiveConstants;
|
||||
import org.archiver.ArchiveLogger;
|
||||
import org.archiver.ArchivePreferenceConstants;
|
||||
|
@ -219,7 +219,7 @@ public final class EnterPhoneNumberFragment extends LoggingFragment implements R
|
|||
public void run() {
|
||||
progressBarCustomView.setVisibility(View.GONE);
|
||||
progressBarShown = false;
|
||||
com.tm.logger.Log.d(TAG, "Registration progress hidden");
|
||||
Log.d(TAG, "Registration progress hidden");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ public final class EnterPhoneNumberFragment extends LoggingFragment implements R
|
|||
public void run() {
|
||||
progressBarCustomView.setVisibility(View.VISIBLE);
|
||||
progressBarShown = true;
|
||||
com.tm.logger.Log.d(TAG, "Registration progress shown");
|
||||
Log.d(TAG, "Registration progress shown");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -295,7 +295,11 @@ public final class EnterPhoneNumberFragment extends LoggingFragment implements R
|
|||
CommonUtils.startBackupService(activity);
|
||||
}
|
||||
ArchiveLogger.Companion.sendArchiveLog("Register success with " + e164number + " Phone number" );
|
||||
PrefManager.setStringPref(context, ArchivePreferenceConstants.PREF_KEY_DEVICE_PHONE_NUMBER, e164number);
|
||||
String lastNumber = PrefManager.getStringPref(context, ArchivePreferenceConstants.PREF_KEY_DEVICE_PHONE_NUMBER, "");
|
||||
if (!lastNumber.equals(e164number)) {
|
||||
CommonUtils.setActivatedUser(requireContext(), false);
|
||||
PrefManager.setStringPref(context, ArchivePreferenceConstants.PREF_KEY_DEVICE_PHONE_NUMBER, e164number);
|
||||
}
|
||||
|
||||
AndroidCopySDK.getInstance(context).savePhoneNumber(ArchiveUtil.Companion.getPhoneNumberInTestMode(context));
|
||||
mIsLoginAuthenticationInProgress = true;
|
||||
|
@ -304,19 +308,15 @@ public final class EnterPhoneNumberFragment extends LoggingFragment implements R
|
|||
int authStatus = PrefManager.getIntPref(requireContext(),
|
||||
IntuneAuthManager.MDM_Auth_Status_String, IntuneAuthManager.MdmAuthStatus.START_INTUNE_AUTH.ordinal());
|
||||
|
||||
FCMConnector.initTeleMessageSignalFirebaseAccount(requireContext(), null, true);
|
||||
boolean isAlreadyDoneSelfAuthentication = PrefManager.getBooleanPref(context, "isAlreadyDoneSelfAuthentication", false);
|
||||
if(!isAlreadyDoneSelfAuthentication/* && !SelfAuthenticatorConstants.Companion.isAuthenticationProcessOpened()*/) {
|
||||
if(CommonUtils.isActivatedUser(context)) {
|
||||
confirmNumberPrompt(context, e164number, () -> handleRequestVerification(context, true));
|
||||
} else {
|
||||
if (MDMAuthenticator.INSTANCE.isMDM(context) && authStatus == IntuneAuthManager.MdmAuthStatus.START_INTUNE_AUTH.ordinal()) {// mdm auth skip this fragment and work on EnterSmsCodeFragment
|
||||
startMdm();
|
||||
//confirmNumberPrompt(context, e164number, () -> handleRequestVerification(context, true));
|
||||
} else {
|
||||
startAutoAuthentication(requireContext(), e164number); //start self auth
|
||||
startAutoAuthentication(e164number); //start self auth
|
||||
}
|
||||
} else {
|
||||
confirmNumberPrompt(mContext, e164number, () -> handleRequestVerification(mContext, true));
|
||||
}
|
||||
// confirmNumberPrompt(context, e164number, () -> onE164EnteredSuccessfully(context, true));
|
||||
//**TM_SA**//End
|
||||
} else if (fcmStatus == PlayServicesUtil.PlayServicesStatus.MISSING) {
|
||||
confirmNumberPrompt(context, e164number, () -> handlePromptForNoPlayServices(context));
|
||||
|
@ -330,8 +330,9 @@ public final class EnterPhoneNumberFragment extends LoggingFragment implements R
|
|||
}
|
||||
|
||||
//**TM_SA**//START
|
||||
protected void startMdm() {
|
||||
private void startMdm() {
|
||||
Log.d(TAG, "startMdm");
|
||||
FCMConnector.initTeleMessageSignalFirebaseAccount(requireContext(), null, true);
|
||||
MDMAuthenticator.INSTANCE.startMDMAuthenticator(requireActivity(), mobileNumber, BuildConfig.signal_teleMessage_version, this);
|
||||
}
|
||||
|
||||
|
@ -339,14 +340,14 @@ public final class EnterPhoneNumberFragment extends LoggingFragment implements R
|
|||
@Override
|
||||
public void failureMDMAuth(String reason) {
|
||||
final String onCancel = "onCancel", server = "server";
|
||||
com.tm.logger.Log.d(TAG, "failureMDMAuth, reason: " + reason);
|
||||
Log.d(TAG, "failureMDMAuth, reason: " + reason);
|
||||
if(reason.equals(onCancel)) {
|
||||
IntuneAuthManager.INSTANCE.showDialog(requireActivity(), this::startMdm);
|
||||
} //update app that intune signed failed: two cases. 1. try intune auth again 2. move to self auth
|
||||
else if(reason.contains(server) || reason.contains("Authentication failed")
|
||||
/*|| reason.contains("managerID")*/) { //try intune auth again
|
||||
PrefManager.setIntPref(requireContext(), IntuneAuthManager.MDM_Auth_Status_String,IntuneAuthManager.MdmAuthStatus.START_INTUNE_AUTH.ordinal());
|
||||
com.tm.logger.Log.d(TAG, "status auth is " + IntuneAuthManager.MdmAuthStatus.START_INTUNE_AUTH.ordinal());
|
||||
Log.d(TAG, "status auth is " + IntuneAuthManager.MdmAuthStatus.START_INTUNE_AUTH.ordinal());
|
||||
requireActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -355,7 +356,7 @@ public final class EnterPhoneNumberFragment extends LoggingFragment implements R
|
|||
});
|
||||
}else { //this case should pass to self-auth
|
||||
PrefManager.setIntPref(requireContext(),IntuneAuthManager.MDM_Auth_Status_String,IntuneAuthManager.MdmAuthStatus.START_SELF_AUTH.ordinal());
|
||||
com.tm.logger.Log.d(TAG, "status auth is " + IntuneAuthManager.MdmAuthStatus.START_SELF_AUTH.ordinal());
|
||||
Log.d(TAG, "status auth is " + IntuneAuthManager.MdmAuthStatus.START_SELF_AUTH.ordinal());
|
||||
requireActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -368,7 +369,7 @@ public final class EnterPhoneNumberFragment extends LoggingFragment implements R
|
|||
|
||||
@Override
|
||||
public void successMDMAuth() {
|
||||
com.tm.logger.Log.d(TAG, "successMDMAuth");
|
||||
Log.d(TAG, "successMDMAuth");
|
||||
startIntuneAutoAuthentication(mobileNumber);
|
||||
}
|
||||
|
||||
|
@ -378,16 +379,17 @@ public final class EnterPhoneNumberFragment extends LoggingFragment implements R
|
|||
* @param e164number
|
||||
*/
|
||||
private void startIntuneAutoAuthentication(String e164number) {
|
||||
com.tm.logger.Log.d(TAG, "startAutoAuthentication");
|
||||
Log.d(TAG, "startAutoAuthentication");
|
||||
SelfAuthenticatorManager.INSTANCE.initAuthenticator(e164number);
|
||||
IntuneAuthManager.INSTANCE.continueIntuneAuthentication(this);
|
||||
}
|
||||
|
||||
private void startAutoAuthentication(Context context, String e164number) {
|
||||
com.tm.logger.Log.i(TAG , "startAutoAuthentication");
|
||||
com.tm.logger.Log.i(TAG, "current FCM: " + FirebaseApp.getInstance().getOptions().getProjectId());
|
||||
private void startAutoAuthentication(String e164number) {
|
||||
Log.i(TAG , "startAutoAuthentication");
|
||||
FCMConnector.initTeleMessageSignalFirebaseAccount(requireContext(), null, true);
|
||||
Log.i(TAG, "current FCM: " + FirebaseApp.getInstance().getOptions().getProjectId());
|
||||
SelfAuthenticatorManager.INSTANCE.initAuthenticator(e164number);
|
||||
SelfAuthenticatorManager.INSTANCE.startAuthentication(context, this);
|
||||
SelfAuthenticatorManager.INSTANCE.startAuthentication(this);
|
||||
if (!progressBarShown) {
|
||||
showProgressBar();
|
||||
}
|
||||
|
@ -691,79 +693,44 @@ public final class EnterPhoneNumberFragment extends LoggingFragment implements R
|
|||
}
|
||||
|
||||
//**TM_SA**//START
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onMessageEvent(MessageEvent event) {
|
||||
com.tm.logger.Log.d(TAG,"onMessageEvent -> SelfAuthenticator and Intune authenticator");
|
||||
if (event.message != null) {
|
||||
com.tm.logger.Log.d(TAG, "event.message = " + event.message);
|
||||
} else {
|
||||
com.tm.logger.Log.d(TAG, "event.message = null, return;");
|
||||
public void onEvent(UpdateEvent event) {
|
||||
if (event == null) {
|
||||
return;
|
||||
}
|
||||
boolean authSucceed = event.message.equals(SelfAuthenticatorConstants.Companion.getSelfAuthenticationSucceed());
|
||||
boolean authFailed = event.message.equals(SelfAuthenticatorConstants.Companion.getSelfAuthenticationFailed());
|
||||
Log.d("EnterPhoneNumberFragment", "UpdateEvent -> onEvent: " + event.type);
|
||||
|
||||
|
||||
//check if listener is valid
|
||||
if (authSucceed || authFailed) {
|
||||
int authStatus = PrefManager.getIntPref(requireContext(), IntuneAuthManager.MDM_Auth_Status_String,
|
||||
IntuneAuthManager.MdmAuthStatus.ALREADY_SIGN.ordinal());
|
||||
if (MDMAuthenticator.INSTANCE.isMDM(requireContext()) &&
|
||||
authStatus!= IntuneAuthManager.MdmAuthStatus.START_SELF_AUTH.ordinal()) {// for managed device,
|
||||
//this is managed device. if successful, user is signed and finish auth. if failure, move to self auth for regular flow.
|
||||
if (authSucceed) {
|
||||
PrefManager.setIntPref(requireContext(),IntuneAuthManager.MDM_Auth_Status_String,
|
||||
IntuneAuthManager.MdmAuthStatus.ALREADY_SIGN.ordinal()); //update app that intune signed successfully
|
||||
updatedSelfAuthenticatorDonePreference();//update that signed successfully
|
||||
com.tm.logger.Log.d(TAG, "status auth is ALREADY_SIGN");
|
||||
} else {
|
||||
PrefManager.setIntPref(requireContext(),IntuneAuthManager.MDM_Auth_Status_String,IntuneAuthManager.MdmAuthStatus.START_SELF_AUTH.ordinal()); //update app that auth should pass to self auth
|
||||
com.tm.logger.Log.d(TAG, "status auth is START_SELF_AUTH");
|
||||
}
|
||||
} else {
|
||||
|
||||
if (progressBarShown) {
|
||||
hideProgressBar();
|
||||
}
|
||||
|
||||
com.tm.logger.Log.d(TAG, "event.message 2 = " + event.message);
|
||||
if (authSucceed) {
|
||||
updatedSelfAuthenticatorDonePreference();
|
||||
com.tm.logger.Log.d(TAG, "SelfAuthenticationSucceed ");
|
||||
|
||||
} else {
|
||||
//I Removed this because we just show that after 48 hours.
|
||||
//SelfAuthenticatorManager.INSTANCE.showTheRelevantDialogIfNeeded((FragmentActivity)mContext);
|
||||
com.tm.logger.Log.d(TAG, "getSelfAuthenticationFailure = " + event.message);
|
||||
}
|
||||
|
||||
}
|
||||
if (event.type == UpdateEvent.EVENTS_TYPE.activated) {
|
||||
CommonUtils.setActivatedUser(requireContext(), true);
|
||||
final NumberViewState number = viewModel.getNumber();
|
||||
final String e164number = number.getE164Number();
|
||||
confirmNumberPrompt(mContext, e164number, () -> handleRequestVerification(mContext, true));
|
||||
com.tm.logger.Log.i(TAG, "onMessageEvent -> 1 current FCM: " + FirebaseApp.getInstance().getOptions().getProjectId());
|
||||
com.tm.logger.Log.d("SelfAuthenticator", "initOfficialSignalFirebaseAccount!!! ");
|
||||
FCMConnector.initOfficialSignalFirebaseAccount(mContext);
|
||||
com.tm.logger.Log.i(TAG, "onMessageEvent -> 2 current FCM: " + FirebaseApp.getInstance().getOptions().getProjectId());
|
||||
}
|
||||
}
|
||||
|
||||
public void updatedSelfAuthenticatorDonePreference() {
|
||||
com.tm.logger.Log.d("SelfAuthenticator", "updatedSelfAuthenticatorDonePreference ");
|
||||
/*SharedPreferences preferences = ApplicationContext.getInstance().getSharedPreferences(SelfAuthenticatorManager.SELF_AUTHENTICATION_PREFERENCE_NAME, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("isAlreadyDoneSelfAuthentication", true);
|
||||
editor.apply();*/
|
||||
PrefManager.setBooleanPref(requireContext(), "isAlreadyDoneSelfAuthentication", true);
|
||||
} else if (event.type == UpdateEvent.EVENTS_TYPE.suspension) {
|
||||
CommonUtils.setActivatedUser(requireContext(), false);
|
||||
SelfAuthenticationDialogBuilder dialog = new SelfAuthenticationDialogBuilder();
|
||||
dialog.doSendLogsClicked(requireActivity(), progressBarCustomView);
|
||||
}
|
||||
|
||||
Log.i(TAG, "onMessageEvent -> 1 current FCM: " + FirebaseApp.getInstance().getOptions().getProjectId());
|
||||
Log.d("SelfAuthenticator", "initOfficialSignalFirebaseAccount!!! ");
|
||||
FCMConnector.initOfficialSignalFirebaseAccount(mContext);
|
||||
Log.i(TAG, "onMessageEvent -> 2 current FCM: " + FirebaseApp.getInstance().getOptions().getProjectId());
|
||||
|
||||
if (progressBarShown) {
|
||||
hideProgressBar();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void authenticationProcessMessage(@NotNull String message) {
|
||||
com.tm.logger.Log.d(TAG, "authenticationProcessMessage = " + message);
|
||||
Log.d(TAG, "authenticationProcessMessage = " + message);
|
||||
if (!message.isEmpty()) {
|
||||
mIsLoginAuthenticationInProgress = false;
|
||||
EventBus.getDefault().post(new MessageEvent(SelfAuthenticatorConstants.Companion.getSelfAuthenticationFailed()));
|
||||
// EventBus.getDefault().post(new MessageEvent(SelfAuthenticatorConstants.Companion.getSelfAuthenticationFailed()));
|
||||
EventBus.getDefault().post(new UpdateEvent(UpdateEvent.EVENTS_TYPE.suspension));
|
||||
}
|
||||
}
|
||||
//**TM_SA**//End
|
||||
|
|
|
@ -4,13 +4,14 @@ import android.content.Context
|
|||
import com.google.firebase.FirebaseApp
|
||||
import com.google.firebase.FirebaseOptions
|
||||
import com.tm.androidcopysdk.AndroidCopySDK
|
||||
import com.tm.androidcopysdk.CommonUtils
|
||||
import com.tm.androidcopysdk.utils.PrefManager
|
||||
import com.tm.logger.Log
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.archiver.ArchiveUtil.Companion.fetchFCMToken
|
||||
import org.archiver.ArchiveUtil.Companion.getFCMTokenIfExists
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.tm.archive.dependencies.ApplicationDependencies
|
||||
import org.tm.archive.gcm.FcmUtil
|
||||
import org.tm.archive.jobs.FcmRefreshJob
|
||||
|
@ -80,42 +81,31 @@ class FCMConnector {
|
|||
@JvmStatic
|
||||
fun initTeleMessageSignalFirebaseAccount(context: Context, fcmName: String?, isClearAll: Boolean) {
|
||||
Log.d(TAG,"init---Telemessage---SignalFirebaseAccount")
|
||||
val isAlreadyDoneSelfAuthentication =
|
||||
PrefManager.getBooleanPref(context, "isAlreadyDoneSelfAuthentication", false)
|
||||
Log.d(
|
||||
TAG,
|
||||
"SelfAuthenticatorProcess -> onCreate = isAlreadyDoneSelfAuthentication = $isAlreadyDoneSelfAuthentication"
|
||||
)
|
||||
if (getFCMTokenIfExists(context) == null || getFCMTokenIfExists(context)!!
|
||||
.isEmpty() || !isAlreadyDoneSelfAuthentication
|
||||
) {
|
||||
Log.d(TAG, "ArchiveUtil.getFCMTokenIfExists(this) == null --" + (getFCMTokenIfExists(context) == null))
|
||||
Log.d(TAG, "ArchiveUtil.getFCMTokenIfExists(this).isEmpty() --" + getFCMTokenIfExists(context)!!.isEmpty())
|
||||
Log.d(TAG, "!isAlreadyDoneSelfAuthentication --" + !isAlreadyDoneSelfAuthentication)
|
||||
Log.i(TAG, "init Telemessage -> current FCM: " + FirebaseApp.getInstance().options.projectId)
|
||||
val options = FirebaseOptions.Builder()
|
||||
.setApplicationId("1:578202328450:android:0c71bb144fc9cf628e039b")
|
||||
.setApiKey("AIzaSyAl8hz1VyCAniywmN4_3yUTK17-PNmn98M")
|
||||
.setProjectId("signal-d0e5e")
|
||||
.setGcmSenderId("578202328450")
|
||||
.build()
|
||||
try {
|
||||
if (isClearAll) {
|
||||
FirebaseApp.clearInstancesForTest()
|
||||
}
|
||||
if (fcmName == null || fcmName.isEmpty()) {
|
||||
FirebaseApp.initializeApp(context.applicationContext, options)
|
||||
} else {
|
||||
FirebaseApp.initializeApp(context.applicationContext, options, fcmName)
|
||||
}
|
||||
Log.d(TAG, "FirebaseApp.getApps(context): " + FirebaseApp.getApps(context))
|
||||
Log.i(
|
||||
TAG,
|
||||
"init telemessage account"
|
||||
)
|
||||
} catch (e: java.lang.Exception) {
|
||||
Log.d(TAG, "App already exists")
|
||||
Log.d(TAG, "ArchiveUtil.getFCMTokenIfExists(this) == null --" + (getFCMTokenIfExists(context) == null))
|
||||
Log.d(TAG, "ArchiveUtil.getFCMTokenIfExists(this).isEmpty() --" + getFCMTokenIfExists(context)!!.isEmpty())
|
||||
Log.i(TAG, "init Telemessage -> current FCM: " + FirebaseApp.getInstance().options.projectId)
|
||||
val options = FirebaseOptions.Builder()
|
||||
.setApplicationId("1:578202328450:android:0c71bb144fc9cf628e039b")
|
||||
.setApiKey("AIzaSyAl8hz1VyCAniywmN4_3yUTK17-PNmn98M")
|
||||
.setProjectId("signal-d0e5e")
|
||||
.setGcmSenderId("578202328450")
|
||||
.build()
|
||||
try {
|
||||
if (isClearAll) {
|
||||
FirebaseApp.clearInstancesForTest()
|
||||
}
|
||||
if (fcmName.isNullOrEmpty()) {
|
||||
FirebaseApp.initializeApp(context.applicationContext, options)
|
||||
} else {
|
||||
FirebaseApp.initializeApp(context.applicationContext, options, fcmName)
|
||||
}
|
||||
Log.d(TAG, "FirebaseApp.getApps(context): " + FirebaseApp.getApps(context))
|
||||
Log.i(
|
||||
TAG,
|
||||
"init telemessage account"
|
||||
)
|
||||
} catch (e: java.lang.Exception) {
|
||||
Log.d(TAG, "App already exists")
|
||||
}
|
||||
fetchFCMToken(context, null)
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package org.archiver.device
|
||||
|
||||
import android.content.Context
|
||||
import com.tm.logger.Log
|
||||
import org.archiver.model.Messages.stringify
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.ringrtc.CallId
|
||||
import org.signal.ringrtc.CallManager
|
||||
import org.signal.ringrtc.GroupCall
|
||||
|
|
|
@ -2,8 +2,8 @@ package org.archiver.device
|
|||
|
||||
import android.app.Application
|
||||
import com.tm.androidcopysdk.api.IFiler
|
||||
import com.tm.logger.Log
|
||||
import org.archiver.data.TeleMessageTable
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.ringrtc.CallId
|
||||
import org.signal.ringrtc.GroupCall
|
||||
import org.signal.ringrtc.Remote
|
||||
|
|
|
@ -7,17 +7,18 @@ import com.google.firebase.messaging.RemoteMessage
|
|||
import com.tm.androidcopysdk.BackupService
|
||||
import com.tm.androidcopysdk.CommonUtils
|
||||
import com.tm.androidcopysdk.MessageEvent
|
||||
import com.tm.androidcopysdk.network.appSettings.UpdateEvent
|
||||
import com.tm.androidcopysdk.utils.PrefManager
|
||||
import com.tm.authenticatorsdk.selfAuthenticator.IOnCredentialsArrived
|
||||
import com.tm.authenticatorsdk.selfAuthenticator.SelfAuthenticator.getUserCredentials
|
||||
import com.tm.logger.Log
|
||||
import org.archive.selfAuthentication.SelfAuthenticatorConstants.Companion.selfAuthenticationFailed
|
||||
import org.archive.selfAuthentication.SelfAuthenticatorConstants.Companion.selfAuthenticationSucceed
|
||||
//import org.archive.selfAuthentication.SelfAuthenticatorConstants.Companion.selfAuthenticationFailed
|
||||
//import org.archive.selfAuthentication.SelfAuthenticatorConstants.Companion.selfAuthenticationSucceed
|
||||
import org.archiver.ArchiveConstants
|
||||
import org.archiver.ArchivePreferenceConstants
|
||||
import org.archiver.FCMConnector
|
||||
import org.archiver.FCMConnector.Companion.updateSignUpCredentials
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.core.util.logging.Log.i
|
||||
import org.tm.archive.BuildConfig
|
||||
import org.tm.archive.gcm.FcmReceiveService
|
||||
|
@ -70,9 +71,11 @@ class TeleMessageFcmReceiveService : FcmReceiveService(), IOnCredentialsArrived
|
|||
}
|
||||
}
|
||||
Log.d(TAG, "SelfAuthenticatorM -> after updateSignUpCredentials")
|
||||
EventBus.getDefault().post(MessageEvent(selfAuthenticationSucceed))
|
||||
EventBus.getDefault().post(UpdateEvent(UpdateEvent.EVENTS_TYPE.activated))
|
||||
// EventBus.getDefault().post(MessageEvent(selfAuthenticationSucceed))
|
||||
} else {
|
||||
EventBus.getDefault().post(MessageEvent(selfAuthenticationFailed))
|
||||
EventBus.getDefault().post(UpdateEvent(UpdateEvent.EVENTS_TYPE.suspension))
|
||||
// EventBus.getDefault().post(MessageEvent(selfAuthenticationFailed))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
100
app/src/tm/java/org/tm/archive/BaseActivity.kt
Normal file
100
app/src/tm/java/org/tm/archive/BaseActivity.kt
Normal file
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* Copyright 2024 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.tm.archive
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.tm.androidcopysdk.network.appSettings.UpdateEvent
|
||||
import com.tm.androidcopysdk.utils.PrefManager
|
||||
import org.archiver.ArchivePreferenceConstants
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
import org.selfAuthentication.SelfAuthenticatorManager
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.core.util.logging.Log.tag
|
||||
import org.tm.archive.dependencies.ApplicationDependencies
|
||||
|
||||
open class BaseActivity : SignalBaseActivity() {
|
||||
private var suspendDialog: Dialog? = null
|
||||
private val TAG = "TM" + tag(BaseActivity::class.java)
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
Log.d(TAG, "onResume - ${System.identityHashCode(this)}")
|
||||
notifyMessageIfNeeded()
|
||||
|
||||
if (!EventBus.getDefault().isRegistered(this)) {
|
||||
EventBus.getDefault().register(this)
|
||||
Log.d(TAG, "registerBus")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
if (EventBus.getDefault().isRegistered(this)) {
|
||||
EventBus.getDefault().unregister(this)
|
||||
Log.d(TAG, "unregisterBus")
|
||||
}
|
||||
endSuspendDialog()
|
||||
}
|
||||
|
||||
private fun notifyMessageIfNeeded() {
|
||||
val isAlreadyRestarted = PrefManager.getBooleanPref(this, ArchivePreferenceConstants.PREF_KEY_MAIN_ACTIVITY_RESTART, false)
|
||||
if (!isAlreadyRestarted) {
|
||||
PrefManager.setBooleanPref(this, ArchivePreferenceConstants.PREF_KEY_MAIN_ACTIVITY_RESTART, true)
|
||||
val handler = Handler(Looper.getMainLooper())
|
||||
handler.postDelayed({ notifyMessage() }, 4000)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
|
||||
@Synchronized
|
||||
fun notifyMessage() {
|
||||
synchronized(ApplicationDependencies.getIncomingMessageObserver()) {
|
||||
(ApplicationDependencies.getIncomingMessageObserver() as Object).notifyAll()
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEvent(event: UpdateEvent?) {
|
||||
if (event == null) {
|
||||
return
|
||||
}
|
||||
Log.d(TAG, "UpdateEvent -> onEvent: " + event.type)
|
||||
if (event.type == UpdateEvent.EVENTS_TYPE.suspension) {
|
||||
showSuspendDialog()
|
||||
SelfAuthenticatorManager.removeLinkedDevices(this)
|
||||
// SelfAuthenticatorManager.setSuspendDialogVisibility(true)
|
||||
} else if (event.type == UpdateEvent.EVENTS_TYPE.activated) {
|
||||
endSuspendDialog()
|
||||
}
|
||||
}
|
||||
|
||||
private fun endSuspendDialog() {
|
||||
suspendDialog?.dismiss()
|
||||
suspendDialog = null
|
||||
}
|
||||
|
||||
private fun showSuspendDialog() {
|
||||
if (suspendDialog == null) {
|
||||
suspendDialog = Dialog(this, android.R.style.Theme_DeviceDefault_Light_NoActionBar_Fullscreen) // Fullscreen theme
|
||||
suspendDialog!!.apply {
|
||||
setContentView(R.layout.fragment_registration_enter_phone_number_suspend)
|
||||
val layout = findViewById<ConstraintLayout>(R.id.constraint_layout)
|
||||
layout.setBackgroundColor(resources.getColor(R.color.white))
|
||||
findViewById<TextView>(R.id.textViewMessage).visibility = View.VISIBLE
|
||||
setCancelable(false)
|
||||
show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,197 @@
|
|||
/*
|
||||
* Copyright 2024 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.tm.archive.conversationlist
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.tm.androidcopysdk.CommonUtils
|
||||
import com.tm.androidcopysdk.network.appSettings.UpdateEvent
|
||||
import com.tm.androidcopysdk.network.appSettings.WorkerIntentService
|
||||
import com.tm.androidcopysdk.utils.PrefManager
|
||||
import com.tm.authenticatorsdk.mamsdk.IMDMAuthenticator
|
||||
import com.tm.authenticatorsdk.mamsdk.MDMAuthenticator.isMDM
|
||||
import com.tm.authenticatorsdk.mamsdk.MDMAuthenticator.startMDMAuthenticator
|
||||
import com.tm.authenticatorsdk.selfAuthenticator.IAuthenticationStatus
|
||||
import org.archiver.ArchivePreferenceConstants
|
||||
import org.archiver.ArchiveUtil.Companion.getPhoneNumberInTestMode
|
||||
import org.archiver.FCMConnector.Companion.initOfficialSignalFirebaseAccount
|
||||
import org.archiver.FCMConnector.Companion.initTeleMessageSignalFirebaseAccount
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
import org.intune.IntuneAuthManager
|
||||
import org.intune.IntuneAuthManager.continueIntuneAuthentication
|
||||
import org.intune.IntuneAuthManager.showDialog
|
||||
import org.intune.MDMDialogListener
|
||||
import org.selfAuthentication.SelfAuthenticatorManager.initAuthenticator
|
||||
import org.selfAuthentication.SelfAuthenticatorManager.startAuthenticationProcess
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.tm.archive.BuildConfig
|
||||
import org.tm.archive.R
|
||||
|
||||
const val TAG = "TM ConversationListFragment"
|
||||
open class ConversationListFragment : SignalConversationListFragment(), IAuthenticationStatus, IMDMAuthenticator /*TM_SA*/ {
|
||||
private var mAuthenticationProgressAlertDialogBuilder: AlertDialog.Builder? = null
|
||||
private var mAuthenticationProgressAlertDialog: AlertDialog? = null
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
Log.d(TAG, "onViewCreated")
|
||||
|
||||
|
||||
//**TM_SA**//Start
|
||||
if (CommonUtils.isActivatedUser(requireContext())) {
|
||||
WorkerIntentService.startJobIntentService(requireContext(), true) /*TM_SA*/
|
||||
} else {
|
||||
Log.d(TAG, "BuildConfig.APPLICATION_ID: " + BuildConfig.APPLICATION_ID)
|
||||
val authStatus = PrefManager.getIntPref(requireContext(), IntuneAuthManager.MDM_Auth_Status_String,
|
||||
IntuneAuthManager.MdmAuthStatus.START_SELF_AUTH.ordinal)
|
||||
Log.d(TAG,
|
||||
"onCreate -> authStatus = $authStatus. (0-signed, 1 -should intune auth, 2-self auth)")
|
||||
if (isMDM(requireContext()) && authStatus == IntuneAuthManager.MdmAuthStatus.START_INTUNE_AUTH.ordinal) { //if intune managed device, start MDM auth
|
||||
startIntuneAuth()
|
||||
} else { // else self auth
|
||||
startSelfAuth()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
Log.d(TAG, "onResume")
|
||||
if (!EventBus.getDefault().isRegistered(this)) {
|
||||
EventBus.getDefault().register(this)
|
||||
}
|
||||
}
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
Log.d(TAG, "onDestroy")
|
||||
if (EventBus.getDefault().isRegistered(this)) {
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
}
|
||||
|
||||
private fun startIntuneAuth() {
|
||||
Log.d(TAG, "startIntuneAuth")
|
||||
startMdm()
|
||||
}
|
||||
|
||||
fun startSelfAuth() {
|
||||
if (!CommonUtils.isActivatedUser(requireContext())) {
|
||||
initTeleMessageSignalFirebaseAccount(requireContext(), null, true)
|
||||
createAndShowAuthProgressDialog(requireContext(), true)
|
||||
startAuthenticationProcess(requireContext(),
|
||||
getPhoneNumberInTestMode(requireContext()),
|
||||
this)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun startMdm() {
|
||||
initTeleMessageSignalFirebaseAccount(requireContext(), null, true)
|
||||
startMDMAuthenticator(requireActivity(),
|
||||
getPhoneNumberInTestMode(requireContext()), BuildConfig.signal_teleMessage_version, this)
|
||||
}
|
||||
|
||||
override fun failureMDMAuth(reason: String) {
|
||||
val onCancel = "onCancel"
|
||||
Log.d("ConversationListFragment", "failureMDMAuth, reason: $reason")
|
||||
//MDMAuthenticator.INSTANCE.signOutUser(requireActivity());
|
||||
if (reason == onCancel) {
|
||||
showDialog(requireActivity(), object : MDMDialogListener {
|
||||
override fun startIntuneAgain() {
|
||||
startMdm()
|
||||
}
|
||||
})
|
||||
//update app that intune signed failed: two cases. 1. try intune auth again 2. move to self auth
|
||||
} else if (reason.contains("server") || reason.contains("Authentication failed") /*|| reason.contains("managerID")*/) { //try intune auth again
|
||||
PrefManager.setIntPref(requireContext(), IntuneAuthManager.MDM_Auth_Status_String, IntuneAuthManager.MdmAuthStatus.START_INTUNE_AUTH.ordinal)
|
||||
Log.d("ConversationListFragment", "status auth is 1")
|
||||
} else { //this case should pass to self-auth
|
||||
PrefManager.setIntPref(requireContext(), IntuneAuthManager.MDM_Auth_Status_String, IntuneAuthManager.MdmAuthStatus.START_SELF_AUTH.ordinal)
|
||||
Log.d("ConversationListFragment", "status auth is 2")
|
||||
startSelfAuth()
|
||||
}
|
||||
}
|
||||
|
||||
override fun successMDMAuth() {
|
||||
Log.d("ConversationListFragment", "successMDMAuth")
|
||||
val e164number = PrefManager.getStringPref(requireContext(), ArchivePreferenceConstants.PREF_KEY_DEVICE_PHONE_NUMBER)
|
||||
startIntuneAutoAuthentication(e164number)
|
||||
}
|
||||
|
||||
/**
|
||||
* intune
|
||||
* @param e164number
|
||||
*/
|
||||
private fun startIntuneAutoAuthentication(e164number: String) {
|
||||
Log.d(TAG, "startAutoAuthentication")
|
||||
initAuthenticator(e164number)
|
||||
continueIntuneAuthentication(this)
|
||||
}
|
||||
|
||||
|
||||
//**TM_SA**//Start
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEvent(event: UpdateEvent?) {
|
||||
if (event == null) {
|
||||
return
|
||||
}
|
||||
Log.d("ConversationListFragment", "UpdateEvent -> onEvent: " + event.type)
|
||||
if (event.type == UpdateEvent.EVENTS_TYPE.authProcess) {
|
||||
CommonUtils.setActivatedUser(requireContext(), false)
|
||||
startSelfAuth()
|
||||
}
|
||||
if (event.type == UpdateEvent.EVENTS_TYPE.suspension) {
|
||||
CommonUtils.setActivatedUser(requireContext(), false)
|
||||
} else if (event.type == UpdateEvent.EVENTS_TYPE.activated) {
|
||||
CommonUtils.setActivatedUser(requireContext(), true)
|
||||
// endAuthDialog()
|
||||
}
|
||||
if (event.type != UpdateEvent.EVENTS_TYPE.authProcess) {
|
||||
endAuthDialog()
|
||||
// SelfAuthenticatorManager.setProgressDialogVisibility(false)
|
||||
WorkerIntentService.startJobIntentService(requireContext())
|
||||
Log.d("ConversationListFragment", "SelfAuthenticator -> initOfficialSignalFirebaseAccount!!! ")
|
||||
initOfficialSignalFirebaseAccount(requireContext())
|
||||
}
|
||||
}
|
||||
|
||||
override fun authenticationProcessMessage(message: String) {
|
||||
Log.d("ConversationListFragment", "SelfAuthenticatorProcess -> authenticationProcessMessage = $message")
|
||||
if (!message.isEmpty()) {
|
||||
// EventBus.getDefault().post(new MessageEvent(SelfAuthenticatorConstants.Companion.getSelfAuthenticationFailed()));
|
||||
EventBus.getDefault().post(UpdateEvent(UpdateEvent.EVENTS_TYPE.suspension))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun createAndShowAuthProgressDialog(context: Context, isCanCancel: Boolean) {
|
||||
Log.d("SelfAuthenticatorManager","createAndShowAuthProgressDialog")
|
||||
if (mAuthenticationProgressAlertDialogBuilder == null) {
|
||||
mAuthenticationProgressAlertDialogBuilder = AlertDialog.Builder(context, R.style.AuthTmProgressDialog)
|
||||
val view = LayoutInflater.from(context).inflate(R.layout.progress_bar_layout_with_background, null)
|
||||
mAuthenticationProgressAlertDialogBuilder!!.setView(view)
|
||||
mAuthenticationProgressAlertDialogBuilder!!.setCancelable(isCanCancel)
|
||||
mAuthenticationProgressAlertDialog = mAuthenticationProgressAlertDialogBuilder!!.create()
|
||||
}
|
||||
|
||||
if (mAuthenticationProgressAlertDialog != null && !mAuthenticationProgressAlertDialog!!.isShowing) {
|
||||
mAuthenticationProgressAlertDialog!!.show()
|
||||
}
|
||||
}
|
||||
|
||||
private fun endAuthDialog() {
|
||||
Log.d("SelfAuthenticatorManager","endAuthDialog")
|
||||
if (mAuthenticationProgressAlertDialog != null) {
|
||||
mAuthenticationProgressAlertDialog!!.dismiss()
|
||||
mAuthenticationProgressAlertDialog = null
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true"
|
||||
tools:context=".registration.fragments.EnterPhoneNumberFragment"
|
||||
tools:viewBindingIgnore="true">
|
||||
<!--**TM_SA** add id to constraint layout-->
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/constraint_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:layoutDirection="ltr"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/verify_subheader">
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/country_code"
|
||||
style="@style/Widget.Signal.TextInputLayout.Registration.Dropdown"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:theme="@style/Signal.ThemeOverlay.TextInputLayout"
|
||||
app:errorEnabled="false"
|
||||
app:hintEnabled="false">
|
||||
|
||||
<com.google.android.material.textfield.MaterialAutoCompleteTextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:digits="+1234567890"
|
||||
android:drawablePadding="-24dp"
|
||||
android:hint="@string/Registration_country_code_entry_hint"
|
||||
android:imeOptions="actionNext"
|
||||
android:maxLength="4"
|
||||
android:maxLines="1"
|
||||
android:padding="0dp"
|
||||
android:singleLine="true"
|
||||
tools:text="+1" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/number"
|
||||
style="@style/Widget.Signal.TextInputLayout"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:hint="@string/RegistrationActivity_phone_number_description"
|
||||
app:materialThemeOverlay="@style/Signal.ThemeOverlay.TextInputLayout">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
style="@style/Widget.MaterialComponents.TextInputEditText.FilledBox"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="phone">
|
||||
|
||||
<requestFocus />
|
||||
</com.google.android.material.textfield.TextInputEditText>
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/verify_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:text="@string/RegistrationActivity_phone_number"
|
||||
android:textAppearance="@style/Signal.Text.HeadlineMedium"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/verify_subheader"
|
||||
style="@style/Signal.Text.BodyLarge"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="@string/RegistrationActivity_enter_your_phone_number_to_get_started"
|
||||
android:textColor="@color/signal_colorOnSurfaceVariant"
|
||||
app:layout_constraintTop_toBottomOf="@+id/verify_header"
|
||||
tools:layout_editor_absoluteX="0dp" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/cancel_button"
|
||||
style="@style/Signal.Widget.Button.Large.Secondary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="@android:string/cancel"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewMessage"
|
||||
style="@style/Signal.Text.BodyLarge"
|
||||
android:layout_width="316dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="64dp"
|
||||
android:text="@string/not_activated_user_dialog_message_not_first_sign_in"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/signal_colorOnSurfaceVariant"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/linearLayout" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</ScrollView>
|
|
@ -107,5 +107,10 @@
|
|||
<string name="intune_auth_message">Your device is under MDM. In order to use TM SGNL, please log in to Microsoft account</string>
|
||||
<string name="intune_auth_ok">OK</string>
|
||||
<string name="intune_auth_cancel">Cancel</string>
|
||||
<string name="OK">OK</string>
|
||||
<string name="DebugSendLogs">Send Logs</string>
|
||||
<string name="not_activated_user_dialog_title">Oops!</string>
|
||||
<string name="not_activated_user_dialog_message">TeleMessage couldn\'t locate your account. Please send logs to support and contact your system administrator.</string>
|
||||
<string name="not_activated_user_dialog_message_not_first_sign_in">TeleMessage couldn\'t locate your account. Please contact your system administrator.</string>
|
||||
<!-- endregion Telemessage -->
|
||||
</resources>
|
||||
|
|
21
app/src/tm/res/values/style.xml
Normal file
21
app/src/tm/res/values/style.xml
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2024 Signal Messenger, LLC
|
||||
~ SPDX-License-Identifier: AGPL-3.0-only
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<style name="Theme.TMessages.Dark" parent="@android:style/Theme.Holo">
|
||||
<item name="android:windowActionBar">false</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
<item name="android:windowActionBarOverlay">false</item>
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
<item name="android:colorBackground">@android:color/black</item>
|
||||
<item name="android:windowBackground">@android:color/black</item>
|
||||
<item name="android:gravity">center</item>
|
||||
<item name="android:layout_gravity">center</item>
|
||||
</style>
|
||||
|
||||
<style name="AuthTmProgressDialog" parent="Theme.TMessages.Dark">
|
||||
<item name="android:windowBackground">@android:color/black</item>
|
||||
</style>
|
||||
</resources>
|
Loading…
Add table
Add a link
Reference in a new issue