Loading src/com/android/server/telecom/CallLogManager.java +19 −18 Original line number Diff line number Diff line Loading @@ -77,18 +77,18 @@ public final class CallLogManager extends CallsManagerListenerBase { private static class AddCallArgs { public AddCallArgs(Context context, CallLog.AddCallParams params, @Nullable LogCallCompletedListener logCallCompletedListener, @NonNull String callId) { @NonNull Call call) { this.context = context; this.params = params; this.logCallCompletedListener = logCallCompletedListener; this.callId = callId; this.call = call; } // Since the members are accessed directly, we don't use the // mXxxx notation. public final Context context; public final CallLog.AddCallParams params; public final String callId; public final Call call; @Nullable public final LogCallCompletedListener logCallCompletedListener; } Loading @@ -100,9 +100,9 @@ public final class CallLogManager extends CallsManagerListenerBase { // a conference was merged successfully private static final String REASON_IMS_MERGED_SUCCESSFULLY = "IMS_MERGED_SUCCESSFULLY"; private static final UUID LOG_CALL_FAILED_ANOMALY_ID = UUID.fromString("1c4c15f3-ab4f-459c-b9ef-43d2988bae82"); UUID.fromString("d9b38771-ff36-417b-8723-2363a870c702"); private static final String LOG_CALL_FAILED_ANOMALY_DESC = "Failed to record a call to the call log."; "Based on the current user, Telecom detected failure to record a call to the call log."; private final Context mContext; private final CarrierConfigManager mCarrierConfigManager; Loading Loading @@ -408,7 +408,7 @@ public final class CallLogManager extends CallsManagerListenerBase { okayToLogCall(accountHandle, logNumber, call.isEmergencyCall()); if (okayToLog) { AddCallArgs args = new AddCallArgs(mContext, paramBuilder.build(), logCallCompletedListener, call.getId()); logCallCompletedListener, call); Log.addEvent(call, LogUtils.Events.LOG_CALL, "number=" + Log.piiHandle(logNumber) + ",postDial=" + Log.piiHandle(call.getPostDialDigits()) + ",pres=" + call.getHandlePresentation()); Loading Loading @@ -539,18 +539,16 @@ public final class CallLogManager extends CallsManagerListenerBase { AddCallArgs c = callList[i]; mListeners[i] = c.logCallCompletedListener; try { // May block. ContentResolver resolver = c.context.getContentResolver(); Pair<Integer, Integer> startStats = getCallLogStats(resolver); Pair<Integer, Integer> startStats = getCallLogStats(c.call); Log.i(TAG, "LogCall; about to log callId=%s, " + "startCount=%d, startMaxId=%d", c.callId, startStats.first, startStats.second); c.call.getId(), startStats.first, startStats.second); result[i] = Calls.addCall(c.context, c.params); Pair<Integer, Integer> endStats = getCallLogStats(resolver); Pair<Integer, Integer> endStats = getCallLogStats(c.call); Log.i(TAG, "LogCall; logged callId=%s, uri=%s, " + "endCount=%d, endMaxId=%s", c.callId, result, endStats.first, endStats.second); c.call.getId(), result, endStats.first, endStats.second); if ((endStats.second - startStats.second) <= 0) { // No call was added or even worse we lost a call in the log. Trigger an // anomaly report. Note: it technically possible that an app modified the Loading @@ -568,7 +566,7 @@ public final class CallLogManager extends CallsManagerListenerBase { // // We don't want to crash the whole process just because of that, so just log // it instead. Log.e(TAG, e, "LogCall: Exception raised adding callId=%s", c.callId); Log.e(TAG, e, "LogCall: Exception raised adding callId=%s", c.call.getId()); result[i] = null; mAnomalyReporterAdapter.reportAnomaly(LOG_CALL_FAILED_ANOMALY_ID, LOG_CALL_FAILED_ANOMALY_DESC); Loading Loading @@ -653,14 +651,17 @@ public final class CallLogManager extends CallsManagerListenerBase { * ID. There is a limit of 500 entries in the call log for a phone account, so once we hit 500 * we can reasonably expect that number to not change before and after logging a call. * We determine the maximum ID in the call log since this is a way we can objectively check if * the provider did record a call log entry or not. Ideally there should me more call log * the provider did record a call log entry or not. Ideally there should be more call log * entries after logging than before, and certainly not less. * @param resolver content resolver * @return pair with number of rows in the call log and max id. */ private Pair<Integer, Integer> getCallLogStats(@NonNull ContentResolver resolver) { private Pair<Integer, Integer> getCallLogStats(@NonNull Call call) { try { final UserManager userManager = mContext.getSystemService(UserManager.class); // Ensure we query the call log based on the current user. final Context currentUserContext = mContext.createContextAsUser( call.getAssociatedUser(), /* flags= */ 0); final ContentResolver currentUserResolver = currentUserContext.getContentResolver(); final UserManager userManager = currentUserContext.getSystemService(UserManager.class); final int currentUserId = userManager.getProcessUserId(); // Use shadow provider based on current user unlock state. Loading @@ -672,7 +673,7 @@ public final class CallLogManager extends CallsManagerListenerBase { } int maxCallId = -1; int numFound; try (Cursor countCursor = resolver.query(providerUri, try (Cursor countCursor = currentUserResolver.query(providerUri, new String[]{Calls._ID}, null, null, Loading Loading
src/com/android/server/telecom/CallLogManager.java +19 −18 Original line number Diff line number Diff line Loading @@ -77,18 +77,18 @@ public final class CallLogManager extends CallsManagerListenerBase { private static class AddCallArgs { public AddCallArgs(Context context, CallLog.AddCallParams params, @Nullable LogCallCompletedListener logCallCompletedListener, @NonNull String callId) { @NonNull Call call) { this.context = context; this.params = params; this.logCallCompletedListener = logCallCompletedListener; this.callId = callId; this.call = call; } // Since the members are accessed directly, we don't use the // mXxxx notation. public final Context context; public final CallLog.AddCallParams params; public final String callId; public final Call call; @Nullable public final LogCallCompletedListener logCallCompletedListener; } Loading @@ -100,9 +100,9 @@ public final class CallLogManager extends CallsManagerListenerBase { // a conference was merged successfully private static final String REASON_IMS_MERGED_SUCCESSFULLY = "IMS_MERGED_SUCCESSFULLY"; private static final UUID LOG_CALL_FAILED_ANOMALY_ID = UUID.fromString("1c4c15f3-ab4f-459c-b9ef-43d2988bae82"); UUID.fromString("d9b38771-ff36-417b-8723-2363a870c702"); private static final String LOG_CALL_FAILED_ANOMALY_DESC = "Failed to record a call to the call log."; "Based on the current user, Telecom detected failure to record a call to the call log."; private final Context mContext; private final CarrierConfigManager mCarrierConfigManager; Loading Loading @@ -408,7 +408,7 @@ public final class CallLogManager extends CallsManagerListenerBase { okayToLogCall(accountHandle, logNumber, call.isEmergencyCall()); if (okayToLog) { AddCallArgs args = new AddCallArgs(mContext, paramBuilder.build(), logCallCompletedListener, call.getId()); logCallCompletedListener, call); Log.addEvent(call, LogUtils.Events.LOG_CALL, "number=" + Log.piiHandle(logNumber) + ",postDial=" + Log.piiHandle(call.getPostDialDigits()) + ",pres=" + call.getHandlePresentation()); Loading Loading @@ -539,18 +539,16 @@ public final class CallLogManager extends CallsManagerListenerBase { AddCallArgs c = callList[i]; mListeners[i] = c.logCallCompletedListener; try { // May block. ContentResolver resolver = c.context.getContentResolver(); Pair<Integer, Integer> startStats = getCallLogStats(resolver); Pair<Integer, Integer> startStats = getCallLogStats(c.call); Log.i(TAG, "LogCall; about to log callId=%s, " + "startCount=%d, startMaxId=%d", c.callId, startStats.first, startStats.second); c.call.getId(), startStats.first, startStats.second); result[i] = Calls.addCall(c.context, c.params); Pair<Integer, Integer> endStats = getCallLogStats(resolver); Pair<Integer, Integer> endStats = getCallLogStats(c.call); Log.i(TAG, "LogCall; logged callId=%s, uri=%s, " + "endCount=%d, endMaxId=%s", c.callId, result, endStats.first, endStats.second); c.call.getId(), result, endStats.first, endStats.second); if ((endStats.second - startStats.second) <= 0) { // No call was added or even worse we lost a call in the log. Trigger an // anomaly report. Note: it technically possible that an app modified the Loading @@ -568,7 +566,7 @@ public final class CallLogManager extends CallsManagerListenerBase { // // We don't want to crash the whole process just because of that, so just log // it instead. Log.e(TAG, e, "LogCall: Exception raised adding callId=%s", c.callId); Log.e(TAG, e, "LogCall: Exception raised adding callId=%s", c.call.getId()); result[i] = null; mAnomalyReporterAdapter.reportAnomaly(LOG_CALL_FAILED_ANOMALY_ID, LOG_CALL_FAILED_ANOMALY_DESC); Loading Loading @@ -653,14 +651,17 @@ public final class CallLogManager extends CallsManagerListenerBase { * ID. There is a limit of 500 entries in the call log for a phone account, so once we hit 500 * we can reasonably expect that number to not change before and after logging a call. * We determine the maximum ID in the call log since this is a way we can objectively check if * the provider did record a call log entry or not. Ideally there should me more call log * the provider did record a call log entry or not. Ideally there should be more call log * entries after logging than before, and certainly not less. * @param resolver content resolver * @return pair with number of rows in the call log and max id. */ private Pair<Integer, Integer> getCallLogStats(@NonNull ContentResolver resolver) { private Pair<Integer, Integer> getCallLogStats(@NonNull Call call) { try { final UserManager userManager = mContext.getSystemService(UserManager.class); // Ensure we query the call log based on the current user. final Context currentUserContext = mContext.createContextAsUser( call.getAssociatedUser(), /* flags= */ 0); final ContentResolver currentUserResolver = currentUserContext.getContentResolver(); final UserManager userManager = currentUserContext.getSystemService(UserManager.class); final int currentUserId = userManager.getProcessUserId(); // Use shadow provider based on current user unlock state. Loading @@ -672,7 +673,7 @@ public final class CallLogManager extends CallsManagerListenerBase { } int maxCallId = -1; int numFound; try (Cursor countCursor = resolver.query(providerUri, try (Cursor countCursor = currentUserResolver.query(providerUri, new String[]{Calls._ID}, null, null, Loading