diff options
Diffstat (limited to 'telecomm/java/android')
-rw-r--r-- | telecomm/java/android/telecom/PhoneAccount.java | 15 | ||||
-rw-r--r-- | telecomm/java/android/telecom/PhoneAccountHandle.java | 39 |
2 files changed, 47 insertions, 7 deletions
diff --git a/telecomm/java/android/telecom/PhoneAccount.java b/telecomm/java/android/telecom/PhoneAccount.java index 6bd6a2f..052a481 100644 --- a/telecomm/java/android/telecom/PhoneAccount.java +++ b/telecomm/java/android/telecom/PhoneAccount.java @@ -105,6 +105,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). + * <p> + * See {@link #getCapabilities} + * @hide + */ + public static final int CAPABILITY_MULTI_USER = 0x20; + + /** * URI scheme for telephone number URIs. */ public static final String SCHEME_TEL = "tel"; @@ -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 7bcf147..97af41a 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<PhoneAccountHandle> CREATOR = new Creator<PhoneAccountHandle>() { @@ -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)); } } |