Messaging: Remove compatibility for old android versions

Change-Id: Id9065d60525a509271a0e64c0e349e857cb998e2
This commit is contained in:
Michael W
2024-12-26 14:55:12 +01:00
parent 9bbc7a8f99
commit 7c55a6d56a
104 changed files with 580 additions and 2306 deletions
+9 -73
View File
@@ -123,11 +123,7 @@
android:screenOrientation="user" android:screenOrientation="user"
android:label="@string/archived_activity_title" android:label="@string/archived_activity_title"
android:theme="@style/BugleTheme.ArchivedConversationListActivity" android:theme="@style/BugleTheme.ArchivedConversationListActivity"
android:parentActivityName="com.android.messaging.ui.conversationlist.ConversationListActivity"> android:parentActivityName="com.android.messaging.ui.conversationlist.ConversationListActivity" />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.android.messaging.ui.conversationlist.ConversationListActivity" />
</activity>
<!-- Displays the contents of a single conversation --> <!-- Displays the contents of a single conversation -->
<activity <activity
@@ -136,11 +132,7 @@
android:screenOrientation="user" android:screenOrientation="user"
android:windowSoftInputMode="stateHidden|adjustResize" android:windowSoftInputMode="stateHidden|adjustResize"
android:theme="@style/BugleTheme.ConversationActivity" android:theme="@style/BugleTheme.ConversationActivity"
android:parentActivityName="com.android.messaging.ui.conversationlist.ConversationListActivity"> android:parentActivityName="com.android.messaging.ui.conversationlist.ConversationListActivity" />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.android.messaging.ui.conversationlist.ConversationListActivity" />
</activity>
<!-- Blocked Participants --> <!-- Blocked Participants -->
<activity <activity
@@ -149,11 +141,7 @@
android:screenOrientation="user" android:screenOrientation="user"
android:label="@string/blocked_contacts_title" android:label="@string/blocked_contacts_title"
android:theme="@style/BugleTheme" android:theme="@style/BugleTheme"
android:parentActivityName="com.android.messaging.ui.conversationlist.ConversationListActivity"> android:parentActivityName="com.android.messaging.ui.conversationlist.ConversationListActivity" />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.android.messaging.ui.conversationlist.ConversationListActivity" />
</activity>
<!-- Full-screen photo viewer --> <!-- Full-screen photo viewer -->
<activity <activity
@@ -171,11 +159,7 @@
android:theme="@style/BugleTheme.SettingsActivity" android:theme="@style/BugleTheme.SettingsActivity"
android:configChanges="orientation|screenSize|keyboardHidden" android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="user" android:screenOrientation="user"
android:parentActivityName="com.android.messaging.ui.conversationlist.ConversationListActivity"> android:parentActivityName="com.android.messaging.ui.conversationlist.ConversationListActivity" />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.android.messaging.ui.conversationlist.ConversationListActivity" />
</activity>
<activity <activity
android:name=".ui.appsettings.PerSubscriptionSettingsActivity" android:name=".ui.appsettings.PerSubscriptionSettingsActivity"
@@ -183,11 +167,7 @@
android:theme="@style/BugleTheme.SettingsActivity" android:theme="@style/BugleTheme.SettingsActivity"
android:configChanges="orientation|screenSize|keyboardHidden" android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="user" android:screenOrientation="user"
android:parentActivityName="com.android.messaging.ui.appsettings.SettingsActivity"> android:parentActivityName="com.android.messaging.ui.appsettings.SettingsActivity" />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.android.messaging.ui.appsettings.SettingsActivity" />
</activity>
<activity <activity
android:name=".ui.appsettings.ApplicationSettingsActivity" android:name=".ui.appsettings.ApplicationSettingsActivity"
@@ -197,10 +177,6 @@
android:screenOrientation="user" android:screenOrientation="user"
android:parentActivityName="com.android.messaging.ui.appsettings.SettingsActivity" android:parentActivityName="com.android.messaging.ui.appsettings.SettingsActivity"
android:exported="true"> android:exported="true">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:exported="true"
android:value="com.android.messaging.ui.appsettings.SettingsActivity" />
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
@@ -239,11 +215,7 @@
android:screenOrientation="user" android:screenOrientation="user"
android:label="@string/people_and_options_activity_title" android:label="@string/people_and_options_activity_title"
android:theme="@style/BugleTheme" android:theme="@style/BugleTheme"
android:parentActivityName="com.android.messaging.ui.conversation.ConversationActivity"> android:parentActivityName="com.android.messaging.ui.conversation.ConversationActivity" />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.android.messaging.ui.conversation.ConversationActivity" />
</activity>
<!-- License --> <!-- License -->
<activity android:name=".ui.LicenseActivity" <activity android:name=".ui.LicenseActivity"
@@ -280,11 +252,8 @@
android:configChanges="orientation|screenSize|keyboardHidden" android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="user" android:screenOrientation="user"
android:label="@string/vcard_detail_activity_title" android:label="@string/vcard_detail_activity_title"
android:theme="@style/BugleTheme"> android:theme="@style/BugleTheme"
<meta-data android:parentActivityName="com.android.messaging.ui.conversation.ConversationActivity" />
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.conversation.ConversationActivity" />
</activity>
<!-- Attachment chooser --> <!-- Attachment chooser -->
<activity <activity
@@ -293,11 +262,7 @@
android:screenOrientation="user" android:screenOrientation="user"
android:label="@string/attachment_chooser_activity_title" android:label="@string/attachment_chooser_activity_title"
android:theme="@style/BugleTheme" android:theme="@style/BugleTheme"
android:parentActivityName="com.android.messaging.ui.conversation.ConversationActivity"> android:parentActivityName="com.android.messaging.ui.conversation.ConversationActivity" />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.android.messaging.ui.conversation.ConversationActivity" />
</activity>
<activity <activity
android:name=".ui.debug.DebugMmsConfigActivity" android:name=".ui.debug.DebugMmsConfigActivity"
@@ -335,15 +300,6 @@
<!-- Intents for Notification and Pre-KLP Delivery --> <!-- Intents for Notification and Pre-KLP Delivery -->
<!-- Registered with the highest possible priority (max_int) --> <!-- Registered with the highest possible priority (max_int) -->
<receiver android:name=".receiver.MmsWapPushReceiver"
android:enabled="false"
android:exported="true"
android:permission="android.permission.BROADCAST_WAP_PUSH">
<intent-filter android:priority="2147483647">
<action android:name="android.provider.Telephony.WAP_PUSH_RECEIVED" />
<data android:mimeType="application/vnd.wap.mms-message" />
</intent-filter>
</receiver>
<receiver android:name=".receiver.SmsReceiver" <receiver android:name=".receiver.SmsReceiver"
android:enabled="false" android:enabled="false"
android:exported="true" android:exported="true"
@@ -356,26 +312,6 @@
</intent-filter> </intent-filter>
</receiver> </receiver>
<!-- Intents for aborting SMS/MMS broadcasts pre-KLP -->
<!-- Registered for a priority just ahead of inbox Messaging apps (2) -->
<receiver android:name=".receiver.AbortMmsWapPushReceiver"
android:enabled="false"
android:exported="true"
android:permission="android.permission.BROADCAST_WAP_PUSH">
<intent-filter android:priority="3">
<action android:name="android.provider.Telephony.WAP_PUSH_RECEIVED" />
<data android:mimeType="application/vnd.wap.mms-message" />
</intent-filter>
</receiver>
<receiver android:name=".receiver.AbortSmsReceiver"
android:enabled="false"
android:exported="true"
android:permission="android.permission.BROADCAST_SMS">
<intent-filter android:priority="3">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<!-- Intents for KLP+ Delivery --> <!-- Intents for KLP+ Delivery -->
<receiver android:name=".receiver.MmsWapPushDeliverReceiver" <receiver android:name=".receiver.MmsWapPushDeliverReceiver"
android:exported="true" android:exported="true"
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 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.
-->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/contact_picker_tab_pressed" />
-26
View File
@@ -1,26 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 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.
-->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/fab_ripple" >
<item>
<shape android:shape="oval">
<solid android:color="@color/fab_color" />
</shape>
</item>
</ripple>
@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 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.
-->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/gallery_image_pressed">
<item android:id="@android:id/mask"
android:drawable="@android:color/white" />
</ripple>
@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 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.
-->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/background_item_pressed" />
@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 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.
-->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/background_item_pressed" />
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

