aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-02-03 01:36:45 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-02-03 01:36:45 +0000
commit86e347658bd2f381e9265721b1fb1bc5a40a95ea (patch)
tree6252944e81370cde9f554736f5bcefe3e12bd689
parent9eb2cbc83fa88847a737beb48a0a867421f927c5 (diff)
parent17e114d01ac0cec2ee91b3f163415c08474a5d0a (diff)
downloadContactsProvider-simpleperf-release.tar.gz
Merge "Snap for 11400057 from a3c215a1e51bcee7087d5e676fdeaafc2ad96328 to simpleperf-release" into simpleperf-releasesimpleperf-release
-rw-r--r--res/values-et/strings.xml2
-rw-r--r--res/values-ne/strings.xml4
-rw-r--r--src/com/android/providers/contacts/CallLogProvider.java45
-rw-r--r--src/com/android/providers/contacts/ContactsProvider2.java28
-rw-r--r--src/com/android/providers/contacts/PhoneLookupWithStarPrefix.java26
5 files changed, 75 insertions, 30 deletions
diff --git a/res/values-et/strings.xml b/res/values-et/strings.xml
index bcaedf7a..d5dbf950 100644
--- a/res/values-et/strings.xml
+++ b/res/values-et/strings.xml
@@ -19,7 +19,7 @@
<string name="sharedUserLabel" msgid="8024311725474286801">"Androidi tuumrakendused"</string>
<string name="app_label" msgid="3389954322874982620">"Kontaktiruum"</string>
<string name="provider_label" msgid="6012150850819899907">"Kontaktid"</string>
- <string name="upgrade_out_of_memory_notification_ticker" msgid="7638747231223520477">"Kontaktisikute uuendamiseks on vaja rohkem mäluruumi."</string>
+ <string name="upgrade_out_of_memory_notification_ticker" msgid="7638747231223520477">"Kontaktisikute uuendamiseks on vaja rohkem mälu"</string>
<string name="upgrade_out_of_memory_notification_title" msgid="8888171924684998531">"Kontaktide salvestusruumi uuendamine"</string>
<string name="upgrade_out_of_memory_notification_text" msgid="2581831842693151968">"Puudutage täiendamise lõpetamiseks."</string>
<string name="default_directory" msgid="93961630309570294">"Kontaktid"</string>
diff --git a/res/values-ne/strings.xml b/res/values-ne/strings.xml
index 4fd36c1c..fd716daf 100644
--- a/res/values-ne/strings.xml
+++ b/res/values-ne/strings.xml
@@ -18,11 +18,11 @@
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="sharedUserLabel" msgid="8024311725474286801">"एन्ड्रोइड कोर एपहरू"</string>
<string name="app_label" msgid="3389954322874982620">"सम्पर्कहरू भण्डारण"</string>
- <string name="provider_label" msgid="6012150850819899907">"कन्ट्याक्टहरू"</string>
+ <string name="provider_label" msgid="6012150850819899907">"सम्पर्कहरू"</string>
<string name="upgrade_out_of_memory_notification_ticker" msgid="7638747231223520477">"सम्पर्क अद्यावधिकका लागि अझै धेरै मेमोरी चाहिन्छ।"</string>
<string name="upgrade_out_of_memory_notification_title" msgid="8888171924684998531">"सम्पर्कका लागि भणडारण अद्यावधिक गर्दै"</string>
<string name="upgrade_out_of_memory_notification_text" msgid="2581831842693151968">"स्तरवृद्धि पूरा गर्न ट्याप गर्नुहोस्।"</string>
- <string name="default_directory" msgid="93961630309570294">"कन्ट्याक्टहरू"</string>
+ <string name="default_directory" msgid="93961630309570294">"सम्पर्कहरू"</string>
<string name="local_invisible_directory" msgid="705244318477396120">"अन्य"</string>
<string name="voicemail_from_column" msgid="435732568832121444">"बाट भ्वाइसमेल "</string>
<string name="debug_dump_title" msgid="4916885724165570279">"सम्पर्क डेटाबेस प्रतिलिप गर्नुहोस्"</string>
diff --git a/src/com/android/providers/contacts/CallLogProvider.java b/src/com/android/providers/contacts/CallLogProvider.java
index da2d0b8a..01f3d577 100644
--- a/src/com/android/providers/contacts/CallLogProvider.java
+++ b/src/com/android/providers/contacts/CallLogProvider.java
@@ -60,6 +60,7 @@ import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.EventLog;
+import android.util.LocalLog;
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
@@ -314,6 +315,7 @@ public class CallLogProvider extends ContentProvider {
private VoicemailPermissions mVoicemailPermissions;
private CallLogInsertionHelper mCallLogInsertionHelper;
private SubscriptionManager mSubscriptionManager;
+ private LocalLog mLocalLog = new LocalLog(20);
private final ThreadLocal<Boolean> mApplyingBatch = new ThreadLocal<>();
private final ThreadLocal<Integer> mCallingUid = new ThreadLocal<>();
@@ -681,7 +683,7 @@ public class CallLogProvider extends ContentProvider {
final int callingUid =
applyingBatch() ? mCallingUid.get() : Binder.getCallingUid();
- mStats.incrementInsertStats(callingUid, applyingBatch());
+ mStats.incrementUpdateStats(callingUid, applyingBatch());
try {
return updateInternal(uri, values, selection, selectionArgs);
} finally {
@@ -694,7 +696,7 @@ public class CallLogProvider extends ContentProvider {
final int callingUid =
applyingBatch() ? mCallingUid.get() : Binder.getCallingUid();
- mStats.incrementInsertStats(callingUid, applyingBatch());
+ mStats.incrementDeleteStats(callingUid, applyingBatch());
try {
return deleteInternal(uri, selection, selectionArgs);
} finally {
@@ -751,6 +753,11 @@ public class CallLogProvider extends ContentProvider {
mCallLogInsertionHelper.addComputedValues(copiedValues);
long rowId = createDatabaseModifier(mCallsInserter).insert(copiedValues);
+ String insertLog = String.format(Locale.getDefault(),
+ "insert uid/pid=%d/%d, uri=%s, rowId=%d",
+ Binder.getCallingUid(), Binder.getCallingPid(), uri, rowId);
+ Log.i(TAG, insertLog);
+ mLocalLog.log(insertLog);
if (rowId > 0) {
return ContentUris.withAppendedId(uri, rowId);
}
@@ -959,8 +966,16 @@ public class CallLogProvider extends ContentProvider {
throw new UnsupportedOperationException("Cannot update URL: " + uri);
}
- return createDatabaseModifier(db, hasReadVoicemailPermission).update(uri, Tables.CALLS,
+ int count = createDatabaseModifier(db, hasReadVoicemailPermission).update(uri, Tables.CALLS,
values, selectionBuilder.build(), selectionArgs);
+
+ String logStr = String.format(Locale. getDefault(),
+ "update uid/pid=%d/%d, uri=%s, numChanged=%d",
+ Binder.getCallingUid(), Binder.getCallingPid(), uri, count);
+ Log.i(TAG, logStr);
+ mLocalLog.log(logStr);
+
+ return count;
}
private int deleteInternal(Uri uri, String selection, String[] selectionArgs) {
@@ -981,8 +996,14 @@ public class CallLogProvider extends ContentProvider {
final int matchedUriId = sURIMatcher.match(uri);
switch (matchedUriId) {
case CALLS:
- return createDatabaseModifier(db, hasReadVoicemailPermission).delete(Tables.CALLS,
- selectionBuilder.build(), selectionArgs);
+ int count = createDatabaseModifier(db, hasReadVoicemailPermission).delete(
+ Tables.CALLS, selectionBuilder.build(), selectionArgs);
+ String logStr = String.format(Locale. getDefault(),
+ "delete uid/pid=%d/%d, uri=%s, numChanged=%d",
+ Binder.getCallingUid(), Binder.getCallingPid(), uri, count);
+ Log.i(TAG, logStr);
+ mLocalLog.log(logStr);
+ return count;
case CALL_COMPOSER_PICTURE:
// TODO(hallliu): implement deletion of file when the corresponding calllog entry
// gets deleted as well.
@@ -1127,10 +1148,21 @@ public class CallLogProvider extends ContentProvider {
new String[] {String.valueOf(lastSyncTime)},
Calls.DATE + " ASC");
if (cursor == null) {
+ Log.i(TAG, String.format(Locale.getDefault(),
+ "syncEntriesFrom: fromUserId=%d, srcIsShadow=%b, forAllUsers=%b; nothing to "
+ + "sync",
+ sourceUserId, sourceIsShadow, forAllUsersOnly));
return;
}
try {
newestTimeStamp = copyEntriesFromCursor(cursor, lastSyncTime, sourceIsShadow);
+ Log.i(TAG,
+ String.format(Locale.getDefault(),
+ "syncEntriesFrom: fromUserId=%d, srcIsShadow=%b, forAllUsers=%b; "
+ + "previousTimeStamp=%d, newTimeStamp=%d, entries=%d",
+ sourceUserId, sourceIsShadow, forAllUsersOnly, lastSyncTime,
+ newestTimeStamp,
+ cursor.getCount()));
} finally {
cursor.close();
}
@@ -1376,6 +1408,9 @@ public class CallLogProvider extends ContentProvider {
@Override
public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
mStats.dump(writer, " ");
+ writer.println();
+ writer.println("Latest call log activity:");
+ mLocalLog.dump(writer);
}
/**
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java
index 56162916..7b6dce38 100644
--- a/src/com/android/providers/contacts/ContactsProvider2.java
+++ b/src/com/android/providers/contacts/ContactsProvider2.java
@@ -2663,6 +2663,7 @@ public class ContactsProvider2 extends AbstractContactsProvider
final long now = Clock.getInstance().currentTimeMillis();
final SQLiteDatabase db = mDbHelper.get().getWritableDatabase();
db.beginTransactionNonExclusive();
+ Cursor cursor = null;
try {
// First delete any pre-authorization URIs that are no longer valid. Unfortunately,
// this operation will grab a write lock for readonly queries. Since this only
@@ -2672,15 +2673,16 @@ public class ContactsProvider2 extends AbstractContactsProvider
new String[]{String.valueOf(now)});
// Now check to see if the pre-authorized URI map contains the URI.
- final Cursor c = db.query(Tables.PRE_AUTHORIZED_URIS, null,
+ cursor = db.query(Tables.PRE_AUTHORIZED_URIS, null,
PreAuthorizedUris.URI + "=?1",
new String[]{uri.toString()}, null, null, null);
- final boolean isValid = c.getCount() != 0;
+ final boolean isValid = cursor.getCount() != 0;
db.setTransactionSuccessful();
return isValid;
} finally {
db.endTransaction();
+ MoreCloseables.closeQuietly(cursor);
}
}
return false;
@@ -7256,7 +7258,7 @@ public class ContactsProvider2 extends AbstractContactsProvider
} finally {
if (!foundResult) {
// We'll be returning a different cursor, so close this one.
- cursor.close();
+ MoreCloseables.closeQuietly(cursor);
}
}
}
@@ -7448,11 +7450,16 @@ public class ContactsProvider2 extends AbstractContactsProvider
// This method will return either primary directory or enterprise directory
final long inputDirectoryId = ContentUris.parseId(uri);
if (Directory.isEnterpriseDirectoryId(inputDirectoryId)) {
- final Cursor cursor = queryCorpContactsProvider(
- ContentUris.withAppendedId(Directory.CONTENT_URI,
- inputDirectoryId - Directory.ENTERPRISE_DIRECTORY_ID_BASE),
- projection, selection, selectionArgs, sortOrder, cancellationSignal);
- return rewriteCorpDirectories(cursor);
+ Cursor cursor = null;
+ try {
+ cursor = queryCorpContactsProvider(
+ ContentUris.withAppendedId(Directory.CONTENT_URI,
+ inputDirectoryId - Directory.ENTERPRISE_DIRECTORY_ID_BASE),
+ projection, selection, selectionArgs, sortOrder, cancellationSignal);
+ return rewriteCorpDirectories(cursor);
+ } finally {
+ MoreCloseables.closeQuietly(cursor);
+ }
} else {
// As it is not an enterprise directory id, fall back to original API
final Uri localUri = ContentUris.withAppendedId(Directory.CONTENT_URI,
@@ -7947,11 +7954,10 @@ public class ContactsProvider2 extends AbstractContactsProvider
lookupQb.appendWhere(contactIdColumn + "=? AND " + lookupKeyColumn + "=?");
Cursor c = doQuery(db, lookupQb, projection, selection, args, sortOrder,
groupBy, null, limit, cancellationSignal);
- if (c.getCount() != 0) {
+ if (c != null && c.getCount() != 0) {
return c;
}
-
- c.close();
+ MoreCloseables.closeQuietly(c);
return null;
}
diff --git a/src/com/android/providers/contacts/PhoneLookupWithStarPrefix.java b/src/com/android/providers/contacts/PhoneLookupWithStarPrefix.java
index ca29edc6..59e213bb 100644
--- a/src/com/android/providers/contacts/PhoneLookupWithStarPrefix.java
+++ b/src/com/android/providers/contacts/PhoneLookupWithStarPrefix.java
@@ -154,7 +154,7 @@ import android.util.Log;
* Check each phone number in the given cursor to detemine if it's a match with the given phone
* number. Return the matching ones in a new cursor.
* @param number phone number to be match
- * @param cursor contains a series of number s to be match
+ * @param cursor contains a series of numbers to be matched
* @param defaultCountryIso The lowercase two letter ISO 3166-1 country code. It is recommended
* to pass in {@link TelephonyManager#getNetworkCountryIso()}.
* @return A new cursor with all matching phone numbers.
@@ -166,19 +166,23 @@ import android.util.Log;
}
final MatrixCursor matrixCursor = new MatrixCursor(cursor.getColumnNames());
-
- cursor.moveToPosition(-1);
- while (cursor.moveToNext()) {
- final int numberIndex = cursor.getColumnIndex(PhoneLookup.NUMBER);
- final String numberToMatch = cursor.getString(numberIndex);
- if (PhoneNumberUtils.areSamePhoneNumber(number, numberToMatch, defaultCountryIso)) {
- final MatrixCursor.RowBuilder b = matrixCursor.newRow();
- for (int column = 0; column < cursor.getColumnCount(); column++) {
- b.add(cursor.getColumnName(column), cursorValue(cursor, column));
+ try {
+ cursor.moveToPosition(-1);
+ while (cursor.moveToNext()) {
+ final int numberIndex = cursor.getColumnIndex(PhoneLookup.NUMBER);
+ final String numberToMatch = cursor.getString(numberIndex);
+ if (PhoneNumberUtils.areSamePhoneNumber(number, numberToMatch, defaultCountryIso)) {
+ final MatrixCursor.RowBuilder b = matrixCursor.newRow();
+ for (int column = 0; column < cursor.getColumnCount(); column++) {
+ b.add(cursor.getColumnName(column), cursorValue(cursor, column));
+ }
}
}
+ } finally {
+ if (cursor != null) {
+ cursor.close();
+ }
}
-
return matrixCursor;
}
}