Merge "Add a comment explaining a bug fix" into main
diff --git a/core/java/android/hardware/input/InputDeviceSensorManager.java b/core/java/android/hardware/input/InputDeviceSensorManager.java
index 05024ea..8afcc78 100644
--- a/core/java/android/hardware/input/InputDeviceSensorManager.java
+++ b/core/java/android/hardware/input/InputDeviceSensorManager.java
@@ -17,6 +17,7 @@
package android.hardware.input;
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.hardware.HardwareBuffer;
import android.hardware.Sensor;
import android.hardware.SensorAdditionalInfo;
@@ -37,7 +38,6 @@
import android.view.InputDevice;
import com.android.internal.annotations.GuardedBy;
-import com.android.internal.os.SomeArgs;
import java.util.ArrayList;
import java.util.HashMap;
@@ -49,14 +49,14 @@
* sensors.
* @hide
*/
-public class InputDeviceSensorManager implements InputManager.InputDeviceListener {
+public class InputDeviceSensorManager {
private static final String TAG = "InputDeviceSensorManager";
private static final boolean DEBUG = false;
private static final int MSG_SENSOR_ACCURACY_CHANGED = 1;
private static final int MSG_SENSOR_CHANGED = 2;
- private InputManagerGlobal mGlobal;
+ private final InputManagerGlobal mGlobal;
// sensor map from device id to sensor list
@GuardedBy("mInputSensorLock")
@@ -66,19 +66,16 @@
private InputSensorEventListener mInputServiceSensorListener;
@GuardedBy("mInputSensorLock")
private final ArrayList<InputSensorEventListenerDelegate> mInputSensorEventListeners =
- new ArrayList<InputSensorEventListenerDelegate>();
- private final HandlerThread mSensorThread;
- private final Handler mSensorHandler;
+ new ArrayList<>();
+
+ // The sensor thread is only initialized if there is a listener added without a handler.
+ @GuardedBy("mInputSensorLock")
+ @Nullable
+ private HandlerThread mSensorThread;
public InputDeviceSensorManager(InputManagerGlobal inputManagerGlobal) {
mGlobal = inputManagerGlobal;
- mSensorThread = new HandlerThread("SensorThread");
- mSensorThread.start();
- mSensorHandler = new Handler(mSensorThread.getLooper());
-
- // Register the input device listener
- mGlobal.registerInputDeviceListener(this, mSensorHandler);
// Initialize the sensor list
initializeSensors();
}
@@ -105,7 +102,6 @@
}
}
- @Override
public void onInputDeviceAdded(int deviceId) {
synchronized (mInputSensorLock) {
if (!mSensors.containsKey(deviceId)) {
@@ -117,14 +113,12 @@
}
}
- @Override
public void onInputDeviceRemoved(int deviceId) {
synchronized (mInputSensorLock) {
mSensors.remove(deviceId);
}
}
- @Override
public void onInputDeviceChanged(int deviceId) {
synchronized (mInputSensorLock) {
mSensors.remove(deviceId);
@@ -133,14 +127,11 @@
}
private static boolean sensorEquals(@NonNull Sensor lhs, @NonNull Sensor rhs) {
- if (lhs.getType() == rhs.getType() && lhs.getId() == rhs.getId()) {
- return true;
- }
- return false;
+ return lhs.getType() == rhs.getType() && lhs.getId() == rhs.getId();
}
private void populateSensorsForInputDeviceLocked(int deviceId, InputSensorInfo[] sensorInfos) {
- List<Sensor> sensors = new ArrayList<Sensor>();
+ List<Sensor> sensors = new ArrayList<>();
for (int i = 0; i < sensorInfos.length; i++) {
Sensor sensor = new Sensor(sensorInfos[i]);
if (DEBUG) {
@@ -197,6 +188,11 @@
}
synchronized (mInputSensorLock) {
Sensor sensor = getInputDeviceSensorLocked(deviceId, sensorType);
+ if (sensor == null) {
+ Slog.wtf(TAG, "onInputSensorChanged: Got sensor update for device " + deviceId
+ + " but the sensor was not found.");
+ return;
+ }
for (int i = 0; i < mInputSensorEventListeners.size(); i++) {
InputSensorEventListenerDelegate listener =
mInputSensorEventListeners.get(i);
@@ -252,20 +248,16 @@
private static final class InputSensorEventListenerDelegate extends Handler {
private final SensorEventListener mListener;
- private final int mDelayUs;
- private final int mMaxBatchReportLatencyUs;
// List of sensors being listened to
- private List<Sensor> mSensors = new ArrayList<Sensor>();
+ private final List<Sensor> mSensors = new ArrayList<>();
// Sensor event array by sensor type, preallocate sensor events for each sensor of listener
// to avoid allocation and garbage collection for each listener callback.
- private final SparseArray<SensorEvent> mSensorEvents = new SparseArray<SensorEvent>();
+ private final SparseArray<SensorEvent> mSensorEvents = new SparseArray<>();
InputSensorEventListenerDelegate(SensorEventListener listener, Sensor sensor,
- int delayUs, int maxBatchReportLatencyUs, Handler handler) {
- super(handler != null ? handler.getLooper() : Looper.myLooper());
+ Looper looper) {
+ super(looper);
mListener = listener;
- mDelayUs = delayUs;
- mMaxBatchReportLatencyUs = maxBatchReportLatencyUs;
addSensor(sensor);
}
@@ -280,12 +272,13 @@
/**
* Remove sensor from sensor list for listener
*/
- public void removeSensor(Sensor sensor) {
+ public void removeSensor(@Nullable Sensor sensor) {
// If sensor is not specified the listener will be unregistered for all sensors
// and the sensor list is cleared.
if (sensor == null) {
mSensors.clear();
mSensorEvents.clear();
+ return;
}
for (Sensor s : mSensors) {
if (sensorEquals(s, sensor)) {
@@ -306,7 +299,7 @@
}
}
mSensors.add(sensor);
- final int vecLength = sensor.getMaxLengthValuesArray(sensor, Build.VERSION.SDK_INT);
+ final int vecLength = Sensor.getMaxLengthValuesArray(sensor, Build.VERSION.SDK_INT);
SensorEvent event = new SensorEvent(sensor, SensorManager.SENSOR_STATUS_NO_CONTACT,
0 /* timestamp */, new float[vecLength]);
mSensorEvents.put(sensor.getType(), event);
@@ -345,7 +338,6 @@
* Send sensor changed message
*/
public void sendSensorChanged(SensorEvent event) {
- SomeArgs args = SomeArgs.obtain();
obtainMessage(MSG_SENSOR_CHANGED, event).sendToTarget();
}
@@ -353,7 +345,6 @@
* Send sensor accuracy changed message
*/
public void sendSensorAccuracyChanged(int deviceId, int sensorType, int accuracy) {
- SomeArgs args = SomeArgs.obtain();
obtainMessage(MSG_SENSOR_ACCURACY_CHANGED, deviceId, sensorType, accuracy)
.sendToTarget();
}
@@ -442,15 +433,21 @@
Slog.e(TAG, "Trigger Sensors should use the requestTriggerSensor.");
return false;
}
+
if (maxBatchReportLatencyUs < 0 || delayUs < 0) {
Slog.e(TAG, "maxBatchReportLatencyUs and delayUs should be non-negative");
return false;
}
- if (getSensorForInputDevice(sensor.getId(), sensor.getType()) != null) {
- synchronized (mInputSensorLock) {
+ synchronized (mInputSensorLock) {
+ if (getSensorForInputDevice(sensor.getId(), sensor.getType()) != null) {
final int deviceId = sensor.getId();
- InputDevice inputDevice = InputDevice.getDevice(deviceId);
+ final InputDevice inputDevice = mGlobal.getInputDevice(deviceId);
+ if (inputDevice == null) {
+ Slog.e(TAG, "input device not found for sensor " + sensor.getId());
+ return false;
+ }
+
if (!inputDevice.hasSensor()) {
Slog.e(TAG, "The device doesn't have the sensor:" + sensor);
return false;
@@ -461,9 +458,7 @@
return false;
}
}
- }
- synchronized (mInputSensorLock) {
// Register the InputManagerService sensor listener if not yet.
if (mInputServiceSensorListener == null) {
mInputServiceSensorListener = new InputSensorEventListener();
@@ -476,9 +471,8 @@
int idx = findSensorEventListenerLocked(listener);
if (idx < 0) {
InputSensorEventListenerDelegate d =
- new InputSensorEventListenerDelegate(listener, sensor, delayUs,
- maxBatchReportLatencyUs,
- handler == null ? mSensorHandler : handler);
+ new InputSensorEventListenerDelegate(listener, sensor,
+ getLooperForListenerLocked(handler));
mInputSensorEventListeners.add(d);
} else {
// The listener is already registered, see if it wants to listen to more sensors.
@@ -489,6 +483,19 @@
return true;
}
+ @GuardedBy("mInputSensorLock")
+ @NonNull
+ private Looper getLooperForListenerLocked(@Nullable Handler requestedHandler) {
+ if (requestedHandler != null) {
+ return requestedHandler.getLooper();
+ }
+ if (mSensorThread == null) {
+ mSensorThread = new HandlerThread("SensorThread");
+ mSensorThread.start();
+ }
+ return mSensorThread.getLooper();
+ }
+
private void unregisterListenerInternal(SensorEventListener listener, Sensor sensor) {
if (DEBUG) {
Slog.d(TAG, "unregisterListenerImpl listener=" + listener + " sensor=" + sensor);
@@ -503,7 +510,7 @@
if (idx >= 0) {
InputSensorEventListenerDelegate delegate =
mInputSensorEventListeners.get(idx);
- sensorsRegistered = new ArrayList<Sensor>(delegate.getSensors());
+ sensorsRegistered = new ArrayList<>(delegate.getSensors());
// Get the sensor types the listener is listening to
delegate.removeSensor(sensor);
if (delegate.isEmpty()) {
@@ -515,7 +522,7 @@
return;
}
// If no delegation remains, unregister the listener to input service
- if (mInputServiceSensorListener != null && mInputSensorEventListeners.size() == 0) {
+ if (mInputServiceSensorListener != null && mInputSensorEventListeners.isEmpty()) {
mGlobal.unregisterSensorListener(mInputServiceSensorListener);
mInputServiceSensorListener = null;
}
@@ -545,7 +552,7 @@
}
}
- private boolean flush(SensorEventListener listener) {
+ private boolean flushInternal(SensorEventListener listener) {
synchronized (mInputSensorLock) {
int idx = findSensorEventListenerLocked(listener);
if (idx < 0) {
@@ -601,7 +608,7 @@
@Override
protected boolean flushImpl(SensorEventListener listener) {
- return flush(listener);
+ return flushInternal(listener);
}
@Override
diff --git a/core/java/android/hardware/input/InputManager.java b/core/java/android/hardware/input/InputManager.java
index 7b8419e..abbf954 100644
--- a/core/java/android/hardware/input/InputManager.java
+++ b/core/java/android/hardware/input/InputManager.java
@@ -1095,62 +1095,6 @@
}
/**
- * Get sensors information as list.
- *
- * @hide
- */
- public InputSensorInfo[] getSensorList(int deviceId) {
- return mGlobal.getSensorList(deviceId);
- }
-
- /**
- * Enable input device sensor
- *
- * @hide
- */
- public boolean enableSensor(int deviceId, int sensorType, int samplingPeriodUs,
- int maxBatchReportLatencyUs) {
- return mGlobal.enableSensor(deviceId, sensorType, samplingPeriodUs,
- maxBatchReportLatencyUs);
- }
-
- /**
- * Enable input device sensor
- *
- * @hide
- */
- public void disableSensor(int deviceId, int sensorType) {
- mGlobal.disableSensor(deviceId, sensorType);
- }
-
- /**
- * Flush input device sensor
- *
- * @hide
- */
- public boolean flushSensor(int deviceId, int sensorType) {
- return mGlobal.flushSensor(deviceId, sensorType);
- }
-
- /**
- * Register input device sensor listener
- *
- * @hide
- */
- public boolean registerSensorListener(IInputSensorEventListener listener) {
- return mGlobal.registerSensorListener(listener);
- }
-
- /**
- * Unregister input device sensor listener
- *
- * @hide
- */
- public void unregisterSensorListener(IInputSensorEventListener listener) {
- mGlobal.unregisterSensorListener(listener);
- }
-
- /**
* Add a runtime association between the input port and the display port. This overrides any
* static associations.
* @param inputPort The port of the input device.
diff --git a/core/java/android/hardware/input/InputManagerGlobal.java b/core/java/android/hardware/input/InputManagerGlobal.java
index 8c598ae..cf1dfe3 100644
--- a/core/java/android/hardware/input/InputManagerGlobal.java
+++ b/core/java/android/hardware/input/InputManagerGlobal.java
@@ -100,6 +100,9 @@
@GuardedBy("mKeyboardBacklightListenerLock")
@Nullable private IKeyboardBacklightListener mKeyboardBacklightListener;
+ // InputDeviceSensorManager gets notified synchronously from the binder thread when input
+ // devices change, so it must be synchronized with the input device listeners.
+ @GuardedBy("mInputDeviceListeners")
@Nullable private InputDeviceSensorManager mInputDeviceSensorManager;
private static InputManagerGlobal sInstance;
@@ -250,6 +253,9 @@
Log.d(TAG, "Device removed: " + deviceId);
}
mInputDevices.removeAt(i);
+ if (mInputDeviceSensorManager != null) {
+ mInputDeviceSensorManager.onInputDeviceRemoved(deviceId);
+ }
sendMessageToInputDeviceListenersLocked(
InputDeviceListenerDelegate.MSG_DEVICE_REMOVED, deviceId);
}
@@ -267,6 +273,9 @@
Log.d(TAG, "Device changed: " + deviceId);
}
mInputDevices.setValueAt(index, null);
+ if (mInputDeviceSensorManager != null) {
+ mInputDeviceSensorManager.onInputDeviceChanged(deviceId);
+ }
sendMessageToInputDeviceListenersLocked(
InputDeviceListenerDelegate.MSG_DEVICE_CHANGED, deviceId);
}
@@ -276,6 +285,9 @@
Log.d(TAG, "Device added: " + deviceId);
}
mInputDevices.put(deviceId, null);
+ if (mInputDeviceSensorManager != null) {
+ mInputDeviceSensorManager.onInputDeviceAdded(deviceId);
+ }
sendMessageToInputDeviceListenersLocked(
InputDeviceListenerDelegate.MSG_DEVICE_ADDED, deviceId);
}
@@ -930,14 +942,17 @@
*/
@NonNull
public SensorManager getInputDeviceSensorManager(int deviceId) {
- if (mInputDeviceSensorManager == null) {
- mInputDeviceSensorManager = new InputDeviceSensorManager(this);
+ synchronized (mInputDeviceListeners) {
+ if (mInputDeviceSensorManager == null) {
+ mInputDeviceSensorManager = new InputDeviceSensorManager(this);
+ }
+ return mInputDeviceSensorManager.getSensorManager(deviceId);
}
- return mInputDeviceSensorManager.getSensorManager(deviceId);
}
/**
- * @see InputManager#getSensorList(int)
+ * Get information about all of the sensors supported by an input device
+ * @see InputDeviceSensorManager
*/
InputSensorInfo[] getSensorList(int deviceId) {
try {
@@ -948,7 +963,7 @@
}
/**
- * @see InputManager#enableSensor(int, int, int, int)
+ * @see InputDeviceSensorManager
*/
boolean enableSensor(int deviceId, int sensorType, int samplingPeriodUs,
int maxBatchReportLatencyUs) {
@@ -961,7 +976,7 @@
}
/**
- * @see InputManager#disableSensor(int, int)
+ * @see InputDeviceSensorManager
*/
void disableSensor(int deviceId, int sensorType) {
try {
@@ -972,7 +987,7 @@
}
/**
- * @see InputManager#flushSensor(int, int)
+ * @see InputDeviceSensorManager
*/
boolean flushSensor(int deviceId, int sensorType) {
try {
@@ -983,7 +998,7 @@
}
/**
- * @see InputManager#registerSensorListener(IInputSensorEventListener)
+ * @see InputDeviceSensorManager
*/
boolean registerSensorListener(IInputSensorEventListener listener) {
try {
@@ -994,7 +1009,7 @@
}
/**
- * @see InputManager#unregisterSensorListener(IInputSensorEventListener)
+ * @see InputDeviceSensorManager
*/
void unregisterSensorListener(IInputSensorEventListener listener) {
try {
diff --git a/packages/PackageInstaller/AndroidManifest.xml b/packages/PackageInstaller/AndroidManifest.xml
index c80891c..2e4fd9b 100644
--- a/packages/PackageInstaller/AndroidManifest.xml
+++ b/packages/PackageInstaller/AndroidManifest.xml
@@ -206,7 +206,7 @@
android:noHistory="true"
android:exported="true">
<intent-filter android:priority="1">
- <action android:name="android.intent.action.UNARCHIVE_DIALOG" />
+ <action android:name="com.android.intent.action.UNARCHIVE_DIALOG" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
diff --git a/packages/PackageInstaller/TEST_MAPPING b/packages/PackageInstaller/TEST_MAPPING
index cef9014..76d7ab1 100644
--- a/packages/PackageInstaller/TEST_MAPPING
+++ b/packages/PackageInstaller/TEST_MAPPING
@@ -22,6 +22,9 @@
},
{
"name": "PackageInstallerTests"
+ },
+ {
+ "name": "CtsIntentSignatureTestCases"
}
]
}
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/media/controls/ui/composable/MediaCarousel.kt b/packages/SystemUI/compose/features/src/com/android/systemui/media/controls/ui/composable/MediaCarousel.kt
new file mode 100644
index 0000000..735c433
--- /dev/null
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/media/controls/ui/composable/MediaCarousel.kt
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2023 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 com.android.systemui.media.controls.ui.composable
+
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.viewinterop.AndroidView
+import com.android.compose.animation.scene.ElementKey
+import com.android.compose.animation.scene.SceneScope
+import com.android.systemui.media.controls.ui.MediaCarouselController
+import com.android.systemui.media.controls.ui.MediaHost
+import com.android.systemui.util.animation.MeasurementInput
+
+private object MediaCarousel {
+ object Elements {
+ internal val Content = ElementKey("MediaCarouselContent")
+ }
+}
+
+@Composable
+fun SceneScope.MediaCarousel(
+ mediaHost: MediaHost,
+ modifier: Modifier = Modifier,
+ layoutWidth: Int,
+ layoutHeight: Int,
+ carouselController: MediaCarouselController,
+) {
+ // Notify controller to size the carousel for the current space
+ mediaHost.measurementInput = MeasurementInput(layoutWidth, layoutHeight)
+ carouselController.setSceneContainerSize(layoutWidth, layoutHeight)
+
+ AndroidView(
+ modifier = modifier.element(MediaCarousel.Elements.Content),
+ factory = { _ -> carouselController.mediaFrame },
+ )
+}
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt
index 2df151b..fcb1619 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt
@@ -23,23 +23,34 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
+import androidx.compose.ui.layout.layout
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.unit.dp
import com.android.compose.animation.scene.ElementKey
import com.android.compose.animation.scene.SceneScope
import com.android.systemui.battery.BatteryMeterViewController
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
+import com.android.systemui.media.controls.ui.MediaCarouselController
+import com.android.systemui.media.controls.ui.MediaHost
+import com.android.systemui.media.controls.ui.composable.MediaCarousel
+import com.android.systemui.media.dagger.MediaModule.QUICK_QS_PANEL
import com.android.systemui.notifications.ui.composable.NotificationStack
import com.android.systemui.qs.ui.adapter.QSSceneAdapter
import com.android.systemui.qs.ui.composable.QuickSettings
+import com.android.systemui.res.R
import com.android.systemui.scene.shared.model.Direction
import com.android.systemui.scene.shared.model.SceneKey
import com.android.systemui.scene.shared.model.SceneModel
@@ -49,7 +60,9 @@
import com.android.systemui.statusbar.phone.StatusBarIconController
import com.android.systemui.statusbar.phone.StatusBarIconController.TintedIconManager
import com.android.systemui.statusbar.phone.StatusBarLocation
+import com.android.systemui.util.animation.MeasurementInput
import javax.inject.Inject
+import javax.inject.Named
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
@@ -59,6 +72,7 @@
object Shade {
object Elements {
val QuickSettings = ElementKey("ShadeQuickSettings")
+ val MediaCarousel = ElementKey("ShadeMediaCarousel")
val Scrim = ElementKey("ShadeScrim")
val ScrimBackground = ElementKey("ShadeScrimBackground")
}
@@ -87,6 +101,8 @@
private val tintedIconManagerFactory: TintedIconManager.Factory,
private val batteryMeterViewControllerFactory: BatteryMeterViewController.Factory,
private val statusBarIconController: StatusBarIconController,
+ private val mediaCarouselController: MediaCarouselController,
+ @Named(QUICK_QS_PANEL) private val mediaHost: MediaHost,
) : ComposableScene {
override val key = SceneKey.Shade
@@ -108,6 +124,8 @@
createTintedIconManager = tintedIconManagerFactory::create,
createBatteryMeterViewController = batteryMeterViewControllerFactory::create,
statusBarIconController = statusBarIconController,
+ mediaCarouselController = mediaCarouselController,
+ mediaHost = mediaHost,
modifier = modifier,
)
@@ -127,8 +145,12 @@
createTintedIconManager: (ViewGroup, StatusBarLocation) -> TintedIconManager,
createBatteryMeterViewController: (ViewGroup, StatusBarLocation) -> BatteryMeterViewController,
statusBarIconController: StatusBarIconController,
+ mediaCarouselController: MediaCarouselController,
+ mediaHost: MediaHost,
modifier: Modifier = Modifier,
) {
+ val layoutWidth = remember { mutableStateOf(0) }
+
Box(modifier.element(Shade.Elements.Scrim)) {
Spacer(
modifier =
@@ -159,6 +181,34 @@
viewModel.qsSceneAdapter,
QSSceneAdapter.State.QQS
)
+
+ if (viewModel.isMediaVisible()) {
+ val mediaHeight = dimensionResource(R.dimen.qs_media_session_height_expanded)
+ MediaCarousel(
+ modifier =
+ Modifier.height(mediaHeight).fillMaxWidth().layout { measurable, constraints
+ ->
+ val placeable = measurable.measure(constraints)
+
+ // Notify controller to size the carousel for the current space
+ mediaHost.measurementInput =
+ MeasurementInput(placeable.width, placeable.height)
+ mediaCarouselController.setSceneContainerSize(
+ placeable.width,
+ placeable.height
+ )
+
+ layout(placeable.width, placeable.height) {
+ placeable.placeRelative(0, 0)
+ }
+ },
+ mediaHost = mediaHost,
+ layoutWidth = layoutWidth.value,
+ layoutHeight = with(LocalDensity.current) { mediaHeight.toPx() }.toInt(),
+ carouselController = mediaCarouselController,
+ )
+ }
+
Spacer(modifier = Modifier.height(16.dp))
NotificationStack(
viewModel = viewModel.notifications,
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt
index 18b7168..9a748b9 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt
@@ -37,6 +37,8 @@
import com.android.systemui.keyguard.ui.viewmodel.KeyguardLongPressViewModel
import com.android.systemui.keyguard.ui.viewmodel.LockscreenSceneViewModel
import com.android.systemui.log.table.TableLogBuffer
+import com.android.systemui.media.controls.pipeline.MediaDataManager
+import com.android.systemui.media.controls.ui.MediaHost
import com.android.systemui.model.SysUiState
import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAsleepForTest
import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAwakeForTest
@@ -188,6 +190,9 @@
private val qsFlexiglassAdapter = FakeQSSceneAdapter(inflateDelegate = { _, _ -> mock<View>() })
+ @Mock private lateinit var mediaDataManager: MediaDataManager
+ @Mock private lateinit var mediaHost: MediaHost
+
@Before
fun setUp() {
MockitoAnnotations.initMocks(this)
@@ -240,6 +245,8 @@
shadeHeaderViewModel = shadeHeaderViewModel,
qsSceneAdapter = qsFlexiglassAdapter,
notifications = utils.notificationsPlaceholderViewModel(),
+ mediaDataManager = mediaDataManager,
+ mediaHost = mediaHost,
)
utils.deviceEntryRepository.setUnlocked(false)
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModelTest.kt
index e2640af..a2946cc 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModelTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModelTest.kt
@@ -23,6 +23,8 @@
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.flags.FakeFeatureFlagsClassic
import com.android.systemui.flags.Flags
+import com.android.systemui.media.controls.pipeline.MediaDataManager
+import com.android.systemui.media.controls.ui.MediaHost
import com.android.systemui.qs.ui.adapter.FakeQSSceneAdapter
import com.android.systemui.scene.SceneTestUtils
import com.android.systemui.scene.shared.model.SceneKey
@@ -35,6 +37,7 @@
import com.android.systemui.statusbar.pipeline.mobile.util.FakeMobileMappingsProxy
import com.android.systemui.statusbar.pipeline.shared.data.repository.FakeConnectivityRepository
import com.android.systemui.util.mockito.mock
+import com.android.systemui.util.mockito.whenever
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runCurrent
@@ -42,6 +45,8 @@
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
+import org.mockito.Mock
+import org.mockito.MockitoAnnotations
@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
@@ -83,8 +88,12 @@
private lateinit var underTest: ShadeSceneViewModel
+ @Mock private lateinit var mediaDataManager: MediaDataManager
+ @Mock private lateinit var mediaHost: MediaHost
+
@Before
fun setUp() {
+ MockitoAnnotations.initMocks(this)
shadeHeaderViewModel =
ShadeHeaderViewModel(
applicationScope = testScope.backgroundScope,
@@ -102,6 +111,8 @@
shadeHeaderViewModel = shadeHeaderViewModel,
qsSceneAdapter = qsFlexiglassAdapter,
notifications = utils.notificationsPlaceholderViewModel(),
+ mediaDataManager = mediaDataManager,
+ mediaHost = mediaHost,
)
}
@@ -174,4 +185,20 @@
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
}
+
+ @Test
+ fun hasActiveMedia_mediaVisible() =
+ testScope.runTest {
+ whenever(mediaDataManager.hasActiveMediaOrRecommendation()).thenReturn(true)
+
+ assertThat(underTest.isMediaVisible()).isTrue()
+ }
+
+ @Test
+ fun doesNotHaveActiveMedia_mediaNotVisible() =
+ testScope.runTest {
+ whenever(mediaDataManager.hasActiveMediaOrRecommendation()).thenReturn(false)
+
+ assertThat(underTest.isMediaVisible()).isFalse()
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaCarouselController.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaCarouselController.kt
index a252470..9cdf857 100644
--- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaCarouselController.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaCarouselController.kt
@@ -271,6 +271,10 @@
private val isReorderingAllowed: Boolean
get() = visualStabilityProvider.isReorderingAllowed
+ /** Size provided by the scene framework container */
+ private var widthInSceneContainerPx = 0
+ private var heightInSceneContainerPx = 0
+
init {
dumpManager.registerDumpable(TAG, this)
mediaFrame = inflateMediaCarousel()
@@ -581,6 +585,15 @@
}
}
+ fun setSceneContainerSize(width: Int, height: Int) {
+ if (width == widthInSceneContainerPx && height == heightInSceneContainerPx) {
+ return
+ }
+ widthInSceneContainerPx = width
+ heightInSceneContainerPx = height
+ updatePlayers(recreateMedia = true)
+ }
+
private fun reorderAllPlayers(
previousVisiblePlayerKey: MediaPlayerData.MediaSortKey?,
key: String? = null
@@ -638,6 +651,11 @@
.elementAtOrNull(mediaCarouselScrollHandler.visibleMediaIndex)
if (existingPlayer == null) {
val newPlayer = mediaControlPanelFactory.get()
+ if (mediaFlags.isSceneContainerEnabled()) {
+ newPlayer.mediaViewController.widthInSceneContainerPx = widthInSceneContainerPx
+ newPlayer.mediaViewController.heightInSceneContainerPx =
+ heightInSceneContainerPx
+ }
newPlayer.attachPlayer(
MediaViewHolder.create(LayoutInflater.from(context), mediaContent)
)
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaControlPanel.java b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaControlPanel.java
index cce4cda..04883c3 100644
--- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaControlPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaControlPanel.java
@@ -81,7 +81,6 @@
import com.android.internal.widget.CachingIconView;
import com.android.settingslib.widget.AdaptiveIcon;
import com.android.systemui.ActivityIntentHelper;
-import com.android.systemui.res.R;
import com.android.systemui.animation.ActivityLaunchAnimator;
import com.android.systemui.animation.GhostedViewLaunchAnimatorController;
import com.android.systemui.bluetooth.BroadcastDialogController;
@@ -102,6 +101,7 @@
import com.android.systemui.media.controls.models.recommendation.SmartspaceMediaData;
import com.android.systemui.media.controls.pipeline.MediaDataManager;
import com.android.systemui.media.controls.util.MediaDataUtils;
+import com.android.systemui.media.controls.util.MediaFlags;
import com.android.systemui.media.controls.util.MediaUiEventLogger;
import com.android.systemui.media.controls.util.SmallHash;
import com.android.systemui.media.dialog.MediaOutputDialogFactory;
@@ -109,6 +109,7 @@
import com.android.systemui.monet.Style;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.FalsingManager;
+import com.android.systemui.res.R;
import com.android.systemui.shared.system.SysUiStatsLog;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.policy.KeyguardStateController;
@@ -190,6 +191,7 @@
@VisibleForTesting static final long TURBULENCE_NOISE_PLAY_DURATION = 7500L;
private final SeekBarViewModel mSeekBarViewModel;
+ private final MediaFlags mMediaFlags;
private SeekBarObserver mSeekBarObserver;
protected final Executor mBackgroundExecutor;
private final DelayableExecutor mMainExecutor;
@@ -280,7 +282,8 @@
NotificationLockscreenUserManager lockscreenUserManager,
BroadcastDialogController broadcastDialogController,
FeatureFlags featureFlags,
- GlobalSettings globalSettings
+ GlobalSettings globalSettings,
+ MediaFlags mediaFlags
) {
mContext = context;
mBackgroundExecutor = backgroundExecutor;
@@ -299,6 +302,7 @@
mActivityIntentHelper = activityIntentHelper;
mLockscreenUserManager = lockscreenUserManager;
mBroadcastDialogController = broadcastDialogController;
+ mMediaFlags = mediaFlags;
mSeekBarViewModel.setLogSeek(() -> {
if (mPackageName != null && mInstanceId != null) {
@@ -575,7 +579,10 @@
// to something which might impact the measurement
// State refresh interferes with the translation animation, only run it if it's not running.
if (!mMetadataAnimationHandler.isRunning()) {
- mMediaViewController.refreshState();
+ // Don't refresh in scene framework, because it will calculate with invalid layout sizes
+ if (!mMediaFlags.isSceneContainerEnabled()) {
+ mMediaViewController.refreshState();
+ }
}
// Turbulence noise
@@ -805,7 +812,14 @@
// Capture width & height from views in foreground for artwork scaling in background
int width = mMediaViewHolder.getAlbumView().getMeasuredWidth();
int height = mMediaViewHolder.getAlbumView().getMeasuredHeight();
+ if (mMediaFlags.isSceneContainerEnabled() && (width <= 0 || height <= 0)) {
+ // TODO(b/312714128): ensure we have a valid size before setting background
+ width = mMediaViewController.getWidthInSceneContainerPx();
+ height = mMediaViewController.getHeightInSceneContainerPx();
+ }
+ final int finalWidth = width;
+ final int finalHeight = height;
mBackgroundExecutor.execute(() -> {
// Album art
ColorScheme mutableColorScheme = null;
@@ -815,7 +829,8 @@
WallpaperColors wallpaperColors = getWallpaperColor(artworkIcon);
if (wallpaperColors != null) {
mutableColorScheme = new ColorScheme(wallpaperColors, true, Style.CONTENT);
- artwork = addGradientToPlayerAlbum(artworkIcon, mutableColorScheme, width, height);
+ artwork = addGradientToPlayerAlbum(artworkIcon, mutableColorScheme, finalWidth,
+ finalHeight);
isArtworkBound = true;
} else {
// If there's no artwork, use colors from the app icon
@@ -857,8 +872,10 @@
TransitionDrawable transitionDrawable = new TransitionDrawable(
new Drawable[]{mPrevArtwork, artwork});
- scaleTransitionDrawableLayer(transitionDrawable, 0, width, height);
- scaleTransitionDrawableLayer(transitionDrawable, 1, width, height);
+ scaleTransitionDrawableLayer(transitionDrawable, 0, finalWidth,
+ finalHeight);
+ scaleTransitionDrawableLayer(transitionDrawable, 1, finalWidth,
+ finalHeight);
transitionDrawable.setLayerGravity(0, Gravity.CENTER);
transitionDrawable.setLayerGravity(1, Gravity.CENTER);
transitionDrawable.setCrossFadeEnabled(true);
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHierarchyManager.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHierarchyManager.kt
index 9d6e9b4..35456d5 100644
--- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHierarchyManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHierarchyManager.kt
@@ -43,6 +43,7 @@
import com.android.systemui.dreams.DreamOverlayStateController
import com.android.systemui.keyguard.WakefulnessLifecycle
import com.android.systemui.media.controls.pipeline.MediaDataManager
+import com.android.systemui.media.controls.util.MediaFlags
import com.android.systemui.media.dream.MediaDreamComplication
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.res.R
@@ -108,6 +109,7 @@
@Application private val coroutineScope: CoroutineScope,
private val splitShadeStateController: SplitShadeStateController,
private val logger: MediaViewLogger,
+ private val mediaFlags: MediaFlags,
) {
/** Track the media player setting status on lock screen. */
@@ -215,6 +217,7 @@
}
private val mediaHosts = arrayOfNulls<MediaHost>(LOCATION_COMMUNAL_HUB + 1)
+
/**
* The last location where this view was at before going to the desired location. This is useful
* for guided transitions.
@@ -1041,6 +1044,17 @@
private fun updateHostAttachment() =
traceSection("MediaHierarchyManager#updateHostAttachment") {
+ if (mediaFlags.isSceneContainerEnabled()) {
+ // No need to manage transition states - just update the desired location directly
+ logger.logMediaHostAttachment(desiredLocation)
+ mediaCarouselController.onDesiredLocationChanged(
+ desiredLocation = desiredLocation,
+ desiredHostState = getHost(desiredLocation),
+ animate = false,
+ )
+ return
+ }
+
var newLocation = resolveLocationForFading()
// Don't use the overlay when fading or when we don't have active media
var canUseOverlay = !isCurrentlyFading() && hasActiveMediaOrRecommendation
@@ -1124,6 +1138,7 @@
(!bypassController.bypassEnabled && (statusbarState == StatusBarState.KEYGUARD))
val location =
when {
+ mediaFlags.isSceneContainerEnabled() -> desiredLocation
dreamOverlayActive && dreamMediaComplicationActive -> LOCATION_DREAM_OVERLAY
(qsExpansion > 0.0f || inSplitShade) && !onLockscreen -> LOCATION_QS
qsExpansion > 0.4f && onLockscreen -> LOCATION_QS
@@ -1282,7 +1297,7 @@
MediaHierarchyManager.LOCATION_QQS,
MediaHierarchyManager.LOCATION_LOCKSCREEN,
MediaHierarchyManager.LOCATION_DREAM_OVERLAY,
- MediaHierarchyManager.LOCATION_COMMUNAL_HUB
+ MediaHierarchyManager.LOCATION_COMMUNAL_HUB,
]
)
@Retention(AnnotationRetention.SOURCE)
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaViewController.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaViewController.kt
index d277f32..a99c51c2 100644
--- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaViewController.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaViewController.kt
@@ -28,6 +28,7 @@
import com.android.systemui.media.controls.util.MediaFlags
import com.android.systemui.res.R
import com.android.systemui.statusbar.policy.ConfigurationController
+import com.android.systemui.util.animation.MeasurementInput
import com.android.systemui.util.animation.MeasurementOutput
import com.android.systemui.util.animation.TransitionLayout
import com.android.systemui.util.animation.TransitionLayoutController
@@ -207,6 +208,10 @@
var isGutsVisible = false
private set
+ /** Size provided by the scene framework container */
+ var widthInSceneContainerPx = 0
+ var heightInSceneContainerPx = 0
+
init {
mediaHostStatesManager.addController(this)
layoutController.sizeChangedListener = { width: Int, height: Int ->
@@ -420,6 +425,10 @@
state: MediaHostState?,
isGutsAnimation: Boolean = false
): TransitionViewState? {
+ if (mediaFlags.isSceneContainerEnabled()) {
+ return obtainSceneContainerViewState()
+ }
+
if (state == null || state.measurementInput == null) {
return null
}
@@ -670,6 +679,24 @@
refreshState()
}
+ /** Get a view state based on the width and height set by the scene */
+ private fun obtainSceneContainerViewState(): TransitionViewState? {
+ logger.logMediaSize("scene container", widthInSceneContainerPx, heightInSceneContainerPx)
+
+ // Similar to obtainViewState: Let's create a new measurement
+ val result =
+ transitionLayout?.calculateViewState(
+ MeasurementInput(widthInSceneContainerPx, heightInSceneContainerPx),
+ expandedLayout,
+ TransitionViewState()
+ )
+ result?.let {
+ // And then ensure the guts visibility is set correctly
+ setGutsViewState(it)
+ }
+ return result
+ }
+
/**
* Retrieves the [TransitionViewState] and [MediaHostState] of a [@MediaLocation]. In the event
* of [location] not being visible, [locationWhenHidden] will be used instead.
@@ -681,6 +708,10 @@
*/
private fun obtainViewStateForLocation(@MediaLocation location: Int): TransitionViewState? {
val mediaHostState = mediaHostStatesManager.mediaHostStates[location] ?: return null
+ if (mediaFlags.isSceneContainerEnabled()) {
+ return obtainSceneContainerViewState()
+ }
+
val viewState = obtainViewState(mediaHostState)
if (viewState != null) {
// update the size of the viewstate for the location with the override
@@ -708,6 +739,21 @@
/** Clear all existing measurements and refresh the state to match the view. */
fun refreshState() =
traceSection("MediaViewController#refreshState") {
+ if (mediaFlags.isSceneContainerEnabled()) {
+ // We don't need to recreate measurements for scene container, since it's a known
+ // size. Just get the view state and update the layout controller
+ obtainSceneContainerViewState()?.let {
+ // Get scene container state, then setCurrentState
+ layoutController.setState(
+ state = it,
+ applyImmediately = true,
+ animate = false,
+ isGuts = false,
+ )
+ }
+ return
+ }
+
// Let's clear all of our measurements and recreate them!
viewStates.clear()
if (firstRefresh) {
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/util/MediaFlags.kt b/packages/SystemUI/src/com/android/systemui/media/controls/util/MediaFlags.kt
index 44232ff..15747b9 100644
--- a/packages/SystemUI/src/com/android/systemui/media/controls/util/MediaFlags.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/util/MediaFlags.kt
@@ -55,7 +55,7 @@
/** Check whether we allow remote media to generate resume controls */
fun isRemoteResumeAllowed() = featureFlags.isEnabled(Flags.MEDIA_REMOTE_RESUME)
- /** Check whether to use flexiglass layout */
- fun isFlexiglassEnabled() =
+ /** Check whether to use scene framework */
+ fun isSceneContainerEnabled() =
sceneContainerFlags.isEnabled() && MediaInSceneContainerFlag.isEnabled
}
diff --git a/packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModel.kt b/packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModel.kt
index 0065db3..d0da945 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModel.kt
@@ -19,10 +19,16 @@
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor
+import com.android.systemui.media.controls.pipeline.MediaDataManager
+import com.android.systemui.media.controls.ui.MediaHierarchyManager
+import com.android.systemui.media.controls.ui.MediaHost
+import com.android.systemui.media.controls.ui.MediaHostState
+import com.android.systemui.media.dagger.MediaModule
import com.android.systemui.qs.ui.adapter.QSSceneAdapter
import com.android.systemui.scene.shared.model.SceneKey
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationsPlaceholderViewModel
import javax.inject.Inject
+import javax.inject.Named
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
@@ -39,6 +45,8 @@
val qsSceneAdapter: QSSceneAdapter,
val shadeHeaderViewModel: ShadeHeaderViewModel,
val notifications: NotificationsPlaceholderViewModel,
+ val mediaDataManager: MediaDataManager,
+ @Named(MediaModule.QUICK_QS_PANEL) private val mediaHost: MediaHost,
) {
/** The key of the scene we should switch to when swiping up. */
val upDestinationSceneKey: StateFlow<SceneKey> =
@@ -74,4 +82,15 @@
else -> SceneKey.Lockscreen
}
}
+
+ init {
+ mediaHost.expansion = MediaHostState.EXPANDED
+ mediaHost.showsOnlyActiveMedia = true
+ mediaHost.init(MediaHierarchyManager.LOCATION_QQS)
+ }
+
+ fun isMediaVisible(): Boolean {
+ // TODO(b/296122467): handle updates to carousel visibility while scene is still visible
+ return mediaDataManager.hasActiveMediaOrRecommendation()
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaControlPanelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaControlPanelTest.kt
index d6e2e97..2f35380 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaControlPanelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaControlPanelTest.kt
@@ -61,7 +61,6 @@
import com.android.internal.logging.InstanceId
import com.android.internal.widget.CachingIconView
import com.android.systemui.ActivityIntentHelper
-import com.android.systemui.res.R
import com.android.systemui.SysuiTestCase
import com.android.systemui.bluetooth.BroadcastDialogController
import com.android.systemui.broadcast.BroadcastSender
@@ -81,12 +80,14 @@
import com.android.systemui.media.controls.models.recommendation.SmartspaceMediaData
import com.android.systemui.media.controls.pipeline.EMPTY_SMARTSPACE_MEDIA_DATA
import com.android.systemui.media.controls.pipeline.MediaDataManager
+import com.android.systemui.media.controls.util.MediaFlags
import com.android.systemui.media.controls.util.MediaUiEventLogger
import com.android.systemui.media.dialog.MediaOutputDialogFactory
import com.android.systemui.monet.ColorScheme
import com.android.systemui.monet.Style
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.plugins.FalsingManager
+import com.android.systemui.res.R
import com.android.systemui.statusbar.NotificationLockscreenUserManager
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.surfaceeffects.ripple.MultiRippleView
@@ -232,6 +233,7 @@
this.set(Flags.UMO_TURBULENCE_NOISE, false)
}
@Mock private lateinit var globalSettings: GlobalSettings
+ @Mock private lateinit var mediaFlags: MediaFlags
@JvmField @Rule val mockito = MockitoJUnit.rule()
@@ -251,6 +253,7 @@
.thenReturn(applicationInfo)
whenever(packageManager.getApplicationLabel(any())).thenReturn(PACKAGE)
context.setMockPackageManager(packageManager)
+ whenever(mediaFlags.isSceneContainerEnabled()).thenReturn(false)
player =
object :
@@ -273,7 +276,8 @@
lockscreenUserManager,
broadcastDialogController,
fakeFeatureFlag,
- globalSettings
+ globalSettings,
+ mediaFlags,
) {
override fun loadAnimator(
animId: Int,
@@ -1884,7 +1888,8 @@
@Test
fun bindRecommendation_listHasTooFewRecs_notDisplayed() {
player.attachRecommendation(recommendationViewHolder)
- val icon = Icon.createWithResource(context, com.android.settingslib.R.drawable.ic_1x_mobiledata)
+ val icon =
+ Icon.createWithResource(context, com.android.settingslib.R.drawable.ic_1x_mobiledata)
val data =
smartspaceData.copy(
recommendations =
@@ -1911,7 +1916,8 @@
@Test
fun bindRecommendation_listHasTooFewRecsWithIcons_notDisplayed() {
player.attachRecommendation(recommendationViewHolder)
- val icon = Icon.createWithResource(context, com.android.settingslib.R.drawable.ic_1x_mobiledata)
+ val icon =
+ Icon.createWithResource(context, com.android.settingslib.R.drawable.ic_1x_mobiledata)
val data =
smartspaceData.copy(
recommendations =
@@ -1955,7 +1961,8 @@
val subtitle1 = "Subtitle1"
val subtitle2 = "Subtitle2"
val subtitle3 = "Subtitle3"
- val icon = Icon.createWithResource(context, com.android.settingslib.R.drawable.ic_1x_mobiledata)
+ val icon =
+ Icon.createWithResource(context, com.android.settingslib.R.drawable.ic_1x_mobiledata)
val data =
smartspaceData.copy(
@@ -1998,7 +2005,12 @@
listOf(
SmartspaceAction.Builder("id1", "")
.setSubtitle("fake subtitle")
- .setIcon(Icon.createWithResource(context, com.android.settingslib.R.drawable.ic_1x_mobiledata))
+ .setIcon(
+ Icon.createWithResource(
+ context,
+ com.android.settingslib.R.drawable.ic_1x_mobiledata
+ )
+ )
.setExtras(Bundle.EMPTY)
.build()
)
@@ -2013,7 +2025,8 @@
useRealConstraintSets()
player.attachRecommendation(recommendationViewHolder)
- val icon = Icon.createWithResource(context, com.android.settingslib.R.drawable.ic_1x_mobiledata)
+ val icon =
+ Icon.createWithResource(context, com.android.settingslib.R.drawable.ic_1x_mobiledata)
val data =
smartspaceData.copy(
recommendations =
@@ -2047,7 +2060,8 @@
useRealConstraintSets()
player.attachRecommendation(recommendationViewHolder)
- val icon = Icon.createWithResource(context, com.android.settingslib.R.drawable.ic_1x_mobiledata)
+ val icon =
+ Icon.createWithResource(context, com.android.settingslib.R.drawable.ic_1x_mobiledata)
val data =
smartspaceData.copy(
recommendations =
@@ -2086,7 +2100,12 @@
listOf(
SmartspaceAction.Builder("id1", "title1")
.setSubtitle("")
- .setIcon(Icon.createWithResource(context, com.android.settingslib.R.drawable.ic_1x_mobiledata))
+ .setIcon(
+ Icon.createWithResource(
+ context,
+ com.android.settingslib.R.drawable.ic_1x_mobiledata
+ )
+ )
.setExtras(Bundle.EMPTY)
.build(),
SmartspaceAction.Builder("id2", "title2")
@@ -2096,7 +2115,12 @@
.build(),
SmartspaceAction.Builder("id3", "title3")
.setSubtitle("")
- .setIcon(Icon.createWithResource(context, com.android.settingslib.R.drawable.ic_3g_mobiledata))
+ .setIcon(
+ Icon.createWithResource(
+ context,
+ com.android.settingslib.R.drawable.ic_3g_mobiledata
+ )
+ )
.setExtras(Bundle.EMPTY)
.build()
)
@@ -2119,7 +2143,12 @@
listOf(
SmartspaceAction.Builder("id1", "")
.setSubtitle("subtitle1")
- .setIcon(Icon.createWithResource(context, com.android.settingslib.R.drawable.ic_1x_mobiledata))
+ .setIcon(
+ Icon.createWithResource(
+ context,
+ com.android.settingslib.R.drawable.ic_1x_mobiledata
+ )
+ )
.setExtras(Bundle.EMPTY)
.build(),
SmartspaceAction.Builder("id2", "")
@@ -2129,7 +2158,12 @@
.build(),
SmartspaceAction.Builder("id3", "")
.setSubtitle("subtitle3")
- .setIcon(Icon.createWithResource(context, com.android.settingslib.R.drawable.ic_3g_mobiledata))
+ .setIcon(
+ Icon.createWithResource(
+ context,
+ com.android.settingslib.R.drawable.ic_3g_mobiledata
+ )
+ )
.setExtras(Bundle.EMPTY)
.build()
)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaHierarchyManagerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaHierarchyManagerTest.kt
index db7c987..73885f4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaHierarchyManagerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaHierarchyManagerTest.kt
@@ -32,6 +32,7 @@
import com.android.systemui.dreams.DreamOverlayStateController
import com.android.systemui.keyguard.WakefulnessLifecycle
import com.android.systemui.media.controls.pipeline.MediaDataManager
+import com.android.systemui.media.controls.util.MediaFlags
import com.android.systemui.media.dream.MediaDreamComplication
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.res.R
@@ -94,6 +95,7 @@
@Mock private lateinit var dreamOverlayStateController: DreamOverlayStateController
@Mock private lateinit var shadeInteractor: ShadeInteractor
@Mock lateinit var logger: MediaViewLogger
+ @Mock private lateinit var mediaFlags: MediaFlags
@Captor
private lateinit var wakefullnessObserver: ArgumentCaptor<(WakefulnessLifecycle.Observer)>
@Captor
@@ -126,6 +128,7 @@
whenever(mediaCarouselController.mediaFrame).thenReturn(mediaFrame)
isQsBypassingShade = MutableStateFlow(false)
whenever(shadeInteractor.isQsBypassingShade).thenReturn(isQsBypassingShade)
+ whenever(mediaFlags.isSceneContainerEnabled()).thenReturn(false)
mediaHierarchyManager =
MediaHierarchyManager(
context,
@@ -145,6 +148,7 @@
testScope.backgroundScope,
ResourcesSplitShadeStateController(),
logger,
+ mediaFlags,
)
verify(wakefulnessLifecycle).addObserver(wakefullnessObserver.capture())
verify(statusBarStateController).addCallback(statusBarCallback.capture())
diff --git a/services/backup/java/com/android/server/backup/restore/PerformUnifiedRestoreTask.java b/services/backup/java/com/android/server/backup/restore/PerformUnifiedRestoreTask.java
index 96a873e..316a16d 100644
--- a/services/backup/java/com/android/server/backup/restore/PerformUnifiedRestoreTask.java
+++ b/services/backup/java/com/android/server/backup/restore/PerformUnifiedRestoreTask.java
@@ -32,7 +32,6 @@
import android.annotation.Nullable;
import android.app.ApplicationThreadConstants;
import android.app.IBackupAgent;
-import android.app.backup.BackupAnnotations;
import android.app.backup.BackupDataInput;
import android.app.backup.BackupDataOutput;
import android.app.backup.BackupManagerMonitor;
@@ -183,8 +182,7 @@
mUserId = 0;
mBackupEligibilityRules = null;
this.backupManagerService = backupManagerService;
- mBackupManagerMonitorEventSender =
- new BackupManagerMonitorEventSender(/*monitor*/null);
+ mBackupManagerMonitorEventSender = new BackupManagerMonitorEventSender(/* monitor= */ null);
}
// This task can assume that the wakelock is properly held for it and doesn't have to worry
@@ -212,8 +210,7 @@
mTransportConnection = transportConnection;
mObserver = observer;
- mBackupManagerMonitorEventSender =
- new BackupManagerMonitorEventSender(monitor);
+ mBackupManagerMonitorEventSender = new BackupManagerMonitorEventSender(monitor);
mToken = restoreSetToken;
mPmToken = pmToken;
mTargetPackage = targetPackage;
@@ -221,9 +218,10 @@
mFinished = false;
mDidLaunch = false;
mListener = listener;
- mAgentTimeoutParameters = Objects.requireNonNull(
- backupManagerService.getAgentTimeoutParameters(),
- "Timeout parameters cannot be null");
+ mAgentTimeoutParameters =
+ Objects.requireNonNull(
+ backupManagerService.getAgentTimeoutParameters(),
+ "Timeout parameters cannot be null");
mBackupEligibilityRules = backupEligibilityRules;
if (targetPackage != null) {
@@ -236,7 +234,8 @@
// We want everything and a pony
List<PackageInfo> apps =
PackageManagerBackupAgent.getStorableApplications(
- backupManagerService.getPackageManager(), mUserId,
+ backupManagerService.getPackageManager(),
+ mUserId,
backupEligibilityRules);
filterSet = packagesToNames(apps);
if (DEBUG) {
@@ -264,11 +263,11 @@
continue;
}
-
ApplicationInfo applicationInfo = info.applicationInfo;
if (backupEligibilityRules.appIsEligibleForBackup(applicationInfo)) {
if (Flags.enableSkippingRestoreLaunchedApps()
- && !backupEligibilityRules.isAppEligibleForRestore(applicationInfo)) {
+ && !backupEligibilityRules.isAppEligibleForRestore(
+ applicationInfo)) {
continue;
}
@@ -280,16 +279,21 @@
}
if (hasSystem) {
try {
- mAcceptSet.add(0, backupManagerService.getPackageManager().getPackageInfoAsUser(
- PLATFORM_PACKAGE_NAME, 0, mUserId));
+ mAcceptSet.add(
+ 0,
+ backupManagerService
+ .getPackageManager()
+ .getPackageInfoAsUser(PLATFORM_PACKAGE_NAME, 0, mUserId));
} catch (NameNotFoundException e) {
// won't happen; we know a priori that it's valid
}
}
if (hasSettings) {
try {
- mAcceptSet.add(backupManagerService.getPackageManager().getPackageInfoAsUser(
- SETTINGS_PACKAGE, 0, mUserId));
+ mAcceptSet.add(
+ backupManagerService
+ .getPackageManager()
+ .getPackageInfoAsUser(SETTINGS_PACKAGE, 0, mUserId));
} catch (NameNotFoundException e) {
// this one is always valid too
}
@@ -402,15 +406,15 @@
// If we're starting a full-system restore, set up to begin widget ID remapping
if (mIsSystemRestore) {
AppWidgetBackupBridge.systemRestoreStarting(mUserId);
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
BackupManagerMonitor.LOG_EVENT_ID_START_SYSTEM_RESTORE,
null,
BackupManagerMonitor.LOG_EVENT_CATEGORY_BACKUP_MANAGER_POLICY,
monitoringExtras);
} else {
- //We are either performing RestoreAtInstall or Bmgr.
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ // We are either performing RestoreAtInstall or Bmgr.
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
BackupManagerMonitor.LOG_EVENT_ID_START_RESTORE_AT_INSTALL,
null,
@@ -443,7 +447,7 @@
mStatus = transport.startRestore(mToken, packages);
if (mStatus != BackupTransport.TRANSPORT_OK) {
Slog.e(TAG, "Transport error " + mStatus + "; no restore possible");
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
BackupManagerMonitor.LOG_EVENT_ID_TRANSPORT_ERROR_DURING_START_RESTORE,
mCurrentPackage,
@@ -457,7 +461,7 @@
RestoreDescription desc = transport.nextRestorePackage();
if (desc == null) {
Slog.e(TAG, "No restore metadata available; halting");
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
BackupManagerMonitor.LOG_EVENT_ID_NO_RESTORE_METADATA_AVAILABLE,
mCurrentPackage,
@@ -467,11 +471,9 @@
executeNextState(UnifiedRestoreState.FINAL);
return;
}
- if (!PACKAGE_MANAGER_SENTINEL.equals(
- desc.getPackageName())) {
- Slog.e(TAG, "Required package metadata but got "
- + desc.getPackageName());
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ if (!PACKAGE_MANAGER_SENTINEL.equals(desc.getPackageName())) {
+ Slog.e(TAG, "Required package metadata but got " + desc.getPackageName());
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
BackupManagerMonitor.LOG_EVENT_ID_NO_PM_METADATA_RECEIVED,
mCurrentPackage,
@@ -500,26 +502,27 @@
// message and jump straight to the FINAL state. Because this was
// synchronous we also know that we should cancel the pending timeout
// message.
- backupManagerService.getBackupHandler().removeMessages(
- MSG_RESTORE_OPERATION_TIMEOUT);
+ backupManagerService.getBackupHandler().removeMessages(MSG_RESTORE_OPERATION_TIMEOUT);
// Verify that the backup set includes metadata. If not, we can't do
// signature/version verification etc, so we simply do not proceed with
// the restore operation.
if (!mPmAgent.hasMetadata()) {
Slog.e(TAG, "PM agent has no metadata, so not restoring");
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
BackupManagerMonitor.LOG_EVENT_ID_PM_AGENT_HAS_NO_METADATA,
mCurrentPackage,
BackupManagerMonitor.LOG_EVENT_CATEGORY_BACKUP_MANAGER_POLICY,
monitoringExtras);
- EventLog.writeEvent(EventLogTags.RESTORE_AGENT_FAILURE,
+ EventLog.writeEvent(
+ EventLogTags.RESTORE_AGENT_FAILURE,
PACKAGE_MANAGER_SENTINEL,
"Package manager restore metadata missing");
mStatus = BackupTransport.TRANSPORT_ERROR;
- backupManagerService.getBackupHandler().removeMessages(
- MSG_BACKUP_RESTORE_STEP, this);
+ backupManagerService
+ .getBackupHandler()
+ .removeMessages(MSG_BACKUP_RESTORE_STEP, this);
executeNextState(UnifiedRestoreState.FINAL);
return;
}
@@ -530,15 +533,14 @@
} catch (Exception e) {
// If we lost the transport at any time, halt
Slog.e(TAG, "Unable to contact transport for restore: " + e.getMessage());
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
BackupManagerMonitor.LOG_EVENT_ID_LOST_TRANSPORT,
null,
BackupManagerMonitor.LOG_EVENT_CATEGORY_TRANSPORT,
monitoringExtras);
mStatus = BackupTransport.TRANSPORT_ERROR;
- backupManagerService.getBackupHandler().removeMessages(
- MSG_BACKUP_RESTORE_STEP, this);
+ backupManagerService.getBackupHandler().removeMessages(MSG_BACKUP_RESTORE_STEP, this);
executeNextState(UnifiedRestoreState.FINAL);
return;
}
@@ -553,10 +555,10 @@
mTransportConnection.connectOrThrow(
"PerformUnifiedRestoreTask.dispatchNextRestore()");
mRestoreDescription = transport.nextRestorePackage();
- final String pkgName = (mRestoreDescription != null)
- ? mRestoreDescription.getPackageName() : null;
+ final String pkgName =
+ (mRestoreDescription != null) ? mRestoreDescription.getPackageName() : null;
if (pkgName == null) {
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
BackupManagerMonitor.LOG_EVENT_ID_CANNOT_GET_NEXT_PKG_NAME,
null,
@@ -586,23 +588,26 @@
if (metaInfo == null) {
PackageInfo pkgInfo = new PackageInfo();
pkgInfo.packageName = pkgName;
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
BackupManagerMonitor.LOG_EVENT_ID_PM_AGENT_HAS_NO_METADATA,
pkgInfo,
BackupManagerMonitor.LOG_EVENT_CATEGORY_BACKUP_MANAGER_POLICY,
monitoringExtras);
Slog.e(TAG, "No metadata for " + pkgName);
- EventLog.writeEvent(EventLogTags.RESTORE_AGENT_FAILURE, pkgName,
- "Package metadata missing");
+ EventLog.writeEvent(
+ EventLogTags.RESTORE_AGENT_FAILURE, pkgName, "Package metadata missing");
nextState = UnifiedRestoreState.RUNNING_QUEUE;
return;
}
try {
- mCurrentPackage = backupManagerService.getPackageManager().getPackageInfoAsUser(
- pkgName, PackageManager.GET_SIGNING_CERTIFICATES, mUserId);
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ mCurrentPackage =
+ backupManagerService
+ .getPackageManager()
+ .getPackageInfoAsUser(
+ pkgName, PackageManager.GET_SIGNING_CERTIFICATES, mUserId);
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
BackupManagerMonitor.LOG_EVENT_ID_START_PACKAGE_RESTORE,
mCurrentPackage,
@@ -613,14 +618,14 @@
// Whoops, we thought we could restore this package but it
// turns out not to be present. Skip it.
Slog.e(TAG, "Package not present: " + pkgName);
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
BackupManagerMonitor.LOG_EVENT_ID_PACKAGE_NOT_PRESENT,
mCurrentPackage,
BackupManagerMonitor.LOG_EVENT_CATEGORY_BACKUP_MANAGER_POLICY,
monitoringExtras);
- EventLog.writeEvent(EventLogTags.RESTORE_AGENT_FAILURE, pkgName,
- "Package missing on device");
+ EventLog.writeEvent(
+ EventLogTags.RESTORE_AGENT_FAILURE, pkgName, "Package missing on device");
nextState = UnifiedRestoreState.RUNNING_QUEUE;
return;
}
@@ -630,40 +635,53 @@
// installed. If the app has not declared that it is prepared to
// handle this case, we do not attempt the restore.
if ((mCurrentPackage.applicationInfo.flags
- & ApplicationInfo.FLAG_RESTORE_ANY_VERSION) == 0) {
- String message = "Source version " + metaInfo.versionCode
- + " > installed version " + mCurrentPackage.getLongVersionCode();
+ & ApplicationInfo.FLAG_RESTORE_ANY_VERSION)
+ == 0) {
+ String message =
+ "Source version "
+ + metaInfo.versionCode
+ + " > installed version "
+ + mCurrentPackage.getLongVersionCode();
Slog.w(TAG, "Package " + pkgName + ": " + message);
- Bundle monitoringExtras = mBackupManagerMonitorEventSender.putMonitoringExtra(
- null,
- BackupManagerMonitor.EXTRA_LOG_RESTORE_VERSION,
- metaInfo.versionCode);
- monitoringExtras = mBackupManagerMonitorEventSender.putMonitoringExtra(
- monitoringExtras,
- BackupManagerMonitor.EXTRA_LOG_RESTORE_ANYWAY, false);
+ Bundle monitoringExtras =
+ mBackupManagerMonitorEventSender.putMonitoringExtra(
+ null,
+ BackupManagerMonitor.EXTRA_LOG_RESTORE_VERSION,
+ metaInfo.versionCode);
+ monitoringExtras =
+ mBackupManagerMonitorEventSender.putMonitoringExtra(
+ monitoringExtras,
+ BackupManagerMonitor.EXTRA_LOG_RESTORE_ANYWAY,
+ false);
monitoringExtras = addRestoreOperationTypeToEvent(monitoringExtras);
mBackupManagerMonitorEventSender.monitorEvent(
BackupManagerMonitor.LOG_EVENT_ID_RESTORE_VERSION_HIGHER,
mCurrentPackage,
BackupManagerMonitor.LOG_EVENT_CATEGORY_BACKUP_MANAGER_POLICY,
monitoringExtras);
- EventLog.writeEvent(EventLogTags.RESTORE_AGENT_FAILURE,
- pkgName, message);
+ EventLog.writeEvent(EventLogTags.RESTORE_AGENT_FAILURE, pkgName, message);
nextState = UnifiedRestoreState.RUNNING_QUEUE;
return;
} else {
if (DEBUG) {
- Slog.v(TAG, "Source version " + metaInfo.versionCode
- + " > installed version " + mCurrentPackage.getLongVersionCode()
- + " but restoreAnyVersion");
+ Slog.v(
+ TAG,
+ "Source version "
+ + metaInfo.versionCode
+ + " > installed version "
+ + mCurrentPackage.getLongVersionCode()
+ + " but restoreAnyVersion");
}
- Bundle monitoringExtras = mBackupManagerMonitorEventSender.putMonitoringExtra(
- null,
- BackupManagerMonitor.EXTRA_LOG_RESTORE_VERSION,
- metaInfo.versionCode);
- monitoringExtras = mBackupManagerMonitorEventSender.putMonitoringExtra(
- monitoringExtras,
- BackupManagerMonitor.EXTRA_LOG_RESTORE_ANYWAY, true);
+ Bundle monitoringExtras =
+ mBackupManagerMonitorEventSender.putMonitoringExtra(
+ null,
+ BackupManagerMonitor.EXTRA_LOG_RESTORE_VERSION,
+ metaInfo.versionCode);
+ monitoringExtras =
+ mBackupManagerMonitorEventSender.putMonitoringExtra(
+ monitoringExtras,
+ BackupManagerMonitor.EXTRA_LOG_RESTORE_ANYWAY,
+ true);
monitoringExtras = addRestoreOperationTypeToEvent(monitoringExtras);
mBackupManagerMonitorEventSender.monitorEvent(
BackupManagerMonitor.LOG_EVENT_ID_RESTORE_VERSION_HIGHER,
@@ -674,10 +692,15 @@
}
if (MORE_DEBUG) {
- Slog.v(TAG, "Package " + pkgName
- + " restore version [" + metaInfo.versionCode
- + "] is compatible with installed version ["
- + mCurrentPackage.getLongVersionCode() + "]");
+ Slog.v(
+ TAG,
+ "Package "
+ + pkgName
+ + " restore version ["
+ + metaInfo.versionCode
+ + "] is compatible with installed version ["
+ + mCurrentPackage.getLongVersionCode()
+ + "]");
}
// Reset per-package preconditions and fire the appropriate next state
@@ -690,19 +713,17 @@
} else {
// Unknown restore type; ignore this package and move on
Slog.e(TAG, "Unrecognized restore type " + type);
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);;
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
BackupManagerMonitor.LOG_EVENT_ID_UNKNOWN_RESTORE_TYPE,
mCurrentPackage,
BackupManagerMonitor.LOG_EVENT_CATEGORY_BACKUP_MANAGER_POLICY,
monitoringExtras);
nextState = UnifiedRestoreState.RUNNING_QUEUE;
- return;
}
} catch (Exception e) {
- Slog.e(TAG, "Can't get next restore target from transport; halting: "
- + e.getMessage());
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);;
+ Slog.e(TAG, "Can't get next restore target from transport; halting: " + e.getMessage());
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
BackupManagerMonitor.LOG_EVENT_ID_NO_NEXT_RESTORE_TARGET,
mCurrentPackage,
@@ -710,7 +731,6 @@
monitoringExtras);
EventLog.writeEvent(EventLogTags.RESTORE_TRANSPORT_FAILURE);
nextState = UnifiedRestoreState.FINAL;
- return;
} finally {
executeNextState(nextState);
}
@@ -725,21 +745,25 @@
// Validate some semantic requirements that apply in this way
// only to the key/value restore API flow
mBackupManagerMonitorEventSender.monitorEvent(
- BackupManagerMonitor.LOG_EVENT_ID_KV_RESTORE, mCurrentPackage,
+ BackupManagerMonitor.LOG_EVENT_ID_KV_RESTORE,
+ mCurrentPackage,
BackupManagerMonitor.LOG_EVENT_CATEGORY_BACKUP_MANAGER_POLICY,
- /*monitoringExtras*/ addRestoreOperationTypeToEvent(/*extras*/null));
+ /* extras= */ addRestoreOperationTypeToEvent(/* extras= */ null));
if (mCurrentPackage.applicationInfo.backupAgentName == null
|| "".equals(mCurrentPackage.applicationInfo.backupAgentName)) {
if (MORE_DEBUG) {
- Slog.i(TAG, "Data exists for package " + packageName
- + " but app has no agent; skipping");
+ Slog.i(
+ TAG,
+ "Data exists for package "
+ + packageName
+ + " but app has no agent; skipping");
}
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
BackupManagerMonitor.LOG_EVENT_ID_APP_HAS_NO_AGENT, mCurrentPackage,
BackupManagerMonitor.LOG_EVENT_CATEGORY_AGENT, monitoringExtras);
- EventLog.writeEvent(EventLogTags.RESTORE_AGENT_FAILURE, packageName,
- "Package has no agent");
+ EventLog.writeEvent(
+ EventLogTags.RESTORE_AGENT_FAILURE, packageName, "Package has no agent");
executeNextState(UnifiedRestoreState.RUNNING_QUEUE);
return;
}
@@ -748,31 +772,34 @@
PackageManagerInternal pmi = LocalServices.getService(PackageManagerInternal.class);
if (!BackupUtils.signaturesMatch(metaInfo.sigHashes, mCurrentPackage, pmi)) {
Slog.w(TAG, "Signature mismatch restoring " + packageName);
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
- BackupManagerMonitor.LOG_EVENT_ID_SIGNATURE_MISMATCH, mCurrentPackage,
+ BackupManagerMonitor.LOG_EVENT_ID_SIGNATURE_MISMATCH,
+ mCurrentPackage,
BackupManagerMonitor.LOG_EVENT_CATEGORY_BACKUP_MANAGER_POLICY,
monitoringExtras);
- EventLog.writeEvent(EventLogTags.RESTORE_AGENT_FAILURE, packageName,
- "Signature mismatch");
+ EventLog.writeEvent(
+ EventLogTags.RESTORE_AGENT_FAILURE, packageName, "Signature mismatch");
executeNextState(UnifiedRestoreState.RUNNING_QUEUE);
return;
}
// Good to go! Set up and bind the agent...
- mAgent = backupManagerService.bindToAgentSynchronous(
- mCurrentPackage.applicationInfo,
- ApplicationThreadConstants.BACKUP_MODE_RESTORE,
- mBackupEligibilityRules.getBackupDestination());
+ mAgent =
+ backupManagerService.bindToAgentSynchronous(
+ mCurrentPackage.applicationInfo,
+ ApplicationThreadConstants.BACKUP_MODE_RESTORE,
+ mBackupEligibilityRules.getBackupDestination());
if (mAgent == null) {
Slog.w(TAG, "Can't find backup agent for " + packageName);
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
- BackupManagerMonitor.LOG_EVENT_ID_CANT_FIND_AGENT, mCurrentPackage,
+ BackupManagerMonitor.LOG_EVENT_ID_CANT_FIND_AGENT,
+ mCurrentPackage,
BackupManagerMonitor.LOG_EVENT_CATEGORY_BACKUP_MANAGER_POLICY,
monitoringExtras);
- EventLog.writeEvent(EventLogTags.RESTORE_AGENT_FAILURE, packageName,
- "Restore agent missing");
+ EventLog.writeEvent(
+ EventLogTags.RESTORE_AGENT_FAILURE, packageName, "Restore agent missing");
executeNextState(UnifiedRestoreState.RUNNING_QUEUE);
return;
}
@@ -786,9 +813,10 @@
++mCount;
} catch (Exception e) {
Slog.e(TAG, "Error when attempting restore: " + e.toString());
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
- BackupManagerMonitor.LOG_EVENT_ID_KV_AGENT_ERROR, mCurrentPackage,
+ BackupManagerMonitor.LOG_EVENT_ID_KV_AGENT_ERROR,
+ mCurrentPackage,
BackupManagerMonitor.LOG_EVENT_CATEGORY_AGENT,
monitoringExtras);
keyValueAgentErrorCleanup(false);
@@ -820,16 +848,18 @@
"PerformUnifiedRestoreTask.initiateOneRestore()");
// Run the transport's restore pass
- stage = ParcelFileDescriptor.open(downloadFile,
- ParcelFileDescriptor.MODE_READ_WRITE |
- ParcelFileDescriptor.MODE_CREATE |
- ParcelFileDescriptor.MODE_TRUNCATE);
+ stage =
+ ParcelFileDescriptor.open(
+ downloadFile,
+ ParcelFileDescriptor.MODE_READ_WRITE
+ | ParcelFileDescriptor.MODE_CREATE
+ | ParcelFileDescriptor.MODE_TRUNCATE);
if (transport.getRestoreData(stage) != BackupTransport.TRANSPORT_OK) {
// Transport-level failure. This failure could be specific to package currently in
// restore.
Slog.e(TAG, "Error getting restore data for " + packageName);
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
BackupManagerMonitor.LOG_EVENT_ID_TRANSPORT_ERROR_KV_RESTORE,
mCurrentPackage,
@@ -840,7 +870,7 @@
downloadFile.delete();
UnifiedRestoreState nextState =
BackupAndRestoreFeatureFlags
- .getUnifiedRestoreContinueAfterTransportFailureInKvRestore()
+ .getUnifiedRestoreContinueAfterTransportFailureInKvRestore()
? UnifiedRestoreState.RUNNING_QUEUE
: UnifiedRestoreState.FINAL;
executeNextState(nextState);
@@ -852,13 +882,16 @@
// if appropriate
if (staging) {
stage.close();
- stage = ParcelFileDescriptor.open(downloadFile,
- ParcelFileDescriptor.MODE_READ_ONLY);
+ stage =
+ ParcelFileDescriptor.open(
+ downloadFile, ParcelFileDescriptor.MODE_READ_ONLY);
- mBackupData = ParcelFileDescriptor.open(mBackupDataName,
- ParcelFileDescriptor.MODE_READ_WRITE |
- ParcelFileDescriptor.MODE_CREATE |
- ParcelFileDescriptor.MODE_TRUNCATE);
+ mBackupData =
+ ParcelFileDescriptor.open(
+ mBackupDataName,
+ ParcelFileDescriptor.MODE_READ_WRITE
+ | ParcelFileDescriptor.MODE_CREATE
+ | ParcelFileDescriptor.MODE_TRUNCATE);
BackupDataInput in = new BackupDataInput(stage.getFileDescriptor());
BackupDataOutput out = new BackupDataOutput(mBackupData.getFileDescriptor());
@@ -870,34 +903,40 @@
// Okay, we have the data. Now have the agent do the restore.
stage.close();
- mBackupData = ParcelFileDescriptor.open(mBackupDataName,
- ParcelFileDescriptor.MODE_READ_ONLY);
+ mBackupData =
+ ParcelFileDescriptor.open(mBackupDataName, ParcelFileDescriptor.MODE_READ_ONLY);
- mNewState = ParcelFileDescriptor.open(mNewStateName,
- ParcelFileDescriptor.MODE_READ_WRITE |
- ParcelFileDescriptor.MODE_CREATE |
- ParcelFileDescriptor.MODE_TRUNCATE);
+ mNewState =
+ ParcelFileDescriptor.open(
+ mNewStateName,
+ ParcelFileDescriptor.MODE_READ_WRITE
+ | ParcelFileDescriptor.MODE_CREATE
+ | ParcelFileDescriptor.MODE_TRUNCATE);
// Kick off the restore, checking for hung agents. The timeout or
// the operationComplete() callback will schedule the next step,
// so we do not do that here.
- long restoreAgentTimeoutMillis = mAgentTimeoutParameters.getRestoreAgentTimeoutMillis(
- app.applicationInfo.uid);
+ long restoreAgentTimeoutMillis =
+ mAgentTimeoutParameters.getRestoreAgentTimeoutMillis(app.applicationInfo.uid);
backupManagerService.prepareOperationTimeout(
mEphemeralOpToken, restoreAgentTimeoutMillis, this, OpType.RESTORE_WAIT);
startedAgentRestore = true;
- mAgent.doRestoreWithExcludedKeys(mBackupData, appVersionCode, mNewState,
- mEphemeralOpToken, backupManagerService.getBackupManagerBinder(),
+ mAgent.doRestoreWithExcludedKeys(
+ mBackupData,
+ appVersionCode,
+ mNewState,
+ mEphemeralOpToken,
+ backupManagerService.getBackupManagerBinder(),
new ArrayList<>(getExcludedKeysForPackage(packageName)));
} catch (Exception e) {
Slog.e(TAG, "Unable to call app for restore: " + packageName, e);
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
- BackupManagerMonitor.LOG_EVENT_ID_KV_AGENT_ERROR, mCurrentPackage,
+ BackupManagerMonitor.LOG_EVENT_ID_KV_AGENT_ERROR,
+ mCurrentPackage,
BackupManagerMonitor.LOG_EVENT_CATEGORY_AGENT,
monitoringExtras);
- EventLog.writeEvent(EventLogTags.RESTORE_AGENT_FAILURE,
- packageName, e.toString());
+ EventLog.writeEvent(EventLogTags.RESTORE_AGENT_FAILURE, packageName, e.toString());
// Clears any pending timeout messages as well.
keyValueAgentErrorCleanup(startedAgentRestore);
@@ -915,8 +954,8 @@
// 2. Widget metadata needs to be separated from the rest to be handled separately
// But 'android' package doesn't contain widget metadata so we want to skip staging for it
// when there are no keys to be excluded either.
- return !packageName.equals(PLATFORM_PACKAGE_NAME) ||
- !getExcludedKeysForPackage(PLATFORM_PACKAGE_NAME).isEmpty();
+ return !packageName.equals(PLATFORM_PACKAGE_NAME)
+ || !getExcludedKeysForPackage(PLATFORM_PACKAGE_NAME).isEmpty();
}
@VisibleForTesting
@@ -970,14 +1009,16 @@
// When finished, StreamFeederThread executes next state as appropriate on the
// backup looper, and the overall unified restore task resumes
mBackupManagerMonitorEventSender.monitorEvent(
- BackupManagerMonitor.LOG_EVENT_ID_FULL_RESTORE, mCurrentPackage,
+ BackupManagerMonitor.LOG_EVENT_ID_FULL_RESTORE,
+ mCurrentPackage,
BackupManagerMonitor.LOG_EVENT_CATEGORY_BACKUP_MANAGER_POLICY,
- /*monitoringExtras*/ addRestoreOperationTypeToEvent(/*extras*/null));
+ /* extras= */ addRestoreOperationTypeToEvent(/* extras= */ null));
try {
StreamFeederThread feeder = new StreamFeederThread();
if (MORE_DEBUG) {
- Slog.i(TAG, "Spinning threads for stream restore of "
- + mCurrentPackage.packageName);
+ Slog.i(
+ TAG,
+ "Spinning threads for stream restore of " + mCurrentPackage.packageName);
}
new Thread(feeder, "unified-stream-feeder").start();
@@ -988,9 +1029,10 @@
// current target. We haven't asked the transport for data yet, though,
// so we can do that simply by going back to running the restore queue.
Slog.e(TAG, "Unable to construct pipes for stream restore!");
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
- BackupManagerMonitor.LOG_EVENT_ID_NO_FEEDER_THREAD, mCurrentPackage,
+ BackupManagerMonitor.LOG_EVENT_ID_NO_FEEDER_THREAD,
+ mCurrentPackage,
BackupManagerMonitor.LOG_EVENT_CATEGORY_BACKUP_MANAGER_POLICY,
monitoringExtras);
executeNextState(UnifiedRestoreState.RUNNING_QUEUE);
@@ -1005,24 +1047,24 @@
try {
long restoreAgentFinishedTimeoutMillis =
mAgentTimeoutParameters.getRestoreAgentFinishedTimeoutMillis();
- backupManagerService
- .prepareOperationTimeout(mEphemeralOpToken,
- restoreAgentFinishedTimeoutMillis, this,
- OpType.RESTORE_WAIT);
- mAgent.doRestoreFinished(mEphemeralOpToken,
- backupManagerService.getBackupManagerBinder());
+ backupManagerService.prepareOperationTimeout(
+ mEphemeralOpToken,
+ restoreAgentFinishedTimeoutMillis,
+ this,
+ OpType.RESTORE_WAIT);
+ mAgent.doRestoreFinished(
+ mEphemeralOpToken, backupManagerService.getBackupManagerBinder());
// If we get this far, the callback or timeout will schedule the
// next restore state, so we're done
} catch (Exception e) {
final String packageName = mCurrentPackage.packageName;
Slog.e(TAG, "Unable to finalize restore of " + packageName);
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
BackupManagerMonitor.LOG_EVENT_ID_AGENT_FAILURE, mCurrentPackage,
BackupManagerMonitor.LOG_EVENT_CATEGORY_AGENT, monitoringExtras);
- EventLog.writeEvent(EventLogTags.RESTORE_AGENT_FAILURE,
- packageName, e.toString());
+ EventLog.writeEvent(EventLogTags.RESTORE_AGENT_FAILURE, packageName, e.toString());
keyValueAgentErrorCleanup(true);
executeNextState(UnifiedRestoreState.RUNNING_QUEUE);
}
@@ -1054,13 +1096,20 @@
UnifiedRestoreState nextState = UnifiedRestoreState.RUNNING_QUEUE;
int status = BackupTransport.TRANSPORT_OK;
- EventLog.writeEvent(EventLogTags.FULL_RESTORE_PACKAGE,
- mCurrentPackage.packageName);
+ EventLog.writeEvent(EventLogTags.FULL_RESTORE_PACKAGE, mCurrentPackage.packageName);
- mEngine = new FullRestoreEngine(backupManagerService, mOperationStorage,
- this, null, mBackupManagerMonitorEventSender.getMonitor(),
- mCurrentPackage, false, mEphemeralOpToken, false,
- mBackupEligibilityRules);
+ mEngine =
+ new FullRestoreEngine(
+ backupManagerService,
+ mOperationStorage,
+ /* monitorTask= */ this,
+ /* observer= */ null,
+ mBackupManagerMonitorEventSender.getMonitor(),
+ mCurrentPackage,
+ /* allowApks= */ false,
+ mEphemeralOpToken,
+ /* isAdbRestore= */ false,
+ mBackupEligibilityRules);
mEngineThread = new FullRestoreEngineThread(mEngine, mEnginePipes[0]);
ParcelFileDescriptor eWriteEnd = mEnginePipes[1];
@@ -1077,8 +1126,8 @@
String callerLogString = "PerformUnifiedRestoreTask$StreamFeederThread.run()";
try {
- BackupTransportClient transport = mTransportConnection.connectOrThrow(
- callerLogString);
+ BackupTransportClient transport =
+ mTransportConnection.connectOrThrow(callerLogString);
while (status == BackupTransport.TRANSPORT_OK) {
// have the transport write some of the restoring data to us
int result = transport.getNextFullRestoreDataChunk(tWriteEnd);
@@ -1104,17 +1153,24 @@
} else if (result == BackupTransport.NO_MORE_DATA) {
// Clean finish. Wind up and we're done!
if (MORE_DEBUG) {
- Slog.i(TAG, "Got clean full-restore EOF for "
- + mCurrentPackage.packageName);
+ Slog.i(
+ TAG,
+ "Got clean full-restore EOF for "
+ + mCurrentPackage.packageName);
}
status = BackupTransport.TRANSPORT_OK;
break;
} else {
// Transport reported some sort of failure; the fall-through
// handling will deal properly with that.
- Slog.e(TAG, "Error " + result + " streaming restore for "
- + mCurrentPackage.packageName);
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ Slog.e(
+ TAG,
+ "Error "
+ + result
+ + " streaming restore for "
+ + mCurrentPackage.packageName);
+ Bundle monitoringExtras =
+ addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
BackupManagerMonitor.LOG_EVENT_ID_TRANSPORT_ERROR_FULL_RESTORE,
mCurrentPackage,
@@ -1132,21 +1188,23 @@
// but potentially recoverable; abandon this package's restore but
// carry on with the next restore target.
Slog.e(TAG, "Unable to route data for restore");
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
BackupManagerMonitor.LOG_EVENT_ID_FULL_AGENT_ERROR,
mCurrentPackage,
BackupManagerMonitor.LOG_EVENT_CATEGORY_AGENT,
monitoringExtras);
- EventLog.writeEvent(EventLogTags.RESTORE_AGENT_FAILURE,
- mCurrentPackage.packageName, "I/O error on pipes");
+ EventLog.writeEvent(
+ EventLogTags.RESTORE_AGENT_FAILURE,
+ mCurrentPackage.packageName,
+ "I/O error on pipes");
status = BackupTransport.AGENT_ERROR;
} catch (Exception e) {
// The transport threw; terminate the whole operation. Closing
// the sockets will wake up the engine and it will then tidy up the
// remote end.
Slog.e(TAG, "Transport failed during restore: " + e.getMessage());
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
BackupManagerMonitor.LOG_EVENT_ID_TRANSPORT_ERROR_FULL_RESTORE,
mCurrentPackage,
@@ -1218,10 +1276,14 @@
// BackupRestoreTask interface, specifically for timeout handling
@Override
- public void execute() { /* intentionally empty */ }
+ public void execute() {
+ // intentionally empty
+ }
@Override
- public void operationComplete(long result) { /* intentionally empty */ }
+ public void operationComplete(long result) {
+ // intentionally empty
+ }
// The app has timed out handling a restoring file
@Override
@@ -1230,10 +1292,11 @@
if (DEBUG) {
Slog.w(TAG, "Full-data restore target timed out; shutting down");
}
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
BackupManagerMonitor.LOG_EVENT_ID_FULL_RESTORE_TIMEOUT,
- mCurrentPackage, BackupManagerMonitor.LOG_EVENT_CATEGORY_AGENT,
+ mCurrentPackage,
+ BackupManagerMonitor.LOG_EVENT_CATEGORY_AGENT,
monitoringExtras);
mEngineThread.handleTimeout();
@@ -1252,8 +1315,7 @@
String callerLogString = "PerformUnifiedRestoreTask.finalizeRestore()";
try {
- BackupTransportClient transport =
- mTransportConnection.connectOrThrow(callerLogString);
+ BackupTransportClient transport = mTransportConnection.connectOrThrow(callerLogString);
transport.finishRestore();
} catch (Exception e) {
Slog.e(TAG, "Error finishing restore", e);
@@ -1278,17 +1340,21 @@
Slog.v(TAG, "finishing PM token " + mPmToken);
}
try {
- backupManagerService.getPackageManagerBinder().finishPackageInstall(mPmToken,
- mDidLaunch);
- } catch (RemoteException e) { /* can't happen */ }
+ backupManagerService
+ .getPackageManagerBinder()
+ .finishPackageInstall(mPmToken, mDidLaunch);
+ } catch (RemoteException e) {
+ // can't happen
+ }
} else {
// We were invoked via an active restore session, not by the Package
// Manager, so start up the session timeout again.
long restoreAgentTimeoutMillis =
mAgentTimeoutParameters.getRestoreSessionTimeoutMillis();
- backupManagerService.getBackupHandler().sendEmptyMessageDelayed(
- MSG_RESTORE_SESSION_TIMEOUT,
- restoreAgentTimeoutMillis);
+ backupManagerService
+ .getBackupHandler()
+ .sendEmptyMessageDelayed(
+ MSG_RESTORE_SESSION_TIMEOUT, restoreAgentTimeoutMillis);
}
if (mIsSystemRestore) {
@@ -1312,9 +1378,12 @@
Slog.d(TAG, "Starting next pending restore.");
}
PerformUnifiedRestoreTask task = backupManagerService.getPendingRestores().remove();
- backupManagerService.getBackupHandler().sendMessage(
- backupManagerService.getBackupHandler().obtainMessage(
- MSG_BACKUP_RESTORE_STEP, task));
+ backupManagerService
+ .getBackupHandler()
+ .sendMessage(
+ backupManagerService
+ .getBackupHandler()
+ .obtainMessage(MSG_BACKUP_RESTORE_STEP, task));
} else {
backupManagerService.setRestoreInProgress(false);
@@ -1325,7 +1394,7 @@
}
Slog.i(TAG, "Restore complete.");
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
BackupManagerMonitor.LOG_EVENT_ID_RESTORE_COMPLETE,
null,
@@ -1381,14 +1450,15 @@
// migration to the newly-restored device's dataset, we will change
// the following from a discard of the newly-written state to the
// "correct" operation of renaming into the canonical state blob.
- mNewStateName.delete(); // TODO: remove; see above comment
+ mNewStateName.delete(); // TODO: remove; see above comment
// If this wasn't the PM pseudopackage, tear down the agent side
if (mCurrentPackage.applicationInfo != null) {
// unbind and tidy up even on timeout or failure
try {
- backupManagerService.getActivityManager().unbindBackupAgent(
- mCurrentPackage.applicationInfo);
+ backupManagerService
+ .getActivityManager()
+ .unbindBackupAgent(mCurrentPackage.applicationInfo);
// The agent was probably running with a stub Application object,
// which isn't a valid run mode for the main app logic. Shut
@@ -1407,17 +1477,22 @@
final boolean killAfterRestore =
!UserHandle.isCore(mCurrentPackage.applicationInfo.uid)
&& ((mRestoreDescription.getDataType()
- == RestoreDescription.TYPE_FULL_STREAM)
- || ((appFlags & ApplicationInfo.FLAG_KILL_AFTER_RESTORE) != 0));
+ == RestoreDescription.TYPE_FULL_STREAM)
+ || ((appFlags & ApplicationInfo.FLAG_KILL_AFTER_RESTORE)
+ != 0));
if (mTargetPackage == null && killAfterRestore) {
if (DEBUG) {
- Slog.d(TAG, "Restore complete, killing host process of "
- + mCurrentPackage.applicationInfo.processName);
+ Slog.d(
+ TAG,
+ "Restore complete, killing host process of "
+ + mCurrentPackage.applicationInfo.processName);
}
- backupManagerService.getActivityManager().killApplicationProcess(
- mCurrentPackage.applicationInfo.processName,
- mCurrentPackage.applicationInfo.uid);
+ backupManagerService
+ .getActivityManager()
+ .killApplicationProcess(
+ mCurrentPackage.applicationInfo.processName,
+ mCurrentPackage.applicationInfo.uid);
}
} catch (RemoteException e) {
// can't happen; we run in the same process as the activity manager
@@ -1434,9 +1509,12 @@
mOperationStorage.removeOperation(mEphemeralOpToken);
if (MORE_DEBUG) {
- Slog.i(TAG, "operationComplete() during restore: target="
- + mCurrentPackage.packageName
- + " state=" + mState);
+ Slog.i(
+ TAG,
+ "operationComplete() during restore: target="
+ + mCurrentPackage.packageName
+ + " state="
+ + mState);
}
final UnifiedRestoreState nextState;
@@ -1449,30 +1527,31 @@
break;
case RESTORE_KEYVALUE:
- case RESTORE_FULL: {
+ case RESTORE_FULL:
// Okay, we've just heard back from the agent that it's done with
// the restore itself. We now have to send the same agent its
// doRestoreFinished() callback, so roll into that state.
nextState = UnifiedRestoreState.RESTORE_FINISHED;
break;
- }
- case RESTORE_FINISHED: {
+ case RESTORE_FINISHED:
// Okay, we're done with this package. Tidy up and go on to the next
// app in the queue.
int size = (int) mBackupDataName.length();
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
- BackupManagerMonitor.LOG_EVENT_ID_PACKAGE_RESTORE_FINISHED, mCurrentPackage,
+ BackupManagerMonitor.LOG_EVENT_ID_PACKAGE_RESTORE_FINISHED,
+ mCurrentPackage,
BackupManagerMonitor.LOG_EVENT_CATEGORY_BACKUP_MANAGER_POLICY,
monitoringExtras);
- EventLog.writeEvent(EventLogTags.RESTORE_PACKAGE,
- mCurrentPackage.packageName, size);
+ EventLog.writeEvent(
+ EventLogTags.RESTORE_PACKAGE, mCurrentPackage.packageName, size);
- // Ask the agent for logs after doRestoreFinished() has completed executing to allow
+ // Ask the agent for logs after doRestoreFinished() has completed executing to
+ // allow
// it to finalize its logs.
- mBackupManagerMonitorEventSender.monitorAgentLoggingResults(mCurrentPackage,
- mAgent);
+ mBackupManagerMonitorEventSender.monitorAgentLoggingResults(
+ mCurrentPackage, mAgent);
// Just go back to running the restore queue
keyValueAgentCleanup();
@@ -1481,22 +1560,20 @@
// incorporate it into current bookeeping and then pass that along to
// the app as part of the restore-time work.
if (mWidgetData != null) {
- backupManagerService.restoreWidgetData(mCurrentPackage.packageName,
- mWidgetData);
+ backupManagerService.restoreWidgetData(
+ mCurrentPackage.packageName, mWidgetData);
}
nextState = UnifiedRestoreState.RUNNING_QUEUE;
break;
- }
- default: {
+ default:
// Some kind of horrible semantic error; we're in an unexpected state.
// Back off hard and wind up.
Slog.e(TAG, "Unexpected restore callback into state " + mState);
keyValueAgentErrorCleanup(true);
nextState = UnifiedRestoreState.FINAL;
break;
- }
}
executeNextState(nextState);
@@ -1507,12 +1584,14 @@
public void handleCancel(boolean cancelAll) {
mOperationStorage.removeOperation(mEphemeralOpToken);
Slog.e(TAG, "Timeout restoring application " + mCurrentPackage.packageName);
- Bundle monitoringExtras = addRestoreOperationTypeToEvent(/*extras*/null);
+ Bundle monitoringExtras = addRestoreOperationTypeToEvent(/* extras= */ null);
mBackupManagerMonitorEventSender.monitorEvent(
BackupManagerMonitor.LOG_EVENT_ID_KEY_VALUE_RESTORE_TIMEOUT,
- mCurrentPackage, BackupManagerMonitor.LOG_EVENT_CATEGORY_AGENT, monitoringExtras);
- EventLog.writeEvent(EventLogTags.RESTORE_AGENT_FAILURE,
- mCurrentPackage.packageName, "restore timeout");
+ mCurrentPackage,
+ BackupManagerMonitor.LOG_EVENT_CATEGORY_AGENT,
+ monitoringExtras);
+ EventLog.writeEvent(
+ EventLogTags.RESTORE_AGENT_FAILURE, mCurrentPackage.packageName, "restore timeout");
// Handle like an agent that threw on invocation: wipe it and go on to the next
keyValueAgentErrorCleanup(true);
executeNextState(UnifiedRestoreState.RUNNING_QUEUE);
@@ -1521,12 +1600,13 @@
@VisibleForTesting
void executeNextState(UnifiedRestoreState nextState) {
if (MORE_DEBUG) {
- Slog.i(TAG, " => executing next step on "
- + this + " nextState=" + nextState);
+ Slog.i(TAG, " => executing next step on " + this + " nextState=" + nextState);
}
mState = nextState;
- Message msg = backupManagerService.getBackupHandler().obtainMessage(
- MSG_BACKUP_RESTORE_STEP, this);
+ Message msg =
+ backupManagerService
+ .getBackupHandler()
+ .obtainMessage(MSG_BACKUP_RESTORE_STEP, this);
backupManagerService.getBackupHandler().sendMessage(msg);
}
@@ -1584,9 +1664,8 @@
}
}
- private Bundle addRestoreOperationTypeToEvent (@Nullable Bundle extra) {
+ private Bundle addRestoreOperationTypeToEvent(@Nullable Bundle extras) {
return mBackupManagerMonitorEventSender.putMonitoringExtra(
- extra,
- BackupManagerMonitor.EXTRA_LOG_OPERATION_TYPE, RESTORE);
+ extras, BackupManagerMonitor.EXTRA_LOG_OPERATION_TYPE, RESTORE);
}
}
diff --git a/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java b/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java
index f47482d..b500ff1 100644
--- a/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java
+++ b/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java
@@ -120,7 +120,6 @@
static final String[] sDeviceConfigAconfigScopes = new String[] {
"accessibility",
"android_core_networking",
- "angle",
"app_widgets",
"arc_next",
"avic",
@@ -144,6 +143,7 @@
"dck_framework",
"devoptions_settings",
"game",
+ "gpu",
"haptics",
"hardware_backed_security_mainline",
"input",
diff --git a/services/core/java/com/android/server/pm/PackageArchiver.java b/services/core/java/com/android/server/pm/PackageArchiver.java
index c6e8a64..fb311da 100644
--- a/services/core/java/com/android/server/pm/PackageArchiver.java
+++ b/services/core/java/com/android/server/pm/PackageArchiver.java
@@ -116,7 +116,8 @@
private static final String ARCHIVE_ICONS_DIR = "package_archiver";
- private static final String ACTION_UNARCHIVE_DIALOG = "android.intent.action.UNARCHIVE_DIALOG";
+ private static final String ACTION_UNARCHIVE_DIALOG =
+ "com.android.intent.action.UNARCHIVE_DIALOG";
private final Context mContext;
private final PackageManagerService mPm;
diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java
index bbaa691..e5794a1 100644
--- a/services/core/java/com/android/server/wm/ActivityStarter.java
+++ b/services/core/java/com/android/server/wm/ActivityStarter.java
@@ -1861,7 +1861,10 @@
+ "PendingIntent. However, only the creator of the PendingIntent allows BAL, "
+ "while the sender does not allow BAL. realCallingPackage: "
+ realCallingPackage + "; callingPackage: " + mRequest.callingPackage
- + "; mTargetRootTask:" + mTargetRootTask);
+ + "; mTargetRootTask:" + mTargetRootTask + "; mIntent: " + mIntent
+ + "; mTargetRootTask.getTopNonFinishingActivity: "
+ + mTargetRootTask.getTopNonFinishingActivity()
+ + "; mTargetRootTask.getRootActivity: " + mTargetRootTask.getRootActivity());
}
}
diff --git a/services/tests/mockingservicestests/src/com/android/server/backup/restore/PerformUnifiedRestoreTaskTest.java b/services/tests/mockingservicestests/src/com/android/server/backup/restore/PerformUnifiedRestoreTaskTest.java
index c84797f..940469f 100644
--- a/services/tests/mockingservicestests/src/com/android/server/backup/restore/PerformUnifiedRestoreTaskTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/backup/restore/PerformUnifiedRestoreTaskTest.java
@@ -53,7 +53,6 @@
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
-import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import java.util.ArrayDeque;
@@ -75,14 +74,10 @@
private static final String SYSTEM_PACKAGE_NAME = "android";
private static final String NON_SYSTEM_PACKAGE_NAME = "package";
- @Mock
- private BackupDataInput mBackupDataInput;
- @Mock
- private BackupDataOutput mBackupDataOutput;
- @Mock
- private UserBackupManagerService mBackupManagerService;
- @Mock
- private TransportConnection mTransportConnection;
+ @Mock private BackupDataInput mBackupDataInput;
+ @Mock private BackupDataOutput mBackupDataOutput;
+ @Mock private UserBackupManagerService mBackupManagerService;
+ @Mock private TransportConnection mTransportConnection;
private Set<String> mExcludedkeys = new HashSet<>();
private Map<String, String> mBackupData = new HashMap<>();
@@ -93,8 +88,8 @@
private PerformUnifiedRestoreTask mRestoreTask;
@Rule
- public TestableDeviceConfig.TestableDeviceConfigRule
- mDeviceConfigRule = new TestableDeviceConfig.TestableDeviceConfigRule();
+ public TestableDeviceConfig.TestableDeviceConfigRule mDeviceConfigRule =
+ new TestableDeviceConfig.TestableDeviceConfigRule();
private Context mContext;
@@ -107,30 +102,21 @@
mContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
mBackupDataSource = new ArrayDeque<>(mBackupData.keySet());
- when(mBackupDataInput.readNextHeader()).then(new Answer<Boolean>() {
- @Override
- public Boolean answer(InvocationOnMock invocation) throws Throwable {
- return !mBackupDataSource.isEmpty();
- }
- });
- when(mBackupDataInput.getKey()).then(new Answer<String>() {
- @Override
- public String answer(InvocationOnMock invocation) throws Throwable {
- return mBackupDataSource.poll();
- }
- });
+ when(mBackupDataInput.readNextHeader())
+ .then((Answer<Boolean>) invocation -> !mBackupDataSource.isEmpty());
+ when(mBackupDataInput.getKey())
+ .then((Answer<String>) invocation -> mBackupDataSource.poll());
when(mBackupDataInput.getDataSize()).thenReturn(0);
mBackupDataDump = new HashSet<>();
ArgumentCaptor<String> keyCaptor = ArgumentCaptor.forClass(String.class);
- when(mBackupDataOutput.writeEntityHeader(keyCaptor.capture(), anyInt())).then(
- new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- mBackupDataDump.add(keyCaptor.getValue());
- return null;
- }
- });
+ when(mBackupDataOutput.writeEntityHeader(keyCaptor.capture(), anyInt()))
+ .then(
+ (Answer<Void>)
+ invocation -> {
+ mBackupDataDump.add(keyCaptor.getValue());
+ return null;
+ });
mRestoreTask = new PerformUnifiedRestoreTask(mBackupManagerService, mTransportConnection);
}
@@ -148,8 +134,8 @@
@Test
public void testFilterExcludedKeys() throws Exception {
- when(mBackupManagerService.getExcludedRestoreKeys(eq(PACKAGE_NAME))).thenReturn(
- mExcludedkeys);
+ when(mBackupManagerService.getExcludedRestoreKeys(eq(PACKAGE_NAME)))
+ .thenReturn(mExcludedkeys);
mRestoreTask.filterExcludedKeys(PACKAGE_NAME, mBackupDataInput, mBackupDataOutput);
@@ -162,46 +148,45 @@
@Test
public void testGetExcludedKeysForPackage_alwaysReturnsLatestKeys() {
Set<String> firstExcludedKeys = new HashSet<>(Collections.singletonList(EXCLUDED_KEY_1));
- when(mBackupManagerService.getExcludedRestoreKeys(eq(PACKAGE_NAME))).thenReturn(
- firstExcludedKeys);
+ when(mBackupManagerService.getExcludedRestoreKeys(eq(PACKAGE_NAME)))
+ .thenReturn(firstExcludedKeys);
assertEquals(firstExcludedKeys, mRestoreTask.getExcludedKeysForPackage(PACKAGE_NAME));
-
- Set<String> secondExcludedKeys = new HashSet<>(Arrays.asList(EXCLUDED_KEY_1,
- EXCLUDED_KEY_2));
- when(mBackupManagerService.getExcludedRestoreKeys(eq(PACKAGE_NAME))).thenReturn(
- secondExcludedKeys);
+ Set<String> secondExcludedKeys =
+ new HashSet<>(Arrays.asList(EXCLUDED_KEY_1, EXCLUDED_KEY_2));
+ when(mBackupManagerService.getExcludedRestoreKeys(eq(PACKAGE_NAME)))
+ .thenReturn(secondExcludedKeys);
assertEquals(secondExcludedKeys, mRestoreTask.getExcludedKeysForPackage(PACKAGE_NAME));
}
@Test
public void testStageBackupData_stageForNonSystemPackageWithKeysToExclude() {
- when(mBackupManagerService.getExcludedRestoreKeys(eq(NON_SYSTEM_PACKAGE_NAME))).thenReturn(
- mExcludedkeys);
+ when(mBackupManagerService.getExcludedRestoreKeys(eq(NON_SYSTEM_PACKAGE_NAME)))
+ .thenReturn(mExcludedkeys);
assertTrue(mRestoreTask.shouldStageBackupData(NON_SYSTEM_PACKAGE_NAME));
}
@Test
public void testStageBackupData_stageForNonSystemPackageWithNoKeysToExclude() {
- when(mBackupManagerService.getExcludedRestoreKeys(any())).thenReturn(
- Collections.emptySet());
+ when(mBackupManagerService.getExcludedRestoreKeys(any()))
+ .thenReturn(Collections.emptySet());
assertTrue(mRestoreTask.shouldStageBackupData(NON_SYSTEM_PACKAGE_NAME));
}
@Test
public void testStageBackupData_doNotStageForSystemPackageWithNoKeysToExclude() {
- when(mBackupManagerService.getExcludedRestoreKeys(any())).thenReturn(
- Collections.emptySet());
+ when(mBackupManagerService.getExcludedRestoreKeys(any()))
+ .thenReturn(Collections.emptySet());
assertFalse(mRestoreTask.shouldStageBackupData(SYSTEM_PACKAGE_NAME));
}
@Test
public void testStageBackupData_stageForSystemPackageWithKeysToExclude() {
- when(mBackupManagerService.getExcludedRestoreKeys(eq(SYSTEM_PACKAGE_NAME))).thenReturn(
- mExcludedkeys);
+ when(mBackupManagerService.getExcludedRestoreKeys(eq(SYSTEM_PACKAGE_NAME)))
+ .thenReturn(mExcludedkeys);
assertTrue(mRestoreTask.shouldStageBackupData(SYSTEM_PACKAGE_NAME));
}