diff options
author | Alec Mouri <alecmouri@google.com> | 2021-02-17 00:18:55 +0000 |
---|---|---|
committer | Dave Mankoff <mankoff@google.com> | 2021-02-18 11:39:15 -0500 |
commit | f23acf33ff3684586b7dc66026b518ada77eed84 (patch) | |
tree | 6bc6d3e0db9ade40b47a64f79f7b1ed068c58fd8 /packages/SystemUI/src/com/android/keyguard/EmergencyButtonController.java | |
parent | 5f65ded5af704ad6f41716a635649e79b557bab8 (diff) |
Revert "Add Controller for Emergency Button."
Revert submission 13536242-b179775696-depenency-get-keyguard
Reason for revert: Candidate reversion for broken tests: b/180440298
Reverted Changes:
I6d0271692:Add ViewController to CarrierText.
I4d9a4a21f:Add Controller for Emergency Button.
I4c76d99f9:Remove Dependency.get from KeyguardSliceTextView.
I730593fcf:Add injection to ClockProvider.
Ifbb93e624:Remove Dependency.get from KeyguardStatusView.
I237215456:Remove final calls to Dependency.get from keyguard...
Change-Id: I7b46dbad24050cfe6a363131549169602fda1f13
Diffstat (limited to 'packages/SystemUI/src/com/android/keyguard/EmergencyButtonController.java')
-rw-r--r-- | packages/SystemUI/src/com/android/keyguard/EmergencyButtonController.java | 196 |
1 files changed, 0 insertions, 196 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/EmergencyButtonController.java b/packages/SystemUI/src/com/android/keyguard/EmergencyButtonController.java deleted file mode 100644 index 4275189cfe26..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/EmergencyButtonController.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (C) 2021 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.keyguard; - -import static com.android.systemui.DejankUtils.whitelistIpcs; - -import android.app.ActivityOptions; -import android.app.ActivityTaskManager; -import android.content.Intent; -import android.content.res.Configuration; -import android.os.PowerManager; -import android.os.SystemClock; -import android.os.UserHandle; -import android.telecom.TelecomManager; -import android.telephony.TelephonyManager; -import android.util.Log; - -import androidx.annotation.Nullable; - -import com.android.internal.logging.MetricsLogger; -import com.android.internal.logging.nano.MetricsProto.MetricsEvent; -import com.android.keyguard.dagger.KeyguardBouncerScope; -import com.android.systemui.statusbar.policy.ConfigurationController; -import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener; -import com.android.systemui.util.EmergencyDialerConstants; -import com.android.systemui.util.ViewController; - -import javax.inject.Inject; - -/** View Controller for {@link com.android.keyguard.EmergencyButton}. */ -@KeyguardBouncerScope -public class EmergencyButtonController extends ViewController<EmergencyButton> { - static final String LOG_TAG = "EmergencyButton"; - private final ConfigurationController mConfigurationController; - private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; - private final TelephonyManager mTelephonyManager; - private final PowerManager mPowerManager; - private final ActivityTaskManager mActivityTaskManager; - private final TelecomManager mTelecomManager; - private final MetricsLogger mMetricsLogger; - - private EmergencyButtonCallback mEmergencyButtonCallback; - - private final KeyguardUpdateMonitorCallback mInfoCallback = - new KeyguardUpdateMonitorCallback() { - @Override - public void onSimStateChanged(int subId, int slotId, int simState) { - updateEmergencyCallButton(); - } - - @Override - public void onPhoneStateChanged(int phoneState) { - updateEmergencyCallButton(); - } - }; - - private final ConfigurationListener mConfigurationListener = new ConfigurationListener() { - @Override - public void onConfigChanged(Configuration newConfig) { - updateEmergencyCallButton(); - } - }; - - private EmergencyButtonController(@Nullable EmergencyButton view, - ConfigurationController configurationController, - KeyguardUpdateMonitor keyguardUpdateMonitor, TelephonyManager telephonyManager, - PowerManager powerManager, ActivityTaskManager activityTaskManager, - @Nullable TelecomManager telecomManager, MetricsLogger metricsLogger) { - super(view); - mConfigurationController = configurationController; - mKeyguardUpdateMonitor = keyguardUpdateMonitor; - mTelephonyManager = telephonyManager; - mPowerManager = powerManager; - mActivityTaskManager = activityTaskManager; - mTelecomManager = telecomManager; - mMetricsLogger = metricsLogger; - } - - @Override - protected void onInit() { - whitelistIpcs(this::updateEmergencyCallButton); - } - - @Override - protected void onViewAttached() { - mKeyguardUpdateMonitor.registerCallback(mInfoCallback); - mConfigurationController.addCallback(mConfigurationListener); - mView.setOnClickListener(v -> takeEmergencyCallAction()); - } - - @Override - protected void onViewDetached() { - mKeyguardUpdateMonitor.removeCallback(mInfoCallback); - mConfigurationController.removeCallback(mConfigurationListener); - } - - private void updateEmergencyCallButton() { - if (mView != null) { - mView.updateEmergencyCallButton( - mTelecomManager != null && mTelecomManager.isInCall(), - mTelephonyManager.isVoiceCapable(), - mKeyguardUpdateMonitor.isSimPinVoiceSecure()); - } - } - - public void setEmergencyButtonCallback(EmergencyButtonCallback callback) { - mEmergencyButtonCallback = callback; - } - /** - * Shows the emergency dialer or returns the user to the existing call. - */ - public void takeEmergencyCallAction() { - mMetricsLogger.action(MetricsEvent.ACTION_EMERGENCY_CALL); - if (mPowerManager != null) { - mPowerManager.userActivity(SystemClock.uptimeMillis(), true); - } - mActivityTaskManager.stopSystemLockTaskMode(); - if (mTelecomManager != null && mTelecomManager.isInCall()) { - mTelecomManager.showInCallScreen(false); - if (mEmergencyButtonCallback != null) { - mEmergencyButtonCallback.onEmergencyButtonClickedWhenInCall(); - } - } else { - mKeyguardUpdateMonitor.reportEmergencyCallAction(true /* bypassHandler */); - if (mTelecomManager == null) { - Log.wtf(LOG_TAG, "TelecomManager was null, cannot launch emergency dialer"); - return; - } - Intent emergencyDialIntent = - mTelecomManager.createLaunchEmergencyDialerIntent(null /* number*/) - .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK - | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS - | Intent.FLAG_ACTIVITY_CLEAR_TOP) - .putExtra(EmergencyDialerConstants.EXTRA_ENTRY_TYPE, - EmergencyDialerConstants.ENTRY_TYPE_LOCKSCREEN_BUTTON); - - getContext().startActivityAsUser(emergencyDialIntent, - ActivityOptions.makeCustomAnimation(getContext(), 0, 0).toBundle(), - new UserHandle(KeyguardUpdateMonitor.getCurrentUser())); - } - } - - /** */ - public interface EmergencyButtonCallback { - /** */ - void onEmergencyButtonClickedWhenInCall(); - } - - /** Injectable Factory for creating {@link EmergencyButtonController}. */ - public static class Factory { - private final ConfigurationController mConfigurationController; - private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; - private final TelephonyManager mTelephonyManager; - private final PowerManager mPowerManager; - private final ActivityTaskManager mActivityTaskManager; - @Nullable - private final TelecomManager mTelecomManager; - private final MetricsLogger mMetricsLogger; - - @Inject - public Factory(ConfigurationController configurationController, - KeyguardUpdateMonitor keyguardUpdateMonitor, TelephonyManager telephonyManager, - PowerManager powerManager, ActivityTaskManager activityTaskManager, - @Nullable TelecomManager telecomManager, MetricsLogger metricsLogger) { - - mConfigurationController = configurationController; - mKeyguardUpdateMonitor = keyguardUpdateMonitor; - mTelephonyManager = telephonyManager; - mPowerManager = powerManager; - mActivityTaskManager = activityTaskManager; - mTelecomManager = telecomManager; - mMetricsLogger = metricsLogger; - } - - /** Construct an {@link com.android.keyguard.EmergencyButtonController}. */ - public EmergencyButtonController create(EmergencyButton view) { - return new EmergencyButtonController(view, mConfigurationController, - mKeyguardUpdateMonitor, mTelephonyManager, mPowerManager, mActivityTaskManager, - mTelecomManager, mMetricsLogger); - } - } -} |