summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AconfigFlags.bp14
-rw-r--r--apct-tests/perftests/autofill/src/android/view/autofill/LoginTest.java6
-rw-r--r--apct-tests/perftests/core/src/android/input/MotionPredictorBenchmark.kt2
-rw-r--r--apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java48
-rw-r--r--apct-tests/perftests/windowmanager/src/android/wm/RelayoutPerfTest.java2
-rw-r--r--apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java10
-rw-r--r--apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java1
-rw-r--r--apex/jobscheduler/service/java/com/android/server/usage/AppIdleHistory.java4
-rw-r--r--cmds/app_process/app_main.cpp10
-rw-r--r--cmds/backup/backup.cpp2
-rw-r--r--cmds/bootanimation/Android.bp3
-rw-r--r--cmds/bootanimation/BootAnimation.cpp17
-rw-r--r--core/api/current.txt1
-rw-r--r--core/api/module-lib-current.txt24
-rw-r--r--core/api/test-current.txt20
-rw-r--r--core/java/android/companion/AssociationInfo.java257
-rw-r--r--core/java/android/companion/CompanionDeviceManager.java96
-rw-r--r--core/java/android/companion/ICompanionDeviceManager.aidl5
-rw-r--r--core/java/android/content/Context.java2
-rw-r--r--core/java/android/content/IntentSender.java4
-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/java/android/text/flags/use_bounds_for_width.aconfig8
-rw-r--r--core/java/android/view/View.java10
-rw-r--r--core/jni/android_hardware_Camera.cpp2
-rw-r--r--core/jni/android_hardware_camera2_CameraMetadata.cpp2
-rw-r--r--core/jni/android_media_AudioSystem.cpp4
-rw-r--r--core/jni/android_util_Process.cpp2
-rw-r--r--core/res/AndroidManifest.xml6
-rw-r--r--core/tests/PackageInstallerSessions/src/android/content/pm/PackageSessionTests.kt6
-rw-r--r--keystore/java/android/security/keystore/KeyGenParameterSpec.java2
-rw-r--r--location/java/android/location/GnssRequest.java4
-rw-r--r--media/java/android/media/Cea708CaptionRenderer.java2
-rw-r--r--media/java/android/media/session/MediaSession.java23
-rw-r--r--media/java/android/media/voice/KeyphraseModelManager.java2
-rw-r--r--packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt19
-rw-r--r--packages/EasterEgg/src/com/android/egg/quares/QuaresActivity.kt2
-rw-r--r--packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/app/AppListRepository.kt1
-rw-r--r--packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/app/PackageManagers.kt3
-rw-r--r--packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/enterprise/EnterpriseRepository.kt2
-rw-r--r--packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/AppInfo.kt2
-rw-r--r--packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/TogglePermissionAppInfoPage.kt2
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java4
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/bluetooth/OWNERS5
-rw-r--r--packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java31
-rw-r--r--packages/Shell/AndroidManifest.xml1
-rw-r--r--packages/StatementService/src/com/android/statementservice/utils/StatementUtils.kt1
-rw-r--r--packages/WAPPushManager/tests/src/com/android/smspush/unitTests/WapPushTest.java4
-rw-r--r--packages/services/VirtualCamera/OWNERS3
-rw-r--r--services/companion/java/com/android/server/companion/AssociationRequestsProcessor.java4
-rw-r--r--services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java24
-rw-r--r--services/companion/java/com/android/server/companion/CompanionDeviceShellCommand.java13
-rw-r--r--services/companion/java/com/android/server/companion/datatransfer/SystemDataTransferProcessor.java2
-rw-r--r--services/companion/java/com/android/server/companion/datatransfer/contextsync/CrossDeviceSyncController.java2
-rw-r--r--services/companion/java/com/android/server/companion/transport/CompanionTransportManager.java3
-rw-r--r--services/companion/java/com/android/server/companion/transport/Transport.java12
-rw-r--r--services/core/java/com/android/server/CertBlacklister.java12
-rw-r--r--services/core/java/com/android/server/StorageManagerService.java44
-rw-r--r--services/core/java/com/android/server/audio/AudioDeviceBroker.java2
-rw-r--r--services/core/java/com/android/server/connectivity/Vpn.java40
-rw-r--r--services/core/java/com/android/server/content/SyncManager.java4
-rw-r--r--services/core/java/com/android/server/content/SyncManagerConstants.java10
-rw-r--r--services/core/java/com/android/server/integrity/AppIntegrityManagerServiceImpl.java2
-rw-r--r--services/core/java/com/android/server/locksettings/SyntheticPasswordManager.java132
-rw-r--r--services/core/java/com/android/server/media/MediaSessionRecord.java8
-rw-r--r--services/core/java/com/android/server/pm/PackageInstallerSession.java39
-rw-r--r--services/core/java/com/android/server/pm/UserRestrictionsUtils.java9
-rw-r--r--services/core/java/com/android/server/policy/SoftRestrictedPermissionPolicy.java2
-rw-r--r--services/core/java/com/android/server/recoverysystem/hal/BootControlHIDL.java6
-rw-r--r--services/core/java/com/android/server/security/KeyChainSystemService.java4
-rw-r--r--services/core/jni/Android.bp1
-rw-r--r--services/net/java/android/net/util/NetworkConstants.java1
-rw-r--r--services/permission/java/com/android/server/permission/access/permission/PermissionService.kt2
-rw-r--r--services/tests/PackageManager/packageinstaller/src/com/android/packageinstaller/test/ExportedComponentTest.kt2
-rw-r--r--services/tests/mockingservicestests/src/com/android/server/pm/SharedLibrariesImplTest.kt8
-rw-r--r--telephony/common/com/android/internal/telephony/SmsApplication.java2
-rw-r--r--telephony/java/android/telephony/SmsManager.java2
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java4
-rw-r--r--telephony/java/android/telephony/ims/ImsReasonInfo.java2
-rw-r--r--tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java2
-rw-r--r--tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/BackingStore.java191
-rw-r--r--tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/FrameBuffer1D.java16
-rw-r--r--tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/MffContext.java26
-rw-r--r--tests/Input/src/com/android/test/input/UnresponsiveGestureMonitorActivity.kt2
-rw-r--r--tests/Internal/src/stub/DummyWallpaperService.java2
-rw-r--r--tests/SilkFX/src/com/android/test/silkfx/hdr/GainmapMetadataEditor.kt60
-rw-r--r--tests/SilkFX/src/com/android/test/silkfx/materials/GlassView.kt6
-rw-r--r--tests/TrustTests/src/android/trust/test/lib/LockStateTrackingRule.kt2
-rw-r--r--tests/TrustTests/src/android/trust/test/lib/ScreenLockRule.kt2
-rw-r--r--tools/aapt/Android.bp1
-rw-r--r--tools/aapt/Package.cpp3
-rw-r--r--tools/aapt/Resource.cpp3
-rw-r--r--tools/aapt/ResourceTable.cpp5
-rw-r--r--tools/aapt/Utils.cpp38
-rw-r--r--tools/aapt/Utils.h28
97 files changed, 897 insertions, 636 deletions
diff --git a/AconfigFlags.bp b/AconfigFlags.bp
index b753aab33dcd..34a62152487d 100644
--- a/AconfigFlags.bp
+++ b/AconfigFlags.bp
@@ -20,6 +20,7 @@ java_defaults {
srcs: [
":com.android.hardware.camera2-aconfig-java{.generated_srcjars}",
":com.android.window.flags.window-aconfig-java{.generated_srcjars}",
+ ":com.android.text.flags-aconfig-java{.generated_srcjars}",
],
}
@@ -56,3 +57,16 @@ java_aconfig_library {
aconfig_declarations: "com.android.window.flags.window-aconfig",
defaults: ["framework-minus-apex-aconfig-java-defaults"],
}
+
+// Text
+aconfig_declarations {
+ name: "com.android.text.flags-aconfig",
+ package: "com.android.text.flags",
+ srcs: ["core/java/android/text/flags/*.aconfig"],
+}
+
+java_aconfig_library {
+ name: "com.android.text.flags-aconfig-java",
+ aconfig_declarations: "com.android.text.flags-aconfig",
+ defaults: ["framework-minus-apex-aconfig-java-defaults"],
+}
diff --git a/apct-tests/perftests/autofill/src/android/view/autofill/LoginTest.java b/apct-tests/perftests/autofill/src/android/view/autofill/LoginTest.java
index a5d1e00139b5..59f08f645def 100644
--- a/apct-tests/perftests/autofill/src/android/view/autofill/LoginTest.java
+++ b/apct-tests/perftests/autofill/src/android/view/autofill/LoginTest.java
@@ -140,7 +140,7 @@ public class LoginTest extends AbstractAutofillPerfTestCase {
state.resumeTiming();
}
- // Sanity check
+ // Check for no errors
callback.assertNoAsyncErrors();
} finally {
mAfm.unregisterCallback(callback);
@@ -190,7 +190,7 @@ public class LoginTest extends AbstractAutofillPerfTestCase {
state.resumeTiming();
}
- // Sanity check
+ // Check for no errors
callback.assertNoAsyncErrors();
} finally {
mAfm.unregisterCallback(callback);
@@ -303,7 +303,7 @@ public class LoginTest extends AbstractAutofillPerfTestCase {
callback.expectEvent(mPassword, EVENT_INPUT_SHOWN);
}
- // Sanity check
+ // Check for no errors
callback.assertNoAsyncErrors();
} finally {
mAfm.unregisterCallback(callback);
diff --git a/apct-tests/perftests/core/src/android/input/MotionPredictorBenchmark.kt b/apct-tests/perftests/core/src/android/input/MotionPredictorBenchmark.kt
index 9482591c65b5..aadbc2319a62 100644
--- a/apct-tests/perftests/core/src/android/input/MotionPredictorBenchmark.kt
+++ b/apct-tests/perftests/core/src/android/input/MotionPredictorBenchmark.kt
@@ -130,7 +130,7 @@ class MotionPredictorBenchmark {
eventTime, ACTION_MOVE, /*x=*/eventPosition, /*y=*/eventPosition)
predictor.record(moveEvent)
val predictionTime = eventTime + eventInterval
- val predicted = predictor.predict(predictionTime.toNanos())
+ val predicted = checkNotNull(predictor.predict(predictionTime.toNanos()))
assertTrue(predicted.eventTime <= (predictionTime + offset).toMillis())
}
}
diff --git a/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java b/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java
index 6dba5b3517f7..a2c67bc3c2e5 100644
--- a/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java
+++ b/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java
@@ -104,16 +104,16 @@ public class UserLifecycleTests {
/** Name of users/profiles in the test. Users with this name may be freely removed. */
private static final String TEST_USER_NAME = "UserLifecycleTests_test_user";
- /** Name of dummy package used when timing how long app launches take. */
+ /** Name of placeholder package used when timing how long app launches take. */
private static final String DUMMY_PACKAGE_NAME = "perftests.multiuser.apps.dummyapp";
- // Copy of UserSystemPackageInstaller whitelist mode constants.
- private static final String PACKAGE_WHITELIST_MODE_PROP =
+ // Copy of UserSystemPackageInstaller allowlist mode constants.
+ private static final String PACKAGE_ALLOWLIST_MODE_PROP =
"persist.debug.user.package_whitelist_mode";
- private static final int USER_TYPE_PACKAGE_WHITELIST_MODE_DISABLE = 0;
- private static final int USER_TYPE_PACKAGE_WHITELIST_MODE_ENFORCE = 0b001;
- private static final int USER_TYPE_PACKAGE_WHITELIST_MODE_IMPLICIT_WHITELIST = 0b100;
- private static final int USER_TYPE_PACKAGE_WHITELIST_MODE_DEVICE_DEFAULT = -1;
+ private static final int USER_TYPE_PACKAGE_ALLOWLIST_MODE_DISABLE = 0;
+ private static final int USER_TYPE_PACKAGE_ALLOWLIST_MODE_ENFORCE = 0b001;
+ private static final int USER_TYPE_PACKAGE_ALLOWLIST_MODE_IMPLICIT_ALLOWLIST = 0b100;
+ private static final int USER_TYPE_PACKAGE_ALLOWLIST_MODE_DEVICE_DEFAULT = -1;
private UserManager mUm;
private ActivityManager mAm;
@@ -1178,13 +1178,13 @@ public class UserLifecycleTests {
}
// TODO: This is just a POC. Do this properly and add more.
- /** Tests starting (unlocking) a newly-created profile using the user-type-pkg-whitelist. */
+ /** Tests starting (unlocking) a newly-created profile using the user-type-pkg-allowlist. */
@Test(timeout = TIMEOUT_MAX_TEST_TIME_MS)
public void managedProfileUnlock_usingWhitelist() throws RemoteException {
assumeTrue(mHasManagedUserFeature);
- final int origMode = getUserTypePackageWhitelistMode();
- setUserTypePackageWhitelistMode(USER_TYPE_PACKAGE_WHITELIST_MODE_ENFORCE
- | USER_TYPE_PACKAGE_WHITELIST_MODE_IMPLICIT_WHITELIST);
+ final int origMode = getUserTypePackageAllowlistMode();
+ setUserTypePackageAllowlistMode(USER_TYPE_PACKAGE_ALLOWLIST_MODE_ENFORCE
+ | USER_TYPE_PACKAGE_ALLOWLIST_MODE_IMPLICIT_ALLOWLIST);
try {
while (mRunner.keepRunning()) {
@@ -1201,15 +1201,15 @@ public class UserLifecycleTests {
mRunner.resumeTimingForNextIteration();
}
} finally {
- setUserTypePackageWhitelistMode(origMode);
+ setUserTypePackageAllowlistMode(origMode);
}
}
- /** Tests starting (unlocking) a newly-created profile NOT using the user-type-pkg-whitelist. */
+ /** Tests starting (unlocking) a newly-created profile NOT using the user-type-pkg-allowlist. */
@Test(timeout = TIMEOUT_MAX_TEST_TIME_MS)
public void managedProfileUnlock_notUsingWhitelist() throws RemoteException {
assumeTrue(mHasManagedUserFeature);
- final int origMode = getUserTypePackageWhitelistMode();
- setUserTypePackageWhitelistMode(USER_TYPE_PACKAGE_WHITELIST_MODE_DISABLE);
+ final int origMode = getUserTypePackageAllowlistMode();
+ setUserTypePackageAllowlistMode(USER_TYPE_PACKAGE_ALLOWLIST_MODE_DISABLE);
try {
while (mRunner.keepRunning()) {
@@ -1226,7 +1226,7 @@ public class UserLifecycleTests {
mRunner.resumeTimingForNextIteration();
}
} finally {
- setUserTypePackageWhitelistMode(origMode);
+ setUserTypePackageAllowlistMode(origMode);
}
}
@@ -1456,17 +1456,17 @@ public class UserLifecycleTests {
attestTrue(errMsg, success);
}
- /** Gets the PACKAGE_WHITELIST_MODE_PROP System Property. */
- private int getUserTypePackageWhitelistMode() {
- return SystemProperties.getInt(PACKAGE_WHITELIST_MODE_PROP,
- USER_TYPE_PACKAGE_WHITELIST_MODE_DEVICE_DEFAULT);
+ /** Gets the PACKAGE_ALLOWLIST_MODE_PROP System Property. */
+ private int getUserTypePackageAllowlistMode() {
+ return SystemProperties.getInt(PACKAGE_ALLOWLIST_MODE_PROP,
+ USER_TYPE_PACKAGE_ALLOWLIST_MODE_DEVICE_DEFAULT);
}
- /** Sets the PACKAGE_WHITELIST_MODE_PROP System Property to the given value. */
- private void setUserTypePackageWhitelistMode(int mode) {
+ /** Sets the PACKAGE_ALLOWLIST_MODE_PROP System Property to the given value. */
+ private void setUserTypePackageAllowlistMode(int mode) {
String result = ShellHelper.runShellCommand(
- String.format("setprop %s %d", PACKAGE_WHITELIST_MODE_PROP, mode));
- attestFalse("Failed to set sysprop " + PACKAGE_WHITELIST_MODE_PROP + ": " + result,
+ String.format("setprop %s %d", PACKAGE_ALLOWLIST_MODE_PROP, mode));
+ attestFalse("Failed to set sysprop " + PACKAGE_ALLOWLIST_MODE_PROP + ": " + result,
result != null && result.contains("Failed"));
}
diff --git a/apct-tests/perftests/windowmanager/src/android/wm/RelayoutPerfTest.java b/apct-tests/perftests/windowmanager/src/android/wm/RelayoutPerfTest.java
index b0da7d1e2870..c42c7ca25133 100644
--- a/apct-tests/perftests/windowmanager/src/android/wm/RelayoutPerfTest.java
+++ b/apct-tests/perftests/windowmanager/src/android/wm/RelayoutPerfTest.java
@@ -111,7 +111,7 @@ public class RelayoutPerfTest extends WindowManagerPerfTestBase
stopProfiling();
}
- /** A dummy view to get IWindow. */
+ /** A placeholder view to get IWindow. */
private static class ContentView extends LinearLayout {
ContentView(Context context) {
super(context);
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/apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java b/apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java
index 109686d76b2f..e636f604ddb0 100644
--- a/apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java
+++ b/apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java
@@ -456,6 +456,7 @@ public final class JobServiceContext implements ServiceConnection {
if (DEBUG) {
Slog.d(TAG, job.getServiceComponent().getShortClassName() + " unavailable.");
}
+ mContext.unbindService(this);
mRunningJob = null;
mRunningJobWorkType = WORK_TYPE_NONE;
mRunningCallback = null;
diff --git a/apex/jobscheduler/service/java/com/android/server/usage/AppIdleHistory.java b/apex/jobscheduler/service/java/com/android/server/usage/AppIdleHistory.java
index fb342b9ba9b3..913a76a65026 100644
--- a/apex/jobscheduler/service/java/com/android/server/usage/AppIdleHistory.java
+++ b/apex/jobscheduler/service/java/com/android/server/usage/AppIdleHistory.java
@@ -61,6 +61,7 @@ import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
@@ -802,6 +803,9 @@ public class AppIdleHistory {
}
}
}
+ } catch (FileNotFoundException e) {
+ // Expected on first boot
+ Slog.d(TAG, "App idle file for user " + userId + " does not exist");
} catch (IOException | XmlPullParserException e) {
Slog.e(TAG, "Unable to read app idle file for user " + userId, e);
} finally {
diff --git a/cmds/app_process/app_main.cpp b/cmds/app_process/app_main.cpp
index 28db61f7d98a..66248128ff29 100644
--- a/cmds/app_process/app_main.cpp
+++ b/cmds/app_process/app_main.cpp
@@ -49,7 +49,7 @@ public:
virtual void onVmCreated(JNIEnv* env)
{
- if (mClassName.isEmpty()) {
+ if (mClassName.empty()) {
return; // Zygote. Nothing to do here.
}
@@ -98,7 +98,7 @@ public:
virtual void onExit(int code)
{
- if (mClassName.isEmpty()) {
+ if (mClassName.empty()) {
// if zygote
IPCThreadState::self()->stopProcess();
hardware::IPCThreadState::self()->stopProcess();
@@ -282,7 +282,7 @@ int main(int argc, char* const argv[])
}
Vector<String8> args;
- if (!className.isEmpty()) {
+ if (!className.empty()) {
// We're not in zygote mode, the only argument we need to pass
// to RuntimeInit is the application argument.
//
@@ -328,13 +328,13 @@ int main(int argc, char* const argv[])
}
}
- if (!niceName.isEmpty()) {
+ if (!niceName.empty()) {
runtime.setArgv0(niceName.string(), true /* setProcName */);
}
if (zygote) {
runtime.start("com.android.internal.os.ZygoteInit", args, zygote);
- } else if (!className.isEmpty()) {
+ } else if (!className.empty()) {
runtime.start("com.android.internal.os.RuntimeInit", args, zygote);
} else {
fprintf(stderr, "Error: no class name or --zygote supplied.\n");
diff --git a/cmds/backup/backup.cpp b/cmds/backup/backup.cpp
index 8d9b528ae6a9..c2ce69011d92 100644
--- a/cmds/backup/backup.cpp
+++ b/cmds/backup/backup.cpp
@@ -75,7 +75,7 @@ static int perform_list(const char* filename)
size_t dataSize;
err = reader.ReadEntityHeader(&key, &dataSize);
if (err == 0) {
- printf(" entity: %s (%zu bytes)\n", key.string(), dataSize);
+ printf(" entity: %s (%zu bytes)\n", key.c_str(), dataSize);
} else {
printf(" Error reading entity header\n");
}
diff --git a/cmds/bootanimation/Android.bp b/cmds/bootanimation/Android.bp
index 3534624a58a2..98767ee733ad 100644
--- a/cmds/bootanimation/Android.bp
+++ b/cmds/bootanimation/Android.bp
@@ -74,4 +74,7 @@ cc_library_shared {
"libGLESv2",
"libgui",
],
+ whole_static_libs: [
+ "libc++fs",
+ ],
}
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp
index 782351c14399..fd79a04814fd 100644
--- a/cmds/bootanimation/BootAnimation.cpp
+++ b/cmds/bootanimation/BootAnimation.cpp
@@ -17,6 +17,7 @@
#define LOG_NDEBUG 0
#define LOG_TAG "BootAnimation"
+#include <filesystem>
#include <vector>
#include <stdint.h>
@@ -705,7 +706,7 @@ void BootAnimation::resizeSurface(int newWidth, int newHeight) {
bool BootAnimation::preloadAnimation() {
findBootAnimationFile();
- if (!mZipFileName.isEmpty()) {
+ if (!mZipFileName.empty()) {
mAnimation = loadAnimation(mZipFileName);
return (mAnimation != nullptr);
}
@@ -818,7 +819,7 @@ bool BootAnimation::threadLoop() {
// We have no bootanimation file, so we use the stock android logo
// animation.
- if (mZipFileName.isEmpty()) {
+ if (mZipFileName.empty()) {
ALOGD("No animation file");
result = android();
} else {
@@ -1269,10 +1270,10 @@ bool BootAnimation::preloadZip(Animation& animation) {
continue;
}
- const String8 entryName(name);
- const String8 path(entryName.getPathDir());
- const String8 leaf(entryName.getPathLeaf());
- if (leaf.size() > 0) {
+ const std::filesystem::path entryName(name);
+ const std::filesystem::path path(entryName.parent_path());
+ const std::filesystem::path leaf(entryName.filename());
+ if (!leaf.empty()) {
if (entryName == CLOCK_FONT_ZIP_NAME) {
FileMap* map = zip->createEntryFileMap(entry);
if (map) {
@@ -1290,7 +1291,7 @@ bool BootAnimation::preloadZip(Animation& animation) {
}
for (size_t j = 0; j < pcount; j++) {
- if (path == animation.parts[j].path) {
+ if (path.string() == animation.parts[j].path.c_str()) {
uint16_t method;
// supports only stored png files
if (zip->getEntryInfo(entry, &method, nullptr, nullptr, nullptr, nullptr, nullptr)) {
@@ -1307,7 +1308,7 @@ bool BootAnimation::preloadZip(Animation& animation) {
map->getDataLength());
} else {
Animation::Frame frame;
- frame.name = leaf;
+ frame.name = leaf.c_str();
frame.map = map;
frame.trimWidth = animation.width;
frame.trimHeight = animation.height;
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/api/module-lib-current.txt b/core/api/module-lib-current.txt
index 7cfa1e377933..b1feb419ecde 100644
--- a/core/api/module-lib-current.txt
+++ b/core/api/module-lib-current.txt
@@ -6,6 +6,7 @@ package android {
field public static final String CONTROL_AUTOMOTIVE_GNSS = "android.permission.CONTROL_AUTOMOTIVE_GNSS";
field public static final String GET_INTENT_SENDER_INTENT = "android.permission.GET_INTENT_SENDER_INTENT";
field public static final String MAKE_UID_VISIBLE = "android.permission.MAKE_UID_VISIBLE";
+ field public static final String USE_COMPANION_TRANSPORTS = "android.permission.USE_COMPANION_TRANSPORTS";
}
}
@@ -81,6 +82,29 @@ package android.app.admin {
}
+package android.companion {
+
+ public final class CompanionDeviceManager {
+ method @RequiresPermission(android.Manifest.permission.USE_COMPANION_TRANSPORTS) public void addOnMessageReceivedListener(@NonNull java.util.concurrent.Executor, int, @NonNull android.companion.CompanionDeviceManager.OnMessageReceivedListener);
+ method @RequiresPermission(android.Manifest.permission.USE_COMPANION_TRANSPORTS) public void addOnTransportsChangedListener(@NonNull java.util.concurrent.Executor, @NonNull android.companion.CompanionDeviceManager.OnTransportsChangedListener);
+ method @RequiresPermission(android.Manifest.permission.USE_COMPANION_TRANSPORTS) public void removeOnMessageReceivedListener(int, @NonNull android.companion.CompanionDeviceManager.OnMessageReceivedListener);
+ method @RequiresPermission(android.Manifest.permission.USE_COMPANION_TRANSPORTS) public void removeOnTransportsChangedListener(@NonNull android.companion.CompanionDeviceManager.OnTransportsChangedListener);
+ method @RequiresPermission(android.Manifest.permission.USE_COMPANION_TRANSPORTS) public void sendMessage(int, @NonNull byte[], @NonNull int[]);
+ field public static final int MESSAGE_REQUEST_CONTEXT_SYNC = 1667729539; // 0x63678883
+ field public static final int MESSAGE_REQUEST_PERMISSION_RESTORE = 1669491075; // 0x63826983
+ field public static final int MESSAGE_REQUEST_REMOTE_AUTHENTICATION = 1669494629; // 0x63827765
+ }
+
+ public static interface CompanionDeviceManager.OnMessageReceivedListener {
+ method public void onMessageReceived(int, @NonNull byte[]);
+ }
+
+ public static interface CompanionDeviceManager.OnTransportsChangedListener {
+ method public void onTransportsChanged(@NonNull java.util.List<android.companion.AssociationInfo>);
+ }
+
+}
+
package android.content {
public abstract class ContentProvider implements android.content.ComponentCallbacks2 {
diff --git a/core/api/test-current.txt b/core/api/test-current.txt
index 70377ab6a0d9..54633c05b6bc 100644
--- a/core/api/test-current.txt
+++ b/core/api/test-current.txt
@@ -836,6 +836,26 @@ package android.appwidget {
package android.companion {
+ public static final class AssociationInfo.Builder {
+ ctor public AssociationInfo.Builder(int, int, @NonNull String);
+ ctor public AssociationInfo.Builder(@NonNull android.companion.AssociationInfo);
+ method @NonNull public android.companion.AssociationInfo build();
+ method @NonNull public android.companion.AssociationInfo.Builder setAssociatedDevice(@Nullable android.companion.AssociatedDevice);
+ method @NonNull public android.companion.AssociationInfo.Builder setDeviceMacAddress(@Nullable android.net.MacAddress);
+ method @NonNull public android.companion.AssociationInfo.Builder setDeviceProfile(@Nullable String);
+ method @NonNull public android.companion.AssociationInfo.Builder setDisplayName(@Nullable CharSequence);
+ method @NonNull public android.companion.AssociationInfo.Builder setLastTimeConnected(long);
+ method @NonNull public android.companion.AssociationInfo.Builder setNotifyOnDeviceNearby(boolean);
+ method @NonNull public android.companion.AssociationInfo.Builder setRevoked(boolean);
+ method @NonNull public android.companion.AssociationInfo.Builder setSelfManaged(boolean);
+ method @NonNull public android.companion.AssociationInfo.Builder setSystemDataSyncFlags(int);
+ method @NonNull public android.companion.AssociationInfo.Builder setTimeApproved(long);
+ }
+
+ public final class CompanionDeviceManager {
+ field public static final int MESSAGE_REQUEST_PING = 1669362552; // 0x63807378
+ }
+
public abstract class CompanionDeviceService extends android.app.Service {
method public void onBindCompanionDeviceService(@NonNull android.content.Intent);
}
diff --git a/core/java/android/companion/AssociationInfo.java b/core/java/android/companion/AssociationInfo.java
index 0958a806a5ff..c62675023e0b 100644
--- a/core/java/android/companion/AssociationInfo.java
+++ b/core/java/android/companion/AssociationInfo.java
@@ -17,7 +17,9 @@ package android.companion;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SuppressLint;
import android.annotation.SystemApi;
+import android.annotation.TestApi;
import android.annotation.UserIdInt;
import android.net.MacAddress;
import android.os.Parcel;
@@ -41,23 +43,24 @@ public final class AssociationInfo implements Parcelable {
private static final String LAST_TIME_CONNECTED_NONE = "None";
/**
* A unique ID of this Association record.
- * Disclosed to the clients (ie. companion applications) for referring to this record (eg. in
+ * Disclosed to the clients (i.e. companion applications) for referring to this record (e.g. in
* {@code disassociate()} API call).
*/
private final int mId;
-
- private final @UserIdInt int mUserId;
- private final @NonNull String mPackageName;
-
- private final @Nullable MacAddress mDeviceMacAddress;
- private final @Nullable CharSequence mDisplayName;
- private final @Nullable String mDeviceProfile;
- private final @Nullable AssociatedDevice mAssociatedDevice;
-
+ @UserIdInt
+ private final int mUserId;
+ @NonNull
+ private final String mPackageName;
+ @Nullable
+ private final MacAddress mDeviceMacAddress;
+ @Nullable
+ private final CharSequence mDisplayName;
+ @Nullable
+ private final String mDeviceProfile;
+ @Nullable
+ private final AssociatedDevice mAssociatedDevice;
private final boolean mSelfManaged;
private final boolean mNotifyOnDeviceNearby;
- private final int mSystemDataSyncFlags;
-
/**
* Indicates that the association has been revoked (removed), but we keep the association
* record for final clean up (e.g. removing the app from the list of the role holders).
@@ -71,6 +74,7 @@ public final class AssociationInfo implements Parcelable {
* Default value is Long.MAX_VALUE.
*/
private final long mLastTimeConnectedMs;
+ private final int mSystemDataSyncFlags;
/**
* Creates a new Association.
@@ -80,8 +84,8 @@ public final class AssociationInfo implements Parcelable {
public AssociationInfo(int id, @UserIdInt int userId, @NonNull String packageName,
@Nullable MacAddress macAddress, @Nullable CharSequence displayName,
@Nullable String deviceProfile, @Nullable AssociatedDevice associatedDevice,
- boolean selfManaged, boolean notifyOnDeviceNearby, boolean revoked,
- long timeApprovedMs, long lastTimeConnectedMs, int systemDataSyncFlags) {
+ boolean selfManaged, boolean notifyOnDeviceNearby, boolean revoked, long timeApprovedMs,
+ long lastTimeConnectedMs, int systemDataSyncFlags) {
if (id <= 0) {
throw new IllegalArgumentException("Association ID should be greater than 0");
}
@@ -91,15 +95,12 @@ public final class AssociationInfo implements Parcelable {
}
mId = id;
-
mUserId = userId;
mPackageName = packageName;
-
mDeviceMacAddress = macAddress;
mDisplayName = displayName;
mDeviceProfile = deviceProfile;
mAssociatedDevice = associatedDevice;
-
mSelfManaged = selfManaged;
mNotifyOnDeviceNearby = notifyOnDeviceNearby;
mRevoked = revoked;
@@ -119,7 +120,8 @@ public final class AssociationInfo implements Parcelable {
* @return the ID of the user who "owns" this association.
* @hide
*/
- public @UserIdInt int getUserId() {
+ @UserIdInt
+ public int getUserId() {
return mUserId;
}
@@ -128,19 +130,22 @@ public final class AssociationInfo implements Parcelable {
* @hide
*/
@SystemApi
- public @NonNull String getPackageName() {
+ @NonNull
+ public String getPackageName() {
return mPackageName;
}
/**
* @return the MAC address of the device.
*/
- public @Nullable MacAddress getDeviceMacAddress() {
+ @Nullable
+ public MacAddress getDeviceMacAddress() {
return mDeviceMacAddress;
}
/** @hide */
- public @Nullable String getDeviceMacAddressAsString() {
+ @Nullable
+ public String getDeviceMacAddressAsString() {
return mDeviceMacAddress != null ? mDeviceMacAddress.toString().toUpperCase() : null;
}
@@ -150,7 +155,8 @@ public final class AssociationInfo implements Parcelable {
*
* @see AssociationRequest.Builder#setDisplayName(CharSequence)
*/
- public @Nullable CharSequence getDisplayName() {
+ @Nullable
+ public CharSequence getDisplayName() {
return mDisplayName;
}
@@ -159,7 +165,8 @@ public final class AssociationInfo implements Parcelable {
* association, or {@code null} if no specific profile was used.
* @see AssociationRequest.Builder#setDeviceProfile(String)
*/
- public @Nullable String getDeviceProfile() {
+ @Nullable
+ public String getDeviceProfile() {
return mDeviceProfile;
}
@@ -176,7 +183,8 @@ public final class AssociationInfo implements Parcelable {
* @return the companion device that was associated, or {@code null} if the device is
* self-managed or this association info was retrieved from persistent storage.
*/
- public @Nullable AssociatedDevice getAssociatedDevice() {
+ @Nullable
+ public AssociatedDevice getAssociatedDevice() {
return mAssociatedDevice;
}
@@ -217,14 +225,14 @@ public final class AssociationInfo implements Parcelable {
* @return the last time self reported disconnected for selfManaged only.
* @hide
*/
- public Long getLastTimeConnectedMs() {
+ public long getLastTimeConnectedMs() {
return mLastTimeConnectedMs;
}
/**
* @return Enabled system data sync flags set via
- * {@link CompanionDeviceManager#enableSystemDataSync(int, int)} and
- * {@link CompanionDeviceManager#disableSystemDataSync(int, int)}.
+ * {@link CompanionDeviceManager#enableSystemDataSyncForTypes(int, int)} (int, int)} and
+ * {@link CompanionDeviceManager#disableSystemDataSyncForTypes(int, int)} (int, int)}.
* Or by default all flags are 1 (enabled).
*/
public int getSystemDataSyncFlags() {
@@ -268,7 +276,8 @@ public final class AssociationInfo implements Parcelable {
}
/** @hide */
- public @NonNull String toShortString() {
+ @NonNull
+ public String toShortString() {
final StringBuilder sb = new StringBuilder();
sb.append("id=").append(mId);
if (mDeviceMacAddress != null) {
@@ -337,15 +346,12 @@ public final class AssociationInfo implements Parcelable {
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
dest.writeInt(mId);
-
dest.writeInt(mUserId);
dest.writeString(mPackageName);
-
dest.writeTypedObject(mDeviceMacAddress, 0);
dest.writeCharSequence(mDisplayName);
dest.writeString(mDeviceProfile);
dest.writeTypedObject(mAssociatedDevice, 0);
-
dest.writeBoolean(mSelfManaged);
dest.writeBoolean(mNotifyOnDeviceNearby);
dest.writeBoolean(mRevoked);
@@ -356,15 +362,12 @@ public final class AssociationInfo implements Parcelable {
private AssociationInfo(@NonNull Parcel in) {
mId = in.readInt();
-
mUserId = in.readInt();
mPackageName = in.readString();
-
mDeviceMacAddress = in.readTypedObject(MacAddress.CREATOR);
mDisplayName = in.readCharSequence();
mDeviceProfile = in.readString();
mAssociatedDevice = in.readTypedObject(AssociatedDevice.CREATOR);
-
mSelfManaged = in.readBoolean();
mNotifyOnDeviceNearby = in.readBoolean();
mRevoked = in.readBoolean();
@@ -388,71 +391,139 @@ public final class AssociationInfo implements Parcelable {
};
/**
- * Use this method to obtain a builder that you can use to create a copy of the
- * given {@link AssociationInfo} with modified values of {@code mLastTimeConnected}
- * or {@code mNotifyOnDeviceNearby}.
- * <p>
- * Note that you <b>must</b> call either {@link Builder#setLastTimeConnected(long)
- * setLastTimeConnected} or {@link Builder#setNotifyOnDeviceNearby(boolean)
- * setNotifyOnDeviceNearby} before you will be able to call {@link Builder#build() build}.
- *
- * This is ensured statically at compile time.
+ * Builder for {@link AssociationInfo}
*
* @hide
*/
- @NonNull
- public static NonActionableBuilder builder(@NonNull AssociationInfo info) {
- return new Builder(info);
- }
-
- /** @hide */
- public static final class Builder implements NonActionableBuilder {
- @NonNull
- private final AssociationInfo mOriginalInfo;
+ @TestApi
+ public static final class Builder {
+ private final int mId;
+ private final int mUserId;
+ private final String mPackageName;
+ private MacAddress mDeviceMacAddress;
+ private CharSequence mDisplayName;
+ private String mDeviceProfile;
+ private AssociatedDevice mAssociatedDevice;
+ private boolean mSelfManaged;
private boolean mNotifyOnDeviceNearby;
private boolean mRevoked;
+ private long mTimeApprovedMs;
private long mLastTimeConnectedMs;
private int mSystemDataSyncFlags;
- private Builder(@NonNull AssociationInfo info) {
- mOriginalInfo = info;
+ /** @hide */
+ @TestApi
+ public Builder(int id, int userId, @NonNull String packageName) {
+ mId = id;
+ mUserId = userId;
+ mPackageName = packageName;
+ }
+
+ /** @hide */
+ @TestApi
+ public Builder(@NonNull AssociationInfo info) {
+ mId = info.mId;
+ mUserId = info.mUserId;
+ mPackageName = info.mPackageName;
+ mDeviceMacAddress = info.mDeviceMacAddress;
+ mDisplayName = info.mDisplayName;
+ mDeviceProfile = info.mDeviceProfile;
+ mAssociatedDevice = info.mAssociatedDevice;
+ mSelfManaged = info.mSelfManaged;
mNotifyOnDeviceNearby = info.mNotifyOnDeviceNearby;
mRevoked = info.mRevoked;
+ mTimeApprovedMs = info.mTimeApprovedMs;
mLastTimeConnectedMs = info.mLastTimeConnectedMs;
mSystemDataSyncFlags = info.mSystemDataSyncFlags;
}
/** @hide */
- @Override
+ @TestApi
@NonNull
- public Builder setLastTimeConnected(long lastTimeConnectedMs) {
- if (lastTimeConnectedMs < 0) {
- throw new IllegalArgumentException(
- "lastTimeConnectedMs must not be negative! (Given " + lastTimeConnectedMs
- + " )");
- }
- mLastTimeConnectedMs = lastTimeConnectedMs;
+ public Builder setDeviceMacAddress(@Nullable MacAddress deviceMacAddress) {
+ mDeviceMacAddress = deviceMacAddress;
return this;
}
/** @hide */
- @Override
+ @TestApi
@NonNull
+ public Builder setDisplayName(@Nullable CharSequence displayName) {
+ mDisplayName = displayName;
+ return this;
+ }
+
+ /** @hide */
+ @TestApi
+ @NonNull
+ public Builder setDeviceProfile(@Nullable String deviceProfile) {
+ mDeviceProfile = deviceProfile;
+ return this;
+ }
+
+ /** @hide */
+ @TestApi
+ @NonNull
+ public Builder setAssociatedDevice(@Nullable AssociatedDevice associatedDevice) {
+ mAssociatedDevice = associatedDevice;
+ return this;
+ }
+
+ /** @hide */
+ @TestApi
+ @NonNull
+ public Builder setSelfManaged(boolean selfManaged) {
+ mSelfManaged = selfManaged;
+ return this;
+ }
+
+ /** @hide */
+ @TestApi
+ @NonNull
+ @SuppressLint("MissingGetterMatchingBuilder")
public Builder setNotifyOnDeviceNearby(boolean notifyOnDeviceNearby) {
mNotifyOnDeviceNearby = notifyOnDeviceNearby;
return this;
}
/** @hide */
- @Override
+ @TestApi
@NonNull
+ @SuppressLint("MissingGetterMatchingBuilder")
public Builder setRevoked(boolean revoked) {
mRevoked = revoked;
return this;
}
/** @hide */
- @Override
+ @TestApi
+ @NonNull
+ @SuppressLint("MissingGetterMatchingBuilder")
+ public Builder setTimeApproved(long timeApprovedMs) {
+ if (timeApprovedMs < 0) {
+ throw new IllegalArgumentException("timeApprovedMs must be positive. Was given ("
+ + timeApprovedMs + ")");
+ }
+ mTimeApprovedMs = timeApprovedMs;
+ return this;
+ }
+
+ /** @hide */
+ @TestApi
+ @NonNull
+ @SuppressLint("MissingGetterMatchingBuilder")
+ public Builder setLastTimeConnected(long lastTimeConnectedMs) {
+ if (lastTimeConnectedMs < 0) {
+ throw new IllegalArgumentException(
+ "lastTimeConnectedMs must not be negative! (Given " + lastTimeConnectedMs
+ + " )");
+ }
+ mLastTimeConnectedMs = lastTimeConnectedMs;
+ return this;
+ }
+
+ /** @hide */
+ @TestApi
@NonNull
public Builder setSystemDataSyncFlags(int flags) {
mSystemDataSyncFlags = flags;
@@ -460,53 +531,31 @@ public final class AssociationInfo implements Parcelable {
}
/** @hide */
+ @TestApi
@NonNull
public AssociationInfo build() {
+ if (mId <= 0) {
+ throw new IllegalArgumentException("Association ID should be greater than 0");
+ }
+ if (mDeviceMacAddress == null && mDisplayName == null) {
+ throw new IllegalArgumentException("MAC address and the display name must NOT be "
+ + "null at the same time");
+ }
return new AssociationInfo(
- mOriginalInfo.mId,
- mOriginalInfo.mUserId,
- mOriginalInfo.mPackageName,
- mOriginalInfo.mDeviceMacAddress,
- mOriginalInfo.mDisplayName,
- mOriginalInfo.mDeviceProfile,
- mOriginalInfo.mAssociatedDevice,
- mOriginalInfo.mSelfManaged,
+ mId,
+ mUserId,
+ mPackageName,
+ mDeviceMacAddress,
+ mDisplayName,
+ mDeviceProfile,
+ mAssociatedDevice,
+ mSelfManaged,
mNotifyOnDeviceNearby,
mRevoked,
- mOriginalInfo.mTimeApprovedMs,
+ mTimeApprovedMs,
mLastTimeConnectedMs,
mSystemDataSyncFlags
);
}
}
-
- /**
- * This interface is returned from the
- * {@link AssociationInfo#builder(android.companion.AssociationInfo) builder} entry point
- * to indicate that this builder is not yet in a state that can produce a meaningful
- * {@link AssociationInfo} object that is different from the one originally passed in.
- *
- * <p>
- * Only by calling one of the setter methods is this builder turned into one where calling
- * {@link Builder#build() build()} makes sense.
- *
- * @hide
- */
- public interface NonActionableBuilder {
- /** @hide */
- @NonNull
- Builder setNotifyOnDeviceNearby(boolean notifyOnDeviceNearby);
-
- /** @hide */
- @NonNull
- Builder setLastTimeConnected(long lastTimeConnectedMs);
-
- /** @hide */
- @NonNull
- Builder setRevoked(boolean revoked);
-
- /** @hide */
- @NonNull
- Builder setSystemDataSyncFlags(int flags);
- }
}
diff --git a/core/java/android/companion/CompanionDeviceManager.java b/core/java/android/companion/CompanionDeviceManager.java
index 4dea4a7e3aca..c77c3c48dde4 100644
--- a/core/java/android/companion/CompanionDeviceManager.java
+++ b/core/java/android/companion/CompanionDeviceManager.java
@@ -20,7 +20,9 @@ import static android.Manifest.permission.REQUEST_COMPANION_PROFILE_APP_STREAMIN
import static android.Manifest.permission.REQUEST_COMPANION_PROFILE_AUTOMOTIVE_PROJECTION;
import static android.Manifest.permission.REQUEST_COMPANION_PROFILE_COMPUTER;
import static android.Manifest.permission.REQUEST_COMPANION_PROFILE_WATCH;
+import static android.annotation.SystemApi.Client.MODULE_LIBRARIES;
+import android.annotation.CallbackExecutor;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -28,6 +30,7 @@ import android.annotation.RequiresPermission;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.annotation.SystemService;
+import android.annotation.TestApi;
import android.annotation.UserHandleAware;
import android.app.Activity;
import android.app.ActivityManager;
@@ -216,6 +219,34 @@ public final class CompanionDeviceManager {
"com.android.companiondevicemanager";
/**
+ * Test message type without a designated callback.
+ *
+ * @hide
+ */
+ @TestApi public static final int MESSAGE_REQUEST_PING = 0x63807378; // ?PIN
+ /**
+ * Message header assigned to the remote authentication handshakes.
+ *
+ * @hide
+ */
+ @SystemApi(client = MODULE_LIBRARIES)
+ public static final int MESSAGE_REQUEST_REMOTE_AUTHENTICATION = 0x63827765; // ?RMA
+ /**
+ * Message header assigned to the telecom context sync metadata.
+ *
+ * @hide
+ */
+ @SystemApi(client = MODULE_LIBRARIES)
+ public static final int MESSAGE_REQUEST_CONTEXT_SYNC = 0x63678883; // ?CXS
+ /**
+ * Message header assigned to the permission restore request.
+ *
+ * @hide
+ */
+ @SystemApi(client = MODULE_LIBRARIES)
+ public static final int MESSAGE_REQUEST_PERMISSION_RESTORE = 0x63826983; // ?RES
+
+ /**
* Callback for applications to receive updates about and the outcome of
* {@link AssociationRequest} issued via {@code associate()} call.
*
@@ -804,28 +835,36 @@ public final class CompanionDeviceManager {
}
/**
- * Listener for any changes to {@link com.android.server.companion.transport.Transport}.
+ * Listener for any changes to the list of attached transports.
+ *
+ * @see com.android.server.companion.transport.Transport
*
* @hide
*/
+ @SystemApi(client = MODULE_LIBRARIES)
public interface OnTransportsChangedListener {
/**
- * Invoked when a change occurs to any of the transports
+ * Invoked when a transport is attached or detached.
*
- * @param associations all the associations which have connected transports
+ * @param associations all the associations which have connected transports.
*/
void onTransportsChanged(@NonNull List<AssociationInfo> associations);
}
/**
- * Register a listener for any changes to
- * {@link com.android.server.companion.transport.Transport}. Your app will receive a callback to
- * {@link OnTransportsChangedListener} immediately with all the existing transports.
+ * Adds a listener for any changes to the list of attached transports.
+ * {@link OnTransportsChangedListener#onTransportsChanged(List)} will be triggered with a list
+ * of existing transports when a transport is detached or a new transport is attached.
+ *
+ * @see com.android.server.companion.transport.Transport
*
* @hide
*/
+ @SystemApi(client = MODULE_LIBRARIES)
+ @RequiresPermission(android.Manifest.permission.USE_COMPANION_TRANSPORTS)
public void addOnTransportsChangedListener(
- @NonNull Executor executor, @NonNull OnTransportsChangedListener listener) {
+ @NonNull @CallbackExecutor Executor executor,
+ @NonNull OnTransportsChangedListener listener) {
final OnTransportsChangedListenerProxy proxy = new OnTransportsChangedListenerProxy(
executor, listener);
try {
@@ -836,11 +875,14 @@ public final class CompanionDeviceManager {
}
/**
- * Unregister a listener to stop receiving any changes to
- * {@link com.android.server.companion.transport.Transport}.
+ * Removes the registered listener for any changes to the list of attached transports.
+ *
+ * @see com.android.server.companion.transport.Transport
*
* @hide
*/
+ @SystemApi(client = MODULE_LIBRARIES)
+ @RequiresPermission(android.Manifest.permission.USE_COMPANION_TRANSPORTS)
public void removeOnTransportsChangedListener(
@NonNull OnTransportsChangedListener listener) {
final OnTransportsChangedListenerProxy proxy = new OnTransportsChangedListenerProxy(
@@ -853,11 +895,16 @@ public final class CompanionDeviceManager {
}
/**
- * Send a message to remote devices
+ * Sends a message to associated remote devices. The target associations must already have a
+ * connected transport.
+ *
+ * @see #attachSystemDataTransport(int, InputStream, OutputStream)
*
* @hide
*/
- public void sendMessage(int messageType, byte[] data, int[] associationIds) {
+ @SystemApi(client = MODULE_LIBRARIES)
+ @RequiresPermission(android.Manifest.permission.USE_COMPANION_TRANSPORTS)
+ public void sendMessage(int messageType, @NonNull byte[] data, @NonNull int[] associationIds) {
try {
mService.sendMessage(messageType, data, associationIds);
} catch (RemoteException e) {
@@ -866,28 +913,30 @@ public final class CompanionDeviceManager {
}
/**
- * Listener when a message is received for the registered message type
+ * Listener that triggers a callback when a message is received through a connected transport.
*
* @see #addOnMessageReceivedListener(Executor, int, OnMessageReceivedListener)
*
* @hide
*/
+ @SystemApi(client = MODULE_LIBRARIES)
public interface OnMessageReceivedListener {
/**
- * Called when a message is received
+ * Called when a message is received.
*/
- void onMessageReceived(int associationId, byte[] data);
+ void onMessageReceived(int associationId, @NonNull byte[] data);
}
/**
- * Register a listener to receive callbacks when a message is received by the given type
- *
- * @see com.android.server.companion.transport.Transport for supported message types
+ * Adds a listener to trigger callbacks when messages of given type are received.
*
* @hide
*/
- public void addOnMessageReceivedListener(@NonNull Executor executor, int messageType,
- OnMessageReceivedListener listener) {
+ @SystemApi(client = MODULE_LIBRARIES)
+ @RequiresPermission(android.Manifest.permission.USE_COMPANION_TRANSPORTS)
+ public void addOnMessageReceivedListener(
+ @NonNull @CallbackExecutor Executor executor, int messageType,
+ @NonNull OnMessageReceivedListener listener) {
final OnMessageReceivedListenerProxy proxy = new OnMessageReceivedListenerProxy(
executor, listener);
try {
@@ -898,15 +947,14 @@ public final class CompanionDeviceManager {
}
/**
- * Unregister a listener to stop receiving callbacks when a message is received by the given
- * type
- *
- * @see com.android.server.companion.transport.Transport for supported message types
+ * Removes the registered listener for received messages of given type.
*
* @hide
*/
+ @SystemApi(client = MODULE_LIBRARIES)
+ @RequiresPermission(android.Manifest.permission.USE_COMPANION_TRANSPORTS)
public void removeOnMessageReceivedListener(int messageType,
- OnMessageReceivedListener listener) {
+ @NonNull OnMessageReceivedListener listener) {
final OnMessageReceivedListenerProxy proxy = new OnMessageReceivedListenerProxy(
null, listener);
try {
diff --git a/core/java/android/companion/ICompanionDeviceManager.aidl b/core/java/android/companion/ICompanionDeviceManager.aidl
index b5e2670e5299..1e95fb3fa532 100644
--- a/core/java/android/companion/ICompanionDeviceManager.aidl
+++ b/core/java/android/companion/ICompanionDeviceManager.aidl
@@ -69,14 +69,19 @@ interface ICompanionDeviceManager {
void removeOnAssociationsChangedListener(IOnAssociationsChangedListener listener, int userId);
+ @EnforcePermission("USE_COMPANION_TRANSPORTS")
void addOnTransportsChangedListener(IOnTransportsChangedListener listener);
+ @EnforcePermission("USE_COMPANION_TRANSPORTS")
void removeOnTransportsChangedListener(IOnTransportsChangedListener listener);
+ @EnforcePermission("USE_COMPANION_TRANSPORTS")
void sendMessage(int messageType, in byte[] data, in int[] associationIds);
+ @EnforcePermission("USE_COMPANION_TRANSPORTS")
void addOnMessageReceivedListener(int messageType, IOnMessageReceivedListener listener);
+ @EnforcePermission("USE_COMPANION_TRANSPORTS")
void removeOnMessageReceivedListener(int messageType, IOnMessageReceivedListener listener);
void notifyDeviceAppeared(int associationId);
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index b5b2e6582969..4e241617cc6e 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -592,7 +592,7 @@ public abstract class Context {
public static final int BIND_IMPORTANT_BACKGROUND = 0x00800000;
/**
- * @hide Flag for {@link #bindService}: allows application hosting service to manage whitelists
+ * @hide Flag for {@link #bindService}: allows application hosting service to manage allowlists
* such as temporary allowing a {@code PendingIntent} to bypass Power Save mode.
*/
public static final int BIND_ALLOW_WHITELIST_MANAGEMENT = 0x01000000;
diff --git a/core/java/android/content/IntentSender.java b/core/java/android/content/IntentSender.java
index ccb53cf29fd4..406c79d2dba0 100644
--- a/core/java/android/content/IntentSender.java
+++ b/core/java/android/content/IntentSender.java
@@ -396,9 +396,9 @@ public class IntentSender implements Parcelable {
}
/** @hide */
- public IntentSender(IIntentSender target, IBinder whitelistToken) {
+ public IntentSender(IIntentSender target, IBinder allowlistToken) {
mTarget = target;
- mWhitelistToken = whitelistToken;
+ mWhitelistToken = allowlistToken;
}
/** @hide */
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/java/android/text/flags/use_bounds_for_width.aconfig b/core/java/android/text/flags/use_bounds_for_width.aconfig
new file mode 100644
index 000000000000..d89d5f4c7216
--- /dev/null
+++ b/core/java/android/text/flags/use_bounds_for_width.aconfig
@@ -0,0 +1,8 @@
+package: "com.android.text.flags"
+
+flag {
+ name: "use_bounds_for_width"
+ namespace: "text"
+ description: "Feature flag for preventing horizontal clipping."
+ bug: "63938206"
+}
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 8dbeb27dc0a8..03a6a00e6af4 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -5318,11 +5318,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
@Retention(RetentionPolicy.SOURCE)
public @interface LayerType {}
- @ViewDebug.ExportedProperty(category = "drawing", mapping = {
- @ViewDebug.IntToString(from = LAYER_TYPE_NONE, to = "NONE"),
- @ViewDebug.IntToString(from = LAYER_TYPE_SOFTWARE, to = "SOFTWARE"),
- @ViewDebug.IntToString(from = LAYER_TYPE_HARDWARE, to = "HARDWARE")
- })
int mLayerType = LAYER_TYPE_NONE;
Paint mLayerPaint;
@@ -22507,6 +22502,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
@EnumEntry(value = LAYER_TYPE_SOFTWARE, name = "software"),
@EnumEntry(value = LAYER_TYPE_HARDWARE, name = "hardware")
})
+ @ViewDebug.ExportedProperty(category = "drawing", mapping = {
+ @ViewDebug.IntToString(from = LAYER_TYPE_NONE, to = "NONE"),
+ @ViewDebug.IntToString(from = LAYER_TYPE_SOFTWARE, to = "SOFTWARE"),
+ @ViewDebug.IntToString(from = LAYER_TYPE_HARDWARE, to = "HARDWARE")
+ })
@LayerType
public int getLayerType() {
return mLayerType;
diff --git a/core/jni/android_hardware_Camera.cpp b/core/jni/android_hardware_Camera.cpp
index 1c597424f221..eb49f411159c 100644
--- a/core/jni/android_hardware_Camera.cpp
+++ b/core/jni/android_hardware_Camera.cpp
@@ -874,7 +874,7 @@ static jstring android_hardware_Camera_getParameters(JNIEnv *env, jobject thiz)
if (camera == 0) return 0;
String8 params8 = camera->getParameters();
- if (params8.isEmpty()) {
+ if (params8.empty()) {
jniThrowRuntimeException(env, "getParameters failed (empty parameters)");
return 0;
}
diff --git a/core/jni/android_hardware_camera2_CameraMetadata.cpp b/core/jni/android_hardware_camera2_CameraMetadata.cpp
index 5293c583cfd0..3e4c7c7f751e 100644
--- a/core/jni/android_hardware_camera2_CameraMetadata.cpp
+++ b/core/jni/android_hardware_camera2_CameraMetadata.cpp
@@ -526,7 +526,7 @@ static void CameraMetadata_dump(JNIEnv *env, jclass thiz, jlong ptr) {
"Failed to read from fd (errno = %#x, message = '%s')",
errno, strerror(errno));
//return;
- } else if (!logLine.isEmpty()) {
+ } else if (!logLine.empty()) {
ALOGD("%s", logLine.string());
}
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/core/jni/android_util_Process.cpp b/core/jni/android_util_Process.cpp
index 4f2bf4a4f6cb..b1d3d92023ad 100644
--- a/core/jni/android_util_Process.cpp
+++ b/core/jni/android_util_Process.cpp
@@ -583,7 +583,7 @@ void android_os_Process_setArgV0(JNIEnv* env, jobject clazz, jstring name)
env->ReleaseStringCritical(name, str);
}
- if (!name8.isEmpty()) {
+ if (!name8.empty()) {
AndroidRuntime::getRuntime()->setArgv0(name8.string(), true /* setProcName */);
}
}
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 7d9d99113663..c16daccac081 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -5633,6 +5633,12 @@
android:description="@string/permdesc_deliverCompanionMessages"
android:protectionLevel="normal" />
+ <!-- @hide @SystemApi(client=android.annotation.SystemApi.Client.MODULE_LIBRARIES)
+ Allows an application to send and receive messages via CDM transports.
+ -->
+ <permission android:name="android.permission.USE_COMPANION_TRANSPORTS"
+ android:protectionLevel="signature|module" />
+
<!-- Allows an application to create new companion device associations.
@SystemApi
@hide -->
diff --git a/core/tests/PackageInstallerSessions/src/android/content/pm/PackageSessionTests.kt b/core/tests/PackageInstallerSessions/src/android/content/pm/PackageSessionTests.kt
index 9acb99a8c1c2..b794352e5e27 100644
--- a/core/tests/PackageInstallerSessions/src/android/content/pm/PackageSessionTests.kt
+++ b/core/tests/PackageInstallerSessions/src/android/content/pm/PackageSessionTests.kt
@@ -445,7 +445,9 @@ class PackageSessionTests {
Manifest.permission.UPDATE_PACKAGES_WITHOUT_USER_ACTION)
}
handlerThread = HandlerThread("PackageSessionTests")
- handlerThread?.start()
- handler = Handler(handlerThread?.looper)
+ handlerThread?.let {
+ it.start()
+ handler = Handler(it.looper)
+ }
}
}
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/location/java/android/location/GnssRequest.java b/location/java/android/location/GnssRequest.java
index 9c9766fd02d6..f3a40cc3af40 100644
--- a/location/java/android/location/GnssRequest.java
+++ b/location/java/android/location/GnssRequest.java
@@ -41,7 +41,7 @@ public final class GnssRequest implements Parcelable {
*
* <p>If true, GNSS chipset switches off duty cycling. In such a mode, no clock
* discontinuities are expected, and when supported, carrier phase should be continuous in
- * good signal conditions. All non-blacklisted, healthy constellations, satellites and
+ * good signal conditions. All non-denylisted, healthy constellations, satellites and
* frequency bands that the chipset supports must be reported in this mode. The GNSS chipset
* is allowed to consume more power in this mode. If false, GNSS chipset optimizes power via
* duty cycling, constellations and frequency limits, etc.
@@ -138,7 +138,7 @@ public final class GnssRequest implements Parcelable {
*
* <p>If true, GNSS chipset switches off duty cycling. In such a mode, no clock
* discontinuities are expected, and when supported, carrier phase should be continuous in
- * good signal conditions. All non-blacklisted, healthy constellations, satellites and
+ * good signal conditions. All non-denylisted, healthy constellations, satellites and
* frequency bands that the chipset supports must be reported in this mode. The GNSS chipset
* is allowed to consume more power in this mode. If false, GNSS chipset optimizes power via
* duty cycling, constellations and frequency limits, etc.
diff --git a/media/java/android/media/Cea708CaptionRenderer.java b/media/java/android/media/Cea708CaptionRenderer.java
index 88912fef4501..efaf3d22f489 100644
--- a/media/java/android/media/Cea708CaptionRenderer.java
+++ b/media/java/android/media/Cea708CaptionRenderer.java
@@ -194,7 +194,7 @@ class Cea708CCParser {
private final StringBuffer mBuffer = new StringBuffer();
private int mCommand = 0;
- // Assign a dummy listener in order to avoid null checks.
+ // Assign a placeholder listener in order to avoid null checks.
private DisplayListener mListener = new DisplayListener() {
@Override
public void emitEvent(CaptionEvent event) {
diff --git a/media/java/android/media/session/MediaSession.java b/media/java/android/media/session/MediaSession.java
index 29e8716f08ac..6121b8837f4f 100644
--- a/media/java/android/media/session/MediaSession.java
+++ b/media/java/android/media/session/MediaSession.java
@@ -267,17 +267,22 @@ public final class MediaSession {
}
/**
- * Set a pending intent for your media button receiver to allow restarting
- * playback after the session has been stopped. If your app is started in
- * this way an {@link Intent#ACTION_MEDIA_BUTTON} intent will be sent via
- * the pending intent.
- * <p>
- * The pending intent is recommended to be explicit to follow the security recommendation of
- * {@link PendingIntent#getActivity}.
+ * Set a pending intent for your media button receiver to allow restarting playback after the
+ * session has been stopped.
+ *
+ * <p>If your app is started in this way an {@link Intent#ACTION_MEDIA_BUTTON} intent will be
+ * sent via the pending intent.
+ *
+ * <p>The provided {@link PendingIntent} must not target an activity. Passing an activity
+ * pending intent will cause the call to be ignored. Refer to this <a
+ * href="https://developer.android.com/guide/components/activities/background-starts">guide</a>
+ * for more information.
+ *
+ * <p>The pending intent is recommended to be explicit to follow the security recommendation of
+ * {@link PendingIntent#getService}.
*
* @param mbr The {@link PendingIntent} to send the media button event to.
* @see PendingIntent#getActivity
- *
* @deprecated Use {@link #setMediaButtonBroadcastReceiver(ComponentName)} instead.
*/
@Deprecated
@@ -285,7 +290,7 @@ public final class MediaSession {
try {
mBinder.setMediaButtonReceiver(mbr);
} catch (RemoteException e) {
- Log.wtf(TAG, "Failure in setMediaButtonReceiver.", e);
+ e.rethrowFromSystemServer();
}
}
diff --git a/media/java/android/media/voice/KeyphraseModelManager.java b/media/java/android/media/voice/KeyphraseModelManager.java
index 5a690a57dbb2..b4bf428d6e7e 100644
--- a/media/java/android/media/voice/KeyphraseModelManager.java
+++ b/media/java/android/media/voice/KeyphraseModelManager.java
@@ -37,7 +37,7 @@ import java.util.Objects;
* This class provides management of voice based sound recognition models. Usage of this class is
* restricted to system or signature applications only. This allows OEMs to write apps that can
* manage voice based sound trigger models.
- * Callers of this class are expected to have whitelist manifest permission MANAGE_VOICE_KEYPHRASES.
+ * Callers of this class are expected to have allowlist manifest permission MANAGE_VOICE_KEYPHRASES.
* Callers of this class are expected to be the designated voice interaction service via
* {@link Settings.Secure.VOICE_INTERACTION_SERVICE} or a bundled voice model enrollment application
* detected by {@link android.hardware.soundtrigger.KeyphraseEnrollmentInfo}.
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/EasterEgg/src/com/android/egg/quares/QuaresActivity.kt b/packages/EasterEgg/src/com/android/egg/quares/QuaresActivity.kt
index 5fa61373a686..562f7be5ae1e 100644
--- a/packages/EasterEgg/src/com/android/egg/quares/QuaresActivity.kt
+++ b/packages/EasterEgg/src/com/android/egg/quares/QuaresActivity.kt
@@ -293,7 +293,7 @@ class ClueView(context: Context) : View(context) {
return correct
}
- override fun onDraw(canvas: Canvas?) {
+ override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
if (!showText) return
canvas?.let {
diff --git a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/app/AppListRepository.kt b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/app/AppListRepository.kt
index 2b38b4cefe3e..657c391da7c2 100644
--- a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/app/AppListRepository.kt
+++ b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/app/AppListRepository.kt
@@ -75,6 +75,7 @@ internal class AppListRepositoryImpl(private val context: Context) : AppListRepo
packageManager.getInstalledModules(0)
.filter { it.isHidden }
.map { it.packageName }
+ .filterNotNull()
.toSet()
}
val hideWhenDisabledPackagesDeferred = async {
diff --git a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/app/PackageManagers.kt b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/app/PackageManagers.kt
index 69c6131679a9..92fd0cd07777 100644
--- a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/app/PackageManagers.kt
+++ b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/app/PackageManagers.kt
@@ -82,7 +82,8 @@ internal class PackageManagersImpl(
val packageInfo = getPackageInfoAsUser(packageName, PackageManager.GET_PERMISSIONS, userId)
val index = packageInfo?.requestedPermissions?.indexOf(permission) ?: return false
return index >= 0 &&
- packageInfo.requestedPermissionsFlags[index].hasFlag(REQUESTED_PERMISSION_GRANTED)
+ checkNotNull(packageInfo.requestedPermissionsFlags)[index]
+ .hasFlag(REQUESTED_PERMISSION_GRANTED)
}
override suspend fun getAppOpPermissionPackages(userId: Int, permission: String): Set<String> =
diff --git a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/enterprise/EnterpriseRepository.kt b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/enterprise/EnterpriseRepository.kt
index fab3ae8e510b..20beec73c958 100644
--- a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/enterprise/EnterpriseRepository.kt
+++ b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/enterprise/EnterpriseRepository.kt
@@ -28,7 +28,7 @@ class EnterpriseRepository(private val context: Context) {
}
fun getEnterpriseString(updatableStringId: String, resId: Int): String =
- resources.getString(updatableStringId) { context.getString(resId) }
+ checkNotNull(resources.getString(updatableStringId) { context.getString(resId) })
fun getProfileTitle(isManagedProfile: Boolean): String = if (isManagedProfile) {
getEnterpriseString(WORK_CATEGORY_HEADER, R.string.category_work)
diff --git a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/AppInfo.kt b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/AppInfo.kt
index a0ff216875a2..55a438f1f1fd 100644
--- a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/AppInfo.kt
+++ b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/AppInfo.kt
@@ -55,7 +55,7 @@ class AppInfoProvider(private val packageInfo: PackageInfo) {
.semantics(mergeDescendants = true) {},
horizontalAlignment = Alignment.CenterHorizontally,
) {
- val app = packageInfo.applicationInfo
+ val app = checkNotNull(packageInfo.applicationInfo)
Box(modifier = Modifier.padding(SettingsDimension.itemPaddingAround)) {
AppIcon(app = app, size = SettingsDimension.appIconInfoSize)
}
diff --git a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/TogglePermissionAppInfoPage.kt b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/TogglePermissionAppInfoPage.kt
index 7c689c62427e..1a627409632e 100644
--- a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/TogglePermissionAppInfoPage.kt
+++ b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/TogglePermissionAppInfoPage.kt
@@ -144,7 +144,7 @@ internal fun TogglePermissionAppListModel<out AppRecord>.TogglePermissionAppInfo
footerContent = footerContent(),
packageManagers = packageManagers,
) {
- val model = createSwitchModel(applicationInfo)
+ val model = createSwitchModel(checkNotNull(applicationInfo))
val restrictions = Restrictions(userId, switchRestrictionKeys)
RestrictedSwitchPreference(model, restrictions, restrictionsProviderFactory)
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java
index f12aa26f6778..755d971e28a6 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java
@@ -307,8 +307,8 @@ public class BluetoothUtils {
*/
public static boolean isDeviceClassMatched(@NonNull BluetoothDevice bluetoothDevice,
int device) {
- return bluetoothDevice.getBluetoothClass() != null
- && bluetoothDevice.getBluetoothClass().getDeviceClass() == device;
+ final BluetoothClass bluetoothClass = bluetoothDevice.getBluetoothClass();
+ return bluetoothClass != null && bluetoothClass.getDeviceClass() == device;
}
private static boolean isAdvancedHeaderEnabled() {
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/OWNERS b/packages/SettingsLib/src/com/android/settingslib/bluetooth/OWNERS
index 5e6697289d5a..7669e79b42be 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/OWNERS
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/OWNERS
@@ -3,7 +3,10 @@ siyuanh@google.com
hughchen@google.com
timhypeng@google.com
robertluo@google.com
-changbetty@google.com
songferngwang@google.com
+yqian@google.com
+chelseahao@google.com
+yiyishen@google.com
+hahong@google.com
# Emergency approvers in case the above are not available
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/Shell/AndroidManifest.xml b/packages/Shell/AndroidManifest.xml
index ee9883b0b0af..809202fa024d 100644
--- a/packages/Shell/AndroidManifest.xml
+++ b/packages/Shell/AndroidManifest.xml
@@ -337,6 +337,7 @@
<uses-permission android:name="android.permission.REQUEST_COMPANION_PROFILE_WATCH" />
<uses-permission android:name="android.permission.REQUEST_COMPANION_PROFILE_GLASSES" />
<uses-permission android:name="android.permission.REQUEST_COMPANION_SELF_MANAGED" />
+ <uses-permission android:name="android.permission.USE_COMPANION_TRANSPORTS" />
<uses-permission android:name="android.permission.MANAGE_APPOPS" />
<uses-permission android:name="android.permission.WATCH_APPOPS" />
diff --git a/packages/StatementService/src/com/android/statementservice/utils/StatementUtils.kt b/packages/StatementService/src/com/android/statementservice/utils/StatementUtils.kt
index 92d752c83a9f..4837aad3a025 100644
--- a/packages/StatementService/src/com/android/statementservice/utils/StatementUtils.kt
+++ b/packages/StatementService/src/com/android/statementservice/utils/StatementUtils.kt
@@ -88,6 +88,7 @@ internal object StatementUtils {
} catch (e: Exception) {
return Result.Failure(e)
}
+ checkNotNull(signingInfo)
return if (signingInfo.hasMultipleSigners()) {
signingInfo.apkContentsSigners
} else {
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/packages/services/VirtualCamera/OWNERS b/packages/services/VirtualCamera/OWNERS
new file mode 100644
index 000000000000..c66443fb8a14
--- /dev/null
+++ b/packages/services/VirtualCamera/OWNERS
@@ -0,0 +1,3 @@
+include /services/companion/java/com/android/server/companion/virtual/OWNERS
+caen@google.com
+jsebechlebsky@google.com \ No newline at end of file
diff --git a/services/companion/java/com/android/server/companion/AssociationRequestsProcessor.java b/services/companion/java/com/android/server/companion/AssociationRequestsProcessor.java
index 77275e056db6..d803c8c8e8c2 100644
--- a/services/companion/java/com/android/server/companion/AssociationRequestsProcessor.java
+++ b/services/companion/java/com/android/server/companion/AssociationRequestsProcessor.java
@@ -318,14 +318,14 @@ class AssociationRequestsProcessor {
public void enableSystemDataSync(int associationId, int flags) {
AssociationInfo association = mAssociationStore.getAssociationById(associationId);
- AssociationInfo updated = AssociationInfo.builder(association)
+ AssociationInfo updated = (new AssociationInfo.Builder(association))
.setSystemDataSyncFlags(association.getSystemDataSyncFlags() | flags).build();
mAssociationStore.updateAssociation(updated);
}
public void disableSystemDataSync(int associationId, int flags) {
AssociationInfo association = mAssociationStore.getAssociationById(associationId);
- AssociationInfo updated = AssociationInfo.builder(association)
+ AssociationInfo updated = (new AssociationInfo.Builder(association))
.setSystemDataSyncFlags(association.getSystemDataSyncFlags() & (~flags)).build();
mAssociationStore.updateAssociation(updated);
}
diff --git a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
index 611541f671cf..9ac2b6dd69c7 100644
--- a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
+++ b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
@@ -18,6 +18,8 @@
package com.android.server.companion;
import static android.Manifest.permission.MANAGE_COMPANION_DEVICES;
+import static android.Manifest.permission.REQUEST_OBSERVE_COMPANION_DEVICE_PRESENCE;
+import static android.Manifest.permission.USE_COMPANION_TRANSPORTS;
import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE;
import static android.companion.AssociationRequest.DEVICE_PROFILE_AUTOMOTIVE_PROJECTION;
import static android.content.pm.PackageManager.CERT_INPUT_SHA256;
@@ -44,6 +46,7 @@ import static java.util.Objects.requireNonNull;
import static java.util.concurrent.TimeUnit.DAYS;
import static java.util.concurrent.TimeUnit.MINUTES;
+import android.annotation.EnforcePermission;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SuppressLint;
@@ -632,29 +635,44 @@ public class CompanionDeviceManagerService extends SystemService {
}
@Override
+ @EnforcePermission(USE_COMPANION_TRANSPORTS)
public void addOnTransportsChangedListener(IOnTransportsChangedListener listener) {
+ addOnTransportsChangedListener_enforcePermission();
+
mTransportManager.addListener(listener);
}
@Override
+ @EnforcePermission(USE_COMPANION_TRANSPORTS)
public void removeOnTransportsChangedListener(IOnTransportsChangedListener listener) {
+ removeOnTransportsChangedListener_enforcePermission();
+
mTransportManager.removeListener(listener);
}
@Override
+ @EnforcePermission(USE_COMPANION_TRANSPORTS)
public void sendMessage(int messageType, byte[] data, int[] associationIds) {
+ sendMessage_enforcePermission();
+
mTransportManager.sendMessage(messageType, data, associationIds);
}
@Override
+ @EnforcePermission(USE_COMPANION_TRANSPORTS)
public void addOnMessageReceivedListener(int messageType,
IOnMessageReceivedListener listener) {
+ addOnMessageReceivedListener_enforcePermission();
+
mTransportManager.addListener(messageType, listener);
}
@Override
+ @EnforcePermission(USE_COMPANION_TRANSPORTS)
public void removeOnMessageReceivedListener(int messageType,
IOnMessageReceivedListener listener) {
+ removeOnMessageReceivedListener_enforcePermission();
+
mTransportManager.removeListener(messageType, listener);
}
@@ -809,7 +827,7 @@ public class CompanionDeviceManagerService extends SystemService {
}
// AssociationInfo class is immutable: create a new AssociationInfo object with updated
// timestamp.
- association = AssociationInfo.builder(association)
+ association = (new AssociationInfo.Builder(association))
.setLastTimeConnected(System.currentTimeMillis())
.build();
mAssociationStore.updateAssociation(association);
@@ -867,7 +885,7 @@ public class CompanionDeviceManagerService extends SystemService {
// AssociationInfo class is immutable: create a new AssociationInfo object with updated
// flag.
- association = AssociationInfo.builder(association)
+ association = (new AssociationInfo.Builder(association))
.setNotifyOnDeviceNearby(active)
.build();
// Do not need to call {@link BleCompanionDeviceScanner#restartScan()} since it will
@@ -1147,7 +1165,7 @@ public class CompanionDeviceManagerService extends SystemService {
*/
private void addToPendingRoleHolderRemoval(@NonNull AssociationInfo association) {
// First: set revoked flag.
- association = AssociationInfo.builder(association)
+ association = (new AssociationInfo.Builder(association))
.setRevoked(true)
.build();
diff --git a/services/companion/java/com/android/server/companion/CompanionDeviceShellCommand.java b/services/companion/java/com/android/server/companion/CompanionDeviceShellCommand.java
index 04fbab434d1f..a86839293feb 100644
--- a/services/companion/java/com/android/server/companion/CompanionDeviceShellCommand.java
+++ b/services/companion/java/com/android/server/companion/CompanionDeviceShellCommand.java
@@ -16,6 +16,8 @@
package com.android.server.companion;
+import static android.companion.CompanionDeviceManager.MESSAGE_REQUEST_CONTEXT_SYNC;
+
import android.companion.AssociationInfo;
import android.companion.ContextSyncMessage;
import android.companion.Telecom;
@@ -30,7 +32,6 @@ import com.android.server.companion.datatransfer.contextsync.BitmapUtils;
import com.android.server.companion.datatransfer.contextsync.CrossDeviceSyncController;
import com.android.server.companion.presence.CompanionDevicePresenceMonitor;
import com.android.server.companion.transport.CompanionTransportManager;
-import com.android.server.companion.transport.Transport;
import java.io.PrintWriter;
import java.util.List;
@@ -135,7 +136,7 @@ class CompanionDeviceShellCommand extends ShellCommand {
case "send-context-sync-empty-message": {
associationId = getNextIntArgRequired();
mTransportManager.createEmulatedTransport(associationId)
- .processMessage(Transport.MESSAGE_REQUEST_CONTEXT_SYNC,
+ .processMessage(MESSAGE_REQUEST_CONTEXT_SYNC,
/* sequence= */ 0,
CrossDeviceSyncController.createEmptyMessage());
break;
@@ -147,7 +148,7 @@ class CompanionDeviceShellCommand extends ShellCommand {
String address = getNextArgRequired();
String facilitator = getNextArgRequired();
mTransportManager.createEmulatedTransport(associationId)
- .processMessage(Transport.MESSAGE_REQUEST_CONTEXT_SYNC,
+ .processMessage(MESSAGE_REQUEST_CONTEXT_SYNC,
/* sequence= */ 0,
CrossDeviceSyncController.createCallCreateMessage(callId,
address, facilitator));
@@ -159,7 +160,7 @@ class CompanionDeviceShellCommand extends ShellCommand {
String callId = getNextArgRequired();
int control = getNextIntArgRequired();
mTransportManager.createEmulatedTransport(associationId)
- .processMessage(Transport.MESSAGE_REQUEST_CONTEXT_SYNC,
+ .processMessage(MESSAGE_REQUEST_CONTEXT_SYNC,
/* sequence= */ 0,
CrossDeviceSyncController.createCallControlMessage(callId,
control));
@@ -184,7 +185,7 @@ class CompanionDeviceShellCommand extends ShellCommand {
}
pos.end(telecomToken);
mTransportManager.createEmulatedTransport(associationId)
- .processMessage(Transport.MESSAGE_REQUEST_CONTEXT_SYNC,
+ .processMessage(MESSAGE_REQUEST_CONTEXT_SYNC,
/* sequence= */ 0, pos.getBytes());
break;
}
@@ -246,7 +247,7 @@ class CompanionDeviceShellCommand extends ShellCommand {
pos.end(callsToken);
pos.end(telecomToken);
mTransportManager.createEmulatedTransport(associationId)
- .processMessage(Transport.MESSAGE_REQUEST_CONTEXT_SYNC,
+ .processMessage(MESSAGE_REQUEST_CONTEXT_SYNC,
/* sequence= */ 0, pos.getBytes());
break;
}
diff --git a/services/companion/java/com/android/server/companion/datatransfer/SystemDataTransferProcessor.java b/services/companion/java/com/android/server/companion/datatransfer/SystemDataTransferProcessor.java
index dd7d38f34f28..fcc7a830e9be 100644
--- a/services/companion/java/com/android/server/companion/datatransfer/SystemDataTransferProcessor.java
+++ b/services/companion/java/com/android/server/companion/datatransfer/SystemDataTransferProcessor.java
@@ -20,10 +20,10 @@ import static android.app.PendingIntent.FLAG_CANCEL_CURRENT;
import static android.app.PendingIntent.FLAG_IMMUTABLE;
import static android.app.PendingIntent.FLAG_ONE_SHOT;
import static android.companion.CompanionDeviceManager.COMPANION_DEVICE_DISCOVERY_PACKAGE_NAME;
+import static android.companion.CompanionDeviceManager.MESSAGE_REQUEST_PERMISSION_RESTORE;
import static android.content.ComponentName.createRelative;
import static com.android.server.companion.Utils.prepareForIpc;
-import static com.android.server.companion.transport.Transport.MESSAGE_REQUEST_PERMISSION_RESTORE;
import android.annotation.NonNull;
import android.annotation.Nullable;
diff --git a/services/companion/java/com/android/server/companion/datatransfer/contextsync/CrossDeviceSyncController.java b/services/companion/java/com/android/server/companion/datatransfer/contextsync/CrossDeviceSyncController.java
index 9bd5af956a6e..ad1eff8cebad 100644
--- a/services/companion/java/com/android/server/companion/datatransfer/contextsync/CrossDeviceSyncController.java
+++ b/services/companion/java/com/android/server/companion/datatransfer/contextsync/CrossDeviceSyncController.java
@@ -16,7 +16,7 @@
package com.android.server.companion.datatransfer.contextsync;
-import static com.android.server.companion.transport.Transport.MESSAGE_REQUEST_CONTEXT_SYNC;
+import static android.companion.CompanionDeviceManager.MESSAGE_REQUEST_CONTEXT_SYNC;
import android.app.admin.DevicePolicyManager;
import android.companion.AssociationInfo;
diff --git a/services/companion/java/com/android/server/companion/transport/CompanionTransportManager.java b/services/companion/java/com/android/server/companion/transport/CompanionTransportManager.java
index a49021a8eec4..ee285be970c9 100644
--- a/services/companion/java/com/android/server/companion/transport/CompanionTransportManager.java
+++ b/services/companion/java/com/android/server/companion/transport/CompanionTransportManager.java
@@ -17,8 +17,7 @@
package com.android.server.companion.transport;
import static android.Manifest.permission.DELIVER_COMPANION_MESSAGES;
-
-import static com.android.server.companion.transport.Transport.MESSAGE_REQUEST_PERMISSION_RESTORE;
+import static android.companion.CompanionDeviceManager.MESSAGE_REQUEST_PERMISSION_RESTORE;
import android.annotation.NonNull;
import android.annotation.SuppressLint;
diff --git a/services/companion/java/com/android/server/companion/transport/Transport.java b/services/companion/java/com/android/server/companion/transport/Transport.java
index 5af3b98d71cc..32d4061db1f7 100644
--- a/services/companion/java/com/android/server/companion/transport/Transport.java
+++ b/services/companion/java/com/android/server/companion/transport/Transport.java
@@ -16,6 +16,11 @@
package com.android.server.companion.transport;
+import static android.companion.CompanionDeviceManager.MESSAGE_REQUEST_CONTEXT_SYNC;
+import static android.companion.CompanionDeviceManager.MESSAGE_REQUEST_PERMISSION_RESTORE;
+import static android.companion.CompanionDeviceManager.MESSAGE_REQUEST_PING;
+import static android.companion.CompanionDeviceManager.MESSAGE_REQUEST_REMOTE_AUTHENTICATION;
+
import android.annotation.NonNull;
import android.companion.IOnMessageReceivedListener;
import android.content.Context;
@@ -45,10 +50,6 @@ public abstract class Transport {
protected static final String TAG = "CDM_CompanionTransport";
protected static final boolean DEBUG = Build.IS_DEBUGGABLE;
- static final int MESSAGE_REQUEST_PING = 0x63807378; // ?PIN
- public static final int MESSAGE_REQUEST_CONTEXT_SYNC = 0x63678883; // ?CXS
- public static final int MESSAGE_REQUEST_PERMISSION_RESTORE = 0x63826983; // ?RES
-
static final int MESSAGE_RESPONSE_SUCCESS = 0x33838567; // !SUC
static final int MESSAGE_RESPONSE_FAILURE = 0x33706573; // !FAI
@@ -181,7 +182,8 @@ public abstract class Transport {
sendMessage(MESSAGE_RESPONSE_SUCCESS, sequence, data);
break;
}
- case MESSAGE_REQUEST_CONTEXT_SYNC: {
+ case MESSAGE_REQUEST_CONTEXT_SYNC:
+ case MESSAGE_REQUEST_REMOTE_AUTHENTICATION: {
callback(message, data);
sendMessage(MESSAGE_RESPONSE_SUCCESS, sequence, EmptyArray.BYTE);
break;
diff --git a/services/core/java/com/android/server/CertBlacklister.java b/services/core/java/com/android/server/CertBlacklister.java
index c16378be7342..e726c6abfac3 100644
--- a/services/core/java/com/android/server/CertBlacklister.java
+++ b/services/core/java/com/android/server/CertBlacklister.java
@@ -31,17 +31,17 @@ import java.io.IOException;
import libcore.io.IoUtils;
/**
- * <p>CertBlacklister provides a simple mechanism for updating the platform blacklists for SSL
+ * <p>CertBlacklister provides a simple mechanism for updating the platform denylists for SSL
* certificate public keys and serial numbers.
*/
public class CertBlacklister extends Binder {
private static final String TAG = "CertBlacklister";
- private static final String BLACKLIST_ROOT = System.getenv("ANDROID_DATA") + "/misc/keychain/";
+ private static final String DENYLIST_ROOT = System.getenv("ANDROID_DATA") + "/misc/keychain/";
- public static final String PUBKEY_PATH = BLACKLIST_ROOT + "pubkey_blacklist.txt";
- public static final String SERIAL_PATH = BLACKLIST_ROOT + "serial_blacklist.txt";
+ public static final String PUBKEY_PATH = DENYLIST_ROOT + "pubkey_blacklist.txt";
+ public static final String SERIAL_PATH = DENYLIST_ROOT + "serial_blacklist.txt";
public static final String PUBKEY_BLACKLIST_KEY = "pubkey_blacklist";
public static final String SERIAL_BLACKLIST_KEY = "serial_blacklist";
@@ -66,14 +66,14 @@ public class CertBlacklister extends Binder {
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
- writeBlacklist();
+ writeDenylist();
}
public String getValue() {
return Settings.Secure.getString(mContentResolver, mKey);
}
- private void writeBlacklist() {
+ private void writeDenylist() {
new Thread("BlacklistUpdater") {
public void run() {
synchronized(mTmpDir) {
diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java
index e9cfceaf2b93..64e73b93d830 100644
--- a/services/core/java/com/android/server/StorageManagerService.java
+++ b/services/core/java/com/android/server/StorageManagerService.java
@@ -676,6 +676,7 @@ class StorageManagerService extends IStorageManager.Stub
private static final int H_VOLUME_STATE_CHANGED = 15;
private static final int H_CLOUD_MEDIA_PROVIDER_CHANGED = 16;
private static final int H_SECURE_KEYGUARD_STATE_CHANGED = 17;
+ private static final int H_REMOUNT_VOLUMES_ON_MOVE = 18;
class StorageManagerServiceHandler extends Handler {
public StorageManagerServiceHandler(Looper looper) {
@@ -831,6 +832,10 @@ class StorageManagerService extends IStorageManager.Stub
}
break;
}
+ case H_REMOUNT_VOLUMES_ON_MOVE: {
+ remountVolumesForRunningUsersOnMove();
+ break;
+ }
}
}
}
@@ -1284,6 +1289,44 @@ class StorageManagerService extends IStorageManager.Stub
}
}
+ /**
+ * This method informs vold and storaged that the user has stopped and started whenever move
+ * storage is performed. This ensures that the correct emulated volumes are mounted for the
+ * users other than the current user. This solves an edge case wherein the correct emulated
+ * volumes are not mounted, this will cause the media data to be still stored on internal
+ * storage whereas the data should be stored in the adopted primary storage. This method stops
+ * the users at vold first which will remove the old volumes which and starts the users at vold
+ * which will reattach the correct volumes. This does not performs a full reset as full reset
+ * clears every state from vold and SMS {@link #resetIfRebootedAndConnected} which is expensive
+ * and causes instability.
+ */
+ private void remountVolumesForRunningUsersOnMove() {
+ // Do not want to hold the lock for long
+ final List<Integer> unlockedUsers = new ArrayList<>();
+ synchronized (mLock) {
+ for (int userId : mSystemUnlockedUsers) {
+ if (userId == mCurrentUserId) continue;
+ unlockedUsers.add(userId);
+ }
+ }
+ for (Integer userId : unlockedUsers) {
+ try {
+ mVold.onUserStopped(userId);
+ mStoraged.onUserStopped(userId);
+ } catch (Exception e) {
+ Slog.wtf(TAG, e);
+ }
+ }
+ for (Integer userId : unlockedUsers) {
+ try {
+ mVold.onUserStarted(userId);
+ mStoraged.onUserStarted(userId);
+ } catch (Exception e) {
+ Slog.wtf(TAG, e);
+ }
+ }
+ }
+
private boolean supportsBlockCheckpoint() throws RemoteException {
enforcePermission(android.Manifest.permission.MOUNT_FORMAT_FILESYSTEMS);
return mVold.supportsBlockCheckpoint();
@@ -1818,6 +1861,7 @@ class StorageManagerService extends IStorageManager.Stub
mPrimaryStorageUuid = mMoveTargetUuid;
writeSettingsLocked();
+ mHandler.obtainMessage(H_REMOUNT_VOLUMES_ON_MOVE).sendToTarget();
}
if (PackageManager.isMoveStatusFinished(status)) {
diff --git a/services/core/java/com/android/server/audio/AudioDeviceBroker.java b/services/core/java/com/android/server/audio/AudioDeviceBroker.java
index 84fe12eebd37..4f45c0dd2f14 100644
--- a/services/core/java/com/android/server/audio/AudioDeviceBroker.java
+++ b/services/core/java/com/android/server/audio/AudioDeviceBroker.java
@@ -2175,7 +2175,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
if (btSCoOn) {
// Use the SCO device known to BtHelper so that it matches exactly
// what has been communicated to audio policy manager. The device
- // returned by requestedCommunicationDevice() can be a dummy SCO device if legacy
+ // returned by requestedCommunicationDevice() can be a placeholder SCO device if legacy
// APIs are used to start SCO audio.
AudioDeviceAttributes device = mBtHelper.getHeadsetAudioDevice();
if (device != null) {
diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java
index cba5039f714d..ff35b192cccd 100644
--- a/services/core/java/com/android/server/connectivity/Vpn.java
+++ b/services/core/java/com/android/server/connectivity/Vpn.java
@@ -3296,13 +3296,6 @@ public class Vpn {
}
agentConnect(this::onValidationStatus);
return; // Link properties are already sent.
- } else {
- // Underlying networks also set in agentConnect()
- doSetUnderlyingNetworks(networkAgent, Collections.singletonList(network));
- mNetworkCapabilities =
- new NetworkCapabilities.Builder(mNetworkCapabilities)
- .setUnderlyingNetworks(Collections.singletonList(network))
- .build();
}
lp = makeLinkProperties(); // Accesses VPN instance fields; must be locked
@@ -3384,8 +3377,6 @@ public class Vpn {
final LinkProperties oldLp = makeLinkProperties();
- final boolean underlyingNetworkHasChanged =
- !Arrays.equals(mConfig.underlyingNetworks, new Network[]{network});
mConfig.underlyingNetworks = new Network[] {network};
mConfig.mtu = calculateVpnMtu();
@@ -3417,18 +3408,9 @@ public class Vpn {
removed.getAddress(), removed.getPrefixLength());
}
} else {
- // Put below 3 updates into else block is because agentConnect() will do
- // those things, so there is no need to do the redundant work.
+ // Put below update into else block is because agentConnect() will do
+ // the same things, so there is no need to do the redundant work.
if (!newLp.equals(oldLp)) doSendLinkProperties(mNetworkAgent, newLp);
- if (underlyingNetworkHasChanged) {
- mNetworkCapabilities =
- new NetworkCapabilities.Builder(mNetworkCapabilities)
- .setUnderlyingNetworks(
- Collections.singletonList(network))
- .build();
- doSetUnderlyingNetworks(mNetworkAgent,
- Collections.singletonList(network));
- }
}
}
@@ -3554,10 +3536,28 @@ public class Vpn {
*/
private void startOrMigrateIkeSession(@Nullable Network underlyingNetwork) {
if (underlyingNetwork == null) {
+ // For null underlyingNetwork case, there will not be a NetworkAgent available so
+ // no underlying network update is necessary here. Note that updating
+ // mNetworkCapabilities here would also be reasonable, but it will be updated next
+ // time the VPN connects anyway.
Log.d(TAG, "There is no active network for starting an IKE session");
return;
}
+ final List<Network> networks = Collections.singletonList(underlyingNetwork);
+ // Update network capabilities if underlying network is changed.
+ if (!networks.equals(mNetworkCapabilities.getUnderlyingNetworks())) {
+ mNetworkCapabilities =
+ new NetworkCapabilities.Builder(mNetworkCapabilities)
+ .setUnderlyingNetworks(networks)
+ .build();
+ // No NetworkAgent case happens when Vpn tries to start a new VPN. The underlying
+ // network update will be done later with NetworkAgent connected event.
+ if (mNetworkAgent != null) {
+ doSetUnderlyingNetworks(mNetworkAgent, networks);
+ }
+ }
+
if (maybeMigrateIkeSessionAndUpdateVpnTransportInfo(underlyingNetwork)) return;
startIkeSession(underlyingNetwork);
diff --git a/services/core/java/com/android/server/content/SyncManager.java b/services/core/java/com/android/server/content/SyncManager.java
index 3e31bd1e820f..9a2d9ce0d55f 100644
--- a/services/core/java/com/android/server/content/SyncManager.java
+++ b/services/core/java/com/android/server/content/SyncManager.java
@@ -781,7 +781,7 @@ public class SyncManager {
// This can be noisy, therefore we will allowlist sync adapters installed
// before we started checking for account access because they already know
// the account (they run before) which is the genie is out of the bottle.
- whiteListExistingSyncAdaptersIfNeeded();
+ allowListExistingSyncAdaptersIfNeeded();
mLogger.log("Sync manager initialized: " + Build.FINGERPRINT);
}
@@ -827,7 +827,7 @@ public class SyncManager {
}
}
- private void whiteListExistingSyncAdaptersIfNeeded() {
+ private void allowListExistingSyncAdaptersIfNeeded() {
if (!mSyncStorageEngine.shouldGrantSyncAdaptersAccountAccess()) {
return;
}
diff --git a/services/core/java/com/android/server/content/SyncManagerConstants.java b/services/core/java/com/android/server/content/SyncManagerConstants.java
index 2a5858c3e182..409b469dc6bf 100644
--- a/services/core/java/com/android/server/content/SyncManagerConstants.java
+++ b/services/core/java/com/android/server/content/SyncManagerConstants.java
@@ -52,11 +52,11 @@ public class SyncManagerConstants extends ContentObserver {
private static final int DEF_MAX_RETRIES_WITH_APP_STANDBY_EXEMPTION = 5;
private int mMaxRetriesWithAppStandbyExemption = DEF_MAX_RETRIES_WITH_APP_STANDBY_EXEMPTION;
- private static final String KEY_EXEMPTION_TEMP_WHITELIST_DURATION_IN_SECONDS =
+ private static final String KEY_EXEMPTION_TEMP_ALLOWLIST_DURATION_IN_SECONDS =
"exemption_temp_whitelist_duration_in_seconds";
- private static final int DEF_EXEMPTION_TEMP_WHITELIST_DURATION_IN_SECONDS = 10 * 60;
+ private static final int DEF_EXEMPTION_TEMP_ALLOWLIST_DURATION_IN_SECONDS = 10 * 60;
private int mKeyExemptionTempWhitelistDurationInSeconds
- = DEF_EXEMPTION_TEMP_WHITELIST_DURATION_IN_SECONDS;
+ = DEF_EXEMPTION_TEMP_ALLOWLIST_DURATION_IN_SECONDS;
protected SyncManagerConstants(Context context) {
super(null);
@@ -105,8 +105,8 @@ public class SyncManagerConstants extends ContentObserver {
DEF_MAX_RETRIES_WITH_APP_STANDBY_EXEMPTION);
mKeyExemptionTempWhitelistDurationInSeconds = parser.getInt(
- KEY_EXEMPTION_TEMP_WHITELIST_DURATION_IN_SECONDS,
- DEF_EXEMPTION_TEMP_WHITELIST_DURATION_IN_SECONDS);
+ KEY_EXEMPTION_TEMP_ALLOWLIST_DURATION_IN_SECONDS,
+ DEF_EXEMPTION_TEMP_ALLOWLIST_DURATION_IN_SECONDS);
}
}
diff --git a/services/core/java/com/android/server/integrity/AppIntegrityManagerServiceImpl.java b/services/core/java/com/android/server/integrity/AppIntegrityManagerServiceImpl.java
index ec03d9d43539..a7c986d04fa4 100644
--- a/services/core/java/com/android/server/integrity/AppIntegrityManagerServiceImpl.java
+++ b/services/core/java/com/android/server/integrity/AppIntegrityManagerServiceImpl.java
@@ -710,7 +710,7 @@ public class AppIntegrityManagerServiceImpl extends IAppIntegrityManager.Stub {
}
private String getCallingRulePusherPackageName(int callingUid) {
- // Obtain the system apps that are whitelisted in config_integrityRuleProviderPackages.
+ // Obtain the system apps that are allowlisted in config_integrityRuleProviderPackages.
List<String> allowedRuleProviders = getAllowedRuleProviderSystemApps();
if (DEBUG_INTEGRITY_COMPONENT) {
Slog.i(
diff --git a/services/core/java/com/android/server/locksettings/SyntheticPasswordManager.java b/services/core/java/com/android/server/locksettings/SyntheticPasswordManager.java
index e8fd6f88359c..11c0f5183e21 100644
--- a/services/core/java/com/android/server/locksettings/SyntheticPasswordManager.java
+++ b/services/core/java/com/android/server/locksettings/SyntheticPasswordManager.java
@@ -31,6 +31,7 @@ import android.hardware.weaver.IWeaver;
import android.hardware.weaver.WeaverConfig;
import android.hardware.weaver.WeaverReadResponse;
import android.hardware.weaver.WeaverReadStatus;
+import android.os.IBinder;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -71,7 +72,6 @@ import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Set;
-
/**
* A class that manages a user's synthetic password (SP) ({@link #SyntheticPassword}), along with a
* set of SP protectors that are independent ways that the SP is protected.
@@ -500,7 +500,7 @@ class SyntheticPasswordManager {
private final Context mContext;
private LockSettingsStorage mStorage;
- private IWeaver mWeaver;
+ private volatile IWeaver mWeaver;
private WeaverConfig mWeaverConfig;
private PasswordSlotManager mPasswordSlotManager;
@@ -531,17 +531,63 @@ class SyntheticPasswordManager {
}
}
- private IWeaver getWeaverService() {
- // Try to get the AIDL service first
+ private class WeaverDiedRecipient implements IBinder.DeathRecipient {
+ // Not synchronized on the outer class, since setting the pointer to null is atomic, and we
+ // don't want to have to worry about any sort of deadlock here.
+ @Override
+ public void binderDied() {
+ // Weaver died. Try to recover by setting mWeaver to null, which makes
+ // getWeaverService() look up the service again. This is done only as a simple
+ // robustness measure; it should not be relied on. If this triggers, the root cause is
+ // almost certainly a bug in the device's Weaver implementation, which must be fixed.
+ Slog.wtf(TAG, "Weaver service has died");
+ mWeaver.asBinder().unlinkToDeath(this, 0);
+ mWeaver = null;
+ }
+ }
+
+ private @Nullable IWeaver getWeaverAidlService() {
+ final IWeaver aidlWeaver;
try {
- IWeaver aidlWeaver = IWeaver.Stub.asInterface(
- ServiceManager.waitForDeclaredService(IWeaver.DESCRIPTOR + "/default"));
- if (aidlWeaver != null) {
- Slog.i(TAG, "Using AIDL weaver service");
- return aidlWeaver;
- }
+ aidlWeaver =
+ IWeaver.Stub.asInterface(
+ ServiceManager.waitForDeclaredService(IWeaver.DESCRIPTOR + "/default"));
} catch (SecurityException e) {
Slog.w(TAG, "Does not have permissions to get AIDL weaver service");
+ return null;
+ }
+ if (aidlWeaver == null) {
+ return null;
+ }
+ final int aidlVersion;
+ try {
+ aidlVersion = aidlWeaver.getInterfaceVersion();
+ } catch (RemoteException e) {
+ Slog.e(TAG, "Cannot get AIDL weaver service version", e);
+ return null;
+ }
+ if (aidlVersion < 2) {
+ Slog.w(TAG,
+ "Ignoring AIDL weaver service v"
+ + aidlVersion
+ + " because only v2 and later are supported");
+ return null;
+ }
+ Slog.i(TAG, "Found AIDL weaver service v" + aidlVersion);
+ return aidlWeaver;
+ }
+
+ private @Nullable IWeaver getWeaverServiceInternal() {
+ // Try to get the AIDL service first
+ IWeaver aidlWeaver = getWeaverAidlService();
+ if (aidlWeaver != null) {
+ Slog.i(TAG, "Using AIDL weaver service");
+ try {
+ aidlWeaver.asBinder().linkToDeath(new WeaverDiedRecipient(), 0);
+ } catch (RemoteException e) {
+ Slog.w(TAG, "Unable to register Weaver death recipient", e);
+ }
+ return aidlWeaver;
}
// If the AIDL service can't be found, look for the HIDL service
@@ -563,15 +609,20 @@ class SyntheticPasswordManager {
return LockPatternUtils.isAutoPinConfirmFeatureAvailable();
}
- private synchronized boolean isWeaverAvailable() {
- if (mWeaver != null) {
- return true;
+ /**
+ * Returns a handle to the Weaver service, or null if Weaver is unavailable. Note that not all
+ * devices support Weaver.
+ */
+ private synchronized @Nullable IWeaver getWeaverService() {
+ IWeaver weaver = mWeaver;
+ if (weaver != null) {
+ return weaver;
}
// Re-initialize weaver in case there was a transient error preventing access to it.
- IWeaver weaver = getWeaverService();
+ weaver = getWeaverServiceInternal();
if (weaver == null) {
- return false;
+ return null;
}
final WeaverConfig weaverConfig;
@@ -579,19 +630,18 @@ class SyntheticPasswordManager {
weaverConfig = weaver.getConfig();
} catch (RemoteException | ServiceSpecificException e) {
Slog.e(TAG, "Failed to get weaver config", e);
- return false;
+ return null;
}
if (weaverConfig == null || weaverConfig.slots <= 0) {
Slog.e(TAG, "Invalid weaver config");
- return false;
+ return null;
}
mWeaver = weaver;
mWeaverConfig = weaverConfig;
mPasswordSlotManager.refreshActiveSlots(getUsedWeaverSlots());
Slog.i(TAG, "Weaver service initialized");
-
- return true;
+ return weaver;
}
/**
@@ -601,7 +651,7 @@ class SyntheticPasswordManager {
*
* @return the value stored in the weaver slot, or null if the operation fails
*/
- private byte[] weaverEnroll(int slot, byte[] key, @Nullable byte[] value) {
+ private byte[] weaverEnroll(IWeaver weaver, int slot, byte[] key, @Nullable byte[] value) {
if (slot == INVALID_WEAVER_SLOT || slot >= mWeaverConfig.slots) {
throw new IllegalArgumentException("Invalid slot for weaver");
}
@@ -614,7 +664,7 @@ class SyntheticPasswordManager {
value = SecureRandomUtils.randomBytes(mWeaverConfig.valueSize);
}
try {
- mWeaver.write(slot, key, value);
+ weaver.write(slot, key, value);
} catch (RemoteException e) {
Slog.e(TAG, "weaver write binder call failed, slot: " + slot, e);
return null;
@@ -643,7 +693,7 @@ class SyntheticPasswordManager {
* the verification is successful, throttled or failed. If successful, the bound secret
* is also returned.
*/
- private VerifyCredentialResponse weaverVerify(int slot, byte[] key) {
+ private VerifyCredentialResponse weaverVerify(IWeaver weaver, int slot, byte[] key) {
if (slot == INVALID_WEAVER_SLOT || slot >= mWeaverConfig.slots) {
throw new IllegalArgumentException("Invalid slot for weaver");
}
@@ -654,7 +704,7 @@ class SyntheticPasswordManager {
}
final WeaverReadResponse readResponse;
try {
- readResponse = mWeaver.read(slot, key);
+ readResponse = weaver.read(slot, key);
} catch (RemoteException e) {
Slog.e(TAG, "weaver read failed, slot: " + slot, e);
return VerifyCredentialResponse.ERROR;
@@ -846,14 +896,15 @@ class SyntheticPasswordManager {
int slot = loadWeaverSlot(protectorId, userId);
destroyState(WEAVER_SLOT_NAME, protectorId, userId);
if (slot != INVALID_WEAVER_SLOT) {
- if (!isWeaverAvailable()) {
+ final IWeaver weaver = getWeaverService();
+ if (weaver == null) {
Slog.e(TAG, "Cannot erase Weaver slot because Weaver is unavailable");
return;
}
Set<Integer> usedSlots = getUsedWeaverSlots();
if (!usedSlots.contains(slot)) {
Slogf.i(TAG, "Erasing Weaver slot %d", slot);
- weaverEnroll(slot, null, null);
+ weaverEnroll(weaver, slot, null, null);
mPasswordSlotManager.markSlotDeleted(slot);
} else {
Slogf.i(TAG, "Weaver slot %d was already reused; not erasing it", slot);
@@ -931,13 +982,14 @@ class SyntheticPasswordManager {
Slogf.i(TAG, "Creating LSKF-based protector %016x for user %d", protectorId, userId);
- if (isWeaverAvailable()) {
+ final IWeaver weaver = getWeaverService();
+ if (weaver != null) {
// Weaver is available, so make the protector use it to verify the LSKF. Do this even
// if the LSKF is empty, as that gives us support for securely deleting the protector.
int weaverSlot = getNextAvailableWeaverSlot();
Slogf.i(TAG, "Enrolling LSKF for user %d into Weaver slot %d", userId, weaverSlot);
- byte[] weaverSecret = weaverEnroll(weaverSlot, stretchedLskfToWeaverKey(stretchedLskf),
- null);
+ byte[] weaverSecret = weaverEnroll(weaver, weaverSlot,
+ stretchedLskfToWeaverKey(stretchedLskf), null);
if (weaverSecret == null) {
throw new IllegalStateException(
"Fail to enroll user password under weaver " + userId);
@@ -1024,7 +1076,8 @@ class SyntheticPasswordManager {
}
return VerifyCredentialResponse.fromGateKeeperResponse(response);
} else if (persistentData.type == PersistentData.TYPE_SP_WEAVER) {
- if (!isWeaverAvailable()) {
+ final IWeaver weaver = getWeaverService();
+ if (weaver == null) {
Slog.e(TAG, "No weaver service to verify SP-based FRP credential");
return VerifyCredentialResponse.ERROR;
}
@@ -1032,7 +1085,8 @@ class SyntheticPasswordManager {
byte[] stretchedLskf = stretchLskf(userCredential, pwd);
int weaverSlot = persistentData.userId;
- return weaverVerify(weaverSlot, stretchedLskfToWeaverKey(stretchedLskf)).stripPayload();
+ return weaverVerify(weaver, weaverSlot,
+ stretchedLskfToWeaverKey(stretchedLskf)).stripPayload();
} else {
Slog.e(TAG, "persistentData.type must be TYPE_SP_GATEKEEPER or TYPE_SP_WEAVER, but is "
+ persistentData.type);
@@ -1134,7 +1188,7 @@ class SyntheticPasswordManager {
TokenData tokenData = new TokenData();
tokenData.mType = type;
final byte[] secdiscardable = SecureRandomUtils.randomBytes(SECDISCARDABLE_LENGTH);
- if (isWeaverAvailable()) {
+ if (getWeaverService() != null) {
tokenData.weaverSecret = SecureRandomUtils.randomBytes(mWeaverConfig.valueSize);
tokenData.secdiscardableOnDisk = SyntheticPasswordCrypto.encrypt(tokenData.weaverSecret,
PERSONALIZATION_WEAVER_TOKEN, secdiscardable);
@@ -1177,10 +1231,11 @@ class SyntheticPasswordManager {
return false;
}
Slogf.i(TAG, "Creating token-based protector %016x for user %d", tokenHandle, userId);
- if (isWeaverAvailable()) {
+ final IWeaver weaver = getWeaverService();
+ if (weaver != null) {
int slot = getNextAvailableWeaverSlot();
Slogf.i(TAG, "Using Weaver slot %d for new token-based protector", slot);
- if (weaverEnroll(slot, null, tokenData.weaverSecret) == null) {
+ if (weaverEnroll(weaver, slot, null, tokenData.weaverSecret) == null) {
Slog.e(TAG, "Failed to enroll weaver secret when activating token");
return false;
}
@@ -1269,12 +1324,14 @@ class SyntheticPasswordManager {
int weaverSlot = loadWeaverSlot(protectorId, userId);
if (weaverSlot != INVALID_WEAVER_SLOT) {
// Protector uses Weaver to verify the LSKF
- if (!isWeaverAvailable()) {
+ final IWeaver weaver = getWeaverService();
+ if (weaver == null) {
Slog.e(TAG, "Protector uses Weaver, but Weaver is unavailable");
result.gkResponse = VerifyCredentialResponse.ERROR;
return result;
}
- result.gkResponse = weaverVerify(weaverSlot, stretchedLskfToWeaverKey(stretchedLskf));
+ result.gkResponse = weaverVerify(weaver, weaverSlot,
+ stretchedLskfToWeaverKey(stretchedLskf));
if (result.gkResponse.getResponseCode() != VerifyCredentialResponse.RESPONSE_OK) {
return result;
}
@@ -1442,12 +1499,13 @@ class SyntheticPasswordManager {
}
int slotId = loadWeaverSlot(protectorId, userId);
if (slotId != INVALID_WEAVER_SLOT) {
- if (!isWeaverAvailable()) {
+ final IWeaver weaver = getWeaverService();
+ if (weaver == null) {
Slog.e(TAG, "Protector uses Weaver, but Weaver is unavailable");
result.gkResponse = VerifyCredentialResponse.ERROR;
return result;
}
- VerifyCredentialResponse response = weaverVerify(slotId, null);
+ VerifyCredentialResponse response = weaverVerify(weaver, slotId, null);
if (response.getResponseCode() != VerifyCredentialResponse.RESPONSE_OK ||
response.getGatekeeperHAT() == null) {
Slog.e(TAG,
diff --git a/services/core/java/com/android/server/media/MediaSessionRecord.java b/services/core/java/com/android/server/media/MediaSessionRecord.java
index 9185a00da570..4084462d3f28 100644
--- a/services/core/java/com/android/server/media/MediaSessionRecord.java
+++ b/services/core/java/com/android/server/media/MediaSessionRecord.java
@@ -1062,6 +1062,14 @@ public class MediaSessionRecord implements IBinder.DeathRecipient, MediaSessionR
!= 0) {
return;
}
+
+ if (pi != null && pi.isActivity()) {
+ Log.w(
+ TAG,
+ "Ignoring invalid media button receiver targeting an activity: " + pi);
+ return;
+ }
+
mMediaButtonReceiverHolder =
MediaButtonReceiverHolder.create(mUserId, pi, mPackageName);
mService.onMediaButtonReceiverChanged(MediaSessionRecord.this);
diff --git a/services/core/java/com/android/server/pm/PackageInstallerSession.java b/services/core/java/com/android/server/pm/PackageInstallerSession.java
index f0e38955f050..d662aaedb774 100644
--- a/services/core/java/com/android/server/pm/PackageInstallerSession.java
+++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java
@@ -67,6 +67,7 @@ import android.app.admin.DevicePolicyEventLogger;
import android.app.admin.DevicePolicyManager;
import android.app.admin.DevicePolicyManagerInternal;
import android.compat.annotation.ChangeId;
+import android.compat.annotation.Disabled;
import android.compat.annotation.EnabledSince;
import android.content.ComponentName;
import android.content.Context;
@@ -311,6 +312,19 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
private static final long SILENT_INSTALL_ALLOWED = 265131695L;
/**
+ * The system supports pre-approval and update ownership features from
+ * {@link Build.VERSION_CODES#UPSIDE_DOWN_CAKE API 34}. The change id is used to make sure
+ * the system includes the fix of pre-approval with update ownership case. When checking the
+ * change id, if it is disabled, it means the build includes the fix. The more detail is on
+ * b/293644536.
+ * See {@link PackageInstaller.SessionParams#setRequestUpdateOwnership(boolean)} and
+ * {@link #requestUserPreapproval(PreapprovalDetails, IntentSender)} for more details.
+ */
+ @Disabled
+ @ChangeId
+ private static final long PRE_APPROVAL_WITH_UPDATE_OWNERSHIP_FIX = 293644536L;
+
+ /**
* The default value of {@link #mValidatedTargetSdk} is {@link Integer#MAX_VALUE}. If {@link
* #mValidatedTargetSdk} is compared with {@link Build.VERSION_CODES#S} before getting the
* target sdk version from a validated apk in {@link #validateApkInstallLocked()}, the compared
@@ -893,16 +907,27 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
if (mPermissionsManuallyAccepted) {
return USER_ACTION_NOT_NEEDED;
}
- packageName = mPackageName;
+ // For pre-pappvoal case, the mPackageName would be null.
+ if (mPackageName != null) {
+ packageName = mPackageName;
+ } else if (mPreapprovalRequested.get() && mPreapprovalDetails != null) {
+ packageName = mPreapprovalDetails.getPackageName();
+ } else {
+ packageName = null;
+ }
hasDeviceAdminReceiver = mHasDeviceAdminReceiver;
}
- final boolean forcePermissionPrompt =
+ // For the below cases, force user action prompt
+ // 1. installFlags includes INSTALL_FORCE_PERMISSION_PROMPT
+ // 2. params.requireUserAction is USER_ACTION_REQUIRED
+ final boolean forceUserActionPrompt =
(params.installFlags & PackageManager.INSTALL_FORCE_PERMISSION_PROMPT) != 0
|| params.requireUserAction == SessionParams.USER_ACTION_REQUIRED;
- if (forcePermissionPrompt) {
- return USER_ACTION_REQUIRED;
- }
+ final int userActionNotTypicallyNeededResponse = forceUserActionPrompt
+ ? USER_ACTION_REQUIRED
+ : USER_ACTION_NOT_NEEDED;
+
// It is safe to access mInstallerUid and mInstallSource without lock
// because they are immutable after sealing.
final Computer snapshot = mPm.snapshotComputer();
@@ -956,7 +981,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|| isInstallerDeviceOwnerOrAffiliatedProfileOwner();
if (noUserActionNecessary) {
- return USER_ACTION_NOT_NEEDED;
+ return userActionNotTypicallyNeededResponse;
}
if (isUpdateOwnershipEnforcementEnabled
@@ -969,7 +994,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
}
if (isPermissionGranted) {
- return USER_ACTION_NOT_NEEDED;
+ return userActionNotTypicallyNeededResponse;
}
if (snapshot.isInstallDisabledForPackage(getInstallerPackageName(), mInstallerUid,
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
);
/**
diff --git a/services/core/java/com/android/server/policy/SoftRestrictedPermissionPolicy.java b/services/core/java/com/android/server/policy/SoftRestrictedPermissionPolicy.java
index 33fc6fbf1de7..32a21c587f08 100644
--- a/services/core/java/com/android/server/policy/SoftRestrictedPermissionPolicy.java
+++ b/services/core/java/com/android/server/policy/SoftRestrictedPermissionPolicy.java
@@ -215,7 +215,7 @@ public abstract class SoftRestrictedPermissionPolicy {
return true;
}
- // The package is now a part of the forced scoped storage whitelist
+ // The package is now a part of the forced scoped storage allowlist
if (isForcedScopedStorage) {
return true;
}
diff --git a/services/core/java/com/android/server/recoverysystem/hal/BootControlHIDL.java b/services/core/java/com/android/server/recoverysystem/hal/BootControlHIDL.java
index 65325c297719..7c4d7875b76f 100644
--- a/services/core/java/com/android/server/recoverysystem/hal/BootControlHIDL.java
+++ b/services/core/java/com/android/server/recoverysystem/hal/BootControlHIDL.java
@@ -22,6 +22,8 @@ import android.os.IBinder;
import android.os.RemoteException;
import android.util.Slog;
+import java.util.NoSuchElementException;
+
public class BootControlHIDL implements IBootControl {
private static final String TAG = "BootControlHIDL";
@@ -32,7 +34,7 @@ public class BootControlHIDL implements IBootControl {
public static boolean isServicePresent() {
try {
android.hardware.boot.V1_0.IBootControl.getService(true);
- } catch (RemoteException e) {
+ } catch (RemoteException | NoSuchElementException e) {
return false;
}
return true;
@@ -41,7 +43,7 @@ public class BootControlHIDL implements IBootControl {
public static boolean isV1_2ServicePresent() {
try {
android.hardware.boot.V1_2.IBootControl.getService(true);
- } catch (RemoteException e) {
+ } catch (RemoteException | NoSuchElementException e) {
return false;
}
return true;
diff --git a/services/core/java/com/android/server/security/KeyChainSystemService.java b/services/core/java/com/android/server/security/KeyChainSystemService.java
index da1ff7325545..caa5340d477b 100644
--- a/services/core/java/com/android/server/security/KeyChainSystemService.java
+++ b/services/core/java/com/android/server/security/KeyChainSystemService.java
@@ -54,7 +54,7 @@ public class KeyChainSystemService extends SystemService {
/**
* Maximum time limit for the KeyChain app to deal with packages being removed.
*/
- private static final int KEYCHAIN_IDLE_WHITELIST_DURATION_MS = 30 * 1000;
+ private static final int KEYCHAIN_IDLE_ALLOWLIST_DURATION_MS = 30 * 1000;
public KeyChainSystemService(final Context context) {
super(context);
@@ -105,7 +105,7 @@ public class KeyChainSystemService extends SystemService {
final DeviceIdleInternal idleController =
LocalServices.getService(DeviceIdleInternal.class);
idleController.addPowerSaveTempWhitelistApp(Process.myUid(), packageName,
- KEYCHAIN_IDLE_WHITELIST_DURATION_MS, user.getIdentifier(), false,
+ KEYCHAIN_IDLE_ALLOWLIST_DURATION_MS, user.getIdentifier(), false,
REASON_KEY_CHAIN, "keychain");
getContext().startServiceAsUser(intent, user);
diff --git a/services/core/jni/Android.bp b/services/core/jni/Android.bp
index d5217c8295bd..6f2455e073a7 100644
--- a/services/core/jni/Android.bp
+++ b/services/core/jni/Android.bp
@@ -168,7 +168,6 @@ cc_defaults {
"android.hardware.graphics.bufferqueue@1.0",
"android.hardware.graphics.bufferqueue@2.0",
"android.hardware.graphics.common@1.2",
- "android.hardware.graphics.mapper@4.0",
"android.hardware.input.processor-V1-ndk",
"android.hardware.ir@1.0",
"android.hardware.light@2.0",
diff --git a/services/net/java/android/net/util/NetworkConstants.java b/services/net/java/android/net/util/NetworkConstants.java
index ea5ce65f6f79..49962eabbff3 100644
--- a/services/net/java/android/net/util/NetworkConstants.java
+++ b/services/net/java/android/net/util/NetworkConstants.java
@@ -52,7 +52,6 @@ public final class NetworkConstants {
public static final int IPV6_ADDR_BITS = 128;
public static final int IPV6_ADDR_LEN = 16;
public static final int IPV6_MIN_MTU = 1280;
- public static final int RFC7421_PREFIX_LENGTH = 64;
/**
* ICMP common (v4/v6) constants.
diff --git a/services/permission/java/com/android/server/permission/access/permission/PermissionService.kt b/services/permission/java/com/android/server/permission/access/permission/PermissionService.kt
index de7dc3b53752..44c58e3e78d7 100644
--- a/services/permission/java/com/android/server/permission/access/permission/PermissionService.kt
+++ b/services/permission/java/com/android/server/permission/access/permission/PermissionService.kt
@@ -931,7 +931,7 @@ class PermissionService(
isGranted: Boolean
) {
val appOpPolicy = service.getSchemePolicy(UidUri.SCHEME, AppOpUri.SCHEME) as UidAppOpPolicy
- val appOpName = AppOpsManager.permissionToOp(permissionName)
+ val appOpName = checkNotNull(AppOpsManager.permissionToOp(permissionName))
val mode = if (isGranted) AppOpsManager.MODE_ALLOWED else AppOpsManager.MODE_ERRORED
with(appOpPolicy) { setAppOpMode(packageState.appId, userId, appOpName, mode) }
}
diff --git a/services/tests/PackageManager/packageinstaller/src/com/android/packageinstaller/test/ExportedComponentTest.kt b/services/tests/PackageManager/packageinstaller/src/com/android/packageinstaller/test/ExportedComponentTest.kt
index d7d2726c1583..7858b301a6f2 100644
--- a/services/tests/PackageManager/packageinstaller/src/com/android/packageinstaller/test/ExportedComponentTest.kt
+++ b/services/tests/PackageManager/packageinstaller/src/com/android/packageinstaller/test/ExportedComponentTest.kt
@@ -43,7 +43,7 @@ class ExportedComponentTest {
assertThat(packageInstallers).isNotEmpty()
packageInstallers.forEach {
- val exported = it.receivers.filter { it.exported }
+ val exported = it.receivers?.filter { it.exported }
assertWithMessage("Receivers should not be exported").that(exported).isEmpty()
}
}
diff --git a/services/tests/mockingservicestests/src/com/android/server/pm/SharedLibrariesImplTest.kt b/services/tests/mockingservicestests/src/com/android/server/pm/SharedLibrariesImplTest.kt
index cffd027a58a3..6c392751abe6 100644
--- a/services/tests/mockingservicestests/src/com/android/server/pm/SharedLibrariesImplTest.kt
+++ b/services/tests/mockingservicestests/src/com/android/server/pm/SharedLibrariesImplTest.kt
@@ -131,7 +131,7 @@ class SharedLibrariesImplTest {
wheneverStatic { HexEncoding.decode(STATIC_LIB_NAME, false) }
.thenReturn(PackageUtils.computeSha256DigestBytes(
mSettings.getPackageLPr(STATIC_LIB_PACKAGE_NAME)
- .pkg.signingDetails.signatures!![0].toByteArray()))
+ .pkg!!.signingDetails.signatures!![0].toByteArray()))
}
@Test
@@ -239,7 +239,7 @@ class SharedLibrariesImplTest {
testPackageSetting.setPkgStateLibraryFiles(listOf())
assertThat(testPackageSetting.usesLibraryFiles).isEmpty()
- mSharedLibrariesImpl.updateSharedLibraries(testPackageSetting.pkg, testPackageSetting,
+ mSharedLibrariesImpl.updateSharedLibraries(testPackageSetting.pkg!!, testPackageSetting,
null /* changingLib */, null /* changingLibSetting */, mExistingPackages)
assertThat(testPackageSetting.usesLibraryFiles).hasSize(1)
@@ -252,7 +252,7 @@ class SharedLibrariesImplTest {
testPackageSetting.setPkgStateLibraryFiles(listOf())
assertThat(testPackageSetting.usesLibraryFiles).isEmpty()
- mSharedLibrariesImpl.updateSharedLibraries(testPackageSetting.pkg, testPackageSetting,
+ mSharedLibrariesImpl.updateSharedLibraries(testPackageSetting.pkg!!, testPackageSetting,
null /* changingLib */, null /* changingLibSetting */, mExistingPackages)
assertThat(testPackageSetting.usesLibraryFiles).hasSize(2)
@@ -266,7 +266,7 @@ class SharedLibrariesImplTest {
testPackageSetting.setPkgStateLibraryFiles(listOf())
assertThat(testPackageSetting.usesLibraryFiles).isEmpty()
- mSharedLibrariesImpl.updateSharedLibraries(testPackageSetting.pkg, testPackageSetting,
+ mSharedLibrariesImpl.updateSharedLibraries(testPackageSetting.pkg!!, testPackageSetting,
null /* changingLib */, null /* changingLibSetting */, mExistingPackages)
assertThat(testPackageSetting.usesLibraryFiles).hasSize(3)
diff --git a/telephony/common/com/android/internal/telephony/SmsApplication.java b/telephony/common/com/android/internal/telephony/SmsApplication.java
index a9cdf7e5bc08..94d4d2260d5c 100644
--- a/telephony/common/com/android/internal/telephony/SmsApplication.java
+++ b/telephony/common/com/android/internal/telephony/SmsApplication.java
@@ -791,7 +791,7 @@ public final class SmsApplication {
AppOpsManager.MODE_ALLOWED);
}
} catch (NameNotFoundException e) {
- // No whitelisted system app on this device
+ // No allowlisted system app on this device
Log.e(LOG_TAG, "Package not found: " + packageName);
}
diff --git a/telephony/java/android/telephony/SmsManager.java b/telephony/java/android/telephony/SmsManager.java
index 40488b15a37c..145cc2c78ed9 100644
--- a/telephony/java/android/telephony/SmsManager.java
+++ b/telephony/java/android/telephony/SmsManager.java
@@ -441,7 +441,7 @@ public final class SmsManager {
}
/**
- * Get {@link Context#getOpPackageName()} if this manager has a context, otherwise a dummy
+ * Get {@link Context#getOpPackageName()} if this manager has a context, otherwise a placeholder
* value.
*
* @return The package name to be used for app-ops checks
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 2a6099a18fab..195dbc47a75b 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -7840,7 +7840,7 @@ public class TelephonyManager {
}
/**
- * Rollback modem configurations to factory default except some config which are in whitelist.
+ * Rollback modem configurations to factory default except some config which are in allowlist.
* Used for device configuration by some carriers.
*
* <p>Requires Permission:
@@ -15340,7 +15340,7 @@ public class TelephonyManager {
*
* 1) User data is turned on, or
* 2) APN is un-metered for this subscription, or
- * 3) APN type is whitelisted. E.g. MMS is whitelisted if
+ * 3) APN type is allowlisted. E.g. MMS is allowlisted if
* {@link #MOBILE_DATA_POLICY_MMS_ALWAYS_ALLOWED} is enabled.
*
* @param apnType Value indicating the apn type. Apn types are defined in {@link ApnSetting}.
diff --git a/telephony/java/android/telephony/ims/ImsReasonInfo.java b/telephony/java/android/telephony/ims/ImsReasonInfo.java
index dda021e6172f..67acda05382b 100644
--- a/telephony/java/android/telephony/ims/ImsReasonInfo.java
+++ b/telephony/java/android/telephony/ims/ImsReasonInfo.java
@@ -460,7 +460,7 @@ public final class ImsReasonInfo implements Parcelable {
*/
public static final int CODE_LOW_BATTERY = 505;
/**
- * Device declined a call due to a blacklisted caller ID.
+ * Device declined a call due to a denylisted caller ID.
*/
public static final int CODE_BLACKLISTED_CALL_ID = 506;
// IMS -> Telephony
diff --git a/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java b/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java
index 1a58f17ef6a0..fa452dd78873 100644
--- a/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java
+++ b/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java
@@ -674,7 +674,7 @@ public class AppLaunch extends InstrumentationTestCase {
return true;
}
- // iorap compiler filters specified: the compilerFilter must be in the whitelist.
+ // iorap compiler filters specified: the compilerFilter must be in the allowlist.
if (mIorapCompilerFilters.indexOf(compilerFilter) != -1) {
return true;
}
diff --git a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/BackingStore.java b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/BackingStore.java
index 216e743938ca..df140b976768 100644
--- a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/BackingStore.java
+++ b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/BackingStore.java
@@ -14,17 +14,10 @@
package androidx.media.filterfw;
-import android.annotation.TargetApi;
import android.graphics.Bitmap;
-import android.os.Build;
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.RenderScript;
-import android.renderscript.Type;
import android.util.Log;
import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
import java.util.Arrays;
import java.util.Vector;
@@ -42,14 +35,11 @@ final class BackingStore {
static final int ACCESS_OBJECT = 0x08;
/** Access mode Bitmap: Frame data will be accessed as a Bitmap. */
static final int ACCESS_BITMAP = 0x10;
- /** Access mode Allocation: Frame data will be accessed as a RenderScript Allocation. */
- static final int ACCESS_ALLOCATION = 0x20;
private static final int BACKING_BYTEBUFFER = 1;
private static final int BACKING_TEXTURE = 2;
private static final int BACKING_OBJECT = 3;
private static final int BACKING_BITMAP = 4;
- private static final int BACKING_ALLOCATION = 5;
private final FrameType mType;
private int[] mDimensions;
@@ -243,14 +233,6 @@ final class BackingStore {
case ACCESS_BITMAP:
backing = new BitmapBacking();
break;
- case ACCESS_ALLOCATION:
- if (!AllocationBacking.isSupported()) {
- throw new RuntimeException(
- "Attempted to create an AllocationBacking in context that does " +
- "not support RenderScript!");
- }
- backing = new AllocationBacking(mFrameManager.getContext().getRenderScript());
- break;
}
if (backing == null) {
throw new RuntimeException(
@@ -518,9 +500,6 @@ final class BackingStore {
RenderTarget renderTarget = (RenderTarget) backing.lock(ACCESS_RENDERTARGET);
mBitmap.copyPixelsFromBuffer(
renderTarget.getPixelData(mDimensions[0], mDimensions[1]));
- } else if ((access & ACCESS_ALLOCATION) != 0 && AllocationBacking.isSupported()) {
- createBitmap();
- syncToAllocationBacking(backing);
} else {
throw new RuntimeException("Cannot sync bytebuffer backing!");
}
@@ -528,12 +507,6 @@ final class BackingStore {
mIsDirty = false;
}
- @TargetApi(11)
- private void syncToAllocationBacking(Backing backing) {
- Allocation allocation = (Allocation) backing.lock(ACCESS_ALLOCATION);
- allocation.copyTo(mBitmap);
- }
-
@Override
public Object lock(int accessType) {
return mBitmap;
@@ -612,8 +585,6 @@ final class BackingStore {
int w = mDimensions[0];
int h = mDimensions[1];
ImageShader.renderTextureToTarget(texture, getRenderTarget(), w, h);
- } else if ((access & ACCESS_ALLOCATION) != 0 && AllocationBacking.isSupported()) {
- syncToAllocationBacking(backing);
} else {
throw new RuntimeException("Cannot sync bytebuffer backing!");
}
@@ -621,14 +592,6 @@ final class BackingStore {
mIsDirty = false;
}
- @TargetApi(11)
- private void syncToAllocationBacking(Backing backing) {
- Allocation allocation = (Allocation) backing.lock(ACCESS_ALLOCATION);
- ByteBuffer pixels = ByteBuffer.allocateDirect(getSize());
- allocation.copyTo(pixels.array());
- mTexture.allocateWithPixels(pixels, mDimensions[0], mDimensions[1]);
- }
-
@Override
public Object lock(int accessType) {
switch (accessType) {
@@ -733,8 +696,6 @@ final class BackingStore {
ByteBuffer otherBuffer = (ByteBuffer) backing.lock(ACCESS_BYTES);
mBuffer.put(otherBuffer);
otherBuffer.rewind();
- } else if ((access & ACCESS_ALLOCATION) != 0 && AllocationBacking.isSupported()) {
- syncToAllocationBacking(backing);
} else {
throw new RuntimeException("Cannot sync bytebuffer backing!");
}
@@ -743,23 +704,6 @@ final class BackingStore {
mIsDirty = false;
}
- @TargetApi(11)
- private void syncToAllocationBacking(Backing backing) {
- Allocation allocation = (Allocation) backing.lock(ACCESS_ALLOCATION);
- if (getElementId() == FrameType.ELEMENT_RGBA8888) {
- byte[] bytes = mBuffer.array();
- allocation.copyTo(bytes);
- } else if (getElementId() == FrameType.ELEMENT_FLOAT32) {
- float[] floats = new float[getSize() / 4];
- allocation.copyTo(floats);
- mBuffer.asFloatBuffer().put(floats);
- } else {
- throw new RuntimeException(
- "Trying to sync to an allocation with an unsupported element id: "
- + getElementId());
- }
- }
-
@Override
public Object lock(int accessType) {
return mBuffer.rewind();
@@ -791,139 +735,4 @@ final class BackingStore {
}
}
-
- @TargetApi(11)
- static class AllocationBacking extends Backing {
-
- private final RenderScript mRenderScript;
- private Allocation mAllocation = null;
-
- public AllocationBacking(RenderScript renderScript) {
- mRenderScript = renderScript;
- }
-
- @Override
- public void allocate(FrameType frameType) {
- assertCompatible(frameType);
-
- Element element = null;
- switch (frameType.getElementId()) {
- case FrameType.ELEMENT_RGBA8888:
- element = Element.RGBA_8888(mRenderScript);
- break;
- case FrameType.ELEMENT_FLOAT32:
- element = Element.F32(mRenderScript);
- break;
- }
- Type.Builder imageTypeBuilder = new Type.Builder(mRenderScript, element);
- imageTypeBuilder.setX(mDimensions.length >= 1 ? mDimensions[0] : 1);
- imageTypeBuilder.setY(mDimensions.length == 2 ? mDimensions[1] : 1);
- Type imageType = imageTypeBuilder.create();
-
- mAllocation = Allocation.createTyped(mRenderScript, imageType);
- }
-
- @Override
- public int readAccess() {
- return ACCESS_ALLOCATION;
- }
-
- @Override
- public int writeAccess() {
- return ACCESS_ALLOCATION;
- }
-
- @Override
- public boolean requiresGpu() {
- return false;
- }
-
- @Override
- public void syncTo(Backing backing) {
- int access = backing.readAccess();
- if ((access & ACCESS_TEXTURE) != 0) {
- RenderTarget target = (RenderTarget) backing.lock(ACCESS_RENDERTARGET);
- ByteBuffer pixels = ByteBuffer.allocateDirect(getSize());
- GLToolbox.readTarget(target, pixels, mDimensions[0], mDimensions[1]);
- mAllocation.copyFrom(pixels.array());
- } else if ((access & ACCESS_BITMAP) != 0) {
- Bitmap bitmap = (Bitmap) backing.lock(ACCESS_BITMAP);
- mAllocation.copyFrom(bitmap);
- } else if ((access & ACCESS_BYTES) != 0) {
- ByteBuffer buffer = (ByteBuffer) backing.lock(ACCESS_BYTES);
- if (buffer.order() != ByteOrder.nativeOrder()) {
- throw new RuntimeException(
- "Trying to sync to the ByteBufferBacking with non-native byte order!");
- }
- byte[] bytes;
- if (buffer.hasArray()) {
- bytes = buffer.array();
- } else {
- bytes = new byte[getSize()];
- buffer.get(bytes);
- buffer.rewind();
- }
- mAllocation.copyFromUnchecked(bytes);
- } else {
- throw new RuntimeException("Cannot sync allocation backing!");
- }
- backing.unlock();
- mIsDirty = false;
- }
-
- @Override
- public Object lock(int accessType) {
- return mAllocation;
- }
-
- @Override
- public void unlock() {
- }
-
- @Override
- public int getType() {
- return BACKING_ALLOCATION;
- }
-
- @Override
- public boolean shouldCache() {
- return true;
- }
-
- @Override
- public void destroy() {
- if (mAllocation != null) {
- mAllocation.destroy();
- mAllocation = null;
- }
- }
-
- @Override
- public int getSize() {
- int elementCount = 1;
- for (int dim : mDimensions) {
- elementCount *= dim;
- }
- return getElementSize() * elementCount;
- }
-
- public static boolean isSupported() {
- return Build.VERSION.SDK_INT >= 11;
- }
-
- private void assertCompatible(FrameType type) {
- // TODO: consider adding support for other data types.
- if (type.getElementId() != FrameType.ELEMENT_RGBA8888
- && type.getElementId() != FrameType.ELEMENT_FLOAT32) {
- throw new RuntimeException(
- "Cannot allocate allocation with a non-RGBA or non-float data type!");
- }
- if (mDimensions == null || mDimensions.length > 2) {
- throw new RuntimeException(
- "Cannot create an allocation with more than 2 dimensions!");
- }
- }
-
- }
-
}
diff --git a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/FrameBuffer1D.java b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/FrameBuffer1D.java
index 0e24f5be954a..20cc1bf3cb80 100644
--- a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/FrameBuffer1D.java
+++ b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/FrameBuffer1D.java
@@ -16,9 +16,6 @@
package androidx.media.filterfw;
-import android.annotation.TargetApi;
-import android.renderscript.Allocation;
-
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@@ -40,19 +37,6 @@ public class FrameBuffer1D extends Frame {
return (ByteBuffer)mBackingStore.lockData(mode, BackingStore.ACCESS_BYTES);
}
- /**
- * Access frame's data using a RenderScript {@link Allocation}.
- * This is a convenience method and is equivalent to calling {@code lockData} with an
- * {@code accessFormat} of {@code ACCESS_ALLOCATION}.
- *
- * @return The Allocation instance holding the Frame's data.
- */
- @TargetApi(11)
- public Allocation lockAllocation(int mode) {
- assertAccessible(mode);
- return (Allocation) mBackingStore.lockData(mode, BackingStore.ACCESS_ALLOCATION);
- }
-
public int getLength() {
return mLength;
}
diff --git a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/MffContext.java b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/MffContext.java
index 6bd6c18f1c0a..8fd44d2df975 100644
--- a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/MffContext.java
+++ b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/MffContext.java
@@ -16,15 +16,12 @@
package androidx.media.filterfw;
-import android.annotation.TargetApi;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ConfigurationInfo;
-import android.os.Build;
import android.os.Handler;
import android.os.Looper;
-import android.renderscript.RenderScript;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
@@ -116,9 +113,6 @@ public class MffContext {
/** Flag whether camera streaming is supported in this context. */
private boolean mCameraStreamingSupport;
- /** RenderScript base master class. */
- private RenderScript mRenderScript;
-
/**
* Creates a new MffContext with the default configuration.
*
@@ -200,9 +194,7 @@ public class MffContext {
mCameraStreamer.stop();
mCameraStreamer.tearDown();
}
- if (Build.VERSION.SDK_INT >= 11) {
- maybeDestroyRenderScript();
- }
+
stopRunners(false);
waitUntilStopped();
tearDown();
@@ -301,14 +293,6 @@ public class MffContext {
return mCameraStreamingSupport;
}
- @TargetApi(11)
- public final RenderScript getRenderScript() {
- if (mRenderScript == null) {
- mRenderScript = RenderScript.create(mApplicationContext);
- }
- return mRenderScript;
- }
-
final void assertOpenGLSupported() {
if (!isOpenGLSupported()) {
throw new RuntimeException("Attempting to use OpenGL ES 2 in a context that does not "
@@ -459,12 +443,4 @@ public class MffContext {
return (context instanceof Activity) ? (Activity) context : null;
}
- @TargetApi(11)
- private void maybeDestroyRenderScript() {
- if (mRenderScript != null) {
- mRenderScript.destroy();
- mRenderScript = null;
- }
- }
-
}
diff --git a/tests/Input/src/com/android/test/input/UnresponsiveGestureMonitorActivity.kt b/tests/Input/src/com/android/test/input/UnresponsiveGestureMonitorActivity.kt
index e56ce81e8ce6..63782f1bf955 100644
--- a/tests/Input/src/com/android/test/input/UnresponsiveGestureMonitorActivity.kt
+++ b/tests/Input/src/com/android/test/input/UnresponsiveGestureMonitorActivity.kt
@@ -45,7 +45,7 @@ class UnresponsiveGestureMonitorActivity : Activity() {
private lateinit var mInputMonitor: InputMonitor
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
- val inputManager = getSystemService(InputManager::class.java)
+ val inputManager = checkNotNull(getSystemService(InputManager::class.java))
mInputMonitor = inputManager.monitorGestureInput(MONITOR_NAME, displayId)
mInputEventReceiver = UnresponsiveReceiver(
mInputMonitor.getInputChannel(), Looper.myLooper()!!)
diff --git a/tests/Internal/src/stub/DummyWallpaperService.java b/tests/Internal/src/stub/DummyWallpaperService.java
index 084c036bea26..db1b7805a316 100644
--- a/tests/Internal/src/stub/DummyWallpaperService.java
+++ b/tests/Internal/src/stub/DummyWallpaperService.java
@@ -19,7 +19,7 @@ package stub;
import android.service.wallpaper.WallpaperService;
/**
- * Dummy wallpaper service only for test purposes, won't draw anything.
+ * Placeholder wallpaper service only for test purposes, won't draw anything.
*/
public class DummyWallpaperService extends WallpaperService {
@Override
diff --git a/tests/SilkFX/src/com/android/test/silkfx/hdr/GainmapMetadataEditor.kt b/tests/SilkFX/src/com/android/test/silkfx/hdr/GainmapMetadataEditor.kt
index 8a653045c97b..1a79a11a3718 100644
--- a/tests/SilkFX/src/com/android/test/silkfx/hdr/GainmapMetadataEditor.kt
+++ b/tests/SilkFX/src/com/android/test/silkfx/hdr/GainmapMetadataEditor.kt
@@ -99,23 +99,23 @@ class GainmapMetadataEditor(val parent: ViewGroup, val renderView: View) {
(view.getParent() as ViewGroup).removeView(view)
parent.addView(view)
- view.findViewById<Button>(R.id.gainmap_metadata_done)!!.setOnClickListener {
+ view.requireViewById<Button>(R.id.gainmap_metadata_done).setOnClickListener {
closeEditor()
}
- view.findViewById<Button>(R.id.gainmap_metadata_reset)!!.setOnClickListener {
+ view.requireViewById<Button>(R.id.gainmap_metadata_reset).setOnClickListener {
resetGainmapMetadata()
}
updateMetadataUi()
- val gainmapMinSeek = view.findViewById<SeekBar>(R.id.gainmap_metadata_gainmapmin)
- val gainmapMaxSeek = view.findViewById<SeekBar>(R.id.gainmap_metadata_gainmapmax)
- val capacityMinSeek = view.findViewById<SeekBar>(R.id.gainmap_metadata_capacitymin)
- val capacityMaxSeek = view.findViewById<SeekBar>(R.id.gainmap_metadata_capacitymax)
- val gammaSeek = view.findViewById<SeekBar>(R.id.gainmap_metadata_gamma)
- val offsetSdrSeek = view.findViewById<SeekBar>(R.id.gainmap_metadata_offsetsdr)
- val offsetHdrSeek = view.findViewById<SeekBar>(R.id.gainmap_metadata_offsethdr)
+ val gainmapMinSeek = view.requireViewById<SeekBar>(R.id.gainmap_metadata_gainmapmin)
+ val gainmapMaxSeek = view.requireViewById<SeekBar>(R.id.gainmap_metadata_gainmapmax)
+ val capacityMinSeek = view.requireViewById<SeekBar>(R.id.gainmap_metadata_capacitymin)
+ val capacityMaxSeek = view.requireViewById<SeekBar>(R.id.gainmap_metadata_capacitymax)
+ val gammaSeek = view.requireViewById<SeekBar>(R.id.gainmap_metadata_gamma)
+ val offsetSdrSeek = view.requireViewById<SeekBar>(R.id.gainmap_metadata_offsetsdr)
+ val offsetHdrSeek = view.requireViewById<SeekBar>(R.id.gainmap_metadata_offsethdr)
arrayOf(gainmapMinSeek, gainmapMaxSeek, capacityMinSeek, capacityMaxSeek, gammaSeek,
offsetSdrSeek, offsetHdrSeek).forEach {
it.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener{
@@ -140,13 +140,13 @@ class GainmapMetadataEditor(val parent: ViewGroup, val renderView: View) {
}
private fun updateMetadataUi() {
- val gainmapMinSeek = parent.findViewById<SeekBar>(R.id.gainmap_metadata_gainmapmin)
- val gainmapMaxSeek = parent.findViewById<SeekBar>(R.id.gainmap_metadata_gainmapmax)
- val capacityMinSeek = parent.findViewById<SeekBar>(R.id.gainmap_metadata_capacitymin)
- val capacityMaxSeek = parent.findViewById<SeekBar>(R.id.gainmap_metadata_capacitymax)
- val gammaSeek = parent.findViewById<SeekBar>(R.id.gainmap_metadata_gamma)
- val offsetSdrSeek = parent.findViewById<SeekBar>(R.id.gainmap_metadata_offsetsdr)
- val offsetHdrSeek = parent.findViewById<SeekBar>(R.id.gainmap_metadata_offsethdr)
+ val gainmapMinSeek = parent.requireViewById<SeekBar>(R.id.gainmap_metadata_gainmapmin)
+ val gainmapMaxSeek = parent.requireViewById<SeekBar>(R.id.gainmap_metadata_gainmapmax)
+ val capacityMinSeek = parent.requireViewById<SeekBar>(R.id.gainmap_metadata_capacitymin)
+ val capacityMaxSeek = parent.requireViewById<SeekBar>(R.id.gainmap_metadata_capacitymax)
+ val gammaSeek = parent.requireViewById<SeekBar>(R.id.gainmap_metadata_gamma)
+ val offsetSdrSeek = parent.requireViewById<SeekBar>(R.id.gainmap_metadata_offsetsdr)
+ val offsetHdrSeek = parent.requireViewById<SeekBar>(R.id.gainmap_metadata_offsethdr)
gainmapMinSeek.setProgress(
((currentMetadata.ratioMin - minRatioMin) / maxRatioMin * maxProgress).toInt())
@@ -166,19 +166,19 @@ class GainmapMetadataEditor(val parent: ViewGroup, val renderView: View) {
((1.0 - Math.log(currentMetadata.offsetHdr.toDouble() / Math.log(3.0)) / -11.0)
.toFloat() * maxProgress).toInt())
- parent.findViewById<TextView>(R.id.gainmap_metadata_gainmapmin_val)!!.setText(
+ parent.requireViewById<TextView>(R.id.gainmap_metadata_gainmapmin_val).setText(
"%.3f".format(currentMetadata.ratioMin))
- parent.findViewById<TextView>(R.id.gainmap_metadata_gainmapmax_val)!!.setText(
+ parent.requireViewById<TextView>(R.id.gainmap_metadata_gainmapmax_val).setText(
"%.3f".format(currentMetadata.ratioMax))
- parent.findViewById<TextView>(R.id.gainmap_metadata_capacitymin_val)!!.setText(
+ parent.requireViewById<TextView>(R.id.gainmap_metadata_capacitymin_val).setText(
"%.3f".format(currentMetadata.capacityMin))
- parent.findViewById<TextView>(R.id.gainmap_metadata_capacitymax_val)!!.setText(
+ parent.requireViewById<TextView>(R.id.gainmap_metadata_capacitymax_val).setText(
"%.3f".format(currentMetadata.capacityMax))
- parent.findViewById<TextView>(R.id.gainmap_metadata_gamma_val)!!.setText(
+ parent.requireViewById<TextView>(R.id.gainmap_metadata_gamma_val).setText(
"%.3f".format(currentMetadata.gamma))
- parent.findViewById<TextView>(R.id.gainmap_metadata_offsetsdr_val)!!.setText(
+ parent.requireViewById<TextView>(R.id.gainmap_metadata_offsetsdr_val).setText(
"%.5f".format(currentMetadata.offsetSdr))
- parent.findViewById<TextView>(R.id.gainmap_metadata_offsethdr_val)!!.setText(
+ parent.requireViewById<TextView>(R.id.gainmap_metadata_offsethdr_val).setText(
"%.5f".format(currentMetadata.offsetHdr))
}
@@ -201,7 +201,7 @@ class GainmapMetadataEditor(val parent: ViewGroup, val renderView: View) {
private fun updateGainmapMin(normalized: Float) {
val newValue = minRatioMin + normalized * (maxRatioMin - minRatioMin)
- parent.findViewById<TextView>(R.id.gainmap_metadata_gainmapmin_val)!!.setText(
+ parent.requireViewById<TextView>(R.id.gainmap_metadata_gainmapmin_val).setText(
"%.3f".format(newValue))
currentMetadata.ratioMin = newValue
if (showingEdits) {
@@ -212,7 +212,7 @@ class GainmapMetadataEditor(val parent: ViewGroup, val renderView: View) {
private fun updateGainmapMax(normalized: Float) {
val newValue = minRatioMax + normalized * (maxRatioMax - minRatioMax)
- parent.findViewById<TextView>(R.id.gainmap_metadata_gainmapmax_val)!!.setText(
+ parent.requireViewById<TextView>(R.id.gainmap_metadata_gainmapmax_val).setText(
"%.3f".format(newValue))
currentMetadata.ratioMax = newValue
if (showingEdits) {
@@ -223,7 +223,7 @@ class GainmapMetadataEditor(val parent: ViewGroup, val renderView: View) {
private fun updateCapacityMin(normalized: Float) {
val newValue = minCapacityMin + normalized * (maxCapacityMin - minCapacityMin)
- parent.findViewById<TextView>(R.id.gainmap_metadata_capacitymin_val)!!.setText(
+ parent.requireViewById<TextView>(R.id.gainmap_metadata_capacitymin_val).setText(
"%.3f".format(newValue))
currentMetadata.capacityMin = newValue
if (showingEdits) {
@@ -234,7 +234,7 @@ class GainmapMetadataEditor(val parent: ViewGroup, val renderView: View) {
private fun updateCapacityMax(normalized: Float) {
val newValue = minCapacityMax + normalized * (maxCapacityMax - minCapacityMax)
- parent.findViewById<TextView>(R.id.gainmap_metadata_capacitymax_val)!!.setText(
+ parent.requireViewById<TextView>(R.id.gainmap_metadata_capacitymax_val).setText(
"%.3f".format(newValue))
currentMetadata.capacityMax = newValue
if (showingEdits) {
@@ -245,7 +245,7 @@ class GainmapMetadataEditor(val parent: ViewGroup, val renderView: View) {
private fun updateGamma(normalized: Float) {
val newValue = minGamma + normalized * (maxGamma - minGamma)
- parent.findViewById<TextView>(R.id.gainmap_metadata_gamma_val)!!.setText(
+ parent.requireViewById<TextView>(R.id.gainmap_metadata_gamma_val).setText(
"%.3f".format(newValue))
currentMetadata.gamma = newValue
if (showingEdits) {
@@ -259,7 +259,7 @@ class GainmapMetadataEditor(val parent: ViewGroup, val renderView: View) {
if (normalized > 0.0f ) {
newValue = Math.pow(3.0, (1.0 - normalized.toDouble()) * -11.0).toFloat()
}
- parent.findViewById<TextView>(R.id.gainmap_metadata_offsetsdr_val)!!.setText(
+ parent.requireViewById<TextView>(R.id.gainmap_metadata_offsetsdr_val).setText(
"%.5f".format(newValue))
currentMetadata.offsetSdr = newValue
if (showingEdits) {
@@ -273,7 +273,7 @@ class GainmapMetadataEditor(val parent: ViewGroup, val renderView: View) {
if (normalized > 0.0f ) {
newValue = Math.pow(3.0, (1.0 - normalized.toDouble()) * -11.0).toFloat()
}
- parent.findViewById<TextView>(R.id.gainmap_metadata_offsethdr_val)!!.setText(
+ parent.requireViewById<TextView>(R.id.gainmap_metadata_offsethdr_val).setText(
"%.5f".format(newValue))
currentMetadata.offsetHdr = newValue
if (showingEdits) {
diff --git a/tests/SilkFX/src/com/android/test/silkfx/materials/GlassView.kt b/tests/SilkFX/src/com/android/test/silkfx/materials/GlassView.kt
index 2f2578b87f35..41baeadf7a8c 100644
--- a/tests/SilkFX/src/com/android/test/silkfx/materials/GlassView.kt
+++ b/tests/SilkFX/src/com/android/test/silkfx/materials/GlassView.kt
@@ -190,9 +190,9 @@ class GlassView(context: Context, attributeSet: AttributeSet) : FrameLayout(cont
sensorManager?.unregisterListener(sensorListener)
}
- override fun onDraw(canvas: Canvas?) {
+ override fun onDraw(canvas: Canvas) {
updateGlassRenderNode()
- canvas?.drawRenderNode(renderNode)
+ canvas.drawRenderNode(renderNode)
}
fun resetGyroOffsets() {
@@ -227,4 +227,4 @@ class GlassView(context: Context, attributeSet: AttributeSet) : FrameLayout(cont
renderNodeIsDirty = false
}
}
-} \ No newline at end of file
+}
diff --git a/tests/TrustTests/src/android/trust/test/lib/LockStateTrackingRule.kt b/tests/TrustTests/src/android/trust/test/lib/LockStateTrackingRule.kt
index 1400dde5781d..c1a7bd9e1d8f 100644
--- a/tests/TrustTests/src/android/trust/test/lib/LockStateTrackingRule.kt
+++ b/tests/TrustTests/src/android/trust/test/lib/LockStateTrackingRule.kt
@@ -30,7 +30,7 @@ import org.junit.runners.model.Statement
*/
class LockStateTrackingRule : TestRule {
private val context: Context = getApplicationContext()
- private val windowManager = WindowManagerGlobal.getWindowManagerService()
+ private val windowManager = checkNotNull(WindowManagerGlobal.getWindowManagerService())
@Volatile lateinit var lockState: LockState
private set
diff --git a/tests/TrustTests/src/android/trust/test/lib/ScreenLockRule.kt b/tests/TrustTests/src/android/trust/test/lib/ScreenLockRule.kt
index 4189baae10cb..f1edca3ff86e 100644
--- a/tests/TrustTests/src/android/trust/test/lib/ScreenLockRule.kt
+++ b/tests/TrustTests/src/android/trust/test/lib/ScreenLockRule.kt
@@ -36,7 +36,7 @@ import org.junit.runners.model.Statement
class ScreenLockRule : TestRule {
private val context: Context = getApplicationContext()
private val uiDevice = UiDevice.getInstance(getInstrumentation())
- private val windowManager = WindowManagerGlobal.getWindowManagerService()
+ private val windowManager = checkNotNull(WindowManagerGlobal.getWindowManagerService())
private val lockPatternUtils = LockPatternUtils(context)
private var instantLockSavedValue = false
diff --git a/tools/aapt/Android.bp b/tools/aapt/Android.bp
index cc10db9e1523..cecd95a5e616 100644
--- a/tools/aapt/Android.bp
+++ b/tools/aapt/Android.bp
@@ -97,6 +97,7 @@ cc_library_host_static {
"ResourceTable.cpp",
"SourcePos.cpp",
"StringPool.cpp",
+ "Utils.cpp",
"WorkQueue.cpp",
"XMLNode.cpp",
"ZipEntry.cpp",
diff --git a/tools/aapt/Package.cpp b/tools/aapt/Package.cpp
index 965655b59a94..a7ff5fabf495 100644
--- a/tools/aapt/Package.cpp
+++ b/tools/aapt/Package.cpp
@@ -8,6 +8,7 @@
#include "OutputSet.h"
#include "ResourceTable.h"
#include "ResourceFilter.h"
+#include "Utils.h"
#include <androidfw/misc.h>
@@ -226,7 +227,7 @@ ssize_t processAssets(Bundle* bundle, ZipFile* zip, const sp<const OutputSet>& o
fprintf(stderr, "warning: null file being processed.\n");
} else {
String8 storagePath(entry.getPath());
- storagePath.convertToResPath();
+ convertToResPath(storagePath);
if (!processFile(bundle, zip, storagePath, entry.getFile())) {
return UNKNOWN_ERROR;
}
diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp
index 4ca3a68d02a6..9c944e0de075 100644
--- a/tools/aapt/Resource.cpp
+++ b/tools/aapt/Resource.cpp
@@ -15,6 +15,7 @@
#include "ResourceTable.h"
#include "StringPool.h"
#include "Symbol.h"
+#include "Utils.h"
#include "WorkQueue.h"
#include "XMLNode.h"
@@ -321,7 +322,7 @@ static status_t makeFileResources(Bundle* bundle, const sp<AaptAssets>& assets,
str++;
}
String8 resPath = it.getPath();
- resPath.convertToResPath();
+ convertToResPath(resPath);
status_t result = table->addEntry(SourcePos(it.getPath(), 0),
String16(assets->getPackage()),
type16,
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index 23440074a326..449e0808806e 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -11,6 +11,7 @@
#include "ResourceFilter.h"
#include "ResourceIdCache.h"
#include "SdkConstants.h"
+#include "Utils.h"
#include <algorithm>
#include <androidfw/ResourceTypes.h>
@@ -4803,7 +4804,7 @@ bool ResourceTable::versionForCompat(const Bundle* bundle, const String16& resou
String8 resPath = String8::format("res/%s/%s.xml",
newFile->getGroupEntry().toDirName(target->getResourceType()).c_str(),
String8(resourceName).c_str());
- resPath.convertToResPath();
+ convertToResPath(resPath);
// Add a resource table entry.
addEntry(SourcePos(),
@@ -4927,7 +4928,7 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle,
String8 resPath = String8::format("res/%s/%s.xml",
newFile->getGroupEntry().toDirName(target->getResourceType()).c_str(),
String8(resourceName).c_str());
- resPath.convertToResPath();
+ convertToResPath(resPath);
// Add a resource table entry.
if (bundle->getVerbose()) {
diff --git a/tools/aapt/Utils.cpp b/tools/aapt/Utils.cpp
new file mode 100644
index 000000000000..36b018e7dd2c
--- /dev/null
+++ b/tools/aapt/Utils.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2005 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "Utils.h"
+
+#include <utils/Compat.h>
+
+// Separator used by resource paths. This is not platform dependent contrary
+// to OS_PATH_SEPARATOR.
+#define RES_PATH_SEPARATOR '/'
+
+using android::String8;
+
+void convertToResPath([[maybe_unused]] String8& s) {
+#if OS_PATH_SEPARATOR != RES_PATH_SEPARATOR
+ size_t len = s.length();
+ if (len > 0) {
+ char* buf = s.lockBuffer(len);
+ for (char* end = buf + len; buf < end; ++buf) {
+ if (*buf == OS_PATH_SEPARATOR) *buf = RES_PATH_SEPARATOR;
+ }
+ s.unlockBuffer(len);
+ }
+#endif
+}
diff --git a/tools/aapt/Utils.h b/tools/aapt/Utils.h
new file mode 100644
index 000000000000..8eb594138478
--- /dev/null
+++ b/tools/aapt/Utils.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2005 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+// This file contains cruft that used to be in libutils' String8, that's only
+// used for aapt.
+
+#include <utils/String8.h>
+
+// Converts all separators in this string to /, the default path
+// separator.
+// If the default OS separator is backslash, this converts all
+// backslashes to slashes, in-place. Otherwise it does nothing.
+void convertToResPath(android::String8&);