Merge "Associate a UserHandle with each PhoneAccountHandle" into lmp-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
59dac0e192
@@ -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).
|
||||
* <p>
|
||||
* 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}.
|
||||
*
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user