From d5e47f6da5b08b13ecdfa7f1edc7e12aeb83fab9 Mon Sep 17 00:00:00 2001 From: Eric Erfanian Date: Wed, 15 Mar 2017 14:41:07 -0700 Subject: Update Dialer source from latest green build. * Refactor voicemail component * Add new enriched calling components Test: treehugger, manual aosp testing Change-Id: I521a0f86327d4b42e14d93927c7d613044ed5942 --- .../dialer/simulator/SimulatorComponent.java | 46 ++++ .../impl/AutoValue_SimulatorCallLog_CallEntry.java | 160 -------------- .../impl/AutoValue_SimulatorContacts_Contact.java | 231 --------------------- .../AutoValue_SimulatorVoicemail_Voicemail.java | 184 ---------------- .../dialer/simulator/impl/SimulatorCallLog.java | 6 +- .../dialer/simulator/impl/SimulatorContacts.java | 6 +- .../dialer/simulator/impl/SimulatorImpl.java | 40 ++++ .../dialer/simulator/impl/SimulatorModule.java | 22 +- .../dialer/simulator/impl/SimulatorVoicemail.java | 6 +- 9 files changed, 104 insertions(+), 597 deletions(-) create mode 100644 java/com/android/dialer/simulator/SimulatorComponent.java delete mode 100644 java/com/android/dialer/simulator/impl/AutoValue_SimulatorCallLog_CallEntry.java delete mode 100644 java/com/android/dialer/simulator/impl/AutoValue_SimulatorContacts_Contact.java delete mode 100644 java/com/android/dialer/simulator/impl/AutoValue_SimulatorVoicemail_Voicemail.java create mode 100644 java/com/android/dialer/simulator/impl/SimulatorImpl.java (limited to 'java/com/android/dialer/simulator') diff --git a/java/com/android/dialer/simulator/SimulatorComponent.java b/java/com/android/dialer/simulator/SimulatorComponent.java new file mode 100644 index 000000000..a16592e34 --- /dev/null +++ b/java/com/android/dialer/simulator/SimulatorComponent.java @@ -0,0 +1,46 @@ +/* + * 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.simulator; + +import android.content.Context; +import dagger.Subcomponent; +import com.android.dialer.simulator.impl.SimulatorImpl; + +/** Subcomponent that can be used to access the simulator implementation. */ +public class SimulatorComponent { + private static SimulatorComponent instance; + private Simulator simulator; + + public Simulator getSimulator() { + if (simulator == null) { + simulator = new SimulatorImpl(); + } + return simulator; + } + + public static SimulatorComponent get(Context context) { + if (instance == null) { + instance = new SimulatorComponent(); + } + return instance; + } + + /** Used to refer to the root application component. */ + public interface HasComponent { + SimulatorComponent simulatorComponent(); + } +} diff --git a/java/com/android/dialer/simulator/impl/AutoValue_SimulatorCallLog_CallEntry.java b/java/com/android/dialer/simulator/impl/AutoValue_SimulatorCallLog_CallEntry.java deleted file mode 100644 index 591819819..000000000 --- a/java/com/android/dialer/simulator/impl/AutoValue_SimulatorCallLog_CallEntry.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * 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.simulator.impl; - -import android.support.annotation.NonNull; -import javax.annotation.Generated; - -@Generated("com.google.auto.value.processor.AutoValueProcessor") - final class AutoValue_SimulatorCallLog_CallEntry extends SimulatorCallLog.CallEntry { - - private final String number; - private final int type; - private final int presentation; - private final long timeMillis; - - private AutoValue_SimulatorCallLog_CallEntry( - String number, - int type, - int presentation, - long timeMillis) { - this.number = number; - this.type = type; - this.presentation = presentation; - this.timeMillis = timeMillis; - } - - @NonNull - @Override - String getNumber() { - return number; - } - - @Override - int getType() { - return type; - } - - @Override - int getPresentation() { - return presentation; - } - - @Override - long getTimeMillis() { - return timeMillis; - } - - @Override - public String toString() { - return "CallEntry{" - + "number=" + number + ", " - + "type=" + type + ", " - + "presentation=" + presentation + ", " - + "timeMillis=" + timeMillis - + "}"; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof SimulatorCallLog.CallEntry) { - SimulatorCallLog.CallEntry that = (SimulatorCallLog.CallEntry) o; - return (this.number.equals(that.getNumber())) - && (this.type == that.getType()) - && (this.presentation == that.getPresentation()) - && (this.timeMillis == that.getTimeMillis()); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= this.number.hashCode(); - h *= 1000003; - h ^= this.type; - h *= 1000003; - h ^= this.presentation; - h *= 1000003; - h ^= (this.timeMillis >>> 32) ^ this.timeMillis; - return h; - } - - static final class Builder extends SimulatorCallLog.CallEntry.Builder { - private String number; - private Integer type; - private Integer presentation; - private Long timeMillis; - Builder() { - } - private Builder(SimulatorCallLog.CallEntry source) { - this.number = source.getNumber(); - this.type = source.getType(); - this.presentation = source.getPresentation(); - this.timeMillis = source.getTimeMillis(); - } - @Override - SimulatorCallLog.CallEntry.Builder setNumber(String number) { - this.number = number; - return this; - } - @Override - SimulatorCallLog.CallEntry.Builder setType(int type) { - this.type = type; - return this; - } - @Override - SimulatorCallLog.CallEntry.Builder setPresentation(int presentation) { - this.presentation = presentation; - return this; - } - @Override - SimulatorCallLog.CallEntry.Builder setTimeMillis(long timeMillis) { - this.timeMillis = timeMillis; - return this; - } - @Override - SimulatorCallLog.CallEntry build() { - String missing = ""; - if (this.number == null) { - missing += " number"; - } - if (this.type == null) { - missing += " type"; - } - if (this.presentation == null) { - missing += " presentation"; - } - if (this.timeMillis == null) { - missing += " timeMillis"; - } - if (!missing.isEmpty()) { - throw new IllegalStateException("Missing required properties:" + missing); - } - return new AutoValue_SimulatorCallLog_CallEntry( - this.number, - this.type, - this.presentation, - this.timeMillis); - } - } - -} diff --git a/java/com/android/dialer/simulator/impl/AutoValue_SimulatorContacts_Contact.java b/java/com/android/dialer/simulator/impl/AutoValue_SimulatorContacts_Contact.java deleted file mode 100644 index 00295f359..000000000 --- a/java/com/android/dialer/simulator/impl/AutoValue_SimulatorContacts_Contact.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * 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.simulator.impl; - -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import java.io.ByteArrayOutputStream; -import java.util.List; -import javax.annotation.Generated; - -@Generated("com.google.auto.value.processor.AutoValueProcessor") - final class AutoValue_SimulatorContacts_Contact extends SimulatorContacts.Contact { - - private final String accountType; - private final String accountName; - private final String name; - private final boolean isStarred; - private final ByteArrayOutputStream photoStream; - private final List phoneNumbers; - private final List emails; - - private AutoValue_SimulatorContacts_Contact( - String accountType, - String accountName, - @Nullable String name, - boolean isStarred, - @Nullable ByteArrayOutputStream photoStream, - List phoneNumbers, - List emails) { - this.accountType = accountType; - this.accountName = accountName; - this.name = name; - this.isStarred = isStarred; - this.photoStream = photoStream; - this.phoneNumbers = phoneNumbers; - this.emails = emails; - } - - @NonNull - @Override - String getAccountType() { - return accountType; - } - - @NonNull - @Override - String getAccountName() { - return accountName; - } - - @Nullable - @Override - String getName() { - return name; - } - - @Override - boolean getIsStarred() { - return isStarred; - } - - @Nullable - @Override - ByteArrayOutputStream getPhotoStream() { - return photoStream; - } - - @NonNull - @Override - List getPhoneNumbers() { - return phoneNumbers; - } - - @NonNull - @Override - List getEmails() { - return emails; - } - - @Override - public String toString() { - return "Contact{" - + "accountType=" + accountType + ", " - + "accountName=" + accountName + ", " - + "name=" + name + ", " - + "isStarred=" + isStarred + ", " - + "photoStream=" + photoStream + ", " - + "phoneNumbers=" + phoneNumbers + ", " - + "emails=" + emails - + "}"; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof SimulatorContacts.Contact) { - SimulatorContacts.Contact that = (SimulatorContacts.Contact) o; - return (this.accountType.equals(that.getAccountType())) - && (this.accountName.equals(that.getAccountName())) - && ((this.name == null) ? (that.getName() == null) : this.name.equals(that.getName())) - && (this.isStarred == that.getIsStarred()) - && ((this.photoStream == null) ? (that.getPhotoStream() == null) : this.photoStream.equals(that.getPhotoStream())) - && (this.phoneNumbers.equals(that.getPhoneNumbers())) - && (this.emails.equals(that.getEmails())); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= this.accountType.hashCode(); - h *= 1000003; - h ^= this.accountName.hashCode(); - h *= 1000003; - h ^= (name == null) ? 0 : this.name.hashCode(); - h *= 1000003; - h ^= this.isStarred ? 1231 : 1237; - h *= 1000003; - h ^= (photoStream == null) ? 0 : this.photoStream.hashCode(); - h *= 1000003; - h ^= this.phoneNumbers.hashCode(); - h *= 1000003; - h ^= this.emails.hashCode(); - return h; - } - - static final class Builder extends SimulatorContacts.Contact.Builder { - private String accountType; - private String accountName; - private String name; - private Boolean isStarred; - private ByteArrayOutputStream photoStream; - private List phoneNumbers; - private List emails; - Builder() { - } - private Builder(SimulatorContacts.Contact source) { - this.accountType = source.getAccountType(); - this.accountName = source.getAccountName(); - this.name = source.getName(); - this.isStarred = source.getIsStarred(); - this.photoStream = source.getPhotoStream(); - this.phoneNumbers = source.getPhoneNumbers(); - this.emails = source.getEmails(); - } - @Override - SimulatorContacts.Contact.Builder setAccountType(String accountType) { - this.accountType = accountType; - return this; - } - @Override - SimulatorContacts.Contact.Builder setAccountName(String accountName) { - this.accountName = accountName; - return this; - } - @Override - SimulatorContacts.Contact.Builder setName(@Nullable String name) { - this.name = name; - return this; - } - @Override - SimulatorContacts.Contact.Builder setIsStarred(boolean isStarred) { - this.isStarred = isStarred; - return this; - } - @Override - SimulatorContacts.Contact.Builder setPhotoStream(@Nullable ByteArrayOutputStream photoStream) { - this.photoStream = photoStream; - return this; - } - @Override - SimulatorContacts.Contact.Builder setPhoneNumbers(List phoneNumbers) { - this.phoneNumbers = phoneNumbers; - return this; - } - @Override - SimulatorContacts.Contact.Builder setEmails(List emails) { - this.emails = emails; - return this; - } - @Override - SimulatorContacts.Contact build() { - String missing = ""; - if (this.accountType == null) { - missing += " accountType"; - } - if (this.accountName == null) { - missing += " accountName"; - } - if (this.isStarred == null) { - missing += " isStarred"; - } - if (this.phoneNumbers == null) { - missing += " phoneNumbers"; - } - if (this.emails == null) { - missing += " emails"; - } - if (!missing.isEmpty()) { - throw new IllegalStateException("Missing required properties:" + missing); - } - return new AutoValue_SimulatorContacts_Contact( - this.accountType, - this.accountName, - this.name, - this.isStarred, - this.photoStream, - this.phoneNumbers, - this.emails); - } - } - -} diff --git a/java/com/android/dialer/simulator/impl/AutoValue_SimulatorVoicemail_Voicemail.java b/java/com/android/dialer/simulator/impl/AutoValue_SimulatorVoicemail_Voicemail.java deleted file mode 100644 index 58934801c..000000000 --- a/java/com/android/dialer/simulator/impl/AutoValue_SimulatorVoicemail_Voicemail.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * 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.simulator.impl; - -import android.support.annotation.NonNull; -import javax.annotation.Generated; - -@Generated("com.google.auto.value.processor.AutoValueProcessor") - final class AutoValue_SimulatorVoicemail_Voicemail extends SimulatorVoicemail.Voicemail { - - private final String phoneNumber; - private final String transcription; - private final long durationSeconds; - private final long timeMillis; - private final boolean isRead; - - private AutoValue_SimulatorVoicemail_Voicemail( - String phoneNumber, - String transcription, - long durationSeconds, - long timeMillis, - boolean isRead) { - this.phoneNumber = phoneNumber; - this.transcription = transcription; - this.durationSeconds = durationSeconds; - this.timeMillis = timeMillis; - this.isRead = isRead; - } - - @NonNull - @Override - String getPhoneNumber() { - return phoneNumber; - } - - @NonNull - @Override - String getTranscription() { - return transcription; - } - - @Override - long getDurationSeconds() { - return durationSeconds; - } - - @Override - long getTimeMillis() { - return timeMillis; - } - - @Override - boolean getIsRead() { - return isRead; - } - - @Override - public String toString() { - return "Voicemail{" - + "phoneNumber=" + phoneNumber + ", " - + "transcription=" + transcription + ", " - + "durationSeconds=" + durationSeconds + ", " - + "timeMillis=" + timeMillis + ", " - + "isRead=" + isRead - + "}"; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof SimulatorVoicemail.Voicemail) { - SimulatorVoicemail.Voicemail that = (SimulatorVoicemail.Voicemail) o; - return (this.phoneNumber.equals(that.getPhoneNumber())) - && (this.transcription.equals(that.getTranscription())) - && (this.durationSeconds == that.getDurationSeconds()) - && (this.timeMillis == that.getTimeMillis()) - && (this.isRead == that.getIsRead()); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= this.phoneNumber.hashCode(); - h *= 1000003; - h ^= this.transcription.hashCode(); - h *= 1000003; - h ^= (this.durationSeconds >>> 32) ^ this.durationSeconds; - h *= 1000003; - h ^= (this.timeMillis >>> 32) ^ this.timeMillis; - h *= 1000003; - h ^= this.isRead ? 1231 : 1237; - return h; - } - - static final class Builder extends SimulatorVoicemail.Voicemail.Builder { - private String phoneNumber; - private String transcription; - private Long durationSeconds; - private Long timeMillis; - private Boolean isRead; - Builder() { - } - private Builder(SimulatorVoicemail.Voicemail source) { - this.phoneNumber = source.getPhoneNumber(); - this.transcription = source.getTranscription(); - this.durationSeconds = source.getDurationSeconds(); - this.timeMillis = source.getTimeMillis(); - this.isRead = source.getIsRead(); - } - @Override - SimulatorVoicemail.Voicemail.Builder setPhoneNumber(String phoneNumber) { - this.phoneNumber = phoneNumber; - return this; - } - @Override - SimulatorVoicemail.Voicemail.Builder setTranscription(String transcription) { - this.transcription = transcription; - return this; - } - @Override - SimulatorVoicemail.Voicemail.Builder setDurationSeconds(long durationSeconds) { - this.durationSeconds = durationSeconds; - return this; - } - @Override - SimulatorVoicemail.Voicemail.Builder setTimeMillis(long timeMillis) { - this.timeMillis = timeMillis; - return this; - } - @Override - SimulatorVoicemail.Voicemail.Builder setIsRead(boolean isRead) { - this.isRead = isRead; - return this; - } - @Override - SimulatorVoicemail.Voicemail build() { - String missing = ""; - if (this.phoneNumber == null) { - missing += " phoneNumber"; - } - if (this.transcription == null) { - missing += " transcription"; - } - if (this.durationSeconds == null) { - missing += " durationSeconds"; - } - if (this.timeMillis == null) { - missing += " timeMillis"; - } - if (this.isRead == null) { - missing += " isRead"; - } - if (!missing.isEmpty()) { - throw new IllegalStateException("Missing required properties:" + missing); - } - return new AutoValue_SimulatorVoicemail_Voicemail( - this.phoneNumber, - this.transcription, - this.durationSeconds, - this.timeMillis, - this.isRead); - } - } - -} diff --git a/java/com/android/dialer/simulator/impl/SimulatorCallLog.java b/java/com/android/dialer/simulator/impl/SimulatorCallLog.java index 9ace047d0..f127d5603 100644 --- a/java/com/android/dialer/simulator/impl/SimulatorCallLog.java +++ b/java/com/android/dialer/simulator/impl/SimulatorCallLog.java @@ -26,7 +26,7 @@ import android.provider.CallLog.Calls; import android.support.annotation.NonNull; import android.support.annotation.WorkerThread; import com.android.dialer.common.Assert; - +import com.google.auto.value.AutoValue; import java.util.ArrayList; import java.util.concurrent.TimeUnit; @@ -96,7 +96,7 @@ final class SimulatorCallLog { } } - + @AutoValue abstract static class CallEntry { @NonNull abstract String getNumber(); @@ -121,7 +121,7 @@ final class SimulatorCallLog { return values; } - + @AutoValue.Builder abstract static class Builder { abstract Builder setNumber(@NonNull String number); diff --git a/java/com/android/dialer/simulator/impl/SimulatorContacts.java b/java/com/android/dialer/simulator/impl/SimulatorContacts.java index 89315094a..c5e25b357 100644 --- a/java/com/android/dialer/simulator/impl/SimulatorContacts.java +++ b/java/com/android/dialer/simulator/impl/SimulatorContacts.java @@ -31,7 +31,7 @@ import android.support.annotation.Nullable; import android.support.annotation.WorkerThread; import android.text.TextUtils; import com.android.dialer.common.Assert; - +import com.google.auto.value.AutoValue; import java.io.ByteArrayOutputStream; import java.util.ArrayList; import java.util.List; @@ -190,7 +190,7 @@ final class SimulatorContacts { } } - + @AutoValue abstract static class Contact { @NonNull abstract String getAccountType(); @@ -221,7 +221,7 @@ final class SimulatorContacts { .setEmails(new ArrayList<>()); } - + @AutoValue.Builder abstract static class Builder { @NonNull private final List phoneNumbers = new ArrayList<>(); @NonNull private final List emails = new ArrayList<>(); diff --git a/java/com/android/dialer/simulator/impl/SimulatorImpl.java b/java/com/android/dialer/simulator/impl/SimulatorImpl.java new file mode 100644 index 000000000..9c6826940 --- /dev/null +++ b/java/com/android/dialer/simulator/impl/SimulatorImpl.java @@ -0,0 +1,40 @@ +/* + * 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.simulator.impl; + +import android.content.Context; +import android.view.ActionProvider; +import com.android.dialer.buildtype.BuildType; +import com.android.dialer.common.LogUtil; +import com.android.dialer.simulator.Simulator; +import javax.inject.Inject; + +/** The entry point for the simulator feature. */ +final public class SimulatorImpl implements Simulator { + @Inject + public SimulatorImpl() {} + + @Override + public boolean shouldShow() { + return BuildType.get() == BuildType.BUGFOOD || LogUtil.isDebugEnabled(); + } + + @Override + public ActionProvider getActionProvider(Context context) { + return new SimulatorActionProvider(context); + } +} diff --git a/java/com/android/dialer/simulator/impl/SimulatorModule.java b/java/com/android/dialer/simulator/impl/SimulatorModule.java index 0f8ad3954..c0cca271b 100644 --- a/java/com/android/dialer/simulator/impl/SimulatorModule.java +++ b/java/com/android/dialer/simulator/impl/SimulatorModule.java @@ -16,19 +16,15 @@ package com.android.dialer.simulator.impl; -import android.content.Context; -import android.view.ActionProvider; import com.android.dialer.simulator.Simulator; +import dagger.Binds; +import dagger.Module; +import javax.inject.Singleton; -/** The entry point for the simulator module. */ -public final class SimulatorModule implements Simulator { - @Override - public boolean shouldShow() { - return true; - } - - @Override - public ActionProvider getActionProvider(Context context) { - return new SimulatorActionProvider(context); - } +/** This module provides an instance of the simulator. */ +@Module +public abstract class SimulatorModule { + @Binds + @Singleton + public abstract Simulator bindsSimulator(SimulatorImpl simulator); } diff --git a/java/com/android/dialer/simulator/impl/SimulatorVoicemail.java b/java/com/android/dialer/simulator/impl/SimulatorVoicemail.java index ffb9191dc..04de201ae 100644 --- a/java/com/android/dialer/simulator/impl/SimulatorVoicemail.java +++ b/java/com/android/dialer/simulator/impl/SimulatorVoicemail.java @@ -26,7 +26,7 @@ import android.support.annotation.WorkerThread; import android.telecom.PhoneAccountHandle; import android.telephony.TelephonyManager; import com.android.dialer.common.Assert; - +import com.google.auto.value.AutoValue; import java.util.concurrent.TimeUnit; /** Populates the device database with voicemail entries. */ @@ -105,7 +105,7 @@ final class SimulatorVoicemail { context.getContentResolver().insert(Status.buildSourceUri(context.getPackageName()), values); } - + @AutoValue abstract static class Voicemail { @NonNull abstract String getPhoneNumber(); @@ -134,7 +134,7 @@ final class SimulatorVoicemail { return values; } - + @AutoValue.Builder abstract static class Builder { abstract Builder setPhoneNumber(@NonNull String phoneNumber); -- cgit v1.2.3