diff options
| -rw-r--r-- | Android.bp | 1 | ||||
| -rw-r--r-- | core/java/android/content/rollback/OWNERS | 8 | ||||
| -rw-r--r-- | core/java/android/os/GraphicsEnvironment.java | 1 | ||||
| -rw-r--r-- | core/java/android/os/UpdateEngineStable.java | 192 | ||||
| -rw-r--r-- | core/java/android/os/UpdateEngineStableCallback.java | 46 | ||||
| -rw-r--r-- | core/java/android/security/responsible_apis_flags.aconfig | 29 | ||||
| -rw-r--r-- | data/keyboards/Generic.kl | 24 | ||||
| -rw-r--r-- | services/tests/mockingservicestests/Android.bp | 1 |
8 files changed, 285 insertions, 17 deletions
diff --git a/Android.bp b/Android.bp index 316555f7391e..ebdb1a1a9082 100644 --- a/Android.bp +++ b/Android.bp @@ -127,6 +127,7 @@ filegroup { ":libcamera_client_aidl", ":libcamera_client_framework_aidl", ":libupdate_engine_aidl", + ":libupdate_engine_stable-V2-java-source", ":logd_aidl", ":resourcemanager_aidl", ":storaged_aidl", diff --git a/core/java/android/content/rollback/OWNERS b/core/java/android/content/rollback/OWNERS index 3093fd686a21..8e5a0d8af550 100644 --- a/core/java/android/content/rollback/OWNERS +++ b/core/java/android/content/rollback/OWNERS @@ -1,5 +1,5 @@ -# Bug component: 557916 +# Bug component: 819107 -narayan@google.com -nandana@google.com -olilan@google.com +ancr@google.com +harshitmahajan@google.com +robertogil@google.com diff --git a/core/java/android/os/GraphicsEnvironment.java b/core/java/android/os/GraphicsEnvironment.java index 8fcff78fb025..3149de4c39e7 100644 --- a/core/java/android/os/GraphicsEnvironment.java +++ b/core/java/android/os/GraphicsEnvironment.java @@ -673,6 +673,7 @@ public class GraphicsEnvironment { if (anglePkg.isEmpty()) { return; } + intent.setPackage(anglePkg); context.sendOrderedBroadcast(intent, null, new BroadcastReceiver() { @Override diff --git a/core/java/android/os/UpdateEngineStable.java b/core/java/android/os/UpdateEngineStable.java new file mode 100644 index 000000000000..9e2593e39e0e --- /dev/null +++ b/core/java/android/os/UpdateEngineStable.java @@ -0,0 +1,192 @@ +/* + * Copyright (C) 2024 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. + */ + +package android.os; + +import android.annotation.IntDef; + +/** + * UpdateEngineStable handles calls to the update engine stalbe which takes care of A/B OTA updates. + * This interface has lesser functionalities than UpdateEngine and doesn't allow cancel. + * + * <p>The minimal flow is: + * + * <ol> + * <li>Create a new UpdateEngineStable instance. + * <li>Call {@link #bind}, provide callback function. + * <li>Call {@link #applyPayloadFd}. + * </ol> + * + * The APIs defined in this class and UpdateEngineStableCallback class must be in sync with the ones + * in {@code system/update_engine/stable/android/os/IUpdateEngineStable.aidl} and {@code + * ssystem/update_engine/stable/android/os/IUpdateEngineStableCallback.aidl}. + * + * @hide + */ +public class UpdateEngineStable { + private static final String TAG = "UpdateEngineStable"; + + private static final String UPDATE_ENGINE_STABLE_SERVICE = + "android.os.UpdateEngineStableService"; + + /** + * Error codes from update engine upon finishing a call to {@link applyPayloadFd}. Values will + * be passed via the callback function {@link + * UpdateEngineStableCallback#onPayloadApplicationComplete}. Values must agree with the ones in + * {@code system/update_engine/common/error_code.h}. + */ + /** @hide */ + @IntDef( + value = { + UpdateEngine.ErrorCodeConstants.SUCCESS, + UpdateEngine.ErrorCodeConstants.ERROR, + UpdateEngine.ErrorCodeConstants.FILESYSTEM_COPIER_ERROR, + UpdateEngine.ErrorCodeConstants.POST_INSTALL_RUNNER_ERROR, + UpdateEngine.ErrorCodeConstants.PAYLOAD_MISMATCHED_TYPE_ERROR, + UpdateEngine.ErrorCodeConstants.INSTALL_DEVICE_OPEN_ERROR, + UpdateEngine.ErrorCodeConstants.KERNEL_DEVICE_OPEN_ERROR, + UpdateEngine.ErrorCodeConstants.DOWNLOAD_TRANSFER_ERROR, + UpdateEngine.ErrorCodeConstants.PAYLOAD_HASH_MISMATCH_ERROR, + UpdateEngine.ErrorCodeConstants.PAYLOAD_SIZE_MISMATCH_ERROR, + UpdateEngine.ErrorCodeConstants.DOWNLOAD_PAYLOAD_VERIFICATION_ERROR, + UpdateEngine.ErrorCodeConstants.PAYLOAD_TIMESTAMP_ERROR, + UpdateEngine.ErrorCodeConstants.UPDATED_BUT_NOT_ACTIVE, + UpdateEngine.ErrorCodeConstants.NOT_ENOUGH_SPACE, + UpdateEngine.ErrorCodeConstants.DEVICE_CORRUPTED, + }) + public @interface ErrorCode {} + + private final IUpdateEngineStable mUpdateEngineStable; + private IUpdateEngineStableCallback mUpdateEngineStableCallback = null; + private final Object mUpdateEngineStableCallbackLock = new Object(); + + /** + * Creates a new instance. + * + * @hide + */ + public UpdateEngineStable() { + mUpdateEngineStable = + IUpdateEngineStable.Stub.asInterface( + ServiceManager.getService(UPDATE_ENGINE_STABLE_SERVICE)); + if (mUpdateEngineStable == null) { + throw new IllegalStateException("Failed to find " + UPDATE_ENGINE_STABLE_SERVICE); + } + } + + /** + * Prepares this instance for use. The callback will be notified on any status change, and when + * the update completes. A handler can be supplied to control which thread runs the callback, or + * null. + * + * @hide + */ + public boolean bind(final UpdateEngineStableCallback callback, final Handler handler) { + synchronized (mUpdateEngineStableCallbackLock) { + mUpdateEngineStableCallback = + new IUpdateEngineStableCallback.Stub() { + @Override + public void onStatusUpdate(final int status, final float percent) { + if (handler != null) { + handler.post( + new Runnable() { + @Override + public void run() { + callback.onStatusUpdate(status, percent); + } + }); + } else { + callback.onStatusUpdate(status, percent); + } + } + + @Override + public void onPayloadApplicationComplete(final int errorCode) { + if (handler != null) { + handler.post( + new Runnable() { + @Override + public void run() { + callback.onPayloadApplicationComplete(errorCode); + } + }); + } else { + callback.onPayloadApplicationComplete(errorCode); + } + } + + @Override + public int getInterfaceVersion() { + return super.VERSION; + } + + @Override + public String getInterfaceHash() { + return super.HASH; + } + }; + + try { + return mUpdateEngineStable.bind(mUpdateEngineStableCallback); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + } + + /** + * Equivalent to {@code bind(callback, null)}. + * + * @hide + */ + public boolean bind(final UpdateEngineStableCallback callback) { + return bind(callback, null); + } + + /** + * Applies payload from given ParcelFileDescriptor. Usage is same as UpdateEngine#applyPayload + * + * @hide + */ + public void applyPayloadFd( + ParcelFileDescriptor fd, long offset, long size, String[] headerKeyValuePairs) { + try { + mUpdateEngineStable.applyPayloadFd(fd, offset, size, headerKeyValuePairs); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** + * Unbinds the last bound callback function. + * + * @hide + */ + public boolean unbind() { + synchronized (mUpdateEngineStableCallbackLock) { + if (mUpdateEngineStableCallback == null) { + return true; + } + try { + boolean result = mUpdateEngineStable.unbind(mUpdateEngineStableCallback); + mUpdateEngineStableCallback = null; + return result; + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + } +} diff --git a/core/java/android/os/UpdateEngineStableCallback.java b/core/java/android/os/UpdateEngineStableCallback.java new file mode 100644 index 000000000000..4bcfb4baae95 --- /dev/null +++ b/core/java/android/os/UpdateEngineStableCallback.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2024 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. + */ + +package android.os; + +/** + * Callback function for UpdateEngineStable. Used to keep the caller up to date with progress, so + * the UI (if any) can be updated. + * + * <p>The APIs defined in this class and UpdateEngineStable class must be in sync with the ones in + * system/update_engine/stable/android/os/IUpdateEngineStable.aidl and + * system/update_engine/stable/android/os/IUpdateEngineStableCallback.aidl. + * + * <p>{@hide} + */ +public abstract class UpdateEngineStableCallback { + + /** + * Invoked when anything changes. The value of {@code status} will be one of the values from + * {@link UpdateEngine.UpdateStatusConstants}, and {@code percent} will be valid + * + * @hide + */ + public abstract void onStatusUpdate(int status, float percent); + + /** + * Invoked when the payload has been applied, whether successfully or unsuccessfully. The value + * of {@code errorCode} will be one of the values from {@link UpdateEngine.ErrorCodeConstants}. + * + * @hide + */ + public abstract void onPayloadApplicationComplete(@UpdateEngineStable.ErrorCode int errorCode); +} diff --git a/core/java/android/security/responsible_apis_flags.aconfig b/core/java/android/security/responsible_apis_flags.aconfig new file mode 100644 index 000000000000..fe6c4a4321e9 --- /dev/null +++ b/core/java/android/security/responsible_apis_flags.aconfig @@ -0,0 +1,29 @@ +package: "android.security" + +flag { + name: "extend_ecm_to_all_settings" + namespace: "responsible_apis" + description: "Allow all app settings to be restrictable via configuration" + bug: "297372999" +} + +flag { + name: "asm_restrictions_enabled" + namespace: "responsible_apis" + description: "Enables ASM restrictions for activity starts and finishes" + bug: "230590090" +} + +flag { + name: "asm_toasts_enabled" + namespace: "responsible_apis" + description: "Enables toasts when ASM restrictions are triggered" + bug: "230590090" +} + +flag { + name: "content_uri_permission_apis" + namespace: "responsible_apis" + description: "Enables the content URI permission APIs" + bug: "293467489" +} diff --git a/data/keyboards/Generic.kl b/data/keyboards/Generic.kl index 31092536bac5..51b720ddb758 100644 --- a/data/keyboards/Generic.kl +++ b/data/keyboards/Generic.kl @@ -430,19 +430,17 @@ key 658 MACRO_3 key 659 MACRO_4 # Keys defined by HID usages -key usage 0x0c0067 WINDOW -key usage 0x0c006F BRIGHTNESS_UP -key usage 0x0c0070 BRIGHTNESS_DOWN -key usage 0x0c0079 KEYBOARD_BACKLIGHT_UP -key usage 0x0c007A KEYBOARD_BACKLIGHT_DOWN -key usage 0x0c007C KEYBOARD_BACKLIGHT_TOGGLE -key usage 0x0c0173 MEDIA_AUDIO_TRACK -key usage 0x0c019C PROFILE_SWITCH -key usage 0x0c01A2 ALL_APPS -# TODO(b/297094448): Add stylus button mappings as a fallback when we have a way to determine -# if a device can actually report it. -# key usage 0x0d0044 STYLUS_BUTTON_PRIMARY -# key usage 0x0d005a STYLUS_BUTTON_SECONDARY +key usage 0x0c0067 WINDOW FALLBACK_USAGE_MAPPING +key usage 0x0c006F BRIGHTNESS_UP FALLBACK_USAGE_MAPPING +key usage 0x0c0070 BRIGHTNESS_DOWN FALLBACK_USAGE_MAPPING +key usage 0x0c0079 KEYBOARD_BACKLIGHT_UP FALLBACK_USAGE_MAPPING +key usage 0x0c007A KEYBOARD_BACKLIGHT_DOWN FALLBACK_USAGE_MAPPING +key usage 0x0c007C KEYBOARD_BACKLIGHT_TOGGLE FALLBACK_USAGE_MAPPING +key usage 0x0c0173 MEDIA_AUDIO_TRACK FALLBACK_USAGE_MAPPING +key usage 0x0c019C PROFILE_SWITCH FALLBACK_USAGE_MAPPING +key usage 0x0c01A2 ALL_APPS FALLBACK_USAGE_MAPPING +key usage 0x0d0044 STYLUS_BUTTON_PRIMARY FALLBACK_USAGE_MAPPING +key usage 0x0d005a STYLUS_BUTTON_SECONDARY FALLBACK_USAGE_MAPPING # Joystick and game controller axes. # Axes that are not mapped will be assigned generic axis numbers by the input subsystem. diff --git a/services/tests/mockingservicestests/Android.bp b/services/tests/mockingservicestests/Android.bp index f56f290643c6..8f25c0d6b013 100644 --- a/services/tests/mockingservicestests/Android.bp +++ b/services/tests/mockingservicestests/Android.bp @@ -71,6 +71,7 @@ android_test { // TODO: remove once Android migrates to JUnit 4.12, which provides assertThrows "testng", "compatibility-device-util-axt", + "flag-junit", ], libs: [ |