summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/com/android/contacts/common/widget/SelectPhoneAccountDialogOptionsUtil.java24
-rw-r--r--java/com/android/contacts/common/widget/select_phone_account_dialog_options.proto2
-rw-r--r--java/com/android/dialer/telecom/TelecomUtil.java15
3 files changed, 39 insertions, 2 deletions
diff --git a/java/com/android/contacts/common/widget/SelectPhoneAccountDialogOptionsUtil.java b/java/com/android/contacts/common/widget/SelectPhoneAccountDialogOptionsUtil.java
index 5a44ae7f8..1880d6538 100644
--- a/java/com/android/contacts/common/widget/SelectPhoneAccountDialogOptionsUtil.java
+++ b/java/com/android/contacts/common/widget/SelectPhoneAccountDialogOptionsUtil.java
@@ -16,9 +16,15 @@
package com.android.contacts.common.widget;
+import android.os.Parcel;
+import android.os.UserHandle;
+import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import com.android.dialer.common.Assert;
import com.android.dialer.telecom.TelecomUtil;
+
+import com.google.protobuf.ByteString;
+
import java.util.Collection;
/** Provides common operation on a {@link SelectPhoneAccountDialogOptions} */
@@ -27,9 +33,21 @@ public final class SelectPhoneAccountDialogOptionsUtil {
public static PhoneAccountHandle getPhoneAccountHandle(
SelectPhoneAccountDialogOptions.Entry entry) {
+ UserHandle userHandle;
+ Parcel parcel = Parcel.obtain();
+ try {
+ byte[] marshalledUserHandle = entry.getUserHandle().toByteArray();
+ parcel.unmarshall(marshalledUserHandle, 0, marshalledUserHandle.length);
+ parcel.setDataPosition(0);
+ userHandle = parcel.readParcelable(UserHandle.class.getClassLoader());
+ } catch (NullPointerException e) {
+ userHandle = null;
+ }
+ parcel.recycle();
return Assert.isNotNull(
TelecomUtil.composePhoneAccountHandle(
- entry.getPhoneAccountHandleComponentName(), entry.getPhoneAccountHandleId()));
+ entry.getPhoneAccountHandleComponentName(), entry.getPhoneAccountHandleId(),
+ userHandle));
}
public static SelectPhoneAccountDialogOptions.Entry.Builder setPhoneAccountHandle(
@@ -38,6 +56,10 @@ public final class SelectPhoneAccountDialogOptionsUtil {
entryBuilder.setPhoneAccountHandleComponentName(
phoneAccountHandle.getComponentName().flattenToString());
entryBuilder.setPhoneAccountHandleId(phoneAccountHandle.getId());
+ Parcel parcel = Parcel.obtain();
+ parcel.writeParcelable(phoneAccountHandle.getUserHandle(), 0);
+ entryBuilder.setUserHandle(ByteString.copyFrom(parcel.marshall()));
+ parcel.recycle();
return entryBuilder;
}
diff --git a/java/com/android/contacts/common/widget/select_phone_account_dialog_options.proto b/java/com/android/contacts/common/widget/select_phone_account_dialog_options.proto
index f96e31f2e..fc443f0cd 100644
--- a/java/com/android/contacts/common/widget/select_phone_account_dialog_options.proto
+++ b/java/com/android/contacts/common/widget/select_phone_account_dialog_options.proto
@@ -49,5 +49,7 @@ message SelectPhoneAccountDialogOptions {
// in a call so the other SIM cannot be used. Hint should also be set to
// inform the user why the account is unavailable.
optional bool enabled = 4 [default = true];
+
+ optional bytes user_handle = 5;
}
} \ No newline at end of file
diff --git a/java/com/android/dialer/telecom/TelecomUtil.java b/java/com/android/dialer/telecom/TelecomUtil.java
index c08814688..633a53e8b 100644
--- a/java/com/android/dialer/telecom/TelecomUtil.java
+++ b/java/com/android/dialer/telecom/TelecomUtil.java
@@ -25,6 +25,7 @@ import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
+import android.os.UserHandle;
import android.provider.CallLog.Calls;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@@ -169,6 +170,14 @@ public abstract class TelecomUtil {
@Nullable
public static PhoneAccountHandle composePhoneAccountHandle(
@Nullable String componentString, @Nullable String accountId) {
+ return composePhoneAccountHandle(componentString, accountId, null);
+ }
+
+ /** Compose {@link PhoneAccountHandle} object from component name, account id and user handle. */
+ @Nullable
+ public static PhoneAccountHandle composePhoneAccountHandle(
+ @Nullable String componentString, @Nullable String accountId,
+ @Nullable UserHandle userHandle) {
if (TextUtils.isEmpty(componentString) || TextUtils.isEmpty(accountId)) {
return null;
}
@@ -176,7 +185,11 @@ public abstract class TelecomUtil {
if (componentName == null) {
return null;
}
- return new PhoneAccountHandle(componentName, accountId);
+ if (userHandle == null) {
+ return new PhoneAccountHandle(componentName, accountId);
+ } else {
+ return new PhoneAccountHandle(componentName, accountId, userHandle);
+ }
}
/**