Merge "Remove unused broadcast DATA_CONNECTION_FAILED"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 92557c8..34c67a4 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -129,8 +129,8 @@
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.SEND_RESPOND_VIA_MESSAGE" />
- <uses-permission android:name="android.permission.SET_TIME" />
<uses-permission android:name="android.permission.SET_TIME_ZONE" />
+ <uses-permission android:name="android.permission.SUGGEST_PHONE_TIME_AND_ZONE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 22845e0..3aa8121 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -50,3 +50,6 @@
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/com.android.services.telephony.common_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/framework/telephony-common.jar)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/framework/ims-common.jar)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/apex/com.android.telephony/javalib/telephony-common.jar)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/apex/com.android.telephony/javalib/ims-common.jar)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/apex/com.android.telephony.apex)
\ No newline at end of file
diff --git a/apex/Android.bp b/apex/Android.bp
index f9e4b67..16bcb72 100644
--- a/apex/Android.bp
+++ b/apex/Android.bp
@@ -4,7 +4,7 @@
// optional. if unspecified, a default one is auto-generated
androidManifest: "AndroidManifest.xml",
- java_libs: ["telephony-common", "ims-common"],
+ //java_libs: ["telephony-common", "ims-common", "voip-common"],
//apps: ["TeleService", "StkLib", "ONSLib"],
key: "com.android.telephony.key",
@@ -30,4 +30,4 @@
// This will use com.android.telephony.x509.pem (the cert) and
// com.android.telephony.pk8 (the private key)
certificate: "com.android.telephony",
-}
+}
\ No newline at end of file
diff --git a/res/drawable/preference_background.xml b/res/drawable/preference_background.xml
index 19ca432..1ec90fb 100644
--- a/res/drawable/preference_background.xml
+++ b/res/drawable/preference_background.xml
@@ -21,7 +21,7 @@
android:insetBottom="0dip">
<shape android:shape="rectangle">
- <solid android:color="@*android:color/background_material_light" />
+ <solid android:color="@color/background_material_light" />
</shape>
</inset>
diff --git a/res/drawable/progress_indeterminate_horizontal_material_trimmed.xml b/res/drawable/progress_indeterminate_horizontal_material_trimmed.xml
deleted file mode 100644
index 905dc55..0000000
--- a/res/drawable/progress_indeterminate_horizontal_material_trimmed.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-
-<!-- Variant of progress_indeterminate_horizontal_material in frameworks/base/core/res, which
- draws the whole height of the progress bar instead having blank space above and below the
- bar. -->
-<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:drawable="@drawable/vector_drawable_progress_indeterminate_horizontal_trimmed" >
- <target
- android:name="rect2_grp"
- android:animation="@*android:anim/progress_indeterminate_horizontal_rect2" />
- <target
- android:name="rect1_grp"
- android:animation="@*android:anim/progress_indeterminate_horizontal_rect1" />
-</animated-vector>
\ No newline at end of file
diff --git a/res/layout/choose_network_progress_header.xml b/res/layout/choose_network_progress_header.xml
deleted file mode 100644
index 671c297..0000000
--- a/res/layout/choose_network_progress_header.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- 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.
--->
-
-<FrameLayout
- android:layout_width="match_parent"
- android:layout_height="3dp"
- xmlns:android="http://schemas.android.com/apk/res/android">
- <View
- android:id="@+id/progress_bar_background"
- style="@style/TrimmedHorizontalProgressBar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="?android:attr/colorSecondary" />
- <ProgressBar
- android:id="@+id/progress_bar_animation"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- style="@style/TrimmedHorizontalProgressBar"
- android:indeterminate="true" />
-</FrameLayout>
\ No newline at end of file
diff --git a/res/layout/pref_dialog_editpin.xml b/res/layout/pref_dialog_editpin.xml
deleted file mode 100644
index 94cdadf..0000000
--- a/res/layout/pref_dialog_editpin.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 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.
--->
-
-<!-- Layout used as the dialog's content View for EditTextPreference. -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@*android:id/edittext_container"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:padding="?android:attr/dialogPreferredPadding">
-
- <TextView android:id="@android:id/message"
- style="?android:attr/textAppearanceSmall"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textColor="?android:attr/textColorSecondary" />
-
-</LinearLayout>
diff --git a/res/values-night/styles.xml b/res/values-night/styles.xml
index fa5c8a1..f7d831b 100644
--- a/res/values-night/styles.xml
+++ b/res/values-night/styles.xml
@@ -27,31 +27,31 @@
<item name="android:dialogTheme">@style/DialerAlertDialogTheme</item>
</style>
- <style name="EmergencyInfoNameTextAppearance">
- <item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
+ <style name="EmergencyInfoNameTextAppearance"
+ parent="@android:style/TextAppearance.Material.Subhead">
<item name="android:textColor">@android:color/white</item>
<item name="android:textSize">@dimen/emergency_info_name_text_size</item>
</style>
- <style name="EmergencyInfoHintTextAppearance">
- <item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
+ <style name="EmergencyInfoHintTextAppearance"
+ parent="@android:style/TextAppearance.Material.Subhead">
<item name="android:textColor">@color/white_70_percent</item>
<item name="android:textSize">@dimen/emergency_info_hint_text_size</item>
</style>
- <style name="EmergencyInfoTapHintTextAppearance">
- <item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
+ <style name="EmergencyInfoTapHintTextAppearance"
+ parent="@android:style/TextAppearance.Material.Subhead">
<item name="android:textColor">@android:color/white</item>
<item name="android:textSize">@dimen/emergency_info_tap_hint_text_size</item>
</style>
- <style name="ShortcutViewHintTextAppearance">
- <item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
+ <style name="ShortcutViewHintTextAppearance"
+ parent="@android:style/TextAppearance.Material.Subhead">
<item name="android:textColor">@android:color/white</item>
</style>
- <style name="PhoneNumberTextAppearance">
- <item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
+ <style name="PhoneNumberTextAppearance"
+ parent="@android:style/TextAppearance.Material.Subhead">
<item name="android:textColor">@android:color/white</item>
<item name="android:textSize">@dimen/emergency_shortcut_number_text_size</item>
</style>
@@ -62,8 +62,8 @@
<item name="android:textSize">@dimen/emergency_shortcut_type_text_size</item>
</style>
- <style name="PhoneNumberTapHintAppearance">
- <item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
+ <style name="PhoneNumberTapHintAppearance"
+ parent="@android:style/TextAppearance.Material.Subhead">
<item name="android:textColor">@android:color/white</item>
<item name="android:textSize">@dimen/emergency_shortcut_tap_hint_text_size</item>
</style>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index a9ed307..d131bd8 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -211,12 +211,6 @@
<item name="android:textColor">?android:attr/textColorPrimaryInverseDisableOnly</item>
</style>
- <style name="TrimmedHorizontalProgressBar" parent="android:Widget.Material.ProgressBar.Horizontal">
- <item name="android:indeterminateDrawable">@drawable/progress_indeterminate_horizontal_material_trimmed</item>
- <item name="android:minHeight">3dip</item>
- <item name="android:maxHeight">3dip</item>
- </style>
-
<style name="Empty" parent="@android:style/Theme.Material.Light">
<item name="android:forceDarkAllowed">true</item>
<item name="android:windowIsTranslucent">true</item>
@@ -227,33 +221,6 @@
<item name="android:backgroundDimEnabled">true</item>
</style>
- <style name="InCallAnimationStyle" parent="@*android:style/Animation.Holo.Activity">
- <!-- Suppress task-to-task animation happening during the transition from
- OutgoingCallBroadcaster (and SipOptionHandler) to InCallScreen.
- The transition unexpectedly happens during the transition (inside the phone task),
- because InCallScreen is using android:launchMode="singleInstance".
-
- - taskOpenEnterAnimation/taskOpenExitAnimation is used for the first time
- InCallScreen instance is created.
-
- - taskToFrontEnterAnimation/taskToFrontExitAnimation is used when InCallScreen
- is already available.
- (Note that InCallScreen won't be destroyed once it is created)
-
- TODO: try removing the flag instead -->
- <item name="*android:taskOpenEnterAnimation">@*android:anim/activity_open_enter</item>
- <item name="*android:taskOpenExitAnimation">@*android:anim/activity_open_exit</item>
- <item name="*android:taskToFrontEnterAnimation">@*android:anim/activity_open_enter</item>
- <item name="*android:taskToFrontExitAnimation">@*android:anim/activity_open_exit</item>
- </style>
-
- <style name="OutgoingAnimationStyle" parent="@*android:style/Animation.Holo.Activity">
- <!-- Suppress task-to-task transition animation happening from
- DialtactsActivity to OutgoingCallBroadcaster. -->
- <item name="*android:taskOpenEnterAnimation">@*android:anim/activity_open_enter</item>
- <item name="*android:taskOpenExitAnimation">@*android:anim/activity_open_exit</item>
- </style>
-
<!-- Style for the call settings action bar. Should be kept in sync with Dialer. -->
<style name="DialtactsActionBarStyle" parent="@style/TelephonyActionBarStyle">
<!-- Shift the title text to the right -->
@@ -284,7 +251,7 @@
<item name="android:src">@drawable/overflow_menu</item>
</style>
- <style name="EmergencyDialerTheme" parent="@*android:style/Theme.DeviceDefault.Settings.Dark.NoActionBar">
+ <style name="EmergencyDialerTheme" parent="@android:style/Theme.Material.NoActionBar">
<item name="android:forceDarkAllowed">true</item>
<item name="android:colorPrimaryDark">?android:attr/colorPrimary</item>
<item name="android:colorBackgroundCacheHint">@null</item>
@@ -318,13 +285,6 @@
<item name="android:actionOverflowButtonStyle">@style/DialtactsActionBarOverflow</item>
</style>
- <style name="OutgoingCallBroadcasterTheme" parent="@android:style/Theme.Holo.NoActionBar">
- <item name="android:forceDarkAllowed">true</item>
- <item name="android:windowBackground">@android:color/black</item>
-
- <item name="*android:windowAnimationStyle">@style/OutgoingAnimationStyle</item>
- </style>
-
<style name="DialtactsDigitsTextAppearance">
<item name="android:maxLines">1</item>
<item name="android:textSize">@dimen/dialpad_digits_text_size</item>
@@ -347,43 +307,43 @@
<item name="android:listDivider">@null</item>
</style>
- <style name="EmergencyInfoNameTextAppearance">
- <item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
- <item name="android:textColor">@*android:color/primary_text_default_material_dark</item>
+ <style name="EmergencyInfoNameTextAppearance"
+ parent="@android:style/TextAppearance.Material.Subhead">
+ <item name="android:textColor">@color/primary_text_default_material_dark</item>
<item name="android:textSize">@dimen/emergency_info_name_text_size</item>
</style>
- <style name="EmergencyInfoHintTextAppearance">
- <item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
- <item name="android:textColor">@*android:color/secondary_text_default_material_dark</item>
+ <style name="EmergencyInfoHintTextAppearance"
+ parent="@android:style/TextAppearance.Material.Subhead">
+ <item name="android:textColor">@color/secondary_text_default_material_dark</item>
<item name="android:textSize">@dimen/emergency_info_hint_text_size</item>
</style>
- <style name="EmergencyInfoTapHintTextAppearance">
- <item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
+ <style name="EmergencyInfoTapHintTextAppearance"
+ parent="@android:style/TextAppearance.Material.Subhead">
<item name="android:textColor">@android:color/white</item>
<item name="android:textSize">@dimen/emergency_info_tap_hint_text_size</item>
</style>
- <style name="ShortcutViewHintTextAppearance">
- <item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
- <item name="android:textColor">@*android:color/secondary_text_default_material_dark</item>
+ <style name="ShortcutViewHintTextAppearance"
+ parent="@android:style/TextAppearance.Material.Subhead">
+ <item name="android:textColor">@color/secondary_text_default_material_dark</item>
</style>
- <style name="PhoneNumberTextAppearance">
- <item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
- <item name="android:textColor">@*android:color/primary_text_default_material_light</item>
+ <style name="PhoneNumberTextAppearance"
+ parent="@android:style/TextAppearance.Material.Subhead">
+ <item name="android:textColor">@color/primary_text_default_material_light</item>
<item name="android:textSize">@dimen/emergency_shortcut_number_text_size</item>
</style>
<style name="PhoneNumberTypeAppearance">
<item name="android:fontFamily">roboto</item>
- <item name="android:textColor">@*android:color/secondary_text_default_material_light</item>
+ <item name="android:textColor">@color/secondary_text_default_material_light</item>
<item name="android:textSize">@dimen/emergency_shortcut_type_text_size</item>
</style>
- <style name="PhoneNumberTapHintAppearance">
- <item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
+ <style name="PhoneNumberTapHintAppearance"
+ parent="@android:style/TextAppearance.Material.Subhead">
<item name="android:textColor">@android:color/white</item>
<item name="android:textSize">@dimen/emergency_shortcut_tap_hint_text_size</item>
</style>
diff --git a/res/values/styles_preference.xml b/res/values/styles_preference.xml
index fef4f72..eace2e7 100644
--- a/res/values/styles_preference.xml
+++ b/res/values/styles_preference.xml
@@ -19,22 +19,22 @@
<!-- Things unrelated to preference framework UI customization should go to other styles files -->
<resources>
<!-- Preferences -->
- <style name="SettingsPreference" parent="@*android:style/Preference.DeviceDefault">
+ <style name="SettingsPreference" parent="@style/Preference.Material">
<item name="android:singleLineTitle">false</item>
<item name="android:iconSpaceReserved">true</item>
</style>
- <style name="SettingsSwitchPreference" parent="@*android:style/Preference.DeviceDefault.SwitchPreference">
+ <style name="SettingsSwitchPreference" parent="@style/Preference.SwitchPreference.Material">
<item name="android:iconSpaceReserved">true</item>
<item name="android:singleLineTitle">false</item>
</style>
- <style name="SettingsDialogPreference" parent="@*android:style/Preference.DeviceDefault.DialogPreference">
+ <style name="SettingsDialogPreference" parent="@style/Preference.DialogPreference.Material">
<item name="android:singleLineTitle">false</item>
<item name="android:iconSpaceReserved">true</item>
</style>
- <style name="SettingsPreferenceScreen" parent="@*android:style/Preference.DeviceDefault.PreferenceScreen">
+ <style name="SettingsPreferenceScreen" parent="@style/Preference.PreferenceScreen.Material">
<item name="android:singleLineTitle">false</item>
<item name="android:iconSpaceReserved">true</item>
</style>
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 4dfe912..5f7b627 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -6786,7 +6786,8 @@
@Override
public boolean isManualNetworkSelectionAllowed(int subId) {
- TelephonyPermissions.enforeceCallingOrSelfReadPhoneStatePermissionOrCarrierPrivilege(
+ TelephonyPermissions
+ .enforeceCallingOrSelfReadPrivilegedPhoneStatePermissionOrCarrierPrivilege(
mApp, subId, "isManualNetworkSelectionAllowed");
boolean isAllowed = true;
diff --git a/src/com/android/phone/settings/fdn/EditPinPreference.java b/src/com/android/phone/settings/fdn/EditPinPreference.java
index 9596f39..a9d1948 100644
--- a/src/com/android/phone/settings/fdn/EditPinPreference.java
+++ b/src/com/android/phone/settings/fdn/EditPinPreference.java
@@ -23,8 +23,6 @@
import android.util.AttributeSet;
import android.view.View;
-import com.android.phone.R;
-
/**
* Class similar to the com.android.settings.EditPinPreference
* class, with a couple of modifications, including a different layout
@@ -62,27 +60,12 @@
super(context, attrs, defStyle);
}
- /**
- * Overridden to setup the correct dialog layout, as well as setting up
- * other properties for the pin / puk entry field.
- */
- @Override
- protected View onCreateDialogView() {
- // set the dialog layout
- setDialogLayoutResource(R.layout.pref_dialog_editpin);
-
- View dialog = super.onCreateDialogView();
-
- getEditText().setInputType(InputType.TYPE_CLASS_NUMBER |
- InputType.TYPE_NUMBER_VARIATION_PASSWORD);
-
- return dialog;
- }
-
@Override
protected void onBindDialogView(View view) {
super.onBindDialogView(view);
+ getEditText().setInputType(InputType.TYPE_CLASS_NUMBER
+ | InputType.TYPE_NUMBER_VARIATION_PASSWORD);
// If the layout does not contain an edittext, hide the buttons.
shouldHideButtons = (view.findViewById(android.R.id.edit) == null);
}
diff --git a/src/com/android/services/telephony/RadioOnHelper.java b/src/com/android/services/telephony/RadioOnHelper.java
index 981dc96..116c61d 100644
--- a/src/com/android/services/telephony/RadioOnHelper.java
+++ b/src/com/android/services/telephony/RadioOnHelper.java
@@ -110,6 +110,11 @@
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.AIRPLANE_MODE_ON, 0);
+ for (Phone phone : PhoneFactory.getPhones()) {
+ Log.d(this, "powerOnRadio, enabling Radio");
+ phone.setRadioPower(true);
+ }
+
// Post the broadcast intend for change in airplane mode
// TODO: We really should not be in charge of sending this broadcast.
// If changing the setting is sufficient to trigger all of the rest of the logic,
diff --git a/src/com/android/services/telephony/RadioOnStateListener.java b/src/com/android/services/telephony/RadioOnStateListener.java
index 52bd9cf..43269b4 100644
--- a/src/com/android/services/telephony/RadioOnStateListener.java
+++ b/src/com/android/services/telephony/RadioOnStateListener.java
@@ -56,6 +56,9 @@
@VisibleForTesting
public static final int MSG_SERVICE_STATE_CHANGED = 2;
private static final int MSG_RETRY_TIMEOUT = 3;
+ @VisibleForTesting
+ public static final int MSG_RADIO_ON = 4;
+ public static final int MSG_RADIO_OFF_OR_NOT_AVAILABLE = 5;
private final Handler mHandler = new Handler(Looper.getMainLooper()) {
@Override
@@ -75,6 +78,12 @@
case MSG_SERVICE_STATE_CHANGED:
onServiceStateChanged((ServiceState) ((AsyncResult) msg.obj).result);
break;
+ case MSG_RADIO_ON:
+ onRadioOn();
+ break;
+ case MSG_RADIO_OFF_OR_NOT_AVAILABLE:
+ registerForRadioOn();
+ break;
case MSG_RETRY_TIMEOUT:
onRetryTimeout();
break;
@@ -135,6 +144,9 @@
mCallback = callback;
registerForServiceStateChanged();
+ // Register for RADIO_OFF to handle cases where emergency call is dialed before
+ // we receive UNSOL_RESPONSE_RADIO_STATE_CHANGED with RADIO_OFF.
+ registerForRadioOff();
// Next step: when the SERVICE_STATE_CHANGED event comes in, we'll retry the call; see
// onServiceStateChanged(). But also, just in case, start a timer to make sure we'll retry
// the call even if the SERVICE_STATE_CHANGED event never comes in for some reason.
@@ -169,6 +181,17 @@
}
}
+ private void onRadioOn() {
+ ServiceState state = mPhone.getServiceState();
+ Log.d(this, "onRadioOn, state = %s, Phone = %s", state,
+ mPhone.getPhoneId());
+ if (isOkToCall(state.getState())) {
+ onComplete(true);
+ cleanup();
+ } else {
+ Log.d(this, "onRadioOn: not ready to call yet, keep waiting.");
+ }
+ }
/**
* Callback to see if it is okay to call yet, given the current conditions.
*/
@@ -239,6 +262,8 @@
onComplete(false);
unregisterForServiceStateChanged();
+ unregisterForRadioOff();
+ unregisterForRadioOn();
cancelRetryTimer();
// Used for unregisterForServiceStateChanged() so we null it out here instead.
@@ -271,6 +296,31 @@
mHandler.removeMessages(MSG_SERVICE_STATE_CHANGED); // Clean up any pending messages too
}
+ private void registerForRadioOff() {
+ mPhone.mCi.registerForOffOrNotAvailable(mHandler, MSG_RADIO_OFF_OR_NOT_AVAILABLE, null);
+ }
+
+ private void unregisterForRadioOff() {
+ // This method is safe to call even if we haven't set mPhone yet.
+ if (mPhone != null) {
+ mPhone.mCi.unregisterForOffOrNotAvailable(mHandler); // Safe even if unnecessary
+ }
+ mHandler.removeMessages(MSG_RADIO_OFF_OR_NOT_AVAILABLE); // Clean up any pending messages
+ }
+
+ private void registerForRadioOn() {
+ unregisterForRadioOff();
+ mPhone.mCi.registerForOn(mHandler, MSG_RADIO_ON, null);
+ }
+
+ private void unregisterForRadioOn() {
+ // This method is safe to call even if we haven't set mPhone yet.
+ if (mPhone != null) {
+ mPhone.mCi.unregisterForOn(mHandler); // Safe even if unnecessary
+ }
+ mHandler.removeMessages(MSG_RADIO_ON); // Clean up any pending messages too
+ }
+
private void onComplete(boolean isRadioReady) {
if (mCallback != null) {
Callback tempCallback = mCallback;
diff --git a/src/com/android/services/telephony/TelephonyConnection.java b/src/com/android/services/telephony/TelephonyConnection.java
index fb865b4..14f0cb8 100644
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -37,12 +37,12 @@
import android.telecom.StatusHints;
import android.telecom.TelecomManager;
import android.telecom.VideoProfile;
-import android.telephony.Annotation.RilRadioTechnology;
import android.telephony.CarrierConfigManager;
import android.telephony.DisconnectCause;
import android.telephony.PhoneNumberUtils;
import android.telephony.Rlog;
import android.telephony.ServiceState;
+import android.telephony.ServiceState.RilRadioTechnology;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.ims.ImsCallProfile;
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index 40b941e..b921466 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -662,7 +662,7 @@
// been powered on and isn't in the UNAVAILABLE state, even if it is
// reporting the OUT_OF_SERVICE state.
return (phone.getState() == PhoneConstants.State.OFFHOOK)
- || phone.getServiceState().getState() != ServiceState.STATE_POWER_OFF;
+ || phone.getServiceStateTracker().isRadioOn();
} else {
// Wait until we are in service and ready to make calls. This can happen
// when we power down the radio on bluetooth to save power on watches or if
diff --git a/tests/src/com/android/services/telephony/RadioOnStateListenerTest.java b/tests/src/com/android/services/telephony/RadioOnStateListenerTest.java
index 8b46bf0..afdfab5 100644
--- a/tests/src/com/android/services/telephony/RadioOnStateListenerTest.java
+++ b/tests/src/com/android/services/telephony/RadioOnStateListenerTest.java
@@ -34,6 +34,7 @@
import androidx.test.runner.AndroidJUnit4;
import com.android.TelephonyTestBase;
+import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
@@ -55,6 +56,7 @@
@Mock Phone mMockPhone;
@Mock RadioOnStateListener.Callback mCallback;
+ @Mock CommandsInterface mMockCi;
RadioOnStateListener mListener;
@Override
@@ -80,6 +82,7 @@
@Test
@SmallTest
public void testRegisterForCallback() {
+ mMockPhone.mCi = mMockCi;
mListener.waitForRadioOn(mMockPhone, mCallback);
waitForHandlerAction(mListener.getHandler(), TIMEOUT_MS);
@@ -87,6 +90,9 @@
verify(mMockPhone).unregisterForServiceStateChanged(any(Handler.class));
verify(mMockPhone).registerForServiceStateChanged(any(Handler.class),
eq(RadioOnStateListener.MSG_SERVICE_STATE_CHANGED), isNull());
+
+ verify(mMockCi).registerForOffOrNotAvailable(any(Handler.class),
+ eq(RadioOnStateListener.MSG_RADIO_OFF_OR_NOT_AVAILABLE), isNull());
}
/**
@@ -101,6 +107,7 @@
state.setState(ServiceState.STATE_IN_SERVICE);
when(mMockPhone.getState()).thenReturn(PhoneConstants.State.IDLE);
when(mCallback.isOkToCall(eq(mMockPhone), anyInt())).thenReturn(true);
+ mMockPhone.mCi = mMockCi;
mListener.waitForRadioOn(mMockPhone, mCallback);
waitForHandlerAction(mListener.getHandler(), TIMEOUT_MS);
@@ -124,6 +131,7 @@
when(mMockPhone.getState()).thenReturn(PhoneConstants.State.IDLE);
when(mCallback.isOkToCall(eq(mMockPhone), anyInt())).thenReturn(false);
when(mMockPhone.getServiceState()).thenReturn(state);
+ mMockPhone.mCi = mMockCi;
mListener.waitForRadioOn(mMockPhone, mCallback);
waitForHandlerAction(mListener.getHandler(), TIMEOUT_MS);
@@ -152,6 +160,7 @@
mListener.setMaxNumRetries(2);
// Wait for the timer to expire and check state manually in onRetryTimeout
+ mMockPhone.mCi = mMockCi;
mListener.waitForRadioOn(mMockPhone, mCallback);
waitForHandlerActionDelayed(mListener.getHandler(), TIMEOUT_MS, TIMEOUT_MS /*delay*/);