diff --git a/telecomm/java/android/telecom/PhoneAccount.java b/telecomm/java/android/telecom/PhoneAccount.java index 6bd6a2f6bc25e..052a481f1ab28 100644 --- a/telecomm/java/android/telecom/PhoneAccount.java +++ b/telecomm/java/android/telecom/PhoneAccount.java @@ -104,6 +104,15 @@ public class PhoneAccount implements Parcelable { */ public static final int CAPABILITY_PLACE_EMERGENCY_CALLS = 0x10; + /** + * Flag indicating that this {@code PhoneAccount} is capable of being used by all users. This + * should only be used by system apps (and will be ignored for all other apps trying to use it). + *

+ * See {@link #getCapabilities} + * @hide + */ + public static final int CAPABILITY_MULTI_USER = 0x20; + /** * URI scheme for telephone number URIs. */ @@ -193,6 +202,12 @@ public class PhoneAccount implements Parcelable { mSupportedUriSchemes.addAll(phoneAccount.getSupportedUriSchemes()); } + /** @hide */ + public Builder setAccountHandle(PhoneAccountHandle accountHandle) { + mAccountHandle = accountHandle; + return this; + } + /** * Sets the address. See {@link PhoneAccount#getAddress}. * diff --git a/telecomm/java/android/telecom/PhoneAccountHandle.java b/telecomm/java/android/telecom/PhoneAccountHandle.java index 7bcf1472f9ee0..97af41afd31aa 100644 --- a/telecomm/java/android/telecom/PhoneAccountHandle.java +++ b/telecomm/java/android/telecom/PhoneAccountHandle.java @@ -20,6 +20,8 @@ import android.annotation.SystemApi; import android.content.ComponentName; import android.os.Parcel; import android.os.Parcelable; +import android.os.Process; +import android.os.UserHandle; import java.util.Objects; @@ -38,14 +40,24 @@ import java.util.Objects; */ @SystemApi public class PhoneAccountHandle implements Parcelable { - private ComponentName mComponentName; - private String mId; + private final ComponentName mComponentName; + private final String mId; + private final UserHandle mUserHandle; public PhoneAccountHandle( ComponentName componentName, String id) { + this(componentName, id, Process.myUserHandle()); + } + + /** @hide */ + public PhoneAccountHandle( + ComponentName componentName, + String id, + UserHandle userHandle) { mComponentName = componentName; mId = id; + mUserHandle = userHandle; } /** @@ -76,9 +88,17 @@ public class PhoneAccountHandle implements Parcelable { return mId; } + /** + * @return the {@link UserHandle} to use when connecting to this PhoneAccount. + * @hide + */ + public UserHandle getUserHandle() { + return mUserHandle; + } + @Override public int hashCode() { - return Objects.hashCode(mComponentName) + Objects.hashCode(mId); + return Objects.hash(mComponentName, mId, mUserHandle); } @Override @@ -88,6 +108,8 @@ public class PhoneAccountHandle implements Parcelable { return new StringBuilder().append(mComponentName) .append(", ") .append(Log.pii(mId)) + .append(", ") + .append(mUserHandle) .toString(); } @@ -97,7 +119,8 @@ public class PhoneAccountHandle implements Parcelable { other instanceof PhoneAccountHandle && Objects.equals(((PhoneAccountHandle) other).getComponentName(), getComponentName()) && - Objects.equals(((PhoneAccountHandle) other).getId(), getId()); + Objects.equals(((PhoneAccountHandle) other).getId(), getId()) && + Objects.equals(((PhoneAccountHandle) other).getUserHandle(), getUserHandle()); } // @@ -111,8 +134,9 @@ public class PhoneAccountHandle implements Parcelable { @Override public void writeToParcel(Parcel out, int flags) { - out.writeParcelable(mComponentName, flags); + mComponentName.writeToParcel(out, flags); out.writeString(mId); + mUserHandle.writeToParcel(out, flags); } public static final Creator CREATOR = new Creator() { @@ -128,7 +152,8 @@ public class PhoneAccountHandle implements Parcelable { }; private PhoneAccountHandle(Parcel in) { - mComponentName = in.readParcelable(getClass().getClassLoader()); - mId = in.readString(); + this(ComponentName.CREATOR.createFromParcel(in), + in.readString(), + UserHandle.CREATOR.createFromParcel(in)); } }