summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java10
-rw-r--r--core/api/current.txt1
-rw-r--r--core/java/android/credentials/ui/BaseDialogResult.java7
-rw-r--r--core/java/android/credentials/ui/UserSelectionDialogResult.java4
-rw-r--r--core/java/android/nfc/NfcAdapter.java30
-rw-r--r--core/java/android/os/UserManager.java26
-rw-r--r--core/jni/android_media_AudioSystem.cpp4
-rw-r--r--keystore/java/android/security/keystore/KeyGenParameterSpec.java2
-rw-r--r--packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt19
-rw-r--r--packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java31
-rw-r--r--packages/WAPPushManager/tests/src/com/android/smspush/unitTests/WapPushTest.java4
-rw-r--r--services/core/java/com/android/server/pm/UserRestrictionsUtils.java9
12 files changed, 107 insertions, 40 deletions
diff --git a/apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java b/apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java
index 220aa2762305..b96354c396a7 100644
--- a/apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java
+++ b/apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java
@@ -755,7 +755,7 @@ public class AlarmManagerService extends SystemService {
private static final long DEFAULT_MIN_INTERVAL = 60 * 1000;
private static final long DEFAULT_MAX_INTERVAL = 365 * INTERVAL_DAY;
private static final long DEFAULT_MIN_WINDOW = 10 * 60 * 1000;
- private static final long DEFAULT_ALLOW_WHILE_IDLE_WHITELIST_DURATION = 10 * 1000;
+ private static final long DEFAULT_ALLOW_WHILE_IDLE_ALLOWLIST_DURATION = 10 * 1000;
private static final long DEFAULT_LISTENER_TIMEOUT = 5 * 1000;
private static final int DEFAULT_MAX_ALARMS_PER_UID = 500;
private static final long DEFAULT_APP_STANDBY_WINDOW = 60 * 60 * 1000; // 1 hr
@@ -811,7 +811,7 @@ public class AlarmManagerService extends SystemService {
// BroadcastOptions.setTemporaryAppWhitelistDuration() to use for FLAG_ALLOW_WHILE_IDLE.
public long ALLOW_WHILE_IDLE_WHITELIST_DURATION
- = DEFAULT_ALLOW_WHILE_IDLE_WHITELIST_DURATION;
+ = DEFAULT_ALLOW_WHILE_IDLE_ALLOWLIST_DURATION;
// Direct alarm listener callback timeout
public long LISTENER_TIMEOUT = DEFAULT_LISTENER_TIMEOUT;
@@ -1018,7 +1018,7 @@ public class AlarmManagerService extends SystemService {
case KEY_ALLOW_WHILE_IDLE_WHITELIST_DURATION:
ALLOW_WHILE_IDLE_WHITELIST_DURATION = properties.getLong(
KEY_ALLOW_WHILE_IDLE_WHITELIST_DURATION,
- DEFAULT_ALLOW_WHILE_IDLE_WHITELIST_DURATION);
+ DEFAULT_ALLOW_WHILE_IDLE_ALLOWLIST_DURATION);
updateAllowWhileIdleWhitelistDurationLocked();
break;
case KEY_LISTENER_TIMEOUT:
@@ -1635,7 +1635,7 @@ public class AlarmManagerService extends SystemService {
* Check all alarms in {@link #mPendingBackgroundAlarms} and send the ones that are not
* restricted.
*
- * This is only called when the power save whitelist changes, so it's okay to be slow.
+ * This is only called when the power save allowlist changes, so it's okay to be slow.
*/
@GuardedBy("mLock")
void sendAllUnrestrictedPendingBackgroundAlarmsLocked() {
@@ -2290,7 +2290,7 @@ public class AlarmManagerService extends SystemService {
}
}
- // Sanity check the recurrence interval. This will catch people who supply
+ // Validate the recurrence interval. This will catch people who supply
// seconds when the API expects milliseconds, or apps trying shenanigans
// around intentional period overflow, etc.
final long minInterval = mConstants.MIN_INTERVAL;
diff --git a/core/api/current.txt b/core/api/current.txt
index e37beb3abd14..02be7726eca4 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -33955,6 +33955,7 @@ package android.os {
field public static final String DISALLOW_MICROPHONE_TOGGLE = "disallow_microphone_toggle";
field public static final String DISALLOW_MODIFY_ACCOUNTS = "no_modify_accounts";
field public static final String DISALLOW_MOUNT_PHYSICAL_MEDIA = "no_physical_media";
+ field public static final String DISALLOW_NEAR_FIELD_COMMUNICATION_RADIO = "no_near_field_communication_radio";
field public static final String DISALLOW_NETWORK_RESET = "no_network_reset";
field public static final String DISALLOW_OUTGOING_BEAM = "no_outgoing_beam";
field public static final String DISALLOW_OUTGOING_CALLS = "no_outgoing_calls";
diff --git a/core/java/android/credentials/ui/BaseDialogResult.java b/core/java/android/credentials/ui/BaseDialogResult.java
index f0442de74e9e..e8cf5abd5239 100644
--- a/core/java/android/credentials/ui/BaseDialogResult.java
+++ b/core/java/android/credentials/ui/BaseDialogResult.java
@@ -85,15 +85,15 @@ public class BaseDialogResult implements Parcelable {
*/
public static final int RESULT_CODE_DATA_PARSING_FAILURE = 3;
- @NonNull
+ @Nullable
private final IBinder mRequestToken;
- public BaseDialogResult(@NonNull IBinder requestToken) {
+ public BaseDialogResult(@Nullable IBinder requestToken) {
mRequestToken = requestToken;
}
/** Returns the unique identifier for the request that launched the operation. */
- @NonNull
+ @Nullable
public IBinder getRequestToken() {
return mRequestToken;
}
@@ -101,7 +101,6 @@ public class BaseDialogResult implements Parcelable {
protected BaseDialogResult(@NonNull Parcel in) {
IBinder requestToken = in.readStrongBinder();
mRequestToken = requestToken;
- AnnotationValidations.validate(NonNull.class, null, mRequestToken);
}
@Override
diff --git a/core/java/android/credentials/ui/UserSelectionDialogResult.java b/core/java/android/credentials/ui/UserSelectionDialogResult.java
index 44b3b36844c2..3089bf674b95 100644
--- a/core/java/android/credentials/ui/UserSelectionDialogResult.java
+++ b/core/java/android/credentials/ui/UserSelectionDialogResult.java
@@ -60,7 +60,7 @@ public final class UserSelectionDialogResult extends BaseDialogResult implements
@Nullable private ProviderPendingIntentResponse mProviderPendingIntentResponse;
public UserSelectionDialogResult(
- @NonNull IBinder requestToken, @NonNull String providerId,
+ @Nullable IBinder requestToken, @NonNull String providerId,
@NonNull String entryKey, @NonNull String entrySubkey) {
super(requestToken);
mProviderId = providerId;
@@ -69,7 +69,7 @@ public final class UserSelectionDialogResult extends BaseDialogResult implements
}
public UserSelectionDialogResult(
- @NonNull IBinder requestToken, @NonNull String providerId,
+ @Nullable IBinder requestToken, @NonNull String providerId,
@NonNull String entryKey, @NonNull String entrySubkey,
@Nullable ProviderPendingIntentResponse providerPendingIntentResponse) {
super(requestToken);
diff --git a/core/java/android/nfc/NfcAdapter.java b/core/java/android/nfc/NfcAdapter.java
index 36199e522520..a9eb672c4e4d 100644
--- a/core/java/android/nfc/NfcAdapter.java
+++ b/core/java/android/nfc/NfcAdapter.java
@@ -600,6 +600,17 @@ public final class NfcAdapter {
return offHostSE;
}
+ private static void retrieveServiceRegisterer() {
+ if (sServiceRegisterer == null) {
+ NfcServiceManager manager = NfcFrameworkInitializer.getNfcServiceManager();
+ if (manager == null) {
+ Log.e(TAG, "NfcServiceManager is null");
+ throw new UnsupportedOperationException();
+ }
+ sServiceRegisterer = manager.getNfcManagerServiceRegisterer();
+ }
+ }
+
/**
* Returns the NfcAdapter for application context,
* or throws if NFC is not available.
@@ -627,12 +638,7 @@ public final class NfcAdapter {
Log.v(TAG, "this device does not have NFC support");
throw new UnsupportedOperationException();
}
- NfcServiceManager manager = NfcFrameworkInitializer.getNfcServiceManager();
- if (manager == null) {
- Log.e(TAG, "NfcServiceManager is null");
- throw new UnsupportedOperationException();
- }
- sServiceRegisterer = manager.getNfcManagerServiceRegisterer();
+ retrieveServiceRegisterer();
sService = getServiceInterface();
if (sService == null) {
Log.e(TAG, "could not retrieve NFC service");
@@ -706,11 +712,13 @@ public final class NfcAdapter {
throw new IllegalArgumentException(
"context not associated with any application (using a mock context?)");
}
-
- if (sIsInitialized && sServiceRegisterer.tryGet() == null) {
- synchronized (NfcAdapter.class) {
- /* Stale sService pointer */
- if (sIsInitialized) sIsInitialized = false;
+ retrieveServiceRegisterer();
+ if (sServiceRegisterer.tryGet() == null) {
+ if (sIsInitialized) {
+ synchronized (NfcAdapter.class) {
+ /* Stale sService pointer */
+ if (sIsInitialized) sIsInitialized = false;
+ }
}
return null;
}
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index 84f1880213b8..cf8e875c1644 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -1810,6 +1810,31 @@ public class UserManager {
public static final String DISALLOW_ULTRA_WIDEBAND_RADIO = "no_ultra_wideband_radio";
/**
+ * This user restriction specifies if Near-field communication is disallowed on the device. If
+ * Near-field communication is disallowed it cannot be turned on via Settings.
+ *
+ * <p>This restriction can only be set by a device owner or a profile owner of an
+ * organization-owned managed profile on the parent profile.
+ * In both cases, the restriction applies globally on the device and will turn off the
+ * Near-field communication radio if it's currently on and prevent the radio from being turned
+ * on in the future.
+ *
+ * <p>
+ * Near-field communication (NFC) is a radio technology that allows two devices (like your phone
+ * and a payments terminal) to communicate with each other when they're close together.
+ *
+ * <p>Default is <code>false</code>.
+ *
+ * <p>Key for user restrictions.
+ * <p>Type: Boolean
+ * @see DevicePolicyManager#addUserRestriction(ComponentName, String)
+ * @see DevicePolicyManager#clearUserRestriction(ComponentName, String)
+ * @see #getUserRestrictions()
+ */
+ public static final String DISALLOW_NEAR_FIELD_COMMUNICATION_RADIO =
+ "no_near_field_communication_radio";
+
+ /**
* List of key values that can be passed into the various user restriction related methods
* in {@link UserManager} & {@link DevicePolicyManager}.
* Note: This is slightly different from the real set of user restrictions listed in {@link
@@ -1893,6 +1918,7 @@ public class UserManager {
DISALLOW_CELLULAR_2G,
DISALLOW_ULTRA_WIDEBAND_RADIO,
DISALLOW_GRANT_ADMIN,
+ DISALLOW_NEAR_FIELD_COMMUNICATION_RADIO,
})
@Retention(RetentionPolicy.SOURCE)
public @interface UserRestrictionKey {}
diff --git a/core/jni/android_media_AudioSystem.cpp b/core/jni/android_media_AudioSystem.cpp
index 4cf17b78f489..7dfd282f3660 100644
--- a/core/jni/android_media_AudioSystem.cpp
+++ b/core/jni/android_media_AudioSystem.cpp
@@ -494,7 +494,7 @@ android_media_AudioSystem_getParameters(JNIEnv *env, jobject thiz, jstring keys)
env->GetStringLength(keys));
env->ReleaseStringCritical(keys, c_keys);
}
- return env->NewStringUTF(AudioSystem::getParameters(c_keys8).string());
+ return env->NewStringUTF(AudioSystem::getParameters(c_keys8).c_str());
}
static void
@@ -523,7 +523,7 @@ android_media_AudioSystem_dyn_policy_callback(int event, String8 regId, int val)
}
jclass clazz = env->FindClass(kClassPathName);
- const char* zechars = regId.string();
+ const char *zechars = regId.c_str();
jstring zestring = env->NewStringUTF(zechars);
env->CallStaticVoidMethod(clazz, gAudioPolicyEventHandlerMethods.postDynPolicyEventFromNative,
diff --git a/keystore/java/android/security/keystore/KeyGenParameterSpec.java b/keystore/java/android/security/keystore/KeyGenParameterSpec.java
index fc5f7d6f399e..395624145cd5 100644
--- a/keystore/java/android/security/keystore/KeyGenParameterSpec.java
+++ b/keystore/java/android/security/keystore/KeyGenParameterSpec.java
@@ -1524,7 +1524,7 @@ public final class KeyGenParameterSpec implements AlgorithmParameterSpec, UserAu
* key has purpose {@link android.security.keystore.KeyProperties#PURPOSE_SIGN}. If the key
* does not have purpose {@link android.security.keystore.KeyProperties#PURPOSE_SIGN}, it is
* not possible to use the key to sign a certificate, so the public key certificate will
- * contain a dummy signature.
+ * contain a placeholder signature.
*
* <p>Symmetric keys, such as AES and HMAC keys, do not have public key certificates. If a
* {@link #getAttestationChallenge()} returns non-null and the spec is used to generate a
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt b/packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt
index b86eec04d542..8361877744cf 100644
--- a/packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt
+++ b/packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt
@@ -68,11 +68,12 @@ fun getAppLabel(
): String? {
return try {
val pkgInfo = pm.getPackageInfo(appPackageName, PackageManager.PackageInfoFlags.of(0))
- pkgInfo.applicationInfo.loadSafeLabel(
+ val applicationInfo = checkNotNull(pkgInfo.applicationInfo)
+ applicationInfo.loadSafeLabel(
pm, 0f,
TextUtils.SAFE_STRING_FLAG_FIRST_LINE or TextUtils.SAFE_STRING_FLAG_TRIM
).toString()
- } catch (e: PackageManager.NameNotFoundException) {
+ } catch (e: Exception) {
Log.e(Constants.LOG_TAG, "Caller app not found", e)
null
}
@@ -93,13 +94,14 @@ private fun getServiceLabelAndIcon(
providerFlattenedComponentName,
PackageManager.PackageInfoFlags.of(0)
)
+ val applicationInfo = checkNotNull(pkgInfo.applicationInfo)
providerLabel =
- pkgInfo.applicationInfo.loadSafeLabel(
+ applicationInfo.loadSafeLabel(
pm, 0f,
TextUtils.SAFE_STRING_FLAG_FIRST_LINE or TextUtils.SAFE_STRING_FLAG_TRIM
).toString()
- providerIcon = pkgInfo.applicationInfo.loadIcon(pm)
- } catch (e: PackageManager.NameNotFoundException) {
+ providerIcon = applicationInfo.loadIcon(pm)
+ } catch (e: Exception) {
Log.e(Constants.LOG_TAG, "Provider package info not found", e)
}
} else {
@@ -119,13 +121,14 @@ private fun getServiceLabelAndIcon(
component.packageName,
PackageManager.PackageInfoFlags.of(0)
)
+ val applicationInfo = checkNotNull(pkgInfo.applicationInfo)
providerLabel =
- pkgInfo.applicationInfo.loadSafeLabel(
+ applicationInfo.loadSafeLabel(
pm, 0f,
TextUtils.SAFE_STRING_FLAG_FIRST_LINE or TextUtils.SAFE_STRING_FLAG_TRIM
).toString()
- providerIcon = pkgInfo.applicationInfo.loadIcon(pm)
- } catch (e: PackageManager.NameNotFoundException) {
+ providerIcon = applicationInfo.loadIcon(pm)
+ } catch (e: Exception) {
Log.e(Constants.LOG_TAG, "Provider package info not found", e)
}
}
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
index 4cb7f94f8e6d..2762d8eb08e0 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
@@ -1950,6 +1950,9 @@ public class SettingsProvider extends ContentProvider {
cacheName = Settings.System.ALARM_ALERT_CACHE;
}
if (cacheName != null) {
+ if (!isValidAudioUri(name, value)) {
+ return false;
+ }
final File cacheFile = new File(
getRingtoneCacheDir(owningUserId), cacheName);
cacheFile.delete();
@@ -1982,6 +1985,34 @@ public class SettingsProvider extends ContentProvider {
}
}
+ private boolean isValidAudioUri(String name, String uri) {
+ if (uri != null) {
+ Uri audioUri = Uri.parse(uri);
+ if (Settings.AUTHORITY.equals(
+ ContentProvider.getAuthorityWithoutUserId(audioUri.getAuthority()))) {
+ // Don't accept setting the default uri to self-referential URIs like
+ // Settings.System.DEFAULT_RINGTONE_URI, which is an alias to the value of this
+ // setting.
+ return false;
+ }
+ final String mimeType = getContext().getContentResolver().getType(audioUri);
+ if (mimeType == null) {
+ Slog.e(LOG_TAG,
+ "mutateSystemSetting for setting: " + name + " URI: " + audioUri
+ + " ignored: failure to find mimeType (no access from this context?)");
+ return false;
+ }
+ if (!(mimeType.startsWith("audio/") || mimeType.equals("application/ogg")
+ || mimeType.equals("application/x-flac"))) {
+ Slog.e(LOG_TAG,
+ "mutateSystemSetting for setting: " + name + " URI: " + audioUri
+ + " ignored: associated mimeType: " + mimeType + " is not an audio type");
+ return false;
+ }
+ }
+ return true;
+ }
+
private boolean hasWriteSecureSettingsPermission() {
// Write secure settings is a more protected permission. If caller has it we are good.
return getContext().checkCallingOrSelfPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
diff --git a/packages/WAPPushManager/tests/src/com/android/smspush/unitTests/WapPushTest.java b/packages/WAPPushManager/tests/src/com/android/smspush/unitTests/WapPushTest.java
index b9dac4e2b28e..c7abed887cac 100644
--- a/packages/WAPPushManager/tests/src/com/android/smspush/unitTests/WapPushTest.java
+++ b/packages/WAPPushManager/tests/src/com/android/smspush/unitTests/WapPushTest.java
@@ -2237,10 +2237,6 @@ public class WapPushTest extends ServiceTestCase<WapPushManager> {
mClassName = "com.android.smspush.unitTests.ReceiverActivity";
- // Phone dummy = new DummyPhone(getContext());
- // Phone gsm = PhoneFactory.getGsmPhone();
- // GSMPhone gsm = new GSMPhone(getContext(), new SimulatedCommands(), null, true);
- // WapPushOverSms dispatcher = new WapPushOverSms(dummy, null);
try {
// set up data
diff --git a/services/core/java/com/android/server/pm/UserRestrictionsUtils.java b/services/core/java/com/android/server/pm/UserRestrictionsUtils.java
index 8815834f6b5c..4e2ceab290d4 100644
--- a/services/core/java/com/android/server/pm/UserRestrictionsUtils.java
+++ b/services/core/java/com/android/server/pm/UserRestrictionsUtils.java
@@ -151,7 +151,8 @@ public class UserRestrictionsUtils {
UserManager.DISALLOW_ADD_WIFI_CONFIG,
UserManager.DISALLOW_CELLULAR_2G,
UserManager.DISALLOW_ULTRA_WIDEBAND_RADIO,
- UserManager.DISALLOW_CONFIG_DEFAULT_APPS
+ UserManager.DISALLOW_CONFIG_DEFAULT_APPS,
+ UserManager.DISALLOW_NEAR_FIELD_COMMUNICATION_RADIO
});
public static final Set<String> DEPRECATED_USER_RESTRICTIONS = Sets.newArraySet(
@@ -201,7 +202,8 @@ public class UserRestrictionsUtils {
UserManager.DISALLOW_WIFI_DIRECT,
UserManager.DISALLOW_ADD_WIFI_CONFIG,
UserManager.DISALLOW_CELLULAR_2G,
- UserManager.DISALLOW_ULTRA_WIDEBAND_RADIO
+ UserManager.DISALLOW_ULTRA_WIDEBAND_RADIO,
+ UserManager.DISALLOW_NEAR_FIELD_COMMUNICATION_RADIO
);
/**
@@ -243,7 +245,8 @@ public class UserRestrictionsUtils {
UserManager.DISALLOW_WIFI_DIRECT,
UserManager.DISALLOW_ADD_WIFI_CONFIG,
UserManager.DISALLOW_CELLULAR_2G,
- UserManager.DISALLOW_ULTRA_WIDEBAND_RADIO
+ UserManager.DISALLOW_ULTRA_WIDEBAND_RADIO,
+ UserManager.DISALLOW_NEAR_FIELD_COMMUNICATION_RADIO
);
/**