Merge tag 'android-14.0.0_r29' into staging/lineage-21.0_merge-android-14.0.0_r29

Android 14.0.0 release 29

# -----BEGIN PGP SIGNATURE-----
#
# iF0EABECAB0WIQRDQNE1cO+UXoOBCWTorT+BmrEOeAUCZeZW4wAKCRDorT+BmrEO
# eAypAJ92YCSA/mNwFDSaKtltXNI8UPV8SQCfSHdsotva2JYIfDFhNmEDmtrdqYY=
# =BWMR
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Mar  5 01:18:59 2024 EET
# gpg:                using DSA key 4340D13570EF945E83810964E8AD3F819AB10E78
# gpg: Good signature from "The Android Open Source Project <initial-contribution@android.com>" [marginal]
# gpg: initial-contribution@android.com: Verified 2353 signatures in the past
#      2 years.  Encrypted 4 messages in the past 2 years.
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 4340 D135 70EF 945E 8381  0964 E8AD 3F81 9AB1 0E78

# By Jake Klinker (2) and others
# Via Automerger Merge Worker (53) and others
* tag 'android-14.0.0_r29':
  Convert the Android.mk of messagingtest to Android.bp
  Fix the syntax issues in fill sms script
  Fix Messaging for use_resource_processor: true
  Add README
  Trim recipient addresses that are unreasonably long.
  Fix exposing private messages files through attachments with a content URI.

Change-Id: Ie09c532b98343cd72eafc8895fb2fd565f3d7bbb
diff --git a/README b/README
new file mode 100644
index 0000000..15142ba
--- /dev/null
+++ b/README
@@ -0,0 +1,2 @@
+This app is not actively supported and the source is only available as a reference. This project will be removed from the source manifest sometime in the future.
+
diff --git a/src/com/android/messaging/ui/contact/ContactRecipientAutoCompleteView.java b/src/com/android/messaging/ui/contact/ContactRecipientAutoCompleteView.java
index 35641b2..17128c1 100644
--- a/src/com/android/messaging/ui/contact/ContactRecipientAutoCompleteView.java
+++ b/src/com/android/messaging/ui/contact/ContactRecipientAutoCompleteView.java
@@ -19,7 +19,6 @@
 import android.database.Cursor;
 import android.graphics.Rect;
 import android.os.AsyncTask;
-import androidx.appcompat.R;
 import android.text.Editable;
 import android.text.TextPaint;
 import android.text.TextWatcher;
@@ -33,6 +32,7 @@
 import com.android.ex.chips.RecipientEditTextView;
 import com.android.ex.chips.RecipientEntry;
 import com.android.ex.chips.recipientchip.DrawableRecipientChip;
+import com.android.messaging.R;
 import com.android.messaging.datamodel.data.ParticipantData;
 import com.android.messaging.util.ContactRecipientEntryUtils;
 import com.android.messaging.util.ContactUtil;
@@ -114,7 +114,7 @@
         setOnFocusListShrinkRecipients(false);
 
         setBackground(context.getResources().getDrawable(
-                R.drawable.abc_textfield_search_default_mtrl_alpha));
+                androidx.appcompat.R.drawable.abc_textfield_search_default_mtrl_alpha));
     }
 
     public void setContactChipsListener(final ContactChipsChangeListener listener) {
diff --git a/tests/Android.bp b/tests/Android.bp
new file mode 100644
index 0000000..d4f964b
--- /dev/null
+++ b/tests/Android.bp
@@ -0,0 +1,41 @@
+//  Copyright (C) 2023 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 {
+    // See: http://go/android-license-faq
+    default_applicable_licenses: [
+        "Android-Apache-2.0",
+    ],
+}
+
+android_test {
+    name: "messagingtests",
+    srcs: ["src/**/*.java"],
+    instrumentation_for: "messaging",
+    optimize: {
+        enabled: false,
+    },
+    sdk_version: "current",
+    test_suites: ["general-tests"],
+    certificate: "platform",
+    static_libs: ["mockito-target"],
+    libs: [
+        "android.test.mock.stubs",
+        "android.test.runner.stubs",
+        "android.test.base.stubs",
+    ],
+    data: [
+        ":messaging",
+    ],
+}
diff --git a/tests/Android.mk b/tests/Android.mk
deleted file mode 100644
index 0c93ea8..0000000
--- a/tests/Android.mk
+++ /dev/null
@@ -1,49 +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.
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-# Only compile source java files in this apk.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := messagingtests
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-
-LOCAL_INSTRUMENTATION_FOR := messaging
-
-LOCAL_PROGUARD_ENABLED := disabled
-
-# Matching ../Android.mk
-LOCAL_SDK_VERSION := current
-
-LOCAL_COMPATIBILITY_SUITE := general-tests
-
-LOCAL_CERTIFICATE := platform
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
-    mockito-target
-
-LOCAL_JAVA_LIBRARIES := \
-    android.test.mock.stubs \
-    android.test.runner.stubs \
-    android.test.base.stubs \
-
-
-include $(BUILD_PACKAGE)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tools/messagegen/fillsms b/tools/messagegen/fillsms
old mode 100755
new mode 100644
index 6903941..dc2e507
--- a/tools/messagegen/fillsms
+++ b/tools/messagegen/fillsms
@@ -100,9 +100,11 @@
 shift
 sql_file=$1
 shift
