Dialer: Remove CallLocation
* We only have a stub implementation, so the code doesn't do much
Change-Id: I340e2177119d72813697403f6124ed0f130465f4
diff --git a/java/com/android/dialer/binary/aosp/AospDialerRootComponent.java b/java/com/android/dialer/binary/aosp/AospDialerRootComponent.java
index 9963279..bc4fbd3 100644
--- a/java/com/android/dialer/binary/aosp/AospDialerRootComponent.java
+++ b/java/com/android/dialer/binary/aosp/AospDialerRootComponent.java
@@ -32,7 +32,6 @@
import com.android.dialer.simulator.impl.SimulatorModule;
import com.android.dialer.storage.StorageModule;
import com.android.dialer.theme.base.impl.AospThemeModule;
-import com.android.incallui.calllocation.stub.StubCallLocationModule;
import com.android.voicemail.impl.VoicemailModule;
import dagger.Component;
import javax.inject.Singleton;
@@ -54,7 +53,6 @@
PromotionModule.class,
SimulatorModule.class,
StorageModule.class,
- StubCallLocationModule.class,
StubSimSuggestionModule.class,
AospThemeModule.class,
VoicemailModule.class,
diff --git a/java/com/android/dialer/binary/basecomponent/BaseDialerRootComponent.java b/java/com/android/dialer/binary/basecomponent/BaseDialerRootComponent.java
index 0a9c2d3..997101c 100644
--- a/java/com/android/dialer/binary/basecomponent/BaseDialerRootComponent.java
+++ b/java/com/android/dialer/binary/basecomponent/BaseDialerRootComponent.java
@@ -34,7 +34,6 @@
import com.android.dialer.speeddial.loader.UiItemLoaderComponent;
import com.android.dialer.storage.StorageComponent;
import com.android.dialer.theme.base.ThemeComponent;
-import com.android.incallui.calllocation.CallLocationComponent;
import com.android.voicemail.VoicemailComponent;
/**
@@ -43,7 +42,6 @@
*/
public interface BaseDialerRootComponent
extends ActiveCallsComponent.HasComponent,
- CallLocationComponent.HasComponent,
CallLogComponent.HasComponent,
CallLogDatabaseComponent.HasComponent,
CallLogUiComponent.HasComponent,
diff --git a/java/com/android/incallui/CallCardPresenter.java b/java/com/android/incallui/CallCardPresenter.java
index f9f385c..0a25e1f 100644
--- a/java/com/android/incallui/CallCardPresenter.java
+++ b/java/com/android/incallui/CallCardPresenter.java
@@ -21,12 +21,10 @@
import android.Manifest;
import android.content.Context;
import android.content.Intent;
-import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.hardware.display.DisplayManager;
-import android.os.BatteryManager;
import android.os.Handler;
import android.os.Trace;
import android.support.v4.app.Fragment;
@@ -42,7 +40,6 @@
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
-import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.android.contacts.common.ContactsUtils;
@@ -66,8 +63,6 @@
import com.android.incallui.call.DialerCall;
import com.android.incallui.call.DialerCallListener;
import com.android.incallui.call.state.DialerCallState;
-import com.android.incallui.calllocation.CallLocation;
-import com.android.incallui.calllocation.CallLocationComponent;
import com.android.incallui.incall.protocol.ContactPhotoType;
import com.android.incallui.incall.protocol.InCallScreen;
import com.android.incallui.incall.protocol.InCallScreenDelegate;
@@ -119,8 +114,6 @@
private boolean isInCallScreenReady;
private boolean shouldSendAccessibilityEvent;
- @NonNull
- private final CallLocation callLocation;
private final Runnable sendAccessibilityEventRunnable =
new Runnable() {
@Override
@@ -139,7 +132,6 @@
public CallCardPresenter(Context context) {
LogUtil.i("CallCardPresenter.constructor", null);
this.context = Assert.isNotNull(context).getApplicationContext();
- callLocation = CallLocationComponent.get(this.context).getCallLocation();
}
private static boolean hasCallSubject(DialerCall call) {
@@ -186,11 +178,6 @@
InCallPresenter.getInstance().addDetailsListener(this);
InCallPresenter.getInstance().addInCallEventListener(this);
isInCallScreenReady = true;
-
- // Showing the location may have been skipped if the UI wasn't ready during previous layout.
- if (shouldShowLocation()) {
- inCallScreen.showLocationUi(getLocationFragment());
- }
}
@Override
@@ -207,8 +194,6 @@
primary.removeListener(this);
}
- callLocation.close();
-
primary = null;
primaryContactInfo = null;
secondaryContactInfo = null;
@@ -642,7 +627,6 @@
.setIsSpam(false)
.setIsLocalContact(false)
.setAnsweringDisconnectsOngoingCall(false)
- .setShouldShowLocation(shouldShowLocation())
.setShowInCallButtonGrid(true)
.setNumberPresentation(primary.getNumberPresentation())
.build());
@@ -692,7 +676,6 @@
.setIsSpam(primary.isSpam())
.setIsLocalContact(primaryContactInfo.isLocalContact())
.setAnsweringDisconnectsOngoingCall(primary.answeringDisconnectsForegroundVideoCall())
- .setShouldShowLocation(shouldShowLocation())
.setContactInfoLookupKey(primaryContactInfo.lookupKey)
.setMultimediaData(multimediaData)
.setShowInCallButtonGrid(true)
@@ -704,7 +687,7 @@
}
if (isInCallScreenReady) {
- inCallScreen.showLocationUi(getLocationFragment());
+ inCallScreen.showLocationUi(null);
} else {
LogUtil.i("CallCardPresenter.updatePrimaryDisplayInfo", "UI not ready, not showing location");
}
@@ -721,88 +704,6 @@
return false;
}
- private Fragment getLocationFragment() {
- if (!shouldShowLocation()) {
- return null;
- }
- LogUtil.i("CallCardPresenter.getLocationFragment", "returning location fragment");
- return callLocation.getLocationFragment(context);
- }
-
- private boolean shouldShowLocation() {
- if (!isPotentialEmergencyCall()) {
- LogUtil.i("CallCardPresenter.getLocationFragment", "shouldn't show location");
- return false;
- }
- if (!hasLocationPermission()) {
- LogUtil.i("CallCardPresenter.getLocationFragment", "no location permission.");
- return false;
- }
- if (isBatteryTooLowForEmergencyLocation()) {
- LogUtil.i("CallCardPresenter.getLocationFragment", "low battery.");
- return false;
- }
- if (inCallScreen.getInCallScreenFragment().getActivity().isInMultiWindowMode()) {
- LogUtil.i("CallCardPresenter.getLocationFragment", "in multi-window mode");
- return false;
- }
- if (primary.isVideoCall()) {
- LogUtil.i("CallCardPresenter.getLocationFragment", "emergency video calls not supported");
- return false;
- }
- if (!callLocation.canGetLocation(context)) {
- LogUtil.i("CallCardPresenter.getLocationFragment", "can't get current location");
- return false;
- }
- return true;
- }
-
- private boolean isPotentialEmergencyCall() {
- if (isOutgoingEmergencyCall(primary)) {
- LogUtil.i("CallCardPresenter.shouldShowLocation", "new emergency call");
- return true;
- } else if (isIncomingEmergencyCall(primary)) {
- LogUtil.i("CallCardPresenter.shouldShowLocation", "potential emergency callback");
- return true;
- } else if (isIncomingEmergencyCall(secondary)) {
- LogUtil.i("CallCardPresenter.shouldShowLocation", "has potential emergency callback");
- return true;
- }
- return false;
- }
-
- private static boolean isOutgoingEmergencyCall(@Nullable DialerCall call) {
- return call != null && !call.isIncoming() && call.isEmergencyCall();
- }
-
- private static boolean isIncomingEmergencyCall(@Nullable DialerCall call) {
- return call != null && call.isIncoming() && call.isPotentialEmergencyCallback();
- }
-
- private boolean hasLocationPermission() {
- return ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION)
- == PackageManager.PERMISSION_GRANTED;
- }
-
- private boolean isBatteryTooLowForEmergencyLocation() {
- Intent batteryStatus =
- context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
- int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
- if (status == BatteryManager.BATTERY_STATUS_CHARGING
- || status == BatteryManager.BATTERY_STATUS_FULL) {
- // Plugged in or full battery
- return false;
- }
- int level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
- int scale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
- float batteryPercent = (100f * level) / scale;
- long threshold = CONFIG_MIN_BATTERY_PERCENT_FOR_EMERGENCY_LOCATION_DEFAULT;
- LogUtil.i(
- "CallCardPresenter.isBatteryTooLowForEmergencyLocation",
- "percent charged: " + batteryPercent + ", min required charge: " + threshold);
- return batteryPercent < threshold;
- }
-
private void updateSecondaryDisplayInfo() {
if (inCallScreen == null) {
return;
diff --git a/java/com/android/incallui/answer/impl/AnswerFragment.java b/java/com/android/incallui/answer/impl/AnswerFragment.java
index 23362ba..c048640 100644
--- a/java/com/android/incallui/answer/impl/AnswerFragment.java
+++ b/java/com/android/incallui/answer/impl/AnswerFragment.java
@@ -535,11 +535,6 @@
.setContactPhoto(
primaryInfo.photoType() == ContactPhotoType.CONTACT ? primaryInfo.photo() : null);
updateDataFragment();
-
- if (primaryInfo.shouldShowLocation()) {
- // Hide the avatar to make room for location
- contactGridManager.setAvatarHidden(true);
- }
}
private void updateDataFragment() {
diff --git a/java/com/android/incallui/calllocation/CallLocation.java b/java/com/android/incallui/calllocation/CallLocation.java
deleted file mode 100644
index 486755e..0000000
--- a/java/com/android/incallui/calllocation/CallLocation.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.calllocation;
-
-import android.content.Context;
-import android.support.v4.app.Fragment;
-
-import androidx.annotation.NonNull;
-
-/** Used to show the user's location during an emergency call. */
-public interface CallLocation {
-
- boolean canGetLocation(@NonNull Context context);
-
- @NonNull
- Fragment getLocationFragment(@NonNull Context context);
-
- void close();
-}
diff --git a/java/com/android/incallui/calllocation/CallLocationComponent.java b/java/com/android/incallui/calllocation/CallLocationComponent.java
deleted file mode 100644
index 46ca669..0000000
--- a/java/com/android/incallui/calllocation/CallLocationComponent.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.calllocation;
-
-import android.content.Context;
-import com.android.dialer.inject.HasRootComponent;
-import dagger.Subcomponent;
-
-/** Subcomponent that can be used to access the call location implementation. */
-@Subcomponent
-public abstract class CallLocationComponent {
-
- public abstract CallLocation getCallLocation();
-
- public static CallLocationComponent get(Context context) {
- return ((HasComponent) ((HasRootComponent) context.getApplicationContext()).component())
- .callLocationComponent();
- }
-
- /** Used to refer to the root application component. */
- public interface HasComponent {
- CallLocationComponent callLocationComponent();
- }
-}
diff --git a/java/com/android/incallui/calllocation/stub/StubCallLocationModule.java b/java/com/android/incallui/calllocation/stub/StubCallLocationModule.java
deleted file mode 100644
index 6578de5..0000000
--- a/java/com/android/incallui/calllocation/stub/StubCallLocationModule.java
+++ /dev/null
@@ -1,56 +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.stub;
-
-import android.content.Context;
-import android.support.v4.app.Fragment;
-
-import androidx.annotation.NonNull;
-
-import com.android.dialer.common.Assert;
-import com.android.incallui.calllocation.CallLocation;
-import dagger.Binds;
-import dagger.Module;
-import javax.inject.Inject;
-
-/** This module provides an instance of call location. */
-@Module
-public abstract class StubCallLocationModule {
-
- @Binds
- public abstract CallLocation bindCallLocation(StubCallLocation callLocation);
-
- static class StubCallLocation implements CallLocation {
- @Inject
- StubCallLocation() {}
-
- @Override
- public boolean canGetLocation(@NonNull Context context) {
- return false;
- }
-
- @Override
- @NonNull
- public Fragment getLocationFragment(@NonNull Context context) {
- throw Assert.createUnsupportedOperationFailException();
- }
-
- @Override
- public void close() {
- }
- }
-}
diff --git a/java/com/android/incallui/callpending/CallPendingActivity.java b/java/com/android/incallui/callpending/CallPendingActivity.java
index 93f370c..a93da7a 100644
--- a/java/com/android/incallui/callpending/CallPendingActivity.java
+++ b/java/com/android/incallui/callpending/CallPendingActivity.java
@@ -178,7 +178,6 @@
.setIsSpam(false)
.setIsLocalContact(true)
.setAnsweringDisconnectsOngoingCall(false)
- .setShouldShowLocation(false)
.setContactInfoLookupKey(getLookupKey())
.setMultimediaData(null)
.setShowInCallButtonGrid(false)
diff --git a/java/com/android/incallui/contactgrid/ContactGridManager.java b/java/com/android/incallui/contactgrid/ContactGridManager.java
index 78c80ee..d71999f 100644
--- a/java/com/android/incallui/contactgrid/ContactGridManager.java
+++ b/java/com/android/incallui/contactgrid/ContactGridManager.java
@@ -435,8 +435,5 @@
BidiFormatter.getInstance()
.unicodeWrap(primaryCallState.callbackNumber(), TextDirectionHeuristics.LTR)));
deviceNumberTextView.setVisibility(View.VISIBLE);
- if (primaryInfo.shouldShowLocation()) {
- deviceNumberDivider.setVisibility(View.VISIBLE);
- }
}
}
diff --git a/java/com/android/incallui/incall/impl/InCallFragment.java b/java/com/android/incallui/incall/impl/InCallFragment.java
index 0e6776c..8f4a575 100644
--- a/java/com/android/incallui/incall/impl/InCallFragment.java
+++ b/java/com/android/incallui/incall/impl/InCallFragment.java
@@ -37,10 +37,8 @@
import android.view.Window;
import android.view.accessibility.AccessibilityEvent;
import android.widget.ImageView;
-import android.widget.RelativeLayout;
import android.widget.Toast;
-import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -275,19 +273,6 @@
LogUtil.i("InCallFragment.setPrimary", primaryInfo.toString());
setAdapterMedia(primaryInfo.multimediaData(), primaryInfo.showInCallButtonGrid());
contactGridManager.setPrimary(primaryInfo);
-
- if (primaryInfo.shouldShowLocation()) {
- // Hide the avatar to make room for location
- contactGridManager.setAvatarHidden(true);
-
- // Need to let the dialpad move up a little further when location info is being shown
- View dialpadView = getView().findViewById(R.id.incall_dialpad_container);
- ViewGroup.LayoutParams params = dialpadView.getLayoutParams();
- if (params instanceof RelativeLayout.LayoutParams) {
- ((RelativeLayout.LayoutParams) params).removeRule(RelativeLayout.BELOW);
- }
- dialpadView.setLayoutParams(params);
- }
}
private void setAdapterMedia(MultimediaData multimediaData, boolean showInCallButtonGrid) {
diff --git a/java/com/android/incallui/incall/protocol/PrimaryInfo.java b/java/com/android/incallui/incall/protocol/PrimaryInfo.java
index 5c1246c..05787bc 100644
--- a/java/com/android/incallui/incall/protocol/PrimaryInfo.java
+++ b/java/com/android/incallui/incall/protocol/PrimaryInfo.java
@@ -64,7 +64,6 @@
public abstract boolean answeringDisconnectsOngoingCall();
- public abstract boolean shouldShowLocation();
// Used for consistent LetterTile coloring.
@Nullable
public abstract String contactInfoLookupKey();
@@ -112,8 +111,6 @@
public abstract Builder setAnsweringDisconnectsOngoingCall(
boolean answeringDisconnectsOngoingCall);
- public abstract Builder setShouldShowLocation(boolean shouldShowLocation);
-
public abstract Builder setContactInfoLookupKey(String contactInfoLookupKey);
public abstract Builder setMultimediaData(MultimediaData multimediaData);
@@ -135,7 +132,6 @@
.setIsSpam(false)
.setIsLocalContact(false)
.setAnsweringDisconnectsOngoingCall(false)
- .setShouldShowLocation(false)
.setShowInCallButtonGrid(true)
.setNumberPresentation(-1)
.build();