Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b0b45293 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove finacial app sms access temp implementation due to security concern."

parents 0b6adaab 61f04dad
Loading
Loading
Loading
Loading
+1 −44
Original line number Diff line number Diff line
@@ -17,14 +17,10 @@ package android.ext.services.sms;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.database.Cursor;
import android.database.CursorWindow;
import android.net.Uri;
import android.os.Bundle;
import android.service.sms.FinancialSmsService;
import android.util.Log;

import java.util.ArrayList;
/**
 * Service to provide financial apps access to sms messages.
 */
@@ -36,45 +32,6 @@ public class FinancialSmsServiceImpl extends FinancialSmsService {
    @Nullable
    @Override
    public CursorWindow onGetSmsMessages(@NonNull Bundle params) {
        ArrayList<String> columnNames = params.getStringArrayList(KEY_COLUMN_NAMES);
        if (columnNames == null || columnNames.size() <= 0) {
        return null;
    }

        Uri inbox = Uri.parse("content://sms/inbox");

        try (Cursor cursor = getContentResolver().query(inbox, null, null, null, null);
                CursorWindow window = new CursorWindow("FinancialSmsMessages")) {
            int messageCount = cursor.getCount();
            if (messageCount > 0 && cursor.moveToFirst()) {
                window.setNumColumns(columnNames.size());
                for (int row = 0; row < messageCount; row++) {
                    if (!window.allocRow()) {
                        Log.e(TAG, "CursorWindow ran out of memory.");
                        return null;
                    }
                    for (int col = 0; col < columnNames.size(); col++) {
                        String columnName = columnNames.get(col);
                        int inboxColumnIndex = cursor.getColumnIndexOrThrow(columnName);
                        String inboxColumnValue = cursor.getString(inboxColumnIndex);
                        boolean addedToCursorWindow = window.putString(inboxColumnValue, row, col);
                        if (!addedToCursorWindow) {
                            Log.e(TAG, "Failed to add:"
                                    + inboxColumnValue
                                    + ";column:"
                                    + columnName);
                            return null;
                        }
                    }
                    cursor.moveToNext();
                }
            } else {
                Log.w(TAG, "No sms messages.");
            }
            return window;
        } catch (Exception e) {
            Log.e(TAG, "Failed to get sms messages.");
            return null;
        }
    }
}