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

Commit 6999138c authored by Marcos Marado's avatar Marcos Marado Committed by Steve Kondik
Browse files

protected SMS [1/4]

Ports "protected SMS" from CM11:

* Add API for protected SMS receive broadcasts.
  Change-Id: I5dfeb94832eefac9607070e9fb29db589bac7a57
* SettingsProvider: fix load protected sms setting logic
  Change-Id: I7d03821c5f5ac5d24445e5c03f7911c3a81c16dd

Change-Id: Ifd31eb9558e397bf92f4cdb87f9e2056bc71d22f
parent 24f360b7
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -4598,6 +4598,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
+20 −1
Original line number Diff line number Diff line
@@ -2542,7 +2542,26 @@
        android:description="@string/permdesc_interceptSmsSent"
        android:protectionLevel="signature" />

    <!-- Allows an application to broadcast an SMS receipt notification -->
    <!-- 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 broadcast an SMS receipt notification.
         Not for use by third-party applications. -->
    <permission android:name="android.permission.BROADCAST_SMS"
        android:permissionGroup="android.permission-group.MESSAGES"
        android:label="@string/permlab_broadcastSmsReceived"
+10 −0
Original line number Diff line number Diff line
@@ -45,6 +45,16 @@
    <!-- label for item that screenshots in phone options dialog -->
    <string name="global_action_screenshot">Screenshot</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>

    <!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
    <string name="permgrouplab_security">Security</string>
    <!-- Description of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
+2 −1
Original line number Diff line number Diff line
@@ -236,5 +236,6 @@

    <!-- Default value of Settings.System.ENABLE_PEOPLE_LOOKUP -->
    <integer name="def_people_lookup">1</integer>

    <!-- Default protected sms originating address values of Settings.Secure.PROTECTED_SMS_ADDRESSES -->
    <string-array name="def_protected_sms_list_values"></string-array>
</resources>
+12 −0
Original line number Diff line number Diff line
@@ -61,6 +61,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;

@@ -2454,6 +2455,16 @@ public class DatabaseHelper extends SQLiteOpenHelper {
        }
    }

    private void loadProtectedSmsSetting(SQLiteStatement stmt) {
        String[] regAddresses = mContext.getResources()
                .getStringArray(R.array.def_protected_sms_list_values);
        if (regAddresses.length > 0) {
            loadSetting(stmt,
                    Settings.Secure.PROTECTED_SMS_ADDRESSES,
                    TextUtils.join("|", regAddresses));
        }
    }

    private void loadSettings(SQLiteDatabase db) {
        loadSystemSettings(db);
        loadSecureSettings(db);
@@ -2681,6 +2692,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
                    R.bool.def_cm_stats_collection);

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