summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/assisteddialing/TransformationInfo.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/com/android/dialer/assisteddialing/TransformationInfo.java')
-rw-r--r--java/com/android/dialer/assisteddialing/TransformationInfo.java103
1 files changed, 103 insertions, 0 deletions
diff --git a/java/com/android/dialer/assisteddialing/TransformationInfo.java b/java/com/android/dialer/assisteddialing/TransformationInfo.java
new file mode 100644
index 000000000..7149d71cc
--- /dev/null
+++ b/java/com/android/dialer/assisteddialing/TransformationInfo.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dialer.assisteddialing;
+
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import com.google.auto.value.AutoValue;
+
+/**
+ * A container class to hold information related to the Assisted Dialing operation. All member
+ * variables must be set when constructing a new instance of this class.
+ */
+@AutoValue
+public abstract class TransformationInfo {
+ @NonNull private static final String ORIGINAL_NUBMER_KEY = "TRANSFORMATION_INFO_ORIGINAL_NUMBER";
+
+ @NonNull
+ private static final String TRANSFORMED_NUMBER_KEY = "TRANSFORMATION_INFO_TRANSFORMED_NUMBER";
+
+ @NonNull
+ private static final String USER_HOME_COUNTRY_CODE_KEY =
+ "TRANSFORMATION_INFO_USER_HOME_COUNTRY_CODE";
+
+ @NonNull
+ private static final String USER_ROAMING_COUNTRY_CODE_KEY =
+ "TRANSFORMATION_INFO_USER_ROAMING_COUNTRY_CODE";
+
+ @NonNull
+ private static final String TRANSFORMED_NUMBER_COUNTRY_CALLING_CODE_KEY =
+ "TRANSFORMED_NUMBER_COUNTRY_CALLING_CODE";
+
+ abstract String originalNumber();
+
+ abstract String transformedNumber();
+
+ abstract String userHomeCountryCode();
+
+ abstract String userRoamingCountryCode();
+
+ abstract int transformedNumberCountryCallingCode();
+
+ public static Builder builder() {
+ return new AutoValue_TransformationInfo.Builder();
+ }
+
+ @AutoValue.Builder
+ abstract static class Builder {
+ abstract Builder setOriginalNumber(String value);
+
+ abstract Builder setTransformedNumber(String value);
+
+ abstract Builder setUserHomeCountryCode(String value);
+
+ abstract Builder setUserRoamingCountryCode(String value);
+
+ abstract Builder setTransformedNumberCountryCallingCode(int value);
+
+ abstract TransformationInfo build();
+ }
+
+ public static TransformationInfo newInstanceFromBundle(@NonNull Bundle transformationInfoBundle) {
+
+ return TransformationInfo.builder()
+ .setOriginalNumber(transformationInfoBundle.getString(ORIGINAL_NUBMER_KEY))
+ .setTransformedNumber(transformationInfoBundle.getString(TRANSFORMED_NUMBER_KEY))
+ .setUserHomeCountryCode(transformationInfoBundle.getString(USER_HOME_COUNTRY_CODE_KEY))
+ .setUserRoamingCountryCode(
+ transformationInfoBundle.getString(USER_ROAMING_COUNTRY_CODE_KEY))
+ .setTransformedNumberCountryCallingCode(
+ transformationInfoBundle.getInt(TRANSFORMED_NUMBER_COUNTRY_CALLING_CODE_KEY))
+ .build();
+ }
+
+ /**
+ * Callers are not expected to directly use this bundle. The bundle is provided for IPC purposes.
+ * Callers wishing to use the data should call newInstanceFromBundle with the bundle to get a
+ * usable POJO.
+ */
+ public Bundle toBundle() {
+ Bundle assistedDialingExtras = new Bundle();
+ assistedDialingExtras.putString(ORIGINAL_NUBMER_KEY, originalNumber());
+ assistedDialingExtras.putString(TRANSFORMED_NUMBER_KEY, transformedNumber());
+ assistedDialingExtras.putString(USER_HOME_COUNTRY_CODE_KEY, userHomeCountryCode());
+ assistedDialingExtras.putString(USER_ROAMING_COUNTRY_CODE_KEY, userRoamingCountryCode());
+ assistedDialingExtras.putInt(
+ TRANSFORMED_NUMBER_COUNTRY_CALLING_CODE_KEY, transformedNumberCountryCallingCode());
+ return assistedDialingExtras;
+ }
+}