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

Commit 08a9111b authored by Adnan's avatar Adnan Committed by Martin Brabham
Browse files

Add API for protected SMS receive broadcasts.

  - Allows an application to receive an sms (usually for auth
  or registration) from whitelisted addresses, without broadcasting
  to any other listeners.

  - Allows an application to modify the whitelisted addresses within
  System.Secure settings.

Change-Id: I5dfeb94832eefac9607070e9fb29db589bac7a57
parent cddcec56
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -58,8 +58,10 @@ import android.util.Log;
import com.android.internal.widget.ILockSettings;

import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;

/**
@@ -4250,6 +4252,30 @@ public final class Settings {
            return sNameValueCache.getStringForUser(resolver, name, userHandle);
        }

        /**
         * Get a delimited string returned as a list
         * @param resolver to access the database with
         * @param name to store
         * @param delimiter to split the list with
         * @return list of strings for a specific Settings.Secure item
         * @hide
         */
        public static List<String> getDelimitedStringAsList(ContentResolver resolver, String name,
                String delimiter) {
            String baseString = Settings.Secure.getString(resolver, name);
            List<String> list = new ArrayList<String>();
            if (!TextUtils.isEmpty(baseString)) {
                final String[] array = TextUtils.split(baseString, delimiter);
                for (String item : array) {
                    if (TextUtils.isEmpty(item)) {
                        continue;
                    }
                    list.add(item);
                }
            }
            return list;
        }

        /**
         * Store a name/value pair into the database.
         * @param resolver to access the database with
@@ -4882,6 +4908,12 @@ public final class Settings {
         */
        public static final String PARENTAL_CONTROL_REDIRECT_URL = "parental_control_redirect_url";

        /**
         * Known good originating source sms addresses
         * @hide
         */
        public static final String PROTECTED_SMS_ADDRESSES = "protected_sms_addresses";

        /**
         * Settings classname to launch when Settings is clicked from All
         * Applications.  Needed because of user testing between the old
+18 −0
Original line number Diff line number Diff line
@@ -2226,6 +2226,24 @@
        android:description="@string/permdesc_broadcastPackageRemoved"
        android:protectionLevel="signature" />

    <!-- Allows an application to add an address to the whitelisted protected sms
         list
         @hide -->
    <permission android:name="android.permission.MODIFY_PROTECTED_SMS_LIST"
        android:permissionGroup="android.permission-group.MESSAGES"
        android:label="@string/permlab_modifyProtectedSmsList"
        android:description="@string/permdesc_modifyProtectedSmsList"
        android:protectionLevel="signature" />

    <!-- Allows an application to receive sms (usually for auth or registration)
         from whitelisted addresses
         @hide -->
    <permission android:name="android.permission.RECEIVE_PROTECTED_SMS"
        android:permissionGroup="android.permission-group.MESSAGES"
        android:label="@string/permlab_receiveProtectedSms"
        android:description="@string/permdesc_receiveProtectedSms"
        android:protectionLevel="signature" />

    <!-- Allows an application to intercept and rewrite outgoing SMS
         @hide -->
    <permission android:name="android.permission.INTERCEPT_SMS"
+10 −0
Original line number Diff line number Diff line
@@ -120,6 +120,16 @@
    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
    <string name="permdesc_interceptSmsSent">Allows the app to intercept an outgoing SMS. Malicious apps may use this to prevent outgoing SMS messages.</string>

    <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
    <string name="permlab_receiveProtectedSms">receive protected SMS</string>
    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
    <string name="permdesc_receiveProtectedSms">Allows the app to receive an incoming protected SMS.</string>

    <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
    <string name="permlab_modifyProtectedSmsList">modify protected SMS list</string>
    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
    <string name="permdesc_modifyProtectedSmsList">Allows the app to modify the protected sms address list.</string>

    <!-- [CHAR LIMIT=NONE] Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
    <string name="permlab_resetBatteryStats">reset battery statistics</string>
    <!-- [CHAR LIMIT=NONE] Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+3 −0
Original line number Diff line number Diff line
@@ -231,4 +231,7 @@

    <!-- Default Blacklist values of Settings.System.HEADS_UP_NOTIFICATION -->
    <string name="def_heads_up_notification_blacklist_values"></string>

    <!-- Default protected sms originating address values of Settings.Secure.PROTECTED_SMS_ADDRESSES -->
    <string-array name="def_protected_sms_list_values"></string-array>
</resources>
+11 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ import org.xmlpull.v1.XmlPullParserException;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;

@@ -2076,6 +2077,14 @@ public class DatabaseHelper extends SQLiteOpenHelper {
        }
    }

    private void loadProtectedSmsSetting(SQLiteStatement stmt) {
        String regAddresses = mContext.getResources()
                .getString(R.array.def_protected_sms_list_values);
        if (!TextUtils.isEmpty(regAddresses)) {
            loadSetting(stmt, Settings.Secure.PROTECTED_SMS_ADDRESSES, regAddresses);
        }
    }

    private void loadSettings(SQLiteDatabase db) {
        loadSystemSettings(db);
        loadSecureSettings(db);
@@ -2288,6 +2297,8 @@ public class DatabaseHelper extends SQLiteOpenHelper {
                    R.bool.def_user_setup_complete);

            loadDefaultThemeSettings(stmt);

            loadProtectedSmsSetting(stmt);
        } finally {
            if (stmt != null) stmt.close();
        }
Loading