Add READ_PHONE_NUMBER permission

READ_PHONE_NUMBER allows only access to the phone number and not all the
other things that READ_PHONE_STATE allows access to. READ_PHONE_NUMBER
will be accessible to ephemeral apps while READ_PHONE_STATE will no
longer be.

Test: Verified that getLine1Number works with READ_PHONE_NUMBER from an
epemheral app
Test: cts-tradefed run cts -m CtsPermission2TestCases
Change-Id: I599c19227f886adbe8efe346a78d51e88ab46379
This commit is contained in:
Chad Brubaker
2016-11-10 11:24:40 -08:00
parent 7f9d210eef
commit 73ec8f963d
7 changed files with 38 additions and 1 deletions

View File

@@ -99,6 +99,7 @@ package android {
field public static final java.lang.String READ_FRAME_BUFFER = "android.permission.READ_FRAME_BUFFER";
field public static final deprecated java.lang.String READ_INPUT_STATE = "android.permission.READ_INPUT_STATE";
field public static final java.lang.String READ_LOGS = "android.permission.READ_LOGS";
field public static final java.lang.String READ_PHONE_NUMBER = "android.permission.READ_PHONE_NUMBER";
field public static final java.lang.String READ_PHONE_STATE = "android.permission.READ_PHONE_STATE";
field public static final java.lang.String READ_SMS = "android.permission.READ_SMS";
field public static final java.lang.String READ_SYNC_SETTINGS = "android.permission.READ_SYNC_SETTINGS";
@@ -4067,6 +4068,7 @@ package android.app {
field public static final java.lang.String OPSTR_READ_CELL_BROADCASTS = "android:read_cell_broadcasts";
field public static final java.lang.String OPSTR_READ_CONTACTS = "android:read_contacts";
field public static final java.lang.String OPSTR_READ_EXTERNAL_STORAGE = "android:read_external_storage";
field public static final java.lang.String OPSTR_READ_PHONE_NUMBER = "android:read_phone_number";
field public static final java.lang.String OPSTR_READ_PHONE_STATE = "android:read_phone_state";
field public static final java.lang.String OPSTR_READ_SMS = "android:read_sms";
field public static final java.lang.String OPSTR_RECEIVE_MMS = "android:receive_mms";

View File

@@ -172,6 +172,7 @@ package android {
field public static final java.lang.String READ_LOGS = "android.permission.READ_LOGS";
field public static final java.lang.String READ_NETWORK_USAGE_HISTORY = "android.permission.READ_NETWORK_USAGE_HISTORY";
field public static final java.lang.String READ_OEM_UNLOCK_STATE = "android.permission.READ_OEM_UNLOCK_STATE";
field public static final java.lang.String READ_PHONE_NUMBER = "android.permission.READ_PHONE_NUMBER";
field public static final java.lang.String READ_PHONE_STATE = "android.permission.READ_PHONE_STATE";
field public static final java.lang.String READ_PRIVILEGED_PHONE_STATE = "android.permission.READ_PRIVILEGED_PHONE_STATE";
field public static final java.lang.String READ_SEARCH_INDEXABLES = "android.permission.READ_SEARCH_INDEXABLES";
@@ -4203,6 +4204,7 @@ package android.app {
field public static final java.lang.String OPSTR_READ_CELL_BROADCASTS = "android:read_cell_broadcasts";
field public static final java.lang.String OPSTR_READ_CONTACTS = "android:read_contacts";
field public static final java.lang.String OPSTR_READ_EXTERNAL_STORAGE = "android:read_external_storage";
field public static final java.lang.String OPSTR_READ_PHONE_NUMBER = "android:read_phone_number";
field public static final java.lang.String OPSTR_READ_PHONE_STATE = "android:read_phone_state";
field public static final java.lang.String OPSTR_READ_SMS = "android:read_sms";
field public static final java.lang.String OPSTR_RECEIVE_MMS = "android:receive_mms";

View File

@@ -99,6 +99,7 @@ package android {
field public static final java.lang.String READ_FRAME_BUFFER = "android.permission.READ_FRAME_BUFFER";
field public static final deprecated java.lang.String READ_INPUT_STATE = "android.permission.READ_INPUT_STATE";
field public static final java.lang.String READ_LOGS = "android.permission.READ_LOGS";
field public static final java.lang.String READ_PHONE_NUMBER = "android.permission.READ_PHONE_NUMBER";
field public static final java.lang.String READ_PHONE_STATE = "android.permission.READ_PHONE_STATE";
field public static final java.lang.String READ_SMS = "android.permission.READ_SMS";
field public static final java.lang.String READ_SYNC_SETTINGS = "android.permission.READ_SYNC_SETTINGS";
@@ -4077,6 +4078,7 @@ package android.app {
field public static final java.lang.String OPSTR_READ_CELL_BROADCASTS = "android:read_cell_broadcasts";
field public static final java.lang.String OPSTR_READ_CONTACTS = "android:read_contacts";
field public static final java.lang.String OPSTR_READ_EXTERNAL_STORAGE = "android:read_external_storage";
field public static final java.lang.String OPSTR_READ_PHONE_NUMBER = "android:read_phone_number";
field public static final java.lang.String OPSTR_READ_PHONE_STATE = "android:read_phone_state";
field public static final java.lang.String OPSTR_READ_SMS = "android:read_sms";
field public static final java.lang.String OPSTR_RECEIVE_MMS = "android:receive_mms";

View File

@@ -241,8 +241,10 @@ public class AppOpsManager {
public static final int OP_RUN_IN_BACKGROUND = 63;
/** @hide */
public static final int OP_AUDIO_ACCESSIBILITY_VOLUME = 64;
/** @hide Read the phone number. */
public static final int OP_READ_PHONE_NUMBER = 65;
/** @hide */
public static final int _NUM_OP = 65;
public static final int _NUM_OP = 66;
/** Access to coarse location information. */
public static final String OPSTR_COARSE_LOCATION = "android:coarse_location";
@@ -343,6 +345,8 @@ public class AppOpsManager {
/** @hide Get device accounts. */
public static final String OPSTR_GET_ACCOUNTS
= "android:get_accounts";
public static final String OPSTR_READ_PHONE_NUMBER
= "android:read_phone_number";
private static final int[] RUNTIME_PERMISSIONS_OPS = {
// Contacts
@@ -367,6 +371,7 @@ public class AppOpsManager {
OP_FINE_LOCATION,
// Phone
OP_READ_PHONE_STATE,
OP_READ_PHONE_NUMBER,
OP_CALL_PHONE,
OP_READ_CALL_LOG,
OP_WRITE_CALL_LOG,
@@ -455,6 +460,7 @@ public class AppOpsManager {
OP_GET_ACCOUNTS,
OP_RUN_IN_BACKGROUND,
OP_AUDIO_ACCESSIBILITY_VOLUME,
OP_READ_PHONE_NUMBER,
};
/**
@@ -527,6 +533,7 @@ public class AppOpsManager {
OPSTR_GET_ACCOUNTS,
null,
null, // OP_AUDIO_ACCESSIBILITY_VOLUME
OPSTR_READ_PHONE_NUMBER,
};
/**
@@ -599,6 +606,7 @@ public class AppOpsManager {
"GET_ACCOUNTS",
"RUN_IN_BACKGROUND",
"AUDIO_ACCESSIBILITY_VOLUME",
"READ_PHONE_NUMBER",
};
/**
@@ -671,6 +679,7 @@ public class AppOpsManager {
Manifest.permission.GET_ACCOUNTS,
null, // no permission for running in background
null, // no permission for changing accessibility volume
Manifest.permission.READ_PHONE_NUMBER,
};
/**
@@ -744,6 +753,7 @@ public class AppOpsManager {
null, // GET_ACCOUNTS
null, // RUN_IN_BACKGROUND
UserManager.DISALLOW_ADJUST_VOLUME, //AUDIO_ACCESSIBILITY_VOLUME
null, // READ_PHONE_NUMBER
};
/**
@@ -816,6 +826,7 @@ public class AppOpsManager {
false, // GET_ACCOUNTS
false, // RUN_IN_BACKGROUND
false, // AUDIO_ACCESSIBILITY_VOLUME
false, // READ_PHONE_NUMBER
};
/**
@@ -887,6 +898,7 @@ public class AppOpsManager {
AppOpsManager.MODE_ALLOWED,
AppOpsManager.MODE_ALLOWED, // OP_RUN_IN_BACKGROUND
AppOpsManager.MODE_ALLOWED, // OP_AUDIO_ACCESSIBILITY_VOLUME
AppOpsManager.MODE_ALLOWED,
};
/**
@@ -962,6 +974,7 @@ public class AppOpsManager {
false,
false,
false, // OP_AUDIO_ACCESSIBILITY_VOLUME
false,
};
/**

View File

@@ -769,6 +769,15 @@
android:permissionGroup="android.permission-group.PHONE"
android:label="@string/permlab_readPhoneState"
android:description="@string/permdesc_readPhoneState"
android:protectionLevel="dangerous" />
<!-- Allows read access to the device's phone number. This is a subset of the capabilities
granted by {@link #READ_PHONE_STATE} but is exposed to ephemeral applications.
<p>Protection level: dangerous-->
<permission android:name="android.permission.READ_PHONE_NUMBER"
android:permissionGroup="android.permission-group.PHONE"
android:label="@string/permlab_readPhoneNumber"
android:description="@string/permdesc_readPhoneNumber"
android:protectionLevel="dangerous|ephemeral" />
<!-- Allows an application to initiate a phone call without going through

View File

@@ -1058,6 +1058,11 @@
phone number and device IDs, whether a call is active, and the remote number
connected by a call.</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_readPhoneNumber">read phone number</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_readPhoneNumber">Allows the app to access the phone number of the device.</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_wakeLock" product="tablet">prevent tablet from sleeping</string>
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->

View File

@@ -2275,6 +2275,8 @@ public class TelephonyManager {
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
* OR
* {@link android.Manifest.permission#READ_SMS}
* OR
* {@link android.Manifest.permission#READ_PHONE_NUMBER}
* <p>
* The default SMS app can also use this.
*/
@@ -2290,6 +2292,8 @@ public class TelephonyManager {
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
* OR
* {@link android.Manifest.permission#READ_SMS}
* OR
* {@link android.Manifest.permission#READ_PHONE_NUMBER}
* <p>
* The default SMS app can also use this.
*