summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Michael Groover <mpgroover@google.com> 2019-06-12 20:31:16 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-06-12 20:31:16 +0000
commit692a68133bfcfab7730e791d961e5454399191ca (patch)
tree6934709608e097b974e19895ffaaef780808db1a
parent034670e90b82dfcaf4a43c10d6c320baa04e55ce (diff)
parent44c92e0708a2027ad97bd8715bcbfd40acd3370e (diff)
Merge "Remove settings to relax device ID access restrictions" into qt-dev
-rw-r--r--core/java/android/provider/Settings.java33
-rw-r--r--core/tests/coretests/src/android/provider/SettingsBackupTest.java3
-rw-r--r--telephony/java/com/android/internal/telephony/TelephonyPermissions.java97
3 files changed, 31 insertions, 102 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 5432e33bacf8..7bde2b552328 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -13569,39 +13569,6 @@ public final class Settings {
"location_global_kill_switch";
/**
- * If set to 1, the device identifier check will be relaxed to the previous READ_PHONE_STATE
- * permission check for 3P apps.
- *
- * STOPSHIP: Remove this once we ship with the new device identifier check enabled.
- *
- * @hide
- */
- public static final String PRIVILEGED_DEVICE_IDENTIFIER_3P_CHECK_RELAXED =
- "privileged_device_identifier_3p_check_relaxed";
-
- /**
- * If set to 1, the device identifier check will be relaxed to the previous READ_PHONE_STATE
- * permission check for preloaded non-privileged apps.
- *
- * STOPSHIP: Remove this once we ship with the new device identifier check enabled.
- *
- * @hide
- */
- public static final String PRIVILEGED_DEVICE_IDENTIFIER_NON_PRIV_CHECK_RELAXED =
- "privileged_device_identifier_non_priv_check_relaxed";
-
- /**
- * If set to 1, the device identifier check will be relaxed to the previous READ_PHONE_STATE
- * permission check for preloaded privileged apps.
- *
- * STOPSHIP: Remove this once we ship with the new device identifier check enabled.
- *
- * @hide
- */
- public static final String PRIVILEGED_DEVICE_IDENTIFIER_PRIV_CHECK_RELAXED =
- "privileged_device_identifier_priv_check_relaxed";
-
- /**
* If set to 1, SettingsProvider's restoreAnyVersion="true" attribute will be ignored
* and restoring to lower version of platform API will be skipped.
*
diff --git a/core/tests/coretests/src/android/provider/SettingsBackupTest.java b/core/tests/coretests/src/android/provider/SettingsBackupTest.java
index 9d5846440a13..0a443458e2bc 100644
--- a/core/tests/coretests/src/android/provider/SettingsBackupTest.java
+++ b/core/tests/coretests/src/android/provider/SettingsBackupTest.java
@@ -397,9 +397,6 @@ public class SettingsBackupTest {
Settings.Global.POWER_MANAGER_CONSTANTS,
Settings.Global.PREFERRED_NETWORK_MODE,
Settings.Global.PRIVATE_DNS_DEFAULT_MODE,
- Settings.Global.PRIVILEGED_DEVICE_IDENTIFIER_NON_PRIV_CHECK_RELAXED,
- Settings.Global.PRIVILEGED_DEVICE_IDENTIFIER_PRIV_CHECK_RELAXED,
- Settings.Global.PRIVILEGED_DEVICE_IDENTIFIER_3P_CHECK_RELAXED,
Settings.Global.PROVISIONING_APN_ALARM_DELAY_IN_MS,
Settings.Global.RADIO_BLUETOOTH,
Settings.Global.RADIO_CELL,
diff --git a/telephony/java/com/android/internal/telephony/TelephonyPermissions.java b/telephony/java/com/android/internal/telephony/TelephonyPermissions.java
index e8e2a3d8453e..7a0ab9ca6a28 100644
--- a/telephony/java/com/android/internal/telephony/TelephonyPermissions.java
+++ b/telephony/java/com/android/internal/telephony/TelephonyPermissions.java
@@ -29,8 +29,6 @@ import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
-import android.provider.DeviceConfig;
-import android.provider.Settings;
import android.telephony.Rlog;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@@ -364,23 +362,8 @@ public final class TelephonyPermissions {
*/
private static boolean reportAccessDeniedToReadIdentifiers(Context context, int subId, int pid,
int uid, String callingPackage, String message) {
- // Check if the application is not preinstalled; if not then a separate setting is required
- // to relax the check to begin flagging problems with non-preinstalled apps early.
- boolean relax3PDeviceIdentifierCheck = Settings.Global.getInt(context.getContentResolver(),
- Settings.Global.PRIVILEGED_DEVICE_IDENTIFIER_3P_CHECK_RELAXED, 0) == 1;
boolean isPreinstalled = false;
- // Also check if the application is a preloaded non-privileged app; if so there is a
- // separate setting to relax the check for these apps to ensure users can relax the check
- // for non-preinstalled or non-priv apps as needed while continuing to test the other.
- boolean relaxNonPrivDeviceIdentifierCheck = Settings.Global.getInt(
- context.getContentResolver(),
- Settings.Global.PRIVILEGED_DEVICE_IDENTIFIER_NON_PRIV_CHECK_RELAXED, 0) == 1;
boolean isPrivApp = false;
- // Similar to above support relaxing the check for privileged apps while still enforcing it
- // for non-privileged and non-preinstalled apps.
- boolean relaxPrivDeviceIdentifierCheck = Settings.Global.getInt(
- context.getContentResolver(),
- Settings.Global.PRIVILEGED_DEVICE_IDENTIFIER_PRIV_CHECK_RELAXED, 0) == 1;
ApplicationInfo callingPackageInfo = null;
try {
callingPackageInfo = context.getPackageManager().getApplicationInfoAsUser(
@@ -399,58 +382,40 @@ public final class TelephonyPermissions {
Log.e(LOG_TAG, "Exception caught obtaining package info for package " + callingPackage,
e);
}
- // The new Q restrictions for device identifier access will be enforced for all apps with
- // settings to individually disable the new restrictions for privileged, preloaded
- // non-privileged, and non-preinstalled apps.
- if (!isIdentifierCheckDisabled() && (
- (isPrivApp && !relaxPrivDeviceIdentifierCheck)
- || (!isPreinstalled && !relax3PDeviceIdentifierCheck)
- || (isPreinstalled && !isPrivApp && !relaxNonPrivDeviceIdentifierCheck))) {
- // The current package should only be reported in StatsLog if it has not previously been
- // reported for the currently invoked device identifier method.
- boolean packageReported = sReportedDeviceIDPackages.containsKey(callingPackage);
- if (!packageReported || !sReportedDeviceIDPackages.get(callingPackage).contains(
- message)) {
- Set invokedMethods;
- if (!packageReported) {
- invokedMethods = new HashSet<String>();
- sReportedDeviceIDPackages.put(callingPackage, invokedMethods);
- } else {
- invokedMethods = sReportedDeviceIDPackages.get(callingPackage);
- }
- invokedMethods.add(message);
- StatsLog.write(StatsLog.DEVICE_IDENTIFIER_ACCESS_DENIED, callingPackage, message,
- isPreinstalled, isPrivApp);
+ // The current package should only be reported in StatsLog if it has not previously been
+ // reported for the currently invoked device identifier method.
+ boolean packageReported = sReportedDeviceIDPackages.containsKey(callingPackage);
+ if (!packageReported || !sReportedDeviceIDPackages.get(callingPackage).contains(
+ message)) {
+ Set invokedMethods;
+ if (!packageReported) {
+ invokedMethods = new HashSet<String>();
+ sReportedDeviceIDPackages.put(callingPackage, invokedMethods);
+ } else {
+ invokedMethods = sReportedDeviceIDPackages.get(callingPackage);
}
- Log.w(LOG_TAG, "reportAccessDeniedToReadIdentifiers:" + callingPackage + ":" + message
- + ":isPreinstalled=" + isPreinstalled + ":isPrivApp=" + isPrivApp);
- // if the target SDK is pre-Q then check if the calling package would have previously
- // had access to device identifiers.
- if (callingPackageInfo != null && (
- callingPackageInfo.targetSdkVersion < Build.VERSION_CODES.Q)) {
- if (context.checkPermission(
- android.Manifest.permission.READ_PHONE_STATE,
- pid,
- uid) == PackageManager.PERMISSION_GRANTED) {
- return false;
- }
- if (checkCarrierPrivilegeForSubId(subId)) {
- return false;
- }
+ invokedMethods.add(message);
+ StatsLog.write(StatsLog.DEVICE_IDENTIFIER_ACCESS_DENIED, callingPackage, message,
+ isPreinstalled, isPrivApp);
+ }
+ Log.w(LOG_TAG, "reportAccessDeniedToReadIdentifiers:" + callingPackage + ":" + message
+ + ":isPreinstalled=" + isPreinstalled + ":isPrivApp=" + isPrivApp);
+ // if the target SDK is pre-Q then check if the calling package would have previously
+ // had access to device identifiers.
+ if (callingPackageInfo != null && (
+ callingPackageInfo.targetSdkVersion < Build.VERSION_CODES.Q)) {
+ if (context.checkPermission(
+ android.Manifest.permission.READ_PHONE_STATE,
+ pid,
+ uid) == PackageManager.PERMISSION_GRANTED) {
+ return false;
+ }
+ if (checkCarrierPrivilegeForSubId(subId)) {
+ return false;
}
- throw new SecurityException(message + ": The user " + uid
- + " does not meet the requirements to access device identifiers.");
- } else {
- return checkReadPhoneState(context, subId, pid, uid, callingPackage, message);
}
- }
-
- /**
- * Returns true if the new device identifier access restrictions are disabled.
- */
- private static boolean isIdentifierCheckDisabled() {
- return DeviceConfig.getInt(DeviceConfig.NAMESPACE_PRIVACY,
- PROPERTY_DEVICE_IDENTIFIER_ACCESS_RESTRICTIONS_DISABLED, 0) == 1;
+ throw new SecurityException(message + ": The user " + uid
+ + " does not meet the requirements to access device identifiers.");
}
/**