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