summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcos Marado <mmarado@cyngn.com>2015-01-19 15:40:21 +0000
committerSteve Kondik <steve@cyngn.com>2015-10-26 16:09:10 -0700
commit588d74f4008f9e35873e8a403842f21358fd51e4 (patch)
tree47a0e130b1d39cdc66a6a9421b31da967c8cf6b2
parented292165842f2c71e2a35f043258f757f0edef6e (diff)
downloadframeworks_base-588d74f4008f9e35873e8a403842f21358fd51e4.zip
frameworks_base-588d74f4008f9e35873e8a403842f21358fd51e4.tar.gz
frameworks_base-588d74f4008f9e35873e8a403842f21358fd51e4.tar.bz2
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
-rw-r--r--core/java/android/provider/Settings.java6
-rw-r--r--core/res/AndroidManifest.xml18
-rw-r--r--core/res/res/values/cm_strings.xml10
-rw-r--r--packages/SettingsProvider/res/values/defaults.xml2
-rw-r--r--packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java11
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java37
-rw-r--r--telephony/java/com/android/internal/telephony/ITelephony.aidl10
7 files changed, 94 insertions, 0 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index e5afca8..e856f44 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -5242,6 +5242,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
* and new Settings apps.
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index ac40f35..863b9ea 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -2258,6 +2258,24 @@
<permission android:name="android.permission.BROADCAST_PACKAGE_REMOVED"
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 broadcast an SMS receipt notification.
<p>Not for use by third-party applications.
-->
diff --git a/core/res/res/values/cm_strings.xml b/core/res/res/values/cm_strings.xml
index bab8a43..bd8b59d 100644
--- a/core/res/res/values/cm_strings.xml
+++ b/core/res/res/values/cm_strings.xml
@@ -34,6 +34,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. -->
diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
index eef03ad..8e2ebd1 100644
--- a/packages/SettingsProvider/res/values/defaults.xml
+++ b/packages/SettingsProvider/res/values/defaults.xml
@@ -226,4 +226,6 @@
<!-- Default for Settings.System.STATUS_BAR_NOTIF_COUNT. -->
<integer name="def_notif_count">0</integer>
+ <!-- Default protected sms originating address values of Settings.Secure.PROTECTED_SMS_ADDRESSES -->
+ <string-array name="def_protected_sms_list_values"></string-array>
</resources>
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index 98a0d0d..62e1223 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -57,6 +57,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;
import java.util.Set;
@@ -2347,6 +2348,16 @@ 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);
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 3249989..a0a0fb3 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -18,6 +18,7 @@ package android.telephony;
import android.annotation.Nullable;
import android.annotation.SystemApi;
+import android.Manifest;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.app.ActivityThread;
@@ -31,6 +32,7 @@ import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.telecom.PhoneAccount;
+import android.text.TextUtils;
import android.util.Log;
import com.android.internal.telecom.ITelecomService;
@@ -45,6 +47,7 @@ import com.android.internal.telephony.TelephonyProperties;
import java.io.FileInputStream;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -2942,6 +2945,40 @@ public class TelephonyManager {
}
/**
+ * Allows an application to add a protected sms address if the application has
+ * been granted the permission MODIFY_PROTECTED_SMS_LIST.
+ * @param address
+ * @hide
+ */
+ public void addProtectedSmsAddress(String address) {
+ mContext.enforceCallingOrSelfPermission(
+ Manifest.permission.MODIFY_PROTECTED_SMS_LIST, null);
+ try {
+ getITelephony().addProtectedSmsAddress(address);
+ } catch (RemoteException ex) {
+ } catch (NullPointerException ex) {
+ }
+ }
+
+ /**
+ * Allows an application to revoke/remove a protected sms address if the application has been
+ * granted the permission MODIFY_PROTECTED_SMS_LIST.
+ * @param address
+ * @return true if address is successfully removed
+ * @hide
+ */
+ public boolean revokeProtectedSmsAddress(String address) {
+ mContext.enforceCallingOrSelfPermission(
+ Manifest.permission.MODIFY_PROTECTED_SMS_LIST, null);
+ try {
+ return getITelephony().revokeProtectedSmsAddress(address);
+ } catch (RemoteException ex) {
+ } catch (NullPointerException ex) {
+ }
+ return false;
+ }
+
+ /**
* Returns the MMS user agent.
*/
public String getMmsUserAgent() {
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index 6e0ac88..5c05191 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -545,6 +545,16 @@ interface ITelephony {
int getLteOnGsmMode();
/**
+ * Adds a protected sms address to the {@link Settings.Secure.PROTECTED_SMS_ADDRESSES}
+ */
+ void addProtectedSmsAddress(String address);
+
+ /**
+ * Revokes a protected sms address from {@link Settings.Secure.PROTECTED_SMS_ADDRESSES}
+ */
+ boolean revokeProtectedSmsAddress(String address);
+
+ /**
* get default sim
* @return sim id
*/