Merge "Add extra data when starting emergency dialer intent"

This commit is contained in:
Shaotang Li
2018-09-17 04:14:51 +00:00
committed by Gerrit Code Review
3 changed files with 47 additions and 6 deletions

View File

@@ -38,6 +38,7 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.telephony.IccCardConstants.State;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.util.EmergencyAffordanceManager;
import com.android.systemui.util.EmergencyDialerConstants;
/**
* This class implements a smart emergency button that updates itself based
@@ -47,11 +48,13 @@ import com.android.internal.util.EmergencyAffordanceManager;
*/
public class EmergencyButton extends Button {
private static final Intent INTENT_EMERGENCY_DIAL = new Intent()
.setAction("com.android.phone.EmergencyDialer.DIAL")
.setAction(EmergencyDialerConstants.ACTION_DIAL)
.setPackage("com.android.phone")
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
| Intent.FLAG_ACTIVITY_CLEAR_TOP)
.putExtra(EmergencyDialerConstants.EXTRA_ENTRY_TYPE,
EmergencyDialerConstants.ENTRY_TYPE_LOCKSCREEN_BUTTON);
private static final String LOG_TAG = "EmergencyButton";
private final EmergencyAffordanceManager mEmergencyAffordanceManager;

View File

@@ -89,6 +89,7 @@ import com.android.systemui.Interpolators;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.plugins.GlobalActions.GlobalActionsManager;
import com.android.systemui.statusbar.phone.ScrimController;
import com.android.systemui.util.EmergencyDialerConstants;
import com.android.systemui.volume.SystemUIInterpolators.LogAccelerateInterpolator;
import java.util.ArrayList;
@@ -448,9 +449,6 @@ class GlobalActionsDialog implements DialogInterface.OnDismissListener,
}
private class EmergencyDialerAction extends SinglePressAction {
private static final String ACTION_EMERGENCY_DIALER_DIAL =
"com.android.phone.EmergencyDialer.DIAL";
private EmergencyDialerAction() {
super(R.drawable.ic_faster_emergency,
R.string.global_action_emergency);
@@ -458,8 +456,10 @@ class GlobalActionsDialog implements DialogInterface.OnDismissListener,
@Override
public void onPress() {
Intent intent = new Intent(ACTION_EMERGENCY_DIALER_DIAL);
Intent intent = new Intent(EmergencyDialerConstants.ACTION_DIAL);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra(EmergencyDialerConstants.EXTRA_ENTRY_TYPE,
EmergencyDialerConstants.ENTRY_TYPE_POWER_MENU);
mContext.startActivityAsUser(intent, UserHandle.CURRENT);
}

View File

@@ -0,0 +1,38 @@
/*
* 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.systemui.util;
/**
* Constants defined and used in emergency dialer.
* Please keep these constants being consistent with those in com.android.phone.EmergencyDialer.
*/
public class EmergencyDialerConstants {
// Intent action for emergency dialer activity.
public static final String ACTION_DIAL = "com.android.phone.EmergencyDialer.DIAL";
/**
* Extra included in {@link #ACTION_DIAL} to indicate the entry type that user starts
* the emergency dialer.
*/
public static final String EXTRA_ENTRY_TYPE =
"com.android.phone.EmergencyDialer.extra.ENTRY_TYPE";
// Indicating the entrance to emergency dialer
public static final int ENTRY_TYPE_UNKNOWN = 0;
public static final int ENTRY_TYPE_LOCKSCREEN_BUTTON = 1;
public static final int ENTRY_TYPE_POWER_MENU = 2;
}