Dialer: Remove excluded code [4/x]
Code that's already not included in builds isn't required
-> Google Dialer stuff
-> Call location
-> Maps
...
Change-Id: I8b7a3002adef2d424e9d54ef991e10341fee554a
Signed-off-by: Michael W <baddaemon87@gmail.com>
diff --git a/Android.mk b/Android.mk
index 72bee8a..5eedab5 100644
--- a/Android.mk
+++ b/Android.mk
@@ -15,24 +15,6 @@
# The base directory for Dialer sources.
BASE_DIR := java/com/android
-# Exclude files incompatible with AOSP.
-EXCLUDE_FILES := \
- $(BASE_DIR)/incallui/calllocation/impl/AuthException.java \
- $(BASE_DIR)/incallui/calllocation/impl/CallLocationImpl.java \
- $(BASE_DIR)/incallui/calllocation/impl/CallLocationModule.java \
- $(BASE_DIR)/incallui/calllocation/impl/DownloadMapImageTask.java \
- $(BASE_DIR)/incallui/calllocation/impl/GoogleLocationSettingHelper.java \
- $(BASE_DIR)/incallui/calllocation/impl/HttpFetcher.java \
- $(BASE_DIR)/incallui/calllocation/impl/LocationFragment.java \
- $(BASE_DIR)/incallui/calllocation/impl/LocationHelper.java \
- $(BASE_DIR)/incallui/calllocation/impl/LocationPresenter.java \
- $(BASE_DIR)/incallui/calllocation/impl/LocationUrlBuilder.java \
- $(BASE_DIR)/incallui/calllocation/impl/ReverseGeocodeTask.java \
- $(BASE_DIR)/incallui/calllocation/impl/TrafficStatsTags.java \
- $(BASE_DIR)/incallui/maps/impl/MapsImpl.java \
- $(BASE_DIR)/incallui/maps/impl/MapsModule.java \
- $(BASE_DIR)/incallui/maps/impl/StaticMapFragment.java \
-
# Exclude testing only class, not used anywhere here
EXCLUDE_FILES += \
$(BASE_DIR)/contacts/common/format/testing/SpannedTestUtils.java
@@ -40,35 +22,12 @@
# Exclude rootcomponentgenerator
EXCLUDE_FILES += \
$(call all-java-files-under, $(BASE_DIR)/dialer/rootcomponentgenerator) \
- $(call all-java-files-under, $(BASE_DIR)/dialer/inject/demo)
-# Exclude build variants for now
-EXCLUDE_FILES += \
- $(BASE_DIR)/dialer/constants/googledialer/ConstantsImpl.java \
- $(BASE_DIR)/dialer/binary/google/GoogleStubDialerRootComponent.java \
- $(BASE_DIR)/dialer/binary/google/GoogleStubDialerApplication.java \
-
-# * b/62875795
-ifneq ($(wildcard packages/apps/Dialer/java/com/android/voicemail/impl/com/google/internal/communications/voicemailtranscription/v1/VoicemailTranscriptionServiceGrpc.java),)
-$(error Please remove file packages/apps/Dialer/java/com/android/voicemail/impl/com/google/internal/communications/voicemailtranscription/v1/VoicemailTranscriptionServiceGrpc.java )
-endif
-
-EXCLUDE_RESOURCE_DIRECTORIES := \
- java/com/android/incallui/maps/impl/res \
-
-# All Dialers resources.
+# All Dialer resources.
RES_DIRS := $(call all-subdir-named-dirs,res,.)
-RES_DIRS := $(filter-out $(EXCLUDE_RESOURCE_DIRECTORIES),$(RES_DIRS))
-
-EXCLUDE_MANIFESTS := \
- $(BASE_DIR)/dialer/binary/aosp/testing/AndroidManifest.xml \
- $(BASE_DIR)/dialer/binary/google/AndroidManifest.xml \
- $(BASE_DIR)/incallui/calllocation/impl/AndroidManifest.xml \
- $(BASE_DIR)/incallui/maps/impl/AndroidManifest.xml \
# Dialer manifest files to merge.
DIALER_MANIFEST_FILES := $(call all-named-files-under,AndroidManifest.xml,.)
-DIALER_MANIFEST_FILES := $(filter-out $(EXCLUDE_MANIFESTS),$(DIALER_MANIFEST_FILES))
# Merge all manifest files.
LOCAL_FULL_LIBS_MANIFEST_FILES := \
@@ -86,16 +45,9 @@
LOCAL_RESOURCE_DIR := $(addprefix $(LOCAL_PATH)/, $(RES_DIRS))
-EXCLUDE_EXTRA_PACKAGES := \
- com.android.dialer.binary.aosp.testing \
- com.android.dialer.binary.google \
- com.android.incallui.calllocation.impl \
- com.android.incallui.maps.impl \
-
# We specify each package explicitly to glob resource files.
include ${LOCAL_PATH}/packages.mk
-LOCAL_AAPT_FLAGS := $(filter-out $(EXCLUDE_EXTRA_PACKAGES),$(LOCAL_AAPT_FLAGS))
LOCAL_AAPT_FLAGS := $(addprefix --extra-packages , $(LOCAL_AAPT_FLAGS))
LOCAL_AAPT_FLAGS += \
--auto-add-overlay \
diff --git a/java/com/android/dialer/binary/aosp/AospDialerRootComponent.java b/java/com/android/dialer/binary/aosp/AospDialerRootComponent.java
index a0acde9..bbf00b9 100644
--- a/java/com/android/dialer/binary/aosp/AospDialerRootComponent.java
+++ b/java/com/android/dialer/binary/aosp/AospDialerRootComponent.java
@@ -43,7 +43,6 @@
import com.android.dialer.strictmode.impl.SystemStrictModeModule;
import com.android.dialer.theme.base.impl.AospThemeModule;
import com.android.incallui.calllocation.stub.StubCallLocationModule;
-import com.android.incallui.maps.stub.StubMapsModule;
import com.android.incallui.speakeasy.StubSpeakEasyModule;
import com.android.voicemail.impl.VoicemailModule;
import dagger.Component;
@@ -75,7 +74,6 @@
StubBubbleModule.class,
StubMetricsModule.class,
StubFeedbackModule.class,
- StubMapsModule.class,
StubSimSuggestionModule.class,
StubSpamModule.class,
StubSpeakEasyModule.class,
diff --git a/java/com/android/dialer/binary/basecomponent/BaseDialerRootComponent.java b/java/com/android/dialer/binary/basecomponent/BaseDialerRootComponent.java
index 7a083f7..737c8b2 100644
--- a/java/com/android/dialer/binary/basecomponent/BaseDialerRootComponent.java
+++ b/java/com/android/dialer/binary/basecomponent/BaseDialerRootComponent.java
@@ -44,7 +44,6 @@
import com.android.dialer.strictmode.StrictModeComponent;
import com.android.dialer.theme.base.ThemeComponent;
import com.android.incallui.calllocation.CallLocationComponent;
-import com.android.incallui.maps.MapsComponent;
import com.android.incallui.speakeasy.SpeakEasyComponent;
import com.android.voicemail.VoicemailComponent;
@@ -67,7 +66,6 @@
EnrichedCallComponent.HasComponent,
FeedbackComponent.HasComponent,
GlidePhotoManagerComponent.HasComponent,
- MapsComponent.HasComponent,
MetricsComponent.HasComponent,
PhoneLookupComponent.HasComponent,
PhoneLookupDatabaseComponent.HasComponent,
diff --git a/java/com/android/dialer/binary/google/AndroidManifest.xml b/java/com/android/dialer/binary/google/AndroidManifest.xml
deleted file mode 100644
index 8555ff6..0000000
--- a/java/com/android/dialer/binary/google/AndroidManifest.xml
+++ /dev/null
@@ -1,113 +0,0 @@
-<!-- Copyright (C) 2016 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.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- coreApp="true"
- package="com.google.android.google_stub_dialer"
- android:versionCode="2900000"
- android:versionName="23.0">
-
- <uses-sdk
- android:minSdkVersion="24"
- android:targetSdkVersion="30"/>
-
- <uses-permission android:name="android.permission.CALL_PHONE"/>
- <uses-permission android:name="android.permission.READ_CONTACTS"/>
- <uses-permission android:name="android.permission.WRITE_CONTACTS"/>
- <uses-permission android:name="android.permission.READ_CALL_LOG"/>
- <uses-permission android:name="android.permission.WRITE_CALL_LOG"/>
- <uses-permission android:name="android.permission.READ_PROFILE"/>
- <uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>
- <uses-permission android:name="android.permission.GET_ACCOUNTS"/>
- <uses-permission android:name="android.permission.GET_ACCOUNTS_PRIVILEGED"/>
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
- <uses-permission android:name="android.permission.INTERNET"/>
- <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>
- <uses-permission android:name="android.permission.NFC"/>
- <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
- <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
- <uses-permission android:name="android.permission.MODIFY_PHONE_STATE"/>
- <uses-permission android:name="android.permission.WAKE_LOCK"/>
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
- <uses-permission android:name="android.permission.WRITE_SETTINGS"/>
- <uses-permission android:name="android.permission.USE_CREDENTIALS"/>
- <uses-permission android:name="android.permission.VIBRATE"/>
- <uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/>
- <uses-permission android:name="com.android.voicemail.permission.ADD_VOICEMAIL"/>
- <uses-permission android:name="com.android.voicemail.permission.WRITE_VOICEMAIL"/>
- <uses-permission android:name="com.android.voicemail.permission.READ_VOICEMAIL"/>
- <uses-permission android:name="android.permission.ALLOW_ANY_CODEC_FOR_PLAYBACK"/>
- <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
- <uses-permission android:name="android.permission.BROADCAST_STICKY"/>
- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
-
- <uses-permission android:name="android.permission.CONTROL_INCALL_EXPERIENCE"/>
- <!-- We use this to disable the status bar buttons of home, back and recent
- during an incoming call. By doing so this allows us to not show the user
- is viewing the activity in full screen alert, on a fresh system/factory
- reset state of the app. -->
- <uses-permission android:name="android.permission.STATUS_BAR"/>
- <uses-permission android:name="android.permission.CAMERA"/>
-
- <!-- This tells the activity manager to not delay any of our activity
- start requests, even if they happen immediately after the user
- presses home. -->
- <uses-permission android:name="android.permission.STOP_APP_SWITCHES"/>
-
- <!-- Permissions needed for badger count showing on launch icon. -->
-
- <!--for Samsung-->
- <uses-permission android:name="com.sec.android.provider.badge.permission.READ"/>
- <uses-permission android:name="com.sec.android.provider.badge.permission.WRITE"/>
-
- <!--for htc-->
- <uses-permission android:name="com.htc.launcher.permission.READ_SETTINGS"/>
- <uses-permission android:name="com.htc.launcher.permission.UPDATE_SHORTCUT"/>
-
- <!--for sony-->
- <uses-permission android:name="com.sonyericsson.home.permission.BROADCAST_BADGE"/>
- <uses-permission android:name="com.sonymobile.home.permission.PROVIDER_INSERT_BADGE"/>
-
- <!--for apex-->
- <uses-permission android:name="com.anddoes.launcher.permission.UPDATE_COUNT"/>
-
- <!--for solid-->
- <uses-permission android:name="com.majeur.launcher.permission.UPDATE_BADGE"/>
-
- <!--for huawei-->
- <uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE"/>
- <uses-permission android:name="com.huawei.android.launcher.permission.READ_SETTINGS"/>
- <uses-permission android:name="com.huawei.android.launcher.permission.WRITE_SETTINGS"/>
-
- <!--for ZUK-->
- <uses-permission android:name="android.permission.READ_APP_BADGE"/>
-
- <!--for OPPO-->
- <uses-permission android:name="com.oppo.launcher.permission.READ_SETTINGS"/>
- <uses-permission android:name="com.oppo.launcher.permission.WRITE_SETTINGS"/>
-
- <application
- android:hardwareAccelerated="true"
- android:icon="@mipmap/ic_launcher_phone"
- android:label="@string/applicationLabel"
- android:name="com.android.dialer.binary.google.GoogleStubDialerApplication"
- android:supportsRtl="true"
- android:usesCleartextTraffic="false"
- android:extractNativeLibs="false">
- </application>
-
-</manifest>
diff --git a/java/com/android/dialer/binary/google/GoogleStubDialerApplication.java b/java/com/android/dialer/binary/google/GoogleStubDialerApplication.java
deleted file mode 100644
index e9289af..0000000
--- a/java/com/android/dialer/binary/google/GoogleStubDialerApplication.java
+++ /dev/null
@@ -1,37 +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.binary.google;
-
-import android.support.annotation.NonNull;
-import com.android.dialer.binary.common.DialerApplication;
-import com.android.dialer.inject.ContextModule;
-
-/**
- * The application class for the Google Stub Dialer. This is a version of the Dialer app that
- * depends on Google Play Services.
- */
-public class GoogleStubDialerApplication extends DialerApplication {
-
- /** Returns a new instance of the root component for the Google Stub Dialer. */
- @Override
- @NonNull
- protected Object buildRootComponent() {
- return DaggerGoogleStubDialerRootComponent.builder()
- .contextModule(new ContextModule(this))
- .build();
- }
-}
diff --git a/java/com/android/dialer/binary/google/GoogleStubDialerRootComponent.java b/java/com/android/dialer/binary/google/GoogleStubDialerRootComponent.java
deleted file mode 100644
index ee0646b..0000000
--- a/java/com/android/dialer/binary/google/GoogleStubDialerRootComponent.java
+++ /dev/null
@@ -1,89 +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.binary.google;
-
-import com.android.bubble.stub.StubBubbleModule;
-import com.android.dialer.activecalls.ActiveCallsModule;
-import com.android.dialer.binary.basecomponent.BaseDialerRootComponent;
-import com.android.dialer.calllog.CallLogModule;
-import com.android.dialer.commandline.CommandLineModule;
-import com.android.dialer.common.concurrent.DialerExecutorModule;
-import com.android.dialer.configprovider.SharedPrefConfigProviderModule;
-import com.android.dialer.contacts.ContactsModule;
-import com.android.dialer.duo.stub.StubDuoModule;
-import com.android.dialer.enrichedcall.stub.StubEnrichedCallModule;
-import com.android.dialer.feedback.stub.StubFeedbackModule;
-import com.android.dialer.glidephotomanager.GlidePhotoManagerModule;
-import com.android.dialer.inject.ContextModule;
-import com.android.dialer.metrics.StubMetricsModule;
-import com.android.dialer.phonelookup.PhoneLookupModule;
-import com.android.dialer.phonenumbergeoutil.impl.PhoneNumberGeoUtilModule;
-import com.android.dialer.precall.impl.PreCallModule;
-import com.android.dialer.preferredsim.PreferredSimModule;
-import com.android.dialer.preferredsim.suggestion.stub.StubSimSuggestionModule;
-import com.android.dialer.promotion.impl.PromotionModule;
-import com.android.dialer.simulator.impl.SimulatorModule;
-import com.android.dialer.simulator.stub.StubSimulatorEnrichedCallModule;
-import com.android.dialer.spam.stub.StubSpamModule;
-import com.android.dialer.storage.StorageModule;
-import com.android.dialer.strictmode.impl.SystemStrictModeModule;
-import com.android.dialer.theme.base.impl.AospThemeModule;
-import com.android.incallui.calllocation.impl.CallLocationModule;
-import com.android.incallui.maps.impl.MapsModule;
-import com.android.incallui.speakeasy.StubSpeakEasyModule;
-import com.android.voicemail.impl.VoicemailModule;
-import dagger.Component;
-import javax.inject.Singleton;
-
-/**
- * Root component for the Google Stub Dialer application. Unlike the AOSP variant, this component
- * can pull in modules that depend on Google Play Services like the maps module.
- */
-@Singleton
-@Component(
- modules = {
- ActiveCallsModule.class,
- CallLocationModule.class,
- CallLogModule.class,
- CommandLineModule.class,
- ContextModule.class,
- ContactsModule.class,
- DialerExecutorModule.class,
- GlidePhotoManagerModule.class,
- MapsModule.class,
- PhoneLookupModule.class, // TODO(zachh): Module which uses APDL?
- PhoneNumberGeoUtilModule.class,
- PreCallModule.class,
- PreferredSimModule.class,
- PromotionModule.class,
- SharedPrefConfigProviderModule.class,
- SimulatorModule.class,
- StorageModule.class,
- StubSimulatorEnrichedCallModule.class,
- StubDuoModule.class,
- StubEnrichedCallModule.class,
- StubFeedbackModule.class,
- StubMetricsModule.class,
- StubBubbleModule.class,
- StubSimSuggestionModule.class,
- StubSpamModule.class,
- StubSpeakEasyModule.class,
- SystemStrictModeModule.class,
- AospThemeModule.class,
- VoicemailModule.class,
- })
-public interface GoogleStubDialerRootComponent extends BaseDialerRootComponent {}
diff --git a/java/com/android/dialer/constants/googledialer/ConstantsImpl.java b/java/com/android/dialer/constants/googledialer/ConstantsImpl.java
deleted file mode 100644
index 9a6fdd7..0000000
--- a/java/com/android/dialer/constants/googledialer/ConstantsImpl.java
+++ /dev/null
@@ -1,73 +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.constants;
-
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.os.Build;
-import android.support.annotation.NonNull;
-import com.android.dialer.proguard.UsedByReflection;
-
-/** Provider config values for Google Dialer. */
-@UsedByReflection(value = "Constants.java")
-public class ConstantsImpl extends Constants {
-
- @Override
- @NonNull
- public String getFileProviderAuthority() {
- return "com.google.android.dialer.files";
- }
-
- @NonNull
- @Override
- public String getAnnotatedCallLogProviderAuthority() {
- return "com.google.android.dialer.annotatedcalllog";
- }
-
- @NonNull
- @Override
- public String getPhoneLookupHistoryProviderAuthority() {
- return "com.google.android.dialer.phonelookuphistory";
- }
-
- @NonNull
- @Override
- public String getPreferredSimFallbackProviderAuthority() {
- return "com.google.android.dialer.preferredsimfallback";
- }
-
- @Override
- public String getUserAgent(Context context) {
- StringBuilder userAgent = new StringBuilder("GoogleDialer ");
- try {
- String versionName =
- context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
- userAgent.append(versionName).append(" ");
- } catch (PackageManager.NameNotFoundException e) {
- // ignore
- }
- userAgent.append(Build.FINGERPRINT);
-
- return userAgent.toString();
- }
-
- @NonNull
- @Override
- public String getSettingsActivity() {
- return "com.google.android.apps.dialer.settings.GoogleDialerSettingsActivity";
- }
-}
diff --git a/java/com/android/dialer/inject/demo/DemoDaggerApplication.java b/java/com/android/dialer/inject/demo/DemoDaggerApplication.java
deleted file mode 100644
index ab40eca..0000000
--- a/java/com/android/dialer/inject/demo/DemoDaggerApplication.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2018 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.inject.demo;
-
-import android.app.Application;
-import android.support.annotation.NonNull;
-import com.android.dialer.inject.ContextModule;
-import com.android.dialer.inject.DialerRootComponent;
-import com.android.dialer.inject.DialerVariant;
-import com.android.dialer.inject.HasRootComponent;
-
-/** Demo dialer dagger application. */
-@DialerRootComponent(variant = DialerVariant.DIALER_DEMO)
-public final class DemoDaggerApplication extends Application implements HasRootComponent {
-
- private volatile Object rootComponent;
-
- /** Returns a cached instance of application's root component. */
- @Override
- @NonNull
- public final Object component() {
- Object result = rootComponent;
- if (result == null) {
- synchronized (this) {
- result = rootComponent;
- if (result == null) {
- rootComponent =
- result = DaggerDialerDemo.builder().contextModule(new ContextModule(this)).build();
- }
- }
- }
- return result;
- }
-
- @Override
- public void onCreate() {
- super.onCreate();
-
- DemoSubcomponent.get(this).demoObjects();
- }
-}
diff --git a/java/com/android/dialer/inject/demo/DemoModule.java b/java/com/android/dialer/inject/demo/DemoModule.java
deleted file mode 100644
index 9917c7d..0000000
--- a/java/com/android/dialer/inject/demo/DemoModule.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2018 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.inject.demo;
-
-import com.android.dialer.inject.DialerVariant;
-import com.android.dialer.inject.InstallIn;
-import dagger.Module;
-import dagger.Provides;
-import dagger.multibindings.IntoSet;
-
-/** Module for demo dagger application. */
-@Module
-@InstallIn(variants = DialerVariant.DIALER_DEMO)
-public final class DemoModule {
-
- private DemoModule() {}
-
- @Provides
- @IntoSet
- static DemoObject provide() {
- return DemoObject.create("prod");
- }
-}
diff --git a/java/com/android/dialer/inject/demo/DemoObject.java b/java/com/android/dialer/inject/demo/DemoObject.java
deleted file mode 100644
index 3c38621..0000000
--- a/java/com/android/dialer/inject/demo/DemoObject.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2018 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.inject.demo;
-
-import com.google.auto.value.AutoValue;
-
-/** Object used to demonstrate dagger bindings. */
-@AutoValue
-abstract class DemoObject {
-
- abstract String value();
-
- static DemoObject create(String value) {
- return new AutoValue_DemoObject(value);
- }
-}
diff --git a/java/com/android/dialer/inject/demo/DemoSubcomponent.java b/java/com/android/dialer/inject/demo/DemoSubcomponent.java
deleted file mode 100644
index 3e4dd66..0000000
--- a/java/com/android/dialer/inject/demo/DemoSubcomponent.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2018 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.inject.demo;
-
-import android.content.Context;
-import com.android.dialer.inject.HasRootComponent;
-import com.android.dialer.inject.IncludeInDialerRoot;
-import dagger.Subcomponent;
-import java.util.Set;
-
-/** Subcomponent for the demo dagger application. */
-@Subcomponent
-public abstract class DemoSubcomponent {
-
- abstract Set<DemoObject> demoObjects();
-
- public static DemoSubcomponent get(Context context) {
- return ((HasComponent) ((HasRootComponent) context.getApplicationContext()).component())
- .demoSubcomponent();
- }
-
- /** Used to refer to the root application component. */
- @IncludeInDialerRoot
- public interface HasComponent {
- DemoSubcomponent demoSubcomponent();
- }
-}
diff --git a/java/com/android/incallui/answer/impl/AnswerFragment.java b/java/com/android/incallui/answer/impl/AnswerFragment.java
index bba1727..4387443 100644
--- a/java/com/android/incallui/answer/impl/AnswerFragment.java
+++ b/java/com/android/incallui/answer/impl/AnswerFragment.java
@@ -84,7 +84,6 @@
import com.android.incallui.incall.protocol.PrimaryInfo;
import com.android.incallui.incall.protocol.SecondaryInfo;
import com.android.incallui.incalluilock.InCallUiLock;
-import com.android.incallui.maps.MapsComponent;
import com.android.incallui.sessiondata.AvatarPresenter;
import com.android.incallui.sessiondata.MultimediaFragment;
import com.android.incallui.speakeasy.Annotations.SpeakEasyChipResourceId;
@@ -591,8 +590,7 @@
MultimediaData multimediaData = getSessionData();
if (multimediaData != null
&& (!TextUtils.isEmpty(multimediaData.getText())
- || (multimediaData.getImageUri() != null)
- || (multimediaData.getLocation() != null && canShowMap()))) {
+ || (multimediaData.getImageUri() != null))) {
// Need message fragment
String subject = multimediaData.getText();
Uri imageUri = multimediaData.getImageUri();
@@ -638,10 +636,6 @@
return !isVideoCall() && !isVideoUpgradeRequest();
}
- private boolean canShowMap() {
- return MapsComponent.get(getContext()).getMaps().isAvailable();
- }
-
@Override
public void updateAvatar(AvatarPresenter avatarContainer) {
contactGridManager.setAvatarImageView(
diff --git a/java/com/android/incallui/calllocation/impl/AndroidManifest.xml b/java/com/android/incallui/calllocation/impl/AndroidManifest.xml
deleted file mode 100644
index 3e5a6d0..0000000
--- a/java/com/android/incallui/calllocation/impl/AndroidManifest.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<!--
- ~ Copyright (C) 2016 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
- -->
-
-<manifest
- xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.incallui.calllocation.impl">
-
- <application>
- <!-- Fix for P -->
- <uses-library android:name="org.apache.http.legacy" android:required="false" />
-
- <meta-data
- android:name="com.google.android.gms.version"
- android:value="@integer/google_play_services_version"/>
- </application>
-</manifest>
diff --git a/java/com/android/incallui/calllocation/impl/AuthException.java b/java/com/android/incallui/calllocation/impl/AuthException.java
deleted file mode 100644
index 26def2f..0000000
--- a/java/com/android/incallui/calllocation/impl/AuthException.java
+++ /dev/null
@@ -1,25 +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.incallui.calllocation.impl;
-
-/** For detecting backend authorization errors */
-public class AuthException extends Exception {
-
- public AuthException(String detailMessage) {
- super(detailMessage);
- }
-}
diff --git a/java/com/android/incallui/calllocation/impl/CallLocationImpl.java b/java/com/android/incallui/calllocation/impl/CallLocationImpl.java
deleted file mode 100644
index 20f5ffb..0000000
--- a/java/com/android/incallui/calllocation/impl/CallLocationImpl.java
+++ /dev/null
@@ -1,67 +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.incallui.calllocation.impl;
-
-import android.content.Context;
-import android.support.annotation.MainThread;
-import android.support.annotation.NonNull;
-import android.support.v4.app.Fragment;
-import com.android.dialer.common.Assert;
-import com.android.incallui.calllocation.CallLocation;
-import javax.inject.Inject;
-
-/** Uses Google Play Services to show the user's location during an emergency call. */
-public class CallLocationImpl implements CallLocation {
-
- private LocationHelper locationHelper;
- private LocationFragment locationFragment;
-
- @Inject
- public CallLocationImpl() {}
-
- @MainThread
- @Override
- public boolean canGetLocation(@NonNull Context context) {
- Assert.isMainThread();
- return LocationHelper.canGetLocation(context);
- }
-
- @MainThread
- @NonNull
- @Override
- public Fragment getLocationFragment(@NonNull Context context) {
- Assert.isMainThread();
- if (locationFragment == null) {
- locationFragment = new LocationFragment();
- locationHelper = new LocationHelper(context);
- locationHelper.addLocationListener(locationFragment.getPresenter());
- }
- return locationFragment;
- }
-
- @MainThread
- @Override
- public void close() {
- Assert.isMainThread();
- if (locationFragment != null) {
- locationHelper.removeLocationListener(locationFragment.getPresenter());
- locationHelper.close();
- locationFragment = null;
- locationHelper = null;
- }
- }
-}
diff --git a/java/com/android/incallui/calllocation/impl/CallLocationModule.java b/java/com/android/incallui/calllocation/impl/CallLocationModule.java
deleted file mode 100644
index 73e8555..0000000
--- a/java/com/android/incallui/calllocation/impl/CallLocationModule.java
+++ /dev/null
@@ -1,29 +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.incallui.calllocation.impl;
-
-import com.android.incallui.calllocation.CallLocation;
-import dagger.Binds;
-import dagger.Module;
-
-/** This module provides an instance of call location. */
-@Module
-public abstract class CallLocationModule {
-
- @Binds
- public abstract CallLocation bindCallLocation(CallLocationImpl callLocation);
-}
diff --git a/java/com/android/incallui/calllocation/impl/GoogleLocationSettingHelper.java b/java/com/android/incallui/calllocation/impl/GoogleLocationSettingHelper.java
deleted file mode 100644
index 0884c2f..0000000
--- a/java/com/android/incallui/calllocation/impl/GoogleLocationSettingHelper.java
+++ /dev/null
@@ -1,127 +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.incallui.calllocation.impl;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.database.Cursor;
-import android.net.Uri;
-import android.provider.Settings.Secure;
-import android.provider.Settings.SettingNotFoundException;
-import com.android.dialer.common.LogUtil;
-import com.android.dialer.strictmode.StrictModeUtils;
-
-/**
- * Helper class to check if Google Location Services is enabled. This class is based on
-
- */
-public class GoogleLocationSettingHelper {
-
- /** User has disagreed to use location for Google services. */
- public static final int USE_LOCATION_FOR_SERVICES_OFF = 0;
- /** User has agreed to use location for Google services. */
- public static final int USE_LOCATION_FOR_SERVICES_ON = 1;
- /** The user has neither agreed nor disagreed to use location for Google services yet. */
- public static final int USE_LOCATION_FOR_SERVICES_NOT_SET = 2;
-
- private static final String GOOGLE_SETTINGS_AUTHORITY = "com.google.settings";
- private static final Uri GOOGLE_SETTINGS_CONTENT_URI =
- Uri.parse("content://" + GOOGLE_SETTINGS_AUTHORITY + "/partner");
- private static final String NAME = "name";
- private static final String VALUE = "value";
- private static final String USE_LOCATION_FOR_SERVICES = "use_location_for_services";
-
- /** Determine if Google apps need to conform to the USE_LOCATION_FOR_SERVICES setting. */
- private static boolean isEnforceable(Context context) {
- final ResolveInfo ri =
- context
- .getPackageManager()
- .resolveActivity(
- new Intent("com.google.android.gsf.GOOGLE_APPS_LOCATION_SETTINGS"),
- PackageManager.MATCH_DEFAULT_ONLY);
- return ri != null;
- }
-
- /**
- * Get the current value for the 'Use value for location' setting.
- *
- * @return One of {@link #USE_LOCATION_FOR_SERVICES_NOT_SET}, {@link
- * #USE_LOCATION_FOR_SERVICES_OFF} or {@link #USE_LOCATION_FOR_SERVICES_ON}.
- */
- private static int getUseLocationForServices(Context context) {
- final ContentResolver resolver = context.getContentResolver();
- Cursor c = null;
- String stringValue = null;
- try {
- c =
- resolver.query(
- GOOGLE_SETTINGS_CONTENT_URI,
- new String[] {VALUE},
- NAME + "=?",
- new String[] {USE_LOCATION_FOR_SERVICES},
- null);
- if (c != null && c.moveToNext()) {
- stringValue = c.getString(0);
- }
- } catch (final RuntimeException e) {
- LogUtil.e(
- "GoogleLocationSettingHelper.getUseLocationForServices",
- "Failed to get 'Use My Location' setting",
- e);
- } finally {
- if (c != null) {
- c.close();
- }
- }
- if (stringValue == null) {
- return USE_LOCATION_FOR_SERVICES_NOT_SET;
- }
- int value;
- try {
- value = Integer.parseInt(stringValue);
- } catch (final NumberFormatException nfe) {
- value = USE_LOCATION_FOR_SERVICES_NOT_SET;
- }
- return value;
- }
-
- /** Whether or not the system location setting is enable */
- static boolean isSystemLocationSettingEnabled(Context context) {
- try {
- return Secure.getInt(context.getContentResolver(), Secure.LOCATION_MODE)
- != Secure.LOCATION_MODE_OFF;
- } catch (SettingNotFoundException e) {
- LogUtil.e(
- "GoogleLocationSettingHelper.isSystemLocationSettingEnabled",
- "Failed to get System Location setting",
- e);
- return false;
- }
- }
-
- /** Convenience method that returns true is GLS is ON or if it's not enforceable. */
- static boolean isGoogleLocationServicesEnabled(Context context) {
- if (!isEnforceable(context)) {
- return true;
- }
- int locationServiceStatus = StrictModeUtils.bypass(() -> getUseLocationForServices(context));
- return locationServiceStatus == USE_LOCATION_FOR_SERVICES_ON;
- }
-}
diff --git a/java/com/android/incallui/calllocation/impl/HttpFetcher.java b/java/com/android/incallui/calllocation/impl/HttpFetcher.java
deleted file mode 100644
index c182fa1..0000000
--- a/java/com/android/incallui/calllocation/impl/HttpFetcher.java
+++ /dev/null
@@ -1,286 +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.incallui.calllocation.impl;
-
-import android.content.Context;
-import android.net.Uri;
-import android.net.Uri.Builder;
-import android.os.SystemClock;
-import android.util.Pair;
-import com.android.dialer.common.LogUtil;
-import com.android.dialer.util.DialerUtils;
-import com.android.dialer.util.MoreStrings;
-import com.google.android.common.http.UrlRules;
-import java.io.ByteArrayOutputStream;
-import java.io.FilterInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.ProtocolException;
-import java.net.URL;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
-
-/** Utility for making http requests. */
-public class HttpFetcher {
-
- // Phone number
- public static final String PARAM_ID = "id";
- // auth token
- public static final String PARAM_ACCESS_TOKEN = "access_token";
- private static final String TAG = HttpFetcher.class.getSimpleName();
-
- /**
- * Send a http request to the given url.
- *
- * @param urlString The url to request.
- * @return The response body as a byte array. Or {@literal null} if status code is not 2xx.
- * @throws java.io.IOException when an error occurs.
- */
- public static byte[] sendRequestAsByteArray(
- Context context, String urlString, String requestMethod, List<Pair<String, String>> headers)
- throws IOException, AuthException {
- Objects.requireNonNull(urlString);
-
- URL url = reWriteUrl(context, urlString);
- if (url == null) {
- return null;
- }
-
- HttpURLConnection conn = null;
- InputStream is = null;
- boolean isError = false;
- final long start = SystemClock.uptimeMillis();
- try {
- conn = (HttpURLConnection) url.openConnection();
- setMethodAndHeaders(conn, requestMethod, headers);
- int responseCode = conn.getResponseCode();
- LogUtil.i("HttpFetcher.sendRequestAsByteArray", "response code: " + responseCode);
- // All 2xx codes are successful.
- if (responseCode / 100 == 2) {
- is = conn.getInputStream();
- } else {
- is = conn.getErrorStream();
- isError = true;
- }
-
- final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- final byte[] buffer = new byte[1024];
- int bytesRead;
-
- while ((bytesRead = is.read(buffer)) != -1) {
- baos.write(buffer, 0, bytesRead);
- }
-
- if (isError) {
- handleBadResponse(url.toString(), baos.toByteArray());
- if (responseCode == 401) {
- throw new AuthException("Auth error");
- }
- return null;
- }
-
- byte[] response = baos.toByteArray();
- LogUtil.i("HttpFetcher.sendRequestAsByteArray", "received " + response.length + " bytes");
- long end = SystemClock.uptimeMillis();
- LogUtil.i("HttpFetcher.sendRequestAsByteArray", "fetch took " + (end - start) + " ms");
- return response;
- } finally {
- DialerUtils.closeQuietly(is);
- if (conn != null) {
- conn.disconnect();
- }
- }
- }
-
- /**
- * Send a http request to the given url.
- *
- * @return The response body as a InputStream. Or {@literal null} if status code is not 2xx.
- * @throws java.io.IOException when an error occurs.
- */
- public static InputStream sendRequestAsInputStream(
- Context context, String urlString, String requestMethod, List<Pair<String, String>> headers)
- throws IOException, AuthException {
- Objects.requireNonNull(urlString);
-
- URL url = reWriteUrl(context, urlString);
- if (url == null) {
- return null;
- }
-
- HttpURLConnection httpUrlConnection = null;
- boolean isSuccess = false;
- try {
- httpUrlConnection = (HttpURLConnection) url.openConnection();
- setMethodAndHeaders(httpUrlConnection, requestMethod, headers);
- int responseCode = httpUrlConnection.getResponseCode();
- LogUtil.i("HttpFetcher.sendRequestAsInputStream", "response code: " + responseCode);
-
- if (responseCode == 401) {
- throw new AuthException("Auth error");
- } else if (responseCode / 100 == 2) { // All 2xx codes are successful.
- InputStream is = httpUrlConnection.getInputStream();
- if (is != null) {
- is = new HttpInputStreamWrapper(httpUrlConnection, is);
- isSuccess = true;
- return is;
- }
- }
-
- return null;
- } finally {
- if (httpUrlConnection != null && !isSuccess) {
- httpUrlConnection.disconnect();
- }
- }
- }
-
- /**
- * Set http method and headers.
- *
- * @param conn The connection to add headers to.
- * @param requestMethod request method
- * @param headers http headers where the first item in the pair is the key and second item is the
- * value.
- */
- private static void setMethodAndHeaders(
- HttpURLConnection conn, String requestMethod, List<Pair<String, String>> headers)
- throws ProtocolException {
- conn.setRequestMethod(requestMethod);
- if (headers != null) {
- for (Pair<String, String> pair : headers) {
- conn.setRequestProperty(pair.first, pair.second);
- }
- }
- }
-
- private static String obfuscateUrl(String urlString) {
- final Uri uri = Uri.parse(urlString);
- final Builder builder =
- new Builder().scheme(uri.getScheme()).authority(uri.getAuthority()).path(uri.getPath());
- final Set<String> names = uri.getQueryParameterNames();
- for (String name : names) {
- if (PARAM_ACCESS_TOKEN.equals(name)) {
- builder.appendQueryParameter(name, "token");
- } else {
- final String value = uri.getQueryParameter(name);
- if (PARAM_ID.equals(name)) {
- builder.appendQueryParameter(name, MoreStrings.toSafeString(value));
- } else {
- builder.appendQueryParameter(name, value);
- }
- }
- }
- return builder.toString();
- }
-
- /** Same as {@link #getRequestAsString(Context, String, String, List)} with null headers. */
- public static String getRequestAsString(Context context, String urlString)
- throws IOException, AuthException {
- return getRequestAsString(context, urlString, "GET" /* Default to get. */, null);
- }
-
- /**
- * Send a http request to the given url.
- *
- * @param context The android context.
- * @param urlString The url to request.
- * @param headers Http headers to pass in the request. {@literal null} is allowed.
- * @return The response body as a String. Or {@literal null} if status code is not 2xx.
- * @throws java.io.IOException when an error occurs.
- */
- public static String getRequestAsString(
- Context context, String urlString, String requestMethod, List<Pair<String, String>> headers)
- throws IOException, AuthException {
- final byte[] byteArr = sendRequestAsByteArray(context, urlString, requestMethod, headers);
- if (byteArr == null) {
- // Encountered error response... just return.
- return null;
- }
- final String response = new String(byteArr);
- LogUtil.i("HttpFetcher.getRequestAsString", "response body: " + response);
- return response;
- }
-
- /**
- * Lookup up url re-write rules from gServices and apply to the given url.
- *
- * @return The new url.
- */
- private static URL reWriteUrl(Context context, String url) {
- final UrlRules rules = UrlRules.getRules(context.getContentResolver());
- final UrlRules.Rule rule = rules.matchRule(url);
- final String newUrl = rule.apply(url);
-
- if (newUrl == null) {
- if (LogUtil.isDebugEnabled()) {
- // Url is blocked by re-write.
- LogUtil.i(
- "HttpFetcher.reWriteUrl",
- "url " + obfuscateUrl(url) + " is blocked. Ignoring request.");
- }
- return null;
- }
-
- if (LogUtil.isDebugEnabled()) {
- LogUtil.i("HttpFetcher.reWriteUrl", "fetching " + obfuscateUrl(newUrl));
- if (!newUrl.equals(url)) {
- LogUtil.i(
- "HttpFetcher.reWriteUrl",
- "Original url: " + obfuscateUrl(url) + ", after re-write: " + obfuscateUrl(newUrl));
- }
- }
-
- URL urlObject = null;
- try {
- urlObject = new URL(newUrl);
- } catch (MalformedURLException e) {
- LogUtil.e("HttpFetcher.reWriteUrl", "failed to parse url: " + url, e);
- }
- return urlObject;
- }
-
- private static void handleBadResponse(String url, byte[] response) {
- LogUtil.i("HttpFetcher.handleBadResponse", "Got bad response code from url: " + url);
- LogUtil.i("HttpFetcher.handleBadResponse", new String(response));
- }
-
- /** Disconnect {@link HttpURLConnection} when InputStream is closed */
- private static class HttpInputStreamWrapper extends FilterInputStream {
-
- final HttpURLConnection httpUrlConnection;
- final long startMillis = SystemClock.uptimeMillis();
-
- public HttpInputStreamWrapper(HttpURLConnection conn, InputStream in) {
- super(in);
- httpUrlConnection = conn;
- }
-
- @Override
- public void close() throws IOException {
- super.close();
- httpUrlConnection.disconnect();
- if (LogUtil.isDebugEnabled()) {
- long endMillis = SystemClock.uptimeMillis();
- LogUtil.i("HttpFetcher.close", "fetch took " + (endMillis - startMillis) + " ms");
- }
- }
- }
-}
diff --git a/java/com/android/incallui/calllocation/impl/LocationFragment.java b/java/com/android/incallui/calllocation/impl/LocationFragment.java
deleted file mode 100644
index 760829d..0000000
--- a/java/com/android/incallui/calllocation/impl/LocationFragment.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * Copyright (C) 2018 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.incallui.calllocation.impl;
-
-import android.animation.LayoutTransition;
-import android.content.Context;
-import android.location.Location;
-import android.os.Bundle;
-import android.os.Handler;
-import android.support.annotation.NonNull;
-import android.text.TextUtils;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-import android.widget.ViewAnimator;
-import com.android.dialer.common.Assert;
-import com.android.dialer.common.LogUtil;
-import com.android.dialer.logging.DialerImpression;
-import com.android.dialer.logging.Logger;
-import com.android.incallui.baseui.BaseFragment;
-import com.google.android.gms.maps.CameraUpdateFactory;
-import com.google.android.gms.maps.GoogleMap;
-import com.google.android.gms.maps.MapView;
-import com.google.android.gms.maps.model.LatLng;
-import com.google.android.gms.maps.model.MarkerOptions;
-import java.util.Objects;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Fragment which shows location during E911 calls, to supplement the user with accurate location
- * information in case the user is asked for their location by the emergency responder.
- *
- * <p>If location data is inaccurate, stale, or unavailable, this should not be shown.
- */
-public class LocationFragment extends BaseFragment<LocationPresenter, LocationPresenter.LocationUi>
- implements LocationPresenter.LocationUi {
-
- private static final String ADDRESS_DELIMITER = ",";
-
- // Indexes used to animate fading between views, 0 for LOADING_VIEW_INDEX
- private static final int LOCATION_VIEW_INDEX = 1;
- private static final int LOCATION_ERROR_INDEX = 2;
-
- private static final long FIND_LOCATION_SPINNING_TIMEOUT_MILLIS = TimeUnit.SECONDS.toMillis(5);
- private static final long LOAD_DATA_TIMEOUT_MILLIS = TimeUnit.SECONDS.toMillis(5);
-
- private static final float MAP_ZOOM_LEVEL = 15f;
-
- private ViewAnimator viewAnimator;
- private MapView locationMapView;
- private TextView addressLine1;
- private TextView addressLine2;
- private TextView latLongLine;
- private Location location;
- private ViewGroup locationLayout;
- private GoogleMap savedGoogleMap;
-
- private boolean isMapSet;
- private boolean isAddressSet;
- private boolean isLocationSet;
- private boolean hasTimeoutStarted;
-
- private final Handler handler = new Handler();
- private final Runnable dataTimeoutRunnable =
- () -> {
- LogUtil.i(
- "LocationFragment.dataTimeoutRunnable",
- "timed out so animate any future layout changes");
- locationLayout.setLayoutTransition(new LayoutTransition());
- showLocationNow();
- };
-
- private final Runnable spinningTimeoutRunnable =
- () -> {
- if (!(isAddressSet || isLocationSet || isMapSet)) {
- // No data received, show error
- viewAnimator.setDisplayedChild(LOCATION_ERROR_INDEX);
- }
- };
-
- @Override
- public LocationPresenter createPresenter() {
- return new LocationPresenter();
- }
-
- @Override
- public LocationPresenter.LocationUi getUi() {
- return this;
- }
-
- @Override
- public View onCreateView(
- LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- LogUtil.enterBlock("LocationFragment.onCreateView");
- final View view = inflater.inflate(R.layout.location_fragment, container, false);
- viewAnimator = (ViewAnimator) view.findViewById(R.id.location_view_animator);
- addressLine1 = (TextView) view.findViewById(R.id.address_line_one);
- addressLine2 = (TextView) view.findViewById(R.id.address_line_two);
- latLongLine = (TextView) view.findViewById(R.id.lat_long_line);
- locationLayout = (ViewGroup) view.findViewById(R.id.location_layout);
- locationMapView = (MapView) view.findViewById(R.id.location_map_view);
- locationMapView.onCreate(savedInstanceState);
- return view;
- }
-
- @Override
- public void onStart() {
- super.onStart();
- handler.postDelayed(spinningTimeoutRunnable, FIND_LOCATION_SPINNING_TIMEOUT_MILLIS);
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- handler.removeCallbacks(dataTimeoutRunnable);
- handler.removeCallbacks(spinningTimeoutRunnable);
- }
-
- private void setMap(@NonNull Location location) {
- LogUtil.enterBlock("LocationFragment.setMap");
- Assert.isNotNull(location);
-
- if (savedGoogleMap == null) {
- locationMapView.getMapAsync(
- (googleMap) -> {
- LogUtil.enterBlock("LocationFragment.onMapReady");
- savedGoogleMap = googleMap;
- savedGoogleMap.getUiSettings().setMapToolbarEnabled(false);
- updateMap(location);
- isMapSet = true;
- locationMapView.setVisibility(View.VISIBLE);
-
- // Hide Google logo
- View child = locationMapView.getChildAt(0);
- if (child instanceof ViewGroup) {
- // Only the first child (View) is useful.
- // Google logo can be in any other child (ViewGroup).
- for (int i = 1; i < ((ViewGroup) child).getChildCount(); ++i) {
- ((ViewGroup) child).getChildAt(i).setVisibility(View.GONE);
- }
- }
- });
- } else {
- updateMap(location);
- }
- displayWhenReady();
- Logger.get(getContext()).logImpression(DialerImpression.Type.EMERGENCY_GOT_MAP);
- }
-
- private void updateMap(@NonNull Location location) {
- Assert.isNotNull(location);
- Assert.isNotNull(savedGoogleMap);
- LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
- savedGoogleMap.clear();
- savedGoogleMap.addMarker(new MarkerOptions().position(latLng).flat(true).draggable(false));
- savedGoogleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, MAP_ZOOM_LEVEL));
- }
-
- @Override
- public void setAddress(String address) {
- LogUtil.i("LocationFragment.setAddress", address);
- isAddressSet = true;
- addressLine1.setVisibility(View.VISIBLE);
- addressLine2.setVisibility(View.VISIBLE);
- if (TextUtils.isEmpty(address)) {
- addressLine1.setText(null);
- addressLine2.setText(null);
- } else {
-
- // Split the address after the first delimiter for display, if present.
- // For example, "1600 Amphitheatre Parkway, Mountain View, CA 94043"
- // => "1600 Amphitheatre Parkway"
- // => "Mountain View, CA 94043"
- int splitIndex = address.indexOf(ADDRESS_DELIMITER);
- if (splitIndex >= 0) {
- updateText(addressLine1, address.substring(0, splitIndex).trim());
- updateText(addressLine2, address.substring(splitIndex + 1).trim());
- } else {
- updateText(addressLine1, address);
- updateText(addressLine2, null);
- }
-
- Logger.get(getContext()).logImpression(DialerImpression.Type.EMERGENCY_GOT_ADDRESS);
- }
- displayWhenReady();
- }
-
- @Override
- public void setLocation(Location location) {
- LogUtil.i("LocationFragment.setLocation", String.valueOf(location));
- isLocationSet = true;
- this.location = location;
-
- if (location != null) {
- latLongLine.setVisibility(View.VISIBLE);
- latLongLine.setText(
- getContext()
- .getString(
- R.string.lat_long_format, location.getLatitude(), location.getLongitude()));
-
- Logger.get(getContext()).logImpression(DialerImpression.Type.EMERGENCY_GOT_LOCATION);
- setMap(location);
- }
- displayWhenReady();
- }
-
- private void displayWhenReady() {
- // Show the location if all data has loaded, otherwise prime the timeout
- if (isMapSet && isAddressSet && isLocationSet) {
- showLocationNow();
- } else if (!hasTimeoutStarted) {
- handler.postDelayed(dataTimeoutRunnable, LOAD_DATA_TIMEOUT_MILLIS);
- hasTimeoutStarted = true;
- }
- }
-
- private void showLocationNow() {
- handler.removeCallbacks(dataTimeoutRunnable);
- handler.removeCallbacks(spinningTimeoutRunnable);
- if (viewAnimator.getDisplayedChild() != LOCATION_VIEW_INDEX) {
- viewAnimator.setDisplayedChild(LOCATION_VIEW_INDEX);
- viewAnimator.setOnClickListener(v -> launchMap());
- }
- }
-
- @Override
- public Context getContext() {
- return getActivity();
- }
-
- private void launchMap() {
- if (location != null) {
- startActivity(
- LocationUrlBuilder.getShowMapIntent(
- location, addressLine1.getText(), addressLine2.getText()));
-
- Logger.get(getContext()).logImpression(DialerImpression.Type.EMERGENCY_LAUNCHED_MAP);
- }
- }
-
- private static void updateText(TextView view, String text) {
- if (!Objects.equals(text, view.getText())) {
- view.setText(text);
- }
- }
-
- @Override
- public void onResume() {
- super.onResume();
- locationMapView.onResume();
- }
-
- @Override
- public void onPause() {
- locationMapView.onPause();
- super.onPause();
- }
-}
diff --git a/java/com/android/incallui/calllocation/impl/LocationHelper.java b/java/com/android/incallui/calllocation/impl/LocationHelper.java
deleted file mode 100644
index 5c105e4..0000000
--- a/java/com/android/incallui/calllocation/impl/LocationHelper.java
+++ /dev/null
@@ -1,251 +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.incallui.calllocation.impl;
-
-import android.content.Context;
-import android.location.Location;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.os.Handler;
-import android.support.annotation.IntDef;
-import android.support.annotation.MainThread;
-import android.support.v4.os.UserManagerCompat;
-import com.android.dialer.common.Assert;
-import com.android.dialer.common.LogUtil;
-import com.android.dialer.util.PermissionsUtil;
-import com.google.android.gms.location.FusedLocationProviderClient;
-import com.google.android.gms.location.LocationListener;
-import com.google.android.gms.location.LocationRequest;
-import com.google.android.gms.location.LocationServices;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.util.ArrayList;
-import java.util.List;
-
-/** Uses the Fused location service to get location and pass updates on to listeners. */
-public class LocationHelper {
-
- private static final int FAST_MIN_UPDATE_INTERVAL_MS = 5 * 1000;
- private static final int SLOW_MIN_UPDATE_INTERVAL_MS = 30 * 1000;
- private static final int LAST_UPDATE_THRESHOLD_MS = 60 * 1000;
- private static final int LOCATION_ACCURACY_THRESHOLD_METERS = 100;
-
- public static final int LOCATION_STATUS_UNKNOWN = 0;
- public static final int LOCATION_STATUS_OK = 1;
- public static final int LOCATION_STATUS_STALE = 2;
- public static final int LOCATION_STATUS_INACCURATE = 3;
- public static final int LOCATION_STATUS_NO_LOCATION = 4;
- public static final int LOCATION_STATUS_MOCK = 5;
-
- /** Possible return values for {@code checkLocation()} */
- @IntDef({
- LOCATION_STATUS_UNKNOWN,
- LOCATION_STATUS_OK,
- LOCATION_STATUS_STALE,
- LOCATION_STATUS_INACCURATE,
- LOCATION_STATUS_NO_LOCATION,
- LOCATION_STATUS_MOCK
- })
- @Retention(RetentionPolicy.SOURCE)
- public @interface LocationStatus {}
-
- private final LocationHelperInternal locationHelperInternal;
- private final List<LocationListener> listeners = new ArrayList<>();
-
- @MainThread
- LocationHelper(Context context) {
- Assert.isMainThread();
- Assert.checkArgument(canGetLocation(context));
- locationHelperInternal = new LocationHelperInternal(context);
- }
-
- static boolean canGetLocation(Context context) {
- if (!PermissionsUtil.hasLocationPermissions(context)) {
- LogUtil.i("LocationHelper.canGetLocation", "no location permissions.");
- return false;
- }
-
- // Ensure that both system location setting is on and google location services are enabled.
- if (!GoogleLocationSettingHelper.isGoogleLocationServicesEnabled(context)
- || !GoogleLocationSettingHelper.isSystemLocationSettingEnabled(context)) {
- LogUtil.i("LocationHelper.canGetLocation", "location service is disabled.");
- return false;
- }
-
- if (!UserManagerCompat.isUserUnlocked(context)) {
- LogUtil.i("LocationHelper.canGetLocation", "location unavailable in FBE mode.");
- return false;
- }
-
- return true;
- }
-
- /**
- * Check whether the location is valid. We consider it valid if it was recorded within the
- * specified time threshold of the present and has an accuracy less than the specified distance
- * threshold.
- *
- * @param location The location to determine the validity of.
- * @return {@code LocationStatus} indicating if the location is valid or the reason its not valid
- */
- static @LocationStatus int checkLocation(Location location) {
- if (location == null) {
- LogUtil.i("LocationHelper.checkLocation", "no location");
- return LOCATION_STATUS_NO_LOCATION;
- }
-
- long locationTimeMs = location.getTime();
- long elapsedTimeMs = System.currentTimeMillis() - locationTimeMs;
- if (elapsedTimeMs > LAST_UPDATE_THRESHOLD_MS) {
- LogUtil.i("LocationHelper.checkLocation", "stale location, age: " + elapsedTimeMs);
- return LOCATION_STATUS_STALE;
- }
-
- if (location.getAccuracy() > LOCATION_ACCURACY_THRESHOLD_METERS) {
- LogUtil.i("LocationHelper.checkLocation", "poor accuracy: " + location.getAccuracy());
- return LOCATION_STATUS_INACCURATE;
- }
-
- if (location.isFromMockProvider()) {
- LogUtil.i("LocationHelper.checkLocation", "from mock provider");
- return LOCATION_STATUS_MOCK;
- }
-
- return LOCATION_STATUS_OK;
- }
-
- @MainThread
- void addLocationListener(LocationListener listener) {
- Assert.isMainThread();
- listeners.add(listener);
- }
-
- @MainThread
- void removeLocationListener(LocationListener listener) {
- Assert.isMainThread();
- listeners.remove(listener);
- }
-
- @MainThread
- void close() {
- Assert.isMainThread();
- LogUtil.enterBlock("LocationHelper.close");
- listeners.clear();
- locationHelperInternal.close();
- }
-
- @MainThread
- void onLocationChanged(Location location, boolean isConnected) {
- Assert.isMainThread();
- LogUtil.i("LocationHelper.onLocationChanged", "location: " + location);
-
- for (LocationListener listener : listeners) {
- listener.onLocationChanged(location);
- }
- }
-
- /**
- * This class contains all the asynchronous callbacks. It only posts location changes back to the
- * outer class on the main thread.
- */
- private class LocationHelperInternal implements LocationListener {
-
- private final FusedLocationProviderClient locationClient;
- private final ConnectivityManager connectivityManager;
- private final Handler mainThreadHandler = new Handler();
- private boolean gotGoodLocation;
-
- @MainThread
- LocationHelperInternal(Context context) {
- Assert.isMainThread();
- locationClient = LocationServices.getFusedLocationProviderClient(context);
- connectivityManager =
- (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
- requestUpdates();
- getLocation();
- }
-
- void close() {
- LogUtil.enterBlock("LocationHelperInternal.close");
- locationClient.removeLocationUpdates(this);
- }
-
- private void requestUpdates() {
- LogUtil.enterBlock("LocationHelperInternal.requestUpdates");
-
- int interval = gotGoodLocation ? SLOW_MIN_UPDATE_INTERVAL_MS : FAST_MIN_UPDATE_INTERVAL_MS;
- LocationRequest locationRequest =
- LocationRequest.create()
- .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
- .setInterval(interval)
- .setFastestInterval(interval);
-
- locationClient
- .requestLocationUpdates(locationRequest, this)
- .addOnSuccessListener(
- result -> LogUtil.i("LocationHelperInternal.requestUpdates", "onSuccess"))
- .addOnFailureListener(
- e -> LogUtil.e("LocationHelperInternal.requestUpdates", "onFailure", e));
- }
-
- private void getLocation() {
- LogUtil.enterBlock("LocationHelperInternal.getLocation");
-
- locationClient
- .getLastLocation()
- .addOnSuccessListener(
- location -> {
- LogUtil.i("LocationHelperInternal.getLocation", "onSuccess");
- Assert.isMainThread();
- LocationHelper.this.onLocationChanged(location, isConnected());
- maybeAdjustUpdateInterval(location);
- })
- .addOnFailureListener(
- e -> LogUtil.e("LocationHelperInternal.getLocation", "onFailure", e));
- }
-
- @Override
- public void onLocationChanged(Location location) {
- // Post new location on main thread
- mainThreadHandler.post(
- new Runnable() {
- @Override
- public void run() {
- LocationHelper.this.onLocationChanged(location, isConnected());
- maybeAdjustUpdateInterval(location);
- }
- });
- }
-
- private void maybeAdjustUpdateInterval(Location location) {
- if (!gotGoodLocation && checkLocation(location) == LOCATION_STATUS_OK) {
- LogUtil.i("LocationHelperInternal.maybeAdjustUpdateInterval", "got good location");
- gotGoodLocation = true;
- requestUpdates();
- }
- }
-
- /** @return Whether the phone is connected to data. */
- private boolean isConnected() {
- if (connectivityManager == null) {
- return false;
- }
- NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
- return networkInfo != null && networkInfo.isConnectedOrConnecting();
- }
- }
-}
diff --git a/java/com/android/incallui/calllocation/impl/LocationPresenter.java b/java/com/android/incallui/calllocation/impl/LocationPresenter.java
deleted file mode 100644
index 94bd235..0000000
--- a/java/com/android/incallui/calllocation/impl/LocationPresenter.java
+++ /dev/null
@@ -1,104 +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.incallui.calllocation.impl;
-
-import android.content.Context;
-import android.location.Location;
-import android.os.AsyncTask;
-import com.android.dialer.common.LogUtil;
-import com.android.dialer.logging.DialerImpression;
-import com.android.dialer.logging.Logger;
-import com.android.incallui.baseui.Presenter;
-import com.android.incallui.baseui.Ui;
-import com.google.android.gms.location.LocationListener;
-import java.lang.ref.WeakReference;
-import java.util.Objects;
-
-/**
- * Presenter for the {@code LocationFragment}.
- *
- * <p>Performs lookup for the address and map image to show.
- */
-public class LocationPresenter extends Presenter<LocationPresenter.LocationUi>
- implements LocationListener {
-
- private Location lastLocation;
- private AsyncTask reverseGeocodeTask;
-
- LocationPresenter() {}
-
- @Override
- public void onUiReady(LocationUi ui) {
- LogUtil.i("LocationPresenter.onUiReady", "");
- super.onUiReady(ui);
- updateLocation(lastLocation, true);
- }
-
- @Override
- public void onUiUnready(LocationUi ui) {
- LogUtil.i("LocationPresenter.onUiUnready", "");
- super.onUiUnready(ui);
-
- if (reverseGeocodeTask != null) {
- reverseGeocodeTask.cancel(true);
- }
- }
-
- @Override
- public void onLocationChanged(Location location) {
- LogUtil.i("LocationPresenter.onLocationChanged", "");
- updateLocation(location, false);
- }
-
- private void updateLocation(Location location, boolean forceUpdate) {
- LogUtil.i("LocationPresenter.updateLocation", "location: " + location);
- if (forceUpdate || !Objects.equals(lastLocation, location)) {
- lastLocation = location;
- int status = LocationHelper.checkLocation(location);
- LocationUi ui = getUi();
- if (status == LocationHelper.LOCATION_STATUS_OK) {
- reverseGeocodeTask = new ReverseGeocodeTask(new WeakReference<>(ui)).execute(location);
- if (ui != null) {
- ui.setLocation(location);
- } else {
- LogUtil.i("LocationPresenter.updateLocation", "no Ui");
- }
- } else if (status != LocationHelper.LOCATION_STATUS_NO_LOCATION) {
- // Log impression indicating why the location is not valid
- // Note: its possible for this to be called before the UI has been initialized.
- Context context = (ui != null) ? ui.getContext() : null;
- if (context != null) {
- if (status == LocationHelper.LOCATION_STATUS_STALE) {
- Logger.get(context).logImpression(DialerImpression.Type.EMERGENCY_STALE_LOCATION);
- } else if (status == LocationHelper.LOCATION_STATUS_INACCURATE) {
- Logger.get(context).logImpression(DialerImpression.Type.EMERGENCY_INACCURATE_LOCATION);
- }
- }
- }
- }
- }
-
- /** UI interface */
- public interface LocationUi extends Ui {
-
- void setAddress(String address);
-
- void setLocation(Location location);
-
- Context getContext();
- }
-}
diff --git a/java/com/android/incallui/calllocation/impl/LocationUrlBuilder.java b/java/com/android/incallui/calllocation/impl/LocationUrlBuilder.java
deleted file mode 100644
index 14a9c76..0000000
--- a/java/com/android/incallui/calllocation/impl/LocationUrlBuilder.java
+++ /dev/null
@@ -1,177 +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.incallui.calllocation.impl;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.res.Resources;
-import android.location.Location;
-import android.net.Uri;
-import android.support.annotation.Nullable;
-import android.support.annotation.VisibleForTesting;
-import java.util.Locale;
-
-class LocationUrlBuilder {
-
- // Static Map API path constants.
- private static final String HTTPS_SCHEME = "https";
- private static final String MAPS_API_DOMAIN = "maps.googleapis.com";
- private static final String MAPS_PATH = "maps";
- private static final String API_PATH = "api";
- private static final String STATIC_MAP_PATH = "staticmap";
- private static final String GEOCODE_PATH = "geocode";
- private static final String GEOCODE_OUTPUT_TYPE = "json";
-
- // Static Map API parameter constants.
- private static final String KEY_PARAM_KEY = "key";
- private static final String CENTER_PARAM_KEY = "center";
- private static final String ZOOM_PARAM_KEY = "zoom";
- private static final String SCALE_PARAM_KEY = "scale";
- private static final String SIZE_PARAM_KEY = "size";
- private static final String MARKERS_PARAM_KEY = "markers";
-
- private static final String ZOOM_PARAM_VALUE = Integer.toString(16);
-
- private static final String LAT_LONG_DELIMITER = ",";
-
- private static final String MARKER_DELIMITER = "|";
- private static final String MARKER_STYLE_DELIMITER = ":";
- private static final String MARKER_STYLE_COLOR = "color";
- private static final String MARKER_STYLE_COLOR_RED = "red";
-
- private static final String LAT_LNG_PARAM_KEY = "latlng";
-
- private static final String ANDROID_API_KEY_VALUE = "AIzaSyAXdDnif6B7sBYxU8hzw9qAp3pRPVHs060";
- private static final String BROWSER_API_KEY_VALUE = "AIzaSyBfLlvWYndiQ3RFEHli65qGQH36QIxdyCI";
-
- /**
- * Generates the URL to a static map image for the given location.
- *
- * <p>This image has the following characteristics:
- *
- * <p>- It is centered at the given latitude and longitutde. - It is scaled according to the
- * device's pixel density. - There is a red marker at the given latitude and longitude.
- *
- * <p>Source: https://developers.google.com/maps/documentation/staticmaps/
- *
- * @param contxt The context.
- * @param Location A location.
- * @return The URL of a static map image url of the given location.
- */
- public static String getStaticMapUrl(Context context, Location location) {
- final Uri.Builder builder = new Uri.Builder();
- Resources res = context.getResources();
- String size =
- res.getDimensionPixelSize(R.dimen.location_map_width)
- + "x"
- + res.getDimensionPixelSize(R.dimen.location_map_height);
-
- builder
- .scheme(HTTPS_SCHEME)
- .authority(MAPS_API_DOMAIN)
- .appendPath(MAPS_PATH)
- .appendPath(API_PATH)
- .appendPath(STATIC_MAP_PATH)
- .appendQueryParameter(CENTER_PARAM_KEY, getFormattedLatLng(location))
- .appendQueryParameter(ZOOM_PARAM_KEY, ZOOM_PARAM_VALUE)
- .appendQueryParameter(SIZE_PARAM_KEY, size)
- .appendQueryParameter(SCALE_PARAM_KEY, Float.toString(res.getDisplayMetrics().density))
- .appendQueryParameter(MARKERS_PARAM_KEY, getMarkerUrlParamValue(location))
- .appendQueryParameter(KEY_PARAM_KEY, ANDROID_API_KEY_VALUE);
-
- return builder.build().toString();
- }
-
- /**
- * Generates the URL for a request to reverse geocode the given location.
- *
- * <p>Source: https://developers.google.com/maps/documentation/geocoding/#ReverseGeocoding
- *
- * @param Location A location.
- */
- public static String getReverseGeocodeUrl(Location location) {
- final Uri.Builder builder = new Uri.Builder();
-
- builder
- .scheme(HTTPS_SCHEME)
- .authority(MAPS_API_DOMAIN)
- .appendPath(MAPS_PATH)
- .appendPath(API_PATH)
- .appendPath(GEOCODE_PATH)
- .appendPath(GEOCODE_OUTPUT_TYPE)
- .appendQueryParameter(LAT_LNG_PARAM_KEY, getFormattedLatLng(location))
- .appendQueryParameter(KEY_PARAM_KEY, BROWSER_API_KEY_VALUE);
-
- return builder.build().toString();
- }
-
- public static Intent getShowMapIntent(
- Location location, @Nullable CharSequence addressLine1, @Nullable CharSequence addressLine2) {
-
- String latLong = getFormattedLatLng(location);
- String url = String.format(Locale.US, "geo: %s?q=%s", latLong, latLong);
-
- // Add a map label
- if (addressLine1 != null) {
- if (addressLine2 != null) {
- url +=
- String.format(Locale.US, "(%s, %s)", addressLine1.toString(), addressLine2.toString());
- } else {
- url += String.format(Locale.US, "(%s)", addressLine1.toString());
- }
- } else {
- // TODO(mdooley): i18n
- url +=
- String.format(
- Locale.US,
- "(Latitude: %f, Longitude: %f)",
- location.getLatitude(),
- location.getLongitude());
- }
-
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
- intent.setPackage("com.google.android.apps.maps");
- return intent;
- }
-
- /**
- * Returns a comma-separated latitude and longitude pair, formatted for use as a URL parameter
- * value.
- *
- * @param location A location.
- * @return The comma-separated latitude and longitude pair of that location.
- */
- @VisibleForTesting
- static String getFormattedLatLng(Location location) {
- return location.getLatitude() + LAT_LONG_DELIMITER + location.getLongitude();
- }
-
- /**
- * Returns the URL parameter value for the marker, specifying its style and position.
- *
- * @param location A location.
- * @return The URL parameter value for the marker.
- */
- @VisibleForTesting
- static String getMarkerUrlParamValue(Location location) {
- return MARKER_STYLE_COLOR
- + MARKER_STYLE_DELIMITER
- + MARKER_STYLE_COLOR_RED
- + MARKER_DELIMITER
- + getFormattedLatLng(location);
- }
-}
diff --git a/java/com/android/incallui/calllocation/impl/ReverseGeocodeTask.java b/java/com/android/incallui/calllocation/impl/ReverseGeocodeTask.java
deleted file mode 100644
index f4592d4..0000000
--- a/java/com/android/incallui/calllocation/impl/ReverseGeocodeTask.java
+++ /dev/null
@@ -1,145 +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.incallui.calllocation.impl;
-
-import android.location.Location;
-import android.net.TrafficStats;
-import android.os.AsyncTask;
-import com.android.dialer.common.LogUtil;
-import com.android.dialer.constants.TrafficStatsTags;
-import com.android.incallui.calllocation.impl.LocationPresenter.LocationUi;
-import java.lang.ref.WeakReference;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-class ReverseGeocodeTask extends AsyncTask<Location, Void, String> {
-
- // Below are the JSON keys for the reverse geocode response.
- // Source: https://developers.google.com/maps/documentation/geocoding/#ReverseGeocoding
- private static final String JSON_KEY_RESULTS = "results";
- private static final String JSON_KEY_ADDRESS = "formatted_address";
- private static final String JSON_KEY_ADDRESS_COMPONENTS = "address_components";
- private static final String JSON_KEY_PREMISE = "premise";
- private static final String JSON_KEY_TYPES = "types";
- private static final String JSON_KEY_LONG_NAME = "long_name";
- private static final String JSON_KEY_SHORT_NAME = "short_name";
-
- private WeakReference<LocationUi> uiReference;
-
- public ReverseGeocodeTask(WeakReference<LocationUi> uiReference) {
- this.uiReference = uiReference;
- }
-
- @Override
- protected String doInBackground(Location... locations) {
- LocationUi ui = uiReference.get();
- if (ui == null) {
- return null;
- }
- if (locations == null || locations.length == 0) {
- LogUtil.e("ReverseGeocodeTask.onLocationChanged", "No location provided");
- return null;
- }
-
- try {
- String address = null;
- String url = LocationUrlBuilder.getReverseGeocodeUrl(locations[0]);
-
- TrafficStats.setThreadStatsTag(TrafficStatsTags.REVERSE_GEOCODE_TAG);
- String jsonResponse = HttpFetcher.getRequestAsString(ui.getContext(), url);
-
- // Parse the JSON response for the formatted address of the first result.
- JSONObject responseObject = new JSONObject(jsonResponse);
- if (responseObject != null) {
- JSONArray results = responseObject.optJSONArray(JSON_KEY_RESULTS);
- if (results != null && results.length() > 0) {
- JSONObject topResult = results.optJSONObject(0);
- if (topResult != null) {
- address = topResult.getString(JSON_KEY_ADDRESS);
-
- // Strip off the Premise component from the address, if present.
- JSONArray components = topResult.optJSONArray(JSON_KEY_ADDRESS_COMPONENTS);
- if (components != null) {
- boolean stripped = false;
- for (int i = 0; !stripped && i < components.length(); i++) {
- JSONObject component = components.optJSONObject(i);
- JSONArray types = component.optJSONArray(JSON_KEY_TYPES);
- if (types != null) {
- for (int j = 0; !stripped && j < types.length(); j++) {
- if (JSON_KEY_PREMISE.equals(types.getString(j))) {
- String premise = null;
- if (component.has(JSON_KEY_SHORT_NAME)
- && address.startsWith(component.getString(JSON_KEY_SHORT_NAME))) {
- premise = component.getString(JSON_KEY_SHORT_NAME);
- } else if (component.has(JSON_KEY_LONG_NAME)
- && address.startsWith(component.getString(JSON_KEY_LONG_NAME))) {
- premise = component.getString(JSON_KEY_SHORT_NAME);
- }
- if (premise != null) {
- int index = address.indexOf(',', premise.length());
- if (index > 0 && index < address.length()) {
- address = address.substring(index + 1).trim();
- }
- stripped = true;
- break;
- }
- }
- }
- }
- }
- }
-
- // Strip off the country, if its USA. Note: unfortunately the country in the formatted
- // address field doesn't match the country in the address component fields (USA != US)
- // so we can't easily strip off the country for all cases, thus this hack.
- if (address.endsWith(", USA")) {
- address = address.substring(0, address.length() - 5);
- }
- }
- }
- }
-
- return address;
- } catch (AuthException ex) {
- LogUtil.e("ReverseGeocodeTask.onLocationChanged", "AuthException", ex);
- return null;
- } catch (JSONException ex) {
- LogUtil.e("ReverseGeocodeTask.onLocationChanged", "JSONException", ex);
- return null;
- } catch (Exception ex) {
- LogUtil.e("ReverseGeocodeTask.onLocationChanged", "Exception!!!", ex);
- return null;
- } finally {
- TrafficStats.clearThreadStatsTag();
- }
- }
-
- @Override
- protected void onPostExecute(String address) {
- LocationUi ui = uiReference.get();
- if (ui == null) {
- return;
- }
-
- try {
- ui.setAddress(address);
- } catch (Exception ex) {
- LogUtil.e("ReverseGeocodeTask.onPostExecute", "Exception!!!", ex);
- }
- }
-}
diff --git a/java/com/android/incallui/calllocation/impl/res/values/dimens.xml b/java/com/android/incallui/calllocation/impl/res/values/dimens.xml
deleted file mode 100644
index 1f41816..0000000
--- a/java/com/android/incallui/calllocation/impl/res/values/dimens.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright 2014 Google Inc. All Rights Reserved. -->
-<resources>
- <dimen name="location_map_width">92dp</dimen>
- <dimen name="location_map_height">92dp</dimen>
-</resources>
diff --git a/java/com/android/incallui/calllocation/impl/res/values/strings.xml b/java/com/android/incallui/calllocation/impl/res/values/strings.xml
deleted file mode 100644
index 1d15dba..0000000
--- a/java/com/android/incallui/calllocation/impl/res/values/strings.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
-~ 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
--->
-
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-
- <!-- Description for location map shown during emergency calls. [CHAR LIMIT=NONE] -->
- <string name="location_map_description">Emergency Location Map</string>
-
- <!-- Label for the address and map shown during emergency calls. [CHAR LIMIT=40] -->
- <string name="location_title">Tell emergency services where you are</string>
-
- <string name="lat_long_format"><xliff:g id="latitude">%1$f</xliff:g>, <xliff:g id="longitude">%2$f</xliff:g></string>
-
- <!-- Progress indicator loading text. [CHAR LIMIT=20] -->
- <string name="location_loading">Finding your location…</string>
-
- <!-- Error message shown when we can't get device location. [CHAR LIMIT=NONE] -->
- <string name="location_error">Error, could not retrieve your location</string>
-
-</resources>
diff --git a/java/com/android/incallui/calllocation/impl/res/values/styles.xml b/java/com/android/incallui/calllocation/impl/res/values/styles.xml
deleted file mode 100644
index 45e9c98..0000000
--- a/java/com/android/incallui/calllocation/impl/res/values/styles.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<!--
- ~ Copyright (C) 2018 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
- -->
-<resources>
-
- <style name="LocationAddressTitleTextStyle">
- <item name="android:textSize">14sp</item>
- <item name="android:textColor">#dd000000</item>
- <item name="android:fontFamily">sans-serif-medium</item>
- </style>
-
- <style name="LocationAddressTextStyle">
- <item name="android:textSize">16sp</item>
- <item name="android:textColor">#dd000000</item>
- <item name="android:fontFamily">sans-serif</item>
- </style>
-
- <style name="LocationLatLongTextStyle">
- <item name="android:textSize">14sp</item>
- <item name="android:textColor">#88000000</item>
- <item name="android:fontFamily">sans-serif</item>
- </style>
-
- <style name="LocationLoadingTextStyle">
- <item name="android:textSize">14sp</item>
- <item name="android:textColor">#dd000000</item>
- <item name="android:fontFamily">sans-serif</item>
- </style>
-
- <style name="LocationErrorTextStyle">
- <item name="android:textSize">14sp</item>
- <item name="android:textColor">#dd000000</item>
- <item name="android:fontFamily">sans-serif</item>
- </style>
-</resources>
diff --git a/java/com/android/incallui/maps/Maps.java b/java/com/android/incallui/maps/Maps.java
deleted file mode 100644
index 648cf9f..0000000
--- a/java/com/android/incallui/maps/Maps.java
+++ /dev/null
@@ -1,33 +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.incallui.maps;
-
-import android.location.Location;
-import android.support.annotation.NonNull;
-import android.support.v4.app.Fragment;
-
-/** Used to create a fragment that can display a static map at the given location. */
-public interface Maps {
- /**
- * Used to check if maps is available. This will return false if Dialer was compiled without
- * support for Google Play Services.
- */
- boolean isAvailable();
-
- @NonNull
- Fragment createStaticMapFragment(@NonNull Location location);
-}
diff --git a/java/com/android/incallui/maps/MapsComponent.java b/java/com/android/incallui/maps/MapsComponent.java
deleted file mode 100644
index 796abaa..0000000
--- a/java/com/android/incallui/maps/MapsComponent.java
+++ /dev/null
@@ -1,38 +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.incallui.maps;
-
-import android.content.Context;
-import com.android.dialer.inject.HasRootComponent;
-import dagger.Subcomponent;
-
-/** Subcomponent that can be used to access the maps implementation. */
-@Subcomponent
-public abstract class MapsComponent {
-
- public abstract Maps getMaps();
-
- public static MapsComponent get(Context context) {
- return ((HasComponent) ((HasRootComponent) context.getApplicationContext()).component())
- .mapsComponent();
- }
-
- /** Used to refer to the root application component. */
- public interface HasComponent {
- MapsComponent mapsComponent();
- }
-}
diff --git a/java/com/android/incallui/maps/impl/AndroidManifest.xml b/java/com/android/incallui/maps/impl/AndroidManifest.xml
deleted file mode 100644
index 4c17f33..0000000
--- a/java/com/android/incallui/maps/impl/AndroidManifest.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<!--
- ~ Copyright (C) 2016 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
- -->
-
-<manifest
- xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.incallui.maps.impl">
-
- <application>
- <!-- Fix for P -->
- <uses-library android:name="org.apache.http.legacy" android:required="false" />
-
- <meta-data
- android:name="com.google.android.gms.version"
- android:value="@integer/google_play_services_version"/>
- </application>
-</manifest>
diff --git a/java/com/android/incallui/maps/impl/MapsImpl.java b/java/com/android/incallui/maps/impl/MapsImpl.java
deleted file mode 100644
index 2cecee9..0000000
--- a/java/com/android/incallui/maps/impl/MapsImpl.java
+++ /dev/null
@@ -1,40 +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.incallui.maps.impl;
-
-import android.location.Location;
-import android.support.annotation.NonNull;
-import android.support.v4.app.Fragment;
-import com.android.incallui.maps.Maps;
-import javax.inject.Inject;
-
-/** Uses Google Play Services APIs to create a static map fragment. */
-final class MapsImpl implements Maps {
- @Inject
- public MapsImpl() {}
-
- @Override
- public boolean isAvailable() {
- return true;
- }
-
- @Override
- @NonNull
- public Fragment createStaticMapFragment(@NonNull Location location) {
- return StaticMapFragment.newInstance(location);
- }
-}
diff --git a/java/com/android/incallui/maps/impl/MapsModule.java b/java/com/android/incallui/maps/impl/MapsModule.java
deleted file mode 100644
index 22f2f32..0000000
--- a/java/com/android/incallui/maps/impl/MapsModule.java
+++ /dev/null
@@ -1,31 +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.incallui.maps.impl;
-
-import com.android.incallui.maps.Maps;
-import dagger.Binds;
-import dagger.Module;
-import javax.inject.Singleton;
-
-/** This module provides an instance of maps. */
-@Module
-public abstract class MapsModule {
-
- @Binds
- @Singleton
- public abstract Maps bindMaps(MapsImpl maps);
-}
diff --git a/java/com/android/incallui/maps/impl/StaticMapFragment.java b/java/com/android/incallui/maps/impl/StaticMapFragment.java
deleted file mode 100644
index 38a4c15..0000000
--- a/java/com/android/incallui/maps/impl/StaticMapFragment.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2016 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.incallui.maps.impl;
-
-import android.location.Location;
-import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import com.android.dialer.common.Assert;
-import com.android.dialer.common.LogUtil;
-import com.google.android.gms.maps.CameraUpdateFactory;
-import com.google.android.gms.maps.GoogleMap;
-import com.google.android.gms.maps.OnMapReadyCallback;
-import com.google.android.gms.maps.SupportMapFragment;
-import com.google.android.gms.maps.model.LatLng;
-import com.google.android.gms.maps.model.MarkerOptions;
-
-/** Shows a static map centered on a specified location */
-public class StaticMapFragment extends Fragment implements OnMapReadyCallback {
-
- private static final String ARG_LOCATION = "location";
-
- public static StaticMapFragment newInstance(@NonNull Location location) {
- Bundle args = new Bundle();
- args.putParcelable(ARG_LOCATION, Assert.isNotNull(location));
- StaticMapFragment fragment = new StaticMapFragment();
- fragment.setArguments(args);
- return fragment;
- }
-
- @Nullable
- @Override
- public View onCreateView(
- LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
- return layoutInflater.inflate(R.layout.static_map_fragment, viewGroup, false);
- }
-
- @Override
- public void onViewCreated(View view, @Nullable Bundle bundle) {
- super.onViewCreated(view, bundle);
- SupportMapFragment mapFragment =
- (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.static_map);
- if (mapFragment != null) {
- mapFragment.getMapAsync(this);
- } else {
- LogUtil.w("StaticMapFragment.onViewCreated", "No map fragment found!");
- }
- }
-
- @Override
- public void onMapReady(GoogleMap googleMap) {
- Location location = getArguments().getParcelable(ARG_LOCATION);
- LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
- googleMap.addMarker(new MarkerOptions().position(latLng).flat(true).draggable(false));
- googleMap.getUiSettings().setMapToolbarEnabled(false);
- googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15f));
- }
-}
diff --git a/java/com/android/incallui/maps/impl/res/layout/static_map_fragment.xml b/java/com/android/incallui/maps/impl/res/layout/static_map_fragment.xml
deleted file mode 100644
index 54f41cb..0000000
--- a/java/com/android/incallui/maps/impl/res/layout/static_map_fragment.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2016 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
- -->
-
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:map="http://schemas.android.com/apk/res-auto"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <fragment
- android:id="@+id/static_map"
- class="com.google.android.gms.maps.SupportMapFragment"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- map:liteMode="true"
- map:mapType="normal"/>
-</FrameLayout>
diff --git a/java/com/android/incallui/maps/stub/StubMapsModule.java b/java/com/android/incallui/maps/stub/StubMapsModule.java
deleted file mode 100644
index 3a193b1..0000000
--- a/java/com/android/incallui/maps/stub/StubMapsModule.java
+++ /dev/null
@@ -1,52 +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.incallui.maps.stub;
-
-import android.location.Location;
-import android.support.annotation.NonNull;
-import android.support.v4.app.Fragment;
-import com.android.dialer.common.Assert;
-import com.android.incallui.maps.Maps;
-import dagger.Binds;
-import dagger.Module;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-/** Stub for the maps module for build variants that don't support Google Play Services. */
-@Module
-public abstract class StubMapsModule {
-
- @Binds
- @Singleton
- public abstract Maps bindMaps(StubMaps maps);
-
- static final class StubMaps implements Maps {
- @Inject
- public StubMaps() {}
-
- @Override
- public boolean isAvailable() {
- return false;
- }
-
- @NonNull
- @Override
- public Fragment createStaticMapFragment(@NonNull Location location) {
- throw Assert.createUnsupportedOperationFailException();
- }
- }
-}
diff --git a/java/com/android/incallui/sessiondata/MultimediaFragment.java b/java/com/android/incallui/sessiondata/MultimediaFragment.java
index 175c779..2bac2f5 100644
--- a/java/com/android/incallui/sessiondata/MultimediaFragment.java
+++ b/java/com/android/incallui/sessiondata/MultimediaFragment.java
@@ -31,11 +31,12 @@
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
+
+import com.android.dialer.R;
import com.android.dialer.common.FragmentUtils;
import com.android.dialer.common.LogUtil;
import com.android.dialer.multimedia.MultimediaData;
import com.android.dialer.theme.base.ThemeComponent;
-import com.android.incallui.maps.MapsComponent;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.engine.GlideException;
@@ -118,25 +119,7 @@
boolean hasImage = getImageUri() != null;
boolean hasSubject = !TextUtils.isEmpty(getSubject());
- boolean hasMap = getLocation() != null;
- if (hasMap && MapsComponent.get(getContext()).getMaps().isAvailable()) {
- if (hasImage) {
- if (hasSubject) {
- LogUtil.i("MultimediaFragment.onCreateView", "show text, image, location layout");
- return layoutInflater.inflate(
- R.layout.fragment_composer_text_image_frag, viewGroup, false);
- } else {
- LogUtil.i("MultimediaFragment.onCreateView", "show image, location layout");
- return layoutInflater.inflate(R.layout.fragment_composer_image_frag, viewGroup, false);
- }
- } else if (hasSubject) {
- LogUtil.i("MultimediaFragment.onCreateView", "show text, location layout");
- return layoutInflater.inflate(R.layout.fragment_composer_text_frag, viewGroup, false);
- } else {
- LogUtil.i("MultimediaFragment.onCreateView", "show location layout");
- return layoutInflater.inflate(R.layout.fragment_composer_frag, viewGroup, false);
- }
- } else if (hasImage) {
+ if (hasImage) {
if (hasSubject) {
LogUtil.i("MultimediaFragment.onCreateView", "show text, image layout");
return layoutInflater.inflate(R.layout.fragment_composer_text_image, viewGroup, false);
@@ -209,12 +192,6 @@
FrameLayout fragmentHolder = view.findViewById(R.id.answer_message_frag);
if (fragmentHolder != null) {
fragmentHolder.setClipToOutline(true);
- Fragment mapFragment =
- MapsComponent.get(getContext()).getMaps().createStaticMapFragment(getLocation());
- getChildFragmentManager()
- .beginTransaction()
- .replace(R.id.answer_message_frag, mapFragment)
- .commitNow();
}
avatarImageView = view.findViewById(R.id.answer_message_avatar);
if (avatarImageView != null) {
diff --git a/packages.mk b/packages.mk
index 936fc3d..2691f77 100644
--- a/packages.mk
+++ b/packages.mk
@@ -10,8 +10,6 @@
com.android.dialer.assisteddialing \
com.android.dialer.assisteddialing.ui \
com.android.dialer.backup \
- com.android.dialer.binary.aosp.testing \
- com.android.dialer.binary.google \
com.android.dialer.blocking \
com.android.dialer.blockreportspam \
com.android.dialer.callcomposer \
@@ -89,7 +87,6 @@
com.android.incallui.answer.impl.hint \
com.android.incallui.audioroute \
com.android.incallui.autoresizetext \
- com.android.incallui.calllocation.impl \
com.android.incallui.callpending \
com.android.incallui.commontheme \
com.android.incallui.contactgrid \