use of com.android.dialer.common.PerAccountSharedPreferences in project android_packages_apps_Dialer by LineageOS.
the class LegacyVoicemailNotificationReceiver method hasVoicemailCountChanged.
private static boolean hasVoicemailCountChanged(Context context, PhoneAccountHandle phoneAccountHandle, int newCount) {
// Need credential encrypted storage to access preferences.
if (!UserManagerCompat.isUserUnlocked(context)) {
LogUtil.i("LegacyVoicemailNotificationReceiver.onReceive", "User locked, bypassing voicemail count check");
return true;
}
if (newCount == -1) {
// Carrier does not report voicemail count
return true;
}
PerAccountSharedPreferences preferences = new PerAccountSharedPreferences(context, phoneAccountHandle, PreferenceManager.getDefaultSharedPreferences(context));
// Carriers may send multiple notifications for the same voicemail.
if (newCount != 0 && newCount == preferences.getInt(LEGACY_VOICEMAIL_COUNT, -1)) {
return false;
}
preferences.edit().putInt(LEGACY_VOICEMAIL_COUNT, newCount).apply();
return true;
}
use of com.android.dialer.common.PerAccountSharedPreferences in project android_packages_apps_Dialer by LineageOS.
the class VvmAccountManager method isAccountActivated.
public static boolean isAccountActivated(Context context, PhoneAccountHandle phoneAccount) {
Assert.isNotNull(phoneAccount);
PerAccountSharedPreferences preferences = getPreferenceForActivationState(context, phoneAccount);
migrateActivationState(context, preferences, phoneAccount);
return preferences.getBoolean(IS_ACCOUNT_ACTIVATED, false);
}
use of com.android.dialer.common.PerAccountSharedPreferences in project android_packages_apps_Dialer by LineageOS.
the class VvmAccountManager method migrateActivationState.
/**
* The activation state is moved from credential protected storage to device protected storage
* after v10, so it can be checked under FBE. The state should be migrated to avoid reactivation.
*/
private static void migrateActivationState(Context context, PerAccountSharedPreferences deviceProtectedPreference, PhoneAccountHandle phoneAccountHandle) {
if (!context.getSystemService(UserManager.class).isUserUnlocked()) {
return;
}
if (deviceProtectedPreference.contains(IS_ACCOUNT_ACTIVATED)) {
return;
}
PerAccountSharedPreferences credentialProtectedPreference = new VisualVoicemailPreferences(context, phoneAccountHandle);
deviceProtectedPreference.edit().putBoolean(IS_ACCOUNT_ACTIVATED, credentialProtectedPreference.getBoolean(IS_ACCOUNT_ACTIVATED, false)).apply();
}
use of com.android.dialer.common.PerAccountSharedPreferences in project android_packages_apps_Dialer by LineageOS.
the class OmtpVoicemailMessageCreator method createInboxErrorMessage.
@Nullable
private static VoicemailErrorMessage createInboxErrorMessage(Context context, VoicemailStatus status, VoicemailStatusReader statusReader) {
float voicemailOccupiedFraction = (float) status.quotaOccupied / (float) status.quotaTotal;
if (voicemailOccupiedFraction < QUOTA_NEAR_FULL_THRESHOLD) {
return null;
}
boolean isFull = voicemailOccupiedFraction >= QUOTA_FULL_THRESHOLD;
PhoneAccountHandle phoneAccountHandle = status.getPhoneAccountHandle();
PerAccountSharedPreferences sharedPreferenceForAccount = new PerAccountSharedPreferences(context, phoneAccountHandle, PreferenceManager.getDefaultSharedPreferences(context));
VoicemailClient voicemailClient = VoicemailComponent.get(context).getVoicemailClient();
boolean shouldShowPromoForArchive = !isPromoForArchiveDismissed(sharedPreferenceForAccount, isFull) && !voicemailClient.isVoicemailArchiveEnabled(context, phoneAccountHandle) && voicemailClient.isVoicemailArchiveAvailable(context);
if (!shouldShowPromoForArchive) {
if (isFull) {
Logger.get(context).logImpression(DialerImpression.Type.VVM_USER_SHOWN_VM_FULL_ERROR_MESSAGE);
return new VoicemailErrorMessage(context.getString(R.string.voicemail_error_inbox_full_title), context.getString(R.string.voicemail_error_inbox_full_message));
} else {
Logger.get(context).logImpression(DialerImpression.Type.VVM_USER_SHOWN_VM_ALMOST_FULL_ERROR_MESSAGE);
return new VoicemailErrorMessage(context.getString(R.string.voicemail_error_inbox_near_full_title), context.getString(R.string.voicemail_error_inbox_near_full_message));
}
}
String title;
CharSequence message;
DialerImpression.Type enabledImpression;
DialerImpression.Type dismissedImpression;
String dismissedKey;
if (isFull) {
Logger.get(context).logImpression(DialerImpression.Type.VVM_USER_SHOWN_VM_FULL_PROMO);
title = context.getString(R.string.voicemail_error_inbox_full_turn_archive_on_title);
message = context.getText(R.string.voicemail_error_inbox_full_turn_archive_on_message);
enabledImpression = DialerImpression.Type.VVM_USER_ENABLED_ARCHIVE_FROM_VM_FULL_PROMO;
dismissedImpression = DialerImpression.Type.VVM_USER_DISMISSED_VM_FULL_PROMO;
dismissedKey = VOICEMAIL_PROMO_DISMISSED_KEY;
} else {
Logger.get(context).logImpression(DialerImpression.Type.VVM_USER_SHOWN_VM_ALMOST_FULL_PROMO);
title = context.getString(R.string.voicemail_error_inbox_almost_full_turn_archive_on_title);
message = context.getText(R.string.voicemail_error_inbox_almost_full_turn_archive_on_message);
enabledImpression = DialerImpression.Type.VVM_USER_ENABLED_ARCHIVE_FROM_VM_ALMOST_FULL_PROMO;
dismissedImpression = DialerImpression.Type.VVM_USER_DISMISSED_VM_ALMOST_FULL_PROMO;
dismissedKey = VOICEMAIL_PROMO_ALMOST_FULL_DISMISSED_KEY;
}
return createVMQuotaPromo(context, phoneAccountHandle, status, statusReader, voicemailClient, sharedPreferenceForAccount, title, message, enabledImpression, dismissedImpression, dismissedKey);
}
Aggregations