Merge "Add shell commands for carrier config debugging"
diff --git a/src/com/android/phone/CallFeaturesSetting.java b/src/com/android/phone/CallFeaturesSetting.java
index 320fc24..29df8b8 100644
--- a/src/com/android/phone/CallFeaturesSetting.java
+++ b/src/com/android/phone/CallFeaturesSetting.java
@@ -202,7 +202,8 @@
if (DBG) log("onCreate: Intent is " + getIntent());
// Make sure we are running as an admin user.
- if (!UserManager.get(this).isAdminUser()) {
+ UserManager userManager = (UserManager) getSystemService(Context.USER_SERVICE);
+ if (!userManager.isAdminUser()) {
Toast.makeText(this, R.string.call_settings_admin_user_only,
Toast.LENGTH_SHORT).show();
finish();
diff --git a/src/com/android/phone/CarrierConfigLoader.java b/src/com/android/phone/CarrierConfigLoader.java
index 9edd0aa..874c412 100644
--- a/src/com/android/phone/CarrierConfigLoader.java
+++ b/src/com/android/phone/CarrierConfigLoader.java
@@ -141,6 +141,8 @@
private static final int EVENT_FETCH_CARRIER_TIMEOUT = 15;
// SubscriptionInfoUpdater has finished updating the sub for the carrier config.
private static final int EVENT_SUBSCRIPTION_INFO_UPDATED = 16;
+ // Multi-SIM config changed.
+ private static final int EVENT_MULTI_SIM_CONFIG_CHANGED = 17;
private static final int BIND_TIMEOUT_MILLIS = 30000;
@@ -174,28 +176,21 @@
public void handleMessage(Message msg) {
final int phoneId = msg.arg1;
logWithLocalLog("mHandler: " + msg.what + " phoneId: " + phoneId);
+ if (!SubscriptionManager.isValidPhoneId(phoneId)
+ && msg.what != EVENT_MULTI_SIM_CONFIG_CHANGED) {
+ return;
+ }
switch (msg.what) {
case EVENT_CLEAR_CONFIG:
{
- /* Ignore clear configuration request if device is being shutdown. */
- Phone phone = PhoneFactory.getPhone(phoneId);
- if (phone != null) {
- if (phone.isShuttingDown()) {
- break;
- }
- }
-
- mConfigFromDefaultApp[phoneId] = null;
- mConfigFromCarrierApp[phoneId] = null;
- mServiceConnection[phoneId] = null;
- broadcastConfigChangedIntent(phoneId, false);
+ clearConfigForPhone(phoneId, true);
break;
}
case EVENT_SYSTEM_UNLOCKED:
{
- for (int i = 0; i < TelephonyManager.from(mContext)
- .getSupportedModemCount(); ++i) {
+ for (int i = 0; i < TelephonyManager.from(mContext).getActiveModemCount();
+ ++i) {
// When user unlock device, we should only try to send broadcast again if we
// have sent it before unlock. This will avoid we try to load carrier config
// when SIM is still loading when unlock happens.
@@ -212,8 +207,7 @@
// Only update if there are cached config removed to avoid updating config for
// unrelated packages.
if (clearCachedConfigForPackage(carrierPackageName)) {
- int numPhones = TelephonyManager.from(mContext)
- .getSupportedModemCount();
+ int numPhones = TelephonyManager.from(mContext).getActiveModemCount();
for (int i = 0; i < numPhones; ++i) {
updateConfigForPhoneId(i);
}
@@ -496,6 +490,9 @@
case EVENT_SUBSCRIPTION_INFO_UPDATED:
broadcastConfigChangedIntent(phoneId);
break;
+ case EVENT_MULTI_SIM_CONFIG_CHANGED:
+ onMultiSimConfigChanged();
+ break;
}
}
}
@@ -555,6 +552,23 @@
}
}
+ private void clearConfigForPhone(int phoneId, boolean sendBroadcast) {
+ /* Ignore clear configuration request if device is being shutdown. */
+ Phone phone = PhoneFactory.getPhone(phoneId);
+ if (phone != null) {
+ if (phone.isShuttingDown()) {
+ return;
+ }
+ }
+
+ mConfigFromDefaultApp[phoneId] = null;
+ mConfigFromCarrierApp[phoneId] = null;
+ mServiceConnection[phoneId] = null;
+ mHasSentConfigChange[phoneId] = false;
+
+ if (sendBroadcast) broadcastConfigChangedIntent(phoneId, false);
+ }
+
private void notifySubscriptionInfoUpdater(int phoneId) {
String configPackagename;
PersistableBundle configToSend;
@@ -920,6 +934,13 @@
mHandler.sendMessage(mHandler.obtainMessage(EVENT_DO_FETCH_DEFAULT, phoneId, -1));
}
+ private void onMultiSimConfigChanged() {
+ for (int i = TelephonyManager.from(mContext).getActiveModemCount();
+ i < mConfigFromDefaultApp.length; i++) {
+ clearConfigForPhone(i, false);
+ }
+ }
+
@Override
public @NonNull PersistableBundle getConfigForSubId(int subId, String callingPackage) {
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
diff --git a/src/com/android/phone/EmergencyDialer.java b/src/com/android/phone/EmergencyDialer.java
index f5c14b9..c20281a 100644
--- a/src/com/android/phone/EmergencyDialer.java
+++ b/src/com/android/phone/EmergencyDialer.java
@@ -70,9 +70,6 @@
import android.view.accessibility.AccessibilityEvent;
import android.widget.TextView;
-import com.android.phone.EmergencyDialerMetricsLogger.DialedFrom;
-import com.android.phone.EmergencyDialerMetricsLogger.PhoneNumberType;
-import com.android.phone.EmergencyDialerMetricsLogger.UiModeErrorCode;
import com.android.phone.common.dialpad.DialpadKeyButton;
import com.android.phone.common.util.ViewUtil;
import com.android.phone.common.widget.ResizingTextEditText;
@@ -221,8 +218,6 @@
private int mEntryType;
private ShortcutViewUtils.Config mShortcutViewConfig;
- private EmergencyDialerMetricsLogger mMetricsLogger;
-
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// Do nothing
@@ -257,8 +252,6 @@
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
- mMetricsLogger = new EmergencyDialerMetricsLogger(this);
-
mEntryType = getIntent().getIntExtra(EXTRA_ENTRY_TYPE, ENTRY_TYPE_UNKNOWN);
Log.d(LOG_TAG, "Launched from " + entryTypeToString(mEntryType));
@@ -498,10 +491,6 @@
if (!TextUtils.isEmpty(phoneNumber)) {
if (DBG) Log.d(LOG_TAG, "dial emergency number: " + Rlog.pii(LOG_TAG, phoneNumber));
- // Write metrics when user has intention to make a call from a shortcut button.
- mMetricsLogger.logPlaceCall(DialedFrom.SHORTCUT, PhoneNumberType.HAS_SHORTCUT,
- mShortcutViewConfig.getPhoneInfo());
-
placeCall(phoneNumber, ParcelableCallAnalytics.CALL_SOURCE_EMERGENCY_SHORTCUT,
mShortcutViewConfig.getPhoneInfo());
} else {
@@ -638,10 +627,6 @@
protected void onStart() {
super.onStart();
- mMetricsLogger.logLaunchEmergencyDialer(mEntryType,
- mShortcutViewConfig.isEnabled() ? UiModeErrorCode.SUCCESS
- : UiModeErrorCode.UNSPECIFIED_ERROR);
-
if (mShortcutViewConfig.isEnabled()) {
// Shortcut view doesn't support dark text theme.
mBackgroundDrawable.setColor(Color.BLACK);
@@ -745,28 +730,20 @@
// nothing and just returns input number.
mLastNumber = PhoneNumberUtils.convertToEmergencyNumber(this, mLastNumber);
- @DialedFrom final int dialedFrom =
- mShortcutViewConfig.isEnabled() ? DialedFrom.FASTER_LAUNCHER_DIALPAD
- : DialedFrom.TRADITIONAL_DIALPAD;
- @PhoneNumberType final int phoneNumberType;
-
boolean isEmergencyNumber;
ShortcutViewUtils.PhoneInfo phoneToMakeCall = null;
if (mShortcutAdapter != null && mShortcutAdapter.hasShortcut(mLastNumber)) {
isEmergencyNumber = true;
phoneToMakeCall = mShortcutViewConfig.getPhoneInfo();
- phoneNumberType = PhoneNumberType.HAS_SHORTCUT;
} else if (mShortcutViewConfig.hasPromotedEmergencyNumber(mLastNumber)) {
// If a number from SIM/network/... is categoried as police/ambulance/fire,
// hasPromotedEmergencyNumber() will return true, but it maybe not promoted as a
// shortcut button because a number provided by database has higher priority.
isEmergencyNumber = true;
phoneToMakeCall = mShortcutViewConfig.getPhoneInfo();
- phoneNumberType = PhoneNumberType.NO_SHORTCUT;
} else {
isEmergencyNumber = getSystemService(TelephonyManager.class)
.isEmergencyNumber(mLastNumber);
- phoneNumberType = PhoneNumberType.NO_SHORTCUT;
}
if (isEmergencyNumber) {
@@ -779,19 +756,11 @@
return;
}
- // Write metrics when user has intention to make a call from dialpad
- mMetricsLogger.logPlaceCall(dialedFrom, phoneNumberType, phoneToMakeCall);
-
placeCall(mLastNumber, ParcelableCallAnalytics.CALL_SOURCE_EMERGENCY_DIALPAD,
phoneToMakeCall);
} else {
if (DBG) Log.d(LOG_TAG, "rejecting bad requested number " + mLastNumber);
- // Write metrics when user has intention to make a call of a non-emergency number, even
- // this number is rejected.
- mMetricsLogger.logPlaceCall(dialedFrom, PhoneNumberType.NOT_EMERGENCY_NUMBER,
- phoneToMakeCall);
-
showDialog(BAD_EMERGENCY_NUMBER_DIALOG);
}
mDigits.getText().delete(0, mDigits.getText().length());
diff --git a/src/com/android/phone/EmergencyDialerMetricsLogger.java b/src/com/android/phone/EmergencyDialerMetricsLogger.java
deleted file mode 100644
index b9ba352..0000000
--- a/src/com/android/phone/EmergencyDialerMetricsLogger.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Copyright (C) 2019 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.phone;
-
-import android.annotation.IntDef;
-import android.app.KeyguardManager;
-import android.content.Context;
-import android.metrics.LogMaker;
-import android.os.Build;
-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 java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * EmergencyCallMetricsLogger is a utility to collect metrics of emergency calls
- */
-class EmergencyDialerMetricsLogger {
- private static final String LOG_TAG = "EmergencyDialerLogger";
-
- @IntDef({
- DialedFrom.TRADITIONAL_DIALPAD,
- DialedFrom.SHORTCUT,
- DialedFrom.FASTER_LAUNCHER_DIALPAD,
- })
- @Retention(RetentionPolicy.SOURCE)
- @interface DialedFrom {
- int TRADITIONAL_DIALPAD = 0;
- int SHORTCUT = 1;
- int FASTER_LAUNCHER_DIALPAD = 2;
- }
-
- @IntDef({
- LaunchedFrom.UNDEFINED,
- LaunchedFrom.LOCK_SCREEN,
- LaunchedFrom.POWER_KEY_MENU,
- })
- @Retention(RetentionPolicy.SOURCE)
- @interface LaunchedFrom {
- int UNDEFINED = 0;
- int LOCK_SCREEN = 1;
- int POWER_KEY_MENU = 2;
- }
-
- @IntDef({
- PhoneNumberType.HAS_SHORTCUT,
- PhoneNumberType.NO_SHORTCUT,
- PhoneNumberType.NOT_EMERGENCY_NUMBER,
- })
- @Retention(RetentionPolicy.SOURCE)
- @interface PhoneNumberType {
- int HAS_SHORTCUT = 0;
- int NO_SHORTCUT = 1;
- int NOT_EMERGENCY_NUMBER = 2;
- }
-
- @IntDef({
- UiModeErrorCode.UNSPECIFIED_ERROR,
- UiModeErrorCode.SUCCESS,
- UiModeErrorCode.CONFIG_ENTRY_POINT,
- UiModeErrorCode.CONFIG_SIM_OPERATOR,
- UiModeErrorCode.UNSUPPORTED_COUNTRY,
- UiModeErrorCode.AIRPLANE_MODE,
- UiModeErrorCode.NO_PROMOTED_NUMBER,
- UiModeErrorCode.NO_CAPABLE_PHONE,
- })
- @Retention(RetentionPolicy.SOURCE)
- @interface UiModeErrorCode {
- int UNSPECIFIED_ERROR = -1;
- int SUCCESS = 0;
- int CONFIG_ENTRY_POINT = 1;
- int CONFIG_SIM_OPERATOR = 2;
- int UNSUPPORTED_COUNTRY = 3;
- int AIRPLANE_MODE = 4;
- int NO_PROMOTED_NUMBER = 5;
- int NO_CAPABLE_PHONE = 6;
- }
-
- private class TelephonyInfo {
- private final String mNetworkCountryIso;
- private final String mNetworkOperator;
-
- TelephonyInfo(String networkCountryIso, String networkOperator) {
- mNetworkCountryIso = networkCountryIso;
- mNetworkOperator = networkOperator;
- }
- }
-
- private final MetricsLogger mMetricsLogger = new MetricsLogger();
-
- private final Context mAppContext;
-
- @LaunchedFrom
- private int mLaunchedFrom;
- @UiModeErrorCode
- private int mUiModeErrorCode;
-
- EmergencyDialerMetricsLogger(Context context) {
- mAppContext = context.getApplicationContext();
- }
-
- /**
- * Log when Emergency Dialer is launched.
- * - Where the user launch Emergency Dialer from.
- * - Whether shortcut view is enabled, and the reason why it's not enabled.
- *
- * @param entryType
- * @param uiModeErrorCode
- */
- public void logLaunchEmergencyDialer(int entryType,
- @UiModeErrorCode int uiModeErrorCode) {
- final @EmergencyDialerMetricsLogger.LaunchedFrom int launchedFrom;
- if (entryType == EmergencyDialer.ENTRY_TYPE_LOCKSCREEN_BUTTON) {
- launchedFrom = EmergencyDialerMetricsLogger.LaunchedFrom.LOCK_SCREEN;
- } else if (entryType == EmergencyDialer.ENTRY_TYPE_POWER_MENU) {
- launchedFrom = EmergencyDialerMetricsLogger.LaunchedFrom.POWER_KEY_MENU;
- } else {
- launchedFrom = EmergencyDialerMetricsLogger.LaunchedFrom.UNDEFINED;
- }
-
- mLaunchedFrom = launchedFrom;
- mUiModeErrorCode = uiModeErrorCode;
- }
-
- /**
- * Log when user tring to place an emergency call.
- * - Which UI (traditional dialpad, shortcut button, dialpad in shortcut view) the user place
- * the call from.
- * - The number is promoted in shortcut view or not, or not even an emergency number?
- * - Whether the device is locked.
- * - Network country ISO and network operator.
- *
- * @param dialedFrom
- * @param phoneNumberType
- * @param phoneInfo
- */
- public void logPlaceCall(@DialedFrom int dialedFrom,
- @PhoneNumberType int phoneNumberType,
- @Nullable ShortcutViewUtils.PhoneInfo phoneInfo) {
- TelephonyInfo telephonyInfo = getTelephonyInfo(phoneNumberType, phoneInfo);
- final KeyguardManager keyguard = mAppContext.getSystemService(KeyguardManager.class);
-
- logBeforeMakeCall(dialedFrom, phoneNumberType, keyguard.isKeyguardLocked(),
- telephonyInfo.mNetworkCountryIso, telephonyInfo.mNetworkOperator);
- }
-
- private TelephonyInfo getTelephonyInfo(@PhoneNumberType int phoneNumberType,
- @Nullable ShortcutViewUtils.PhoneInfo phoneInfo) {
- final TelephonyManager telephonyManager = mAppContext.getSystemService(
- TelephonyManager.class);
- final TelephonyManager subTelephonyManager;
- final String networkCountryIso;
- final String networkOperator;
- if (phoneNumberType == PhoneNumberType.HAS_SHORTCUT && phoneInfo != null) {
- subTelephonyManager = telephonyManager.createForSubscriptionId(phoneInfo.getSubId());
- networkCountryIso = phoneInfo.getCountryIso();
- } else {
- // No specific phone to make this call. Take information of default network.
- subTelephonyManager = null;
- networkCountryIso = telephonyManager.getNetworkCountryIso();
- }
- if (subTelephonyManager != null) {
- networkOperator = subTelephonyManager.getNetworkOperator();
- } else {
- // This could be:
- // - No specific phone to make this call.
- // - Subscription changed! Maybe the device roamed to another network?
- // Take information of default network.
- networkOperator = telephonyManager.getNetworkOperator();
- }
-
- return new TelephonyInfo(networkCountryIso, networkOperator);
- }
-
- private void logBeforeMakeCall(@DialedFrom int dialedFrom,
- @PhoneNumberType int phoneNumberType,
- boolean isDeviceLocked,
- String networkCountryIso,
- String networkOperator) {
- if (Log.isLoggable(LOG_TAG, Log.DEBUG)) {
- Log.d(LOG_TAG, "EmergencyDialer session: dialedFrom=" + dialFromToString(dialedFrom)
- + ", launchedFrom=" + launchedFromToString(mLaunchedFrom)
- + ", uimode=" + uiModeErrorCodeToString(mUiModeErrorCode)
- + ", type=" + phoneNumberTypeToString(phoneNumberType)
- + ", locked=" + isDeviceLocked
- + ", country=" + networkCountryIso
- + ", operator=" + networkOperator);
- }
- mMetricsLogger.write(new LogMaker(MetricsEvent.EMERGENCY_DIALER_MAKE_CALL_V2)
- .setType(MetricsEvent.TYPE_ACTION)
- .setSubtype(dialedFrom)
- .addTaggedData(MetricsEvent.FIELD_EMERGENCY_DIALER_LAUNCH_FROM, mLaunchedFrom)
- .addTaggedData(MetricsEvent.FIELD_EMERGENCY_DIALER_UI_MODE_ERROR_CODE,
- mUiModeErrorCode)
- .addTaggedData(MetricsEvent.FIELD_EMERGENCY_DIALER_PHONE_NUMBER_TYPE,
- phoneNumberType)
- .addTaggedData(MetricsEvent.FIELD_EMERGENCY_DIALER_IS_DEVICE_LOCKED,
- isDeviceLocked ? 1 : 0)
- .addTaggedData(MetricsEvent.FIELD_EMERGENCY_DIALER_NETWORK_COUNTRY_ISO,
- networkCountryIso)
- .addTaggedData(MetricsEvent.FIELD_EMERGENCY_DIALER_NETWORK_OPERATOR,
- networkOperator)
- .addTaggedData(MetricsEvent.FIELD_EMERGENCY_DIALER_RADIO_VERSION,
- Build.getRadioVersion())
- );
- }
-
- private String dialFromToString(@DialedFrom int dialedFrom) {
- switch (dialedFrom) {
- case DialedFrom.TRADITIONAL_DIALPAD:
- return "traditional";
- case DialedFrom.SHORTCUT:
- return "shortcut";
- case DialedFrom.FASTER_LAUNCHER_DIALPAD:
- return "dialpad";
- default:
- return "unknown_error";
- }
- }
-
- private String launchedFromToString(@LaunchedFrom int launchedFrom) {
- switch (launchedFrom) {
- case LaunchedFrom.UNDEFINED:
- return "undefined";
- case LaunchedFrom.LOCK_SCREEN:
- return "lockscreen";
- case LaunchedFrom.POWER_KEY_MENU:
- return "powermenu";
- default:
- return "unknown_error";
- }
- }
-
- private String phoneNumberTypeToString(@PhoneNumberType int phoneNumberType) {
- switch (phoneNumberType) {
- case PhoneNumberType.HAS_SHORTCUT:
- return "has_shortcut";
- case PhoneNumberType.NO_SHORTCUT:
- return "no_shortcut";
- case PhoneNumberType.NOT_EMERGENCY_NUMBER:
- return "not_emergency";
- default:
- return "unknown_error";
- }
- }
-
- private String uiModeErrorCodeToString(@UiModeErrorCode int uiModeErrorCode) {
- switch (uiModeErrorCode) {
- case UiModeErrorCode.UNSPECIFIED_ERROR:
- return "unspecified_error";
- case UiModeErrorCode.SUCCESS:
- return "success";
- case UiModeErrorCode.CONFIG_ENTRY_POINT:
- return "config_entry_point";
- case UiModeErrorCode.CONFIG_SIM_OPERATOR:
- return "config_sim_operator";
- case UiModeErrorCode.UNSUPPORTED_COUNTRY:
- return "unsupported_country";
- case UiModeErrorCode.AIRPLANE_MODE:
- return "airplane_mode";
- case UiModeErrorCode.NO_PROMOTED_NUMBER:
- return "no_promoted_number";
- case UiModeErrorCode.NO_CAPABLE_PHONE:
- return "no_capable_phone";
- default:
- return "unknown_error";
- }
- }
-}
diff --git a/src/com/android/phone/EmergencyInfoGroup.java b/src/com/android/phone/EmergencyInfoGroup.java
index 9e7121d..186de03 100644
--- a/src/com/android/phone/EmergencyInfoGroup.java
+++ b/src/com/android/phone/EmergencyInfoGroup.java
@@ -153,7 +153,7 @@
private Drawable getCircularUserIcon() {
final UserManager userManager = (UserManager) getContext().getSystemService(
Context.USER_SERVICE);
- Bitmap bitmapUserIcon = userManager.getUserIcon(UserHandle.getCallingUserId());
+ Bitmap bitmapUserIcon = userManager.getUserIcon();
if (bitmapUserIcon == null) {
// get default user icon.
diff --git a/src/com/android/phone/EmergencyShortcutButton.java b/src/com/android/phone/EmergencyShortcutButton.java
index f77595b..9e51e82 100644
--- a/src/com/android/phone/EmergencyShortcutButton.java
+++ b/src/com/android/phone/EmergencyShortcutButton.java
@@ -19,8 +19,6 @@
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.Context;
-import android.metrics.LogMaker;
-import android.os.SystemClock;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
@@ -32,9 +30,6 @@
import androidx.annotation.NonNull;
-import com.android.internal.logging.MetricsLogger;
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-
/**
* Emergency shortcut button displays a local emergency phone number information(including phone
* number, and phone type). To decrease false clicking, it need to click twice to confirm to place
@@ -66,12 +61,6 @@
private boolean mConfirmViewHiding;
- /**
- * The time, in millis, since boot when user taps on shortcut button to reveal confirm view.
- * This is used for metrics when calculating the interval between reveal tap and confirm tap.
- */
- private long mTimeOfRevealTapInMillis = 0;
-
public EmergencyShortcutButton(Context context, AttributeSet attrs) {
super(context, attrs);
}
@@ -209,15 +198,6 @@
}
break;
case R.id.emergency_call_confirm_view:
- if (mTimeOfRevealTapInMillis != 0) {
- long timeBetweenTwoTaps =
- SystemClock.elapsedRealtime() - mTimeOfRevealTapInMillis;
- // Reset reveal time to zero for next reveal-confirm taps pair.
- mTimeOfRevealTapInMillis = 0;
-
- writeMetricsForConfirmTap(timeBetweenTwoTaps);
- }
-
if (mOnConfirmClickListener != null) {
mOnConfirmClickListener.onConfirmClick(this);
}
@@ -229,7 +209,6 @@
mConfirmViewHiding = false;
mConfirmView.setVisibility(View.VISIBLE);
- mTimeOfRevealTapInMillis = SystemClock.elapsedRealtime();
int centerX = mCallNumberInfoView.getLeft() + mCallNumberInfoView.getWidth() / 2;
int centerY = mCallNumberInfoView.getTop() + mCallNumberInfoView.getHeight() / 2;
Animator reveal = ViewAnimationUtils.createCircularReveal(
@@ -266,8 +245,6 @@
@Override
public void onAnimationEnd(Animator animation) {
mConfirmView.setVisibility(INVISIBLE);
- // Reset reveal time to zero for next reveal-confirm taps pair.
- mTimeOfRevealTapInMillis = 0;
}
});
reveal.start();
@@ -282,12 +259,4 @@
hideSelectedButton();
}
};
-
- private void writeMetricsForConfirmTap(long timeBetweenTwoTaps) {
- LogMaker logContent = new LogMaker(MetricsEvent.EMERGENCY_DIALER_SHORTCUT_CONFIRM_TAP)
- .setType(MetricsEvent.TYPE_ACTION)
- .addTaggedData(MetricsEvent.FIELD_EMERGENCY_DIALER_SHORTCUT_TAPS_INTERVAL,
- timeBetweenTwoTaps);
- MetricsLogger.action(logContent);
- }
}
diff --git a/src/com/android/phone/PhoneDisplayMessage.java b/src/com/android/phone/PhoneDisplayMessage.java
index 2b86a61..199fbb8 100644
--- a/src/com/android/phone/PhoneDisplayMessage.java
+++ b/src/com/android/phone/PhoneDisplayMessage.java
@@ -78,10 +78,11 @@
sDisplayMessageDialog.getWindow().setType(
WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG);
sDisplayMessageDialog.getWindow().addFlags(
- WindowManager.LayoutParams.FLAG_DIM_BEHIND);
+ WindowManager.LayoutParams.FLAG_DIM_BEHIND
+ | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
+ | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
sDisplayMessageDialog.show();
- PhoneGlobals.getInstance().wakeUpScreen();
}
/**
@@ -91,6 +92,9 @@
if (DBG) log("Dissmissing Display Info Record...");
if (sDisplayMessageDialog != null) {
+ sDisplayMessageDialog.getWindow().clearFlags(
+ WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
+ | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
sDisplayMessageDialog.dismiss();
sDisplayMessageDialog = null;
}
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index c3c3eb8..06ae81c 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -37,12 +37,11 @@
import android.os.Message;
import android.os.PersistableBundle;
import android.os.PowerManager;
-import android.os.SystemClock;
import android.os.SystemProperties;
-import android.os.UpdateLock;
import android.os.UserManager;
import android.preference.PreferenceManager;
import android.provider.Settings;
+import android.sysprop.TelephonyProperties;
import android.telecom.TelecomManager;
import android.telephony.AnomalyReporter;
import android.telephony.CarrierConfigManager;
@@ -187,8 +186,6 @@
private PowerManager.WakeLock mPartialWakeLock;
private KeyguardManager mKeyguardManager;
- private UpdateLock mUpdateLock;
-
private int mDefaultDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
private final LocalLog mDataRoamingNotifLog = new LocalLog(50);
@@ -274,7 +271,8 @@
// not want this running if the device is still in the FBE encrypted state.
// This is the same procedure that is triggered in the SipIncomingCallReceiver
// upon BOOT_COMPLETED.
- UserManager userManager = UserManager.get(sMe);
+ UserManager userManager =
+ (UserManager) sMe.getSystemService(Context.USER_SERVICE);
if (userManager != null && userManager.isUserUnlocked()) {
SipUtil.startSipService();
}
@@ -347,12 +345,6 @@
mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
- // Get UpdateLock to suppress system-update related events (e.g. dialog show-up)
- // during phone calls.
- mUpdateLock = new UpdateLock("phone");
-
- if (DBG) Log.d(LOG_TAG, "onCreate: mUpdateLock: " + mUpdateLock);
-
// Create the CallerInfoCache singleton, which remembers custom ring tone and
// send-to-voicemail settings.
//
@@ -505,19 +497,6 @@
mPUKEntryProgressDialog = dialog;
}
- /**
- * If we are not currently keeping the screen on, then poke the power
- * manager to wake up the screen for the user activity timeout duration.
- */
- /* package */ void wakeUpScreen() {
- synchronized (this) {
- if (mWakeState == WakeState.SLEEP) {
- if (DBG) Log.d(LOG_TAG, "pulse screen lock");
- mPowerManager.wakeUp(SystemClock.uptimeMillis(), "android.phone:WAKE");
- }
- }
- }
-
KeyguardManager getKeyguardManager() {
return mKeyguardManager;
}
@@ -568,7 +547,7 @@
Log.i(LOG_TAG, "Turning radio off - airplane");
Settings.Global.putInt(context.getContentResolver(), Settings.Global.CELL_ON,
PhoneConstants.CELL_OFF_DUE_TO_AIRPLANE_MODE_FLAG);
- SystemProperties.set("persist.radio.airplane_mode_on", "1");
+ TelephonyProperties.airplane_mode_on(true); // true means int value 1
Settings.Global.putInt(getContentResolver(), Settings.Global.ENABLE_CELLULAR_ON_BOOT, 0);
PhoneUtils.setRadioPower(false);
}
@@ -579,7 +558,7 @@
PhoneConstants.CELL_ON_FLAG);
Settings.Global.putInt(getContentResolver(), Settings.Global.ENABLE_CELLULAR_ON_BOOT,
1);
- SystemProperties.set("persist.radio.airplane_mode_on", "0");
+ TelephonyProperties.airplane_mode_on(false); // false means int value 0
PhoneUtils.setRadioPower(true);
}
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index e6457a3..0940954 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -62,6 +62,7 @@
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
+import android.telephony.Annotation.ApnType;
import android.telephony.CarrierConfigManager;
import android.telephony.CarrierRestrictionRules;
import android.telephony.CellIdentity;
@@ -94,7 +95,6 @@
import android.telephony.VisualVoicemailSmsFilterSettings;
import android.telephony.cdma.CdmaCellLocation;
import android.telephony.data.ApnSetting;
-import android.telephony.data.ApnSetting.ApnType;
import android.telephony.emergency.EmergencyNumber;
import android.telephony.gsm.GsmCellLocation;
import android.telephony.ims.ImsException;
@@ -1077,11 +1077,13 @@
try {
if (ar.exception != null) {
Log.e(LOG_TAG, "Exception retrieving CellInfo=" + ar.exception);
- cb.onError(TelephonyManager.CellInfoCallback.ERROR_MODEM_ERROR,
- new android.os.ParcelableException(ar.exception));
+ cb.onError(
+ TelephonyManager.CellInfoCallback.ERROR_MODEM_ERROR,
+ ar.exception.getClass().getName(),
+ ar.exception.toString());
} else if (ar.result == null) {
Log.w(LOG_TAG, "Timeout Waiting for CellInfo!");
- cb.onError(TelephonyManager.CellInfoCallback.ERROR_TIMEOUT, null);
+ cb.onError(TelephonyManager.CellInfoCallback.ERROR_TIMEOUT, null, null);
} else {
// use the result as returned
cb.onCellInfo((List<CellInfo>) ar.result);
@@ -2927,18 +2929,19 @@
if (!SubscriptionManager.isValidSubscriptionId(subId)) {
throw new IllegalArgumentException("Invalid Subscription ID: " + subId);
}
- Binder.withCleanCallingIdentity(() -> {
- try {
- // TODO: Refactor to remove ImsManager dependence and query through ImsPhone.
- ImsManager.getInstance(mApp, getSlotIndexOrException(subId))
- .removeRegistrationCallbackForSubscription(c, subId);
- } catch (ImsException e) {
- Log.i(LOG_TAG, "unregisterImsRegistrationCallback: " + subId
- + "is inactive, ignoring unregister.");
- // If the subscription is no longer active, just return, since the callback
- // will already have been removed internally.
- }
- });
+ final long token = Binder.clearCallingIdentity();
+ try {
+ // TODO: Refactor to remove ImsManager dependence and query through ImsPhone.
+ ImsManager.getInstance(mApp, getSlotIndexOrException(subId))
+ .removeRegistrationCallbackForSubscription(c, subId);
+ } catch (ImsException e) {
+ Log.i(LOG_TAG, "unregisterImsRegistrationCallback: " + subId
+ + "is inactive, ignoring unregister.");
+ // If the subscription is no longer active, just return, since the callback
+ // will already have been removed internally.
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
}
/**
@@ -3032,22 +3035,23 @@
@Override
public void unregisterMmTelCapabilityCallback(int subId, IImsCapabilityCallback c) {
enforceReadPrivilegedPermission("unregisterMmTelCapabilityCallback");
-
if (!SubscriptionManager.isValidSubscriptionId(subId)) {
throw new IllegalArgumentException("Invalid Subscription ID: " + subId);
}
- Binder.withCleanCallingIdentity(() -> {
- try {
- // TODO: Refactor to remove ImsManager dependence and query through ImsPhone.
- ImsManager.getInstance(mApp, getSlotIndexOrException(subId))
+
+ final long token = Binder.clearCallingIdentity();
+ try {
+ // TODO: Refactor to remove ImsManager dependence and query through ImsPhone.
+ ImsManager.getInstance(mApp, getSlotIndexOrException(subId))
.removeCapabilitiesCallbackForSubscription(c, subId);
- } catch (ImsException e) {
- Log.i(LOG_TAG, "unregisterMmTelCapabilityCallback: " + subId
- + "is inactive, ignoring unregister.");
- // If the subscription is no longer active, just return, since the callback
- // will already have been removed internally.
- }
- });
+ } catch (ImsException e) {
+ Log.i(LOG_TAG, "unregisterMmTelCapabilityCallback: " + subId
+ + "is inactive, ignoring unregister.");
+ // If the subscription is no longer active, just return, since the callback
+ // will already have been removed internally.
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
}
@Override
diff --git a/src/com/android/phone/euicc/EuiccUiDispatcherActivity.java b/src/com/android/phone/euicc/EuiccUiDispatcherActivity.java
index 7c7b75d..4c85818 100644
--- a/src/com/android/phone/euicc/EuiccUiDispatcherActivity.java
+++ b/src/com/android/phone/euicc/EuiccUiDispatcherActivity.java
@@ -153,7 +153,7 @@
mPackageManager.revokeDefaultPermissionsFromLuiApps(luiAppsArray, getUserId());
} catch (RemoteException e) {
Log.e(TAG, "Failed to revoke LUI app permissions.");
- throw e.rethrowAsRuntimeException();
+ throw new RuntimeException(e);
}
}
diff --git a/src/com/android/services/telephony/EmergencyTonePlayer.java b/src/com/android/services/telephony/EmergencyTonePlayer.java
index 8e26349..431f8d7 100644
--- a/src/com/android/services/telephony/EmergencyTonePlayer.java
+++ b/src/com/android/services/telephony/EmergencyTonePlayer.java
@@ -23,7 +23,6 @@
import android.media.AudioAttributes;
import android.media.AudioManager;
import android.media.ToneGenerator;
-import android.os.SystemVibrator;
import android.os.Vibrator;
import android.provider.Settings;
@@ -49,11 +48,9 @@
.setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION)
.build();
- // We don't rely on getSystemService(Context.VIBRATOR_SERVICE) to make sure that this vibrator
- // object will be isolated from others.
- private final Vibrator mVibrator = new SystemVibrator();
private final Context mContext;
private final AudioManager mAudioManager;
+ private final Vibrator mVibrator;
private ToneGenerator mToneGenerator;
private int mSavedInCallVolume;
@@ -62,6 +59,7 @@
EmergencyTonePlayer(Context context) {
mContext = context;
mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
+ mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
}
public void start() {
diff --git a/src/com/android/services/telephony/RadioOnHelper.java b/src/com/android/services/telephony/RadioOnHelper.java
index 741a6c5..981dc96 100644
--- a/src/com/android/services/telephony/RadioOnHelper.java
+++ b/src/com/android/services/telephony/RadioOnHelper.java
@@ -49,13 +49,19 @@
}
private void setupListeners() {
- if (mListeners != null) {
- return;
+ if (mListeners == null) {
+ mListeners = new ArrayList<>(2);
}
- mListeners = new ArrayList<>(2);
- for (int i = 0; i < TelephonyManager.getDefault().getSupportedModemCount(); i++) {
+ int activeModems = TelephonyManager.from(mContext).getActiveModemCount();
+ // Add new listeners if active modem count increased.
+ while (mListeners.size() < activeModems) {
mListeners.add(new RadioOnStateListener());
}
+ // Clean up listeners if active modem count decreased.
+ while (mListeners.size() > activeModems) {
+ mListeners.get(mListeners.size() - 1).cleanup();
+ mListeners.remove(mListeners.size() - 1);
+ }
}
/**
* Starts the "turn on radio" sequence. This is the (single) external API of the
@@ -76,7 +82,7 @@
mCallback = callback;
mInProgressListeners.clear();
mIsRadioOnCallingEnabled = false;
- for (int i = 0; i < TelephonyManager.getDefault().getSupportedModemCount(); i++) {
+ for (int i = 0; i < TelephonyManager.from(mContext).getActiveModemCount(); i++) {
Phone phone = PhoneFactory.getPhone(i);
if (phone == null) {
continue;
diff --git a/src/com/android/services/telephony/RadioOnStateListener.java b/src/com/android/services/telephony/RadioOnStateListener.java
index 729f6a9..52bd9cf 100644
--- a/src/com/android/services/telephony/RadioOnStateListener.java
+++ b/src/com/android/services/telephony/RadioOnStateListener.java
@@ -231,7 +231,7 @@
* Note we don't call this method simply after a successful call to placeCall(), since it's
* still possible the call will disconnect very quickly with an OUT_OF_SERVICE error.
*/
- private void cleanup() {
+ public void cleanup() {
Log.d(this, "cleanup()");
// This will send a failure call back if callback has yet to be invoked. If the callback
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index 1e681e8..2e923ec 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -803,8 +803,10 @@
Log.i(this, "User changed, re-registering phone accounts.");
int userHandleId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0);
- UserHandle currentUserHandle = new UserHandle(userHandleId);
- mIsPrimaryUser = UserManager.get(mContext).getPrimaryUser().getUserHandle()
+ UserHandle currentUserHandle = UserHandle.of(userHandleId);
+ UserManager userManager =
+ (UserManager) context.getSystemService(Context.USER_SERVICE);
+ mIsPrimaryUser = userManager.getPrimaryUser().getUserHandle()
.equals(currentUserHandle);
// Any time the user changes, re-register the accounts.