@@ -14,8 +14,5 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <ripple xmlns:android="http://schemas.android.com/apk/res/android"
<item android:color="@color/contact_picker_tab_pressed" />
android:state_pressed="true"
android:drawable="@color/contact_picker_tab_pressed" />
</selector>
+7 -26
View File
@@ -14,32 +14,13 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<layer-list <ripple xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"> android:color="@color/fab_ripple" >
<item> <item>
<bitmap <shape android:shape="oval">
android:src="@drawable/fab_new_message_static_shadow" /> <solid android:color="@color/fab_color" />
</item>
<item
android:left="2dp"
android:right="2dp"
android:bottom="@dimen/fab_padding_bottom">
<selector>
<item
android:state_pressed="true">
<shape
android:shape="oval" >
<solid
android:color="@color/fab_pressed_color" />
</shape> </shape>
</item> </item>
<item>
<shape </ripple>
android:shape="oval" >
<solid
android:color="@color/fab_color" />
</shape>
</item>
</selector>
</item>
</layer-list>
@@ -14,10 +14,8 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <ripple xmlns:android="http://schemas.android.com/apk/res/android"
<item android:color="@color/gallery_image_pressed">
android:state_pressed="true" <item android:id="@android:id/mask"
android:drawable="@color/gallery_image_pressed" /> android:drawable="@android:color/white" />
<item </ripple>
android:drawable="@android:color/transparent" />
</selector>
@@ -14,13 +14,5 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <ripple xmlns:android="http://schemas.android.com/apk/res/android"
<item android:color="@color/background_item_pressed" />
android:state_pressed="true"
android:drawable="@color/background_item_pressed" />
<item
android:state_activated="true"
android:drawable="@color/background_item_activated" />
<item
android:drawable="@color/background_item_transparent" />
</selector>
+2 -10
View File
@@ -14,13 +14,5 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <ripple xmlns:android="http://schemas.android.com/apk/res/android"
<item android:color="@color/background_item_pressed" />
android:state_pressed="true"
android:drawable="@color/background_item_pressed" />
<item
android:state_activated="true"
android:drawable="@color/background_item_activated" />
<item
android:drawable="@color/background_item_transparent" />
</selector>
-23
View File
@@ -1,23 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 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.
-->
<resources>
<style name="ComposeMessageViewAttachMediaButtonStyle">
<item name="android:paddingStart">@dimen/compose_message_attachment_padding_sides</item>
<item name="android:paddingEnd">@dimen/compose_message_attachment_padding_sides</item>
<item name="android:background">?android:attr/selectableItemBackgroundBorderless</item>
</style>
</resources>
+2 -1
View File
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
Copyright (C) 2015 The Android Open Source Project Copyright (C) 2015 The Android Open Source Project
Copyright (C) 2024 The LineageOS Project
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@@ -22,7 +23,7 @@
<style name="ComposeMessageViewAttachMediaButtonStyle"> <style name="ComposeMessageViewAttachMediaButtonStyle">
<item name="android:paddingStart">@dimen/compose_message_attachment_padding_sides</item> <item name="android:paddingStart">@dimen/compose_message_attachment_padding_sides</item>
<item name="android:paddingEnd">@dimen/compose_message_attachment_padding_sides</item> <item name="android:paddingEnd">@dimen/compose_message_attachment_padding_sides</item>
<item name="android:background">?android:attr/selectableItemBackground</item> <item name="android:background">?android:attr/selectableItemBackgroundBorderless</item>
</style> </style>
<style name="ConversationComposeSendText"> <style name="ConversationComposeSendText">
-77
View File
@@ -1,77 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 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.
-->
<resources>
<style name="GalleryGridItemViewCheckBoxStyle">
<item name="android:paddingEnd">4dp</item>
</style>
<style name="AttachmentGridItemViewCheckBoxStyle">
<item name="android:paddingEnd">4dp</item>
</style>
<style name="PeopleAndOptionsItemStyle">
<item name="android:paddingStart">16dp</item>
<item name="android:paddingEnd">16dp</item>
</style>
<style name="AudioAttachmentViewStyle">
<item name="android:paddingStart">16dp</item>
<item name="android:paddingEnd">16dp</item>
</style>
<style name="VcardAttachmentSingleStyle">
<item name="android:paddingStart">@dimen/message_text_left_right_padding</item>
<item name="android:paddingEnd">@dimen/message_text_left_right_padding</item>
</style>
<style name="PeopleListItemViewStyle">
<item name="android:paddingStart">16dp</item>
</style>
<style name="MessageVcardAttachmentStyle">
<item name="android:paddingStart">@dimen/message_text_left_right_padding</item>
<item name="android:paddingEnd">@dimen/message_text_left_right_padding</item>
</style>
<style name="CameraChooserFrameStyle">
<item name="android:paddingStart">16dp</item>
</style>
<style name="AddContactConfirmationTextStyle">
<item name="android:paddingStart">12dp</item>
<item name="android:paddingEnd">24dp</item>
</style>
<style name="ContactListItemDetailType">
<item name="android:paddingStart">12dp</item>
</style>
<style name="DebugMmsConfigItemStyle">
<item name="android:paddingStart">16dp</item>
<item name="android:paddingEnd">16dp</item>
</style>
<style name="ApnPreferenceLayoutStyle">
<item name="android:paddingStart">?android:attr/listPreferredItemPaddingStart</item>
<item name="android:paddingEnd">?android:attr/listPreferredItemPaddingEnd</item>
</style>
<style name="CopyContactDialogTextStyle">
<item name="android:paddingStart">@dimen/copy_contact_dialog_left_padding</item>
<item name="android:paddingEnd">@dimen/copy_contact_dialog_right_padding</item>
</style>
</resources>
-22
View File
@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 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.
-->
<resources>
<color name="notification_sender_text">#DE000000</color>
<color name="notification_secondary_text">#8A000000</color>
<color name="notification_tertiary_text">#8A000000</color>
<color name="notification_subject_color">#DE000000</color>
</resources>
-22
View File
@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 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.
-->
<resources>
<dimen name="fab_bottom_margin">16dp</dimen>
<dimen name="fab_left_right_margin">16dp</dimen>
<dimen name="fab_size">56dp</dimen>
<dimen name="fab_padding_bottom">0dp</dimen>
</resources>
-43
View File
@@ -1,43 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Copyright (C) 2024 The LineageOS 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.
-->
<resources>
<style name="BugleTheme.ConversationActivity"
parent="@style/BugleTheme.ConversationActivityBase">
<item name="android:colorEdgeEffect">@color/conversation_edge_effect</item>
</style>
<style name="BugleTheme.DialogActivity" parent="@style/Theme.AppCompat.DayNight.Dialog">
<item name="android:windowNoTitle">false</item>
<item name="android:background">@color/window_background</item>
<item name="android:dialogCornerRadius">28dp</item>
</style>
<style name="ContactListItemDrawableIndicator">
<item name="android:background">?android:attr/selectableItemBackgroundBorderless</item>
</style>
<style name="ConversationActionBarTitleTextStyle" parent="BugleActionBarTitleTextStyle">
<item name="android:background">?android:attr/selectableItemBackgroundBorderless</item>
</style>
<style name="WidgetConversationListItemStyle">
<item name="android:background">@drawable/widget_item_background</item>
<item name="android:layout_height">72dp</item>
</style>
</resources>
-23
View File
@@ -1,23 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2018 The LineageOS 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.
-->
<resources>
<style name="BugleBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:forceDarkAllowed">true</item>
<item name="android:navigationBarColor">@color/navigation_bar_bg</item>
<item name="android:windowLightNavigationBar">true</item>
</style>
</resources>
+5 -4
View File
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
Copyright (C) 2015 The Android Open Source Project Copyright (C) 2015 The Android Open Source Project
Copyright (C) 2024 The LineageOS Project
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@@ -128,13 +129,13 @@
<color name="contact_picker_hint_text_color">#40000000</color> <color name="contact_picker_hint_text_color">#40000000</color>
<color name="notification_sender_text">#9A9A9A</color> <color name="notification_sender_text">#DE000000</color>
<color name="notification_secondary_text">#FFFFFF</color> <color name="notification_secondary_text">#8A000000</color>
<color name="notification_tertiary_text">#FFFFFF</color> <color name="notification_tertiary_text">#8A000000</color>
<color name="wearable_notification_participants_count">#a2a2a2</color> <color name="wearable_notification_participants_count">#a2a2a2</color>
<color name="notification_accent_color">@color/primary_color</color> <color name="notification_accent_color">@color/primary_color</color>
<color name="notification_warning_color">#ff0000</color> <color name="notification_warning_color">#ff0000</color>
<color name="notification_subject_color">#99aaaaaa</color> <color name="notification_subject_color">#DE000000</color>
<color name="participant_list_text_primary">#4d4d4d</color> <color name="participant_list_text_primary">#4d4d4d</color>
<color name="people_and_options_header_text">#6d6d6d</color> <color name="people_and_options_header_text">#6d6d6d</color>
+5 -4
View File
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
Copyright (C) 2015 The Android Open Source Project Copyright (C) 2015 The Android Open Source Project
Copyright (C) 2024 The LineageOS Project
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@@ -112,12 +113,12 @@
<dimen name="image_attachment_fallback_width">240dp</dimen> <dimen name="image_attachment_fallback_width">240dp</dimen>
<dimen name="image_attachment_fallback_height">240dp</dimen> <dimen name="image_attachment_fallback_height">240dp</dimen>
<dimen name="fab_size">60dp</dimen> <dimen name="fab_size">56dp</dimen>
<dimen name="fab_padding_bottom">4dp</dimen> <dimen name="fab_padding_bottom">0dp</dimen>
<dimen name="fab_elevation">2dp</dimen> <dimen name="fab_elevation">2dp</dimen>
<dimen name="fab_elevation_pressed">6dp</dimen> <dimen name="fab_elevation_pressed">6dp</dimen>
<dimen name="fab_bottom_margin">12dp</dimen> <dimen name="fab_bottom_margin">16dp</dimen>
<dimen name="fab_left_right_margin">14dp</dimen> <dimen name="fab_left_right_margin">16dp</dimen>
<dimen name="message_body_size_text_size">12sp</dimen> <dimen name="message_body_size_text_size">12sp</dimen>
<dimen name="vcard_detail_group_indicator_width">40dp</dimen> <dimen name="vcard_detail_group_indicator_width">40dp</dimen>
+37 -36
View File
@@ -17,18 +17,14 @@
--> -->
<resources> <resources>
<!-- <!--
Base application theme, dependent on API level. This theme is replaced Base application theme
by BugleBaseTheme from res/values-vXX/styles.xml on newer devices.
--> -->
<style name="BugleBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <style name="BugleBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- <item name="android:forceDarkAllowed">true</item>
Theme customizations available in newer API levels can go in <item name="android:navigationBarColor">@color/navigation_bar_bg</item>
res/values-vXX/styles.xml, while customizations related to <item name="android:windowLightNavigationBar">true</item>
backward-compatibility can go here.
-->
</style> </style>
<!-- Application theme. --> <!-- Application theme. -->
<style name="BugleTheme" parent="BugleBaseTheme"> <style name="BugleTheme" parent="BugleBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. --> <!-- All customizations that are NOT specific to a particular API-level can go here. -->
@@ -49,6 +45,7 @@
<style name="BugleTheme.ConversationActivity" <style name="BugleTheme.ConversationActivity"
parent="@style/BugleTheme.ConversationActivityBase"> parent="@style/BugleTheme.ConversationActivityBase">
<item name="android:colorEdgeEffect">@color/conversation_edge_effect</item>
</style> </style>
<style name="BugleTheme.ConversationActivityBase" parent="BugleTheme"> <style name="BugleTheme.ConversationActivityBase" parent="BugleTheme">
@@ -59,7 +56,10 @@
<item name="android:fastScrollPreviewBackgroundRight">@drawable/contacts_fastscroll_label_right</item> <item name="android:fastScrollPreviewBackgroundRight">@drawable/contacts_fastscroll_label_right</item>
</style> </style>
<style name="BugleTheme.DialogActivity" parent="@style/Theme.AppCompat.Light.Dialog"> <style name="BugleTheme.DialogActivity" parent="@style/Theme.AppCompat.DayNight.Dialog">
<item name="android:windowNoTitle">false</item>
<item name="android:background">@color/window_background</item>
<item name="android:dialogCornerRadius">28dp</item>
</style> </style>
<style name="BugleTheme.ConversationListActivity" parent="BugleTheme"> <style name="BugleTheme.ConversationListActivity" parent="BugleTheme">
@@ -107,7 +107,7 @@
</style> </style>
<style name="ConversationActionBarTitleTextStyle" parent="BugleActionBarTitleTextStyle"> <style name="ConversationActionBarTitleTextStyle" parent="BugleActionBarTitleTextStyle">
<item name="android:background">?android:attr/selectableItemBackground</item> <item name="android:background">?android:attr/selectableItemBackgroundBorderless</item>
</style> </style>
<style name="BuglePhotoViewTheme" parent="PhotoViewTheme.Translucent"> <style name="BuglePhotoViewTheme" parent="PhotoViewTheme.Translucent">
@@ -173,12 +173,12 @@
<item name="android:background">@null</item> <item name="android:background">@null</item>
</style> </style>
<style name="ContactListItemDetailType" parent="ContactListItemDetail"> <style name="ContactListItemDetailType">
<item name="android:paddingLeft">12dp</item> <item name="android:paddingStart">12dp</item>
</style> </style>
<style name="ContactListItemDrawableIndicator"> <style name="ContactListItemDrawableIndicator">
<item name="android:background">?android:attr/selectableItemBackground</item> <item name="android:background">?android:attr/selectableItemBackgroundBorderless</item>
</style> </style>
<style name="RecipientEditTextView"> <style name="RecipientEditTextView">
@@ -224,8 +224,8 @@
</style> </style>
<style name="AudioAttachmentViewStyle"> <style name="AudioAttachmentViewStyle">
<item name="android:paddingRight">16dp</item> <item name="android:paddingStart">16dp</item>
<item name="android:paddingLeft">16dp</item> <item name="android:paddingEnd">16dp</item>
</style> </style>
<style name="ContactPickerHintText"> <style name="ContactPickerHintText">
@@ -234,13 +234,13 @@
</style> </style>
<style name="VcardAttachmentSingleStyle"> <style name="VcardAttachmentSingleStyle">
<item name="android:paddingRight">@dimen/message_text_left_right_padding</item> <item name="android:paddingStart">@dimen/message_text_left_right_padding</item>
<item name="android:paddingLeft">@dimen/message_text_left_right_padding</item> <item name="android:paddingEnd">@dimen/message_text_left_right_padding</item>
</style> </style>
<style name="MessageVcardAttachmentStyle"> <style name="MessageVcardAttachmentStyle">
<item name="android:paddingRight">@dimen/message_text_left_right_padding</item> <item name="android:paddingStart">@dimen/message_text_left_right_padding</item>
<item name="android:paddingLeft">@dimen/message_text_left_right_padding</item> <item name="android:paddingEnd">@dimen/message_text_left_right_padding</item>
</style> </style>
<style name="NotificationSenderText"> <style name="NotificationSenderText">
@@ -265,7 +265,7 @@
</style> </style>
<style name="CameraChooserFrameStyle"> <style name="CameraChooserFrameStyle">
<item name="android:paddingLeft">16dp</item> <item name="android:paddingStart">16dp</item>
</style> </style>
<style name="ComposeMessageViewAttachMediaButtonStyle"> <style name="ComposeMessageViewAttachMediaButtonStyle">
@@ -309,7 +309,7 @@
</style> </style>
<style name="GalleryGridItemViewCheckBoxStyle"> <style name="GalleryGridItemViewCheckBoxStyle">
<item name="android:paddingRight">22dp</item> <item name="android:paddingEnd">4dp</item>
</style> </style>
<style name="AttachmentPreviewAttachmentStyle"> <style name="AttachmentPreviewAttachmentStyle">
@@ -342,23 +342,23 @@
<item name="android:layout_gravity">left|center_vertical</item> <item name="android:layout_gravity">left|center_vertical</item>
</style> </style>
<style name="AddContactConfirmationTextStyle" parent="ParticipantListItem"> <style name="AddContactConfirmationTextStyle">
<item name="android:paddingLeft">12dp</item> <item name="android:paddingStart">12dp</item>
<item name="android:paddingRight">24dp</item> <item name="android:paddingEnd">24dp</item>
</style> </style>
<style name="CopyContactDialogTextStyle" parent="ParticipantListItem"> <style name="CopyContactDialogTextStyle">
<item name="android:paddingLeft">@dimen/copy_contact_dialog_left_padding</item> <item name="android:paddingStart">@dimen/copy_contact_dialog_left_padding</item>
<item name="android:paddingRight">@dimen/copy_contact_dialog_right_padding</item> <item name="android:paddingEnd">@dimen/copy_contact_dialog_right_padding</item>
</style> </style>
<style name="PeopleListItemViewStyle"> <style name="PeopleListItemViewStyle">
<item name="android:paddingLeft">16dp</item> <item name="android:paddingStart">16dp</item>
</style> </style>
<style name="PeopleAndOptionsItemStyle"> <style name="PeopleAndOptionsItemStyle">
<item name="android:paddingRight">16dp</item> <item name="android:paddingStart">16dp</item>
<item name="android:paddingLeft">16dp</item> <item name="android:paddingEnd">16dp</item>
</style> </style>
<style name="PeopleAndOptionsSectionHeader"> <style name="PeopleAndOptionsSectionHeader">
@@ -477,8 +477,8 @@
</style> </style>
<style name="ApnPreferenceLayoutStyle"> <style name="ApnPreferenceLayoutStyle">
<item name="android:paddingLeft">?android:attr/listPreferredItemPaddingStart</item> <item name="android:paddingStart">?android:attr/listPreferredItemPaddingStart</item>
<item name="android:paddingRight">?android:attr/listPreferredItemPaddingEnd</item> <item name="android:paddingEnd">?android:attr/listPreferredItemPaddingEnd</item>
</style> </style>
<style name="SettingsListItem"> <style name="SettingsListItem">
@@ -505,8 +505,8 @@
</style> </style>
<style name="DebugMmsConfigItemStyle"> <style name="DebugMmsConfigItemStyle">
<item name="android:paddingLeft">16dp</item> <item name="android:paddingStart">16dp</item>
<item name="android:paddingRight">16dp</item> <item name="android:paddingEnd">16dp</item>
</style> </style>
<style name="WidgetTitle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title"> <style name="WidgetTitle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
@@ -612,11 +612,12 @@
</style> </style>
<style name="WidgetConversationListItemStyle"> <style name="WidgetConversationListItemStyle">
<item name="android:layout_height">80dp</item> <item name="android:background">@drawable/widget_item_background</item>
<item name="android:layout_height">72dp</item>
</style> </style>
<style name="AttachmentGridItemViewCheckBoxStyle"> <style name="AttachmentGridItemViewCheckBoxStyle">
<item name="android:paddingRight">4dp</item> <item name="android:paddingEnd">4dp</item>
</style> </style>
<style name="PromoScreenTextStyle"> <style name="PromoScreenTextStyle">
-79
View File
@@ -1,79 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 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.
-->
<!-- Preference screen definition for Bugle's application-wide settings -->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<!-- KLP+ only -->
<PreferenceScreen
android:key="@string/sms_disabled_pref_key"
android:title="@string/sms_disabled_pref_title"
android:persistent="false">
<intent
android:action="android.provider.Telephony.ACTION_CHANGE_DEFAULT">
<extra android:name="package" android:value="com.android.messaging" />
</intent>
</PreferenceScreen>
<PreferenceScreen
android:key="@string/sms_enabled_pref_key"
android:title="@string/sms_enabled_pref_title"
android:persistent="false">
<intent
android:action="android.settings.WIRELESS_SETTINGS">
</intent>
</PreferenceScreen>
<SwitchPreference
android:key="@string/send_sound_pref_key"
android:title="@string/send_sound_pref_title"
android:defaultValue="@bool/send_sound_pref_default"
android:persistent="true" />
<Preference
android:key="@string/notifications_pref_key"
android:title="@string/notifications_pref_title"
android:persistent="true" />
<SwitchPreference
android:key="@string/swipe_right_deletes_conversation_key"
android:title="@string/swipe_to_delete_conversation_pref_title"
android:summary="@string/swipe_to_delete_conversation_pref_summary"
android:defaultValue="false"
android:persistent="true" />
<PreferenceScreen
android:key="@string/advanced_pref_key"
android:title="@string/advanced_settings" />
<PreferenceCategory
android:key="@string/debug_pref_key"
android:title="@string/debug_category_pref_title">
<SwitchPreference
android:key="@string/dump_sms_pref_key"
android:title="@string/dump_sms_pref_title"
android:summary="@string/dump_sms_pref_summary"
android:defaultValue="@bool/dump_sms_pref_default" />
<SwitchPreference
android:key="@string/dump_mms_pref_key"
android:title="@string/dump_mms_pref_title"
android:summary="@string/dump_mms_pref_summary"
android:defaultValue="@bool/dump_mms_pref_default" />
</PreferenceCategory>
</PreferenceScreen>
@@ -1,63 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Copyright (C) 2024 The LineageOS 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.
-->
<!-- Preference screen definition for Bugle's subscription-specific settings -->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:key="@string/mms_messaging_category_pref_key"
android:title="@string/mms_messaging_category_pref_title">
<Preference
android:title="@string/group_mms_pref_title"
android:key="@string/group_mms_pref_key"/>
<com.android.messaging.ui.appsettings.PhoneNumberPreference
android:key="@string/mms_phone_number_pref_key"
android:title="@string/mms_phone_number_pref_title" />
<SwitchPreference
android:key="@string/auto_retrieve_mms_pref_key"
android:title="@string/auto_retrieve_mms_pref_title"
android:summary="@string/auto_retrieve_mms_pref_summary"
android:defaultValue="@bool/auto_retrieve_mms_pref_default" />
<SwitchPreference
android:key="@string/auto_retrieve_mms_when_roaming_pref_key"
android:dependency="@string/auto_retrieve_mms_pref_key"
android:title="@string/auto_retrieve_mms_when_roaming_pref_title"
android:summary="@string/auto_retrieve_mms_when_roaming_pref_summary"
android:defaultValue="@bool/auto_retrieve_mms_when_roaming_pref_default" />
</PreferenceCategory>
<PreferenceCategory
android:key="@string/advanced_category_pref_key"
android:title="@string/advanced_category_pref_title">
<SwitchPreference
android:key="@string/delivery_reports_pref_key"
android:title="@string/delivery_reports_pref_title"
android:summary="@string/delivery_reports_pref_summary"
android:defaultValue="@bool/delivery_reports_pref_default" />
<PreferenceScreen
android:key="@string/sms_apns_key"
android:title="@string/sms_apns_title" />
</PreferenceCategory>
</PreferenceScreen>
-80
View File
@@ -1,80 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 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.
-->
<!-- Preference screen definition for Bugle's application-wide settings -->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<!-- KLP+ only -->
<PreferenceScreen
android:key="@string/sms_disabled_pref_key"
android:title="@string/sms_disabled_pref_title"
android:persistent="false">
<intent
android:action="android.provider.Telephony.ACTION_CHANGE_DEFAULT">
<extra android:name="package" android:value="com.android.messaging" />
</intent>
</PreferenceScreen>
<!-- MNC+ only -->
<PreferenceScreen
android:key="@string/sms_enabled_pref_key"
android:title="@string/sms_enabled_pref_title"
android:persistent="false">
<intent
android:action="android.provider.Telephony.ACTION_CHANGE_DEFAULT">
</intent>
</PreferenceScreen>
<SwitchPreference
android:key="@string/send_sound_pref_key"
android:title="@string/send_sound_pref_title"
android:defaultValue="@bool/send_sound_pref_default"
android:persistent="true" />
<Preference
android:key="@string/notifications_pref_key"
android:title="@string/notifications_pref_title"
android:persistent="true" />
<SwitchPreference
android:key="@string/swipe_right_deletes_conversation_key"
android:title="@string/swipe_to_delete_conversation_pref_title"
android:summary="@string/swipe_to_delete_conversation_pref_summary"
android:defaultValue="false"
android:persistent="true" />
<PreferenceScreen
android:key="@string/advanced_pref_key"
android:title="@string/advanced_settings" />
<PreferenceCategory
android:key="@string/debug_pref_key"
android:title="@string/debug_category_pref_title">
<SwitchPreference
android:key="@string/dump_sms_pref_key"
android:title="@string/dump_sms_pref_title"
android:summary="@string/dump_sms_pref_summary"
android:defaultValue="@bool/dump_sms_pref_default" />
<SwitchPreference
android:key="@string/dump_mms_pref_key"
android:title="@string/dump_mms_pref_title"
android:summary="@string/dump_mms_pref_summary"
android:defaultValue="@bool/dump_mms_pref_default" />
</PreferenceCategory>
</PreferenceScreen>
+1 -1
View File
@@ -32,7 +32,7 @@
android:title="@string/sms_enabled_pref_title" android:title="@string/sms_enabled_pref_title"
android:persistent="false"> android:persistent="false">
<intent <intent
android:action="android.settings.WIRELESS_SETTINGS"> android:action="android.provider.Telephony.ACTION_CHANGE_DEFAULT">
</intent> </intent>
</PreferenceScreen> </PreferenceScreen>
@@ -286,7 +286,7 @@ class DefaultApnSettingsLoader implements ApnSettingsLoader {
*/ */
private void loadFromSystem(final int subId, final String apnName, final List<Apn> apns) { private void loadFromSystem(final int subId, final String apnName, final List<Apn> apns) {
Uri uri; Uri uri;
if (Utils.supportMSim() && subId != MmsManager.DEFAULT_SUB_ID) { if (subId != MmsManager.DEFAULT_SUB_ID) {
uri = Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "/subId/" + subId); uri = Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "/subId/" + subId);
} else { } else {
uri = Telephony.Carriers.CONTENT_URI; uri = Telephony.Carriers.CONTENT_URI;
@@ -68,13 +68,9 @@ class DefaultCarrierConfigValuesLoader implements CarrierConfigValuesLoader {
} }
private void loadLocked(final int subId, final Bundle values) { private void loadLocked(final int subId, final Bundle values) {
// For K and earlier, load from resources
loadFromResources(subId, values); loadFromResources(subId, values);
if (Utils.hasMmsApi()) {
// For L and later, also load from system MMS service
loadFromSystem(subId, values); loadFromSystem(subId, values);
} }
}
/** /**
* Load from system, using MMS API * Load from system, using MMS API
@@ -72,13 +72,11 @@ class DefaultUserAgentInfoLoader implements UserAgentInfoLoader {
} }
private void loadLocked() { private void loadLocked() {
if (Utils.hasUserAgentApi()) {
// load the MMS User agent and UaProfUrl from TelephonyManager APIs // load the MMS User agent and UaProfUrl from TelephonyManager APIs
final TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService( final TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(
Context.TELEPHONY_SERVICE); Context.TELEPHONY_SERVICE);
mUserAgent = telephonyManager.getMmsUserAgent(); mUserAgent = telephonyManager.getMmsUserAgent();
mUAProfUrl = telephonyManager.getMmsUAProfUrl(); mUAProfUrl = telephonyManager.getMmsUAProfUrl();
}
if (TextUtils.isEmpty(mUserAgent)) { if (TextUtils.isEmpty(mUserAgent)) {
mUserAgent = DEFAULT_USER_AGENT; mUserAgent = DEFAULT_USER_AGENT;
} }
+1 -14
View File
@@ -392,7 +392,6 @@ public class MmsHttpClient {
* @return the phone number text * @return the phone number text
*/ */
private String getSelfNumber() { private String getSelfNumber() {
if (Utils.supportMSim()) {
final SubscriptionManager subscriptionManager = SubscriptionManager.from(mContext); final SubscriptionManager subscriptionManager = SubscriptionManager.from(mContext);
final SubscriptionInfo info = subscriptionManager.getActiveSubscriptionInfo( final SubscriptionInfo info = subscriptionManager.getActiveSubscriptionInfo(
SmsManager.getDefaultSmsSubscriptionId()); SmsManager.getDefaultSmsSubscriptionId());
@@ -401,9 +400,6 @@ public class MmsHttpClient {
} else { } else {
return null; return null;
} }
} else {
return mTelephonyManager.getLine1Number();
}
} }
/** /**
@@ -413,16 +409,12 @@ public class MmsHttpClient {
*/ */
private String getSimOrLocaleCountry() { private String getSimOrLocaleCountry() {
String country = null; String country = null;
if (Utils.supportMSim()) {
final SubscriptionManager subscriptionManager = SubscriptionManager.from(mContext); final SubscriptionManager subscriptionManager = SubscriptionManager.from(mContext);
final SubscriptionInfo info = subscriptionManager.getActiveSubscriptionInfo( final SubscriptionInfo info = subscriptionManager.getActiveSubscriptionInfo(
SmsManager.getDefaultSmsSubscriptionId()); SmsManager.getDefaultSmsSubscriptionId());
if (info != null) { if (info != null) {
country = info.getCountryIso(); country = info.getCountryIso();
} }
} else {
country = mTelephonyManager.getSimCountryIso();
}
if (!TextUtils.isEmpty(country)) { if (!TextUtils.isEmpty(country)) {
return country.toUpperCase(); return country.toUpperCase();
} else { } else {
@@ -439,13 +431,8 @@ public class MmsHttpClient {
* @return the Base64 encoded NAI string to use as HTTP header * @return the Base64 encoded NAI string to use as HTTP header
*/ */
private String getEncodedNai(final String naiSuffix) { private String getEncodedNai(final String naiSuffix) {
String nai; String nai = getNaiBySystemApi(
if (Utils.supportMSim()) {
nai = getNaiBySystemApi(
getSlotId(Utils.getEffectiveSubscriptionId(MmsManager.DEFAULT_SUB_ID))); getSlotId(Utils.getEffectiveSubscriptionId(MmsManager.DEFAULT_SUB_ID)));
} else {
nai = getNaiBySystemProperty();
}
if (!TextUtils.isEmpty(nai)) { if (!TextUtils.isEmpty(nai)) {
Log.i(MmsService.TAG, "NAI is not empty"); Log.i(MmsService.TAG, "NAI is not empty");
if (!TextUtils.isEmpty(naiSuffix)) { if (!TextUtils.isEmpty(naiSuffix)) {
+1 -5
View File
@@ -175,7 +175,7 @@ public class MmsManager {
* @return true if forced to use legacy APIs or platform doesn't supports MMS APIs. * @return true if forced to use legacy APIs or platform doesn't supports MMS APIs.
*/ */
public static boolean shouldUseLegacyMms() { public static boolean shouldUseLegacyMms() {
return sForceLegacyMms || !Utils.hasMmsApi(); return sForceLegacyMms;
} }
/** /**
@@ -187,10 +187,6 @@ public class MmsManager {
* @return a Bundle containing the overrides * @return a Bundle containing the overrides
*/ */
private static Bundle getConfigOverrides(final int subId) { private static Bundle getConfigOverrides(final int subId) {
if (!Utils.hasMmsApi()) {
// If MMS API is not present, it is not necessary to compute overrides
return null;
}
Bundle overrides = null; Bundle overrides = null;
synchronized (sConfigOverridesMap) { synchronized (sConfigOverridesMap) {
overrides = sConfigOverridesMap.get(subId); overrides = sConfigOverridesMap.get(subId);
@@ -23,7 +23,6 @@ import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.NetworkInfo; import android.net.NetworkInfo;
import android.os.Build;
import android.os.SystemClock; import android.os.SystemClock;
import android.util.Log; import android.util.Log;
@@ -350,16 +349,7 @@ class MmsNetworkManager {
* @return The change's network type * @return The change's network type
*/ */
private static int getConnectivityChangeNetworkType(final Intent intent) { private static int getConnectivityChangeNetworkType(final Intent intent) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
return intent.getIntExtra(ConnectivityManager.EXTRA_NETWORK_TYPE, TYPE_NONE); return intent.getIntExtra(ConnectivityManager.EXTRA_NETWORK_TYPE, TYPE_NONE);
} else {
final NetworkInfo info = intent.getParcelableExtra(
ConnectivityManager.EXTRA_NETWORK_INFO);
if (info != null) {
return info.getType();
}
}
return TYPE_NONE;
} }
private static String getMmsConnectivityResultString(int result) { private static String getMmsConnectivityResultString(int result) {
-52
View File
@@ -19,11 +19,9 @@ package android.support.v7.mms;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Build;
import android.telephony.SmsManager; import android.telephony.SmsManager;
import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
@@ -34,33 +32,6 @@ import java.net.URL;
* Utility methods * Utility methods
*/ */
class Utils { class Utils {
/**
* Check if MMS API is available
*
* @return true if MMS API is available, false otherwise
*/
static boolean hasMmsApi() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
}
/**
* Check if support multi-SIM
*
* @return true if MSIM is supported, false otherwise
*/
static boolean supportMSim() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1;
}
/**
* Check if support APIs for getting UserAgent and UAProfUrl
*
* @return true if those APIs are supported, false otherwise
*/
static boolean hasUserAgentApi() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
}
/** /**
* Get system SmsManager * Get system SmsManager
* *
@@ -68,11 +39,7 @@ class Utils {
* @return the SmsManager for the input subId * @return the SmsManager for the input subId
*/ */
static SmsManager getSmsManager(final int subId) { static SmsManager getSmsManager(final int subId) {
if (supportMSim()) {
return SmsManager.getSmsManagerForSubscriptionId(subId); return SmsManager.getSmsManagerForSubscriptionId(subId);
} else {
return SmsManager.getDefault();
}
} }
/** /**
@@ -82,11 +49,9 @@ class Utils {
* @return the default SMS subscription ID if the input is -1, otherwise the original * @return the default SMS subscription ID if the input is -1, otherwise the original
*/ */
static int getEffectiveSubscriptionId(int subId) { static int getEffectiveSubscriptionId(int subId) {
if (supportMSim()) {
if (subId == MmsManager.DEFAULT_SUB_ID) { if (subId == MmsManager.DEFAULT_SUB_ID) {
subId = SmsManager.getDefaultSmsSubscriptionId(); subId = SmsManager.getDefaultSmsSubscriptionId();
} }
}
if (subId < 0) { if (subId < 0) {
subId = MmsManager.DEFAULT_SUB_ID; subId = MmsManager.DEFAULT_SUB_ID;
} }
@@ -102,26 +67,12 @@ class Utils {
*/ */
static int[] getMccMnc(final Context context, final int subId) { static int[] getMccMnc(final Context context, final int subId) {
final int[] mccMnc = new int[] { 0, 0 }; final int[] mccMnc = new int[] { 0, 0 };
if (Utils.supportMSim()) {
final SubscriptionManager subscriptionManager = SubscriptionManager.from(context); final SubscriptionManager subscriptionManager = SubscriptionManager.from(context);
final SubscriptionInfo subInfo = subscriptionManager.getActiveSubscriptionInfo(subId); final SubscriptionInfo subInfo = subscriptionManager.getActiveSubscriptionInfo(subId);
if (subInfo != null) { if (subInfo != null) {
mccMnc[0] = subInfo.getMcc(); mccMnc[0] = subInfo.getMcc();
mccMnc[1] = subInfo.getMnc(); mccMnc[1] = subInfo.getMnc();
} }
} else {
final TelephonyManager telephonyManager =
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
final String mccMncString = telephonyManager.getSimOperator();
try {
mccMnc[0] = Integer.parseInt(mccMncString.substring(0, 3));
mccMnc[1] = Integer.parseInt(mccMncString.substring(3));
} catch (Exception e) {
Log.w(MmsService.TAG, "Invalid mcc/mnc from system " + mccMncString + ": " + e);
mccMnc[0] = 0;
mccMnc[1] = 0;
}
}
return mccMnc; return mccMnc;
} }
@@ -133,9 +84,6 @@ class Utils {
* @return the sub-dependent Context * @return the sub-dependent Context
*/ */
static Context getSubDepContext(final Context context, final int subId) { static Context getSubDepContext(final Context context, final int subId) {
if (!supportMSim()) {
return context;
}
final int[] mccMnc = getMccMnc(context, subId); final int[] mccMnc = getMccMnc(context, subId);
final int mcc = mccMnc[0]; final int mcc = mccMnc[0];
final int mnc = mccMnc[1]; final int mnc = mccMnc[1];
@@ -42,7 +42,6 @@ import com.android.messaging.util.BuglePrefs;
import com.android.messaging.util.BuglePrefsKeys; import com.android.messaging.util.BuglePrefsKeys;
import com.android.messaging.util.DebugUtils; import com.android.messaging.util.DebugUtils;
import com.android.messaging.util.LogUtil; import com.android.messaging.util.LogUtil;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.PhoneUtils; import com.android.messaging.util.PhoneUtils;
import com.android.messaging.util.Trace; import com.android.messaging.util.Trace;
@@ -99,9 +98,7 @@ public class BugleApplication extends Application implements UncaughtExceptionHa
// Fixup messages in flight if we crashed and send any pending // Fixup messages in flight if we crashed and send any pending
dataModel.onApplicationCreated(); dataModel.onApplicationCreated();
// Register carrier config change receiver // Register carrier config change receiver
if (OsUtil.isAtLeastM()) {
registerCarrierConfigChangeReceiver(context); registerCarrierConfigChangeReceiver(context);
}
Trace.endSection(); Trace.endSection();
} }
+1 -16
View File
@@ -64,9 +64,6 @@ class FactoryImpl extends Factory {
private SparseArray<BugleSubscriptionPrefs> mSubscriptionPrefs; private SparseArray<BugleSubscriptionPrefs> mSubscriptionPrefs;
private BugleCarrierConfigValuesLoader mCarrierConfigValuesLoader; private BugleCarrierConfigValuesLoader mCarrierConfigValuesLoader;
// Cached instance for Pre-L_MR1
private static final Object PHONEUTILS_INSTANCE_LOCK = new Object();
private static PhoneUtils sPhoneUtilsInstancePreLMR1 = null;
// Cached subId->instance for L_MR1 and beyond // Cached subId->instance for L_MR1 and beyond
private static final ConcurrentHashMap<Integer, PhoneUtils> sPhoneUtilsInstanceCacheLMR1 = private static final ConcurrentHashMap<Integer, PhoneUtils> sPhoneUtilsInstanceCacheLMR1 =
new ConcurrentHashMap<>(); new ConcurrentHashMap<>();
@@ -197,7 +194,6 @@ class FactoryImpl extends Factory {
@Override @Override
public PhoneUtils getPhoneUtils(int subId) { public PhoneUtils getPhoneUtils(int subId) {
if (OsUtil.isAtLeastL_MR1()) {
if (subId == ParticipantData.DEFAULT_SELF_SUB_ID) { if (subId == ParticipantData.DEFAULT_SELF_SUB_ID) {
subId = SmsManager.getDefaultSmsSubscriptionId(); subId = SmsManager.getDefaultSmsSubscriptionId();
} }
@@ -207,21 +203,10 @@ class FactoryImpl extends Factory {
} }
PhoneUtils instance = sPhoneUtilsInstanceCacheLMR1.get(subId); PhoneUtils instance = sPhoneUtilsInstanceCacheLMR1.get(subId);
if (instance == null) { if (instance == null) {
instance = new PhoneUtils.PhoneUtilsLMR1(subId); instance = new PhoneUtils(subId);
sPhoneUtilsInstanceCacheLMR1.putIfAbsent(subId, instance); sPhoneUtilsInstanceCacheLMR1.putIfAbsent(subId, instance);
} }
return instance; return instance;
} else {
Assert.isTrue(subId == ParticipantData.DEFAULT_SELF_SUB_ID);
if (sPhoneUtilsInstancePreLMR1 == null) {
synchronized (PHONEUTILS_INSTANCE_LOCK) {
if (sPhoneUtilsInstancePreLMR1 == null) {
sPhoneUtilsInstancePreLMR1 = new PhoneUtils.PhoneUtilsPreLMR1();
}
}
}
return sPhoneUtilsInstancePreLMR1;
}
} }
@Override @Override
@@ -45,7 +45,6 @@ import com.android.messaging.util.Assert.DoesNotRunOnMainThread;
import com.android.messaging.util.AvatarUriUtil; import com.android.messaging.util.AvatarUriUtil;
import com.android.messaging.util.ContentType; import com.android.messaging.util.ContentType;
import com.android.messaging.util.LogUtil; import com.android.messaging.util.LogUtil;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.PhoneUtils; import com.android.messaging.util.PhoneUtils;
import com.android.messaging.util.UriUtil; import com.android.messaging.util.UriUtil;
import com.android.messaging.widget.WidgetConversationProvider; import com.android.messaging.widget.WidgetConversationProvider;
@@ -567,7 +566,7 @@ public class BugleDatabaseOperations {
// reading and if necessary creating the conversation. // reading and if necessary creating the conversation.
updateConversationRow(dbWrapper, conversationId, values); updateConversationRow(dbWrapper, conversationId, values);
if (shouldAutoSwitchSelfId && OsUtil.isAtLeastL_MR1()) { if (shouldAutoSwitchSelfId) {
// Normally, the draft message compose UI trusts its UI state for providing up-to-date // Normally, the draft message compose UI trusts its UI state for providing up-to-date
// conversation self id. Therefore, notify UI through local broadcast receiver about // conversation self id. Therefore, notify UI through local broadcast receiver about
// this external change so the change can be properly reflected. // this external change so the change can be properly reflected.
@@ -624,7 +623,7 @@ public class BugleDatabaseOperations {
static boolean addSelfIdAutoSwitchInfoToContentValues(final DatabaseWrapper dbWrapper, static boolean addSelfIdAutoSwitchInfoToContentValues(final DatabaseWrapper dbWrapper,
final MessageData message, final String conversationId, final ContentValues values) { final MessageData message, final String conversationId, final ContentValues values) {
// Only auto switch conversation self for incoming messages. // Only auto switch conversation self for incoming messages.
if (!OsUtil.isAtLeastL_MR1() || !message.getIsIncoming()) { if (!message.getIsIncoming()) {
return false; return false;
} }
@@ -77,7 +77,6 @@ import com.android.messaging.util.ImageUtils;
import com.android.messaging.util.LogUtil; import com.android.messaging.util.LogUtil;
import com.android.messaging.util.NotificationPlayer; import com.android.messaging.util.NotificationPlayer;
import com.android.messaging.util.NotificationsUtil; import com.android.messaging.util.NotificationsUtil;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.PendingIntentConstants; import com.android.messaging.util.PendingIntentConstants;
import com.android.messaging.util.PhoneUtils; import com.android.messaging.util.PhoneUtils;
import com.android.messaging.util.ThreadUtil; import com.android.messaging.util.ThreadUtil;
@@ -429,7 +428,7 @@ public class BugleNotifications {
if (state.mParticipantAvatarsUris != null) { if (state.mParticipantAvatarsUris != null) {
final Uri avatarUri = state.mParticipantAvatarsUris.get(0); final Uri avatarUri = state.mParticipantAvatarsUris.get(0);
final AvatarRequestDescriptor descriptor = new AvatarRequestDescriptor(avatarUri, final AvatarRequestDescriptor descriptor = new AvatarRequestDescriptor(avatarUri,
sIconWidth, sIconHeight, OsUtil.isAtLeastL()); sIconWidth, sIconHeight, true);
final MediaRequest<ImageResource> imageRequest = descriptor.buildSyncMediaRequest( final MediaRequest<ImageResource> imageRequest = descriptor.buildSyncMediaRequest(
context); context);
@@ -676,7 +675,6 @@ public class BugleNotifications {
MediaRequest<ImageResource> imageRequest; MediaRequest<ImageResource> imageRequest;
if (isVideo) { if (isVideo) {
Assert.isTrue(VideoThumbnailRequest.shouldShowIncomingVideoThumbnails());
final MessagePartVideoThumbnailRequestDescriptor videoDescriptor = final MessagePartVideoThumbnailRequestDescriptor videoDescriptor =
new MessagePartVideoThumbnailRequestDescriptor(attachmentUri); new MessagePartVideoThumbnailRequestDescriptor(attachmentUri);
imageRequest = videoDescriptor.buildSyncMediaRequest(context); imageRequest = videoDescriptor.buildSyncMediaRequest(context);
@@ -54,7 +54,6 @@ import com.android.messaging.util.Assert;
import com.android.messaging.util.Assert.DoesNotRunOnMainThread; import com.android.messaging.util.Assert.DoesNotRunOnMainThread;
import com.android.messaging.util.ConnectivityUtil; import com.android.messaging.util.ConnectivityUtil;
import com.android.messaging.util.LogUtil; import com.android.messaging.util.LogUtil;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.PhoneUtils; import com.android.messaging.util.PhoneUtils;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@@ -66,8 +65,6 @@ public class DataModelImpl extends DataModel {
private final DatabaseHelper mDatabaseHelper; private final DatabaseHelper mDatabaseHelper;
private final SyncManager mSyncManager; private final SyncManager mSyncManager;
// Cached ConnectivityUtil instance for Pre-N.
private static ConnectivityUtil sConnectivityUtilInstanceCachePreN = null;
// Cached ConnectivityUtil subId->instance for N and beyond // Cached ConnectivityUtil subId->instance for N and beyond
private static final ConcurrentHashMap<Integer, ConnectivityUtil> private static final ConcurrentHashMap<Integer, ConnectivityUtil>
sConnectivityUtilInstanceCacheN = new ConcurrentHashMap<>(); sConnectivityUtilInstanceCacheN = new ConcurrentHashMap<>();
@@ -214,20 +211,15 @@ public class DataModelImpl extends DataModel {
@Override @Override
public void onApplicationCreated() { public void onApplicationCreated() {
if (OsUtil.isAtLeastN()) {
createConnectivityUtilForEachActiveSubscription(); createConnectivityUtilForEachActiveSubscription();
} else {
sConnectivityUtilInstanceCachePreN = new ConnectivityUtil(mContext);
}
FixupMessageStatusOnStartupAction.fixupMessageStatus(); FixupMessageStatusOnStartupAction.fixupMessageStatus();
ProcessPendingMessagesAction.processFirstPendingMessage(); ProcessPendingMessagesAction.processFirstPendingMessage();
SyncManager.immediateSync(); SyncManager.immediateSync();
if (OsUtil.isAtLeastL_MR1()) {
// Start listening for subscription change events for refreshing any data associated // Start listening for subscription change events for refreshing any data associated
// with subscriptions. // with subscriptions.
PhoneUtils.getDefault().toLMr1().registerOnSubscriptionsChangedListener( PhoneUtils.getDefault().registerOnSubscriptionsChangedListener(
new SubscriptionManager.OnSubscriptionsChangedListener() { new SubscriptionManager.OnSubscriptionsChangedListener() {
@Override @Override
public void onSubscriptionsChanged() { public void onSubscriptionsChanged() {
@@ -237,13 +229,10 @@ public class DataModelImpl extends DataModel {
// gracefully // gracefully
MmsConfig.loadAsync(); MmsConfig.loadAsync();
ParticipantRefresh.refreshSelfParticipants(); ParticipantRefresh.refreshSelfParticipants();
if (OsUtil.isAtLeastN()) {
createConnectivityUtilForEachActiveSubscription(); createConnectivityUtilForEachActiveSubscription();
} }
}
}); });
} }
}
private void createConnectivityUtilForEachActiveSubscription() { private void createConnectivityUtilForEachActiveSubscription() {
PhoneUtils.forEachActiveSubscription(new PhoneUtils.SubscriptionRunnable() { PhoneUtils.forEachActiveSubscription(new PhoneUtils.SubscriptionRunnable() {
@@ -262,10 +251,6 @@ public class DataModelImpl extends DataModel {
} }
public static ConnectivityUtil getConnectivityUtil(final int subId) { public static ConnectivityUtil getConnectivityUtil(final int subId) {
if (OsUtil.isAtLeastN()) {
return sConnectivityUtilInstanceCacheN.get(subId); return sConnectivityUtilInstanceCacheN.get(subId);
} else {
return sConnectivityUtilInstanceCachePreN;
}
} }
} }
@@ -25,7 +25,6 @@ import android.provider.ContactsContract.Contacts;
import com.android.messaging.util.FallbackStrategies; import com.android.messaging.util.FallbackStrategies;
import com.android.messaging.util.FallbackStrategies.Strategy; import com.android.messaging.util.FallbackStrategies.Strategy;
import com.android.messaging.util.LogUtil; import com.android.messaging.util.LogUtil;
import com.android.messaging.util.OsUtil;
/** /**
* Helper for querying frequent (and/or starred) contacts. * Helper for querying frequent (and/or starred) contacts.
@@ -90,9 +89,7 @@ public class FrequentContactsCursorQueryData extends CursorQueryData {
// queries. Using strequent_phone_only query as a fallback to display only phone // queries. Using strequent_phone_only query as a fallback to display only phone
// contacts. This is the last-ditch effort; if this fails, we will display an // contacts. This is the last-ditch effort; if this fails, we will display an
// empty frequent list (b/18354836). // empty frequent list (b/18354836).
final String strequentQueryParam = OsUtil.isAtLeastL() ? final String strequentQueryParam = ContactsContract.STREQUENT_PHONE_ONLY;
ContactsContract.STREQUENT_PHONE_ONLY : "strequent_phone_only";
// TODO: Handle enterprise contacts post M once contacts provider supports it
return Contacts.CONTENT_STREQUENT_URI.buildUpon() return Contacts.CONTENT_STREQUENT_URI.buildUpon()
.appendQueryParameter(strequentQueryParam, "true").build(); .appendQueryParameter(strequentQueryParam, "true").build();
} }
@@ -519,8 +519,7 @@ public abstract class MessageNotificationState extends NotificationState {
if (messageCount == 1) { if (messageCount == 1) {
final boolean shouldShowImage = ContentType.isImageType(mAttachmentType) final boolean shouldShowImage = ContentType.isImageType(mAttachmentType)
|| (ContentType.isVideoType(mAttachmentType) || (ContentType.isVideoType(mAttachmentType));
&& VideoThumbnailRequest.shouldShowIncomingVideoThumbnails());
if (mAttachmentUri != null && shouldShowImage) { if (mAttachmentUri != null && shouldShowImage) {
// Show "Picture" as the content // Show "Picture" as the content
final MessageLineInfo messageLineInfo = (MessageLineInfo) lineInfos.get(0); final MessageLineInfo messageLineInfo = (MessageLineInfo) lineInfos.get(0);
@@ -36,7 +36,6 @@ import com.android.messaging.datamodel.data.ConversationMessageData;
import com.android.messaging.datamodel.data.MessageData; import com.android.messaging.datamodel.data.MessageData;
import com.android.messaging.datamodel.data.ParticipantData; import com.android.messaging.datamodel.data.ParticipantData;
import com.android.messaging.util.LogUtil; import com.android.messaging.util.LogUtil;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.PhoneUtils; import com.android.messaging.util.PhoneUtils;
import com.android.messaging.widget.BugleWidgetProvider; import com.android.messaging.widget.BugleWidgetProvider;
import com.android.messaging.widget.WidgetConversationProvider; import com.android.messaging.widget.WidgetConversationProvider;
@@ -448,11 +447,7 @@ public class MessagingContentProvider extends ContentProvider {
// First dump out the default SMS app package name // First dump out the default SMS app package name
String defaultSmsApp = PhoneUtils.getDefault().getDefaultSmsApp(); String defaultSmsApp = PhoneUtils.getDefault().getDefaultSmsApp();
if (TextUtils.isEmpty(defaultSmsApp)) { if (TextUtils.isEmpty(defaultSmsApp)) {
if (OsUtil.isAtLeastKLP()) {
defaultSmsApp = "None"; defaultSmsApp = "None";
} else {
defaultSmsApp = "None (pre-Kitkat)";
}
} }
writer.println("Default SMS app: " + defaultSmsApp); writer.println("Default SMS app: " + defaultSmsApp);
// Now dump logs // Now dump logs
@@ -353,14 +353,10 @@ public class ParticipantRefresh {
* that any other older SIM self participants are marked as inactive. * that any other older SIM self participants are marked as inactive.
*/ */
private static void refreshSelfParticipantList() { private static void refreshSelfParticipantList() {
if (!OsUtil.isAtLeastL_MR1()) {
return;
}
final DatabaseWrapper db = DataModel.get().getDatabase(); final DatabaseWrapper db = DataModel.get().getDatabase();
final List<SubscriptionInfo> subInfoRecords = final List<SubscriptionInfo> subInfoRecords =
PhoneUtils.getDefault().toLMr1().getActiveSubscriptionInfoList(); PhoneUtils.getDefault().getActiveSubscriptionInfoList();
final ArrayMap<Integer, SubscriptionInfo> activeSubscriptionIdToRecordMap = final ArrayMap<Integer, SubscriptionInfo> activeSubscriptionIdToRecordMap =
new ArrayMap<Integer, SubscriptionInfo>(); new ArrayMap<Integer, SubscriptionInfo>();
db.beginTransaction(); db.beginTransaction();
@@ -445,14 +441,12 @@ public class ParticipantRefresh {
changed = SELF_PHONE_NUMBER_OR_SUBSCRIPTION_CHANGED; changed = SELF_PHONE_NUMBER_OR_SUBSCRIPTION_CHANGED;
} }
if (OsUtil.isAtLeastL_MR1()) {
// Refresh the subscription info based on information from SubscriptionManager. // Refresh the subscription info based on information from SubscriptionManager.
final SubscriptionInfo subscriptionInfo = final SubscriptionInfo subscriptionInfo =
PhoneUtils.get(participantData.getSubId()).toLMr1().getActiveSubscriptionInfo(); PhoneUtils.get(participantData.getSubId()).getActiveSubscriptionInfo();
if (participantData.updateSubscriptionInfoForSelfIfChanged(subscriptionInfo)) { if (participantData.updateSubscriptionInfoForSelfIfChanged(subscriptionInfo)) {
changed = SELF_PHONE_NUMBER_OR_SUBSCRIPTION_CHANGED; changed = SELF_PHONE_NUMBER_OR_SUBSCRIPTION_CHANGED;
} }
}
// For self participant, try getting name/avatar from self profile in CP2 first. // For self participant, try getting name/avatar from self profile in CP2 first.
// TODO: in case of multi-sim, profile would not be able to be used for // TODO: in case of multi-sim, profile would not be able to be used for
@@ -36,7 +36,6 @@ import com.android.messaging.datamodel.data.ParticipantData;
import com.android.messaging.sms.MmsUtils; import com.android.messaging.sms.MmsUtils;
import com.android.messaging.util.Assert; import com.android.messaging.util.Assert;
import com.android.messaging.util.LogUtil; import com.android.messaging.util.LogUtil;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.PhoneUtils; import com.android.messaging.util.PhoneUtils;
import java.util.ArrayList; import java.util.ArrayList;
@@ -225,8 +224,7 @@ public class InsertNewMessageAction extends Action implements Parcelable {
// to bind the message to the system default subscription if it's unbound. // to bind the message to the system default subscription if it's unbound.
final ParticipantData unboundSelf = BugleDatabaseOperations.getExistingParticipant( final ParticipantData unboundSelf = BugleDatabaseOperations.getExistingParticipant(
db, selfId); db, selfId);
if (unboundSelf.getSubId() == ParticipantData.DEFAULT_SELF_SUB_ID if (unboundSelf.getSubId() == ParticipantData.DEFAULT_SELF_SUB_ID) {
&& OsUtil.isAtLeastL_MR1()) {
final int defaultSubId = PhoneUtils.getDefault().getDefaultSmsSubscriptionId(); final int defaultSubId = PhoneUtils.getDefault().getDefaultSmsSubscriptionId();
self = BugleDatabaseOperations.getOrCreateSelf(db, defaultSubId); self = BugleDatabaseOperations.getOrCreateSelf(db, defaultSubId);
} else { } else {
@@ -39,7 +39,6 @@ import com.android.messaging.util.BuglePrefsKeys;
import com.android.messaging.util.ConnectivityUtil; import com.android.messaging.util.ConnectivityUtil;
import com.android.messaging.util.ConnectivityUtil.ConnectivityListener; import com.android.messaging.util.ConnectivityUtil.ConnectivityListener;
import com.android.messaging.util.LogUtil; import com.android.messaging.util.LogUtil;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.PhoneUtils; import com.android.messaging.util.PhoneUtils;
import java.util.HashSet; import java.util.HashSet;
@@ -356,13 +355,11 @@ public class ProcessPendingMessagesAction extends Action implements Parcelable {
// Prior to L_MR1, isActiveSubscription is true always // Prior to L_MR1, isActiveSubscription is true always
boolean isActiveSubscription = true; boolean isActiveSubscription = true;
if (OsUtil.isAtLeastL_MR1()) {
final ParticipantData messageSelf = final ParticipantData messageSelf =
BugleDatabaseOperations.getExistingParticipant(db, selfId); BugleDatabaseOperations.getExistingParticipant(db, selfId);
if (messageSelf == null || !messageSelf.isActiveSubscription()) { if (messageSelf == null || !messageSelf.isActiveSubscription()) {
isActiveSubscription = false; isActiveSubscription = false;
} }
}
while (cursor.moveToNext()) { while (cursor.moveToNext()) {
final MessageData message = new MessageData(); final MessageData message = new MessageData();
message.bind(cursor); message.bind(cursor);
@@ -51,7 +51,6 @@ import com.android.messaging.util.Assert;
import com.android.messaging.util.Assert.RunsOnMainThread; import com.android.messaging.util.Assert.RunsOnMainThread;
import com.android.messaging.util.ContactUtil; import com.android.messaging.util.ContactUtil;
import com.android.messaging.util.LogUtil; import com.android.messaging.util.LogUtil;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.PhoneUtils; import com.android.messaging.util.PhoneUtils;
import com.android.messaging.util.SafeAsyncTask; import com.android.messaging.util.SafeAsyncTask;
import com.android.messaging.widget.WidgetConversationProvider; import com.android.messaging.widget.WidgetConversationProvider;
@@ -595,7 +594,7 @@ public class ConversationData extends BindableData {
Assert.isTrue(TextUtils.equals(mConversationId, message.getConversationId())); Assert.isTrue(TextUtils.equals(mConversationId, message.getConversationId()));
Assert.isTrue(binding.getData() == this); Assert.isTrue(binding.getData() == this);
if (!OsUtil.isAtLeastL_MR1() || message.getSelfId() == null) { if (message.getSelfId() == null) {
InsertNewMessageAction.insertNewMessage(message); InsertNewMessageAction.insertNewMessage(message);
} else { } else {
final int systemDefaultSubId = PhoneUtils.getDefault().getDefaultSmsSubscriptionId(); final int systemDefaultSubId = PhoneUtils.getDefault().getDefaultSmsSubscriptionId();
@@ -767,8 +766,7 @@ public class ConversationData extends BindableData {
// 1. Framework has MSIM support AND // 1. Framework has MSIM support AND
// 2. The device has had multiple *active* subscriptions. AND // 2. The device has had multiple *active* subscriptions. AND
// 3. The message's subscription is active. // 3. The message's subscription is active.
if (OsUtil.isAtLeastL_MR1() && if (selfParticipantsData.getSelfParticipantsCountExcludingDefault(true) > 1) {
selfParticipantsData.getSelfParticipantsCountExcludingDefault(true) > 1) {
return subscriptionListData.getActiveSubscriptionEntryBySelfId(selfParticipantId, return subscriptionListData.getActiveSubscriptionEntryBySelfId(selfParticipantId,
excludeDefault); excludeDefault);
} }
@@ -24,8 +24,6 @@ import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import com.android.messaging.util.OsUtil;
/** /**
* A class that contains the list of all self participants potentially involved in a conversation. * A class that contains the list of all self participants potentially involved in a conversation.
* This class contains both active/inactive self entries when there is multi-SIM support. * This class contains both active/inactive self entries when there is multi-SIM support.
@@ -86,9 +84,6 @@ public class SelfParticipantsData {
* Returns if a given self id represents the default self. * Returns if a given self id represents the default self.
*/ */
boolean isDefaultSelf(final String selfId) { boolean isDefaultSelf(final String selfId) {
if (!OsUtil.isAtLeastL_MR1()) {
return true;
}
final ParticipantData self = getSelfParticipantById(selfId); final ParticipantData self = getSelfParticipantById(selfId);
return self == null ? false : self.getSubId() == ParticipantData.DEFAULT_SELF_SUB_ID; return self == null ? false : self.getSubId() == ParticipantData.DEFAULT_SELF_SUB_ID;
} }
@@ -31,7 +31,6 @@ import com.android.messaging.datamodel.binding.BindableData;
import com.android.messaging.datamodel.binding.BindingBase; import com.android.messaging.datamodel.binding.BindingBase;
import com.android.messaging.util.Assert; import com.android.messaging.util.Assert;
import com.android.messaging.util.LogUtil; import com.android.messaging.util.LogUtil;
import com.android.messaging.util.OsUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -200,7 +199,7 @@ public class SettingsData extends BindableData implements
// platorm is at least L-MR1 and there are multiple active SIMs. // platorm is at least L-MR1 and there are multiple active SIMs.
final int activeSubCountExcludingDefault = final int activeSubCountExcludingDefault =
mSelfParticipantsData.getSelfParticipantsCountExcludingDefault(true); mSelfParticipantsData.getSelfParticipantsCountExcludingDefault(true);
if (OsUtil.isAtLeastL_MR1() && activeSubCountExcludingDefault > 0) { if (activeSubCountExcludingDefault > 0) {
for (ParticipantData self : selfs) { for (ParticipantData self : selfs) {
if (!self.isDefaultSelf()) { if (!self.isDefaultSelf()) {
if (activeSubCountExcludingDefault > 1) { if (activeSubCountExcludingDefault > 1) {
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -24,7 +25,6 @@ import com.android.messaging.util.Assert;
import com.android.messaging.util.Assert.DoesNotRunOnMainThread; import com.android.messaging.util.Assert.DoesNotRunOnMainThread;
import com.android.messaging.util.ImageUtils; import com.android.messaging.util.ImageUtils;
import com.android.messaging.util.LogUtil; import com.android.messaging.util.LogUtil;
import com.android.messaging.util.OsUtil;
import java.util.List; import java.util.List;
@@ -109,11 +109,7 @@ public class DecodedImageResource extends ImageResource {
acquireLock(); acquireLock();
try { try {
Assert.notNull(mBitmap); Assert.notNull(mBitmap);
if (OsUtil.isAtLeastKLP()) {
return mBitmap.getAllocationByteCount(); return mBitmap.getAllocationByteCount();
} else {
return mBitmap.getRowBytes() * mBitmap.getHeight();
}
} finally { } finally {
releaseLock(); releaseLock();
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -20,7 +21,6 @@ import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import com.android.messaging.util.MediaMetadataRetrieverWrapper; import com.android.messaging.util.MediaMetadataRetrieverWrapper;
import com.android.messaging.util.MediaUtil;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
@@ -28,7 +28,6 @@ import java.io.InputStream;
/** /**
* Class to request a video thumbnail. * Class to request a video thumbnail.
* Users of this class as responsible for checking {@link #shouldShowIncomingVideoThumbnails}
*/ */
public class VideoThumbnailRequest extends ImageRequest<UriImageRequestDescriptor> { public class VideoThumbnailRequest extends ImageRequest<UriImageRequestDescriptor> {
@@ -37,10 +36,6 @@ public class VideoThumbnailRequest extends ImageRequest<UriImageRequestDescripto
super(context, descriptor); super(context, descriptor);
} }
public static boolean shouldShowIncomingVideoThumbnails() {
return MediaUtil.canAutoAccessIncomingMedia();
}
@Override @Override
protected InputStream getInputStreamForResource() throws FileNotFoundException { protected InputStream getInputStreamForResource() throws FileNotFoundException {
return null; return null;
@@ -39,7 +39,6 @@ import android.util.Log;
import android.util.SparseArray; import android.util.SparseArray;
import android.util.SparseIntArray; import android.util.SparseIntArray;
import com.android.messaging.datamodel.data.ParticipantData;
import com.android.messaging.mmslib.InvalidHeaderValueException; import com.android.messaging.mmslib.InvalidHeaderValueException;
import com.android.messaging.mmslib.MmsException; import com.android.messaging.mmslib.MmsException;
import com.android.messaging.mmslib.SqliteWrapper; import com.android.messaging.mmslib.SqliteWrapper;
@@ -51,7 +50,6 @@ import com.android.messaging.sms.MmsSmsUtils;
import com.android.messaging.util.Assert; import com.android.messaging.util.Assert;
import com.android.messaging.util.ContentType; import com.android.messaging.util.ContentType;
import com.android.messaging.util.LogUtil; import com.android.messaging.util.LogUtil;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.UriUtil; import com.android.messaging.util.UriUtil;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@@ -1481,15 +1479,8 @@ public class PduPersister {
} }
// Record whether this mms message is a simple plain text or not. This is a hint for the // Record whether this mms message is a simple plain text or not. This is a hint for the
// UI. // UI.
if (OsUtil.isAtLeastJB_MR1()) {
values.put(Mms.TEXT_ONLY, textOnly ? 1 : 0); values.put(Mms.TEXT_ONLY, textOnly ? 1 : 0);
}
if (OsUtil.isAtLeastL_MR1()) {
values.put(Mms.SUBSCRIPTION_ID, subId); values.put(Mms.SUBSCRIPTION_ID, subId);
} else {
Assert.equals(ParticipantData.DEFAULT_SELF_SUB_ID, subId);
}
Uri res = null; Uri res = null;
if (existingUri) { if (existingUri) {
@@ -1,43 +0,0 @@
/*
* Copyright (C) 2015 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.messaging.receiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.provider.Telephony;
import com.android.messaging.util.ContentType;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.PhoneUtils;
/**
* This receiver is used to abort MMS WAP broadcasts pre-KLP when SMS is enabled.
*/
public class AbortMmsWapPushReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, final Intent intent) {
if (Telephony.Sms.Intents.WAP_PUSH_RECEIVED_ACTION.equals(intent.getAction())
&& ContentType.MMS_MESSAGE.equals(intent.getType())) {
// If we are enabled, it's our job to stop the broadcast from continuing. This
// receiver is not used on KLP but we do an extra check here just to make sure.
if (!OsUtil.isAtLeastKLP() && PhoneUtils.getDefault().isSmsEnabled()) {
abortBroadcast();
}
}
}
}
@@ -1,41 +0,0 @@
/*
* Copyright (C) 2015 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.messaging.receiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.PhoneUtils;
/**
* This receiver is used to abort SMS broadcasts pre-KLP when SMS is enabled.
*/
public final class AbortSmsReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, final Intent intent) {
// If we are enabled, it's our job to stop the broadcast from continuing. This
// receiver is not used on KLP but we do an extra check here just to make sure.
if (!OsUtil.isAtLeastKLP() && PhoneUtils.getDefault().isSmsEnabled()) {
if (!SmsReceiver.shouldIgnoreMessage(intent)) {
abortBroadcast();
}
}
}
}
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -21,6 +22,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.provider.Telephony; import android.provider.Telephony;
import com.android.messaging.datamodel.action.ReceiveMmsMessageAction;
import com.android.messaging.util.ContentType; import com.android.messaging.util.ContentType;
import com.android.messaging.util.PhoneUtils; import com.android.messaging.util.PhoneUtils;
@@ -29,15 +31,27 @@ import com.android.messaging.util.PhoneUtils;
*/ */
public class MmsWapPushDeliverReceiver extends BroadcastReceiver { public class MmsWapPushDeliverReceiver extends BroadcastReceiver {
static final String EXTRA_SUBSCRIPTION = "subscription";
static final String EXTRA_DATA = "data";
@Override @Override
public void onReceive(final Context context, final Intent intent) { public void onReceive(final Context context, final Intent intent) {
if (Telephony.Sms.Intents.WAP_PUSH_DELIVER_ACTION.equals(intent.getAction()) if (Telephony.Sms.Intents.WAP_PUSH_DELIVER_ACTION.equals(intent.getAction())
&& ContentType.MMS_MESSAGE.equals(intent.getType())) { && ContentType.MMS_MESSAGE.equals(intent.getType())) {
// Always convert negative subIds into -1 // Always convert negative subIds into -1
int subId = PhoneUtils.getDefault().getEffectiveIncomingSubIdFromSystem( int subId = PhoneUtils.getDefault().getEffectiveIncomingSubIdFromSystem(
intent, MmsWapPushReceiver.EXTRA_SUBSCRIPTION); intent, EXTRA_SUBSCRIPTION);
byte[] data = intent.getByteArrayExtra(MmsWapPushReceiver.EXTRA_DATA); byte[] data = intent.getByteArrayExtra(EXTRA_DATA);
MmsWapPushReceiver.mmsReceived(subId, data); mmsReceived(subId, data);
} }
} }
static void mmsReceived(final int subId, final byte[] data) {
if (!PhoneUtils.getDefault().isSmsEnabled()) {
return;
}
final ReceiveMmsMessageAction action = new ReceiveMmsMessageAction(subId, data);
action.start();
}
} }
@@ -1,58 +0,0 @@
/*
* Copyright (C) 2015 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.messaging.receiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.provider.Telephony;
import com.android.messaging.datamodel.action.ReceiveMmsMessageAction;
import com.android.messaging.util.ContentType;
import com.android.messaging.util.PhoneUtils;
/**
* Class that handles MMS WAP push intent from telephony on pre-KLP Devices.
*/
public class MmsWapPushReceiver extends BroadcastReceiver {
static final String EXTRA_SUBSCRIPTION = "subscription";
static final String EXTRA_DATA = "data";
@Override
public void onReceive(final Context context, final Intent intent) {
if (Telephony.Sms.Intents.WAP_PUSH_RECEIVED_ACTION.equals(intent.getAction())
&& ContentType.MMS_MESSAGE.equals(intent.getType())) {
if (PhoneUtils.getDefault().isSmsEnabled()) {
// Always convert negative subIds into -1
final int subId = PhoneUtils.getDefault().getEffectiveIncomingSubIdFromSystem(
intent, MmsWapPushReceiver.EXTRA_SUBSCRIPTION);
final byte[] data = intent.getByteArrayExtra(MmsWapPushReceiver.EXTRA_DATA);
mmsReceived(subId, data);
}
}
}
static void mmsReceived(final int subId, final byte[] data) {
if (!PhoneUtils.getDefault().isSmsEnabled()) {
return;
}
final ReceiveMmsMessageAction action = new ReceiveMmsMessageAction(subId, data);
action.start();
}
}
@@ -73,36 +73,12 @@ public final class SmsReceiver extends BroadcastReceiver {
* notification. * notification.
*/ */
public static void updateSmsReceiveHandler(final Context context) { public static void updateSmsReceiveHandler(final Context context) {
boolean smsReceiverEnabled;
boolean mmsWapPushReceiverEnabled;
boolean respondViaMessageEnabled;
boolean broadcastAbortEnabled;
if (OsUtil.isAtLeastKLP()) {
// When we're running as the secondary user, we don't get the new SMS_DELIVER intent, // When we're running as the secondary user, we don't get the new SMS_DELIVER intent,
// only the primary user receives that. As secondary, we need to go old-school and // only the primary user receives that. As secondary, we need to go old-school and
// listen for the SMS_RECEIVED intent. For the secondary user, use this SmsReceiver // listen for the SMS_RECEIVED intent. For the secondary user, use this SmsReceiver
// for both sms and mms notification. For the primary user on KLP (and above), we don't // for both sms and mms notification. For the primary user on KLP (and above), we don't
// use the SmsReceiver. // use the SmsReceiver.
smsReceiverEnabled = OsUtil.isSecondaryUser(); boolean smsReceiverEnabled = OsUtil.isSecondaryUser();
// On KLP use the new deliver event for mms
mmsWapPushReceiverEnabled = false;
// On KLP we need to always enable this handler to show in the list of sms apps
respondViaMessageEnabled = true;
// On KLP we don't need to abort the broadcast
broadcastAbortEnabled = false;
} else {
// On JB we use the sms receiver for both sms/mms delivery
final boolean carrierSmsEnabled = PhoneUtils.getDefault().isSmsEnabled();
smsReceiverEnabled = carrierSmsEnabled;
// On JB we use the mms receiver when sms/mms is enabled
mmsWapPushReceiverEnabled = carrierSmsEnabled;
// On JB this is dynamic to make sure we don't show in dialer if sms is disabled
respondViaMessageEnabled = carrierSmsEnabled;
// On JB we need to abort broadcasts if SMS is enabled
broadcastAbortEnabled = carrierSmsEnabled;
}
final PackageManager packageManager = context.getPackageManager(); final PackageManager packageManager = context.getPackageManager();
final boolean logv = LogUtil.isLoggable(TAG, LogUtil.VERBOSE); final boolean logv = LogUtil.isLoggable(TAG, LogUtil.VERBOSE);
@@ -122,57 +98,13 @@ public final class SmsReceiver extends BroadcastReceiver {
new ComponentName(context, SmsReceiver.class), new ComponentName(context, SmsReceiver.class),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
} }
if (mmsWapPushReceiverEnabled) {
if (logv) {
LogUtil.v(TAG, "Enabling MMS message receiving");
}
packageManager.setComponentEnabledSetting(
new ComponentName(context, MmsWapPushReceiver.class),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
} else {
if (logv) {
LogUtil.v(TAG, "Disabling MMS message receiving");
}
packageManager.setComponentEnabledSetting(
new ComponentName(context, MmsWapPushReceiver.class),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
}
if (broadcastAbortEnabled) {
if (logv) {
LogUtil.v(TAG, "Enabling SMS/MMS broadcast abort");
}
packageManager.setComponentEnabledSetting(
new ComponentName(context, AbortSmsReceiver.class),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
packageManager.setComponentEnabledSetting(
new ComponentName(context, AbortMmsWapPushReceiver.class),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
} else {
if (logv) {
LogUtil.v(TAG, "Disabling SMS/MMS broadcast abort");
}
packageManager.setComponentEnabledSetting(
new ComponentName(context, AbortSmsReceiver.class),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
packageManager.setComponentEnabledSetting(
new ComponentName(context, AbortMmsWapPushReceiver.class),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
}
if (respondViaMessageEnabled) {
if (logv) { if (logv) {
LogUtil.v(TAG, "Enabling respond via message intent"); LogUtil.v(TAG, "Enabling respond via message intent");
} }
packageManager.setComponentEnabledSetting( packageManager.setComponentEnabledSetting(
new ComponentName(context, NoConfirmationSmsSendService.class), new ComponentName(context, NoConfirmationSmsSendService.class),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
} else {
if (logv) {
LogUtil.v(TAG, "Disabling respond via message intent");
}
packageManager.setComponentEnabledSetting(
new ComponentName(context, NoConfirmationSmsSendService.class),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
}
} }
private static final String EXTRA_ERROR_CODE = "errorCode"; private static final String EXTRA_ERROR_CODE = "errorCode";
@@ -214,9 +146,7 @@ public final class SmsReceiver extends BroadcastReceiver {
// seen for the telephony db. // seen for the telephony db.
messageValues.put(Sms.Inbox.READ, 0); messageValues.put(Sms.Inbox.READ, 0);
messageValues.put(Sms.Inbox.SEEN, 0); messageValues.put(Sms.Inbox.SEEN, 0);
if (OsUtil.isAtLeastL_MR1()) {
messageValues.put(Sms.SUBSCRIPTION_ID, subId); messageValues.put(Sms.SUBSCRIPTION_ID, subId);
}
if (messages[0].getMessageClass() == android.telephony.SmsMessage.MessageClass.CLASS_0 || if (messages[0].getMessageClass() == android.telephony.SmsMessage.MessageClass.CLASS_0 ||
DebugUtils.debugClassZeroSmsEnabled()) { DebugUtils.debugClassZeroSmsEnabled()) {
@@ -238,8 +168,6 @@ public final class SmsReceiver extends BroadcastReceiver {
// TODO: update this with the actual constant from Telephony // TODO: update this with the actual constant from Telephony
"android.provider.Telephony.MMS_DOWNLOADED".equals(action))) { "android.provider.Telephony.MMS_DOWNLOADED".equals(action))) {
postNewMessageSecondaryUserNotification(); postNewMessageSecondaryUserNotification();
} else if (!OsUtil.isAtLeastKLP()) {
deliverSmsIntent(context, intent);
} }
} }
} }
@@ -34,7 +34,6 @@ import com.android.messaging.mmslib.SqliteWrapper;
import com.android.messaging.util.BugleGservices; import com.android.messaging.util.BugleGservices;
import com.android.messaging.util.BugleGservicesKeys; import com.android.messaging.util.BugleGservicesKeys;
import com.android.messaging.util.LogUtil; import com.android.messaging.util.LogUtil;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.PhoneUtils; import com.android.messaging.util.PhoneUtils;
import java.net.URI; import java.net.URI;
@@ -384,7 +383,7 @@ public class BugleApnSettingsLoader implements ApnSettingsLoader {
*/ */
private void loadFromSystem(final int subId, final String apnName, final List<Apn> apns) { private void loadFromSystem(final int subId, final String apnName, final List<Apn> apns) {
Uri uri; Uri uri;
if (OsUtil.isAtLeastL_MR1() && subId != MmsManager.DEFAULT_SUB_ID) { if (subId != MmsManager.DEFAULT_SUB_ID) {
uri = Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "/subId/" + subId); uri = Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "/subId/" + subId);
} else { } else {
uri = Telephony.Carriers.CONTENT_URI; uri = Telephony.Carriers.CONTENT_URI;
@@ -27,7 +27,6 @@ import android.util.SparseArray;
import com.android.messaging.R; import com.android.messaging.R;
import com.android.messaging.util.LogUtil; import com.android.messaging.util.LogUtil;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.PhoneUtils; import com.android.messaging.util.PhoneUtils;
/** /**
@@ -93,13 +92,10 @@ public class BugleCarrierConfigValuesLoader implements CarrierConfigValuesLoader
private String loadLocked(final int subId, final Bundle values) { private String loadLocked(final int subId, final Bundle values) {
// Load from resources in earlier platform // Load from resources in earlier platform
loadFromResources(subId, values); loadFromResources(subId, values);
if (OsUtil.isAtLeastL()) {
// Load from system to override if system API exists // Load from system to override if system API exists
loadFromSystem(subId, values); loadFromSystem(subId, values);
return "resources+system"; return "resources+system";
} }
return "resources";
}
/** /**
* Load from system, using MMS API * Load from system, using MMS API
@@ -158,9 +154,6 @@ public class BugleCarrierConfigValuesLoader implements CarrierConfigValuesLoader
* @return the sub-dependent Context * @return the sub-dependent Context
*/ */
private static Context getSubDepContext(final Context context, final int subId) { private static Context getSubDepContext(final Context context, final int subId) {
if (!OsUtil.isAtLeastL_MR1()) {
return context;
}
final int[] mccMnc = PhoneUtils.get(subId).getMccMnc(); final int[] mccMnc = PhoneUtils.get(subId).getMccMnc();
final int mcc = mccMnc[0]; final int mcc = mccMnc[0];
final int mnc = mccMnc[1]; final int mnc = mccMnc[1];
@@ -25,7 +25,6 @@ import android.text.TextUtils;
import com.android.messaging.util.BugleGservices; import com.android.messaging.util.BugleGservices;
import com.android.messaging.util.BugleGservicesKeys; import com.android.messaging.util.BugleGservicesKeys;
import com.android.messaging.util.LogUtil; import com.android.messaging.util.LogUtil;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.VersionUtil; import com.android.messaging.util.VersionUtil;
/** /**
@@ -75,13 +74,11 @@ public class BugleUserAgentInfoLoader implements UserAgentInfoLoader {
} }
private void loadLocked() { private void loadLocked() {
if (OsUtil.isAtLeastKLP()) {
// load the MMS User agent and UaProfUrl from TelephonyManager APIs // load the MMS User agent and UaProfUrl from TelephonyManager APIs
final TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService( final TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(
Context.TELEPHONY_SERVICE); Context.TELEPHONY_SERVICE);
mUserAgent = telephonyManager.getMmsUserAgent(); mUserAgent = telephonyManager.getMmsUserAgent();
mUAProfUrl = telephonyManager.getMmsUAProfUrl(); mUAProfUrl = telephonyManager.getMmsUAProfUrl();
}
// if user agent string isn't set, use the format "Bugle/<app_version>". // if user agent string isn't set, use the format "Bugle/<app_version>".
if (TextUtils.isEmpty(mUserAgent)) { if (TextUtils.isEmpty(mUserAgent)) {
final String simpleVersionName = VersionUtil.getInstance(mContext).getSimpleName(); final String simpleVersionName = VersionUtil.getInstance(mContext).getSimpleName();
@@ -37,11 +37,9 @@ import com.android.messaging.Factory;
import com.android.messaging.datamodel.data.MessageData; import com.android.messaging.datamodel.data.MessageData;
import com.android.messaging.datamodel.media.VideoThumbnailRequest; import com.android.messaging.datamodel.media.VideoThumbnailRequest;
import com.android.messaging.mmslib.pdu.CharacterSets; import com.android.messaging.mmslib.pdu.CharacterSets;
import com.android.messaging.util.Assert;
import com.android.messaging.util.ContentType; import com.android.messaging.util.ContentType;
import com.android.messaging.util.LogUtil; import com.android.messaging.util.LogUtil;
import com.android.messaging.util.MediaMetadataRetrieverWrapper; import com.android.messaging.util.MediaMetadataRetrieverWrapper;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.PhoneUtils; import com.android.messaging.util.PhoneUtils;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@@ -120,12 +118,6 @@ public class DatabaseMessages {
if (!MmsUtils.hasSmsDateSentColumn()) { if (!MmsUtils.hasSmsDateSentColumn()) {
projection[INDEX_DATE_SENT] = Sms.DATE; projection[INDEX_DATE_SENT] = Sms.DATE;
} }
if (!OsUtil.isAtLeastL_MR1()) {
Assert.equals(INDEX_SUB_ID, projection.length - 1);
String[] withoutSubId = new String[projection.length - 1];
System.arraycopy(projection, 0, withoutSubId, 0, withoutSubId.length);
projection = withoutSubId;
}
sProjection = projection; sProjection = projection;
} }
@@ -307,13 +299,6 @@ public class DatabaseMessages {
Mms.SUBSCRIPTION_ID, Mms.SUBSCRIPTION_ID,
}; };
if (!OsUtil.isAtLeastL_MR1()) {
Assert.equals(INDEX_SUB_ID, projection.length - 1);
String[] withoutSubId = new String[projection.length - 1];
System.arraycopy(projection, 0, withoutSubId, 0, withoutSubId.length);
projection = withoutSubId;
}
sProjection = projection; sProjection = projection;
} }
@@ -722,11 +707,6 @@ public class DatabaseMessages {
* Load video file of a video part and parse the dimensions and type * Load video file of a video part and parse the dimensions and type
*/ */
private void loadVideo() { private void loadVideo() {
// This is a coarse check, and should not be applied to outgoing messages. However,
// currently, this does not cause any problems.
if (!VideoThumbnailRequest.shouldShowIncomingVideoThumbnails()) {
return;
}
final Uri uri = getDataUri(); final Uri uri = getDataUri();
final MediaMetadataRetrieverWrapper retriever = new MediaMetadataRetrieverWrapper(); final MediaMetadataRetrieverWrapper retriever = new MediaMetadataRetrieverWrapper();
try { try {
+2 -9
View File
@@ -25,7 +25,6 @@ import com.android.messaging.Factory;
import com.android.messaging.datamodel.data.ParticipantData; import com.android.messaging.datamodel.data.ParticipantData;
import com.android.messaging.util.Assert; import com.android.messaging.util.Assert;
import com.android.messaging.util.LogUtil; import com.android.messaging.util.LogUtil;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.PhoneUtils; import com.android.messaging.util.PhoneUtils;
import com.android.messaging.util.SafeAsyncTask; import com.android.messaging.util.SafeAsyncTask;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
@@ -151,9 +150,8 @@ public class MmsConfig {
// Rebuild the entire MmsConfig map. // Rebuild the entire MmsConfig map.
sSubIdToMmsConfigMap.clear(); sSubIdToMmsConfigMap.clear();
loader.reset(); loader.reset();
if (OsUtil.isAtLeastL_MR1()) {
final List<SubscriptionInfo> subInfoRecords = final List<SubscriptionInfo> subInfoRecords =
PhoneUtils.getDefault().toLMr1().getActiveSubscriptionInfoList(); PhoneUtils.getDefault().getActiveSubscriptionInfoList();
if (subInfoRecords == null) { if (subInfoRecords == null) {
LogUtil.w(TAG, "Loading mms config failed: no active SIM"); LogUtil.w(TAG, "Loading mms config failed: no active SIM");
return; return;
@@ -163,15 +161,10 @@ public class MmsConfig {
final Bundle values = loader.get(subId); final Bundle values = loader.get(subId);
addMmsConfig(new MmsConfig(subId, values)); addMmsConfig(new MmsConfig(subId, values));
} }
} else {
final Bundle values = loader.get(ParticipantData.DEFAULT_SELF_SUB_ID);
addMmsConfig(new MmsConfig(ParticipantData.DEFAULT_SELF_SUB_ID, values));
}
} }
private static void addMmsConfig(MmsConfig mmsConfig) { private static void addMmsConfig(MmsConfig mmsConfig) {
Assert.isTrue(OsUtil.isAtLeastL_MR1() != Assert.isTrue(mmsConfig.mSubId != ParticipantData.DEFAULT_SELF_SUB_ID);
(mmsConfig.mSubId == ParticipantData.DEFAULT_SELF_SUB_ID));
sSubIdToMmsConfigMap.put(mmsConfig.mSubId, mmsConfig); sSubIdToMmsConfigMap.put(mmsConfig.mSubId, mmsConfig);
} }
+1 -60
View File
@@ -76,7 +76,6 @@ import com.android.messaging.util.ImageUtils;
import com.android.messaging.util.ImageUtils.ImageResizer; import com.android.messaging.util.ImageUtils.ImageResizer;
import com.android.messaging.util.LogUtil; import com.android.messaging.util.LogUtil;
import com.android.messaging.util.MediaMetadataRetrieverWrapper; import com.android.messaging.util.MediaMetadataRetrieverWrapper;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.PhoneUtils; import com.android.messaging.util.PhoneUtils;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
@@ -869,9 +868,7 @@ public class MmsUtils {
values.put(Telephony.Sms.SEEN, seen ? 1 : 0); values.put(Telephony.Sms.SEEN, seen ? 1 : 0);
values.put(Telephony.Sms.SUBJECT, subject); values.put(Telephony.Sms.SUBJECT, subject);
values.put(Telephony.Sms.BODY, body); values.put(Telephony.Sms.BODY, body);
if (OsUtil.isAtLeastL_MR1()) {
values.put(Telephony.Sms.SUBSCRIPTION_ID, subId); values.put(Telephony.Sms.SUBSCRIPTION_ID, subId);
}
if (status != Telephony.Sms.STATUS_NONE) { if (status != Telephony.Sms.STATUS_NONE) {
values.put(Telephony.Sms.STATUS, status); values.put(Telephony.Sms.STATUS, status);
} }
@@ -1156,9 +1153,7 @@ public class MmsUtils {
public static SmsMessage getSmsMessageFromDeliveryReport(final Intent intent) { public static SmsMessage getSmsMessageFromDeliveryReport(final Intent intent) {
final byte[] pdu = intent.getByteArrayExtra("pdu"); final byte[] pdu = intent.getByteArrayExtra("pdu");
final String format = intent.getStringExtra("format"); final String format = intent.getStringExtra("format");
return OsUtil.isAtLeastM() return SmsMessage.createFromPdu(pdu, format);
? SmsMessage.createFromPdu(pdu, format)
: SmsMessage.createFromPdu(pdu);
} }
/** /**
@@ -1520,12 +1515,8 @@ public class MmsUtils {
// For the internal debugger only // For the internal debugger only
public static void setUseSystemApnTable(final boolean turnOn) { public static void setUseSystemApnTable(final boolean turnOn) {
if (!turnOn) { if (!turnOn) {
// We're not turning on to the system table. Instead, we're using our internal table.
final int osVersion = OsUtil.getApiVersion();
if (osVersion != android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
// We're turning on local APNs on a device where we wouldn't normally have the // We're turning on local APNs on a device where we wouldn't normally have the
// local APN table. Build it here. // local APN table. Build it here.
final SQLiteDatabase database = ApnDatabase.getApnDatabase().getWritableDatabase(); final SQLiteDatabase database = ApnDatabase.getApnDatabase().getWritableDatabase();
// Do we already have the table? // Do we already have the table?
@@ -1543,7 +1534,6 @@ public class MmsUtils {
} }
} }
} }
}
sUseSystemApn = turnOn; sUseSystemApn = turnOn;
} }
@@ -1812,14 +1802,6 @@ public class MmsUtils {
return new StatusPlusUri( return new StatusPlusUri(
MMS_REQUEST_NO_RETRY, MessageData.RAW_TELEPHONY_STATUS_UNDEFINED, null); MMS_REQUEST_NO_RETRY, MessageData.RAW_TELEPHONY_STATUS_UNDEFINED, null);
} }
if (!isMmsDataAvailable(subId)) {
LogUtil.e(TAG,
"MmsUtils: failed to download message, no data available");
return new StatusPlusUri(MMS_REQUEST_MANUAL_RETRY,
MessageData.RAW_TELEPHONY_STATUS_UNDEFINED,
null,
SmsManager.MMS_ERROR_NO_DATA_NETWORK);
}
int status = MMS_REQUEST_MANUAL_RETRY; int status = MMS_REQUEST_MANUAL_RETRY;
try { try {
RetrieveConf retrieveConf = null; RetrieveConf retrieveConf = null;
@@ -1837,15 +1819,11 @@ public class MmsUtils {
LogUtil.d(TAG, "MmsUtils: Downloading MMS via MMS lib API; notification " LogUtil.d(TAG, "MmsUtils: Downloading MMS via MMS lib API; notification "
+ "message: " + notificationUri); + "message: " + notificationUri);
} }
if (OsUtil.isAtLeastL_MR1()) {
if (subId < 0) { if (subId < 0) {
LogUtil.e(TAG, "MmsUtils: Incoming MMS came from unknown SIM"); LogUtil.e(TAG, "MmsUtils: Incoming MMS came from unknown SIM");
throw new MmsFailureException(MMS_REQUEST_NO_RETRY, throw new MmsFailureException(MMS_REQUEST_NO_RETRY,
"Message from unknown SIM"); "Message from unknown SIM");
} }
} else {
Assert.isTrue(subId == ParticipantData.DEFAULT_SELF_SUB_ID);
}
if (extras == null) { if (extras == null) {
extras = new Bundle(); extras = new Bundle();
} }
@@ -1943,10 +1921,6 @@ public class MmsUtils {
LogUtil.w(TAG, "MmsUtils: Can't send NotifyResp; transaction id is null"); LogUtil.w(TAG, "MmsUtils: Can't send NotifyResp; transaction id is null");
return; return;
} }
if (!isMmsDataAvailable(subId)) {
LogUtil.w(TAG, "MmsUtils: Can't send NotifyResp; no data available");
return;
}
MmsSender.sendNotifyResponseForMmsDownload( MmsSender.sendNotifyResponseForMmsDownload(
context, subId, transactionId, contentLocation, status); context, subId, transactionId, contentLocation, status);
} catch (final MmsFailureException e) { } catch (final MmsFailureException e) {
@@ -1973,10 +1947,6 @@ public class MmsUtils {
LogUtil.w(TAG, "MmsUtils: Can't send AckInd; transaction id is null"); LogUtil.w(TAG, "MmsUtils: Can't send AckInd; transaction id is null");
return; return;
} }
if (!isMmsDataAvailable(subId)) {
LogUtil.w(TAG, "MmsUtils: Can't send AckInd; no data available");
return;
}
MmsSender.sendAcknowledgeForMmsDownload(context, subId, transactionId, contentLocation); MmsSender.sendAcknowledgeForMmsDownload(context, subId, transactionId, contentLocation);
} catch (final MmsFailureException e) { } catch (final MmsFailureException e) {
LogUtil.e(TAG, "sendAcknowledgeForMmsDownload: failed to retrieve message " + e, e); LogUtil.e(TAG, "sendAcknowledgeForMmsDownload: failed to retrieve message " + e, e);
@@ -2021,35 +1991,10 @@ public class MmsUtils {
return (RetrieveConf) pdu; return (RetrieveConf) pdu;
} }
private static boolean isMmsDataAvailable(final int subId) {
if (OsUtil.isAtLeastL_MR1()) {
// L_MR1 above may support sending mms via wifi
return true;
}
final PhoneUtils phoneUtils = PhoneUtils.get(subId);
return !phoneUtils.isAirplaneModeOn() && phoneUtils.isMobileDataEnabled();
}
private static boolean isSmsDataAvailable(final int subId) {
if (OsUtil.isAtLeastL_MR1()) {
// L_MR1 above may support sending sms via wifi
return true;
}
final PhoneUtils phoneUtils = PhoneUtils.get(subId);
return !phoneUtils.isAirplaneModeOn();
}
public static StatusPlusUri sendMmsMessage(final Context context, final int subId, public static StatusPlusUri sendMmsMessage(final Context context, final int subId,
final Uri messageUri, final Bundle extras) { final Uri messageUri, final Bundle extras) {
int status = MMS_REQUEST_MANUAL_RETRY; int status = MMS_REQUEST_MANUAL_RETRY;
int rawStatus = MessageData.RAW_TELEPHONY_STATUS_UNDEFINED; int rawStatus = MessageData.RAW_TELEPHONY_STATUS_UNDEFINED;
if (!isMmsDataAvailable(subId)) {
LogUtil.w(TAG, "MmsUtils: failed to send message, no data available");
return new StatusPlusUri(MMS_REQUEST_MANUAL_RETRY,
MessageData.RAW_TELEPHONY_STATUS_UNDEFINED,
messageUri,
SmsManager.MMS_ERROR_NO_DATA_NETWORK);
}
final PduPersister persister = PduPersister.getPduPersister(context); final PduPersister persister = PduPersister.getPduPersister(context);
try { try {
final SendReq sendReq = (SendReq) persister.load(messageUri); final SendReq sendReq = (SendReq) persister.load(messageUri);
@@ -2460,10 +2405,6 @@ public class MmsUtils {
public static int sendSmsMessage(final String recipient, final String messageText, public static int sendSmsMessage(final String recipient, final String messageText,
final Uri requestUri, final int subId, final Uri requestUri, final int subId,
final String smsServiceCenter, final boolean requireDeliveryReport) { final String smsServiceCenter, final boolean requireDeliveryReport) {
if (!isSmsDataAvailable(subId)) {
LogUtil.w(TAG, "MmsUtils: can't send SMS without radio");
return MMS_REQUEST_MANUAL_RETRY;
}
final Context context = Factory.get().getApplicationContext(); final Context context = Factory.get().getApplicationContext();
int status = MMS_REQUEST_MANUAL_RETRY; int status = MMS_REQUEST_MANUAL_RETRY;
try { try {
@@ -41,7 +41,6 @@ import com.android.messaging.ui.mediapicker.PausableChronometer;
import com.android.messaging.util.Assert; import com.android.messaging.util.Assert;
import com.android.messaging.util.ContentType; import com.android.messaging.util.ContentType;
import com.android.messaging.util.LogUtil; import com.android.messaging.util.LogUtil;
import com.android.messaging.util.MediaUtil;
import com.android.messaging.util.UiUtils; import com.android.messaging.util.UiUtils;
/** /**
@@ -79,9 +78,6 @@ public class AudioAttachmentView extends LinearLayout {
private int mThemeColor; private int mThemeColor;
private boolean mStartPlayAfterPrepare; private boolean mStartPlayAfterPrepare;
// should the MediaPlayer be prepared lazily when the user chooses to play the audio (as
// opposed to preparing it early, on bind)
private boolean mPrepareOnPlayback;
private boolean mPrepared; private boolean mPrepared;
private boolean mPlaybackFinished; // Was the audio played all the way to the end private boolean mPlaybackFinished; // Was the audio played all the way to the end
private final int mMode; private final int mMode;
@@ -148,13 +144,8 @@ public class AudioAttachmentView extends LinearLayout {
return; return;
} }
if (mPrepareOnPlayback) {
// For lazy preparation, the chronometer will only be shown during playback
mChronometer.setVisibility(playing ? View.VISIBLE : View.INVISIBLE);
} else {
mChronometer.setVisibility(View.VISIBLE); mChronometer.setVisibility(View.VISIBLE);
} }
}
/** /**
* Bind the audio attachment view with a MessagePartData. * Bind the audio attachment view with a MessagePartData.
@@ -180,7 +171,6 @@ public class AudioAttachmentView extends LinearLayout {
mUseIncomingStyle = useIncomingStyle; mUseIncomingStyle = useIncomingStyle;
mThemeColor = themeColor; mThemeColor = themeColor;
mPrepareOnPlayback = incoming && !MediaUtil.canAutoAccessIncomingMedia();
if (!TextUtils.equals(currentUriString, newUriString)) { if (!TextUtils.equals(currentUriString, newUriString)) {
mDataSourceUri = dataSourceUri; mDataSourceUri = dataSourceUri;
@@ -216,7 +206,7 @@ public class AudioAttachmentView extends LinearLayout {
} }
/** /**
* Prepare the MediaPlayer, and if mPrepareOnPlayback, start playing the audio * Prepare the MediaPlayer and start playing the audio
*/ */
private void setupMediaPlayer() { private void setupMediaPlayer() {
Assert.notNull(mDataSourceUri); Assert.notNull(mDataSourceUri);
@@ -332,7 +322,7 @@ public class AudioAttachmentView extends LinearLayout {
updateVisualStyle(); updateVisualStyle();
updateChronometerVisibility(false /* playing */); updateChronometerVisibility(false /* playing */);
if (mDataSourceUri != null && !mPrepareOnPlayback) { if (mDataSourceUri != null) {
// Prepare the media player, so we can read the duration of the audio. // Prepare the media player, so we can read the duration of the audio.
setupMediaPlayer(); setupMediaPlayer();
} }
@@ -22,9 +22,6 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.UiUtils;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
@@ -43,8 +40,8 @@ public class LineWrapLayout extends ViewGroup {
@Override @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int startPadding = UiUtils.getPaddingStart(this); final int startPadding = getPaddingStart();
final int endPadding = UiUtils.getPaddingEnd(this); final int endPadding = getPaddingEnd();
final int widthMode = MeasureSpec.getMode(widthMeasureSpec); final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
final int widthSize = MeasureSpec.getSize(widthMeasureSpec) - startPadding - endPadding; final int widthSize = MeasureSpec.getSize(widthMeasureSpec) - startPadding - endPadding;
final boolean isFixedSize = (widthMode == MeasureSpec.EXACTLY); final boolean isFixedSize = (widthMode == MeasureSpec.EXACTLY);
@@ -96,8 +93,8 @@ public class LineWrapLayout extends ViewGroup {
@Override @Override
protected void onLayout(boolean changed, int l, int t, int r, int b) { protected void onLayout(boolean changed, int l, int t, int r, int b) {
final int startPadding = UiUtils.getPaddingStart(this); final int startPadding = getPaddingStart();
final int endPadding = UiUtils.getPaddingEnd(this); final int endPadding = getPaddingEnd();
int width = getWidth() - startPadding - endPadding; int width = getWidth() - startPadding - endPadding;
int y = getPaddingTop(); int y = getPaddingTop();
int x = startPadding; int x = startPadding;
@@ -171,7 +168,7 @@ public class LineWrapLayout extends ViewGroup {
} }
} }
if (OsUtil.isAtLeastJB_MR2() && getResources().getConfiguration() if (getResources().getConfiguration()
.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { .getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
currChild.layout(width - startPositionX - childWidth, startPositionY, currChild.layout(width - startPositionX - childWidth, startPositionY,
width - startPositionX, startPositionY + childHeight); width - startPositionX, startPositionY + childHeight);
@@ -214,19 +211,11 @@ public class LineWrapLayout extends ViewGroup {
} }
public int getStartMargin() { public int getStartMargin() {
if (OsUtil.isAtLeastJB_MR2()) {
return getMarginStart(); return getMarginStart();
} else {
return leftMargin;
}
} }
public int getEndMargin() { public int getEndMargin() {
if (OsUtil.isAtLeastJB_MR2()) {
return getMarginEnd(); return getMarginEnd();
} else {
return rightMargin;
}
} }
} }
} }
@@ -42,7 +42,6 @@ import com.android.messaging.ui.SnackBar.SnackBarListener;
import com.android.messaging.util.AccessibilityUtil; import com.android.messaging.util.AccessibilityUtil;
import com.android.messaging.util.Assert; import com.android.messaging.util.Assert;
import com.android.messaging.util.LogUtil; import com.android.messaging.util.LogUtil;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.TextUtil; import com.android.messaging.util.TextUtil;
import com.android.messaging.util.UiUtils; import com.android.messaging.util.UiUtils;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
@@ -354,14 +353,10 @@ public class SnackBarManager {
private int getScreenBottomOffset(final SnackBar snackBar) { private int getScreenBottomOffset(final SnackBar snackBar) {
final WindowManager windowManager = getWindowManager(snackBar.getContext()); final WindowManager windowManager = getWindowManager(snackBar.getContext());
final DisplayMetrics displayMetrics = new DisplayMetrics(); final DisplayMetrics displayMetrics = new DisplayMetrics();
if (OsUtil.isAtLeastL()) {
windowManager.getDefaultDisplay().getRealMetrics(displayMetrics); windowManager.getDefaultDisplay().getRealMetrics(displayMetrics);
} else {
windowManager.getDefaultDisplay().getMetrics(displayMetrics);
}
final int screenHeight = displayMetrics.heightPixels; final int screenHeight = displayMetrics.heightPixels;
if (OsUtil.isAtLeastL()) {
// In L, the navigation bar is included in the space for the popup window, so we have to // In L, the navigation bar is included in the space for the popup window, so we have to
// offset by the size of the navigation bar // offset by the size of the navigation bar
final Rect displayRect = new Rect(); final Rect displayRect = new Rect();
@@ -369,9 +364,6 @@ public class SnackBarManager {
return screenHeight - displayRect.bottom; return screenHeight - displayRect.bottom;
} }
return 0;
}
private int getRelativeOffset(final SnackBar snackBar) { private int getRelativeOffset(final SnackBar snackBar) {
final Placement placement = snackBar.getPlacement(); final Placement placement = snackBar.getPlacement();
Assert.notNull(placement); Assert.notNull(placement);
@@ -211,22 +211,12 @@ public class VideoThumbnailView extends FrameLayout {
mVideoView.start(); mVideoView.start();
} }
// TODO: The check could be added to MessagePartData itself so that all users of MessagePartData
// get the right behavior, instead of requiring all the users to do similar checks.
private static boolean shouldUseGenericVideoIcon(final boolean incomingMessage) {
return incomingMessage && !VideoThumbnailRequest.shouldShowIncomingVideoThumbnails();
}
public void setSource(final MessagePartData part, final boolean incomingMessage) { public void setSource(final MessagePartData part, final boolean incomingMessage) {
if (part == null) { if (part == null) {
clearSource(); clearSource();
} else { } else {
mVideoSource = part.getContentUri(); mVideoSource = part.getContentUri();
if (shouldUseGenericVideoIcon(incomingMessage)) {
mThumbnailImage.setImageResource(R.drawable.generic_video_icon);
mVideoWidth = ImageRequest.UNSPECIFIED_SIZE;
mVideoHeight = ImageRequest.UNSPECIFIED_SIZE;
} else {
mThumbnailImage.setImageResourceId( mThumbnailImage.setImageResourceId(
new MessagePartVideoThumbnailRequestDescriptor(part)); new MessagePartVideoThumbnailRequestDescriptor(part));
if (mVideoView != null) { if (mVideoView != null) {
@@ -236,18 +226,12 @@ public class VideoThumbnailView extends FrameLayout {
mVideoHeight = part.getHeight(); mVideoHeight = part.getHeight();
} }
} }
}
public void setSource(final Uri videoSource, final boolean incomingMessage) { public void setSource(final Uri videoSource, final boolean incomingMessage) {
if (videoSource == null) { if (videoSource == null) {
clearSource(); clearSource();
} else { } else {
mVideoSource = videoSource; mVideoSource = videoSource;
if (shouldUseGenericVideoIcon(incomingMessage)) {
mThumbnailImage.setImageResource(R.drawable.generic_video_icon);
mVideoWidth = ImageRequest.UNSPECIFIED_SIZE;
mVideoHeight = ImageRequest.UNSPECIFIED_SIZE;
} else {
mThumbnailImage.setImageResourceId( mThumbnailImage.setImageResourceId(
new MessagePartVideoThumbnailRequestDescriptor(videoSource)); new MessagePartVideoThumbnailRequestDescriptor(videoSource));
if (mVideoView != null) { if (mVideoView != null) {
@@ -255,7 +239,6 @@ public class VideoThumbnailView extends FrameLayout {
} }
} }
} }
}
private void clearSource() { private void clearSource() {
mVideoSource = null; mVideoSource = null;
@@ -25,7 +25,6 @@ import android.view.View;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import com.android.messaging.R; import com.android.messaging.R;
import com.android.messaging.util.OsUtil;
public class ViewPagerTabStrip extends LinearLayout { public class ViewPagerTabStrip extends LinearLayout {
private int mSelectedUnderlineThickness; private int mSelectedUnderlineThickness;
@@ -97,6 +96,6 @@ public class ViewPagerTabStrip extends LinearLayout {
} }
private boolean isRtl() { private boolean isRtl() {
return OsUtil.isAtLeastJB_MR2() ? getLayoutDirection() == View.LAYOUT_DIRECTION_RTL : false; return getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
} }
} }
@@ -35,7 +35,6 @@ import android.widget.Toast;
import com.android.messaging.Factory; import com.android.messaging.Factory;
import com.android.messaging.R; import com.android.messaging.R;
import com.android.messaging.util.OsUtil;
/** /**
* Lightweight implementation of ViewPager tabs. This looks similar to traditional actionBar tabs, * Lightweight implementation of ViewPager tabs. This looks similar to traditional actionBar tabs,
@@ -130,7 +129,6 @@ public class ViewPagerTabs extends HorizontalScrollView implements ViewPager.OnP
a.recycle(); a.recycle();
// enable shadow casting from view bounds // enable shadow casting from view bounds
if (OsUtil.isAtLeastL()) {
setOutlineProvider(new ViewOutlineProvider() { setOutlineProvider(new ViewOutlineProvider() {
@Override @Override
public void getOutline(View view, Outline outline) { public void getOutline(View view, Outline outline) {
@@ -138,7 +136,6 @@ public class ViewPagerTabs extends HorizontalScrollView implements ViewPager.OnP
} }
}); });
} }
}
public void setViewPager(ViewPager viewPager) { public void setViewPager(ViewPager viewPager) {
mPager = viewPager; mPager = viewPager;
@@ -223,7 +220,7 @@ public class ViewPagerTabs extends HorizontalScrollView implements ViewPager.OnP
} }
private int getRtlPosition(int position) { private int getRtlPosition(int position) {
if (OsUtil.isAtLeastJB_MR2() && Factory.get().getApplicationContext().getResources() if (Factory.get().getApplicationContext().getResources()
.getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { .getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
return mTabStrip.getChildCount() - 1 - position; return mTabStrip.getChildCount() - 1 - position;
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -19,19 +20,12 @@ import android.animation.RectEvaluator;
import android.animation.TypeEvaluator; import android.animation.TypeEvaluator;
import android.graphics.Rect; import android.graphics.Rect;
import com.android.messaging.util.OsUtil;
/** /**
* This evaluator can be used to perform type interpolation between <code>Rect</code> values. * This evaluator can be used to perform type interpolation between <code>Rect</code> values.
* It's backward compatible to Api Level 11.
*/ */
public class RectEvaluatorCompat implements TypeEvaluator<Rect> { public class RectEvaluatorCompat implements TypeEvaluator<Rect> {
public static TypeEvaluator<Rect> create() { public static TypeEvaluator<Rect> create() {
if (OsUtil.isAtLeastJB_MR2()) {
return new RectEvaluator(); return new RectEvaluator();
} else {
return new RectEvaluatorCompat();
}
} }
@Override @Override
@@ -15,7 +15,6 @@
*/ */
package com.android.messaging.ui.animation; package com.android.messaging.ui.animation;
import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
@@ -34,7 +33,6 @@ import android.widget.FrameLayout;
import com.android.messaging.R; import com.android.messaging.R;
import com.android.messaging.util.ImageUtils; import com.android.messaging.util.ImageUtils;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.UiUtils; import com.android.messaging.util.UiUtils;
/** /**
@@ -69,20 +67,15 @@ public class ViewGroupItemVerticalExplodeAnimation {
*/ */
public static void startAnimationForView(final ViewGroup container, final View viewToAnimate, public static void startAnimationForView(final ViewGroup container, final View viewToAnimate,
final View animationStagingView, final boolean snapshotView, final int duration) { final View animationStagingView, final boolean snapshotView, final int duration) {
if (OsUtil.isAtLeastJB_MR2() && (viewToAnimate.getContext() instanceof Activity)) { if ((viewToAnimate.getContext() instanceof Activity)) {
new ViewExplodeAnimationJellyBeanMR2(viewToAnimate, container, snapshotView, duration) new ViewExplodeAnimationJellyBeanMR2(viewToAnimate, container, snapshotView, duration)
.startAnimation(); .startAnimation();
} else {
// Pre JB_MR2, this animation can cause rendering failures which causes the framework
// to fall back to software rendering where camera preview isn't supported (b/18264647)
// just skip the animation to avoid this case.
} }
} }
/** /**
* Implementation class for API level >= 18. * Implementation class for API level >= 18.
*/ */
@TargetApi(18)
private static class ViewExplodeAnimationJellyBeanMR2 { private static class ViewExplodeAnimationJellyBeanMR2 {
private final View mViewToAnimate; private final View mViewToAnimate;
private final ViewGroup mContainer; private final ViewGroup mContainer;
@@ -49,7 +49,6 @@ import com.android.messaging.sms.ApnDatabase;
import com.android.messaging.sms.BugleApnSettingsLoader; import com.android.messaging.sms.BugleApnSettingsLoader;
import com.android.messaging.ui.BugleActionBarActivity; import com.android.messaging.ui.BugleActionBarActivity;
import com.android.messaging.ui.UIIntents; import com.android.messaging.ui.UIIntents;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.PhoneUtils; import com.android.messaging.util.PhoneUtils;
public class ApnSettingsActivity extends BugleActionBarActivity { public class ApnSettingsActivity extends BugleActionBarActivity {
@@ -150,15 +149,10 @@ public class ApnSettingsActivity extends BugleActionBarActivity {
super.onCreate(icicle); super.onCreate(icicle);
mDatabase = ApnDatabase.getApnDatabase().getWritableDatabase(); mDatabase = ApnDatabase.getApnDatabase().getWritableDatabase();
if (OsUtil.isAtLeastL()) {
mUm = (UserManager) getActivity().getSystemService(Context.USER_SERVICE); mUm = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
if (!mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) { if (!mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) {
setHasOptionsMenu(true); setHasOptionsMenu(true);
} }
} else {
setHasOptionsMenu(true);
}
} }
@Override @Override
@@ -172,8 +166,7 @@ public class ApnSettingsActivity extends BugleActionBarActivity {
lv.setEmptyView(empty); lv.setEmptyView(empty);
} }
if (OsUtil.isAtLeastL() && if (mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) {
mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) {
mUnavailable = true; mUnavailable = true;
setPreferenceScreen(getPreferenceManager().createPreferenceScreen(getActivity())); setPreferenceScreen(getPreferenceManager().createPreferenceScreen(getActivity()));
return; return;
@@ -36,7 +36,6 @@ import com.android.messaging.ui.LicenseActivity;
import com.android.messaging.ui.UIIntents; import com.android.messaging.ui.UIIntents;
import com.android.messaging.util.BuglePrefs; import com.android.messaging.util.BuglePrefs;
import com.android.messaging.util.DebugUtils; import com.android.messaging.util.DebugUtils;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.PhoneUtils; import com.android.messaging.util.PhoneUtils;
public class ApplicationSettingsActivity extends BugleActionBarActivity { public class ApplicationSettingsActivity extends BugleActionBarActivity {
@@ -151,36 +150,15 @@ public class ApplicationSettingsActivity extends BugleActionBarActivity {
} }
private void updateSmsEnabledPreferences() { private void updateSmsEnabledPreferences() {
if (!OsUtil.isAtLeastKLP()) {
getPreferenceScreen().removePreference(mSmsDisabledPreference);
getPreferenceScreen().removePreference(mSmsEnabledPreference);
} else {
final String defaultSmsAppLabel = getString(R.string.default_sms_app, final String defaultSmsAppLabel = getString(R.string.default_sms_app,
PhoneUtils.getDefault().getDefaultSmsAppLabel()); PhoneUtils.getDefault().getDefaultSmsAppLabel());
boolean isSmsEnabledBeforeState;
boolean isSmsEnabledCurrentState;
if (PhoneUtils.getDefault().isDefaultSmsApp()) { if (PhoneUtils.getDefault().isDefaultSmsApp()) {
if (getPreferenceScreen().findPreference(mSmsEnabledPrefKey) == null) {
getPreferenceScreen().addPreference(mSmsEnabledPreference);
isSmsEnabledBeforeState = false;
} else {
isSmsEnabledBeforeState = true;
}
isSmsEnabledCurrentState = true;
getPreferenceScreen().removePreference(mSmsDisabledPreference); getPreferenceScreen().removePreference(mSmsDisabledPreference);
mSmsEnabledPreference.setSummary(defaultSmsAppLabel); mSmsEnabledPreference.setSummary(defaultSmsAppLabel);
} else { } else {
if (getPreferenceScreen().findPreference(mSmsDisabledPrefKey) == null) {
getPreferenceScreen().addPreference(mSmsDisabledPreference);
isSmsEnabledBeforeState = true;
} else {
isSmsEnabledBeforeState = false;
}
isSmsEnabledCurrentState = false;
getPreferenceScreen().removePreference(mSmsEnabledPreference); getPreferenceScreen().removePreference(mSmsEnabledPreference);
mSmsDisabledPreference.setSummary(defaultSmsAppLabel); mSmsDisabledPreference.setSummary(defaultSmsAppLabel);
} }
}
mIsSmsPreferenceClicked = false; mIsSmsPreferenceClicked = false;
} }
@@ -60,7 +60,6 @@ import com.android.messaging.util.Assert.RunsOnMainThread;
import com.android.messaging.util.ContactUtil; import com.android.messaging.util.ContactUtil;
import com.android.messaging.util.ImeUtil; import com.android.messaging.util.ImeUtil;
import com.android.messaging.util.LogUtil; import com.android.messaging.util.LogUtil;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.PhoneUtils; import com.android.messaging.util.PhoneUtils;
import com.android.messaging.util.UiUtils; import com.android.messaging.util.UiUtils;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
@@ -503,10 +502,6 @@ public class ContactPickerFragment extends Fragment implements ContactPickerData
* @param show whether the contact lists are to be shown or hidden. * @param show whether the contact lists are to be shown or hidden.
*/ */
private void startExplodeTransitionForContactLists(final boolean show) { private void startExplodeTransitionForContactLists(final boolean show) {
if (!OsUtil.isAtLeastL()) {
// Explode animation is not supported pre-L.
return;
}
final Explode transition = new Explode(); final Explode transition = new Explode();
final Rect epicenter = mPendingExplodeView == null ? null : final Rect epicenter = mPendingExplodeView == null ? null :
UiUtils.getMeasuredBoundsOnScreen(mPendingExplodeView); UiUtils.getMeasuredBoundsOnScreen(mPendingExplodeView);
@@ -533,10 +528,6 @@ public class ContactPickerFragment extends Fragment implements ContactPickerData
* the transition manager for pending explode transition. * the transition manager for pending explode transition.
*/ */
private void toggleContactListItemsVisibilityForPendingTransition(final boolean show) { private void toggleContactListItemsVisibilityForPendingTransition(final boolean show) {
if (!OsUtil.isAtLeastL()) {
// Explode animation is not supported pre-L.
return;
}
mAllContactsListViewHolder.toggleVisibilityForPendingTransition(show, mPendingExplodeView); mAllContactsListViewHolder.toggleVisibilityForPendingTransition(show, mPendingExplodeView);
mFrequentContactsListViewHolder.toggleVisibilityForPendingTransition(show, mFrequentContactsListViewHolder.toggleVisibilityForPendingTransition(show,
mPendingExplodeView); mPendingExplodeView);
@@ -39,7 +39,6 @@ import com.android.messaging.util.BugleGservices;
import com.android.messaging.util.BugleGservicesKeys; import com.android.messaging.util.BugleGservicesKeys;
import com.android.messaging.util.ContactRecipientEntryUtils; import com.android.messaging.util.ContactRecipientEntryUtils;
import com.android.messaging.util.ContactUtil; import com.android.messaging.util.ContactUtil;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.PhoneUtils; import com.android.messaging.util.PhoneUtils;
import java.text.Collator; import java.text.Collator;
@@ -129,7 +128,6 @@ public final class ContactRecipientAdapter extends BaseRecipientAdapter {
new Cursor[]{personalFilterEmailsCursor, personalFilterPhonesCursor}); new Cursor[]{personalFilterEmailsCursor, personalFilterPhonesCursor});
final CursorResult cursorResult = final CursorResult cursorResult =
new CursorResult(personalCursor, false /* sorted */); new CursorResult(personalCursor, false /* sorted */);
if (OsUtil.isAtLeastN()) {
// Including enterprise result starting from N. // Including enterprise result starting from N.
final Cursor enterpriseFilterPhonesCursor = ContactUtil.filterPhonesEnterprise( final Cursor enterpriseFilterPhonesCursor = ContactUtil.filterPhonesEnterprise(
getContext(), searchText).performSynchronousQuery(); getContext(), searchText).performSynchronousQuery();
@@ -139,20 +137,17 @@ public final class ContactRecipientAdapter extends BaseRecipientAdapter {
new Cursor[]{enterpriseFilterEmailsCursor, new Cursor[]{enterpriseFilterEmailsCursor,
enterpriseFilterPhonesCursor}); enterpriseFilterPhonesCursor});
cursorResult.enterpriseCursor = enterpriseCursor; cursorResult.enterpriseCursor = enterpriseCursor;
}
return cursorResult; return cursorResult;
} else { } else {
final Cursor personalFilterDestinationCursor = ContactUtil final Cursor personalFilterDestinationCursor = ContactUtil
.filterDestination(getContext(), searchText).performSynchronousQuery(); .filterDestination(getContext(), searchText).performSynchronousQuery();
final CursorResult cursorResult = new CursorResult(personalFilterDestinationCursor, final CursorResult cursorResult = new CursorResult(personalFilterDestinationCursor,
true); true);
if (OsUtil.isAtLeastN()) {
// Including enterprise result starting from N. // Including enterprise result starting from N.
final Cursor enterpriseFilterDestinationCursor = ContactUtil final Cursor enterpriseFilterDestinationCursor = ContactUtil
.filterDestinationEnterprise(getContext(), searchText) .filterDestinationEnterprise(getContext(), searchText)
.performSynchronousQuery(); .performSynchronousQuery();
cursorResult.enterpriseCursor = enterpriseFilterDestinationCursor; cursorResult.enterpriseCursor = enterpriseFilterDestinationCursor;
}
return cursorResult; return cursorResult;
} }
} }
@@ -67,7 +67,6 @@ import com.android.messaging.util.BuglePrefs;
import com.android.messaging.util.ContentType; import com.android.messaging.util.ContentType;
import com.android.messaging.util.LogUtil; import com.android.messaging.util.LogUtil;
import com.android.messaging.util.MediaUtil; import com.android.messaging.util.MediaUtil;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.PhoneUtils; import com.android.messaging.util.PhoneUtils;
import com.android.messaging.util.SafeAsyncTask; import com.android.messaging.util.SafeAsyncTask;
import com.android.messaging.util.UiUtils; import com.android.messaging.util.UiUtils;
@@ -867,7 +866,6 @@ public class ComposeMessageView extends LinearLayout
// Set accessibility traversal order of the components in the send widget. // Set accessibility traversal order of the components in the send widget.
private void setSendWidgetAccessibilityTraversalOrder(final int mode) { private void setSendWidgetAccessibilityTraversalOrder(final int mode) {
if (OsUtil.isAtLeastL_MR1()) {
mAttachMediaButton.setAccessibilityTraversalBefore(R.id.compose_message_text); mAttachMediaButton.setAccessibilityTraversalBefore(R.id.compose_message_text);
switch (mode) { switch (mode) {
case SEND_WIDGET_MODE_SIM_SELECTOR: case SEND_WIDGET_MODE_SIM_SELECTOR:
@@ -880,7 +878,6 @@ public class ComposeMessageView extends LinearLayout
break; break;
} }
} }
}
@Override @Override
public void afterTextChanged(final Editable editable) { public void afterTextChanged(final Editable editable) {
@@ -979,8 +976,7 @@ public class ComposeMessageView extends LinearLayout
} }
public static boolean shouldShowSimSelector(final ConversationData convData) { public static boolean shouldShowSimSelector(final ConversationData convData) {
return OsUtil.isAtLeastL_MR1() && return convData.getSelfParticipantsCountExcludingDefault(true /* activeOnly */) > 1;
convData.getSelfParticipantsCountExcludingDefault(true /* activeOnly */) > 1;
} }
public void sendMessageIgnoreMessageSizeLimit() { public void sendMessageIgnoreMessageSizeLimit() {
@@ -39,7 +39,6 @@ import com.android.messaging.ui.conversationlist.ConversationListActivity;
import com.android.messaging.util.Assert; import com.android.messaging.util.Assert;
import com.android.messaging.util.ContentType; import com.android.messaging.util.ContentType;
import com.android.messaging.util.LogUtil; import com.android.messaging.util.LogUtil;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.UiUtils; import com.android.messaging.util.UiUtils;
public class ConversationActivity extends BugleActionBarActivity public class ConversationActivity extends BugleActionBarActivity
@@ -348,11 +347,7 @@ public class ConversationActivity extends BugleActionBarActivity
public void onFinishCurrentConversation() { public void onFinishCurrentConversation() {
// Simply finish the current activity. The current design is to leave any empty // Simply finish the current activity. The current design is to leave any empty
// conversations as is. // conversations as is.
if (OsUtil.isAtLeastL()) {
finishAfterTransition(); finishAfterTransition();
} else {
finish();
}
} }
@Override @Override
@@ -41,7 +41,6 @@ import com.android.messaging.R;
import com.android.messaging.datamodel.data.ConversationMessageData; import com.android.messaging.datamodel.data.ConversationMessageData;
import com.android.messaging.ui.ConversationDrawables; import com.android.messaging.ui.ConversationDrawables;
import com.android.messaging.util.Dates; import com.android.messaging.util.Dates;
import com.android.messaging.util.OsUtil;
/** /**
* Adds a "fast-scroll" bar to the conversation RecyclerView that shows the current position within * Adds a "fast-scroll" bar to the conversation RecyclerView that shows the current position within
@@ -63,11 +62,8 @@ public class ConversationFastScroller extends RecyclerView.OnScrollListener impl
* (the feature requires Jellybean MR2 or newer) * (the feature requires Jellybean MR2 or newer)
*/ */
public static ConversationFastScroller addTo(RecyclerView rv, int position) { public static ConversationFastScroller addTo(RecyclerView rv, int position) {
if (OsUtil.isAtLeastJB_MR2()) {
return new ConversationFastScroller(rv, position); return new ConversationFastScroller(rv, position);
} }
return null;
}
public static final int POSITION_RIGHT_SIDE = 0; public static final int POSITION_RIGHT_SIDE = 0;
public static final int POSITION_LEFT_SIDE = 1; public static final int POSITION_LEFT_SIDE = 1;
@@ -164,20 +160,12 @@ public class ConversationFastScroller extends RecyclerView.OnScrollListener impl
public void refreshConversationThemeColor() { public void refreshConversationThemeColor() {
mPreviewTextView.setBackground( mPreviewTextView.setBackground(
ConversationDrawables.get().getFastScrollPreviewDrawable(mPosRight)); ConversationDrawables.get().getFastScrollPreviewDrawable(mPosRight));
if (OsUtil.isAtLeastL()) {
final StateListDrawable drawable = new StateListDrawable(); final StateListDrawable drawable = new StateListDrawable();
drawable.addState(new int[]{ android.R.attr.state_pressed }, drawable.addState(new int[]{ android.R.attr.state_pressed },
ConversationDrawables.get().getFastScrollThumbDrawable(true /* pressed */)); ConversationDrawables.get().getFastScrollThumbDrawable(true /* pressed */));
drawable.addState(StateSet.WILD_CARD, drawable.addState(StateSet.WILD_CARD,
ConversationDrawables.get().getFastScrollThumbDrawable(false /* pressed */)); ConversationDrawables.get().getFastScrollThumbDrawable(false /* pressed */));
mThumbImageView.setImageDrawable(drawable); mThumbImageView.setImageDrawable(drawable);
} else {
// Android pre-L doesn't seem to handle a StateListDrawable containing a tinted
// drawable (it's rendered in the filter base color, which is red), so fall back to
// just the regular (non-pressed) drawable.
mThumbImageView.setImageDrawable(
ConversationDrawables.get().getFastScrollThumbDrawable(false /* pressed */));
}
} }
@Override @Override
@@ -1012,7 +1012,7 @@ public class ConversationFragment extends Fragment implements ConversationDataLi
} }
private FragmentManager getFragmentManagerToUse() { private FragmentManager getFragmentManagerToUse() {
return OsUtil.isAtLeastJB_MR1() ? getChildFragmentManager() : getFragmentManager(); return getChildFragmentManager();
} }
public MediaPicker getMediaPicker() { public MediaPicker getMediaPicker() {
@@ -1158,21 +1158,7 @@ public class ConversationFragment extends Fragment implements ConversationDataLi
} }
}) })
.setNegativeButton(android.R.string.cancel, null); .setNegativeButton(android.R.string.cancel, null);
if (OsUtil.isAtLeastJB_MR1()) { builder.setOnDismissListener(dialog -> mHost.dismissActionMode());
builder.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(final DialogInterface dialog) {
mHost.dismissActionMode();
}
});
} else {
builder.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(final DialogInterface dialog) {
mHost.dismissActionMode();
}
});
}
builder.create().show(); builder.create().show();
} else { } else {
warnOfMissingActionConditions(false /*sending*/, warnOfMissingActionConditions(false /*sending*/,
@@ -26,7 +26,6 @@ import com.android.messaging.datamodel.data.SubscriptionListData.SubscriptionLis
import com.android.messaging.ui.conversation.SimSelectorView.SimSelectorViewListener; import com.android.messaging.ui.conversation.SimSelectorView.SimSelectorViewListener;
import com.android.messaging.util.AccessibilityUtil; import com.android.messaging.util.AccessibilityUtil;
import com.android.messaging.util.Assert; import com.android.messaging.util.Assert;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.ThreadUtil; import com.android.messaging.util.ThreadUtil;
/** /**
@@ -47,7 +46,6 @@ abstract class ConversationSimSelector extends ConversationInput {
mSimSelectorView.bind(subscriptionListData); mSimSelectorView.bind(subscriptionListData);
mDataReady = subscriptionListData != null && subscriptionListData.hasData(); mDataReady = subscriptionListData != null && subscriptionListData.hasData();
if (mPendingShow != null && mDataReady) { if (mPendingShow != null && mDataReady) {
Assert.isTrue(OsUtil.isAtLeastL_MR1());
final boolean show = mPendingShow.first; final boolean show = mPendingShow.first;
final boolean animate = mPendingShow.second; final boolean animate = mPendingShow.second;
ThreadUtil.getMainThreadHandler().post(new Runnable() { ThreadUtil.getMainThreadHandler().post(new Runnable() {
@@ -88,10 +86,6 @@ abstract class ConversationSimSelector extends ConversationInput {
} }
private boolean showHide(final boolean show, final boolean animate) { private boolean showHide(final boolean show, final boolean animate) {
if (!OsUtil.isAtLeastL_MR1()) {
return false;
}
if (mDataReady) { if (mDataReady) {
mSimSelectorView.showOrHide(show, animate); mSimSelectorView.showOrHide(show, animate);
return mSimSelectorView.isOpen() == show; return mSimSelectorView.isOpen() == show;
@@ -37,7 +37,6 @@ import com.android.messaging.util.Assert;
import com.android.messaging.util.Assert.DoesNotRunOnMainThread; import com.android.messaging.util.Assert.DoesNotRunOnMainThread;
import com.android.messaging.util.Dates; import com.android.messaging.util.Dates;
import com.android.messaging.util.DebugUtils; import com.android.messaging.util.DebugUtils;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.PhoneUtils; import com.android.messaging.util.PhoneUtils;
import com.android.messaging.util.SafeAsyncTask; import com.android.messaging.util.SafeAsyncTask;
@@ -356,9 +355,7 @@ public class MessageDetailsDialog {
private static void appendSimInfo(final Resources res, private static void appendSimInfo(final Resources res,
final ParticipantData self, final StringBuilder outString) { final ParticipantData self, final StringBuilder outString) {
if (!OsUtil.isAtLeastL_MR1() if (self == null || PhoneUtils.getDefault().getActiveSubscriptionCount() < 2) {
|| self == null
|| PhoneUtils.getDefault().getActiveSubscriptionCount() < 2) {
return; return;
} }
// The appended SIM info would look like: // The appended SIM info would look like:
@@ -26,7 +26,6 @@ import android.view.ViewOutlineProvider;
import com.android.messaging.ui.ContactIconView; import com.android.messaging.ui.ContactIconView;
import com.android.messaging.util.Assert; import com.android.messaging.util.Assert;
import com.android.messaging.util.AvatarUriUtil; import com.android.messaging.util.AvatarUriUtil;
import com.android.messaging.util.OsUtil;
/** /**
* Shows SIM avatar icon in the SIM switcher / Self-send button. * Shows SIM avatar icon in the SIM switcher / Self-send button.
@@ -34,7 +33,6 @@ import com.android.messaging.util.OsUtil;
public class SimIconView extends ContactIconView { public class SimIconView extends ContactIconView {
public SimIconView(Context context, AttributeSet attrs) { public SimIconView(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
if (OsUtil.isAtLeastL()) {
setOutlineProvider(new ViewOutlineProvider() { setOutlineProvider(new ViewOutlineProvider() {
@Override @Override
public void getOutline(View v, Outline outline) { public void getOutline(View v, Outline outline) {
@@ -42,7 +40,6 @@ public class SimIconView extends ContactIconView {
} }
}); });
} }
}
@Override @Override
public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event) {
@@ -53,7 +53,6 @@ import com.android.messaging.ui.SnackBarInteraction;
import com.android.messaging.util.Assert; import com.android.messaging.util.Assert;
import com.android.messaging.util.ContentType; import com.android.messaging.util.ContentType;
import com.android.messaging.util.ImageUtils; import com.android.messaging.util.ImageUtils;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.PhoneUtils; import com.android.messaging.util.PhoneUtils;
import com.android.messaging.util.Typefaces; import com.android.messaging.util.Typefaces;
import com.android.messaging.util.UiUtils; import com.android.messaging.util.UiUtils;
@@ -168,10 +167,8 @@ public class ConversationListItemView extends FrameLayout implements OnClickList
mListItemReadTypeface = Typefaces.getRobotoNormal(); mListItemReadTypeface = Typefaces.getRobotoNormal();
mListItemUnreadTypeface = Typefaces.getRobotoBold(); mListItemUnreadTypeface = Typefaces.getRobotoBold();
if (OsUtil.isAtLeastL()) {
setTransitionGroup(true); setTransitionGroup(true);
} }
}
@Override @Override
public void onLayoutChange(final View v, final int left, final int top, final int right, public void onLayoutChange(final View v, final int left, final int top, final int right,
@@ -31,10 +31,8 @@ import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import com.android.messaging.R; import com.android.messaging.R;
import com.android.messaging.datamodel.data.ParticipantData;
import com.android.messaging.sms.MmsConfig; import com.android.messaging.sms.MmsConfig;
import com.android.messaging.ui.debug.DebugMmsConfigItemView.MmsConfigItemListener; import com.android.messaging.ui.debug.DebugMmsConfigItemView.MmsConfigItemListener;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.PhoneUtils; import com.android.messaging.util.PhoneUtils;
import java.util.ArrayList; import java.util.ArrayList;
@@ -79,11 +77,8 @@ public class DebugMmsConfigFragment extends Fragment {
} }
public static Integer[] getActiveSubIds() { public static Integer[] getActiveSubIds() {
if (!OsUtil.isAtLeastL_MR1()) {
return new Integer[] { ParticipantData.DEFAULT_SELF_SUB_ID };
}
final List<SubscriptionInfo> subRecords = final List<SubscriptionInfo> subRecords =
PhoneUtils.getDefault().toLMr1().getActiveSubscriptionInfoList(); PhoneUtils.getDefault().getActiveSubscriptionInfoList();
if (subRecords == null) { if (subRecords == null) {
return new Integer[0]; return new Integer[0];
} }
@@ -34,7 +34,6 @@ import com.android.messaging.datamodel.data.MediaPickerData;
import com.android.messaging.datamodel.data.DraftMessageData.DraftMessageSubscriptionDataProvider; import com.android.messaging.datamodel.data.DraftMessageData.DraftMessageSubscriptionDataProvider;
import com.android.messaging.ui.BasePagerViewHolder; import com.android.messaging.ui.BasePagerViewHolder;
import com.android.messaging.util.Assert; import com.android.messaging.util.Assert;
import com.android.messaging.util.OsUtil;
abstract class MediaChooser extends BasePagerViewHolder abstract class MediaChooser extends BasePagerViewHolder
implements DraftMessageSubscriptionDataProvider { implements DraftMessageSubscriptionDataProvider {
@@ -107,8 +106,7 @@ abstract class MediaChooser extends BasePagerViewHolder
} }
protected FragmentManager getFragmentManager() { protected FragmentManager getFragmentManager() {
return OsUtil.isAtLeastJB_MR1() ? mMediaPicker.getChildFragmentManager() : return mMediaPicker.getChildFragmentManager();
mMediaPicker.getFragmentManager();
} }
protected LayoutInflater getLayoutInflater() { protected LayoutInflater getLayoutInflater() {
return LayoutInflater.from(getContext()); return LayoutInflater.from(getContext());
@@ -31,7 +31,6 @@ import android.widget.LinearLayout;
import com.android.messaging.R; import com.android.messaging.R;
import com.android.messaging.ui.PagingAwareViewPager; import com.android.messaging.ui.PagingAwareViewPager;
import com.android.messaging.util.Assert; import com.android.messaging.util.Assert;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.UiUtils; import com.android.messaging.util.UiUtils;
/** /**
@@ -202,7 +201,7 @@ public class MediaPickerPanel extends ViewGroup {
private int getDesiredHeight() { private int getDesiredHeight() {
if (mFullScreen) { if (mFullScreen) {
int fullHeight = getContext().getResources().getDisplayMetrics().heightPixels; int fullHeight = getContext().getResources().getDisplayMetrics().heightPixels;
if (OsUtil.isAtLeastKLP() && isAttachedToWindow()) { if (isAttachedToWindow()) {
// When we're attached to the window, we can get an accurate height, not necessary // When we're attached to the window, we can get an accurate height, not necessary
// on older API level devices because they don't include the action bar height // on older API level devices because they don't include the action bar height
View composeContainer = View composeContainer =
@@ -73,8 +73,7 @@ public class AccessibilityUtil {
} }
// Jelly Bean added support for speaking text verbatim // Jelly Bean added support for speaking text verbatim
final int eventType = OsUtil.isAtLeastJB() ? AccessibilityEvent.TYPE_ANNOUNCEMENT final int eventType = AccessibilityEvent.TYPE_ANNOUNCEMENT;
: AccessibilityEvent.TYPE_VIEW_FOCUSED;
// Construct an accessibility event with the minimum recommended // Construct an accessibility event with the minimum recommended
// attributes. An event without a class name or package may be dropped. // attributes. An event without a class name or package may be dropped.
@@ -101,11 +100,7 @@ public class AccessibilityUtil {
* @return boolean Boolean indicating whether the currently locale is RTL. * @return boolean Boolean indicating whether the currently locale is RTL.
*/ */
public static boolean isLayoutRtl(final View view) { public static boolean isLayoutRtl(final View view) {
if (OsUtil.isAtLeastJB_MR1()) {
return View.LAYOUT_DIRECTION_RTL == view.getLayoutDirection(); return View.LAYOUT_DIRECTION_RTL == view.getLayoutDirection();
} else {
return false;
}
} }
public static String getVocalizedPhoneNumber(final Resources res, final String phoneNumber) { public static String getVocalizedPhoneNumber(final Resources res, final String phoneNumber) {
@@ -62,10 +62,6 @@ public class BugleActivityUtil {
* @return true if the user has SMS permissions, otherwise false. * @return true if the user has SMS permissions, otherwise false.
*/ */
private static boolean checkHasSmsPermissionsForUser(Context context, Activity activity) { private static boolean checkHasSmsPermissionsForUser(Context context, Activity activity) {
if (!OsUtil.isAtLeastL()) {
// UserManager.DISALLOW_SMS added in L. No multiuser phones before this
return true;
}
UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE); UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
if (userManager.hasUserRestriction(UserManager.DISALLOW_SMS)) { if (userManager.hasUserRestriction(UserManager.DISALLOW_SMS)) {
new AlertDialog.Builder(activity) new AlertDialog.Builder(activity)
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -25,13 +26,6 @@ import com.android.messaging.datamodel.data.ParticipantData;
/** /**
* ConnectivityUtil listens to the network service state changes. * ConnectivityUtil listens to the network service state changes.
*
* On N and beyond, This class instance can be created via ConnectivityUtil(context, subId), use
* ConnectivityUtil(context) for others.
*
* Note that TelephonyManager has createForSubscriptionId() for a specific subId from N but listen()
* does not use the subId on the manager, and uses the default subId on PhoneStateListener. From O,
* the manager uses its' own subId in listen().
*/ */
public class ConnectivityUtil { public class ConnectivityUtil {
// Assume not connected until informed differently // Assume not connected until informed differently
@@ -45,12 +39,7 @@ public class ConnectivityUtil {
public void onPhoneStateChanged(int serviceState); public void onPhoneStateChanged(int serviceState);
} }
public ConnectivityUtil(final Context context) {
mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
}
public ConnectivityUtil(final Context context, final int subId) { public ConnectivityUtil(final Context context, final int subId) {
Assert.isTrue(OsUtil.isAtLeastN());
mTelephonyManager = mTelephonyManager =
((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)) ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE))
.createForSubscriptionId(subId); .createForSubscriptionId(subId);
@@ -519,28 +519,22 @@ public class ContactUtil {
* Returns if a given contact id belongs to managed profile. * Returns if a given contact id belongs to managed profile.
*/ */
public static boolean isEnterpriseContactId(final long contactId) { public static boolean isEnterpriseContactId(final long contactId) {
return OsUtil.isAtLeastL() && ContactsContract.Contacts.isEnterpriseContactId(contactId); return ContactsContract.Contacts.isEnterpriseContactId(contactId);
} }
/** /**
* Returns Email lookup uri that will query both primary and corp profile * Returns Email lookup uri that will query both primary and corp profile
*/ */
private static Uri getEmailContentLookupUri() { private static Uri getEmailContentLookupUri() {
if (OsUtil.isAtLeastM()) {
return Email.ENTERPRISE_CONTENT_LOOKUP_URI; return Email.ENTERPRISE_CONTENT_LOOKUP_URI;
} }
return Email.CONTENT_LOOKUP_URI;
}
/** /**
* Returns PhoneLookup URI. * Returns PhoneLookup URI.
*/ */
public static Uri getPhoneLookupUri() { public static Uri getPhoneLookupUri() {
if (OsUtil.isAtLeastM()) {
return PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI; return PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI;
} }
return PhoneLookup.CONTENT_FILTER_URI;
}
public static boolean hasReadContactsPermission() { public static boolean hasReadContactsPermission() {
return OsUtil.hasPermission(Manifest.permission.READ_CONTACTS); return OsUtil.hasPermission(Manifest.permission.READ_CONTACTS);
@@ -302,10 +302,7 @@ public class DebugUtils {
final int length = dis.readInt(); final int length = dis.readInt();
final byte[] pdu = new byte[length]; final byte[] pdu = new byte[length];
dis.read(pdu, 0, length); dis.read(pdu, 0, length);
messagesTemp[i] = messagesTemp[i] = SmsMessage.createFromPdu(pdu, format);
OsUtil.isAtLeastM()
? SmsMessage.createFromPdu(pdu, format)
: SmsMessage.createFromPdu(pdu);
} }
messages = messagesTemp; messages = messagesTemp;
} catch (final FileNotFoundException e) { } catch (final FileNotFoundException e) {
@@ -174,11 +174,7 @@ public class ImageUtils {
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void setBackgroundDrawableOnView(final View view, final Drawable drawable) { public static void setBackgroundDrawableOnView(final View view, final Drawable drawable) {
if (OsUtil.isAtLeastJB()) {
view.setBackground(drawable); view.setBackground(drawable);
} else {
view.setBackgroundDrawable(drawable);
}
} }
/** /**
@@ -33,8 +33,4 @@ public abstract class MediaUtil {
*/ */
public abstract void playSound(final Context context, final int resId, public abstract void playSound(final Context context, final int resId,
final OnCompletionListener completionListener); final OnCompletionListener completionListener);
public static boolean canAutoAccessIncomingMedia() {
return OsUtil.isAtLeastM();
}
} }
@@ -20,7 +20,6 @@ import android.app.NotificationChannel;
import android.app.NotificationChannelGroup; import android.app.NotificationChannelGroup;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.content.Context; import android.content.Context;
import android.os.Build;
public final class NotificationsUtil { public final class NotificationsUtil {
public static final String DEFAULT_CHANNEL_ID = "messaging_channel"; public static final String DEFAULT_CHANNEL_ID = "messaging_channel";
@@ -37,10 +36,6 @@ public final class NotificationsUtil {
public static void createNotificationChannel(Context context, String id, public static void createNotificationChannel(Context context, String id,
String title, int priority, String groupId) { String title, int priority, String groupId) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
return;
}
NotificationManager manager = context.getSystemService(NotificationManager.class); NotificationManager manager = context.getSystemService(NotificationManager.class);
NotificationChannel existing = manager.getNotificationChannel(id); NotificationChannel existing = manager.getNotificationChannel(id);
if (existing != null) { if (existing != null) {
@@ -56,20 +51,12 @@ public final class NotificationsUtil {
} }
public static void deleteNotificationChannel(Context context, String id) { public static void deleteNotificationChannel(Context context, String id) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
return;
}
NotificationManager manager = context.getSystemService(NotificationManager.class); NotificationManager manager = context.getSystemService(NotificationManager.class);
manager.deleteNotificationChannel(id); manager.deleteNotificationChannel(id);
} }
public static void createNotificationChannelGroup(Context context, String id, public static void createNotificationChannelGroup(Context context, String id,
int titleResId) { int titleResId) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
return;
}
NotificationManager manager = context.getSystemService(NotificationManager.class); NotificationManager manager = context.getSystemService(NotificationManager.class);
NotificationChannelGroup existing = manager.getNotificationChannelGroup(id); NotificationChannelGroup existing = manager.getNotificationChannelGroup(id);
if (existing != null) { if (existing != null) {
@@ -82,19 +69,11 @@ public final class NotificationsUtil {
} }
public static NotificationChannel getNotificationChannel(Context context, String id) { public static NotificationChannel getNotificationChannel(Context context, String id) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
return null;
}
NotificationManager manager = context.getSystemService(NotificationManager.class); NotificationManager manager = context.getSystemService(NotificationManager.class);
return manager.getNotificationChannel(id); return manager.getNotificationChannel(id);
} }
public static NotificationChannelGroup getNotificationChannelGroup(Context context, String id) { public static NotificationChannelGroup getNotificationChannelGroup(Context context, String id) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
return null;
}
NotificationManager manager = context.getSystemService(NotificationManager.class); NotificationManager manager = context.getSystemService(NotificationManager.class);
return manager.getNotificationChannelGroup(id); return manager.getNotificationChannelGroup(id);
} }
-110
View File
@@ -19,10 +19,8 @@ package com.android.messaging.util;
import android.Manifest; import android.Manifest;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.os.Build;
import android.os.UserHandle; import android.os.UserHandle;
import android.os.UserManager; import android.os.UserManager;
import androidx.core.os.BuildCompat;
import com.android.messaging.Factory; import com.android.messaging.Factory;
@@ -34,117 +32,14 @@ import java.util.Set;
* Android OS version utilities * Android OS version utilities
*/ */
public class OsUtil { public class OsUtil {
private static boolean sIsAtLeastICS_MR1;
private static boolean sIsAtLeastJB;
private static boolean sIsAtLeastJB_MR1;
private static boolean sIsAtLeastJB_MR2;
private static boolean sIsAtLeastKLP;
private static boolean sIsAtLeastL;
private static boolean sIsAtLeastL_MR1;
private static boolean sIsAtLeastM;
private static boolean sIsAtLeastN;
private static Boolean sIsSecondaryUser = null; private static Boolean sIsSecondaryUser = null;
static {
final int v = getApiVersion();
sIsAtLeastICS_MR1 = v >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1;
sIsAtLeastJB = v >= android.os.Build.VERSION_CODES.JELLY_BEAN;
sIsAtLeastJB_MR1 = v >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
sIsAtLeastJB_MR2 = v >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2;
sIsAtLeastKLP = v >= android.os.Build.VERSION_CODES.KITKAT;
sIsAtLeastL = v >= android.os.Build.VERSION_CODES.LOLLIPOP;
sIsAtLeastL_MR1 = v >= android.os.Build.VERSION_CODES.LOLLIPOP_MR1;
sIsAtLeastM = v >= android.os.Build.VERSION_CODES.M;
sIsAtLeastN = BuildCompat.isAtLeastN();
}
/**
* @return True if the version of Android that we're running on is at least Ice Cream Sandwich
* MR1 (API level 15).
*/
public static boolean isAtLeastICS_MR1() {
return sIsAtLeastICS_MR1;
}
/**
* @return True if the version of Android that we're running on is at least Jelly Bean
* (API level 16).
*/
public static boolean isAtLeastJB() {
return sIsAtLeastJB;
}
/**
* @return True if the version of Android that we're running on is at least Jelly Bean MR1
* (API level 17).
*/
public static boolean isAtLeastJB_MR1() {
return sIsAtLeastJB_MR1;
}
/**
* @return True if the version of Android that we're running on is at least Jelly Bean MR2
* (API level 18).
*/
public static boolean isAtLeastJB_MR2() {
return sIsAtLeastJB_MR2;
}
/**
* @return True if the version of Android that we're running on is at least KLP
* (API level 19).
*/
public static boolean isAtLeastKLP() {
return sIsAtLeastKLP;
}
/**
* @return True if the version of Android that we're running on is at least L
* (API level 21).
*/
public static boolean isAtLeastL() {
return sIsAtLeastL;
}
/**
* @return True if the version of Android that we're running on is at least L MR1
* (API level 22).
*/
public static boolean isAtLeastL_MR1() {
return sIsAtLeastL_MR1;
}
/**
* @return True if the version of Android that we're running on is at least M
* (API level 23).
*/
public static boolean isAtLeastM() {
return sIsAtLeastM;
}
/**
* @return True if the version of Android that we're running on is at least N
* (API level 24).
*/
public static boolean isAtLeastN() {
return sIsAtLeastN;
}
/**
* @return The Android API version of the OS that we're currently running on.
*/
public static int getApiVersion() {
return android.os.Build.VERSION.SDK_INT;
}
public static boolean isSecondaryUser() { public static boolean isSecondaryUser() {
if (sIsSecondaryUser == null) { if (sIsSecondaryUser == null) {
final Context context = Factory.get().getApplicationContext(); final Context context = Factory.get().getApplicationContext();
boolean isSecondaryUser = false; boolean isSecondaryUser = false;
// Only check for newer devices (but not the nexus 10)
if (OsUtil.sIsAtLeastJB_MR1 && !"Nexus 10".equals(Build.MODEL)) {
final UserHandle uh = android.os.Process.myUserHandle(); final UserHandle uh = android.os.Process.myUserHandle();
final UserManager userManager = final UserManager userManager =
(UserManager) context.getSystemService(Context.USER_SERVICE); (UserManager) context.getSystemService(Context.USER_SERVICE);
@@ -152,7 +47,6 @@ public class OsUtil {
final long userSerialNumber = userManager.getSerialNumberForUser(uh); final long userSerialNumber = userManager.getSerialNumberForUser(uh);
isSecondaryUser = (0 != userSerialNumber); isSecondaryUser = (0 != userSerialNumber);
} }
}
sIsSecondaryUser = isSecondaryUser; sIsSecondaryUser = isSecondaryUser;
} }
return sIsSecondaryUser; return sIsSecondaryUser;
@@ -192,7 +86,6 @@ public class OsUtil {
* @param permission A permission from {@link android.Manifest.permission} * @param permission A permission from {@link android.Manifest.permission}
*/ */
public static boolean hasPermission(final String permission) { public static boolean hasPermission(final String permission) {
if (OsUtil.isAtLeastM()) {
// It is safe to cache the PERMISSION_GRANTED result as the process gets killed if the // It is safe to cache the PERMISSION_GRANTED result as the process gets killed if the
// user revokes the permission setting. However, PERMISSION_DENIED should not be // user revokes the permission setting. However, PERMISSION_DENIED should not be
// cached as the process does not get killed if the user enables the permission setting. // cached as the process does not get killed if the user enables the permission setting.
@@ -203,9 +96,6 @@ public class OsUtil {
sPermissions.put(permission, permissionState); sPermissions.put(permission, permissionState);
} }
return sPermissions.get(permission) == PackageManager.PERMISSION_GRANTED; return sPermissions.get(permission) == PackageManager.PERMISSION_GRANTED;
} else {
return true;
}
} }
/** Does the app have all the specified permissions */ /** Does the app have all the specified permissions */
+206 -470
View File
@@ -17,14 +17,13 @@
package com.android.messaging.util; package com.android.messaging.util;
import android.app.role.RoleManager; import android.app.role.RoleManager;
import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.PackageManager.ApplicationInfoFlags;
import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManager.NameNotFoundException;
import android.database.Cursor; import android.database.Cursor;
import android.net.ConnectivityManager;
import android.provider.Settings; import android.provider.Settings;
import android.provider.Telephony; import android.provider.Telephony;
import android.telephony.PhoneNumberUtils; import android.telephony.PhoneNumberUtils;
@@ -35,7 +34,6 @@ import android.telephony.TelephonyManager;
import android.text.TextUtils; import android.text.TextUtils;
import androidx.collection.ArrayMap; import androidx.collection.ArrayMap;
import androidx.core.os.BuildCompat;
import com.android.messaging.Factory; import com.android.messaging.Factory;
import com.android.messaging.R; import com.android.messaging.R;
@@ -64,7 +62,7 @@ import java.util.Locale;
* *
* A convenient getDefault() method is provided for default subId (-1) on any platform * A convenient getDefault() method is provided for default subId (-1) on any platform
*/ */
public abstract class PhoneUtils { public class PhoneUtils {
private static final String TAG = LogUtil.BUGLE_TAG; private static final String TAG = LogUtil.BUGLE_TAG;
private static final int MINIMUM_PHONE_NUMBER_LENGTH_TO_FORMAT = 6; private static final int MINIMUM_PHONE_NUMBER_LENGTH_TO_FORMAT = 6;
@@ -79,6 +77,7 @@ public abstract class PhoneUtils {
protected final Context mContext; protected final Context mContext;
protected final TelephonyManager mTelephonyManager; protected final TelephonyManager mTelephonyManager;
private final SubscriptionManager mSubscriptionManager;
protected final int mSubId; protected final int mSubId;
public PhoneUtils(int subId) { public PhoneUtils(int subId) {
@@ -86,6 +85,7 @@ public abstract class PhoneUtils {
mContext = Factory.get().getApplicationContext(); mContext = Factory.get().getApplicationContext();
mTelephonyManager = mTelephonyManager =
(TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
mSubscriptionManager = SubscriptionManager.from(Factory.get().getApplicationContext());
} }
/** /**
@@ -93,336 +93,6 @@ public abstract class PhoneUtils {
* *
* @return the country code on the SIM * @return the country code on the SIM
*/ */
public abstract String getSimCountry();
/**
* Get number of SIM slots
*
* @return the SIM slot count
*/
public abstract int getSimSlotCount();
/**
* Get SIM's carrier name
*
* @return the carrier name of the SIM
*/
public abstract String getCarrierName();
/**
* Check if there is SIM inserted on the device
*
* @return true if there is SIM inserted, false otherwise
*/
public abstract boolean hasSim();
/**
* Check if the SIM is roaming
*
* @return true if the SIM is in romaing state, false otherwise
*/
public abstract boolean isRoaming();
/**
* Get the MCC and MNC in integer of the SIM's provider
*
* @return an array of two ints, [0] is the MCC code and [1] is the MNC code
*/
public abstract int[] getMccMnc();
/**
* Get the mcc/mnc string
*
* @return the text of mccmnc string
*/
public abstract String getSimOperatorNumeric();
/**
* Get the SIM's self raw number, i.e. not canonicalized
*
* @param allowOverride Whether to use the app's setting to override the self number
* @return the original self number
* @throws IllegalStateException if no active subscription on L-MR1+
*/
public abstract String getSelfRawNumber(final boolean allowOverride);
/**
* Returns the "effective" subId, or the subId used in the context of actual messages,
* conversations and subscription-specific settings, for the given "nominal" sub id.
*
* For pre-L-MR1 platform, this should always be
* {@value com.android.messaging.datamodel.data.ParticipantData#DEFAULT_SELF_SUB_ID};
*
* On the other hand, for L-MR1 and above, DEFAULT_SELF_SUB_ID will be mapped to the system
* default subscription id for SMS.
*
* @param subId The input subId
* @return the real subId if we can convert
*/
public abstract int getEffectiveSubId(int subId);
/**
* Returns the number of active subscriptions in the device.
*/
public abstract int getActiveSubscriptionCount();
/**
* Get {@link SmsManager} instance
*
* @return the relevant SmsManager instance based on OS version and subId
*/
public abstract SmsManager getSmsManager();
/**
* Get the default SMS subscription id
*
* @return the default sub ID
*/
public abstract int getDefaultSmsSubscriptionId();
/**
* Returns if there's currently a system default SIM selected for sending SMS.
*/
public abstract boolean getHasPreferredSmsSim();
/**
* For L_MR1, system may return a negative subId. Convert this into our own
* subId, so that we consistently use -1 for invalid or default.
*
* see b/18629526 and b/18670346
*
* @param intent The push intent from system
* @param extraName The name of the sub id extra
* @return the subId that is valid and meaningful for the app
*/
public abstract int getEffectiveIncomingSubIdFromSystem(Intent intent, String extraName);
/**
* Get the subscription_id column value from a telephony provider cursor
*
* @param cursor The database query cursor
* @param subIdIndex The index of the subId column in the cursor
* @return the subscription_id column value from the cursor
*/
public abstract int getSubIdFromTelephony(Cursor cursor, int subIdIndex);
/**
* Check if data roaming is enabled
*
* @return true if data roaming is enabled, false otherwise
*/
public abstract boolean isDataRoamingEnabled();
/**
* Check if mobile data is enabled
*
* @return true if mobile data is enabled, false otherwise
*/
public abstract boolean isMobileDataEnabled();
/**
* Get the set of self phone numbers, all normalized
*
* @return the set of normalized self phone numbers
*/
public abstract HashSet<String> getNormalizedSelfNumbers();
/**
* This interface packages methods should only compile on L_MR1.
* This is needed to make unit tests happy when mockito tries to
* mock these methods. Calling on these methods on L_MR1 requires
* an extra invocation of toMr1().
*/
public interface LMr1 {
/**
* Get this SIM's information. Only applies to L_MR1 above
*
* @return the subscription info of the SIM
*/
public abstract SubscriptionInfo getActiveSubscriptionInfo();
/**
* Get the list of active SIMs in system. Only applies to L_MR1 above
*
* @return the list of subscription info for all inserted SIMs
*/
public abstract List<SubscriptionInfo> getActiveSubscriptionInfoList();
/**
* Register subscription change listener. Only applies to L_MR1 above
*
* @param listener The listener to register
*/
public abstract void registerOnSubscriptionsChangedListener(
SubscriptionManager.OnSubscriptionsChangedListener listener);
}
/**
* The PhoneUtils class for pre L_MR1
*/
public static class PhoneUtilsPreLMR1 extends PhoneUtils {
private final ConnectivityManager mConnectivityManager;
public PhoneUtilsPreLMR1() {
super(ParticipantData.DEFAULT_SELF_SUB_ID);
mConnectivityManager =
(ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
}
@Override
public String getSimCountry() {
final String country = mTelephonyManager.getSimCountryIso();
if (TextUtils.isEmpty(country)) {
return null;
}
return country.toUpperCase();
}
@Override
public int getSimSlotCount() {
// Don't support MSIM pre-L_MR1
return 1;
}
@Override
public String getCarrierName() {
return mTelephonyManager.getNetworkOperatorName();
}
@Override
public boolean hasSim() {
return mTelephonyManager.getSimState() != TelephonyManager.SIM_STATE_ABSENT;
}
@Override
public boolean isRoaming() {
return mTelephonyManager.isNetworkRoaming();
}
@Override
public int[] getMccMnc() {
final String mccmnc = mTelephonyManager.getSimOperator();
int mcc = 0;
int mnc = 0;
try {
mcc = Integer.parseInt(mccmnc.substring(0, 3));
mnc = Integer.parseInt(mccmnc.substring(3));
} catch (Exception e) {
LogUtil.w(TAG, "PhoneUtils.getMccMnc: invalid string " + mccmnc, e);
}
return new int[]{mcc, mnc};
}
@Override
public String getSimOperatorNumeric() {
return mTelephonyManager.getSimOperator();
}
@Override
public String getSelfRawNumber(final boolean allowOverride) {
if (allowOverride) {
final String userDefinedNumber = getNumberFromPrefs(mContext,
ParticipantData.DEFAULT_SELF_SUB_ID);
if (!TextUtils.isEmpty(userDefinedNumber)) {
return userDefinedNumber;
}
}
return mTelephonyManager.getLine1Number();
}
@Override
public int getEffectiveSubId(int subId) {
Assert.equals(ParticipantData.DEFAULT_SELF_SUB_ID, subId);
return ParticipantData.DEFAULT_SELF_SUB_ID;
}
@Override
public SmsManager getSmsManager() {
return SmsManager.getDefault();
}
@Override
public int getDefaultSmsSubscriptionId() {
Assert.fail("PhoneUtils.getDefaultSmsSubscriptionId(): not supported before L MR1");
return ParticipantData.DEFAULT_SELF_SUB_ID;
}
@Override
public boolean getHasPreferredSmsSim() {
// SIM selection is not supported pre-L_MR1.
return true;
}
@Override
public int getActiveSubscriptionCount() {
return hasSim() ? 1 : 0;
}
@Override
public int getEffectiveIncomingSubIdFromSystem(Intent intent, String extraName) {
// Pre-L_MR1 always returns the default id
return ParticipantData.DEFAULT_SELF_SUB_ID;
}
@Override
public int getSubIdFromTelephony(Cursor cursor, int subIdIndex) {
// No subscription_id column before L_MR1
return ParticipantData.DEFAULT_SELF_SUB_ID;
}
@Override
@SuppressWarnings("deprecation")
public boolean isDataRoamingEnabled() {
if (BuildCompat.isAtLeastT()) {
return mTelephonyManager.isDataRoamingEnabled();
}
boolean dataRoamingEnabled = false;
final ContentResolver cr = mContext.getContentResolver();
if (OsUtil.isAtLeastJB_MR1()) {
dataRoamingEnabled =
(Settings.Global.getInt(cr, Settings.Global.DATA_ROAMING, 0) != 0);
} else {
dataRoamingEnabled =
(Settings.System.getInt(cr, Settings.System.DATA_ROAMING, 0) != 0);
}
return dataRoamingEnabled;
}
@Override
public boolean isMobileDataEnabled() {
boolean mobileDataEnabled = false;
try {
final Class cmClass = mConnectivityManager.getClass();
final Method method = cmClass.getDeclaredMethod("getMobileDataEnabled");
method.setAccessible(true); // Make the method callable
// get the setting for "mobile data"
mobileDataEnabled = (Boolean) method.invoke(mConnectivityManager);
} catch (final Exception e) {
LogUtil.e(TAG, "PhoneUtil.isMobileDataEnabled: system api not found", e);
}
return mobileDataEnabled;
}
@Override
public HashSet<String> getNormalizedSelfNumbers() {
final HashSet<String> numbers = new HashSet<>();
numbers.add(getCanonicalForSelf(true/*allowOverride*/));
return numbers;
}
}
/**
* The PhoneUtils class for L_MR1
*/
public static class PhoneUtilsLMR1 extends PhoneUtils implements LMr1 {
private final SubscriptionManager mSubscriptionManager;
public PhoneUtilsLMR1(final int subId) {
super(subId);
mSubscriptionManager = SubscriptionManager.from(Factory.get().getApplicationContext());
}
@Override
public String getSimCountry() { public String getSimCountry() {
final SubscriptionInfo subInfo = getActiveSubscriptionInfo(); final SubscriptionInfo subInfo = getActiveSubscriptionInfo();
if (subInfo != null) { if (subInfo != null) {
@@ -435,12 +105,20 @@ public abstract class PhoneUtils {
return null; return null;
} }
@Override /**
* Get number of SIM slots
*
* @return the SIM slot count
*/
public int getSimSlotCount() { public int getSimSlotCount() {
return mSubscriptionManager.getActiveSubscriptionInfoCountMax(); return mSubscriptionManager.getActiveSubscriptionInfoCountMax();
} }
@Override /**
* Get SIM's carrier name
*
* @return the carrier name of the SIM
*/
public String getCarrierName() { public String getCarrierName() {
final SubscriptionInfo subInfo = getActiveSubscriptionInfo(); final SubscriptionInfo subInfo = getActiveSubscriptionInfo();
if (subInfo != null) { if (subInfo != null) {
@@ -456,17 +134,29 @@ public abstract class PhoneUtils {
return null; return null;
} }
@Override /**
* Check if there is SIM inserted on the device
*
* @return true if there is SIM inserted, false otherwise
*/
public boolean hasSim() { public boolean hasSim() {
return mSubscriptionManager.getActiveSubscriptionInfoCount() > 0; return mSubscriptionManager.getActiveSubscriptionInfoCount() > 0;
} }
@Override /**
* Check if the SIM is roaming
*
* @return true if the SIM is in romaing state, false otherwise
*/
public boolean isRoaming() { public boolean isRoaming() {
return mSubscriptionManager.isNetworkRoaming(mSubId); return mSubscriptionManager.isNetworkRoaming(mSubId);
} }
@Override /**
* Get the MCC and MNC in integer of the SIM's provider
*
* @return an array of two ints, [0] is the MCC code and [1] is the MNC code
*/
public int[] getMccMnc() { public int[] getMccMnc() {
int mcc = 0; int mcc = 0;
int mnc = 0; int mnc = 0;
@@ -478,13 +168,23 @@ public abstract class PhoneUtils {
return new int[]{mcc, mnc}; return new int[]{mcc, mnc};
} }
@Override /**
* Get the mcc/mnc string
*
* @return the text of mccmnc string
*/
public String getSimOperatorNumeric() { public String getSimOperatorNumeric() {
// For L_MR1 we return the canonicalized (xxxxxx) string // For L_MR1 we return the canonicalized (xxxxxx) string
return getMccMncString(getMccMnc()); return getMccMncString(getMccMnc());
} }
@Override /**
* Get the SIM's self raw number, i.e. not canonicalized
*
* @param allowOverride Whether to use the app's setting to override the self number
* @return the original self number
* @throws IllegalStateException if no active subscription on L-MR1+
*/
public String getSelfRawNumber(final boolean allowOverride) { public String getSelfRawNumber(final boolean allowOverride) {
if (allowOverride) { if (allowOverride) {
final String userDefinedNumber = getNumberFromPrefs(mContext, mSubId); final String userDefinedNumber = getNumberFromPrefs(mContext, mSubId);
@@ -505,7 +205,158 @@ public abstract class PhoneUtils {
throw new IllegalStateException("No active subscription"); throw new IllegalStateException("No active subscription");
} }
@Override /**
* Returns the "effective" subId, or the subId used in the context of actual messages,
* conversations and subscription-specific settings, for the given "nominal" sub id.
*
* For pre-L-MR1 platform, this should always be
* {@value com.android.messaging.datamodel.data.ParticipantData#DEFAULT_SELF_SUB_ID};
*
* On the other hand, for L-MR1 and above, DEFAULT_SELF_SUB_ID will be mapped to the system
* default subscription id for SMS.
*
* @param subId The input subId
* @return the real subId if we can convert
*/
public int getEffectiveSubId(int subId) {
if (subId == ParticipantData.DEFAULT_SELF_SUB_ID) {
return getDefaultSmsSubscriptionId();
}
return subId;
}
/**
* Returns the number of active subscriptions in the device.
*/
public int getActiveSubscriptionCount() {
return mSubscriptionManager.getActiveSubscriptionInfoCount();
}
/**
* Get {@link SmsManager} instance
*
* @return the relevant SmsManager instance based on OS version and subId
*/
public SmsManager getSmsManager() {
return SmsManager.getSmsManagerForSubscriptionId(mSubId);
}
/**
* Get the default SMS subscription id
*
* @return the default sub ID
*/
public int getDefaultSmsSubscriptionId() {
final int systemDefaultSubId = SmsManager.getDefaultSmsSubscriptionId();
if (systemDefaultSubId < 0) {
// Always use -1 for any negative subId from system
return ParticipantData.DEFAULT_SELF_SUB_ID;
}
return systemDefaultSubId;
}
/**
* Returns if there's currently a system default SIM selected for sending SMS.
*/
public boolean getHasPreferredSmsSim() {
return getDefaultSmsSubscriptionId() != ParticipantData.DEFAULT_SELF_SUB_ID;
}
/**
* For L_MR1, system may return a negative subId. Convert this into our own
* subId, so that we consistently use -1 for invalid or default.
*
* see b/18629526 and b/18670346
*
* @param intent The push intent from system
* @param extraName The name of the sub id extra
* @return the subId that is valid and meaningful for the app
*/
public int getEffectiveIncomingSubIdFromSystem(Intent intent, String extraName) {
return getEffectiveIncomingSubIdFromSystem(intent.getIntExtra(extraName,
ParticipantData.DEFAULT_SELF_SUB_ID));
}
private int getEffectiveIncomingSubIdFromSystem(int subId) {
if (subId < 0) {
if (mSubscriptionManager.getActiveSubscriptionInfoCount() > 1) {
// For multi-SIM device, we can not decide which SIM to use if system
// does not know either. So just make it the invalid sub id.
return ParticipantData.DEFAULT_SELF_SUB_ID;
}
// For single-SIM device, it must come from the only SIM we have
return getDefaultSmsSubscriptionId();
}
return subId;
}
/**
* Get the subscription_id column value from a telephony provider cursor
*
* @param cursor The database query cursor
* @param subIdIndex The index of the subId column in the cursor
* @return the subscription_id column value from the cursor
*/
public int getSubIdFromTelephony(Cursor cursor, int subIdIndex) {
return getEffectiveIncomingSubIdFromSystem(cursor.getInt(subIdIndex));
}
/**
* Check if data roaming is enabled
*
* @return true if data roaming is enabled, false otherwise
*/
public boolean isDataRoamingEnabled() {
final SubscriptionInfo subInfo = getActiveSubscriptionInfo();
if (subInfo == null) {
// There is nothing we can do if system give us empty sub info
LogUtil.e(TAG, "PhoneUtils.isDataRoamingEnabled: system return empty sub info for "
+ mSubId);
return false;
}
return subInfo.getDataRoaming() != SubscriptionManager.DATA_ROAMING_DISABLE;
}
/**
* Check if mobile data is enabled
*
* @return true if mobile data is enabled, false otherwise
*/
public boolean isMobileDataEnabled() {
boolean mobileDataEnabled = false;
try {
final Class cmClass = mTelephonyManager.getClass();
final Method method = cmClass.getDeclaredMethod("getDataEnabled", Integer.TYPE);
method.setAccessible(true); // Make the method callable
// get the setting for "mobile data"
mobileDataEnabled = (Boolean) method.invoke(
mTelephonyManager, Integer.valueOf(mSubId));
} catch (final Exception e) {
LogUtil.e(TAG, "PhoneUtil.isMobileDataEnabled: system api not found", e);
}
return mobileDataEnabled;
}
/**
* Get the set of self phone numbers, all normalized
*
* @return the set of normalized self phone numbers
*/
public HashSet<String> getNormalizedSelfNumbers() {
final HashSet<String> numbers = new HashSet<>();
for (SubscriptionInfo info : getActiveSubscriptionInfoList()) {
numbers.add(PhoneUtils.get(info.getSubscriptionId()).getCanonicalForSelf(
true/*allowOverride*/));
}
return numbers;
}
/**
* Get this SIM's information. Only applies to L_MR1 above
*
* @return the subscription info of the SIM
*/
public SubscriptionInfo getActiveSubscriptionInfo() { public SubscriptionInfo getActiveSubscriptionInfo() {
try { try {
final SubscriptionInfo subInfo = final SubscriptionInfo subInfo =
@@ -525,7 +376,11 @@ public abstract class PhoneUtils {
return null; return null;
} }
@Override /**
* Get the list of active SIMs in system. Only applies to L_MR1 above
*
* @return the list of subscription info for all inserted SIMs
*/
public List<SubscriptionInfo> getActiveSubscriptionInfoList() { public List<SubscriptionInfo> getActiveSubscriptionInfoList() {
final List<SubscriptionInfo> subscriptionInfos = final List<SubscriptionInfo> subscriptionInfos =
mSubscriptionManager.getActiveSubscriptionInfoList(); mSubscriptionManager.getActiveSubscriptionInfoList();
@@ -535,109 +390,16 @@ public abstract class PhoneUtils {
return EMPTY_SUBSCRIPTION_LIST; return EMPTY_SUBSCRIPTION_LIST;
} }
@Override /**
public int getEffectiveSubId(int subId) { * Register subscription change listener. Only applies to L_MR1 above
if (subId == ParticipantData.DEFAULT_SELF_SUB_ID) { *
return getDefaultSmsSubscriptionId(); * @param listener The listener to register
} */
return subId;
}
@Override
public void registerOnSubscriptionsChangedListener( public void registerOnSubscriptionsChangedListener(
SubscriptionManager.OnSubscriptionsChangedListener listener) { SubscriptionManager.OnSubscriptionsChangedListener listener) {
mSubscriptionManager.addOnSubscriptionsChangedListener(listener); mSubscriptionManager.addOnSubscriptionsChangedListener(listener);
} }
@Override
public SmsManager getSmsManager() {
return SmsManager.getSmsManagerForSubscriptionId(mSubId);
}
@Override
public int getDefaultSmsSubscriptionId() {
final int systemDefaultSubId = SmsManager.getDefaultSmsSubscriptionId();
if (systemDefaultSubId < 0) {
// Always use -1 for any negative subId from system
return ParticipantData.DEFAULT_SELF_SUB_ID;
}
return systemDefaultSubId;
}
@Override
public boolean getHasPreferredSmsSim() {
return getDefaultSmsSubscriptionId() != ParticipantData.DEFAULT_SELF_SUB_ID;
}
@Override
public int getActiveSubscriptionCount() {
return mSubscriptionManager.getActiveSubscriptionInfoCount();
}
@Override
public int getEffectiveIncomingSubIdFromSystem(Intent intent, String extraName) {
return getEffectiveIncomingSubIdFromSystem(intent.getIntExtra(extraName,
ParticipantData.DEFAULT_SELF_SUB_ID));
}
private int getEffectiveIncomingSubIdFromSystem(int subId) {
if (subId < 0) {
if (mSubscriptionManager.getActiveSubscriptionInfoCount() > 1) {
// For multi-SIM device, we can not decide which SIM to use if system
// does not know either. So just make it the invalid sub id.
return ParticipantData.DEFAULT_SELF_SUB_ID;
}
// For single-SIM device, it must come from the only SIM we have
return getDefaultSmsSubscriptionId();
}
return subId;
}
@Override
public int getSubIdFromTelephony(Cursor cursor, int subIdIndex) {
return getEffectiveIncomingSubIdFromSystem(cursor.getInt(subIdIndex));
}
@Override
public boolean isDataRoamingEnabled() {
final SubscriptionInfo subInfo = getActiveSubscriptionInfo();
if (subInfo == null) {
// There is nothing we can do if system give us empty sub info
LogUtil.e(TAG, "PhoneUtils.isDataRoamingEnabled: system return empty sub info for "
+ mSubId);
return false;
}
return subInfo.getDataRoaming() != SubscriptionManager.DATA_ROAMING_DISABLE;
}
@Override
public boolean isMobileDataEnabled() {
boolean mobileDataEnabled = false;
try {
final Class cmClass = mTelephonyManager.getClass();
final Method method = cmClass.getDeclaredMethod("getDataEnabled", Integer.TYPE);
method.setAccessible(true); // Make the method callable
// get the setting for "mobile data"
mobileDataEnabled = (Boolean) method.invoke(
mTelephonyManager, Integer.valueOf(mSubId));
} catch (final Exception e) {
LogUtil.e(TAG, "PhoneUtil.isMobileDataEnabled: system api not found", e);
}
return mobileDataEnabled;
}
@Override
public HashSet<String> getNormalizedSelfNumbers() {
final HashSet<String> numbers = new HashSet<>();
for (SubscriptionInfo info : getActiveSubscriptionInfoList()) {
numbers.add(PhoneUtils.get(info.getSubscriptionId()).getCanonicalForSelf(
true/*allowOverride*/));
}
return numbers;
}
}
/** /**
* A convenient get() method that uses the default SIM. Use this when SIM is * A convenient get() method that uses the default SIM. Use this when SIM is
* not relevant, e.g. isDefaultSmsApp * not relevant, e.g. isDefaultSmsApp
@@ -659,15 +421,6 @@ public abstract class PhoneUtils {
return Factory.get().getPhoneUtils(subId); return Factory.get().getPhoneUtils(subId);
} }
public LMr1 toLMr1() {
if (OsUtil.isAtLeastL_MR1()) {
return (LMr1) this;
} else {
Assert.fail("PhoneUtils.toLMr1(): invalid OS version");
return null;
}
}
/** /**
* Check if this device supports SMS * Check if this device supports SMS
* *
@@ -897,13 +650,10 @@ public abstract class PhoneUtils {
* - On JB (and below) this always returns true, since the setting was added in KLP. * - On JB (and below) this always returns true, since the setting was added in KLP.
*/ */
public boolean isDefaultSmsApp() { public boolean isDefaultSmsApp() {
if (OsUtil.isAtLeastKLP()) {
RoleManager roleManager = mContext.getSystemService(RoleManager.class); RoleManager roleManager = mContext.getSystemService(RoleManager.class);
return roleManager.isRoleAvailable(RoleManager.ROLE_SMS) return roleManager.isRoleAvailable(RoleManager.ROLE_SMS)
&& roleManager.isRoleHeld(RoleManager.ROLE_SMS); && roleManager.isRoleHeld(RoleManager.ROLE_SMS);
} }
return true;
}
/** /**
* Get default SMS app package name * Get default SMS app package name
@@ -911,11 +661,8 @@ public abstract class PhoneUtils {
* @return the package name of default SMS app * @return the package name of default SMS app
*/ */
public String getDefaultSmsApp() { public String getDefaultSmsApp() {
if (OsUtil.isAtLeastKLP()) {
return Telephony.Sms.getDefaultSmsPackage(mContext); return Telephony.Sms.getDefaultSmsPackage(mContext);
} }
return null;
}
/** /**
* Determines if SMS is currently enabled on this device. * Determines if SMS is currently enabled on this device.
@@ -931,16 +678,15 @@ public abstract class PhoneUtils {
* an error or there is no default app (e.g. JB and below). * an error or there is no default app (e.g. JB and below).
*/ */
public String getDefaultSmsAppLabel() { public String getDefaultSmsAppLabel() {
if (OsUtil.isAtLeastKLP()) {
final String packageName = Telephony.Sms.getDefaultSmsPackage(mContext); final String packageName = Telephony.Sms.getDefaultSmsPackage(mContext);
final PackageManager pm = mContext.getPackageManager(); final PackageManager pm = mContext.getPackageManager();
try { try {
final ApplicationInfo appInfo = pm.getApplicationInfo(packageName, 0); final ApplicationInfo appInfo = pm.getApplicationInfo(packageName,
ApplicationInfoFlags.of(0));
return pm.getApplicationLabel(appInfo).toString(); return pm.getApplicationLabel(appInfo).toString();
} catch (NameNotFoundException e) { } catch (NameNotFoundException e) {
// Fall through and return empty string // Fall through and return empty string
} }
}
return ""; return "";
} }
@@ -949,15 +695,9 @@ public abstract class PhoneUtils {
* *
* @return true if enabled. * @return true if enabled.
*/ */
@SuppressWarnings("deprecation")
public boolean isAirplaneModeOn() { public boolean isAirplaneModeOn() {
if (OsUtil.isAtLeastJB_MR1()) {
return Settings.Global.getInt(mContext.getContentResolver(), return Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.AIRPLANE_MODE_ON, 0) != 0; Settings.Global.AIRPLANE_MODE_ON, 0) != 0;
} else {
return Settings.System.getInt(mContext.getContentResolver(),
Settings.System.AIRPLANE_MODE_ON, 0) != 0;
}
} }
public static String getMccMncString(int[] mccmnc) { public static String getMccMncString(int[] mccmnc) {
@@ -995,15 +735,11 @@ public abstract class PhoneUtils {
* @param runnable a {@link SubscriptionRunnable} for performing work on each subscription. * @param runnable a {@link SubscriptionRunnable} for performing work on each subscription.
*/ */
public static void forEachActiveSubscription(final SubscriptionRunnable runnable) { public static void forEachActiveSubscription(final SubscriptionRunnable runnable) {
if (OsUtil.isAtLeastL_MR1()) {
final List<SubscriptionInfo> subscriptionList = final List<SubscriptionInfo> subscriptionList =
getDefault().toLMr1().getActiveSubscriptionInfoList(); getDefault().getActiveSubscriptionInfoList();
for (final SubscriptionInfo subscriptionInfo : subscriptionList) { for (final SubscriptionInfo subscriptionInfo : subscriptionList) {
runnable.runForSubscription(subscriptionInfo.getSubscriptionId()); runnable.runForSubscription(subscriptionInfo.getSubscriptionId());
} }
} else {
runnable.runForSubscription(ParticipantData.DEFAULT_SELF_SUB_ID);
}
} }
private static String getNumberFromPrefs(final Context context, final int subId) { private static String getNumberFromPrefs(final Context context, final int subId) {
+2 -13
View File
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -16,20 +17,10 @@
package com.android.messaging.util; package com.android.messaging.util;
import android.annotation.TargetApi;
import android.os.Build;
/** /**
* Helper class for systrace (see http://developer.android.com/tools/help/systrace.html).<p> * Helper class for systrace (see http://developer.android.com/tools/help/systrace.html).<p>
* To enable, set log.tag.Bugle_Trace (defined by {@link #TAG} to VERBOSE before * To enable, set log.tag.Bugle_Trace (defined by {@link #TAG} to VERBOSE before
* the process starts.<p> * the process starts.<p>
* Note that this will run only on JBMR2 or later; on earlier platforms or if the log
* tag isn't set, calls to {@link #beginSection(String)} or {@link #endSection()} are no-ops. <p>
* Internally, calls dispatch to either a class that actually does work or a class that doesn't.
* This avoids Dalvik complaining when it loads the class on earlier platforms that the
* opcodes aren't available, and, according to the Dalvik team, using vtable dispatching for
* something like this should be faster than if (OsUtil.isAtLeast...()) on each call.
*/ */
public final class Trace { public final class Trace {
private static final String TAG = "Bugle_Trace"; private static final String TAG = "Bugle_Trace";
@@ -44,8 +35,7 @@ public final class Trace {
static { static {
// Use android.util.Log instead of LogUtil here to avoid pulling in Gservices // Use android.util.Log instead of LogUtil here to avoid pulling in Gservices
// too early in app startup. // too early in app startup.
if (OsUtil.isAtLeastJB_MR2() && if (android.util.Log.isLoggable(TAG, android.util.Log.VERBOSE)) {
android.util.Log.isLoggable(TAG, android.util.Log.VERBOSE)) {
sTrace = new TraceJBMR2(); sTrace = new TraceJBMR2();
} else { } else {
sTrace = new TraceShim(); sTrace = new TraceShim();
@@ -87,7 +77,6 @@ public final class Trace {
/** /**
* Internal class that we use if we really did enable tracing. * Internal class that we use if we really did enable tracing.
*/ */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private static final class TraceJBMR2 extends AbstractTrace { private static final class TraceJBMR2 extends AbstractTrace {
@Override @Override
void beginSection(String sectionName) { void beginSection(String sectionName) {

Some files were not shown because too many files have changed in this diff Show More