use of com.android.dialer.voicemail.model.VoicemailEntry in project android_packages_apps_Dialer by LineageOS.
the class VoicemailCursorLoader method toVoicemailEntry.
/**
* Creates a new {@link VoicemailEntry} from the provided cursor using the current position.
*/
static VoicemailEntry toVoicemailEntry(Cursor cursor) {
DialerPhoneNumber number;
try {
number = DialerPhoneNumber.parseFrom(cursor.getBlob(NUMBER));
} catch (InvalidProtocolBufferException e) {
throw new IllegalStateException("Couldn't parse DialerPhoneNumber bytes");
}
NumberAttributes numberAttributes;
try {
numberAttributes = NumberAttributes.parseFrom(cursor.getBlob(NUMBER_ATTRIBUTES));
} catch (InvalidProtocolBufferException e) {
throw new IllegalStateException("Couldn't parse NumberAttributes bytes");
}
// Voicemail numbers should always be valid so the CP2 information should never be incomplete,
// and there should be no need to query PhoneLookup at render time.
Assert.checkArgument(!numberAttributes.getIsCp2InfoIncomplete(), "CP2 info incomplete for number: %s", LogUtil.sanitizePii(number.getNormalizedNumber()));
VoicemailEntry.Builder voicemailEntryBuilder = VoicemailEntry.newBuilder().setId(cursor.getInt(ID)).setTimestamp(cursor.getLong(TIMESTAMP)).setNumber(number).setDuration(cursor.getLong(DURATION)).setCallType(cursor.getInt(CALL_TYPE)).setIsRead(cursor.getInt(IS_READ)).setNumberAttributes(numberAttributes).setTranscriptionState(cursor.getInt(TRANSCRIPTION_STATE));
String formattedNumber = cursor.getString(FORMATTED_NUMBER);
if (!TextUtils.isEmpty(formattedNumber)) {
voicemailEntryBuilder.setFormattedNumber(formattedNumber);
}
String geocodedLocation = cursor.getString(GEOCODED_LOCATION);
if (!TextUtils.isEmpty(geocodedLocation)) {
voicemailEntryBuilder.setGeocodedLocation(geocodedLocation);
}
String transcription = cursor.getString(TRANSCRIPTION);
if (!TextUtils.isEmpty(transcription)) {
voicemailEntryBuilder.setTranscription(transcription);
}
String voicemailUri = cursor.getString(VOICEMAIL_URI);
if (!TextUtils.isEmpty(voicemailUri)) {
voicemailEntryBuilder.setVoicemailUri(voicemailUri);
}
String phoneAccountComponentName = cursor.getString(PHONE_ACCOUNT_COMPONENT_NAME);
if (!TextUtils.isEmpty(phoneAccountComponentName)) {
voicemailEntryBuilder.setPhoneAccountComponentName(phoneAccountComponentName);
}
String phoneAccountId = cursor.getString(PHONE_ACCOUNT_ID);
if (!TextUtils.isEmpty(phoneAccountId)) {
voicemailEntryBuilder.setPhoneAccountId(phoneAccountId);
}
return voicemailEntryBuilder.build();
}
Aggregations