Merge "Listen for individual subscription mobile data toggles" into sc-v2-dev
diff --git a/core/java/android/app/ActivityClient.java b/core/java/android/app/ActivityClient.java
index eb4a355..db7ab1a 100644
--- a/core/java/android/app/ActivityClient.java
+++ b/core/java/android/app/ActivityClient.java
@@ -20,7 +20,6 @@
import android.content.ComponentName;
import android.content.Intent;
import android.content.res.Configuration;
-import android.content.res.Resources;
import android.os.Bundle;
import android.os.IBinder;
import android.os.PersistableBundle;
@@ -499,28 +498,6 @@
}
}
- /**
- * Shows or hides a Camera app compat toggle for stretched issues with the requested state.
- *
- * @param token The token for the window that needs a control.
- * @param showControl Whether the control should be shown or hidden.
- * @param transformationApplied Whether the treatment is already applied.
- * @param callback The callback executed when the user clicks on a control.
- */
- void requestCompatCameraControl(Resources res, IBinder token, boolean showControl,
- boolean transformationApplied, ICompatCameraControlCallback callback) {
- if (!res.getBoolean(com.android.internal.R.bool
- .config_isCameraCompatControlForStretchedIssuesEnabled)) {
- return;
- }
- try {
- getActivityClientController().requestCompatCameraControl(
- token, showControl, transformationApplied, callback);
- } catch (RemoteException e) {
- e.rethrowFromSystemServer();
- }
- }
-
public static ActivityClient getInstance() {
return sInstance.get();
}
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 131bfd3..8af74ed 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -561,8 +561,8 @@
private Configuration mPendingOverrideConfig;
// Used for consolidating configs before sending on to Activity.
private Configuration tmpConfig = new Configuration();
- // Callback used for updating activity override config and camera compat control state.
- ViewRootImpl.ActivityConfigCallback activityConfigCallback;
+ // Callback used for updating activity override config.
+ ViewRootImpl.ActivityConfigCallback configCallback;
ActivityClientRecord nextIdle;
// Indicates whether this activity is currently the topmost resumed one in the system.
@@ -660,30 +660,13 @@
stopped = false;
hideForNow = false;
nextIdle = null;
- activityConfigCallback = new ViewRootImpl.ActivityConfigCallback() {
- @Override
- public void onConfigurationChanged(Configuration overrideConfig,
- int newDisplayId) {
- if (activity == null) {
- throw new IllegalStateException(
- "Received config update for non-existing activity");
- }
- activity.mMainThread.handleActivityConfigurationChanged(
- ActivityClientRecord.this, overrideConfig, newDisplayId);
+ configCallback = (Configuration overrideConfig, int newDisplayId) -> {
+ if (activity == null) {
+ throw new IllegalStateException(
+ "Received config update for non-existing activity");
}
-
- @Override
- public void requestCompatCameraControl(boolean showControl,
- boolean transformationApplied, ICompatCameraControlCallback callback) {
- if (activity == null) {
- throw new IllegalStateException(
- "Received camera compat control update for non-existing activity");
- }
- ActivityClient.getInstance().requestCompatCameraControl(
- activity.getResources(), token, showControl, transformationApplied,
- callback);
- }
-
+ activity.mMainThread.handleActivityConfigurationChanged(this, overrideConfig,
+ newDisplayId);
};
}
@@ -3674,7 +3657,7 @@
activity.attach(appContext, this, getInstrumentation(), r.token,
r.ident, app, r.intent, r.activityInfo, title, r.parent,
r.embeddedID, r.lastNonConfigurationInstances, config,
- r.referrer, r.voiceInteractor, window, r.activityConfigCallback,
+ r.referrer, r.voiceInteractor, window, r.configCallback,
r.assistToken, r.shareableActivityToken);
if (customIntent != null) {
@@ -5522,8 +5505,8 @@
} else {
final ViewRootImpl viewRoot = v.getViewRootImpl();
if (viewRoot != null) {
- // Clear callbacks to avoid the destroyed activity from receiving
- // configuration or camera compat changes that are no longer effective.
+ // Clear the callback to avoid the destroyed activity from receiving
+ // configuration changes that are no longer effective.
viewRoot.setActivityConfigCallback(null);
}
wm.removeViewImmediate(v);
diff --git a/core/java/android/app/IActivityClientController.aidl b/core/java/android/app/IActivityClientController.aidl
index 83c57c5..aba6eb9 100644
--- a/core/java/android/app/IActivityClientController.aidl
+++ b/core/java/android/app/IActivityClientController.aidl
@@ -17,7 +17,6 @@
package android.app;
import android.app.ActivityManager;
-import android.app.ICompatCameraControlCallback;
import android.app.IRequestFinishCallback;
import android.app.PictureInPictureParams;
import android.content.ComponentName;
@@ -144,15 +143,4 @@
/** Reports that the splash screen view has attached to activity. */
oneway void splashScreenAttached(in IBinder token);
-
- /**
- * Shows or hides a Camera app compat toggle for stretched issues with the requested state.
- *
- * @param token The token for the window that needs a control.
- * @param showControl Whether the control should be shown or hidden.
- * @param transformationApplied Whether the treatment is already applied.
- * @param callback The callback executed when the user clicks on a control.
- */
- oneway void requestCompatCameraControl(in IBinder token, boolean showControl,
- boolean transformationApplied, in ICompatCameraControlCallback callback);
}
diff --git a/core/java/android/app/ICompatCameraControlCallback.aidl b/core/java/android/app/ICompatCameraControlCallback.aidl
deleted file mode 100644
index 1a7f210..0000000
--- a/core/java/android/app/ICompatCameraControlCallback.aidl
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.app;
-
-/**
- * This callback allows ActivityRecord to ask the calling View to apply the treatment for stretched
- * issues affecting camera viewfinders when the user clicks on the camera compat control.
- *
- * {@hide}
- */
-oneway interface ICompatCameraControlCallback {
-
- void applyCameraCompatTreatment();
-
- void revertCameraCompatTreatment();
-}
diff --git a/core/java/android/app/Instrumentation.java b/core/java/android/app/Instrumentation.java
index 9f4107c..fd6fa57 100644
--- a/core/java/android/app/Instrumentation.java
+++ b/core/java/android/app/Instrumentation.java
@@ -1259,7 +1259,7 @@
info, title, parent, id,
(Activity.NonConfigurationInstances)lastNonConfigurationInstance,
new Configuration(), null /* referrer */, null /* voiceInteractor */,
- null /* window */, null /* activityCallback */, null /*assistToken*/,
+ null /* window */, null /* activityConfigCallback */, null /*assistToken*/,
null /*shareableActivityToken*/);
return activity;
}
diff --git a/core/java/android/app/TaskInfo.java b/core/java/android/app/TaskInfo.java
index cd885c1..ddde272 100644
--- a/core/java/android/app/TaskInfo.java
+++ b/core/java/android/app/TaskInfo.java
@@ -19,7 +19,6 @@
import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.window.DisplayAreaOrganizer.FEATURE_UNDEFINED;
-import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.TestApi;
@@ -40,8 +39,6 @@
import android.window.TaskSnapshot;
import android.window.WindowContainerToken;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Objects;
@@ -259,51 +256,6 @@
*/
public boolean isSleeping;
- /**
- * Camera compat control isn't shown because it's not requested by heuristics.
- * @hide
- */
- public static final int CAMERA_COMPAT_CONTROL_HIDDEN = 0;
-
- /**
- * Camera compat control is shown with the treatment suggested.
- * @hide
- */
- public static final int CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED = 1;
-
- /**
- * Camera compat control is shown to allow reverting the applied treatment.
- * @hide
- */
- public static final int CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED = 2;
-
- /**
- * Camera compat control is dismissed by user.
- * @hide
- */
- public static final int CAMERA_COMPAT_CONTROL_DISMISSED = 3;
-
- /**
- * Enum for the Camera app compat control states.
- * @hide
- */
- @Retention(RetentionPolicy.SOURCE)
- @IntDef(prefix = { "CAMERA_COMPAT_CONTROL_" }, value = {
- CAMERA_COMPAT_CONTROL_HIDDEN,
- CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED,
- CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED,
- CAMERA_COMPAT_CONTROL_DISMISSED,
- })
- public @interface CameraCompatControlState {};
-
- /**
- * State of the Camera app compat control which is used to correct stretched viewfinder
- * in apps that don't handle all possible configurations and changes between them correctly.
- * @hide
- */
- @CameraCompatControlState
- public int cameraCompatControlState = CAMERA_COMPAT_CONTROL_HIDDEN;
-
TaskInfo() {
// Do nothing
}
@@ -372,17 +324,6 @@
launchCookies.add(cookie);
}
- /** @hide */
- public boolean hasCameraCompatControl() {
- return cameraCompatControlState != CAMERA_COMPAT_CONTROL_HIDDEN
- && cameraCompatControlState != CAMERA_COMPAT_CONTROL_DISMISSED;
- }
-
- /** @hide */
- public boolean hasCompatUI() {
- return hasCameraCompatControl() || topActivityInSizeCompat;
- }
-
/**
* @return {@code true} if this task contains the launch cookie.
* @hide
@@ -435,20 +376,19 @@
* @return {@code true} if parameters that are important for size compat have changed.
* @hide
*/
- public boolean equalsForCompatUi(@Nullable TaskInfo that) {
+ public boolean equalsForSizeCompat(@Nullable TaskInfo that) {
if (that == null) {
return false;
}
return displayId == that.displayId
&& taskId == that.taskId
&& topActivityInSizeCompat == that.topActivityInSizeCompat
- && cameraCompatControlState == that.cameraCompatControlState
- // Bounds are important if top activity has compat controls.
- && (!hasCompatUI() || configuration.windowConfiguration.getBounds()
+ // Bounds are important if top activity is in size compat
+ && (!topActivityInSizeCompat || configuration.windowConfiguration.getBounds()
.equals(that.configuration.windowConfiguration.getBounds()))
- && (!hasCompatUI() || configuration.getLayoutDirection()
+ && (!topActivityInSizeCompat || configuration.getLayoutDirection()
== that.configuration.getLayoutDirection())
- && (!hasCompatUI() || isVisible == that.isVisible);
+ && (!topActivityInSizeCompat || isVisible == that.isVisible);
}
/**
@@ -488,7 +428,6 @@
topActivityInSizeCompat = source.readBoolean();
mTopActivityLocusId = source.readTypedObject(LocusId.CREATOR);
displayAreaFeatureId = source.readInt();
- cameraCompatControlState = source.readInt();
}
/**
@@ -529,7 +468,6 @@
dest.writeBoolean(topActivityInSizeCompat);
dest.writeTypedObject(mTopActivityLocusId, flags);
dest.writeInt(displayAreaFeatureId);
- dest.writeInt(cameraCompatControlState);
}
@Override
@@ -560,22 +498,6 @@
+ " topActivityInSizeCompat=" + topActivityInSizeCompat
+ " locusId=" + mTopActivityLocusId
+ " displayAreaFeatureId=" + displayAreaFeatureId
- + " cameraCompatControlState="
- + cameraCompatControlStateToString(cameraCompatControlState)
+ "}";
}
-
- /** @hide */
- public static String cameraCompatControlStateToString(
- @CameraCompatControlState int cameraCompatControlState) {
- switch (cameraCompatControlState) {
- case CAMERA_COMPAT_CONTROL_HIDDEN: return "hidden";
- case CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED: return "treatment-suggested";
- case CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED: return "treatment-applied";
- case CAMERA_COMPAT_CONTROL_DISMISSED: return "dismissed";
- default:
- throw new AssertionError(
- "Unexpected camera compat control state: " + cameraCompatControlState);
- }
- }
}
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 74b9731..f1eb783 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -89,7 +89,6 @@
import android.annotation.UiContext;
import android.app.ActivityManager;
import android.app.ActivityThread;
-import android.app.ICompatCameraControlCallback;
import android.app.ResourcesManager;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.ClipData;
@@ -330,7 +329,7 @@
private static final ArrayList<ConfigChangedCallback> sConfigCallbacks = new ArrayList<>();
/**
- * Callback for notifying activities.
+ * Callback for notifying activities about override configuration changes.
*/
public interface ActivityConfigCallback {
@@ -340,23 +339,11 @@
* @param newDisplayId New display id, {@link Display#INVALID_DISPLAY} if not changed.
*/
void onConfigurationChanged(Configuration overrideConfig, int newDisplayId);
-
- /**
- * Notify the corresponding activity about the request to show or hide a camera compat
- * control for stretched issues in the viewfinder.
- *
- * @param showControl Whether the control should be shown or hidden.
- * @param transformationApplied Whether the treatment is already applied.
- * @param callback The callback executed when the user clicks on a control.
- */
- void requestCompatCameraControl(boolean showControl, boolean transformationApplied,
- ICompatCameraControlCallback callback);
}
/**
- * Callback used to notify corresponding activity about camera compat control changes, override
- * configuration change and make sure that all resources are set correctly before updating the
- * ViewRootImpl's internal state.
+ * Callback used to notify corresponding activity about override configuration change and make
+ * sure that all resources are set correctly before updating the ViewRootImpl's internal state.
*/
private ActivityConfigCallback mActivityConfigCallback;
@@ -908,10 +895,7 @@
}
}
- /**
- * Add activity config callback to be notified about override config changes and camera
- * compat control state updates.
- */
+ /** Add activity config callback to be notified about override config changes. */
public void setActivityConfigCallback(ActivityConfigCallback callback) {
mActivityConfigCallback = callback;
}
@@ -10616,20 +10600,6 @@
}
/**
- * Shows or hides a Camera app compat toggle for stretched issues with the requested state
- * for the corresponding activity.
- *
- * @param showControl Whether the control should be shown or hidden.
- * @param transformationApplied Whether the treatment is already applied.
- * @param callback The callback executed when the user clicks on a control.
- */
- public void requestCompatCameraControl(boolean showControl, boolean transformationApplied,
- ICompatCameraControlCallback callback) {
- mActivityConfigCallback.requestCompatCameraControl(
- showControl, transformationApplied, callback);
- }
-
- /**
* Redirect the next draw of this ViewRoot (from the UI thread perspective)
* to the passed in consumer. This can be used to create P2P synchronization
* between ViewRoot's however it comes with many caveats.
diff --git a/core/java/android/window/ITaskOrganizerController.aidl b/core/java/android/window/ITaskOrganizerController.aidl
index 022d05d..a833600 100644
--- a/core/java/android/window/ITaskOrganizerController.aidl
+++ b/core/java/android/window/ITaskOrganizerController.aidl
@@ -66,7 +66,4 @@
* Restarts the top activity in the given task by killing its process if it is visible.
*/
void restartTaskTopActivityProcessIfVisible(in WindowContainerToken task);
-
- /** Updates a state of camera compat control for stretched issues in the viewfinder. */
- void updateCameraCompatControlState(in WindowContainerToken task, int state);
}
diff --git a/core/java/android/window/TaskOrganizer.java b/core/java/android/window/TaskOrganizer.java
index 3ec18db..27c7d315 100644
--- a/core/java/android/window/TaskOrganizer.java
+++ b/core/java/android/window/TaskOrganizer.java
@@ -24,7 +24,6 @@
import android.annotation.SuppressLint;
import android.annotation.TestApi;
import android.app.ActivityManager;
-import android.app.TaskInfo.CameraCompatControlState;
import android.os.IBinder;
import android.os.RemoteException;
import android.view.SurfaceControl;
@@ -239,20 +238,6 @@
}
/**
- * Updates a state of camera compat control for stretched issues in the viewfinder.
- * @hide
- */
- @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS)
- public void updateCameraCompatControlState(@NonNull WindowContainerToken task,
- @CameraCompatControlState int state) {
- try {
- mTaskOrganizerController.updateCameraCompatControlState(task, state);
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
- }
-
- /**
* Gets the executor to run callbacks on.
* @hide
*/
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 7bedcc6..d9007e5 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -2679,6 +2679,16 @@
<item>350</item>
</integer-array>
+ <!-- A vibration waveform for notifications that specify DEFAULT_VIBRATE.
+ This value is a float array with values grouped as
+ { targetAmplitude (within [0,1]), targetFrequency [-1,1], duration (in milliseconds) }
+ This is only applied on devices with vibration frequency control. If the device doesn't
+ support frequency control, then the vibration specified in
+ config_defaultNotificationVibePattern is used instead.
+ -->
+ <array name="config_defaultNotificationVibeWaveform">
+ </array>
+
<!-- Vibrator pattern to be used as the default for notifications
that do not specify vibration but vibrate anyway because the device
is in vibrate mode.
@@ -2690,6 +2700,16 @@
<item>100</item>
</integer-array>
+ <!-- A vibration waveform for notifications that do not specify vibration but vibrate anyway,
+ because the device is in vibrate mode. This value is a float array with values grouped as
+ { targetAmplitude (within [0,1]), targetFrequency [-1,1], duration (in milliseconds) }
+ This is only applied on devices with vibration frequency control. If the device doesn't
+ support frequency control, then the vibration specified in
+ config_notificationFallbackVibePattern is used instead.
+ -->
+ <array name="config_notificationFallbackVibeWaveform">
+ </array>
+
<!-- Flag indicating if the speed up audio on mt call code should be executed -->
<bool name="config_speed_up_audio_on_mt_calls">false</bool>
@@ -4938,10 +4958,6 @@
If given value is outside of this range, the option 1 (center) is assummed. -->
<integer name="config_letterboxDefaultPositionForReachability">1</integer>
- <!-- Whether a camera compat controller is enabled to allow the user to apply or revert
- treatment for stretched issues in camera viewfinder. -->
- <bool name="config_isCameraCompatControlForStretchedIssuesEnabled">false</bool>
-
<!-- If true, hide the display cutout with display area -->
<bool name="config_hideDisplayCutoutWithDisplayArea">false</bool>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 46b249e..f68c26d 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1917,7 +1917,9 @@
<java-symbol type="array" name="config_locationExtraPackageNames" />
<java-symbol type="array" name="config_testLocationProviders" />
<java-symbol type="array" name="config_defaultNotificationVibePattern" />
+ <java-symbol type="array" name="config_defaultNotificationVibeWaveform" />
<java-symbol type="array" name="config_notificationFallbackVibePattern" />
+ <java-symbol type="array" name="config_notificationFallbackVibeWaveform" />
<java-symbol type="bool" name="config_enableServerNotificationEffectsForAutomotive" />
<java-symbol type="bool" name="config_useAttentionLight" />
<java-symbol type="bool" name="config_adaptive_sleep_available" />
@@ -4273,7 +4275,6 @@
<java-symbol type="dimen" name="config_letterboxHorizontalPositionMultiplier" />
<java-symbol type="bool" name="config_letterboxIsReachabilityEnabled" />
<java-symbol type="integer" name="config_letterboxDefaultPositionForReachability" />
- <java-symbol type="bool" name="config_isCameraCompatControlForStretchedIssuesEnabled" />
<java-symbol type="bool" name="config_hideDisplayCutoutWithDisplayArea" />
diff --git a/data/etc/services.core.protolog.json b/data/etc/services.core.protolog.json
index 9584994..6bfbd8d 100644
--- a/data/etc/services.core.protolog.json
+++ b/data/etc/services.core.protolog.json
@@ -1201,12 +1201,6 @@
"group": "WM_ERROR",
"at": "com\/android\/server\/wm\/WindowManagerService.java"
},
- "-846931068": {
- "message": "Update camera compat control state to %s for taskId=%d",
- "level": "VERBOSE",
- "group": "WM_DEBUG_WINDOW_ORGANIZER",
- "at": "com\/android\/server\/wm\/TaskOrganizerController.java"
- },
"-846078709": {
"message": "Configuration doesn't matter in finishing %s",
"level": "VERBOSE",
diff --git a/libs/WindowManager/Shell/res/color/compat_background_ripple.xml b/libs/WindowManager/Shell/res/color/size_compat_background_ripple.xml
similarity index 100%
rename from libs/WindowManager/Shell/res/color/compat_background_ripple.xml
rename to libs/WindowManager/Shell/res/color/size_compat_background_ripple.xml
diff --git a/libs/WindowManager/Shell/res/drawable/camera_compat_dismiss_button.xml b/libs/WindowManager/Shell/res/drawable/camera_compat_dismiss_button.xml
deleted file mode 100644
index 1c8cb91..0000000
--- a/libs/WindowManager/Shell/res/drawable/camera_compat_dismiss_button.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<!--
- Copyright (C) 2019 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.
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="48dp"
- android:height="43dp"
- android:viewportWidth="48"
- android:viewportHeight="43">
- <group>
- <clip-path
- android:pathData="M48,43l-48,-0l-0,-43l48,-0z"/>
- <path
- android:pathData="M24,43C37.2548,43 48,32.2548 48,19L48,0L0,-0L0,19C0,32.2548 10.7452,43 24,43Z"
- android:fillColor="@color/compat_controls_background"
- android:strokeAlpha="0.8"
- android:fillAlpha="0.8"/>
- <path
- android:pathData="M31,12.41L29.59,11L24,16.59L18.41,11L17,12.41L22.59,18L17,23.59L18.41,25L24,19.41L29.59,25L31,23.59L25.41,18L31,12.41Z"
- android:fillColor="@color/compat_controls_text"/>
- </group>
-</vector>
diff --git a/libs/WindowManager/Shell/res/drawable/camera_compat_dismiss_ripple.xml b/libs/WindowManager/Shell/res/drawable/camera_compat_dismiss_ripple.xml
deleted file mode 100644
index c810139..0000000
--- a/libs/WindowManager/Shell/res/drawable/camera_compat_dismiss_ripple.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2021 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.
- -->
-<ripple xmlns:android="http://schemas.android.com/apk/res/android"
- android:color="@color/compat_background_ripple">
- <item android:drawable="@drawable/camera_compat_dismiss_button"/>
-</ripple>
\ No newline at end of file
diff --git a/libs/WindowManager/Shell/res/drawable/camera_compat_treatment_applied_button.xml b/libs/WindowManager/Shell/res/drawable/camera_compat_treatment_applied_button.xml
deleted file mode 100644
index c796b59..0000000
--- a/libs/WindowManager/Shell/res/drawable/camera_compat_treatment_applied_button.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<!--
- Copyright (C) 2019 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.
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="48dp"
- android:height="43dp"
- android:viewportWidth="48"
- android:viewportHeight="43">
- <path
- android:pathData="M24,0C10.7452,0 0,10.7452 0,24V43H48V24C48,10.7452 37.2548,0 24,0Z"
- android:fillColor="@color/compat_controls_background"
- android:strokeAlpha="0.8"
- android:fillAlpha="0.8"/>
- <path
- android:pathData="M32,17H28.83L27,15H21L19.17,17H16C14.9,17 14,17.9 14,19V31C14,32.1 14.9,33 16,33H32C33.1,33 34,32.1 34,31V19C34,17.9 33.1,17 32,17ZM32,31H16V19H32V31Z"
- android:fillColor="@color/compat_controls_text"/>
- <path
- android:pathData="M24.6618,22C23.0436,22 21.578,22.6187 20.4483,23.625L18.25,21.375V27H23.7458L21.5353,24.7375C22.3841,24.0125 23.4649,23.5625 24.6618,23.5625C26.8235,23.5625 28.6616,25.0062 29.3028,27L30.75,26.5125C29.9012,23.8938 27.5013,22 24.6618,22Z"
- android:fillColor="@color/compat_controls_text"/>
-</vector>
diff --git a/libs/WindowManager/Shell/res/drawable/camera_compat_treatment_applied_ripple.xml b/libs/WindowManager/Shell/res/drawable/camera_compat_treatment_applied_ripple.xml
deleted file mode 100644
index 3e9fe6d..0000000
--- a/libs/WindowManager/Shell/res/drawable/camera_compat_treatment_applied_ripple.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2021 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.
- -->
-<ripple xmlns:android="http://schemas.android.com/apk/res/android"
- android:color="@color/compat_background_ripple">
- <item android:drawable="@drawable/camera_compat_treatment_applied_button"/>
-</ripple>
diff --git a/libs/WindowManager/Shell/res/drawable/camera_compat_treatment_suggested_button.xml b/libs/WindowManager/Shell/res/drawable/camera_compat_treatment_suggested_button.xml
deleted file mode 100644
index af505d1..0000000
--- a/libs/WindowManager/Shell/res/drawable/camera_compat_treatment_suggested_button.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-<!--
- Copyright (C) 2019 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.
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="48dp"
- android:height="43dp"
- android:viewportWidth="48"
- android:viewportHeight="43">
- <path
- android:pathData="M24,0C10.7452,0 0,10.7452 0,24V43H48V24C48,10.7452 37.2548,0 24,0Z"
- android:fillColor="@color/compat_controls_background"
- android:strokeAlpha="0.8"
- android:fillAlpha="0.8"/>
- <path
- android:pathData="M32,17H28.83L27,15H21L19.17,17H16C14.9,17 14,17.9 14,19V31C14,32.1 14.9,33 16,33H32C33.1,33 34,32.1 34,31V19C34,17.9 33.1,17 32,17ZM32,31H16V19H32V31Z"
- android:fillColor="@color/compat_controls_text"/>
- <path
- android:pathData="M18,29L18,25.5L19.5,25.5L19.5,29L18,29Z"
- android:fillColor="@color/compat_controls_text"/>
- <path
- android:pathData="M30,29L30,25.5L28.5,25.5L28.5,29L30,29Z"
- android:fillColor="@color/compat_controls_text"/>
- <path
- android:pathData="M30,21L30,24.5L28.5,24.5L28.5,21L30,21Z"
- android:fillColor="@color/compat_controls_text"/>
- <path
- android:pathData="M18,21L18,24.5L19.5,24.5L19.5,21L18,21Z"
- android:fillColor="@color/compat_controls_text"/>
- <path
- android:pathData="M18,27.5L21.5,27.5L21.5,29L18,29L18,27.5Z"
- android:fillColor="@color/compat_controls_text"/>
- <path
- android:pathData="M30,27.5L26.5,27.5L26.5,29L30,29L30,27.5Z"
- android:fillColor="@color/compat_controls_text"/>
- <path
- android:pathData="M30,22.5L26.5,22.5L26.5,21L30,21L30,22.5Z"
- android:fillColor="@color/compat_controls_text"/>
- <path
- android:pathData="M18,22.5L21.5,22.5L21.5,21L18,21L18,22.5Z"
- android:fillColor="@color/compat_controls_text"/>
-</vector>
diff --git a/libs/WindowManager/Shell/res/drawable/camera_compat_treatment_suggested_ripple.xml b/libs/WindowManager/Shell/res/drawable/camera_compat_treatment_suggested_ripple.xml
deleted file mode 100644
index c0f1c89..0000000
--- a/libs/WindowManager/Shell/res/drawable/camera_compat_treatment_suggested_ripple.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2021 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.
- -->
-<ripple xmlns:android="http://schemas.android.com/apk/res/android"
- android:color="@color/compat_background_ripple">
- <item android:drawable="@drawable/camera_compat_treatment_suggested_button"/>
-</ripple>
diff --git a/libs/WindowManager/Shell/res/drawable/size_compat_restart_button.xml b/libs/WindowManager/Shell/res/drawable/size_compat_restart_button.xml
index e6ae282..ab74e43 100644
--- a/libs/WindowManager/Shell/res/drawable/size_compat_restart_button.xml
+++ b/libs/WindowManager/Shell/res/drawable/size_compat_restart_button.xml
@@ -21,9 +21,7 @@
android:viewportHeight="48">
<path
android:fillColor="@color/compat_controls_background"
- android:strokeAlpha="0.8"
- android:fillAlpha="0.8"
- android:pathData="M0,24 a24,24 0 1,0 48,0 a24,24 0 1,0 -48,0"/>
+ android:pathData="M0,24 a24,24 0 1,0 48,0 a24,24 0 1,0 -48,0" />
<group
android:translateX="12"
android:translateY="12">
diff --git a/libs/WindowManager/Shell/res/drawable/size_compat_restart_button_ripple.xml b/libs/WindowManager/Shell/res/drawable/size_compat_restart_button_ripple.xml
index 6551edf..95decff 100644
--- a/libs/WindowManager/Shell/res/drawable/size_compat_restart_button_ripple.xml
+++ b/libs/WindowManager/Shell/res/drawable/size_compat_restart_button_ripple.xml
@@ -15,6 +15,6 @@
~ limitations under the License.
-->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
- android:color="@color/compat_background_ripple">
+ android:color="@color/size_compat_background_ripple">
<item android:drawable="@drawable/size_compat_restart_button"/>
</ripple>
\ No newline at end of file
diff --git a/libs/WindowManager/Shell/res/layout/compat_mode_hint.xml b/libs/WindowManager/Shell/res/layout/compat_mode_hint.xml
index 44b2f45..bb48bf7 100644
--- a/libs/WindowManager/Shell/res/layout/compat_mode_hint.xml
+++ b/libs/WindowManager/Shell/res/layout/compat_mode_hint.xml
@@ -16,7 +16,7 @@
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:clipToPadding="false"
@@ -26,7 +26,7 @@
<TextView
android:id="@+id/compat_mode_hint_text"
- android:layout_width="match_parent"
+ android:layout_width="188dp"
android:layout_height="wrap_content"
android:lineSpacingExtra="4sp"
android:background="@drawable/compat_hint_bubble"
diff --git a/libs/WindowManager/Shell/res/layout/compat_ui_layout.xml b/libs/WindowManager/Shell/res/layout/compat_ui_layout.xml
index dfaeeeb..dc16834 100644
--- a/libs/WindowManager/Shell/res/layout/compat_ui_layout.xml
+++ b/libs/WindowManager/Shell/res/layout/compat_ui_layout.xml
@@ -21,47 +21,11 @@
android:orientation="vertical"
android:gravity="bottom|end">
- <include android:id="@+id/camera_compat_hint"
- android:visibility="gone"
- android:layout_width="@dimen/camera_compat_hint_width"
- android:layout_height="wrap_content"
- layout="@layout/compat_mode_hint"/>
-
- <LinearLayout
- android:id="@+id/camera_compat_control"
- android:visibility="gone"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:clipToPadding="false"
- android:layout_marginEnd="@dimen/compat_button_margin"
- android:layout_marginBottom="@dimen/compat_button_margin"
- android:orientation="vertical">
-
- <ImageButton
- android:id="@+id/camera_compat_treatment_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:background="@android:color/transparent"/>
-
- <ImageButton
- android:id="@+id/camera_compat_dismiss_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/camera_compat_dismiss_ripple"
- android:background="@android:color/transparent"
- android:contentDescription="@string/camera_compat_dismiss_button_description"/>
-
- </LinearLayout>
-
<include android:id="@+id/size_compat_hint"
- android:visibility="gone"
- android:layout_width="@dimen/size_compat_hint_width"
- android:layout_height="wrap_content"
- layout="@layout/compat_mode_hint"/>
+ layout="@layout/compat_mode_hint"/>
<ImageButton
android:id="@+id/size_compat_restart_button"
- android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/compat_button_margin"
diff --git a/libs/WindowManager/Shell/res/values/dimen.xml b/libs/WindowManager/Shell/res/values/dimen.xml
index 1c19a10..af78293 100644
--- a/libs/WindowManager/Shell/res/values/dimen.xml
+++ b/libs/WindowManager/Shell/res/values/dimen.xml
@@ -213,12 +213,6 @@
+ compat_button_margin - compat_hint_corner_radius - compat_hint_point_width / 2). -->
<dimen name="compat_hint_padding_end">7dp</dimen>
- <!-- The width of the size compat hint. -->
- <dimen name="size_compat_hint_width">188dp</dimen>
-
- <!-- The width of the camera compat hint. -->
- <dimen name="camera_compat_hint_width">143dp</dimen>
-
<!-- The width of the brand image on staring surface. -->
<dimen name="starting_surface_brand_image_width">200dp</dimen>
diff --git a/libs/WindowManager/Shell/res/values/strings.xml b/libs/WindowManager/Shell/res/values/strings.xml
index ab0013a..c88fc16 100644
--- a/libs/WindowManager/Shell/res/values/strings.xml
+++ b/libs/WindowManager/Shell/res/values/strings.xml
@@ -158,17 +158,4 @@
<!-- Description of the restart button in the hint of size compatibility mode. [CHAR LIMIT=NONE] -->
<string name="restart_button_description">Tap to restart this app and go full screen.</string>
-
- <!-- Description of the camera compat button for applying stretched issues treatment in the hint for
- compatibility control. [CHAR LIMIT=NONE] -->
- <string name="camera_compat_treatment_suggested_button_description">Camera issues?\nTap to refit</string>
-
- <!-- Description of the camera compat button for reverting stretched issues treatment in the hint for
- compatibility control. [CHAR LIMIT=NONE] -->
- <string name="camera_compat_treatment_applied_button_description">Didn\u2019t fix it?\nTap to revert</string>
-
- <!-- Accessibillity description of the camera dismiss button for stretched issues in the hint for
- compatibility control. [CHAR LIMIT=NONE] -->
- <string name="camera_compat_dismiss_button_description">No camera issues? Tap to dismiss.</string>
-
</resources>
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/ShellTaskOrganizer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/ShellTaskOrganizer.java
index 91ea436..8b3a356 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/ShellTaskOrganizer.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/ShellTaskOrganizer.java
@@ -458,7 +458,7 @@
newListener.onTaskInfoChanged(taskInfo);
}
notifyLocusVisibilityIfNeeded(taskInfo);
- if (updated || !taskInfo.equalsForCompatUi(data.getTaskInfo())) {
+ if (updated || !taskInfo.equalsForSizeCompat(data.getTaskInfo())) {
// Notify the compat UI if the listener or task info changed.
notifyCompatUI(taskInfo, newListener);
}
@@ -607,19 +607,6 @@
restartTaskTopActivityProcessIfVisible(info.getTaskInfo().token);
}
- @Override
- public void onCameraControlStateUpdated(
- int taskId, @TaskInfo.CameraCompatControlState int state) {
- final TaskAppearedInfo info;
- synchronized (mLock) {
- info = mTasks.get(taskId);
- }
- if (info == null) {
- return;
- }
- updateCameraCompatControlState(info.getTaskInfo().token, state);
- }
-
private void logSizeCompatRestartButtonEventReported(@NonNull TaskAppearedInfo info,
int event) {
ActivityInfo topActivityInfo = info.getTaskInfo().topActivityInfo;
@@ -646,11 +633,14 @@
// The task is vanished or doesn't support compat UI, notify to remove compat UI
// on this Task if there is any.
if (taskListener == null || !taskListener.supportCompatUI()
- || !taskInfo.hasCompatUI() || !taskInfo.isVisible) {
- mCompatUI.onCompatInfoChanged(taskInfo, null /* taskListener */);
+ || !taskInfo.topActivityInSizeCompat || !taskInfo.isVisible) {
+ mCompatUI.onCompatInfoChanged(taskInfo.displayId, taskInfo.taskId,
+ null /* taskConfig */, null /* taskListener */);
return;
}
- mCompatUI.onCompatInfoChanged(taskInfo, taskListener);
+
+ mCompatUI.onCompatInfoChanged(taskInfo.displayId, taskInfo.taskId,
+ taskInfo.configuration, taskListener);
}
private TaskListener getTaskListener(RunningTaskInfo runningTaskInfo) {
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java
index 8f4cfb0..e0b2387 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java
@@ -17,8 +17,6 @@
package com.android.wm.shell.compatui;
import android.annotation.Nullable;
-import android.app.TaskInfo;
-import android.app.TaskInfo.CameraCompatControlState;
import android.content.Context;
import android.content.res.Configuration;
import android.hardware.display.DisplayManager;
@@ -55,14 +53,12 @@
public class CompatUIController implements OnDisplaysChangedListener,
DisplayImeController.ImePositionProcessor {
- /** Callback for compat UI interaction. */
+ /** Callback for size compat UI interaction. */
public interface CompatUICallback {
/** Called when the size compat restart button appears. */
void onSizeCompatRestartButtonAppeared(int taskId);
/** Called when the size compat restart button is clicked. */
void onSizeCompatRestartButtonClicked(int taskId);
- /** Called when the camera compat control state is updated. */
- void onCameraControlStateUpdated(int taskId, @CameraCompatControlState int state);
}
private static final String TAG = "CompatUIController";
@@ -90,12 +86,10 @@
private CompatUICallback mCallback;
- // Only show once automatically in the process life.
- private boolean mHasShownSizeCompatHint;
- private boolean mHasShownCameraCompatHint;
-
- // Indicates if the keyguard is currently occluded, in which case compat UIs shouldn't
- // be shown.
+ /** Only show once automatically in the process life. */
+ private boolean mHasShownHint;
+ /** Indicates if the keyguard is currently occluded, in which case compat UIs shouldn't
+ * be shown. */
private boolean mKeyguardOccluded;
public CompatUIController(Context context,
@@ -128,20 +122,23 @@
* Called when the Task info changed. Creates and updates the compat UI if there is an
* activity in size compat, or removes the UI if there is no size compat activity.
*
- * @param taskInfo {@link TaskInfo} task the activity is in.
+ * @param displayId display the task and activity are in.
+ * @param taskId task the activity is in.
+ * @param taskConfig task config to place the compat UI with.
* @param taskListener listener to handle the Task Surface placement.
*/
- public void onCompatInfoChanged(TaskInfo taskInfo,
+ public void onCompatInfoChanged(int displayId, int taskId,
+ @Nullable Configuration taskConfig,
@Nullable ShellTaskOrganizer.TaskListener taskListener) {
- if (taskInfo.configuration == null || taskListener == null) {
+ if (taskConfig == null || taskListener == null) {
// Null token means the current foreground activity is not in compatibility mode.
- removeLayout(taskInfo.taskId);
- } else if (mActiveLayouts.contains(taskInfo.taskId)) {
+ removeLayout(taskId);
+ } else if (mActiveLayouts.contains(taskId)) {
// UI already exists, update the UI layout.
- updateLayout(taskInfo, taskListener);
+ updateLayout(taskId, taskConfig, taskListener);
} else {
// Create a new compat UI.
- createLayout(taskInfo, taskListener);
+ createLayout(displayId, taskId, taskConfig, taskListener);
}
}
@@ -218,45 +215,38 @@
return mDisplaysWithIme.contains(displayId);
}
- private void createLayout(TaskInfo taskInfo, ShellTaskOrganizer.TaskListener taskListener) {
- final Context context = getOrCreateDisplayContext(taskInfo.displayId);
+ private void createLayout(int displayId, int taskId, Configuration taskConfig,
+ ShellTaskOrganizer.TaskListener taskListener) {
+ final Context context = getOrCreateDisplayContext(displayId);
if (context == null) {
- Log.e(TAG, "Cannot get context for display " + taskInfo.displayId);
+ Log.e(TAG, "Cannot get context for display " + displayId);
return;
}
final CompatUIWindowManager compatUIWindowManager =
- createLayout(context, taskInfo, taskListener);
- mActiveLayouts.put(taskInfo.taskId, compatUIWindowManager);
- compatUIWindowManager.createLayout(showOnDisplay(taskInfo.displayId),
- taskInfo.topActivityInSizeCompat, taskInfo.cameraCompatControlState);
+ createLayout(context, displayId, taskId, taskConfig, taskListener);
+ mActiveLayouts.put(taskId, compatUIWindowManager);
+ compatUIWindowManager.createLayout(showOnDisplay(displayId));
}
@VisibleForTesting
- CompatUIWindowManager createLayout(Context context, TaskInfo taskInfo,
- ShellTaskOrganizer.TaskListener taskListener) {
+ CompatUIWindowManager createLayout(Context context, int displayId, int taskId,
+ Configuration taskConfig, ShellTaskOrganizer.TaskListener taskListener) {
final CompatUIWindowManager compatUIWindowManager = new CompatUIWindowManager(context,
- taskInfo.configuration, mSyncQueue, mCallback, taskInfo.taskId, taskListener,
- mDisplayController.getDisplayLayout(taskInfo.displayId), mHasShownSizeCompatHint,
- mHasShownCameraCompatHint);
- // Only show hints for the first time.
- if (taskInfo.topActivityInSizeCompat) {
- mHasShownSizeCompatHint = true;
- }
- if (taskInfo.hasCameraCompatControl()) {
- mHasShownCameraCompatHint = true;
- }
+ taskConfig, mSyncQueue, mCallback, taskId, taskListener,
+ mDisplayController.getDisplayLayout(displayId), mHasShownHint);
+ // Only show hint for the first time.
+ mHasShownHint = true;
return compatUIWindowManager;
}
- private void updateLayout(TaskInfo taskInfo, ShellTaskOrganizer.TaskListener taskListener) {
- final CompatUIWindowManager layout = mActiveLayouts.get(taskInfo.taskId);
+ private void updateLayout(int taskId, Configuration taskConfig,
+ ShellTaskOrganizer.TaskListener taskListener) {
+ final CompatUIWindowManager layout = mActiveLayouts.get(taskId);
if (layout == null) {
return;
}
- layout.updateCompatInfo(taskInfo.configuration, taskListener,
- showOnDisplay(layout.getDisplayId()), taskInfo.topActivityInSizeCompat,
- taskInfo.cameraCompatControlState);
+ layout.updateCompatInfo(taskConfig, taskListener, showOnDisplay(layout.getDisplayId()));
}
private void removeLayout(int taskId) {
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUILayout.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUILayout.java
index 29b2baa..ea4f209 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUILayout.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUILayout.java
@@ -16,9 +16,6 @@
package com.android.wm.shell.compatui;
-import android.annotation.IdRes;
-import android.app.TaskInfo;
-import android.app.TaskInfo.CameraCompatControlState;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
@@ -56,53 +53,6 @@
mWindowManager = windowManager;
}
- void updateCameraTreatmentButton(@CameraCompatControlState int newState) {
- int buttonBkgId = newState == TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED
- ? R.drawable.camera_compat_treatment_suggested_ripple
- : R.drawable.camera_compat_treatment_applied_ripple;
- int hintStringId = newState == TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED
- ? R.string.camera_compat_treatment_suggested_button_description
- : R.string.camera_compat_treatment_applied_button_description;
- final ImageButton button = findViewById(R.id.camera_compat_treatment_button);
- button.setImageResource(buttonBkgId);
- button.setContentDescription(getResources().getString(hintStringId));
- final LinearLayout hint = findViewById(R.id.camera_compat_hint);
- ((TextView) hint.findViewById(R.id.compat_mode_hint_text)).setText(hintStringId);
- }
-
- void setSizeCompatHintVisibility(boolean show) {
- setViewVisibility(R.id.size_compat_hint, show);
- }
-
- void setCameraCompatHintVisibility(boolean show) {
- setViewVisibility(R.id.camera_compat_hint, show);
- }
-
- void setRestartButtonVisibility(boolean show) {
- setViewVisibility(R.id.size_compat_restart_button, show);
- // Hint should never be visible without button.
- if (!show) {
- setSizeCompatHintVisibility(/* show= */ false);
- }
- }
-
- void setCameraControlVisibility(boolean show) {
- setViewVisibility(R.id.camera_compat_control, show);
- // Hint should never be visible without button.
- if (!show) {
- setCameraCompatHintVisibility(/* show= */ false);
- }
- }
-
- private void setViewVisibility(@IdRes int resId, boolean show) {
- final View view = findViewById(resId);
- int visibility = show ? View.VISIBLE : View.GONE;
- if (view.getVisibility() == visibility) {
- return;
- }
- view.setVisibility(visibility);
- }
-
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
@@ -111,6 +61,15 @@
mWindowManager.relayout();
}
+ void setSizeCompatHintVisibility(boolean show) {
+ final LinearLayout sizeCompatHint = findViewById(R.id.size_compat_hint);
+ int visibility = show ? View.VISIBLE : View.GONE;
+ if (sizeCompatHint.getVisibility() == visibility) {
+ return;
+ }
+ sizeCompatHint.setVisibility(visibility);
+ }
+
@Override
protected void onFinishInflate() {
super.onFinishInflate();
@@ -126,26 +85,5 @@
((TextView) sizeCompatHint.findViewById(R.id.compat_mode_hint_text))
.setText(R.string.restart_button_description);
sizeCompatHint.setOnClickListener(view -> setSizeCompatHintVisibility(/* show= */ false));
-
- final ImageButton cameraTreatmentButton =
- findViewById(R.id.camera_compat_treatment_button);
- cameraTreatmentButton.setOnClickListener(
- view -> mWindowManager.onCameraTreatmentButtonClicked());
- cameraTreatmentButton.setOnLongClickListener(view -> {
- mWindowManager.onCameraButtonLongClicked();
- return true;
- });
-
- final ImageButton cameraDismissButton = findViewById(R.id.camera_compat_dismiss_button);
- cameraDismissButton.setOnClickListener(
- view -> mWindowManager.onCameraDismissButtonClicked());
- cameraDismissButton.setOnLongClickListener(view -> {
- mWindowManager.onCameraButtonLongClicked();
- return true;
- });
-
- final LinearLayout cameraCompatHint = findViewById(R.id.camera_compat_hint);
- cameraCompatHint.setOnClickListener(
- view -> setCameraCompatHintVisibility(/* show= */ false));
}
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIWindowManager.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIWindowManager.java
index 44526b0..997ad04 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIWindowManager.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIWindowManager.java
@@ -16,10 +16,6 @@
package com.android.wm.shell.compatui;
-import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_DISMISSED;
-import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_HIDDEN;
-import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED;
-import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION;
@@ -27,7 +23,6 @@
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
import android.annotation.Nullable;
-import android.app.TaskInfo.CameraCompatControlState;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
@@ -68,17 +63,8 @@
private ShellTaskOrganizer.TaskListener mTaskListener;
private DisplayLayout mDisplayLayout;
- // Remember the last reported states in case visibility changes due to keyguard or
- // IME updates.
@VisibleForTesting
- boolean mHasSizeCompat;
- @CameraCompatControlState
- private int mCameraCompatControlState = CAMERA_COMPAT_CONTROL_HIDDEN;
-
- @VisibleForTesting
- boolean mShouldShowSizeCompatHint;
- @VisibleForTesting
- boolean mShouldShowCameraCompatHint;
+ boolean mShouldShowHint;
@Nullable
@VisibleForTesting
@@ -92,7 +78,7 @@
CompatUIWindowManager(Context context, Configuration taskConfig,
SyncTransactionQueue syncQueue, CompatUIController.CompatUICallback callback,
int taskId, ShellTaskOrganizer.TaskListener taskListener, DisplayLayout displayLayout,
- boolean hasShownSizeCompatHint, boolean hasShownCameraCompatHint) {
+ boolean hasShownHint) {
super(taskConfig, null /* rootSurface */, null /* hostInputToken */);
mContext = context;
mSyncQueue = syncQueue;
@@ -102,8 +88,7 @@
mTaskId = taskId;
mTaskListener = taskListener;
mDisplayLayout = displayLayout;
- mShouldShowSizeCompatHint = !hasShownSizeCompatHint;
- mShouldShowCameraCompatHint = !hasShownCameraCompatHint;
+ mShouldShowHint = !hasShownHint;
mStableBounds = new Rect();
mDisplayLayout.getStableBounds(mStableBounds);
}
@@ -128,10 +113,7 @@
}
/** Creates the layout for compat controls. */
- void createLayout(boolean show, boolean hasSizeCompat,
- @CameraCompatControlState int cameraCompatControlState) {
- mHasSizeCompat = hasSizeCompat;
- mCameraCompatControlState = cameraCompatControlState;
+ void createLayout(boolean show) {
if (!show || mCompatUILayout != null) {
// Wait until compat controls should be visible.
return;
@@ -140,27 +122,16 @@
initCompatUi();
updateSurfacePosition();
- if (hasSizeCompat) {
- mCallback.onSizeCompatRestartButtonAppeared(mTaskId);
- }
- }
-
- private void createLayout(boolean show) {
- createLayout(show, mHasSizeCompat, mCameraCompatControlState);
+ mCallback.onSizeCompatRestartButtonAppeared(mTaskId);
}
/** Called when compat info changed. */
void updateCompatInfo(Configuration taskConfig,
- ShellTaskOrganizer.TaskListener taskListener, boolean show, boolean hasSizeCompat,
- @CameraCompatControlState int cameraCompatControlState) {
+ ShellTaskOrganizer.TaskListener taskListener, boolean show) {
final Configuration prevTaskConfig = mTaskConfig;
final ShellTaskOrganizer.TaskListener prevTaskListener = mTaskListener;
mTaskConfig = taskConfig;
mTaskListener = taskListener;
- final boolean prevHasSizeCompat = mHasSizeCompat;
- final int prevCameraCompatControlState = mCameraCompatControlState;
- mHasSizeCompat = hasSizeCompat;
- mCameraCompatControlState = cameraCompatControlState;
// Update configuration.
mContext = mContext.createConfigurationContext(taskConfig);
@@ -173,11 +144,6 @@
return;
}
- if (prevHasSizeCompat != mHasSizeCompat
- || prevCameraCompatControlState != mCameraCompatControlState) {
- updateVisibilityOfViews();
- }
-
if (!taskConfig.windowConfiguration.getBounds()
.equals(prevTaskConfig.windowConfiguration.getBounds())) {
// Reposition the UI surfaces.
@@ -189,7 +155,6 @@
mCompatUILayout.setLayoutDirection(taskConfig.getLayoutDirection());
updateSurfacePosition();
}
-
}
/** Called when the visibility of the UI should change. */
@@ -230,34 +195,6 @@
mCallback.onSizeCompatRestartButtonClicked(mTaskId);
}
- /** Called when the camera treatment button is clicked. */
- void onCameraTreatmentButtonClicked() {
- if (!shouldShowCameraControl()) {
- Log.w(TAG, "Camera compat shouldn't receive clicks in the hidden state.");
- return;
- }
- // When a camera control is shown, only two states are allowed: "treament applied" and
- // "treatment suggested". Clicks on the conrol's treatment button toggle between these
- // two states.
- mCameraCompatControlState =
- mCameraCompatControlState == CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED
- ? CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED
- : CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED;
- mCallback.onCameraControlStateUpdated(mTaskId, mCameraCompatControlState);
- mCompatUILayout.updateCameraTreatmentButton(mCameraCompatControlState);
- }
-
- /** Called when the camera dismiss button is clicked. */
- void onCameraDismissButtonClicked() {
- if (!shouldShowCameraControl()) {
- Log.w(TAG, "Camera compat shouldn't receive clicks in the hidden state.");
- return;
- }
- mCameraCompatControlState = CAMERA_COMPAT_CONTROL_DISMISSED;
- mCallback.onCameraControlStateUpdated(mTaskId, CAMERA_COMPAT_CONTROL_DISMISSED);
- mCompatUILayout.setCameraControlVisibility(/* show= */ false);
- }
-
/** Called when the restart button is long clicked. */
void onRestartButtonLongClicked() {
if (mCompatUILayout == null) {
@@ -266,14 +203,6 @@
mCompatUILayout.setSizeCompatHintVisibility(/* show= */ true);
}
- /** Called when either dismiss or treatment camera buttons is long clicked. */
- void onCameraButtonLongClicked() {
- if (mCompatUILayout == null) {
- return;
- }
- mCompatUILayout.setCameraCompatHintVisibility(/* show= */ true);
- }
-
int getDisplayId() {
return mDisplayId;
}
@@ -284,8 +213,6 @@
/** Releases the surface control and tears down the view hierarchy. */
void release() {
- // Hiding before releasing to avoid flickering when transitioning to the Home screen.
- mCompatUILayout.setVisibility(View.GONE);
mCompatUILayout = null;
if (mViewHost != null) {
@@ -356,35 +283,12 @@
mCompatUILayout = inflateCompatUILayout();
mCompatUILayout.inject(this);
- updateVisibilityOfViews();
+ mCompatUILayout.setSizeCompatHintVisibility(mShouldShowHint);
mViewHost.setView(mCompatUILayout, getWindowLayoutParams());
- }
- private void updateVisibilityOfViews() {
- // Size Compat mode restart button.
- mCompatUILayout.setRestartButtonVisibility(mHasSizeCompat);
- if (mHasSizeCompat && mShouldShowSizeCompatHint) {
- mCompatUILayout.setSizeCompatHintVisibility(/* show= */ true);
- // Only show by default for the first time.
- mShouldShowSizeCompatHint = false;
- }
-
- // Camera control for stretched issues.
- mCompatUILayout.setCameraControlVisibility(shouldShowCameraControl());
- if (shouldShowCameraControl() && mShouldShowCameraCompatHint) {
- mCompatUILayout.setCameraCompatHintVisibility(/* show= */ true);
- // Only show by default for the first time.
- mShouldShowCameraCompatHint = false;
- }
- if (shouldShowCameraControl()) {
- mCompatUILayout.updateCameraTreatmentButton(mCameraCompatControlState);
- }
- }
-
- private boolean shouldShowCameraControl() {
- return mCameraCompatControlState != CAMERA_COMPAT_CONTROL_HIDDEN
- && mCameraCompatControlState != CAMERA_COMPAT_CONTROL_DISMISSED;
+ // Only show by default for the first time.
+ mShouldShowHint = false;
}
@VisibleForTesting
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/ShellTaskOrganizerTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/ShellTaskOrganizerTests.java
index 825320b..a3b98a8f 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/ShellTaskOrganizerTests.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/ShellTaskOrganizerTests.java
@@ -37,7 +37,6 @@
import static org.mockito.Mockito.verify;
import android.app.ActivityManager.RunningTaskInfo;
-import android.app.TaskInfo;
import android.content.Context;
import android.content.LocusId;
import android.content.pm.ParceledListSlice;
@@ -335,7 +334,8 @@
mOrganizer.onTaskAppeared(taskInfo1, null);
// sizeCompatActivity is null if top activity is not in size compat.
- verify(mCompatUI).onCompatInfoChanged(taskInfo1, null /* taskListener */);
+ verify(mCompatUI).onCompatInfoChanged(taskInfo1.displayId, taskInfo1.taskId,
+ null /* taskConfig */, null /* taskListener */);
// sizeCompatActivity is non-null if top activity is in size compat.
clearInvocations(mCompatUI);
@@ -345,7 +345,8 @@
taskInfo2.topActivityInSizeCompat = true;
taskInfo2.isVisible = true;
mOrganizer.onTaskInfoChanged(taskInfo2);
- verify(mCompatUI).onCompatInfoChanged(taskInfo2, taskListener);
+ verify(mCompatUI).onCompatInfoChanged(taskInfo1.displayId, taskInfo1.taskId,
+ taskInfo1.configuration, taskListener);
// Not show size compat UI if task is not visible.
clearInvocations(mCompatUI);
@@ -355,82 +356,13 @@
taskInfo3.topActivityInSizeCompat = true;
taskInfo3.isVisible = false;
mOrganizer.onTaskInfoChanged(taskInfo3);
- verify(mCompatUI).onCompatInfoChanged(taskInfo3, null /* taskListener */);
+ verify(mCompatUI).onCompatInfoChanged(taskInfo1.displayId, taskInfo1.taskId,
+ null /* taskConfig */, null /* taskListener */);
clearInvocations(mCompatUI);
mOrganizer.onTaskVanished(taskInfo1);
- verify(mCompatUI).onCompatInfoChanged(taskInfo1, null /* taskListener */);
- }
-
- @Test
- public void testOnCameraCompatActivityChanged() {
- final RunningTaskInfo taskInfo1 = createTaskInfo(1, WINDOWING_MODE_FULLSCREEN);
- taskInfo1.displayId = DEFAULT_DISPLAY;
- taskInfo1.cameraCompatControlState = TaskInfo.CAMERA_COMPAT_CONTROL_HIDDEN;
- final TrackingTaskListener taskListener = new TrackingTaskListener();
- mOrganizer.addListenerForType(taskListener, TASK_LISTENER_TYPE_FULLSCREEN);
- mOrganizer.onTaskAppeared(taskInfo1, null);
-
- // Task listener sent to compat UI is null if top activity doesn't request a camera
- // compat control.
- verify(mCompatUI).onCompatInfoChanged(taskInfo1, null /* taskListener */);
-
- // Task linster is non-null when request a camera compat control for a visible task.
- clearInvocations(mCompatUI);
- final RunningTaskInfo taskInfo2 =
- createTaskInfo(taskInfo1.taskId, taskInfo1.getWindowingMode());
- taskInfo2.displayId = taskInfo1.displayId;
- taskInfo2.cameraCompatControlState = TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED;
- taskInfo2.isVisible = true;
- mOrganizer.onTaskInfoChanged(taskInfo2);
- verify(mCompatUI).onCompatInfoChanged(taskInfo2, taskListener);
-
- // CompatUIController#onCompatInfoChanged is called when requested state for a camera
- // compat control changes for a visible task.
- clearInvocations(mCompatUI);
- final RunningTaskInfo taskInfo3 =
- createTaskInfo(taskInfo1.taskId, taskInfo1.getWindowingMode());
- taskInfo3.displayId = taskInfo1.displayId;
- taskInfo3.cameraCompatControlState = TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED;
- taskInfo3.isVisible = true;
- mOrganizer.onTaskInfoChanged(taskInfo3);
- verify(mCompatUI).onCompatInfoChanged(taskInfo3, taskListener);
-
- // CompatUIController#onCompatInfoChanged is called when a top activity goes in size compat
- // mode for a visible task that has a compat control.
- clearInvocations(mCompatUI);
- final RunningTaskInfo taskInfo4 =
- createTaskInfo(taskInfo1.taskId, taskInfo1.getWindowingMode());
- taskInfo4.displayId = taskInfo1.displayId;
- taskInfo4.topActivityInSizeCompat = true;
- taskInfo4.cameraCompatControlState = TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED;
- taskInfo4.isVisible = true;
- mOrganizer.onTaskInfoChanged(taskInfo4);
- verify(mCompatUI).onCompatInfoChanged(taskInfo4, taskListener);
-
- // Task linster is null when a camera compat control is dimissed for a visible task.
- clearInvocations(mCompatUI);
- final RunningTaskInfo taskInfo5 =
- createTaskInfo(taskInfo1.taskId, taskInfo1.getWindowingMode());
- taskInfo5.displayId = taskInfo1.displayId;
- taskInfo5.cameraCompatControlState = TaskInfo.CAMERA_COMPAT_CONTROL_DISMISSED;
- taskInfo5.isVisible = true;
- mOrganizer.onTaskInfoChanged(taskInfo5);
- verify(mCompatUI).onCompatInfoChanged(taskInfo5, null /* taskListener */);
-
- // Task linster is null when request a camera compat control for a invisible task.
- clearInvocations(mCompatUI);
- final RunningTaskInfo taskInfo6 =
- createTaskInfo(taskInfo1.taskId, taskInfo1.getWindowingMode());
- taskInfo6.displayId = taskInfo1.displayId;
- taskInfo6.cameraCompatControlState = TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED;
- taskInfo6.isVisible = false;
- mOrganizer.onTaskInfoChanged(taskInfo6);
- verify(mCompatUI).onCompatInfoChanged(taskInfo6, null /* taskListener */);
-
- clearInvocations(mCompatUI);
- mOrganizer.onTaskVanished(taskInfo1);
- verify(mCompatUI).onCompatInfoChanged(taskInfo1, null /* taskListener */);
+ verify(mCompatUI).onCompatInfoChanged(taskInfo1.displayId, taskInfo1.taskId,
+ null /* taskConfig */, null /* taskListener */);
}
@Test
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java
index 4352fd3..f622edb 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java
@@ -16,10 +16,6 @@
package com.android.wm.shell.compatui;
-import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_DISMISSED;
-import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_HIDDEN;
-import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED;
-import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED;
import static android.view.InsetsState.ITYPE_EXTRA_NAVIGATION_BAR;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
@@ -33,9 +29,6 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import android.app.ActivityManager.RunningTaskInfo;
-import android.app.TaskInfo;
-import android.app.TaskInfo.CameraCompatControlState;
import android.content.Context;
import android.content.res.Configuration;
import android.testing.AndroidTestingRunner;
@@ -97,8 +90,8 @@
mController = new CompatUIController(mContext, mMockDisplayController,
mMockDisplayInsetsController, mMockImeController, mMockSyncQueue, mMockExecutor) {
@Override
- CompatUIWindowManager createLayout(Context context, TaskInfo taskInfo,
- ShellTaskOrganizer.TaskListener taskListener) {
+ CompatUIWindowManager createLayout(Context context, int displayId, int taskId,
+ Configuration taskConfig, ShellTaskOrganizer.TaskListener taskListener) {
return mMockLayout;
}
};
@@ -113,59 +106,23 @@
@Test
public void testOnCompatInfoChanged() {
- TaskInfo taskInfo = createTaskInfo(DISPLAY_ID, TASK_ID, true /* hasSizeCompat */,
- CAMERA_COMPAT_CONTROL_HIDDEN);
+ final Configuration taskConfig = new Configuration();
// Verify that the restart button is added with non-null size compat info.
- mController.onCompatInfoChanged(taskInfo, mMockTaskListener);
+ mController.onCompatInfoChanged(DISPLAY_ID, TASK_ID, taskConfig, mMockTaskListener);
- verify(mController).createLayout(any(), eq(taskInfo), eq(mMockTaskListener));
+ verify(mController).createLayout(any(), eq(DISPLAY_ID), eq(TASK_ID), eq(taskConfig),
+ eq(mMockTaskListener));
// Verify that the restart button is updated with non-null new size compat info.
- mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID,
- true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN),
- mMockTaskListener);
+ final Configuration newTaskConfig = new Configuration();
+ mController.onCompatInfoChanged(DISPLAY_ID, TASK_ID, newTaskConfig, mMockTaskListener);
- verify(mMockLayout).updateCompatInfo(new Configuration(), mMockTaskListener,
- true /* show */, true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN);
+ verify(mMockLayout).updateCompatInfo(taskConfig, mMockTaskListener,
+ true /* show */);
- // Verify that the restart button is updated with new camera state.
- mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID,
- true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED),
- mMockTaskListener);
-
- verify(mMockLayout).updateCompatInfo(new Configuration(), mMockTaskListener,
- true /* show */, true /* hasSizeCompat */,
- CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED);
-
- mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID,
- true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED),
- mMockTaskListener);
-
- verify(mMockLayout).updateCompatInfo(new Configuration(), mMockTaskListener,
- true /* show */, true /* hasSizeCompat */,
- CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED);
-
- // Verify that compat controls are removed with null compat info.
- mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID,
- false /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN),
- null /* taskListener */);
-
- verify(mMockLayout).release();
-
- clearInvocations(mMockLayout);
- clearInvocations(mController);
- // Verify that compat controls are removed with dismissed camera state.
- taskInfo = createTaskInfo(DISPLAY_ID, TASK_ID,
- true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED);
-
- mController.onCompatInfoChanged(taskInfo, mMockTaskListener);
-
- verify(mController).createLayout(any(), eq(taskInfo), eq(mMockTaskListener));
-
- mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID,
- false /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_DISMISSED),
- null /* taskListener */);
+ // Verify that the restart button is removed with null size compat info.
+ mController.onCompatInfoChanged(DISPLAY_ID, TASK_ID, null, mMockTaskListener);
verify(mMockLayout).release();
}
@@ -182,8 +139,8 @@
@Test
public void testOnDisplayRemoved() {
mController.onDisplayAdded(DISPLAY_ID);
- mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID,
- true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN),
+ final Configuration taskConfig = new Configuration();
+ mController.onCompatInfoChanged(DISPLAY_ID, TASK_ID, taskConfig,
mMockTaskListener);
mController.onDisplayRemoved(DISPLAY_ID + 1);
@@ -200,14 +157,16 @@
@Test
public void testOnDisplayConfigurationChanged() {
- mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID,
- true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener);
+ final Configuration taskConfig = new Configuration();
+ mController.onCompatInfoChanged(DISPLAY_ID, TASK_ID, taskConfig,
+ mMockTaskListener);
- mController.onDisplayConfigurationChanged(DISPLAY_ID + 1, new Configuration());
+ final Configuration newTaskConfig = new Configuration();
+ mController.onDisplayConfigurationChanged(DISPLAY_ID + 1, newTaskConfig);
verify(mMockLayout, never()).updateDisplayLayout(any());
- mController.onDisplayConfigurationChanged(DISPLAY_ID, new Configuration());
+ mController.onDisplayConfigurationChanged(DISPLAY_ID, newTaskConfig);
verify(mMockLayout).updateDisplayLayout(mMockDisplayLayout);
}
@@ -215,8 +174,9 @@
@Test
public void testInsetsChanged() {
mController.onDisplayAdded(DISPLAY_ID);
- mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID,
- true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener);
+ final Configuration taskConfig = new Configuration();
+ mController.onCompatInfoChanged(DISPLAY_ID, TASK_ID, taskConfig,
+ mMockTaskListener);
InsetsState insetsState = new InsetsState();
InsetsSource insetsSource = new InsetsSource(ITYPE_EXTRA_NAVIGATION_BAR);
insetsSource.setFrame(0, 0, 1000, 1000);
@@ -236,8 +196,8 @@
@Test
public void testChangeButtonVisibilityOnImeShowHide() {
- mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID,
- true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener);
+ final Configuration taskConfig = new Configuration();
+ mController.onCompatInfoChanged(DISPLAY_ID, TASK_ID, taskConfig, mMockTaskListener);
// Verify that the restart button is hidden after IME is showing.
mController.onImeVisibilityChanged(DISPLAY_ID, true /* isShowing */);
@@ -245,11 +205,10 @@
verify(mMockLayout).updateVisibility(false);
// Verify button remains hidden while IME is showing.
- mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID,
- true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener);
+ mController.onCompatInfoChanged(DISPLAY_ID, TASK_ID, taskConfig, mMockTaskListener);
- verify(mMockLayout).updateCompatInfo(new Configuration(), mMockTaskListener,
- false /* show */, true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN);
+ verify(mMockLayout).updateCompatInfo(taskConfig, mMockTaskListener,
+ false /* show */);
// Verify button is shown after IME is hidden.
mController.onImeVisibilityChanged(DISPLAY_ID, false /* isShowing */);
@@ -259,8 +218,8 @@
@Test
public void testChangeButtonVisibilityOnKeyguardOccludedChanged() {
- mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID,
- true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener);
+ final Configuration taskConfig = new Configuration();
+ mController.onCompatInfoChanged(DISPLAY_ID, TASK_ID, taskConfig, mMockTaskListener);
// Verify that the restart button is hidden after keyguard becomes occluded.
mController.onKeyguardOccludedChanged(true);
@@ -268,11 +227,10 @@
verify(mMockLayout).updateVisibility(false);
// Verify button remains hidden while keyguard is occluded.
- mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID,
- true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener);
+ mController.onCompatInfoChanged(DISPLAY_ID, TASK_ID, taskConfig, mMockTaskListener);
- verify(mMockLayout).updateCompatInfo(new Configuration(), mMockTaskListener,
- false /* show */, true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN);
+ verify(mMockLayout).updateCompatInfo(taskConfig, mMockTaskListener,
+ false /* show */);
// Verify button is shown after keyguard becomes not occluded.
mController.onKeyguardOccludedChanged(false);
@@ -282,8 +240,8 @@
@Test
public void testButtonRemainsHiddenOnKeyguardOccludedFalseWhenImeIsShowing() {
- mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID,
- true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener);
+ final Configuration taskConfig = new Configuration();
+ mController.onCompatInfoChanged(DISPLAY_ID, TASK_ID, taskConfig, mMockTaskListener);
mController.onImeVisibilityChanged(DISPLAY_ID, true /* isShowing */);
mController.onKeyguardOccludedChanged(true);
@@ -305,8 +263,8 @@
@Test
public void testButtonRemainsHiddenOnImeHideWhenKeyguardIsOccluded() {
- mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID,
- true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener);
+ final Configuration taskConfig = new Configuration();
+ mController.onCompatInfoChanged(DISPLAY_ID, TASK_ID, taskConfig, mMockTaskListener);
mController.onImeVisibilityChanged(DISPLAY_ID, true /* isShowing */);
mController.onKeyguardOccludedChanged(true);
@@ -325,14 +283,4 @@
verify(mMockLayout).updateVisibility(true);
}
-
- private static TaskInfo createTaskInfo(int displayId, int taskId, boolean hasSizeCompat,
- @CameraCompatControlState int cameraCompatControlState) {
- RunningTaskInfo taskInfo = new RunningTaskInfo();
- taskInfo.taskId = taskId;
- taskInfo.displayId = displayId;
- taskInfo.topActivityInSizeCompat = hasSizeCompat;
- taskInfo.cameraCompatControlState = cameraCompatControlState;
- return taskInfo;
- }
}
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUILayoutTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUILayoutTest.java
index 353d8fe..2c3987b 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUILayoutTest.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUILayoutTest.java
@@ -16,11 +16,6 @@
package com.android.wm.shell.compatui;
-import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_DISMISSED;
-import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_HIDDEN;
-import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED;
-import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED;
-
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static org.mockito.Mockito.doNothing;
@@ -74,7 +69,7 @@
mWindowManager = new CompatUIWindowManager(mContext, new Configuration(),
mSyncTransactionQueue, mCallback, TASK_ID, mTaskListener, new DisplayLayout(),
- false /* hasShownSizeCompatHint */, false /* hasShownCameraCompatHint */);
+ false /* hasShownHint */);
mCompatUILayout = (CompatUILayout)
LayoutInflater.from(mContext).inflate(R.layout.compat_ui_layout, null);
@@ -83,7 +78,6 @@
spyOn(mWindowManager);
spyOn(mCompatUILayout);
doReturn(mViewHost).when(mWindowManager).createSurfaceViewHost();
- doReturn(mCompatUILayout).when(mWindowManager).inflateCompatUILayout();
}
@Test
@@ -92,6 +86,7 @@
button.performClick();
verify(mWindowManager).onRestartButtonClicked();
+ doReturn(mCompatUILayout).when(mWindowManager).inflateCompatUILayout();
verify(mCallback).onSizeCompatRestartButtonClicked(TASK_ID);
}
@@ -107,92 +102,10 @@
@Test
public void testOnClickForSizeCompatHint() {
- mWindowManager.createLayout(true /* show */, true /* hasSizeCompat */,
- CAMERA_COMPAT_CONTROL_HIDDEN);
+ mWindowManager.createLayout(true /* show */);
final LinearLayout sizeCompatHint = mCompatUILayout.findViewById(R.id.size_compat_hint);
sizeCompatHint.performClick();
verify(mCompatUILayout).setSizeCompatHintVisibility(/* show= */ false);
}
-
- @Test
- public void testUpdateCameraTreatmentButton_treatmentAppliedByDefault() {
- mWindowManager.createLayout(true /* show */, true /* hasSizeCompat */,
- CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED);
- final ImageButton button =
- mCompatUILayout.findViewById(R.id.camera_compat_treatment_button);
- button.performClick();
-
- verify(mWindowManager).onCameraTreatmentButtonClicked();
- verify(mCallback).onCameraControlStateUpdated(
- TASK_ID, CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED);
-
- button.performClick();
-
- verify(mCallback).onCameraControlStateUpdated(
- TASK_ID, CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED);
- }
-
- @Test
- public void testUpdateCameraTreatmentButton_treatmentSuggestedByDefault() {
- mWindowManager.createLayout(true /* show */, true /* hasSizeCompat */,
- CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED);
- final ImageButton button =
- mCompatUILayout.findViewById(R.id.camera_compat_treatment_button);
- button.performClick();
-
- verify(mWindowManager).onCameraTreatmentButtonClicked();
- verify(mCallback).onCameraControlStateUpdated(
- TASK_ID, CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED);
-
- button.performClick();
-
- verify(mCallback).onCameraControlStateUpdated(
- TASK_ID, CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED);
- }
-
- @Test
- public void testOnCameraDismissButtonClicked() {
- mWindowManager.createLayout(true /* show */, true /* hasSizeCompat */,
- CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED);
- final ImageButton button =
- mCompatUILayout.findViewById(R.id.camera_compat_dismiss_button);
- button.performClick();
-
- verify(mWindowManager).onCameraDismissButtonClicked();
- verify(mCallback).onCameraControlStateUpdated(
- TASK_ID, CAMERA_COMPAT_CONTROL_DISMISSED);
- verify(mCompatUILayout).setCameraControlVisibility(/* show */ false);
- }
-
- @Test
- public void testOnLongClickForCameraTreatementButton() {
- doNothing().when(mWindowManager).onCameraButtonLongClicked();
-
- final ImageButton button =
- mCompatUILayout.findViewById(R.id.camera_compat_treatment_button);
- button.performLongClick();
-
- verify(mWindowManager).onCameraButtonLongClicked();
- }
-
- @Test
- public void testOnLongClickForCameraDismissButton() {
- doNothing().when(mWindowManager).onCameraButtonLongClicked();
-
- final ImageButton button = mCompatUILayout.findViewById(R.id.camera_compat_dismiss_button);
- button.performLongClick();
-
- verify(mWindowManager).onCameraButtonLongClicked();
- }
-
- @Test
- public void testOnClickForCameraCompatHint() {
- mWindowManager.createLayout(true /* show */, false /* hasSizeCompat */,
- CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED);
- final LinearLayout hint = mCompatUILayout.findViewById(R.id.camera_compat_hint);
- hint.performClick();
-
- verify(mCompatUILayout).setCameraCompatHintVisibility(/* show= */ false);
- }
}
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIWindowManagerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIWindowManagerTest.java
index 11c7973..d5dcf2e 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIWindowManagerTest.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIWindowManagerTest.java
@@ -16,10 +16,6 @@
package com.android.wm.shell.compatui;
-import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_DISMISSED;
-import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_HIDDEN;
-import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED;
-import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED;
import static android.view.InsetsState.ITYPE_EXTRA_NAVIGATION_BAR;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
@@ -27,7 +23,6 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.anyBoolean;
-import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -86,7 +81,7 @@
mWindowManager = new CompatUIWindowManager(mContext, new Configuration(),
mSyncTransactionQueue, mCallback, TASK_ID, mTaskListener, new DisplayLayout(),
- false /* hasShownSizeCompatHint */, false /* hasShownSizeCompatHint */);
+ false /* hasShownHint */);
spyOn(mWindowManager);
doReturn(mCompatUILayout).when(mWindowManager).inflateCompatUILayout();
@@ -96,35 +91,31 @@
@Test
public void testCreateSizeCompatButton() {
// Not create layout if show is false.
- mWindowManager.createLayout(false /* show */, true /* hasSizeCompat */,
- CAMERA_COMPAT_CONTROL_HIDDEN);
+ mWindowManager.createLayout(false /* show */);
verify(mWindowManager, never()).inflateCompatUILayout();
// Not create hint popup.
- mWindowManager.mShouldShowSizeCompatHint = false;
- mWindowManager.createLayout(true /* show */, true /* hasSizeCompat */,
- CAMERA_COMPAT_CONTROL_HIDDEN);
+ mWindowManager.mShouldShowHint = false;
+ mWindowManager.createLayout(true /* show */);
verify(mWindowManager).inflateCompatUILayout();
- verify(mCompatUILayout, never()).setSizeCompatHintVisibility(true /* show */);
+ verify(mCompatUILayout).setSizeCompatHintVisibility(false /* show */);
// Create hint popup.
mWindowManager.release();
- mWindowManager.mShouldShowSizeCompatHint = true;
- mWindowManager.createLayout(true /* show */, true /* hasSizeCompat */,
- CAMERA_COMPAT_CONTROL_HIDDEN);
+ mWindowManager.mShouldShowHint = true;
+ mWindowManager.createLayout(true /* show */);
verify(mWindowManager, times(2)).inflateCompatUILayout();
assertNotNull(mCompatUILayout);
verify(mCompatUILayout).setSizeCompatHintVisibility(true /* show */);
- assertFalse(mWindowManager.mShouldShowSizeCompatHint);
+ assertFalse(mWindowManager.mShouldShowHint);
}
@Test
public void testRelease() {
- mWindowManager.createLayout(true /* show */, true /* hasSizeCompat */,
- CAMERA_COMPAT_CONTROL_HIDDEN);
+ mWindowManager.createLayout(true /* show */);
verify(mWindowManager).inflateCompatUILayout();
@@ -135,60 +126,32 @@
@Test
public void testUpdateCompatInfo() {
- mWindowManager.createLayout(true /* show */, true /* hasSizeCompat */,
- CAMERA_COMPAT_CONTROL_HIDDEN);
+ mWindowManager.createLayout(true /* show */);
// No diff
clearInvocations(mWindowManager);
- mWindowManager.updateCompatInfo(mTaskConfig, mTaskListener, true /* show */,
- true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN);
+ mWindowManager.updateCompatInfo(mTaskConfig, mTaskListener, true /* show */);
verify(mWindowManager, never()).updateSurfacePosition();
verify(mWindowManager, never()).release();
- verify(mWindowManager, never()).createLayout(anyBoolean(), anyBoolean(), anyInt());
+ verify(mWindowManager, never()).createLayout(anyBoolean());
// Change task listener, recreate button.
clearInvocations(mWindowManager);
final ShellTaskOrganizer.TaskListener newTaskListener = mock(
ShellTaskOrganizer.TaskListener.class);
mWindowManager.updateCompatInfo(mTaskConfig, newTaskListener,
- true /* show */, true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN);
+ true /* show */);
verify(mWindowManager).release();
- verify(mWindowManager).createLayout(anyBoolean(), anyBoolean(), anyInt());
-
- // Change Camera Compat state, show a control.
- mWindowManager.updateCompatInfo(mTaskConfig, newTaskListener, true /* show */,
- true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED);
-
- verify(mCompatUILayout).setCameraControlVisibility(/* show */ true);
- verify(mCompatUILayout).updateCameraTreatmentButton(
- CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED);
-
- clearInvocations(mWindowManager);
- clearInvocations(mCompatUILayout);
- // Change Camera Compat state, update a control.
- mWindowManager.updateCompatInfo(mTaskConfig, newTaskListener, true /* show */,
- true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED);
-
- verify(mCompatUILayout).setCameraControlVisibility(/* show */ true);
- verify(mCompatUILayout).updateCameraTreatmentButton(
- CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED);
-
- clearInvocations(mWindowManager);
- clearInvocations(mCompatUILayout);
- // Change Camera Compat state to hidden, hide a control.
- mWindowManager.updateCompatInfo(mTaskConfig, newTaskListener,
- true /* show */, true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN);
-
- verify(mCompatUILayout).setCameraControlVisibility(/* show */ false);
+ verify(mWindowManager).createLayout(anyBoolean());
// Change task bounds, update position.
clearInvocations(mWindowManager);
final Configuration newTaskConfiguration = new Configuration();
newTaskConfiguration.windowConfiguration.setBounds(new Rect(0, 1000, 0, 2000));
mWindowManager.updateCompatInfo(newTaskConfiguration, newTaskListener,
- true /* show */, true /* hasSizeCompat */, CAMERA_COMPAT_CONTROL_HIDDEN);
+ true /* show */);
verify(mWindowManager).updateSurfacePosition();
}
@@ -238,25 +201,23 @@
public void testUpdateVisibility() {
// Create button if it is not created.
mWindowManager.mCompatUILayout = null;
- mWindowManager.mHasSizeCompat = true;
mWindowManager.updateVisibility(true /* show */);
- verify(mWindowManager).createLayout(true /* show */, true /* hasSizeCompat */,
- CAMERA_COMPAT_CONTROL_HIDDEN);
+ verify(mWindowManager).createLayout(true /* show */);
// Hide button.
clearInvocations(mWindowManager);
doReturn(View.VISIBLE).when(mCompatUILayout).getVisibility();
mWindowManager.updateVisibility(false /* show */);
- verify(mWindowManager, never()).createLayout(anyBoolean(), anyBoolean(), anyInt());
+ verify(mWindowManager, never()).createLayout(anyBoolean());
verify(mCompatUILayout).setVisibility(View.GONE);
// Show button.
doReturn(View.GONE).when(mCompatUILayout).getVisibility();
mWindowManager.updateVisibility(true /* show */);
- verify(mWindowManager, never()).createLayout(anyBoolean(), anyBoolean(), anyInt());
+ verify(mWindowManager, never()).createLayout(anyBoolean());
verify(mCompatUILayout).setVisibility(View.VISIBLE);
}
@@ -269,37 +230,6 @@
}
@Test
- public void testOnCameraDismissButtonClicked() {
- mWindowManager.createLayout(true /* show */, true /* hasSizeCompat */,
- CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED);
- clearInvocations(mCompatUILayout);
- mWindowManager.onCameraDismissButtonClicked();
-
- verify(mCallback).onCameraControlStateUpdated(TASK_ID, CAMERA_COMPAT_CONTROL_DISMISSED);
- verify(mCompatUILayout).setCameraControlVisibility(/* show= */ false);
- }
-
- @Test
- public void testOnCameraTreatmentButtonClicked() {
- mWindowManager.createLayout(true /* show */, true /* hasSizeCompat */,
- CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED);
- clearInvocations(mCompatUILayout);
- mWindowManager.onCameraTreatmentButtonClicked();
-
- verify(mCallback).onCameraControlStateUpdated(
- TASK_ID, CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED);
- verify(mCompatUILayout).updateCameraTreatmentButton(
- CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED);
-
- mWindowManager.onCameraTreatmentButtonClicked();
-
- verify(mCallback).onCameraControlStateUpdated(
- TASK_ID, CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED);
- verify(mCompatUILayout).updateCameraTreatmentButton(
- CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED);
- }
-
- @Test
public void testOnRestartButtonClicked() {
mWindowManager.onRestartButtonClicked();
@@ -309,60 +239,15 @@
@Test
public void testOnRestartButtonLongClicked_showHint() {
// Not create hint popup.
- mWindowManager.mShouldShowSizeCompatHint = false;
- mWindowManager.createLayout(true /* show */, true /* hasSizeCompat */,
- CAMERA_COMPAT_CONTROL_HIDDEN);
+ mWindowManager.mShouldShowHint = false;
+ mWindowManager.createLayout(true /* show */);
verify(mWindowManager).inflateCompatUILayout();
- verify(mCompatUILayout, never()).setSizeCompatHintVisibility(true /* show */);
+ verify(mCompatUILayout).setSizeCompatHintVisibility(false /* show */);
mWindowManager.onRestartButtonLongClicked();
verify(mCompatUILayout).setSizeCompatHintVisibility(true /* show */);
}
- @Test
- public void testOnCamerControlLongClicked_showHint() {
- // Not create hint popup.
- mWindowManager.mShouldShowCameraCompatHint = false;
- mWindowManager.createLayout(true /* show */, false /* hasSizeCompat */,
- CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED);
-
- verify(mWindowManager).inflateCompatUILayout();
- verify(mCompatUILayout, never()).setCameraCompatHintVisibility(true /* show */);
-
- mWindowManager.onCameraButtonLongClicked();
-
- verify(mCompatUILayout).setCameraCompatHintVisibility(true /* show */);
- }
-
- @Test
- public void testCreateCameraCompatControl() {
- // Not create layout if show is false.
- mWindowManager.createLayout(false /* show */, false /* hasSizeCompat */,
- CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED);
-
- verify(mWindowManager, never()).inflateCompatUILayout();
-
- // Not create hint popup.
- mWindowManager.mShouldShowCameraCompatHint = false;
- mWindowManager.createLayout(true /* show */, false /* hasSizeCompat */,
- CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED);
-
- verify(mWindowManager).inflateCompatUILayout();
- verify(mCompatUILayout, never()).setCameraCompatHintVisibility(true /* show */);
- verify(mCompatUILayout).setCameraControlVisibility(true /* show */);
-
- // Create hint popup.
- mWindowManager.release();
- mWindowManager.mShouldShowCameraCompatHint = true;
- mWindowManager.createLayout(true /* show */, false /* hasSizeCompat */,
- CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED);
-
- verify(mWindowManager, times(2)).inflateCompatUILayout();
- assertNotNull(mCompatUILayout);
- verify(mCompatUILayout, times(2)).setCameraControlVisibility(true /* show */);
- assertFalse(mWindowManager.mShouldShowCameraCompatHint);
- }
-
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index 7a53fd1..e9f288d 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -1727,6 +1727,21 @@
|| mUpdateMonitor.isSimPinSecure();
}
+ /**
+ * Whether any of the SIMs on the device are secured with a PIN. If so, the keyguard should not
+ * be dismissable until the PIN is entered, even if the device itself has no lock set.
+ */
+ public boolean isAnySimPinSecure() {
+ for (int i = 0; i < mLastSimStates.size(); i++) {
+ final int key = mLastSimStates.keyAt(i);
+ if (KeyguardUpdateMonitor.isSimPinSecure(mLastSimStates.get(key))) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
public void setSwitchingUser(boolean switching) {
mUpdateMonitor.setSwitchingUser(switching);
}
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java
index e368577..44b4540 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java
@@ -39,13 +39,11 @@
import android.app.ActivityOptions;
import android.app.ExitTransitionCoordinator;
import android.app.ExitTransitionCoordinator.ExitTransitionCallbacks;
-import android.app.ICompatCameraControlCallback;
import android.app.Notification;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
-import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Insets;
import android.graphics.PixelFormat;
@@ -74,7 +72,6 @@
import android.view.ScrollCaptureResponse;
import android.view.SurfaceControl;
import android.view.View;
-import android.view.ViewRootImpl;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowInsets;
@@ -600,35 +597,20 @@
withWindowAttached(() -> {
requestScrollCapture();
mWindow.peekDecorView().getViewRootImpl().setActivityConfigCallback(
- new ViewRootImpl.ActivityConfigCallback() {
- @Override
- public void onConfigurationChanged(Configuration overrideConfig,
- int newDisplayId) {
- if (mConfigChanges.applyNewConfig(mContext.getResources())) {
- // Hide the scroll chip until we know it's available in this
- // orientation
- mScreenshotView.hideScrollChip();
- // Delay scroll capture eval a bit to allow the underlying activity
- // to set up in the new orientation.
- mScreenshotHandler.postDelayed(
- ScreenshotController.this::requestScrollCapture, 150);
- mScreenshotView.updateInsets(
- mWindowManager.getCurrentWindowMetrics()
- .getWindowInsets());
- // Screenshot animation calculations won't be valid anymore,
- // so just end
- if (mScreenshotAnimation != null
- && mScreenshotAnimation.isRunning()) {
- mScreenshotAnimation.end();
- }
+ (overrideConfig, newDisplayId) -> {
+ if (mConfigChanges.applyNewConfig(mContext.getResources())) {
+ // Hide the scroll chip until we know it's available in this orientation
+ mScreenshotView.hideScrollChip();
+ // Delay scroll capture eval a bit to allow the underlying activity
+ // to set up in the new orientation.
+ mScreenshotHandler.postDelayed(this::requestScrollCapture, 150);
+ mScreenshotView.updateInsets(
+ mWindowManager.getCurrentWindowMetrics().getWindowInsets());
+ // screenshot animation calculations won't be valid anymore, so just end
+ if (mScreenshotAnimation != null && mScreenshotAnimation.isRunning()) {
+ mScreenshotAnimation.end();
}
}
- @Override
- public void requestCompatCameraControl(boolean showControl,
- boolean transformationApplied,
- ICompatCameraControlCallback callback) {
- Log.w(TAG, "Unexpected requestCompatCameraControl callback");
- }
});
});
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/NetworkControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/NetworkControllerImpl.java
index 3f5ef48..631a1ca 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/NetworkControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/NetworkControllerImpl.java
@@ -335,6 +335,8 @@
setUserSetupComplete(deviceProvisionedController.isCurrentUserSetup());
}
});
+ // Get initial user setup state
+ setUserSetupComplete(deviceProvisionedController.isCurrentUserSetup());
WifiManager.ScanResultsCallback scanResultsCallback =
new WifiManager.ScanResultsCallback() {
@@ -1000,6 +1002,11 @@
}
@VisibleForTesting
+ boolean isUserSetup() {
+ return mUserSetup;
+ }
+
+ @VisibleForTesting
boolean hasCorrectMobileControllers(List<SubscriptionInfo> allSubscriptions) {
if (allSubscriptions.size() != mMobileSignalControllers.size()) {
return false;
@@ -1144,6 +1151,7 @@
/** */
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
pw.println("NetworkController state:");
+ pw.println(" mUserSetup=" + mUserSetup);
pw.println(" - telephony ------");
pw.print(" hasVoiceCallingFeature()=");
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index 7a68b96..778a1e3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -1354,10 +1354,14 @@
// Things that mean we're not dismissing the keyguard, and should ignore this expansion:
// - Keyguard isn't even visible.
// - Keyguard is visible, but can't be dismissed (swiping up will show PIN/password prompt).
+ // - The SIM is locked, you can't swipe to unlock. If the SIM is locked but there is no
+ // device lock set, canDismissLockScreen returns true even though you should not be able
+ // to dismiss the lock screen until entering the SIM PIN.
// - QS is expanded and we're swiping - swiping up now will hide QS, not dismiss the
// keyguard.
if (!isKeyguardShowing()
|| !mKeyguardStateController.canDismissLockScreen()
+ || mKeyguardViewMediator.isAnySimPinSecure()
|| (mNotificationPanelViewController.isQsExpanded() && trackingTouch)) {
return;
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/connectivity/NetworkControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/connectivity/NetworkControllerBaseTest.java
index 47a11fc..23f3c53 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/connectivity/NetworkControllerBaseTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/connectivity/NetworkControllerBaseTest.java
@@ -23,7 +23,7 @@
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertTrue;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.isA;
@@ -216,8 +216,6 @@
when(mMockProvisionController.isCurrentUserSetup()).thenReturn(true);
doAnswer(invocation -> {
mUserCallback = (DeviceProvisionedListener) invocation.getArguments()[0];
- mUserCallback.onUserSetupChanged();
- mUserCallback.onDeviceProvisionedChanged();
TestableLooper.get(this).processAllMessages();
return null;
}).when(mMockProvisionController).addCallback(any());
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/connectivity/NetworkControllerSignalTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/connectivity/NetworkControllerSignalTest.java
index 73eddd1..6262a9b6 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/connectivity/NetworkControllerSignalTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/connectivity/NetworkControllerSignalTest.java
@@ -35,6 +35,7 @@
import android.telephony.TelephonyManager;
import android.test.suitebuilder.annotation.SmallTest;
import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper;
import android.testing.TestableLooper.RunWithLooper;
import com.android.settingslib.graph.SignalDrawable;
@@ -60,6 +61,72 @@
public class NetworkControllerSignalTest extends NetworkControllerBaseTest {
@Test
+ public void testDeviceProvisioned_userNotSetUp() {
+ // GIVEN - user is not setup
+ when(mMockProvisionController.isCurrentUserSetup()).thenReturn(false);
+
+ // WHEN - a NetworkController is created
+ mNetworkController = new NetworkControllerImpl(mContext,
+ mMockCm,
+ mMockTm,
+ mTelephonyListenerManager,
+ mMockWm,
+ mMockNsm,
+ mMockSm,
+ mConfig,
+ TestableLooper.get(this).getLooper(),
+ mFakeExecutor,
+ mCallbackHandler,
+ mock(AccessPointControllerImpl.class),
+ mock(DataUsageController.class),
+ mMockSubDefaults,
+ mMockProvisionController,
+ mMockBd,
+ mDemoModeController,
+ mCarrierConfigTracker,
+ mFeatureFlags,
+ mock(DumpManager.class)
+ );
+ TestableLooper.get(this).processAllMessages();
+
+ // THEN - NetworkController claims the user is not setup
+ assertFalse("User has not been set up", mNetworkController.isUserSetup());
+ }
+
+ @Test
+ public void testDeviceProvisioned_userSetUp() {
+ // GIVEN - user is not setup
+ when(mMockProvisionController.isCurrentUserSetup()).thenReturn(true);
+
+ // WHEN - a NetworkController is created
+ mNetworkController = new NetworkControllerImpl(mContext,
+ mMockCm,
+ mMockTm,
+ mTelephonyListenerManager,
+ mMockWm,
+ mMockNsm,
+ mMockSm,
+ mConfig,
+ TestableLooper.get(this).getLooper(),
+ mFakeExecutor,
+ mCallbackHandler,
+ mock(AccessPointControllerImpl.class),
+ mock(DataUsageController.class),
+ mMockSubDefaults,
+ mMockProvisionController,
+ mMockBd,
+ mDemoModeController,
+ mCarrierConfigTracker,
+ mFeatureFlags,
+ mock(DumpManager.class)
+ );
+ TestableLooper.get(this).processAllMessages();
+
+ // THEN - NetworkController claims the user is not setup
+ assertTrue("User has been set up", mNetworkController.isUserSetup());
+ }
+
+ @Test
public void testNoIconWithoutMobile() {
// Turn off mobile network support.
when(mMockTm.isDataCapable()).thenReturn(false);
diff --git a/services/core/java/com/android/server/notification/VibratorHelper.java b/services/core/java/com/android/server/notification/VibratorHelper.java
index 0a69aec..449fae1 100644
--- a/services/core/java/com/android/server/notification/VibratorHelper.java
+++ b/services/core/java/com/android/server/notification/VibratorHelper.java
@@ -19,6 +19,7 @@
import android.annotation.Nullable;
import android.content.Context;
import android.content.res.Resources;
+import android.content.res.TypedArray;
import android.media.AudioAttributes;
import android.os.Process;
import android.os.VibrationAttributes;
@@ -39,18 +40,16 @@
private static final long[] DEFAULT_VIBRATE_PATTERN = {0, 250, 250, 250};
private static final int VIBRATE_PATTERN_MAXLEN = 8 * 2 + 1; // up to eight bumps
- private static final int CHIRP_LEVEL_DURATION_MILLIS = 100;
- private static final int DEFAULT_CHIRP_RAMP_DURATION_MILLIS = 100;
- private static final int FALLBACK_CHIRP_RAMP_DURATION_MILLIS = 50;
private final Vibrator mVibrator;
private final long[] mDefaultPattern;
private final long[] mFallbackPattern;
+ @Nullable private final float[] mDefaultPwlePattern;
+ @Nullable private final float[] mFallbackPwlePattern;
public VibratorHelper(Context context) {
mVibrator = context.getSystemService(Vibrator.class);
- mDefaultPattern = getLongArray(
- context.getResources(),
+ mDefaultPattern = getLongArray(context.getResources(),
com.android.internal.R.array.config_defaultNotificationVibePattern,
VIBRATE_PATTERN_MAXLEN,
DEFAULT_VIBRATE_PATTERN);
@@ -58,6 +57,10 @@
R.array.config_notificationFallbackVibePattern,
VIBRATE_PATTERN_MAXLEN,
DEFAULT_VIBRATE_PATTERN);
+ mDefaultPwlePattern = getFloatArray(context.getResources(),
+ com.android.internal.R.array.config_defaultNotificationVibeWaveform);
+ mFallbackPwlePattern = getFloatArray(context.getResources(),
+ com.android.internal.R.array.config_notificationFallbackVibeWaveform);
}
/**
@@ -83,6 +86,50 @@
}
/**
+ * Safely create a {@link VibrationEffect} from given waveform description.
+ *
+ * <p>The waveform is described by a sequence of values for target amplitude, frequency and
+ * duration, that are forwarded to
+ * {@link VibrationEffect.WaveformBuilder#addRamp(float, float, int)}.
+ *
+ * <p>This method returns {@code null} if the pattern is also {@code null} or invalid.
+ *
+ * @param values The list of values describing the waveform as a sequence of target amplitude,
+ * frequency and duration.
+ * @param insistent {@code true} if the vibration should loop until it is cancelled.
+ */
+ @Nullable
+ public static VibrationEffect createPwleWaveformVibration(@Nullable float[] values,
+ boolean insistent) {
+ try {
+ if (values == null) {
+ return null;
+ }
+
+ int length = values.length;
+ // The waveform is described by triples (amplitude, frequency, duration)
+ if ((length == 0) || (length % 3 != 0)) {
+ return null;
+ }
+
+ VibrationEffect.WaveformBuilder waveformBuilder = VibrationEffect.startWaveform();
+ for (int i = 0; i < length; i += 3) {
+ waveformBuilder.addRamp(/* amplitude= */ values[i], /* frequency= */ values[i + 1],
+ /* duration= */ (int) values[i + 2]);
+ }
+
+ if (insistent) {
+ return waveformBuilder.build(/* repeat= */ 0);
+ }
+ return waveformBuilder.build();
+ } catch (IllegalArgumentException e) {
+ Slog.e(TAG, "Error creating vibration PWLE waveform with pattern: "
+ + Arrays.toString(values));
+ }
+ return null;
+ }
+
+ /**
* Vibrate the device with given {@code effect}.
*
* <p>We need to vibrate as "android" so we can breakthrough DND.
@@ -106,7 +153,10 @@
*/
public VibrationEffect createFallbackVibration(boolean insistent) {
if (mVibrator.hasFrequencyControl()) {
- return createChirpVibration(FALLBACK_CHIRP_RAMP_DURATION_MILLIS, insistent);
+ VibrationEffect effect = createPwleWaveformVibration(mFallbackPwlePattern, insistent);
+ if (effect != null) {
+ return effect;
+ }
}
return createWaveformVibration(mFallbackPattern, insistent);
}
@@ -118,29 +168,29 @@
*/
public VibrationEffect createDefaultVibration(boolean insistent) {
if (mVibrator.hasFrequencyControl()) {
- return createChirpVibration(DEFAULT_CHIRP_RAMP_DURATION_MILLIS, insistent);
+ VibrationEffect effect = createPwleWaveformVibration(mDefaultPwlePattern, insistent);
+ if (effect != null) {
+ return effect;
+ }
}
return createWaveformVibration(mDefaultPattern, insistent);
}
- private static VibrationEffect createChirpVibration(int rampDuration, boolean insistent) {
- VibrationEffect.WaveformBuilder waveformBuilder = VibrationEffect.startWaveform()
- .addStep(/* amplitude= */ 0, /* frequency= */ -0.85f, /* duration= */ 0)
- .addRamp(/* amplitude= */ 1, /* frequency= */ -0.25f, rampDuration)
- .addStep(/* amplitude= */ 1, /* frequency= */ -0.25f, CHIRP_LEVEL_DURATION_MILLIS)
- .addRamp(/* amplitude= */ 0, /* frequency= */ -0.85f, rampDuration);
-
- if (insistent) {
- return waveformBuilder
- .addStep(/* amplitude= */ 0, CHIRP_LEVEL_DURATION_MILLIS)
- .build(/* repeat= */ 0);
+ @Nullable
+ private static float[] getFloatArray(Resources resources, int resId) {
+ TypedArray array = resources.obtainTypedArray(resId);
+ try {
+ float[] values = new float[array.length()];
+ for (int i = 0; i < values.length; i++) {
+ values[i] = array.getFloat(i, Float.NaN);
+ if (Float.isNaN(values[i])) {
+ return null;
+ }
+ }
+ return values;
+ } finally {
+ array.recycle();
}
-
- VibrationEffect singleBeat = waveformBuilder.build();
- return VibrationEffect.startComposition()
- .addEffect(singleBeat)
- .addEffect(singleBeat, /* delay= */ CHIRP_LEVEL_DURATION_MILLIS)
- .compose();
}
private static long[] getLongArray(Resources resources, int resId, int maxLength, long[] def) {
diff --git a/services/core/java/com/android/server/powerstats/PowerStatsLogger.java b/services/core/java/com/android/server/powerstats/PowerStatsLogger.java
index ef0079e..ca67597 100644
--- a/services/core/java/com/android/server/powerstats/PowerStatsLogger.java
+++ b/services/core/java/com/android/server/powerstats/PowerStatsLogger.java
@@ -35,7 +35,6 @@
import android.util.proto.ProtoOutputStream;
import com.android.internal.annotations.VisibleForTesting;
-
import com.android.server.powerstats.PowerStatsHALWrapper.IPowerStatsHALWrapper;
import com.android.server.powerstats.ProtoStreamUtils.ChannelUtils;
import com.android.server.powerstats.ProtoStreamUtils.EnergyConsumerResultUtils;
@@ -313,12 +312,12 @@
return mStartWallTime;
}
- public PowerStatsLogger(Context context, File dataStoragePath,
+ public PowerStatsLogger(Context context, Looper looper, File dataStoragePath,
String meterFilename, String meterCacheFilename,
String modelFilename, String modelCacheFilename,
String residencyFilename, String residencyCacheFilename,
IPowerStatsHALWrapper powerStatsHALWrapper) {
- super(Looper.getMainLooper());
+ super(looper);
mStartWallTime = currentTimeMillis() - SystemClock.elapsedRealtime();
if (DEBUG) Slog.d(TAG, "mStartWallTime: " + mStartWallTime);
mPowerStatsHALWrapper = powerStatsHALWrapper;
diff --git a/services/core/java/com/android/server/powerstats/PowerStatsService.java b/services/core/java/com/android/server/powerstats/PowerStatsService.java
index bb52c1d..9953ca8 100644
--- a/services/core/java/com/android/server/powerstats/PowerStatsService.java
+++ b/services/core/java/com/android/server/powerstats/PowerStatsService.java
@@ -28,6 +28,7 @@
import android.os.Environment;
import android.os.Handler;
import android.os.HandlerThread;
+import android.os.Looper;
import android.os.UserHandle;
import android.power.PowerStatsInternal;
import android.util.Slog;
@@ -79,6 +80,9 @@
private StatsPullAtomCallbackImpl mPullAtomCallback;
@Nullable
private PowerStatsInternal mPowerStatsInternal;
+ @Nullable
+ @GuardedBy("this")
+ private Looper mLooper;
@VisibleForTesting
static class Injector {
@@ -127,12 +131,12 @@
}
}
- PowerStatsLogger createPowerStatsLogger(Context context, File dataStoragePath,
- String meterFilename, String meterCacheFilename,
+ PowerStatsLogger createPowerStatsLogger(Context context, Looper looper,
+ File dataStoragePath, String meterFilename, String meterCacheFilename,
String modelFilename, String modelCacheFilename,
String residencyFilename, String residencyCacheFilename,
IPowerStatsHALWrapper powerStatsHALWrapper) {
- return new PowerStatsLogger(context, dataStoragePath,
+ return new PowerStatsLogger(context, looper, dataStoragePath,
meterFilename, meterCacheFilename,
modelFilename, modelCacheFilename,
residencyFilename, residencyCacheFilename,
@@ -229,11 +233,11 @@
mDataStoragePath = mInjector.createDataStoragePath();
// Only start logger and triggers if initialization is successful.
- mPowerStatsLogger = mInjector.createPowerStatsLogger(mContext, mDataStoragePath,
- mInjector.createMeterFilename(), mInjector.createMeterCacheFilename(),
- mInjector.createModelFilename(), mInjector.createModelCacheFilename(),
- mInjector.createResidencyFilename(), mInjector.createResidencyCacheFilename(),
- getPowerStatsHal());
+ mPowerStatsLogger = mInjector.createPowerStatsLogger(mContext, getLooper(),
+ mDataStoragePath, mInjector.createMeterFilename(),
+ mInjector.createMeterCacheFilename(), mInjector.createModelFilename(),
+ mInjector.createModelCacheFilename(), mInjector.createResidencyFilename(),
+ mInjector.createResidencyCacheFilename(), getPowerStatsHal());
mBatteryTrigger = mInjector.createBatteryTrigger(mContext, mPowerStatsLogger);
mTimerTrigger = mInjector.createTimerTrigger(mContext, mPowerStatsLogger);
} else {
@@ -245,6 +249,17 @@
return mInjector.getPowerStatsHALWrapperImpl();
}
+ private Looper getLooper() {
+ synchronized (this) {
+ if (mLooper == null) {
+ HandlerThread thread = new HandlerThread(TAG);
+ thread.start();
+ return thread.getLooper();
+ }
+ return mLooper;
+ }
+ }
+
public PowerStatsService(Context context) {
this(context, new Injector());
}
@@ -260,9 +275,7 @@
private final Handler mHandler;
LocalService() {
- HandlerThread thread = new HandlerThread(TAG);
- thread.start();
- mHandler = new Handler(thread.getLooper());
+ mHandler = new Handler(getLooper());
}
diff --git a/services/core/java/com/android/server/wm/ActivityClientController.java b/services/core/java/com/android/server/wm/ActivityClientController.java
index e9ffcc0..ee72fc8 100644
--- a/services/core/java/com/android/server/wm/ActivityClientController.java
+++ b/services/core/java/com/android/server/wm/ActivityClientController.java
@@ -49,7 +49,6 @@
import android.app.ActivityManager;
import android.app.ActivityTaskManager;
import android.app.IActivityClientController;
-import android.app.ICompatCameraControlCallback;
import android.app.IRequestFinishCallback;
import android.app.PictureInPictureParams;
import android.app.PictureInPictureUiState;
@@ -767,22 +766,6 @@
Binder.restoreCallingIdentity(origId);
}
- @Override
- public void requestCompatCameraControl(IBinder token, boolean showControl,
- boolean transformationApplied, ICompatCameraControlCallback callback) {
- final long origId = Binder.clearCallingIdentity();
- try {
- synchronized (mGlobalLock) {
- final ActivityRecord r = ActivityRecord.isInRootTaskLocked(token);
- if (r != null) {
- r.updateCameraCompatState(showControl, transformationApplied, callback);
- }
- }
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
-
/**
* Checks the state of the system and the activity associated with the given {@param token} to
* verify that picture-in-picture is supported for that activity.
diff --git a/services/core/java/com/android/server/wm/ActivityMetricsLogger.java b/services/core/java/com/android/server/wm/ActivityMetricsLogger.java
index 614c532..f878562 100644
--- a/services/core/java/com/android/server/wm/ActivityMetricsLogger.java
+++ b/services/core/java/com/android/server/wm/ActivityMetricsLogger.java
@@ -61,11 +61,6 @@
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.TYPE_TRANSITION_WARM_LAUNCH;
import static com.android.internal.util.FrameworkStatsLog.APP_COMPAT_STATE_CHANGED__STATE__NOT_LETTERBOXED;
import static com.android.internal.util.FrameworkStatsLog.APP_COMPAT_STATE_CHANGED__STATE__NOT_VISIBLE;
-import static com.android.internal.util.FrameworkStatsLog.CAMERA_COMPAT_CONTROL_EVENT_REPORTED__EVENT__APPEARED_APPLY_TREATMENT;
-import static com.android.internal.util.FrameworkStatsLog.CAMERA_COMPAT_CONTROL_EVENT_REPORTED__EVENT__APPEARED_REVERT_TREATMENT;
-import static com.android.internal.util.FrameworkStatsLog.CAMERA_COMPAT_CONTROL_EVENT_REPORTED__EVENT__CLICKED_APPLY_TREATMENT;
-import static com.android.internal.util.FrameworkStatsLog.CAMERA_COMPAT_CONTROL_EVENT_REPORTED__EVENT__CLICKED_DISMISS;
-import static com.android.internal.util.FrameworkStatsLog.CAMERA_COMPAT_CONTROL_EVENT_REPORTED__EVENT__CLICKED_REVERT_TREATMENT;
import static com.android.server.am.MemoryStatUtil.MemoryStat;
import static com.android.server.am.MemoryStatUtil.readMemoryStatFromFilesystem;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_METRICS;
@@ -78,8 +73,6 @@
import android.annotation.Nullable;
import android.app.ActivityOptions;
import android.app.ActivityOptions.SourceInfo;
-import android.app.TaskInfo;
-import android.app.TaskInfo.CameraCompatControlState;
import android.app.WaitResult;
import android.app.WindowConfiguration.WindowingMode;
import android.content.ComponentName;
@@ -1384,71 +1377,6 @@
}
}
- /**
- * Logs the Camera Compat Control appeared event that corresponds to the given {@code state}
- * with the given {@code packageUid}.
- */
- void logCameraCompatControlAppearedEventReported(@CameraCompatControlState int state,
- int packageUid) {
- switch (state) {
- case TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED:
- logCameraCompatControlEventReported(
- CAMERA_COMPAT_CONTROL_EVENT_REPORTED__EVENT__APPEARED_APPLY_TREATMENT,
- packageUid);
- break;
- case TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED:
- logCameraCompatControlEventReported(
- CAMERA_COMPAT_CONTROL_EVENT_REPORTED__EVENT__APPEARED_REVERT_TREATMENT,
- packageUid);
- break;
- case TaskInfo.CAMERA_COMPAT_CONTROL_HIDDEN:
- // Nothing to log.
- break;
- default:
- Slog.w(TAG, "Unexpected state in logCameraCompatControlAppearedEventReported: "
- + state);
- break;
- }
- }
-
- /**
- * Logs the Camera Compat Control clicked event that corresponds to the given {@code state}
- * with the given {@code packageUid}.
- */
- void logCameraCompatControlClickedEventReported(@CameraCompatControlState int state,
- int packageUid) {
- switch (state) {
- case TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED:
- logCameraCompatControlEventReported(
- CAMERA_COMPAT_CONTROL_EVENT_REPORTED__EVENT__CLICKED_APPLY_TREATMENT,
- packageUid);
- break;
- case TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED:
- logCameraCompatControlEventReported(
- CAMERA_COMPAT_CONTROL_EVENT_REPORTED__EVENT__CLICKED_REVERT_TREATMENT,
- packageUid);
- break;
- case TaskInfo.CAMERA_COMPAT_CONTROL_DISMISSED:
- logCameraCompatControlEventReported(
- CAMERA_COMPAT_CONTROL_EVENT_REPORTED__EVENT__CLICKED_DISMISS,
- packageUid);
- break;
- default:
- Slog.w(TAG, "Unexpected state in logCameraCompatControlAppearedEventReported: "
- + state);
- break;
- }
- }
-
- private void logCameraCompatControlEventReported(int event, int packageUid) {
- FrameworkStatsLog.write(FrameworkStatsLog.CAMERA_COMPAT_CONTROL_EVENT_REPORTED, packageUid,
- event);
- if (DEBUG_METRICS) {
- Slog.i(TAG, String.format("CAMERA_COMPAT_CONTROL_EVENT_REPORTED(%s, %s)", packageUid,
- event));
- }
- }
-
private ArtManagerInternal getArtManagerInternal() {
if (mArtManagerInternal == null) {
// Note that this may be null.
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index 48f81ff..393d101 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -235,12 +235,9 @@
import android.app.Activity;
import android.app.ActivityManager.TaskDescription;
import android.app.ActivityOptions;
-import android.app.ICompatCameraControlCallback;
import android.app.PendingIntent;
import android.app.PictureInPictureParams;
import android.app.ResultInfo;
-import android.app.TaskInfo;
-import android.app.TaskInfo.CameraCompatControlState;
import android.app.WaitResult;
import android.app.WindowConfiguration;
import android.app.servertransaction.ActivityConfigurationChangeItem;
@@ -726,20 +723,6 @@
@Nullable
private Rect mLetterboxBoundsForFixedOrientationAndAspectRatio;
- // State of the Camera app compat control which is used to correct stretched viewfinder
- // in apps that don't handle all possible configurations and changes between them correctly.
- @CameraCompatControlState
- private int mCameraCompatControlState = TaskInfo.CAMERA_COMPAT_CONTROL_HIDDEN;
-
-
- // The callback that allows to ask the calling View to apply the treatment for stretched
- // issues affecting camera viewfinders when the user clicks on the camera compat control.
- @Nullable
- private ICompatCameraControlCallback mCompatCameraControlCallback;
-
- private final boolean mCameraCompatControlEnabled;
- private boolean mCameraCompatControlClickedByUser;
-
// activity is not displayed?
// TODO: rename to mNoDisplay
@VisibleForTesting
@@ -1193,10 +1176,6 @@
}
mLetterboxUiController.dump(pw, prefix);
-
- pw.println(prefix + "mCameraCompatControlState="
- + TaskInfo.cameraCompatControlStateToString(mCameraCompatControlState));
- pw.println(prefix + "mCameraCompatControlEnabled=" + mCameraCompatControlEnabled);
}
static boolean dumpActivity(FileDescriptor fd, PrintWriter pw, int index, ActivityRecord r,
@@ -1596,95 +1575,6 @@
mLetterboxUiController.getLetterboxInnerBounds(outBounds);
}
- void updateCameraCompatState(boolean showControl, boolean transformationApplied,
- ICompatCameraControlCallback callback) {
- if (!isCameraCompatControlEnabled()) {
- // Feature is disabled by config_isCameraCompatControlForStretchedIssuesEnabled.
- return;
- }
- if (mCameraCompatControlClickedByUser && (showControl
- || mCameraCompatControlState == TaskInfo.CAMERA_COMPAT_CONTROL_DISMISSED)) {
- // The user already applied treatment on this activity or dismissed control.
- // Respecting their choice.
- return;
- }
- mCompatCameraControlCallback = callback;
- int newCameraCompatControlState = !showControl
- ? TaskInfo.CAMERA_COMPAT_CONTROL_HIDDEN
- : transformationApplied
- ? TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED
- : TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED;
- boolean changed = setCameraCompatControlState(newCameraCompatControlState);
- if (!changed) {
- return;
- }
- mTaskSupervisor.getActivityMetricsLogger().logCameraCompatControlAppearedEventReported(
- newCameraCompatControlState, info.applicationInfo.uid);
- if (newCameraCompatControlState == TaskInfo.CAMERA_COMPAT_CONTROL_HIDDEN) {
- mCameraCompatControlClickedByUser = false;
- mCompatCameraControlCallback = null;
- }
- // Trigger TaskInfoChanged to update the camera compat UI.
- getTask().dispatchTaskInfoChangedIfNeeded(true /* force */);
- }
-
- void updateCameraCompatStateFromUser(@CameraCompatControlState int state) {
- if (!isCameraCompatControlEnabled()) {
- // Feature is disabled by config_isCameraCompatControlForStretchedIssuesEnabled.
- return;
- }
- if (state == TaskInfo.CAMERA_COMPAT_CONTROL_HIDDEN) {
- Slog.w(TAG, "Unexpected hidden state in updateCameraCompatState");
- return;
- }
- boolean changed = setCameraCompatControlState(state);
- mCameraCompatControlClickedByUser = true;
- if (!changed) {
- return;
- }
- mTaskSupervisor.getActivityMetricsLogger().logCameraCompatControlClickedEventReported(
- state, info.applicationInfo.uid);
- if (state == TaskInfo.CAMERA_COMPAT_CONTROL_DISMISSED) {
- mCompatCameraControlCallback = null;
- return;
- }
- if (mCompatCameraControlCallback == null) {
- Slog.w(TAG, "Callback for a camera compat control is null");
- return;
- }
- try {
- if (state == TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED) {
- mCompatCameraControlCallback.applyCameraCompatTreatment();
- } else {
- mCompatCameraControlCallback.revertCameraCompatTreatment();
- }
- } catch (RemoteException e) {
- Slog.e(TAG, "Unable to apply or revert camera compat treatment", e);
- }
- }
-
- private boolean setCameraCompatControlState(@CameraCompatControlState int state) {
- if (!isCameraCompatControlEnabled()) {
- // Feature is disabled by config_isCameraCompatControlForStretchedIssuesEnabled.
- return false;
- }
- if (mCameraCompatControlState != state) {
- mCameraCompatControlState = state;
- return true;
- }
- return false;
- }
-
- @CameraCompatControlState
- int getCameraCompatControlState() {
- return mCameraCompatControlState;
- }
-
- @VisibleForTesting
- boolean isCameraCompatControlEnabled() {
- return mCameraCompatControlEnabled;
- }
-
/**
* @return {@code true} if bar shown within a given rectangle is allowed to be fully transparent
* when the current activity is displayed.
@@ -1946,8 +1836,6 @@
taskDescription = _taskDescription;
mLetterboxUiController = new LetterboxUiController(mWmService, this);
- mCameraCompatControlEnabled = mWmService.mContext.getResources()
- .getBoolean(R.bool.config_isCameraCompatControlForStretchedIssuesEnabled);
if (_createTime > 0) {
createTime = _createTime;
diff --git a/services/core/java/com/android/server/wm/LetterboxConfiguration.java b/services/core/java/com/android/server/wm/LetterboxConfiguration.java
index 212a036..e8490c5 100644
--- a/services/core/java/com/android/server/wm/LetterboxConfiguration.java
+++ b/services/core/java/com/android/server/wm/LetterboxConfiguration.java
@@ -174,7 +174,7 @@
* Overrides corners raidus for activities presented in the letterbox mode. If given value < 0,
* both it and a value of {@link
* com.android.internal.R.integer.config_letterboxActivityCornersRadius} will be ignored and
- * and corners of the activity won't be rounded.
+ * corners of the activity won't be rounded.
*/
void setLetterboxActivityCornersRadius(int cornersRadius) {
mLetterboxActivityCornersRadius = cornersRadius;
diff --git a/services/core/java/com/android/server/wm/LetterboxUiController.java b/services/core/java/com/android/server/wm/LetterboxUiController.java
index 7d07357..8866343 100644
--- a/services/core/java/com/android/server/wm/LetterboxUiController.java
+++ b/services/core/java/com/android/server/wm/LetterboxUiController.java
@@ -150,7 +150,7 @@
if (mLetterbox == null) {
mLetterbox = new Letterbox(() -> mActivityRecord.makeChildSurface(null),
mActivityRecord.mWmService.mTransactionFactory,
- mLetterboxConfiguration::isLetterboxActivityCornersRounded,
+ this::shouldLetterboxHaveRoundedCorners,
this::getLetterboxBackgroundColor,
this::hasWallpaperBackgroudForLetterbox,
this::getLetterboxWallpaperBlurRadius,
@@ -175,6 +175,13 @@
}
}
+ private boolean shouldLetterboxHaveRoundedCorners() {
+ // TODO(b/214030873): remove once background is drawn for transparent activities
+ // Letterbox shouldn't have rounded corners if the activity is transparent
+ return mLetterboxConfiguration.isLetterboxActivityCornersRounded()
+ && mActivityRecord.fillsParent();
+ }
+
float getHorizontalPositionMultiplier(Configuration parentConfiguration) {
// Don't check resolved configuration because it may not be updated yet during
// configuration change.
@@ -257,8 +264,6 @@
@VisibleForTesting
boolean shouldShowLetterboxUi(WindowState mainWindow) {
return isSurfaceReadyAndVisible(mainWindow) && mainWindow.areAppWindowBoundsLetterboxed()
- // Check that an activity isn't transparent.
- && mActivityRecord.fillsParent()
// Check for FLAG_SHOW_WALLPAPER explicitly instead of using
// WindowContainer#showWallpaper because the later will return true when this
// activity is using blurred wallpaper for letterbox backgroud.
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index 33235d0..2231ebd 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -3460,18 +3460,11 @@
info.topActivityInfo = mReuseActivitiesReport.top != null
? mReuseActivitiesReport.top.info
: null;
-
- boolean isTopActivityResumed = mReuseActivitiesReport.top != null
- && mReuseActivitiesReport.top.getOrganizedTask() == this
- && mReuseActivitiesReport.top.isState(RESUMED);
// Whether the direct top activity is in size compat mode on foreground.
- info.topActivityInSizeCompat = isTopActivityResumed
- && mReuseActivitiesReport.top.inSizeCompatMode();
- // Whether the direct top activity requested showing camera compat control.
- info.cameraCompatControlState = isTopActivityResumed
- ? mReuseActivitiesReport.top.getCameraCompatControlState()
- : TaskInfo.CAMERA_COMPAT_CONTROL_HIDDEN;
-
+ info.topActivityInSizeCompat = mReuseActivitiesReport.top != null
+ && mReuseActivitiesReport.top.getOrganizedTask() == this
+ && mReuseActivitiesReport.top.inSizeCompatMode()
+ && mReuseActivitiesReport.top.isState(RESUMED);
info.launchCookies.clear();
info.addLaunchCookie(mLaunchCookie);
forAllActivities(r -> {
diff --git a/services/core/java/com/android/server/wm/TaskOrganizerController.java b/services/core/java/com/android/server/wm/TaskOrganizerController.java
index 037d582..3d5f988 100644
--- a/services/core/java/com/android/server/wm/TaskOrganizerController.java
+++ b/services/core/java/com/android/server/wm/TaskOrganizerController.java
@@ -16,8 +16,6 @@
package com.android.server.wm;
-import static android.app.TaskInfo.cameraCompatControlStateToString;
-
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_WINDOW_ORGANIZER;
import static com.android.server.wm.ActivityTaskManagerService.enforceTaskPermission;
import static com.android.server.wm.DisplayContent.IME_TARGET_LAYERING;
@@ -933,35 +931,6 @@
}
}
- @Override
- public void updateCameraCompatControlState(WindowContainerToken token, int state) {
- enforceTaskPermission("updateCameraCompatControlState()");
- final long origId = Binder.clearCallingIdentity();
- try {
- synchronized (mGlobalLock) {
- final WindowContainer wc = WindowContainer.fromBinder(token.asBinder());
- if (wc == null) {
- Slog.w(TAG, "Could not resolve window from token");
- return;
- }
- final Task task = wc.asTask();
- if (task == null) {
- Slog.w(TAG, "Could not resolve task from token");
- return;
- }
- ProtoLog.v(WM_DEBUG_WINDOW_ORGANIZER,
- "Update camera compat control state to %s for taskId=%d",
- cameraCompatControlStateToString(state), task.mTaskId);
- final ActivityRecord activity = task.getTopNonFinishingActivity();
- if (activity != null) {
- activity.updateCameraCompatStateFromUser(state);
- }
- }
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
-
public boolean handleInterceptBackPressedOnTaskRoot(Task task) {
if (task == null || !task.isOrganized()
|| !mInterceptBackPressedOnRootTasks.contains(task.mTaskId)) {
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 41e605b..774a485 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -4003,6 +4003,10 @@
final CallerIdentity caller = getCallerIdentity();
Preconditions.checkCallAuthorization(hasFullCrossUsersPermission(caller, userHandle));
+ // System caller can query policy for a particular admin.
+ Preconditions.checkCallAuthorization(
+ who == null || isCallingFromPackage(who.getPackageName(), caller.getUid())
+ || isSystemUid(caller));
synchronized (getLockObject()) {
int mode = PASSWORD_QUALITY_UNSPECIFIED;
@@ -4218,7 +4222,7 @@
}
Preconditions.checkArgumentNonnegative(userHandle, "Invalid userId");
- final CallerIdentity caller = getCallerIdentity();
+ final CallerIdentity caller = getCallerIdentity(who);
Preconditions.checkCallAuthorization(hasFullCrossUsersPermission(caller, userHandle));
synchronized (getLockObject()) {
@@ -4368,7 +4372,7 @@
}
Preconditions.checkArgumentNonnegative(userHandle, "Invalid userId");
- final CallerIdentity caller = getCallerIdentity();
+ final CallerIdentity caller = getCallerIdentity(who);
Preconditions.checkCallAuthorization(hasFullCrossUsersPermission(caller, userHandle));
synchronized (getLockObject()) {
@@ -4581,7 +4585,7 @@
}
Preconditions.checkArgumentNonnegative(userHandle, "Invalid userId");
- final CallerIdentity caller = getCallerIdentity();
+ final CallerIdentity caller = getCallerIdentity(who);
Preconditions.checkCallAuthorization(hasFullCrossUsersPermission(caller, userHandle));
synchronized (getLockObject()) {
@@ -4999,6 +5003,10 @@
final CallerIdentity caller = getCallerIdentity();
Preconditions.checkCallAuthorization(hasFullCrossUsersPermission(caller, userHandle));
+ // System caller can query policy for a particular admin.
+ Preconditions.checkCallAuthorization(
+ who == null || isCallingFromPackage(who.getPackageName(), caller.getUid())
+ || isSystemUid(caller));
synchronized (getLockObject()) {
ActiveAdmin admin = (who != null)
@@ -5310,6 +5318,10 @@
final CallerIdentity caller = getCallerIdentity();
Preconditions.checkCallAuthorization(hasFullCrossUsersPermission(caller, userHandle));
+ // System caller can query policy for a particular admin.
+ Preconditions.checkCallAuthorization(
+ who == null || isCallingFromPackage(who.getPackageName(), caller.getUid())
+ || isSystemUid(caller));
synchronized (getLockObject()) {
if (who != null) {
@@ -5387,7 +5399,7 @@
}
Preconditions.checkArgumentNonnegative(userId, "Invalid userId");
- final CallerIdentity caller = getCallerIdentity();
+ final CallerIdentity caller = getCallerIdentity(who);
Preconditions.checkCallAuthorization(hasFullCrossUsersPermission(caller, userId));
if (!mLockPatternUtils.hasSecureLockScreen()) {
@@ -7452,7 +7464,8 @@
Preconditions.checkArgumentNonnegative(userHandle, "Invalid userId");
final CallerIdentity caller = getCallerIdentity();
- Preconditions.checkCallAuthorization(hasFullCrossUsersPermission(caller, userHandle));
+ Preconditions.checkCallAuthorization(
+ hasFullCrossUsersPermission(caller, userHandle) && isSystemUid(caller));
synchronized (getLockObject()) {
DevicePolicyData policy = getUserData(UserHandle.USER_SYSTEM);
@@ -7730,6 +7743,10 @@
if (!mHasFeature) {
return false;
}
+
+ final CallerIdentity caller = getCallerIdentity(who);
+ Preconditions.checkCallAuthorization(hasFullCrossUsersPermission(caller, userHandle));
+
if (parent) {
Preconditions.checkCallAuthorization(
isProfileOwnerOfOrganizationOwnedDevice(getCallerIdentity().getUserId()));
@@ -9950,7 +9967,7 @@
Objects.requireNonNull(agent, "agent null");
Preconditions.checkArgumentNonnegative(userHandle, "Invalid userId");
- final CallerIdentity caller = getCallerIdentity();
+ final CallerIdentity caller = getCallerIdentity(admin);
Preconditions.checkCallAuthorization(hasFullCrossUsersPermission(caller, userHandle));
synchronized (getLockObject()) {
diff --git a/services/tests/servicestests/src/com/android/server/powerstats/PowerStatsServiceTest.java b/services/tests/servicestests/src/com/android/server/powerstats/PowerStatsServiceTest.java
index 26b34fd..304fe5a 100644
--- a/services/tests/servicestests/src/com/android/server/powerstats/PowerStatsServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/powerstats/PowerStatsServiceTest.java
@@ -30,6 +30,7 @@
import android.hardware.power.stats.State;
import android.hardware.power.stats.StateResidency;
import android.hardware.power.stats.StateResidencyResult;
+import android.os.Looper;
import androidx.test.InstrumentationRegistry;
@@ -145,12 +146,12 @@
}
@Override
- PowerStatsLogger createPowerStatsLogger(Context context, File dataStoragePath,
- String meterFilename, String meterCacheFilename,
+ PowerStatsLogger createPowerStatsLogger(Context context, Looper looper,
+ File dataStoragePath, String meterFilename, String meterCacheFilename,
String modelFilename, String modelCacheFilename,
String residencyFilename, String residencyCacheFilename,
IPowerStatsHALWrapper powerStatsHALWrapper) {
- mPowerStatsLogger = new PowerStatsLogger(context, dataStoragePath,
+ mPowerStatsLogger = new PowerStatsLogger(context, looper, dataStoragePath,
meterFilename, meterCacheFilename,
modelFilename, modelCacheFilename,
residencyFilename, residencyCacheFilename,
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/VibratorHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/VibratorHelperTest.java
index c77a474..8bc0c6c 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/VibratorHelperTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/VibratorHelperTest.java
@@ -40,7 +40,10 @@
@RunWith(AndroidJUnit4.class)
public class VibratorHelperTest extends UiServiceTestCase {
+ // OFF/ON vibration pattern
private static final long[] CUSTOM_PATTERN = new long[] { 100, 200, 300, 400 };
+ // (amplitude, frequency, duration) triples list
+ private static final float[] PWLE_PATTERN = new float[] { 1, 0, 100 };
@Mock private Vibrator mVibrator;
@@ -58,12 +61,16 @@
public void createWaveformVibration_insistent_createsRepeatingVibration() {
assertRepeatingVibration(
VibratorHelper.createWaveformVibration(CUSTOM_PATTERN, /* insistent= */ true));
+ assertRepeatingVibration(
+ VibratorHelper.createPwleWaveformVibration(PWLE_PATTERN, /* insistent= */ true));
}
@Test
public void createWaveformVibration_nonInsistent_createsSingleShotVibration() {
assertSingleVibration(
VibratorHelper.createWaveformVibration(CUSTOM_PATTERN, /* insistent= */ false));
+ assertSingleVibration(
+ VibratorHelper.createPwleWaveformVibration(PWLE_PATTERN, /* insistent= */ false));
}
@Test
@@ -71,6 +78,11 @@
assertNull(VibratorHelper.createWaveformVibration(null, false));
assertNull(VibratorHelper.createWaveformVibration(new long[0], false));
assertNull(VibratorHelper.createWaveformVibration(new long[] { 0, 0 }, false));
+
+ assertNull(VibratorHelper.createPwleWaveformVibration(null, false));
+ assertNull(VibratorHelper.createPwleWaveformVibration(new float[0], false));
+ assertNull(VibratorHelper.createPwleWaveformVibration(new float[] { 0 }, false));
+ assertNull(VibratorHelper.createPwleWaveformVibration(new float[] { 0, 0, 0 }, false));
}
@Test
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
index a9a603b..9a68b5f 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
@@ -16,10 +16,6 @@
package com.android.server.wm;
-import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_DISMISSED;
-import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_HIDDEN;
-import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED;
-import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
@@ -107,7 +103,6 @@
import static org.mockito.Mockito.never;
import android.app.ActivityOptions;
-import android.app.ICompatCameraControlCallback;
import android.app.servertransaction.ActivityConfigurationChangeItem;
import android.app.servertransaction.ClientTransaction;
import android.app.servertransaction.DestroyActivityItem;
@@ -3103,188 +3098,6 @@
eq(null));
}
- @Test
- public void testUpdateCameraCompatState_flagIsEnabled_controlStateIsUpdated() {
- final ActivityRecord activity = createActivityWithTask();
- // Mock a flag being enabled.
- doReturn(true).when(activity).isCameraCompatControlEnabled();
-
- activity.updateCameraCompatState(/* showControl */ true,
- /* transformationApplied */ false, /* callback */ null);
-
- assertEquals(activity.getCameraCompatControlState(),
- CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED);
-
- activity.updateCameraCompatState(/* showControl */ true,
- /* transformationApplied */ true, /* callback */ null);
-
- assertEquals(activity.getCameraCompatControlState(),
- CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED);
-
- activity.updateCameraCompatState(/* showControl */ false,
- /* transformationApplied */ false, /* callback */ null);
-
- assertEquals(activity.getCameraCompatControlState(), CAMERA_COMPAT_CONTROL_HIDDEN);
-
- activity.updateCameraCompatState(/* showControl */ false,
- /* transformationApplied */ true, /* callback */ null);
-
- assertEquals(activity.getCameraCompatControlState(), CAMERA_COMPAT_CONTROL_HIDDEN);
- }
-
- @Test
- public void testUpdateCameraCompatState_flagIsDisabled_controlStateIsHidden() {
- final ActivityRecord activity = createActivityWithTask();
- // Mock a flag being disabled.
- doReturn(false).when(activity).isCameraCompatControlEnabled();
-
- activity.updateCameraCompatState(/* showControl */ true,
- /* transformationApplied */ false, /* callback */ null);
-
- assertEquals(activity.getCameraCompatControlState(), CAMERA_COMPAT_CONTROL_HIDDEN);
-
- activity.updateCameraCompatState(/* showControl */ true,
- /* transformationApplied */ true, /* callback */ null);
-
- assertEquals(activity.getCameraCompatControlState(), CAMERA_COMPAT_CONTROL_HIDDEN);
- }
-
- @Test
- public void testUpdateCameraCompatStateFromUser_clickedOnDismiss() throws RemoteException {
- final ActivityRecord activity = createActivityWithTask();
- // Mock a flag being enabled.
- doReturn(true).when(activity).isCameraCompatControlEnabled();
-
- ICompatCameraControlCallback callback = getCompatCameraControlCallback();
- spyOn(callback);
- activity.updateCameraCompatState(/* showControl */ true,
- /* transformationApplied */ false, callback);
-
- assertEquals(activity.getCameraCompatControlState(),
- CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED);
-
- // Clicking on the button.
- activity.updateCameraCompatStateFromUser(CAMERA_COMPAT_CONTROL_DISMISSED);
-
- verify(callback, never()).revertCameraCompatTreatment();
- verify(callback, never()).applyCameraCompatTreatment();
- assertEquals(activity.getCameraCompatControlState(), CAMERA_COMPAT_CONTROL_DISMISSED);
-
- // All following updates are ignored.
- activity.updateCameraCompatState(/* showControl */ true,
- /* transformationApplied */ false, /* callback */ null);
-
- assertEquals(activity.getCameraCompatControlState(), CAMERA_COMPAT_CONTROL_DISMISSED);
-
- activity.updateCameraCompatState(/* showControl */ true,
- /* transformationApplied */ true, /* callback */ null);
-
- assertEquals(activity.getCameraCompatControlState(), CAMERA_COMPAT_CONTROL_DISMISSED);
-
- activity.updateCameraCompatState(/* showControl */ false,
- /* transformationApplied */ true, /* callback */ null);
-
- assertEquals(activity.getCameraCompatControlState(), CAMERA_COMPAT_CONTROL_DISMISSED);
- }
-
- @Test
- public void testUpdateCameraCompatStateFromUser_clickedOnApplyTreatment()
- throws RemoteException {
- final ActivityRecord activity = createActivityWithTask();
- // Mock a flag being enabled.
- doReturn(true).when(activity).isCameraCompatControlEnabled();
-
- ICompatCameraControlCallback callback = getCompatCameraControlCallback();
- spyOn(callback);
- activity.updateCameraCompatState(/* showControl */ true,
- /* transformationApplied */ false, callback);
-
- assertEquals(activity.getCameraCompatControlState(),
- CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED);
-
- // Clicking on the button.
- activity.updateCameraCompatStateFromUser(CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED);
-
- verify(callback, never()).revertCameraCompatTreatment();
- verify(callback).applyCameraCompatTreatment();
- assertEquals(activity.getCameraCompatControlState(),
- CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED);
-
- // Request from the client to show the control are ignored respecting the user choice.
- activity.updateCameraCompatState(/* showControl */ true,
- /* transformationApplied */ false, /* callback */ null);
-
- assertEquals(activity.getCameraCompatControlState(),
- CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED);
-
- // Request from the client to hide the control is respected.
- activity.updateCameraCompatState(/* showControl */ false,
- /* transformationApplied */ true, /* callback */ null);
-
- assertEquals(activity.getCameraCompatControlState(), CAMERA_COMPAT_CONTROL_HIDDEN);
-
- // Request from the client to show the control again is respected.
- activity.updateCameraCompatState(/* showControl */ true,
- /* transformationApplied */ false, /* callback */ null);
-
- assertEquals(activity.getCameraCompatControlState(),
- CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED);
- }
-
- @Test
- public void testUpdateCameraCompatStateFromUser_clickedOnRevertTreatment()
- throws RemoteException {
- final ActivityRecord activity = createActivityWithTask();
- // Mock a flag being enabled.
- doReturn(true).when(activity).isCameraCompatControlEnabled();
-
- ICompatCameraControlCallback callback = getCompatCameraControlCallback();
- spyOn(callback);
- activity.updateCameraCompatState(/* showControl */ true,
- /* transformationApplied */ true, callback);
-
- assertEquals(activity.getCameraCompatControlState(),
- CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED);
-
- // Clicking on the button.
- activity.updateCameraCompatStateFromUser(CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED);
-
- verify(callback).revertCameraCompatTreatment();
- verify(callback, never()).applyCameraCompatTreatment();
- assertEquals(activity.getCameraCompatControlState(),
- CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED);
-
- // Request from the client to show the control are ignored respecting the user choice.
- activity.updateCameraCompatState(/* showControl */ true,
- /* transformationApplied */ true, /* callback */ null);
-
- assertEquals(activity.getCameraCompatControlState(),
- CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED);
-
- // Request from the client to hide the control is respected.
- activity.updateCameraCompatState(/* showControl */ false,
- /* transformationApplied */ true, /* callback */ null);
-
- assertEquals(activity.getCameraCompatControlState(), CAMERA_COMPAT_CONTROL_HIDDEN);
-
- // Request from the client to show the control again is respected.
- activity.updateCameraCompatState(/* showControl */ true,
- /* transformationApplied */ true, /* callback */ null);
-
- assertEquals(activity.getCameraCompatControlState(),
- CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED);
- }
-
- private ICompatCameraControlCallback getCompatCameraControlCallback() {
- return new ICompatCameraControlCallback.Stub() {
- @Override
- public void applyCameraCompatTreatment() {}
-
- @Override
- public void revertCameraCompatTreatment() {}
- };
- }
-
private void assertHasStartingWindow(ActivityRecord atoken) {
assertNotNull(atoken.mStartingSurface);
assertNotNull(atoken.mStartingData);