1 package org.robolectric.shadows; 2 3 import android.annotation.Nullable; 4 import android.os.Build.VERSION_CODES; 5 import android.os.Bundle; 6 import android.os.Parcel; 7 import android.os.Parcelable.Creator; 8 import android.telecom.PhoneAccountHandle; 9 import android.telephony.VisualVoicemailSms; 10 import org.robolectric.annotation.Implementation; 11 import org.robolectric.annotation.Implements; 12 import org.robolectric.shadow.api.Shadow; 13 import org.robolectric.util.ReflectionHelpers; 14 15 @Implements(value = VisualVoicemailSms.class, minSdk = VERSION_CODES.O) 16 public class ShadowVisualVoicemailSms { 17 private PhoneAccountHandle phoneAccountHandle; 18 19 @Nullable private String prefix; 20 21 @Nullable private Bundle fields; 22 23 private String messageBody; 24 25 @Implementation __staticInitializer__()26 protected static void __staticInitializer__() { 27 ReflectionHelpers.setStaticField( 28 VisualVoicemailSms.class, "CREATOR", ShadowVisualVoicemailSms.CREATOR); 29 } 30 31 @Implementation getPhoneAccountHandle()32 protected PhoneAccountHandle getPhoneAccountHandle() { 33 return phoneAccountHandle; 34 } 35 setPhoneAccountHandle(PhoneAccountHandle phoneAccountHandle)36 public ShadowVisualVoicemailSms setPhoneAccountHandle(PhoneAccountHandle phoneAccountHandle) { 37 this.phoneAccountHandle = phoneAccountHandle; 38 return this; 39 } 40 41 @Implementation getPrefix()42 protected String getPrefix() { 43 return prefix; 44 } 45 setPrefix(String prefix)46 public ShadowVisualVoicemailSms setPrefix(String prefix) { 47 this.prefix = prefix; 48 return this; 49 } 50 51 @Implementation getFields()52 protected Bundle getFields() { 53 return fields; 54 } 55 setFields(Bundle fields)56 public ShadowVisualVoicemailSms setFields(Bundle fields) { 57 this.fields = fields; 58 return this; 59 } 60 61 @Implementation getMessageBody()62 protected String getMessageBody() { 63 return messageBody; 64 } 65 setMessageBody(String messageBody)66 public ShadowVisualVoicemailSms setMessageBody(String messageBody) { 67 this.messageBody = messageBody; 68 return this; 69 } 70 71 public static final Creator<VisualVoicemailSms> CREATOR = 72 new Creator<VisualVoicemailSms>() { 73 @Override 74 public VisualVoicemailSms createFromParcel(Parcel in) { 75 VisualVoicemailSms sms = Shadow.newInstanceOf(VisualVoicemailSms.class); 76 ShadowVisualVoicemailSms shadowSms = Shadow.extract(sms); 77 shadowSms 78 .setPhoneAccountHandle(in.readParcelable(PhoneAccountHandle.class.getClassLoader())) 79 .setPrefix(in.readString()) 80 .setFields(in.readBundle()) 81 .setMessageBody(in.readString()); 82 return sms; 83 } 84 85 @Override 86 public VisualVoicemailSms[] newArray(int size) { 87 return new VisualVoicemailSms[size]; 88 } 89 }; 90 91 @Implementation describeContents()92 protected int describeContents() { 93 return 0; 94 } 95 96 @Implementation writeToParcel(Parcel dest, int flags)97 protected void writeToParcel(Parcel dest, int flags) { 98 dest.writeParcelable(getPhoneAccountHandle(), flags); 99 dest.writeString(getPrefix()); 100 dest.writeBundle(getFields()); 101 dest.writeString(getMessageBody()); 102 } 103 } 104