+echo $image_list_file
 
 dict_lines=`wc -l < $DICT`
 image_files=`wc -l < $image_list_file`
+echo $image_files
 
 if [ $mms_per_thread -gt "0" ]; then
   if [ ! -f $image_list_file ]; then
@@ -123,7 +125,7 @@
 
 dict_word ()
 {
-  local v=$(random_value 30000)
+  local v=$(random_value $dict_lines)
   sed $v"q;d" $DICT
 }
 
@@ -156,6 +158,11 @@
   adb shell sqlite3 data/data/com.android.providers.telephony/databases/mmssms.db "$1"
 }
 
+adb_sql_with_quotes ()
+{
+  echo $1
+  adb shell "sqlite3 data/data/com.android.providers.telephony/databases/mmssms.db \"$1\""
+}
 ######################################################################################
 ######################################################################################
 
@@ -163,6 +170,7 @@
   # clean up sql file
   rm -f $sql_file
 
+  add_sql "PRAGMA trusted_schema=1;"
   # add sql to clean up database
   add_sql "delete from pdu where _id>=$TABLE_SMS_START_ID;"
   add_sql "delete from part where _id>=$TABLE_SMS_START_ID;"
@@ -197,6 +205,7 @@
 
     # Generate SMS
     if [ $sms_per_thread -gt "0" ]; then
+      add_sql "PRAGMA trusted_schema=1;"
       half_timestamp_inc=$(( 500 + ((($sms_per_thread + $mms_per_thread) * $TIMESTAMP_INC_IN_SECONDS) * 500 / $sms_per_thread) ))
       for j in `seq 1 $sms_per_thread`;
       do
@@ -268,20 +277,22 @@
   echo
   adb_sql ".read /data/fillsms"
   echo
-  adb_sql "select count(*) from canonical_addresses where _id>=$TABLE_CANONICAL_ADDRESSES_START_ID;"
+  add_sql "PRAGMA trusted_schema=1;"
   echo
-  adb_sql "select count(*) from threads where _id>=$TABLE_THREADS_START_ID;"
+  adb_sql_with_quotes "select count(*) from canonical_addresses where _id>=$TABLE_CANONICAL_ADDRESSES_START_ID;"
+  echo
+  adb_sql_with_quotes "select count(*) from threads where _id>=$TABLE_THREADS_START_ID;"
   echo
   if [ $sms_per_thread -gt "0" ]; then
-    adb_sql "select count(*) from sms where _id>=$TABLE_SMS_START_ID;"
+    adb_sql_with_quotes "select count(*) from sms where _id>=$TABLE_SMS_START_ID;"
     echo
   fi
   if [ $mms_per_thread -gt "0" ]; then
-    adb_sql "select count(*) from pdu where _id>=$TABLE_SMS_START_ID;"
+    adb_sql_with_quotes "select count(*) from pdu where _id>=$TABLE_SMS_START_ID;"
     echo
-    adb_sql "select count(*) from part where _id>=$TABLE_SMS_START_ID;"
+    adb_sql_with_quotes "select count(*) from part where _id>=$TABLE_SMS_START_ID;"
     echo
-    adb_sql "select count(*) from addr where _id>=$TABLE_SMS_START_ID;"
+    adb_sql_with_quotes "select count(*) from addr where _id>=$TABLE_SMS_START_ID;"
     echo
   fi
 fi