Merge "Merge "Set min_sdk_version for SystemUISharedLib" am: ce2417fa9c" into stage-aosp-master am: 0bda334b4f
am: 1918e5cb87
Change-Id: I81f2cb5421671c310d01819b375ff3866dc6046e
diff --git a/api/test-current.txt b/api/test-current.txt
index 9fa7f99..30b9e7a 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -2346,6 +2346,7 @@
field public static final String LOCATION_IGNORE_SETTINGS_PACKAGE_WHITELIST = "location_ignore_settings_package_whitelist";
field public static final String LOW_POWER_MODE = "low_power";
field public static final String LOW_POWER_MODE_STICKY = "low_power_sticky";
+ field public static final String NOTIFICATION_BUBBLES = "notification_bubbles";
field public static final String OVERLAY_DISPLAY_DEVICES = "overlay_display_devices";
field public static final String USE_OPEN_WIFI_PACKAGE = "use_open_wifi_package";
}
@@ -2369,7 +2370,7 @@
field public static final String LOCATION_ACCESS_CHECK_DELAY_MILLIS = "location_access_check_delay_millis";
field public static final String LOCATION_ACCESS_CHECK_INTERVAL_MILLIS = "location_access_check_interval_millis";
field public static final String NOTIFICATION_BADGING = "notification_badging";
- field public static final String NOTIFICATION_BUBBLES = "notification_bubbles";
+ field @Deprecated public static final String NOTIFICATION_BUBBLES = "notification_bubbles";
field @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public static final String SYNC_PARENT_SOUNDS = "sync_parent_sounds";
field public static final String USER_SETUP_COMPLETE = "user_setup_complete";
field public static final String VOICE_INTERACTION_SERVICE = "voice_interaction_service";
diff --git a/cmds/incidentd/src/WorkDirectory.cpp b/cmds/incidentd/src/WorkDirectory.cpp
index e826061..7e7c642 100644
--- a/cmds/incidentd/src/WorkDirectory.cpp
+++ b/cmds/incidentd/src/WorkDirectory.cpp
@@ -664,7 +664,7 @@
nanosleep(&spec, nullptr);
}
clock_gettime(CLOCK_REALTIME, &spec);
- timestampNs = (spec.tv_sec) * 1000 + spec.tv_nsec;
+ timestampNs = int64_t(spec.tv_sec) * 1000 + spec.tv_nsec;
} while (file_exists_locked(timestampNs));
return timestampNs;
}
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index 847c298..32d90b7 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -5927,7 +5927,8 @@
optional bool is_ongoing = 10;
// Whether the bubble is produced by an app running in foreground.
- optional bool is_foreground = 11;
+ // This is deprecated and the value should be ignored.
+ optional bool is_foreground = 11 [deprecated = true];
}
/**
diff --git a/cmds/statsd/src/main.cpp b/cmds/statsd/src/main.cpp
index 68082c2..42132ee 100644
--- a/cmds/statsd/src/main.cpp
+++ b/cmds/statsd/src/main.cpp
@@ -78,7 +78,7 @@
ps->giveThreadPoolName();
IPCThreadState::self()->disableBackgroundScheduling(true);
- ::android::hardware::configureRpcThreadpool(1 /*threads*/, false /*willJoin*/);
+ ::android::hardware::configureRpcThreadpool(4 /*threads*/, false /*willJoin*/);
std::shared_ptr<LogEventQueue> eventQueue =
std::make_shared<LogEventQueue>(2000 /*buffer limit. Buffer is NOT pre-allocated*/);
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index f5b0b59..5bc0647 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -146,6 +146,7 @@
import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -943,6 +944,10 @@
/** @hide */
boolean mEnterAnimationComplete;
+ /** Track last dispatched multi-window and PiP mode to client, internal debug purpose **/
+ private Boolean mLastDispatchedIsInMultiWindowMode;
+ private Boolean mLastDispatchedIsInPictureInPictureMode;
+
private static native String getDlWarning();
/** Return the intent that started this activity. */
@@ -3656,6 +3661,22 @@
return false;
}
+ private static final class RequestFinishCallback extends IRequestFinishCallback.Stub {
+ private final WeakReference<Activity> mActivityRef;
+
+ RequestFinishCallback(WeakReference<Activity> activityRef) {
+ mActivityRef = activityRef;
+ }
+
+ @Override
+ public void requestFinish() {
+ Activity activity = mActivityRef.get();
+ if (activity != null) {
+ activity.mHandler.post(activity::finishAfterTransition);
+ }
+ }
+ }
+
/**
* Called when the activity has detected the user's press of the back
* key. The default implementation simply finishes the current activity,
@@ -3681,11 +3702,7 @@
// while at the root of the task. This call allows ActivityTaskManager
// to intercept or defer finishing.
ActivityTaskManager.getService().onBackPressedOnTaskRoot(mToken,
- new IRequestFinishCallback.Stub() {
- public void requestFinish() {
- mHandler.post(() -> finishAfterTransition());
- }
- });
+ new RequestFinishCallback(new WeakReference<>(this)));
} catch (RemoteException e) {
finishAfterTransition();
}
@@ -6986,6 +7003,10 @@
writer.print(mResumed); writer.print(" mStopped=");
writer.print(mStopped); writer.print(" mFinished=");
writer.println(mFinished);
+ writer.print(innerPrefix); writer.print("mLastDispatchedIsInMultiWindowMode=");
+ writer.print(mLastDispatchedIsInMultiWindowMode);
+ writer.print(" mLastDispatchedIsInPictureInPictureMode=");
+ writer.println(mLastDispatchedIsInPictureInPictureMode);
writer.print(innerPrefix); writer.print("mChangingConfigurations=");
writer.println(mChangingConfigurations);
writer.print(innerPrefix); writer.print("mCurrentConfig=");
@@ -8065,6 +8086,7 @@
if (mWindow != null) {
mWindow.onMultiWindowModeChanged();
}
+ mLastDispatchedIsInMultiWindowMode = isInMultiWindowMode;
onMultiWindowModeChanged(isInMultiWindowMode, newConfig);
}
@@ -8077,6 +8099,7 @@
if (mWindow != null) {
mWindow.onPictureInPictureModeChanged(isInPictureInPictureMode);
}
+ mLastDispatchedIsInPictureInPictureMode = isInPictureInPictureMode;
onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig);
}
diff --git a/core/java/android/app/ActivityView.java b/core/java/android/app/ActivityView.java
index 3bf659b..2b4ff01 100644
--- a/core/java/android/app/ActivityView.java
+++ b/core/java/android/app/ActivityView.java
@@ -120,7 +120,10 @@
mActivityTaskManager = ActivityTaskManager.getService();
mSurfaceView = new SurfaceView(context);
- mSurfaceView.setAlpha(0f);
+ // Since ActivityView#getAlpha has been overridden, we should use parent class's alpha
+ // as master to synchronize surface view's alpha value.
+ mSurfaceView.setAlpha(super.getAlpha());
+ mSurfaceView.setUseAlpha();
mSurfaceCallback = new SurfaceCallback();
mSurfaceView.getHolder().addCallback(mSurfaceCallback);
addView(mSurfaceView);
@@ -347,9 +350,20 @@
mSurfaceView.layout(0 /* left */, 0 /* top */, r - l /* right */, b - t /* bottom */);
}
+ /**
+ * Sets the alpha value when the content of {@link SurfaceView} needs to show or hide.
+ * <p>Note: The surface view may ignore the alpha value in some cases. Refer to
+ * {@link SurfaceView#setAlpha} for more details.
+ *
+ * @param alpha The opacity of the view.
+ */
@Override
public void setAlpha(float alpha) {
- mSurfaceView.setAlpha(alpha);
+ super.setAlpha(alpha);
+
+ if (mSurfaceView != null) {
+ mSurfaceView.setAlpha(alpha);
+ }
}
@Override
diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java
index 8cae56d..c5ead79 100644
--- a/core/java/android/app/AppOpsManager.java
+++ b/core/java/android/app/AppOpsManager.java
@@ -834,9 +834,12 @@
public static final int OP_ACCESS_ACCESSIBILITY = 88;
/** @hide Read the device identifiers (IMEI / MEID, IMSI, SIM / Build serial) */
public static final int OP_READ_DEVICE_IDENTIFIERS = 89;
+ /** @hide Read location metadata from media */
+ public static final int OP_ACCESS_MEDIA_LOCATION = 90;
+
/** @hide */
@UnsupportedAppUsage
- public static final int _NUM_OP = 90;
+ public static final int _NUM_OP = 91;
/** Access to coarse location information. */
public static final String OPSTR_COARSE_LOCATION = "android:coarse_location";
@@ -1107,6 +1110,9 @@
@TestApi
@SystemApi
public static final String OPSTR_LEGACY_STORAGE = "android:legacy_storage";
+ /** @hide Read location metadata from media */
+ public static final String OPSTR_ACCESS_MEDIA_LOCATION = "android:access_media_location";
+
/** @hide Interact with accessibility. */
@SystemApi
public static final String OPSTR_ACCESS_ACCESSIBILITY = "android:access_accessibility";
@@ -1134,6 +1140,7 @@
// Storage
OP_READ_EXTERNAL_STORAGE,
OP_WRITE_EXTERNAL_STORAGE,
+ OP_ACCESS_MEDIA_LOCATION,
// Location
OP_COARSE_LOCATION,
OP_FINE_LOCATION,
@@ -1273,6 +1280,7 @@
OP_LEGACY_STORAGE, // LEGACY_STORAGE
OP_ACCESS_ACCESSIBILITY, // ACCESS_ACCESSIBILITY
OP_READ_DEVICE_IDENTIFIERS, // READ_DEVICE_IDENTIFIERS
+ OP_ACCESS_MEDIA_LOCATION, // ACCESS_MEDIA_LOCATION
};
/**
@@ -1369,6 +1377,7 @@
OPSTR_LEGACY_STORAGE,
OPSTR_ACCESS_ACCESSIBILITY,
OPSTR_READ_DEVICE_IDENTIFIERS,
+ OPSTR_ACCESS_MEDIA_LOCATION,
};
/**
@@ -1466,6 +1475,7 @@
"LEGACY_STORAGE",
"ACCESS_ACCESSIBILITY",
"READ_DEVICE_IDENTIFIERS",
+ "ACCESS_MEDIA_LOCATION",
};
/**
@@ -1564,6 +1574,7 @@
null, // no permission for OP_LEGACY_STORAGE
null, // no permission for OP_ACCESS_ACCESSIBILITY
null, // no direct permission for OP_READ_DEVICE_IDENTIFIERS
+ Manifest.permission.ACCESS_MEDIA_LOCATION,
};
/**
@@ -1662,6 +1673,7 @@
null, // LEGACY_STORAGE
null, // ACCESS_ACCESSIBILITY
null, // READ_DEVICE_IDENTIFIERS
+ null, // ACCESS_MEDIA_LOCATION
};
/**
@@ -1759,6 +1771,7 @@
false, // LEGACY_STORAGE
false, // ACCESS_ACCESSIBILITY
false, // READ_DEVICE_IDENTIFIERS
+ false, // ACCESS_MEDIA_LOCATION
};
/**
@@ -1855,6 +1868,7 @@
AppOpsManager.MODE_DEFAULT, // LEGACY_STORAGE
AppOpsManager.MODE_ALLOWED, // ACCESS_ACCESSIBILITY
AppOpsManager.MODE_ERRORED, // READ_DEVICE_IDENTIFIERS
+ AppOpsManager.MODE_ALLOWED, // ALLOW_MEDIA_LOCATION
};
/**
@@ -1955,6 +1969,7 @@
false, // LEGACY_STORAGE
false, // ACCESS_ACCESSIBILITY
false, // READ_DEVICE_IDENTIFIERS
+ false, // ACCESS_MEDIA_LOCATION
};
/**
@@ -2587,7 +2602,7 @@
* @return The proxy UID.
*/
public int getProxyUid() {
- return (int) findFirstNonNegativeForFlagsInStates(mDurations,
+ return (int) findFirstNonNegativeForFlagsInStates(mProxyUids,
MAX_PRIORITY_UID_STATE, MIN_PRIORITY_UID_STATE, OP_FLAGS_ALL);
}
@@ -2609,7 +2624,7 @@
* @return The proxy UID.
*/
public int getProxyUid(@UidState int uidState, @OpFlags int flags) {
- return (int) findFirstNonNegativeForFlagsInStates(mDurations,
+ return (int) findFirstNonNegativeForFlagsInStates(mProxyUids,
uidState, uidState, flags);
}
@@ -4170,8 +4185,8 @@
* end UID states.
*
* @param counts The data array.
- * @param beginUidState The beginning UID state (exclusive).
- * @param endUidState The end UID state.
+ * @param beginUidState The beginning UID state (inclusive).
+ * @param endUidState The end UID state (inclusive).
* @param flags The UID flags.
* @return The sum.
*/
@@ -4200,13 +4215,13 @@
* end UID states.
*
* @param counts The data array.
+ * @param beginUidState The beginning UID state (inclusive).
+ * @param endUidState The end UID state (inclusive).
* @param flags The UID flags.
- * @param beginUidState The beginning UID state (exclusive).
- * @param endUidState The end UID state.
* @return The non-negative value or -1.
*/
private static long findFirstNonNegativeForFlagsInStates(@Nullable LongSparseLongArray counts,
- @OpFlags int flags, @UidState int beginUidState, @UidState int endUidState) {
+ @UidState int beginUidState, @UidState int endUidState, @OpFlags int flags) {
if (counts == null) {
return -1;
}
@@ -4232,14 +4247,14 @@
* end UID states.
*
* @param counts The data array.
+ * @param beginUidState The beginning UID state (inclusive).
+ * @param endUidState The end UID state (inclusive).
* @param flags The UID flags.
- * @param beginUidState The beginning UID state (exclusive).
- * @param endUidState The end UID state.
* @return The non-negative value or -1.
*/
private static @Nullable String findFirstNonNullForFlagsInStates(
- @Nullable LongSparseArray<String> counts, @OpFlags int flags,
- @UidState int beginUidState, @UidState int endUidState) {
+ @Nullable LongSparseArray<String> counts, @UidState int beginUidState,
+ @UidState int endUidState, @OpFlags int flags) {
if (counts == null) {
return null;
}
diff --git a/core/java/android/app/INotificationManager.aidl b/core/java/android/app/INotificationManager.aidl
index e57738f..9f51db8 100644
--- a/core/java/android/app/INotificationManager.aidl
+++ b/core/java/android/app/INotificationManager.aidl
@@ -108,6 +108,8 @@
ParceledListSlice getNotificationChannelsBypassingDnd(String pkg, int userId);
boolean isPackagePaused(String pkg);
+ void silenceNotificationSound();
+
// TODO: Remove this when callers have been migrated to the equivalent
// INotificationListener method.
@UnsupportedAppUsage
diff --git a/core/java/android/app/ITaskStackListener.aidl b/core/java/android/app/ITaskStackListener.aidl
index 650147b..6fd43a6 100644
--- a/core/java/android/app/ITaskStackListener.aidl
+++ b/core/java/android/app/ITaskStackListener.aidl
@@ -178,6 +178,13 @@
*/
void onSingleTaskDisplayDrawn(int displayId);
+ /*
+ * Called when the last task is removed from a display which can only contain one task.
+ *
+ * @param displayId the id of the display from which the window is removed.
+ */
+ void onSingleTaskDisplayEmpty(int displayId);
+
/**
* Called when a task is reparented to a stack on a different display.
*
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index ceadd85..16a98c6 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -8539,24 +8539,34 @@
* If set and the app creating the bubble is in the foreground, the bubble will be posted
* in its expanded state, with the contents of {@link #getIntent()} in a floating window.
*
- * <p>If the app creating the bubble is not in the foreground this flag has no effect.</p>
+ * <p>This flag has no effect if the app posting the bubble is not in the foreground.
+ * The app is considered foreground if it is visible and on the screen, note that
+ * a foreground service does not qualify.
+ * </p>
*
* <p>Generally this flag should only be set if the user has performed an action to request
* or create a bubble.</p>
+ *
+ * @hide
*/
- private static final int FLAG_AUTO_EXPAND_BUBBLE = 0x00000001;
+ public static final int FLAG_AUTO_EXPAND_BUBBLE = 0x00000001;
/**
* If set and the app posting the bubble is in the foreground, the bubble will
* be posted <b>without</b> the associated notification in the notification shade.
*
- * <p>If the app posting the bubble is not in the foreground this flag has no effect.</p>
+ * <p>This flag has no effect if the app posting the bubble is not in the foreground.
+ * The app is considered foreground if it is visible and on the screen, note that
+ * a foreground service does not qualify.
+ * </p>
*
* <p>Generally this flag should only be set if the user has performed an action to request
* or create a bubble, or if the user has seen the content in the notification and the
* notification is no longer relevant.</p>
+ *
+ * @hide
*/
- private static final int FLAG_SUPPRESS_NOTIFICATION = 0x00000002;
+ public static final int FLAG_SUPPRESS_NOTIFICATION = 0x00000002;
private BubbleMetadata(PendingIntent expandIntent, PendingIntent deleteIntent,
Icon icon, int height, @DimenRes int heightResId) {
@@ -8672,11 +8682,21 @@
out.writeInt(mDesiredHeightResId);
}
- private void setFlags(int flags) {
+ /**
+ * @hide
+ */
+ public void setFlags(int flags) {
mFlags = flags;
}
/**
+ * @hide
+ */
+ public int getFlags() {
+ return mFlags;
+ }
+
+ /**
* Builder to construct a {@link BubbleMetadata} object.
*/
public static final class Builder {
@@ -8792,6 +8812,8 @@
* {@link #getIntent()} in a floating window).
*
* <p>This flag has no effect if the app posting the bubble is not in the foreground.
+ * The app is considered foreground if it is visible and on the screen, note that
+ * a foreground service does not qualify.
* </p>
*
* <p>Generally, this flag should only be set if the user has performed an action to
@@ -8810,6 +8832,8 @@
* the notification shade.
*
* <p>This flag has no effect if the app posting the bubble is not in the foreground.
+ * The app is considered foreground if it is visible and on the screen, note that
+ * a foreground service does not qualify.
* </p>
*
* <p>Generally, this flag should only be set if the user has performed an action to
diff --git a/core/java/android/app/NotificationManager.java b/core/java/android/app/NotificationManager.java
index dd39376..b13a34f 100644
--- a/core/java/android/app/NotificationManager.java
+++ b/core/java/android/app/NotificationManager.java
@@ -1095,6 +1095,25 @@
}
/**
+ * Silences the current notification sound, if ones currently playing.
+ * <p>
+ * It is intended to handle use-cases such as silencing a ringing call
+ * when the user presses the volume button during ringing.
+ * <p>
+ * If this method is called prior to when the notification begins playing, the sound will not be
+ * silenced. As such it is not intended as a means to avoid playing of a sound.
+ * @hide
+ */
+ public void silenceNotificationSound() {
+ INotificationManager service = getService();
+ try {
+ service.silenceNotificationSound();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* Returns whether notifications from this package are temporarily hidden. This
* could be done because the package was marked as distracting to the user via
* {@code PackageManager#setDistractingPackageRestrictions(String[], int)} or because the
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java
index cfe2cf0..d29cf80 100644
--- a/core/java/android/app/SystemServiceRegistry.java
+++ b/core/java/android/app/SystemServiceRegistry.java
@@ -1162,7 +1162,8 @@
@Override
public AppPredictionManager createService(ContextImpl ctx)
throws ServiceNotFoundException {
- return new AppPredictionManager(ctx);
+ IBinder b = ServiceManager.getService(Context.APP_PREDICTION_SERVICE);
+ return b == null ? null : new AppPredictionManager(ctx);
}
});
diff --git a/core/java/android/app/TaskStackListener.java b/core/java/android/app/TaskStackListener.java
index b63feb5..b4b7df9 100644
--- a/core/java/android/app/TaskStackListener.java
+++ b/core/java/android/app/TaskStackListener.java
@@ -180,6 +180,10 @@
}
@Override
+ public void onSingleTaskDisplayEmpty(int displayId) throws RemoteException {
+ }
+
+ @Override
public void onTaskDisplayChanged(int taskId, int newDisplayId) throws RemoteException {
}
}
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 4a5ea03..1bc922d 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -4117,6 +4117,9 @@
/**
* Official published name of the app prediction service.
*
+ * <p><b>NOTE: </b> this service is optional; callers of
+ * {@code Context.getSystemServiceName(APP_PREDICTION_SERVICE)} should check for {@code null}.
+ *
* @hide
* @see #getSystemService(String)
*/
diff --git a/core/java/android/content/pm/IPackageManager.aidl b/core/java/android/content/pm/IPackageManager.aidl
index a7eecd7..abcf77b 100644
--- a/core/java/android/content/pm/IPackageManager.aidl
+++ b/core/java/android/content/pm/IPackageManager.aidl
@@ -44,6 +44,7 @@
import android.content.pm.PermissionInfo;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
+import android.content.pm.permission.SplitPermissionInfoParcelable;
import android.content.pm.SuspendDialogInfo;
import android.content.pm.UserInfo;
import android.content.pm.VerifierDeviceIdentity;
@@ -772,4 +773,6 @@
void setRuntimePermissionsVersion(int version, int userId);
void notifyPackagesReplacedReceived(in String[] packages);
+
+ List<SplitPermissionInfoParcelable> getSplitPermissions();
}
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 643cb3e..f682ebb 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -57,6 +57,7 @@
import android.content.IntentFilter;
import android.content.pm.PackageParserCacheHelper.ReadHelper;
import android.content.pm.PackageParserCacheHelper.WriteHelper;
+import android.content.pm.permission.SplitPermissionInfoParcelable;
import android.content.pm.split.DefaultSplitAssetLoader;
import android.content.pm.split.SplitAssetDependencyLoader;
import android.content.pm.split.SplitAssetLoader;
@@ -103,6 +104,7 @@
import com.android.internal.os.ClassLoaderFactory;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.XmlUtils;
+import com.android.server.SystemConfig;
import libcore.io.IoUtils;
import libcore.util.EmptyArray;
@@ -2482,11 +2484,10 @@
Slog.i(TAG, newPermsMsg.toString());
}
-
- final int NS = PermissionManager.SPLIT_PERMISSIONS.size();
- for (int is=0; is<NS; is++) {
- final PermissionManager.SplitPermissionInfo spi =
- PermissionManager.SPLIT_PERMISSIONS.get(is);
+ List<SplitPermissionInfoParcelable> splitPermissions = getSplitPermissions();
+ final int listSize = splitPermissions.size();
+ for (int is = 0; is < listSize; is++) {
+ final SplitPermissionInfoParcelable spi = splitPermissions.get(is);
if (pkg.applicationInfo.targetSdkVersion >= spi.getTargetSdk()
|| !pkg.requestedPermissions.contains(spi.getSplitPermission())) {
continue;
@@ -2540,6 +2541,23 @@
return pkg;
}
+ private List<SplitPermissionInfoParcelable> getSplitPermissions() {
+ // PackageManager runs this code during initialization prior to registering with
+ // ServiceManager, so we can't use the PackageManager API. Instead, just read from
+ // SystemConfig directly when in any SystemProcess and only use PackageManager when not in
+ // one.
+ if (ActivityThread.isSystem()) {
+ return PermissionManager.splitPermissionInfoListToParcelableList(
+ SystemConfig.getInstance().getSplitPermissions());
+ } else {
+ try {
+ return ActivityThread.getPackageManager().getSplitPermissions();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+ }
+
private boolean checkOverlayRequiredSystemProperty(String propName, String propValue) {
if (TextUtils.isEmpty(propName) || TextUtils.isEmpty(propValue)) {
diff --git a/core/java/android/content/pm/permission/SplitPermissionInfoParcelable.aidl b/core/java/android/content/pm/permission/SplitPermissionInfoParcelable.aidl
new file mode 100644
index 0000000..d84454c
--- /dev/null
+++ b/core/java/android/content/pm/permission/SplitPermissionInfoParcelable.aidl
@@ -0,0 +1,19 @@
+/**
+ * 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.
+ */
+
+ package android.content.pm.permission;
+
+ parcelable SplitPermissionInfoParcelable;
\ No newline at end of file
diff --git a/core/java/android/content/pm/permission/SplitPermissionInfoParcelable.java b/core/java/android/content/pm/permission/SplitPermissionInfoParcelable.java
new file mode 100644
index 0000000..6537fbc
--- /dev/null
+++ b/core/java/android/content/pm/permission/SplitPermissionInfoParcelable.java
@@ -0,0 +1,178 @@
+/*
+ * 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.
+ */
+
+package android.content.pm.permission;
+
+import android.annotation.IntRange;
+import android.annotation.NonNull;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import com.android.internal.util.Preconditions;
+
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * Parcelable version of {@link android.permission.PermissionManager.SplitPermissionInfo}
+ * @hide
+ */
+public class SplitPermissionInfoParcelable implements Parcelable {
+
+ /**
+ * The permission that is split.
+ */
+ @NonNull
+ private final String mSplitPermission;
+
+ /**
+ * The permissions that are added.
+ */
+ @NonNull
+ private final List<String> mNewPermissions;
+
+ /**
+ * The target API level when the permission was split.
+ */
+ @IntRange(from = 0)
+ private final int mTargetSdk;
+
+ private void onConstructed() {
+ Preconditions.checkCollectionElementsNotNull(mNewPermissions, "newPermissions");
+ }
+
+
+
+ // Code below generated by codegen v1.0.0.
+ //
+ // DO NOT MODIFY!
+ //
+ // To regenerate run:
+ // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/content/pm/SplitPermissionInfoParcelable.java
+ //
+ // CHECKSTYLE:OFF Generated code
+
+ /**
+ * Creates a new SplitPermissionInfoParcelable.
+ *
+ * @param splitPermission
+ * The permission that is split.
+ * @param newPermissions
+ * The permissions that are added.
+ * @param targetSdk
+ * The target API level when the permission was split.
+ */
+ public SplitPermissionInfoParcelable(
+ @NonNull String splitPermission,
+ @NonNull List<String> newPermissions,
+ @IntRange(from = 0) int targetSdk) {
+ this.mSplitPermission = splitPermission;
+ Preconditions.checkNotNull(mSplitPermission);
+ this.mNewPermissions = newPermissions;
+ Preconditions.checkNotNull(mNewPermissions);
+ this.mTargetSdk = targetSdk;
+ Preconditions.checkArgumentNonnegative(mTargetSdk);
+
+ onConstructed();
+ }
+
+ /**
+ * The permission that is split.
+ */
+ public @NonNull String getSplitPermission() {
+ return mSplitPermission;
+ }
+
+ /**
+ * The permissions that are added.
+ */
+ public @NonNull List<String> getNewPermissions() {
+ return mNewPermissions;
+ }
+
+ /**
+ * The target API level when the permission was split.
+ */
+ public @IntRange(from = 0) int getTargetSdk() {
+ return mTargetSdk;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ // You can override field equality logic by defining either of the methods like:
+ // boolean fieldNameEquals(SplitPermissionInfoParcelable other) { ... }
+ // boolean fieldNameEquals(FieldType otherValue) { ... }
+
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ @SuppressWarnings("unchecked")
+ SplitPermissionInfoParcelable that = (SplitPermissionInfoParcelable) o;
+ //noinspection PointlessBooleanExpression
+ return true
+ && Objects.equals(mSplitPermission, that.mSplitPermission)
+ && Objects.equals(mNewPermissions, that.mNewPermissions)
+ && mTargetSdk == that.mTargetSdk;
+ }
+
+ @Override
+ public int hashCode() {
+ // You can override field hashCode logic by defining methods like:
+ // int fieldNameHashCode() { ... }
+
+ int _hash = 1;
+ _hash = 31 * _hash + Objects.hashCode(mSplitPermission);
+ _hash = 31 * _hash + Objects.hashCode(mNewPermissions);
+ _hash = 31 * _hash + mTargetSdk;
+ return _hash;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ // You can override field parcelling by defining methods like:
+ // void parcelFieldName(Parcel dest, int flags) { ... }
+
+ dest.writeString(mSplitPermission);
+ dest.writeStringList(mNewPermissions);
+ dest.writeInt(mTargetSdk);
+ }
+
+ @Override
+ public int describeContents() { return 0; }
+
+ public static final @NonNull Parcelable.Creator<SplitPermissionInfoParcelable> CREATOR
+ = new Parcelable.Creator<SplitPermissionInfoParcelable>() {
+ @Override
+ public SplitPermissionInfoParcelable[] newArray(int size) {
+ return new SplitPermissionInfoParcelable[size];
+ }
+
+ @Override
+ @SuppressWarnings({"unchecked", "RedundantCast"})
+ public SplitPermissionInfoParcelable createFromParcel(Parcel in) {
+ // You can override field unparcelling by defining methods like:
+ // static FieldType unparcelFieldName(Parcel in) { ... }
+
+ String splitPermission = in.readString();
+ List<String> newPermissions = new java.util.ArrayList<>();
+ in.readStringList(newPermissions);
+ int targetSdk = in.readInt();
+ return new SplitPermissionInfoParcelable(
+ splitPermission,
+ newPermissions,
+ targetSdk);
+ }
+ };
+}
diff --git a/core/java/android/hardware/camera2/CameraMetadata.java b/core/java/android/hardware/camera2/CameraMetadata.java
index 5ac13d8..a0170da 100644
--- a/core/java/android/hardware/camera2/CameraMetadata.java
+++ b/core/java/android/hardware/camera2/CameraMetadata.java
@@ -206,10 +206,16 @@
continue;
}
- if (filterTags == null || Arrays.binarySearch(filterTags,
- CameraMetadataNative.getTag(keyName, vendorId)) >= 0) {
+
+ if (filterTags != null && Arrays.binarySearch(filterTags,
+ CameraMetadataNative.getTag(keyName, vendorId)) < 0) {
+ // ignore vendor keys not in filterTags
+ continue;
+ }
+ if (instance == null || instance.getProtected(k) != null) {
keyList.add(k);
}
+
}
}
diff --git a/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java b/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java
index cc8c182..f422289 100644
--- a/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java
+++ b/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java
@@ -1026,34 +1026,35 @@
// callback is valid
executor = checkExecutor(executor, callback);
- // Make sure that there all requests have at least 1 surface; all surfaces are non-null;
- // the surface isn't a physical stream surface for reprocessing request
- for (CaptureRequest request : requestList) {
- if (request.getTargets().isEmpty()) {
- throw new IllegalArgumentException(
- "Each request must have at least one Surface target");
- }
+ synchronized(mInterfaceLock) {
+ checkIfCameraClosedOrInError();
- for (Surface surface : request.getTargets()) {
- if (surface == null) {
- throw new IllegalArgumentException("Null Surface targets are not allowed");
+ // Make sure that there all requests have at least 1 surface; all surfaces are non-null;
+ // the surface isn't a physical stream surface for reprocessing request
+ for (CaptureRequest request : requestList) {
+ if (request.getTargets().isEmpty()) {
+ throw new IllegalArgumentException(
+ "Each request must have at least one Surface target");
}
- for (int i = 0; i < mConfiguredOutputs.size(); i++) {
- OutputConfiguration configuration = mConfiguredOutputs.valueAt(i);
- if (configuration.isForPhysicalCamera()
- && configuration.getSurfaces().contains(surface)) {
- if (request.isReprocess()) {
- throw new IllegalArgumentException(
- "Reprocess request on physical stream is not allowed");
+ for (Surface surface : request.getTargets()) {
+ if (surface == null) {
+ throw new IllegalArgumentException("Null Surface targets are not allowed");
+ }
+
+ for (int i = 0; i < mConfiguredOutputs.size(); i++) {
+ OutputConfiguration configuration = mConfiguredOutputs.valueAt(i);
+ if (configuration.isForPhysicalCamera()
+ && configuration.getSurfaces().contains(surface)) {
+ if (request.isReprocess()) {
+ throw new IllegalArgumentException(
+ "Reprocess request on physical stream is not allowed");
+ }
}
}
}
}
- }
- synchronized(mInterfaceLock) {
- checkIfCameraClosedOrInError();
if (repeating) {
stopRepeating();
}
@@ -2337,20 +2338,33 @@
final CaptureCallbackHolder holder =
CameraDeviceImpl.this.mCaptureCallbackMap.get(requestId);
+ if (holder == null) {
+ Log.e(TAG, String.format("Receive capture error on unknown request ID %d",
+ requestId));
+ return;
+ }
+
final CaptureRequest request = holder.getRequest(subsequenceId);
Runnable failureDispatch = null;
if (errorCode == ERROR_CAMERA_BUFFER) {
// Because 1 stream id could map to multiple surfaces, we need to specify both
// streamId and surfaceId.
- List<Surface> surfaces =
- mConfiguredOutputs.get(resultExtras.getErrorStreamId()).getSurfaces();
- for (Surface surface : surfaces) {
+ OutputConfiguration config = mConfiguredOutputs.get(
+ resultExtras.getErrorStreamId());
+ if (config == null) {
+ Log.v(TAG, String.format(
+ "Stream %d has been removed. Skipping buffer lost callback",
+ resultExtras.getErrorStreamId()));
+ return;
+ }
+ for (Surface surface : config.getSurfaces()) {
if (!request.containsTarget(surface)) {
continue;
}
if (DEBUG) {
- Log.v(TAG, String.format("Lost output buffer reported for frame %d, target %s",
+ Log.v(TAG, String.format(
+ "Lost output buffer reported for frame %d, target %s",
frameNumber, surface));
}
failureDispatch = new Runnable() {
diff --git a/core/java/android/hardware/radio/TunerAdapter.java b/core/java/android/hardware/radio/TunerAdapter.java
index be2846f..aa5480a 100644
--- a/core/java/android/hardware/radio/TunerAdapter.java
+++ b/core/java/android/hardware/radio/TunerAdapter.java
@@ -271,6 +271,8 @@
mCallback.setProgramListObserver(list, () -> {
try {
mTuner.stopProgramListUpdates();
+ } catch (IllegalStateException ex) {
+ // it's fine to not stop updates if tuner is already closed
} catch (RemoteException ex) {
Log.e(TAG, "Couldn't stop program list updates", ex);
}
diff --git a/core/java/android/hardware/radio/TunerCallbackAdapter.java b/core/java/android/hardware/radio/TunerCallbackAdapter.java
index 0fb93e5..beff0f7 100644
--- a/core/java/android/hardware/radio/TunerCallbackAdapter.java
+++ b/core/java/android/hardware/radio/TunerCallbackAdapter.java
@@ -211,10 +211,12 @@
@Override
public void onProgramListUpdated(ProgramList.Chunk chunk) {
- synchronized (mLock) {
- if (mProgramList == null) return;
- mProgramList.apply(Objects.requireNonNull(chunk));
- }
+ mHandler.post(() -> {
+ synchronized (mLock) {
+ if (mProgramList == null) return;
+ mProgramList.apply(Objects.requireNonNull(chunk));
+ }
+ });
}
@Override
diff --git a/core/java/android/inputmethodservice/SoftInputWindow.java b/core/java/android/inputmethodservice/SoftInputWindow.java
index 0513fee..356b344 100644
--- a/core/java/android/inputmethodservice/SoftInputWindow.java
+++ b/core/java/android/inputmethodservice/SoftInputWindow.java
@@ -21,6 +21,7 @@
import android.annotation.IntDef;
import android.app.Dialog;
import android.content.Context;
+import android.content.pm.PackageManager;
import android.graphics.Rect;
import android.os.Debug;
import android.os.IBinder;
@@ -50,6 +51,7 @@
final int mWindowType;
final int mGravity;
final boolean mTakesFocus;
+ final boolean mAutomotiveHideNavBarForKeyboard;
private final Rect mBounds = new Rect();
@Retention(SOURCE)
@@ -134,6 +136,8 @@
mWindowType = windowType;
mGravity = gravity;
mTakesFocus = takesFocus;
+ mAutomotiveHideNavBarForKeyboard = context.getResources().getBoolean(
+ com.android.internal.R.bool.config_automotiveHideNavBarForKeyboard);
initDockWindow();
}
@@ -247,6 +251,11 @@
windowModFlags |= WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
}
+ if (isAutomotive() && mAutomotiveHideNavBarForKeyboard) {
+ windowSetFlags |= WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
+ windowModFlags |= WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
+ }
+
getWindow().setFlags(windowSetFlags, windowModFlags);
}
@@ -338,6 +347,10 @@
mWindowState = newState;
}
+ private boolean isAutomotive() {
+ return getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE);
+ }
+
private static String stateToString(@SoftInputWindowState int state) {
switch (state) {
case SoftInputWindowState.TOKEN_PENDING:
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index 00d522b..ecd16dd 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -266,8 +266,11 @@
* - Fixed bug in min learned capacity updating process.
* New in version 34:
* - Deprecated STATS_SINCE_UNPLUGGED and STATS_CURRENT.
+ * New in version 35:
+ * - Fixed bug that was not reporting high cellular tx power correctly
+ * - Added out of service and emergency service modes to data connection types
*/
- static final int CHECKIN_VERSION = 34;
+ static final int CHECKIN_VERSION = 35;
/**
* Old version, we hit 9 and ran out of room, need to remove.
@@ -2371,18 +2374,21 @@
*/
public abstract int getMobileRadioActiveUnknownCount(int which);
- public static final int DATA_CONNECTION_NONE = 0;
- public static final int DATA_CONNECTION_OTHER = TelephonyManager.MAX_NETWORK_TYPE + 1;
+ public static final int DATA_CONNECTION_OUT_OF_SERVICE = 0;
+ public static final int DATA_CONNECTION_EMERGENCY_SERVICE =
+ TelephonyManager.MAX_NETWORK_TYPE + 1;
+ public static final int DATA_CONNECTION_OTHER = DATA_CONNECTION_EMERGENCY_SERVICE + 1;
+
static final String[] DATA_CONNECTION_NAMES = {
- "none", "gprs", "edge", "umts", "cdma", "evdo_0", "evdo_A",
+ "oos", "gprs", "edge", "umts", "cdma", "evdo_0", "evdo_A",
"1xrtt", "hsdpa", "hsupa", "hspa", "iden", "evdo_b", "lte",
"ehrpd", "hspap", "gsm", "td_scdma", "iwlan", "lte_ca", "nr",
- "other"
+ "emngcy", "other"
};
@UnsupportedAppUsage
- public static final int NUM_DATA_CONNECTION_TYPES = DATA_CONNECTION_OTHER+1;
+ public static final int NUM_DATA_CONNECTION_TYPES = DATA_CONNECTION_OTHER + 1;
/**
* Returns the time in microseconds that the phone has been running with
@@ -6564,6 +6570,10 @@
}
oldState = rec.states;
oldState2 = rec.states2;
+ // Clear High Tx Power Flag for volta positioning
+ if ((rec.states2 & HistoryItem.STATE2_CELLULAR_HIGH_TX_POWER_FLAG) != 0) {
+ rec.states2 &= ~HistoryItem.STATE2_CELLULAR_HIGH_TX_POWER_FLAG;
+ }
}
return item.toString();
@@ -7865,9 +7875,9 @@
// Phone data connection (DATA_CONNECTION_TIME_DATA and DATA_CONNECTION_COUNT_DATA)
for (int i = 0; i < NUM_DATA_CONNECTION_TYPES; ++i) {
// Map OTHER to TelephonyManager.NETWORK_TYPE_UNKNOWN and mark NONE as a boolean.
- boolean isNone = (i == DATA_CONNECTION_NONE);
+ boolean isNone = (i == DATA_CONNECTION_OUT_OF_SERVICE);
int telephonyNetworkType = i;
- if (i == DATA_CONNECTION_OTHER) {
+ if (i == DATA_CONNECTION_OTHER || i == DATA_CONNECTION_EMERGENCY_SERVICE) {
telephonyNetworkType = TelephonyManager.NETWORK_TYPE_UNKNOWN;
}
final long pdcToken = proto.start(SystemProto.DATA_CONNECTION);
diff --git a/core/java/android/os/GraphicsEnvironment.java b/core/java/android/os/GraphicsEnvironment.java
index ce1942c..7a70e93 100644
--- a/core/java/android/os/GraphicsEnvironment.java
+++ b/core/java/android/os/GraphicsEnvironment.java
@@ -67,6 +67,8 @@
private static final String PROPERTY_GFX_DRIVER_PRERELEASE = "ro.gfx.driver.1";
private static final String PROPERTY_GFX_DRIVER_BUILD_TIME = "ro.gfx.driver_build_time";
private static final String METADATA_DRIVER_BUILD_TIME = "com.android.gamedriver.build_time";
+ private static final String METADATA_DEVELOPER_DRIVER_ENABLE =
+ "com.android.graphics.developerdriver.enable";
private static final String ANGLE_RULES_FILE = "a4a_rules.json";
private static final String ANGLE_TEMP_RULES = "debug.angle.rules";
private static final String ACTION_ANGLE_FOR_ANDROID = "android.app.action.ANGLE_FOR_ANDROID";
@@ -691,7 +693,8 @@
/**
* Return the driver package name to use. Return null for system driver.
*/
- private static String chooseDriverInternal(Context context, Bundle coreSettings) {
+ private static String chooseDriverInternal(
+ Context context, Bundle coreSettings, PackageManager pm, String packageName) {
final String gameDriver = SystemProperties.get(PROPERTY_GFX_DRIVER);
final boolean hasGameDriver = gameDriver != null && !gameDriver.isEmpty();
@@ -706,12 +709,24 @@
// To minimize risk of driver updates crippling the device beyond user repair, never use an
// updated driver for privileged or non-updated system apps. Presumably pre-installed apps
// were tested thoroughly with the pre-installed driver.
- final ApplicationInfo ai = context.getApplicationInfo();
+ ApplicationInfo ai;
+ try {
+ // Get the ApplicationInfo from PackageManager so that metadata fields present.
+ ai = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
+ } catch (PackageManager.NameNotFoundException e) {
+ // Unlikely to fail for applications, but in case of failure, fall back to use the
+ // ApplicationInfo from context directly.
+ ai = context.getApplicationInfo();
+ }
if (ai.isPrivilegedApp() || (ai.isSystemApp() && !ai.isUpdatedSystemApp())) {
if (DEBUG) Log.v(TAG, "Ignoring driver package for privileged/non-updated system app.");
return null;
}
+ final boolean enablePrereleaseDriver =
+ (ai.metaData != null && ai.metaData.getBoolean(METADATA_DEVELOPER_DRIVER_ENABLE))
+ || getCanLoadSystemLibraries() == 1;
+
// Priority for Game Driver settings global on confliction (Higher priority comes first):
// 1. GAME_DRIVER_ALL_APPS
// 2. GAME_DRIVER_OPT_OUT_APPS
@@ -728,7 +743,7 @@
return hasGameDriver ? gameDriver : null;
case GAME_DRIVER_GLOBAL_OPT_IN_PRERELEASE_DRIVER:
if (DEBUG) Log.v(TAG, "All apps opt in to use prerelease driver.");
- return hasPrereleaseDriver ? prereleaseDriver : null;
+ return hasPrereleaseDriver && enablePrereleaseDriver ? prereleaseDriver : null;
case GAME_DRIVER_GLOBAL_OPT_IN_DEFAULT:
default:
break;
@@ -745,7 +760,7 @@
null, coreSettings, Settings.Global.GAME_DRIVER_PRERELEASE_OPT_IN_APPS)
.contains(appPackageName)) {
if (DEBUG) Log.v(TAG, "App opts in for prerelease Game Driver.");
- return hasPrereleaseDriver ? prereleaseDriver : null;
+ return hasPrereleaseDriver && enablePrereleaseDriver ? prereleaseDriver : null;
}
// Early return here since the rest logic is only for Game Driver.
@@ -783,7 +798,8 @@
*/
private static boolean chooseDriver(
Context context, Bundle coreSettings, PackageManager pm, String packageName) {
- final String driverPackageName = chooseDriverInternal(context, coreSettings);
+ final String driverPackageName = chooseDriverInternal(context, coreSettings, pm,
+ packageName);
if (driverPackageName == null) {
return false;
}
diff --git a/core/java/android/permission/PermissionManager.java b/core/java/android/permission/PermissionManager.java
index a2ab0c1..3c45b0c 100644
--- a/core/java/android/permission/PermissionManager.java
+++ b/core/java/android/permission/PermissionManager.java
@@ -26,14 +26,15 @@
import android.annotation.TestApi;
import android.content.Context;
import android.content.pm.IPackageManager;
+import android.content.pm.permission.SplitPermissionInfoParcelable;
import android.os.RemoteException;
+import android.util.Log;
import com.android.internal.annotations.Immutable;
-import com.android.server.SystemConfig;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
-import java.util.Objects;
/**
* System level service for accessing the permission capabilities of the platform.
@@ -44,18 +45,14 @@
@SystemApi
@SystemService(Context.PERMISSION_SERVICE)
public final class PermissionManager {
- /**
- * {@link android.content.pm.PackageParser} needs access without having a {@link Context}.
- *
- * @hide
- */
- public static final ArrayList<SplitPermissionInfo> SPLIT_PERMISSIONS =
- SystemConfig.getInstance().getSplitPermissions();
+ private static final String TAG = PermissionManager.class.getName();
private final @NonNull Context mContext;
private final IPackageManager mPackageManager;
+ private List<SplitPermissionInfo> mSplitPermissionInfos;
+
/**
* Creates a new instance.
*
@@ -123,7 +120,48 @@
* @return All permissions that are split.
*/
public @NonNull List<SplitPermissionInfo> getSplitPermissions() {
- return SPLIT_PERMISSIONS;
+ if (mSplitPermissionInfos != null) {
+ return mSplitPermissionInfos;
+ }
+
+ List<SplitPermissionInfoParcelable> parcelableList;
+ try {
+ parcelableList = mPackageManager.getSplitPermissions();
+ } catch (RemoteException e) {
+ Log.w(TAG, "Error getting split permissions", e);
+ return Collections.emptyList();
+ }
+
+ mSplitPermissionInfos = splitPermissionInfoListToNonParcelableList(parcelableList);
+
+ return mSplitPermissionInfos;
+ }
+
+ private List<SplitPermissionInfo> splitPermissionInfoListToNonParcelableList(
+ List<SplitPermissionInfoParcelable> parcelableList) {
+ final int size = parcelableList.size();
+ List<SplitPermissionInfo> list = new ArrayList<>(size);
+ for (int i = 0; i < size; i++) {
+ list.add(new SplitPermissionInfo(parcelableList.get(i)));
+ }
+ return list;
+ }
+
+ /**
+ * Converts a {@link List} of {@link SplitPermissionInfo} into a List of
+ * {@link SplitPermissionInfoParcelable} and returns it.
+ * @hide
+ */
+ public static List<SplitPermissionInfoParcelable> splitPermissionInfoListToParcelableList(
+ List<SplitPermissionInfo> splitPermissionsList) {
+ final int size = splitPermissionsList.size();
+ List<SplitPermissionInfoParcelable> outList = new ArrayList<>(size);
+ for (int i = 0; i < size; i++) {
+ SplitPermissionInfo info = splitPermissionsList.get(i);
+ outList.add(new SplitPermissionInfoParcelable(
+ info.getSplitPermission(), info.getNewPermissions(), info.getTargetSdk()));
+ }
+ return outList;
}
/**
@@ -132,44 +170,40 @@
*/
@Immutable
public static final class SplitPermissionInfo {
- private final @NonNull String mSplitPerm;
- private final @NonNull List<String> mNewPerms;
- private final int mTargetSdk;
+ private @NonNull final SplitPermissionInfoParcelable mSplitPermissionInfoParcelable;
@Override
public boolean equals(@Nullable Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SplitPermissionInfo that = (SplitPermissionInfo) o;
- return mTargetSdk == that.mTargetSdk
- && mSplitPerm.equals(that.mSplitPerm)
- && mNewPerms.equals(that.mNewPerms);
+ return mSplitPermissionInfoParcelable.equals(that.mSplitPermissionInfoParcelable);
}
@Override
public int hashCode() {
- return Objects.hash(mSplitPerm, mNewPerms, mTargetSdk);
+ return mSplitPermissionInfoParcelable.hashCode();
}
/**
* Get the permission that is split.
*/
public @NonNull String getSplitPermission() {
- return mSplitPerm;
+ return mSplitPermissionInfoParcelable.getSplitPermission();
}
/**
* Get the permissions that are added.
*/
public @NonNull List<String> getNewPermissions() {
- return mNewPerms;
+ return mSplitPermissionInfoParcelable.getNewPermissions();
}
/**
* Get the target API level when the permission was split.
*/
public int getTargetSdk() {
- return mTargetSdk;
+ return mSplitPermissionInfoParcelable.getTargetSdk();
}
/**
@@ -183,9 +217,11 @@
*/
public SplitPermissionInfo(@NonNull String splitPerm, @NonNull List<String> newPerms,
int targetSdk) {
- mSplitPerm = splitPerm;
- mNewPerms = newPerms;
- mTargetSdk = targetSdk;
+ this(new SplitPermissionInfoParcelable(splitPerm, newPerms, targetSdk));
+ }
+
+ private SplitPermissionInfo(@NonNull SplitPermissionInfoParcelable parcelable) {
+ mSplitPermissionInfoParcelable = parcelable;
}
}
}
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 94d6e01..c73e8e3 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -8697,10 +8697,16 @@
* Whether the notification bubbles are globally enabled
* The value is boolean (1 or 0).
* @hide
+ * @deprecated use {@link Global#NOTIFICATION_BUBBLES} instead.
*/
@TestApi
+ @Deprecated
public static final String NOTIFICATION_BUBBLES = "notification_bubbles";
+ /**
+ * @deprecated use {@link Global#NOTIFICATION_BUBBLES_VALIDATOR} instead.
+ */
+ @Deprecated
private static final Validator NOTIFICATION_BUBBLES_VALIDATOR = BOOLEAN_VALIDATOR;
/**
@@ -9025,7 +9031,6 @@
ASSIST_GESTURE_WAKE_ENABLED,
VR_DISPLAY_MODE,
NOTIFICATION_BADGING,
- NOTIFICATION_BUBBLES,
NOTIFICATION_DISMISS_RTL,
QS_AUTO_ADDED_TILES,
SCREENSAVER_ENABLED,
@@ -9394,6 +9399,16 @@
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/global");
/**
+ * Whether the notification bubbles are globally enabled
+ * The value is boolean (1 or 0).
+ * @hide
+ */
+ @TestApi
+ public static final String NOTIFICATION_BUBBLES = "notification_bubbles";
+
+ private static final Validator NOTIFICATION_BUBBLES_VALIDATOR = BOOLEAN_VALIDATOR;
+
+ /**
* Whether users are allowed to add more users or guest from lockscreen.
* <p>
* Type: int
@@ -13852,6 +13867,7 @@
ZEN_DURATION,
CHARGING_VIBRATION_ENABLED,
AWARE_ALLOWED,
+ NOTIFICATION_BUBBLES,
};
/**
@@ -13918,6 +13934,7 @@
VALIDATORS.put(AWARE_ALLOWED, AWARE_ALLOWED_VALIDATOR);
VALIDATORS.put(POWER_BUTTON_LONG_PRESS, POWER_BUTTON_LONG_PRESS_VALIDATOR);
VALIDATORS.put(POWER_BUTTON_VERY_LONG_PRESS, POWER_BUTTON_VERY_LONG_PRESS_VALIDATOR);
+ VALIDATORS.put(NOTIFICATION_BUBBLES, NOTIFICATION_BUBBLES_VALIDATOR);
}
/**
diff --git a/core/java/android/service/notification/ZenModeConfig.java b/core/java/android/service/notification/ZenModeConfig.java
index cb7d41b..93bcdbf 100644
--- a/core/java/android/service/notification/ZenModeConfig.java
+++ b/core/java/android/service/notification/ZenModeConfig.java
@@ -1639,7 +1639,7 @@
@UnsupportedAppUsage
public String name; // required for automatic
@UnsupportedAppUsage
- public int zenMode;
+ public int zenMode; // ie: Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS
@UnsupportedAppUsage
public Uri conditionId; // required for automatic
public Condition condition; // optional
diff --git a/core/java/android/service/textclassifier/TextClassifierService.java b/core/java/android/service/textclassifier/TextClassifierService.java
index 30c4e90..bb39be2 100644
--- a/core/java/android/service/textclassifier/TextClassifierService.java
+++ b/core/java/android/service/textclassifier/TextClassifierService.java
@@ -51,7 +51,6 @@
import com.android.internal.util.Preconditions;
-import java.lang.ref.WeakReference;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -431,23 +430,18 @@
* Forwards the callback result to a wrapped binder callback.
*/
private static final class ProxyCallback<T extends Parcelable> implements Callback<T> {
- private WeakReference<ITextClassifierCallback> mTextClassifierCallback;
+ private ITextClassifierCallback mTextClassifierCallback;
private ProxyCallback(ITextClassifierCallback textClassifierCallback) {
- mTextClassifierCallback =
- new WeakReference<>(Preconditions.checkNotNull(textClassifierCallback));
+ mTextClassifierCallback = Preconditions.checkNotNull(textClassifierCallback);
}
@Override
public void onSuccess(T result) {
- ITextClassifierCallback callback = mTextClassifierCallback.get();
- if (callback == null) {
- return;
- }
try {
Bundle bundle = new Bundle(1);
bundle.putParcelable(KEY_RESULT, result);
- callback.onSuccess(bundle);
+ mTextClassifierCallback.onSuccess(bundle);
} catch (RemoteException e) {
Slog.d(LOG_TAG, "Error calling callback");
}
@@ -455,12 +449,8 @@
@Override
public void onFailure(CharSequence error) {
- ITextClassifierCallback callback = mTextClassifierCallback.get();
- if (callback == null) {
- return;
- }
try {
- callback.onFailure();
+ mTextClassifierCallback.onFailure();
} catch (RemoteException e) {
Slog.d(LOG_TAG, "Error calling callback");
}
diff --git a/core/java/android/view/GestureExclusionTracker.java b/core/java/android/view/GestureExclusionTracker.java
index 6fcdd71..fffb323e 100644
--- a/core/java/android/view/GestureExclusionTracker.java
+++ b/core/java/android/view/GestureExclusionTracker.java
@@ -44,7 +44,7 @@
while (i.hasNext()) {
final GestureExclusionViewInfo info = i.next();
final View v = info.getView();
- if (v == null || !v.isAttachedToWindow()) {
+ if (v == null || !v.isAttachedToWindow() || !v.isAggregatedVisible()) {
mGestureExclusionViewsChanged = true;
i.remove();
continue;
@@ -122,7 +122,8 @@
public int update() {
final View excludedView = getView();
- if (excludedView == null || !excludedView.isAttachedToWindow()) return GONE;
+ if (excludedView == null || !excludedView.isAttachedToWindow()
+ || !excludedView.isAggregatedVisible()) return GONE;
final List<Rect> localRects = excludedView.getSystemGestureExclusionRects();
final List<Rect> newRects = new ArrayList<>(localRects.size());
for (Rect src : localRects) {
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java
index 3c045f4..2313b13 100644
--- a/core/java/android/view/SurfaceControl.java
+++ b/core/java/android/view/SurfaceControl.java
@@ -84,7 +84,6 @@
private static native long nativeCopyFromSurfaceControl(long nativeObject);
private static native void nativeWriteToParcel(long nativeObject, Parcel out);
private static native void nativeRelease(long nativeObject);
- private static native void nativeDestroy(long nativeObject);
private static native void nativeDisconnect(long nativeObject);
private static native ScreenshotGraphicBuffer nativeScreenshot(IBinder displayToken,
@@ -930,19 +929,6 @@
}
/**
- * Release the local resources like {@link #release} but also
- * remove the Surface from the screen.
- * @hide
- */
- public void remove() {
- if (mNativeObject != 0) {
- nativeDestroy(mNativeObject);
- mNativeObject = 0;
- }
- mCloseGuard.close();
- }
-
- /**
* Disconnect any client still connected to the surface.
* @hide
*/
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index 254d04e..d11548d 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -23,7 +23,6 @@
import android.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.res.CompatibilityInfo.Translator;
-import android.content.res.Configuration;
import android.graphics.BlendMode;
import android.graphics.Canvas;
import android.graphics.Color;
@@ -100,10 +99,10 @@
public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallback {
private static final String TAG = "SurfaceView";
private static final boolean DEBUG = false;
+ private static final boolean DEBUG_POSITION = false;
@UnsupportedAppUsage
- final ArrayList<SurfaceHolder.Callback> mCallbacks
- = new ArrayList<SurfaceHolder.Callback>();
+ final ArrayList<SurfaceHolder.Callback> mCallbacks = new ArrayList<>();
final int[] mLocation = new int[2];
@@ -126,8 +125,8 @@
// we need to preserve the old one until the new one has drawn.
SurfaceControl mDeferredDestroySurfaceControl;
SurfaceControl mBackgroundControl;
+ final Object mSurfaceControlLock = new Object();
final Rect mTmpRect = new Rect();
- final Configuration mConfiguration = new Configuration();
Paint mRoundedViewportPaint;
@@ -137,25 +136,16 @@
boolean mIsCreating = false;
private volatile boolean mRtHandlingPositionUpdates = false;
- private final ViewTreeObserver.OnScrollChangedListener mScrollChangedListener
- = new ViewTreeObserver.OnScrollChangedListener() {
- @Override
- public void onScrollChanged() {
- updateSurface();
- }
- };
+ private final ViewTreeObserver.OnScrollChangedListener mScrollChangedListener =
+ this::updateSurface;
@UnsupportedAppUsage
- private final ViewTreeObserver.OnPreDrawListener mDrawListener =
- new ViewTreeObserver.OnPreDrawListener() {
- @Override
- public boolean onPreDraw() {
- // reposition ourselves where the surface is
- mHaveFrame = getWidth() > 0 && getHeight() > 0;
- updateSurface();
- return true;
- }
- };
+ private final ViewTreeObserver.OnPreDrawListener mDrawListener = () -> {
+ // reposition ourselves where the surface is
+ mHaveFrame = getWidth() > 0 && getHeight() > 0;
+ updateSurface();
+ return true;
+ };
boolean mRequestedVisible = false;
boolean mWindowVisibility = false;
@@ -173,6 +163,9 @@
@UnsupportedAppUsage
int mRequestedFormat = PixelFormat.RGB_565;
+ boolean mUseAlpha = false;
+ float mSurfaceAlpha = 1f;
+
@UnsupportedAppUsage
boolean mHaveFrame = false;
boolean mSurfaceCreated = false;
@@ -190,7 +183,6 @@
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
final Rect mSurfaceFrame = new Rect();
int mLastSurfaceWidth = -1, mLastSurfaceHeight = -1;
- private Translator mTranslator;
private boolean mGlobalListenersAdded;
private boolean mAttachedToWindow;
@@ -200,6 +192,7 @@
private int mPendingReportDraws;
private SurfaceControl.Transaction mRtTransaction = new SurfaceControl.Transaction();
+ private SurfaceControl.Transaction mTmpTransaction = new SurfaceControl.Transaction();
public SurfaceView(Context context) {
this(context, null);
@@ -288,6 +281,152 @@
updateSurface();
}
+ /**
+ * Make alpha value of this view reflect onto the surface. This can only be called from at most
+ * one SurfaceView within a view tree.
+ *
+ * <p class="note"><strong>Note:</strong> Alpha value of the view is ignored and the underlying
+ * surface is rendered opaque by default.</p>
+ *
+ * @hide
+ */
+ public void setUseAlpha() {
+ if (!mUseAlpha) {
+ mUseAlpha = true;
+ updateSurfaceAlpha();
+ }
+ }
+
+ @Override
+ public void setAlpha(float alpha) {
+ // Sets the opacity of the view to a value, where 0 means the view is completely transparent
+ // and 1 means the view is completely opaque.
+ //
+ // Note: Alpha value of this view is ignored by default. To enable alpha blending, you need
+ // to call setUseAlpha() as well.
+ // This view doesn't support translucent opacity if the view is located z-below, since the
+ // logic to punch a hole in the view hierarchy cannot handle such case. See also
+ // #clearSurfaceViewPort(Canvas)
+ if (DEBUG) {
+ Log.d(TAG, System.identityHashCode(this)
+ + " setAlpha: mUseAlpha = " + mUseAlpha + " alpha=" + alpha);
+ }
+ super.setAlpha(alpha);
+ updateSurfaceAlpha();
+ }
+
+ private float getFixedAlpha() {
+ // Compute alpha value to be set on the underlying surface.
+ final float alpha = getAlpha();
+ return mUseAlpha && (mSubLayer > 0 || alpha == 0f) ? alpha : 1f;
+ }
+
+ private void updateSurfaceAlpha() {
+ if (!mUseAlpha) {
+ if (DEBUG) {
+ Log.d(TAG, System.identityHashCode(this)
+ + " updateSurfaceAlpha: setUseAlpha() is not called, ignored.");
+ }
+ return;
+ }
+ final float viewAlpha = getAlpha();
+ if (mSubLayer < 0 && 0f < viewAlpha && viewAlpha < 1f) {
+ Log.w(TAG, System.identityHashCode(this)
+ + " updateSurfaceAlpha:"
+ + " translucent color is not supported for a surface placed z-below.");
+ }
+ if (!mHaveFrame) {
+ if (DEBUG) {
+ Log.d(TAG, System.identityHashCode(this)
+ + " updateSurfaceAlpha: has no surface.");
+ }
+ return;
+ }
+ final ViewRootImpl viewRoot = getViewRootImpl();
+ if (viewRoot == null) {
+ if (DEBUG) {
+ Log.d(TAG, System.identityHashCode(this)
+ + " updateSurfaceAlpha: ViewRootImpl not available.");
+ }
+ return;
+ }
+ if (mSurfaceControl == null) {
+ if (DEBUG) {
+ Log.d(TAG, System.identityHashCode(this)
+ + "updateSurfaceAlpha:"
+ + " surface is not yet created, or already released.");
+ }
+ return;
+ }
+ final Surface parent = viewRoot.mSurface;
+ if (parent == null || !parent.isValid()) {
+ if (DEBUG) {
+ Log.d(TAG, System.identityHashCode(this)
+ + " updateSurfaceAlpha: ViewRootImpl has no valid surface");
+ }
+ return;
+ }
+ final float alpha = getFixedAlpha();
+ if (alpha != mSurfaceAlpha) {
+ if (isHardwareAccelerated()) {
+ /*
+ * Schedule a callback that reflects an alpha value onto the underlying surfaces.
+ * This gets called on a RenderThread worker thread, so members accessed here must
+ * be protected by a lock.
+ */
+ viewRoot.registerRtFrameCallback(frame -> {
+ try {
+ final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
+ synchronized (mSurfaceControlLock) {
+ if (!parent.isValid()) {
+ if (DEBUG) {
+ Log.d(TAG, System.identityHashCode(this)
+ + " updateSurfaceAlpha RT:"
+ + " ViewRootImpl has no valid surface");
+ }
+ return;
+ }
+ if (mSurfaceControl == null) {
+ if (DEBUG) {
+ Log.d(TAG, System.identityHashCode(this)
+ + "updateSurfaceAlpha RT:"
+ + " mSurfaceControl has already released");
+ }
+ return;
+ }
+ if (DEBUG) {
+ Log.d(TAG, System.identityHashCode(this)
+ + " updateSurfaceAlpha RT: set alpha=" + alpha);
+ }
+ t.setAlpha(mSurfaceControl, alpha);
+ t.deferTransactionUntilSurface(mSurfaceControl, parent, frame);
+ }
+ // It's possible that mSurfaceControl is released in the UI thread before
+ // the transaction completes. If that happens, an exception is thrown, which
+ // must be caught immediately.
+ t.apply();
+ } catch (Exception e) {
+ Log.e(TAG, System.identityHashCode(this)
+ + "updateSurfaceAlpha RT: Exception during surface transaction", e);
+ }
+ });
+ damageInParent();
+ } else {
+ if (DEBUG) {
+ Log.d(TAG, System.identityHashCode(this)
+ + " updateSurfaceAlpha: set alpha=" + alpha);
+ }
+ SurfaceControl.openTransaction();
+ try {
+ mSurfaceControl.setAlpha(alpha);
+ } finally {
+ SurfaceControl.closeTransaction();
+ }
+ }
+ mSurfaceAlpha = alpha;
+ }
+ }
+
private void performDrawFinished() {
if (mPendingReportDraws > 0) {
mDrawFinished = true;
@@ -337,11 +476,7 @@
mRequestedVisible = false;
updateSurface();
- if (mSurfaceControl != null) {
- mSurfaceControl.remove();
- }
- mSurfaceControl = null;
-
+ releaseSurfaces();
mHaveFrame = false;
super.onDetachedFromWindow();
@@ -510,15 +645,6 @@
}
}
- private Rect getParentSurfaceInsets() {
- final ViewRootImpl root = getViewRootImpl();
- if (root == null) {
- return null;
- } else {
- return root.mWindowAttributes.surfaceInsets;
- }
- }
-
private void updateBackgroundVisibilityInTransaction(SurfaceControl viewRoot) {
if (mBackgroundControl == null) {
return;
@@ -532,29 +658,40 @@
}
private void releaseSurfaces() {
- if (mSurfaceControl != null) {
- mSurfaceControl.remove();
- mSurfaceControl = null;
+ synchronized (mSurfaceControlLock) {
+ if (mSurfaceControl != null) {
+ mTmpTransaction.remove(mSurfaceControl);
+ mSurfaceControl = null;
+ }
+ if (mBackgroundControl != null) {
+ mTmpTransaction.remove(mBackgroundControl);
+ mBackgroundControl = null;
+ }
+ mTmpTransaction.apply();
}
- if (mBackgroundControl != null) {
- mBackgroundControl.remove();
- mBackgroundControl = null;
- }
+ mSurfaceAlpha = 1f;
}
/** @hide */
protected void updateSurface() {
if (!mHaveFrame) {
+ if (DEBUG) {
+ Log.d(TAG, System.identityHashCode(this) + " updateSurface: has no frame");
+ }
return;
}
ViewRootImpl viewRoot = getViewRootImpl();
if (viewRoot == null || viewRoot.mSurface == null || !viewRoot.mSurface.isValid()) {
+ if (DEBUG) {
+ Log.d(TAG, System.identityHashCode(this)
+ + " updateSurface: no valid surface");
+ }
return;
}
- mTranslator = viewRoot.mTranslator;
- if (mTranslator != null) {
- mSurface.setCompatibilityTranslator(mTranslator);
+ final Translator translator = viewRoot.mTranslator;
+ if (translator != null) {
+ mSurface.setCompatibilityTranslator(translator);
}
int myWidth = mRequestedWidth;
@@ -562,20 +699,25 @@
int myHeight = mRequestedHeight;
if (myHeight <= 0) myHeight = getHeight();
+ final float alpha = getFixedAlpha();
final boolean formatChanged = mFormat != mRequestedFormat;
final boolean visibleChanged = mVisible != mRequestedVisible;
+ final boolean alphaChanged = mSurfaceAlpha != alpha;
final boolean creating = (mSurfaceControl == null || formatChanged || visibleChanged)
&& mRequestedVisible;
final boolean sizeChanged = mSurfaceWidth != myWidth || mSurfaceHeight != myHeight;
final boolean windowVisibleChanged = mWindowVisibility != mLastWindowVisibility;
boolean redrawNeeded = false;
- if (creating || formatChanged || sizeChanged || visibleChanged || windowVisibleChanged) {
+ if (creating || formatChanged || sizeChanged || visibleChanged || (mUseAlpha
+ && alphaChanged) || windowVisibleChanged) {
getLocationInWindow(mLocation);
if (DEBUG) Log.i(TAG, System.identityHashCode(this) + " "
+ "Changes: creating=" + creating
+ " format=" + formatChanged + " size=" + sizeChanged
+ + " visible=" + visibleChanged + " alpha=" + alphaChanged
+ + " mUseAlpha=" + mUseAlpha
+ " visible=" + visibleChanged
+ " left=" + (mWindowSpaceLeft != mLocation[0])
+ " top=" + (mWindowSpaceTop != mLocation[1]));
@@ -593,11 +735,11 @@
mScreenRect.top = mWindowSpaceTop;
mScreenRect.right = mWindowSpaceLeft + getWidth();
mScreenRect.bottom = mWindowSpaceTop + getHeight();
- if (mTranslator != null) {
- mTranslator.translateRectInAppWindowToScreen(mScreenRect);
+ if (translator != null) {
+ translator.translateRectInAppWindowToScreen(mScreenRect);
}
- final Rect surfaceInsets = getParentSurfaceInsets();
+ final Rect surfaceInsets = viewRoot.mWindowAttributes.surfaceInsets;
mScreenRect.offset(surfaceInsets.left, surfaceInsets.top);
if (creating) {
@@ -646,6 +788,10 @@
mSurfaceControl.hide();
}
updateBackgroundVisibilityInTransaction(viewRoot.getSurfaceControl());
+ if (mUseAlpha) {
+ mSurfaceControl.setAlpha(alpha);
+ mSurfaceAlpha = alpha;
+ }
// While creating the surface, we will set it's initial
// geometry. Outside of that though, we should generally
@@ -680,11 +826,11 @@
mSurfaceFrame.left = 0;
mSurfaceFrame.top = 0;
- if (mTranslator == null) {
+ if (translator == null) {
mSurfaceFrame.right = mSurfaceWidth;
mSurfaceFrame.bottom = mSurfaceHeight;
} else {
- float appInvertedScale = mTranslator.applicationInvertedScale;
+ float appInvertedScale = translator.applicationInvertedScale;
mSurfaceFrame.right = (int) (mSurfaceWidth * appInvertedScale + 0.5f);
mSurfaceFrame.bottom = (int) (mSurfaceHeight * appInvertedScale + 0.5f);
}
@@ -702,7 +848,7 @@
try {
redrawNeeded |= visible && !mDrawFinished;
- SurfaceHolder.Callback callbacks[] = null;
+ SurfaceHolder.Callback[] callbacks = null;
final boolean surfaceChanged = creating;
if (mSurfaceCreated && (surfaceChanged || (!visible && visibleChanged))) {
@@ -788,7 +934,6 @@
mIsCreating = false;
if (mSurfaceControl != null && !mSurfaceCreated) {
mSurface.release();
-
releaseSurfaces();
}
}
@@ -818,8 +963,8 @@
mScreenRect.set(mWindowSpaceLeft, mWindowSpaceTop,
mWindowSpaceLeft + mLocation[0], mWindowSpaceTop + mLocation[1]);
- if (mTranslator != null) {
- mTranslator.translateRectInAppWindowToScreen(mScreenRect);
+ if (translator != null) {
+ translator.translateRectInAppWindowToScreen(mScreenRect);
}
if (mSurfaceControl == null) {
@@ -828,10 +973,13 @@
if (!isHardwareAccelerated() || !mRtHandlingPositionUpdates) {
try {
- if (DEBUG) Log.d(TAG, String.format("%d updateSurfacePosition UI, " +
- "postion = [%d, %d, %d, %d]", System.identityHashCode(this),
- mScreenRect.left, mScreenRect.top,
- mScreenRect.right, mScreenRect.bottom));
+ if (DEBUG_POSITION) {
+ Log.d(TAG, String.format("%d updateSurfacePosition UI, "
+ + "position = [%d, %d, %d, %d]",
+ System.identityHashCode(this),
+ mScreenRect.left, mScreenRect.top,
+ mScreenRect.right, mScreenRect.bottom));
+ }
setParentSpaceRectangle(mScreenRect, -1);
} catch (Exception ex) {
Log.e(TAG, "Exception configuring surface", ex);
@@ -848,13 +996,11 @@
}
if (mDeferredDestroySurfaceControl != null) {
- mDeferredDestroySurfaceControl.remove();
+ mTmpTransaction.remove(mDeferredDestroySurfaceControl).apply();
mDeferredDestroySurfaceControl = null;
}
- runOnUiThread(() -> {
- performDrawFinished();
- });
+ runOnUiThread(this::performDrawFinished);
}
/**
@@ -884,7 +1030,6 @@
if (mViewVisibility) {
mRtTransaction.show(surface);
}
-
}
private void setParentSpaceRectangle(Rect position, long frameNumber) {
@@ -925,10 +1070,10 @@
return;
}
try {
- if (DEBUG) {
+ if (DEBUG_POSITION) {
Log.d(TAG, String.format(
"%d updateSurfacePosition RenderWorker, frameNr = %d, "
- + "postion = [%d, %d, %d, %d]",
+ + "position = [%d, %d, %d, %d]",
System.identityHashCode(this), frameNumber,
left, top, right, bottom));
}
@@ -964,7 +1109,7 @@
};
private SurfaceHolder.Callback[] getSurfaceCallbacks() {
- SurfaceHolder.Callback callbacks[];
+ SurfaceHolder.Callback[] callbacks;
synchronized (mCallbacks) {
callbacks = new SurfaceHolder.Callback[mCallbacks.size()];
mCallbacks.toArray(callbacks);
@@ -1034,7 +1179,7 @@
synchronized (mCallbacks) {
// This is a linear search, but in practice we'll
// have only a couple callbacks, so it doesn't matter.
- if (mCallbacks.contains(callback) == false) {
+ if (!mCallbacks.contains(callback)) {
mCallbacks.add(callback);
}
}
diff --git a/core/java/android/view/ThreadedRenderer.java b/core/java/android/view/ThreadedRenderer.java
index 3d3d5dc..f18aa81 100644
--- a/core/java/android/view/ThreadedRenderer.java
+++ b/core/java/android/view/ThreadedRenderer.java
@@ -17,6 +17,7 @@
package android.view;
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.HardwareRenderer;
@@ -35,6 +36,7 @@
import java.io.FileDescriptor;
import java.io.PrintWriter;
+import java.util.ArrayList;
/**
* Threaded renderer that proxies the rendering to a render thread. Most calls
@@ -300,7 +302,8 @@
private boolean mEnabled;
private boolean mRequested = true;
- private FrameDrawingCallback mNextRtFrameCallback;
+ @Nullable
+ private ArrayList<FrameDrawingCallback> mNextRtFrameCallbacks;
ThreadedRenderer(Context context, boolean translucent, String name) {
super();
@@ -441,8 +444,11 @@
*
* @param callback The callback to register.
*/
- void registerRtFrameCallback(FrameDrawingCallback callback) {
- mNextRtFrameCallback = callback;
+ void registerRtFrameCallback(@NonNull FrameDrawingCallback callback) {
+ if (mNextRtFrameCallbacks == null) {
+ mNextRtFrameCallbacks = new ArrayList<>();
+ }
+ mNextRtFrameCallbacks.add(callback);
}
/**
@@ -583,10 +589,14 @@
// Consume and set the frame callback after we dispatch draw to the view above, but before
// onPostDraw below which may reset the callback for the next frame. This ensures that
// updates to the frame callback during scroll handling will also apply in this frame.
- final FrameDrawingCallback callback = mNextRtFrameCallback;
- mNextRtFrameCallback = null;
- if (callback != null) {
- setFrameCallback(callback);
+ if (mNextRtFrameCallbacks != null) {
+ final ArrayList<FrameDrawingCallback> frameCallbacks = mNextRtFrameCallbacks;
+ mNextRtFrameCallbacks = null;
+ setFrameCallback(frame -> {
+ for (int i = 0; i < frameCallbacks.size(); ++i) {
+ frameCallbacks.get(i).onFrameDraw(frame);
+ }
+ });
}
if (mRootNodeNeedsUpdate || !mRootNode.hasDisplayList()) {
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 4e86e60..c6536bb 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -14344,6 +14344,14 @@
}
/**
+ * @return true if this view and all ancestors are visible as of the last
+ * {@link #onVisibilityAggregated(boolean)} call.
+ */
+ boolean isAggregatedVisible() {
+ return (mPrivateFlags3 & PFLAG3_AGGREGATED_VISIBLE) != 0;
+ }
+
+ /**
* Internal dispatching method for {@link #onVisibilityAggregated}. Overridden by
* ViewGroup. Intended to only be called when {@link #isAttachedToWindow()},
* {@link #getWindowVisibility()} is {@link #VISIBLE} and this view's parent {@link #isShown()}.
@@ -14371,7 +14379,7 @@
@CallSuper
public void onVisibilityAggregated(boolean isVisible) {
// Update our internal visibility tracking so we can detect changes
- boolean oldVisible = (mPrivateFlags3 & PFLAG3_AGGREGATED_VISIBLE) != 0;
+ boolean oldVisible = isAggregatedVisible();
mPrivateFlags3 = isVisible ? (mPrivateFlags3 | PFLAG3_AGGREGATED_VISIBLE)
: (mPrivateFlags3 & ~PFLAG3_AGGREGATED_VISIBLE);
if (isVisible && mAttachInfo != null) {
@@ -14423,6 +14431,9 @@
}
notifyAppearedOrDisappearedForContentCaptureIfNeeded(isVisible);
+ if (!getSystemGestureExclusionRects().isEmpty() && isVisible != oldVisible) {
+ postUpdateSystemGestureExclusionRects();
+ }
}
/**
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 440df89..57a01a3 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -1129,7 +1129,7 @@
*
* @param callback The callback to register.
*/
- public void registerRtFrameCallback(FrameDrawingCallback callback) {
+ public void registerRtFrameCallback(@NonNull FrameDrawingCallback callback) {
if (mAttachInfo.mThreadedRenderer != null) {
mAttachInfo.mThreadedRenderer.registerRtFrameCallback(frame -> {
try {
@@ -1637,7 +1637,7 @@
mSurfaceSession = null;
if (mBoundsSurfaceControl != null) {
- mBoundsSurfaceControl.remove();
+ mTransaction.remove(mBoundsSurfaceControl).apply();
mBoundsSurface.release();
mBoundsSurfaceControl = null;
}
diff --git a/core/java/android/view/ViewTreeObserver.java b/core/java/android/view/ViewTreeObserver.java
index c50a3aa..9a5f4c9 100644
--- a/core/java/android/view/ViewTreeObserver.java
+++ b/core/java/android/view/ViewTreeObserver.java
@@ -1074,7 +1074,7 @@
* be called manually if you are forcing the drawing on a View or a hierarchy of Views
* that are not attached to a Window or in the GONE state.
*
- * @return True if the current draw should be canceled and resceduled, false otherwise.
+ * @return True if the current draw should be canceled and rescheduled, false otherwise.
*/
@SuppressWarnings("unchecked")
public final boolean dispatchOnPreDraw() {
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index 2e5a750..36fea58 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -1473,6 +1473,9 @@
* <p>When this flag is enabled for a window, it automatically sets
* the system UI visibility flags {@link View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
* {@link View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}.</p>
+ *
+ * <p>Note: For devices that support
+ * {@link android.content.pm.PackageManager#FEATURE_AUTOMOTIVE} this flag may be ignored.
*/
public static final int FLAG_TRANSLUCENT_STATUS = 0x04000000;
@@ -1492,6 +1495,10 @@
* <p>When this flag is enabled for a window, it automatically sets
* the system UI visibility flags {@link View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
* {@link View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION}.</p>
+ *
+ * <p>Note: For devices that support
+ * {@link android.content.pm.PackageManager#FEATURE_AUTOMOTIVE} this flag can be disabled
+ * by the car manufacturers.
*/
public static final int FLAG_TRANSLUCENT_NAVIGATION = 0x08000000;
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index d302c2b..032af1c 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -707,9 +707,10 @@
if (mBindSequence != bindSequence) {
return;
}
- if (matrixValues == null) {
- // That this app is unbound from the parent ActivityView. In this case,
- // calling updateCursorAnchorInfo() isn't safe. Only clear the matrix.
+ if (matrixValues == null || mActivityViewToScreenMatrix == null) {
+ // Either InputBoundResult#mActivityViewToScreenMatrixValues is null
+ // OR this app is unbound from the parent ActivityView. In this case,
+ // calling updateCursorAnchorInfo() isn't safe. Only clear the matrix.
mActivityViewToScreenMatrix = null;
return;
}
diff --git a/core/java/android/widget/Magnifier.java b/core/java/android/widget/Magnifier.java
index ccafa64..d3c6972 100644
--- a/core/java/android/widget/Magnifier.java
+++ b/core/java/android/widget/Magnifier.java
@@ -1035,7 +1035,7 @@
// Destroy the renderer. This will not proceed until pending frame callbacks complete.
mRenderer.destroy();
mSurface.destroy();
- mSurfaceControl.remove();
+ new SurfaceControl.Transaction().remove(mSurfaceControl).apply();
mSurfaceSession.kill();
mHandler.removeCallbacks(mMagnifierUpdater);
if (mBitmap != null) {
diff --git a/core/java/android/widget/SelectionActionModeHelper.java b/core/java/android/widget/SelectionActionModeHelper.java
index 51ca805..d0f8093 100644
--- a/core/java/android/widget/SelectionActionModeHelper.java
+++ b/core/java/android/widget/SelectionActionModeHelper.java
@@ -999,6 +999,7 @@
}
private void onTimeOut() {
+ Log.d(LOG_TAG, "Timeout in TextClassificationAsyncTask");
if (getStatus() == Status.RUNNING) {
onPostExecute(mTimeOutResultSupplier.get());
}
diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java
index 00206fc..cae1f38 100644
--- a/core/java/com/android/internal/app/ChooserActivity.java
+++ b/core/java/com/android/internal/app/ChooserActivity.java
@@ -24,6 +24,7 @@
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.annotation.IntDef;
+import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.Activity;
import android.app.ActivityManager;
@@ -120,6 +121,7 @@
import java.io.IOException;
import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Arrays;
@@ -164,6 +166,8 @@
public static final String LAUNCH_LOCATON_DIRECT_SHARE = "direct_share";
private static final int APP_PREDICTION_SHARE_TARGET_QUERY_PACKAGE_LIMIT = 20;
public static final String APP_PREDICTION_INTENT_FILTER_KEY = "intent_filter";
+
+ private boolean mIsAppPredictorComponentAvailable;
private AppPredictor mAppPredictor;
private AppPredictor.Callback mAppPredictorCallback;
private Map<ChooserTarget, AppTarget> mDirectShareAppTargetCache;
@@ -176,6 +180,20 @@
private static final boolean USE_SHORTCUT_MANAGER_FOR_DIRECT_TARGETS = true;
private static final boolean USE_CHOOSER_TARGET_SERVICE_FOR_DIRECT_TARGETS = true;
+ public static final int TARGET_TYPE_DEFAULT = 0;
+ public static final int TARGET_TYPE_CHOOSER_TARGET = 1;
+ public static final int TARGET_TYPE_SHORTCUTS_FROM_SHORTCUT_MANAGER = 2;
+ public static final int TARGET_TYPE_SHORTCUTS_FROM_PREDICTION_SERVICE = 3;
+
+ @IntDef(flag = false, prefix = { "TARGET_TYPE_" }, value = {
+ TARGET_TYPE_DEFAULT,
+ TARGET_TYPE_CHOOSER_TARGET,
+ TARGET_TYPE_SHORTCUTS_FROM_SHORTCUT_MANAGER,
+ TARGET_TYPE_SHORTCUTS_FROM_PREDICTION_SERVICE
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface ShareTargetType {}
+
/**
* The transition time between placeholders for direct share to a message
* indicating that non are available.
@@ -216,9 +234,9 @@
private int mCurrAvailableWidth = 0;
/** {@link ChooserActivity#getBaseScore} */
- private static final float CALLER_TARGET_SCORE_BOOST = 900.f;
+ public static final float CALLER_TARGET_SCORE_BOOST = 900.f;
/** {@link ChooserActivity#getBaseScore} */
- private static final float SHORTCUT_TARGET_SCORE_BOOST = 90.f;
+ public static final float SHORTCUT_TARGET_SCORE_BOOST = 90.f;
private static final String TARGET_DETAILS_FRAGMENT_TAG = "targetDetailsFragment";
// TODO: Update to handle landscape instead of using static value
private static final int MAX_RANKED_TARGETS = 4;
@@ -441,7 +459,7 @@
}
if (sri.resultTargets != null) {
mChooserListAdapter.addServiceResults(sri.originalTarget,
- sri.resultTargets, false);
+ sri.resultTargets, TARGET_TYPE_CHOOSER_TARGET);
}
unbindService(sri.connection);
sri.connection.destroy();
@@ -472,7 +490,7 @@
final ServiceResultInfo resultInfo = (ServiceResultInfo) msg.obj;
if (resultInfo.resultTargets != null) {
mChooserListAdapter.addServiceResults(resultInfo.originalTarget,
- resultInfo.resultTargets, true);
+ resultInfo.resultTargets, msg.arg1);
}
break;
@@ -491,6 +509,9 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
final long intentReceivedTime = System.currentTimeMillis();
+ // This is the only place this value is being set. Effectively final.
+ mIsAppPredictorComponentAvailable = isAppPredictionServiceAvailable();
+
mIsSuccessfullySelected = false;
Intent intent = getIntent();
Parcelable targetParcelable = intent.getParcelableExtra(Intent.EXTRA_INTENT);
@@ -707,6 +728,38 @@
}
/**
+ * Returns true if app prediction service is defined and the component exists on device.
+ */
+ @VisibleForTesting
+ public boolean isAppPredictionServiceAvailable() {
+ if (getPackageManager().getAppPredictionServicePackageName() == null) {
+ // Default AppPredictionService is not defined.
+ return false;
+ }
+
+ final String appPredictionServiceName =
+ getString(R.string.config_defaultAppPredictionService);
+ if (appPredictionServiceName == null) {
+ return false;
+ }
+ final ComponentName appPredictionComponentName =
+ ComponentName.unflattenFromString(appPredictionServiceName);
+ if (appPredictionComponentName == null) {
+ return false;
+ }
+
+ // Check if the app prediction component actually exists on the device.
+ Intent intent = new Intent();
+ intent.setComponent(appPredictionComponentName);
+ if (getPackageManager().resolveService(intent, PackageManager.MATCH_ALL) == null) {
+ Log.e(TAG, "App prediction service is defined, but does not exist: "
+ + appPredictionServiceName);
+ return false;
+ }
+ return true;
+ }
+
+ /**
* Check if the profile currently used is a work profile.
* @return true if it is work profile, false if it is parent profile (or no work profile is
* set up)
@@ -766,6 +819,11 @@
clipboardManager.setPrimaryClip(clipData);
Toast.makeText(getApplicationContext(), R.string.copied, Toast.LENGTH_SHORT).show();
+ // Log share completion via copy
+ LogMaker targetLogMaker = new LogMaker(
+ MetricsEvent.ACTION_ACTIVITY_CHOOSER_PICKED_SYSTEM_TARGET).setSubtype(1);
+ getMetricsLogger().write(targetLogMaker);
+
finish();
}
}
@@ -1178,7 +1236,7 @@
mChooserListAdapter = (ChooserListAdapter) adapter;
if (mCallerChooserTargets != null && mCallerChooserTargets.length > 0) {
mChooserListAdapter.addServiceResults(null, Lists.newArrayList(mCallerChooserTargets),
- false);
+ TARGET_TYPE_DEFAULT);
}
mChooserRowAdapter = new ChooserRowAdapter(mChooserListAdapter);
if (listView != null) {
@@ -1524,33 +1582,32 @@
}
}
+ // If |appTargets| is not null, results are from AppPredictionService and already sorted.
+ final int shortcutType = (appTargets == null ? TARGET_TYPE_SHORTCUTS_FROM_SHORTCUT_MANAGER :
+ TARGET_TYPE_SHORTCUTS_FROM_PREDICTION_SERVICE);
+
// Match ShareShortcutInfos with DisplayResolveInfos to be able to use the old code path
// for direct share targets. After ShareSheet is refactored we should use the
// ShareShortcutInfos directly.
boolean resultMessageSent = false;
for (int i = 0; i < driList.size(); i++) {
- List<ChooserTarget> chooserTargets = new ArrayList<>();
+ List<ShortcutManager.ShareShortcutInfo> matchingShortcuts = new ArrayList<>();
for (int j = 0; j < resultList.size(); j++) {
if (driList.get(i).getResolvedComponentName().equals(
resultList.get(j).getTargetComponent())) {
- ShortcutManager.ShareShortcutInfo shareShortcutInfo = resultList.get(j);
- // Incoming results are ordered but without a score. Create a score
- // based on the index in order to be sorted appropriately when joined
- // with legacy direct share api results.
- float score = Math.max(1.0f - (0.05f * j), 0.0f);
- ChooserTarget chooserTarget = convertToChooserTarget(shareShortcutInfo, score);
- chooserTargets.add(chooserTarget);
- if (mDirectShareAppTargetCache != null && appTargets != null) {
- mDirectShareAppTargetCache.put(chooserTarget, appTargets.get(j));
- }
+ matchingShortcuts.add(resultList.get(j));
}
}
- if (chooserTargets.isEmpty()) {
+ if (matchingShortcuts.isEmpty()) {
continue;
}
+ List<ChooserTarget> chooserTargets = convertToChooserTarget(
+ matchingShortcuts, resultList, appTargets, shortcutType);
+
final Message msg = Message.obtain();
msg.what = ChooserHandler.SHORTCUT_MANAGER_SHARE_TARGET_RESULT;
msg.obj = new ServiceResultInfo(driList.get(i), chooserTargets, null);
+ msg.arg1 = shortcutType;
mChooserHandler.sendMessage(msg);
resultMessageSent = true;
}
@@ -1584,23 +1641,69 @@
return false;
}
- private ChooserTarget convertToChooserTarget(ShortcutManager.ShareShortcutInfo shareShortcut,
- float score) {
- ShortcutInfo shortcutInfo = shareShortcut.getShortcutInfo();
- Bundle extras = new Bundle();
- extras.putString(Intent.EXTRA_SHORTCUT_ID, shortcutInfo.getId());
- return new ChooserTarget(
- // The name of this target.
- shortcutInfo.getShortLabel(),
- // Don't load the icon until it is selected to be shown
- null,
- // The ranking score for this target (0.0-1.0); the system will omit items with low
- // scores when there are too many Direct Share items.
- score,
- // The name of the component to be launched if this target is chosen.
- shareShortcut.getTargetComponent().clone(),
- // The extra values here will be merged into the Intent when this target is chosen.
- extras);
+ /**
+ * Converts a list of ShareShortcutInfos to ChooserTargets.
+ * @param matchingShortcuts List of shortcuts, all from the same package, that match the current
+ * share intent filter.
+ * @param allShortcuts List of all the shortcuts from all the packages on the device that are
+ * returned for the current sharing action.
+ * @param allAppTargets List of AppTargets. Null if the results are not from prediction service.
+ * @param shortcutType One of the values TARGET_TYPE_SHORTCUTS_FROM_SHORTCUT_MANAGER or
+ * TARGET_TYPE_SHORTCUTS_FROM_PREDICTION_SERVICE
+ * @return A list of ChooserTargets sorted by score in descending order.
+ */
+ @VisibleForTesting
+ @NonNull
+ public List<ChooserTarget> convertToChooserTarget(
+ @NonNull List<ShortcutManager.ShareShortcutInfo> matchingShortcuts,
+ @NonNull List<ShortcutManager.ShareShortcutInfo> allShortcuts,
+ @Nullable List<AppTarget> allAppTargets, @ShareTargetType int shortcutType) {
+ // A set of distinct scores for the matched shortcuts. We use index of a rank in the sorted
+ // list instead of the actual rank value when converting a rank to a score.
+ List<Integer> scoreList = new ArrayList<>();
+ if (shortcutType == TARGET_TYPE_SHORTCUTS_FROM_SHORTCUT_MANAGER) {
+ for (int i = 0; i < matchingShortcuts.size(); i++) {
+ int shortcutRank = matchingShortcuts.get(i).getShortcutInfo().getRank();
+ if (!scoreList.contains(shortcutRank)) {
+ scoreList.add(shortcutRank);
+ }
+ }
+ Collections.sort(scoreList);
+ }
+
+ List<ChooserTarget> chooserTargetList = new ArrayList<>(matchingShortcuts.size());
+ for (int i = 0; i < matchingShortcuts.size(); i++) {
+ ShortcutInfo shortcutInfo = matchingShortcuts.get(i).getShortcutInfo();
+ int indexInAllShortcuts = allShortcuts.indexOf(matchingShortcuts.get(i));
+
+ float score;
+ if (shortcutType == TARGET_TYPE_SHORTCUTS_FROM_PREDICTION_SERVICE) {
+ // Incoming results are ordered. Create a score based on index in the original list.
+ score = Math.max(1.0f - (0.01f * indexInAllShortcuts), 0.0f);
+ } else {
+ // Create a score based on the rank of the shortcut.
+ int rankIndex = scoreList.indexOf(shortcutInfo.getRank());
+ score = Math.max(1.0f - (0.01f * rankIndex), 0.0f);
+ }
+
+ Bundle extras = new Bundle();
+ extras.putString(Intent.EXTRA_SHORTCUT_ID, shortcutInfo.getId());
+ ChooserTarget chooserTarget = new ChooserTarget(shortcutInfo.getShortLabel(),
+ null, // Icon will be loaded later if this target is selected to be shown.
+ score, matchingShortcuts.get(i).getTargetComponent().clone(), extras);
+
+ chooserTargetList.add(chooserTarget);
+ if (mDirectShareAppTargetCache != null && allAppTargets != null) {
+ mDirectShareAppTargetCache.put(chooserTarget,
+ allAppTargets.get(indexInAllShortcuts));
+ }
+ }
+
+ // Sort ChooserTargets by score in descending order
+ Comparator<ChooserTarget> byScore =
+ (ChooserTarget a, ChooserTarget b) -> -Float.compare(a.getScore(), b.getScore());
+ Collections.sort(chooserTargetList, byScore);
+ return chooserTargetList;
}
private String convertServiceName(String packageName, String serviceName) {
@@ -1635,10 +1738,6 @@
mServiceConnections.clear();
}
- public void onSetupVoiceInteraction() {
- // Do nothing. We'll send the voice stuff ourselves.
- }
-
private void logDirectShareTargetReceived(int logCategory) {
final long queryTime =
logCategory == MetricsEvent.ACTION_DIRECT_SHARE_TARGETS_LOADED_SHORTCUT_MANAGER
@@ -1693,8 +1792,10 @@
@Nullable
private AppPredictor getAppPredictor() {
- if (mAppPredictor == null
- && getPackageManager().getAppPredictionServicePackageName() != null) {
+ if (!mIsAppPredictorComponentAvailable) {
+ return null;
+ }
+ if (mAppPredictor == null) {
final IntentFilter filter = getTargetIntentFilter();
Bundle extras = new Bundle();
extras.putParcelable(APP_PREDICTION_INTENT_FILTER_KEY, filter);
@@ -2642,7 +2743,7 @@
* if score is too low.
*/
public void addServiceResults(DisplayResolveInfo origTarget, List<ChooserTarget> targets,
- boolean isShortcutResult) {
+ @ShareTargetType int targetType) {
if (DEBUG) {
Log.d(TAG, "addServiceResults " + origTarget + ", " + targets.size()
+ " targets");
@@ -2652,9 +2753,12 @@
return;
}
- final float baseScore = getBaseScore(origTarget, isShortcutResult);
+ final float baseScore = getBaseScore(origTarget, targetType);
Collections.sort(targets, mBaseTargetComparator);
+ final boolean isShortcutResult =
+ (targetType == TARGET_TYPE_SHORTCUTS_FROM_SHORTCUT_MANAGER
+ || targetType == TARGET_TYPE_SHORTCUTS_FROM_PREDICTION_SERVICE);
final int maxTargets = isShortcutResult ? mMaxShortcutTargetsPerApp
: MAX_CHOOSER_TARGETS_PER_APP;
float lastScore = 0;
@@ -2705,17 +2809,17 @@
* <li>Legacy direct share targets
* </ol>
*/
- private float getBaseScore(DisplayResolveInfo target, boolean isShortcutResult) {
+ public float getBaseScore(DisplayResolveInfo target, @ShareTargetType int targetType) {
if (target == null) {
return CALLER_TARGET_SCORE_BOOST;
}
- if (isShortcutResult && getAppPredictorForDirectShareIfEnabled() != null) {
+ if (targetType == TARGET_TYPE_SHORTCUTS_FROM_PREDICTION_SERVICE) {
return SHORTCUT_TARGET_SCORE_BOOST;
}
float score = super.getScore(target);
- if (isShortcutResult) {
+ if (targetType == TARGET_TYPE_SHORTCUTS_FROM_SHORTCUT_MANAGER) {
return score * SHORTCUT_TARGET_SCORE_BOOST;
}
diff --git a/core/java/com/android/internal/app/IBatteryStats.aidl b/core/java/com/android/internal/app/IBatteryStats.aidl
index d60d543..15b1d75 100644
--- a/core/java/com/android/internal/app/IBatteryStats.aidl
+++ b/core/java/com/android/internal/app/IBatteryStats.aidl
@@ -106,7 +106,7 @@
void notePhoneOn();
void notePhoneOff();
void notePhoneSignalStrength(in SignalStrength signalStrength);
- void notePhoneDataConnectionState(int dataType, boolean hasData);
+ void notePhoneDataConnectionState(int dataType, boolean hasData, int serviceType);
void notePhoneState(int phoneState);
void noteWifiOn();
void noteWifiOff();
diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java
index 58ce03b..407a85f 100644
--- a/core/java/com/android/internal/app/ResolverActivity.java
+++ b/core/java/com/android/internal/app/ResolverActivity.java
@@ -361,9 +361,6 @@
initSuspendedColorMatrix();
- if (isVoiceInteraction()) {
- onSetupVoiceInteraction();
- }
final Set<String> categories = intent.getCategories();
MetricsLogger.action(this, mAdapter.hasFilteredItem()
? MetricsProto.MetricsEvent.ACTION_SHOW_APP_DISAMBIG_APP_FEATURED
@@ -442,24 +439,21 @@
mSuspendedMatrixColorFilter = new ColorMatrixColorFilter(matrix);
}
- /**
- * Perform any initialization needed for voice interaction.
- */
- public void onSetupVoiceInteraction() {
- // Do it right now. Subclasses may delay this and send it later.
- sendVoiceChoicesIfNeeded();
- }
-
public void sendVoiceChoicesIfNeeded() {
if (!isVoiceInteraction()) {
// Clearly not needed.
return;
}
-
final Option[] options = new Option[mAdapter.getCount()];
for (int i = 0, N = options.length; i < N; i++) {
- options[i] = optionForChooserTarget(mAdapter.getItem(i), i);
+ TargetInfo target = mAdapter.getItem(i);
+ if (target == null) {
+ // If this occurs, a new set of targets is being loaded. Let that complete,
+ // and have the next call to send voice choices proceed instead.
+ return;
+ }
+ options[i] = optionForChooserTarget(target, i);
}
mPickOptionRequest = new PickTargetOptionRequest(
@@ -1872,7 +1866,7 @@
}
}
-
+ sendVoiceChoicesIfNeeded();
postListReadyRunnable();
}
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index 651991d..e1a640ee 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -906,8 +906,6 @@
@VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
protected StopwatchTimer mBluetoothScanTimer;
- boolean mIsCellularTxPowerHigh = false;
-
int mMobileRadioPowerState = DataConnectionRealTimeInfo.DC_POWER_STATE_LOW;
long mMobileRadioActiveStartTime;
StopwatchTimer mMobileRadioActiveTimer;
@@ -5261,16 +5259,26 @@
}
@UnsupportedAppUsage
- public void notePhoneDataConnectionStateLocked(int dataType, boolean hasData) {
+ public void notePhoneDataConnectionStateLocked(int dataType, boolean hasData, int serviceType) {
// BatteryStats uses 0 to represent no network type.
// Telephony does not have a concept of no network type, and uses 0 to represent unknown.
// Unknown is included in DATA_CONNECTION_OTHER.
- int bin = DATA_CONNECTION_NONE;
+ int bin = DATA_CONNECTION_OUT_OF_SERVICE;
if (hasData) {
if (dataType > 0 && dataType <= TelephonyManager.MAX_NETWORK_TYPE) {
bin = dataType;
} else {
- bin = DATA_CONNECTION_OTHER;
+ switch (serviceType) {
+ case ServiceState.STATE_OUT_OF_SERVICE:
+ bin = DATA_CONNECTION_OUT_OF_SERVICE;
+ break;
+ case ServiceState.STATE_EMERGENCY_ONLY:
+ bin = DATA_CONNECTION_EMERGENCY_SERVICE;
+ break;
+ default:
+ bin = DATA_CONNECTION_OTHER;
+ break;
+ }
}
}
if (DEBUG) Log.i(TAG, "Phone Data Connection -> " + dataType + " = " + hasData);
@@ -11190,19 +11198,9 @@
}
}
if (levelMaxTimeSpent == ModemActivityInfo.TX_POWER_LEVELS - 1) {
- if (!mIsCellularTxPowerHigh) {
- mHistoryCur.states2 |= HistoryItem.STATE2_CELLULAR_HIGH_TX_POWER_FLAG;
- addHistoryRecordLocked(elapsedRealtime, uptime);
- mIsCellularTxPowerHigh = true;
- }
- return;
- }
- if (mIsCellularTxPowerHigh) {
- mHistoryCur.states2 &= ~HistoryItem.STATE2_CELLULAR_HIGH_TX_POWER_FLAG;
+ mHistoryCur.states2 |= HistoryItem.STATE2_CELLULAR_HIGH_TX_POWER_FLAG;
addHistoryRecordLocked(elapsedRealtime, uptime);
- mIsCellularTxPowerHigh = false;
}
- return;
}
private final class BluetoothActivityInfoCache {
@@ -13660,7 +13658,6 @@
mCameraOnTimer.readSummaryFromParcelLocked(in);
mBluetoothScanNesting = 0;
mBluetoothScanTimer.readSummaryFromParcelLocked(in);
- mIsCellularTxPowerHigh = false;
int NRPMS = in.readInt();
if (NRPMS > 10000) {
@@ -14644,7 +14641,6 @@
mCameraOnTimer = new StopwatchTimer(mClocks, null, -13, null, mOnBatteryTimeBase, in);
mBluetoothScanNesting = 0;
mBluetoothScanTimer = new StopwatchTimer(mClocks, null, -14, null, mOnBatteryTimeBase, in);
- mIsCellularTxPowerHigh = false;
mDischargeUnplugLevel = in.readInt();
mDischargePlugLevel = in.readInt();
mDischargeCurrentLevel = in.readInt();
diff --git a/core/java/com/android/internal/policy/DecorView.java b/core/java/com/android/internal/policy/DecorView.java
index 7c52a40..07002d7 100644
--- a/core/java/com/android/internal/policy/DecorView.java
+++ b/core/java/com/android/internal/policy/DecorView.java
@@ -796,7 +796,9 @@
updateElevation();
mAllowUpdateElevation = true;
- if (changed && mResizeMode == RESIZE_MODE_DOCKED_DIVIDER) {
+ if (changed
+ && (mResizeMode == RESIZE_MODE_DOCKED_DIVIDER
+ || mDrawLegacyNavigationBarBackground)) {
getViewRootImpl().requestInvalidateRootRenderNode();
}
}
diff --git a/core/java/com/android/internal/util/ScreenshotHelper.java b/core/java/com/android/internal/util/ScreenshotHelper.java
index 7fd94c6..cac691c 100644
--- a/core/java/com/android/internal/util/ScreenshotHelper.java
+++ b/core/java/com/android/internal/util/ScreenshotHelper.java
@@ -1,6 +1,7 @@
package com.android.internal.util;
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -13,6 +14,8 @@
import android.os.UserHandle;
import android.util.Log;
+import java.util.function.Consumer;
+
public class ScreenshotHelper {
private static final String TAG = "ScreenshotHelper";
@@ -34,17 +37,58 @@
}
/**
- * Request a screenshot be taken.
+ * Request a screenshot be taken with a specific timeout.
*
- * @param screenshotType The type of screenshot, for example either
- * {@link android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN}
- * or {@link android.view.WindowManager.TAKE_SCREENSHOT_SELECTED_REGION}
- * @param hasStatus {@code true} if the status bar is currently showing. {@code false} if not.
- * @param hasNav {@code true} if the navigation bar is currently showing. {@code false} if not.
- * @param handler A handler used in case the screenshot times out
+ * Added to support reducing unit test duration; the method variant without a timeout argument
+ * is recommended for general use.
+ *
+ * @param screenshotType The type of screenshot, for example either
+ * {@link android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN}
+ * or
+ * {@link android.view.WindowManager.TAKE_SCREENSHOT_SELECTED_REGION}
+ * @param hasStatus {@code true} if the status bar is currently showing. {@code false}
+ * if
+ * not.
+ * @param hasNav {@code true} if the navigation bar is currently showing. {@code
+ * false}
+ * if not.
+ * @param handler A handler used in case the screenshot times out
+ * @param completionConsumer Consumes `false` if a screenshot was not taken, and `true` if the
+ * screenshot was taken.
*/
public void takeScreenshot(final int screenshotType, final boolean hasStatus,
- final boolean hasNav, @NonNull Handler handler) {
+ final boolean hasNav, @NonNull Handler handler,
+ @Nullable Consumer<Boolean> completionConsumer) {
+ takeScreenshot(screenshotType, hasStatus, hasNav, SCREENSHOT_TIMEOUT_MS, handler,
+ completionConsumer);
+ }
+
+ /**
+ * Request a screenshot be taken.
+ *
+ * Added to support reducing unit test duration; the method variant without a timeout argument
+ * is recommended for general use.
+ *
+ * @param screenshotType The type of screenshot, for example either
+ * {@link android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN}
+ * or
+ * {@link android.view.WindowManager.TAKE_SCREENSHOT_SELECTED_REGION}
+ * @param hasStatus {@code true} if the status bar is currently showing. {@code false}
+ * if
+ * not.
+ * @param hasNav {@code true} if the navigation bar is currently showing. {@code
+ * false}
+ * if not.
+ * @param timeoutMs If the screenshot hasn't been completed within this time period,
+ * the screenshot attempt will be cancelled and `completionConsumer`
+ * will be run.
+ * @param handler A handler used in case the screenshot times out
+ * @param completionConsumer Consumes `false` if a screenshot was not taken, and `true` if the
+ * screenshot was taken.
+ */
+ public void takeScreenshot(final int screenshotType, final boolean hasStatus,
+ final boolean hasNav, long timeoutMs, @NonNull Handler handler,
+ @Nullable Consumer<Boolean> completionConsumer) {
synchronized (mScreenshotLock) {
if (mScreenshotConnection != null) {
return;
@@ -54,7 +98,8 @@
final Intent serviceIntent = new Intent();
final Runnable mScreenshotTimeout = new Runnable() {
- @Override public void run() {
+ @Override
+ public void run() {
synchronized (mScreenshotLock) {
if (mScreenshotConnection != null) {
mContext.unbindService(mScreenshotConnection);
@@ -62,6 +107,9 @@
notifyScreenshotError();
}
}
+ if (completionConsumer != null) {
+ completionConsumer.accept(false);
+ }
}
};
@@ -86,15 +134,22 @@
handler.removeCallbacks(mScreenshotTimeout);
}
}
+ if (completionConsumer != null) {
+ completionConsumer.accept(true);
+ }
}
};
msg.replyTo = new Messenger(h);
- msg.arg1 = hasStatus ? 1: 0;
- msg.arg2 = hasNav ? 1: 0;
+ msg.arg1 = hasStatus ? 1 : 0;
+ msg.arg2 = hasNav ? 1 : 0;
+
try {
messenger.send(msg);
} catch (RemoteException e) {
Log.e(TAG, "Couldn't take screenshot: " + e);
+ if (completionConsumer != null) {
+ completionConsumer.accept(false);
+ }
}
}
}
@@ -115,7 +170,7 @@
Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE,
UserHandle.CURRENT)) {
mScreenshotConnection = conn;
- handler.postDelayed(mScreenshotTimeout, SCREENSHOT_TIMEOUT_MS);
+ handler.postDelayed(mScreenshotTimeout, timeoutMs);
}
}
}
diff --git a/core/java/com/android/internal/util/XmlUtils.java b/core/java/com/android/internal/util/XmlUtils.java
index 344d7ef..8799e3d 100644
--- a/core/java/com/android/internal/util/XmlUtils.java
+++ b/core/java/com/android/internal/util/XmlUtils.java
@@ -26,6 +26,8 @@
import android.util.Base64;
import android.util.Xml;
+import libcore.util.HexEncoding;
+
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer;
@@ -396,16 +398,7 @@
final int N = val.length;
out.attribute(null, "num", Integer.toString(N));
- StringBuilder sb = new StringBuilder(val.length*2);
- for (int i=0; i<N; i++) {
- int b = val[i];
- int h = (b >> 4) & 0x0f;
- sb.append((char)(h >= 10 ? ('a'+h-10) : ('0'+h)));
- h = b & 0x0f;
- sb.append((char)(h >= 10 ? ('a'+h-10) : ('0'+h)));
- }
-
- out.text(sb.toString());
+ out.text(HexEncoding.encodeToString(val).toLowerCase());
out.endTag(null, "byte-array");
}
@@ -1032,7 +1025,9 @@
"Not a number in num attribute in byte-array");
}
- byte[] array = new byte[num];
+ // 0 len byte array does not have a text in the XML tag. So, initialize to 0 len array.
+ // For all other array lens, HexEncoding.decode() below overrides the array.
+ byte[] array = new byte[0];
int eventType = parser.getEventType();
do {
@@ -1043,16 +1038,7 @@
throw new XmlPullParserException(
"Invalid value found in byte-array: " + values);
}
- // This is ugly, but keeping it to mirror the logic in #writeByteArrayXml.
- for (int i = 0; i < num; i ++) {
- char nibbleHighChar = values.charAt(2 * i);
- char nibbleLowChar = values.charAt(2 * i + 1);
- int nibbleHigh = nibbleHighChar > 'a' ? (nibbleHighChar - 'a' + 10)
- : (nibbleHighChar - '0');
- int nibbleLow = nibbleLowChar > 'a' ? (nibbleLowChar - 'a' + 10)
- : (nibbleLowChar - '0');
- array[i] = (byte) ((nibbleHigh & 0x0F) << 4 | (nibbleLow & 0x0F));
- }
+ array = HexEncoding.decode(values);
}
} else if (eventType == parser.END_TAG) {
if (parser.getName().equals(endTag)) {
diff --git a/core/java/com/android/server/SystemConfig.java b/core/java/com/android/server/SystemConfig.java
index 9fc79cb..510b321 100644
--- a/core/java/com/android/server/SystemConfig.java
+++ b/core/java/com/android/server/SystemConfig.java
@@ -53,6 +53,8 @@
/**
* Loads global system configuration info.
+ * Note: Initializing this class hits the disk and is slow. This class should generally only be
+ * accessed by the system_server process.
*/
public class SystemConfig {
static final String TAG = "SystemConfig";
@@ -209,6 +211,11 @@
private final ArraySet<String> mBugreportWhitelistedPackages = new ArraySet<>();
public static SystemConfig getInstance() {
+ if (!isSystemProcess()) {
+ Slog.wtf(TAG, "SystemConfig is being accessed by a process other than "
+ + "system_server.");
+ }
+
synchronized (SystemConfig.class) {
if (sInstance == null) {
sInstance = new SystemConfig();
@@ -1154,4 +1161,8 @@
mSplitPermissions.add(new SplitPermissionInfo(splitPerm, newPermissions, targetSdk));
}
}
+
+ private static boolean isSystemProcess() {
+ return Process.myUid() == Process.SYSTEM_UID;
+ }
}
diff --git a/core/jni/android_hardware_input_InputWindowHandle.cpp b/core/jni/android_hardware_input_InputWindowHandle.cpp
index a1d1d4f..57d1649 100644
--- a/core/jni/android_hardware_input_InputWindowHandle.cpp
+++ b/core/jni/android_hardware_input_InputWindowHandle.cpp
@@ -28,6 +28,7 @@
#include "android_hardware_input_InputWindowHandle.h"
#include "android_hardware_input_InputApplicationHandle.h"
#include "android_util_Binder.h"
+#include <binder/IPCThreadState.h>
namespace android {
@@ -78,6 +79,12 @@
NativeInputWindowHandle::~NativeInputWindowHandle() {
JNIEnv* env = AndroidRuntime::getJNIEnv();
env->DeleteWeakGlobalRef(mObjWeak);
+
+ // Clear the weak reference to the layer handle and flush any binder ref count operations so we
+ // do not hold on to any binder references.
+ // TODO(b/139697085) remove this after it can be flushed automatically
+ mInfo.touchableRegionCropHandle.clear();
+ IPCThreadState::self()->flushCommands();
}
jobject NativeInputWindowHandle::getInputWindowHandleObjLocalRef(JNIEnv* env) {
diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp
index 986771d..030d3be 100644
--- a/core/jni/android_view_SurfaceControl.cpp
+++ b/core/jni/android_view_SurfaceControl.cpp
@@ -217,12 +217,6 @@
ctrl->decStrong((void *)nativeCreate);
}
-static void nativeDestroy(JNIEnv* env, jclass clazz, jlong nativeObject) {
- sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject));
- ctrl->destroy();
- ctrl->decStrong((void *)nativeCreate);
-}
-
static void nativeDisconnect(JNIEnv* env, jclass clazz, jlong nativeObject) {
SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
if (ctrl != NULL) {
@@ -1268,8 +1262,6 @@
(void*)nativeWriteToParcel },
{"nativeRelease", "(J)V",
(void*)nativeRelease },
- {"nativeDestroy", "(J)V",
- (void*)nativeDestroy },
{"nativeDisconnect", "(J)V",
(void*)nativeDisconnect },
{"nativeCreateTransaction", "()J",
diff --git a/core/proto/android/app/settings_enums.proto b/core/proto/android/app/settings_enums.proto
index c023438..f817c9b 100644
--- a/core/proto/android/app/settings_enums.proto
+++ b/core/proto/android/app/settings_enums.proto
@@ -2401,4 +2401,9 @@
// OS: Q
// Note: Gear icon is shown next to gesture navigation preference and opens sensitivity dialog
SETTINGS_GESTURE_NAV_BACK_SENSITIVITY_DLG = 1748;
+
+ // OPEN: Settings > System > Aware > Aware Display
+ // CATEGORY: SETTINGS
+ // OS: Q
+ SETTINGS_AWARE_DISPLAY = 1750;
}
diff --git a/core/proto/android/providers/settings/global.proto b/core/proto/android/providers/settings/global.proto
index 0070694..ca71314 100644
--- a/core/proto/android/providers/settings/global.proto
+++ b/core/proto/android/providers/settings/global.proto
@@ -688,6 +688,7 @@
// Configuration options for smart replies and smart actions in notifications. This is
// encoded as a key=value list separated by commas.
optional SettingProto smart_suggestions_in_notifications_flags = 5 [ (android.privacy).dest = DEST_AUTOMATIC ];
+ optional SettingProto bubbles = 6 [ (android.privacy).dest = DEST_AUTOMATIC ];
}
optional Notification notification = 82;
diff --git a/core/res/res/values-en-rCA/strings.xml b/core/res/res/values-en-rCA/strings.xml
index a10300e..b60f6e9 100644
--- a/core/res/res/values-en-rCA/strings.xml
+++ b/core/res/res/values-en-rCA/strings.xml
@@ -1294,10 +1294,8 @@
<string name="wifi_available_content_failed_to_connect" msgid="3377406637062802645">"Tap to see all networks"</string>
<string name="wifi_available_action_connect" msgid="2635699628459488788">"Connect"</string>
<string name="wifi_available_action_all_networks" msgid="4368435796357931006">"All networks"</string>
- <!-- no translation found for wifi_suggestion_title (9099832833531486167) -->
- <skip />
- <!-- no translation found for wifi_suggestion_content (5883181205841582873) -->
- <skip />
+ <string name="wifi_suggestion_title" msgid="9099832833531486167">"Connect to Wi‑Fi networks?"</string>
+ <string name="wifi_suggestion_content" msgid="5883181205841582873">"Suggested by <xliff:g id="NAME">%s</xliff:g>"</string>
<string name="wifi_suggestion_action_allow_app" msgid="3689946344485394085">"Yes"</string>
<string name="wifi_suggestion_action_disallow_app" msgid="7977918905605931385">"No"</string>
<string name="wifi_wakeup_onboarding_title" msgid="228772560195634292">"Wi‑Fi will turn on automatically"</string>
diff --git a/core/res/res/values-en-rXC/strings.xml b/core/res/res/values-en-rXC/strings.xml
index a531355..b6f6674 100644
--- a/core/res/res/values-en-rXC/strings.xml
+++ b/core/res/res/values-en-rXC/strings.xml
@@ -1294,10 +1294,8 @@
<string name="wifi_available_content_failed_to_connect" msgid="3377406637062802645">"Tap to see all networks"</string>
<string name="wifi_available_action_connect" msgid="2635699628459488788">"Connect"</string>
<string name="wifi_available_action_all_networks" msgid="4368435796357931006">"All networks"</string>
- <!-- no translation found for wifi_suggestion_title (9099832833531486167) -->
- <skip />
- <!-- no translation found for wifi_suggestion_content (5883181205841582873) -->
- <skip />
+ <string name="wifi_suggestion_title" msgid="9099832833531486167">"Connect to Wi‑Fi networks?"</string>
+ <string name="wifi_suggestion_content" msgid="5883181205841582873">"Suggested by <xliff:g id="NAME">%s</xliff:g>"</string>
<string name="wifi_suggestion_action_allow_app" msgid="3689946344485394085">"Yes"</string>
<string name="wifi_suggestion_action_disallow_app" msgid="7977918905605931385">"No"</string>
<string name="wifi_wakeup_onboarding_title" msgid="228772560195634292">"Wi‑Fi will turn on automatically"</string>
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index efc943e..f8c8f5b 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -4284,4 +4284,9 @@
<!-- The list of packages to automatically opt out of refresh rates higher than 60hz because
of known compatibility issues. -->
<string-array name="config_highRefreshRateBlacklist"></string-array>
+
+ <!-- Whether or not to hide the navigation bar when the soft keyboard is visible in order to
+ create additional screen real estate outside beyond the keyboard. Note that the user needs
+ to have a confirmed way to dismiss the keyboard when desired. -->
+ <bool name="config_automotiveHideNavBarForKeyboard">false</bool>
</resources>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index b4edc4d..71bd802 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -3390,13 +3390,13 @@
<string name="wifi_available_action_all_networks">All networks</string>
<!-- Notification title for a connection to a app suggested wireless network.-->
- <string name="wifi_suggestion_title">Connect to Wi\u2011Fi networks?</string>
+ <string name="wifi_suggestion_title">Allow suggested Wi\u2011Fi networks?</string>
<!-- Notification content for a connection to a app suggested wireless network.-->
- <string name="wifi_suggestion_content">Suggested by <xliff:g id="name" example="App123">%s</xliff:g></string>
+ <string name="wifi_suggestion_content"><xliff:g id="name" example="App123">%s</xliff:g> suggested networks. Device may connect automatically. </string>
<!-- Notification action for allowing app specified in the notification body.-->
- <string name="wifi_suggestion_action_allow_app">Yes</string>
+ <string name="wifi_suggestion_action_allow_app">Allow</string>
<!-- Notification action for disallowing app specified in the notification body.-->
- <string name="wifi_suggestion_action_disallow_app">No</string>
+ <string name="wifi_suggestion_action_disallow_app">No thanks</string>
<!--Notification title for Wi-Fi Wake onboarding. This is displayed the first time a user disables Wi-Fi with the feature enabled. -->
<string name="wifi_wakeup_onboarding_title">Wi\u2011Fi will turn on automatically</string>
@@ -5009,9 +5009,9 @@
<string name="importance_from_person">This is important because of the people involved.</string>
<!-- Message to user that app trying to create user for an account that already exists. [CHAR LIMIT=none] -->
- <string name="user_creation_account_exists">Allow <xliff:g id="app" example="Gmail">%1$s</xliff:g> to create a new User with <xliff:g id="account" example="foobar@gmail.com">%2$s</xliff:g> ?</string>
+ <string name="user_creation_account_exists">Allow <xliff:g id="app" example="Gmail">%1$s</xliff:g> to create a new User with <xliff:g id="account" example="foobar@gmail.com">%2$s</xliff:g> (a User with this account already exists) ?</string>
<!-- Message to user that app is trying to create user for a specified account. [CHAR LIMIT=none] -->
- <string name="user_creation_adding">Allow <xliff:g id="app" example="Gmail">%1$s</xliff:g> to create a new User with <xliff:g id="account" example="foobar">%2$s</xliff:g> (a User with this account already exists) ?</string>
+ <string name="user_creation_adding">Allow <xliff:g id="app" example="Gmail">%1$s</xliff:g> to create a new User with <xliff:g id="account" example="foobar@gmail.com">%2$s</xliff:g> ?</string>
<!-- Locale picker strings -->
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index e5805fd..c419a9d 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -3842,4 +3842,5 @@
<java-symbol type="drawable" name="android_logotype" />
<java-symbol type="layout" name="platlogo_layout" />
+ <java-symbol type="bool" name="config_automotiveHideNavBarForKeyboard" />
</resources>
diff --git a/core/tests/coretests/src/com/android/internal/app/ChooserActivityTest.java b/core/tests/coretests/src/com/android/internal/app/ChooserActivityTest.java
index 767ec0e..c44b7d8 100644
--- a/core/tests/coretests/src/com/android/internal/app/ChooserActivityTest.java
+++ b/core/tests/coretests/src/com/android/internal/app/ChooserActivityTest.java
@@ -24,12 +24,19 @@
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
+import static com.android.internal.app.ChooserActivity.CALLER_TARGET_SCORE_BOOST;
+import static com.android.internal.app.ChooserActivity.SHORTCUT_TARGET_SCORE_BOOST;
+import static com.android.internal.app.ChooserActivity.TARGET_TYPE_CHOOSER_TARGET;
+import static com.android.internal.app.ChooserActivity.TARGET_TYPE_DEFAULT;
+import static com.android.internal.app.ChooserActivity.TARGET_TYPE_SHORTCUTS_FROM_PREDICTION_SERVICE;
+import static com.android.internal.app.ChooserActivity.TARGET_TYPE_SHORTCUTS_FROM_SHORTCUT_MANAGER;
import static com.android.internal.app.ChooserWrapperActivity.sOverrides;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
@@ -45,6 +52,8 @@
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.content.pm.ShortcutInfo;
+import android.content.pm.ShortcutManager.ShareShortcutInfo;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@@ -770,6 +779,139 @@
onView(withId(R.id.content_preview_file_icon)).check(matches(isDisplayed()));
}
+ @Test
+ public void testGetBaseScore() {
+ final float testBaseScore = 0.89f;
+
+ Intent sendIntent = createSendTextIntent();
+ List<ResolvedComponentInfo> resolvedComponentInfos = createResolvedComponentsForTest(2);
+
+ when(sOverrides.resolverListController.getResolversForIntent(Mockito.anyBoolean(),
+ Mockito.anyBoolean(),
+ Mockito.isA(List.class))).thenReturn(resolvedComponentInfos);
+ when(sOverrides.resolverListController.getScore(Mockito.isA(
+ ResolverActivity.DisplayResolveInfo.class))).thenReturn(testBaseScore);
+
+ final ChooserWrapperActivity activity = mActivityRule
+ .launchActivity(Intent.createChooser(sendIntent, null));
+ waitForIdle();
+
+ final ResolverActivity.DisplayResolveInfo testDri =
+ activity.createTestDisplayResolveInfo(sendIntent,
+ ResolverDataProvider.createResolveInfo(3, 0), "testLabel", "testInfo", sendIntent);
+ final ChooserActivity.ChooserListAdapter adapter = activity.getAdapter();
+
+ assertThat(adapter.getBaseScore(null, 0), is(CALLER_TARGET_SCORE_BOOST));
+ assertThat(adapter.getBaseScore(testDri, TARGET_TYPE_DEFAULT), is(testBaseScore));
+ assertThat(adapter.getBaseScore(testDri, TARGET_TYPE_CHOOSER_TARGET), is(testBaseScore));
+ assertThat(adapter.getBaseScore(testDri, TARGET_TYPE_SHORTCUTS_FROM_PREDICTION_SERVICE),
+ is(SHORTCUT_TARGET_SCORE_BOOST));
+ assertThat(adapter.getBaseScore(testDri, TARGET_TYPE_SHORTCUTS_FROM_SHORTCUT_MANAGER),
+ is(testBaseScore * SHORTCUT_TARGET_SCORE_BOOST));
+ }
+
+ /**
+ * The case when AppPrediction service is not defined in PackageManager is already covered
+ * as a test parameter {@link ChooserActivityTest#packageManagers}. This test is checking the
+ * case when the prediction service is defined but the component is not available on the device.
+ */
+ @Test
+ public void testIsAppPredictionServiceAvailable() {
+ Intent sendIntent = createSendTextIntent();
+ List<ResolvedComponentInfo> resolvedComponentInfos = createResolvedComponentsForTest(2);
+ when(sOverrides.resolverListController.getResolversForIntent(Mockito.anyBoolean(),
+ Mockito.anyBoolean(),
+ Mockito.isA(List.class))).thenReturn(resolvedComponentInfos);
+
+ final ChooserWrapperActivity activity = mActivityRule
+ .launchActivity(Intent.createChooser(sendIntent, null));
+ waitForIdle();
+
+ if (activity.getPackageManager().getAppPredictionServicePackageName() == null) {
+ assertThat(activity.isAppPredictionServiceAvailable(), is(false));
+ } else {
+ assertThat(activity.isAppPredictionServiceAvailable(), is(true));
+
+ sOverrides.resources = Mockito.spy(activity.getResources());
+ when(sOverrides.resources.getString(R.string.config_defaultAppPredictionService))
+ .thenReturn("ComponentNameThatDoesNotExist");
+
+ assertThat(activity.isAppPredictionServiceAvailable(), is(false));
+ }
+ }
+
+ @Test
+ public void testConvertToChooserTarget_predictionService() {
+ Intent sendIntent = createSendTextIntent();
+ List<ResolvedComponentInfo> resolvedComponentInfos = createResolvedComponentsForTest(2);
+ when(sOverrides.resolverListController.getResolversForIntent(Mockito.anyBoolean(),
+ Mockito.anyBoolean(),
+ Mockito.isA(List.class))).thenReturn(resolvedComponentInfos);
+
+ final ChooserWrapperActivity activity = mActivityRule
+ .launchActivity(Intent.createChooser(sendIntent, null));
+ waitForIdle();
+
+ List<ShareShortcutInfo> shortcuts = createShortcuts(activity);
+
+ int[] expectedOrderAllShortcuts = {0, 1, 2, 3};
+ float[] expectedScoreAllShortcuts = {1.0f, 0.99f, 0.98f, 0.97f};
+
+ List<ChooserTarget> chooserTargets = activity.convertToChooserTarget(shortcuts, shortcuts,
+ null, TARGET_TYPE_SHORTCUTS_FROM_PREDICTION_SERVICE);
+ assertCorrectShortcutToChooserTargetConversion(shortcuts, chooserTargets,
+ expectedOrderAllShortcuts, expectedScoreAllShortcuts);
+
+ List<ShareShortcutInfo> subset = new ArrayList<>();
+ subset.add(shortcuts.get(1));
+ subset.add(shortcuts.get(2));
+ subset.add(shortcuts.get(3));
+
+ int[] expectedOrderSubset = {1, 2, 3};
+ float[] expectedScoreSubset = {0.99f, 0.98f, 0.97f};
+
+ chooserTargets = activity.convertToChooserTarget(subset, shortcuts, null,
+ TARGET_TYPE_SHORTCUTS_FROM_PREDICTION_SERVICE);
+ assertCorrectShortcutToChooserTargetConversion(shortcuts, chooserTargets,
+ expectedOrderSubset, expectedScoreSubset);
+ }
+
+ @Test
+ public void testConvertToChooserTarget_shortcutManager() {
+ Intent sendIntent = createSendTextIntent();
+ List<ResolvedComponentInfo> resolvedComponentInfos = createResolvedComponentsForTest(2);
+ when(sOverrides.resolverListController.getResolversForIntent(Mockito.anyBoolean(),
+ Mockito.anyBoolean(),
+ Mockito.isA(List.class))).thenReturn(resolvedComponentInfos);
+
+ final ChooserWrapperActivity activity = mActivityRule
+ .launchActivity(Intent.createChooser(sendIntent, null));
+ waitForIdle();
+
+ List<ShareShortcutInfo> shortcuts = createShortcuts(activity);
+
+ int[] expectedOrderAllShortcuts = {2, 0, 3, 1};
+ float[] expectedScoreAllShortcuts = {1.0f, 0.99f, 0.99f, 0.98f};
+
+ List<ChooserTarget> chooserTargets = activity.convertToChooserTarget(shortcuts, shortcuts,
+ null, TARGET_TYPE_SHORTCUTS_FROM_SHORTCUT_MANAGER);
+ assertCorrectShortcutToChooserTargetConversion(shortcuts, chooserTargets,
+ expectedOrderAllShortcuts, expectedScoreAllShortcuts);
+
+ List<ShareShortcutInfo> subset = new ArrayList<>();
+ subset.add(shortcuts.get(1));
+ subset.add(shortcuts.get(2));
+ subset.add(shortcuts.get(3));
+
+ int[] expectedOrderSubset = {2, 3, 1};
+ float[] expectedScoreSubset = {1.0f, 0.99f, 0.98f};
+
+ chooserTargets = activity.convertToChooserTarget(subset, shortcuts, null,
+ TARGET_TYPE_SHORTCUTS_FROM_SHORTCUT_MANAGER);
+ assertCorrectShortcutToChooserTargetConversion(shortcuts, chooserTargets,
+ expectedOrderSubset, expectedScoreSubset);
+ }
+
// This test is too long and too slow and should not be taken as an example for future tests.
@Test
public void testDirectTargetSelectionLogging() throws InterruptedException {
@@ -800,7 +942,7 @@
"testInfo",
sendIntent),
serviceTargets,
- false)
+ TARGET_TYPE_CHOOSER_TARGET)
);
// Thread.sleep shouldn't be a thing in an integration test but it's
// necessary here because of the way the code is structured
@@ -866,7 +1008,7 @@
"testInfo",
sendIntent),
serviceTargets,
- false)
+ TARGET_TYPE_CHOOSER_TARGET)
);
// Thread.sleep shouldn't be a thing in an integration test but it's
// necessary here because of the way the code is structured
@@ -927,7 +1069,7 @@
"testInfo",
sendIntent),
serviceTargets,
- false)
+ TARGET_TYPE_CHOOSER_TARGET)
);
// Thread.sleep shouldn't be a thing in an integration test but it's
// necessary here because of the way the code is structured
@@ -1066,4 +1208,43 @@
return bitmap;
}
+
+ private List<ShareShortcutInfo> createShortcuts(Context context) {
+ Intent testIntent = new Intent("TestIntent");
+
+ List<ShareShortcutInfo> shortcuts = new ArrayList<>();
+ shortcuts.add(new ShareShortcutInfo(
+ new ShortcutInfo.Builder(context, "shortcut1")
+ .setIntent(testIntent).setShortLabel("label1").setRank(3).build(), // 0 2
+ new ComponentName("package1", "class1")));
+ shortcuts.add(new ShareShortcutInfo(
+ new ShortcutInfo.Builder(context, "shortcut2")
+ .setIntent(testIntent).setShortLabel("label2").setRank(7).build(), // 1 3
+ new ComponentName("package2", "class2")));
+ shortcuts.add(new ShareShortcutInfo(
+ new ShortcutInfo.Builder(context, "shortcut3")
+ .setIntent(testIntent).setShortLabel("label3").setRank(1).build(), // 2 0
+ new ComponentName("package3", "class3")));
+ shortcuts.add(new ShareShortcutInfo(
+ new ShortcutInfo.Builder(context, "shortcut4")
+ .setIntent(testIntent).setShortLabel("label4").setRank(3).build(), // 3 2
+ new ComponentName("package4", "class4")));
+
+ return shortcuts;
+ }
+
+ private void assertCorrectShortcutToChooserTargetConversion(List<ShareShortcutInfo> shortcuts,
+ List<ChooserTarget> chooserTargets, int[] expectedOrder, float[] expectedScores) {
+ assertEquals(expectedOrder.length, chooserTargets.size());
+ for (int i = 0; i < chooserTargets.size(); i++) {
+ ChooserTarget ct = chooserTargets.get(i);
+ ShortcutInfo si = shortcuts.get(expectedOrder[i]).getShortcutInfo();
+ ComponentName cn = shortcuts.get(expectedOrder[i]).getTargetComponent();
+
+ assertEquals(si.getId(), ct.getIntentExtras().getString(Intent.EXTRA_SHORTCUT_ID));
+ assertEquals(si.getShortLabel(), ct.getTitle());
+ assertThat(Math.abs(expectedScores[i] - ct.getScore()) < 0.000001, is(true));
+ assertEquals(cn.flattenToString(), ct.getComponentName().flattenToString());
+ }
+ }
}
diff --git a/core/tests/coretests/src/com/android/internal/app/ChooserWrapperActivity.java b/core/tests/coretests/src/com/android/internal/app/ChooserWrapperActivity.java
index 44e56ea..1d567c7 100644
--- a/core/tests/coretests/src/com/android/internal/app/ChooserWrapperActivity.java
+++ b/core/tests/coretests/src/com/android/internal/app/ChooserWrapperActivity.java
@@ -24,6 +24,7 @@
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.net.Uri;
@@ -85,6 +86,14 @@
}
@Override
+ public Resources getResources() {
+ if (sOverrides.resources != null) {
+ return sOverrides.resources;
+ }
+ return super.getResources();
+ }
+
+ @Override
protected Bitmap loadThumbnail(Uri uri, Size size) {
if (sOverrides.previewThumbnail != null) {
return sOverrides.previewThumbnail;
@@ -145,6 +154,7 @@
public Bitmap previewThumbnail;
public MetricsLogger metricsLogger;
public int alternateProfileSetting;
+ public Resources resources;
public void reset() {
onSafelyStartCallback = null;
@@ -157,6 +167,7 @@
resolverListController = mock(ResolverListController.class);
metricsLogger = mock(MetricsLogger.class);
alternateProfileSetting = 0;
+ resources = null;
}
}
}
diff --git a/core/tests/screenshothelpertests/Android.bp b/core/tests/screenshothelpertests/Android.bp
new file mode 100644
index 0000000..3d54b68
--- /dev/null
+++ b/core/tests/screenshothelpertests/Android.bp
@@ -0,0 +1,28 @@
+android_test {
+ name: "ScreenshotHelperTests",
+
+ srcs: [
+ "src/**/*.java",
+ ],
+
+ static_libs: [
+ "frameworks-base-testutils",
+ "androidx.test.runner",
+ "androidx.test.rules",
+ "androidx.test.ext.junit",
+ "mockito-target-minus-junit4",
+ "platform-test-annotations",
+ ],
+
+ libs: [
+ "android.test.runner",
+ "android.test.base",
+ "android.test.mock",
+ ],
+
+ platform_apis: true,
+ test_suites: ["device-tests"],
+
+ certificate: "platform",
+}
+
diff --git a/core/tests/screenshothelpertests/AndroidManifest.xml b/core/tests/screenshothelpertests/AndroidManifest.xml
new file mode 100644
index 0000000..2e12ef4
--- /dev/null
+++ b/core/tests/screenshothelpertests/AndroidManifest.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ android:installLocation="internalOnly"
+ package="com.android.internal.util"
+ android:sharedUserId="android.uid.systemui" >
+
+ <application >
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
+ android:targetPackage="com.android.internal.util"
+ android:label="Screenshot Helper Tests" />
+
+ <protected-broadcast android:name="android.intent.action.USER_PRESENT" />
+
+</manifest>
diff --git a/core/tests/screenshothelpertests/src/com/android/internal/util/ScreenshotHelperTest.java b/core/tests/screenshothelpertests/src/com/android/internal/util/ScreenshotHelperTest.java
new file mode 100644
index 0000000..8483645
--- /dev/null
+++ b/core/tests/screenshothelpertests/src/com/android/internal/util/ScreenshotHelperTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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.
+ */
+
+package com.android.internal.util;
+
+import static android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN;
+import static android.view.WindowManager.TAKE_SCREENSHOT_SELECTED_REGION;
+
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.fail;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.Looper;
+
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+@RunWith(AndroidJUnit4.class)
+public final class ScreenshotHelperTest {
+ private Context mContext;
+ private ScreenshotHelper mScreenshotHelper;
+ private Handler mHandler;
+
+
+ @Before
+ public void setUp() {
+ // `ScreenshotHelper.notifyScreenshotError()` calls `Context.sendBroadcastAsUser()` and
+ // `Context.bindServiceAsUser`.
+ //
+ // This raises a `SecurityException` if the device is locked. Calling either `Context`
+ // method results in a broadcast of `android.intent.action. USER_PRESENT`. Only the system
+ // process is allowed to broadcast that `Intent`.
+ mContext = Mockito.spy(Context.class);
+ Mockito.doNothing().when(mContext).sendBroadcastAsUser(any(), any());
+ Mockito.doReturn(true).when(mContext).bindServiceAsUser(any(), any(), anyInt(), any());
+
+ mHandler = new Handler(Looper.getMainLooper());
+ mScreenshotHelper = new ScreenshotHelper(mContext);
+ }
+
+ @Test
+ public void testFullscreenScreenshot() {
+ mScreenshotHelper.takeScreenshot(TAKE_SCREENSHOT_FULLSCREEN, false, false, mHandler, null);
+ }
+
+ @Test
+ public void testSelectedRegionScreenshot() {
+ mScreenshotHelper.takeScreenshot(TAKE_SCREENSHOT_SELECTED_REGION, false, false, mHandler,
+ null);
+ }
+
+ @Test
+ public void testScreenshotTimesOut() {
+ long timeoutMs = 10;
+
+ CountDownLatch lock = new CountDownLatch(1);
+ mScreenshotHelper.takeScreenshot(TAKE_SCREENSHOT_FULLSCREEN, false, false, timeoutMs,
+ mHandler,
+ worked -> {
+ assertFalse(worked);
+ lock.countDown();
+ });
+
+ try {
+ // Add tolerance for delay to prevent flakes.
+ long awaitDurationMs = timeoutMs + 100;
+ if (!lock.await(awaitDurationMs, TimeUnit.MILLISECONDS)) {
+ fail("lock never freed");
+ }
+ } catch (InterruptedException e) {
+ fail("lock interrupted");
+ }
+ }
+}
diff --git a/core/tests/utiltests/src/com/android/internal/util/XmlUtilsTest.java b/core/tests/utiltests/src/com/android/internal/util/XmlUtilsTest.java
index 2596ece..27f3596 100644
--- a/core/tests/utiltests/src/com/android/internal/util/XmlUtilsTest.java
+++ b/core/tests/utiltests/src/com/android/internal/util/XmlUtilsTest.java
@@ -16,13 +16,22 @@
package com.android.internal.util;
+import static org.junit.Assert.assertArrayEquals;
+
+import android.util.Xml;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
+
import junit.framework.TestCase;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlSerializer;
+
public class XmlUtilsTest extends TestCase {
// https://code.google.com/p/android/issues/detail?id=63717
@@ -38,4 +47,23 @@
assertEquals("nullValue", deserialized.get(null));
assertEquals("fooValue", deserialized.get("foo"));
}
+
+ public void testreadWriteXmlByteArrayValue() throws Exception {
+ byte[] testByteArray = {0x1 , 0xa, 0xb, 0x9, 0x34, (byte) 0xaa, (byte) 0xba, (byte) 0x99};
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
+ XmlSerializer serializer = new FastXmlSerializer();
+ serializer.setOutput(baos, StandardCharsets.UTF_8.name());
+ serializer.startDocument(null, true);
+ XmlUtils.writeValueXml(testByteArray, "testByteArray", serializer);
+ serializer.endDocument();
+
+ InputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ XmlPullParser pullParser = Xml.newPullParser();
+ pullParser.setInput(bais, StandardCharsets.UTF_8.name());
+ String[] name = new String[1];
+ byte[] testByteArrayDeserialized = (byte[]) XmlUtils.readValueXml(pullParser, name);
+ assertEquals("testByteArray", name[0]);
+ assertArrayEquals(testByteArray, testByteArrayDeserialized);
+ }
}
diff --git a/data/etc/platform.xml b/data/etc/platform.xml
index 233f826..65f784d 100644
--- a/data/etc/platform.xml
+++ b/data/etc/platform.xml
@@ -205,6 +205,10 @@
targetSdk="29">
<new-permission name="android.permission.ACCESS_BACKGROUND_LOCATION" />
</split-permission>
+ <split-permission name="android.permission.READ_EXTERNAL_STORAGE"
+ targetSdk="29">
+ <new-permission name="android.permission.ACCESS_MEDIA_LOCATION" />
+ </split-permission>
<!-- This is a list of all the libraries available for application
code to link against. -->
diff --git a/location/java/com/android/internal/location/gnssmetrics/GnssMetrics.java b/location/java/com/android/internal/location/gnssmetrics/GnssMetrics.java
index 7823971..b6a24e4 100644
--- a/location/java/com/android/internal/location/gnssmetrics/GnssMetrics.java
+++ b/location/java/com/android/internal/location/gnssmetrics/GnssMetrics.java
@@ -31,7 +31,9 @@
import com.android.internal.location.nano.GnssLogsProto.GnssLog;
import com.android.internal.location.nano.GnssLogsProto.PowerMetrics;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
/**
* GnssMetrics: Is used for logging GNSS metrics
@@ -60,13 +62,20 @@
/** Default time between location fixes (in millisecs) */
private static final int DEFAULT_TIME_BETWEEN_FIXES_MILLISECS = 1000;
+ /** The number of hertz in one MHz */
+ private static final double HZ_PER_MHZ = 1e6;
+
/* The time since boot when logging started */
private String logStartInElapsedRealTime;
/* GNSS power metrics */
private GnssPowerMetrics mGnssPowerMetrics;
- /**
+ /** Frequency range of GPS L5, Galileo E5a, QZSS J5 frequency band */
+ private static final double L5_CARRIER_FREQ_RANGE_LOW_HZ = 1164 * HZ_PER_MHZ;
+ private static final double L5_CARRIER_FREQ_RANGE_HIGH_HZ = 1189 * HZ_PER_MHZ;
+
+ /**
* A boolean array indicating whether the constellation types have been used in fix.
*/
private boolean[] mConstellationTypes;
@@ -78,6 +87,11 @@
timeToFirstFixSecStatistics = new Statistics();
positionAccuracyMeterStatistics = new Statistics();
topFourAverageCn0Statistics = new Statistics();
+ mTopFourAverageCn0StatisticsL5 = new Statistics();
+ mNumSvStatus = 0;
+ mNumL5SvStatus = 0;
+ mNumSvStatusUsedInFix = 0;
+ mNumL5SvStatusUsedInFix = 0;
reset();
}
@@ -133,11 +147,16 @@
return;
}
- /*
+ /**
* Logs CN0 when at least 4 SVs are available
*
+ * @param cn0s
+ * @param numSv
+ * @param svCarrierFreqs
*/
- public void logCn0(float[] cn0s, int numSv) {
+ public void logCn0(float[] cn0s, int numSv, float[] svCarrierFreqs) {
+ // Calculate L5 Cn0
+ logCn0L5(numSv, cn0s, svCarrierFreqs);
if (numSv == 0 || cn0s == null || cn0s.length == 0 || cn0s.length < numSv) {
if (numSv == 0) {
mGnssPowerMetrics.reportSignalQuality(null, 0);
@@ -161,6 +180,76 @@
return;
}
+ /* Helper function to check if a SV is L5 */
+ private static boolean isL5Sv(float carrierFreq) {
+ return (carrierFreq >= L5_CARRIER_FREQ_RANGE_LOW_HZ
+ && carrierFreq <= L5_CARRIER_FREQ_RANGE_HIGH_HZ);
+ }
+
+ /**
+ * Logs sv status data
+ *
+ * @param svCount
+ * @param svidWithFlags
+ * @param svCarrierFreqs
+ */
+ public void logSvStatus(int svCount, int[] svidWithFlags, float[] svCarrierFreqs) {
+ boolean isL5 = false;
+ // Calculate SvStatus Information
+ for (int i = 0; i < svCount; i++) {
+ if ((svidWithFlags[i] & GnssStatus.GNSS_SV_FLAGS_HAS_CARRIER_FREQUENCY) != 0) {
+ mNumSvStatus++;
+ isL5 = isL5Sv(svCarrierFreqs[i]);
+ if (isL5) {
+ mNumL5SvStatus++;
+ }
+ if ((svidWithFlags[i] & GnssStatus.GNSS_SV_FLAGS_USED_IN_FIX) != 0) {
+ mNumSvStatusUsedInFix++;
+ if (isL5) {
+ mNumL5SvStatusUsedInFix++;
+ }
+ }
+ }
+ }
+ return;
+ }
+
+ /**
+ * Logs CN0 when at least 4 SVs are available L5 Only
+ *
+ * @param svCount
+ * @param cn0s
+ * @param svCarrierFreqs
+ */
+ private void logCn0L5(int svCount, float[] cn0s, float[] svCarrierFreqs) {
+ if (svCount == 0 || cn0s == null || cn0s.length == 0 || cn0s.length < svCount
+ || svCarrierFreqs == null || svCarrierFreqs.length == 0
+ || svCarrierFreqs.length < svCount) {
+ return;
+ }
+ // Create array list of all L5 satellites in report.
+ ArrayList<Float> CnoL5Array = new ArrayList();
+ for (int i = 0; i < svCount; i++) {
+ if (isL5Sv(svCarrierFreqs[i])) {
+ CnoL5Array.add(cn0s[i]);
+ }
+ }
+ if (CnoL5Array.size() == 0 || CnoL5Array.size() < 4) {
+ return;
+ }
+ int numSvL5 = CnoL5Array.size();
+ Collections.sort(CnoL5Array);
+ if (CnoL5Array.get(numSvL5 - 4) > 0.0) {
+ double top4AvgCn0 = 0.0;
+ for (int i = numSvL5 - 4; i < numSvL5; i++) {
+ top4AvgCn0 += (double) CnoL5Array.get(i);
+ }
+ top4AvgCn0 /= 4;
+ mTopFourAverageCn0StatisticsL5.addItem(top4AvgCn0);
+ }
+ return;
+ }
+
/**
* Logs that a constellation type has been observed.
@@ -201,6 +290,24 @@
msg.standardDeviationTopFourAverageCn0DbHz
= topFourAverageCn0Statistics.getStandardDeviation();
}
+ if (mNumSvStatus > 0) {
+ msg.numSvStatusProcessed = mNumSvStatus;
+ }
+ if (mNumL5SvStatus > 0) {
+ msg.numL5SvStatusProcessed = mNumL5SvStatus;
+ }
+ if (mNumSvStatusUsedInFix > 0) {
+ msg.numSvStatusUsedInFix = mNumSvStatusUsedInFix;
+ }
+ if (mNumL5SvStatusUsedInFix > 0) {
+ msg.numL5SvStatusUsedInFix = mNumL5SvStatusUsedInFix;
+ }
+ if (mTopFourAverageCn0StatisticsL5.getCount() > 0) {
+ msg.numL5TopFourAverageCn0Processed = mTopFourAverageCn0StatisticsL5.getCount();
+ msg.meanL5TopFourAverageCn0DbHz = mTopFourAverageCn0StatisticsL5.getMean();
+ msg.standardDeviationL5TopFourAverageCn0DbHz =
+ mTopFourAverageCn0StatisticsL5.getStandardDeviation();
+ }
msg.powerMetrics = mGnssPowerMetrics.buildProto();
msg.hardwareRevision = SystemProperties.get("ro.boot.revision", "");
String s = Base64.encodeToString(GnssLog.toByteArray(msg), Base64.DEFAULT);
@@ -249,6 +356,22 @@
s.append(" Top 4 Avg CN0 standard deviation (dB-Hz): ").append(
topFourAverageCn0Statistics.getStandardDeviation()).append("\n");
}
+ s.append(" Total number of sv status messages processed: ").append(
+ mNumSvStatus).append("\n");
+ s.append(" Total number of L5 sv status messages processed: ").append(
+ mNumL5SvStatus).append("\n");
+ s.append(" Total number of sv status messages processed, where sv is used in fix: ").append(
+ mNumSvStatusUsedInFix).append("\n");
+ s.append(" Total number of L5 sv status messages processed, where sv is used in fix: ").append(
+ mNumL5SvStatusUsedInFix).append("\n");
+ s.append(" Number of L5 CN0 reports: ").append(
+ mTopFourAverageCn0StatisticsL5.getCount()).append("\n");
+ if (mTopFourAverageCn0StatisticsL5.getCount() > 0) {
+ s.append(" L5 Top 4 Avg CN0 mean (dB-Hz): ").append(
+ mTopFourAverageCn0StatisticsL5.getMean()).append("\n");
+ s.append(" L5 Top 4 Avg CN0 standard deviation (dB-Hz): ").append(
+ mTopFourAverageCn0StatisticsL5.getStandardDeviation()).append("\n");
+ }
s.append(" Used-in-fix constellation types: ");
for (int i = 0; i < mConstellationTypes.length; i++) {
if (mConstellationTypes[i]) {
@@ -333,6 +456,21 @@
/** Top 4 average CN0 statistics */
private Statistics topFourAverageCn0Statistics;
+ /** Top 4 average CN0 statistics L5 */
+ private Statistics mTopFourAverageCn0StatisticsL5;
+
+ /** Total number of sv status messages processed */
+ private int mNumSvStatus;
+
+ /** Total number of L5 sv status messages processed */
+ private int mNumL5SvStatus;
+
+ /** Total number of sv status messages processed, where sv is used in fix */
+ private int mNumSvStatusUsedInFix;
+
+ /** Total number of L5 sv status messages processed, where sv is used in fix */
+ private int mNumL5SvStatusUsedInFix;
+
/**
* Resets GNSS metrics
*/
@@ -344,6 +482,11 @@
timeToFirstFixSecStatistics.reset();
positionAccuracyMeterStatistics.reset();
topFourAverageCn0Statistics.reset();
+ mTopFourAverageCn0StatisticsL5.reset();
+ mNumSvStatus = 0;
+ mNumL5SvStatus = 0;
+ mNumSvStatusUsedInFix = 0;
+ mNumL5SvStatusUsedInFix = 0;
resetConstellationTypes();
return;
}
diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java
index e29e569..7cd09de 100644
--- a/media/java/android/media/AudioTrack.java
+++ b/media/java/android/media/AudioTrack.java
@@ -1184,8 +1184,15 @@
int bufferSizeInBytes, int mode) {
// If no attributes, OK
// otherwise check attributes for USAGE_MEDIA and CONTENT_UNKNOWN, MUSIC, or MOVIE.
+ // Only consider flags that are not compatible with FLAG_DEEP_BUFFER. We include
+ // FLAG_DEEP_BUFFER because if set the request is explicit and
+ // shouldEnablePowerSaving() should return false.
+ final int flags = attributes.getAllFlags()
+ & (AudioAttributes.FLAG_DEEP_BUFFER | AudioAttributes.FLAG_LOW_LATENCY
+ | AudioAttributes.FLAG_HW_AV_SYNC | AudioAttributes.FLAG_BEACON);
+
if (attributes != null &&
- (attributes.getAllFlags() != 0 // cannot have any special flags
+ (flags != 0 // cannot have any special flags
|| attributes.getUsage() != AudioAttributes.USAGE_MEDIA
|| (attributes.getContentType() != AudioAttributes.CONTENT_TYPE_UNKNOWN
&& attributes.getContentType() != AudioAttributes.CONTENT_TYPE_MUSIC
diff --git a/media/jni/android_media_ImageWriter.cpp b/media/jni/android_media_ImageWriter.cpp
index cfcba76..7a0eeee 100644
--- a/media/jni/android_media_ImageWriter.cpp
+++ b/media/jni/android_media_ImageWriter.cpp
@@ -26,6 +26,7 @@
#include <gui/IProducerListener.h>
#include <gui/Surface.h>
+#include <ui/PublicFormat.h>
#include <android_runtime/AndroidRuntime.h>
#include <android_runtime/android_view_Surface.h>
#include <android_runtime/android_hardware_HardwareBuffer.h>
@@ -126,7 +127,7 @@
Condition mCondition;
std::deque<wp<Surface>> mQueue;
- static const nsecs_t kWaitDuration = 20000000; // 20 ms
+ static const nsecs_t kWaitDuration = 500000000; // 500 ms
};
sp<DetachThread> mThread;
@@ -401,8 +402,28 @@
return 0;
}
} else {
+ // Set consumer buffer format to user specified format
+ PublicFormat publicFormat = static_cast<PublicFormat>(userFormat);
+ int nativeFormat = mapPublicFormatToHalFormat(publicFormat);
+ android_dataspace nativeDataspace = mapPublicFormatToHalDataspace(publicFormat);
+ res = native_window_set_buffers_format(anw.get(), nativeFormat);
+ if (res != OK) {
+ ALOGE("%s: Unable to configure consumer native buffer format to %#x",
+ __FUNCTION__, nativeFormat);
+ jniThrowRuntimeException(env, "Failed to set Surface format");
+ return 0;
+ }
+
+ res = native_window_set_buffers_data_space(anw.get(), nativeDataspace);
+ if (res != OK) {
+ ALOGE("%s: Unable to configure consumer dataspace %#x",
+ __FUNCTION__, nativeDataspace);
+ jniThrowRuntimeException(env, "Failed to set Surface dataspace");
+ return 0;
+ }
surfaceFormat = userFormat;
}
+
ctx->setBufferFormat(surfaceFormat);
env->SetIntField(thiz,
gImageWriterClassInfo.mWriterFormat, reinterpret_cast<jint>(surfaceFormat));
diff --git a/packages/CarSystemUI/Android.bp b/packages/CarSystemUI/Android.bp
index 589623b..672879a 100644
--- a/packages/CarSystemUI/Android.bp
+++ b/packages/CarSystemUI/Android.bp
@@ -13,21 +13,22 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
-android_app {
- name: "CarSystemUI",
-
- overrides: [
- "SystemUI",
- ],
+android_library {
+ name: "CarSystemUI-core",
srcs: [
"src/**/*.java",
"src/**/I*.aidl",
],
+ resource_dirs: [
+ "res-keyguard",
+ "res",
+ ],
+
static_libs: [
- "CarNotificationLib",
"SystemUI-core",
+ "CarNotificationLib",
"SystemUIPluginLib",
"SystemUISharedLib",
"SettingsLib",
@@ -47,6 +48,8 @@
"androidx.lifecycle_lifecycle-extensions",
"SystemUI-tags",
"SystemUI-proto",
+ "dagger2-2.19",
+ "//external/kotlinc:kotlin-annotations",
],
libs: [
@@ -56,6 +59,28 @@
manifest: "AndroidManifest.xml",
+ plugins: ["dagger2-compiler-2.19"],
+
+}
+
+android_app {
+ name: "CarSystemUI",
+
+ static_libs: [
+ "CarSystemUI-core",
+ ],
+
+ libs: [
+ "telephony-common",
+ "android.car",
+ ],
+
+ resource_dirs: [],
+
+ overrides: [
+ "SystemUI",
+ ],
+
platform_apis: true,
product_specific: true,
certificate: "platform",
@@ -66,12 +91,6 @@
"proguard.flags",
],
},
- resource_dirs: [
- "res-keyguard",
- "res",
- ],
-
-
dxflags: ["--multi-dex"],
aaptflags: [
@@ -79,6 +98,8 @@
"com.android.keyguard",
],
+ kotlincflags: ["-Xjvm-default=enable"],
+
plugins: ["dagger2-compiler-2.19"],
required: ["privapp_whitelist_com.android.systemui"],
diff --git a/packages/CarSystemUI/AndroidManifest.xml b/packages/CarSystemUI/AndroidManifest.xml
index 195d4fe..261b9f5 100644
--- a/packages/CarSystemUI/AndroidManifest.xml
+++ b/packages/CarSystemUI/AndroidManifest.xml
@@ -21,4 +21,8 @@
coreApp="true">
<!-- This permission is required to monitor car power state. -->
<uses-permission android:name="android.car.permission.CAR_POWER" />
+ <!-- This permission is required to get the trusted device list of a user. -->
+ <uses-permission android:name="android.car.permission.CAR_ENROLL_TRUST"/>
+ <!-- This permission is required to get bluetooth broadcast. -->
+ <uses-permission android:name="android.permission.BLUETOOTH" />
</manifest>
diff --git a/packages/CarSystemUI/res/drawable/unlock_dialog_background.xml b/packages/CarSystemUI/res/drawable/unlock_dialog_background.xml
new file mode 100644
index 0000000..bec6ba7
--- /dev/null
+++ b/packages/CarSystemUI/res/drawable/unlock_dialog_background.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ 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
+ -->
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+ <solid android:color="@color/unlock_dialog_background_color"/>
+ <padding
+ android:bottom="@*android:dimen/car_padding_2"
+ android:left="@*android:dimen/car_padding_2"
+ android:right="@*android:dimen/car_padding_2"
+ android:top="@*android:dimen/car_padding_2"/>
+ <corners
+ android:radius="@dimen/unlock_dialog_radius"/>
+</shape>
\ No newline at end of file
diff --git a/packages/CarSystemUI/res/layout/super_status_bar.xml b/packages/CarSystemUI/res/layout/super_status_bar.xml
index 728a239..e1bcc2e 100644
--- a/packages/CarSystemUI/res/layout/super_status_bar.xml
+++ b/packages/CarSystemUI/res/layout/super_status_bar.xml
@@ -42,6 +42,14 @@
</com.android.systemui.statusbar.BackDropView>
<com.android.systemui.statusbar.ScrimView
+ android:id="@+id/scrim_for_bubble"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:importantForAccessibility="no"
+ sysui:ignoreRightInset="true"
+ />
+
+ <com.android.systemui.statusbar.ScrimView
android:id="@+id/scrim_behind"
android:layout_width="match_parent"
android:layout_height="match_parent"
diff --git a/packages/CarSystemUI/res/layout/trust_agent_unlock_dialog.xml b/packages/CarSystemUI/res/layout/trust_agent_unlock_dialog.xml
new file mode 100644
index 0000000..9df78f1
--- /dev/null
+++ b/packages/CarSystemUI/res/layout/trust_agent_unlock_dialog.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ 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
+ -->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/unlock_dialog_parent"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center">
+
+ <LinearLayout
+ android:id="@+id/unlock_dialog"
+ android:layout_width="@dimen/unlock_dialog_width"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:layout_gravity="center"
+ android:orientation="vertical"
+ android:background="@drawable/unlock_dialog_background"
+ android:padding="@*android:dimen/car_padding_2">
+ <FrameLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
+ <ProgressBar
+ android:layout_gravity="center"
+ android:layout_width="@dimen/unlock_dialog_progress_bar_size"
+ android:layout_height="@dimen/unlock_dialog_progress_bar_size" />
+ <ImageView
+ android:id="@+id/avatar"
+ android:layout_gravity="center"
+ android:layout_width="@dimen/unlock_dialog_avatar_size"
+ android:layout_height="@dimen/unlock_dialog_avatar_size"
+ android:scaleType="fitCenter"/>
+ </FrameLayout>
+
+ <TextView
+ android:id="@+id/user_name"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:text="@string/unlock_dialog_default_user_name"
+ android:textSize="@*android:dimen/car_body1_size"
+ android:textColor="@android:color/white"/>
+
+ <TextView
+ android:id="@+id/unlocking_text"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:layout_marginTop="@*android:dimen/car_padding_1"
+ android:text="@string/unlock_dialog_message_default"
+ android:textSize="@*android:dimen/car_body4_size"
+ android:textColor="@color/unlock_dialog_message_text_default"/>
+
+ <Button
+ android:id="@+id/enter_pin_button"
+ android:layout_marginTop="@*android:dimen/car_padding_1"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:text="@string/unlock_dialog_button_text_pin"
+ style="@style/UnlockDialogButton"/>
+ </LinearLayout>
+</FrameLayout>
\ No newline at end of file
diff --git a/packages/CarSystemUI/res/values/colors.xml b/packages/CarSystemUI/res/values/colors.xml
index e13c940..b818962 100644
--- a/packages/CarSystemUI/res/values/colors.xml
+++ b/packages/CarSystemUI/res/values/colors.xml
@@ -32,7 +32,7 @@
<color name="system_bar_background_opaque">#ff172026</color>
<color name="status_bar_background_color">#33000000</color>
- <drawable name="system_bar_background">@android:color/transparent</drawable>
+ <drawable name="system_bar_background">@color/status_bar_background_color</drawable>
<!-- The background color of the notification shade -->
<color name="notification_shade_background_color">#DD000000</color>
diff --git a/packages/CarSystemUI/res/values/colors_car.xml b/packages/CarSystemUI/res/values/colors_car.xml
index 69ab3f3..0a3f7aa 100644
--- a/packages/CarSystemUI/res/values/colors_car.xml
+++ b/packages/CarSystemUI/res/values/colors_car.xml
@@ -26,4 +26,9 @@
<color name="car_user_switcher_add_user_background_color">@*android:color/car_dark_blue_grey_600</color>
<color name="car_user_switcher_add_user_add_sign_color">@*android:color/car_body1_light</color>
+ <!-- colors for unlock dialog -->
+ <color name="unlock_dialog_background_color">#ff282a2d</color>
+ <color name="unlock_dialog_message_text_default">@*android:color/car_grey_400</color>
+ <color name="unlock_dialog_enter_pin_text_color">#ff66b5ff</color>
+
</resources>
diff --git a/packages/CarSystemUI/res/values/dimens_car.xml b/packages/CarSystemUI/res/values/dimens_car.xml
index 42a7649..9cb09c9 100644
--- a/packages/CarSystemUI/res/values/dimens_car.xml
+++ b/packages/CarSystemUI/res/values/dimens_car.xml
@@ -43,4 +43,10 @@
<!-- This must be the negative of car_user_switcher_container_height for the animation. -->
<dimen name="car_user_switcher_container_anim_height">-420dp</dimen>
+ <!-- dimensions for the unlock dialog -->
+ <dimen name="unlock_dialog_width">500dp</dimen>
+ <dimen name="unlock_dialog_radius">16dp</dimen>
+ <dimen name="unlock_dialog_avatar_size">100dp</dimen>
+ <dimen name="unlock_dialog_progress_bar_size">140dp</dimen>
+
</resources>
diff --git a/packages/CarSystemUI/res/values/integers_car.xml b/packages/CarSystemUI/res/values/integers_car.xml
index be2cb0d..fb67b30 100644
--- a/packages/CarSystemUI/res/values/integers_car.xml
+++ b/packages/CarSystemUI/res/values/integers_car.xml
@@ -31,5 +31,7 @@
<!--Percentage of the screen height, from the bottom, that a notification panel being peeked
at will result in remaining closed the panel if released-->
<integer name="notification_settle_close_percentage">80</integer>
+ <!-- The delay before the unlock dialog pops up -->
+ <integer name="unlock_dialog_delay_ms">0</integer>
</resources>
diff --git a/packages/CarSystemUI/res/values/strings_car.xml b/packages/CarSystemUI/res/values/strings_car.xml
index 83e91c5..717692e 100644
--- a/packages/CarSystemUI/res/values/strings_car.xml
+++ b/packages/CarSystemUI/res/values/strings_car.xml
@@ -29,4 +29,19 @@
<string name="user_add_user_message_setup">When you add a new user, that person needs to set up their space.</string>
<!-- Message to inform user that the newly created user will have permissions to update apps for all other users. [CHAR LIMIT=100] -->
<string name="user_add_user_message_update">Any user can update apps for all other users.</string>
+ <!-- Default messages displayed on the unlock dialog before unlock advertising started. [CHAR LIMIT=30]-->
+ <string name="unlock_dialog_message_default">Waiting\u2026</string>
+ <!-- Message to inform user that the IHU is looking for trusted device. [CHAR LIMIT=30] -->
+ <string name="unlock_dialog_message_start">Looking for trusted device\u2026</string>
+
+ <!-- Cancel Button text for user who has PIN as security lock. [CHAR LIMIT=30] -->
+ <string name="unlock_dialog_button_text_pin">Enter PIN instead</string>
+ <!-- Cancel Button text for user who has Pattern as security lock. [CHAR LIMIT=30] -->
+ <string name="unlock_dialog_button_text_pattern">Enter Pattern instead</string>
+ <!-- Cancel Button text for user who has Password as security lock. [CHAR LIMIT=30] -->
+ <string name="unlock_dialog_button_text_password">Enter Password instead</string>
+ <!-- Default user name shows on unlock dialog -->
+ <string name="unlock_dialog_default_user_name">Default Name</string>
+ <!-- Default title for unlock dialog -->
+ <string name="unlock_dialog_title">Unlock Dialogue</string>
</resources>
diff --git a/packages/CarSystemUI/res/values/styles.xml b/packages/CarSystemUI/res/values/styles.xml
index 371bebd..a9423bf 100644
--- a/packages/CarSystemUI/res/values/styles.xml
+++ b/packages/CarSystemUI/res/values/styles.xml
@@ -46,4 +46,12 @@
<item name="android:layout_width">96dp</item>
<item name="android:background">@drawable/nav_button_background</item>
</style>
+
+ <style name="UnlockDialogButton">
+ <item name="android:background">?android:attr/selectableItemBackground</item>
+ <item name="android:textAlignment">center</item>
+ <item name="android:textColor">@color/unlock_dialog_enter_pin_text_color</item>
+ <item name="android:paddingHorizontal">16dp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
</resources>
\ No newline at end of file
diff --git a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIFactory.java b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIFactory.java
index 3b278b4..c7654e8 100644
--- a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIFactory.java
+++ b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIFactory.java
@@ -20,12 +20,8 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.ViewMediatorCallback;
-import com.android.systemui.car.CarNotificationEntryManager;
-import com.android.systemui.car.CarNotificationInterruptionStateProvider;
import com.android.systemui.statusbar.car.CarFacetButtonController;
import com.android.systemui.statusbar.car.CarStatusBarKeyguardViewManager;
-import com.android.systemui.statusbar.notification.NotificationEntryManager;
-import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.volume.CarVolumeDialogComponent;
import com.android.systemui.volume.VolumeDialogComponent;
@@ -33,8 +29,6 @@
import javax.inject.Singleton;
import dagger.Component;
-import dagger.Module;
-import dagger.Provides;
/**
* Class factory to provide car specific SystemUI components.
@@ -44,11 +38,14 @@
private CarDependencyComponent mCarDependencyComponent;
@Override
- protected void init(Context context) {
- super.init(context);
+ protected SystemUIRootComponent buildSystemUIRootComponent(Context context) {
mCarDependencyComponent = DaggerCarSystemUIFactory_CarDependencyComponent.builder()
.contextHolder(new ContextHolder(context))
.build();
+ return DaggerCarSystemUIRootComponent.builder()
+ .dependencyProvider(new com.android.systemui.DependencyProvider())
+ .contextHolder(new ContextHolder(context))
+ .build();
}
public CarDependencyComponent getCarDependencyComponent() {
@@ -64,42 +61,9 @@
return new CarVolumeDialogComponent(systemUi, context);
}
- @Override
- public NotificationInterruptionStateProvider provideNotificationInterruptionStateProvider(
- Context context) {
- return new CarNotificationInterruptionStateProvider(context);
- }
-
- @Override
- public boolean provideAllowNotificationLongPress() {
- return false;
- }
-
- @Module
- protected static class ContextHolder {
- private Context mContext;
-
- public ContextHolder(Context context) {
- mContext = context;
- }
-
- @Provides
- public Context provideContext() {
- return mContext;
- }
- }
-
@Singleton
@Component(modules = ContextHolder.class)
public interface CarDependencyComponent {
CarFacetButtonController getCarFacetButtonController();
}
-
- /**
- * Use {@link CarNotificationEntryManager}, which does nothing when adding a notification.
- */
- @Singleton
- public NotificationEntryManager provideNotificationEntryManager(Context context) {
- return new CarNotificationEntryManager(context);
- }
}
diff --git a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java
new file mode 100644
index 0000000..9a063aa
--- /dev/null
+++ b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java
@@ -0,0 +1,97 @@
+/*
+ * 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.
+ */
+
+package com.android.systemui;
+
+import static com.android.systemui.Dependency.ALLOW_NOTIFICATION_LONG_PRESS_NAME;
+import static com.android.systemui.Dependency.LEAK_REPORT_EMAIL_NAME;
+
+import android.content.Context;
+
+import com.android.systemui.car.CarNotificationEntryManager;
+import com.android.systemui.car.CarNotificationInterruptionStateProvider;
+import com.android.systemui.dock.DockManager;
+import com.android.systemui.dock.DockManagerImpl;
+import com.android.systemui.power.EnhancedEstimates;
+import com.android.systemui.power.EnhancedEstimatesImpl;
+import com.android.systemui.statusbar.NotificationLockscreenUserManager;
+import com.android.systemui.statusbar.NotificationLockscreenUserManagerImpl;
+import com.android.systemui.statusbar.notification.NotificationEntryManager;
+import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider;
+import com.android.systemui.statusbar.notification.collection.NotificationData;
+import com.android.systemui.statusbar.phone.KeyguardEnvironmentImpl;
+import com.android.systemui.statusbar.phone.ShadeController;
+import com.android.systemui.statusbar.phone.StatusBar;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import dagger.Binds;
+import dagger.Module;
+import dagger.Provides;
+
+@Module
+abstract class CarSystemUIModule {
+
+ @Binds
+ abstract NotificationInterruptionStateProvider bindNotificationInterruptionStateProvider(
+ CarNotificationInterruptionStateProvider notificationInterruptionStateProvider);
+
+ @Singleton
+ @Provides
+ @Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME)
+ static boolean provideAllowNotificationLongPress() {
+ return false;
+ }
+
+ /**
+ * Use {@link CarNotificationEntryManager}, which does nothing when adding a notification.
+ */
+ @Binds
+ abstract NotificationEntryManager bindNotificationEntryManager(
+ CarNotificationEntryManager notificationEntryManager);
+
+ @Singleton
+ @Provides
+ @Named(LEAK_REPORT_EMAIL_NAME)
+ static String provideLeakReportEmail() {
+ return "buganizer-system+181579@google.com";
+ }
+
+ @Binds
+ abstract EnhancedEstimates bindEnhancedEstimates(EnhancedEstimatesImpl enhancedEstimates);
+
+ @Binds
+ abstract NotificationLockscreenUserManager bindNotificationLockscreenUserManager(
+ NotificationLockscreenUserManagerImpl notificationLockscreenUserManager);
+
+ @Binds
+ abstract DockManager bindDockManager(DockManagerImpl dockManager);
+
+ @Binds
+ abstract NotificationData.KeyguardEnvironment bindKeyguardEnvironment(
+ KeyguardEnvironmentImpl keyguardEnvironment);
+
+ @Singleton
+ @Provides
+ static ShadeController provideShadeController(Context context) {
+ return SysUiServiceProvider.getComponent(context, StatusBar.class);
+ }
+
+ @Binds
+ abstract SystemUIRootComponent bindSystemUIRootComponent(
+ CarSystemUIRootComponent systemUIRootComponent);
+}
diff --git a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIRootComponent.java b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIRootComponent.java
new file mode 100644
index 0000000..d6b766b
--- /dev/null
+++ b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIRootComponent.java
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+package com.android.systemui;
+
+import javax.inject.Singleton;
+
+import dagger.Component;
+
+@Singleton
+@Component(
+ modules = {
+ DependencyProvider.class,
+ DependencyBinder.class,
+ ServiceBinder.class,
+ SystemUIFactory.ContextHolder.class,
+ SystemUIModule.class,
+ CarSystemUIModule.class
+ })
+interface CarSystemUIRootComponent extends SystemUIRootComponent {
+
+}
diff --git a/packages/CarSystemUI/src/com/android/systemui/car/CarNotificationEntryManager.java b/packages/CarSystemUI/src/com/android/systemui/car/CarNotificationEntryManager.java
index 6d9c7ba..a107dd7 100644
--- a/packages/CarSystemUI/src/com/android/systemui/car/CarNotificationEntryManager.java
+++ b/packages/CarSystemUI/src/com/android/systemui/car/CarNotificationEntryManager.java
@@ -21,13 +21,19 @@
import com.android.systemui.statusbar.notification.NotificationEntryManager;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
/**
* Car specific notification entry manager that does nothing when adding a notification.
*
* <p> This is because system UI notifications are disabled and we have a different implementation.
* Please see {@link com.android.car.notification}.
*/
+@Singleton
public class CarNotificationEntryManager extends NotificationEntryManager {
+
+ @Inject
public CarNotificationEntryManager(Context context) {
super(context);
}
diff --git a/packages/CarSystemUI/src/com/android/systemui/car/CarNotificationInterruptionStateProvider.java b/packages/CarSystemUI/src/com/android/systemui/car/CarNotificationInterruptionStateProvider.java
index 6d960d7..afd722b 100644
--- a/packages/CarSystemUI/src/com/android/systemui/car/CarNotificationInterruptionStateProvider.java
+++ b/packages/CarSystemUI/src/com/android/systemui/car/CarNotificationInterruptionStateProvider.java
@@ -18,14 +18,24 @@
import android.content.Context;
+import com.android.systemui.plugins.statusbar.StatusBarStateController;
+import com.android.systemui.statusbar.notification.NotificationFilter;
import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
/** Auto-specific implementation of {@link NotificationInterruptionStateProvider}. */
+@Singleton
public class CarNotificationInterruptionStateProvider extends
NotificationInterruptionStateProvider {
- public CarNotificationInterruptionStateProvider(Context context) {
- super(context);
+
+ @Inject
+ public CarNotificationInterruptionStateProvider(Context context,
+ NotificationFilter filter,
+ StatusBarStateController stateController) {
+ super(context, filter, stateController);
}
@Override
diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
index 2874ce6..25191f6 100644
--- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
+++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
@@ -26,11 +26,15 @@
import android.car.drivingstate.CarDrivingStateEvent;
import android.car.drivingstate.CarUxRestrictionsManager;
import android.car.hardware.power.CarPowerManager.CarPowerStateListener;
+import android.car.trust.CarTrustAgentEnrollmentManager;
import android.content.Context;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
+import android.inputmethodservice.InputMethodService;
+import android.os.IBinder;
import android.util.Log;
+import android.view.Display;
import android.view.GestureDetector;
import android.view.Gravity;
import android.view.MotionEvent;
@@ -61,9 +65,9 @@
import com.android.systemui.R;
import com.android.systemui.SystemUIFactory;
import com.android.systemui.classifier.FalsingLog;
-import com.android.systemui.classifier.FalsingManagerFactory;
import com.android.systemui.fragments.FragmentHostManager;
import com.android.systemui.keyguard.ScreenLifecycle;
+import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.qs.QS;
import com.android.systemui.qs.car.CarQSFragment;
import com.android.systemui.shared.system.ActivityManagerWrapper;
@@ -85,8 +89,7 @@
/**
* A status bar (and navigation bar) tailored for the automotive use case.
*/
-public class CarStatusBar extends StatusBar implements
- CarBatteryController.BatteryViewHandler {
+public class CarStatusBar extends StatusBar implements CarBatteryController.BatteryViewHandler {
private static final String TAG = "CarStatusBar";
// used to calculate how fast to open or close the window
private static final float DEFAULT_FLING_VELOCITY = 0;
@@ -167,6 +170,9 @@
private boolean mIsSwipingVerticallyToClose;
// Whether heads-up notifications should be shown when shade is open.
private boolean mEnableHeadsUpNotificationWhenNotificationShadeOpen;
+ // If the nav bar should be hidden when the soft keyboard is visible.
+ private boolean mHideNavBarForKeyboard;
+ private boolean mBottomNavBarVisible;
private final CarPowerStateListener mCarPowerStateListener =
(int state) -> {
@@ -188,6 +194,17 @@
// builds the nav bar
mDeviceProvisionedController = Dependency.get(DeviceProvisionedController.class);
mDeviceIsProvisioned = mDeviceProvisionedController.isDeviceProvisioned();
+
+ // Keyboard related setup, before nav bars are created.
+ mHideNavBarForKeyboard = mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_automotiveHideNavBarForKeyboard);
+ mBottomNavBarVisible = false;
+
+ // Need to initialize screen lifecycle before calling super.start - before switcher is
+ // created.
+ mScreenLifecycle = Dependency.get(ScreenLifecycle.class);
+ mScreenLifecycle.addObserver(mScreenObserver);
+
super.start();
mTaskStackListener = new TaskStackListenerImpl();
mActivityManagerWrapper = ActivityManagerWrapper.getInstance();
@@ -234,9 +251,6 @@
mPowerManagerHelper.connectToCarService();
mSwitchToGuestTimer = new SwitchToGuestTimer(mContext);
-
- mScreenLifecycle = Dependency.get(ScreenLifecycle.class);
- mScreenLifecycle.addObserver(mScreenObserver);
}
/**
@@ -718,6 +732,13 @@
buildNavBarContent();
attachNavBarWindows();
+ // Try setting up the initial state of the nav bar if applicable.
+ if (result != null) {
+ setImeWindowStatus(Display.DEFAULT_DISPLAY, result.mImeToken,
+ result.mImeWindowVis, result.mImeBackDisposition,
+ result.mShowImeSwitcher);
+ }
+
// There has been a car customized nav bar on the default display, so just create nav bars
// on external displays.
mNavigationBarController.createNavigationBars(false /* includeDefaultDisplay */, result);
@@ -756,22 +777,33 @@
}
- private void attachNavBarWindows() {
-
- if (mShowBottom) {
- WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
- LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,
- WindowManager.LayoutParams.TYPE_NAVIGATION_BAR,
- WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
- | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
- | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
- | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
- PixelFormat.TRANSLUCENT);
- lp.setTitle("CarNavigationBar");
- lp.windowAnimations = 0;
- mWindowManager.addView(mNavigationBarWindow, lp);
+ /**
+ * We register for soft keyboard visibility events such that we can hide the navigation bar
+ * giving more screen space to the IME. Note: this is optional and controlled by
+ * {@code com.android.internal.R.bool.config_automotiveHideNavBarForKeyboard}.
+ */
+ @Override
+ public void setImeWindowStatus(int displayId, IBinder token, int vis, int backDisposition,
+ boolean showImeSwitcher) {
+ if (!mHideNavBarForKeyboard) {
+ return;
}
+ if (mContext.getDisplay().getDisplayId() != displayId) {
+ return;
+ }
+
+ boolean isKeyboardVisible = (vis & InputMethodService.IME_VISIBLE) != 0;
+ if (!isKeyboardVisible) {
+ attachBottomNavBarWindow();
+ } else {
+ detachBottomNavBarWindow();
+ }
+ }
+
+ private void attachNavBarWindows() {
+ attachBottomNavBarWindow();
+
if (mShowLeft) {
int width = mContext.getResources().getDimensionPixelSize(
R.dimen.car_left_navigation_bar_width);
@@ -806,7 +838,49 @@
rightlp.gravity = Gravity.RIGHT;
mWindowManager.addView(mRightNavigationBarWindow, rightlp);
}
+ }
+ /**
+ * Attaches the bottom nav bar window. Can be extended to modify the specific behavior of
+ * attaching the bottom nav bar.
+ */
+ protected void attachBottomNavBarWindow() {
+ if (!mShowBottom) {
+ return;
+ }
+
+ if (mBottomNavBarVisible) {
+ return;
+ }
+ mBottomNavBarVisible = true;
+
+ WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
+ LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,
+ WindowManager.LayoutParams.TYPE_NAVIGATION_BAR,
+ WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
+ | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
+ | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
+ | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
+ PixelFormat.TRANSLUCENT);
+ lp.setTitle("CarNavigationBar");
+ lp.windowAnimations = 0;
+ mWindowManager.addView(mNavigationBarWindow, lp);
+ }
+
+ /**
+ * Detaches the bottom nav bar window. Can be extended to modify the specific behavior of
+ * detaching the bottom nav bar.
+ */
+ protected void detachBottomNavBarWindow() {
+ if (!mShowBottom) {
+ return;
+ }
+
+ if (!mBottomNavBarVisible) {
+ return;
+ }
+ mBottomNavBarVisible = false;
+ mWindowManager.removeView(mNavigationBarWindow);
}
private void buildBottomBar(int layout) {
@@ -877,7 +951,7 @@
KeyguardUpdateMonitor.getInstance(mContext).dump(fd, pw, args);
}
- FalsingManagerFactory.getInstance(mContext).dump(pw);
+ Dependency.get(FalsingManager.class).dump(pw);
FalsingLog.dump(pw);
pw.println("SharedPreferences:");
@@ -956,8 +1030,12 @@
UserSwitcherController userSwitcherController =
Dependency.get(UserSwitcherController.class);
if (userSwitcherController.useFullscreenUserSwitcher()) {
+ Car car = Car.createCar(mContext);
+ CarTrustAgentEnrollmentManager enrollmentManager = (CarTrustAgentEnrollmentManager) car
+ .getCarManager(Car.CAR_TRUST_AGENT_ENROLLMENT_SERVICE);
mFullscreenUserSwitcher = new FullscreenUserSwitcher(this,
- mStatusBarWindow.findViewById(R.id.fullscreen_user_switcher_stub), mContext);
+ mStatusBarWindow.findViewById(R.id.fullscreen_user_switcher_stub),
+ enrollmentManager, mContext);
} else {
super.createUserSwitcher();
}
@@ -1072,9 +1150,10 @@
// shade is visible to the user. When the notification shade is completely open then
// alpha value will be 1.
float alpha = (float) height / mNotificationView.getHeight();
- Drawable background = mNotificationView.getBackground();
+ Drawable background = mNotificationView.getBackground().mutate();
background.setAlpha((int) (alpha * 255));
+ mNotificationView.setBackground(background);
}
}
diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarTrustAgentUnlockDialogHelper.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarTrustAgentUnlockDialogHelper.java
new file mode 100644
index 0000000..ec72ee7
--- /dev/null
+++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarTrustAgentUnlockDialogHelper.java
@@ -0,0 +1,256 @@
+/*
+ * 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.
+ */
+
+package com.android.systemui.statusbar.car;
+
+import android.app.admin.DevicePolicyManager;
+import android.bluetooth.BluetoothAdapter;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.graphics.PixelFormat;
+import android.os.Handler;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.android.internal.widget.LockPatternUtils;
+import com.android.systemui.R;
+
+/**
+ * A helper class displays an unlock dialog and receives broadcast about detecting trusted device
+ * & unlocking state to show the appropriate message on the dialog.
+ */
+class CarTrustAgentUnlockDialogHelper extends BroadcastReceiver{
+ private static final String TAG = CarTrustAgentUnlockDialogHelper.class.getSimpleName();
+
+ private final Context mContext;
+ private final WindowManager mWindowManager;
+ private final UserManager mUserManager;
+ private final WindowManager.LayoutParams mParams;
+ /**
+ * Not using Dialog because context passed from {@link FullscreenUserSwitcher} is not an
+ * activity.
+ */
+ private final View mUnlockDialogLayout;
+ private final TextView mUnlockingText;
+ private final Button mButton;
+ private final IntentFilter mFilter;
+ private int mUid;
+ private boolean mIsDialogShowing;
+ private OnHideListener mOnHideListener;
+
+ CarTrustAgentUnlockDialogHelper(Context context) {
+ mContext = context;
+ mUserManager = mContext.getSystemService(UserManager.class);
+ mWindowManager = mContext.getSystemService(WindowManager.class);
+ mParams = createLayoutParams();
+ mFilter = getIntentFilter();
+
+ mParams.packageName = mContext.getPackageName();
+ mParams.setTitle(mContext.getString(R.string.unlock_dialog_title));
+
+ mUnlockDialogLayout = LayoutInflater.from(mContext).inflate(
+ R.layout.trust_agent_unlock_dialog, null);
+ mUnlockDialogLayout.setLayoutParams(mParams);
+
+ View dialogParent = mUnlockDialogLayout.findViewById(R.id.unlock_dialog_parent);
+ dialogParent.setOnTouchListener((v, event)-> {
+ hideUnlockDialog(/* dismissUserSwitcher= */ false);
+ return true;
+ });
+ View unlockDialog = mUnlockDialogLayout.findViewById(R.id.unlock_dialog);
+ unlockDialog.setOnTouchListener((v, event) -> {
+ // If the person taps inside the unlock dialog, the touch event will be intercepted here
+ // and the dialog will not exit
+ return true;
+ });
+ mUnlockingText = mUnlockDialogLayout.findViewById(R.id.unlocking_text);
+ mButton = mUnlockDialogLayout.findViewById(R.id.enter_pin_button);
+ mButton.setOnClickListener(v -> {
+ hideUnlockDialog(/* dismissUserSwitcher= */true);
+ // TODO(b/138250105) Stop unlock advertising
+ });
+
+ BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+ if (bluetoothAdapter != null
+ && bluetoothAdapter.getLeState() == BluetoothAdapter.STATE_BLE_ON) {
+ mUnlockingText.setText(R.string.unlock_dialog_message_start);
+ }
+ }
+
+ /**
+ * This filter is listening on:
+ * {@link BluetoothAdapter#ACTION_BLE_STATE_CHANGED} for starting unlock advertising;
+ * {@link Intent#ACTION_USER_UNLOCKED} for IHU unlocked
+ */
+ private IntentFilter getIntentFilter() {
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(BluetoothAdapter.ACTION_BLE_STATE_CHANGED);
+ filter.addAction(Intent.ACTION_USER_UNLOCKED);
+ return filter;
+ }
+
+ /**
+ * Show dialog for the given user
+ */
+ void showUnlockDialog(int uid, OnHideListener listener) {
+ showUnlockDialogAfterDelay(uid, 0, listener);
+ }
+
+ /**
+ * Show dialog for the given user after the certain time of delay has elapsed
+ *
+ * @param uid the user to unlock
+ * @param listener listener that listens to dialog hide
+ */
+ void showUnlockDialogAfterDelay(int uid, OnHideListener listener) {
+ long delayMillis = mContext.getResources().getInteger(R.integer.unlock_dialog_delay_ms);
+ showUnlockDialogAfterDelay(uid, delayMillis, listener);
+ }
+
+ /**
+ * Show dialog for the given user after the supplied delay has elapsed
+ */
+ private void showUnlockDialogAfterDelay(int uid, long delayMillis, OnHideListener listener) {
+ setUid(uid);
+ mOnHideListener = listener;
+ if (!mIsDialogShowing) {
+ logd("Receiver registered");
+ mContext.registerReceiverAsUser(this, UserHandle.ALL, mFilter,
+ /* broadcastPermission= */ null,
+ /* scheduler= */ null);
+ new Handler().postDelayed(() -> {
+ if (!mUserManager.isUserUnlocked(uid)) {
+ logd("Showed unlock dialog for user: " + uid + " after " + delayMillis
+ + " delay.");
+ mWindowManager.addView(mUnlockDialogLayout, mParams);
+ }
+ }, delayMillis);
+ }
+ mIsDialogShowing = true;
+ }
+
+ private void setUid(int uid) {
+ mUid = uid;
+ TextView userName = mUnlockDialogLayout.findViewById(R.id.user_name);
+ userName.setText(mUserManager.getUserInfo(mUid).name);
+ ImageView avatar = mUnlockDialogLayout.findViewById(R.id.avatar);
+ avatar.setImageBitmap(mUserManager.getUserIcon(mUid));
+ setButtonText();
+ }
+
+ private void hideUnlockDialog(boolean dismissUserSwitcher) {
+ if (!mIsDialogShowing) {
+ return;
+ }
+ mWindowManager.removeView(mUnlockDialogLayout);
+ logd("Receiver unregistered");
+ mContext.unregisterReceiver(this);
+ if (mOnHideListener != null) {
+ mOnHideListener.onHide(dismissUserSwitcher);
+ }
+ mIsDialogShowing = false;
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ if (action == null) {
+ return;
+ }
+ switch (action) {
+ case BluetoothAdapter.ACTION_BLE_STATE_CHANGED:
+ logd("Received ACTION_BLE_STATE_CHANGED");
+ int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1);
+ if (state == BluetoothAdapter.STATE_BLE_ON) {
+ logd("Received BLE_ON");
+ mUnlockingText.setText(R.string.unlock_dialog_message_start);
+ }
+ break;
+ case Intent.ACTION_USER_UNLOCKED:
+ int uid = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1);
+ if (uid == mUid) {
+ logd("IHU unlocked");
+ hideUnlockDialog(/* notifyOnHideListener= */false);
+ } else {
+ Log.e(TAG, "Received ACTION_USER_UNLOCKED for unexpected uid: " + uid);
+ }
+ break;
+ default:
+ Log.e(TAG, "Encountered unexpected action when attempting to set "
+ + "unlock state message: " + action);
+ }
+ }
+
+ // Set button text based on screen lock type
+ private void setButtonText() {
+ LockPatternUtils lockPatternUtils = new LockPatternUtils(mContext);
+ int passwordQuality = lockPatternUtils.getActivePasswordQuality(mUid);
+ switch (passwordQuality) {
+ // PIN
+ case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
+ case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX:
+ mButton.setText(R.string.unlock_dialog_button_text_pin);
+ break;
+ // Pattern
+ case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
+ mButton.setText(R.string.unlock_dialog_button_text_pattern);
+ break;
+ // Password
+ case DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC:
+ case DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC:
+ case DevicePolicyManager.PASSWORD_QUALITY_COMPLEX:
+ mButton.setText(R.string.unlock_dialog_button_text_password);
+ break;
+ default:
+ Log.e(TAG, "Encountered unexpected screen lock type when attempting to set "
+ + "button text:" + passwordQuality);
+ }
+ }
+
+ private WindowManager.LayoutParams createLayoutParams() {
+ return new WindowManager.LayoutParams(
+ WindowManager.LayoutParams.MATCH_PARENT,
+ WindowManager.LayoutParams.MATCH_PARENT,
+ WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN
+ | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
+ | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
+ PixelFormat.TRANSLUCENT
+ );
+ }
+
+ private void logd(String message) {
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, message);
+ }
+ }
+
+ /**
+ * Listener used to notify when the dialog is hidden
+ */
+ interface OnHideListener {
+ void onHide(boolean dismissUserSwitcher);
+ }
+}
diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java
index 0a167d9..0f7c1ee 100644
--- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java
+++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java
@@ -18,29 +18,61 @@
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
+import android.car.trust.CarTrustAgentEnrollmentManager;
+import android.car.userlib.CarUserManagerHelper;
+import android.content.BroadcastReceiver;
import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.pm.UserInfo;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.util.Log;
import android.view.View;
import android.view.ViewStub;
import androidx.recyclerview.widget.GridLayoutManager;
import com.android.systemui.R;
+import com.android.systemui.statusbar.car.CarTrustAgentUnlockDialogHelper.OnHideListener;
+import com.android.systemui.statusbar.car.UserGridRecyclerView.UserRecord;
/**
* Manages the fullscreen user switcher.
*/
public class FullscreenUserSwitcher {
+ private static final String TAG = FullscreenUserSwitcher.class.getSimpleName();
+ // Because user 0 is headless, user count for single user is 2
+ private static final int NUMBER_OF_BACKGROUND_USERS = 1;
private final UserGridRecyclerView mUserGridView;
private final View mParent;
private final int mShortAnimDuration;
private final CarStatusBar mStatusBar;
+ private final Context mContext;
+ private final UserManager mUserManager;
+ private final CarTrustAgentEnrollmentManager mEnrollmentManager;
+ private CarTrustAgentUnlockDialogHelper mUnlockDialogHelper;
+ private UserGridRecyclerView.UserRecord mSelectedUser;
+ private CarUserManagerHelper mCarUserManagerHelper;
+ private final BroadcastReceiver mUserUnlockReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "user 0 is unlocked, SharedPreference is accessible.");
+ }
+ showDialogForInitialUser();
+ mContext.unregisterReceiver(mUserUnlockReceiver);
+ }
+ };
- public FullscreenUserSwitcher(CarStatusBar statusBar, ViewStub containerStub, Context context) {
+
+ public FullscreenUserSwitcher(CarStatusBar statusBar, ViewStub containerStub,
+ CarTrustAgentEnrollmentManager enrollmentManager, Context context) {
mStatusBar = statusBar;
mParent = containerStub.inflate();
- // Hide the user grid by default. It will only be made visible by clicking on a cancel
- // button in a bouncer.
- hide();
+ mEnrollmentManager = enrollmentManager;
+ mContext = context;
+
View container = mParent.findViewById(R.id.container);
// Initialize user grid.
@@ -50,9 +82,51 @@
mUserGridView.setLayoutManager(layoutManager);
mUserGridView.buildAdapter();
mUserGridView.setUserSelectionListener(this::onUserSelected);
+ mCarUserManagerHelper = new CarUserManagerHelper(context);
+ mUnlockDialogHelper = new CarTrustAgentUnlockDialogHelper(mContext);
+ mUserManager = mContext.getSystemService(UserManager.class);
mShortAnimDuration = container.getResources()
.getInteger(android.R.integer.config_shortAnimTime);
+ IntentFilter filter = new IntentFilter(Intent.ACTION_USER_UNLOCKED);
+ if (mUserManager.isUserUnlocked(UserHandle.USER_SYSTEM)) {
+ // User0 is unlocked, switched to the initial user
+ showDialogForInitialUser();
+ } else {
+ // listen to USER_UNLOCKED
+ mContext.registerReceiverAsUser(mUserUnlockReceiver,
+ UserHandle.getUserHandleForUid(UserHandle.USER_SYSTEM),
+ filter,
+ /* broadcastPermission= */ null,
+ /* scheduler */ null);
+ }
+ }
+
+ private void showDialogForInitialUser() {
+ int initialUser = mCarUserManagerHelper.getInitialUser();
+ UserInfo initialUserInfo = mUserManager.getUserInfo(initialUser);
+ mSelectedUser = new UserRecord(initialUserInfo,
+ /* isStartGuestSession= */ false,
+ /* isAddUser= */ false,
+ /* isForeground= */ true);
+ // For single user without trusted device, hide the user switcher.
+ if (!hasMultipleUsers() && !hasTrustedDevice(initialUser)) {
+ dismissUserSwitcher();
+ return;
+ }
+ // Show unlock dialog for initial user
+ if (hasTrustedDevice(initialUser)) {
+ mUnlockDialogHelper.showUnlockDialogAfterDelay(initialUser,
+ mOnHideListener);
+ }
+ }
+
+ /**
+ * Check if there is only one possible user to login in.
+ * In a Multi-User system there is always one background user (user 0)
+ */
+ private boolean hasMultipleUsers() {
+ return mUserManager.getUserCount() > NUMBER_OF_BACKGROUND_USERS + 1;
}
/**
@@ -77,14 +151,33 @@
}
/**
- * Every time user clicks on an item in the switcher, we hide the switcher, either
- * gradually or immediately.
+ * Every time user clicks on an item in the switcher, if the clicked user has no trusted device,
+ * we hide the switcher, either gradually or immediately.
*
- * We dismiss the entire keyguard if user clicked on the foreground user (user we're already
- * logged in as).
+ * If the user has trusted device, we show an unlock dialog to notify user the unlock state.
+ * When the unlock dialog is dismissed by user, we hide the unlock dialog and the switcher.
+ *
+ * We dismiss the entire keyguard when we hide the switcher if user clicked on the foreground
+ * user (user we're already logged in as).
*/
private void onUserSelected(UserGridRecyclerView.UserRecord record) {
- if (record.mIsForeground) {
+ mSelectedUser = record;
+ if (hasTrustedDevice(record.mInfo.id)) {
+ mUnlockDialogHelper.showUnlockDialog(record.mInfo.id, mOnHideListener);
+ return;
+ }
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "no trusted device enrolled for uid: " + record.mInfo.id);
+ }
+ dismissUserSwitcher();
+ }
+
+ private void dismissUserSwitcher() {
+ if (mSelectedUser == null) {
+ Log.e(TAG, "Request to dismiss user switcher, but no user selected");
+ return;
+ }
+ if (mSelectedUser.mIsForeground) {
hide();
mStatusBar.dismissKeyguard();
return;
@@ -106,4 +199,22 @@
});
}
+
+ private boolean hasTrustedDevice(int uid) {
+ return !mEnrollmentManager.getEnrolledDeviceInfoForUser(uid).isEmpty();
+ }
+
+ private OnHideListener mOnHideListener = new OnHideListener() {
+ @Override
+ public void onHide(boolean dismissUserSwitcher) {
+ if (dismissUserSwitcher) {
+ dismissUserSwitcher();
+ } else {
+ // Re-draw the parent view, otherwise the unlock dialog will not be removed from
+ // the screen immediately.
+ mParent.invalidate();
+ }
+
+ }
+ };
}
diff --git a/packages/SettingsLib/HelpUtils/AndroidManifest.xml b/packages/SettingsLib/HelpUtils/AndroidManifest.xml
index 5240ce4..ccad6e4 100644
--- a/packages/SettingsLib/HelpUtils/AndroidManifest.xml
+++ b/packages/SettingsLib/HelpUtils/AndroidManifest.xml
@@ -16,6 +16,6 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.settingslib.helputils">
+ package="com.android.settingslib.widget">
</manifest>
diff --git a/packages/SettingsLib/HelpUtils/src/com/android/settingslib/HelpUtils.java b/packages/SettingsLib/HelpUtils/src/com/android/settingslib/HelpUtils.java
index e407d72..2d13b73 100644
--- a/packages/SettingsLib/HelpUtils/src/com/android/settingslib/HelpUtils.java
+++ b/packages/SettingsLib/HelpUtils/src/com/android/settingslib/HelpUtils.java
@@ -33,11 +33,11 @@
import android.view.MenuItem;
import android.view.MenuItem.OnMenuItemClickListener;
+import com.android.settingslib.widget.R;
+
import java.net.URISyntaxException;
import java.util.Locale;
-import com.android.settingslib.helputils.R;
-
/**
* Functions to easily prepare contextual help menu option items with an intent that opens up the
* browser to a particular URL, while taking into account the preferred language and app version.
diff --git a/packages/SettingsLib/RestrictedLockUtils/AndroidManifest.xml b/packages/SettingsLib/RestrictedLockUtils/AndroidManifest.xml
index d19a022..0975640 100644
--- a/packages/SettingsLib/RestrictedLockUtils/AndroidManifest.xml
+++ b/packages/SettingsLib/RestrictedLockUtils/AndroidManifest.xml
@@ -16,6 +16,6 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.settingslib.restrictedlockutils">
+ package="com.android.settingslib.widget">
</manifest>
\ No newline at end of file
diff --git a/packages/SettingsLib/res/values-es-rUS/strings.xml b/packages/SettingsLib/res/values-es-rUS/strings.xml
index 3b67eead..bdc6a1d 100644
--- a/packages/SettingsLib/res/values-es-rUS/strings.xml
+++ b/packages/SettingsLib/res/values-es-rUS/strings.xml
@@ -143,7 +143,7 @@
<string name="data_usage_uninstalled_apps" msgid="614263770923231598">"Aplicaciones eliminadas"</string>
<string name="data_usage_uninstalled_apps_users" msgid="7986294489899813194">"Aplicaciones y usuarios eliminados"</string>
<string name="data_usage_ota" msgid="5377889154805560860">"Actualizaciones del sistema"</string>
- <string name="tether_settings_title_usb" msgid="6688416425801386511">"Conexión mediante USB"</string>
+ <string name="tether_settings_title_usb" msgid="6688416425801386511">"Conexión USB"</string>
<string name="tether_settings_title_wifi" msgid="3277144155960302049">"Hotspot portátil"</string>
<string name="tether_settings_title_bluetooth" msgid="355855408317564420">"Conexión mediante Bluetooth"</string>
<string name="tether_settings_title_usb_bluetooth" msgid="5355828977109785001">"Compartir conexión"</string>
diff --git a/packages/SettingsLib/res/values-hi/strings.xml b/packages/SettingsLib/res/values-hi/strings.xml
index 76097fd..7bba7cf 100644
--- a/packages/SettingsLib/res/values-hi/strings.xml
+++ b/packages/SettingsLib/res/values-hi/strings.xml
@@ -90,7 +90,7 @@
<string name="bluetooth_profile_pbap_summary" msgid="6605229608108852198">"संपर्क साझाकरण के लिए उपयोग करें"</string>
<string name="bluetooth_profile_pan_nap" msgid="8429049285027482959">"इंटरनेट कनेक्शन साझाकरण"</string>
<string name="bluetooth_profile_map" msgid="1019763341565580450">"लेख संदेश"</string>
- <string name="bluetooth_profile_sap" msgid="5764222021851283125">"सिम ऐक्सेस"</string>
+ <string name="bluetooth_profile_sap" msgid="5764222021851283125">"सिम एक्सेस"</string>
<string name="bluetooth_profile_a2dp_high_quality" msgid="5444517801472820055">"HD ऑडियो: <xliff:g id="CODEC_NAME">%1$s</xliff:g>"</string>
<string name="bluetooth_profile_a2dp_high_quality_unknown_codec" msgid="8510588052415438887">"HD ऑडियो"</string>
<string name="bluetooth_profile_hearing_aid" msgid="6680721080542444257">"सुनने में मदद करने वाले डिवाइस"</string>
diff --git a/packages/SettingsLib/res/values-vi/strings.xml b/packages/SettingsLib/res/values-vi/strings.xml
index 65e3c17..9240b45 100644
--- a/packages/SettingsLib/res/values-vi/strings.xml
+++ b/packages/SettingsLib/res/values-vi/strings.xml
@@ -204,7 +204,7 @@
<string name="tethering_settings_not_available" msgid="6765770438438291012">"Cài đặt chia sẻ kết nối không khả dụng cho người dùng này"</string>
<string name="apn_settings_not_available" msgid="7873729032165324000">"Cài đặt tên điểm truy cập không khả dụng cho người dùng này"</string>
<string name="enable_adb" msgid="7982306934419797485">"Gỡ lỗi USB"</string>
- <string name="enable_adb_summary" msgid="4881186971746056635">"Chế độ gỡ lỗi khi USB được kết nối"</string>
+ <string name="enable_adb_summary" msgid="4881186971746056635">"Bật chế độ gỡ lỗi khi kết nối USB"</string>
<string name="clear_adb_keys" msgid="4038889221503122743">"Thu hồi ủy quyền gỡ lỗi USB"</string>
<string name="bugreport_in_power" msgid="7923901846375587241">"Phím tắt báo cáo lỗi"</string>
<string name="bugreport_in_power_summary" msgid="1778455732762984579">"Hiển thị một nút trong menu nguồn để thêm báo cáo lỗi"</string>
@@ -261,8 +261,8 @@
<string name="allow_mock_location" msgid="2787962564578664888">"Cho phép vị trí mô phỏng"</string>
<string name="allow_mock_location_summary" msgid="317615105156345626">"Cho phép vị trí mô phỏng"</string>
<string name="debug_view_attributes" msgid="6485448367803310384">"Cho phép kiểm tra thuộc tính của chế độ xem"</string>
- <string name="mobile_data_always_on_summary" msgid="8149773901431697910">"Luôn giữ cho dữ liệu di động hoạt động, ngay cả khi Wi-Fi đang hoạt động (để chuyển đổi mạng nhanh)."</string>
- <string name="tethering_hardware_offload_summary" msgid="7726082075333346982">"Sử dụng tăng tốc phần cứng cho chia sẻ kết nối nếu được"</string>
+ <string name="mobile_data_always_on_summary" msgid="8149773901431697910">"Luôn bật dữ liệu di động ngay cả khi Wi-Fi đang hoạt động (để chuyển đổi mạng nhanh)."</string>
+ <string name="tethering_hardware_offload_summary" msgid="7726082075333346982">"Sử dụng tính năng tăng tốc phần cứng khi chia sẻ kết nối nếu có"</string>
<string name="adb_warning_title" msgid="6234463310896563253">"Cho phép gỡ lỗi USB?"</string>
<string name="adb_warning_message" msgid="7316799925425402244">"Gỡ lỗi USB chỉ dành cho mục đích phát triển. Hãy sử dụng tính năng này để sao chép dữ liệu giữa máy tính và thiết bị của bạn, cài đặt ứng dụng trên thiết bị của bạn mà không thông báo và đọc dữ liệu nhật ký."</string>
<string name="adb_keys_warning_message" msgid="5659849457135841625">"Thu hồi quyền truy cập gỡ lỗi USB từ tất cả máy tính mà bạn đã ủy quyền trước đó?"</string>
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java
index b2c10ec..f8c9bcc 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java
@@ -1057,6 +1057,9 @@
Settings.Global.NOTIFICATION_SNOOZE_OPTIONS,
GlobalSettingsProto.Notification.SNOOZE_OPTIONS);
dumpSetting(s, p,
+ Settings.Global.NOTIFICATION_BUBBLES,
+ GlobalSettingsProto.Notification.BUBBLES);
+ dumpSetting(s, p,
Settings.Global.SMART_REPLIES_IN_NOTIFICATIONS_FLAGS,
GlobalSettingsProto.Notification.SMART_REPLIES_IN_NOTIFICATIONS_FLAGS);
dumpSetting(s, p,
@@ -2150,7 +2153,7 @@
Settings.Secure.NOTIFICATION_BADGING,
SecureSettingsProto.Notification.BADGING);
dumpSetting(s, p,
- Settings.Secure.NOTIFICATION_BUBBLES,
+ Settings.Global.NOTIFICATION_BUBBLES,
SecureSettingsProto.Notification.BUBBLES);
dumpSetting(s, p,
Settings.Secure.SHOW_NOTE_ABOUT_NOTIFICATION_HIDING,
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
index 7016d30..e75ad13 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
@@ -3241,7 +3241,7 @@
}
private final class UpgradeController {
- private static final int SETTINGS_VERSION = 182;
+ private static final int SETTINGS_VERSION = 183;
private final int mUserId;
@@ -4258,19 +4258,7 @@
if (currentVersion == 173) {
// Version 173: Set the default value for Secure Settings: NOTIFICATION_BUBBLES
-
- final SettingsState secureSettings = getSecureSettingsLocked(userId);
-
- final Setting bubblesSetting = secureSettings.getSettingLocked(
- Secure.NOTIFICATION_BUBBLES);
-
- if (bubblesSetting.isNull()) {
- secureSettings.insertSettingLocked(Secure.NOTIFICATION_BUBBLES,
- getContext().getResources().getBoolean(
- R.bool.def_notification_bubbles) ? "1" : "0", null,
- true, SettingsState.SYSTEM_PACKAGE_NAME);
- }
-
+ // Removed. Moved NOTIFICATION_BUBBLES to Global Settings.
currentVersion = 174;
}
@@ -4394,14 +4382,9 @@
if (currentVersion == 179) {
// Version 178: Reset the default for Secure Settings: NOTIFICATION_BUBBLES
// This is originally set in version 173, however, the default value changed
- // so this step is to ensure the value is updated to the correct defaulte
- final SettingsState secureSettings = getSecureSettingsLocked(userId);
+ // so this step is to ensure the value is updated to the correct default.
- secureSettings.insertSettingLocked(Secure.NOTIFICATION_BUBBLES,
- getContext().getResources().getBoolean(
- R.bool.def_notification_bubbles) ? "1" : "0", null,
- true, SettingsState.SYSTEM_PACKAGE_NAME);
-
+ // Removed. Moved NOTIFICATION_BUBBLES to Global Settings.
currentVersion = 180;
}
@@ -4455,6 +4438,20 @@
currentVersion = 182;
}
+ if (currentVersion == 182) {
+ // Remove secure bubble settings.
+ getSecureSettingsLocked(userId).deleteSettingLocked(
+ Secure.NOTIFICATION_BUBBLES);
+
+ // Add global bubble settings.
+ getGlobalSettingsLocked().insertSettingLocked(Global.NOTIFICATION_BUBBLES,
+ getContext().getResources().getBoolean(
+ R.bool.def_notification_bubbles) ? "1" : "0", null /* tag */,
+ true /* makeDefault */, SettingsState.SYSTEM_PACKAGE_NAME);
+
+ currentVersion = 183;
+ }
+
// vXXX: Add new settings above this point.
if (currentVersion != newVersion) {
diff --git a/packages/SystemUI/Android.bp b/packages/SystemUI/Android.bp
index 4c52b132..d674be4 100644
--- a/packages/SystemUI/Android.bp
+++ b/packages/SystemUI/Android.bp
@@ -71,10 +71,6 @@
"telephony-common",
],
- aaptflags: [
- "--extra-packages",
- "com.android.keyguard",
- ],
kotlincflags: ["-Xjvm-default=enable"],
plugins: ["dagger2-compiler-2.19"],
@@ -114,6 +110,7 @@
"androidx.lifecycle_lifecycle-extensions",
"androidx.dynamicanimation_dynamicanimation",
"androidx-constraintlayout_constraintlayout",
+ "iconloader_base",
"SystemUI-tags",
"SystemUI-proto",
"metrics-helper-lib",
@@ -132,7 +129,7 @@
kotlincflags: ["-Xjvm-default=enable"],
aaptflags: [
"--extra-packages",
- "com.android.keyguard:com.android.systemui",
+ "com.android.systemui",
],
plugins: ["dagger2-compiler-2.19"],
}
@@ -160,10 +157,6 @@
kotlincflags: ["-Xjvm-default=enable"],
dxflags: ["--multi-dex"],
- aaptflags: [
- "--extra-packages",
- "com.android.keyguard",
- ],
required: ["privapp_whitelist_com.android.systemui"],
}
@@ -180,10 +173,6 @@
privileged: true,
dxflags: ["--multi-dex"],
- aaptflags: [
- "--extra-packages",
- "com.android.keyguard",
- ],
optimize: {
proguard_flags_files: ["proguard.flags", "legacy/recents/proguard.flags"],
},
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index 17274f4..403e894 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -20,6 +20,7 @@
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
package="com.android.systemui"
android:sharedUserId="android.uid.systemui"
+ xmlns:tools="http://schemas.android.com/tools"
coreApp="true">
<!-- Using OpenGL ES 2.0 -->
@@ -259,7 +260,8 @@
android:theme="@style/Theme.SystemUI"
android:defaultToDeviceProtectedStorage="true"
android:directBootAware="true"
- android:appComponentFactory="androidx.core.app.CoreComponentFactory">
+ tools:replace="android:appComponentFactory"
+ android:appComponentFactory=".SystemUIAppComponentFactory">
<!-- Keep theme in sync with SystemUIApplication.onCreate().
Setting the theme on the application does not affect views inflated by services.
The application theme is set again from onCreate to take effect for those views. -->
@@ -607,6 +609,10 @@
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation|keyboard|keyboardHidden"
android:process=":ui"
android:visibleToInstantApps="true">
+ <intent-filter>
+ <action android:name="android.intent.action.CHOOSER" />
+ <category android:name="android.intent.category.VOICE" />
+ </intent-filter>
</activity>
<!-- Doze with notifications, run in main sysui process for every user -->
diff --git a/packages/SystemUI/docs/dagger.md b/packages/SystemUI/docs/dagger.md
index c2159df..c440fba 100644
--- a/packages/SystemUI/docs/dagger.md
+++ b/packages/SystemUI/docs/dagger.md
@@ -53,7 +53,7 @@
### Adding injection to a new SystemUI object
Anything that depends on any `@Singleton` provider from SystemUIRootComponent
-should be declared as an `@Subcomponent` of the root component, this requires
+should be declared as a `@Subcomponent` of the root component. This requires
declaring your own interface for generating your own modules or just the
object you need injected. The subcomponent also needs to be added to
SystemUIRootComponent in SystemUIFactory so it can be acquired.
@@ -204,6 +204,13 @@
}
```
+## Updating Dagger2
+
+Binaries can be downloaded from https://repo1.maven.org/maven2/com/google/dagger/ and then loaded
+into
+[/prebuilts/tools/common/m2/repository/com/google/dagger/](http://cs/android/prebuilts/tools/common/m2/repository/com/google/dagger/)
+
+
## TODO List
- Eliminate usages of Dependency#get
diff --git a/packages/SystemUI/docs/physics-animation-layout.md b/packages/SystemUI/docs/physics-animation-layout.md
index 488c465..de2ee9e 100644
--- a/packages/SystemUI/docs/physics-animation-layout.md
+++ b/packages/SystemUI/docs/physics-animation-layout.md
@@ -1,7 +1,11 @@
# Physics Animation Layout
## Overview
-**PhysicsAnimationLayout** works with an implementation of **PhysicsAnimationController** to construct and maintain physics animations for each of its child views. During the initial construction of the animations, the layout queries the controller for configuration settings such as which properties to animate, which animations to chain together, and what stiffness or bounciness to use. Once the animations are built to the controller’s specifications, the controller can then ask the layout to start, stop and manipulate them arbitrarily to achieve any desired animation effect. The controller is notified whenever children are added or removed from the layout, so that it can animate their entrance or exit, respectively.
+**PhysicsAnimationLayout** works with implementations of **PhysicsAnimationController** to configure and run physics-based animations for each of its child views. During the initial construction of the animations, the layout queries the controller for basic configuration settings such as which properties to animate, which animations to chain together, and the default physics parameters to use.
+
+Once the animations are built, the controller can access **PhysicsPropertyAnimator** instances to run them. The animator behaves similarly to the familiar `ViewPropertyAnimator`, with the ability to animate `alpha`, `translation`, and `scale` values. It also supports additional functionality such as `followAnimatedTargetAlongPath` for more advanced motion.
+
+The controller is notified whenever children are added or removed from the layout, so that it can animate their entrance or exit, respectively.
An example usage is Bubbles, which uses a PhysicsAnimationLayout for its stack of bubbles. Bubbles has controller subclasses including StackAnimationController and ExpansionAnimationController. StackAnimationController tells the layout to configure the translation animations to be chained (for the ‘following’ drag effect), and has methods such as ```moveStack(x, y)``` to animate the stack to a given point. ExpansionAnimationController asks for no animations to be chained, and exposes methods like ```expandStack()``` and ```collapseStack()```, which animate the bubbles to positions along the bottom of the screen.
@@ -27,7 +31,7 @@
### Animation Control Methods
Once the layout has used the controller’s configuration properties to build the animations, the controller can use them to actually run animations. This is done for two reasons - reacting to a view being added or removed, or responding to another class (such as a touch handler or broadcast receiver) requesting an animation. ```onChildAdded```, ```onChildRemoved```, and ```setChildVisibility``` are called automatically by the layout, giving the controller the opportunity to animate the child in/out/visible/gone. Custom methods are called by anyone with access to the controller instance to do things like expand, collapse, or move the child views.
-In either case, the controller can use `super.animationForChild` to retrieve a `PhysicsPropertyAnimator` instance. This object behaves similarly to the `ViewPropertyAnimator` object you would receive from `View.animate()`.
+In either case, the controller can use `super.animationForChild` to retrieve a `PhysicsPropertyAnimator` instance. This object behaves similarly to the `ViewPropertyAnimator` object you would receive from `View.animate()`.
#### PhysicsPropertyAnimator
@@ -36,9 +40,14 @@
- `translationX/Y/Z(float)`
- `scaleX/Y(float)`
+...as well as shortcut methods to reduce the amount of boilerplate code needed for common use cases:
+- `position(float, float, Runnable…)`, which starts translationX and translationY animations, and calls the provided callbacks only when both animations have completed.
+- `followAnimatedTargetAlongPath(Path, int, TimeInterpolator)`, which animates a ‘target’ point along the given path using a traditional Animator. As the target moves, the translationX/Y physics animations are updated to follow the target, similarly to how they might follow a touch event location. This results in the view roughly following the path, but with natural motion that takes momentum into account. For example, if a path makes a 90 degree turn to the right, the physics animations will cause the view to curve naturally towards the new trajectory.
+
It also provides the following configuration methods:
- `withStartDelay(int)`, for starting the animation after a given delay.
- `withStartVelocity(float)`, for starting the animation with the given start velocity.
+- `withStiffness(float)` and `withDampingRatio(float)`, for overriding the default physics param values returned by the controller’s getSpringForce method.
- `withPositionStartVelocities(float, float)`, for setting specific start velocities for TRANSLATION_X and TRANSLATION_Y, since these typically differ.
- `start(Runnable)`, to start the animation, with an optional end action to call when the animations for every property (including chained animations) have completed.
@@ -61,8 +70,7 @@
- Often, animations will set starting values for properties before the animation begins. Property methods like `translationX` have an overloaded variant: `translationX(from, to)`. When `start()` is called, the animation will set the view's translationX property to `from` before beginning the animation to `to`.
- We may want to use different end actions for each property. For example, if we're animating a view to the bottom of the screen, and also fading it out, we might want to perform an action as soon as the fade out is complete. We can use `alpha(to, endAction)`, which will call endAction as soon as the alpha animation is finished. A special case is `position(x, y, endAction)`, where the endAction is called when both translationX and translationY animations have completed.
-
-`PhysicsAnimationController` also provides `animationsForChildrenFromIndex(int, ChildAnimationConfigurator)`. This is a convenience method for starting animations on multiple child views, starting at the given index. The `ChildAnimationConfigurator` is called with a `PhysicsPropertyAnimator` for each child, where calls to methods like `translationX` and `withStartVelocity` can be made. `animationsForChildrenFromIndex` returns a `MultiAnimationStarter` with a single method, `startAll(endAction)`, which starts all of the animations and calls the end action when they have all completed.
+- `PhysicsAnimationController` also provides `animationsForChildrenFromIndex(int, ChildAnimationConfigurator)`. This is a convenience method for starting animations on multiple child views, starting at the given index. The `ChildAnimationConfigurator` is called with a `PhysicsPropertyAnimator` for each child, where calls to methods like `translationX` and `withStartVelocity` can be made. `animationsForChildrenFromIndex` returns a `MultiAnimationStarter` with a single method, `startAll(endAction)`, which starts all of the animations and calls the end action when they have all completed.
##### Examples
Spring the stack of bubbles (whose animations are chained) to the bottom of the screen, shrinking them to 50% size. Once the first bubble is done shrinking, begin fading them out, and then remove them all from the parent once all bubbles have faded out:
@@ -93,16 +101,22 @@
.startAll(removeFirstView);
```
+Move a view up along the left side of the screen, and then to the top right of the screen (assume a view that is currently halfway down the left side of the screen). When the translation animations have finished following the target, call a callback:
+
+```
+Path path = new Path();
+path.moveTo(view.getTranslationX(), view.getTranslationY());
+path.lineTo(view.getTranslationX(), 0);
+path.lineTo(mScreenWidth, 0);
+animationForChild(view)
+ .followAnimatedTargetAlongPath(path, 100, new LinearInterpolator())
+ .start(callbackAfterFollowingFinished);
+```
+
## PhysicsAnimationLayout
The layout itself is a FrameLayout descendant with a few extra methods:
-```setController(PhysicsAnimationController controller)```
-Attaches the layout to the controller, so that the controller can access the layout’s protected methods. It also constructs or reconfigures the physics animations according to the new controller’s configuration methods.
+```setActiveController(PhysicsAnimationController controller)```
+Sets the given controller as the active controller for the layout. This causes the layout to construct or reconfigure the physics animations according to the new controller’s configuration methods, and halt any in-progress animations.
-```setEndListenerForProperty(ViewProperty property, AnimationEndListener endListener)```
-Sets an end listener that is called when all animations on the given property have ended.
-
-```setMaxRenderedChildren(int max)```
-Child views beyond this limit will be set to GONE, and won't be animated, for performance reasons. Defaults to **5**.
-
-It has one protected method, ```animateValueForChildAtIndex(ViewProperty property, int index, float value)```, which is visible to PhysicsAnimationController descendants. This method dispatches the given value to the appropriate animation.
\ No newline at end of file
+Only the currently active controller is allowed to start animations. If a different controller is set as the active controller, the previous controller will no longer be able to start animations. Attempts to do so will have no effect. This is to ensure that multiple controllers aren’t updating animations at the same time, which can cause undefined behavior.
\ No newline at end of file
diff --git a/packages/SystemUI/legacy/recents/src/com/android/systemui/recents/views/TaskStackView.java b/packages/SystemUI/legacy/recents/src/com/android/systemui/recents/views/TaskStackView.java
index 14fd149..b89218c 100644
--- a/packages/SystemUI/legacy/recents/src/com/android/systemui/recents/views/TaskStackView.java
+++ b/packages/SystemUI/legacy/recents/src/com/android/systemui/recents/views/TaskStackView.java
@@ -41,8 +41,10 @@
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.systemui.Dependency;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
+import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.recents.LegacyRecentsImpl;
import com.android.systemui.recents.RecentsActivity;
import com.android.systemui.recents.RecentsActivityLaunchState;
@@ -86,15 +88,15 @@
import com.android.systemui.recents.misc.DozeTrigger;
import com.android.systemui.recents.misc.ReferenceCountedTrigger;
import com.android.systemui.recents.misc.SystemServicesProxy;
+import com.android.systemui.recents.model.TaskStack;
import com.android.systemui.recents.utilities.AnimationProps;
import com.android.systemui.recents.utilities.Utilities;
-import com.android.systemui.shared.recents.model.Task;
-import com.android.systemui.recents.model.TaskStack;
import com.android.systemui.recents.views.grid.GridTaskView;
import com.android.systemui.recents.views.grid.TaskGridLayoutAlgorithm;
import com.android.systemui.recents.views.grid.TaskViewFocusFrame;
-
+import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.system.ActivityManagerWrapper;
+
import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -256,7 +258,8 @@
mLayoutAlgorithm = new TaskStackLayoutAlgorithm(context, this);
mStableLayoutAlgorithm = new TaskStackLayoutAlgorithm(context, null);
mStackScroller = new TaskStackViewScroller(context, this, mLayoutAlgorithm);
- mTouchHandler = new TaskStackViewTouchHandler(context, this, mStackScroller);
+ mTouchHandler = new TaskStackViewTouchHandler(
+ context, this, mStackScroller, Dependency.get(FalsingManager.class));
mAnimationHelper = new TaskStackAnimationHelper(context, this);
mTaskCornerRadiusPx = LegacyRecentsImpl.getConfiguration().isGridEnabled ?
res.getDimensionPixelSize(R.dimen.recents_grid_task_view_rounded_corners_radius) :
diff --git a/packages/SystemUI/legacy/recents/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java b/packages/SystemUI/legacy/recents/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
index dd6926c..a7fb4fa 100644
--- a/packages/SystemUI/legacy/recents/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
+++ b/packages/SystemUI/legacy/recents/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
@@ -37,6 +37,7 @@
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.SwipeHelper;
+import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.recents.Constants;
import com.android.systemui.recents.LegacyRecentsImpl;
import com.android.systemui.recents.events.EventBus;
@@ -107,7 +108,7 @@
boolean mInterceptedBySwipeHelper;
public TaskStackViewTouchHandler(Context context, TaskStackView sv,
- TaskStackViewScroller scroller) {
+ TaskStackViewScroller scroller, FalsingManager falsingManager) {
Resources res = context.getResources();
ViewConfiguration configuration = ViewConfiguration.get(context);
mContext = context;
@@ -119,7 +120,7 @@
mWindowTouchSlop = configuration.getScaledWindowTouchSlop();
mFlingAnimUtils = new FlingAnimationUtils(context, 0.2f);
mOverscrollSize = res.getDimensionPixelSize(R.dimen.recents_fling_overscroll_distance);
- mSwipeHelper = new SwipeHelper(SwipeHelper.X, this, context) {
+ mSwipeHelper = new SwipeHelper(SwipeHelper.X, this, context, falsingManager) {
@Override
protected float getSize(View v) {
return getScaledDismissSize();
diff --git a/packages/SystemUI/res/drawable/bubble_dismiss_circle.xml b/packages/SystemUI/res/drawable/bubble_dismiss_circle.xml
index 1661bb2..8c7e82f 100644
--- a/packages/SystemUI/res/drawable/bubble_dismiss_circle.xml
+++ b/packages/SystemUI/res/drawable/bubble_dismiss_circle.xml
@@ -24,4 +24,5 @@
android:width="1dp"
android:color="#66FFFFFF" />
+ <solid android:color="#B3000000" />
</shape>
\ No newline at end of file
diff --git a/packages/SystemUI/res/layout/bubble_dismiss_target.xml b/packages/SystemUI/res/layout/bubble_dismiss_target.xml
index 245177c..ca085b6 100644
--- a/packages/SystemUI/res/layout/bubble_dismiss_target.xml
+++ b/packages/SystemUI/res/layout/bubble_dismiss_target.xml
@@ -20,6 +20,13 @@
android:layout_height="@dimen/pip_dismiss_gradient_height"
android:layout_gravity="bottom|center_horizontal">
+ <FrameLayout
+ android:id="@+id/bubble_dismiss_circle"
+ android:layout_width="@dimen/bubble_dismiss_encircle_size"
+ android:layout_height="@dimen/bubble_dismiss_encircle_size"
+ android:layout_gravity="center"
+ android:background="@drawable/bubble_dismiss_circle" />
+
<LinearLayout
android:id="@+id/bubble_dismiss_icon_container"
android:layout_width="wrap_content"
@@ -38,29 +45,5 @@
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/bubble_dismiss_icon" />
-
- <TextView
- android:id="@+id/bubble_dismiss_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="9dp"
- android:layout_marginBottom="9dp"
- android:layout_marginLeft="8dp"
- android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
- android:textColor="@android:color/white"
- android:shadowColor="@android:color/black"
- android:shadowDx="-1"
- android:shadowDy="1"
- android:shadowRadius="0.01"
- android:text="@string/bubble_dismiss_text" />
-
</LinearLayout>
-
- <FrameLayout
- android:id="@+id/bubble_dismiss_circle"
- android:layout_width="@dimen/bubble_dismiss_encircle_size"
- android:layout_height="@dimen/bubble_dismiss_encircle_size"
- android:layout_gravity="center"
- android:alpha="0"
- android:background="@drawable/bubble_dismiss_circle" />
</FrameLayout>
\ No newline at end of file
diff --git a/packages/SystemUI/res/layout/bubble_view.xml b/packages/SystemUI/res/layout/bubble_view.xml
index a8eb2914..e2dea45 100644
--- a/packages/SystemUI/res/layout/bubble_view.xml
+++ b/packages/SystemUI/res/layout/bubble_view.xml
@@ -24,7 +24,6 @@
android:id="@+id/bubble_image"
android:layout_width="@dimen/individual_bubble_size"
android:layout_height="@dimen/individual_bubble_size"
- android:padding="@dimen/bubble_view_padding"
android:clipToPadding="false"/>
</com.android.systemui.bubbles.BubbleView>
diff --git a/packages/SystemUI/res/layout/keyguard_bottom_area.xml b/packages/SystemUI/res/layout/keyguard_bottom_area.xml
index 21c2c6b..1bfc4c0 100644
--- a/packages/SystemUI/res/layout/keyguard_bottom_area.xml
+++ b/packages/SystemUI/res/layout/keyguard_bottom_area.xml
@@ -24,48 +24,7 @@
android:outlineProvider="none"
android:elevation="5dp" > <!-- Put it above the status bar header -->
- <LinearLayout
- android:id="@+id/keyguard_indication_area"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/keyguard_indication_margin_bottom"
- android:layout_gravity="bottom|center_horizontal"
- android:orientation="horizontal">
-
- <include layout="@layout/left_docked_overlay" />
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:layout_gravity="center_vertical|center_horizontal"
- android:orientation="vertical">
-
- <com.android.systemui.statusbar.phone.KeyguardIndicationTextView
- android:id="@+id/keyguard_indication_enterprise_disclosure"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:paddingStart="@dimen/keyguard_indication_text_padding"
- android:paddingEnd="@dimen/keyguard_indication_text_padding"
- android:textAppearance="@style/TextAppearance.Keyguard.BottomArea"
- android:visibility="gone" />
-
- <com.android.systemui.statusbar.phone.KeyguardIndicationTextView
- android:id="@+id/keyguard_indication_text"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:paddingStart="@dimen/keyguard_indication_text_padding"
- android:paddingEnd="@dimen/keyguard_indication_text_padding"
- android:textAppearance="@style/TextAppearance.Keyguard.BottomArea"
- android:accessibilityLiveRegion="polite" />
-
- </LinearLayout>
-
- <include layout="@layout/right_docked_overlay" />
-
- </LinearLayout>
+ <include layout="@layout/keyguard_indication_area_overlay" />
<FrameLayout
android:id="@+id/preview_container"
diff --git a/packages/SystemUI/res/layout/keyguard_indication_area_overlay.xml b/packages/SystemUI/res/layout/keyguard_indication_area_overlay.xml
new file mode 100644
index 0000000..cc30a68
--- /dev/null
+++ b/packages/SystemUI/res/layout/keyguard_indication_area_overlay.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/keyguard_indication_area"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/keyguard_indication_margin_bottom"
+ android:layout_gravity="bottom|center_horizontal"
+ android:orientation="vertical">
+
+ <include layout="@layout/keyguard_indication_text_view" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/packages/SystemUI/res/layout/keyguard_indication_text_view.xml b/packages/SystemUI/res/layout/keyguard_indication_text_view.xml
new file mode 100644
index 0000000..2b2100c
--- /dev/null
+++ b/packages/SystemUI/res/layout/keyguard_indication_text_view.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<merge xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <com.android.systemui.statusbar.phone.KeyguardIndicationTextView
+ android:id="@+id/keyguard_indication_enterprise_disclosure"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:paddingStart="@dimen/keyguard_indication_text_padding"
+ android:paddingEnd="@dimen/keyguard_indication_text_padding"
+ android:textAppearance="@style/TextAppearance.Keyguard.BottomArea"
+ android:visibility="gone"/>
+
+ <com.android.systemui.statusbar.phone.KeyguardIndicationTextView
+ android:id="@+id/keyguard_indication_text"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:paddingStart="@dimen/keyguard_indication_text_padding"
+ android:paddingEnd="@dimen/keyguard_indication_text_padding"
+ android:textAppearance="@style/TextAppearance.Keyguard.BottomArea"
+ android:accessibilityLiveRegion="polite"/>
+</merge>
\ No newline at end of file
diff --git a/packages/SystemUI/res/layout/left_docked_overlay.xml b/packages/SystemUI/res/layout/left_docked_overlay.xml
deleted file mode 100644
index 430143c..0000000
--- a/packages/SystemUI/res/layout/left_docked_overlay.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ 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.
- -->
-
-<!-- empty stub -->
-<merge />
diff --git a/packages/SystemUI/res/layout/qs_carrier_group.xml b/packages/SystemUI/res/layout/qs_carrier_group.xml
index 36f382b..56efb49 100644
--- a/packages/SystemUI/res/layout/qs_carrier_group.xml
+++ b/packages/SystemUI/res/layout/qs_carrier_group.xml
@@ -25,6 +25,17 @@
android:orientation="horizontal">
+ <com.android.systemui.util.AutoMarqueeTextView
+ android:id="@+id/no_carrier_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="@style/TextAppearance.QS.Status"
+ android:textDirection="locale"
+ android:marqueeRepeatLimit="marquee_forever"
+ android:singleLine="true"
+ android:maxEms="7"
+ android:visibility="gone"/>
+
<include
layout="@layout/qs_carrier"
android:id="@+id/carrier1"
diff --git a/packages/SystemUI/res/layout/right_docked_overlay.xml b/packages/SystemUI/res/layout/right_docked_overlay.xml
deleted file mode 100644
index 430143c..0000000
--- a/packages/SystemUI/res/layout/right_docked_overlay.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ 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.
- -->
-
-<!-- empty stub -->
-<merge />
diff --git a/packages/SystemUI/res/layout/super_status_bar.xml b/packages/SystemUI/res/layout/super_status_bar.xml
index a914930..9716a00 100644
--- a/packages/SystemUI/res/layout/super_status_bar.xml
+++ b/packages/SystemUI/res/layout/super_status_bar.xml
@@ -44,7 +44,7 @@
</com.android.systemui.statusbar.BackDropView>
<com.android.systemui.statusbar.ScrimView
- android:id="@+id/scrim_behind"
+ android:id="@+id/scrim_for_bubble"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:importantForAccessibility="no"
@@ -56,6 +56,14 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />
+ <com.android.systemui.statusbar.ScrimView
+ android:id="@+id/scrim_behind"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:importantForAccessibility="no"
+ sysui:ignoreRightInset="true"
+ />
+
<include layout="@layout/status_bar_expanded"
android:layout_width="match_parent"
android:layout_height="match_parent"
diff --git a/packages/SystemUI/res/values-bn/strings.xml b/packages/SystemUI/res/values-bn/strings.xml
index 2628a24..1ca6f63 100644
--- a/packages/SystemUI/res/values-bn/strings.xml
+++ b/packages/SystemUI/res/values-bn/strings.xml
@@ -442,6 +442,8 @@
<string name="media_projection_remember_text" msgid="3103510882172746752">"আর দেখাবেন না"</string>
<string name="clear_all_notifications_text" msgid="814192889771462828">"সবকিছু সাফ করুন"</string>
<string name="manage_notifications_text" msgid="2386728145475108753">"পরিচালনা করুন"</string>
+ <string name="notification_section_header_gentle" msgid="4372438504154095677">"নীরব বিজ্ঞপ্তি"</string>
+ <string name="accessibility_notification_section_header_gentle_clear_all" msgid="4286716295850400959">"সব নীরব বিজ্ঞপ্তি মুছুন"</string>
<string name="dnd_suppressing_shade_text" msgid="1904574852846769301">"\'বিরক্ত করবেন না\' দিয়ে বিজ্ঞপ্তি পজ করা হয়েছে"</string>
<string name="media_projection_action_text" msgid="8470872969457985954">"এখন শুরু করুন"</string>
<string name="empty_shade_text" msgid="708135716272867002">"কোনো বিজ্ঞপ্তি নেই"</string>
@@ -703,9 +705,9 @@
<string name="keyboard_shortcut_group_applications_youtube" msgid="6555453761294723317">"YouTube"</string>
<string name="keyboard_shortcut_group_applications_calendar" msgid="9043614299194991263">"ক্যালেন্ডার"</string>
<string name="tuner_full_zen_title" msgid="4540823317772234308">"ভলিউম নিয়ন্ত্রণ সহ দেখান"</string>
- <string name="volume_and_do_not_disturb" msgid="3373784330208603030">"বিরক্ত করবেন না"</string>
+ <string name="volume_and_do_not_disturb" msgid="1750270820297253561">"বিরক্ত করবেন না"</string>
<string name="volume_dnd_silent" msgid="4363882330723050727">"ভলিউম বোতামের শর্টকাট"</string>
- <string name="volume_up_silent" msgid="7141255269783588286">"ভলিউম বাড়ানোর মাধ্যেমে \'বিরক্ত করবেন না\' থেকে বেরিয়ে আসুন"</string>
+ <string name="volume_up_silent" msgid="7545869833038212815">"ভলিউম বাড়িয়ে \'বিরক্ত করবেন না\' মোড থেকে বেরিয়ে আসুন"</string>
<string name="battery" msgid="7498329822413202973">"ব্যাটারি"</string>
<string name="clock" msgid="7416090374234785905">"ঘড়ি"</string>
<string name="headset" msgid="4534219457597457353">"হেডসেট"</string>
diff --git a/packages/SystemUI/res/values-en-rCA/strings.xml b/packages/SystemUI/res/values-en-rCA/strings.xml
index 926b077..10f6317 100644
--- a/packages/SystemUI/res/values-en-rCA/strings.xml
+++ b/packages/SystemUI/res/values-en-rCA/strings.xml
@@ -385,8 +385,8 @@
<string name="keyguard_more_overflow_text" msgid="9195222469041601365">"+<xliff:g id="NUMBER_OF_NOTIFICATIONS">%d</xliff:g>"</string>
<string name="speed_bump_explanation" msgid="1288875699658819755">"Less urgent notifications below"</string>
<string name="notification_tap_again" msgid="7590196980943943842">"Tap again to open"</string>
- <string name="keyguard_unlock" msgid="8043466894212841998">"Swipe up to unlock"</string>
- <string name="do_disclosure_generic" msgid="5615898451805157556">"This device is managed by your organization"</string>
+ <string name="keyguard_unlock" msgid="6035822649218712063">"Swipe up to open"</string>
+ <string name="do_disclosure_generic" msgid="5615898451805157556">"This device is managed by your organisation"</string>
<string name="do_disclosure_with_name" msgid="5640615509915445501">"This device is managed by <xliff:g id="ORGANIZATION_NAME">%s</xliff:g>"</string>
<string name="phone_hint" msgid="4872890986869209950">"Swipe from icon for phone"</string>
<string name="voice_hint" msgid="8939888732119726665">"Swipe from icon for voice assist"</string>
diff --git a/packages/SystemUI/res/values-en-rXC/strings.xml b/packages/SystemUI/res/values-en-rXC/strings.xml
index e23236a..2383c79 100644
--- a/packages/SystemUI/res/values-en-rXC/strings.xml
+++ b/packages/SystemUI/res/values-en-rXC/strings.xml
@@ -385,7 +385,7 @@
<string name="keyguard_more_overflow_text" msgid="9195222469041601365">"+<xliff:g id="NUMBER_OF_NOTIFICATIONS">%d</xliff:g>"</string>
<string name="speed_bump_explanation" msgid="1288875699658819755">"Less urgent notifications below"</string>
<string name="notification_tap_again" msgid="7590196980943943842">"Tap again to open"</string>
- <string name="keyguard_unlock" msgid="8043466894212841998">"Swipe up to unlock"</string>
+ <string name="keyguard_unlock" msgid="6035822649218712063">"Swipe up to open"</string>
<string name="do_disclosure_generic" msgid="5615898451805157556">"This device is managed by your organization"</string>
<string name="do_disclosure_with_name" msgid="5640615509915445501">"This device is managed by <xliff:g id="ORGANIZATION_NAME">%s</xliff:g>"</string>
<string name="phone_hint" msgid="4872890986869209950">"Swipe from icon for phone"</string>
diff --git a/packages/SystemUI/res/values-land/dimens.xml b/packages/SystemUI/res/values-land/dimens.xml
index 90e78e8..5a8c5dc 100644
--- a/packages/SystemUI/res/values-land/dimens.xml
+++ b/packages/SystemUI/res/values-land/dimens.xml
@@ -36,4 +36,8 @@
<dimen name="volume_tool_tip_right_margin">136dp</dimen>
<dimen name="volume_tool_tip_top_margin">12dp</dimen>
+
+ <!-- Padding between status bar and bubbles when displayed in expanded state, smaller
+ value in landscape since we have limited vertical space-->
+ <dimen name="bubble_padding_top">4dp</dimen>
</resources>
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index 6e8e823..78318cb 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -273,7 +273,6 @@
<!-- SystemUI Services: The classes of the stuff to start. -->
<string-array name="config_systemUIServiceComponents" translatable="false">
- <item>com.android.systemui.Dependency$DependencyCreator</item>
<item>com.android.systemui.util.NotificationChannels</item>
<item>com.android.systemui.statusbar.CommandQueue$CommandQueueStart</item>
<item>com.android.systemui.keyguard.KeyguardViewMediator</item>
@@ -304,7 +303,6 @@
<!-- SystemUI Services (per user): The classes of the stuff to start for each user. This is a subset of the config_systemUIServiceComponents -->
<string-array name="config_systemUIServiceComponentsPerUser" translatable="false">
- <item>com.android.systemui.Dependency$DependencyCreator</item>
<item>com.android.systemui.util.NotificationChannels</item>
</string-array>
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index bef1fc2..2e17991 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -385,22 +385,16 @@
<!-- The width of the panel that holds the quick settings. -->
<dimen name="qs_panel_width">@dimen/notification_panel_width</dimen>
- <dimen name="volume_dialog_panel_transparent_padding_right">8dp</dimen>
+ <dimen name="volume_dialog_panel_transparent_padding_right">4dp</dimen>
<dimen name="volume_dialog_panel_transparent_padding">20dp</dimen>
<dimen name="volume_dialog_stream_padding">8dp</dimen>
- <!-- the amount the volume panel should be offset at the end from the view next to it (or
- the screen edge, in portrait-->
- <dimen name="volume_dialog_base_margin">8dp</dimen>
-
<dimen name="volume_dialog_panel_width">64dp</dimen>
<dimen name="volume_dialog_slider_height">116dp</dimen>
- <dimen name="volume_dialog_row_height">252dp</dimen>
-
<dimen name="volume_dialog_ringer_size">64dp</dimen>
<dimen name="volume_dialog_ringer_icon_padding">20dp</dimen>
@@ -417,8 +411,6 @@
<dimen name="volume_dialog_row_margin_bottom">8dp</dimen>
- <dimen name="volume_dialog_settings_icon_size">16dp</dimen>
-
<dimen name="volume_dialog_elevation">9dp</dimen>
<dimen name="volume_tool_tip_right_margin">76dp</dimen>
@@ -1110,18 +1102,23 @@
<dimen name="bubble_flyout_pointer_size">6dp</dimen>
<!-- How much space to leave between the flyout (tip of the arrow) and the bubble stack. -->
<dimen name="bubble_flyout_space_from_bubble">8dp</dimen>
- <!-- Padding around a collapsed bubble -->
- <dimen name="bubble_view_padding">0dp</dimen>
- <!-- Padding between bubbles when displayed in expanded state -->
- <dimen name="bubble_padding">8dp</dimen>
+ <!-- Padding between status bar and bubbles when displayed in expanded state -->
+ <dimen name="bubble_padding_top">16dp</dimen>
<!-- Size of individual bubbles. -->
- <dimen name="individual_bubble_size">52dp</dimen>
+ <dimen name="individual_bubble_size">60dp</dimen>
+ <!-- Size of bubble icon bitmap. -->
+ <dimen name="bubble_icon_bitmap_size">52dp</dimen>
+ <!-- Extra padding added to the touchable rect for bubbles so they are easier to grab. -->
+ <dimen name="bubble_touch_padding">12dp</dimen>
<!-- Size of the circle around the bubbles when they're in the dismiss target. -->
- <dimen name="bubble_dismiss_encircle_size">56dp</dimen>
+ <dimen name="bubble_dismiss_encircle_size">52dp</dimen>
<!-- How much to inset the icon in the circle -->
<dimen name="bubble_icon_inset">16dp</dimen>
<!-- Padding around the view displayed when the bubble is expanded -->
<dimen name="bubble_expanded_view_padding">4dp</dimen>
+ <!-- This should be at least the size of bubble_expanded_view_padding; it is used to include
+ a slight touch slop around the expanded view. -->
+ <dimen name="bubble_expanded_view_slop">8dp</dimen>
<!-- Default (and minimum) height of the expanded view shown when the bubble is expanded -->
<dimen name="bubble_expanded_default_height">180dp</dimen>
<!-- Height of the triangle that points to the expanded bubble -->
@@ -1130,10 +1127,8 @@
<dimen name="bubble_pointer_width">6dp</dimen>
<!-- Extra padding around the dismiss target for bubbles -->
<dimen name="bubble_dismiss_slop">16dp</dimen>
- <!-- Height of the header within the expanded view. -->
- <dimen name="bubble_expanded_header_height">48dp</dimen>
- <!-- Left and right padding applied to the header. -->
- <dimen name="bubble_expanded_header_horizontal_padding">24dp</dimen>
+ <!-- Height of button allowing users to adjust settings for bubbles. -->
+ <dimen name="bubble_settings_size">48dp</dimen>
<!-- How far, horizontally, to animate the expanded view over when animating in/out. -->
<dimen name="bubble_expanded_animate_x_distance">100dp</dimen>
<!-- How far, vertically, to animate the expanded view over when animating in/out. -->
@@ -1146,12 +1141,10 @@
<dimen name="bubble_message_padding">4dp</dimen>
<!-- Offset between bubbles in their stacked position. -->
<dimen name="bubble_stack_offset">5dp</dimen>
- <!-- How far offscreen the bubble stack rests. -->
- <dimen name="bubble_stack_offscreen">5dp</dimen>
+ <!-- How far offscreen the bubble stack rests. Cuts off padding and part of icon bitmap. -->
+ <dimen name="bubble_stack_offscreen">9dp</dimen>
<!-- How far down the screen the stack starts. -->
- <dimen name="bubble_stack_starting_offset_y">100dp</dimen>
- <!-- Size of image buttons in the bubble header -->
- <dimen name="bubble_header_icon_size">48dp</dimen>
+ <dimen name="bubble_stack_starting_offset_y">96dp</dimen>
<!-- Space between the pointer triangle and the bubble expanded view -->
<dimen name="bubble_pointer_margin">8dp</dimen>
<!-- Height of the permission prompt shown with bubbles -->
@@ -1160,6 +1153,7 @@
snap to the dismiss target. -->
<dimen name="bubble_dismiss_target_padding_x">40dp</dimen>
<dimen name="bubble_dismiss_target_padding_y">20dp</dimen>
+
<!-- Size of the RAT type for CellularTile -->
<dimen name="celltile_rat_type_size">10sp</dimen>
</resources>
diff --git a/packages/SystemUI/res/values/ids.xml b/packages/SystemUI/res/values/ids.xml
index 66f1949..3727181 100644
--- a/packages/SystemUI/res/values/ids.xml
+++ b/packages/SystemUI/res/values/ids.xml
@@ -137,6 +137,7 @@
<item type="id" name="scale_x_dynamicanimation_tag"/>
<item type="id" name="scale_y_dynamicanimation_tag"/>
<item type="id" name="physics_animator_tag"/>
+ <item type="id" name="target_animator_tag" />
<!-- Global Actions Menu -->
<item type="id" name="global_actions_view" />
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 4b70b97..6ffea1b 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -961,6 +961,9 @@
<!-- Message shown when lock screen is tapped or face authentication fails. [CHAR LIMIT=60] -->
<string name="keyguard_unlock">Swipe up to open</string>
+ <!-- Message shown when face authentication fails and the pin pad is visible. [CHAR LIMIT=60] -->
+ <string name="keyguard_retry">Swipe up to try again</string>
+
<!-- Text on keyguard screen and in Quick Settings footer indicating that the device is enterprise-managed by a Device Owner [CHAR LIMIT=60] -->
<string name="do_disclosure_generic">This device is managed by your organization</string>
@@ -1386,6 +1389,8 @@
buttons</string>
<string name="screen_pinning_toast_recents_invisible">To unpin this screen, touch & hold Back
and Home buttons</string>
+ <!-- Notify (in toast) user how to unpin screen in gesture navigation mode [CHAR LIMIT=NONE] -->
+ <string name="screen_pinning_toast_gesture_nav">To unpin this screen, swipe up & hold</string>
<!-- Screen pinning positive response. -->
<string name="screen_pinning_positive">Got it</string>
<!-- Screen pinning negative response. -->
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityManagerWrapper.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityManagerWrapper.java
index 328116d..13fc702 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityManagerWrapper.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityManagerWrapper.java
@@ -236,7 +236,8 @@
@Override
public void onAnimationCanceled(boolean deferredWithScreenshot) {
- animationHandler.onAnimationCanceled(deferredWithScreenshot);
+ animationHandler.onAnimationCanceled(
+ deferredWithScreenshot ? new ThumbnailData() : null);
}
};
}
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RecentsAnimationListener.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RecentsAnimationListener.java
index 5850fda..579858a 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RecentsAnimationListener.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RecentsAnimationListener.java
@@ -18,6 +18,8 @@
import android.graphics.Rect;
+import com.android.systemui.shared.recents.model.ThumbnailData;
+
public interface RecentsAnimationListener {
/**
@@ -29,5 +31,5 @@
/**
* Called when the animation into Recents was canceled. This call is made on the binder thread.
*/
- void onAnimationCanceled(boolean deferredWithScreenshot);
+ void onAnimationCanceled(ThumbnailData thumbnailData);
}
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListener.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListener.java
index c215d0f..4c49494 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListener.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListener.java
@@ -72,6 +72,13 @@
*/
public void onSingleTaskDisplayDrawn(int displayId) { }
+ /**
+ * Called when the last task is removed from a display which can only contain one task.
+ *
+ * @param displayId the id of the display from which the window is removed.
+ */
+ public void onSingleTaskDisplayEmpty(int displayId) {}
+
public void onTaskProfileLocked(int taskId, int userId) { }
public void onTaskCreated(int taskId, ComponentName componentName) { }
public void onTaskRemoved(int taskId) { }
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListeners.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListeners.java
index d570a58..4465f04 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListeners.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListeners.java
@@ -209,6 +209,12 @@
}
@Override
+ public void onSingleTaskDisplayEmpty(int displayId) throws RemoteException {
+ mHandler.obtainMessage(H.ON_SINGLE_TASK_DISPLAY_EMPTY, displayId,
+ 0 /* unused */).sendToTarget();
+ }
+
+ @Override
public void onTaskDisplayChanged(int taskId, int newDisplayId) throws RemoteException {
mHandler.obtainMessage(H.ON_TASK_DISPLAY_CHANGED, taskId, newDisplayId).sendToTarget();
}
@@ -233,7 +239,8 @@
private static final int ON_SIZE_COMPAT_MODE_ACTIVITY_CHANGED = 17;
private static final int ON_BACK_PRESSED_ON_TASK_ROOT = 18;
private static final int ON_SINGLE_TASK_DISPLAY_DRAWN = 19;
- private static final int ON_TASK_DISPLAY_CHANGED = 20;
+ private static final int ON_SINGLE_TASK_DISPLAY_EMPTY = 20;
+ private static final int ON_TASK_DISPLAY_CHANGED = 21;
public H(Looper looper) {
@@ -376,6 +383,13 @@
}
break;
}
+ case ON_SINGLE_TASK_DISPLAY_EMPTY: {
+ for (int i = mTaskStackListeners.size() - 1; i >= 0; i--) {
+ mTaskStackListeners.get(i).onSingleTaskDisplayEmpty(
+ msg.arg1);
+ }
+ break;
+ }
case ON_TASK_DISPLAY_CHANGED: {
for (int i = mTaskStackListeners.size() - 1; i >= 0; i--) {
mTaskStackListeners.get(i).onTaskDisplayChanged(msg.arg1, msg.arg2);
diff --git a/packages/SystemUI/src/com/android/keyguard/CarrierText.java b/packages/SystemUI/src/com/android/keyguard/CarrierText.java
index adcb7a1..b70d834 100644
--- a/packages/SystemUI/src/com/android/keyguard/CarrierText.java
+++ b/packages/SystemUI/src/com/android/keyguard/CarrierText.java
@@ -24,6 +24,8 @@
import android.view.View;
import android.widget.TextView;
+import com.android.systemui.R;
+
import java.util.Locale;
public class CarrierText extends TextView {
diff --git a/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java b/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
index 10d132a..3f3d8a5 100644
--- a/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
+++ b/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
@@ -44,6 +44,7 @@
import com.android.internal.telephony.TelephonyProperties;
import com.android.settingslib.WirelessUtils;
import com.android.systemui.Dependency;
+import com.android.systemui.R;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import java.util.ArrayList;
@@ -361,7 +362,9 @@
}
}
}
- if (allSimsMissing) {
+ // Only create "No SIM card" if no cards with CarrierName && no wifi when some sim is READY
+ // This condition will also be true always when numSubs == 0
+ if (allSimsMissing && !anySimReadyAndInService) {
if (numSubs != 0) {
// Shows "No SIM card | Emergency calls only" on devices that are voice-capable.
// This depends on mPlmn containing the text "Emergency calls only" when the radio
diff --git a/packages/SystemUI/src/com/android/keyguard/EmergencyCarrierArea.java b/packages/SystemUI/src/com/android/keyguard/EmergencyCarrierArea.java
index e98ef06..225bebe 100644
--- a/packages/SystemUI/src/com/android/keyguard/EmergencyCarrierArea.java
+++ b/packages/SystemUI/src/com/android/keyguard/EmergencyCarrierArea.java
@@ -21,6 +21,8 @@
import android.view.MotionEvent;
import android.view.View;
+import com.android.systemui.R;
+
public class EmergencyCarrierArea extends AlphaOptimizedLinearLayout {
private CarrierText mCarrierText;
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputView.java
index a4b6958..d45603f 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputView.java
@@ -33,6 +33,7 @@
import com.android.internal.util.LatencyTracker;
import com.android.internal.widget.LockPatternChecker;
import com.android.internal.widget.LockPatternUtils;
+import com.android.systemui.R;
import java.util.Arrays;
@@ -253,6 +254,7 @@
protected void onUserInput() {
if (mCallback != null) {
mCallback.userActivity();
+ mCallback.onUserInput();
}
mSecurityMessageDisplay.setMessage("");
}
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockAccessibilityDelegate.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockAccessibilityDelegate.java
index 6a83c71..a78c293 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockAccessibilityDelegate.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockAccessibilityDelegate.java
@@ -23,6 +23,8 @@
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.TextView;
+import com.android.systemui.R;
+
/**
* Replaces fancy colons with regular colons. Only works on TextViews.
*/
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java
index 5097216..df0dc46 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java
@@ -30,6 +30,7 @@
import com.android.internal.colorextraction.ColorExtractor.OnColorsChangedListener;
import com.android.keyguard.clock.ClockManager;
import com.android.systemui.Interpolators;
+import com.android.systemui.R;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.plugins.ClockPlugin;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java b/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java
index 0ec60e5..9380eb4 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java
@@ -35,6 +35,7 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.Dependency;
+import com.android.systemui.R;
import com.android.systemui.statusbar.NavigationBarController;
import com.android.systemui.statusbar.phone.NavigationBarView;
import com.android.systemui.util.InjectionInflationController;
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardEsimArea.java b/packages/SystemUI/src/com/android/keyguard/KeyguardEsimArea.java
index c2bbfbf..fe64142 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardEsimArea.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardEsimArea.java
@@ -32,6 +32,8 @@
import android.view.WindowManager;
import android.widget.Button;
+import com.android.systemui.R;
+
/***
* This button is used by the device with embedded SIM card to disable current carrier to unlock
* the device with no cellular service.
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardHostView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardHostView.java
index 14ead04..8e1f6d3 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardHostView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardHostView.java
@@ -35,6 +35,7 @@
import com.android.keyguard.KeyguardSecurityContainer.SecurityCallback;
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
import com.android.settingslib.Utils;
+import com.android.systemui.R;
import com.android.systemui.plugins.ActivityStarter.OnDismissAction;
import java.io.File;
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java b/packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java
index 037a8d3..1ff98dd 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java
@@ -31,6 +31,7 @@
import android.view.View;
import android.widget.TextView;
+import com.android.systemui.R;
import com.android.systemui.statusbar.policy.ConfigurationController;
import java.lang.ref.WeakReference;
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java
index 6808c0f..15d2ea7 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java
@@ -24,6 +24,7 @@
import com.android.settingslib.animation.AppearAnimationUtils;
import com.android.settingslib.animation.DisappearAnimationUtils;
+import com.android.systemui.R;
/**
* Displays a PIN pad for unlocking.
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPasswordView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPasswordView.java
index 96392156..eaaa3ed 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardPasswordView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPasswordView.java
@@ -37,6 +37,7 @@
import android.widget.TextView.OnEditorActionListener;
import com.android.internal.widget.TextViewInputDisabler;
+import com.android.systemui.R;
import java.util.List;
/**
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java
index 55ddfc3..34c15e6 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java
@@ -42,6 +42,7 @@
import com.android.settingslib.animation.AppearAnimationCreator;
import com.android.settingslib.animation.AppearAnimationUtils;
import com.android.settingslib.animation.DisappearAnimationUtils;
+import com.android.systemui.R;
import java.util.List;
@@ -274,6 +275,7 @@
@Override
public void onPatternCellAdded(List<LockPatternView.Cell> pattern) {
mCallback.userActivity();
+ mCallback.onUserInput();
}
@Override
@@ -336,6 +338,7 @@
});
if (pattern.size() > MIN_PATTERN_BEFORE_POKE_WAKELOCK) {
mCallback.userActivity();
+ mCallback.onUserInput();
}
}
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java
index ecafc34..274f739 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java
@@ -23,6 +23,8 @@
import android.view.MotionEvent;
import android.view.View;
+import com.android.systemui.R;
+
/**
* A Pin based Keyguard input view
*/
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityCallback.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityCallback.java
index cbfbffb..49dcfff 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityCallback.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityCallback.java
@@ -55,4 +55,9 @@
default void onCancelClicked() {
// No-op
}
+
+ /**
+ * Invoked whenever users are typing their password or drawing a pattern.
+ */
+ void onUserInput();
}
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java
index 8059dcf..ca7cd0d 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java
@@ -45,6 +45,7 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
import com.android.systemui.Dependency;
+import com.android.systemui.R;
import com.android.systemui.SystemUIFactory;
import com.android.systemui.statusbar.phone.UnlockMethodCache;
import com.android.systemui.util.InjectionInflationController;
@@ -596,6 +597,11 @@
}
}
+ @Override
+ public void onUserInput() {
+ mUpdateMonitor.cancelFaceAuth();
+ }
+
public void dismiss(boolean authenticated, int targetId) {
mSecurityCallback.dismiss(authenticated, targetId);
}
@@ -640,6 +646,8 @@
@Override
public void dismiss(boolean securityVerified, int targetUserId) { }
@Override
+ public void onUserInput() { }
+ @Override
public void reset() {}
};
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipper.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipper.java
index e6a0250..24da3ad 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipper.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipper.java
@@ -32,6 +32,7 @@
import android.widget.ViewFlipper;
import com.android.internal.widget.LockPatternUtils;
+import com.android.systemui.R;
/**
* Subclass of the current view flipper that allows us to overload dispatchTouchEvent() so
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java
index 69da990..367a7bd 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java
@@ -41,6 +41,7 @@
import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.IccCardConstants.State;
import com.android.internal.telephony.PhoneConstants;
+import com.android.systemui.R;
/**
* Displays a PIN pad for unlocking.
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java
index 27f71d1..81f8c67 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java
@@ -40,6 +40,7 @@
import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.IccCardConstants.State;
import com.android.internal.telephony.PhoneConstants;
+import com.android.systemui.R;
/**
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java
index 37e89c0..1dfc5f2 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java
@@ -40,6 +40,7 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.systemui.Dependency;
+import com.android.systemui.R;
import com.android.systemui.statusbar.policy.ConfigurationController;
import java.io.FileDescriptor;
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
index 109f270..8d858dc 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -94,6 +94,7 @@
import com.android.internal.util.Preconditions;
import com.android.internal.widget.LockPatternUtils;
import com.android.settingslib.WirelessUtils;
+import com.android.systemui.R;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.TaskStackChangeListener;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
@@ -844,11 +845,6 @@
getCurrentUser());
}
- // The face timeout message is not very actionable, let's ask the user to
- // manually retry.
- if (msgId == FaceManager.FACE_ERROR_TIMEOUT) {
- errString = mContext.getString(R.string.keyguard_unlock);
- }
for (int i = 0; i < mCallbacks.size(); i++) {
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
if (cb != null) {
@@ -1408,6 +1404,7 @@
}
protected void handleStartedGoingToSleep(int arg1) {
+ mLockIconPressed = false;
clearBiometricRecognized();
final int count = mCallbacks.size();
for (int i = 0; i < count; i++) {
@@ -1443,7 +1440,6 @@
}
private void handleScreenTurnedOff() {
- mLockIconPressed = false;
mHardwareFingerprintUnavailableRetryCount = 0;
mHardwareFaceUnavailableRetryCount = 0;
final int count = mCallbacks.size();
@@ -1646,6 +1642,13 @@
updateFaceListeningState();
}
+ /**
+ * In case face auth is running, cancel it.
+ */
+ public void cancelFaceAuth() {
+ stopListeningForFace();
+ }
+
private void updateFaceListeningState() {
// If this message exists, we should not authenticate again until this message is
// consumed by the handler
@@ -1685,7 +1688,10 @@
return shouldListen;
}
- private boolean shouldListenForFace() {
+ /**
+ * If face auth is allows to scan on this exact moment.
+ */
+ public boolean shouldListenForFace() {
final boolean awakeKeyguard = mKeyguardIsVisible && mDeviceInteractive && !mGoingToSleep;
final int user = getCurrentUser();
final int strongAuth = mStrongAuthTracker.getStrongAuthForUser(user);
diff --git a/packages/SystemUI/src/com/android/keyguard/NumPadKey.java b/packages/SystemUI/src/com/android/keyguard/NumPadKey.java
index 08691ec..ebdd8c6 100644
--- a/packages/SystemUI/src/com/android/keyguard/NumPadKey.java
+++ b/packages/SystemUI/src/com/android/keyguard/NumPadKey.java
@@ -29,6 +29,7 @@
import android.widget.TextView;
import com.android.internal.widget.LockPatternUtils;
+import com.android.systemui.R;
public class NumPadKey extends ViewGroup {
// list of "ABC", etc per digit, starting with '0'
diff --git a/packages/SystemUI/src/com/android/keyguard/PasswordTextView.java b/packages/SystemUI/src/com/android/keyguard/PasswordTextView.java
index b21bcc9..409ae3f 100644
--- a/packages/SystemUI/src/com/android/keyguard/PasswordTextView.java
+++ b/packages/SystemUI/src/com/android/keyguard/PasswordTextView.java
@@ -42,6 +42,8 @@
import android.view.animation.Interpolator;
import android.widget.EditText;
+import com.android.systemui.R;
+
import java.util.ArrayList;
import java.util.Stack;
diff --git a/packages/SystemUI/src/com/android/keyguard/clock/AnalogClockController.java b/packages/SystemUI/src/com/android/keyguard/clock/AnalogClockController.java
index 9c5242c..eba2400 100644
--- a/packages/SystemUI/src/com/android/keyguard/clock/AnalogClockController.java
+++ b/packages/SystemUI/src/com/android/keyguard/clock/AnalogClockController.java
@@ -26,7 +26,7 @@
import android.widget.TextClock;
import com.android.internal.colorextraction.ColorExtractor;
-import com.android.keyguard.R;
+import com.android.systemui.R;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.plugins.ClockPlugin;
diff --git a/packages/SystemUI/src/com/android/keyguard/clock/BubbleClockController.java b/packages/SystemUI/src/com/android/keyguard/clock/BubbleClockController.java
index 8e81327..3a2fbe5 100644
--- a/packages/SystemUI/src/com/android/keyguard/clock/BubbleClockController.java
+++ b/packages/SystemUI/src/com/android/keyguard/clock/BubbleClockController.java
@@ -26,7 +26,7 @@
import android.widget.TextClock;
import com.android.internal.colorextraction.ColorExtractor;
-import com.android.keyguard.R;
+import com.android.systemui.R;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.plugins.ClockPlugin;
diff --git a/packages/SystemUI/src/com/android/keyguard/clock/ClockLayout.java b/packages/SystemUI/src/com/android/keyguard/clock/ClockLayout.java
index 7485d33..d44d89e 100644
--- a/packages/SystemUI/src/com/android/keyguard/clock/ClockLayout.java
+++ b/packages/SystemUI/src/com/android/keyguard/clock/ClockLayout.java
@@ -24,7 +24,7 @@
import android.view.View;
import android.widget.FrameLayout;
-import com.android.keyguard.R;
+import com.android.systemui.R;
/**
* Positions clock faces (analog, digital, typographic) and handles pixel shifting
diff --git a/packages/SystemUI/src/com/android/keyguard/clock/DefaultClockController.java b/packages/SystemUI/src/com/android/keyguard/clock/DefaultClockController.java
index 98679ade..c81935a 100644
--- a/packages/SystemUI/src/com/android/keyguard/clock/DefaultClockController.java
+++ b/packages/SystemUI/src/com/android/keyguard/clock/DefaultClockController.java
@@ -26,7 +26,7 @@
import android.widget.TextView;
import com.android.internal.colorextraction.ColorExtractor;
-import com.android.keyguard.R;
+import com.android.systemui.R;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.plugins.ClockPlugin;
diff --git a/packages/SystemUI/src/com/android/keyguard/clock/ImageClock.java b/packages/SystemUI/src/com/android/keyguard/clock/ImageClock.java
index 95f1004..34c041b 100644
--- a/packages/SystemUI/src/com/android/keyguard/clock/ImageClock.java
+++ b/packages/SystemUI/src/com/android/keyguard/clock/ImageClock.java
@@ -21,7 +21,7 @@
import android.widget.FrameLayout;
import android.widget.ImageView;
-import com.android.keyguard.R;
+import com.android.systemui.R;
import java.text.SimpleDateFormat;
import java.util.Calendar;
diff --git a/packages/SystemUI/src/com/android/keyguard/clock/SmallClockPosition.java b/packages/SystemUI/src/com/android/keyguard/clock/SmallClockPosition.java
index 60ca945..b304074 100644
--- a/packages/SystemUI/src/com/android/keyguard/clock/SmallClockPosition.java
+++ b/packages/SystemUI/src/com/android/keyguard/clock/SmallClockPosition.java
@@ -20,6 +20,7 @@
import android.util.MathUtils;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.systemui.R;
/**
* Computes preferred position of clock by considering height of status bar and lock icon.
@@ -40,10 +41,10 @@
private float mDarkAmount;
SmallClockPosition(Resources res) {
- this(res.getDimensionPixelSize(com.android.keyguard.R.dimen.status_bar_height),
- res.getDimensionPixelSize(com.android.keyguard.R.dimen.keyguard_lock_padding),
- res.getDimensionPixelSize(com.android.keyguard.R.dimen.keyguard_lock_height),
- res.getDimensionPixelSize(com.android.keyguard.R.dimen.burn_in_prevention_offset_y)
+ this(res.getDimensionPixelSize(R.dimen.status_bar_height),
+ res.getDimensionPixelSize(R.dimen.keyguard_lock_padding),
+ res.getDimensionPixelSize(R.dimen.keyguard_lock_height),
+ res.getDimensionPixelSize(R.dimen.burn_in_prevention_offset_y)
);
}
diff --git a/packages/SystemUI/src/com/android/systemui/ContextComponentHelper.java b/packages/SystemUI/src/com/android/systemui/ContextComponentHelper.java
new file mode 100644
index 0000000..8fabe7a
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/ContextComponentHelper.java
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+package com.android.systemui;
+
+/**
+ * Interface necessary to make Dagger happy. See {@link ContextComponentResolver}.
+ */
+public interface ContextComponentHelper {
+ /** Turns a classname into an instance of the class or returns null. */
+ <T> T resolve(String className);
+}
diff --git a/packages/SystemUI/src/com/android/systemui/ContextComponentResolver.java b/packages/SystemUI/src/com/android/systemui/ContextComponentResolver.java
new file mode 100644
index 0000000..09bccd9
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/ContextComponentResolver.java
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+package com.android.systemui;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.inject.Provider;
+
+/**
+ * Used during Service and Activity instantiation to make them injectable.
+ */
+public class ContextComponentResolver implements ContextComponentHelper {
+ private final Map<Class<?>, Provider<Object>> mCreators;
+
+ @Inject
+ ContextComponentResolver(Map<Class<?>, Provider<Object>> creators) {
+ mCreators = creators;
+ }
+
+ /**
+ * Looks up the class name to see if Dagger has an instance of it.
+ */
+ @Override
+ public <T> T resolve(String className) {
+ for (Map.Entry<Class<?>, Provider<Object>> p : mCreators.entrySet()) {
+ if (p.getKey().getName().equals(className)) {
+ return (T) p.getValue().get();
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/Dependency.java b/packages/SystemUI/src/com/android/systemui/Dependency.java
index 6c36bc9..15bea24 100644
--- a/packages/SystemUI/src/com/android/systemui/Dependency.java
+++ b/packages/SystemUI/src/com/android/systemui/Dependency.java
@@ -16,7 +16,6 @@
import android.annotation.Nullable;
import android.app.INotificationManager;
-import android.content.Context;
import android.content.res.Configuration;
import android.hardware.SensorPrivacyManager;
import android.hardware.display.NightDisplayListener;
@@ -114,7 +113,6 @@
import java.io.FileDescriptor;
import java.io.PrintWriter;
-import java.util.HashMap;
import java.util.function.Consumer;
import javax.inject.Inject;
@@ -138,9 +136,7 @@
* they have no clients they should not have any registered resources like bound
* services, registered receivers, etc.
*/
-public class Dependency extends SystemUI {
- private static final String TAG = "Dependency";
-
+public class Dependency {
/**
* Key for getting a background Looper for background work.
*/
@@ -305,8 +301,20 @@
public Dependency() {
}
- @Override
- public void start() {
+
+ /**
+ * Initialize Depenency.
+ */
+ public static void initDependencies(SystemUIRootComponent rootComponent) {
+ if (sDependency != null) {
+ return;
+ }
+ sDependency = new Dependency();
+ rootComponent.createDependency().createSystemUI(sDependency);
+ sDependency.start();
+ }
+
+ protected void start() {
// TODO: Think about ways to push these creation rules out of Dependency to cut down
// on imports.
mProviders.put(TIME_TICK_HANDLER, mTimeTickHandler::get);
@@ -486,10 +494,14 @@
sDependency = this;
}
- @Override
- public synchronized void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
- super.dump(fd, pw, args);
+ static void staticDump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ sDependency.dump(fd, pw, args);
+ }
+ /**
+ * {@see SystemUI.dump}
+ */
+ public synchronized void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
// Make sure that the DumpController gets added to mDependencies, as they are only added
// with Dependency#get.
getDependency(DumpController.class);
@@ -509,9 +521,11 @@
.forEach(o -> ((Dumpable) o).dump(fd, pw, args));
}
- @Override
+ protected static void staticOnConfigurationChanged(Configuration newConfig) {
+ sDependency.onConfigurationChanged(newConfig);
+ }
+
protected synchronized void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
mDependencies.values().stream().filter(obj -> obj instanceof ConfigurationChangedReceiver)
.forEach(o -> ((ConfigurationChangedReceiver) o).onConfigurationChanged(newConfig));
}
@@ -565,20 +579,6 @@
}
/**
- * Used in separate processes (like tuner settings) to init the dependencies.
- */
- public static void initDependencies(Context context) {
- if (sDependency != null) return;
- Dependency d = new Dependency();
- SystemUIFactory.getInstance().getRootComponent()
- .createDependency()
- .createSystemUI(d);
- d.mContext = context;
- d.mComponents = new HashMap<>();
- d.start();
- }
-
- /**
* Used in separate process teardown to ensure the context isn't leaked.
*
* TODO: Remove once PreferenceFragment doesn't reference getActivity()
@@ -629,15 +629,4 @@
public interface DependencyInjector {
void createSystemUI(Dependency dependency);
}
-
- public static class DependencyCreator implements Injector {
- @Override
- public SystemUI apply(Context context) {
- Dependency dependency = new Dependency();
- SystemUIFactory.getInstance().getRootComponent()
- .createDependency()
- .createSystemUI(dependency);
- return dependency;
- }
- }
}
diff --git a/packages/SystemUI/src/com/android/systemui/ForegroundServicesDialog.java b/packages/SystemUI/src/com/android/systemui/ForegroundServicesDialog.java
index cb9523f..6fec92c 100644
--- a/packages/SystemUI/src/com/android/systemui/ForegroundServicesDialog.java
+++ b/packages/SystemUI/src/com/android/systemui/ForegroundServicesDialog.java
@@ -75,7 +75,7 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- Dependency.initDependencies(getApplicationContext());
+ Dependency.initDependencies(SystemUIFactory.getInstance().getRootComponent());
mMetricsLogger = Dependency.get(MetricsLogger.class);
diff --git a/packages/SystemUI/src/com/android/systemui/ServiceBinder.java b/packages/SystemUI/src/com/android/systemui/ServiceBinder.java
new file mode 100644
index 0000000..6282c6e
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/ServiceBinder.java
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+package com.android.systemui;
+
+import com.android.systemui.doze.DozeService;
+
+import dagger.Binds;
+import dagger.Module;
+import dagger.multibindings.ClassKey;
+import dagger.multibindings.IntoMap;
+
+/**
+ * Services and Activities that are injectable should go here.
+ */
+@Module
+public abstract class ServiceBinder {
+
+ @Binds
+ public abstract ContextComponentHelper bindComponentHelper(
+ ContextComponentResolver componentHelper);
+
+ @Binds
+ @IntoMap
+ @ClassKey(DozeService.class)
+ public abstract Object bindDozeService(DozeService service);
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
index 84e0238..58c52a1 100644
--- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
@@ -34,7 +34,6 @@
import android.view.ViewConfiguration;
import android.view.accessibility.AccessibilityEvent;
-import com.android.systemui.classifier.FalsingManagerFactory;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.statusbar.FlingAnimationUtils;
@@ -98,7 +97,8 @@
private final ArrayMap<View, Animator> mDismissPendingMap = new ArrayMap<>();
- public SwipeHelper(int swipeDirection, Callback callback, Context context) {
+ public SwipeHelper(
+ int swipeDirection, Callback callback, Context context, FalsingManager falsingManager) {
mContext = context;
mCallback = callback;
mHandler = new Handler();
@@ -113,7 +113,7 @@
mDensityScale = res.getDisplayMetrics().density;
mFalsingThreshold = res.getDimensionPixelSize(R.dimen.swipe_helper_falsing_threshold);
mFadeDependingOnAmountSwiped = res.getBoolean(R.bool.config_fadeDependingOnAmountSwiped);
- mFalsingManager = FalsingManagerFactory.getInstance(context);
+ mFalsingManager = falsingManager;
mFlingAnimationUtils = new FlingAnimationUtils(context, getMaxEscapeAnimDuration() / 1000f);
}
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIAppComponentFactory.java b/packages/SystemUI/src/com/android/systemui/SystemUIAppComponentFactory.java
new file mode 100644
index 0000000..8cb5948
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/SystemUIAppComponentFactory.java
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+package com.android.systemui;
+
+import android.app.Application;
+
+import androidx.core.app.CoreComponentFactory;
+
+import javax.inject.Inject;
+
+/**
+ * Implementation of AppComponentFactory that injects into constructors.
+ */
+public class SystemUIAppComponentFactory extends CoreComponentFactory {
+
+ @Inject
+ public ContextComponentHelper mComponentHelper;
+
+ public SystemUIAppComponentFactory() {
+ super();
+ }
+
+ @Override
+ public Application instantiateApplication(ClassLoader cl, String className)
+ throws InstantiationException, IllegalAccessException, ClassNotFoundException {
+ Application app = super.instantiateApplication(cl, className);
+ if (app instanceof SystemUIApplication) {
+ ((SystemUIApplication) app).setContextAvailableCallback(
+ context -> {
+ SystemUIFactory.createFromConfig(context);
+ SystemUIFactory.getInstance().getRootComponent().inject(
+ SystemUIAppComponentFactory.this);
+ }
+ );
+ }
+
+ return app;
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java
index e89e6cb..48127a7 100644
--- a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java
+++ b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java
@@ -60,17 +60,30 @@
private boolean mServicesStarted;
private boolean mBootCompleted;
private final Map<Class<?>, Object> mComponents = new HashMap<>();
+ private ContextAvailableCallback mContextAvailableCallback;
+
+ public SystemUIApplication() {
+ super();
+ Log.v(TAG, "SystemUIApplication constructed.");
+ }
@Override
public void onCreate() {
super.onCreate();
+ Log.v(TAG, "SystemUIApplication created.");
+ // This line is used to setup Dagger's dependency injection and should be kept at the
+ // top of this method.
+ TimingsTraceLog log = new TimingsTraceLog("SystemUIBootTiming",
+ Trace.TRACE_TAG_APP);
+ log.traceBegin("DependencyInjection");
+ mContextAvailableCallback.onContextAvailable(this);
+ log.traceEnd();
+
// Set the application theme that is inherited by all services. Note that setting the
// application theme in the manifest does only work for activities. Keep this in sync with
// the theme set there.
setTheme(R.style.Theme_SystemUI);
- SystemUIFactory.createFromConfig(this);
-
if (Process.myUserHandle().equals(UserHandle.SYSTEM)) {
IntentFilter bootCompletedFilter = new IntentFilter(Intent.ACTION_BOOT_COMPLETED);
bootCompletedFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
@@ -134,7 +147,7 @@
/**
* Ensures that all the Secondary user SystemUI services are running. If they are already
- * running, this is a no-op. This is needed to conditinally start all the services, as we only
+ * running, this is a no-op. This is needed to conditionally start all the services, as we only
* need to have it in the main process.
* <p>This method must only be called from the main thread.</p>
*/
@@ -155,7 +168,9 @@
// see ActivityManagerService.finishBooting()
if ("1".equals(SystemProperties.get("sys.boot_completed"))) {
mBootCompleted = true;
- if (DEBUG) Log.v(TAG, "BOOT_COMPLETED was already sent");
+ if (DEBUG) {
+ Log.v(TAG, "BOOT_COMPLETED was already sent");
+ }
}
}
@@ -269,6 +284,7 @@
@Override
public void onConfigurationChanged(Configuration newConfig) {
if (mServicesStarted) {
+ Dependency.staticOnConfigurationChanged(newConfig);
int len = mServices.length;
for (int i = 0; i < len; i++) {
if (mServices[i] != null) {
@@ -286,4 +302,12 @@
public SystemUI[] getServices() {
return mServices;
}
+
+ void setContextAvailableCallback(ContextAvailableCallback callback) {
+ mContextAvailableCallback = callback;
+ }
+
+ interface ContextAvailableCallback {
+ void onContextAvailable(Context context);
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIDefaultModule.java b/packages/SystemUI/src/com/android/systemui/SystemUIDefaultModule.java
new file mode 100644
index 0000000..262b5ec
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/SystemUIDefaultModule.java
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ */
+
+package com.android.systemui;
+
+import static com.android.systemui.Dependency.ALLOW_NOTIFICATION_LONG_PRESS_NAME;
+import static com.android.systemui.Dependency.LEAK_REPORT_EMAIL_NAME;
+
+import android.content.Context;
+
+import androidx.annotation.Nullable;
+
+import com.android.systemui.dock.DockManager;
+import com.android.systemui.dock.DockManagerImpl;
+import com.android.systemui.power.EnhancedEstimates;
+import com.android.systemui.power.EnhancedEstimatesImpl;
+import com.android.systemui.statusbar.NotificationLockscreenUserManager;
+import com.android.systemui.statusbar.NotificationLockscreenUserManagerImpl;
+import com.android.systemui.statusbar.notification.collection.NotificationData;
+import com.android.systemui.statusbar.phone.KeyguardEnvironmentImpl;
+import com.android.systemui.statusbar.phone.ShadeController;
+import com.android.systemui.statusbar.phone.StatusBar;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import dagger.Binds;
+import dagger.Module;
+import dagger.Provides;
+
+/**
+ * A dagger module for injecting default implementations of components of System UI that may be
+ * overridden by the System UI implementation.
+ */
+@Module
+abstract class SystemUIDefaultModule {
+
+ @Singleton
+ @Provides
+ @Named(LEAK_REPORT_EMAIL_NAME)
+ @Nullable
+ static String provideLeakReportEmail() {
+ return null;
+ }
+
+ @Binds
+ abstract EnhancedEstimates bindEnhancedEstimates(EnhancedEstimatesImpl enhancedEstimates);
+
+ @Binds
+ abstract NotificationLockscreenUserManager bindNotificationLockscreenUserManager(
+ NotificationLockscreenUserManagerImpl notificationLockscreenUserManager);
+
+ @Binds
+ abstract DockManager bindDockManager(DockManagerImpl dockManager);
+
+ @Binds
+ abstract NotificationData.KeyguardEnvironment bindKeyguardEnvironment(
+ KeyguardEnvironmentImpl keyguardEnvironment);
+
+ @Singleton
+ @Provides
+ static ShadeController provideShadeController(Context context) {
+ return SysUiServiceProvider.getComponent(context, StatusBar.class);
+ }
+
+ @Singleton
+ @Provides
+ @Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME)
+ static boolean provideAllowNotificationLongPress() {
+ return true;
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java
index 0d85a3f..d151f7d 100644
--- a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java
+++ b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java
@@ -16,13 +16,8 @@
package com.android.systemui;
-import static com.android.systemui.Dependency.ALLOW_NOTIFICATION_LONG_PRESS_NAME;
-import static com.android.systemui.Dependency.LEAK_REPORT_EMAIL_NAME;
-
-import android.annotation.Nullable;
import android.app.AlarmManager;
import android.content.Context;
-import android.content.pm.PackageManager;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
@@ -33,63 +28,40 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.ViewMediatorCallback;
-import com.android.systemui.assist.AssistManager;
-import com.android.systemui.classifier.FalsingManagerFactory;
-import com.android.systemui.dock.DockManager;
-import com.android.systemui.fragments.FragmentService;
import com.android.systemui.keyguard.DismissCallbackRegistry;
+import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
-import com.android.systemui.power.EnhancedEstimates;
-import com.android.systemui.power.EnhancedEstimatesImpl;
import com.android.systemui.statusbar.KeyguardIndicationController;
-import com.android.systemui.statusbar.NotificationListener;
-import com.android.systemui.statusbar.NotificationLockscreenUserManager;
-import com.android.systemui.statusbar.NotificationLockscreenUserManagerImpl;
import com.android.systemui.statusbar.NotificationMediaManager;
import com.android.systemui.statusbar.ScrimView;
-import com.android.systemui.statusbar.notification.NotificationEntryManager;
-import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider;
import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator;
-import com.android.systemui.statusbar.notification.collection.NotificationData;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.statusbar.phone.KeyguardBouncer;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
-import com.android.systemui.statusbar.phone.KeyguardEnvironmentImpl;
-import com.android.systemui.statusbar.phone.KeyguardLiftController;
import com.android.systemui.statusbar.phone.LockIcon;
import com.android.systemui.statusbar.phone.LockscreenWallpaper;
import com.android.systemui.statusbar.phone.NotificationIconAreaController;
import com.android.systemui.statusbar.phone.ScrimController;
import com.android.systemui.statusbar.phone.ScrimState;
-import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.phone.UnlockMethodCache;
-import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.KeyguardMonitor;
-import com.android.systemui.util.AsyncSensorManager;
-import com.android.systemui.util.InjectionInflationController;
-import com.android.systemui.util.leak.GarbageMonitor;
import com.android.systemui.volume.VolumeDialogComponent;
import java.util.function.Consumer;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import dagger.Component;
import dagger.Module;
import dagger.Provides;
/**
* Class factory to provide customizable SystemUI components.
*/
-@Module
public class SystemUIFactory {
private static final String TAG = "SystemUIFactory";
static SystemUIFactory mFactory;
- private SystemUIRootComponent mRootComponent;
+ protected SystemUIRootComponent mRootComponent;
public static <T extends SystemUIFactory> T getInstance() {
return (T) mFactory;
@@ -114,9 +86,16 @@
public SystemUIFactory() {}
- protected void init(Context context) {
- mRootComponent = DaggerSystemUIFactory_SystemUIRootComponent.builder()
- .systemUIFactory(this)
+ private void init(Context context) {
+ mRootComponent = buildSystemUIRootComponent(context);
+
+ // Every other part of our codebase currently relies on Dependency, so we
+ // really need to ensure the Dependency gets initialized early on.
+ Dependency.initDependencies(mRootComponent);
+ }
+
+ protected SystemUIRootComponent buildSystemUIRootComponent(Context context) {
+ return DaggerSystemUIRootComponent.builder()
.dependencyProvider(new com.android.systemui.DependencyProvider())
.contextHolder(new ContextHolder(context))
.build();
@@ -132,23 +111,24 @@
}
public KeyguardBouncer createKeyguardBouncer(Context context, ViewMediatorCallback callback,
- LockPatternUtils lockPatternUtils, ViewGroup container,
+ LockPatternUtils lockPatternUtils, ViewGroup container,
DismissCallbackRegistry dismissCallbackRegistry,
KeyguardBouncer.BouncerExpansionCallback expansionCallback,
- KeyguardBypassController bypassController) {
+ FalsingManager falsingManager, KeyguardBypassController bypassController) {
return new KeyguardBouncer(context, callback, lockPatternUtils, container,
- dismissCallbackRegistry, FalsingManagerFactory.getInstance(context),
+ dismissCallbackRegistry, falsingManager,
expansionCallback, UnlockMethodCache.getInstance(context),
KeyguardUpdateMonitor.getInstance(context), bypassController,
new Handler(Looper.getMainLooper()));
}
public ScrimController createScrimController(ScrimView scrimBehind, ScrimView scrimInFront,
+ ScrimView scrimForBubble,
LockscreenWallpaper lockscreenWallpaper,
TriConsumer<ScrimState, Float, GradientColors> scrimStateListener,
Consumer<Integer> scrimVisibleListener, DozeParameters dozeParameters,
AlarmManager alarmManager, KeyguardMonitor keyguardMonitor) {
- return new ScrimController(scrimBehind, scrimInFront, scrimStateListener,
+ return new ScrimController(scrimBehind, scrimInFront, scrimForBubble, scrimStateListener,
scrimVisibleListener, dozeParameters, alarmManager, keyguardMonitor);
}
@@ -171,93 +151,8 @@
return new VolumeDialogComponent(systemUi, context);
}
- @Singleton
- @Provides
- public NotificationData.KeyguardEnvironment provideKeyguardEnvironment(Context context) {
- return new KeyguardEnvironmentImpl();
- }
-
- @Singleton
- @Provides
- public NotificationLockscreenUserManager provideNotificationLockscreenUserManager(
- Context context) {
- return new NotificationLockscreenUserManagerImpl(context);
- }
-
- @Singleton
- @Provides
- public AssistManager provideAssistManager(DeviceProvisionedController controller,
- Context context) {
- return new AssistManager(controller, context);
- }
-
- @Singleton
- @Provides
- @Nullable
- public DockManager provideDockManager(Context context) {
- return null;
- }
-
- @Singleton
- @Provides
- public NotificationEntryManager provideNotificationEntryManager(Context context) {
- return new NotificationEntryManager(context);
- }
-
- @Singleton
- @Provides
- public EnhancedEstimates provideEnhancedEstimates(Context context) {
- return new EnhancedEstimatesImpl();
- }
-
- @Singleton
- @Provides
- @Named(LEAK_REPORT_EMAIL_NAME)
- @Nullable
- public String provideLeakReportEmail() {
- return null;
- }
-
- @Singleton
- @Provides
- @Nullable
- public KeyguardLiftController provideKeyguardLiftController(Context context,
- StatusBarStateController statusBarStateController,
- AsyncSensorManager asyncSensorManager) {
- if (!context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE)) {
- return null;
- }
- return new KeyguardLiftController(context, statusBarStateController, asyncSensorManager);
- }
-
- @Singleton
- @Provides
- public NotificationListener provideNotificationListener(Context context) {
- return new NotificationListener(context);
- }
-
- @Singleton
- @Provides
- public NotificationInterruptionStateProvider provideNotificationInterruptionStateProvider(
- Context context) {
- return new NotificationInterruptionStateProvider(context);
- }
-
- @Singleton
- @Provides
- @Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME)
- public boolean provideAllowNotificationLongPress() {
- return true;
- }
-
- @Singleton
- @Provides
- public ShadeController provideShadeController(Context context) {
- return SysUiServiceProvider.getComponent(context, StatusBar.class);
- }
-
@Module
- protected static class ContextHolder {
+ public static class ContextHolder {
private Context mContext;
public ContextHolder(Context context) {
@@ -269,29 +164,4 @@
return mContext;
}
}
-
- @Singleton
- @Component(modules = {SystemUIFactory.class, DependencyProvider.class, DependencyBinder.class,
- ContextHolder.class})
- public interface SystemUIRootComponent {
- @Singleton
- Dependency.DependencyInjector createDependency();
-
- @Singleton
- StatusBar.StatusBarInjector getStatusBarInjector();
-
- /**
- * FragmentCreator generates all Fragments that need injection.
- */
- @Singleton
- FragmentService.FragmentCreator createFragmentCreator();
-
- /**
- * ViewCreator generates all Views that need injection.
- */
- InjectionInflationController.ViewCreator createViewCreator();
-
- @Singleton
- GarbageMonitor createGarbageMonitor();
- }
}
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/SystemUIModule.java
new file mode 100644
index 0000000..defa574
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/SystemUIModule.java
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+package com.android.systemui;
+
+import android.annotation.Nullable;
+import android.content.Context;
+import android.content.pm.PackageManager;
+
+import com.android.systemui.assist.AssistModule;
+import com.android.systemui.plugins.statusbar.StatusBarStateController;
+import com.android.systemui.statusbar.phone.KeyguardLiftController;
+import com.android.systemui.util.AsyncSensorManager;
+
+import javax.inject.Singleton;
+
+import dagger.Module;
+import dagger.Provides;
+
+/**
+ * A dagger module for injecting components of System UI that are not overridden by the System UI
+ * implementation.
+ */
+@Module(includes = {AssistModule.class})
+public abstract class SystemUIModule {
+
+ @Singleton
+ @Provides
+ @Nullable
+ static KeyguardLiftController provideKeyguardLiftController(Context context,
+ StatusBarStateController statusBarStateController,
+ AsyncSensorManager asyncSensorManager) {
+ if (!context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE)) {
+ return null;
+ }
+ return new KeyguardLiftController(context, statusBarStateController, asyncSensorManager);
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIRootComponent.java b/packages/SystemUI/src/com/android/systemui/SystemUIRootComponent.java
new file mode 100644
index 0000000..f18c8b2
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/SystemUIRootComponent.java
@@ -0,0 +1,82 @@
+/*
+ * 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.
+ */
+
+package com.android.systemui;
+
+import static com.android.systemui.Dependency.ALLOW_NOTIFICATION_LONG_PRESS_NAME;
+
+import com.android.systemui.fragments.FragmentService;
+import com.android.systemui.statusbar.phone.StatusBar;
+import com.android.systemui.util.InjectionInflationController;
+import com.android.systemui.util.leak.GarbageMonitor;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import dagger.Component;
+
+/**
+ * Root component for Dagger injection.
+ */
+@Singleton
+@Component(modules = {
+ DependencyProvider.class,
+ DependencyBinder.class,
+ ServiceBinder.class,
+ SystemUIFactory.ContextHolder.class,
+ SystemUIModule.class,
+ SystemUIDefaultModule.class})
+public interface SystemUIRootComponent {
+ /**
+ * Main dependency providing module.
+ */
+ @Singleton
+ Dependency.DependencyInjector createDependency();
+
+ /**
+ * Injects the StatusBar.
+ */
+ @Singleton
+ StatusBar.StatusBarInjector getStatusBarInjector();
+
+ /**
+ * FragmentCreator generates all Fragments that need injection.
+ */
+ @Singleton
+ FragmentService.FragmentCreator createFragmentCreator();
+
+ /**
+ * ViewCreator generates all Views that need injection.
+ */
+ InjectionInflationController.ViewCreator createViewCreator();
+
+ /**
+ * Creatse a GarbageMonitor.
+ */
+ @Singleton
+ GarbageMonitor createGarbageMonitor();
+
+ /**
+ * Whether notification long press is allowed.
+ */
+ @Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME)
+ boolean allowNotificationLongPressName();
+
+ /**
+ * Injects into the supplied argument.
+ */
+ void inject(SystemUIAppComponentFactory factory);
+}
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUISecondaryUserService.java b/packages/SystemUI/src/com/android/systemui/SystemUISecondaryUserService.java
index c8a2e17..2d2d91d 100644
--- a/packages/SystemUI/src/com/android/systemui/SystemUISecondaryUserService.java
+++ b/packages/SystemUI/src/com/android/systemui/SystemUISecondaryUserService.java
@@ -38,25 +38,8 @@
@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
- SystemUI[] services = ((SystemUIApplication) getApplication()).getServices();
- if (args == null || args.length == 0) {
- for (SystemUI ui: services) {
- if (ui != null) {
- pw.println("dumping service: " + ui.getClass().getName());
- ui.dump(fd, pw, args);
- }
- }
- } else {
- String svc = args[0];
- for (SystemUI ui: services) {
- if (ui != null) {
- String name = ui.getClass().getName();
- if (name.endsWith(svc)) {
- ui.dump(fd, pw, args);
- }
- }
- }
- }
+ SystemUIService.dumpServices(
+ ((SystemUIApplication) getApplication()).getServices(), fd, pw, args);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIService.java b/packages/SystemUI/src/com/android/systemui/SystemUIService.java
index dc1218d..1c5e800 100644
--- a/packages/SystemUI/src/com/android/systemui/SystemUIService.java
+++ b/packages/SystemUI/src/com/android/systemui/SystemUIService.java
@@ -66,8 +66,14 @@
@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
- SystemUI[] services = ((SystemUIApplication) getApplication()).getServices();
+ dumpServices(((SystemUIApplication) getApplication()).getServices(), fd, pw, args);
+ }
+
+ static void dumpServices(
+ SystemUI[] services, FileDescriptor fd, PrintWriter pw, String[] args) {
if (args == null || args.length == 0) {
+ pw.println("dumping service: " + Dependency.class.getName());
+ Dependency.staticDump(fd, pw, args);
for (SystemUI ui: services) {
pw.println("dumping service: " + ui.getClass().getName());
ui.dump(fd, pw, args);
@@ -78,6 +84,9 @@
}
} else {
String svc = args[0].toLowerCase();
+ if (Dependency.class.getName().endsWith(svc)) {
+ Dependency.staticDump(fd, pw, args);
+ }
for (SystemUI ui: services) {
String name = ui.getClass().getName().toLowerCase();
if (name.endsWith(svc)) {
diff --git a/packages/SystemUI/src/com/android/systemui/assist/AssistHandleBehaviorController.java b/packages/SystemUI/src/com/android/systemui/assist/AssistHandleBehaviorController.java
index 6da3818..738ec80 100644
--- a/packages/SystemUI/src/com/android/systemui/assist/AssistHandleBehaviorController.java
+++ b/packages/SystemUI/src/com/android/systemui/assist/AssistHandleBehaviorController.java
@@ -16,6 +16,8 @@
package com.android.systemui.assist;
+import static com.android.systemui.assist.AssistModule.ASSIST_HANDLE_THREAD_NAME;
+
import android.content.ComponentName;
import android.content.Context;
import android.os.Handler;
@@ -28,20 +30,21 @@
import com.android.internal.app.AssistUtils;
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
import com.android.keyguard.KeyguardUpdateMonitor;
-import com.android.systemui.Dependency;
import com.android.systemui.DumpController;
import com.android.systemui.Dumpable;
import com.android.systemui.ScreenDecorations;
-import com.android.systemui.SysUiServiceProvider;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.statusbar.phone.NavigationModeController;
import java.io.FileDescriptor;
import java.io.PrintWriter;
-import java.util.EnumMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
-import java.util.function.Supplier;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+import javax.inject.Singleton;
/**
* A class for managing Assistant handle logic.
@@ -49,6 +52,7 @@
* Controls when visual handles for Assistant gesture affordance should be shown or hidden using an
* {@link AssistHandleBehavior}.
*/
+@Singleton
public final class AssistHandleBehaviorController implements AssistHandleCallbacks, Dumpable {
private static final String TAG = "AssistHandleBehavior";
@@ -67,10 +71,9 @@
private final Handler mHandler;
private final Runnable mHideHandles = this::hideHandles;
private final Runnable mShowAndGo = this::showAndGoInternal;
- private final Supplier<ScreenDecorations> mScreenDecorationsSupplier;
+ private final Provider<ScreenDecorations> mScreenDecorations;
private final PhenotypeHelper mPhenotypeHelper;
- private final Map<AssistHandleBehavior, BehaviorController> mBehaviorMap =
- new EnumMap<>(AssistHandleBehavior.class);
+ private final Map<AssistHandleBehavior, BehaviorController> mBehaviorMap;
private boolean mHandlesShowing = false;
private long mHandlesLastHiddenAt;
@@ -82,41 +85,25 @@
private AssistHandleBehavior mCurrentBehavior = AssistHandleBehavior.OFF;
private boolean mInGesturalMode;
- AssistHandleBehaviorController(Context context, AssistUtils assistUtils, Handler handler) {
- this(
- context,
- assistUtils,
- handler,
- () -> SysUiServiceProvider.getComponent(context, ScreenDecorations.class),
- new PhenotypeHelper(),
- /* testBehavior = */ null);
- }
-
- @VisibleForTesting
+ @Inject
AssistHandleBehaviorController(
Context context,
AssistUtils assistUtils,
- Handler handler,
- Supplier<ScreenDecorations> screenDecorationsSupplier,
+ @Named(ASSIST_HANDLE_THREAD_NAME) Handler handler,
+ Provider<ScreenDecorations> screenDecorations,
PhenotypeHelper phenotypeHelper,
- @Nullable BehaviorController testBehavior) {
+ Map<AssistHandleBehavior, BehaviorController> behaviorMap,
+ NavigationModeController navigationModeController,
+ DumpController dumpController) {
mContext = context;
mAssistUtils = assistUtils;
mHandler = handler;
- mScreenDecorationsSupplier = screenDecorationsSupplier;
+ mScreenDecorations = screenDecorations;
mPhenotypeHelper = phenotypeHelper;
- mBehaviorMap.put(AssistHandleBehavior.OFF, new AssistHandleOffBehavior());
- mBehaviorMap.put(AssistHandleBehavior.LIKE_HOME, new AssistHandleLikeHomeBehavior());
- mBehaviorMap.put(
- AssistHandleBehavior.REMINDER_EXP,
- new AssistHandleReminderExpBehavior(handler, phenotypeHelper));
- if (testBehavior != null) {
- mBehaviorMap.put(AssistHandleBehavior.TEST, testBehavior);
- }
+ mBehaviorMap = behaviorMap;
mInGesturalMode = QuickStepContract.isGesturalMode(
- Dependency.get(NavigationModeController.class)
- .addListener(this::handleNavigationModeChange));
+ navigationModeController.addListener(this::handleNavigationModeChange));
setBehavior(getBehaviorMode());
mPhenotypeHelper.addOnPropertiesChangedListener(
@@ -128,7 +115,8 @@
SystemUiDeviceConfigFlags.ASSIST_HANDLES_BEHAVIOR_MODE, null));
}
});
- Dependency.get(DumpController.class).addListener(this);
+
+ dumpController.addListener(this);
}
@Override // AssistHandleCallbacks
@@ -177,6 +165,12 @@
mBehaviorMap.get(mCurrentBehavior).onAssistantGesturePerformed();
}
+ void onAssistHandlesRequested() {
+ if (mInGesturalMode) {
+ mBehaviorMap.get(mCurrentBehavior).onAssistHandlesRequested();
+ }
+ }
+
void setBehavior(AssistHandleBehavior behavior) {
if (mCurrentBehavior == behavior) {
return;
@@ -235,7 +229,7 @@
}
if (handlesUnblocked(ignoreThreshold)) {
- ScreenDecorations screenDecorations = mScreenDecorationsSupplier.get();
+ ScreenDecorations screenDecorations = mScreenDecorations.get();
if (screenDecorations == null) {
Log.w(TAG, "Couldn't show handles, ScreenDecorations unavailable");
} else {
@@ -250,7 +244,7 @@
return;
}
- ScreenDecorations screenDecorations = mScreenDecorationsSupplier.get();
+ ScreenDecorations screenDecorations = mScreenDecorations.get();
if (screenDecorations == null) {
Log.w(TAG, "Couldn't hide handles, ScreenDecorations unavailable");
} else {
@@ -316,6 +310,7 @@
void onModeActivated(Context context, AssistHandleCallbacks callbacks);
default void onModeDeactivated() {}
default void onAssistantGesturePerformed() {}
+ default void onAssistHandlesRequested() {}
default void dump(PrintWriter pw, String prefix) {}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/assist/AssistHandleLikeHomeBehavior.java b/packages/SystemUI/src/com/android/systemui/assist/AssistHandleLikeHomeBehavior.java
index 6cf2034..31115bb 100644
--- a/packages/SystemUI/src/com/android/systemui/assist/AssistHandleLikeHomeBehavior.java
+++ b/packages/SystemUI/src/com/android/systemui/assist/AssistHandleLikeHomeBehavior.java
@@ -20,18 +20,24 @@
import androidx.annotation.Nullable;
-import com.android.systemui.Dependency;
import com.android.systemui.assist.AssistHandleBehaviorController.BehaviorController;
+import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.recents.OverviewProxyService;
import com.android.systemui.shared.system.QuickStepContract;
import java.io.PrintWriter;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import dagger.Lazy;
+
/**
* Assistant Handle behavior that makes Assistant handles show/hide when the home handle is
* shown/hidden, respectively.
*/
+@Singleton
final class AssistHandleLikeHomeBehavior implements BehaviorController {
private final StatusBarStateController.StateListener mStatusBarStateListener =
@@ -41,6 +47,28 @@
handleDozingChanged(isDozing);
}
};
+ private final WakefulnessLifecycle.Observer mWakefulnessLifecycleObserver =
+ new WakefulnessLifecycle.Observer() {
+ @Override
+ public void onStartedWakingUp() {
+ handleWakefullnessChanged(/* isAwake = */ false);
+ }
+
+ @Override
+ public void onFinishedWakingUp() {
+ handleWakefullnessChanged(/* isAwake = */ true);
+ }
+
+ @Override
+ public void onStartedGoingToSleep() {
+ handleWakefullnessChanged(/* isAwake = */ false);
+ }
+
+ @Override
+ public void onFinishedGoingToSleep() {
+ handleWakefullnessChanged(/* isAwake = */ false);
+ }
+ };
private final OverviewProxyService.OverviewProxyListener mOverviewProxyListener =
new OverviewProxyService.OverviewProxyListener() {
@Override
@@ -48,32 +76,45 @@
handleSystemUiStateChange(sysuiStateFlags);
}
};
- private final StatusBarStateController mStatusBarStateController;
- private final OverviewProxyService mOverviewProxyService;
+
+ private final Lazy<StatusBarStateController> mStatusBarStateController;
+ private final Lazy<WakefulnessLifecycle> mWakefulnessLifecycle;
+ private final Lazy<OverviewProxyService> mOverviewProxyService;
private boolean mIsDozing;
+ private boolean mIsAwake;
private boolean mIsHomeHandleHiding;
@Nullable private AssistHandleCallbacks mAssistHandleCallbacks;
- AssistHandleLikeHomeBehavior() {
- mStatusBarStateController = Dependency.get(StatusBarStateController.class);
- mOverviewProxyService = Dependency.get(OverviewProxyService.class);
+ @Inject
+ AssistHandleLikeHomeBehavior(
+ Lazy<StatusBarStateController> statusBarStateController,
+ Lazy<WakefulnessLifecycle> wakefulnessLifecycle,
+ Lazy<OverviewProxyService> overviewProxyService) {
+ mStatusBarStateController = statusBarStateController;
+ mWakefulnessLifecycle = wakefulnessLifecycle;
+ mOverviewProxyService = overviewProxyService;
}
@Override
public void onModeActivated(Context context, AssistHandleCallbacks callbacks) {
mAssistHandleCallbacks = callbacks;
- mIsDozing = mStatusBarStateController.isDozing();
- mStatusBarStateController.addCallback(mStatusBarStateListener);
- mOverviewProxyService.addCallback(mOverviewProxyListener);
+ mIsDozing = mStatusBarStateController.get().isDozing();
+ mStatusBarStateController.get().addCallback(mStatusBarStateListener);
+ mIsAwake = mWakefulnessLifecycle.get().getWakefulness()
+ == WakefulnessLifecycle.WAKEFULNESS_AWAKE;
+ mWakefulnessLifecycle.get().addObserver(mWakefulnessLifecycleObserver);
+ mOverviewProxyService.get().addCallback(mOverviewProxyListener);
callbackForCurrentState();
}
@Override
public void onModeDeactivated() {
mAssistHandleCallbacks = null;
- mOverviewProxyService.removeCallback(mOverviewProxyListener);
+ mStatusBarStateController.get().removeCallback(mStatusBarStateListener);
+ mWakefulnessLifecycle.get().removeObserver(mWakefulnessLifecycleObserver);
+ mOverviewProxyService.get().removeCallback(mOverviewProxyListener);
}
private static boolean isHomeHandleHiding(int sysuiStateFlags) {
@@ -89,6 +130,15 @@
callbackForCurrentState();
}
+ private void handleWakefullnessChanged(boolean isAwake) {
+ if (mIsAwake == isAwake) {
+ return;
+ }
+
+ mIsAwake = isAwake;
+ callbackForCurrentState();
+ }
+
private void handleSystemUiStateChange(int sysuiStateFlags) {
boolean isHomeHandleHiding = isHomeHandleHiding(sysuiStateFlags);
if (mIsHomeHandleHiding == isHomeHandleHiding) {
@@ -104,18 +154,23 @@
return;
}
- if (mIsHomeHandleHiding || mIsDozing) {
+ if (mIsHomeHandleHiding || !isFullyAwake()) {
mAssistHandleCallbacks.hide();
} else {
mAssistHandleCallbacks.showAndStay();
}
}
+ private boolean isFullyAwake() {
+ return mIsAwake && !mIsDozing;
+ }
+
@Override
public void dump(PrintWriter pw, String prefix) {
- pw.println("Current AssistHandleLikeHomeBehavior State:");
+ pw.println(prefix + "Current AssistHandleLikeHomeBehavior State:");
pw.println(prefix + " mIsDozing=" + mIsDozing);
+ pw.println(prefix + " mIsAwake=" + mIsAwake);
pw.println(prefix + " mIsHomeHandleHiding=" + mIsHomeHandleHiding);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/assist/AssistHandleOffBehavior.java b/packages/SystemUI/src/com/android/systemui/assist/AssistHandleOffBehavior.java
index f4130ae..df913f9 100644
--- a/packages/SystemUI/src/com/android/systemui/assist/AssistHandleOffBehavior.java
+++ b/packages/SystemUI/src/com/android/systemui/assist/AssistHandleOffBehavior.java
@@ -20,9 +20,17 @@
import com.android.systemui.assist.AssistHandleBehaviorController.BehaviorController;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
/** Assistant handle behavior that hides the Assistant handles. */
+@Singleton
final class AssistHandleOffBehavior implements BehaviorController {
+ @Inject
+ AssistHandleOffBehavior() {
+ }
+
@Override
public void onModeActivated(Context context, AssistHandleCallbacks callbacks) {
callbacks.hide();
diff --git a/packages/SystemUI/src/com/android/systemui/assist/AssistHandleReminderExpBehavior.java b/packages/SystemUI/src/com/android/systemui/assist/AssistHandleReminderExpBehavior.java
index f9ddeae..0394048 100644
--- a/packages/SystemUI/src/com/android/systemui/assist/AssistHandleReminderExpBehavior.java
+++ b/packages/SystemUI/src/com/android/systemui/assist/AssistHandleReminderExpBehavior.java
@@ -16,6 +16,9 @@
package com.android.systemui.assist;
+import static com.android.systemui.assist.AssistModule.ASSIST_HANDLE_THREAD_NAME;
+import static com.android.systemui.assist.AssistModule.UPTIME_NAME;
+
import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
@@ -24,14 +27,14 @@
import android.content.IntentFilter;
import android.content.pm.ResolveInfo;
import android.os.Handler;
-import android.os.SystemClock;
import android.provider.Settings;
import androidx.annotation.Nullable;
+import androidx.slice.Clock;
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
-import com.android.systemui.Dependency;
import com.android.systemui.assist.AssistHandleBehaviorController.BehaviorController;
+import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.recents.OverviewProxyService;
import com.android.systemui.shared.system.ActivityManagerWrapper;
@@ -46,11 +49,18 @@
import java.util.List;
import java.util.concurrent.TimeUnit;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import dagger.Lazy;
+
/**
* Assistant handle behavior that hides the handles when the phone is dozing or in immersive mode,
* shows the handles when on lockscreen, and shows the handles temporarily when changing tasks or
* entering overview.
*/
+@Singleton
final class AssistHandleReminderExpBehavior implements BehaviorController {
private static final String LEARNING_TIME_ELAPSED_KEY = "reminder_exp_learning_time_elapsed";
@@ -113,6 +123,28 @@
handleSystemUiStateChanged(sysuiStateFlags);
}
};
+ private final WakefulnessLifecycle.Observer mWakefulnessLifecycleObserver =
+ new WakefulnessLifecycle.Observer() {
+ @Override
+ public void onStartedWakingUp() {
+ handleWakefullnessChanged(/* isAwake = */ false);
+ }
+
+ @Override
+ public void onFinishedWakingUp() {
+ handleWakefullnessChanged(/* isAwake = */ true);
+ }
+
+ @Override
+ public void onStartedGoingToSleep() {
+ handleWakefullnessChanged(/* isAwake = */ false);
+ }
+
+ @Override
+ public void onFinishedGoingToSleep() {
+ handleWakefullnessChanged(/* isAwake = */ false);
+ }
+ };
private final BroadcastReceiver mDefaultHomeBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@@ -122,14 +154,18 @@
private final IntentFilter mDefaultHomeIntentFilter;
private final Runnable mResetConsecutiveTaskSwitches = this::resetConsecutiveTaskSwitches;
+ private final Clock mClock;
private final Handler mHandler;
private final PhenotypeHelper mPhenotypeHelper;
- private final StatusBarStateController mStatusBarStateController;
- private final ActivityManagerWrapper mActivityManagerWrapper;
- private final OverviewProxyService mOverviewProxyService;
+ private final Lazy<StatusBarStateController> mStatusBarStateController;
+ private final Lazy<ActivityManagerWrapper> mActivityManagerWrapper;
+ private final Lazy<OverviewProxyService> mOverviewProxyService;
+ private final Lazy<WakefulnessLifecycle> mWakefulnessLifecycle;
+ private final Lazy<PackageManagerWrapper> mPackageManagerWrapper;
private boolean mOnLockscreen;
private boolean mIsDozing;
+ private boolean mIsAwake;
private int mRunningTaskId;
private boolean mIsNavBarHidden;
private boolean mIsLauncherShowing;
@@ -148,12 +184,24 @@
@Nullable private AssistHandleCallbacks mAssistHandleCallbacks;
@Nullable private ComponentName mDefaultHome;
- AssistHandleReminderExpBehavior(Handler handler, PhenotypeHelper phenotypeHelper) {
+ @Inject
+ AssistHandleReminderExpBehavior(
+ @Named(UPTIME_NAME) Clock clock,
+ @Named(ASSIST_HANDLE_THREAD_NAME) Handler handler,
+ PhenotypeHelper phenotypeHelper,
+ Lazy<StatusBarStateController> statusBarStateController,
+ Lazy<ActivityManagerWrapper> activityManagerWrapper,
+ Lazy<OverviewProxyService> overviewProxyService,
+ Lazy<WakefulnessLifecycle> wakefulnessLifecycle,
+ Lazy<PackageManagerWrapper> packageManagerWrapper) {
+ mClock = clock;
mHandler = handler;
mPhenotypeHelper = phenotypeHelper;
- mStatusBarStateController = Dependency.get(StatusBarStateController.class);
- mActivityManagerWrapper = ActivityManagerWrapper.getInstance();
- mOverviewProxyService = Dependency.get(OverviewProxyService.class);
+ mStatusBarStateController = statusBarStateController;
+ mActivityManagerWrapper = activityManagerWrapper;
+ mOverviewProxyService = overviewProxyService;
+ mWakefulnessLifecycle = wakefulnessLifecycle;
+ mPackageManagerWrapper = packageManagerWrapper;
mDefaultHomeIntentFilter = new IntentFilter();
for (String action : DEFAULT_HOME_CHANGE_ACTIONS) {
mDefaultHomeIntentFilter.addAction(action);
@@ -167,13 +215,17 @@
mConsecutiveTaskSwitches = 0;
mDefaultHome = getCurrentDefaultHome();
context.registerReceiver(mDefaultHomeBroadcastReceiver, mDefaultHomeIntentFilter);
- mOnLockscreen = onLockscreen(mStatusBarStateController.getState());
- mIsDozing = mStatusBarStateController.isDozing();
- mStatusBarStateController.addCallback(mStatusBarStateListener);
- ActivityManager.RunningTaskInfo runningTaskInfo = mActivityManagerWrapper.getRunningTask();
+ mOnLockscreen = onLockscreen(mStatusBarStateController.get().getState());
+ mIsDozing = mStatusBarStateController.get().isDozing();
+ mStatusBarStateController.get().addCallback(mStatusBarStateListener);
+ ActivityManager.RunningTaskInfo runningTaskInfo =
+ mActivityManagerWrapper.get().getRunningTask();
mRunningTaskId = runningTaskInfo == null ? 0 : runningTaskInfo.taskId;
- mActivityManagerWrapper.registerTaskStackListener(mTaskStackChangeListener);
- mOverviewProxyService.addCallback(mOverviewProxyListener);
+ mActivityManagerWrapper.get().registerTaskStackListener(mTaskStackChangeListener);
+ mOverviewProxyService.get().addCallback(mOverviewProxyListener);
+ mIsAwake = mWakefulnessLifecycle.get().getWakefulness()
+ == WakefulnessLifecycle.WAKEFULNESS_AWAKE;
+ mWakefulnessLifecycle.get().addObserver(mWakefulnessLifecycleObserver);
mLearningTimeElapsed = Settings.Secure.getLong(
context.getContentResolver(), LEARNING_TIME_ELAPSED_KEY, /* default = */ 0);
@@ -181,7 +233,7 @@
context.getContentResolver(), LEARNING_EVENT_COUNT_KEY, /* default = */ 0);
mLearnedHintLastShownEpochDay = Settings.Secure.getLong(
context.getContentResolver(), LEARNED_HINT_LAST_SHOWN_KEY, /* default = */ 0);
- mLastLearningTimestamp = SystemClock.uptimeMillis();
+ mLastLearningTimestamp = mClock.currentTimeMillis();
callbackForCurrentState(/* justUnlocked = */ false);
}
@@ -196,9 +248,10 @@
Settings.Secure.putLong(mContext.getContentResolver(), LEARNED_HINT_LAST_SHOWN_KEY, 0);
mContext = null;
}
- mStatusBarStateController.removeCallback(mStatusBarStateListener);
- mActivityManagerWrapper.unregisterTaskStackListener(mTaskStackChangeListener);
- mOverviewProxyService.removeCallback(mOverviewProxyListener);
+ mStatusBarStateController.get().removeCallback(mStatusBarStateListener);
+ mActivityManagerWrapper.get().unregisterTaskStackListener(mTaskStackChangeListener);
+ mOverviewProxyService.get().removeCallback(mOverviewProxyListener);
+ mWakefulnessLifecycle.get().removeObserver(mWakefulnessLifecycleObserver);
}
@Override
@@ -211,15 +264,20 @@
mContext.getContentResolver(), LEARNING_EVENT_COUNT_KEY, ++mLearningCount);
}
- private static boolean isNavBarHidden(int sysuiStateFlags) {
- return (sysuiStateFlags & QuickStepContract.SYSUI_STATE_NAV_BAR_HIDDEN) != 0;
+ @Override
+ public void onAssistHandlesRequested() {
+ if (mAssistHandleCallbacks != null
+ && isFullyAwake()
+ && !mIsNavBarHidden
+ && !mOnLockscreen) {
+ mAssistHandleCallbacks.showAndGo();
+ }
}
@Nullable
- private static ComponentName getCurrentDefaultHome() {
+ private ComponentName getCurrentDefaultHome() {
List<ResolveInfo> homeActivities = new ArrayList<>();
- ComponentName defaultHome =
- PackageManagerWrapper.getInstance().getHomeActivities(homeActivities);
+ ComponentName defaultHome = mPackageManagerWrapper.get().getHomeActivities(homeActivities);
if (defaultHome != null) {
return defaultHome;
}
@@ -258,6 +316,16 @@
callbackForCurrentState(/* justUnlocked = */ false);
}
+ private void handleWakefullnessChanged(boolean isAwake) {
+ if (mIsAwake == isAwake) {
+ return;
+ }
+
+ resetConsecutiveTaskSwitches();
+ mIsAwake = isAwake;
+ callbackForCurrentState(/* justUnlocked = */ false);
+ }
+
private void handleTaskStackTopChanged(int taskId, @Nullable ComponentName taskComponentName) {
if (mRunningTaskId == taskId || taskComponentName == null) {
return;
@@ -275,7 +343,8 @@
}
private void handleSystemUiStateChanged(int sysuiStateFlags) {
- boolean isNavBarHidden = isNavBarHidden(sysuiStateFlags);
+ boolean isNavBarHidden =
+ (sysuiStateFlags & QuickStepContract.SYSUI_STATE_NAV_BAR_HIDDEN) != 0;
if (mIsNavBarHidden == isNavBarHidden) {
return;
}
@@ -310,7 +379,7 @@
return;
}
- if (mIsDozing || mIsNavBarHidden || mOnLockscreen || !getShowWhenTaught()) {
+ if (!isFullyAwake() || mIsNavBarHidden || mOnLockscreen || !getShowWhenTaught()) {
mAssistHandleCallbacks.hide();
} else if (justUnlocked) {
long currentEpochDay = LocalDate.now().toEpochDay();
@@ -332,7 +401,7 @@
return;
}
- if (mIsDozing || mIsNavBarHidden || isSuppressed()) {
+ if (!isFullyAwake() || mIsNavBarHidden || isSuppressed()) {
mAssistHandleCallbacks.hide();
} else if (mOnLockscreen) {
mAssistHandleCallbacks.showAndStay();
@@ -362,14 +431,15 @@
return;
}
- long currentTimestamp = SystemClock.uptimeMillis();
+ long currentTimestamp = mClock.currentTimeMillis();
mLearningTimeElapsed += currentTimestamp - mLastLearningTimestamp;
mLastLearningTimestamp = currentTimestamp;
- Settings.Secure.putLong(
- mContext.getContentResolver(), LEARNING_TIME_ELAPSED_KEY, mLearningTimeElapsed);
mIsLearned =
mLearningCount >= getLearningCount() || mLearningTimeElapsed >= getLearningTimeMs();
+
+ mHandler.post(() -> Settings.Secure.putLong(
+ mContext.getContentResolver(), LEARNING_TIME_ELAPSED_KEY, mLearningTimeElapsed));
}
private void resetConsecutiveTaskSwitches() {
@@ -382,6 +452,10 @@
mHandler.postDelayed(mResetConsecutiveTaskSwitches, getShowAndGoDelayResetTimeoutMs());
}
+ private boolean isFullyAwake() {
+ return mIsAwake && !mIsDozing;
+ }
+
private long getLearningTimeMs() {
return mPhenotypeHelper.getLong(
SystemUiDeviceConfigFlags.ASSIST_HANDLES_LEARN_TIME_MS,
@@ -441,6 +515,7 @@
pw.println(prefix + "Current AssistHandleReminderExpBehavior State:");
pw.println(prefix + " mOnLockscreen=" + mOnLockscreen);
pw.println(prefix + " mIsDozing=" + mIsDozing);
+ pw.println(prefix + " mIsAwake=" + mIsAwake);
pw.println(prefix + " mRunningTaskId=" + mRunningTaskId);
pw.println(prefix + " mDefaultHome=" + mDefaultHome);
pw.println(prefix + " mIsNavBarHidden=" + mIsNavBarHidden);
diff --git a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
index cf9c470..e502191 100644
--- a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
+++ b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
@@ -48,9 +48,13 @@
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
/**
* Class to manage everything related to assist in SystemUI.
*/
+@Singleton
public class AssistManager implements ConfigurationChangedReceiver {
/**
@@ -97,6 +101,8 @@
private static final String INVOCATION_TIME_MS_KEY = "invocation_time_ms";
private static final String INVOCATION_PHONE_STATE_KEY = "invocation_phone_state";
public static final String INVOCATION_TYPE_KEY = "invocation_type";
+ protected static final String ACTION_KEY = "action";
+ protected static final String SHOW_ASSIST_HANDLES_ACTION = "show_assist_handles";
public static final int INVOCATION_TYPE_GESTURE = 1;
public static final int INVOCATION_TYPE_ACTIVE_EDGE = 2;
@@ -147,15 +153,19 @@
}
};
- public AssistManager(DeviceProvisionedController controller, Context context) {
+ @Inject
+ public AssistManager(
+ DeviceProvisionedController controller,
+ Context context,
+ AssistUtils assistUtils,
+ AssistHandleBehaviorController handleController) {
mContext = context;
mDeviceProvisionedController = controller;
mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
- mAssistUtils = new AssistUtils(context);
+ mAssistUtils = assistUtils;
mAssistDisclosure = new AssistDisclosure(context, new Handler());
mPhoneStateMonitor = new PhoneStateMonitor(context);
- mHandleController =
- new AssistHandleBehaviorController(context, mAssistUtils, new Handler());
+ mHandleController = handleController;
registerVoiceInteractionSessionListener();
mInterestingConfigChanges = new InterestingConfigChanges(ActivityInfo.CONFIG_ORIENTATION
@@ -204,6 +214,9 @@
if (VERBOSE) {
Log.v(TAG, "UI hints received");
}
+ if (SHOW_ASSIST_HANDLES_ACTION.equals(hints.getString(ACTION_KEY))) {
+ requestAssistHandles();
+ }
}
});
}
@@ -277,6 +290,10 @@
mUiController.onGestureCompletion(velocity);
}
+ protected void requestAssistHandles() {
+ mHandleController.onAssistHandlesRequested();
+ }
+
public void hideAssist() {
mAssistUtils.hideCurrentSession();
}
diff --git a/packages/SystemUI/src/com/android/systemui/assist/AssistModule.java b/packages/SystemUI/src/com/android/systemui/assist/AssistModule.java
new file mode 100644
index 0000000..2a82d21
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/assist/AssistModule.java
@@ -0,0 +1,88 @@
+/*
+ * 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.
+ */
+
+package com.android.systemui.assist;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.SystemClock;
+
+import androidx.slice.Clock;
+
+import com.android.internal.app.AssistUtils;
+import com.android.systemui.ScreenDecorations;
+import com.android.systemui.SysUiServiceProvider;
+
+import java.util.EnumMap;
+import java.util.Map;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import dagger.Module;
+import dagger.Provides;
+
+/** Module for dagger injections related to the Assistant. */
+@Module
+public abstract class AssistModule {
+
+ static final String ASSIST_HANDLE_THREAD_NAME = "assist_handle_thread";
+ static final String UPTIME_NAME = "uptime";
+
+ @Provides
+ @Singleton
+ @Named(ASSIST_HANDLE_THREAD_NAME)
+ static Handler provideBackgroundHandler() {
+ final HandlerThread backgroundHandlerThread =
+ new HandlerThread("AssistHandleThread");
+ backgroundHandlerThread.start();
+ return backgroundHandlerThread.getThreadHandler();
+ }
+
+ @Provides
+ @Singleton
+ static Map<AssistHandleBehavior, AssistHandleBehaviorController.BehaviorController>
+ provideAssistHandleBehaviorControllerMap(
+ AssistHandleOffBehavior offBehavior,
+ AssistHandleLikeHomeBehavior likeHomeBehavior,
+ AssistHandleReminderExpBehavior reminderExpBehavior) {
+ Map<AssistHandleBehavior, AssistHandleBehaviorController.BehaviorController> map =
+ new EnumMap<>(AssistHandleBehavior.class);
+ map.put(AssistHandleBehavior.OFF, offBehavior);
+ map.put(AssistHandleBehavior.LIKE_HOME, likeHomeBehavior);
+ map.put(AssistHandleBehavior.REMINDER_EXP, reminderExpBehavior);
+ return map;
+ }
+
+ @Provides
+ static ScreenDecorations provideScreenDecorations(Context context) {
+ return SysUiServiceProvider.getComponent(context, ScreenDecorations.class);
+ }
+
+ @Provides
+ @Singleton
+ static AssistUtils provideAssistUtils(Context context) {
+ return new AssistUtils(context);
+ }
+
+ @Provides
+ @Singleton
+ @Named(UPTIME_NAME)
+ static Clock provideSystemClock() {
+ return SystemClock::uptimeMillis;
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/assist/PhenotypeHelper.java b/packages/SystemUI/src/com/android/systemui/assist/PhenotypeHelper.java
index b3f57af..ff76adf 100644
--- a/packages/SystemUI/src/com/android/systemui/assist/PhenotypeHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/assist/PhenotypeHelper.java
@@ -22,8 +22,18 @@
import java.util.concurrent.Executor;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+/**
+ * Wrapper class for retrieving phenotype flag values.
+ *
+ * Can be mocked in tests for ease of testing the effects of particular values.
+ */
+@Singleton
public class PhenotypeHelper {
+ @Inject
public PhenotypeHelper() {}
public long getLong(String name, long defaultValue) {
diff --git a/packages/SystemUI/src/com/android/systemui/assist/ui/InvocationLightsView.java b/packages/SystemUI/src/com/android/systemui/assist/ui/InvocationLightsView.java
index bc782a7..bb3bd78 100644
--- a/packages/SystemUI/src/com/android/systemui/assist/ui/InvocationLightsView.java
+++ b/packages/SystemUI/src/com/android/systemui/assist/ui/InvocationLightsView.java
@@ -100,7 +100,9 @@
int cornerRadiusBottom = DisplayUtils.getCornerRadiusBottom(context);
int cornerRadiusTop = DisplayUtils.getCornerRadiusTop(context);
- mViewHeight = Math.max(cornerRadiusBottom, cornerRadiusTop);
+ // ensure that height is non-zero even for square corners
+ mViewHeight = Math.max(Math.max(cornerRadiusBottom, cornerRadiusTop),
+ DisplayUtils.convertDpToPx(LIGHT_HEIGHT_DP, context));
final int dualToneDarkTheme = Utils.getThemeAttr(mContext, R.attr.darkIconTheme);
final int dualToneLightTheme = Utils.getThemeAttr(mContext, R.attr.lightIconTheme);
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BadgeRenderer.java b/packages/SystemUI/src/com/android/systemui/bubbles/BadgeRenderer.java
deleted file mode 100644
index 74ad0fa..0000000
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BadgeRenderer.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.systemui.bubbles;
-
-import static android.graphics.Paint.ANTI_ALIAS_FLAG;
-import static android.graphics.Paint.FILTER_BITMAP_FLAG;
-
-import android.content.Context;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Point;
-import android.graphics.Rect;
-import android.util.Log;
-
-import com.android.systemui.R;
-
-// XXX: Mostly opied from launcher code / can we share?
-/**
- * Contains parameters necessary to draw a badge for an icon (e.g. the size of the badge).
- */
-public class BadgeRenderer {
-
- private static final String TAG = "BadgeRenderer";
-
- /** The badge sizes are defined as percentages of the app icon size. */
- private static final float SIZE_PERCENTAGE = 0.38f;
-
- /** Extra scale down of the dot. */
- private static final float DOT_SCALE = 0.6f;
-
- private final float mDotCenterOffset;
- private final float mCircleRadius;
- private final Paint mCirclePaint = new Paint(ANTI_ALIAS_FLAG | FILTER_BITMAP_FLAG);
-
- public BadgeRenderer(Context context) {
- mDotCenterOffset = getDotCenterOffset(context);
- mCircleRadius = getDotRadius(mDotCenterOffset);
- }
-
- /** Space between the center of the dot and the top or left of the bubble stack. */
- static float getDotCenterOffset(Context context) {
- final int iconSizePx =
- context.getResources().getDimensionPixelSize(R.dimen.individual_bubble_size);
- return SIZE_PERCENTAGE * iconSizePx;
- }
-
- static float getDotRadius(float dotCenterOffset) {
- int size = (int) (DOT_SCALE * dotCenterOffset);
- return size / 2f;
- }
-
- /**
- * Draw a circle in the top right corner of the given bounds.
- *
- * @param color The color (based on the icon) to use for the badge.
- * @param iconBounds The bounds of the icon being badged.
- * @param badgeScale The progress of the animation, from 0 to 1.
- * @param spaceForOffset How much space to offset the badge up and to the left or right.
- * @param onLeft Whether the badge should be draw on left or right side.
- */
- public void draw(Canvas canvas, int color, Rect iconBounds, float badgeScale,
- Point spaceForOffset, boolean onLeft) {
- if (iconBounds == null) {
- Log.e(TAG, "Invalid null argument(s) passed in call to draw.");
- return;
- }
- canvas.save();
- // We draw the badge relative to its center.
- int x = onLeft ? iconBounds.left : iconBounds.right;
- float offset = onLeft ? (mDotCenterOffset / 2) : -(mDotCenterOffset / 2);
- float badgeCenterX = x + offset;
- float badgeCenterY = iconBounds.top + mDotCenterOffset / 2;
-
- canvas.translate(badgeCenterX + spaceForOffset.x, badgeCenterY - spaceForOffset.y);
-
- canvas.scale(badgeScale, badgeScale);
- mCirclePaint.setColor(color);
- canvas.drawCircle(0, 0, mCircleRadius, mCirclePaint);
- canvas.restore();
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BadgedImageView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BadgedImageView.java
index 783780f..c0053d1 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BadgedImageView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BadgedImageView.java
@@ -18,12 +18,13 @@
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
-import android.graphics.Point;
+import android.graphics.Path;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.ImageView;
import com.android.internal.graphics.ColorUtils;
+import com.android.launcher3.icons.DotRenderer;
import com.android.systemui.R;
/**
@@ -31,16 +32,19 @@
*/
public class BadgedImageView extends ImageView {
- private BadgeRenderer mDotRenderer;
- private int mIconSize;
private Rect mTempBounds = new Rect();
- private Point mTempPoint = new Point();
+ private DotRenderer mDotRenderer;
+ private DotRenderer.DrawParams mDrawParams;
+ private int mIconBitmapSize;
+ private int mDotColor;
private float mDotScale = 0f;
- private int mUpdateDotColor;
- private boolean mShowUpdateDot;
+ private boolean mShowDot;
private boolean mOnLeft;
+ /** Same as value in Launcher3 IconShape */
+ static final int DEFAULT_PATH_SIZE = 100;
+
public BadgedImageView(Context context) {
this(context, null);
}
@@ -56,69 +60,100 @@
public BadgedImageView(Context context, AttributeSet attrs, int defStyleAttr,
int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
- mIconSize = getResources().getDimensionPixelSize(R.dimen.individual_bubble_size);
- mDotRenderer = new BadgeRenderer(getContext());
+ mIconBitmapSize = getResources().getDimensionPixelSize(R.dimen.bubble_icon_bitmap_size);
+ mDrawParams = new DotRenderer.DrawParams();
TypedArray ta = context.obtainStyledAttributes(
- new int[] {android.R.attr.colorBackgroundFloating});
+ new int[]{android.R.attr.colorBackgroundFloating});
ta.recycle();
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
- if (mShowUpdateDot) {
- getDrawingRect(mTempBounds);
- mTempPoint.set((getWidth() - mIconSize) / 2, getPaddingTop());
- mDotRenderer.draw(canvas, mUpdateDotColor, mTempBounds, mDotScale, mTempPoint,
- mOnLeft);
+ if (!mShowDot) {
+ return;
}
+ getDrawingRect(mTempBounds);
+
+ mDrawParams.color = mDotColor;
+ mDrawParams.iconBounds = mTempBounds;
+ mDrawParams.leftAlign = mOnLeft;
+ mDrawParams.scale = mDotScale;
+
+ if (mDotRenderer == null) {
+ Path circlePath = new Path();
+ float radius = DEFAULT_PATH_SIZE * 0.5f;
+ circlePath.addCircle(radius /* x */, radius /* y */, radius, Path.Direction.CW);
+ mDotRenderer = new DotRenderer(mIconBitmapSize, circlePath, DEFAULT_PATH_SIZE);
+ }
+ mDotRenderer.draw(canvas, mDrawParams);
}
/**
* Set whether the dot should appear on left or right side of the view.
*/
- public void setDotPosition(boolean onLeft) {
+ void setDotOnLeft(boolean onLeft) {
mOnLeft = onLeft;
invalidate();
}
- public boolean getDotPosition() {
+ boolean getDotOnLeft() {
return mOnLeft;
}
/**
* Set whether the dot should show or not.
*/
- public void setShowDot(boolean showBadge) {
- mShowUpdateDot = showBadge;
+ void setShowDot(boolean showDot) {
+ mShowDot = showDot;
invalidate();
}
/**
* @return whether the dot is being displayed.
*/
- public boolean isShowingDot() {
- return mShowUpdateDot;
+ boolean isShowingDot() {
+ return mShowDot;
}
/**
* The colour to use for the dot.
*/
public void setDotColor(int color) {
- mUpdateDotColor = ColorUtils.setAlphaComponent(color, 255 /* alpha */);
+ mDotColor = ColorUtils.setAlphaComponent(color, 255 /* alpha */);
+ invalidate();
+ }
+
+ /**
+ * @param iconPath The new icon path to use when calculating dot position.
+ */
+ public void drawDot(Path iconPath) {
+ mDotRenderer = new DotRenderer(mIconBitmapSize, iconPath, DEFAULT_PATH_SIZE);
invalidate();
}
/**
* How big the dot should be, fraction from 0 to 1.
*/
- public void setDotScale(float fraction) {
+ void setDotScale(float fraction) {
mDotScale = fraction;
invalidate();
}
- public float getDotScale() {
- return mDotScale;
+ /**
+ * Return dot position relative to bubble view container bounds.
+ */
+ float[] getDotCenter() {
+ float[] dotPosition;
+ if (mOnLeft) {
+ dotPosition = mDotRenderer.getLeftDotPosition();
+ } else {
+ dotPosition = mDotRenderer.getRightDotPosition();
+ }
+ getDrawingRect(mTempBounds);
+ float dotCenterX = mTempBounds.width() * dotPosition[0];
+ float dotCenterY = mTempBounds.height() * dotPosition[1];
+ return new float[]{dotCenterX, dotCenterY};
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java b/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java
index 5c6c397..c3cee35 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java
@@ -20,38 +20,67 @@
import static com.android.internal.annotations.VisibleForTesting.Visibility.PRIVATE;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.app.Notification;
+import android.app.PendingIntent;
import android.content.Context;
+import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
+import android.content.res.Resources;
+import android.graphics.drawable.Drawable;
+import android.os.Parcelable;
import android.os.UserHandle;
+import android.provider.Settings;
+import android.text.TextUtils;
+import android.util.Log;
import android.view.LayoutInflater;
import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.R;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+import java.util.List;
import java.util.Objects;
/**
* Encapsulates the data and UI elements of a bubble.
*/
class Bubble {
-
- private static final boolean DEBUG = false;
private static final String TAG = "Bubble";
+ private NotificationEntry mEntry;
private final String mKey;
private final String mGroupId;
private String mAppName;
- private final BubbleExpandedView.OnBubbleBlockedListener mListener;
+ private Drawable mUserBadgedAppIcon;
private boolean mInflated;
- public NotificationEntry entry;
- BubbleView iconView;
- BubbleExpandedView expandedView;
+ private BubbleView mIconView;
+ private BubbleExpandedView mExpandedView;
+
private long mLastUpdated;
private long mLastAccessed;
- private PackageManager mPm;
+ private boolean mIsRemoved;
+
+ /**
+ * Whether this notification should be shown in the shade when it is also displayed as a bubble.
+ *
+ * <p>When a notification is a bubble we don't show it in the shade once the bubble has been
+ * expanded</p>
+ */
+ private boolean mShowInShadeWhenBubble = true;
+
+ /**
+ * Whether the bubble should show a dot for the notification indicating updated content.
+ */
+ private boolean mShowBubbleUpdateDot = true;
+
+ /** Whether flyout text should be suppressed, regardless of any other flags or state. */
+ private boolean mSuppressFlyout;
public static String groupId(NotificationEntry entry) {
UserHandle user = entry.notification.getUser();
@@ -61,31 +90,27 @@
/** Used in tests when no UI is required. */
@VisibleForTesting(visibility = PRIVATE)
Bubble(Context context, NotificationEntry e) {
- this (context, e, null);
- }
-
- Bubble(Context context, NotificationEntry e,
- BubbleExpandedView.OnBubbleBlockedListener listener) {
- entry = e;
+ mEntry = e;
mKey = e.key;
mLastUpdated = e.notification.getPostTime();
mGroupId = groupId(e);
- mListener = listener;
- mPm = context.getPackageManager();
+ PackageManager pm = context.getPackageManager();
ApplicationInfo info;
try {
- info = mPm.getApplicationInfo(
- entry.notification.getPackageName(),
+ info = pm.getApplicationInfo(
+ mEntry.notification.getPackageName(),
PackageManager.MATCH_UNINSTALLED_PACKAGES
| PackageManager.MATCH_DISABLED_COMPONENTS
| PackageManager.MATCH_DIRECT_BOOT_UNAWARE
| PackageManager.MATCH_DIRECT_BOOT_AWARE);
if (info != null) {
- mAppName = String.valueOf(mPm.getApplicationLabel(info));
+ mAppName = String.valueOf(pm.getApplicationLabel(info));
}
+ Drawable appIcon = pm.getApplicationIcon(mEntry.notification.getPackageName());
+ mUserBadgedAppIcon = pm.getUserBadgedIcon(appIcon, mEntry.notification.getUser());
} catch (PackageManager.NameNotFoundException unused) {
- mAppName = entry.notification.getPackageName();
+ mAppName = mEntry.notification.getPackageName();
}
}
@@ -93,12 +118,16 @@
return mKey;
}
+ public NotificationEntry getEntry() {
+ return mEntry;
+ }
+
public String getGroupId() {
return mGroupId;
}
public String getPackageName() {
- return entry.notification.getPackageName();
+ return mEntry.notification.getPackageName();
}
public String getAppName() {
@@ -109,9 +138,23 @@
return mInflated;
}
- public void updateDotVisibility() {
- if (iconView != null) {
- iconView.updateDotVisibility(true /* animate */);
+ void updateDotVisibility() {
+ if (mIconView != null) {
+ mIconView.updateDotVisibility(true /* animate */);
+ }
+ }
+
+ BubbleView getIconView() {
+ return mIconView;
+ }
+
+ BubbleExpandedView getExpandedView() {
+ return mExpandedView;
+ }
+
+ void cleanupExpandedState() {
+ if (mExpandedView != null) {
+ mExpandedView.cleanUpExpandedState();
}
}
@@ -119,14 +162,14 @@
if (mInflated) {
return;
}
- iconView = (BubbleView) inflater.inflate(
+ mIconView = (BubbleView) inflater.inflate(
R.layout.bubble_view, stackView, false /* attachToRoot */);
- iconView.setNotif(entry);
+ mIconView.setBubble(this);
+ mIconView.setAppIcon(mUserBadgedAppIcon);
- expandedView = (BubbleExpandedView) inflater.inflate(
+ mExpandedView = (BubbleExpandedView) inflater.inflate(
R.layout.bubble_expanded_view, stackView, false /* attachToRoot */);
- expandedView.setEntry(entry, stackView, mAppName);
- expandedView.setOnBlockedListener(mListener);
+ mExpandedView.setBubble(this, stackView, mAppName);
mInflated = true;
}
@@ -140,46 +183,38 @@
* and setting {@code false} actually means rendering the expanded view in transparent.
*/
void setContentVisibility(boolean visibility) {
- if (expandedView != null) {
- expandedView.setContentVisibility(visibility);
+ if (mExpandedView != null) {
+ mExpandedView.setContentVisibility(visibility);
}
}
- void setDismissed() {
- entry.setBubbleDismissed(true);
- // TODO: move this somewhere where it can be guaranteed not to run until safe from flicker
- if (expandedView != null) {
- expandedView.cleanUpExpandedState();
- }
- }
-
- void setEntry(NotificationEntry entry) {
- this.entry = entry;
+ void updateEntry(NotificationEntry entry) {
+ mEntry = entry;
mLastUpdated = entry.notification.getPostTime();
if (mInflated) {
- iconView.update(entry);
- expandedView.update(entry);
+ mIconView.update(this);
+ mExpandedView.update(this);
}
}
/**
* @return the newer of {@link #getLastUpdateTime()} and {@link #getLastAccessTime()}
*/
- public long getLastActivity() {
+ long getLastActivity() {
return Math.max(mLastUpdated, mLastAccessed);
}
/**
* @return the timestamp in milliseconds of the most recent notification entry for this bubble
*/
- public long getLastUpdateTime() {
+ long getLastUpdateTime() {
return mLastUpdated;
}
/**
* @return the timestamp in milliseconds when this bubble was last displayed in expanded state
*/
- public long getLastAccessTime() {
+ long getLastAccessTime() {
return mLastAccessed;
}
@@ -187,7 +222,7 @@
* @return the display id of the virtual display on which bubble contents is drawn.
*/
int getDisplayId() {
- return expandedView != null ? expandedView.getVirtualDisplayId() : INVALID_DISPLAY;
+ return mExpandedView != null ? mExpandedView.getVirtualDisplayId() : INVALID_DISPLAY;
}
/**
@@ -195,14 +230,204 @@
*/
void markAsAccessedAt(long lastAccessedMillis) {
mLastAccessed = lastAccessedMillis;
- entry.setShowInShadeWhenBubble(false);
+ setShowInShadeWhenBubble(false);
+ setShowBubbleDot(false);
}
/**
- * @return whether bubble is from a notification associated with a foreground service.
+ * Whether this notification should be shown in the shade when it is also displayed as a
+ * bubble.
*/
- public boolean isOngoing() {
- return entry.isForegroundService();
+ boolean showInShadeWhenBubble() {
+ return !mEntry.isRowDismissed() && !shouldSuppressNotification()
+ && (!mEntry.isClearable() || mShowInShadeWhenBubble);
+ }
+
+ /**
+ * Sets whether this notification should be shown in the shade when it is also displayed as a
+ * bubble.
+ */
+ void setShowInShadeWhenBubble(boolean showInShade) {
+ mShowInShadeWhenBubble = showInShade;
+ }
+
+ /**
+ * Sets whether the bubble for this notification should show a dot indicating updated content.
+ */
+ void setShowBubbleDot(boolean showDot) {
+ mShowBubbleUpdateDot = showDot;
+ }
+
+ /**
+ * Whether the bubble for this notification should show a dot indicating updated content.
+ */
+ boolean showBubbleDot() {
+ return mShowBubbleUpdateDot && !mEntry.shouldSuppressNotificationDot();
+ }
+
+ /**
+ * Whether the flyout for the bubble should be shown.
+ */
+ boolean showFlyoutForBubble() {
+ return !mSuppressFlyout && !mEntry.shouldSuppressPeek()
+ && !mEntry.shouldSuppressNotificationList();
+ }
+
+ /**
+ * Set whether the flyout text for the bubble should be shown when an update is received.
+ *
+ * @param suppressFlyout whether the flyout text is shown
+ */
+ void setSuppressFlyout(boolean suppressFlyout) {
+ mSuppressFlyout = suppressFlyout;
+ }
+
+ /**
+ * Returns whether the notification for this bubble is a foreground service. It shows that this
+ * is an ongoing bubble.
+ */
+ boolean isOngoing() {
+ int flags = mEntry.notification.getNotification().flags;
+ return (flags & Notification.FLAG_FOREGROUND_SERVICE) != 0;
+ }
+
+ float getDesiredHeight(Context context) {
+ Notification.BubbleMetadata data = mEntry.getBubbleMetadata();
+ boolean useRes = data.getDesiredHeightResId() != 0;
+ if (useRes) {
+ return getDimenForPackageUser(context, data.getDesiredHeightResId(),
+ mEntry.notification.getPackageName(),
+ mEntry.notification.getUser().getIdentifier());
+ } else {
+ return data.getDesiredHeight()
+ * context.getResources().getDisplayMetrics().density;
+ }
+ }
+
+ String getDesiredHeightString() {
+ Notification.BubbleMetadata data = mEntry.getBubbleMetadata();
+ boolean useRes = data.getDesiredHeightResId() != 0;
+ if (useRes) {
+ return String.valueOf(data.getDesiredHeightResId());
+ } else {
+ return String.valueOf(data.getDesiredHeight());
+ }
+ }
+
+ @Nullable
+ PendingIntent getBubbleIntent(Context context) {
+ Notification notif = mEntry.notification.getNotification();
+ Notification.BubbleMetadata data = notif.getBubbleMetadata();
+ if (BubbleController.canLaunchInActivityView(context, mEntry) && data != null) {
+ return data.getIntent();
+ }
+ return null;
+ }
+
+ Intent getSettingsIntent() {
+ final Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_BUBBLE_SETTINGS);
+ intent.putExtra(Settings.EXTRA_APP_PACKAGE, getPackageName());
+ intent.putExtra(Settings.EXTRA_APP_UID, mEntry.notification.getUid());
+ intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
+ return intent;
+ }
+
+ /**
+ * Returns our best guess for the most relevant text summary of the latest update to this
+ * notification, based on its type. Returns null if there should not be an update message.
+ */
+ CharSequence getUpdateMessage(Context context) {
+ final Notification underlyingNotif = mEntry.notification.getNotification();
+ final Class<? extends Notification.Style> style = underlyingNotif.getNotificationStyle();
+
+ try {
+ if (Notification.BigTextStyle.class.equals(style)) {
+ // Return the big text, it is big so probably important. If it's not there use the
+ // normal text.
+ CharSequence bigText =
+ underlyingNotif.extras.getCharSequence(Notification.EXTRA_BIG_TEXT);
+ return !TextUtils.isEmpty(bigText)
+ ? bigText
+ : underlyingNotif.extras.getCharSequence(Notification.EXTRA_TEXT);
+ } else if (Notification.MessagingStyle.class.equals(style)) {
+ final List<Notification.MessagingStyle.Message> messages =
+ Notification.MessagingStyle.Message.getMessagesFromBundleArray(
+ (Parcelable[]) underlyingNotif.extras.get(
+ Notification.EXTRA_MESSAGES));
+
+ final Notification.MessagingStyle.Message latestMessage =
+ Notification.MessagingStyle.findLatestIncomingMessage(messages);
+
+ if (latestMessage != null) {
+ final CharSequence personName = latestMessage.getSenderPerson() != null
+ ? latestMessage.getSenderPerson().getName()
+ : null;
+
+ // Prepend the sender name if available since group chats also use messaging
+ // style.
+ if (!TextUtils.isEmpty(personName)) {
+ return context.getResources().getString(
+ R.string.notification_summary_message_format,
+ personName,
+ latestMessage.getText());
+ } else {
+ return latestMessage.getText();
+ }
+ }
+ } else if (Notification.InboxStyle.class.equals(style)) {
+ CharSequence[] lines =
+ underlyingNotif.extras.getCharSequenceArray(Notification.EXTRA_TEXT_LINES);
+
+ // Return the last line since it should be the most recent.
+ if (lines != null && lines.length > 0) {
+ return lines[lines.length - 1];
+ }
+ } else if (Notification.MediaStyle.class.equals(style)) {
+ // Return nothing, media updates aren't typically useful as a text update.
+ return null;
+ } else {
+ // Default to text extra.
+ return underlyingNotif.extras.getCharSequence(Notification.EXTRA_TEXT);
+ }
+ } catch (ClassCastException | NullPointerException | ArrayIndexOutOfBoundsException e) {
+ // No use crashing, we'll just return null and the caller will assume there's no update
+ // message.
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ private int getDimenForPackageUser(Context context, int resId, String pkg, int userId) {
+ PackageManager pm = context.getPackageManager();
+ Resources r;
+ if (pkg != null) {
+ try {
+ if (userId == UserHandle.USER_ALL) {
+ userId = UserHandle.USER_SYSTEM;
+ }
+ r = pm.getResourcesForApplicationAsUser(pkg, userId);
+ return r.getDimensionPixelSize(resId);
+ } catch (PackageManager.NameNotFoundException ex) {
+ // Uninstalled, don't care
+ } catch (Resources.NotFoundException e) {
+ // Invalid res id, return 0 and user our default
+ Log.e(TAG, "Couldn't find desired height res id", e);
+ }
+ }
+ return 0;
+ }
+
+ private boolean shouldSuppressNotification() {
+ return mEntry.getBubbleMetadata() != null
+ && mEntry.getBubbleMetadata().isNotificationSuppressed();
+ }
+
+ boolean shouldAutoExpand() {
+ Notification.BubbleMetadata metadata = mEntry.getBubbleMetadata();
+ return metadata != null && metadata.getAutoExpandBubble();
}
@Override
@@ -210,6 +435,20 @@
return "Bubble{" + mKey + '}';
}
+ /**
+ * Description of current bubble state.
+ */
+ public void dump(
+ @NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) {
+ pw.print("key: "); pw.println(mKey);
+ pw.print(" showInShade: "); pw.println(showInShadeWhenBubble());
+ pw.print(" showDot: "); pw.println(showBubbleDot());
+ pw.print(" showFlyout: "); pw.println(showFlyoutForBubble());
+ pw.print(" desiredHeight: "); pw.println(getDesiredHeightString());
+ pw.print(" suppressNotif: "); pw.println(shouldSuppressNotification());
+ pw.print(" autoExpand: "); pw.println(shouldAutoExpand());
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
index a23c99e..3cc91de 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
@@ -16,21 +16,24 @@
package com.android.systemui.bubbles;
+import static android.app.Notification.FLAG_AUTOGROUP_SUMMARY;
import static android.app.Notification.FLAG_BUBBLE;
-import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_BADGE;
-import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST;
-import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK;
import static android.content.pm.ActivityInfo.DOCUMENT_LAUNCH_ALWAYS;
import static android.service.notification.NotificationListenerService.REASON_APP_CANCEL;
import static android.service.notification.NotificationListenerService.REASON_APP_CANCEL_ALL;
import static android.service.notification.NotificationListenerService.REASON_CANCEL;
import static android.service.notification.NotificationListenerService.REASON_CANCEL_ALL;
+import static android.service.notification.NotificationListenerService.REASON_CLICK;
+import static android.service.notification.NotificationListenerService.REASON_GROUP_SUMMARY_CANCELED;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
+import static com.android.systemui.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_CONTROLLER;
+import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_BUBBLES;
+import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.systemui.statusbar.StatusBarState.SHADE;
import static com.android.systemui.statusbar.notification.NotificationEntryManager.UNDEFINED_DISMISS_REASON;
@@ -39,9 +42,8 @@
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.SOURCE;
-import android.app.ActivityManager;
+import android.annotation.UserIdInt;
import android.app.ActivityManager.RunningTaskInfo;
-import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
@@ -53,10 +55,11 @@
import android.os.ServiceManager;
import android.provider.Settings;
import android.service.notification.NotificationListenerService.RankingMap;
-import android.service.notification.StatusBarNotification;
import android.service.notification.ZenModeConfig;
+import android.util.ArraySet;
import android.util.Log;
import android.util.Pair;
+import android.util.SparseSetArray;
import android.view.Display;
import android.view.IPinnedStackController;
import android.view.IPinnedStackListener;
@@ -75,18 +78,23 @@
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.TaskStackChangeListener;
import com.android.systemui.shared.system.WindowManagerWrapper;
+import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationRemoveInterceptor;
import com.android.systemui.statusbar.notification.NotificationEntryListener;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider;
+import com.android.systemui.statusbar.notification.collection.NotificationData;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
-import com.android.systemui.statusbar.notification.row.NotificationContentInflater.InflationFlag;
+import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.phone.StatusBarWindowController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.ZenModeController;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
@@ -101,12 +109,12 @@
@Singleton
public class BubbleController implements ConfigurationController.ConfigurationListener {
- private static final String TAG = "BubbleController";
- private static final boolean DEBUG = false;
+ private static final String TAG = TAG_WITH_CLASS_NAME ? "BubbleController" : TAG_BUBBLES;
@Retention(SOURCE)
@IntDef({DISMISS_USER_GESTURE, DISMISS_AGED, DISMISS_TASK_FINISHED, DISMISS_BLOCKED,
- DISMISS_NOTIF_CANCEL, DISMISS_ACCESSIBILITY_ACTION, DISMISS_NO_LONGER_BUBBLE})
+ DISMISS_NOTIF_CANCEL, DISMISS_ACCESSIBILITY_ACTION, DISMISS_NO_LONGER_BUBBLE,
+ DISMISS_USER_CHANGED, DISMISS_GROUP_CANCELLED, DISMISS_INVALID_INTENT})
@Target({FIELD, LOCAL_VARIABLE, PARAMETER})
@interface DismissReason {}
@@ -117,24 +125,14 @@
static final int DISMISS_NOTIF_CANCEL = 5;
static final int DISMISS_ACCESSIBILITY_ACTION = 6;
static final int DISMISS_NO_LONGER_BUBBLE = 7;
+ static final int DISMISS_USER_CHANGED = 8;
+ static final int DISMISS_GROUP_CANCELLED = 9;
+ static final int DISMISS_INVALID_INTENT = 10;
public static final int MAX_BUBBLES = 5; // TODO: actually enforce this
- // Enables some subset of notifs to automatically become bubbles
- public static final boolean DEBUG_ENABLE_AUTO_BUBBLE = false;
-
/** Flag to enable or disable the entire feature */
private static final String ENABLE_BUBBLES = "experiment_enable_bubbles";
- /** Auto bubble flags set whether different notif types should be presented as a bubble */
- private static final String ENABLE_AUTO_BUBBLE_MESSAGES = "experiment_autobubble_messaging";
- private static final String ENABLE_AUTO_BUBBLE_ONGOING = "experiment_autobubble_ongoing";
- private static final String ENABLE_AUTO_BUBBLE_ALL = "experiment_autobubble_all";
-
- /** Use an activityView for an auto-bubbled notifs if it has an appropriate content intent */
- private static final String ENABLE_BUBBLE_CONTENT_INTENT = "experiment_bubble_content_intent";
-
- private static final String BUBBLE_STIFFNESS = "experiment_bubble_stiffness";
- private static final String BUBBLE_BOUNCINESS = "experiment_bubble_bounciness";
private final Context mContext;
private final NotificationEntryManager mNotificationEntryManager;
@@ -142,10 +140,16 @@
private BubbleStateChangeListener mStateChangeListener;
private BubbleExpandListener mExpandListener;
@Nullable private BubbleStackView.SurfaceSynchronizer mSurfaceSynchronizer;
+ private final NotificationGroupManager mNotificationGroupManager;
private BubbleData mBubbleData;
@Nullable private BubbleStackView mStackView;
+ // Tracks the id of the current (foreground) user.
+ private int mCurrentUserId;
+ // Saves notification keys of active bubbles when users are switched.
+ private final SparseSetArray<String> mSavedBubbleKeysPerUser;
+
// Bubbles get added to the status bar view
private final StatusBarWindowController mStatusBarWindowController;
private final ZenModeController mZenModeController;
@@ -157,6 +161,9 @@
// Used for determining view rect for touch interaction
private Rect mTempRect = new Rect();
+ // Listens to user switch so bubbles can be saved and restored.
+ private final NotificationLockscreenUserManager mNotifUserManager;
+
/** Last known orientation, used to detect orientation changes in {@link #onConfigChanged}. */
private int mOrientation = Configuration.ORIENTATION_UNDEFINED;
@@ -211,28 +218,38 @@
public BubbleController(Context context, StatusBarWindowController statusBarWindowController,
BubbleData data, ConfigurationController configurationController,
NotificationInterruptionStateProvider interruptionStateProvider,
- ZenModeController zenModeController) {
+ ZenModeController zenModeController,
+ NotificationLockscreenUserManager notifUserManager,
+ NotificationGroupManager groupManager) {
this(context, statusBarWindowController, data, null /* synchronizer */,
- configurationController, interruptionStateProvider, zenModeController);
+ configurationController, interruptionStateProvider, zenModeController,
+ notifUserManager, groupManager);
}
public BubbleController(Context context, StatusBarWindowController statusBarWindowController,
BubbleData data, @Nullable BubbleStackView.SurfaceSynchronizer synchronizer,
ConfigurationController configurationController,
NotificationInterruptionStateProvider interruptionStateProvider,
- ZenModeController zenModeController) {
+ ZenModeController zenModeController,
+ NotificationLockscreenUserManager notifUserManager,
+ NotificationGroupManager groupManager) {
mContext = context;
mNotificationInterruptionStateProvider = interruptionStateProvider;
+ mNotifUserManager = notifUserManager;
mZenModeController = zenModeController;
mZenModeController.addCallback(new ZenModeController.Callback() {
@Override
public void onZenChanged(int zen) {
- updateStackViewForZenConfig();
+ if (mStackView != null) {
+ mStackView.updateDots();
+ }
}
@Override
public void onConfigChanged(ZenModeConfig config) {
- updateStackViewForZenConfig();
+ if (mStackView != null) {
+ mStackView.updateDots();
+ }
}
});
@@ -244,6 +261,24 @@
mNotificationEntryManager = Dependency.get(NotificationEntryManager.class);
mNotificationEntryManager.addNotificationEntryListener(mEntryListener);
mNotificationEntryManager.setNotificationRemoveInterceptor(mRemoveInterceptor);
+ mNotificationGroupManager = groupManager;
+ mNotificationGroupManager.addOnGroupChangeListener(
+ new NotificationGroupManager.OnGroupChangeListener() {
+ @Override
+ public void onGroupSuppressionChanged(
+ NotificationGroupManager.NotificationGroup group,
+ boolean suppressed) {
+ // More notifications could be added causing summary to no longer
+ // be suppressed -- in this case need to remove the key.
+ final String groupKey = group.summary != null
+ ? group.summary.notification.getGroupKey()
+ : null;
+ if (!suppressed && groupKey != null
+ && mBubbleData.isSummarySuppressed(groupKey)) {
+ mBubbleData.removeSuppressedSummary(groupKey);
+ }
+ }
+ });
mStatusBarWindowController = statusBarWindowController;
mStatusBarStateListener = new StatusBarStateListener();
@@ -261,6 +296,16 @@
mBarService = IStatusBarService.Stub.asInterface(
ServiceManager.getService(Context.STATUS_BAR_SERVICE));
+
+ mSavedBubbleKeysPerUser = new SparseSetArray<>();
+ mCurrentUserId = mNotifUserManager.getCurrentUserId();
+ mNotifUserManager.addUserChangedListener(
+ newUserId -> {
+ saveBubbles(mCurrentUserId);
+ mBubbleData.dismissAll(DISMISS_USER_CHANGED);
+ restoreBubbles(newUserId);
+ mCurrentUserId = newUserId;
+ });
}
/**
@@ -271,19 +316,55 @@
if (mStackView == null) {
mStackView = new BubbleStackView(mContext, mBubbleData, mSurfaceSynchronizer);
ViewGroup sbv = mStatusBarWindowController.getStatusBarView();
- // TODO(b/130237686): When you expand the shade on top of expanded bubble, there is no
- // scrim between bubble and the shade
- int bubblePosition = sbv.indexOfChild(sbv.findViewById(R.id.scrim_behind)) + 1;
- sbv.addView(mStackView, bubblePosition,
+ int bubbleScrimIndex = sbv.indexOfChild(sbv.findViewById(R.id.scrim_for_bubble));
+ int stackIndex = bubbleScrimIndex + 1; // Show stack above bubble scrim.
+ sbv.addView(mStackView, stackIndex,
new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
if (mExpandListener != null) {
mStackView.setExpandListener(mExpandListener);
}
-
- updateStackViewForZenConfig();
}
}
+ /**
+ * Records the notification key for any active bubbles. These are used to restore active
+ * bubbles when the user returns to the foreground.
+ *
+ * @param userId the id of the user
+ */
+ private void saveBubbles(@UserIdInt int userId) {
+ // First clear any existing keys that might be stored.
+ mSavedBubbleKeysPerUser.remove(userId);
+ // Add in all active bubbles for the current user.
+ for (Bubble bubble: mBubbleData.getBubbles()) {
+ mSavedBubbleKeysPerUser.add(userId, bubble.getKey());
+ }
+ }
+
+ /**
+ * Promotes existing notifications to Bubbles if they were previously bubbles.
+ *
+ * @param userId the id of the user
+ */
+ private void restoreBubbles(@UserIdInt int userId) {
+ NotificationData notificationData =
+ mNotificationEntryManager.getNotificationData();
+ ArraySet<String> savedBubbleKeys = mSavedBubbleKeysPerUser.get(userId);
+ if (savedBubbleKeys == null) {
+ // There were no bubbles saved for this used.
+ return;
+ }
+ for (NotificationEntry e : notificationData.getNotificationsForCurrentUser()) {
+ if (savedBubbleKeys.contains(e.key)
+ && mNotificationInterruptionStateProvider.shouldBubbleUp(e)
+ && canLaunchInActivityView(mContext, e)) {
+ updateBubble(e, /* suppressFlyout= */ true);
+ }
+ }
+ // Finally, remove the entries for this user now that bubbles are restored.
+ mSavedBubbleKeysPerUser.remove(mCurrentUserId);
+ }
+
@Override
public void onUiModeChanged() {
if (mStackView != null) {
@@ -301,8 +382,8 @@
@Override
public void onConfigChanged(Configuration newConfig) {
if (mStackView != null && newConfig != null && newConfig.orientation != mOrientation) {
- mStackView.onOrientationChanged();
mOrientation = newConfig.orientation;
+ mStackView.onOrientationChanged(newConfig.orientation);
}
}
@@ -360,6 +441,25 @@
mBubbleData.setExpanded(false /* expanded */);
}
+ /**
+ * True if either:
+ * (1) There is a bubble associated with the provided key and if its notification is hidden
+ * from the shade.
+ * (2) There is a group summary associated with the provided key that is hidden from the shade
+ * because it has been dismissed but still has child bubbles active.
+ *
+ * False otherwise.
+ */
+ public boolean isBubbleNotificationSuppressedFromShade(String key) {
+ boolean isBubbleAndSuppressed = mBubbleData.hasBubbleWithKey(key)
+ && !mBubbleData.getBubbleWithKey(key).showInShadeWhenBubble();
+ NotificationEntry entry = mNotificationEntryManager.getNotificationData().get(key);
+ String groupKey = entry != null ? entry.notification.getGroupKey() : null;
+ boolean isSuppressedSummary = mBubbleData.isSummarySuppressed(groupKey);
+ boolean isSummary = key.equals(mBubbleData.getSummaryKey(groupKey));
+ return (isSummary && isSuppressedSummary) || isBubbleAndSuppressed;
+ }
+
void selectBubble(Bubble bubble) {
mBubbleData.setSelectedBubble(bubble);
}
@@ -406,11 +506,15 @@
* @param notif the notification associated with this bubble.
*/
void updateBubble(NotificationEntry notif) {
+ updateBubble(notif, /* supressFlyout */ false);
+ }
+
+ void updateBubble(NotificationEntry notif, boolean suppressFlyout) {
// If this is an interruptive notif, mark that it's interrupted
if (notif.importance >= NotificationManager.IMPORTANCE_HIGH) {
notif.setInterruption();
}
- mBubbleData.notificationEntryUpdated(notif);
+ mBubbleData.notificationEntryUpdated(notif, suppressFlyout);
}
/**
@@ -423,7 +527,7 @@
// TEMP: refactor to change this to pass entry
Bubble bubble = mBubbleData.getBubbleWithKey(key);
if (bubble != null) {
- mBubbleData.notificationEntryRemoved(bubble.entry, reason);
+ mBubbleData.notificationEntryRemoved(bubble.getEntry(), reason);
}
}
@@ -432,33 +536,50 @@
new NotificationRemoveInterceptor() {
@Override
public boolean onNotificationRemoveRequested(String key, int reason) {
- if (!mBubbleData.hasBubbleWithKey(key)) {
+ NotificationEntry entry = mNotificationEntryManager.getNotificationData().get(key);
+ String groupKey = entry != null ? entry.notification.getGroupKey() : null;
+ ArrayList<Bubble> bubbleChildren = mBubbleData.getBubblesInGroup(groupKey);
+
+ boolean inBubbleData = mBubbleData.hasBubbleWithKey(key);
+ boolean isSuppressedSummary = (mBubbleData.isSummarySuppressed(groupKey)
+ && mBubbleData.getSummaryKey(groupKey).equals(key));
+ boolean isSummary = entry != null
+ && entry.notification.getNotification().isGroupSummary();
+ boolean isSummaryOfBubbles = (isSuppressedSummary || isSummary)
+ && bubbleChildren != null && !bubbleChildren.isEmpty();
+
+ if (!inBubbleData && !isSummaryOfBubbles) {
return false;
}
- NotificationEntry entry = mBubbleData.getBubbleWithKey(key).entry;
final boolean isClearAll = reason == REASON_CANCEL_ALL;
- final boolean isUserDimiss = reason == REASON_CANCEL;
+ final boolean isUserDimiss = reason == REASON_CANCEL || reason == REASON_CLICK;
final boolean isAppCancel = reason == REASON_APP_CANCEL
|| reason == REASON_APP_CANCEL_ALL;
+ final boolean isSummaryCancel = reason == REASON_GROUP_SUMMARY_CANCELED;
// Need to check for !appCancel here because the notification may have
// previously been dismissed & entry.isRowDismissed would still be true
- boolean userRemovedNotif = (entry.isRowDismissed() && !isAppCancel)
- || isClearAll || isUserDimiss;
+ boolean userRemovedNotif = (entry != null && entry.isRowDismissed() && !isAppCancel)
+ || isClearAll || isUserDimiss || isSummaryCancel;
+
+ if (isSummaryOfBubbles) {
+ return handleSummaryRemovalInterception(entry, userRemovedNotif);
+ }
// The bubble notification sticks around in the data as long as the bubble is
// not dismissed and the app hasn't cancelled the notification.
- boolean bubbleExtended = entry.isBubble() && !entry.isBubbleDismissed()
- && userRemovedNotif;
+ Bubble bubble = mBubbleData.getBubbleWithKey(key);
+ boolean bubbleExtended = entry != null && entry.isBubble() && userRemovedNotif;
if (bubbleExtended) {
- entry.setShowInShadeWhenBubble(false);
+ bubble.setShowInShadeWhenBubble(false);
+ bubble.setShowBubbleDot(false);
if (mStackView != null) {
mStackView.updateDotVisibility(entry.key);
}
mNotificationEntryManager.updateNotifications();
return true;
- } else if (!userRemovedNotif && !entry.isBubbleDismissed()) {
+ } else if (!userRemovedNotif && entry != null) {
// This wasn't a user removal so we should remove the bubble as well
mBubbleData.notificationEntryRemoved(entry, DISMISS_NOTIF_CANCEL);
return false;
@@ -467,6 +588,52 @@
}
};
+ private boolean handleSummaryRemovalInterception(NotificationEntry summary,
+ boolean userRemovedNotif) {
+ String groupKey = summary.notification.getGroupKey();
+ ArrayList<Bubble> bubbleChildren = mBubbleData.getBubblesInGroup(groupKey);
+
+ if (userRemovedNotif) {
+ // If it's a user dismiss we mark the children to be hidden from the shade.
+ for (int i = 0; i < bubbleChildren.size(); i++) {
+ Bubble bubbleChild = bubbleChildren.get(i);
+ // As far as group manager is concerned, once a child is no longer shown
+ // in the shade, it is essentially removed.
+ mNotificationGroupManager.onEntryRemoved(bubbleChild.getEntry());
+ bubbleChild.setShowInShadeWhenBubble(false);
+ bubbleChild.setShowBubbleDot(false);
+ if (mStackView != null) {
+ mStackView.updateDotVisibility(bubbleChild.getKey());
+ }
+ }
+ // And since all children are removed, remove the summary.
+ mNotificationGroupManager.onEntryRemoved(summary);
+
+ // If the summary was auto-generated we don't need to keep that notification around
+ // because apps can't cancel it; so we only intercept & suppress real summaries.
+ boolean isAutogroupSummary = (summary.notification.getNotification().flags
+ & FLAG_AUTOGROUP_SUMMARY) != 0;
+ if (!isAutogroupSummary) {
+ mBubbleData.addSummaryToSuppress(summary.notification.getGroupKey(),
+ summary.key);
+ // Tell shade to update for the suppression
+ mNotificationEntryManager.updateNotifications();
+ }
+ return !isAutogroupSummary;
+ } else {
+ // If it's not a user dismiss it's a cancel.
+ mBubbleData.removeSuppressedSummary(groupKey);
+
+ // Remove any associated bubble children.
+ for (int i = 0; i < bubbleChildren.size(); i++) {
+ Bubble bubbleChild = bubbleChildren.get(i);
+ mBubbleData.notificationEntryRemoved(bubbleChild.getEntry(),
+ DISMISS_GROUP_CANCELLED);
+ }
+ return false;
+ }
+ }
+
@SuppressWarnings("FieldCanBeLocal")
private final NotificationEntryListener mEntryListener = new NotificationEntryListener() {
@Override
@@ -476,17 +643,6 @@
}
if (mNotificationInterruptionStateProvider.shouldBubbleUp(entry)
&& canLaunchInActivityView(mContext, entry)) {
- updateShowInShadeForSuppressNotification(entry);
- }
- }
-
- @Override
- public void onEntryInflated(NotificationEntry entry, @InflationFlag int inflatedFlags) {
- if (!areBubblesEnabled(mContext)) {
- return;
- }
- if (mNotificationInterruptionStateProvider.shouldBubbleUp(entry)
- && canLaunchInActivityView(mContext, entry)) {
updateBubble(entry);
}
}
@@ -502,8 +658,7 @@
// It was previously a bubble but no longer a bubble -- lets remove it
removeBubble(entry.key, DISMISS_NO_LONGER_BUBBLE);
} else if (shouldBubble) {
- updateShowInShadeForSuppressNotification(entry);
- entry.setBubbleDismissed(false); // updates come back as bubbles even if dismissed
+ Bubble b = mBubbleData.getBubbleWithKey(entry.key);
updateBubble(entry);
}
}
@@ -540,27 +695,60 @@
}
// Do removals, if any.
- for (Pair<Bubble, Integer> removed : update.removedBubbles) {
+ ArrayList<Pair<Bubble, Integer>> removedBubbles =
+ new ArrayList<>(update.removedBubbles);
+ for (Pair<Bubble, Integer> removed : removedBubbles) {
final Bubble bubble = removed.first;
@DismissReason final int reason = removed.second;
mStackView.removeBubble(bubble);
- if (!mBubbleData.hasBubbleWithKey(bubble.getKey())
- && !bubble.entry.showInShadeWhenBubble()) {
- // The bubble is gone & the notification is gone, time to actually remove it
- mNotificationEntryManager.performRemoveNotification(bubble.entry.notification,
- UNDEFINED_DISMISS_REASON);
- } else {
- // Update the flag for SysUI
- bubble.entry.notification.getNotification().flags &= ~FLAG_BUBBLE;
+ // If the bubble is removed for user switching, leave the notification in place.
+ if (reason != DISMISS_USER_CHANGED) {
+ if (!mBubbleData.hasBubbleWithKey(bubble.getKey())
+ && !bubble.showInShadeWhenBubble()) {
+ // The bubble is gone & the notification is gone, time to actually remove it
+ mNotificationEntryManager.performRemoveNotification(
+ bubble.getEntry().notification, UNDEFINED_DISMISS_REASON);
+ } else {
+ // Update the flag for SysUI
+ bubble.getEntry().notification.getNotification().flags &= ~FLAG_BUBBLE;
- // Make sure NoMan knows it's not a bubble anymore so anyone querying it will
- // get right result back
- try {
- mBarService.onNotificationBubbleChanged(bubble.getKey(),
- false /* isBubble */);
- } catch (RemoteException e) {
- // Bad things have happened
+ // Make sure NoMan knows it's not a bubble anymore so anyone querying it
+ // will get right result back
+ try {
+ mBarService.onNotificationBubbleChanged(bubble.getKey(),
+ false /* isBubble */);
+ } catch (RemoteException e) {
+ // Bad things have happened
+ }
+ }
+
+ // Check if removed bubble has an associated suppressed group summary that needs
+ // to be removed now.
+ final String groupKey = bubble.getEntry().notification.getGroupKey();
+ if (mBubbleData.isSummarySuppressed(groupKey)
+ && mBubbleData.getBubblesInGroup(groupKey).isEmpty()) {
+ // Time to actually remove the summary.
+ String notifKey = mBubbleData.getSummaryKey(groupKey);
+ mBubbleData.removeSuppressedSummary(groupKey);
+ NotificationEntry entry =
+ mNotificationEntryManager.getNotificationData().get(notifKey);
+ mNotificationEntryManager.performRemoveNotification(
+ entry.notification, UNDEFINED_DISMISS_REASON);
+ }
+
+ // Check if summary should be removed from NoManGroup
+ NotificationEntry summary = mNotificationGroupManager.getLogicalGroupSummary(
+ bubble.getEntry().notification);
+ if (summary != null) {
+ ArrayList<NotificationEntry> summaryChildren =
+ mNotificationGroupManager.getLogicalChildren(summary.notification);
+ boolean isSummaryThisNotif = summary.key.equals(bubble.getEntry().key);
+ if (!isSummaryThisNotif
+ && (summaryChildren == null || summaryChildren.isEmpty())) {
+ mNotificationEntryManager.performRemoveNotification(
+ summary.notification, UNDEFINED_DISMISS_REASON);
+ }
}
}
}
@@ -575,6 +763,10 @@
if (update.selectionChanged) {
mStackView.setSelectedBubble(update.selectedBubble);
+ if (update.selectedBubble != null) {
+ mNotificationGroupManager.updateSuppression(
+ update.selectedBubble.getEntry());
+ }
}
// Expanding? Apply this last.
@@ -585,7 +777,7 @@
mNotificationEntryManager.updateNotifications();
updateStack();
- if (DEBUG) {
+ if (DEBUG_BUBBLE_CONTROLLER) {
Log.d(TAG, "[BubbleData]");
Log.d(TAG, formatBubblesString(mBubbleData.getBubbles(),
mBubbleData.getSelectedBubble()));
@@ -600,34 +792,6 @@
};
/**
- * Updates the stack view's suppression flags from the latest config from the zen (do not
- * disturb) controller.
- */
- private void updateStackViewForZenConfig() {
- final ZenModeConfig zenModeConfig = mZenModeController.getConfig();
-
- if (zenModeConfig == null || mStackView == null) {
- return;
- }
-
- final int suppressedEffects = zenModeConfig.suppressedVisualEffects;
- final boolean hideNotificationDotsSelected =
- (suppressedEffects & SUPPRESSED_EFFECT_BADGE) != 0;
- final boolean dontPopNotifsOnScreenSelected =
- (suppressedEffects & SUPPRESSED_EFFECT_PEEK) != 0;
- final boolean hideFromPullDownShadeSelected =
- (suppressedEffects & SUPPRESSED_EFFECT_NOTIFICATION_LIST) != 0;
-
- final boolean dndEnabled = mZenModeController.getZen() != Settings.Global.ZEN_MODE_OFF;
-
- mStackView.setSuppressNewDot(
- dndEnabled && hideNotificationDotsSelected);
- mStackView.setSuppressFlyout(
- dndEnabled && (dontPopNotifsOnScreenSelected
- || hideFromPullDownShadeSelected));
- }
-
- /**
* Lets any listeners know if bubble state has changed.
* Updates the visibility of the bubbles based on current state.
* Does not un-bubble, just hides or un-hides. Notifies any
@@ -697,46 +861,16 @@
}
/**
- * Whether the notification should automatically bubble or not. Gated by secure settings flags.
+ * Description of current bubble state.
*/
- @VisibleForTesting
- protected boolean shouldAutoBubbleForFlags(Context context, NotificationEntry entry) {
- if (entry.isBubbleDismissed()) {
- return false;
+ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ pw.println("BubbleController state:");
+ mBubbleData.dump(fd, pw, args);
+ pw.println();
+ if (mStackView != null) {
+ mStackView.dump(fd, pw, args);
}
- StatusBarNotification n = entry.notification;
-
- boolean autoBubbleMessages = shouldAutoBubbleMessages(context) || DEBUG_ENABLE_AUTO_BUBBLE;
- boolean autoBubbleOngoing = shouldAutoBubbleOngoing(context) || DEBUG_ENABLE_AUTO_BUBBLE;
- boolean autoBubbleAll = shouldAutoBubbleAll(context) || DEBUG_ENABLE_AUTO_BUBBLE;
-
- boolean hasRemoteInput = false;
- if (n.getNotification().actions != null) {
- for (Notification.Action action : n.getNotification().actions) {
- if (action.getRemoteInputs() != null) {
- hasRemoteInput = true;
- break;
- }
- }
- }
- boolean isCall = Notification.CATEGORY_CALL.equals(n.getNotification().category)
- && n.isOngoing();
- boolean isMusic = n.getNotification().hasMediaSession();
- boolean isImportantOngoing = isMusic || isCall;
-
- Class<? extends Notification.Style> style = n.getNotification().getNotificationStyle();
- boolean isMessageType = Notification.CATEGORY_MESSAGE.equals(n.getNotification().category);
- boolean isMessageStyle = Notification.MessagingStyle.class.equals(style);
- return (((isMessageType && hasRemoteInput) || isMessageStyle) && autoBubbleMessages)
- || (isImportantOngoing && autoBubbleOngoing)
- || autoBubbleAll;
- }
-
- private void updateShowInShadeForSuppressNotification(NotificationEntry entry) {
- boolean suppressNotification = entry.getBubbleMetadata() != null
- && entry.getBubbleMetadata().isNotificationSuppressed()
- && isForegroundApp(mContext, entry.notification.getPackageName());
- entry.setShowInShadeWhenBubble(!suppressNotification);
+ pw.println();
}
static String formatBubblesString(List<Bubble> bubbles, Bubble selected) {
@@ -757,18 +891,6 @@
}
/**
- * Return true if the applications with the package name is running in foreground.
- *
- * @param context application context.
- * @param pkgName application package name.
- */
- public static boolean isForegroundApp(Context context, String pkgName) {
- ActivityManager am = context.getSystemService(ActivityManager.class);
- List<RunningTaskInfo> tasks = am.getRunningTasks(1 /* maxNum */);
- return !tasks.isEmpty() && pkgName.equals(tasks.get(0).topActivity.getPackageName());
- }
-
- /**
* This task stack listener is responsible for responding to tasks moved to the front
* which are on the default (main) display. When this happens, expanded bubbles must be
* collapsed so the user may interact with the app which was just moved to the front.
@@ -782,7 +904,9 @@
@Override
public void onTaskMovedToFront(RunningTaskInfo taskInfo) {
if (mStackView != null && taskInfo.displayId == Display.DEFAULT_DISPLAY) {
- mBubbleData.setExpanded(false);
+ if (!mStackView.isExpansionAnimating()) {
+ mBubbleData.setExpanded(false);
+ }
}
}
@@ -802,31 +926,25 @@
@Override
public void onSingleTaskDisplayDrawn(int displayId) {
- final Bubble expandedBubble = getExpandedBubble(mContext);
+ final Bubble expandedBubble = mStackView != null
+ ? mStackView.getExpandedBubble()
+ : null;
if (expandedBubble != null && expandedBubble.getDisplayId() == displayId) {
expandedBubble.setContentVisibility(true);
}
}
- }
- private static boolean shouldAutoBubbleMessages(Context context) {
- return Settings.Secure.getInt(context.getContentResolver(),
- ENABLE_AUTO_BUBBLE_MESSAGES, 0) != 0;
- }
-
- private static boolean shouldAutoBubbleOngoing(Context context) {
- return Settings.Secure.getInt(context.getContentResolver(),
- ENABLE_AUTO_BUBBLE_ONGOING, 0) != 0;
- }
-
- private static boolean shouldAutoBubbleAll(Context context) {
- return Settings.Secure.getInt(context.getContentResolver(),
- ENABLE_AUTO_BUBBLE_ALL, 0) != 0;
- }
-
- static boolean shouldUseContentIntent(Context context) {
- return Settings.Secure.getInt(context.getContentResolver(),
- ENABLE_BUBBLE_CONTENT_INTENT, 0) != 0;
+ @Override
+ public void onSingleTaskDisplayEmpty(int displayId) {
+ final Bubble expandedBubble = mStackView != null
+ ? mStackView.getExpandedBubble()
+ : null;
+ int expandedId = expandedBubble != null ? expandedBubble.getDisplayId() : -1;
+ if (mStackView != null && mStackView.isExpanded() && expandedId == displayId) {
+ mBubbleData.setExpanded(false);
+ }
+ mBubbleData.notifyDisplayEmpty(displayId);
+ }
}
private static boolean areBubblesEnabled(Context context) {
@@ -834,20 +952,6 @@
ENABLE_BUBBLES, 1) != 0;
}
- /** Default stiffness to use for bubble physics animations. */
- public static int getBubbleStiffness(Context context, int defaultStiffness) {
- return Settings.Secure.getInt(
- context.getContentResolver(), BUBBLE_STIFFNESS, defaultStiffness);
- }
-
- /** Default bounciness/damping ratio to use for bubble physics animations. */
- public static float getBubbleBounciness(Context context, float defaultBounciness) {
- return Settings.Secure.getInt(
- context.getContentResolver(),
- BUBBLE_BOUNCINESS,
- (int) (defaultBounciness * 100)) / 100f;
- }
-
/**
* Whether an intent is properly configured to display in an {@link android.app.ActivityView}.
*
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java
index 5575b35..eb826e5 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java
@@ -16,6 +16,9 @@
package com.android.systemui.bubbles;
import static com.android.internal.annotations.VisibleForTesting.Visibility.PRIVATE;
+import static com.android.systemui.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_DATA;
+import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_BUBBLES;
+import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME;
import static java.util.stream.Collectors.toList;
@@ -33,11 +36,12 @@
import com.android.systemui.bubbles.BubbleController.DismissReason;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -51,8 +55,7 @@
@Singleton
public class BubbleData {
- private static final String TAG = "BubbleData";
- private static final boolean DEBUG = false;
+ private static final String TAG = TAG_WITH_CLASS_NAME ? "BubbleData" : TAG_BUBBLES;
private static final int MAX_BUBBLES = 5;
@@ -123,6 +126,19 @@
@Nullable
private Listener mListener;
+ /**
+ * We track groups with summaries that aren't visibly displayed but still kept around because
+ * the bubble(s) associated with the summary still exist.
+ *
+ * The summary must be kept around so that developers can cancel it (and hence the bubbles
+ * associated with it). This list is used to check if the summary should be hidden from the
+ * shade.
+ *
+ * Key: group key of the NotificationEntry
+ * Value: key of the NotificationEntry
+ */
+ private HashMap<String, String> mSuppressedGroupKeys = new HashMap<>();
+
@Inject
public BubbleData(Context context) {
mContext = context;
@@ -148,7 +164,7 @@
}
public void setExpanded(boolean expanded) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "setExpanded: " + expanded);
}
setExpandedInternal(expanded);
@@ -156,29 +172,30 @@
}
public void setSelectedBubble(Bubble bubble) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "setSelectedBubble: " + bubble);
}
setSelectedBubbleInternal(bubble);
dispatchPendingChanges();
}
- public void notificationEntryUpdated(NotificationEntry entry) {
- if (DEBUG) {
+ void notificationEntryUpdated(NotificationEntry entry, boolean suppressFlyout) {
+ if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "notificationEntryUpdated: " + entry);
}
Bubble bubble = getBubbleWithKey(entry.key);
if (bubble == null) {
// Create a new bubble
- bubble = new Bubble(mContext, entry, this::onBubbleBlocked);
+ bubble = new Bubble(mContext, entry);
+ bubble.setSuppressFlyout(suppressFlyout);
doAdd(bubble);
trim();
} else {
// Updates an existing bubble
- bubble.setEntry(entry);
+ bubble.updateEntry(entry);
doUpdate(bubble);
}
- if (shouldAutoExpand(entry)) {
+ if (bubble.shouldAutoExpand()) {
setSelectedBubbleInternal(bubble);
if (!mExpanded) {
setExpandedInternal(true);
@@ -186,11 +203,14 @@
} else if (mSelectedBubble == null) {
setSelectedBubbleInternal(bubble);
}
+ boolean isBubbleExpandedAndSelected = mExpanded && mSelectedBubble == bubble;
+ bubble.setShowInShadeWhenBubble(!isBubbleExpandedAndSelected);
+ bubble.setShowBubbleDot(!isBubbleExpandedAndSelected);
dispatchPendingChanges();
}
public void notificationEntryRemoved(NotificationEntry entry, @DismissReason int reason) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "notificationEntryRemoved: entry=" + entry + " reason=" + reason);
}
doRemove(entry.key, reason);
@@ -222,8 +242,59 @@
dispatchPendingChanges();
}
+ /**
+ * Adds a group key indicating that the summary for this group should be suppressed.
+ *
+ * @param groupKey the group key of the group whose summary should be suppressed.
+ * @param notifKey the notification entry key of that summary.
+ */
+ void addSummaryToSuppress(String groupKey, String notifKey) {
+ mSuppressedGroupKeys.put(groupKey, notifKey);
+ }
+
+ /**
+ * Retrieves the notif entry key of the summary associated with the provided group key.
+ *
+ * @param groupKey the group to look up
+ * @return the key for the {@link NotificationEntry} that is the summary of this group.
+ */
+ String getSummaryKey(String groupKey) {
+ return mSuppressedGroupKeys.get(groupKey);
+ }
+
+ /**
+ * Removes a group key indicating that summary for this group should no longer be suppressed.
+ */
+ void removeSuppressedSummary(String groupKey) {
+ mSuppressedGroupKeys.remove(groupKey);
+ }
+
+ /**
+ * Whether the summary for the provided group key is suppressed.
+ */
+ boolean isSummarySuppressed(String groupKey) {
+ return mSuppressedGroupKeys.containsKey(groupKey);
+ }
+
+ /**
+ * Retrieves any bubbles that are part of the notification group represented by the provided
+ * group key.
+ */
+ ArrayList<Bubble> getBubblesInGroup(@Nullable String groupKey) {
+ ArrayList<Bubble> bubbleChildren = new ArrayList<>();
+ if (groupKey == null) {
+ return bubbleChildren;
+ }
+ for (Bubble b : mBubbles) {
+ if (groupKey.equals(b.getEntry().notification.getGroupKey())) {
+ bubbleChildren.add(b);
+ }
+ }
+ return bubbleChildren;
+ }
+
private void doAdd(Bubble bubble) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "doAdd: " + bubble);
}
int minInsertPoint = 0;
@@ -256,7 +327,7 @@
}
private void doUpdate(Bubble bubble) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "doUpdate: " + bubble);
}
mStateChange.updatedBubble = bubble;
@@ -301,12 +372,11 @@
Bubble newSelected = mBubbles.get(newIndex);
setSelectedBubbleInternal(newSelected);
}
- bubbleToRemove.setDismissed();
- maybeSendDeleteIntent(reason, bubbleToRemove.entry);
+ maybeSendDeleteIntent(reason, bubbleToRemove.getEntry());
}
public void dismissAll(@DismissReason int reason) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "dismissAll: reason=" + reason);
}
if (mBubbles.isEmpty()) {
@@ -316,13 +386,28 @@
setSelectedBubbleInternal(null);
while (!mBubbles.isEmpty()) {
Bubble bubble = mBubbles.remove(0);
- bubble.setDismissed();
- maybeSendDeleteIntent(reason, bubble.entry);
+ maybeSendDeleteIntent(reason, bubble.getEntry());
mStateChange.bubbleRemoved(bubble, reason);
}
dispatchPendingChanges();
}
+ /**
+ * Indicates that the provided display is no longer in use and should be cleaned up.
+ *
+ * @param displayId the id of the display to clean up.
+ */
+ void notifyDisplayEmpty(int displayId) {
+ for (Bubble b : mBubbles) {
+ if (b.getDisplayId() == displayId) {
+ if (b.getExpandedView() != null) {
+ b.getExpandedView().notifyDisplayEmpty();
+ }
+ return;
+ }
+ }
+ }
+
private void dispatchPendingChanges() {
if (mListener != null && mStateChange.anythingChanged()) {
mListener.applyUpdate(mStateChange);
@@ -336,7 +421,7 @@
* @param bubble the new selected bubble
*/
private void setSelectedBubbleInternal(@Nullable Bubble bubble) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "setSelectedBubbleInternal: " + bubble);
}
if (Objects.equals(bubble, mSelectedBubble)) {
@@ -361,7 +446,7 @@
* @param shouldExpand the new requested state
*/
private void setExpandedInternal(boolean shouldExpand) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "setExpandedInternal: shouldExpand=" + shouldExpand);
}
if (mExpanded == shouldExpand) {
@@ -396,7 +481,7 @@
// bubble remains on top.
mBubbles.remove(mSelectedBubble);
mBubbles.add(0, mSelectedBubble);
- packGroup(0);
+ mStateChange.orderChanged |= packGroup(0);
}
}
}
@@ -466,7 +551,7 @@
* @return true if the position of any bubbles has changed as a result
*/
private boolean packGroup(int position) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "packGroup: position=" + position);
}
Bubble groupStart = mBubbles.get(position);
@@ -495,7 +580,7 @@
* @return true if the position of any bubbles changed as a result
*/
private boolean repackAll() {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "repackAll()");
}
if (mBubbles.isEmpty()) {
@@ -550,28 +635,6 @@
}
}
- private void onBubbleBlocked(NotificationEntry entry) {
- final String blockedGroupId = Bubble.groupId(entry);
- int selectedIndex = mBubbles.indexOf(mSelectedBubble);
- for (Iterator<Bubble> i = mBubbles.iterator(); i.hasNext(); ) {
- Bubble bubble = i.next();
- if (bubble.getGroupId().equals(blockedGroupId)) {
- mStateChange.bubbleRemoved(bubble, BubbleController.DISMISS_BLOCKED);
- i.remove();
- }
- }
- if (mBubbles.isEmpty()) {
- setExpandedInternal(false);
- setSelectedBubbleInternal(null);
- } else if (!mBubbles.contains(mSelectedBubble)) {
- // choose a new one
- int newIndex = Math.min(selectedIndex, mBubbles.size() - 1);
- Bubble newSelected = mBubbles.get(newIndex);
- setSelectedBubbleInternal(newSelected);
- }
- dispatchPendingChanges();
- }
-
private int indexForKey(String key) {
for (int i = 0; i < mBubbles.size(); i++) {
Bubble bubble = mBubbles.get(i);
@@ -610,9 +673,21 @@
mListener = listener;
}
- boolean shouldAutoExpand(NotificationEntry entry) {
- Notification.BubbleMetadata metadata = entry.getBubbleMetadata();
- return metadata != null && metadata.getAutoExpandBubble()
- && BubbleController.isForegroundApp(mContext, entry.notification.getPackageName());
+ /**
+ * Description of current bubble data state.
+ */
+ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ pw.print("selected: "); pw.println(mSelectedBubble != null
+ ? mSelectedBubble.getKey()
+ : "null");
+ pw.print("expanded: "); pw.println(mExpanded);
+ pw.print("count: "); pw.println(mBubbles.size());
+ for (Bubble bubble : mBubbles) {
+ bubble.dump(fd, pw, args);
+ }
+ pw.print("summaryKeys: "); pw.println(mSuppressedGroupKeys.size());
+ for (String key : mSuppressedGroupKeys.keySet()) {
+ pw.println(" suppressing: " + key);
+ }
}
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleDebugConfig.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleDebugConfig.java
new file mode 100644
index 0000000..b702d06
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleDebugConfig.java
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+package com.android.systemui.bubbles;
+
+/**
+ * Common class for the various debug {@link android.util.Log} output configuration in the Bubbles
+ * package.
+ */
+public class BubbleDebugConfig {
+
+ // All output logs in the Bubbles package use the {@link #TAG_BUBBLES} string for tagging their
+ // log output. This makes it easy to identify the origin of the log message when sifting
+ // through a large amount of log output from multiple sources. However, it also makes trying
+ // to figure-out the origin of a log message while debugging the Bubbles a little painful. By
+ // setting this constant to true, log messages from the Bubbles package will be tagged with
+ // their class names instead fot the generic tag.
+ static final boolean TAG_WITH_CLASS_NAME = false;
+
+ // Default log tag for the Bubbles package.
+ static final String TAG_BUBBLES = "Bubbles";
+
+ static final boolean DEBUG_BUBBLE_CONTROLLER = false;
+ static final boolean DEBUG_BUBBLE_DATA = false;
+ static final boolean DEBUG_BUBBLE_STACK_VIEW = false;
+ static final boolean DEBUG_BUBBLE_EXPANDED_VIEW = false;
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleDismissView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleDismissView.java
index 4db1e27..9db371e 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleDismissView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleDismissView.java
@@ -16,18 +16,13 @@
package com.android.systemui.bubbles;
-import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
-
import android.content.Context;
-import android.graphics.drawable.Drawable;
-import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
-import android.widget.TextView;
import androidx.dynamicanimation.animation.DynamicAnimation;
import androidx.dynamicanimation.animation.SpringAnimation;
@@ -37,14 +32,13 @@
/** Dismiss view that contains a scrim gradient, as well as a dismiss icon, text, and circle. */
public class BubbleDismissView extends FrameLayout {
- /** Duration for animations involving the dismiss target text/icon/gradient. */
+ /** Duration for animations involving the dismiss target text/icon. */
private static final int DISMISS_TARGET_ANIMATION_BASE_DURATION = 150;
-
- private View mDismissGradient;
+ private static final float SCALE_FOR_POP = 1.2f;
+ private static final float SCALE_FOR_DISMISS = 0.9f;
private LinearLayout mDismissTarget;
private ImageView mDismissIcon;
- private TextView mDismissText;
private View mDismissCircle;
private SpringAnimation mDismissTargetAlphaSpring;
@@ -54,36 +48,15 @@
super(context);
setVisibility(GONE);
- mDismissGradient = new FrameLayout(mContext);
-
- FrameLayout.LayoutParams gradientParams =
- new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);
- gradientParams.gravity = Gravity.BOTTOM;
- mDismissGradient.setLayoutParams(gradientParams);
-
- Drawable gradient = mContext.getResources().getDrawable(R.drawable.pip_dismiss_scrim);
- gradient.setAlpha((int) (255 * 0.85f));
- mDismissGradient.setBackground(gradient);
-
- mDismissGradient.setVisibility(GONE);
- addView(mDismissGradient);
-
LayoutInflater.from(context).inflate(R.layout.bubble_dismiss_target, this, true);
mDismissTarget = findViewById(R.id.bubble_dismiss_icon_container);
mDismissIcon = findViewById(R.id.bubble_dismiss_close_icon);
- mDismissText = findViewById(R.id.bubble_dismiss_text);
mDismissCircle = findViewById(R.id.bubble_dismiss_circle);
// Set up the basic target area animations. These are very simple animations that don't need
// fancy interpolators.
final AccelerateDecelerateInterpolator interpolator =
new AccelerateDecelerateInterpolator();
- mDismissGradient.animate()
- .setDuration(DISMISS_TARGET_ANIMATION_BASE_DURATION)
- .setInterpolator(interpolator);
- mDismissText.animate()
- .setDuration(DISMISS_TARGET_ANIMATION_BASE_DURATION)
- .setInterpolator(interpolator);
mDismissIcon.animate()
.setDuration(DISMISS_TARGET_ANIMATION_BASE_DURATION)
.setInterpolator(interpolator);
@@ -108,110 +81,58 @@
// safely assume it was animating out rather than in.
if (alpha < 0.5f) {
// If the alpha spring was animating the view out, set it to GONE when it's done.
- setVisibility(GONE);
+ setVisibility(INVISIBLE);
}
});
}
- /** Springs in the dismiss target and fades in the gradient. */
+ /** Springs in the dismiss target. */
void springIn() {
setVisibility(View.VISIBLE);
- // Fade in the dismiss target (icon + text).
+ // Fade in the dismiss target icon.
+ mDismissIcon.animate()
+ .setDuration(50)
+ .scaleX(1f)
+ .scaleY(1f)
+ .alpha(1f);
mDismissTarget.setAlpha(0f);
mDismissTargetAlphaSpring.animateToFinalPosition(1f);
- // Spring up the dismiss target (icon + text).
+ // Spring up the dismiss target.
mDismissTarget.setTranslationY(mDismissTarget.getHeight() / 2f);
mDismissTargetVerticalSpring.animateToFinalPosition(0);
- // Fade in the gradient.
- mDismissGradient.setVisibility(VISIBLE);
- mDismissGradient.animate().alpha(1f);
+ mDismissCircle.setAlpha(0f);
+ mDismissCircle.setScaleX(SCALE_FOR_POP);
+ mDismissCircle.setScaleY(SCALE_FOR_POP);
- // Make sure the dismiss elements are in the separated position (in case we hid the target
- // while they were condensed to cover the bubbles being in the target).
- mDismissIcon.setAlpha(1f);
- mDismissIcon.setScaleX(1f);
- mDismissIcon.setScaleY(1f);
- mDismissIcon.setTranslationX(0f);
- mDismissText.setAlpha(1f);
- mDismissText.setTranslationX(0f);
+ // Fade in circle and reduce size.
+ mDismissCircle.animate()
+ .alpha(1f)
+ .scaleX(1f)
+ .scaleY(1f);
}
- /** Springs out the dismiss target and fades out the gradient. */
+ /** Springs out the dismiss target. */
void springOut() {
+ // Fade out the target icon.
+ mDismissIcon.animate()
+ .setDuration(50)
+ .scaleX(SCALE_FOR_DISMISS)
+ .scaleY(SCALE_FOR_DISMISS)
+ .alpha(0f);
+
// Fade out the target.
mDismissTargetAlphaSpring.animateToFinalPosition(0f);
// Spring the target down a bit.
mDismissTargetVerticalSpring.animateToFinalPosition(mDismissTarget.getHeight() / 2f);
- // Fade out the gradient and then set it to GONE so it's not in the SBV hierarchy.
- mDismissGradient.animate().alpha(0f).withEndAction(
- () -> mDismissGradient.setVisibility(GONE));
-
- // Pop out the dismiss circle.
- mDismissCircle.animate().alpha(0f).scaleX(1.2f).scaleY(1.2f);
- }
-
- /**
- * Encircles the center of the dismiss target, pulling the X towards the center and hiding the
- * text.
- */
- void animateEncircleCenterWithX(boolean encircle) {
- // Pull the text towards the center if we're encircling (it'll be faded out, leaving only
- // the X icon over the bubbles), or back to normal if we're un-encircling.
- final float textTranslation = encircle
- ? -mDismissIcon.getWidth() / 4f
- : 0f;
-
- // Center the icon if we're encircling, or put it back to normal if not.
- final float iconTranslation = encircle
- ? mDismissTarget.getWidth() / 2f
- - mDismissIcon.getWidth() / 2f
- - mDismissIcon.getLeft()
- : 0f;
-
- // Fade in/out the text and translate it.
- mDismissText.animate()
- .alpha(encircle ? 0f : 1f)
- .translationX(textTranslation);
-
- mDismissIcon.animate()
- .setDuration(150)
- .translationX(iconTranslation);
-
- // Fade out the gradient if we're encircling (the bubbles will 'absorb' it by darkening
- // themselves).
- mDismissGradient.animate()
- .alpha(encircle ? 0f : 1f);
-
- // Prepare the circle to be 'dropped in'.
- if (encircle) {
- mDismissCircle.setAlpha(0f);
- mDismissCircle.setScaleX(1.2f);
- mDismissCircle.setScaleY(1.2f);
- }
-
- // Drop in the circle, or pull it back up.
+ // Pop out the circle.
mDismissCircle.animate()
- .alpha(encircle ? 1f : 0f)
- .scaleX(encircle ? 1f : 0f)
- .scaleY(encircle ? 1f : 0f);
- }
-
- /** Animates the circle and the centered icon out. */
- void animateEncirclingCircleDisappearance() {
- // Pop out the dismiss icon and circle.
- mDismissIcon.animate()
- .setDuration(50)
- .scaleX(0.9f)
- .scaleY(0.9f)
- .alpha(0f);
- mDismissCircle.animate()
- .scaleX(0.9f)
- .scaleY(0.9f)
+ .scaleX(SCALE_FOR_DISMISS)
+ .scaleY(SCALE_FOR_DISMISS)
.alpha(0f);
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
index 923ca20..521ebde 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
@@ -18,14 +18,15 @@
import static android.view.Display.INVALID_DISPLAY;
-import static com.android.systemui.bubbles.BubbleController.DEBUG_ENABLE_AUTO_BUBBLE;
+import static com.android.systemui.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_EXPANDED_VIEW;
+import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_BUBBLES;
+import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME;
-import android.annotation.Nullable;
import android.app.ActivityOptions;
+import android.app.ActivityTaskManager;
import android.app.ActivityView;
-import android.app.INotificationManager;
-import android.app.Notification;
import android.app.PendingIntent;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
@@ -35,18 +36,17 @@
import android.graphics.Color;
import android.graphics.Insets;
import android.graphics.Point;
+import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.ShapeDrawable;
-import android.os.ServiceManager;
-import android.os.UserHandle;
-import android.provider.Settings;
+import android.os.RemoteException;
import android.service.notification.StatusBarNotification;
import android.util.AttributeSet;
import android.util.Log;
import android.util.StatsLog;
import android.view.View;
-import android.view.ViewGroup;
import android.view.WindowInsets;
+import android.view.WindowManager;
import android.widget.LinearLayout;
import com.android.internal.policy.ScreenDecorationsUtils;
@@ -54,15 +54,23 @@
import com.android.systemui.R;
import com.android.systemui.recents.TriangleShape;
import com.android.systemui.statusbar.AlphaOptimizedButton;
-import com.android.systemui.statusbar.notification.collection.NotificationEntry;
-import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
-import com.android.systemui.statusbar.notification.stack.ExpandableViewState;
/**
* Container for the expanded bubble view, handles rendering the caret and settings icon.
*/
public class BubbleExpandedView extends LinearLayout implements View.OnClickListener {
- private static final String TAG = "BubbleExpandedView";
+ private static final String TAG = TAG_WITH_CLASS_NAME ? "BubbleExpandedView" : TAG_BUBBLES;
+
+ private enum ActivityViewStatus {
+ // ActivityView is being initialized, cannot start an activity yet.
+ INITIALIZING,
+ // ActivityView is initialized, and ready to start an activity.
+ INITIALIZED,
+ // Activity runs in the ActivityView.
+ ACTIVITY_STARTED,
+ // ActivityView is released, so activity launching will no longer be permitted.
+ RELEASED,
+ }
// The triangle pointing to the expanded view
private View mPointerView;
@@ -71,50 +79,90 @@
private AlphaOptimizedButton mSettingsIcon;
// Views for expanded state
- private ExpandableNotificationRow mNotifRow;
private ActivityView mActivityView;
- private boolean mActivityViewReady = false;
+ private ActivityViewStatus mActivityViewStatus = ActivityViewStatus.INITIALIZING;
+ private int mTaskId = -1;
+
private PendingIntent mBubbleIntent;
private boolean mKeyboardVisible;
private boolean mNeedsNewHeight;
+ private Point mDisplaySize;
private int mMinHeight;
private int mSettingsIconHeight;
- private int mBubbleHeight;
private int mPointerWidth;
private int mPointerHeight;
private ShapeDrawable mPointerDrawable;
+ private Rect mTempRect = new Rect();
+ private int[] mTempLoc = new int[2];
+ private int mExpandedViewTouchSlop;
- private NotificationEntry mEntry;
+ private Bubble mBubble;
private PackageManager mPm;
private String mAppName;
private Drawable mAppIcon;
- private INotificationManager mNotificationManagerService;
private BubbleController mBubbleController = Dependency.get(BubbleController.class);
+ private WindowManager mWindowManager;
private BubbleStackView mStackView;
- private BubbleExpandedView.OnBubbleBlockedListener mOnBubbleBlockedListener;
-
private ActivityView.StateCallback mStateCallback = new ActivityView.StateCallback() {
@Override
public void onActivityViewReady(ActivityView view) {
- if (!mActivityViewReady) {
- mActivityViewReady = true;
- // Custom options so there is no activity transition animation
- ActivityOptions options = ActivityOptions.makeCustomAnimation(getContext(),
- 0 /* enterResId */, 0 /* exitResId */);
- // Post to keep the lifecycle normal
- post(() -> mActivityView.startActivity(mBubbleIntent, options));
+ if (DEBUG_BUBBLE_EXPANDED_VIEW) {
+ Log.d(TAG, "onActivityViewReady: mActivityViewStatus=" + mActivityViewStatus
+ + " bubble=" + getBubbleKey());
+ }
+ switch (mActivityViewStatus) {
+ case INITIALIZING:
+ case INITIALIZED:
+ // Custom options so there is no activity transition animation
+ ActivityOptions options = ActivityOptions.makeCustomAnimation(getContext(),
+ 0 /* enterResId */, 0 /* exitResId */);
+ // Post to keep the lifecycle normal
+ post(() -> {
+ if (DEBUG_BUBBLE_EXPANDED_VIEW) {
+ Log.d(TAG, "onActivityViewReady: calling startActivity, "
+ + "bubble=" + getBubbleKey());
+ }
+ try {
+ mActivityView.startActivity(mBubbleIntent, options);
+ } catch (RuntimeException e) {
+ // If there's a runtime exception here then there's something
+ // wrong with the intent, we can't really recover / try to populate
+ // the bubble again so we'll just remove it.
+ Log.w(TAG, "Exception while displaying bubble: " + getBubbleKey()
+ + ", " + e.getMessage() + "; removing bubble");
+ mBubbleController.removeBubble(mBubble.getKey(),
+ BubbleController.DISMISS_INVALID_INTENT);
+ }
+ });
+ mActivityViewStatus = ActivityViewStatus.ACTIVITY_STARTED;
}
}
@Override
public void onActivityViewDestroyed(ActivityView view) {
- mActivityViewReady = false;
+ if (DEBUG_BUBBLE_EXPANDED_VIEW) {
+ Log.d(TAG, "onActivityViewDestroyed: mActivityViewStatus=" + mActivityViewStatus
+ + " bubble=" + getBubbleKey());
+ }
+ mActivityViewStatus = ActivityViewStatus.RELEASED;
+ }
+
+ @Override
+ public void onTaskCreated(int taskId, ComponentName componentName) {
+ if (DEBUG_BUBBLE_EXPANDED_VIEW) {
+ Log.d(TAG, "onTaskCreated: taskId=" + taskId
+ + " bubble=" + getBubbleKey());
+ }
+ // Since Bubble ActivityView applies singleTaskDisplay this is
+ // guaranteed to only be called once per ActivityView. The taskId is
+ // saved to use for removeTask, preventing appearance in recent tasks.
+ mTaskId = taskId;
}
/**
@@ -125,9 +173,14 @@
*/
@Override
public void onTaskRemovalStarted(int taskId) {
- if (mEntry != null) {
+ if (DEBUG_BUBBLE_EXPANDED_VIEW) {
+ Log.d(TAG, "onTaskRemovalStarted: taskId=" + taskId
+ + " mActivityViewStatus=" + mActivityViewStatus
+ + " bubble=" + getBubbleKey());
+ }
+ if (mBubble != null) {
// Must post because this is called from a binder thread.
- post(() -> mBubbleController.removeBubble(mEntry.key,
+ post(() -> mBubbleController.removeBubble(mBubble.getKey(),
BubbleController.DISMISS_TASK_FINISHED));
}
}
@@ -149,20 +202,22 @@
int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
mPm = context.getPackageManager();
- mMinHeight = getResources().getDimensionPixelSize(
- R.dimen.bubble_expanded_default_height);
- mPointerMargin = getResources().getDimensionPixelSize(R.dimen.bubble_pointer_margin);
- try {
- mNotificationManagerService = INotificationManager.Stub.asInterface(
- ServiceManager.getServiceOrThrow(Context.NOTIFICATION_SERVICE));
- } catch (ServiceManager.ServiceNotFoundException e) {
- Log.w(TAG, e);
- }
+ mDisplaySize = new Point();
+ mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+ // Get the real size -- this includes screen decorations (notches, statusbar, navbar).
+ mWindowManager.getDefaultDisplay().getRealSize(mDisplaySize);
+ Resources res = getResources();
+ mMinHeight = res.getDimensionPixelSize(R.dimen.bubble_expanded_default_height);
+ mPointerMargin = res.getDimensionPixelSize(R.dimen.bubble_pointer_margin);
+ mExpandedViewTouchSlop = res.getDimensionPixelSize(R.dimen.bubble_expanded_view_slop);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
+ if (DEBUG_BUBBLE_EXPANDED_VIEW) {
+ Log.d(TAG, "onFinishInflate: bubble=" + getBubbleKey());
+ }
Resources res = getResources();
mPointerView = findViewById(R.id.pointer_view);
@@ -173,16 +228,16 @@
mPointerDrawable = new ShapeDrawable(TriangleShape.create(
mPointerWidth, mPointerHeight, true /* pointUp */));
mPointerView.setBackground(mPointerDrawable);
- mPointerView.setVisibility(GONE);
+ mPointerView.setVisibility(INVISIBLE);
mSettingsIconHeight = getContext().getResources().getDimensionPixelSize(
- R.dimen.bubble_expanded_header_height);
+ R.dimen.bubble_settings_size);
mSettingsIcon = findViewById(R.id.settings_button);
mSettingsIcon.setOnClickListener(this);
mActivityView = new ActivityView(mContext, null /* attrs */, 0 /* defStyle */,
true /* singleTaskInstance */);
-
+ // Set ActivityView's alpha value as zero, since there is no view content to be shown.
setContentVisibility(false);
addView(mActivityView);
@@ -210,6 +265,10 @@
});
}
+ private String getBubbleKey() {
+ return mBubble != null ? mBubble.getKey() : "null";
+ }
+
void applyThemeAttrs() {
TypedArray ta = getContext().obtainStyledAttributes(R.styleable.BubbleExpandedView);
int bgColor = ta.getColor(
@@ -235,6 +294,9 @@
if (mActivityView != null) {
mActivityView.setForwardedInsets(Insets.of(0, 0, 0, 0));
}
+ if (DEBUG_BUBBLE_EXPANDED_VIEW) {
+ Log.d(TAG, "onDetachedFromWindow: bubble=" + getBubbleKey());
+ }
}
/**
@@ -246,6 +308,10 @@
* and setting {@code false} actually means rendering the contents in transparent.
*/
void setContentVisibility(boolean visibility) {
+ if (DEBUG_BUBBLE_EXPANDED_VIEW) {
+ Log.d(TAG, "setContentVisibility: visibility=" + visibility
+ + " bubble=" + getBubbleKey());
+ }
final float alpha = visibility ? 1f : 0f;
mPointerView.setAlpha(alpha);
if (mActivityView != null) {
@@ -259,44 +325,37 @@
*/
void updateInsets(WindowInsets insets) {
if (usingActivityView()) {
- Point displaySize = new Point();
- mActivityView.getContext().getDisplay().getSize(displaySize);
- int[] windowLocation = mActivityView.getLocationOnScreen();
- final int windowBottom = windowLocation[1] + mActivityView.getHeight();
- final int keyboardHeight = insets.getSystemWindowInsetBottom()
- - insets.getStableInsetBottom();
- final int insetsBottom = Math.max(0,
- windowBottom + keyboardHeight - displaySize.y);
+ int[] screenLoc = mActivityView.getLocationOnScreen();
+ final int activityViewBottom = screenLoc[1] + mActivityView.getHeight();
+ final int keyboardTop = mDisplaySize.y - Math.max(insets.getSystemWindowInsetBottom(),
+ insets.getDisplayCutout() != null
+ ? insets.getDisplayCutout().getSafeInsetBottom()
+ : 0);
+ final int insetsBottom = Math.max(activityViewBottom - keyboardTop, 0);
mActivityView.setForwardedInsets(Insets.of(0, 0, 0, insetsBottom));
}
}
/**
- * Sets the listener to notify when a bubble has been blocked.
+ * Sets the bubble used to populate this view.
*/
- public void setOnBlockedListener(OnBubbleBlockedListener listener) {
- mOnBubbleBlockedListener = listener;
- }
+ public void setBubble(Bubble bubble, BubbleStackView stackView, String appName) {
+ if (DEBUG_BUBBLE_EXPANDED_VIEW) {
+ Log.d(TAG, "setBubble: bubble=" + (bubble != null ? bubble.getKey() : "null"));
+ }
- /**
- * Sets the notification entry used to populate this view.
- */
- public void setEntry(NotificationEntry entry, BubbleStackView stackView, String appName) {
mStackView = stackView;
- mEntry = entry;
+ mBubble = bubble;
mAppName = appName;
- ApplicationInfo info;
try {
- info = mPm.getApplicationInfo(
- entry.notification.getPackageName(),
+ ApplicationInfo info = mPm.getApplicationInfo(
+ bubble.getPackageName(),
PackageManager.MATCH_UNINSTALLED_PACKAGES
| PackageManager.MATCH_DISABLED_COMPONENTS
| PackageManager.MATCH_DIRECT_BOOT_UNAWARE
| PackageManager.MATCH_DIRECT_BOOT_AWARE);
- if (info != null) {
- mAppIcon = mPm.getApplicationIcon(info);
- }
+ mAppIcon = mPm.getApplicationIcon(info);
} catch (PackageManager.NameNotFoundException e) {
// Do nothing.
}
@@ -312,52 +371,46 @@
* Lets activity view know it should be shown / populated.
*/
public void populateExpandedView() {
+ if (DEBUG_BUBBLE_EXPANDED_VIEW) {
+ Log.d(TAG, "populateExpandedView: "
+ + "bubble=" + getBubbleKey());
+ }
+
if (usingActivityView()) {
mActivityView.setCallback(mStateCallback);
} else {
- // We're using notification template
- ViewGroup parent = (ViewGroup) mNotifRow.getParent();
- if (parent == this) {
- // Already added
- return;
- } else if (parent != null) {
- // Still in the shade... remove it
- parent.removeView(mNotifRow);
- }
- addView(mNotifRow, 1 /* index */);
- mPointerView.setAlpha(1f);
+ Log.e(TAG, "Cannot populate expanded view.");
}
}
/**
- * Updates the entry backing this view. This will not re-populate ActivityView, it will
+ * Updates the bubble backing this view. This will not re-populate ActivityView, it will
* only update the deep-links in the title, and the height of the view.
*/
- public void update(NotificationEntry entry) {
- if (entry.key.equals(mEntry.key)) {
- mEntry = entry;
+ public void update(Bubble bubble) {
+ if (DEBUG_BUBBLE_EXPANDED_VIEW) {
+ Log.d(TAG, "update: bubble=" + (bubble != null ? bubble.getKey() : "null"));
+ }
+ if (bubble.getKey().equals(mBubble.getKey())) {
+ mBubble = bubble;
updateSettingsContentDescription();
updateHeight();
} else {
- Log.w(TAG, "Trying to update entry with different key, new entry: "
- + entry.key + " old entry: " + mEntry.key);
+ Log.w(TAG, "Trying to update entry with different key, new bubble: "
+ + bubble.getKey() + " old bubble: " + bubble.getKey());
}
}
private void updateExpandedView() {
- mBubbleIntent = getBubbleIntent(mEntry);
+ if (DEBUG_BUBBLE_EXPANDED_VIEW) {
+ Log.d(TAG, "updateExpandedView: bubble="
+ + getBubbleKey());
+ }
+
+ mBubbleIntent = mBubble.getBubbleIntent(mContext);
if (mBubbleIntent != null) {
- if (mNotifRow != null) {
- // Clear out the row if we had it previously
- removeView(mNotifRow);
- mNotifRow = null;
- }
setContentVisibility(false);
mActivityView.setVisibility(VISIBLE);
- } else if (DEBUG_ENABLE_AUTO_BUBBLE) {
- // Hide activity view if we had it previously
- mActivityView.setVisibility(GONE);
- mNotifRow = mEntry.getRow();
}
updateView();
}
@@ -371,29 +424,12 @@
}
void updateHeight() {
+ if (DEBUG_BUBBLE_EXPANDED_VIEW) {
+ Log.d(TAG, "updateHeight: bubble=" + getBubbleKey());
+ }
if (usingActivityView()) {
- Notification.BubbleMetadata data = mEntry.getBubbleMetadata();
- float desiredHeight;
- if (data == null) {
- // This is a contentIntent based bubble, lets allow it to be the max height
- // as it was forced into this mode and not prepared to be small
- desiredHeight = mStackView.getMaxExpandedHeight();
- } else {
- boolean useRes = data.getDesiredHeightResId() != 0;
- float desiredPx;
- if (useRes) {
- desiredPx = getDimenForPackageUser(data.getDesiredHeightResId(),
- mEntry.notification.getPackageName(),
- mEntry.notification.getUser().getIdentifier());
- } else {
- desiredPx = data.getDesiredHeight()
- * getContext().getResources().getDisplayMetrics().density;
- }
- desiredHeight = desiredPx > 0 ? desiredPx : mMinHeight;
- }
- int max = mStackView.getMaxExpandedHeight() - mSettingsIconHeight - mPointerHeight
- - mPointerMargin;
- float height = Math.min(desiredHeight, max);
+ float desiredHeight = Math.max(mBubble.getDesiredHeight(mContext), mMinHeight);
+ float height = Math.min(desiredHeight, getMaxExpandedHeight());
height = Math.max(height, mMinHeight);
LayoutParams lp = (LayoutParams) mActivityView.getLayoutParams();
mNeedsNewHeight = lp.height != height;
@@ -401,28 +437,66 @@
// If the keyboard is visible... don't adjust the height because that will cause
// a configuration change and the keyboard will be lost.
lp.height = (int) height;
- mBubbleHeight = (int) height;
mActivityView.setLayoutParams(lp);
mNeedsNewHeight = false;
}
- } else {
- mBubbleHeight = mNotifRow != null ? mNotifRow.getIntrinsicHeight() : mMinHeight;
+ if (DEBUG_BUBBLE_EXPANDED_VIEW) {
+ Log.d(TAG, "updateHeight: bubble=" + getBubbleKey() + " height=" + height
+ + " mNeedsNewHeight=" + mNeedsNewHeight);
+ }
}
}
+ private int getMaxExpandedHeight() {
+ mWindowManager.getDefaultDisplay().getRealSize(mDisplaySize);
+ int[] windowLocation = mActivityView.getLocationOnScreen();
+ int bottomInset = getRootWindowInsets() != null
+ ? getRootWindowInsets().getStableInsetBottom()
+ : 0;
+ return mDisplaySize.y - windowLocation[1] - mSettingsIconHeight - mPointerHeight
+ - mPointerMargin - bottomInset;
+ }
+
+ /**
+ * Whether the provided x, y values (in raw coordinates) are in a touchable area of the
+ * expanded view.
+ *
+ * The touchable areas are the ActivityView (plus some slop around it) and the manage button.
+ */
+ boolean intersectingTouchableContent(int rawX, int rawY) {
+ mTempRect.setEmpty();
+ if (mActivityView != null) {
+ mTempLoc = mActivityView.getLocationOnScreen();
+ mTempRect.set(mTempLoc[0] - mExpandedViewTouchSlop,
+ mTempLoc[1] - mExpandedViewTouchSlop,
+ mTempLoc[0] + mActivityView.getWidth() + mExpandedViewTouchSlop,
+ mTempLoc[1] + mActivityView.getHeight() + mExpandedViewTouchSlop);
+ }
+ if (mTempRect.contains(rawX, rawY)) {
+ return true;
+ }
+ mTempLoc = mSettingsIcon.getLocationOnScreen();
+ mTempRect.set(mTempLoc[0],
+ mTempLoc[1],
+ mTempLoc[0] + mSettingsIcon.getWidth(),
+ mTempLoc[1] + mSettingsIcon.getHeight());
+ if (mTempRect.contains(rawX, rawY)) {
+ return true;
+ }
+ return false;
+ }
+
@Override
public void onClick(View view) {
- if (mEntry == null) {
+ if (mBubble == null) {
return;
}
- Notification n = mEntry.notification.getNotification();
int id = view.getId();
if (id == R.id.settings_button) {
- Intent intent = getSettingsIntent(mEntry.notification.getPackageName(),
- mEntry.notification.getUid());
+ Intent intent = mBubble.getSettingsIntent();
mStackView.collapseStack(() -> {
- mContext.startActivityAsUser(intent, mEntry.notification.getUser());
- logBubbleClickEvent(mEntry,
+ mContext.startActivityAsUser(intent, mBubble.getEntry().notification.getUser());
+ logBubbleClickEvent(mBubble,
StatsLog.BUBBLE_UICHANGED__ACTION__HEADER_GO_TO_SETTINGS);
});
}
@@ -442,13 +516,14 @@
* Update appearance of the expanded view being displayed.
*/
public void updateView() {
+ if (DEBUG_BUBBLE_EXPANDED_VIEW) {
+ Log.d(TAG, "updateView: bubble="
+ + getBubbleKey());
+ }
if (usingActivityView()
&& mActivityView.getVisibility() == VISIBLE
&& mActivityView.isAttachedToWindow()) {
mActivityView.onLocationChanged();
- } else if (mNotifRow != null) {
- applyRowState(mNotifRow);
- mPointerView.setAlpha(1f);
}
updateHeight();
}
@@ -467,17 +542,44 @@
* Removes and releases an ActivityView if one was previously created for this bubble.
*/
public void cleanUpExpandedState() {
- removeView(mNotifRow);
-
+ if (DEBUG_BUBBLE_EXPANDED_VIEW) {
+ Log.d(TAG, "cleanUpExpandedState: mActivityViewStatus=" + mActivityViewStatus
+ + ", bubble=" + getBubbleKey());
+ }
if (mActivityView == null) {
return;
}
- if (mActivityViewReady) {
- mActivityView.release();
+ switch (mActivityViewStatus) {
+ case INITIALIZED:
+ case ACTIVITY_STARTED:
+ mActivityView.release();
+ }
+ if (mTaskId != -1) {
+ try {
+ ActivityTaskManager.getService().removeTask(mTaskId);
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed to remove taskId " + mTaskId);
+ }
+ mTaskId = -1;
}
removeView(mActivityView);
+
mActivityView = null;
- mActivityViewReady = false;
+ }
+
+ /**
+ * Called when the last task is removed from a {@link android.hardware.display.VirtualDisplay}
+ * which {@link ActivityView} uses.
+ */
+ void notifyDisplayEmpty() {
+ if (DEBUG_BUBBLE_EXPANDED_VIEW) {
+ Log.d(TAG, "notifyDisplayEmpty: bubble="
+ + getBubbleKey()
+ + " mActivityViewStatus=" + mActivityViewStatus);
+ }
+ if (mActivityViewStatus == ActivityViewStatus.ACTIVITY_STARTED) {
+ mActivityViewStatus = ActivityViewStatus.INITIALIZED;
+ }
}
private boolean usingActivityView() {
@@ -494,76 +596,14 @@
return INVALID_DISPLAY;
}
- private void applyRowState(ExpandableNotificationRow view) {
- view.reset();
- view.setHeadsUp(false);
- view.resetTranslation();
- view.setOnKeyguard(false);
- view.setClipBottomAmount(0);
- view.setClipTopAmount(0);
- view.setContentTransformationAmount(0, false);
- view.setIconsVisible(true);
-
- // TODO - Need to reset this (and others) when view goes back in shade, leave for now
- // view.setTopRoundness(1, false);
- // view.setBottomRoundness(1, false);
-
- ExpandableViewState viewState = view.getViewState();
- viewState = viewState == null ? new ExpandableViewState() : viewState;
- viewState.height = view.getIntrinsicHeight();
- viewState.gone = false;
- viewState.hidden = false;
- viewState.dimmed = false;
- viewState.alpha = 1f;
- viewState.notGoneIndex = -1;
- viewState.xTranslation = 0;
- viewState.yTranslation = 0;
- viewState.zTranslation = 0;
- viewState.scaleX = 1;
- viewState.scaleY = 1;
- viewState.inShelf = true;
- viewState.headsUpIsVisible = false;
- viewState.applyToView(view);
- }
-
- private Intent getSettingsIntent(String packageName, final int appUid) {
- final Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_BUBBLE_SETTINGS);
- intent.putExtra(Settings.EXTRA_APP_PACKAGE, packageName);
- intent.putExtra(Settings.EXTRA_APP_UID, appUid);
- intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
- return intent;
- }
-
- @Nullable
- private PendingIntent getBubbleIntent(NotificationEntry entry) {
- Notification notif = entry.notification.getNotification();
- Notification.BubbleMetadata data = notif.getBubbleMetadata();
- if (BubbleController.canLaunchInActivityView(mContext, entry) && data != null) {
- return data.getIntent();
- }
- return null;
- }
-
- /**
- * Listener that is notified when a bubble is blocked.
- */
- public interface OnBubbleBlockedListener {
- /**
- * Called when a bubble is blocked for the provided entry.
- */
- void onBubbleBlocked(NotificationEntry entry);
- }
-
/**
* Logs bubble UI click event.
*
- * @param entry the bubble notification entry that user is interacting with.
+ * @param bubble the bubble notification entry that user is interacting with.
* @param action the user interaction enum.
*/
- private void logBubbleClickEvent(NotificationEntry entry, int action) {
- StatusBarNotification notification = entry.notification;
+ private void logBubbleClickEvent(Bubble bubble, int action) {
+ StatusBarNotification notification = bubble.getEntry().notification;
StatsLog.write(StatsLog.BUBBLE_UI_CHANGED,
notification.getPackageName(),
notification.getNotification().getChannelId(),
@@ -573,27 +613,8 @@
action,
mStackView.getNormalizedXPosition(),
mStackView.getNormalizedYPosition(),
- entry.showInShadeWhenBubble(),
- entry.isForegroundService(),
- BubbleController.isForegroundApp(mContext, notification.getPackageName()));
- }
-
- private int getDimenForPackageUser(int resId, String pkg, int userId) {
- Resources r;
- if (pkg != null) {
- try {
- if (userId == UserHandle.USER_ALL) {
- userId = UserHandle.USER_SYSTEM;
- }
- r = mPm.getResourcesForApplicationAsUser(pkg, userId);
- return r.getDimensionPixelSize(resId);
- } catch (PackageManager.NameNotFoundException ex) {
- // Uninstalled, don't care
- } catch (Resources.NotFoundException e) {
- // Invalid res id, return 0 and user our default
- Log.e(TAG, "Couldn't find desired height res id", e);
- }
- }
- return 0;
+ bubble.showInShadeWhenBubble(),
+ bubble.isOngoing(),
+ false /* isAppForeground (unused) */);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleFlyoutView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleFlyoutView.java
index 71f68c1..58f3f22 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleFlyoutView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleFlyoutView.java
@@ -39,8 +39,7 @@
import android.widget.FrameLayout;
import android.widget.TextView;
-import androidx.dynamicanimation.animation.DynamicAnimation;
-import androidx.dynamicanimation.animation.SpringAnimation;
+import androidx.annotation.Nullable;
import com.android.systemui.R;
import com.android.systemui.recents.TriangleShape;
@@ -57,6 +56,9 @@
private final int mFlyoutSpaceFromBubble;
private final int mPointerSize;
private final int mBubbleSize;
+ private final int mBubbleIconBitmapSize;
+ private final float mBubbleIconTopPadding;
+
private final int mFlyoutElevation;
private final int mBubbleElevation;
private final int mFloatingBackgroundColor;
@@ -64,14 +66,11 @@
private final ViewGroup mFlyoutTextContainer;
private final TextView mFlyoutText;
- /** Spring animation for the flyout. */
- private final SpringAnimation mFlyoutSpring =
- new SpringAnimation(this, DynamicAnimation.TRANSLATION_X);
/** Values related to the 'new' dot which we use to figure out where to collapse the flyout. */
private final float mNewDotRadius;
private final float mNewDotSize;
- private final float mNewDotOffsetFromBubbleBounds;
+ private final float mOriginalDotSize;
/**
* The paint used to draw the background, whose color changes as the flyout transitions to the
@@ -113,7 +112,6 @@
*/
private float mFlyoutToDotWidthDelta = 0f;
private float mFlyoutToDotHeightDelta = 0f;
- private float mFlyoutToDotCornerRadiusDelta;
/** The translation values when the flyout is completely transitioned into the dot. */
private float mTranslationXWhenDot = 0f;
@@ -126,11 +124,18 @@
private float mBgTranslationX;
private float mBgTranslationY;
+ private float[] mDotCenter;
+
/** The flyout's X translation when at rest (not animating or dragging). */
private float mRestingTranslationX = 0f;
+ /** The badge sizes are defined as percentages of the app icon size. Same value as Launcher3. */
+ private static final float SIZE_PERCENTAGE = 0.228f;
+
+ private static final float DOT_SCALE = 1f;
+
/** Callback to run when the flyout is hidden. */
- private Runnable mOnHide;
+ @Nullable private Runnable mOnHide;
public BubbleFlyoutView(Context context) {
super(context);
@@ -143,11 +148,16 @@
mFlyoutPadding = res.getDimensionPixelSize(R.dimen.bubble_flyout_padding_x);
mFlyoutSpaceFromBubble = res.getDimensionPixelSize(R.dimen.bubble_flyout_space_from_bubble);
mPointerSize = res.getDimensionPixelSize(R.dimen.bubble_flyout_pointer_size);
+
mBubbleSize = res.getDimensionPixelSize(R.dimen.individual_bubble_size);
+ mBubbleIconBitmapSize = res.getDimensionPixelSize(R.dimen.bubble_icon_bitmap_size);
+ mBubbleIconTopPadding = (mBubbleSize - mBubbleIconBitmapSize) / 2f;
+
mBubbleElevation = res.getDimensionPixelSize(R.dimen.bubble_elevation);
mFlyoutElevation = res.getDimensionPixelSize(R.dimen.bubble_flyout_elevation);
- mNewDotOffsetFromBubbleBounds = BadgeRenderer.getDotCenterOffset(context);
- mNewDotRadius = BadgeRenderer.getDotRadius(mNewDotOffsetFromBubbleBounds);
+
+ mOriginalDotSize = SIZE_PERCENTAGE * mBubbleIconBitmapSize;
+ mNewDotRadius = (DOT_SCALE * mOriginalDotSize) / 2f;
mNewDotSize = mNewDotRadius * 2f;
final TypedArray ta = mContext.obtainStyledAttributes(
@@ -156,7 +166,6 @@
android.R.attr.dialogCornerRadius});
mFloatingBackgroundColor = ta.getColor(0, Color.WHITE);
mCornerRadius = ta.getDimensionPixelSize(1, 0);
- mFlyoutToDotCornerRadiusDelta = mNewDotRadius - mCornerRadius;
ta.recycle();
// Add padding for the pointer on either side, onDraw will draw it in this space.
@@ -193,17 +202,17 @@
super.onDraw(canvas);
}
- /** Configures the flyout and animates it in. */
- void showFlyout(
+ /** Configures the flyout, collapsed into to dot form. */
+ void setupFlyoutStartingAsDot(
CharSequence updateMessage, PointF stackPos, float parentWidth,
- boolean arrowPointingLeft, int dotColor, Runnable onHide) {
+ boolean arrowPointingLeft, int dotColor, @Nullable Runnable onLayoutComplete,
+ @Nullable Runnable onHide, float[] dotCenter) {
mArrowPointingLeft = arrowPointingLeft;
mDotColor = dotColor;
mOnHide = onHide;
+ mDotCenter = dotCenter;
- setCollapsePercent(0f);
- setAlpha(0f);
- setVisibility(VISIBLE);
+ setCollapsePercent(1f);
// Set the flyout TextView's max width in terms of percent, and then subtract out the
// padding so that the entire flyout view will be the desired width (rather than the
@@ -214,14 +223,16 @@
// Wait for the TextView to lay out so we know its line count.
post(() -> {
+ float restingTranslationY;
// Multi line flyouts get top-aligned to the bubble.
if (mFlyoutText.getLineCount() > 1) {
- setTranslationY(stackPos.y);
+ restingTranslationY = stackPos.y + mBubbleIconTopPadding;
} else {
// Single line flyouts are vertically centered with respect to the bubble.
- setTranslationY(
- stackPos.y + (mBubbleSize - mFlyoutTextContainer.getHeight()) / 2f);
+ restingTranslationY =
+ stackPos.y + (mBubbleSize - mFlyoutTextContainer.getHeight()) / 2f;
}
+ setTranslationY(restingTranslationY);
// Calculate the translation required to position the flyout next to the bubble stack,
// with the desired padding.
@@ -229,40 +240,30 @@
? stackPos.x + mBubbleSize + mFlyoutSpaceFromBubble
: stackPos.x - getWidth() - mFlyoutSpaceFromBubble;
- // Translate towards the stack slightly.
- setTranslationX(
- mRestingTranslationX + (arrowPointingLeft ? -mBubbleSize : mBubbleSize));
-
- // Fade in the entire flyout and spring it to its normal position.
- animate().alpha(1f);
- mFlyoutSpring.animateToFinalPosition(mRestingTranslationX);
-
// Calculate the difference in size between the flyout and the 'dot' so that we can
// transform into the dot later.
mFlyoutToDotWidthDelta = getWidth() - mNewDotSize;
mFlyoutToDotHeightDelta = getHeight() - mNewDotSize;
// Calculate the translation values needed to be in the correct 'new dot' position.
- final float distanceFromFlyoutLeftToDotCenterX =
- mFlyoutSpaceFromBubble + mNewDotOffsetFromBubbleBounds / 2;
- if (mArrowPointingLeft) {
- mTranslationXWhenDot = -distanceFromFlyoutLeftToDotCenterX - mNewDotRadius;
- } else {
- mTranslationXWhenDot =
- getWidth() + distanceFromFlyoutLeftToDotCenterX - mNewDotRadius;
- }
+ final float dotPositionX = stackPos.x + mDotCenter[0] - (mOriginalDotSize / 2f);
+ final float dotPositionY = stackPos.y + mDotCenter[1] - (mOriginalDotSize / 2f);
- mTranslationYWhenDot =
- getHeight() / 2f
- - mNewDotRadius
- - mBubbleSize / 2f
- + mNewDotOffsetFromBubbleBounds / 2;
+ final float distanceFromFlyoutLeftToDotCenterX = mRestingTranslationX - dotPositionX;
+ final float distanceFromLayoutTopToDotCenterY = restingTranslationY - dotPositionY;
+
+ mTranslationXWhenDot = -distanceFromFlyoutLeftToDotCenterX;
+ mTranslationYWhenDot = -distanceFromLayoutTopToDotCenterY;
+ if (onLayoutComplete != null) {
+ onLayoutComplete.run();
+ }
});
}
/**
- * Hides the flyout and runs the optional callback passed into showFlyout. The flyout has been
- * animated into the 'new' dot by the time we call this, so no animations are needed.
+ * Hides the flyout and runs the optional callback passed into setupFlyoutStartingAsDot.
+ * The flyout has been animated into the 'new' dot by the time we call this, so no animations
+ * are needed.
*/
void hideFlyout() {
if (mOnHide != null) {
@@ -275,6 +276,13 @@
/** Sets the percentage that the flyout should be collapsed into dot form. */
void setCollapsePercent(float percentCollapsed) {
+ // This is unlikely, but can happen in a race condition where the flyout view hasn't been
+ // laid out and returns 0 for getWidth(). We check for this condition at the sites where
+ // this method is called, but better safe than sorry.
+ if (Float.isNaN(percentCollapsed)) {
+ return;
+ }
+
mPercentTransitionedToDot = Math.max(0f, Math.min(percentCollapsed, 1f));
mPercentStillFlyout = (1f - mPercentTransitionedToDot);
@@ -311,8 +319,8 @@
// percentage.
final float width = getWidth() - (mFlyoutToDotWidthDelta * mPercentTransitionedToDot);
final float height = getHeight() - (mFlyoutToDotHeightDelta * mPercentTransitionedToDot);
- final float cornerRadius = mCornerRadius
- - (mFlyoutToDotCornerRadiusDelta * mPercentTransitionedToDot);
+ final float interpolatedRadius = mNewDotRadius * mPercentTransitionedToDot
+ + mCornerRadius * (1 - mPercentTransitionedToDot);
// Translate the flyout background towards the collapsed 'dot' state.
mBgTranslationX = mTranslationXWhenDot * mPercentTransitionedToDot;
@@ -336,7 +344,7 @@
canvas.save();
canvas.translate(mBgTranslationX, mBgTranslationY);
renderPointerTriangle(canvas, width, height);
- canvas.drawRoundRect(mBgRect, cornerRadius, cornerRadius, mBgPaint);
+ canvas.drawRoundRect(mBgRect, interpolatedRadius, interpolatedRadius, mBgPaint);
canvas.restore();
}
@@ -379,7 +387,10 @@
if (!mTriangleOutline.isEmpty()) {
// Draw the rect into the outline as a path so we can merge the triangle path into it.
final Path rectPath = new Path();
- rectPath.addRoundRect(mBgRect, mCornerRadius, mCornerRadius, Path.Direction.CW);
+ final float interpolatedRadius = mNewDotRadius * mPercentTransitionedToDot
+ + mCornerRadius * (1 - mPercentTransitionedToDot);
+ rectPath.addRoundRect(mBgRect, interpolatedRadius,
+ interpolatedRadius, Path.Direction.CW);
outline.setConvexPath(rectPath);
// Get rid of the triangle path once it has disappeared behind the flyout.
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleIconFactory.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleIconFactory.java
new file mode 100644
index 0000000..a1c77c0
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleIconFactory.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.systemui.bubbles;
+
+import android.content.Context;
+
+import com.android.launcher3.icons.BaseIconFactory;
+import com.android.systemui.R;
+
+/**
+ * Factory for creating normalized bubble icons.
+ * We are not using Launcher's IconFactory because bubbles only runs on the UI thread,
+ * so there is no need to manage a pool across multiple threads.
+ */
+public class BubbleIconFactory extends BaseIconFactory {
+ protected BubbleIconFactory(Context context) {
+ super(context, context.getResources().getConfiguration().densityDpi,
+ context.getResources().getDimensionPixelSize(R.dimen.individual_bubble_size));
+ }
+
+ public int getBadgeSize() {
+ return mContext.getResources().getDimensionPixelSize(
+ com.android.launcher3.icons.R.dimen.profile_badge_size);
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
index f87bcef..b68b762 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
@@ -19,16 +19,20 @@
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
+import static com.android.systemui.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_STACK_VIEW;
+import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_BUBBLES;
+import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME;
+
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.annotation.NonNull;
import android.app.Notification;
import android.content.Context;
+import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
-import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.PointF;
@@ -41,11 +45,11 @@
import android.util.Log;
import android.util.StatsLog;
import android.view.Choreographer;
+import android.view.DisplayCutout;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
-import android.view.ViewOutlineProvider;
import android.view.ViewTreeObserver;
import android.view.WindowInsets;
import android.view.WindowManager;
@@ -69,6 +73,8 @@
import com.android.systemui.bubbles.animation.StackAnimationController;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
@@ -79,8 +85,7 @@
* Renders bubbles in a stack and handles animating expanded and collapsed states.
*/
public class BubbleStackView extends FrameLayout {
- private static final String TAG = "BubbleStackView";
- private static final boolean DEBUG = false;
+ private static final String TAG = TAG_WITH_CLASS_NAME ? "BubbleStackView" : TAG_BUBBLES;
/** How far the flyout needs to be dragged before it's dismissed regardless of velocity. */
static final float FLYOUT_DRAG_PERCENT_DISMISS = 0.25f;
@@ -160,9 +165,14 @@
private BubbleFlyoutView mFlyout;
/** Runnable that fades out the flyout and then sets it to GONE. */
private Runnable mHideFlyout = () -> animateFlyoutCollapsed(true, 0 /* velX */);
+ /**
+ * Callback to run after the flyout hides. Also called if a new flyout is shown before the
+ * previous one animates out.
+ */
+ private Runnable mAfterFlyoutHides;
/** Layout change listener that moves the stack to the nearest valid position on rotation. */
- private OnLayoutChangeListener mMoveStackToValidPositionOnLayoutListener;
+ private OnLayoutChangeListener mOrientationChangedListener;
/** Whether the stack was on the left side of the screen prior to rotation. */
private boolean mWasOnLeftBeforeRotation = false;
/**
@@ -172,18 +182,17 @@
private float mVerticalPosPercentBeforeRotation = -1;
private int mBubbleSize;
- private int mBubblePadding;
+ private int mBubblePaddingTop;
+ private int mBubbleTouchPadding;
private int mExpandedViewPadding;
private int mExpandedAnimateXDistance;
private int mExpandedAnimateYDistance;
private int mPointerHeight;
private int mStatusBarHeight;
- private int mPipDismissHeight;
private int mImeOffset;
-
+ private BubbleIconFactory mBubbleIconFactory;
private Bubble mExpandedBubble;
private boolean mIsExpanded;
- private boolean mImeVisible;
/** Whether the stack is currently on the left side of the screen, or animating there. */
private boolean mStackOnLeftOrWillBe = false;
@@ -191,9 +200,20 @@
/** Whether a touch gesture, such as a stack/bubble drag or flyout drag, is in progress. */
private boolean mIsGestureInProgress = false;
+ /** Description of current animation controller state. */
+ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ pw.println("Stack view state:");
+ pw.print(" gestureInProgress: "); pw.println(mIsGestureInProgress);
+ pw.print(" showingDismiss: "); pw.println(mShowingDismiss);
+ pw.print(" isExpansionAnimating: "); pw.println(mIsExpansionAnimating);
+ pw.print(" draggingInDismiss: "); pw.println(mDraggingInDismissTarget);
+ pw.print(" animatingMagnet: "); pw.println(mAnimatingMagnet);
+ mStackAnimationController.dump(fd, pw, args);
+ mExpandedAnimationController.dump(fd, pw, args);
+ }
+
private BubbleTouchHandler mTouchHandler;
private BubbleController.BubbleExpandListener mExpandListener;
- private BubbleExpandedView.OnBubbleBlockedListener mBlockedListener;
private boolean mViewUpdatedRequested = false;
private boolean mIsExpansionAnimating = false;
@@ -225,7 +245,7 @@
@Override
public boolean onPreDraw() {
getViewTreeObserver().removeOnPreDrawListener(mViewUpdater);
- applyCurrentState();
+ updateExpandedView();
mViewUpdatedRequested = false;
return true;
}
@@ -270,6 +290,11 @@
private float mFlyoutDragDeltaX = 0f;
/**
+ * Runnable that animates in the flyout. This reference is needed to cancel delayed postings.
+ */
+ private Runnable mAnimateInFlyout;
+
+ /**
* End listener for the flyout spring that either posts a runnable to hide the flyout, or hides
* it immediately.
*/
@@ -282,13 +307,13 @@
}
};
- @NonNull private final SurfaceSynchronizer mSurfaceSynchronizer;
+ @NonNull
+ private final SurfaceSynchronizer mSurfaceSynchronizer;
private BubbleDismissView mDismissContainer;
private Runnable mAfterMagnet;
- private boolean mSuppressNewDot = false;
- private boolean mSuppressFlyout = false;
+ private int mOrientation = Configuration.ORIENTATION_UNDEFINED;
public BubbleStackView(Context context, BubbleData data,
@Nullable SurfaceSynchronizer synchronizer) {
@@ -302,7 +327,8 @@
Resources res = getResources();
mBubbleSize = res.getDimensionPixelSize(R.dimen.individual_bubble_size);
- mBubblePadding = res.getDimensionPixelSize(R.dimen.bubble_padding);
+ mBubblePaddingTop = res.getDimensionPixelSize(R.dimen.bubble_padding_top);
+ mBubbleTouchPadding = res.getDimensionPixelSize(R.dimen.bubble_touch_padding);
mExpandedAnimateXDistance =
res.getDimensionPixelSize(R.dimen.bubble_expanded_animate_x_distance);
mExpandedAnimateYDistance =
@@ -311,13 +337,12 @@
mStatusBarHeight =
res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height);
- mPipDismissHeight = mContext.getResources().getDimensionPixelSize(
- R.dimen.pip_dismiss_gradient_height);
mImeOffset = res.getDimensionPixelSize(R.dimen.pip_ime_offset);
mDisplaySize = new Point();
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
- wm.getDefaultDisplay().getSize(mDisplaySize);
+ // We use the real size & subtract screen decorations / window insets ourselves when needed
+ wm.getDefaultDisplay().getRealSize(mDisplaySize);
mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
@@ -325,8 +350,9 @@
int elevation = res.getDimensionPixelSize(R.dimen.bubble_elevation);
mStackAnimationController = new StackAnimationController();
+
mExpandedAnimationController = new ExpandedAnimationController(
- mDisplaySize, mExpandedViewPadding);
+ mDisplaySize, mExpandedViewPadding, res.getConfiguration().orientation);
mSurfaceSynchronizer = synchronizer != null ? synchronizer : DEFAULT_SURFACE_SYNCHRONIZER;
mBubbleContainer = new PhysicsAnimationLayout(context);
@@ -335,6 +361,8 @@
mBubbleContainer.setClipChildren(false);
addView(mBubbleContainer, new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
+ mBubbleIconFactory = new BubbleIconFactory(context);
+
mExpandedViewContainer = new FrameLayout(context);
mExpandedViewContainer.setElevation(elevation);
mExpandedViewContainer.setPadding(mExpandedViewPadding, mExpandedViewPadding,
@@ -342,15 +370,9 @@
mExpandedViewContainer.setClipChildren(false);
addView(mExpandedViewContainer);
- mFlyout = new BubbleFlyoutView(context);
- mFlyout.setVisibility(GONE);
- mFlyout.animate()
- .setDuration(FLYOUT_ALPHA_ANIMATION_DURATION)
- .setInterpolator(new AccelerateDecelerateInterpolator());
- addView(mFlyout, new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
-
+ setUpFlyout();
mFlyoutTransitionSpring.setSpring(new SpringForce()
- .setStiffness(SpringForce.STIFFNESS_MEDIUM)
+ .setStiffness(SpringForce.STIFFNESS_LOW)
.setDampingRatio(SpringForce.DAMPING_RATIO_LOW_BOUNCY));
mFlyoutTransitionSpring.addEndListener(mAfterFlyoutTransitionSpring);
@@ -361,13 +383,6 @@
Gravity.BOTTOM));
addView(mDismissContainer);
- mDismissContainer = new BubbleDismissView(mContext);
- mDismissContainer.setLayoutParams(new FrameLayout.LayoutParams(
- MATCH_PARENT,
- getResources().getDimensionPixelSize(R.dimen.pip_dismiss_gradient_height),
- Gravity.BOTTOM));
- addView(mDismissContainer);
-
mExpandedViewXAnim =
new SpringAnimation(mExpandedViewContainer, DynamicAnimation.TRANSLATION_X);
mExpandedViewXAnim.setSpring(
@@ -383,7 +398,7 @@
.setDampingRatio(SpringForce.DAMPING_RATIO_LOW_BOUNCY));
mExpandedViewYAnim.addEndListener((anim, cancelled, value, velocity) -> {
if (mIsExpanded && mExpandedBubble != null) {
- mExpandedBubble.expandedView.updateView();
+ mExpandedBubble.getExpandedView().updateView();
}
});
@@ -392,34 +407,58 @@
mBubbleContainer.bringToFront();
setOnApplyWindowInsetsListener((View view, WindowInsets insets) -> {
- final int keyboardHeight = insets.getSystemWindowInsetBottom()
- - insets.getStableInsetBottom();
if (!mIsExpanded || mIsExpansionAnimating) {
return view.onApplyWindowInsets(insets);
}
- mImeVisible = keyboardHeight != 0;
-
- float newY = getYPositionForExpandedView();
- if (newY < 0) {
- // TODO: This means our expanded content is too big to fit on screen. Right now
- // we'll let it translate off but we should be clipping it & pushing the header
- // down so that it always remains visible.
- }
- mExpandedViewYAnim.animateToFinalPosition(newY);
mExpandedAnimationController.updateYPosition(
// Update the insets after we're done translating otherwise position
// calculation for them won't be correct.
- () -> mExpandedBubble.expandedView.updateInsets(insets));
+ () -> mExpandedBubble.getExpandedView().updateInsets(insets));
return view.onApplyWindowInsets(insets);
});
- mMoveStackToValidPositionOnLayoutListener =
+ mOrientationChangedListener =
(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
+ mExpandedAnimationController.updateOrientation(mOrientation, mDisplaySize);
+ mStackAnimationController.updateOrientation(mOrientation);
+
+ // Reposition & adjust the height for new orientation
+ if (mIsExpanded) {
+ mExpandedViewContainer.setTranslationY(getExpandedViewY());
+ mExpandedBubble.getExpandedView().updateView();
+ }
+
+ // Need to update the padding around the view
+ WindowInsets insets = getRootWindowInsets();
+ int leftPadding = mExpandedViewPadding;
+ int rightPadding = mExpandedViewPadding;
+ if (insets != null) {
+ // Can't have the expanded view overlaying notches
+ int cutoutLeft = 0;
+ int cutoutRight = 0;
+ DisplayCutout cutout = insets.getDisplayCutout();
+ if (cutout != null) {
+ cutoutLeft = cutout.getSafeInsetLeft();
+ cutoutRight = cutout.getSafeInsetRight();
+ }
+ // Or overlaying nav or status bar
+ leftPadding += Math.max(cutoutLeft, insets.getStableInsetLeft());
+ rightPadding += Math.max(cutoutRight, insets.getStableInsetRight());
+ }
+ mExpandedViewContainer.setPadding(leftPadding, mExpandedViewPadding,
+ rightPadding, mExpandedViewPadding);
+
+ if (mIsExpanded) {
+ // Re-draw bubble row and pointer for new orientation.
+ mExpandedAnimationController.expandFromStack(() -> {
+ updatePointerPosition();
+ } /* after */);
+ }
if (mVerticalPosPercentBeforeRotation >= 0) {
mStackAnimationController.moveStackToSimilarPositionAfterRotation(
mWasOnLeftBeforeRotation, mVerticalPosPercentBeforeRotation);
}
- removeOnLayoutChangeListener(mMoveStackToValidPositionOnLayoutListener);
+ removeOnLayoutChangeListener(mOrientationChangedListener);
};
// This must be a separate OnDrawListener since it should be called for every draw.
@@ -449,25 +488,53 @@
});
}
+ private void setUpFlyout() {
+ if (mFlyout != null) {
+ removeView(mFlyout);
+ }
+ mFlyout = new BubbleFlyoutView(getContext());
+ mFlyout.setVisibility(GONE);
+ mFlyout.animate()
+ .setDuration(FLYOUT_ALPHA_ANIMATION_DURATION)
+ .setInterpolator(new AccelerateDecelerateInterpolator());
+ addView(mFlyout, new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
+ }
+
/**
* Handle theme changes.
*/
public void onThemeChanged() {
+ // Recreate icon factory to update default adaptive icon scale.
+ mBubbleIconFactory = new BubbleIconFactory(mContext);
+ setUpFlyout();
for (Bubble b: mBubbleData.getBubbles()) {
- b.iconView.updateViews();
- b.expandedView.applyThemeAttrs();
+ b.getIconView().setBubbleIconFactory(mBubbleIconFactory);
+ b.getIconView().updateViews();
+ b.getExpandedView().applyThemeAttrs();
}
}
/** Respond to the phone being rotated by repositioning the stack and hiding any flyouts. */
- public void onOrientationChanged() {
+ public void onOrientationChanged(int orientation) {
+ mOrientation = orientation;
+
+ // Display size is based on the rotation device was in when requested, we should update it
+ // We use the real size & subtract screen decorations / window insets ourselves when needed
+ WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
+ wm.getDefaultDisplay().getRealSize(mDisplaySize);
+
+ // Some resources change depending on orientation
+ Resources res = getContext().getResources();
+ mStatusBarHeight = res.getDimensionPixelSize(
+ com.android.internal.R.dimen.status_bar_height);
+ mBubblePaddingTop = res.getDimensionPixelSize(R.dimen.bubble_padding_top);
+
final RectF allowablePos = mStackAnimationController.getAllowableStackPositionRegion();
mWasOnLeftBeforeRotation = mStackAnimationController.isStackOnLeftSide();
mVerticalPosPercentBeforeRotation =
(mStackAnimationController.getStackPosition().y - allowablePos.top)
/ (allowablePos.bottom - allowablePos.top);
- addOnLayoutChangeListener(mMoveStackToValidPositionOnLayoutListener);
-
+ addOnLayoutChangeListener(mOrientationChangedListener);
hideFlyoutImmediate();
}
@@ -483,18 +550,6 @@
}
@Override
- public boolean onInterceptTouchEvent(MotionEvent ev) {
- float x = ev.getRawX();
- float y = ev.getRawY();
- // If we're expanded only intercept if the tap is outside of the widget container
- if (mIsExpanded && isIntersecting(mExpandedViewContainer, x, y)) {
- return false;
- } else {
- return isIntersecting(mBubbleContainer, x, y);
- }
- }
-
- @Override
public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfoInternal(info);
@@ -570,7 +625,7 @@
}
Bubble topBubble = mBubbleData.getBubbles().get(0);
String appName = topBubble.getAppName();
- Notification notification = topBubble.entry.notification.getNotification();
+ Notification notification = topBubble.getEntry().notification.getNotification();
CharSequence titleCharSeq = notification.extras.getCharSequence(Notification.EXTRA_TITLE);
String titleStr = getResources().getString(R.string.stream_notification);
if (titleCharSeq != null) {
@@ -616,6 +671,7 @@
/**
* Updates the visibility of the 'dot' indicating an update on the bubble.
+ *
* @param key the {@link NotificationEntry#key} associated with the bubble.
*/
public void updateDotVisibility(String key) {
@@ -640,10 +696,17 @@
}
/**
+ * Whether the stack of bubbles is animating to or from expansion.
+ */
+ public boolean isExpansionAnimating() {
+ return mIsExpansionAnimating;
+ }
+
+ /**
* The {@link BubbleView} that is expanded, null if one does not exist.
*/
BubbleView getExpandedBubbleView() {
- return mExpandedBubble != null ? mExpandedBubble.iconView : null;
+ return mExpandedBubble != null ? mExpandedBubble.getIconView() : null;
}
/**
@@ -664,36 +727,33 @@
Bubble bubbleToExpand = mBubbleData.getBubbleWithKey(key);
if (bubbleToExpand != null) {
setSelectedBubble(bubbleToExpand);
- bubbleToExpand.entry.setShowInShadeWhenBubble(false);
+ bubbleToExpand.setShowInShadeWhenBubble(false);
setExpanded(true);
}
}
- /**
- * Sets the entry that should be expanded and expands if needed.
- */
- @VisibleForTesting
- void setExpandedBubble(NotificationEntry entry) {
- for (int i = 0; i < mBubbleContainer.getChildCount(); i++) {
- BubbleView bv = (BubbleView) mBubbleContainer.getChildAt(i);
- if (entry.equals(bv.getEntry())) {
- setExpandedBubble(entry.key);
- }
- }
- }
-
// via BubbleData.Listener
void addBubble(Bubble bubble) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "addBubble: " + bubble);
}
- bubble.inflate(mInflater, this);
- mBubbleContainer.addView(bubble.iconView, 0,
- new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
- ViewClippingUtil.setClippingDeactivated(bubble.iconView, true, mClippingParameters);
- if (bubble.iconView != null) {
- bubble.iconView.setSuppressDot(mSuppressNewDot, false /* animate */);
+
+ if (mBubbleContainer.getChildCount() == 0) {
+ mStackOnLeftOrWillBe = mStackAnimationController.isStackOnLeftSide();
}
+
+ bubble.inflate(mInflater, this);
+ bubble.getIconView().setBubbleIconFactory(mBubbleIconFactory);
+ bubble.getIconView().updateViews();
+
+ // Set the dot position to the opposite of the side the stack is resting on, since the stack
+ // resting slightly off-screen would result in the dot also being off-screen.
+ bubble.getIconView().setDotPosition(
+ !mStackOnLeftOrWillBe /* onLeft */, false /* animate */);
+
+ mBubbleContainer.addView(bubble.getIconView(), 0,
+ new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
+ ViewClippingUtil.setClippingDeactivated(bubble.getIconView(), true, mClippingParameters);
animateInFlyoutForBubble(bubble);
requestUpdate();
logBubbleEvent(bubble, StatsLog.BUBBLE_UICHANGED__ACTION__POSTED);
@@ -702,13 +762,14 @@
// via BubbleData.Listener
void removeBubble(Bubble bubble) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "removeBubble: " + bubble);
}
// Remove it from the views
- int removedIndex = mBubbleContainer.indexOfChild(bubble.iconView);
+ int removedIndex = mBubbleContainer.indexOfChild(bubble.getIconView());
if (removedIndex >= 0) {
mBubbleContainer.removeViewAt(removedIndex);
+ bubble.cleanupExpandedState();
logBubbleEvent(bubble, StatsLog.BUBBLE_UICHANGED__ACTION__DISMISSED);
} else {
Log.d(TAG, "was asked to remove Bubble, but didn't find the view! " + bubble);
@@ -726,8 +787,10 @@
public void updateBubbleOrder(List<Bubble> bubbles) {
for (int i = 0; i < bubbles.size(); i++) {
Bubble bubble = bubbles.get(i);
- mBubbleContainer.reorderView(bubble.iconView, i);
+ mBubbleContainer.reorderView(bubble.getIconView(), i);
}
+
+ updateBubbleZOrdersAndDotPosition(false /* animate */);
}
/**
@@ -737,7 +800,7 @@
*/
// via BubbleData.Listener
public void setSelectedBubble(@Nullable Bubble bubbleToSelect) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "setSelectedBubble: " + bubbleToSelect);
}
if (mExpandedBubble != null && mExpandedBubble.equals(bubbleToSelect)) {
@@ -760,9 +823,8 @@
requestUpdate();
logBubbleEvent(previouslySelected, StatsLog.BUBBLE_UICHANGED__ACTION__COLLAPSED);
logBubbleEvent(bubbleToSelect, StatsLog.BUBBLE_UICHANGED__ACTION__EXPANDED);
- notifyExpansionChanged(previouslySelected.entry, false /* expanded */);
- notifyExpansionChanged(bubbleToSelect == null ? null : bubbleToSelect.entry,
- true /* expanded */);
+ notifyExpansionChanged(previouslySelected, false /* expanded */);
+ notifyExpansionChanged(bubbleToSelect, true /* expanded */);
});
}
}
@@ -774,42 +836,32 @@
*/
// via BubbleData.Listener
public void setExpanded(boolean shouldExpand) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "setExpanded: " + shouldExpand);
}
- boolean wasExpanded = mIsExpanded;
- if (shouldExpand == wasExpanded) {
+ if (shouldExpand == mIsExpanded) {
return;
}
- if (wasExpanded) {
- // Collapse the stack
- mExpandedViewContainer.setAlpha(0.0f);
- // TODO: In order to prevent flicker, code below should be executed after the alpha
- // value set on the mExpandedViewContainer is reflected on the screen. However, we
- // cannot just postpone the execution like #setSelectedBubble(), since some of member
- // variables referred by the code are overridden before the execution.
- if (mExpandedBubble != null) {
- mExpandedBubble.setContentVisibility(false);
- }
- animateExpansion(false /* expand */);
+ if (mIsExpanded) {
+ animateCollapse();
logBubbleEvent(mExpandedBubble, StatsLog.BUBBLE_UICHANGED__ACTION__COLLAPSED);
} else {
- // Expand the stack
- animateExpansion(true /* expand */);
+ animateExpansion();
// TODO: move next line to BubbleData
logBubbleEvent(mExpandedBubble, StatsLog.BUBBLE_UICHANGED__ACTION__EXPANDED);
logBubbleEvent(mExpandedBubble, StatsLog.BUBBLE_UICHANGED__ACTION__STACK_EXPANDED);
}
- notifyExpansionChanged(mExpandedBubble.entry, mIsExpanded);
+ notifyExpansionChanged(mExpandedBubble, mIsExpanded);
}
/**
* Dismiss the stack of bubbles.
+ *
* @deprecated
*/
@Deprecated
void stackDismissed(int reason) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "stackDismissed: reason=" + reason);
}
mBubbleData.dismissAll(reason);
@@ -826,21 +878,23 @@
float y = event.getRawY();
if (mIsExpanded) {
if (isIntersecting(mBubbleContainer, x, y)) {
+ // Could be tapping or dragging a bubble while expanded
for (int i = 0; i < mBubbleContainer.getChildCount(); i++) {
BubbleView view = (BubbleView) mBubbleContainer.getChildAt(i);
if (isIntersecting(view, x, y)) {
return view;
}
}
- } else if (isIntersecting(mExpandedViewContainer, x, y)) {
- return mExpandedViewContainer;
}
- // Outside parts of view we care about.
+ BubbleExpandedView bev = (BubbleExpandedView) mExpandedViewContainer.getChildAt(0);
+ if (bev.intersectingTouchableContent((int) x, (int) y)) {
+ return bev;
+ }
+ // Outside of the parts we care about.
return null;
} else if (mFlyout.getVisibility() == VISIBLE && isIntersecting(mFlyout, x, y)) {
return mFlyout;
}
-
// If it wasn't an individual bubble in the expanded state, or the flyout, it's the stack.
return this;
}
@@ -859,7 +913,7 @@
@Deprecated
@MainThread
void collapseStack() {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "collapseStack()");
}
mBubbleData.setExpanded(false);
@@ -871,7 +925,7 @@
@Deprecated
@MainThread
void collapseStack(Runnable endRunnable) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "collapseStack(endRunnable)");
}
collapseStack();
@@ -889,73 +943,83 @@
@Deprecated
@MainThread
void expandStack() {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "expandStack()");
}
mBubbleData.setExpanded(true);
}
- /**
- * Tell the stack to animate to collapsed or expanded state.
- */
- private void animateExpansion(boolean shouldExpand) {
- if (DEBUG) {
- Log.d(TAG, "animateExpansion: shouldExpand=" + shouldExpand);
- }
- if (mIsExpanded != shouldExpand) {
- hideFlyoutImmediate();
-
- mIsExpanded = shouldExpand;
- updateExpandedBubble();
- applyCurrentState();
-
- mIsExpansionAnimating = true;
-
- Runnable updateAfter = () -> {
- applyCurrentState();
- mIsExpansionAnimating = false;
- requestUpdate();
- };
-
- if (shouldExpand) {
- mBubbleContainer.setActiveController(mExpandedAnimationController);
- mExpandedAnimationController.expandFromStack(() -> {
- updatePointerPosition();
- updateAfter.run();
- } /* after */);
- } else {
- mBubbleContainer.cancelAllAnimations();
- mExpandedAnimationController.collapseBackToStack(
- mStackAnimationController.getStackPositionAlongNearestHorizontalEdge(),
- () -> {
- mBubbleContainer.setActiveController(mStackAnimationController);
- updateAfter.run();
- });
- }
-
- final float xStart =
- mStackAnimationController.getStackPosition().x < getWidth() / 2
- ? -mExpandedAnimateXDistance
- : mExpandedAnimateXDistance;
-
- final float yStart = Math.min(
- mStackAnimationController.getStackPosition().y,
- mExpandedAnimateYDistance);
- final float yDest = getYPositionForExpandedView();
-
- if (shouldExpand) {
- mExpandedViewContainer.setTranslationX(xStart);
- mExpandedViewContainer.setTranslationY(yStart);
- }
-
- mExpandedViewXAnim.animateToFinalPosition(shouldExpand ? 0f : xStart);
- mExpandedViewYAnim.animateToFinalPosition(shouldExpand ? yDest : yStart);
- }
+ private void beforeExpandedViewAnimation() {
+ hideFlyoutImmediate();
+ updateExpandedBubble();
+ updateExpandedView();
+ mIsExpansionAnimating = true;
}
- private void notifyExpansionChanged(NotificationEntry entry, boolean expanded) {
- if (mExpandListener != null) {
- mExpandListener.onBubbleExpandChanged(expanded, entry != null ? entry.key : null);
+ private void afterExpandedViewAnimation() {
+ updateExpandedView();
+ mIsExpansionAnimating = false;
+ requestUpdate();
+ }
+
+ private void animateCollapse() {
+ mIsExpanded = false;
+ final Bubble previouslySelected = mExpandedBubble;
+ beforeExpandedViewAnimation();
+
+ mBubbleContainer.cancelAllAnimations();
+ mExpandedAnimationController.collapseBackToStack(
+ mStackAnimationController.getStackPositionAlongNearestHorizontalEdge()
+ /* collapseTo */,
+ () -> {
+ mBubbleContainer.setActiveController(mStackAnimationController);
+ afterExpandedViewAnimation();
+ previouslySelected.setContentVisibility(false);
+ });
+
+ mExpandedViewXAnim.animateToFinalPosition(getCollapsedX());
+ mExpandedViewYAnim.animateToFinalPosition(getCollapsedY());
+ mExpandedViewContainer.animate()
+ .setDuration(100)
+ .alpha(0f);
+ }
+
+ private void animateExpansion() {
+ mIsExpanded = true;
+ beforeExpandedViewAnimation();
+
+ mBubbleContainer.setActiveController(mExpandedAnimationController);
+ mExpandedAnimationController.expandFromStack(() -> {
+ updatePointerPosition();
+ afterExpandedViewAnimation();
+ } /* after */);
+
+
+ mExpandedViewContainer.setTranslationX(getCollapsedX());
+ mExpandedViewContainer.setTranslationY(getCollapsedY());
+ mExpandedViewContainer.setAlpha(0f);
+
+ mExpandedViewXAnim.animateToFinalPosition(0f);
+ mExpandedViewYAnim.animateToFinalPosition(getExpandedViewY());
+ mExpandedViewContainer.animate()
+ .setDuration(100)
+ .alpha(1f);
+ }
+
+ private float getCollapsedX() {
+ return mStackAnimationController.getStackPosition().x < getWidth() / 2
+ ? -mExpandedAnimateXDistance
+ : mExpandedAnimateXDistance;
+ }
+
+ private float getCollapsedY() {
+ return Math.min(mStackAnimationController.getStackPosition().y,
+ mExpandedAnimateYDistance);
+ }
+
+ private void notifyExpansionChanged(Bubble bubble, boolean expanded) {
+ if (mExpandListener != null && bubble != null) {
+ mExpandListener.onBubbleExpandChanged(expanded, bubble.getKey());
}
}
@@ -968,7 +1032,7 @@
/** Moves the bubbles out of the way if they're going to be over the keyboard. */
public void onImeVisibilityChanged(boolean visible, int height) {
- mStackAnimationController.setImeHeight(height + mImeOffset);
+ mStackAnimationController.setImeHeight(visible ? height + mImeOffset : 0);
if (!mIsExpanded) {
mStackAnimationController.animateForImeVisibility(visible);
@@ -977,7 +1041,7 @@
/** Called when a drag operation on an individual bubble has started. */
public void onBubbleDragStart(View bubble) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "onBubbleDragStart: bubble=" + bubble);
}
mExpandedAnimationController.prepareForBubbleDrag(bubble);
@@ -996,7 +1060,7 @@
/** Called when a drag operation on an individual bubble has finished. */
public void onBubbleDragFinish(
View bubble, float x, float y, float velX, float velY) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "onBubbleDragFinish: bubble=" + bubble);
}
@@ -1005,11 +1069,11 @@
}
mExpandedAnimationController.snapBubbleBack(bubble, velX, velY);
- springOutDismissTargetAndHideCircle();
+ hideDismissTarget();
}
void onDragStart() {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "onDragStart()");
}
if (mIsExpanded || mIsExpansionAnimating) {
@@ -1033,7 +1097,7 @@
}
void onDragFinish(float x, float y, float velX, float velY) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "onDragFinish");
}
@@ -1046,8 +1110,8 @@
StatsLog.BUBBLE_UICHANGED__ACTION__STACK_MOVED);
mStackOnLeftOrWillBe = newStackX <= 0;
- updateBubbleShadowsAndDotPosition(true /* animate */);
- springOutDismissTargetAndHideCircle();
+ updateBubbleZOrdersAndDotPosition(true /* animate */);
+ hideDismissTarget();
}
void onFlyoutDragStart() {
@@ -1055,6 +1119,12 @@
}
void onFlyoutDragged(float deltaX) {
+ // This shouldn't happen, but if it does, just wait until the flyout lays out. This method
+ // is continually called.
+ if (mFlyout.getWidth() <= 0) {
+ return;
+ }
+
final boolean onLeft = mStackAnimationController.isStackOnLeftSide();
mFlyoutDragDeltaX = deltaX;
@@ -1062,7 +1132,7 @@
onLeft ? -deltaX / mFlyout.getWidth() : deltaX / mFlyout.getWidth();
mFlyout.setCollapsePercent(Math.min(1f, Math.max(0f, collapsePercent)));
- // Calculate how to translate the flyout if it has been dragged too far in etiher direction.
+ // Calculate how to translate the flyout if it has been dragged too far in either direction.
float overscrollTranslation = 0f;
if (collapsePercent < 0f || collapsePercent > 1f) {
// Whether we are more than 100% transitioned to the dot.
@@ -1073,7 +1143,6 @@
// after it has already become the dot.
final boolean overscrollingLeft =
(onLeft && collapsePercent > 1f) || (!onLeft && collapsePercent < 0f);
-
overscrollTranslation =
(overscrollingPastDot ? collapsePercent - 1f : collapsePercent * -1)
* (overscrollingLeft ? -1 : 1)
@@ -1086,6 +1155,19 @@
}
/**
+ * Set when the flyout is tapped, so that we can expand the bubble associated with the flyout
+ * once it collapses.
+ */
+ @Nullable private Bubble mBubbleToExpandAfterFlyoutCollapse = null;
+
+ void onFlyoutTapped() {
+ mBubbleToExpandAfterFlyoutCollapse = mBubbleData.getSelectedBubble();
+
+ mFlyout.removeCallbacks(mHideFlyout);
+ mHideFlyout.run();
+ }
+
+ /**
* Called when the flyout drag has finished, and returns true if the gesture successfully
* dismissed the flyout.
*/
@@ -1181,9 +1263,6 @@
animateDesaturateAndDarken(magnetView, true);
}
-
- mDismissContainer.animateEncircleCenterWithX(true);
-
} else {
mAnimatingMagnet = false;
@@ -1194,8 +1273,6 @@
mExpandedAnimationController.demagnetizeBubbleTo(x, y, velX, velY);
animateDesaturateAndDarken(magnetView, false);
}
-
- mDismissContainer.animateEncircleCenterWithX(false);
}
mVibrator.vibrate(VibrationEffect.get(toTarget
@@ -1214,7 +1291,7 @@
mAfterMagnet = null;
mVibrator.vibrate(VibrationEffect.get(VibrationEffect.EFFECT_CLICK));
- mDismissContainer.animateEncirclingCircleDisappearance();
+ mDismissContainer.springOut();
// 'Implode' the stack and then hide the dismiss target.
if (touchedView == this) {
@@ -1252,7 +1329,7 @@
}
}
- /** Animates in the dismiss target, including the gradient behind it. */
+ /** Animates in the dismiss target. */
private void springInDismissTarget() {
if (mShowingDismiss) {
return;
@@ -1270,7 +1347,7 @@
* Animates the dismiss target out, as well as the circle that encircles the bubbles, if they
* were dragged into the target and encircled.
*/
- private void springOutDismissTargetAndHideCircle() {
+ private void hideDismissTarget() {
if (!mShowingDismiss) {
return;
}
@@ -1287,6 +1364,12 @@
/** Animates the flyout collapsed (to dot), or the reverse, starting with the given velocity. */
private void animateFlyoutCollapsed(boolean collapsed, float velX) {
final boolean onLeft = mStackAnimationController.isStackOnLeftSide();
+ // If the flyout was tapped, we want a higher stiffness for the collapse animation so it's
+ // faster.
+ mFlyoutTransitionSpring.getSpring().setStiffness(
+ (mBubbleToExpandAfterFlyoutCollapse != null)
+ ? SpringForce.STIFFNESS_MEDIUM
+ : SpringForce.STIFFNESS_LOW);
mFlyoutTransitionSpring
.setStartValue(mFlyoutDragDeltaX)
.setStartVelocity(velX)
@@ -1295,123 +1378,121 @@
: 0f);
}
- /**
- * Calculates how large the expanded view of the bubble can be. This takes into account the
- * y position when the bubbles are expanded as well as the bounds of the dismiss target.
- */
- int getMaxExpandedHeight() {
- int expandedY = (int) mExpandedAnimationController.getExpandedY();
- // PIP dismiss view uses FLAG_LAYOUT_IN_SCREEN so we need to subtract the bottom inset
- int pipDismissHeight = mPipDismissHeight - getBottomInset();
- return mDisplaySize.y - expandedY - mBubbleSize - pipDismissHeight;
+ /** Updates the dot visibility, this is used in response to a zen mode config change. */
+ void updateDots() {
+ int bubbsCount = mBubbleContainer.getChildCount();
+ for (int i = 0; i < bubbsCount; i++) {
+ BubbleView bv = (BubbleView) mBubbleContainer.getChildAt(i);
+ // If nothing changed the animation won't happen
+ bv.updateDotVisibility(true /* animate */);
+ }
}
/**
* Calculates the y position of the expanded view when it is expanded.
*/
- float getYPositionForExpandedView() {
- return getStatusBarHeight() + mBubbleSize + mBubblePadding + mPointerHeight;
+ float getExpandedViewY() {
+ return getStatusBarHeight() + mBubbleSize + mBubblePaddingTop + mPointerHeight;
}
/**
- * Called when the height of the currently expanded view has changed (not via an
- * update to the bubble's desired height but for some other reason, e.g. permission view
- * goes away).
- */
- void onExpandedHeightChanged() {
- if (mIsExpanded) {
- requestUpdate();
- }
- }
-
- /** Sets whether all bubbles in the stack should not show the 'new' dot. */
- void setSuppressNewDot(boolean suppressNewDot) {
- mSuppressNewDot = suppressNewDot;
-
- for (int i = 0; i < mBubbleContainer.getChildCount(); i++) {
- BubbleView bv = (BubbleView) mBubbleContainer.getChildAt(i);
- bv.setSuppressDot(suppressNewDot, true /* animate */);
- }
- }
-
- /**
- * Sets whether the flyout should not appear, even if the notif otherwise would generate one.
- */
- void setSuppressFlyout(boolean suppressFlyout) {
- mSuppressFlyout = suppressFlyout;
- }
-
- /**
- * Callback to run after the flyout hides. Also called if a new flyout is shown before the
- * previous one animates out.
- */
- private Runnable mAfterFlyoutHides;
-
- /**
* Animates in the flyout for the given bubble, if available, and then hides it after some time.
*/
@VisibleForTesting
void animateInFlyoutForBubble(Bubble bubble) {
- final CharSequence updateMessage = bubble.entry.getUpdateMessage(getContext());
+ final CharSequence updateMessage = bubble.getUpdateMessage(getContext());
- // Show the message if one exists, and we're not expanded or animating expansion.
- if (updateMessage != null
- && !isExpanded()
- && !mIsExpansionAnimating
- && !mIsGestureInProgress
- && !mSuppressFlyout) {
- if (bubble.iconView != null) {
- // Temporarily suppress the dot while the flyout is visible.
- bubble.iconView.setSuppressDot(
- true /* suppressDot */, false /* animate */);
+ if (!bubble.showFlyoutForBubble()) {
+ // In case flyout was suppressed for this update, reset now.
+ bubble.setSuppressFlyout(false);
+ return;
+ }
- mFlyoutDragDeltaX = 0f;
- mFlyout.setAlpha(0f);
+ if (updateMessage == null
+ || isExpanded()
+ || mIsExpansionAnimating
+ || mIsGestureInProgress
+ || mBubbleToExpandAfterFlyoutCollapse != null) {
+ // Skip the message if none exists, we're expanded or animating expansion, or we're
+ // about to expand a bubble from the previous tapped flyout.
+ return;
+ }
- if (mAfterFlyoutHides != null) {
- mAfterFlyoutHides.run();
- }
+ if (bubble.getIconView() != null) {
+ // Temporarily suppress the dot while the flyout is visible.
+ bubble.getIconView().setSuppressDot(
+ true /* suppressDot */, false /* animate */);
- mAfterFlyoutHides = () -> {
- if (bubble.iconView == null) {
- return;
- }
+ mFlyout.removeCallbacks(mAnimateInFlyout);
+ mFlyoutDragDeltaX = 0f;
- // If we're going to suppress the dot, make it visible first so it'll
- // visibly animate away.
- if (mSuppressNewDot) {
- bubble.iconView.setSuppressDot(
- false /* suppressDot */, false /* animate */);
- }
-
- // Reset dot suppression. If we're not suppressing due to DND, then
- // stop suppressing it with no animation (since the flyout has
- // transformed into the dot). If we are suppressing due to DND, animate
- // it away.
- bubble.iconView.setSuppressDot(
- mSuppressNewDot /* suppressDot */,
- mSuppressNewDot /* animate */);
- };
-
- // Post in case layout isn't complete and getWidth returns 0.
- post(() -> {
- // An auto-expanding bubble could have been posted during the time it takes to
- // layout.
- if (isExpanded()) {
- return;
- }
-
- mFlyout.showFlyout(
- updateMessage, mStackAnimationController.getStackPosition(), getWidth(),
- mStackAnimationController.isStackOnLeftSide(),
- bubble.iconView.getBadgeColor(), mAfterFlyoutHides);
- });
+ if (mAfterFlyoutHides != null) {
+ mAfterFlyoutHides.run();
}
- mFlyout.removeCallbacks(mHideFlyout);
- mFlyout.postDelayed(mHideFlyout, FLYOUT_HIDE_AFTER);
- logBubbleEvent(bubble, StatsLog.BUBBLE_UICHANGED__ACTION__FLYOUT);
+ mAfterFlyoutHides = () -> {
+ final boolean suppressDot = !bubble.showBubbleDot();
+ // If we're going to suppress the dot, make it visible first so it'll
+ // visibly animate away.
+ if (suppressDot) {
+ bubble.getIconView().setSuppressDot(
+ false /* suppressDot */, false /* animate */);
+ }
+ // Reset dot suppression. If we're not suppressing due to DND, then
+ // stop suppressing it with no animation (since the flyout has
+ // transformed into the dot). If we are suppressing due to DND, animate
+ // it away.
+ bubble.getIconView().setSuppressDot(
+ suppressDot /* suppressDot */,
+ suppressDot /* animate */);
+
+ if (mBubbleToExpandAfterFlyoutCollapse != null) {
+ mBubbleData.setSelectedBubble(mBubbleToExpandAfterFlyoutCollapse);
+ mBubbleData.setExpanded(true);
+ mBubbleToExpandAfterFlyoutCollapse = null;
+ }
+ };
+
+ mFlyout.setVisibility(INVISIBLE);
+
+ // Post in case layout isn't complete and getWidth returns 0.
+ post(() -> {
+ // An auto-expanding bubble could have been posted during the time it takes to
+ // layout.
+ if (isExpanded()) {
+ return;
+ }
+
+ final Runnable afterShow = () -> {
+ mAnimateInFlyout = () -> {
+ mFlyout.setVisibility(VISIBLE);
+ bubble.getIconView().setSuppressDot(
+ true /* suppressDot */, false /* animate */);
+ mFlyoutDragDeltaX =
+ mStackAnimationController.isStackOnLeftSide()
+ ? -mFlyout.getWidth()
+ : mFlyout.getWidth();
+ animateFlyoutCollapsed(false /* collapsed */, 0 /* velX */);
+ mFlyout.postDelayed(mHideFlyout, FLYOUT_HIDE_AFTER);
+ };
+
+ mFlyout.postDelayed(mAnimateInFlyout, 200);
+ };
+
+ mFlyout.setupFlyoutStartingAsDot(
+ updateMessage, mStackAnimationController.getStackPosition(), getWidth(),
+ mStackAnimationController.isStackOnLeftSide(),
+ bubble.getIconView().getBadgeColor(),
+ afterShow,
+ mAfterFlyoutHides,
+ bubble.getIconView().getDotCenter());
+ mFlyout.bringToFront();
+ });
}
+
+ mFlyout.removeCallbacks(mHideFlyout);
+ mFlyout.postDelayed(mHideFlyout, FLYOUT_HIDE_AFTER);
+ logBubbleEvent(bubble, StatsLog.BUBBLE_UICHANGED__ACTION__FLYOUT);
}
/** Hide the flyout immediately and cancel any pending hide runnables. */
@@ -1420,6 +1501,7 @@
mAfterFlyoutHides.run();
}
+ mFlyout.removeCallbacks(mAnimateInFlyout);
mFlyout.removeCallbacks(mHideFlyout);
mFlyout.hideFlyout();
}
@@ -1430,6 +1512,11 @@
if (mBubbleContainer.getChildCount() > 0) {
mBubbleContainer.getChildAt(0).getBoundsOnScreen(outRect);
}
+ // Increase the touch target size of the bubble
+ outRect.top -= mBubbleTouchPadding;
+ outRect.left -= mBubbleTouchPadding;
+ outRect.right += mBubbleTouchPadding;
+ outRect.bottom += mBubbleTouchPadding;
} else {
mBubbleContainer.getBoundsOnScreen(outRect);
}
@@ -1454,14 +1541,6 @@
return 0;
}
- private int getBottomInset() {
- if (getRootWindowInsets() != null) {
- WindowInsets insets = getRootWindowInsets();
- return insets.getSystemWindowInsetBottom();
- }
- return 0;
- }
-
private boolean isIntersecting(View view, float x, float y) {
mTempLoc = view.getLocationOnScreen();
mTempRect.set(mTempLoc[0], mTempLoc[1], mTempLoc[0] + view.getWidth(),
@@ -1479,33 +1558,33 @@
}
private void updateExpandedBubble() {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "updateExpandedBubble()");
}
mExpandedViewContainer.removeAllViews();
if (mExpandedBubble != null && mIsExpanded) {
- mExpandedViewContainer.addView(mExpandedBubble.expandedView);
- mExpandedBubble.expandedView.populateExpandedView();
+ mExpandedViewContainer.addView(mExpandedBubble.getExpandedView());
+ mExpandedBubble.getExpandedView().populateExpandedView();
mExpandedViewContainer.setVisibility(mIsExpanded ? VISIBLE : GONE);
mExpandedViewContainer.setAlpha(1.0f);
}
}
- private void applyCurrentState() {
- if (DEBUG) {
- Log.d(TAG, "applyCurrentState: mIsExpanded=" + mIsExpanded);
+ private void updateExpandedView() {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
+ Log.d(TAG, "updateExpandedView: mIsExpanded=" + mIsExpanded);
}
mExpandedViewContainer.setVisibility(mIsExpanded ? VISIBLE : GONE);
if (mIsExpanded) {
// First update the view so that it calculates a new height (ensuring the y position
// calculation is correct)
- mExpandedBubble.expandedView.updateView();
- final float y = getYPositionForExpandedView();
+ mExpandedBubble.getExpandedView().updateView();
+ final float y = getExpandedViewY();
if (!mExpandedViewYAnim.isRunning()) {
// We're not animating so set the value
mExpandedViewContainer.setTranslationY(y);
- mExpandedBubble.expandedView.updateView();
+ mExpandedBubble.getExpandedView().updateView();
} else {
// We are animating so update the value; there is an end listener on the animator
// that will ensure expandedeView.updateView gets called.
@@ -1514,29 +1593,17 @@
}
mStackOnLeftOrWillBe = mStackAnimationController.isStackOnLeftSide();
- updateBubbleShadowsAndDotPosition(false);
+ updateBubbleZOrdersAndDotPosition(false);
}
/** Sets the appropriate Z-order and dot position for each bubble in the stack. */
- private void updateBubbleShadowsAndDotPosition(boolean animate) {
- int bubbsCount = mBubbleContainer.getChildCount();
- for (int i = 0; i < bubbsCount; i++) {
+ private void updateBubbleZOrdersAndDotPosition(boolean animate) {
+ int bubbleCount = mBubbleContainer.getChildCount();
+ for (int i = 0; i < bubbleCount; i++) {
BubbleView bv = (BubbleView) mBubbleContainer.getChildAt(i);
bv.updateDotVisibility(true /* animate */);
bv.setZ((BubbleController.MAX_BUBBLES
* getResources().getDimensionPixelSize(R.dimen.bubble_elevation)) - i);
-
- // Draw the shadow around the circle inscribed within the bubble's bounds. This
- // (intentionally) does not draw a shadow behind the update dot, which should be drawing
- // its own shadow since it's on a different (higher) plane.
- bv.setOutlineProvider(new ViewOutlineProvider() {
- @Override
- public void getOutline(View view, Outline outline) {
- outline.setOval(0, 0, mBubbleSize, mBubbleSize);
- }
- });
- bv.setClipToOutline(false);
-
// If the dot is on the left, and so is the stack, we need to change the dot position.
if (bv.getDotPositionOnLeft() == mStackOnLeftOrWillBe) {
bv.setDotPosition(!mStackOnLeftOrWillBe, animate);
@@ -1545,7 +1612,7 @@
}
private void updatePointerPosition() {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "updatePointerPosition()");
}
@@ -1557,13 +1624,11 @@
int index = getBubbleIndex(expandedBubble);
float bubbleLeftFromScreenLeft = mExpandedAnimationController.getBubbleLeft(index);
float halfBubble = mBubbleSize / 2f;
+ float bubbleCenter = bubbleLeftFromScreenLeft + halfBubble;
+ // Padding might be adjusted for insets, so get it directly from the view
+ bubbleCenter -= mExpandedViewContainer.getPaddingLeft();
- // Bubbles live in expanded view container (x includes expanded view padding).
- // Pointer lives in expanded view, which has padding (x does not include padding).
- // Remove padding when deriving pointer location from bubbles.
- float bubbleCenter = bubbleLeftFromScreenLeft + halfBubble - mExpandedViewPadding;
-
- expandedBubble.expandedView.setPointerPosition(bubbleCenter);
+ expandedBubble.getExpandedView().setPointerPosition(bubbleCenter);
}
/**
@@ -1584,7 +1649,7 @@
if (bubble == null) {
return 0;
}
- return mBubbleContainer.indexOfChild(bubble.iconView);
+ return mBubbleContainer.indexOfChild(bubble.getIconView());
}
/**
@@ -1617,8 +1682,8 @@
* @param action the user interaction enum.
*/
private void logBubbleEvent(@Nullable Bubble bubble, int action) {
- if (bubble == null || bubble.entry == null
- || bubble.entry.notification == null) {
+ if (bubble == null || bubble.getEntry() == null
+ || bubble.getEntry().notification == null) {
StatsLog.write(StatsLog.BUBBLE_UI_CHANGED,
null /* package name */,
null /* notification channel */,
@@ -1630,9 +1695,9 @@
getNormalizedYPosition(),
false /* unread bubble */,
false /* on-going bubble */,
- false /* foreground bubble */);
+ false /* isAppForeground (unused) */);
} else {
- StatusBarNotification notification = bubble.entry.notification;
+ StatusBarNotification notification = bubble.getEntry().notification;
StatsLog.write(StatsLog.BUBBLE_UI_CHANGED,
notification.getPackageName(),
notification.getNotification().getChannelId(),
@@ -1642,9 +1707,9 @@
action,
getNormalizedXPosition(),
getNormalizedYPosition(),
- bubble.entry.showInShadeWhenBubble(),
- bubble.entry.isForegroundService(),
- BubbleController.isForegroundApp(mContext, notification.getPackageName()));
+ bubble.showInShadeWhenBubble(),
+ bubble.isOngoing(),
+ false /* isAppForeground (unused) */);
}
}
@@ -1656,7 +1721,7 @@
if (!isExpanded()) {
return false;
}
- return mExpandedBubble.expandedView.performBackPressIfNeeded();
+ return mExpandedBubble.getExpandedView().performBackPressIfNeeded();
}
/** For debugging only */
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.java
index 8fe8bd3..4240e06 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.java
@@ -18,7 +18,6 @@
import android.content.Context;
import android.graphics.PointF;
-import android.os.Handler;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
@@ -45,7 +44,6 @@
*/
private static final float INDIVIDUAL_BUBBLE_DISMISS_MIN_VELOCITY = 6000f;
- private static final String TAG = "BubbleTouchHandler";
/**
* When the stack is flung towards the bottom of the screen, it'll be dismissed if it's flung
* towards the center of the screen (where the dismiss target is). This value is the width of
@@ -66,11 +64,10 @@
private int mTouchSlopSquared;
private VelocityTracker mVelocityTracker;
- private boolean mInDismissTarget;
- private Handler mHandler = new Handler();
-
/** View that was initially touched, when we received the first ACTION_DOWN event. */
private View mTouchedView;
+ /** Whether the current touched view is in the dismiss target. */
+ private boolean mInDismissTarget;
BubbleTouchHandler(BubbleStackView stackView,
BubbleData bubbleData, Context context) {
@@ -98,6 +95,15 @@
return false;
}
+ if (!(mTouchedView instanceof BubbleView)
+ && !(mTouchedView instanceof BubbleStackView)
+ && !(mTouchedView instanceof BubbleFlyoutView)) {
+ // Not touching anything touchable, but we shouldn't collapse (e.g. touching edge
+ // of expanded view).
+ resetForNextGesture();
+ return false;
+ }
+
final boolean isStack = mStack.equals(mTouchedView);
final boolean isFlyout = mStack.getFlyoutView().equals(mTouchedView);
final float rawX = event.getRawX();
@@ -193,9 +199,8 @@
}
});
} else if (isFlyout) {
- // TODO(b/129768381): Expand if tapped, dismiss if swiped away.
if (!mBubbleData.isExpanded() && !mMovedEnough) {
- mBubbleData.setExpanded(true);
+ mStack.onFlyoutTapped();
}
} else if (mMovedEnough) {
if (isStack) {
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java
index 6f1ed28..603c416 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java
@@ -19,16 +19,23 @@
import android.annotation.Nullable;
import android.app.Notification;
import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
import android.graphics.Color;
+import android.graphics.Matrix;
+import android.graphics.Path;
import android.graphics.drawable.AdaptiveIconDrawable;
+import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.graphics.drawable.InsetDrawable;
import android.util.AttributeSet;
+import android.util.PathParser;
import android.widget.FrameLayout;
import com.android.internal.graphics.ColorUtils;
+import com.android.launcher3.icons.ShadowGenerator;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
@@ -38,23 +45,25 @@
* A floating object on the screen that can post message updates.
*/
public class BubbleView extends FrameLayout {
- private static final String TAG = "BubbleView";
private static final int DARK_ICON_ALPHA = 180;
private static final double ICON_MIN_CONTRAST = 4.1;
- private static final int DEFAULT_BACKGROUND_COLOR = Color.LTGRAY;
+ private static final int DEFAULT_BACKGROUND_COLOR = Color.LTGRAY;
// Same value as Launcher3 badge code
private static final float WHITE_SCRIM_ALPHA = 0.54f;
private Context mContext;
private BadgedImageView mBadgedImageView;
private int mBadgeColor;
- private int mPadding;
private int mIconInset;
+ private Drawable mUserBadgedAppIcon;
+
+ // mBubbleIconFactory cannot be static because it depends on Context.
+ private BubbleIconFactory mBubbleIconFactory;
private boolean mSuppressDot = false;
- private NotificationEntry mEntry;
+ private Bubble mBubble;
public BubbleView(Context context) {
this(context, null);
@@ -71,8 +80,6 @@
public BubbleView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
mContext = context;
- // XXX: can this padding just be on the view and we look it up?
- mPadding = getResources().getDimensionPixelSize(R.dimen.bubble_view_padding);
mIconInset = getResources().getDimensionPixelSize(R.dimen.bubble_icon_inset);
}
@@ -88,16 +95,15 @@
}
/**
- * Populates this view with a notification.
+ * Populates this view with a bubble.
* <p>
- * This should only be called when a new notification is being set on the view, updates to the
- * current notification should use {@link #update(NotificationEntry)}.
+ * This should only be called when a new bubble is being set on the view, updates to the
+ * current bubble should use {@link #update(Bubble)}.
*
- * @param entry the notification to display as a bubble.
+ * @param bubble the bubble to display in this view.
*/
- public void setNotif(NotificationEntry entry) {
- mEntry = entry;
- updateViews();
+ public void setBubble(Bubble bubble) {
+ mBubble = bubble;
}
/**
@@ -105,7 +111,7 @@
*/
@Nullable
public NotificationEntry getEntry() {
- return mEntry;
+ return mBubble != null ? mBubble.getEntry() : null;
}
/**
@@ -113,24 +119,34 @@
*/
@Nullable
public String getKey() {
- return (mEntry != null) ? mEntry.key : null;
+ return (mBubble != null) ? mBubble.getKey() : null;
}
/**
- * Updates the UI based on the entry, updates badge and animates messages as needed.
+ * Updates the UI based on the bubble, updates badge and animates messages as needed.
*/
- public void update(NotificationEntry entry) {
- mEntry = entry;
+ public void update(Bubble bubble) {
+ mBubble = bubble;
updateViews();
}
/**
+ * @param factory Factory for creating normalized bubble icons.
+ */
+ public void setBubbleIconFactory(BubbleIconFactory factory) {
+ mBubbleIconFactory = factory;
+ }
+
+ public void setAppIcon(Drawable appIcon) {
+ mUserBadgedAppIcon = appIcon;
+ }
+ /**
* @return the {@link ExpandableNotificationRow} view to display notification content when the
* bubble is expanded.
*/
@Nullable
public ExpandableNotificationRow getRowView() {
- return (mEntry != null) ? mEntry.getRow() : null;
+ return (mBubble != null) ? mBubble.getEntry().getRow() : null;
}
/** Changes the dot's visibility to match the bubble view's state. */
@@ -150,18 +166,23 @@
/** Sets the position of the 'new' dot, animating it out and back in if requested. */
void setDotPosition(boolean onLeft, boolean animate) {
- if (animate && onLeft != mBadgedImageView.getDotPosition() && !mSuppressDot) {
+ if (animate && onLeft != mBadgedImageView.getDotOnLeft() && !mSuppressDot) {
animateDot(false /* showDot */, () -> {
- mBadgedImageView.setDotPosition(onLeft);
+ mBadgedImageView.setDotOnLeft(onLeft);
animateDot(true /* showDot */, null);
});
} else {
- mBadgedImageView.setDotPosition(onLeft);
+ mBadgedImageView.setDotOnLeft(onLeft);
}
}
+ float[] getDotCenter() {
+ float[] unscaled = mBadgedImageView.getDotCenter();
+ return new float[]{unscaled[0], unscaled[1]};
+ }
+
boolean getDotPositionOnLeft() {
- return mBadgedImageView.getDotPosition();
+ return mBadgedImageView.getDotOnLeft();
}
/**
@@ -169,7 +190,7 @@
* after animation if requested.
*/
private void updateDotVisibility(boolean animate, Runnable after) {
- boolean showDot = getEntry().showInShadeWhenBubble() && !mSuppressDot;
+ boolean showDot = mBubble.showBubbleDot() && !mSuppressDot;
if (animate) {
animateDot(showDot, after);
@@ -186,7 +207,6 @@
if (showDot) {
mBadgedImageView.setShowDot(true);
}
-
mBadgedImageView.clearAnimation();
mBadgedImageView.animate().setDuration(200)
.setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
@@ -207,37 +227,60 @@
}
void updateViews() {
- if (mEntry == null) {
+ if (mBubble == null || mBubbleIconFactory == null) {
return;
}
- Notification.BubbleMetadata metadata = mEntry.getBubbleMetadata();
- Notification n = mEntry.notification.getNotification();
- Icon ic;
- boolean needsTint;
- if (metadata != null) {
- ic = metadata.getIcon();
- needsTint = ic.getType() != Icon.TYPE_ADAPTIVE_BITMAP;
- } else {
- needsTint = n.getLargeIcon() == null;
- ic = needsTint ? n.getSmallIcon() : n.getLargeIcon();
- }
+ // Update icon.
+ Notification.BubbleMetadata metadata = mBubble.getEntry().getBubbleMetadata();
+ Notification n = mBubble.getEntry().notification.getNotification();
+ Icon ic = metadata.getIcon();
+ boolean needsTint = ic.getType() != Icon.TYPE_ADAPTIVE_BITMAP;
+
Drawable iconDrawable = ic.loadDrawable(mContext);
if (needsTint) {
- mBadgedImageView.setImageDrawable(buildIconWithTint(iconDrawable, n.color));
- } else {
- mBadgedImageView.setImageDrawable(iconDrawable);
+ iconDrawable = buildIconWithTint(iconDrawable, n.color);
}
+ Bitmap bubbleIcon = mBubbleIconFactory.createBadgedIconBitmap(iconDrawable,
+ null /* user */,
+ true /* shrinkNonAdaptiveIcons */).icon;
+
+ // Give it a shadow
+ Bitmap userBadgedBitmap = mBubbleIconFactory.createIconBitmap(mUserBadgedAppIcon,
+ 1f, mBubbleIconFactory.getBadgeSize());
+ Canvas c = new Canvas();
+ ShadowGenerator shadowGenerator = new ShadowGenerator(mBubbleIconFactory.getBadgeSize());
+ c.setBitmap(userBadgedBitmap);
+ shadowGenerator.recreateIcon(Bitmap.createBitmap(userBadgedBitmap), c);
+
+ mBubbleIconFactory.badgeWithDrawable(bubbleIcon,
+ new BitmapDrawable(mContext.getResources(), userBadgedBitmap));
+ mBadgedImageView.setImageBitmap(bubbleIcon);
+
+ // Update badge.
int badgeColor = determineDominateColor(iconDrawable, n.color);
mBadgeColor = badgeColor;
mBadgedImageView.setDotColor(badgeColor);
- animateDot(mEntry.showInShadeWhenBubble() /* showDot */, null /* after */);
+
+ // Update dot.
+ Path iconPath = PathParser.createPathFromPathData(
+ getResources().getString(com.android.internal.R.string.config_icon_mask));
+ Matrix matrix = new Matrix();
+ float scale = mBubbleIconFactory.getNormalizer().getScale(iconDrawable,
+ null /* outBounds */, null /* path */, null /* outMaskShape */);
+ float radius = BadgedImageView.DEFAULT_PATH_SIZE / 2f;
+ matrix.setScale(scale /* x scale */, scale /* y scale */, radius /* pivot x */,
+ radius /* pivot y */);
+ iconPath.transform(matrix);
+ mBadgedImageView.drawDot(iconPath);
+
+ animateDot(mBubble.showBubbleDot() /* showDot */, null /* after */);
}
int getBadgeColor() {
return mBadgeColor;
}
- private Drawable buildIconWithTint(Drawable iconDrawable, int backgroundColor) {
+ private AdaptiveIconDrawable buildIconWithTint(Drawable iconDrawable, int backgroundColor) {
iconDrawable = checkTint(iconDrawable, backgroundColor);
InsetDrawable foreground = new InsetDrawable(iconDrawable, mIconInset);
ColorDrawable background = new ColorDrawable(backgroundColor);
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java b/packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java
index 1fa0e12..59d68bc 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java
@@ -16,9 +16,12 @@
package com.android.systemui.bubbles.animation;
+import android.content.res.Configuration;
import android.content.res.Resources;
+import android.graphics.Path;
import android.graphics.Point;
import android.graphics.PointF;
+import android.view.DisplayCutout;
import android.view.View;
import android.view.WindowInsets;
@@ -26,10 +29,13 @@
import androidx.dynamicanimation.animation.DynamicAnimation;
import androidx.dynamicanimation.animation.SpringForce;
+import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.google.android.collect.Sets;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
import java.util.Set;
/**
@@ -46,24 +52,29 @@
*/
private static final int ANIMATE_TRANSLATION_FACTOR = 4;
- /** How much to scale down bubbles when they're animating in/out. */
- private static final float ANIMATE_SCALE_PERCENT = 0.5f;
+ /** Duration of the expand/collapse target path animation. */
+ private static final int EXPAND_COLLAPSE_TARGET_ANIM_DURATION = 175;
- /** The stack position to collapse back to in {@link #collapseBackToStack}. */
- private PointF mCollapseToPoint;
+ /** Stiffness for the expand/collapse path-following animation. */
+ private static final int EXPAND_COLLAPSE_ANIM_STIFFNESS = 1000;
+
+ /** What percentage of the screen to use when centering the bubbles in landscape. */
+ private static final float CENTER_BUBBLES_LANDSCAPE_PERCENT = 0.66f;
/** Horizontal offset between bubbles, which we need to know to re-stack them. */
private float mStackOffsetPx;
- /** Spacing between bubbles in the expanded state. */
- private float mBubblePaddingPx;
+ /** Space between status bar and bubbles in the expanded state. */
+ private float mBubblePaddingTop;
/** Size of each bubble. */
private float mBubbleSizePx;
/** Height of the status bar. */
private float mStatusBarHeight;
/** Size of display. */
private Point mDisplaySize;
- /** Size of dismiss target at bottom of screen. */
- private float mPipDismissHeight;
+ /** Max number of bubbles shown in row above expanded view.*/
+ private int mBubblesMaxRendered;
+ /** What the current screen orientation is. */
+ private int mScreenOrientation;
/** Whether the dragged-out bubble is in the dismiss target. */
private boolean mIndividualBubbleWithinDismissTarget = false;
@@ -86,10 +97,13 @@
private boolean mSpringingBubbleToTouch = false;
private int mExpandedViewPadding;
+ private float mLauncherGridDiff;
- public ExpandedAnimationController(Point displaySize, int expandedViewPadding) {
- mDisplaySize = displaySize;
+ public ExpandedAnimationController(Point displaySize, int expandedViewPadding,
+ int orientation) {
+ updateOrientation(orientation, displaySize);
mExpandedViewPadding = expandedViewPadding;
+ mLauncherGridDiff = 30f;
}
/**
@@ -109,7 +123,7 @@
mAnimatingExpand = true;
mAfterExpand = after;
- startOrUpdateExpandAnimation();
+ startOrUpdatePathAnimation(true /* expanding */);
}
/** Animate collapsing the bubbles back to their stacked position. */
@@ -119,43 +133,105 @@
mAfterCollapse = after;
mCollapsePoint = collapsePoint;
- startOrUpdateCollapseAnimation();
+ startOrUpdatePathAnimation(false /* expanding */);
}
- private void startOrUpdateExpandAnimation() {
- animationsForChildrenFromIndex(
- 0, /* startIndex */
- (index, animation) -> animation.position(getBubbleLeft(index), getExpandedY()))
- .startAll(() -> {
- mAnimatingExpand = false;
-
- if (mAfterExpand != null) {
- mAfterExpand.run();
- }
-
- mAfterExpand = null;
- });
+ /**
+ * Update effective screen width based on current orientation.
+ * @param orientation Landscape or portrait.
+ * @param displaySize Updated display size.
+ */
+ public void updateOrientation(int orientation, Point displaySize) {
+ mScreenOrientation = orientation;
+ mDisplaySize = displaySize;
+ if (mLayout != null) {
+ Resources res = mLayout.getContext().getResources();
+ mBubblePaddingTop = res.getDimensionPixelSize(R.dimen.bubble_padding_top);
+ mStatusBarHeight = res.getDimensionPixelSize(
+ com.android.internal.R.dimen.status_bar_height);
+ }
}
- private void startOrUpdateCollapseAnimation() {
- // Stack to the left if we're going to the left, or right if not.
- final float sideMultiplier = mLayout.isFirstChildXLeftOfCenter(mCollapsePoint.x) ? -1 : 1;
- animationsForChildrenFromIndex(
- 0, /* startIndex */
- (index, animation) -> {
- animation.position(
- mCollapsePoint.x + (sideMultiplier * index * mStackOffsetPx),
- mCollapsePoint.y);
- })
- .startAll(() -> {
- mAnimatingCollapse = false;
+ /**
+ * Animates the bubbles along a curved path, either to expand them along the top or collapse
+ * them back into a stack.
+ */
+ private void startOrUpdatePathAnimation(boolean expanding) {
+ Runnable after;
- if (mAfterCollapse != null) {
- mAfterCollapse.run();
- }
+ if (expanding) {
+ after = () -> {
+ mAnimatingExpand = false;
- mAfterCollapse = null;
- });
+ if (mAfterExpand != null) {
+ mAfterExpand.run();
+ }
+
+ mAfterExpand = null;
+ };
+ } else {
+ after = () -> {
+ mAnimatingCollapse = false;
+
+ if (mAfterCollapse != null) {
+ mAfterCollapse.run();
+ }
+
+ mAfterCollapse = null;
+ };
+ }
+
+ // Animate each bubble individually, since each path will end in a different spot.
+ animationsForChildrenFromIndex(0, (index, animation) -> {
+ final View bubble = mLayout.getChildAt(index);
+
+ // Start a path at the bubble's current position.
+ final Path path = new Path();
+ path.moveTo(bubble.getTranslationX(), bubble.getTranslationY());
+
+ final float expandedY = getExpandedY();
+ if (expanding) {
+ // If we're expanding, first draw a line from the bubble's current position to the
+ // top of the screen.
+ path.lineTo(bubble.getTranslationX(), expandedY);
+
+ // Then, draw a line across the screen to the bubble's resting position.
+ path.lineTo(getBubbleLeft(index), expandedY);
+ } else {
+ final float sideMultiplier =
+ mLayout.isFirstChildXLeftOfCenter(mCollapsePoint.x) ? -1 : 1;
+ final float stackedX = mCollapsePoint.x + (sideMultiplier * index * mStackOffsetPx);
+
+ // If we're collapsing, draw a line from the bubble's current position to the side
+ // of the screen where the bubble will be stacked.
+ path.lineTo(stackedX, expandedY);
+
+ // Then, draw a line down to the stack position.
+ path.lineTo(stackedX, mCollapsePoint.y);
+ }
+
+ // The lead bubble should be the bubble with the longest distance to travel when we're
+ // expanding, and the bubble with the shortest distance to travel when we're collapsing.
+ // During expansion from the left side, the last bubble has to travel to the far right
+ // side, so we have it lead and 'pull' the rest of the bubbles into place. From the
+ // right side, the first bubble is traveling to the top left, so it leads. During
+ // collapse to the left, the first bubble has the shortest travel time back to the stack
+ // position, so it leads (and vice versa).
+ final boolean firstBubbleLeads =
+ (expanding && !mLayout.isFirstChildXLeftOfCenter(bubble.getTranslationX()))
+ || (!expanding && mLayout.isFirstChildXLeftOfCenter(mCollapsePoint.x));
+ final int startDelay = firstBubbleLeads
+ ? (index * 10)
+ : ((mLayout.getChildCount() - index) * 10);
+
+ animation
+ .followAnimatedTargetAlongPath(
+ path,
+ EXPAND_COLLAPSE_TARGET_ANIM_DURATION /* targetAnimDuration */,
+ Interpolators.LINEAR /* targetAnimInterpolator */)
+ .withStartDelay(startDelay)
+ .withStiffness(EXPAND_COLLAPSE_ANIM_STIFFNESS);
+ }).startAll(after);
}
/** Prepares the given bubble to be dragged out. */
@@ -265,6 +341,7 @@
public void onGestureFinished() {
mBubbleDraggedOutEnough = false;
mBubbleDraggingOut = null;
+ updateBubblePositions();
}
/**
@@ -276,41 +353,38 @@
0, (i, anim) -> anim.translationY(getExpandedY())).startAll(after);
}
- /**
- * Animates the bubbles, starting at the given index, to the left or right by the given number
- * of bubble widths. Passing zero for numBubbleWidths will animate the bubbles to their normal
- * positions.
- */
- private void animateStackByBubbleWidthsStartingFrom(int numBubbleWidths, int startIndex) {
- animationsForChildrenFromIndex(
- startIndex,
- (index, animation) ->
- animation.translationX(getXForChildAtIndex(index + numBubbleWidths)))
- .startAll();
- }
-
/** The Y value of the row of expanded bubbles. */
public float getExpandedY() {
if (mLayout == null || mLayout.getRootWindowInsets() == null) {
return 0;
}
final WindowInsets insets = mLayout.getRootWindowInsets();
- return mBubblePaddingPx + Math.max(
+ return mBubblePaddingTop + Math.max(
mStatusBarHeight,
insets.getDisplayCutout() != null
? insets.getDisplayCutout().getSafeInsetTop()
: 0);
}
+ /** Description of current animation controller state. */
+ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ pw.println("ExpandedAnimationController state:");
+ pw.print(" isActive: "); pw.println(isActiveController());
+ pw.print(" animatingExpand: "); pw.println(mAnimatingExpand);
+ pw.print(" animatingCollapse: "); pw.println(mAnimatingCollapse);
+ pw.print(" bubbleInDismiss: "); pw.println(mIndividualBubbleWithinDismissTarget);
+ pw.print(" springingBubble: "); pw.println(mSpringingBubbleToTouch);
+ }
+
@Override
void onActiveControllerForLayout(PhysicsAnimationLayout layout) {
final Resources res = layout.getResources();
mStackOffsetPx = res.getDimensionPixelSize(R.dimen.bubble_stack_offset);
- mBubblePaddingPx = res.getDimensionPixelSize(R.dimen.bubble_padding);
+ mBubblePaddingTop = res.getDimensionPixelSize(R.dimen.bubble_padding_top);
mBubbleSizePx = res.getDimensionPixelSize(R.dimen.individual_bubble_size);
mStatusBarHeight =
res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height);
- mPipDismissHeight = res.getDimensionPixelSize(R.dimen.pip_dismiss_gradient_height);
+ mBubblesMaxRendered = res.getInteger(R.integer.bubbles_max_rendered);
// Ensure that all child views are at 1x scale, and visible, in case they were animating
// in.
@@ -351,11 +425,11 @@
// If a bubble is added while the expand/collapse animations are playing, update the
// animation to include the new bubble.
if (mAnimatingExpand) {
- startOrUpdateExpandAnimation();
+ startOrUpdatePathAnimation(true /* expanding */);
} else if (mAnimatingCollapse) {
- startOrUpdateCollapseAnimation();
+ startOrUpdatePathAnimation(false /* expanding */);
} else {
- child.setTranslationX(getXForChildAtIndex(index));
+ child.setTranslationX(getBubbleLeft(index));
animationForChild(child)
.translationY(
getExpandedY() - mBubbleSizePx * ANIMATE_TRANSLATION_FACTOR, /* from */
@@ -389,6 +463,12 @@
@Override
void onChildReordered(View child, int oldIndex, int newIndex) {
updateBubblePositions();
+
+ // We expect reordering during collapse, since we'll put the last selected bubble on top.
+ // Update the collapse animation so they end up in the right stacked positions.
+ if (mAnimatingCollapse) {
+ startOrUpdatePathAnimation(false /* expanding */);
+ }
}
private void updateBubblePositions() {
@@ -411,35 +491,100 @@
}
}
- /** Returns the appropriate X translation value for a bubble at the given index. */
- private float getXForChildAtIndex(int index) {
- return mBubblePaddingPx + (mBubbleSizePx + mBubblePaddingPx) * index;
- }
-
/**
* @param index Bubble index in row.
* @return Bubble left x from left edge of screen.
*/
public float getBubbleLeft(int index) {
- float bubbleLeftFromRowLeft = index * (mBubbleSizePx + mBubblePaddingPx);
- return getRowLeft() + bubbleLeftFromRowLeft;
+ final float bubbleFromRowLeft = index * (mBubbleSizePx + getSpaceBetweenBubbles());
+ return getRowLeft() + bubbleFromRowLeft;
+ }
+
+ /**
+ * When expanded, the bubbles are centered in the screen. In portrait, all available space is
+ * used. In landscape we have too much space so the value is restricted. This method accounts
+ * for window decorations (nav bar, cutouts).
+ *
+ * @return the desired width to display the expanded bubbles in.
+ */
+ private float getWidthForDisplayingBubbles() {
+ final float availableWidth = getAvailableScreenWidth(true /* includeStableInsets */);
+ if (mScreenOrientation == Configuration.ORIENTATION_LANDSCAPE) {
+ // display size y in landscape will be the smaller dimension of the screen
+ return Math.max(mDisplaySize.y, availableWidth * CENTER_BUBBLES_LANDSCAPE_PERCENT);
+ } else {
+ return availableWidth;
+ }
+ }
+
+ /**
+ * Determines the available screen width without the cutout.
+ *
+ * @param subtractStableInsets Whether or not stable insets should also be removed from the
+ * returned width.
+ * @return the total screen width available accounting for cutouts and insets,
+ * iff {@param includeStableInsets} is true.
+ */
+ private float getAvailableScreenWidth(boolean subtractStableInsets) {
+ float availableSize = mDisplaySize.x;
+ WindowInsets insets = mLayout != null ? mLayout.getRootWindowInsets() : null;
+ if (insets != null) {
+ int cutoutLeft = 0;
+ int cutoutRight = 0;
+ DisplayCutout cutout = insets.getDisplayCutout();
+ if (cutout != null) {
+ cutoutLeft = cutout.getSafeInsetLeft();
+ cutoutRight = cutout.getSafeInsetRight();
+ }
+ final int stableLeft = subtractStableInsets ? insets.getStableInsetLeft() : 0;
+ final int stableRight = subtractStableInsets ? insets.getStableInsetRight() : 0;
+ availableSize -= Math.max(stableLeft, cutoutLeft);
+ availableSize -= Math.max(stableRight, cutoutRight);
+ }
+ return availableSize;
}
private float getRowLeft() {
if (mLayout == null) {
return 0;
}
+
int bubbleCount = mLayout.getChildCount();
- // Width calculations.
- double bubble = bubbleCount * mBubbleSizePx;
- float gap = (bubbleCount - 1) * mBubblePaddingPx;
- float row = gap + (float) bubble;
+ final float totalBubbleWidth = bubbleCount * mBubbleSizePx;
+ final float totalGapWidth = (bubbleCount - 1) * getSpaceBetweenBubbles();
+ final float rowWidth = totalGapWidth + totalBubbleWidth;
- float halfRow = row / 2f;
- float centerScreen = mDisplaySize.x / 2;
- float rowLeftFromScreenLeft = centerScreen - halfRow;
+ // This display size we're using includes the size of the insets, we want the true
+ // center of the display minus the notch here, which means we should include the
+ // stable insets (e.g. status bar, nav bar) in this calculation.
+ final float trueCenter = getAvailableScreenWidth(false /* subtractStableInsets */) / 2f;
+ final float halfRow = rowWidth / 2f;
+ final float rowLeft = trueCenter - halfRow;
- return rowLeftFromScreenLeft;
+ return rowLeft;
+ }
+
+ /**
+ * @return Space between bubbles in row above expanded view.
+ */
+ private float getSpaceBetweenBubbles() {
+ /**
+ * Ordered left to right:
+ * Screen edge
+ * [mExpandedViewPadding]
+ * Expanded view edge
+ * [launcherGridDiff] --- arbitrary value until launcher exports widths
+ * Launcher's app icon grid edge that we must match
+ */
+ final float rowMargins = (mExpandedViewPadding + mLauncherGridDiff) * 2;
+ final float maxRowWidth = getWidthForDisplayingBubbles() - rowMargins;
+
+ final float totalBubbleWidth = mBubblesMaxRendered * mBubbleSizePx;
+ final float totalGapWidth = maxRowWidth - totalBubbleWidth;
+
+ final int gapCount = mBubblesMaxRendered - 1;
+ final float gapWidth = totalGapWidth / gapCount;
+ return gapWidth;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayout.java b/packages/SystemUI/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayout.java
index 3a33392..563a0a7 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayout.java
@@ -16,7 +16,14 @@
package com.android.systemui.bubbles.animation;
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.animation.ObjectAnimator;
+import android.animation.TimeInterpolator;
import android.content.Context;
+import android.graphics.Path;
+import android.graphics.PointF;
+import android.util.FloatProperty;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
@@ -160,7 +167,7 @@
/** Whether this controller is the currently active controller for its associated layout. */
protected boolean isActiveController() {
- return this == mLayout.mController;
+ return mLayout != null && this == mLayout.mController;
}
protected void setLayout(PhysicsAnimationLayout layout) {
@@ -232,7 +239,7 @@
}
if (endActions != null) {
- mLayout.setEndActionForMultipleProperties(
+ setEndActionForMultipleProperties(
runAllEndActions,
allAnimatedProperties.toArray(
new DynamicAnimation.ViewProperty[0]));
@@ -243,6 +250,44 @@
}
};
}
+
+ /**
+ * Sets an end action that will be run when all child animations for a given property have
+ * stopped running.
+ */
+ protected void setEndActionForProperty(
+ Runnable action, DynamicAnimation.ViewProperty property) {
+ mLayout.mEndActionForProperty.put(property, action);
+ }
+
+ /**
+ * Sets an end action that will be run when all child animations for all of the given
+ * properties have stopped running.
+ */
+ protected void setEndActionForMultipleProperties(
+ Runnable action, DynamicAnimation.ViewProperty... properties) {
+ final Runnable checkIfAllFinished = () -> {
+ if (!mLayout.arePropertiesAnimating(properties)) {
+ action.run();
+
+ for (DynamicAnimation.ViewProperty property : properties) {
+ removeEndActionForProperty(property);
+ }
+ }
+ };
+
+ for (DynamicAnimation.ViewProperty property : properties) {
+ setEndActionForProperty(checkIfAllFinished, property);
+ }
+ }
+
+ /**
+ * Removes the end listener that would have been called when all child animations for a
+ * given property stopped running.
+ */
+ protected void removeEndActionForProperty(DynamicAnimation.ViewProperty property) {
+ mLayout.mEndActionForProperty.remove(property);
+ }
}
/**
@@ -275,43 +320,6 @@
}
}
- /**
- * Sets an end action that will be run when all child animations for a given property have
- * stopped running.
- */
- public void setEndActionForProperty(Runnable action, DynamicAnimation.ViewProperty property) {
- mEndActionForProperty.put(property, action);
- }
-
- /**
- * Sets an end action that will be run when all child animations for all of the given properties
- * have stopped running.
- */
- public void setEndActionForMultipleProperties(
- Runnable action, DynamicAnimation.ViewProperty... properties) {
- final Runnable checkIfAllFinished = () -> {
- if (!arePropertiesAnimating(properties)) {
- action.run();
-
- for (DynamicAnimation.ViewProperty property : properties) {
- removeEndActionForProperty(property);
- }
- }
- };
-
- for (DynamicAnimation.ViewProperty property : properties) {
- setEndActionForProperty(checkIfAllFinished, property);
- }
- }
-
- /**
- * Removes the end listener that would have been called when all child animations for a given
- * property stopped running.
- */
- public void removeEndActionForProperty(DynamicAnimation.ViewProperty property) {
- mEndActionForProperty.remove(property);
- }
-
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
addViewInternal(child, index, params, false /* isReorder */);
@@ -372,11 +380,22 @@
/** Checks whether any animations of the given properties are running on the given view. */
public boolean arePropertiesAnimatingOnView(
View view, DynamicAnimation.ViewProperty... properties) {
+ final ObjectAnimator targetAnimator = getTargetAnimatorFromView(view);
for (DynamicAnimation.ViewProperty property : properties) {
final SpringAnimation animation = getAnimationFromView(property, view);
if (animation != null && animation.isRunning()) {
return true;
}
+
+ // If the target animator is running, its update listener will trigger the translation
+ // physics animations at some point. We should consider the translation properties to be
+ // be animating in this case, even if the physics animations haven't been started yet.
+ final boolean isTranslation =
+ property.equals(DynamicAnimation.TRANSLATION_X)
+ || property.equals(DynamicAnimation.TRANSLATION_Y);
+ if (isTranslation && targetAnimator != null && targetAnimator.isRunning()) {
+ return true;
+ }
}
return false;
@@ -388,8 +407,18 @@
return;
}
+ cancelAllAnimationsOfProperties(
+ mController.getAnimatedProperties().toArray(new DynamicAnimation.ViewProperty[]{}));
+ }
+
+ /** Cancels all animations that are running on all child views, for the given properties. */
+ public void cancelAllAnimationsOfProperties(DynamicAnimation.ViewProperty... properties) {
+ if (mController == null) {
+ return;
+ }
+
for (int i = 0; i < getChildCount(); i++) {
- for (DynamicAnimation.ViewProperty property : mController.getAnimatedProperties()) {
+ for (DynamicAnimation.ViewProperty property : properties) {
final DynamicAnimation anim = getAnimationAtIndex(property, i);
if (anim != null) {
anim.cancel();
@@ -400,6 +429,14 @@
/** Cancels all of the physics animations running on the given view. */
public void cancelAnimationsOnView(View view) {
+ // If present, cancel the target animator so it doesn't restart the translation physics
+ // animations.
+ final ObjectAnimator targetAnimator = getTargetAnimatorFromView(view);
+ if (targetAnimator != null) {
+ targetAnimator.cancel();
+ }
+
+ // Cancel physics animations on the view.
for (DynamicAnimation.ViewProperty property : mController.getAnimatedProperties()) {
getAnimationFromView(property, view).cancel();
}
@@ -470,6 +507,11 @@
return (SpringAnimation) view.getTag(getTagIdForProperty(property));
}
+ /** Retrieves the target animator from the view via the view tag system. */
+ @Nullable private ObjectAnimator getTargetAnimatorFromView(View view) {
+ return (ObjectAnimator) view.getTag(R.id.target_animator_tag);
+ }
+
/** Sets up SpringAnimations of the given property for each child view in the layout. */
private void setUpAnimationsForProperty(DynamicAnimation.ViewProperty property) {
for (int i = 0; i < getChildCount(); i++) {
@@ -587,7 +629,7 @@
* End actions to call when both TRANSLATION_X and TRANSLATION_Y animations have completed,
* if {@link #position} was used to animate TRANSLATION_X and TRANSLATION_Y simultaneously.
*/
- private Runnable[] mPositionEndActions;
+ @Nullable private Runnable[] mPositionEndActions;
/**
* All of the properties that have been set and will animate when {@link #start} is called.
@@ -603,6 +645,46 @@
/** The animation controller that last retrieved this animator instance. */
private PhysicsAnimationController mAssociatedController;
+ /**
+ * Animator used to traverse the path provided to {@link #followAnimatedTargetAlongPath}. As
+ * the path is traversed, the view's translation spring animation final positions are
+ * updated such that the view 'follows' the current position on the path.
+ */
+ @Nullable private ObjectAnimator mPathAnimator;
+
+ /** Current position on the path. This is animated by {@link #mPathAnimator}. */
+ private PointF mCurrentPointOnPath = new PointF();
+
+ /**
+ * FloatProperty instances that can be passed to {@link ObjectAnimator} to animate the value
+ * of {@link #mCurrentPointOnPath}.
+ */
+ private final FloatProperty<PhysicsPropertyAnimator> mCurrentPointOnPathXProperty =
+ new FloatProperty<PhysicsPropertyAnimator>("PathX") {
+ @Override
+ public void setValue(PhysicsPropertyAnimator object, float value) {
+ mCurrentPointOnPath.x = value;
+ }
+
+ @Override
+ public Float get(PhysicsPropertyAnimator object) {
+ return mCurrentPointOnPath.x;
+ }
+ };
+
+ private final FloatProperty<PhysicsPropertyAnimator> mCurrentPointOnPathYProperty =
+ new FloatProperty<PhysicsPropertyAnimator>("PathY") {
+ @Override
+ public void setValue(PhysicsPropertyAnimator object, float value) {
+ mCurrentPointOnPath.y = value;
+ }
+
+ @Override
+ public Float get(PhysicsPropertyAnimator object) {
+ return mCurrentPointOnPath.y;
+ }
+ };
+
protected PhysicsPropertyAnimator(View view) {
this.mView = view;
}
@@ -628,6 +710,7 @@
/** Animate the view's translationX value to the provided value. */
public PhysicsPropertyAnimator translationX(float translationX, Runnable... endActions) {
+ mPathAnimator = null; // We aren't using the path anymore if we're translating.
return property(DynamicAnimation.TRANSLATION_X, translationX, endActions);
}
@@ -640,6 +723,7 @@
/** Animate the view's translationY value to the provided value. */
public PhysicsPropertyAnimator translationY(float translationY, Runnable... endActions) {
+ mPathAnimator = null; // We aren't using the path anymore if we're translating.
return property(DynamicAnimation.TRANSLATION_Y, translationY, endActions);
}
@@ -661,6 +745,46 @@
return translationY(translationY);
}
+ /**
+ * Animates a 'target' point that moves along the given path, using the provided duration
+ * and interpolator to animate the target. The view itself is animated using physics-based
+ * animations, whose final positions are updated to the target position as it animates. This
+ * results in the view 'following' the target in a realistic way.
+ *
+ * This method will override earlier calls to {@link #translationX}, {@link #translationY},
+ * or {@link #position}, ultimately animating the view's position to the final point on the
+ * given path.
+ *
+ * Any provided end listeners will be called when the physics-based animations kicked off by
+ * the moving target have completed - not when the target animation completes.
+ */
+ public PhysicsPropertyAnimator followAnimatedTargetAlongPath(
+ Path path,
+ int targetAnimDuration,
+ TimeInterpolator targetAnimInterpolator,
+ Runnable... endActions) {
+ mPathAnimator = ObjectAnimator.ofFloat(
+ this, mCurrentPointOnPathXProperty, mCurrentPointOnPathYProperty, path);
+ mPathAnimator.setDuration(targetAnimDuration);
+ mPathAnimator.setInterpolator(targetAnimInterpolator);
+
+ mPositionEndActions = endActions;
+
+ // Remove translation related values since we're going to ignore them and follow the
+ // path instead.
+ clearTranslationValues();
+ return this;
+ }
+
+ private void clearTranslationValues() {
+ mAnimatedProperties.remove(DynamicAnimation.TRANSLATION_X);
+ mAnimatedProperties.remove(DynamicAnimation.TRANSLATION_Y);
+ mInitialPropertyValues.remove(DynamicAnimation.TRANSLATION_X);
+ mInitialPropertyValues.remove(DynamicAnimation.TRANSLATION_Y);
+ mEndActionForProperty.remove(DynamicAnimation.TRANSLATION_X);
+ mEndActionForProperty.remove(DynamicAnimation.TRANSLATION_Y);
+ }
+
/** Animate the view's scaleX value to the provided value. */
public PhysicsPropertyAnimator scaleX(float scaleX, Runnable... endActions) {
return property(DynamicAnimation.SCALE_X, scaleX, endActions);
@@ -742,7 +866,7 @@
if (after != null && after.length > 0) {
final DynamicAnimation.ViewProperty[] propertiesArray =
properties.toArray(new DynamicAnimation.ViewProperty[0]);
- setEndActionForMultipleProperties(() -> {
+ mAssociatedController.setEndActionForMultipleProperties(() -> {
for (Runnable callback : after) {
callback.run();
}
@@ -774,8 +898,20 @@
new Runnable[]{waitForBothXAndY});
}
+ if (mPathAnimator != null) {
+ startPathAnimation();
+ }
+
// Actually start the animations.
for (DynamicAnimation.ViewProperty property : properties) {
+ // Don't start translation animations if we're using a path animator, the update
+ // listeners added to that animator will take care of that.
+ if (mPathAnimator != null
+ && (property.equals(DynamicAnimation.TRANSLATION_X)
+ || property.equals(DynamicAnimation.TRANSLATION_Y))) {
+ return;
+ }
+
if (mInitialPropertyValues.containsKey(property)) {
property.setValue(mView, mInitialPropertyValues.get(property));
}
@@ -797,7 +933,16 @@
/** Returns the set of properties that will animate once {@link #start} is called. */
protected Set<DynamicAnimation.ViewProperty> getAnimatedProperties() {
- return mAnimatedProperties.keySet();
+ final HashSet<DynamicAnimation.ViewProperty> animatedProperties = new HashSet<>(
+ mAnimatedProperties.keySet());
+
+ // If we're using a path animator, it'll kick off translation animations.
+ if (mPathAnimator != null) {
+ animatedProperties.add(DynamicAnimation.TRANSLATION_X);
+ animatedProperties.add(DynamicAnimation.TRANSLATION_Y);
+ }
+
+ return animatedProperties;
}
/**
@@ -812,7 +957,7 @@
long startDelay,
float stiffness,
float dampingRatio,
- Runnable[] afterCallbacks) {
+ Runnable... afterCallbacks) {
if (view != null) {
final SpringAnimation animation =
(SpringAnimation) view.getTag(getTagIdForProperty(property));
@@ -855,6 +1000,92 @@
}
}
+ /**
+ * Updates the final position of a view's animation, without changing any of the animation's
+ * other settings. Calling this before an initial call to {@link #animateValueForChild} will
+ * work, but result in unknown values for stiffness, etc. and is not recommended.
+ */
+ private void updateValueForChild(
+ DynamicAnimation.ViewProperty property, View view, float position) {
+ if (view != null) {
+ final SpringAnimation animation =
+ (SpringAnimation) view.getTag(getTagIdForProperty(property));
+ final SpringForce animationSpring = animation.getSpring();
+
+ if (animationSpring == null) {
+ return;
+ }
+
+ animationSpring.setFinalPosition(position);
+ animation.start();
+ }
+ }
+
+ /**
+ * Configures the path animator to respect the settings passed into the animation builder
+ * and adds update listeners that update the translation physics animations. Then, starts
+ * the path animation.
+ */
+ protected void startPathAnimation() {
+ final SpringForce defaultSpringForceX = mController.getSpringForce(
+ DynamicAnimation.TRANSLATION_X, mView);
+ final SpringForce defaultSpringForceY = mController.getSpringForce(
+ DynamicAnimation.TRANSLATION_Y, mView);
+
+ if (mStartDelay > 0) {
+ mPathAnimator.setStartDelay(mStartDelay);
+ }
+
+ final Runnable updatePhysicsAnims = () -> {
+ updateValueForChild(
+ DynamicAnimation.TRANSLATION_X, mView, mCurrentPointOnPath.x);
+ updateValueForChild(
+ DynamicAnimation.TRANSLATION_Y, mView, mCurrentPointOnPath.y);
+ };
+
+ mPathAnimator.addUpdateListener(pathAnim -> updatePhysicsAnims.run());
+ mPathAnimator.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationStart(Animator animation) {
+ animateValueForChild(
+ DynamicAnimation.TRANSLATION_X,
+ mView,
+ mCurrentPointOnPath.x,
+ mDefaultStartVelocity,
+ 0 /* startDelay */,
+ mStiffness >= 0 ? mStiffness : defaultSpringForceX.getStiffness(),
+ mDampingRatio >= 0
+ ? mDampingRatio
+ : defaultSpringForceX.getDampingRatio());
+
+ animateValueForChild(
+ DynamicAnimation.TRANSLATION_Y,
+ mView,
+ mCurrentPointOnPath.y,
+ mDefaultStartVelocity,
+ 0 /* startDelay */,
+ mStiffness >= 0 ? mStiffness : defaultSpringForceY.getStiffness(),
+ mDampingRatio >= 0
+ ? mDampingRatio
+ : defaultSpringForceY.getDampingRatio());
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ updatePhysicsAnims.run();
+ }
+ });
+
+ // If there's a target animator saved for the view, make sure it's not running.
+ final ObjectAnimator targetAnimator = getTargetAnimatorFromView(mView);
+ if (targetAnimator != null) {
+ targetAnimator.cancel();
+ }
+
+ mView.setTag(R.id.target_animator_tag, mPathAnimator);
+ mPathAnimator.start();
+ }
+
private void clearAnimator() {
mInitialPropertyValues.clear();
mAnimatedProperties.clear();
@@ -864,6 +1095,8 @@
mStiffness = -1;
mDampingRatio = -1;
mEndActionsForProperty.clear();
+ mPathAnimator = null;
+ mPositionEndActions = null;
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java b/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java
index ab8752e4..2ec09a9 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java
@@ -23,6 +23,7 @@
import android.view.View;
import android.view.WindowInsets;
+import androidx.annotation.Nullable;
import androidx.dynamicanimation.animation.DynamicAnimation;
import androidx.dynamicanimation.animation.FlingAnimation;
import androidx.dynamicanimation.animation.FloatPropertyCompat;
@@ -33,6 +34,8 @@
import com.google.android.collect.Sets;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Set;
@@ -53,6 +56,10 @@
/** Translation factor (multiplied by stack offset) to use for bubbles being animated in/out. */
private static final int ANIMATE_TRANSLATION_FACTOR = 4;
+ /** Values to use for animating bubbles in. */
+ private static final float ANIMATE_IN_STIFFNESS = 1000f;
+ private static final int ANIMATE_IN_START_DELAY = 25;
+
/**
* Values to use for the default {@link SpringForce} provided to the physics animation layout.
*/
@@ -92,7 +99,7 @@
private boolean mStackMovedToStartPosition = false;
/** The most recent position in which the stack was resting on the edge of the screen. */
- private PointF mRestingStackPosition;
+ @Nullable private PointF mRestingStackPosition;
/** The height of the most recently visible IME. */
private float mImeHeight = 0f;
@@ -139,14 +146,16 @@
/** Horizontal offset of bubbles in the stack. */
private float mStackOffset;
- /** Diameter of the bubbles themselves. */
- private int mIndividualBubbleSize;
+ /** Diameter of the bubble icon. */
+ private int mBubbleIconBitmapSize;
+ /** Width of the bubble (icon and padding). */
+ private int mBubbleSize;
/**
* The amount of space to add between the bubbles and certain UI elements, such as the top of
* the screen or the IME. This does not apply to the left/right sides of the screen since the
* stack goes offscreen intentionally.
*/
- private int mBubblePadding;
+ private int mBubblePaddingTop;
/** How far offscreen the stack rests. */
private int mBubbleOffscreen;
/** How far down the screen the stack starts, when there is no pre-existing location. */
@@ -185,7 +194,7 @@
return false;
}
- float stackCenter = mStackPosition.x + mIndividualBubbleSize / 2;
+ float stackCenter = mStackPosition.x + mBubbleIconBitmapSize / 2;
float screenCenter = mLayout.getWidth() / 2;
return stackCenter < screenCenter;
}
@@ -197,18 +206,18 @@
*/
public void springStack(float destinationX, float destinationY) {
springFirstBubbleWithStackFollowing(DynamicAnimation.TRANSLATION_X,
- new SpringForce()
+ new SpringForce()
.setStiffness(SPRING_AFTER_FLING_STIFFNESS)
.setDampingRatio(SPRING_AFTER_FLING_DAMPING_RATIO),
- 0 /* startXVelocity */,
- destinationX);
+ 0 /* startXVelocity */,
+ destinationX);
springFirstBubbleWithStackFollowing(DynamicAnimation.TRANSLATION_Y,
- new SpringForce()
+ new SpringForce()
.setStiffness(SPRING_AFTER_FLING_STIFFNESS)
.setDampingRatio(SPRING_AFTER_FLING_DAMPING_RATIO),
- 0 /* startYVelocity */,
- destinationY);
+ 0 /* startYVelocity */,
+ destinationY);
}
/**
@@ -218,7 +227,7 @@
* @return The X value that the stack will end up at after the fling/spring.
*/
public float flingStackThenSpringToEdge(float x, float velX, float velY) {
- final boolean stackOnLeftSide = x - mIndividualBubbleSize / 2 < mLayout.getWidth() / 2;
+ final boolean stackOnLeftSide = x - mBubbleIconBitmapSize / 2 < mLayout.getWidth() / 2;
final boolean stackShouldFlingLeft = stackOnLeftSide
? velX < ESCAPE_VELOCITY
@@ -230,6 +239,12 @@
final float destinationRelativeX = stackShouldFlingLeft
? stackBounds.left : stackBounds.right;
+ // If all bubbles were removed during a drag event, just return the X we would have animated
+ // to if there were still bubbles.
+ if (mLayout == null || mLayout.getChildCount() == 0) {
+ return destinationRelativeX;
+ }
+
// Minimum velocity required for the stack to make it to the targeted side of the screen,
// taking friction into account (4.2f is the number that friction scalars are multiplied by
// in DynamicAnimation.DragForce). This is an estimate - it could possibly be slightly off,
@@ -262,15 +277,6 @@
.setDampingRatio(SPRING_AFTER_FLING_DAMPING_RATIO),
/* destination */ null);
- mLayout.setEndActionForMultipleProperties(
- () -> {
- mRestingStackPosition = new PointF();
- mRestingStackPosition.set(mStackPosition);
- mLayout.removeEndActionForProperty(DynamicAnimation.TRANSLATION_X);
- mLayout.removeEndActionForProperty(DynamicAnimation.TRANSLATION_Y);
- },
- DynamicAnimation.TRANSLATION_X, DynamicAnimation.TRANSLATION_Y);
-
// If we're flinging now, there's no more touch event to catch up to.
mFirstBubbleSpringingToTouch = false;
mIsMovingFromFlinging = true;
@@ -304,6 +310,18 @@
setStackPosition(new PointF(x, y));
}
+ /** Description of current animation controller state. */
+ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ pw.println("StackAnimationController state:");
+ pw.print(" isActive: "); pw.println(isActiveController());
+ pw.print(" restingStackPos: ");
+ pw.println(mRestingStackPosition != null ? mRestingStackPosition.toString() : "null");
+ pw.print(" currentStackPos: "); pw.println(mStackPosition.toString());
+ pw.print(" isMovingFromFlinging: "); pw.println(mIsMovingFromFlinging);
+ pw.print(" withinDismiss: "); pw.println(mWithinDismissTarget);
+ pw.print(" firstBubbleSpringing: "); pw.println(mFirstBubbleSpringingToTouch);
+ }
+
/**
* Flings the first bubble along the given property's axis, using the provided configuration
* values. When the animation ends - either by hitting the min/max, or by friction sufficiently
@@ -317,7 +335,7 @@
SpringForce spring,
Float finalPosition) {
Log.d(TAG, String.format("Flinging %s.",
- PhysicsAnimationLayout.getReadablePropertyName(property)));
+ PhysicsAnimationLayout.getReadablePropertyName(property)));
StackPositionProperty firstBubbleProperty = new StackPositionProperty(property);
final float currentValue = firstBubbleProperty.getValue(this);
@@ -347,6 +365,9 @@
.addEndListener((animation, canceled, endValue, endVelocity) -> {
if (!canceled) {
+ mRestingStackPosition = new PointF();
+ mRestingStackPosition.set(mStackPosition);
+
springFirstBubbleWithStackFollowing(property, spring, endVelocity,
finalPosition != null
? finalPosition
@@ -368,8 +389,8 @@
cancelStackPositionAnimation(DynamicAnimation.TRANSLATION_X);
cancelStackPositionAnimation(DynamicAnimation.TRANSLATION_Y);
- mLayout.removeEndActionForProperty(DynamicAnimation.TRANSLATION_X);
- mLayout.removeEndActionForProperty(DynamicAnimation.TRANSLATION_Y);
+ removeEndActionForProperty(DynamicAnimation.TRANSLATION_X);
+ removeEndActionForProperty(DynamicAnimation.TRANSLATION_Y);
}
/** Save the current IME height so that we know where the stack bounds should be. */
@@ -427,7 +448,7 @@
: 0);
allowableRegion.right =
mLayout.getWidth()
- - mIndividualBubbleSize
+ - mBubbleSize
+ mBubbleOffscreen
- Math.max(
insets.getSystemWindowInsetRight(),
@@ -436,7 +457,7 @@
: 0);
allowableRegion.top =
- mBubblePadding
+ mBubblePaddingTop
+ Math.max(
mStatusBarHeight,
insets.getDisplayCutout() != null
@@ -444,9 +465,9 @@
: 0);
allowableRegion.bottom =
mLayout.getHeight()
- - mIndividualBubbleSize
- - mBubblePadding
- - (mImeHeight > Float.MIN_VALUE ? mImeHeight + mBubblePadding : 0f)
+ - mBubbleSize
+ - mBubblePaddingTop
+ - (mImeHeight > Float.MIN_VALUE ? mImeHeight + mBubblePaddingTop : 0f)
- Math.max(
insets.getSystemWindowInsetBottom(),
insets.getDisplayCutout() != null
@@ -516,13 +537,19 @@
mWithinDismissTarget = true;
mFirstBubbleSpringingToTouch = false;
- animationForChildAtIndex(0)
- .translationX(mLayout.getWidth() / 2f - mIndividualBubbleSize / 2f)
- .translationY(destY, after)
- .withPositionStartVelocities(velX, velY)
- .withStiffness(SpringForce.STIFFNESS_MEDIUM)
- .withDampingRatio(SpringForce.DAMPING_RATIO_LOW_BOUNCY)
- .start();
+ springFirstBubbleWithStackFollowing(
+ DynamicAnimation.TRANSLATION_X,
+ new SpringForce()
+ .setDampingRatio(SpringForce.DAMPING_RATIO_LOW_BOUNCY)
+ .setStiffness(SpringForce.STIFFNESS_MEDIUM),
+ velX, mLayout.getWidth() / 2f - mBubbleIconBitmapSize / 2f);
+
+ springFirstBubbleWithStackFollowing(
+ DynamicAnimation.TRANSLATION_Y,
+ new SpringForce()
+ .setDampingRatio(SpringForce.DAMPING_RATIO_LOW_BOUNCY)
+ .setStiffness(SpringForce.STIFFNESS_MEDIUM),
+ velY, destY, after);
}
/**
@@ -550,7 +577,7 @@
*/
protected void springFirstBubbleWithStackFollowing(
DynamicAnimation.ViewProperty property, SpringForce spring,
- float vel, float finalPosition) {
+ float vel, float finalPosition, @Nullable Runnable... after) {
if (mLayout.getChildCount() == 0) {
return;
@@ -564,6 +591,13 @@
SpringAnimation springAnimation =
new SpringAnimation(this, firstBubbleProperty)
.setSpring(spring)
+ .addEndListener((dynamicAnimation, b, v, v1) -> {
+ if (after != null) {
+ for (Runnable callback : after) {
+ callback.run();
+ }
+ }
+ })
.setStartVelocity(vel);
cancelStackPositionAnimation(property);
@@ -620,13 +654,18 @@
@Override
void onChildAdded(View child, int index) {
+ // Don't animate additions within the dismiss target.
+ if (mWithinDismissTarget) {
+ return;
+ }
+
if (mLayout.getChildCount() == 1) {
// If this is the first child added, position the stack in its starting position.
moveStackToStartPosition();
} else if (isStackPositionSet() && mLayout.indexOfChild(child) == 0) {
// Otherwise, animate the bubble in if it's the newest bubble. If we're adding a bubble
// to the back of the stack, it'll be largely invisible so don't bother animating it in.
- animateInBubble(child);
+ animateInBubble(child, index);
}
}
@@ -641,24 +680,29 @@
.translationX(mStackPosition.x - (-xOffset * ANIMATE_TRANSLATION_FACTOR))
.start();
+ // If there are other bubbles, pull them into the correct position.
if (mLayout.getChildCount() > 0) {
animationForChildAtIndex(0).translationX(mStackPosition.x).start();
} else {
- // Set the start position back to the default since we're out of bubbles. New bubbles
- // will then animate in from the start position.
- mStackPosition = getDefaultStartPosition();
+ // If there's no other bubbles, and we were in the dismiss target, reset the flag.
+ mWithinDismissTarget = false;
}
}
@Override
- void onChildReordered(View child, int oldIndex, int newIndex) {}
+ void onChildReordered(View child, int oldIndex, int newIndex) {
+ if (isStackPositionSet()) {
+ setStackPosition(mStackPosition);
+ }
+ }
@Override
void onActiveControllerForLayout(PhysicsAnimationLayout layout) {
Resources res = layout.getResources();
mStackOffset = res.getDimensionPixelSize(R.dimen.bubble_stack_offset);
- mIndividualBubbleSize = res.getDimensionPixelSize(R.dimen.individual_bubble_size);
- mBubblePadding = res.getDimensionPixelSize(R.dimen.bubble_padding);
+ mBubbleSize = res.getDimensionPixelSize(R.dimen.individual_bubble_size);
+ mBubbleIconBitmapSize = res.getDimensionPixelSize(R.dimen.bubble_icon_bitmap_size);
+ mBubblePaddingTop = res.getDimensionPixelSize(R.dimen.bubble_padding_top);
mBubbleOffscreen = res.getDimensionPixelSize(R.dimen.bubble_stack_offscreen);
mStackStartingVerticalOffset =
res.getDimensionPixelSize(R.dimen.bubble_stack_starting_offset_y);
@@ -666,6 +710,20 @@
res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height);
}
+ /**
+ * Update effective screen width based on current orientation.
+ * @param orientation Landscape or portrait.
+ */
+ public void updateOrientation(int orientation) {
+ if (mLayout != null) {
+ Resources res = mLayout.getContext().getResources();
+ mBubblePaddingTop = res.getDimensionPixelSize(R.dimen.bubble_padding_top);
+ mStatusBarHeight = res.getDimensionPixelSize(
+ com.android.internal.R.dimen.status_bar_height);
+ }
+ }
+
+
/** Moves the stack, without any animation, to the starting position. */
private void moveStackToStartPosition() {
// Post to ensure that the layout's width and height have been calculated.
@@ -679,7 +737,7 @@
// Animate in the top bubble now that we're visible.
if (mLayout.getChildCount() > 0) {
- animateInBubble(mLayout.getChildAt(0));
+ animateInBubble(mLayout.getChildAt(0), 0 /* index */);
}
});
}
@@ -715,7 +773,9 @@
// If we're not the active controller, we don't want to physically move the bubble views.
if (isActiveController()) {
- mLayout.cancelAllAnimations();
+ // Cancel animations that could be moving the views.
+ mLayout.cancelAllAnimationsOfProperties(
+ DynamicAnimation.TRANSLATION_X, DynamicAnimation.TRANSLATION_Y);
cancelStackPositionAnimations();
// Since we're not using the chained animations, apply the offsets manually.
@@ -742,21 +802,34 @@
}
/** Animates in the given bubble. */
- private void animateInBubble(View child) {
+ private void animateInBubble(View child, int index) {
if (!isActiveController()) {
return;
}
- child.setTranslationY(mStackPosition.y);
+ final float xOffset =
+ getOffsetForChainedPropertyAnimation(DynamicAnimation.TRANSLATION_X);
- float xOffset = getOffsetForChainedPropertyAnimation(DynamicAnimation.TRANSLATION_X);
+ // Position the new bubble in the correct position, scaled down completely.
+ child.setTranslationX(mStackPosition.x + xOffset * index);
+ child.setTranslationY(mStackPosition.y);
+ child.setScaleX(0f);
+ child.setScaleY(0f);
+
+ // Push the subsequent views out of the way, if there are subsequent views.
+ if (index + 1 < mLayout.getChildCount()) {
+ animationForChildAtIndex(index + 1)
+ .translationX(mStackPosition.x + xOffset * (index + 1))
+ .withStiffness(SpringForce.STIFFNESS_LOW)
+ .start();
+ }
+
+ // Scale in the new bubble, slightly delayed.
animationForChild(child)
- .scaleX(ANIMATE_IN_STARTING_SCALE /* from */, 1f /* to */)
- .scaleY(ANIMATE_IN_STARTING_SCALE /* from */, 1f /* to */)
- .alpha(0f /* from */, 1f /* to */)
- .translationX(
- mStackPosition.x - ANIMATE_TRANSLATION_FACTOR * xOffset /* from */,
- mStackPosition.x /* to */)
+ .scaleX(1f)
+ .scaleY(1f)
+ .withStiffness(ANIMATE_IN_STIFFNESS)
+ .withStartDelay(mLayout.getChildCount() > 1 ? ANIMATE_IN_START_DELAY : 0)
.start();
}
diff --git a/packages/SystemUI/src/com/android/systemui/classifier/FalsingManagerFactory.java b/packages/SystemUI/src/com/android/systemui/classifier/FalsingManagerFactory.java
deleted file mode 100644
index 01921f0..0000000
--- a/packages/SystemUI/src/com/android/systemui/classifier/FalsingManagerFactory.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.classifier;
-
-import android.content.Context;
-
-import com.android.systemui.Dependency;
-import com.android.systemui.plugins.FalsingManager;
-
-/**
- * When the phone is locked, listens to touch, sensor and phone events and sends them to
- * DataCollector and HumanInteractionClassifier.
- *
- * It does not collect touch events when the bouncer shows up.
- *
- * TODO: FalsingManager supports dependency injection. Use it.
- */
-public class FalsingManagerFactory {
- private static FalsingManager sInstance = null;
-
- private FalsingManagerFactory() {}
-
- public static FalsingManager getInstance(Context context) {
- if (sInstance == null) {
- sInstance = Dependency.get(FalsingManager.class);
- }
- return sInstance;
- }
-
-}
diff --git a/packages/SystemUI/src/com/android/systemui/classifier/FalsingManagerFake.java b/packages/SystemUI/src/com/android/systemui/classifier/FalsingManagerFake.java
new file mode 100644
index 0000000..ea175ed
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/classifier/FalsingManagerFake.java
@@ -0,0 +1,246 @@
+/*
+ * 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.
+ */
+
+package com.android.systemui.classifier;
+
+import android.net.Uri;
+import android.view.MotionEvent;
+
+import com.android.internal.annotations.VisibleForTesting;
+import com.android.systemui.plugins.FalsingManager;
+
+import java.io.PrintWriter;
+
+/**
+ * Simple Fake for testing where {@link FalsingManager} is required.
+ */
+public class FalsingManagerFake implements FalsingManager {
+ private boolean mIsFalseTouch;
+ private boolean mIsUnlockingDisabled;
+ private boolean mIsClassiferEnabled;
+ private boolean mShouldEnforceBouncer;
+ private boolean mIsReportingEnabled;
+
+ @Override
+ public void onSucccessfulUnlock() {
+
+ }
+
+ @Override
+ public void onNotificationActive() {
+
+ }
+
+ @Override
+ public void setShowingAod(boolean showingAod) {
+
+ }
+
+ @Override
+ public void onNotificatonStartDraggingDown() {
+
+ }
+
+ @VisibleForTesting
+ public void setIsUnlockingDisabled(boolean isUnlockingDisabled) {
+ mIsUnlockingDisabled = isUnlockingDisabled;
+ }
+
+ @Override
+ public boolean isUnlockingDisabled() {
+ return mIsUnlockingDisabled;
+ }
+
+ @VisibleForTesting
+ public void setIsFalseTouch(boolean isFalseTouch) {
+ mIsFalseTouch = isFalseTouch;
+ }
+
+ @Override
+ public boolean isFalseTouch() {
+ return mIsFalseTouch;
+ }
+
+ @Override
+ public void onNotificatonStopDraggingDown() {
+
+ }
+
+ @Override
+ public void setNotificationExpanded() {
+
+ }
+
+ @VisibleForTesting
+ public void setIsClassiferEnabled(boolean isClassiferEnabled) {
+ mIsClassiferEnabled = isClassiferEnabled;
+ }
+
+ @Override
+ public boolean isClassiferEnabled() {
+ return mIsClassiferEnabled;
+ }
+
+ @Override
+ public void onQsDown() {
+
+ }
+
+ @Override
+ public void setQsExpanded(boolean expanded) {
+
+ }
+
+ @VisibleForTesting
+ public void setShouldEnforceBouncer(boolean shouldEnforceBouncer) {
+ mShouldEnforceBouncer = shouldEnforceBouncer;
+ }
+
+ @Override
+ public boolean shouldEnforceBouncer() {
+ return mShouldEnforceBouncer;
+ }
+
+ @Override
+ public void onTrackingStarted(boolean secure) {
+
+ }
+
+ @Override
+ public void onTrackingStopped() {
+
+ }
+
+ @Override
+ public void onLeftAffordanceOn() {
+
+ }
+
+ @Override
+ public void onCameraOn() {
+
+ }
+
+ @Override
+ public void onAffordanceSwipingStarted(boolean rightCorner) {
+
+ }
+
+ @Override
+ public void onAffordanceSwipingAborted() {
+
+ }
+
+ @Override
+ public void onStartExpandingFromPulse() {
+
+ }
+
+ @Override
+ public void onExpansionFromPulseStopped() {
+
+ }
+
+ @Override
+ public Uri reportRejectedTouch() {
+ return null;
+ }
+
+ @Override
+ public void onScreenOnFromTouch() {
+
+ }
+
+
+ @VisibleForTesting
+ public void setIsReportingEnabled(boolean isReportingEnabled) {
+ mIsReportingEnabled = isReportingEnabled;
+ }
+
+ @Override
+ public boolean isReportingEnabled() {
+ return mIsReportingEnabled;
+ }
+
+ @Override
+ public void onUnlockHintStarted() {
+
+ }
+
+ @Override
+ public void onCameraHintStarted() {
+
+ }
+
+ @Override
+ public void onLeftAffordanceHintStarted() {
+
+ }
+
+ @Override
+ public void onScreenTurningOn() {
+
+ }
+
+ @Override
+ public void onScreenOff() {
+
+ }
+
+ @Override
+ public void onNotificatonStopDismissing() {
+
+ }
+
+ @Override
+ public void onNotificationDismissed() {
+
+ }
+
+ @Override
+ public void onNotificatonStartDismissing() {
+
+ }
+
+ @Override
+ public void onNotificationDoubleTap(boolean accepted, float dx, float dy) {
+
+ }
+
+ @Override
+ public void onBouncerShown() {
+
+ }
+
+ @Override
+ public void onBouncerHidden() {
+
+ }
+
+ @Override
+ public void onTouchEvent(MotionEvent ev, int width, int height) {
+
+ }
+
+ @Override
+ public void dump(PrintWriter pw) {
+
+ }
+
+ @Override
+ public void cleanup() {
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/classifier/FalsingManagerProxy.java b/packages/SystemUI/src/com/android/systemui/classifier/FalsingManagerProxy.java
index ee79e6b..cff0622 100644
--- a/packages/SystemUI/src/com/android/systemui/classifier/FalsingManagerProxy.java
+++ b/packages/SystemUI/src/com/android/systemui/classifier/FalsingManagerProxy.java
@@ -27,14 +27,13 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.keyguard.KeyguardUpdateMonitor;
-import com.android.systemui.Dependency;
import com.android.systemui.classifier.brightline.BrightLineFalsingManager;
import com.android.systemui.classifier.brightline.FalsingDataProvider;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.FalsingPlugin;
import com.android.systemui.plugins.PluginListener;
import com.android.systemui.shared.plugins.PluginManager;
-import com.android.systemui.util.AsyncSensorManager;
+import com.android.systemui.util.ProximitySensor;
import java.io.PrintWriter;
@@ -50,18 +49,23 @@
@Singleton
public class FalsingManagerProxy implements FalsingManager {
+ private static final String PROXIMITY_SENSOR_TAG = "FalsingManager";
+
+ private final ProximitySensor mProximitySensor;
private FalsingManager mInternalFalsingManager;
private final Handler mMainHandler;
@Inject
FalsingManagerProxy(Context context, PluginManager pluginManager,
- @Named(MAIN_HANDLER_NAME) Handler handler) {
+ @Named(MAIN_HANDLER_NAME) Handler handler,
+ ProximitySensor proximitySensor) {
mMainHandler = handler;
+ mProximitySensor = proximitySensor;
+ mProximitySensor.setTag(PROXIMITY_SENSOR_TAG);
DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_SYSTEMUI,
command -> mMainHandler.post(command),
properties -> onDeviceConfigPropertiesChanged(context, properties.getNamespace())
- );
- setupFalsingManager(context);
+ ); setupFalsingManager(context);
final PluginListener<FalsingPlugin> mPluginListener = new PluginListener<FalsingPlugin>() {
public void onPluginConnected(FalsingPlugin plugin, Context context) {
FalsingManager pluginFalsingManager = plugin.getFalsingManager(context);
@@ -103,8 +107,8 @@
} else {
mInternalFalsingManager = new BrightLineFalsingManager(
new FalsingDataProvider(context.getResources().getDisplayMetrics()),
- Dependency.get(AsyncSensorManager.class),
- KeyguardUpdateMonitor.getInstance(context)
+ KeyguardUpdateMonitor.getInstance(context),
+ mProximitySensor
);
}
diff --git a/packages/SystemUI/src/com/android/systemui/classifier/brightline/BrightLineFalsingManager.java b/packages/SystemUI/src/com/android/systemui/classifier/brightline/BrightLineFalsingManager.java
index 9e0b702..b68a56d 100644
--- a/packages/SystemUI/src/com/android/systemui/classifier/brightline/BrightLineFalsingManager.java
+++ b/packages/SystemUI/src/com/android/systemui/classifier/brightline/BrightLineFalsingManager.java
@@ -19,10 +19,6 @@
import static com.android.systemui.classifier.FalsingManagerImpl.FALSING_REMAIN_LOCKED;
import static com.android.systemui.classifier.FalsingManagerImpl.FALSING_SUCCESS;
-import android.hardware.Sensor;
-import android.hardware.SensorEvent;
-import android.hardware.SensorEventListener;
-import android.hardware.SensorManager;
import android.hardware.biometrics.BiometricSourceType;
import android.net.Uri;
import android.util.Log;
@@ -33,12 +29,11 @@
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.systemui.classifier.Classifier;
import com.android.systemui.plugins.FalsingManager;
+import com.android.systemui.util.ProximitySensor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
/**
* FalsingManager designed to make clear why a touch was rejected.
@@ -48,9 +43,9 @@
static final boolean DEBUG = false;
private static final String TAG = "FalsingManagerPlugin";
- private final SensorManager mSensorManager;
private final FalsingDataProvider mDataProvider;
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
+ private final ProximitySensor mProximitySensor;
private boolean mSessionStarted;
private MetricsLogger mMetricsLogger;
private int mIsFalseTouchCalls;
@@ -58,20 +53,9 @@
private boolean mScreenOn;
private boolean mJustUnlockedWithFace;
- private final ExecutorService mBackgroundExecutor = Executors.newSingleThreadExecutor();
-
private final List<FalsingClassifier> mClassifiers;
- private SensorEventListener mSensorEventListener = new SensorEventListener() {
- @Override
- public synchronized void onSensorChanged(SensorEvent event) {
- onSensorEvent(event);
- }
-
- @Override
- public void onAccuracyChanged(Sensor sensor, int accuracy) {
- }
- };
+ private ProximitySensor.ProximitySensorListener mSensorEventListener = this::onProximityEvent;
private final KeyguardUpdateMonitorCallback mKeyguardUpdateCallback =
new KeyguardUpdateMonitorCallback() {
@@ -87,11 +71,11 @@
public BrightLineFalsingManager(
FalsingDataProvider falsingDataProvider,
- SensorManager sensorManager,
- KeyguardUpdateMonitor keyguardUpdateMonitor) {
+ KeyguardUpdateMonitor keyguardUpdateMonitor,
+ ProximitySensor proximitySensor) {
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
mDataProvider = falsingDataProvider;
- mSensorManager = sensorManager;
+ mProximitySensor = proximitySensor;
mKeyguardUpdateMonitor.registerCallback(mKeyguardUpdateCallback);
mMetricsLogger = new MetricsLogger();
@@ -108,24 +92,12 @@
}
private void registerSensors() {
- Sensor s = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
- if (s != null) {
- // This can be expensive, and doesn't need to happen on the main thread.
- mBackgroundExecutor.submit(() -> {
- logDebug("registering sensor listener");
- mSensorManager.registerListener(
- mSensorEventListener, s, SensorManager.SENSOR_DELAY_GAME);
- });
- }
+ mProximitySensor.register(mSensorEventListener);
}
private void unregisterSensors() {
- // This can be expensive, and doesn't need to happen on the main thread.
- mBackgroundExecutor.submit(() -> {
- logDebug("unregistering sensor listener");
- mSensorManager.unregisterListener(mSensorEventListener);
- });
+ mProximitySensor.unregister(mSensorEventListener);
}
private void sessionStart() {
@@ -187,10 +159,10 @@
mClassifiers.forEach((classifier) -> classifier.onTouchEvent(motionEvent));
}
- private void onSensorEvent(SensorEvent sensorEvent) {
+ private void onProximityEvent(ProximitySensor.ProximityEvent proximityEvent) {
// TODO: some of these classifiers might allow us to abort early, meaning we don't have to
// make these calls.
- mClassifiers.forEach((classifier) -> classifier.onSensorEvent(sensorEvent));
+ mClassifiers.forEach((classifier) -> classifier.onProximityEvent(proximityEvent));
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/classifier/brightline/FalsingClassifier.java b/packages/SystemUI/src/com/android/systemui/classifier/brightline/FalsingClassifier.java
index 685e7c5..bf39751 100644
--- a/packages/SystemUI/src/com/android/systemui/classifier/brightline/FalsingClassifier.java
+++ b/packages/SystemUI/src/com/android/systemui/classifier/brightline/FalsingClassifier.java
@@ -16,10 +16,10 @@
package com.android.systemui.classifier.brightline;
-import android.hardware.SensorEvent;
import android.view.MotionEvent;
import com.android.systemui.classifier.Classifier;
+import com.android.systemui.util.ProximitySensor;
import java.util.List;
@@ -98,9 +98,9 @@
void onTouchEvent(MotionEvent motionEvent) {};
/**
- * Called whenever a SensorEvent occurs, specifically the ProximitySensor.
+ * Called when a ProximityEvent occurs (change in near/far).
*/
- void onSensorEvent(SensorEvent sensorEvent) {};
+ void onProximityEvent(ProximitySensor.ProximityEvent proximityEvent) {};
/**
* The phone screen has turned on and we need to begin falsing detection.
diff --git a/packages/SystemUI/src/com/android/systemui/classifier/brightline/ProximityClassifier.java b/packages/SystemUI/src/com/android/systemui/classifier/brightline/ProximityClassifier.java
index 2644bf9..5045095 100644
--- a/packages/SystemUI/src/com/android/systemui/classifier/brightline/ProximityClassifier.java
+++ b/packages/SystemUI/src/com/android/systemui/classifier/brightline/ProximityClassifier.java
@@ -19,11 +19,11 @@
import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_PROXIMITY_PERCENT_COVERED_THRESHOLD;
import static com.android.systemui.classifier.Classifier.QUICK_SETTINGS;
-import android.hardware.Sensor;
-import android.hardware.SensorEvent;
import android.provider.DeviceConfig;
import android.view.MotionEvent;
+import com.android.systemui.util.ProximitySensor;
+
/**
* False touch if proximity sensor is covered for more than a certain percentage of the gesture.
@@ -97,14 +97,12 @@
}
@Override
- public void onSensorEvent(SensorEvent sensorEvent) {
- if (sensorEvent.sensor.getType() == Sensor.TYPE_PROXIMITY) {
- logDebug("Sensor is: " + (sensorEvent.values[0] < sensorEvent.sensor.getMaximumRange())
- + " at time " + sensorEvent.timestamp);
- update(
- sensorEvent.values[0] < sensorEvent.sensor.getMaximumRange(),
- sensorEvent.timestamp);
- }
+ public void onProximityEvent(
+ ProximitySensor.ProximityEvent proximityEvent) {
+ boolean near = proximityEvent.getNear();
+ long timestampNs = proximityEvent.getTimestampNs();
+ logDebug("Sensor is: " + near + " at time " + timestampNs);
+ update(near, timestampNs);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/dock/DockManagerImpl.java b/packages/SystemUI/src/com/android/systemui/dock/DockManagerImpl.java
new file mode 100644
index 0000000..fa7f503
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/dock/DockManagerImpl.java
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+package com.android.systemui.dock;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+@Singleton
+public class DockManagerImpl implements DockManager {
+
+ @Inject
+ public DockManagerImpl() {
+ }
+
+ @Override
+ public void addListener(DockEventListener callback) {
+ }
+
+ @Override
+ public void removeListener(DockEventListener callback) {
+ }
+
+ @Override
+ public boolean isDocked() {
+ return false;
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeAuthRemover.java b/packages/SystemUI/src/com/android/systemui/doze/DozeAuthRemover.java
index e6a9e47..e5a54b8 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeAuthRemover.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeAuthRemover.java
@@ -25,7 +25,7 @@
*/
public class DozeAuthRemover implements DozeMachine.Part {
- KeyguardUpdateMonitor mKeyguardUpdateMonitor;
+ private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
public DozeAuthRemover(Context context) {
mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(context);
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java b/packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java
index d22d2c3..90cb05a 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java
@@ -28,8 +28,9 @@
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.SystemUIApplication;
-import com.android.systemui.classifier.FalsingManagerFactory;
import com.android.systemui.dock.DockManager;
+import com.android.systemui.keyguard.WakefulnessLifecycle;
+import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.statusbar.phone.BiometricUnlockController;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.util.AsyncSensorManager;
@@ -42,11 +43,12 @@
}
/** Creates a DozeMachine with its parts for {@code dozeService}. */
- public DozeMachine assembleMachine(DozeService dozeService) {
+ public DozeMachine assembleMachine(DozeService dozeService, FalsingManager falsingManager) {
Context context = dozeService;
SensorManager sensorManager = Dependency.get(AsyncSensorManager.class);
AlarmManager alarmManager = context.getSystemService(AlarmManager.class);
DockManager dockManager = Dependency.get(DockManager.class);
+ WakefulnessLifecycle wakefulnessLifecycle = Dependency.get(WakefulnessLifecycle.class);
DozeHost host = getHost(dozeService);
AmbientDisplayConfiguration config = new AmbientDisplayConfiguration(context);
@@ -61,10 +63,11 @@
wrappedService = DozeSuspendScreenStatePreventingAdapter.wrapIfNeeded(wrappedService,
params);
- DozeMachine machine = new DozeMachine(wrappedService, config, wakeLock);
+ DozeMachine machine = new DozeMachine(wrappedService, config, wakeLock,
+ wakefulnessLifecycle);
machine.setParts(new DozeMachine.Part[]{
new DozePauser(handler, machine, alarmManager, params.getPolicy()),
- new DozeFalsingManagerAdapter(FalsingManagerFactory.getInstance(context)),
+ new DozeFalsingManagerAdapter(falsingManager),
createDozeTriggers(context, sensorManager, host, alarmManager, config, params,
handler, wakeLock, machine, dockManager),
createDozeUi(context, host, wakeLock, machine, handler, alarmManager, params),
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java b/packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java
index 8bf2256..93a51cc 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java
@@ -24,6 +24,8 @@
import android.view.Display;
import com.android.internal.util.Preconditions;
+import com.android.systemui.keyguard.WakefulnessLifecycle;
+import com.android.systemui.keyguard.WakefulnessLifecycle.Wakefulness;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.util.Assert;
import com.android.systemui.util.wakelock.WakeLock;
@@ -118,6 +120,7 @@
private final Service mDozeService;
private final WakeLock mWakeLock;
private final AmbientDisplayConfiguration mConfig;
+ private final WakefulnessLifecycle mWakefulnessLifecycle;
private Part[] mParts;
private final ArrayList<State> mQueuedRequests = new ArrayList<>();
@@ -126,9 +129,10 @@
private boolean mWakeLockHeldForCurrentState = false;
public DozeMachine(Service service, AmbientDisplayConfiguration config,
- WakeLock wakeLock) {
+ WakeLock wakeLock, WakefulnessLifecycle wakefulnessLifecycle) {
mDozeService = service;
mConfig = config;
+ mWakefulnessLifecycle = wakefulnessLifecycle;
mWakeLock = wakeLock;
}
@@ -334,9 +338,18 @@
switch (state) {
case INITIALIZED:
case DOZE_PULSE_DONE:
- transitionTo(mConfig.alwaysOnEnabled(UserHandle.USER_CURRENT)
- ? DozeMachine.State.DOZE_AOD : DozeMachine.State.DOZE,
- DozeLog.PULSE_REASON_NONE);
+ final State nextState;
+ @Wakefulness int wakefulness = mWakefulnessLifecycle.getWakefulness();
+ if (wakefulness == WakefulnessLifecycle.WAKEFULNESS_AWAKE
+ || wakefulness == WakefulnessLifecycle.WAKEFULNESS_WAKING) {
+ nextState = State.FINISH;
+ } else if (mConfig.alwaysOnEnabled(UserHandle.USER_CURRENT)) {
+ nextState = State.DOZE_AOD;
+ } else {
+ nextState = State.DOZE;
+ }
+
+ transitionTo(nextState, DozeLog.PULSE_REASON_NONE);
break;
default:
break;
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeService.java b/packages/SystemUI/src/com/android/systemui/doze/DozeService.java
index 2db7306..9e1514c 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeService.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeService.java
@@ -25,12 +25,15 @@
import com.android.systemui.Dependency;
import com.android.systemui.plugins.DozeServicePlugin;
import com.android.systemui.plugins.DozeServicePlugin.RequestDoze;
+import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.PluginListener;
import com.android.systemui.shared.plugins.PluginManager;
import java.io.FileDescriptor;
import java.io.PrintWriter;
+import javax.inject.Inject;
+
public class DozeService extends DreamService
implements DozeMachine.Service, RequestDoze, PluginListener<DozeServicePlugin> {
private static final String TAG = "DozeService";
@@ -40,6 +43,7 @@
private DozeServicePlugin mDozePlugin;
private PluginManager mPluginManager;
+ @Inject
public DozeService() {
setDebug(DEBUG);
}
@@ -56,7 +60,8 @@
}
mPluginManager = Dependency.get(PluginManager.class);
mPluginManager.addPluginListener(this, DozeServicePlugin.class, false /* allowMultiple */);
- mDozeMachine = new DozeFactory().assembleMachine(this);
+ mDozeMachine = new DozeFactory().assembleMachine(
+ this, Dependency.get(FalsingManager.class));
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/fragments/FragmentService.java b/packages/SystemUI/src/com/android/systemui/fragments/FragmentService.java
index 8dbaf0f..b4cc571 100644
--- a/packages/SystemUI/src/com/android/systemui/fragments/FragmentService.java
+++ b/packages/SystemUI/src/com/android/systemui/fragments/FragmentService.java
@@ -22,7 +22,7 @@
import com.android.systemui.ConfigurationChangedReceiver;
import com.android.systemui.Dumpable;
-import com.android.systemui.SystemUIFactory;
+import com.android.systemui.SystemUIRootComponent;
import com.android.systemui.qs.QSFragment;
import com.android.systemui.statusbar.phone.NavigationBarFragment;
@@ -51,7 +51,7 @@
private final FragmentCreator mFragmentCreator;
@Inject
- public FragmentService(SystemUIFactory.SystemUIRootComponent rootComponent) {
+ public FragmentService(SystemUIRootComponent rootComponent) {
mFragmentCreator = rootComponent.createFragmentCreator();
initInjectionMap();
}
diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
index 0e4c155..ff02e71 100644
--- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
+++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
@@ -614,7 +614,7 @@
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
- mScreenshotHelper.takeScreenshot(1, true, true, mHandler);
+ mScreenshotHelper.takeScreenshot(1, true, true, mHandler, null);
MetricsLogger.action(mContext,
MetricsEvent.ACTION_SCREENSHOT_POWER_MENU);
}
diff --git a/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageWallpaperRenderer.java b/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageWallpaperRenderer.java
index 7b22a49..2960634 100644
--- a/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageWallpaperRenderer.java
+++ b/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageWallpaperRenderer.java
@@ -111,7 +111,12 @@
mBitmap = mWallpaperManager.getBitmap();
mWallpaperManager.forgetLoadedWallpaper();
if (mBitmap != null) {
- mSurfaceSize.set(0, 0, mBitmap.getWidth(), mBitmap.getHeight());
+ float scale = (float) mScissor.height() / mBitmap.getHeight();
+ int surfaceHeight = Math.max(mScissor.height(), mBitmap.getHeight());
+ int surfaceWidth = scale > 1f
+ ? Math.round(mBitmap.getWidth() * scale)
+ : mBitmap.getWidth();
+ mSurfaceSize.set(0, 0, surfaceWidth, surfaceHeight);
}
}
return mBitmap != null;
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index e9f99ac..f424a8e 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -81,10 +81,11 @@
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.keyguard.ViewMediatorCallback;
import com.android.systemui.Dependency;
+import com.android.systemui.R;
import com.android.systemui.SystemUI;
import com.android.systemui.SystemUIFactory;
import com.android.systemui.UiOffloadThread;
-import com.android.systemui.classifier.FalsingManagerFactory;
+import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.statusbar.phone.BiometricUnlockController;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.NotificationPanelView;
@@ -713,8 +714,7 @@
// Assume keyguard is showing (unless it's disabled) until we know for sure, unless Keyguard
// is disabled.
- if (mContext.getResources().getBoolean(
- com.android.keyguard.R.bool.config_enableKeyguardService)) {
+ if (mContext.getResources().getBoolean(R.bool.config_enableKeyguardService)) {
setShowingLocked(!shouldWaitForProvisioning()
&& !mLockPatternUtils.isLockScreenDisabled(
KeyguardUpdateMonitor.getCurrentUser()), true /* forceCallbacks */);
@@ -1599,7 +1599,7 @@
Trace.beginSection("KeyguardViewMediator#handleMessage START_KEYGUARD_EXIT_ANIM");
StartKeyguardExitAnimParams params = (StartKeyguardExitAnimParams) msg.obj;
handleStartKeyguardExitAnimation(params.startTime, params.fadeoutDuration);
- FalsingManagerFactory.getInstance(mContext).onSucccessfulUnlock();
+ Dependency.get(FalsingManager.class).onSucccessfulUnlock();
Trace.endSection();
break;
case KEYGUARD_DONE_PENDING_TIMEOUT:
@@ -2071,10 +2071,11 @@
public StatusBarKeyguardViewManager registerStatusBar(StatusBar statusBar,
ViewGroup container, NotificationPanelView panelView,
BiometricUnlockController biometricUnlockController, ViewGroup lockIconContainer,
- View notificationContainer, KeyguardBypassController bypassController) {
+ View notificationContainer, KeyguardBypassController bypassController,
+ FalsingManager falsingManager) {
mStatusBarKeyguardViewManager.registerStatusBar(statusBar, container, panelView,
biometricUnlockController, mDismissCallbackRegistry, lockIconContainer,
- notificationContainer, bypassController);
+ notificationContainer, bypassController, falsingManager);
return mStatusBarKeyguardViewManager;
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/WakefulnessLifecycle.java b/packages/SystemUI/src/com/android/systemui/keyguard/WakefulnessLifecycle.java
index 52a0214..d17f2f6 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/WakefulnessLifecycle.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/WakefulnessLifecycle.java
@@ -16,12 +16,15 @@
package com.android.systemui.keyguard;
+import android.annotation.IntDef;
import android.os.Trace;
import com.android.systemui.Dumpable;
import java.io.FileDescriptor;
import java.io.PrintWriter;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -33,6 +36,15 @@
public class WakefulnessLifecycle extends Lifecycle<WakefulnessLifecycle.Observer> implements
Dumpable {
+ @IntDef(prefix = { "WAKEFULNESS_" }, value = {
+ WAKEFULNESS_ASLEEP,
+ WAKEFULNESS_WAKING,
+ WAKEFULNESS_AWAKE,
+ WAKEFULNESS_GOING_TO_SLEEP,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface Wakefulness {}
+
public static final int WAKEFULNESS_ASLEEP = 0;
public static final int WAKEFULNESS_WAKING = 1;
public static final int WAKEFULNESS_AWAKE = 2;
@@ -44,7 +56,7 @@
public WakefulnessLifecycle() {
}
- public int getWakefulness() {
+ public @Wakefulness int getWakefulness() {
return mWakefulness;
}
@@ -86,7 +98,7 @@
pw.println(" mWakefulness=" + mWakefulness);
}
- private void setWakefulness(int wakefulness) {
+ private void setWakefulness(@Wakefulness int wakefulness) {
mWakefulness = wakefulness;
Trace.traceCounter(Trace.TRACE_TAG_APP, "wakefulness", wakefulness);
}
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java
index 1740290..3be3422 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java
@@ -16,6 +16,9 @@
package com.android.systemui.pip.phone;
+import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
+import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
+
import android.app.ActivityManager;
import android.app.ActivityTaskManager;
import android.app.IActivityManager;
@@ -182,7 +185,6 @@
ActivityManagerWrapper.getInstance().registerTaskStackListener(mTaskStackListener);
mInputConsumerController = InputConsumerController.getPipInputConsumer();
- mInputConsumerController.registerInputConsumer();
mMediaController = new PipMediaController(context, mActivityManager);
mMenuController = new PipMenuActivityController(context, mActivityManager, mMediaController,
mInputConsumerController);
@@ -190,6 +192,18 @@
mMenuController, mInputConsumerController);
mAppOpsListener = new PipAppOpsListener(context, mActivityManager,
mTouchHandler.getMotionHelper());
+
+ // If SystemUI restart, and it already existed a pinned stack,
+ // register the pip input consumer to ensure touch can send to it.
+ try {
+ ActivityManager.StackInfo stackInfo = mActivityTaskManager.getStackInfo(
+ WINDOWING_MODE_PINNED, ACTIVITY_TYPE_UNDEFINED);
+ if (stackInfo != null) {
+ mInputConsumerController.registerInputConsumer();
+ }
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java
index 86ce60d..ec6d7ff 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java
@@ -48,7 +48,6 @@
import android.content.Intent;
import android.content.pm.ParceledListSlice;
import android.graphics.Color;
-import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
@@ -64,7 +63,6 @@
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
-import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.WindowManager.LayoutParams;
import android.view.accessibility.AccessibilityManager;
@@ -92,6 +90,7 @@
public static final int MESSAGE_UPDATE_ACTIONS = 4;
public static final int MESSAGE_UPDATE_DISMISS_FRACTION = 5;
public static final int MESSAGE_ANIMATION_ENDED = 6;
+ public static final int MESSAGE_TOUCH_EVENT = 7;
private static final int INITIAL_DISMISS_DELAY = 3500;
private static final int POST_INTERACTION_DISMISS_DELAY = 2000;
@@ -129,10 +128,6 @@
}
};
- private PipTouchState mTouchState;
- private PointF mDownPosition = new PointF();
- private PointF mDownDelta = new PointF();
- private ViewConfiguration mViewConfig;
private Handler mHandler = new Handler();
private Messenger mToControllerMessenger;
private Messenger mMessenger = new Messenger(new Handler() {
@@ -170,6 +165,12 @@
mAllowTouches = true;
break;
}
+
+ case MESSAGE_TOUCH_EVENT: {
+ final MotionEvent ev = (MotionEvent) msg.obj;
+ dispatchTouchEvent(ev);
+ break;
+ }
}
}
});
@@ -185,15 +186,7 @@
protected void onCreate(@Nullable Bundle savedInstanceState) {
// Set the flags to allow us to watch for outside touches and also hide the menu and start
// manipulating the PIP in the same touch gesture
- mViewConfig = ViewConfiguration.get(this);
- mTouchState = new PipTouchState(mViewConfig, mHandler, () -> {
- if (mMenuState == MENU_STATE_CLOSE) {
- showPipMenu();
- } else {
- expandPip();
- }
- });
- getWindow().addFlags(LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | LayoutParams.FLAG_SLIPPERY);
+ getWindow().addFlags(LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
super.onCreate(savedInstanceState);
setContentView(R.layout.pip_menu_activity);
@@ -205,32 +198,6 @@
mViewRoot.setBackground(mBackgroundDrawable);
mMenuContainer = findViewById(R.id.menu_container);
mMenuContainer.setAlpha(0);
- mMenuContainer.setOnTouchListener((v, event) -> {
- mTouchState.onTouchEvent(event);
- switch (event.getAction()) {
- case MotionEvent.ACTION_UP:
- if (mTouchState.isDoubleTap() || mMenuState == MENU_STATE_FULL) {
- // Expand to fullscreen if this is a double tap or we are already expanded
- expandPip();
- } else if (!mTouchState.isWaitingForDoubleTap()) {
- // User has stalled long enough for this not to be a drag or a double tap,
- // just expand the menu if necessary
- if (mMenuState == MENU_STATE_CLOSE) {
- showPipMenu();
- }
- } else {
- // Next touch event _may_ be the second tap for the double-tap, schedule a
- // fallback runnable to trigger the menu if no touch event occurs before the
- // next tap
- mTouchState.scheduleDoubleTapTimeoutCallback();
- }
- // Fall through
- case MotionEvent.ACTION_CANCEL:
- mTouchState.reset();
- break;
- }
- return true;
- });
mSettingsButton = findViewById(R.id.settings);
mSettingsButton.setAlpha(0);
mSettingsButton.setOnClickListener((v) -> {
@@ -240,8 +207,11 @@
});
mDismissButton = findViewById(R.id.dismiss);
mDismissButton.setAlpha(0);
- mDismissButton.setOnClickListener((v) -> {
- dismissPip();
+ mDismissButton.setOnClickListener(v -> dismissPip());
+ findViewById(R.id.expand_button).setOnClickListener(v -> {
+ if (mMenuContainer.getAlpha() != 0) {
+ expandPip();
+ }
});
mActionsGroup = findViewById(R.id.actions_group);
mBetweenActionPaddingLand = getResources().getDimensionPixelSize(
@@ -301,27 +271,14 @@
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (!mAllowTouches) {
- return super.dispatchTouchEvent(ev);
+ return false;
}
// On the first action outside the window, hide the menu
switch (ev.getAction()) {
case MotionEvent.ACTION_OUTSIDE:
hideMenu();
- break;
- case MotionEvent.ACTION_DOWN:
- mDownPosition.set(ev.getX(), ev.getY());
- mDownDelta.set(0f, 0f);
- break;
- case MotionEvent.ACTION_MOVE:
- mDownDelta.set(ev.getX() - mDownPosition.x, ev.getY() - mDownPosition.y);
- if (mDownDelta.length() > mViewConfig.getScaledTouchSlop()
- && mMenuState != MENU_STATE_NONE) {
- // Restore the input consumer and let that drive the movement of this menu
- notifyRegisterInputConsumer();
- cancelDelayedFinish();
- }
- break;
+ return true;
}
return super.dispatchTouchEvent(ev);
}
@@ -384,7 +341,6 @@
if (allowMenuTimeout) {
repostDelayedFinish(POST_INTERACTION_DISMISS_DELAY);
}
- notifyUnregisterInputConsumer();
}
}
@@ -509,11 +465,13 @@
actionView.setContentDescription(action.getContentDescription());
if (action.isEnabled()) {
actionView.setOnClickListener(v -> {
- try {
- action.getActionIntent().send();
- } catch (CanceledException e) {
- Log.w(TAG, "Failed to send action", e);
- }
+ mHandler.post(() -> {
+ try {
+ action.getActionIntent().send();
+ } catch (CanceledException e) {
+ Log.w(TAG, "Failed to send action", e);
+ }
+ });
});
}
actionView.setEnabled(action.isEnabled());
@@ -557,18 +515,6 @@
mBackgroundDrawable.setAlpha(alpha);
}
- private void notifyRegisterInputConsumer() {
- Message m = Message.obtain();
- m.what = PipMenuActivityController.MESSAGE_REGISTER_INPUT_CONSUMER;
- sendMessage(m, "Could not notify controller to register input consumer");
- }
-
- private void notifyUnregisterInputConsumer() {
- Message m = Message.obtain();
- m.what = PipMenuActivityController.MESSAGE_UNREGISTER_INPUT_CONSUMER;
- sendMessage(m, "Could not notify controller to unregister input consumer");
- }
-
private void notifyMenuStateChange(int menuState) {
mMenuState = menuState;
Message m = Message.obtain();
@@ -586,11 +532,6 @@
}, false /* notifyMenuVisibility */, false /* isDismissing */);
}
- private void minimizePip() {
- sendEmptyMessage(PipMenuActivityController.MESSAGE_MINIMIZE_PIP,
- "Could not notify controller to minimize PIP");
- }
-
private void dismissPip() {
// Do not notify menu visibility when hiding the menu, the controller will do this when it
// handles the message
@@ -600,12 +541,6 @@
}, false /* notifyMenuVisibility */, true /* isDismissing */);
}
- private void showPipMenu() {
- Message m = Message.obtain();
- m.what = PipMenuActivityController.MESSAGE_SHOW_MENU;
- sendMessage(m, "Could not notify controller to show PIP menu");
- }
-
private void showSettings() {
final Pair<ComponentName, Integer> topPipActivityInfo =
PipUtils.getTopPinnedActivity(this, ActivityManager.getService());
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java
index 46d53e4..57c04c3 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java
@@ -37,6 +37,7 @@
import android.os.SystemClock;
import android.os.UserHandle;
import android.util.Log;
+import android.view.MotionEvent;
import com.android.systemui.pip.phone.PipMediaController.ActionListener;
import com.android.systemui.shared.system.InputConsumerController;
@@ -156,14 +157,6 @@
mListeners.forEach(l -> l.onPipShowMenu());
break;
}
- case MESSAGE_REGISTER_INPUT_CONSUMER: {
- mInputConsumerController.registerInputConsumer();
- break;
- }
- case MESSAGE_UNREGISTER_INPUT_CONSUMER: {
- mInputConsumerController.unregisterInputConsumer();
- break;
- }
case MESSAGE_UPDATE_ACTIVITY_CALLBACK: {
mToActivityMessenger = msg.replyTo;
setStartActivityRequested(false);
@@ -212,15 +205,12 @@
}
public void onActivityPinned() {
- if (mMenuState == MENU_STATE_NONE) {
- // If the menu is not visible, then re-register the input consumer if it is not already
- // registered
- mInputConsumerController.registerInputConsumer();
- }
+ mInputConsumerController.registerInputConsumer();
}
public void onActivityUnpinned() {
hideMenu();
+ mInputConsumerController.unregisterInputConsumer();
setStartActivityRequested(false);
}
@@ -494,11 +484,7 @@
Log.d(TAG, "onMenuStateChanged() mMenuState=" + mMenuState
+ " menuState=" + menuState + " resize=" + resize);
}
- if (menuState == MENU_STATE_NONE) {
- mInputConsumerController.registerInputConsumer();
- } else {
- mInputConsumerController.unregisterInputConsumer();
- }
+
if (menuState != mMenuState) {
mListeners.forEach(l -> l.onPipMenuStateChanged(menuState, resize));
if (menuState == MENU_STATE_FULL) {
@@ -520,6 +506,22 @@
mStartActivityRequestedTime = requested ? SystemClock.uptimeMillis() : 0;
}
+ /**
+ * Handles touch event sent from pip input consumer.
+ */
+ void handleTouchEvent(MotionEvent ev) {
+ if (mToActivityMessenger != null) {
+ Message m = Message.obtain();
+ m.what = PipMenuActivity.MESSAGE_TOUCH_EVENT;
+ m.obj = ev;
+ try {
+ mToActivityMessenger.send(m);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Could not dispatch touch event", e);
+ }
+ }
+ }
+
public void dump(PrintWriter pw, String prefix) {
final String innerPrefix = prefix + " ";
pw.println(prefix + TAG);
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
index b05058a..30cf412 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
@@ -363,6 +363,8 @@
// Update the touch state
mTouchState.onTouchEvent(ev);
+ boolean shouldDeliverToMenu = mMenuState != MENU_STATE_NONE;
+
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN: {
mMotionHelper.synchronizePinnedStackBounds();
@@ -378,6 +380,8 @@
break;
}
}
+
+ shouldDeliverToMenu = !mTouchState.isDragging();
break;
}
case MotionEvent.ACTION_UP: {
@@ -394,6 +398,7 @@
// Fall through to clean up
}
case MotionEvent.ACTION_CANCEL: {
+ shouldDeliverToMenu = !mTouchState.startedDragging() && !mTouchState.isDragging();
mTouchState.reset();
break;
}
@@ -425,7 +430,20 @@
break;
}
}
- return mMenuState == MENU_STATE_NONE;
+
+ // Deliver the event to PipMenuActivity to handle button click if the menu has shown.
+ if (shouldDeliverToMenu) {
+ final MotionEvent cloneEvent = MotionEvent.obtain(ev);
+ // Send the cancel event and cancel menu timeout if it starts to drag.
+ if (mTouchState.startedDragging()) {
+ cloneEvent.setAction(MotionEvent.ACTION_CANCEL);
+ mMenuController.pokeMenu();
+ }
+
+ mMenuController.handleTouchEvent(cloneEvent);
+ }
+
+ return true;
}
/**
@@ -741,11 +759,11 @@
mMotionHelper.animateToClosestSnapTarget(mMovementBounds, null /* updateListener */,
null /* animatorListener */);
setMinimizedStateInternal(false);
+ } else if (mTouchState.isDoubleTap()) {
+ // Expand to fullscreen if this is a double tap
+ mMotionHelper.expandPip();
} else if (mMenuState != MENU_STATE_FULL) {
- if (mTouchState.isDoubleTap()) {
- // Expand to fullscreen if this is a double tap
- mMotionHelper.expandPip();
- } else if (!mTouchState.isWaitingForDoubleTap()) {
+ if (!mTouchState.isWaitingForDoubleTap()) {
// User has stalled long enough for this not to be a drag or a double tap, just
// expand the menu
mMenuController.showMenu(MENU_STATE_FULL, mMotionHelper.getBounds(),
@@ -756,9 +774,6 @@
// next tap
mTouchState.scheduleDoubleTapTimeoutCallback();
}
- } else {
- mMenuController.hideMenu();
- mMotionHelper.expandPip();
}
return true;
}
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchState.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchState.java
index 69efbc8..e3f65ef 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchState.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchState.java
@@ -106,6 +106,7 @@
mIsDoubleTap = !mPreviouslyDragging &&
(mDownTouchTime - mLastDownTouchTime) < DOUBLE_TAP_TIMEOUT;
mIsWaitingForDoubleTap = false;
+ mIsDragging = false;
mLastDownTouchTime = mDownTouchTime;
if (mDoubleTapTimeoutCallback != null) {
mHandler.removeCallbacks(mDoubleTapTimeoutCallback);
diff --git a/packages/SystemUI/src/com/android/systemui/power/EnhancedEstimatesImpl.java b/packages/SystemUI/src/com/android/systemui/power/EnhancedEstimatesImpl.java
index 9b1f23a..78f5350 100644
--- a/packages/SystemUI/src/com/android/systemui/power/EnhancedEstimatesImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/power/EnhancedEstimatesImpl.java
@@ -2,8 +2,16 @@
import com.android.settingslib.fuelgauge.Estimate;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+@Singleton
public class EnhancedEstimatesImpl implements EnhancedEstimates {
+ @Inject
+ public EnhancedEstimatesImpl() {
+ }
+
@Override
public boolean isHybridNotificationEnabled() {
return false;
diff --git a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
index 991d9fa..0403a05 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
@@ -248,7 +248,9 @@
int numPages = Math.max(nTiles / mPages.get(0).maxTiles(), 1);
// Add one more not full page if needed
- numPages += (nTiles % mPages.get(0).maxTiles() == 0 ? 0 : 1);
+ if (nTiles > numPages * mPages.get(0).maxTiles()) {
+ numPages++;
+ }
final int NP = mPages.size();
for (int i = 0; i < NP; i++) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSCarrierGroup.java b/packages/SystemUI/src/com/android/systemui/qs/QSCarrierGroup.java
index 255a4ba..cca889c 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSCarrierGroup.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSCarrierGroup.java
@@ -26,6 +26,7 @@
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;
+import android.widget.TextView;
import androidx.annotation.VisibleForTesting;
@@ -54,6 +55,7 @@
private View[] mCarrierDividers = new View[SIM_SLOTS - 1];
private QSCarrier[] mCarrierGroups = new QSCarrier[SIM_SLOTS];
+ private TextView mNoSimTextView;
private final CellSignalState[] mInfos = new CellSignalState[SIM_SLOTS];
private CarrierTextController mCarrierTextController;
private ActivityStarter mActivityStarter;
@@ -93,10 +95,13 @@
mCarrierDividers[0] = findViewById(R.id.qs_carrier_divider1);
mCarrierDividers[1] = findViewById(R.id.qs_carrier_divider2);
+ mNoSimTextView = findViewById(R.id.no_carrier_text);
+
for (int i = 0; i < SIM_SLOTS; i++) {
mInfos[i] = new CellSignalState();
mCarrierGroups[i].setOnClickListener(this);
}
+ mNoSimTextView.setOnClickListener(this);
CharSequence separator = mContext.getString(
com.android.internal.R.string.kg_text_message_separator);
@@ -153,50 +158,47 @@
@Override
public void updateCarrierInfo(CarrierTextController.CarrierTextCallbackInfo info) {
- if (info.airplaneMode) {
- setVisibility(View.GONE);
- } else {
- setVisibility(View.VISIBLE);
- if (info.anySimReady) {
- boolean[] slotSeen = new boolean[SIM_SLOTS];
- if (info.listOfCarriers.length == info.subscriptionIds.length) {
- for (int i = 0; i < SIM_SLOTS && i < info.listOfCarriers.length; i++) {
- int slot = getSlotIndex(info.subscriptionIds[i]);
- if (slot >= SIM_SLOTS) {
- Log.w(TAG, "updateInfoCarrier - slot: " + slot);
- continue;
- }
- if (slot == SubscriptionManager.INVALID_SIM_SLOT_INDEX) {
- Log.e(TAG,
- "Invalid SIM slot index for subscription: "
- + info.subscriptionIds[i]);
- continue;
- }
- mInfos[slot].visible = true;
- slotSeen[slot] = true;
- mCarrierGroups[slot].setCarrierText(
- info.listOfCarriers[i].toString().trim());
- mCarrierGroups[slot].setVisibility(View.VISIBLE);
+ mNoSimTextView.setVisibility(View.GONE);
+ if (!info.airplaneMode && info.anySimReady) {
+ boolean[] slotSeen = new boolean[SIM_SLOTS];
+ if (info.listOfCarriers.length == info.subscriptionIds.length) {
+ for (int i = 0; i < SIM_SLOTS && i < info.listOfCarriers.length; i++) {
+ int slot = getSlotIndex(info.subscriptionIds[i]);
+ if (slot >= SIM_SLOTS) {
+ Log.w(TAG, "updateInfoCarrier - slot: " + slot);
+ continue;
}
- for (int i = 0; i < SIM_SLOTS; i++) {
- if (!slotSeen[i]) {
- mInfos[i].visible = false;
- mCarrierGroups[i].setVisibility(View.GONE);
- }
+ if (slot == SubscriptionManager.INVALID_SIM_SLOT_INDEX) {
+ Log.e(TAG,
+ "Invalid SIM slot index for subscription: "
+ + info.subscriptionIds[i]);
+ continue;
}
- } else {
- Log.e(TAG, "Carrier information arrays not of same length");
+ mInfos[slot].visible = true;
+ slotSeen[slot] = true;
+ mCarrierGroups[slot].setCarrierText(
+ info.listOfCarriers[i].toString().trim());
+ mCarrierGroups[slot].setVisibility(View.VISIBLE);
+ }
+ for (int i = 0; i < SIM_SLOTS; i++) {
+ if (!slotSeen[i]) {
+ mInfos[i].visible = false;
+ mCarrierGroups[i].setVisibility(View.GONE);
+ }
}
} else {
- mInfos[0].visible = false;
- mCarrierGroups[0].setCarrierText(info.carrierText);
- mCarrierGroups[0].setVisibility(View.VISIBLE);
- for (int i = 1; i < SIM_SLOTS; i++) {
- mInfos[i].visible = false;
- mCarrierGroups[i].setCarrierText("");
- mCarrierGroups[i].setVisibility(View.GONE);
- }
+ Log.e(TAG, "Carrier information arrays not of same length");
}
+ } else {
+ // No sims or airplane mode (but not WFC). Do not show QSCarrierGroup, instead just show
+ // info.carrierText in a different view.
+ for (int i = 0; i < SIM_SLOTS; i++) {
+ mInfos[i].visible = false;
+ mCarrierGroups[i].setCarrierText("");
+ mCarrierGroups[i].setVisibility(View.GONE);
+ }
+ mNoSimTextView.setText(info.carrierText);
+ mNoSimTextView.setVisibility(View.VISIBLE);
}
handleUpdateState();
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java b/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java
index f0413cd..be8a8fd 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java
@@ -111,13 +111,25 @@
+ mQSPanel.getMeasuredHeight() + getPaddingBottom();
super.onMeasure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
-
// QSCustomizer will always be the height of the screen, but do this after
// other measuring to avoid changing the height of the QS.
mQSCustomizer.measure(widthMeasureSpec,
MeasureSpec.makeMeasureSpec(getDisplayHeight(), MeasureSpec.EXACTLY));
}
+
+ @Override
+ protected void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed,
+ int parentHeightMeasureSpec, int heightUsed) {
+ // Do not measure QSPanel again when doing super.onMeasure.
+ // This prevents the pages in PagedTileLayout to be remeasured with a different (incorrect)
+ // size to the one used for determining the number of rows and then the number of pages.
+ if (child != mQSPanel) {
+ super.measureChildWithMargins(child, parentWidthMeasureSpec, widthUsed,
+ parentHeightMeasureSpec, heightUsed);
+ }
+ }
+
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
diff --git a/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java b/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java
index 83b000d..38153ec 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java
@@ -38,8 +38,8 @@
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto;
-import com.android.systemui.Dependency;
import com.android.systemui.R;
+import com.android.systemui.keyguard.ScreenLifecycle;
import com.android.systemui.plugins.qs.QS;
import com.android.systemui.plugins.qs.QSTile;
import com.android.systemui.qs.QSDetailClipper;
@@ -52,6 +52,8 @@
import java.util.ArrayList;
import java.util.List;
+import javax.inject.Inject;
+
/**
* Allows full-screen customization of QS, through show() and hide().
*
@@ -66,6 +68,8 @@
private final QSDetailClipper mClipper;
private final LightBarController mLightBarController;
+ private KeyguardMonitor mKeyguardMonitor;
+ private final ScreenLifecycle mScreenLifecycle;
private final TileQueryHelper mTileQueryHelper;
private final View mTransparentView;
@@ -82,7 +86,11 @@
private boolean mOpening;
private boolean mIsShowingNavBackdrop;
- public QSCustomizer(Context context, AttributeSet attrs) {
+ @Inject
+ public QSCustomizer(Context context, AttributeSet attrs,
+ LightBarController lightBarController,
+ KeyguardMonitor keyguardMonitor,
+ ScreenLifecycle screenLifecycle) {
super(new ContextThemeWrapper(context, R.style.edit_theme), attrs);
LayoutInflater.from(getContext()).inflate(R.layout.qs_customize_panel_content, this);
@@ -115,7 +123,9 @@
DefaultItemAnimator animator = new DefaultItemAnimator();
animator.setMoveDuration(TileAdapter.MOVE_DURATION);
mRecyclerView.setItemAnimator(animator);
- mLightBarController = Dependency.get(LightBarController.class);
+ mLightBarController = lightBarController;
+ mKeyguardMonitor = keyguardMonitor;
+ mScreenLifecycle = screenLifecycle;
updateNavBackDrop(getResources().getConfiguration());
}
@@ -177,7 +187,7 @@
queryTiles();
mNotifQsContainer.setCustomizerAnimating(true);
mNotifQsContainer.setCustomizerShowing(true);
- Dependency.get(KeyguardMonitor.class).addCallback(mKeyguardCallback);
+ mKeyguardMonitor.addCallback(mKeyguardCallback);
updateNavColors();
}
}
@@ -193,7 +203,7 @@
queryTiles();
mNotifQsContainer.setCustomizerAnimating(false);
mNotifQsContainer.setCustomizerShowing(true);
- Dependency.get(KeyguardMonitor.class).addCallback(mKeyguardCallback);
+ mKeyguardMonitor.addCallback(mKeyguardCallback);
updateNavColors();
}
}
@@ -203,16 +213,21 @@
}
public void hide() {
+ final boolean animate = mScreenLifecycle.getScreenState() != ScreenLifecycle.SCREEN_OFF;
if (isShown) {
MetricsLogger.hidden(getContext(), MetricsProto.MetricsEvent.QS_EDIT);
isShown = false;
mToolbar.dismissPopupMenus();
setCustomizing(false);
save();
- mClipper.animateCircularClip(mX, mY, false, mCollapseAnimationListener);
- mNotifQsContainer.setCustomizerAnimating(true);
+ if (animate) {
+ mClipper.animateCircularClip(mX, mY, false, mCollapseAnimationListener);
+ } else {
+ setVisibility(View.GONE);
+ }
+ mNotifQsContainer.setCustomizerAnimating(animate);
mNotifQsContainer.setCustomizerShowing(false);
- Dependency.get(KeyguardMonitor.class).removeCallback(mKeyguardCallback);
+ mKeyguardMonitor.removeCallback(mKeyguardCallback);
updateNavColors();
}
}
@@ -268,7 +283,7 @@
public void saveInstanceState(Bundle outState) {
if (isShown) {
- Dependency.get(KeyguardMonitor.class).removeCallback(mKeyguardCallback);
+ mKeyguardMonitor.removeCallback(mKeyguardCallback);
}
outState.putBoolean(EXTRA_QS_CUSTOMIZING, mCustomizing);
}
@@ -300,7 +315,7 @@
@Override
public void onKeyguardShowingChanged() {
if (!isAttachedToWindow()) return;
- if (Dependency.get(KeyguardMonitor.class).isShowing() && !mOpening) {
+ if (mKeyguardMonitor.isShowing() && !mOpening) {
hide();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/external/TileLifecycleManager.java b/packages/SystemUI/src/com/android/systemui/qs/external/TileLifecycleManager.java
index b135f7b..effea6a 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/external/TileLifecycleManager.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/external/TileLifecycleManager.java
@@ -159,8 +159,11 @@
mBindTryCount++;
try {
mIsBound = mContext.bindServiceAsUser(mIntent, this,
- Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS, mUser);
+ Context.BIND_AUTO_CREATE
+ | Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE
+ | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS
+ | Context.BIND_WAIVE_PRIORITY,
+ mUser);
} catch (SecurityException e) {
Log.e(TAG, "Failed to bind to service", e);
mIsBound = false;
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java
index 664ea8b..cb87f59 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java
@@ -41,8 +41,10 @@
import com.android.systemui.R;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.qs.DetailAdapter;
+import com.android.systemui.plugins.qs.QSIconView;
import com.android.systemui.plugins.qs.QSTile.SignalState;
import com.android.systemui.qs.QSHost;
+import com.android.systemui.qs.SignalTileView;
import com.android.systemui.qs.tileimpl.QSTileImpl;
import com.android.systemui.statusbar.phone.SystemUIDialog;
import com.android.systemui.statusbar.policy.NetworkController;
@@ -79,6 +81,11 @@
}
@Override
+ public QSIconView createTileView(Context context) {
+ return new SignalTileView(context);
+ }
+
+ @Override
public DetailAdapter getDetailAdapter() {
return mDetailAdapter;
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailView.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailView.java
index 91d38bd..187a3bd 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailView.java
@@ -76,8 +76,11 @@
UserSwitcherController.UserRecord item) {
UserDetailItemView v = UserDetailItemView.convertOrInflate(
mContext, convertView, parent);
- if (v != convertView) {
+ if (!item.isCurrent || item.isGuest) {
v.setOnClickListener(this);
+ } else {
+ v.setOnClickListener(null);
+ v.setClickable(false);
}
String name = getName(mContext, item);
if (item.picture == null) {
diff --git a/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingService.java b/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingService.java
index a9896f5..0383dee 100644
--- a/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingService.java
+++ b/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingService.java
@@ -22,34 +22,34 @@
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
+import android.content.ContentResolver;
+import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
+import android.graphics.Point;
import android.graphics.drawable.Icon;
import android.hardware.display.DisplayManager;
import android.hardware.display.VirtualDisplay;
import android.media.MediaRecorder;
-import android.media.ThumbnailUtils;
import android.media.projection.MediaProjection;
import android.media.projection.MediaProjectionManager;
import android.net.Uri;
-import android.os.Environment;
import android.os.IBinder;
import android.provider.MediaStore;
import android.provider.Settings;
import android.util.DisplayMetrics;
import android.util.Log;
+import android.util.Size;
import android.view.Surface;
import android.widget.Toast;
-import androidx.core.content.FileProvider;
-
import com.android.systemui.R;
import java.io.File;
import java.io.IOException;
+import java.io.OutputStream;
import java.nio.file.Files;
-import java.nio.file.Path;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -76,12 +76,10 @@
private static final String ACTION_DELETE = "com.android.systemui.screenrecord.DELETE";
private static final int TOTAL_NUM_TRACKS = 1;
- private static final String RECORD_DIR = "Captures"; // TODO: use a translatable string
private static final int VIDEO_BIT_RATE = 6000000;
private static final int VIDEO_FRAME_RATE = 30;
private static final int AUDIO_BIT_RATE = 16;
private static final int AUDIO_SAMPLE_RATE = 44100;
- private static final String FILE_PROVIDER = "com.android.systemui.fileprovider";
private MediaProjectionManager mMediaProjectionManager;
private MediaProjection mMediaProjection;
@@ -117,11 +115,11 @@
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
- Log.d(TAG, "RecordingService is starting");
if (intent == null) {
return Service.START_NOT_STICKY;
}
String action = intent.getAction();
+ Log.d(TAG, "onStartCommand " + action);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
@@ -157,26 +155,7 @@
case ACTION_STOP:
stopRecording();
-
- // Move temp file to user directory
- File recordDir = new File(
- Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES),
- RECORD_DIR);
- recordDir.mkdirs();
-
- String fileName = new SimpleDateFormat("'screen-'yyyyMMdd-HHmmss'.mp4'")
- .format(new Date());
- Path path = new File(recordDir, fileName).toPath();
-
- try {
- Files.move(mTempFile.toPath(), path);
- Notification notification = createSaveNotification(path);
- notificationManager.notify(NOTIFICATION_ID, notification);
- } catch (IOException e) {
- e.printStackTrace();
- Toast.makeText(this, R.string.screenrecord_delete_error, Toast.LENGTH_LONG)
- .show();
- }
+ saveRecording(notificationManager);
break;
case ACTION_PAUSE:
@@ -190,8 +169,7 @@
break;
case ACTION_SHARE:
- File shareFile = new File(intent.getStringExtra(EXTRA_PATH));
- Uri shareUri = FileProvider.getUriForFile(this, FILE_PROVIDER, shareFile);
+ Uri shareUri = Uri.parse(intent.getStringExtra(EXTRA_PATH));
Intent shareIntent = new Intent(Intent.ACTION_SEND)
.setType("video/mp4")
@@ -211,20 +189,18 @@
// Close quick shade
sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
- File file = new File(intent.getStringExtra(EXTRA_PATH));
- if (file.delete()) {
- Toast.makeText(
- this,
- R.string.screenrecord_delete_description,
- Toast.LENGTH_LONG).show();
+ ContentResolver resolver = getContentResolver();
+ Uri uri = Uri.parse(intent.getStringExtra(EXTRA_PATH));
+ resolver.delete(uri, null, null);
- // Remove notification
- notificationManager.cancel(NOTIFICATION_ID);
- } else {
- Log.e(TAG, "Error deleting screen recording!");
- Toast.makeText(this, R.string.screenrecord_delete_error, Toast.LENGTH_LONG)
- .show();
- }
+ Toast.makeText(
+ this,
+ R.string.screenrecord_delete_description,
+ Toast.LENGTH_LONG).show();
+
+ // Remove notification
+ notificationManager.cancel(NOTIFICATION_ID);
+ Log.d(TAG, "Deleted recording " + uri);
break;
}
return Service.START_STICKY;
@@ -295,6 +271,7 @@
mMediaRecorder.start();
} catch (IOException e) {
+ Log.e(TAG, "Error starting screen recording: " + e.getMessage());
e.printStackTrace();
throw new RuntimeException(e);
}
@@ -352,13 +329,10 @@
notificationManager.notify(NOTIFICATION_ID, mRecordingNotificationBuilder.build());
}
- private Notification createSaveNotification(Path path) {
- Uri saveUri = FileProvider.getUriForFile(this, FILE_PROVIDER, path.toFile());
- Log.d(TAG, "Screen recording saved to " + path.toString());
-
+ private Notification createSaveNotification(Uri uri) {
Intent viewIntent = new Intent(Intent.ACTION_VIEW)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_GRANT_READ_URI_PERMISSION)
- .setDataAndType(saveUri, "video/mp4");
+ .setDataAndType(uri, "video/mp4");
Notification.Action shareAction = new Notification.Action.Builder(
Icon.createWithResource(this, R.drawable.ic_android),
@@ -366,7 +340,7 @@
PendingIntent.getService(
this,
REQUEST_CODE,
- getShareIntent(this, path.toString()),
+ getShareIntent(this, uri.toString()),
PendingIntent.FLAG_UPDATE_CURRENT))
.build();
@@ -376,7 +350,7 @@
PendingIntent.getService(
this,
REQUEST_CODE,
- getDeleteIntent(this, path.toString()),
+ getDeleteIntent(this, uri.toString()),
PendingIntent.FLAG_UPDATE_CURRENT))
.build();
@@ -394,8 +368,15 @@
.setAutoCancel(true);
// Add thumbnail if available
- Bitmap thumbnailBitmap = ThumbnailUtils.createVideoThumbnail(path.toString(),
- MediaStore.Video.Thumbnails.MINI_KIND);
+ Bitmap thumbnailBitmap = null;
+ try {
+ ContentResolver resolver = getContentResolver();
+ Size size = Point.convert(MediaStore.ThumbnailConstants.MINI_SIZE);
+ thumbnailBitmap = resolver.loadThumbnail(uri, size, null);
+ } catch (IOException e) {
+ Log.e(TAG, "Error creating thumbnail: " + e.getMessage());
+ e.printStackTrace();
+ }
if (thumbnailBitmap != null) {
Notification.BigPictureStyle pictureStyle = new Notification.BigPictureStyle()
.bigPicture(thumbnailBitmap)
@@ -417,6 +398,38 @@
stopSelf();
}
+ private void saveRecording(NotificationManager notificationManager) {
+ String fileName = new SimpleDateFormat("'screen-'yyyyMMdd-HHmmss'.mp4'")
+ .format(new Date());
+
+ ContentValues values = new ContentValues();
+ values.put(MediaStore.Video.Media.DISPLAY_NAME, fileName);
+ values.put(MediaStore.Video.Media.MIME_TYPE, "video/mp4");
+ values.put(MediaStore.Video.Media.DATE_ADDED, System.currentTimeMillis());
+ values.put(MediaStore.Video.Media.DATE_TAKEN, System.currentTimeMillis());
+
+ ContentResolver resolver = getContentResolver();
+ Uri collectionUri = MediaStore.Video.Media.getContentUri(
+ MediaStore.VOLUME_EXTERNAL_PRIMARY);
+ Uri itemUri = resolver.insert(collectionUri, values);
+
+ try {
+ // Add to the mediastore
+ OutputStream os = resolver.openOutputStream(itemUri, "w");
+ Files.copy(mTempFile.toPath(), os);
+ os.close();
+
+ Notification notification = createSaveNotification(itemUri);
+ notificationManager.notify(NOTIFICATION_ID, notification);
+
+ mTempFile.delete();
+ } catch (IOException e) {
+ Log.e(TAG, "Error saving screen recording: " + e.getMessage());
+ Toast.makeText(this, R.string.screenrecord_delete_error, Toast.LENGTH_LONG)
+ .show();
+ }
+ }
+
private void setTapsVisible(boolean turnOn) {
int value = turnOn ? 1 : 0;
Settings.System.putInt(getApplicationContext().getContentResolver(),
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/DragDownHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/DragDownHelper.java
index 8385c8e..5adee40 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/DragDownHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/DragDownHelper.java
@@ -29,7 +29,6 @@
import com.android.systemui.Gefingerpoken;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
-import com.android.systemui.classifier.FalsingManagerFactory;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.statusbar.notification.row.ExpandableView;
@@ -59,14 +58,15 @@
private FalsingManager mFalsingManager;
public DragDownHelper(Context context, View host, ExpandHelper.Callback callback,
- DragDownCallback dragDownCallback) {
+ DragDownCallback dragDownCallback,
+ FalsingManager falsingManager) {
mMinDragDistance = context.getResources().getDimensionPixelSize(
R.dimen.keyguard_drag_down_min_distance);
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
mCallback = callback;
mDragDownCallback = dragDownCallback;
mHost = host;
- mFalsingManager = FalsingManagerFactory.getInstance(context);
+ mFalsingManager = falsingManager;
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
index 4be93df..6f87b29 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
@@ -562,11 +562,11 @@
return;
}
- String message = mContext.getString(R.string.keyguard_unlock);
if (mStatusBarKeyguardViewManager.isBouncerShowing()) {
+ String message = mContext.getString(R.string.keyguard_retry);
mStatusBarKeyguardViewManager.showBouncerMessage(message, mInitialTextColorState);
} else if (mKeyguardUpdateMonitor.isScreenOn()) {
- showTransientIndication(message);
+ showTransientIndication(mContext.getString(R.string.keyguard_unlock));
hideTransientIndicationDelayed(BaseKeyguardCallback.HIDE_DELAY_MS);
}
}
@@ -650,7 +650,6 @@
if (!updateMonitor.isUnlockingWithBiometricAllowed()) {
return;
}
- animatePadlockError();
boolean showSwipeToUnlock =
msgId == KeyguardUpdateMonitor.BIOMETRIC_HELP_FACE_NOT_RECOGNIZED;
if (mStatusBarKeyguardViewManager.isBouncerShowing()) {
@@ -676,7 +675,11 @@
return;
}
animatePadlockError();
- if (mStatusBarKeyguardViewManager.isBouncerShowing()) {
+ if (msgId == FaceManager.FACE_ERROR_TIMEOUT) {
+ // The face timeout message is not very actionable, let's ask the user to
+ // manually retry.
+ showSwipeUpToUnlock();
+ } else if (mStatusBarKeyguardViewManager.isBouncerShowing()) {
mStatusBarKeyguardViewManager.showBouncerMessage(errString, mInitialTextColorState);
} else if (updateMonitor.isScreenOn()) {
showTransientIndication(errString);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java
index c375574..1400921 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java
@@ -37,11 +37,15 @@
import java.util.ArrayList;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
/**
* This class handles listening to notification updates and passing them along to
* NotificationPresenter to be displayed to the user.
*/
@SuppressLint("OverrideAbstract")
+@Singleton
public class NotificationListener extends NotificationListenerWithPlugins {
private static final String TAG = "NotificationListener";
@@ -56,6 +60,7 @@
private final ArrayList<NotificationSettingsListener> mSettingsListeners = new ArrayList<>();
private final Context mContext;
+ @Inject
public NotificationListener(Context context) {
mContext = context;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java
index e08a5ae..802a7d2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java
@@ -58,10 +58,14 @@
import java.util.ArrayList;
import java.util.List;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
/**
* Handles keeping track of the current user, profiles, and various things related to hiding
* contents, redacting notifications, and the lockscreen.
*/
+@Singleton
public class NotificationLockscreenUserManagerImpl implements
Dumpable, NotificationLockscreenUserManager, StateListener {
private static final String TAG = "LockscreenUserManager";
@@ -171,6 +175,7 @@
return mEntryManager;
}
+ @Inject
public NotificationLockscreenUserManagerImpl(Context context) {
mContext = context;
mDevicePolicyManager = (DevicePolicyManager) mContext.getSystemService(
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java
index 6e75c03..66a0619 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java
@@ -28,7 +28,7 @@
import android.view.ViewGroup;
import com.android.systemui.R;
-import com.android.systemui.bubbles.BubbleData;
+import com.android.systemui.bubbles.BubbleController;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.notification.DynamicPrivacyController;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
@@ -85,7 +85,7 @@
* possible.
*/
private final boolean mAlwaysExpandNonGroupedNotification;
- private final BubbleData mBubbleData;
+ private final BubbleController mBubbleController;
private final DynamicPrivacyController mDynamicPrivacyController;
private final KeyguardBypassController mBypassController;
@@ -107,8 +107,8 @@
StatusBarStateController statusBarStateController,
NotificationEntryManager notificationEntryManager,
Lazy<ShadeController> shadeController,
- BubbleData bubbleData,
KeyguardBypassController bypassController,
+ BubbleController bubbleController,
DynamicPrivacyController privacyController) {
mHandler = mainHandler;
mLockscreenUserManager = notificationLockscreenUserManager;
@@ -121,7 +121,7 @@
Resources res = context.getResources();
mAlwaysExpandNonGroupedNotification =
res.getBoolean(R.bool.config_alwaysExpandNonGroupedNotifications);
- mBubbleData = bubbleData;
+ mBubbleController = bubbleController;
mDynamicPrivacyController = privacyController;
privacyController.addListener(this);
}
@@ -147,7 +147,7 @@
for (int i = 0; i < N; i++) {
NotificationEntry ent = activeNotifications.get(i);
if (ent.isRowDismissed() || ent.isRowRemoved()
- || (mBubbleData.hasBubbleWithKey(ent.key) && !ent.showInShadeWhenBubble())) {
+ || mBubbleController.isBubbleNotificationSuppressedFromShade(ent.key)) {
// we don't want to update removed notifications because they could
// temporarily become children if they were isolated before.
continue;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt b/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt
index 986486a..a70dc7c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt
@@ -27,12 +27,13 @@
import android.view.MotionEvent
import android.view.VelocityTracker
import android.view.ViewConfiguration
+import com.android.systemui.Dependency
import com.android.systemui.Gefingerpoken
import com.android.systemui.Interpolators
import com.android.systemui.R
-import com.android.systemui.classifier.FalsingManagerFactory
import com.android.systemui.plugins.FalsingManager
+import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.row.ExpandableView
@@ -41,7 +42,6 @@
import com.android.systemui.statusbar.phone.HeadsUpManagerPhone
import com.android.systemui.statusbar.phone.KeyguardBypassController
import com.android.systemui.statusbar.phone.ShadeController
-import com.android.systemui.statusbar.policy.HeadsUpManager
import javax.inject.Inject
import javax.inject.Singleton
@@ -52,11 +52,14 @@
*/
@Singleton
class PulseExpansionHandler @Inject
-constructor(context: Context,
- private val wakeUpCoordinator: NotificationWakeUpCoordinator,
- private val bypassController: KeyguardBypassController,
- private val headsUpManager: HeadsUpManagerPhone,
- private val roundnessManager: NotificationRoundnessManager) : Gefingerpoken {
+constructor(
+ context: Context,
+ private val wakeUpCoordinator: NotificationWakeUpCoordinator,
+ private val bypassController: KeyguardBypassController,
+ private val headsUpManager: HeadsUpManagerPhone,
+ private val roundnessManager: NotificationRoundnessManager,
+ private val statusBarStateController: StatusBarStateController
+) : Gefingerpoken {
companion object {
private val RUBBERBAND_FACTOR_STATIC = 0.25f
private val SPRING_BACK_ANIMATION_LENGTH_MS = 375
@@ -115,7 +118,7 @@
mMinDragDistance = context.resources.getDimensionPixelSize(
R.dimen.keyguard_drag_down_min_distance)
mTouchSlop = ViewConfiguration.get(context).scaledTouchSlop.toFloat()
- mFalsingManager = FalsingManagerFactory.getInstance(context)
+ mFalsingManager = Dependency.get(FalsingManager::class.java)
mPowerManager = context.getSystemService(PowerManager::class.java)
}
@@ -124,8 +127,8 @@
}
private fun maybeStartExpansion(event: MotionEvent): Boolean {
- if (!wakeUpCoordinator.canShowPulsingHuns || qsExpanded
- || bouncerShowing) {
+ if (!wakeUpCoordinator.canShowPulsingHuns || qsExpanded ||
+ bouncerShowing) {
return false
}
if (velocityTracker == null) {
@@ -160,18 +163,18 @@
}
MotionEvent.ACTION_UP -> {
- recycleVelocityTracker();
+ recycleVelocityTracker()
}
MotionEvent.ACTION_CANCEL -> {
- recycleVelocityTracker();
+ recycleVelocityTracker()
}
}
return false
}
private fun recycleVelocityTracker() {
- velocityTracker?.recycle();
+ velocityTracker?.recycle()
velocityTracker = null
}
@@ -187,7 +190,8 @@
MotionEvent.ACTION_MOVE -> updateExpansionHeight(moveDistance)
MotionEvent.ACTION_UP -> {
velocityTracker!!.computeCurrentVelocity(1000 /* units */)
- val canExpand = moveDistance > 0 && velocityTracker!!.getYVelocity() > -1000
+ val canExpand = moveDistance > 0 && velocityTracker!!.getYVelocity() > -1000 &&
+ statusBarStateController.state != StatusBarState.SHADE
if (!mFalsingManager.isUnlockingDisabled && !isFalseTouch && canExpand) {
finishExpansion()
} else {
@@ -216,7 +220,7 @@
"com.android.systemui:PULSEDRAG")
}
shadeController.goToLockedShade(mStartingChild)
- leavingLockscreen = true;
+ leavingLockscreen = true
isExpanding = false
if (mStartingChild is ExpandableNotificationRow) {
val row = mStartingChild as ExpandableNotificationRow?
@@ -227,7 +231,7 @@
private fun updateExpansionHeight(height: Float) {
var expansionHeight = max(height, 0.0f)
if (!mReachedWakeUpHeight && height > mWakeUpHeight) {
- mReachedWakeUpHeight = true;
+ mReachedWakeUpHeight = true
}
if (mStartingChild != null) {
val child = mStartingChild!!
@@ -317,9 +321,11 @@
} else null
}
- fun setUp(stackScroller: NotificationStackScrollLayout,
- expansionCallback: ExpansionCallback,
- shadeController: ShadeController) {
+ fun setUp(
+ stackScroller: NotificationStackScrollLayout,
+ expansionCallback: ExpansionCallback,
+ shadeController: ShadeController
+ ) {
this.expansionCallback = expansionCallback
this.shadeController = shadeController
this.stackScroller = stackScroller
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java
index f0eeb04..abf29c4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java
@@ -20,6 +20,7 @@
import android.animation.ValueAnimator;
import android.text.format.DateFormat;
import android.util.FloatProperty;
+import android.util.Log;
import android.view.View;
import android.view.animation.Interpolator;
@@ -136,6 +137,11 @@
// Record the to-be mState and mLastState
recordHistoricalState(state, mState);
+ // b/139259891
+ if (mState == StatusBarState.SHADE && state == StatusBarState.SHADE_LOCKED) {
+ Log.e(TAG, "Invalid state transition: SHADE -> SHADE_LOCKED", new Throwable());
+ }
+
synchronized (mListeners) {
for (RankedListener rl : new ArrayList<>(mListeners)) {
rl.mListener.onStatePreChange(mState, state);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/DynamicPrivacyController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/DynamicPrivacyController.java
index d9328fa..e4bd4fa 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/DynamicPrivacyController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/DynamicPrivacyController.java
@@ -107,7 +107,7 @@
*/
public boolean isInLockedDownShade() {
if (!mStatusBarKeyguardViewManager.isShowing()
- || !mStatusBarKeyguardViewManager.isSecure()) {
+ || !mUnlockMethodCache.isMethodSecure()) {
return false;
}
int state = mStateController.getState();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
index 879a8df..f8fef7d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
@@ -54,11 +54,15 @@
import java.util.List;
import java.util.Map;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
/**
* NotificationEntryManager is responsible for the adding, removing, and updating of notifications.
* It also handles tasks such as their inflation and their interaction with other
* Notification.*Manager objects.
*/
+@Singleton
public class NotificationEntryManager implements
Dumpable,
NotificationContentInflater.InflationCallback,
@@ -118,6 +122,7 @@
}
}
+ @Inject
public NotificationEntryManager(Context context) {
mNotificationData = new NotificationData();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationFilter.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationFilter.java
index 154d7b35..f99662e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationFilter.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationFilter.java
@@ -133,11 +133,6 @@
}
}
}
-
- if (entry.isBubble() && !entry.showInShadeWhenBubble()) {
- return true;
- }
-
return false;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInterruptionStateProvider.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInterruptionStateProvider.java
index 4fc6461..150667b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInterruptionStateProvider.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInterruptionStateProvider.java
@@ -39,12 +39,15 @@
import com.android.systemui.statusbar.NotificationPresenter;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
-import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.policy.HeadsUpManager;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
/**
* Provides heads-up and pulsing state for notification entries.
*/
+@Singleton
public class NotificationInterruptionStateProvider {
private static final String TAG = "InterruptionStateProvider";
@@ -53,9 +56,8 @@
private static final boolean ENABLE_HEADS_UP = true;
private static final String SETTING_HEADS_UP_TICKER = "ticker_gets_heads_up";
- private final StatusBarStateController mStatusBarStateController =
- Dependency.get(StatusBarStateController.class);
- private final NotificationFilter mNotificationFilter = Dependency.get(NotificationFilter.class);
+ private final StatusBarStateController mStatusBarStateController;
+ private final NotificationFilter mNotificationFilter;
private final AmbientDisplayConfiguration mAmbientDisplayConfiguration;
private final Context mContext;
@@ -63,7 +65,6 @@
private final IDreamManager mDreamManager;
private NotificationPresenter mPresenter;
- private ShadeController mShadeController;
private HeadsUpManager mHeadsUpManager;
private HeadsUpSuppressor mHeadsUpSuppressor;
@@ -72,12 +73,16 @@
protected boolean mUseHeadsUp = false;
private boolean mDisableNotificationAlerts;
- public NotificationInterruptionStateProvider(Context context) {
+ @Inject
+ public NotificationInterruptionStateProvider(Context context, NotificationFilter filter,
+ StatusBarStateController stateController) {
this(context,
(PowerManager) context.getSystemService(Context.POWER_SERVICE),
IDreamManager.Stub.asInterface(
ServiceManager.checkService(DreamService.DREAM_SERVICE)),
- new AmbientDisplayConfiguration(context));
+ new AmbientDisplayConfiguration(context),
+ filter,
+ stateController);
}
@VisibleForTesting
@@ -85,11 +90,15 @@
Context context,
PowerManager powerManager,
IDreamManager dreamManager,
- AmbientDisplayConfiguration ambientDisplayConfiguration) {
+ AmbientDisplayConfiguration ambientDisplayConfiguration,
+ NotificationFilter notificationFilter,
+ StatusBarStateController statusBarStateController) {
mContext = context;
mPowerManager = powerManager;
mDreamManager = dreamManager;
mAmbientDisplayConfiguration = ambientDisplayConfiguration;
+ mNotificationFilter = notificationFilter;
+ mStatusBarStateController = statusBarStateController;
}
/** Sets up late-binding dependencies for this component. */
@@ -97,29 +106,39 @@
NotificationPresenter notificationPresenter,
HeadsUpManager headsUpManager,
HeadsUpSuppressor headsUpSuppressor) {
+ setUpWithPresenter(notificationPresenter, headsUpManager, headsUpSuppressor,
+ new ContentObserver(Dependency.get(Dependency.MAIN_HANDLER)) {
+ @Override
+ public void onChange(boolean selfChange) {
+ boolean wasUsing = mUseHeadsUp;
+ mUseHeadsUp = ENABLE_HEADS_UP && !mDisableNotificationAlerts
+ && Settings.Global.HEADS_UP_OFF != Settings.Global.getInt(
+ mContext.getContentResolver(),
+ Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED,
+ Settings.Global.HEADS_UP_OFF);
+ Log.d(TAG, "heads up is " + (mUseHeadsUp ? "enabled" : "disabled"));
+ if (wasUsing != mUseHeadsUp) {
+ if (!mUseHeadsUp) {
+ Log.d(TAG,
+ "dismissing any existing heads up notification on disable"
+ + " event");
+ mHeadsUpManager.releaseAllImmediately();
+ }
+ }
+ }
+ });
+ }
+
+ /** Sets up late-binding dependencies for this component. */
+ public void setUpWithPresenter(
+ NotificationPresenter notificationPresenter,
+ HeadsUpManager headsUpManager,
+ HeadsUpSuppressor headsUpSuppressor,
+ ContentObserver observer) {
mPresenter = notificationPresenter;
mHeadsUpManager = headsUpManager;
mHeadsUpSuppressor = headsUpSuppressor;
-
- mHeadsUpObserver = new ContentObserver(Dependency.get(Dependency.MAIN_HANDLER)) {
- @Override
- public void onChange(boolean selfChange) {
- boolean wasUsing = mUseHeadsUp;
- mUseHeadsUp = ENABLE_HEADS_UP && !mDisableNotificationAlerts
- && Settings.Global.HEADS_UP_OFF != Settings.Global.getInt(
- mContext.getContentResolver(),
- Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED,
- Settings.Global.HEADS_UP_OFF);
- Log.d(TAG, "heads up is " + (mUseHeadsUp ? "enabled" : "disabled"));
- if (wasUsing != mUseHeadsUp) {
- if (!mUseHeadsUp) {
- Log.d(TAG,
- "dismissing any existing heads up notification on disable event");
- mHeadsUpManager.releaseAllImmediately();
- }
- }
- }
- };
+ mHeadsUpObserver = observer;
if (ENABLE_HEADS_UP) {
mContext.getContentResolver().registerContentObserver(
@@ -133,13 +152,6 @@
mHeadsUpObserver.onChange(true); // set up
}
- private ShadeController getShadeController() {
- if (mShadeController == null) {
- mShadeController = Dependency.get(ShadeController.class);
- }
- return mShadeController;
- }
-
/**
* Whether the notification should appear as a bubble with a fly-out on top of the screen.
*
@@ -148,6 +160,15 @@
*/
public boolean shouldBubbleUp(NotificationEntry entry) {
final StatusBarNotification sbn = entry.notification;
+
+ if (!canAlertCommon(entry)) {
+ return false;
+ }
+
+ if (!canAlertAwakeCommon(entry)) {
+ return false;
+ }
+
if (!entry.canBubble) {
if (DEBUG) {
Log.d(TAG, "No bubble up: not allowed to bubble: " + sbn.getKey());
@@ -172,10 +193,6 @@
return false;
}
- if (!canHeadsUpCommon(entry)) {
- return false;
- }
-
return true;
}
@@ -196,6 +213,21 @@
private boolean shouldHeadsUpWhenAwake(NotificationEntry entry) {
StatusBarNotification sbn = entry.notification;
+ if (!mUseHeadsUp) {
+ if (DEBUG_HEADS_UP) {
+ Log.d(TAG, "No heads up: no huns");
+ }
+ return false;
+ }
+
+ if (!canAlertCommon(entry)) {
+ return false;
+ }
+
+ if (!canAlertAwakeCommon(entry)) {
+ return false;
+ }
+
boolean inShade = mStatusBarStateController.getState() == SHADE;
if (entry.isBubble() && inShade) {
if (DEBUG_HEADS_UP) {
@@ -205,17 +237,13 @@
return false;
}
- if (!canAlertCommon(entry)) {
+ if (entry.shouldSuppressPeek()) {
if (DEBUG_HEADS_UP) {
- Log.d(TAG, "No heads up: notification shouldn't alert: " + sbn.getKey());
+ Log.d(TAG, "No heads up: suppressed by DND: " + sbn.getKey());
}
return false;
}
- if (!canHeadsUpCommon(entry)) {
- return false;
- }
-
if (entry.importance < NotificationManager.IMPORTANCE_HIGH) {
if (DEBUG_HEADS_UP) {
Log.d(TAG, "No heads up: unimportant notification: " + sbn.getKey());
@@ -289,16 +317,13 @@
}
/**
- * Common checks between regular heads up and when pulsing. See
- * {@link #shouldHeadsUp(NotificationEntry)} and
- * {@link #shouldHeadsUpWhenDozing(NotificationEntry)}. Notifications that fail any of these
- * checks
- * should not alert at all.
+ * Common checks between regular & AOD heads up and bubbles.
*
* @param entry the entry to check
* @return true if these checks pass, false if the notification should not alert
*/
- protected boolean canAlertCommon(NotificationEntry entry) {
+ @VisibleForTesting
+ public boolean canAlertCommon(NotificationEntry entry) {
StatusBarNotification sbn = entry.notification;
if (mNotificationFilter.shouldFilterOut(entry)) {
@@ -315,46 +340,36 @@
}
return false;
}
-
return true;
}
/**
- * Common checks between heads up alerting and bubble fly out alerting. See
- * {@link #shouldHeadsUp(NotificationEntry)} and
- * {@link #shouldBubbleUp(NotificationEntry)}. Notifications that fail any of these
- * checks should not interrupt the user on screen.
+ * Common checks between alerts that occur while the device is awake (heads up & bubbles).
*
* @param entry the entry to check
- * @return true if these checks pass, false if the notification should not interrupt on screen
+ * @return true if these checks pass, false if the notification should not alert
*/
- public boolean canHeadsUpCommon(NotificationEntry entry) {
+ @VisibleForTesting
+ public boolean canAlertAwakeCommon(NotificationEntry entry) {
StatusBarNotification sbn = entry.notification;
- if (!mUseHeadsUp || mPresenter.isDeviceInVrMode()) {
+ if (mPresenter.isDeviceInVrMode()) {
if (DEBUG_HEADS_UP) {
- Log.d(TAG, "No heads up: no huns or vr mode");
- }
- return false;
- }
-
- if (entry.shouldSuppressPeek()) {
- if (DEBUG_HEADS_UP) {
- Log.d(TAG, "No heads up: suppressed by DND: " + sbn.getKey());
+ Log.d(TAG, "No alerting: no huns or vr mode");
}
return false;
}
if (isSnoozedPackage(sbn)) {
if (DEBUG_HEADS_UP) {
- Log.d(TAG, "No heads up: snoozed package: " + sbn.getKey());
+ Log.d(TAG, "No alerting: snoozed package: " + sbn.getKey());
}
return false;
}
if (entry.hasJustLaunchedFullScreenIntent()) {
if (DEBUG_HEADS_UP) {
- Log.d(TAG, "No heads up: recent fullscreen: " + sbn.getKey());
+ Log.d(TAG, "No alerting: recent fullscreen: " + sbn.getKey());
}
return false;
}
@@ -372,6 +387,18 @@
mHeadsUpObserver.onChange(true);
}
+ /** Whether all alerts are disabled. */
+ @VisibleForTesting
+ public boolean areNotificationAlertsDisabled() {
+ return mDisableNotificationAlerts;
+ }
+
+ /** Whether HUNs should be used. */
+ @VisibleForTesting
+ public boolean getUseHeadsUp() {
+ return mUseHeadsUp;
+ }
+
protected NotificationPresenter getPresenter() {
return mPresenter;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java
index fe88541..027e8e4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java
@@ -23,6 +23,7 @@
import static android.app.Notification.CATEGORY_REMINDER;
import static android.app.Notification.FLAG_BUBBLE;
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_AMBIENT;
+import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_BADGE;
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_FULL_SCREEN_INTENT;
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST;
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK;
@@ -41,7 +42,6 @@
import android.service.notification.NotificationListenerService;
import android.service.notification.SnoozeCriterion;
import android.service.notification.StatusBarNotification;
-import android.text.TextUtils;
import android.util.ArraySet;
import android.view.View;
import android.widget.ImageView;
@@ -52,7 +52,6 @@
import com.android.internal.statusbar.StatusBarIcon;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.ContrastColorUtil;
-import com.android.systemui.R;
import com.android.systemui.statusbar.InflationTask;
import com.android.systemui.statusbar.StatusBarIconView;
import com.android.systemui.statusbar.notification.InflationException;
@@ -156,19 +155,6 @@
public boolean canBubble;
/**
- * Whether this notification should be shown in the shade when it is also displayed as a bubble.
- *
- * <p>When a notification is a bubble we don't show it in the shade once the bubble has been
- * expanded</p>
- */
- private boolean mShowInShadeWhenBubble;
-
- /**
- * Whether the user has dismissed this notification when it was in bubble form.
- */
- private boolean mUserDismissedBubble;
-
- /**
* Whether this notification is shown to the user as a high priority notification: visible on
* the lock screen/status bar and in the top section in the shade.
*/
@@ -244,31 +230,6 @@
return (notification.getNotification().flags & FLAG_BUBBLE) != 0;
}
- public void setBubbleDismissed(boolean userDismissed) {
- mUserDismissedBubble = userDismissed;
- }
-
- public boolean isBubbleDismissed() {
- return mUserDismissedBubble;
- }
-
- /**
- * Sets whether this notification should be shown in the shade when it is also displayed as a
- * bubble.
- */
- public void setShowInShadeWhenBubble(boolean showInShade) {
- mShowInShadeWhenBubble = showInShade;
- }
-
- /**
- * Whether this notification should be shown in the shade when it is also displayed as a
- * bubble.
- */
- public boolean showInShadeWhenBubble() {
- // We always show it in the shade if non-clearable
- return !isRowDismissed() && (!isClearable() || mShowInShadeWhenBubble);
- }
-
/**
* Returns the data needed for a bubble for this notification, if it exists.
*/
@@ -463,72 +424,6 @@
}
/**
- * Returns our best guess for the most relevant text summary of the latest update to this
- * notification, based on its type. Returns null if there should not be an update message.
- */
- public CharSequence getUpdateMessage(Context context) {
- final Notification underlyingNotif = notification.getNotification();
- final Class<? extends Notification.Style> style = underlyingNotif.getNotificationStyle();
-
- try {
- if (Notification.BigTextStyle.class.equals(style)) {
- // Return the big text, it is big so probably important. If it's not there use the
- // normal text.
- CharSequence bigText =
- underlyingNotif.extras.getCharSequence(Notification.EXTRA_BIG_TEXT);
- return !TextUtils.isEmpty(bigText)
- ? bigText
- : underlyingNotif.extras.getCharSequence(Notification.EXTRA_TEXT);
- } else if (Notification.MessagingStyle.class.equals(style)) {
- final List<Notification.MessagingStyle.Message> messages =
- Notification.MessagingStyle.Message.getMessagesFromBundleArray(
- (Parcelable[]) underlyingNotif.extras.get(
- Notification.EXTRA_MESSAGES));
-
- final Notification.MessagingStyle.Message latestMessage =
- Notification.MessagingStyle.findLatestIncomingMessage(messages);
-
- if (latestMessage != null) {
- final CharSequence personName = latestMessage.getSenderPerson() != null
- ? latestMessage.getSenderPerson().getName()
- : null;
-
- // Prepend the sender name if available since group chats also use messaging
- // style.
- if (!TextUtils.isEmpty(personName)) {
- return context.getResources().getString(
- R.string.notification_summary_message_format,
- personName,
- latestMessage.getText());
- } else {
- return latestMessage.getText();
- }
- }
- } else if (Notification.InboxStyle.class.equals(style)) {
- CharSequence[] lines =
- underlyingNotif.extras.getCharSequenceArray(Notification.EXTRA_TEXT_LINES);
-
- // Return the last line since it should be the most recent.
- if (lines != null && lines.length > 0) {
- return lines[lines.length - 1];
- }
- } else if (Notification.MediaStyle.class.equals(style)) {
- // Return nothing, media updates aren't typically useful as a text update.
- return null;
- } else {
- // Default to text extra.
- return underlyingNotif.extras.getCharSequence(Notification.EXTRA_TEXT);
- }
- } catch (ClassCastException | NullPointerException | ArrayIndexOutOfBoundsException e) {
- // No use crashing, we'll just return null and the caller will assume there's no update
- // message.
- e.printStackTrace();
- }
-
- return null;
- }
-
- /**
* Abort all existing inflation tasks
*/
public void abortTask() {
@@ -875,6 +770,16 @@
return shouldSuppressVisualEffect(SUPPRESSED_EFFECT_NOTIFICATION_LIST);
}
+
+ /**
+ * Returns whether {@link Policy#SUPPRESSED_EFFECT_BADGE}
+ * is set for this entry. This badge is not an app badge, but rather an indicator of "unseen"
+ * content. Typically this is referred to as a "dot" internally in Launcher & SysUI code.
+ */
+ public boolean shouldSuppressNotificationDot() {
+ return shouldSuppressVisualEffect(SUPPRESSED_EFFECT_BADGE);
+ }
+
/**
* Categories that are explicitly called out on DND settings screens are always blocked, if
* DND has flagged them, even if they are foreground or system notifications that might
@@ -942,12 +847,4 @@
this.index = index;
}
}
-
- /**
- * Returns whether the notification is a foreground service. It shows that this is an ongoing
- * bubble.
- */
- public boolean isForegroundService() {
- return (notification.getNotification().flags & Notification.FLAG_FOREGROUND_SERVICE) != 0;
- }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java
index dca152f..8d73251 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java
@@ -33,9 +33,9 @@
import android.view.animation.Interpolator;
import android.view.animation.PathInterpolator;
+import com.android.systemui.Dependency;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
-import com.android.systemui.classifier.FalsingManagerFactory;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.statusbar.NotificationShelf;
import com.android.systemui.statusbar.notification.FakeShadowView;
@@ -130,7 +130,7 @@
private boolean mLastInSection;
private boolean mFirstInSection;
private boolean mIsBelowSpeedBump;
- private FalsingManager mFalsingManager;
+ private final FalsingManager mFalsingManager;
private float mNormalBackgroundVisibilityAmount;
private float mDimmedBackgroundFadeInAmount = -1;
@@ -164,10 +164,10 @@
super(context, attrs);
mSlowOutFastInInterpolator = new PathInterpolator(0.8f, 0.0f, 0.6f, 1.0f);
mSlowOutLinearInInterpolator = new PathInterpolator(0.8f, 0.0f, 1.0f, 1.0f);
+ mFalsingManager = Dependency.get(FalsingManager.class); // TODO: inject into a controller.
setClipChildren(false);
setClipToPadding(false);
updateColors();
- mFalsingManager = FalsingManagerFactory.getInstance(context);
mAccessibilityManager = AccessibilityManager.getInstance(mContext);
mDoubleTapHelper = new DoubleTapHelper(this, (active) -> {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java
index ea31be4..12d537d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java
@@ -74,7 +74,6 @@
import com.android.systemui.Dependency;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
-import com.android.systemui.classifier.FalsingManagerFactory;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.PluginListener;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
@@ -1209,12 +1208,12 @@
mChildrenContainer.reInflateViews(mExpandClickListener, mEntry.notification);
}
if (mGuts != null) {
- View oldGuts = mGuts;
+ NotificationGuts oldGuts = mGuts;
int index = indexOfChild(oldGuts);
removeView(oldGuts);
mGuts = (NotificationGuts) LayoutInflater.from(mContext).inflate(
R.layout.notification_guts, this, false);
- mGuts.setVisibility(oldGuts.getVisibility());
+ mGuts.setVisibility(oldGuts.isExposed() ? VISIBLE : GONE);
addView(mGuts, index);
}
View oldMenu = mMenuRow == null ? null : mMenuRow.getMenuView();
@@ -1637,7 +1636,7 @@
public ExpandableNotificationRow(Context context, AttributeSet attrs) {
super(context, attrs);
- mFalsingManager = FalsingManagerFactory.getInstance(context);
+ mFalsingManager = Dependency.get(FalsingManager.class); // TODO: inject into a controller.
mNotificationInflater = new NotificationContentInflater(this);
mMenuRow = new NotificationMenuRow(mContext);
mImageResolver = new NotificationInlineImageResolver(context,
@@ -2312,9 +2311,6 @@
@Override
public int getIntrinsicHeight() {
- if (isShownAsBubble()) {
- return getMaxExpandHeight();
- }
if (isUserLocked()) {
return getActualHeight();
}
@@ -2360,10 +2356,6 @@
return mStatusbarStateController != null && mStatusbarStateController.isDozing();
}
- private boolean isShownAsBubble() {
- return mEntry.isBubble() && !mEntry.showInShadeWhenBubble() && !mEntry.isBubbleDismissed();
- }
-
@Override
public boolean isGroupExpanded() {
return mGroupManager.isGroupExpanded(mStatusBarNotification);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java
index 48a8295..a612a17 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java
@@ -264,7 +264,7 @@
mIsChildInGroup, mUsesIncreasedHeight, mUsesIncreasedHeadsUpHeight,
packageContext);
result = inflateSmartReplyViews(result, reInflateFlags, mRow.getEntry(),
- mRow.getContext(), mRow.getHeadsUpManager(),
+ mRow.getContext(), packageContext, mRow.getHeadsUpManager(),
mRow.getExistingSmartRepliesAndActions());
apply(
inflateSynchronously,
@@ -311,20 +311,21 @@
private static InflationProgress inflateSmartReplyViews(InflationProgress result,
@InflationFlag int reInflateFlags, NotificationEntry entry, Context context,
- HeadsUpManager headsUpManager, SmartRepliesAndActions previousSmartRepliesAndActions) {
+ Context packageContext, HeadsUpManager headsUpManager,
+ SmartRepliesAndActions previousSmartRepliesAndActions) {
SmartReplyConstants smartReplyConstants = Dependency.get(SmartReplyConstants.class);
SmartReplyController smartReplyController = Dependency.get(SmartReplyController.class);
if ((reInflateFlags & FLAG_CONTENT_VIEW_EXPANDED) != 0 && result.newExpandedView != null) {
result.expandedInflatedSmartReplies =
InflatedSmartReplies.inflate(
- context, entry, smartReplyConstants, smartReplyController,
- headsUpManager, previousSmartRepliesAndActions);
+ context, packageContext, entry, smartReplyConstants,
+ smartReplyController, headsUpManager, previousSmartRepliesAndActions);
}
if ((reInflateFlags & FLAG_CONTENT_VIEW_HEADS_UP) != 0 && result.newHeadsUpView != null) {
result.headsUpInflatedSmartReplies =
InflatedSmartReplies.inflate(
- context, entry, smartReplyConstants, smartReplyController,
- headsUpManager, previousSmartRepliesAndActions);
+ context, packageContext, entry, smartReplyConstants,
+ smartReplyController, headsUpManager, previousSmartRepliesAndActions);
}
return result;
}
@@ -817,7 +818,7 @@
recoveredBuilder, mIsLowPriority, mIsChildInGroup, mUsesIncreasedHeight,
mUsesIncreasedHeadsUpHeight, packageContext);
return inflateSmartReplyViews(inflationProgress, mReInflateFlags, mRow.getEntry(),
- mRow.getContext(), mRow.getHeadsUpManager(),
+ mRow.getContext(), packageContext, mRow.getHeadsUpManager(),
mRow.getExistingSmartRepliesAndActions());
} catch (Exception e) {
mError = e;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
index f50790f..688e8eb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
@@ -86,7 +86,6 @@
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.SwipeHelper;
-import com.android.systemui.classifier.FalsingManagerFactory;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.FalsingManager;
@@ -516,7 +515,8 @@
ActivityStarter activityStarter,
StatusBarStateController statusBarStateController,
HeadsUpManagerPhone headsUpManager,
- KeyguardBypassController keyguardBypassController) {
+ KeyguardBypassController keyguardBypassController,
+ FalsingManager falsingManager) {
super(context, attrs, 0, 0);
Resources res = getResources();
@@ -531,6 +531,7 @@
mHeadsUpManager.addListener(mRoundnessManager);
mHeadsUpManager.setAnimationStateHandler(this::setHeadsUpGoingAwayAnimationsAllowed);
mKeyguardBypassController = keyguardBypassController;
+ mFalsingManager = falsingManager;
mSectionsManager =
new NotificationSectionsManager(
@@ -555,10 +556,9 @@
mExpandHelper.setEventSource(this);
mExpandHelper.setScrollAdapter(this);
mSwipeHelper = new NotificationSwipeHelper(SwipeHelper.X, mNotificationCallback,
- getContext(), mMenuEventListener);
+ getContext(), mMenuEventListener, mFalsingManager);
mStackScrollAlgorithm = createStackScrollAlgorithm(context);
initView(context);
- mFalsingManager = FalsingManagerFactory.getInstance(context);
mShouldDrawNotificationBackground =
res.getBoolean(R.bool.config_drawNotificationBackground);
mFadeNotificationsOnDismiss =
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java
index 4dfc343..0968674 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java
@@ -28,6 +28,7 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.SwipeHelper;
+import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
@@ -50,9 +51,11 @@
private boolean mIsExpanded;
private boolean mPulsing;
- public NotificationSwipeHelper(int swipeDirection, NotificationCallback callback,
- Context context, NotificationMenuRowPlugin.OnMenuEventListener menuListener) {
- super(swipeDirection, callback, context);
+ NotificationSwipeHelper(
+ int swipeDirection, NotificationCallback callback, Context context,
+ NotificationMenuRowPlugin.OnMenuEventListener menuListener,
+ FalsingManager falsingManager) {
+ super(swipeDirection, callback, context, falsingManager);
mMenuListener = menuListener;
mCallback = callback;
mFalsingCheck = new Runnable() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java
index 4691a31..66b1dd8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java
@@ -27,7 +27,6 @@
import com.android.systemui.Interpolators;
import com.android.systemui.R;
-import com.android.systemui.classifier.FalsingManagerFactory;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.statusbar.FlingAnimationUtils;
import com.android.systemui.statusbar.KeyguardAffordanceView;
@@ -59,7 +58,7 @@
private KeyguardAffordanceView mLeftIcon;
private KeyguardAffordanceView mRightIcon;
private Animator mSwipeAnimator;
- private FalsingManager mFalsingManager;
+ private final FalsingManager mFalsingManager;
private int mMinBackgroundRadius;
private boolean mMotionCancelled;
private int mTouchTargetSize;
@@ -80,12 +79,13 @@
}
};
- KeyguardAffordanceHelper(Callback callback, Context context) {
+ KeyguardAffordanceHelper(Callback callback, Context context, FalsingManager falsingManager) {
mContext = context;
mCallback = callback;
initIcons();
updateIcon(mLeftIcon, 0.0f, mLeftIcon.getRestingAlpha(), false, false, true, false);
updateIcon(mRightIcon, 0.0f, mRightIcon.getRestingAlpha(), false, false, true, false);
+ mFalsingManager = falsingManager;
initDimens();
}
@@ -102,7 +102,6 @@
mHintGrowAmount =
mContext.getResources().getDimensionPixelSize(R.dimen.hint_grow_amount_sideways);
mFlingAnimationUtils = new FlingAnimationUtils(mContext, 0.4f);
- mFalsingManager = FalsingManagerFactory.getInstance(mContext);
}
private void initIcons() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java
index dc9b373..0854e84 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java
@@ -40,9 +40,9 @@
import com.android.keyguard.KeyguardSecurityView;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
-import com.android.keyguard.R;
import com.android.keyguard.ViewMediatorCallback;
import com.android.systemui.DejankUtils;
+import com.android.systemui.R;
import com.android.systemui.keyguard.DismissCallbackRegistry;
import com.android.systemui.plugins.FalsingManager;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardEnvironmentImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardEnvironmentImpl.java
index 925a19d..2c931ae 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardEnvironmentImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardEnvironmentImpl.java
@@ -25,6 +25,10 @@
import com.android.systemui.statusbar.notification.collection.NotificationData.KeyguardEnvironment;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+@Singleton
public class KeyguardEnvironmentImpl implements KeyguardEnvironment {
private static final String TAG = "KeyguardEnvironmentImpl";
@@ -34,6 +38,7 @@
private final DeviceProvisionedController mDeviceProvisionedController =
Dependency.get(DeviceProvisionedController.class);
+ @Inject
public KeyguardEnvironmentImpl() {
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java
index 06a2225..ecfc45b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java
@@ -604,7 +604,7 @@
*/
public void onScrimVisibilityChanged(@ScrimVisibility int scrimsVisible) {
if (mWakeAndUnlockRunning
- && scrimsVisible == ScrimController.VISIBILITY_FULLY_TRANSPARENT) {
+ && scrimsVisible == ScrimController.TRANSPARENT) {
mWakeAndUnlockRunning = false;
update();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index f689a3e..a2740c8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.phone;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_HOME_DISABLED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED;
@@ -920,7 +921,8 @@
}
public void showPinningEscapeToast() {
- mScreenPinningNotify.showEscapeToast(isRecentsButtonVisible());
+ mScreenPinningNotify.showEscapeToast(
+ mNavBarMode == NAV_BAR_MODE_GESTURAL, isRecentsButtonVisible());
}
public boolean isVertical() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
index 0bbfbef..08602e1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
@@ -22,6 +22,7 @@
import android.util.Log;
import com.android.systemui.Dependency;
+import com.android.systemui.bubbles.BubbleController;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener;
import com.android.systemui.statusbar.StatusBarState;
@@ -53,12 +54,20 @@
private HashMap<String, StatusBarNotification> mIsolatedEntries = new HashMap<>();
private HeadsUpManager mHeadsUpManager;
private boolean mIsUpdatingUnchangedGroup;
+ @Nullable private BubbleController mBubbleController = null;
@Inject
public NotificationGroupManager(StatusBarStateController statusBarStateController) {
statusBarStateController.addCallback(this);
}
+ private BubbleController getBubbleController() {
+ if (mBubbleController == null) {
+ mBubbleController = Dependency.get(BubbleController.class);
+ }
+ return mBubbleController;
+ }
+
/**
* Add a listener for changes to groups.
*
@@ -187,12 +196,22 @@
if (group == null) {
return;
}
+ int childCount = 0;
+ boolean hasBubbles = false;
+ for (String key : group.children.keySet()) {
+ if (!getBubbleController().isBubbleNotificationSuppressedFromShade(key)) {
+ childCount++;
+ } else {
+ hasBubbles = true;
+ }
+ }
+
boolean prevSuppressed = group.suppressed;
group.suppressed = group.summary != null && !group.expanded
- && (group.children.size() == 1
- || (group.children.size() == 0
+ && (childCount == 1
+ || (childCount == 0
&& group.summary.notification.getNotification().isGroupSummary()
- && hasIsolatedChildren(group)));
+ && (hasIsolatedChildren(group) || hasBubbles)));
if (prevSuppressed != group.suppressed) {
for (OnGroupChangeListener listener : mListeners) {
if (!mIsUpdatingUnchangedGroup) {
@@ -381,6 +400,17 @@
}
/**
+ * If there is a {@link NotificationGroup} associated with the provided entry, this method
+ * will update the suppression of that group.
+ */
+ public void updateSuppression(NotificationEntry entry) {
+ NotificationGroup group = mGroupMap.get(getGroupKey(entry.notification));
+ if (group != null) {
+ updateSuppression(group);
+ }
+ }
+
+ /**
* Get the group key. May differ from the one in the notification due to the notification
* being temporarily isolated.
*
@@ -565,6 +595,7 @@
? Log.getStackTraceString(child.getDebugThrowable())
: "");
}
+ result += "\n summary suppressed: " + suppressed;
return result;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java
index ba34069..1a3560e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java
@@ -537,11 +537,7 @@
if (dozeParameters.shouldControlScreenOff()) {
mAodIcons.setTranslationY(-mAodIconAppearTranslation);
mAodIcons.setAlpha(0);
- mAodIcons.animate()
- .setInterpolator(Interpolators.DECELERATE_QUINT)
- .translationY(0)
- .setDuration(AOD_ICONS_APPEAR_DURATION)
- .start();
+ animateInAodIconTranslation();
mAodIcons.animate()
.alpha(1)
.setInterpolator(Interpolators.LINEAR)
@@ -550,6 +546,14 @@
}
}
+ private void animateInAodIconTranslation() {
+ mAodIcons.animate()
+ .setInterpolator(Interpolators.DECELERATE_QUINT)
+ .translationY(0)
+ .setDuration(AOD_ICONS_APPEAR_DURATION)
+ .start();
+ }
+
private void reloadAodColor() {
mAodIconTint = Utils.getColorAttrDefaultColor(mContext,
R.attr.wallpaperTextColor);
@@ -606,14 +610,19 @@
mAodIcons.setAlpha(1.0f);
appearAodIcons();
} else {
+ // Let's make sure the icon are translated to 0, since we cancelled it above
+ animateInAodIconTranslation();
// We were fading out, let's fade in instead
CrossFadeHelper.fadeIn(mAodIcons);
}
} else {
+ // Let's make sure the icon are translated to 0, since we cancelled it above
+ animateInAodIconTranslation();
CrossFadeHelper.fadeOut(mAodIcons);
}
} else {
mAodIcons.setAlpha(1.0f);
+ mAodIcons.setTranslationY(0);
mAodIcons.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index a0847b6..6bc0cf6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -39,6 +39,7 @@
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.Region;
+import android.hardware.biometrics.BiometricSourceType;
import android.os.PowerManager;
import android.os.SystemClock;
import android.util.AttributeSet;
@@ -59,11 +60,11 @@
import com.android.keyguard.KeyguardClockSwitch;
import com.android.keyguard.KeyguardStatusView;
import com.android.keyguard.KeyguardUpdateMonitor;
+import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.systemui.DejankUtils;
import com.android.systemui.Dependency;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
-import com.android.systemui.classifier.FalsingManagerFactory;
import com.android.systemui.fragments.FragmentHostManager;
import com.android.systemui.fragments.FragmentHostManager.FragmentListener;
import com.android.systemui.plugins.FalsingManager;
@@ -95,6 +96,7 @@
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
import com.android.systemui.statusbar.policy.ConfigurationController;
+import com.android.systemui.statusbar.policy.KeyguardMonitor;
import com.android.systemui.statusbar.policy.KeyguardUserSwitcher;
import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener;
import com.android.systemui.statusbar.policy.ZenModeController;
@@ -165,6 +167,46 @@
R.id.keyguard_hun_animator_start_tag);
private static final AnimationProperties KEYGUARD_HUN_PROPERTIES =
new AnimationProperties().setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD);
+ @VisibleForTesting
+ final KeyguardUpdateMonitorCallback mKeyguardUpdateCallback =
+ new KeyguardUpdateMonitorCallback() {
+
+ @Override
+ public void onBiometricAuthenticated(int userId,
+ BiometricSourceType biometricSourceType) {
+ if (mFirstBypassAttempt && mUpdateMonitor.isUnlockingWithBiometricAllowed()) {
+ mDelayShowingKeyguardStatusBar = true;
+ }
+ }
+
+ @Override
+ public void onBiometricRunningStateChanged(boolean running,
+ BiometricSourceType biometricSourceType) {
+ boolean keyguardOrShadeLocked = mBarState == StatusBarState.KEYGUARD
+ || mBarState == StatusBarState.SHADE_LOCKED;
+ if (!running && mFirstBypassAttempt && keyguardOrShadeLocked && !mDozing
+ && !mDelayShowingKeyguardStatusBar) {
+ mFirstBypassAttempt = false;
+ animateKeyguardStatusBarIn(StackStateAnimator.ANIMATION_DURATION_STANDARD);
+ }
+ }
+
+ @Override
+ public void onFinishedGoingToSleep(int why) {
+ mFirstBypassAttempt = mKeyguardBypassController.getBypassEnabled();
+ mDelayShowingKeyguardStatusBar = false;
+ }
+ };
+ private final KeyguardMonitor.Callback mKeyguardMonitorCallback =
+ new KeyguardMonitor.Callback() {
+ @Override
+ public void onKeyguardFadingAwayChanged() {
+ if (!mKeyguardMonitor.isKeyguardFadingAway()) {
+ mFirstBypassAttempt = false;
+ mDelayShowingKeyguardStatusBar = false;
+ }
+ }
+ };
private final InjectionInflationController mInjectionInflationController;
private final PowerManager mPowerManager;
@@ -172,8 +214,8 @@
private final NotificationWakeUpCoordinator mWakeUpCoordinator;
private final PulseExpansionHandler mPulseExpansionHandler;
private final KeyguardBypassController mKeyguardBypassController;
- private final KeyguardUpdateMonitor mUpdateMonitor;
-
+ @VisibleForTesting
+ protected KeyguardUpdateMonitor mUpdateMonitor;
@VisibleForTesting
protected KeyguardAffordanceHelper mAffordanceHelper;
private KeyguardUserSwitcher mKeyguardUserSwitcher;
@@ -385,17 +427,29 @@
private boolean mAllowExpandForSmallExpansion;
private Runnable mExpandAfterLayoutRunnable;
+ /**
+ * If face auth with bypass is running for the first time after you turn on the screen.
+ * (From aod or screen off)
+ */
+ private boolean mFirstBypassAttempt;
+ /**
+ * If auth happens successfully during {@code mFirstBypassAttempt}, and we should wait until
+ * the keyguard is dismissed to show the status bar.
+ */
+ private boolean mDelayShowingKeyguardStatusBar;
+
@Inject
public NotificationPanelView(@Named(VIEW_CONTEXT) Context context, AttributeSet attrs,
InjectionInflationController injectionInflationController,
NotificationWakeUpCoordinator coordinator,
PulseExpansionHandler pulseExpansionHandler,
DynamicPrivacyController dynamicPrivacyController,
- KeyguardBypassController bypassController) {
+ KeyguardBypassController bypassController,
+ FalsingManager falsingManager) {
super(context, attrs);
setWillNotDraw(!DEBUG);
mInjectionInflationController = injectionInflationController;
- mFalsingManager = FalsingManagerFactory.getInstance(context);
+ mFalsingManager = falsingManager;
mPowerManager = context.getSystemService(PowerManager.class);
mWakeUpCoordinator = coordinator;
mAccessibilityManager = context.getSystemService(AccessibilityManager.class);
@@ -413,6 +467,8 @@
mThemeResId = context.getThemeResId();
mKeyguardBypassController = bypassController;
mUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
+ mFirstBypassAttempt = mKeyguardBypassController.getBypassEnabled();
+ mKeyguardMonitor.addCallback(mKeyguardMonitorCallback);
dynamicPrivacyController.addListener(this);
mBottomAreaShadeAlphaAnimator = ValueAnimator.ofFloat(1f, 0);
@@ -485,6 +541,7 @@
Dependency.get(StatusBarStateController.class).addCallback(this);
Dependency.get(ZenModeController.class).addCallback(this);
Dependency.get(ConfigurationController.class).addCallback(this);
+ mUpdateMonitor.registerCallback(mKeyguardUpdateCallback);
// Theme might have changed between inflating this view and attaching it to the window, so
// force a call to onThemeChanged
onThemeChanged();
@@ -497,6 +554,7 @@
Dependency.get(StatusBarStateController.class).removeCallback(this);
Dependency.get(ZenModeController.class).removeCallback(this);
Dependency.get(ConfigurationController.class).removeCallback(this);
+ mUpdateMonitor.removeCallback(mKeyguardUpdateCallback);
}
@Override
@@ -625,7 +683,7 @@
}
private void initBottomArea() {
- mAffordanceHelper = new KeyguardAffordanceHelper(this, getContext());
+ mAffordanceHelper = new KeyguardAffordanceHelper(this, getContext(), mFalsingManager);
mKeyguardBottomArea.setAffordanceHelper(mAffordanceHelper);
mKeyguardBottomArea.setStatusBar(mStatusBar);
mKeyguardBottomArea.setUserSetupComplete(mUserSetupComplete);
@@ -1738,7 +1796,8 @@
private void setQsExpansion(float height) {
height = Math.min(Math.max(height, mQsMinExpansionHeight), mQsMaxExpansionHeight);
mQsFullyExpanded = height == mQsMaxExpansionHeight && mQsMaxExpansionHeight != 0;
- if (height > mQsMinExpansionHeight && !mQsExpanded && !mStackScrollerOverscrolling) {
+ if (height > mQsMinExpansionHeight && !mQsExpanded && !mStackScrollerOverscrolling
+ && !mDozing) {
setQsExpanded(true);
} else if (height <= mQsMinExpansionHeight && mQsExpanded) {
setQsExpanded(false);
@@ -2237,7 +2296,10 @@
* mKeyguardStatusBarAnimateAlpha;
newAlpha *= 1.0f - mKeyguardHeadsUpShowingAmount;
mKeyguardStatusBar.setAlpha(newAlpha);
- mKeyguardStatusBar.setVisibility(newAlpha != 0f && !mDozing ? VISIBLE : INVISIBLE);
+ boolean hideForBypass = mFirstBypassAttempt && mUpdateMonitor.shouldListenForFace()
+ || mDelayShowingKeyguardStatusBar;
+ mKeyguardStatusBar.setVisibility(newAlpha != 0f && !mDozing && !hideForBypass
+ ? VISIBLE : INVISIBLE);
}
private void updateKeyguardBottomAreaAlpha() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index f8e1093..31600e3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -42,7 +42,6 @@
import com.android.systemui.Dependency;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
-import com.android.systemui.classifier.FalsingManagerFactory;
import com.android.systemui.doze.DozeLog;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
@@ -111,7 +110,7 @@
private FlingAnimationUtils mFlingAnimationUtils;
private FlingAnimationUtils mFlingAnimationUtilsClosing;
private FlingAnimationUtils mFlingAnimationUtilsDismissing;
- private FalsingManager mFalsingManager;
+ private final FalsingManager mFalsingManager;
private final VibratorHelper mVibratorHelper;
/**
@@ -214,7 +213,7 @@
0.5f /* maxLengthSeconds */, 0.2f /* speedUpFactor */, 0.6f /* x2 */,
0.84f /* y2 */);
mBounceInterpolator = new BounceInterpolator();
- mFalsingManager = FalsingManagerFactory.getInstance(context);
+ mFalsingManager = Dependency.get(FalsingManager.class); // TODO: inject into a controller.
mNotificationsDragEnabled =
getResources().getBoolean(R.bool.config_enableNotificationShadeDrag);
mVibratorHelper = Dependency.get(VibratorHelper.class);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScreenPinningNotify.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScreenPinningNotify.java
index f8731b4..071e00d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScreenPinningNotify.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScreenPinningNotify.java
@@ -51,7 +51,7 @@
}
/** Show a toast that describes the gesture the user should use to escape pinned mode. */
- public void showEscapeToast(boolean isRecentsButtonVisible) {
+ public void showEscapeToast(boolean isGestureNavEnabled, boolean isRecentsButtonVisible) {
long showToastTime = SystemClock.elapsedRealtime();
if ((showToastTime - mLastShowToastTime) < SHOW_TOAST_MINIMUM_INTERVAL) {
Slog.i(TAG, "Ignore toast since it is requested in very short interval.");
@@ -60,9 +60,11 @@
if (mLastToast != null) {
mLastToast.cancel();
}
- mLastToast = makeAllUserToastAndShow(isRecentsButtonVisible
- ? R.string.screen_pinning_toast
- : R.string.screen_pinning_toast_recents_invisible);
+ mLastToast = makeAllUserToastAndShow(isGestureNavEnabled
+ ? R.string.screen_pinning_toast_gesture_nav
+ : isRecentsButtonVisible
+ ? R.string.screen_pinning_toast
+ : R.string.screen_pinning_toast_recents_invisible);
mLastShowToastTime = showToastTime;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
index a7262cf..45f3b32 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
@@ -79,23 +79,24 @@
/**
* When both scrims have 0 alpha.
*/
- public static final int VISIBILITY_FULLY_TRANSPARENT = 0;
+ public static final int TRANSPARENT = 0;
/**
* When scrims aren't transparent (alpha 0) but also not opaque (alpha 1.)
*/
- public static final int VISIBILITY_SEMI_TRANSPARENT = 1;
+ public static final int SEMI_TRANSPARENT = 1;
/**
* When at least 1 scrim is fully opaque (alpha set to 1.)
*/
- public static final int VISIBILITY_FULLY_OPAQUE = 2;
+ public static final int OPAQUE = 2;
- @IntDef(prefix = { "VISIBILITY_" }, value = {
- VISIBILITY_FULLY_TRANSPARENT,
- VISIBILITY_SEMI_TRANSPARENT,
- VISIBILITY_FULLY_OPAQUE
+ @IntDef(prefix = {"VISIBILITY_"}, value = {
+ TRANSPARENT,
+ SEMI_TRANSPARENT,
+ OPAQUE
})
@Retention(RetentionPolicy.SOURCE)
- public @interface ScrimVisibility {}
+ public @interface ScrimVisibility {
+ }
/**
* Default alpha value for most scrims.
@@ -123,8 +124,11 @@
private ScrimState mState = ScrimState.UNINITIALIZED;
private final Context mContext;
- protected final ScrimView mScrimBehind;
+
protected final ScrimView mScrimInFront;
+ protected final ScrimView mScrimBehind;
+ protected final ScrimView mScrimForBubble;
+
private final UnlockMethodCache mUnlockMethodCache;
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
private final DozeParameters mDozeParameters;
@@ -153,10 +157,15 @@
private Runnable mOnAnimationFinished;
private boolean mDeferFinishedListener;
private final Interpolator mInterpolator = new DecelerateInterpolator();
- private float mCurrentInFrontAlpha = NOT_INITIALIZED;
- private float mCurrentBehindAlpha = NOT_INITIALIZED;
- private int mCurrentInFrontTint;
- private int mCurrentBehindTint;
+
+ private float mInFrontAlpha = NOT_INITIALIZED;
+ private float mBehindAlpha = NOT_INITIALIZED;
+ private float mBubbleAlpha = NOT_INITIALIZED;
+
+ private int mInFrontTint;
+ private int mBehindTint;
+ private int mBubbleTint;
+
private boolean mWallpaperVisibilityTimedOut;
private int mScrimsVisibility;
private final TriConsumer<ScrimState, Float, GradientColors> mScrimStateListener;
@@ -175,14 +184,17 @@
private boolean mWakeLockHeld;
private boolean mKeyguardOccluded;
- public ScrimController(ScrimView scrimBehind, ScrimView scrimInFront,
+ public ScrimController(ScrimView scrimBehind, ScrimView scrimInFront, ScrimView scrimForBubble,
TriConsumer<ScrimState, Float, GradientColors> scrimStateListener,
Consumer<Integer> scrimVisibleListener, DozeParameters dozeParameters,
AlarmManager alarmManager, KeyguardMonitor keyguardMonitor) {
mScrimBehind = scrimBehind;
mScrimInFront = scrimInFront;
+ mScrimForBubble = scrimForBubble;
+
mScrimStateListener = scrimStateListener;
mScrimVisibleListener = scrimVisibleListener;
+
mContext = scrimBehind.getContext();
mUnlockMethodCache = UnlockMethodCache.getInstance(mContext);
mDarkenWhileDragging = !mUnlockMethodCache.canSkipBouncer();
@@ -213,12 +225,13 @@
final ScrimState[] states = ScrimState.values();
for (int i = 0; i < states.length; i++) {
- states[i].init(mScrimInFront, mScrimBehind, mDozeParameters);
+ states[i].init(mScrimInFront, mScrimBehind, mScrimForBubble, mDozeParameters);
states[i].setScrimBehindAlphaKeyguard(mScrimBehindAlphaKeyguard);
}
mScrimBehind.setDefaultFocusHighlightEnabled(false);
mScrimInFront.setDefaultFocusHighlightEnabled(false);
+ mScrimForBubble.setDefaultFocusHighlightEnabled(false);
updateScrims();
}
@@ -257,10 +270,14 @@
mBlankScreen = state.getBlanksScreen();
mAnimateChange = state.getAnimateChange();
mAnimationDuration = state.getAnimationDuration();
- mCurrentInFrontTint = state.getFrontTint();
- mCurrentBehindTint = state.getBehindTint();
- mCurrentInFrontAlpha = state.getFrontAlpha();
- mCurrentBehindAlpha = state.getBehindAlpha();
+
+ mInFrontTint = state.getFrontTint();
+ mBehindTint = state.getBehindTint();
+ mBubbleTint = state.getBubbleTint();
+
+ mInFrontAlpha = state.getFrontAlpha();
+ mBehindAlpha = state.getBehindAlpha();
+ mBubbleAlpha = state.getBubbleAlpha();
applyExpansionToAlpha();
// Scrim might acquire focus when user is navigating with a D-pad or a keyboard.
@@ -393,21 +410,20 @@
if (mExpansionFraction != fraction) {
mExpansionFraction = fraction;
- final boolean keyguardOrUnlocked = mState == ScrimState.UNLOCKED
- || mState == ScrimState.KEYGUARD || mState == ScrimState.PULSING;
- if (!keyguardOrUnlocked || !mExpansionAffectsAlpha) {
+ boolean relevantState = (mState == ScrimState.UNLOCKED
+ || mState == ScrimState.KEYGUARD
+ || mState == ScrimState.PULSING
+ || mState == ScrimState.BUBBLE_EXPANDED);
+ if (!(relevantState && mExpansionAffectsAlpha)) {
return;
}
-
applyExpansionToAlpha();
-
if (mUpdatePending) {
return;
}
-
setOrAdaptCurrentAnimation(mScrimBehind);
setOrAdaptCurrentAnimation(mScrimInFront);
-
+ setOrAdaptCurrentAnimation(mScrimForBubble);
dispatchScrimState(mScrimBehind.getViewAlpha());
// Reset wallpaper timeout if it's already timeout like expanding panel while PULSING
@@ -421,11 +437,10 @@
}
private void setOrAdaptCurrentAnimation(View scrim) {
- if (!isAnimating(scrim)) {
- updateScrimColor(scrim, getCurrentScrimAlpha(scrim), getCurrentScrimTint(scrim));
- } else {
+ float alpha = getCurrentScrimAlpha(scrim);
+ if (isAnimating(scrim)) {
+ // Adapt current animation.
ValueAnimator previousAnimator = (ValueAnimator) scrim.getTag(TAG_KEY_ANIM);
- float alpha = getCurrentScrimAlpha(scrim);
float previousEndValue = (Float) scrim.getTag(TAG_END_ALPHA);
float previousStartValue = (Float) scrim.getTag(TAG_START_ALPHA);
float relativeDiff = alpha - previousEndValue;
@@ -433,6 +448,9 @@
scrim.setTag(TAG_START_ALPHA, newStartValue);
scrim.setTag(TAG_END_ALPHA, alpha);
previousAnimator.setCurrentPlayTime(previousAnimator.getCurrentPlayTime());
+ } else {
+ // Set animation.
+ updateScrimColor(scrim, alpha, getCurrentScrimTint(scrim));
}
}
@@ -441,27 +459,27 @@
return;
}
- if (mState == ScrimState.UNLOCKED) {
+ if (mState == ScrimState.UNLOCKED || mState == ScrimState.BUBBLE_EXPANDED) {
// Darken scrim as you pull down the shade when unlocked
float behindFraction = getInterpolatedFraction();
behindFraction = (float) Math.pow(behindFraction, 0.8f);
- mCurrentBehindAlpha = behindFraction * GRADIENT_SCRIM_ALPHA_BUSY;
- mCurrentInFrontAlpha = 0;
+ mBehindAlpha = behindFraction * GRADIENT_SCRIM_ALPHA_BUSY;
+ mInFrontAlpha = 0;
} else if (mState == ScrimState.KEYGUARD || mState == ScrimState.PULSING) {
// Either darken of make the scrim transparent when you
// pull down the shade
float interpolatedFract = getInterpolatedFraction();
float alphaBehind = mState.getBehindAlpha();
if (mDarkenWhileDragging) {
- mCurrentBehindAlpha = MathUtils.lerp(GRADIENT_SCRIM_ALPHA_BUSY, alphaBehind,
+ mBehindAlpha = MathUtils.lerp(GRADIENT_SCRIM_ALPHA_BUSY, alphaBehind,
interpolatedFract);
- mCurrentInFrontAlpha = 0;
+ mInFrontAlpha = mState.getFrontAlpha();
} else {
- mCurrentBehindAlpha = MathUtils.lerp(0 /* start */, alphaBehind,
+ mBehindAlpha = MathUtils.lerp(0 /* start */, alphaBehind,
interpolatedFract);
- mCurrentInFrontAlpha = 0;
+ mInFrontAlpha = mState.getFrontAlpha();
}
- mCurrentBehindTint = ColorUtils.blendARGB(ScrimState.BOUNCER.getBehindTint(),
+ mBehindTint = ColorUtils.blendARGB(ScrimState.BOUNCER.getBehindTint(),
mState.getBehindTint(), interpolatedFract);
}
}
@@ -485,13 +503,14 @@
* device is dozing when the light sensor is on.
*/
public void setAodFrontScrimAlpha(float alpha) {
- if (mState == ScrimState.AOD && mDozeParameters.getAlwaysOn()
- && mCurrentInFrontAlpha != alpha) {
- mCurrentInFrontAlpha = alpha;
+ if (((mState == ScrimState.AOD && mDozeParameters.getAlwaysOn())
+ || mState == ScrimState.PULSING) && mInFrontAlpha != alpha) {
+ mInFrontAlpha = alpha;
updateScrims();
}
mState.AOD.setAodFrontScrimAlpha(alpha);
+ mState.PULSING.setAodFrontScrimAlpha(alpha);
}
/**
@@ -499,10 +518,10 @@
* away once the display turns on.
*/
public void prepareForGentleWakeUp() {
- if (mState == ScrimState.AOD) {
- mCurrentInFrontAlpha = 1f;
- mCurrentInFrontTint = Color.BLACK;
- mCurrentBehindTint = Color.BLACK;
+ if (mState == ScrimState.AOD && mDozeParameters.getAlwaysOn()) {
+ mInFrontAlpha = 1f;
+ mInFrontTint = Color.BLACK;
+ mBehindTint = Color.BLACK;
mAnimateChange = false;
updateScrims();
mAnimateChange = true;
@@ -520,8 +539,8 @@
if (mState == ScrimState.PULSING) {
float newBehindAlpha = mState.getBehindAlpha();
- if (mCurrentBehindAlpha != newBehindAlpha) {
- mCurrentBehindAlpha = newBehindAlpha;
+ if (mBehindAlpha != newBehindAlpha) {
+ mBehindAlpha = newBehindAlpha;
updateScrims();
}
}
@@ -543,8 +562,11 @@
// Only animate scrim color if the scrim view is actually visible
boolean animateScrimInFront = mScrimInFront.getViewAlpha() != 0 && !mBlankScreen;
boolean animateScrimBehind = mScrimBehind.getViewAlpha() != 0 && !mBlankScreen;
+ boolean animateScrimForBubble = mScrimForBubble.getViewAlpha() != 0 && !mBlankScreen;
+
mScrimInFront.setColors(mColors, animateScrimInFront);
mScrimBehind.setColors(mColors, animateScrimBehind);
+ mScrimForBubble.setColors(mColors, animateScrimForBubble);
// Calculate minimum scrim opacity for white or black text.
int textColor = mColors.supportsDarkText() ? Color.BLACK : Color.WHITE;
@@ -563,12 +585,11 @@
boolean occludedKeyguard = (mState == ScrimState.PULSING || mState == ScrimState.AOD)
&& mKeyguardOccluded;
if (aodWallpaperTimeout || occludedKeyguard) {
- mCurrentBehindAlpha = 1;
+ mBehindAlpha = 1;
}
-
- setScrimInFrontAlpha(mCurrentInFrontAlpha);
- setScrimBehindAlpha(mCurrentBehindAlpha);
-
+ setScrimAlpha(mScrimInFront, mInFrontAlpha);
+ setScrimAlpha(mScrimBehind, mBehindAlpha);
+ setScrimAlpha(mScrimForBubble, mBubbleAlpha);
dispatchScrimsVisible();
}
@@ -579,11 +600,11 @@
private void dispatchScrimsVisible() {
final int currentScrimVisibility;
if (mScrimInFront.getViewAlpha() == 1 || mScrimBehind.getViewAlpha() == 1) {
- currentScrimVisibility = VISIBILITY_FULLY_OPAQUE;
+ currentScrimVisibility = OPAQUE;
} else if (mScrimInFront.getViewAlpha() == 0 && mScrimBehind.getViewAlpha() == 0) {
- currentScrimVisibility = VISIBILITY_FULLY_TRANSPARENT;
+ currentScrimVisibility = TRANSPARENT;
} else {
- currentScrimVisibility = VISIBILITY_SEMI_TRANSPARENT;
+ currentScrimVisibility = SEMI_TRANSPARENT;
}
if (mScrimsVisibility != currentScrimVisibility) {
@@ -600,18 +621,10 @@
return 0;
} else {
// woo, special effects
- return (float)(1f-0.5f*(1f-Math.cos(3.14159f * Math.pow(1f-frac, 2f))));
+ return (float) (1f - 0.5f * (1f - Math.cos(3.14159f * Math.pow(1f - frac, 2f))));
}
}
- private void setScrimBehindAlpha(float alpha) {
- setScrimAlpha(mScrimBehind, alpha);
- }
-
- private void setScrimInFrontAlpha(float alpha) {
- setScrimAlpha(mScrimInFront, alpha);
- }
-
private void setScrimAlpha(ScrimView scrim, float alpha) {
if (alpha == 0f) {
scrim.setClickable(false);
@@ -622,17 +635,26 @@
updateScrim(scrim, alpha);
}
+ private String getScrimName(ScrimView scrim) {
+ if (scrim == mScrimInFront) {
+ return "front_scrim";
+ } else if (scrim == mScrimBehind) {
+ return "back_scrim";
+ } else if (scrim == mScrimForBubble) {
+ return "bubble_scrim";
+ }
+ return "unknown_scrim";
+ }
+
private void updateScrimColor(View scrim, float alpha, int tint) {
alpha = Math.max(0, Math.min(1.0f, alpha));
if (scrim instanceof ScrimView) {
ScrimView scrimView = (ScrimView) scrim;
- Trace.traceCounter(Trace.TRACE_TAG_APP,
- scrim == mScrimInFront ? "front_scrim_alpha" : "back_scrim_alpha",
+ Trace.traceCounter(Trace.TRACE_TAG_APP, getScrimName(scrimView) + "_alpha",
(int) (alpha * 255));
- Trace.traceCounter(Trace.TRACE_TAG_APP,
- scrim == mScrimInFront ? "front_scrim_tint" : "back_scrim_tint",
+ Trace.traceCounter(Trace.TRACE_TAG_APP, getScrimName(scrimView) + "_tint",
Color.alpha(tint));
scrimView.setTint(tint);
@@ -689,9 +711,11 @@
private float getCurrentScrimAlpha(View scrim) {
if (scrim == mScrimInFront) {
- return mCurrentInFrontAlpha;
+ return mInFrontAlpha;
} else if (scrim == mScrimBehind) {
- return mCurrentBehindAlpha;
+ return mBehindAlpha;
+ } else if (scrim == mScrimForBubble) {
+ return mBubbleAlpha;
} else {
throw new IllegalArgumentException("Unknown scrim view");
}
@@ -699,9 +723,11 @@
private int getCurrentScrimTint(View scrim) {
if (scrim == mScrimInFront) {
- return mCurrentInFrontTint;
+ return mInFrontTint;
} else if (scrim == mScrimBehind) {
- return mCurrentBehindTint;
+ return mBehindTint;
+ } else if (scrim == mScrimForBubble) {
+ return mBubbleTint;
} else {
throw new IllegalArgumentException("Unknown scrim view");
}
@@ -744,8 +770,9 @@
// When unlocking with fingerprint, we'll fade the scrims from black to transparent.
// At the end of the animation we need to remove the tint.
if (mState == ScrimState.UNLOCKED) {
- mCurrentInFrontTint = Color.TRANSPARENT;
- mCurrentBehindTint = Color.TRANSPARENT;
+ mInFrontTint = Color.TRANSPARENT;
+ mBehindTint = Color.TRANSPARENT;
+ mBubbleTint = Color.TRANSPARENT;
}
}
@@ -850,6 +877,7 @@
/**
* Executes a callback after the frame has hit the display.
+ *
* @param callback What to run.
*/
@VisibleForTesting
@@ -893,16 +921,35 @@
@Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
pw.println(" ScrimController: ");
- pw.print(" state: "); pw.println(mState);
- pw.print(" frontScrim:"); pw.print(" viewAlpha="); pw.print(mScrimInFront.getViewAlpha());
- pw.print(" alpha="); pw.print(mCurrentInFrontAlpha);
- pw.print(" tint=0x"); pw.println(Integer.toHexString(mScrimInFront.getTint()));
+ pw.print(" state: ");
+ pw.println(mState);
- pw.print(" backScrim:"); pw.print(" viewAlpha="); pw.print(mScrimBehind.getViewAlpha());
- pw.print(" alpha="); pw.print(mCurrentBehindAlpha);
- pw.print(" tint=0x"); pw.println(Integer.toHexString(mScrimBehind.getTint()));
+ pw.print(" frontScrim:");
+ pw.print(" viewAlpha=");
+ pw.print(mScrimInFront.getViewAlpha());
+ pw.print(" alpha=");
+ pw.print(mInFrontAlpha);
+ pw.print(" tint=0x");
+ pw.println(Integer.toHexString(mScrimInFront.getTint()));
- pw.print(" mTracking="); pw.println(mTracking);
+ pw.print(" backScrim:");
+ pw.print(" viewAlpha=");
+ pw.print(mScrimBehind.getViewAlpha());
+ pw.print(" alpha=");
+ pw.print(mBehindAlpha);
+ pw.print(" tint=0x");
+ pw.println(Integer.toHexString(mScrimBehind.getTint()));
+
+ pw.print(" bubbleScrim:");
+ pw.print(" viewAlpha=");
+ pw.print(mScrimForBubble.getViewAlpha());
+ pw.print(" alpha=");
+ pw.print(mBubbleAlpha);
+ pw.print(" tint=0x");
+ pw.println(Integer.toHexString(mScrimForBubble.getTint()));
+
+ pw.print(" mTracking=");
+ pw.println(mTracking);
}
public void setWallpaperSupportsAmbientMode(boolean wallpaperSupportsAmbientMode) {
@@ -949,8 +996,8 @@
// in this case, back-scrim needs to be re-evaluated
if (mState == ScrimState.AOD || mState == ScrimState.PULSING) {
float newBehindAlpha = mState.getBehindAlpha();
- if (mCurrentBehindAlpha != newBehindAlpha) {
- mCurrentBehindAlpha = newBehindAlpha;
+ if (mBehindAlpha != newBehindAlpha) {
+ mBehindAlpha = newBehindAlpha;
updateScrims();
}
}
@@ -971,10 +1018,13 @@
public interface Callback {
default void onStart() {
}
+
default void onDisplayBlanked() {
}
+
default void onFinished() {
}
+
default void onCancelled() {
}
/** Returns whether to timeout wallpaper or not. */
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java
index 9fdd3b8..7463c7c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java
@@ -36,7 +36,6 @@
* On the lock screen.
*/
KEYGUARD(0) {
-
@Override
public void prepare(ScrimState previousState) {
mBlankScreen = false;
@@ -53,10 +52,13 @@
} else {
mAnimationDuration = ScrimController.ANIMATION_DURATION;
}
- mCurrentInFrontTint = Color.BLACK;
- mCurrentBehindTint = Color.BLACK;
- mCurrentBehindAlpha = mScrimBehindAlphaKeyguard;
- mCurrentInFrontAlpha = 0;
+ mFrontTint = Color.BLACK;
+ mBehindTint = Color.BLACK;
+ mBubbleTint = Color.TRANSPARENT;
+
+ mFrontAlpha = 0;
+ mBehindAlpha = mScrimBehindAlphaKeyguard;
+ mBubbleAlpha = 0;
}
},
@@ -66,8 +68,9 @@
BOUNCER(1) {
@Override
public void prepare(ScrimState previousState) {
- mCurrentBehindAlpha = ScrimController.GRADIENT_SCRIM_ALPHA_BUSY;
- mCurrentInFrontAlpha = 0f;
+ mBehindAlpha = ScrimController.GRADIENT_SCRIM_ALPHA_BUSY;
+ mFrontAlpha = 0f;
+ mBubbleAlpha = 0f;
}
},
@@ -77,8 +80,9 @@
BOUNCER_SCRIMMED(2) {
@Override
public void prepare(ScrimState previousState) {
- mCurrentBehindAlpha = 0;
- mCurrentInFrontAlpha = ScrimController.GRADIENT_SCRIM_ALPHA_BUSY;
+ mBehindAlpha = 0;
+ mBubbleAlpha = 0f;
+ mFrontAlpha = ScrimController.GRADIENT_SCRIM_ALPHA_BUSY;
}
},
@@ -88,8 +92,9 @@
BRIGHTNESS_MIRROR(3) {
@Override
public void prepare(ScrimState previousState) {
- mCurrentBehindAlpha = 0;
- mCurrentInFrontAlpha = 0;
+ mBehindAlpha = 0;
+ mFrontAlpha = 0;
+ mBubbleAlpha = 0;
}
},
@@ -101,9 +106,16 @@
public void prepare(ScrimState previousState) {
final boolean alwaysOnEnabled = mDozeParameters.getAlwaysOn();
mBlankScreen = mDisplayRequiresBlanking;
- mCurrentInFrontAlpha = alwaysOnEnabled ? mAodFrontScrimAlpha : 1f;
- mCurrentInFrontTint = Color.BLACK;
- mCurrentBehindTint = Color.BLACK;
+
+ mFrontTint = Color.BLACK;
+ mFrontAlpha = alwaysOnEnabled ? mAodFrontScrimAlpha : 1f;
+
+ mBehindTint = Color.BLACK;
+ mBehindAlpha = ScrimController.TRANSPARENT;
+
+ mBubbleTint = Color.TRANSPARENT;
+ mBubbleAlpha = ScrimController.TRANSPARENT;
+
mAnimationDuration = ScrimController.ANIMATION_DURATION_LONG;
// DisplayPowerManager may blank the screen for us,
// in this case we just need to set our state.
@@ -127,9 +139,10 @@
PULSING(5) {
@Override
public void prepare(ScrimState previousState) {
- mCurrentInFrontAlpha = 0f;
- mCurrentBehindTint = Color.BLACK;
- mCurrentInFrontTint = Color.BLACK;
+ mFrontAlpha = mAodFrontScrimAlpha;
+ mBubbleAlpha = 0f;
+ mBehindTint = Color.BLACK;
+ mFrontTint = Color.BLACK;
mBlankScreen = mDisplayRequiresBlanking;
mAnimationDuration = mWakeLockScreenSensorActive
? ScrimController.ANIMATION_DURATION_LONG : ScrimController.ANIMATION_DURATION;
@@ -154,25 +167,33 @@
UNLOCKED(6) {
@Override
public void prepare(ScrimState previousState) {
- mCurrentBehindAlpha = 0;
- mCurrentInFrontAlpha = 0;
+ // State that UI will sync to.
+ mBehindAlpha = 0;
+ mFrontAlpha = 0;
+ mBubbleAlpha = 0;
+
mAnimationDuration = mKeyguardFadingAway
? mKeyguardFadingAwayDuration
: StatusBar.FADE_KEYGUARD_DURATION;
+
mAnimateChange = !mLaunchingAffordanceWithPreview;
+ mFrontTint = Color.TRANSPARENT;
+ mBehindTint = Color.TRANSPARENT;
+ mBubbleTint = Color.TRANSPARENT;
+ mBlankScreen = false;
+
if (previousState == ScrimState.AOD) {
- // Fade from black to transparent when coming directly from AOD
- updateScrimColor(mScrimInFront, 1, Color.BLACK);
- updateScrimColor(mScrimBehind, 1, Color.BLACK);
+ // Set all scrims black, before they fade transparent.
+ updateScrimColor(mScrimInFront, 1f /* alpha */, Color.BLACK /* tint */);
+ updateScrimColor(mScrimBehind, 1f /* alpha */, Color.BLACK /* tint */);
+ updateScrimColor(mScrimForBubble, 1f /* alpha */, Color.BLACK /* tint */);
+
// Scrims should still be black at the end of the transition.
- mCurrentInFrontTint = Color.BLACK;
- mCurrentBehindTint = Color.BLACK;
+ mFrontTint = Color.BLACK;
+ mBehindTint = Color.BLACK;
+ mBubbleTint = Color.BLACK;
mBlankScreen = true;
- } else {
- mCurrentInFrontTint = Color.TRANSPARENT;
- mCurrentBehindTint = Color.TRANSPARENT;
- mBlankScreen = false;
}
}
},
@@ -183,25 +204,36 @@
BUBBLE_EXPANDED(7) {
@Override
public void prepare(ScrimState previousState) {
- mCurrentInFrontTint = Color.TRANSPARENT;
- mCurrentBehindTint = Color.TRANSPARENT;
+ mFrontTint = Color.TRANSPARENT;
+ mBehindTint = Color.TRANSPARENT;
+ mBubbleTint = Color.TRANSPARENT;
+
+ mFrontAlpha = ScrimController.TRANSPARENT;
+ mBehindAlpha = ScrimController.GRADIENT_SCRIM_ALPHA_BUSY;
+ mBubbleAlpha = ScrimController.GRADIENT_SCRIM_ALPHA_BUSY;
+
mAnimationDuration = ScrimController.ANIMATION_DURATION;
- mCurrentBehindAlpha = ScrimController.GRADIENT_SCRIM_ALPHA_BUSY;
mBlankScreen = false;
}
};
boolean mBlankScreen = false;
long mAnimationDuration = ScrimController.ANIMATION_DURATION;
- int mCurrentInFrontTint = Color.TRANSPARENT;
- int mCurrentBehindTint = Color.TRANSPARENT;
+ int mFrontTint = Color.TRANSPARENT;
+ int mBehindTint = Color.TRANSPARENT;
+ int mBubbleTint = Color.TRANSPARENT;
+
boolean mAnimateChange = true;
- float mCurrentInFrontAlpha;
- float mCurrentBehindAlpha;
float mAodFrontScrimAlpha;
+ float mFrontAlpha;
+ float mBehindAlpha;
+ float mBubbleAlpha;
+
float mScrimBehindAlphaKeyguard;
ScrimView mScrimInFront;
ScrimView mScrimBehind;
+ ScrimView mScrimForBubble;
+
DozeParameters mDozeParameters;
boolean mDisplayRequiresBlanking;
boolean mWallpaperSupportsAmbientMode;
@@ -216,13 +248,17 @@
mIndex = index;
}
- public void init(ScrimView scrimInFront, ScrimView scrimBehind, DozeParameters dozeParameters) {
+ public void init(ScrimView scrimInFront, ScrimView scrimBehind, ScrimView scrimForBubble,
+ DozeParameters dozeParameters) {
mScrimInFront = scrimInFront;
mScrimBehind = scrimBehind;
+ mScrimForBubble = scrimForBubble;
+
mDozeParameters = dozeParameters;
mDisplayRequiresBlanking = dozeParameters.getDisplayNeedsBlanking();
}
+ /** Prepare state for transition. */
public void prepare(ScrimState previousState) {
}
@@ -231,19 +267,27 @@
}
public float getFrontAlpha() {
- return mCurrentInFrontAlpha;
+ return mFrontAlpha;
}
public float getBehindAlpha() {
- return mCurrentBehindAlpha;
+ return mBehindAlpha;
+ }
+
+ public float getBubbleAlpha() {
+ return mBubbleAlpha;
}
public int getFrontTint() {
- return mCurrentInFrontTint;
+ return mFrontTint;
}
public int getBehindTint() {
- return mCurrentBehindTint;
+ return mBehindTint;
+ }
+
+ public int getBubbleTint() {
+ return mBubbleTint;
}
public long getAnimationDuration() {
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 d12bed9..fc20d83 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -25,6 +25,7 @@
import static android.app.StatusBarManager.windowStateToString;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY;
+import static com.android.systemui.Dependency.ALLOW_NOTIFICATION_LONG_PRESS_NAME;
import static com.android.systemui.Dependency.BG_HANDLER;
import static com.android.systemui.Dependency.MAIN_HANDLER;
import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_ASLEEP;
@@ -147,7 +148,6 @@
import com.android.systemui.bubbles.BubbleController;
import com.android.systemui.charging.WirelessChargingAnimation;
import com.android.systemui.classifier.FalsingLog;
-import com.android.systemui.classifier.FalsingManagerFactory;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.doze.DozeHost;
import com.android.systemui.doze.DozeLog;
@@ -239,6 +239,7 @@
import java.util.Map;
import javax.inject.Inject;
+import javax.inject.Named;
import dagger.Subcomponent;
@@ -383,6 +384,9 @@
@Nullable
@Inject
protected KeyguardLiftController mKeyguardLiftController;
+ @Inject
+ @Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME)
+ boolean mAllowNotificationLongPress;
// expanded notifications
protected NotificationPanelView mNotificationPanel; // the sliding/resizing panel within the notification window
@@ -701,6 +705,7 @@
mRecents = getComponent(Recents.class);
mKeyguardManager = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
+ mFalsingManager = Dependency.get(FalsingManager.class);
// Connect in to the status bar manager service
mCommandQueue = getComponent(CommandQueue.class);
@@ -776,7 +781,6 @@
putComponent(DozeHost.class, mDozeServiceHost);
mScreenPinningRequest = new ScreenPinningRequest(mContext);
- mFalsingManager = FalsingManagerFactory.getInstance(mContext);
Dependency.get(ActivityStarterDelegate.class).setActivityStarterImpl(this);
@@ -807,6 +811,7 @@
// TODO: Deal with the ugliness that comes from having some of the statusbar broken out
// into fragments, but the rest here, it leaves some awkward lifecycle and whatnot.
mNotificationPanel = mStatusBarWindow.findViewById(R.id.notification_panel);
+
mStackScroller = mStatusBarWindow.findViewById(R.id.notification_stack_scroller);
mZenController.addCallback(this);
NotificationListContainer notifListContainer = (NotificationListContainer) mStackScroller;
@@ -927,8 +932,10 @@
ScrimView scrimBehind = mStatusBarWindow.findViewById(R.id.scrim_behind);
ScrimView scrimInFront = mStatusBarWindow.findViewById(R.id.scrim_in_front);
+ ScrimView scrimForBubble = mStatusBarWindow.findViewById(R.id.scrim_for_bubble);
+
mScrimController = SystemUIFactory.getInstance().createScrimController(
- scrimBehind, scrimInFront, mLockscreenWallpaper,
+ scrimBehind, scrimInFront, scrimForBubble, mLockscreenWallpaper,
(state, alpha, color) -> mLightBarController.setScrimState(state, alpha, color),
scrimsVisible -> {
if (mStatusBarWindowController != null) {
@@ -1065,7 +1072,7 @@
final NotificationRowBinderImpl rowBinder =
new NotificationRowBinderImpl(
mContext,
- SystemUIFactory.getInstance().provideAllowNotificationLongPress(),
+ mAllowNotificationLongPress,
mKeyguardBypassController,
mStatusBarStateController);
@@ -1243,7 +1250,7 @@
mStatusBarKeyguardViewManager = keyguardViewMediator.registerStatusBar(this,
getBouncerContainer(), mNotificationPanel, mBiometricUnlockController,
mStatusBarWindow.findViewById(R.id.lock_icon_container), mStackScroller,
- mKeyguardBypassController);
+ mKeyguardBypassController, mFalsingManager);
mKeyguardIndicationController
.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager);
mBiometricUnlockController.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager);
@@ -2399,6 +2406,10 @@
pw.println(" mGroupManager: null");
}
+ if (mBubbleController != null) {
+ mBubbleController.dump(fd, pw, args);
+ }
+
if (mLightBarController != null) {
mLightBarController.dump(fd, pw, args);
}
@@ -2415,7 +2426,7 @@
mKeyguardUpdateMonitor.dump(fd, pw, args);
}
- FalsingManagerFactory.getInstance(mContext).dump(pw);
+ Dependency.get(FalsingManager.class).dump(pw);
FalsingLog.dump(pw);
pw.println("SharedPreferences:");
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
index 7e86651..0c47d14 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
@@ -44,6 +44,7 @@
import com.android.systemui.SystemUIFactory;
import com.android.systemui.dock.DockManager;
import com.android.systemui.keyguard.DismissCallbackRegistry;
+import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.statusbar.CommandQueue;
@@ -210,7 +211,7 @@
BiometricUnlockController biometricUnlockController,
DismissCallbackRegistry dismissCallbackRegistry,
ViewGroup lockIconContainer, View notificationContainer,
- KeyguardBypassController bypassController) {
+ KeyguardBypassController bypassController, FalsingManager falsingManager) {
mStatusBar = statusBar;
mContainer = container;
mLockIconContainer = lockIconContainer;
@@ -220,7 +221,7 @@
mBiometricUnlockController = biometricUnlockController;
mBouncer = SystemUIFactory.getInstance().createKeyguardBouncer(mContext,
mViewMediatorCallback, mLockPatternUtils, container, dismissCallbackRegistry,
- mExpansionCallback, bypassController);
+ mExpansionCallback, falsingManager, bypassController);
mNotificationPanelView = notificationPanelView;
notificationPanelView.addExpansionListener(this);
mBypassController = bypassController;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowController.java
index 0ef981b..d3ae5cf 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowController.java
@@ -39,9 +39,9 @@
import android.view.WindowManager.LayoutParams;
import com.android.internal.annotations.VisibleForTesting;
-import com.android.keyguard.R;
import com.android.systemui.Dependency;
import com.android.systemui.Dumpable;
+import com.android.systemui.R;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
@@ -222,7 +222,7 @@
}
final boolean scrimsOccludingWallpaper =
- state.scrimsVisibility == ScrimController.VISIBILITY_FULLY_OPAQUE;
+ state.scrimsVisibility == ScrimController.OPAQUE;
final boolean keyguardOrAod = state.keyguardShowing
|| (state.dozing && mDozeParameters.getAlwaysOn());
if (keyguardOrAod && !state.backdropShowing && !scrimsOccludingWallpaper) {
@@ -308,7 +308,7 @@
return !state.forceCollapsed && (state.isKeyguardShowingAndNotOccluded()
|| state.panelVisible || state.keyguardFadingAway || state.bouncerShowing
|| state.headsUpShowing || state.bubblesShowing
- || state.scrimsVisibility != ScrimController.VISIBILITY_FULLY_TRANSPARENT);
+ || state.scrimsVisibility != ScrimController.TRANSPARENT);
}
private void applyFitsSystemWindows(State state) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
index 1081bad..6789930 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
@@ -62,7 +62,6 @@
import com.android.systemui.Dependency;
import com.android.systemui.ExpandHelper;
import com.android.systemui.R;
-import com.android.systemui.classifier.FalsingManagerFactory;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.DragDownHelper;
@@ -157,7 +156,7 @@
setMotionEventSplittingEnabled(false);
mTransparentSrcPaint.setColor(0);
mTransparentSrcPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
- mFalsingManager = FalsingManagerFactory.getInstance(context);
+ mFalsingManager = Dependency.get(FalsingManager.class); // TODO: inject into a controller.
mGestureDetector = new GestureDetector(context, mGestureListener);
mStatusBarStateController = Dependency.get(StatusBarStateController.class);
Dependency.get(TunerService.class).addTunable(mTunable,
@@ -291,7 +290,7 @@
ExpandHelper.Callback expandHelperCallback = stackScrollLayout.getExpandHelperCallback();
DragDownHelper.DragDownCallback dragDownCallback = stackScrollLayout.getDragDownCallback();
setDragDownHelper(new DragDownHelper(getContext(), this, expandHelperCallback,
- dragDownCallback));
+ dragDownCallback, mFalsingManager));
}
@VisibleForTesting
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/InflatedSmartReplies.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/InflatedSmartReplies.java
index ee78a72..ea93193 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/InflatedSmartReplies.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/InflatedSmartReplies.java
@@ -80,6 +80,7 @@
*/
public static InflatedSmartReplies inflate(
Context context,
+ Context packageContext,
NotificationEntry entry,
SmartReplyConstants smartReplyConstants,
SmartReplyController smartReplyController,
@@ -108,9 +109,9 @@
}
if (newSmartRepliesAndActions.smartActions != null) {
suggestionButtons.addAll(
- smartReplyView.inflateSmartActions(newSmartRepliesAndActions.smartActions,
- smartReplyController, entry, headsUpManager,
- delayOnClickListener));
+ smartReplyView.inflateSmartActions(packageContext,
+ newSmartRepliesAndActions.smartActions, smartReplyController, entry,
+ headsUpManager, delayOnClickListener));
}
return new InflatedSmartReplies(smartReplyView, suggestionButtons,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
index 94c2232..8ea09e5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
@@ -21,6 +21,7 @@
import android.net.NetworkCapabilities;
import android.os.Handler;
import android.os.Looper;
+import android.os.Message;
import android.provider.Settings.Global;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.PhoneStateListener;
@@ -55,6 +56,10 @@
public class MobileSignalController extends SignalController<
MobileSignalController.MobileState, MobileSignalController.MobileIconGroup> {
+
+ // The message to display Nr5G icon gracfully by CarrierConfig timeout
+ private static final int MSG_DISPLAY_GRACE = 1;
+
private final TelephonyManager mPhone;
private final SubscriptionDefaults mDefaults;
private final String mNetworkNameDefault;
@@ -77,8 +82,11 @@
private SignalStrength mSignalStrength;
private MobileIconGroup mDefaultIcons;
private Config mConfig;
+ private final Handler mDisplayGraceHandler;
@VisibleForTesting
boolean mInflateSignalStrengths = false;
+ @VisibleForTesting
+ boolean mIsShowingIconGracefully = false;
// Some specific carriers have 5GE network which is special LTE CA network.
private static final int NETWORK_TYPE_LTE_CA_5GE = TelephonyManager.MAX_NETWORK_TYPE + 1;
@@ -118,6 +126,16 @@
updateTelephony();
}
};
+
+ mDisplayGraceHandler = new Handler(receiverLooper) {
+ @Override
+ public void handleMessage(Message msg) {
+ if (msg.what == MSG_DISPLAY_GRACE) {
+ mIsShowingIconGracefully = false;
+ updateTelephony();
+ }
+ }
+ };
}
public void setConfiguration(Config config) {
@@ -274,7 +292,8 @@
}
boolean dataDisabled = mCurrentState.userSetup
&& (mCurrentState.iconGroup == TelephonyIcons.DATA_DISABLED
- || mCurrentState.iconGroup == TelephonyIcons.NOT_DEFAULT_DATA);
+ || (mCurrentState.iconGroup == TelephonyIcons.NOT_DEFAULT_DATA
+ && mCurrentState.defaultDataOff));
boolean noInternet = mCurrentState.inetCondition == 0;
boolean cutOut = dataDisabled || noInternet;
return SignalDrawable.getState(level, getNumLevels(), cutOut);
@@ -306,7 +325,7 @@
dataContentDescription = mContext.getString(R.string.data_connection_no_internet);
}
final boolean dataDisabled = (mCurrentState.iconGroup == TelephonyIcons.DATA_DISABLED
- || mCurrentState.iconGroup == TelephonyIcons.NOT_DEFAULT_DATA)
+ || (mCurrentState.iconGroup == TelephonyIcons.NOT_DEFAULT_DATA))
&& mCurrentState.userSetup;
// Show icon in QS when we are connected or data is disabled.
@@ -471,6 +490,7 @@
Log.d(mTag, "updateTelephonySignalStrength: hasService=" +
Utils.isInService(mServiceState) + " ss=" + mSignalStrength);
}
+ checkDefaultData();
mCurrentState.connected = Utils.isInService(mServiceState)
&& mSignalStrength != null;
if (mCurrentState.connected) {
@@ -484,6 +504,10 @@
// When the device is camped on a 5G Non-Standalone network, the data network type is still
// LTE. In this case, we first check which 5G icon should be shown.
MobileIconGroup nr5GIconGroup = getNr5GIconGroup();
+ if (mConfig.nrIconDisplayGracePeriodMs > 0) {
+ nr5GIconGroup = adjustNr5GIconGroupByDisplayGraceTime(nr5GIconGroup);
+ }
+
if (nr5GIconGroup != null) {
mCurrentState.iconGroup = nr5GIconGroup;
} else if (mNetworkToIconLookup.indexOfKey(mDataNetType) >= 0) {
@@ -524,6 +548,23 @@
notifyListenersIfNecessary();
}
+ /**
+ * If we are controlling the NOT_DEFAULT_DATA icon, check the status of the other one
+ */
+ private void checkDefaultData() {
+ if (mCurrentState.iconGroup != TelephonyIcons.NOT_DEFAULT_DATA) {
+ mCurrentState.defaultDataOff = false;
+ return;
+ }
+
+ mCurrentState.defaultDataOff = mNetworkController.isDataControllerDisabled();
+ }
+
+ void onMobileDataChanged() {
+ checkDefaultData();
+ notifyListenersIfNecessary();
+ }
+
private MobileIconGroup getNr5GIconGroup() {
if (mServiceState == null) return null;
@@ -542,8 +583,14 @@
return mConfig.nr5GIconMap.get(Config.NR_CONNECTED);
}
} else if (nrState == NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED) {
- if (mConfig.nr5GIconMap.containsKey(Config.NR_NOT_RESTRICTED)) {
- return mConfig.nr5GIconMap.get(Config.NR_NOT_RESTRICTED);
+ if (mCurrentState.activityDormant) {
+ if (mConfig.nr5GIconMap.containsKey(Config.NR_NOT_RESTRICTED_RRC_IDLE)) {
+ return mConfig.nr5GIconMap.get(Config.NR_NOT_RESTRICTED_RRC_IDLE);
+ }
+ } else {
+ if (mConfig.nr5GIconMap.containsKey(Config.NR_NOT_RESTRICTED_RRC_CON)) {
+ return mConfig.nr5GIconMap.get(Config.NR_NOT_RESTRICTED_RRC_CON);
+ }
}
} else if (nrState == NetworkRegistrationInfo.NR_STATE_RESTRICTED) {
if (mConfig.nr5GIconMap.containsKey(Config.NR_RESTRICTED)) {
@@ -554,7 +601,47 @@
return null;
}
- private boolean isDataDisabled() {
+ /**
+ * The function to adjust MobileIconGroup depend on CarrierConfig's time
+ * nextIconGroup == null imply next state could be 2G/3G/4G/4G+
+ * nextIconGroup != null imply next state will be 5G/5G+
+ * Flag : mIsShowingIconGracefully
+ * ---------------------------------------------------------------------------------
+ * | Last state | Current state | Flag | Action |
+ * ---------------------------------------------------------------------------------
+ * | 5G/5G+ | 2G/3G/4G/4G+ | true | return previous IconGroup |
+ * | 5G/5G+ | 5G/5G+ | true | Bypass |
+ * | 2G/3G/4G/4G+ | 5G/5G+ | true | Bypass |
+ * | 2G/3G/4G/4G+ | 2G/3G/4G/4G+ | true | Bypass |
+ * | SS.connected | SS.disconnect | T|F | Reset timer |
+ * |NETWORK_TYPE_LTE|!NETWORK_TYPE_LTE| T|F | Reset timer |
+ * | 5G/5G+ | 2G/3G/4G/4G+ | false| Bypass |
+ * | 5G/5G+ | 5G/5G+ | false| Bypass |
+ * | 2G/3G/4G/4G+ | 5G/5G+ | false| SendMessageDelay(time), flag->true |
+ * | 2G/3G/4G/4G+ | 2G/3G/4G/4G+ | false| Bypass |
+ * ---------------------------------------------------------------------------------
+ */
+ private MobileIconGroup adjustNr5GIconGroupByDisplayGraceTime(
+ MobileIconGroup candidateIconGroup) {
+ if (mIsShowingIconGracefully && candidateIconGroup == null) {
+ candidateIconGroup = (MobileIconGroup) mCurrentState.iconGroup;
+ } else if (!mIsShowingIconGracefully && candidateIconGroup != null
+ && mLastState.iconGroup != candidateIconGroup) {
+ mDisplayGraceHandler.sendMessageDelayed(
+ mDisplayGraceHandler.obtainMessage(MSG_DISPLAY_GRACE),
+ mConfig.nrIconDisplayGracePeriodMs);
+ mIsShowingIconGracefully = true;
+ } else if (!mCurrentState.connected || mDataState == TelephonyManager.DATA_DISCONNECTED
+ || candidateIconGroup == null) {
+ mDisplayGraceHandler.removeMessages(MSG_DISPLAY_GRACE);
+ mIsShowingIconGracefully = false;
+ candidateIconGroup = null;
+ }
+
+ return candidateIconGroup;
+ }
+
+ boolean isDataDisabled() {
return !mPhone.isDataCapable();
}
@@ -564,6 +651,8 @@
|| activity == TelephonyManager.DATA_ACTIVITY_IN;
mCurrentState.activityOut = activity == TelephonyManager.DATA_ACTIVITY_INOUT
|| activity == TelephonyManager.DATA_ACTIVITY_OUT;
+ mCurrentState.activityDormant = activity == TelephonyManager.DATA_ACTIVITY_DORMANT;
+
notifyListenersIfNecessary();
}
@@ -577,6 +666,7 @@
pw.println(" mDataNetType=" + mDataNetType + ",");
pw.println(" mInflateSignalStrengths=" + mInflateSignalStrengths + ",");
pw.println(" isDataDisabled=" + isDataDisabled() + ",");
+ pw.println(" mIsShowingIconGracefully=" + mIsShowingIconGracefully + ",");
}
class MobilePhoneStateListener extends PhoneStateListener {
@@ -684,6 +774,7 @@
boolean isDefault;
boolean userSetup;
boolean roaming;
+ boolean defaultDataOff; // Tracks the on/off state of the defaultDataSubscription
@Override
public void copyFrom(State s) {
@@ -699,6 +790,7 @@
carrierNetworkChangeMode = state.carrierNetworkChangeMode;
userSetup = state.userSetup;
roaming = state.roaming;
+ defaultDataOff = state.defaultDataOff;
}
@Override
@@ -715,7 +807,8 @@
builder.append("airplaneMode=").append(airplaneMode).append(',');
builder.append("carrierNetworkChangeMode=").append(carrierNetworkChangeMode)
.append(',');
- builder.append("userSetup=").append(userSetup);
+ builder.append("userSetup=").append(userSetup).append(',');
+ builder.append("defaultDataOff=").append(defaultDataOff);
}
@Override
@@ -730,7 +823,8 @@
&& ((MobileState) o).carrierNetworkChangeMode == carrierNetworkChangeMode
&& ((MobileState) o).userSetup == userSetup
&& ((MobileState) o).isDefault == isDefault
- && ((MobileState) o).roaming == roaming;
+ && ((MobileState) o).roaming == roaming
+ && ((MobileState) o).defaultDataOff == defaultDataOff;
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
index 011dd85..7a09455 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
@@ -51,6 +51,7 @@
import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
+import android.text.format.DateUtils;
import android.util.Log;
import android.util.MathUtils;
import android.util.SparseArray;
@@ -219,6 +220,7 @@
@Override
public void onMobileDataEnabled(boolean enabled) {
mCallbackHandler.setMobileDataEnabled(enabled);
+ notifyControllersMobileDataChanged();
}
});
mWifiSignalController = new WifiSignalController(mContext, mHasMobileDataFeature,
@@ -384,6 +386,22 @@
return mMobileSignalControllers.size();
}
+ boolean isDataControllerDisabled() {
+ MobileSignalController dataController = getDataController();
+ if (dataController == null) {
+ return false;
+ }
+
+ return dataController.isDataDisabled();
+ }
+
+ private void notifyControllersMobileDataChanged() {
+ for (int i = 0; i < mMobileSignalControllers.size(); i++) {
+ MobileSignalController mobileSignalController = mMobileSignalControllers.valueAt(i);
+ mobileSignalController.onMobileDataChanged();
+ }
+ }
+
public boolean isEmergencyOnly() {
if (mMobileSignalControllers.size() == 0) {
// When there are no active subscriptions, determine emengency state from last
@@ -829,6 +847,13 @@
pw.print(" mEmergencySource=");
pw.println(emergencyToString(mEmergencySource));
+ pw.println(" - config ------");
+ pw.print(" patternOfCarrierSpecificDataIcon=");
+ pw.println(mConfig.patternOfCarrierSpecificDataIcon);
+ pw.print(" nr5GIconMap=");
+ pw.println(mConfig.nr5GIconMap.toString());
+ pw.print(" nrIconDisplayGracePeriodMs=");
+ pw.println(mConfig.nrIconDisplayGracePeriodMs);
for (int i = 0; i < mMobileSignalControllers.size(); i++) {
MobileSignalController mobileSignalController = mMobileSignalControllers.valueAt(i);
mobileSignalController.dump(pw);
@@ -1111,8 +1136,9 @@
static class Config {
static final int NR_CONNECTED_MMWAVE = 1;
static final int NR_CONNECTED = 2;
- static final int NR_NOT_RESTRICTED = 3;
- static final int NR_RESTRICTED = 4;
+ static final int NR_NOT_RESTRICTED_RRC_IDLE = 3;
+ static final int NR_NOT_RESTRICTED_RRC_CON = 4;
+ static final int NR_RESTRICTED = 5;
Map<Integer, MobileIconGroup> nr5GIconMap = new HashMap<>();
@@ -1125,6 +1151,7 @@
boolean inflateSignalStrengths = false;
boolean alwaysShowDataRatIcon = false;
public String patternOfCarrierSpecificDataIcon = "";
+ public long nrIconDisplayGracePeriodMs;
/**
* Mapping from NR 5G status string to an integer. The NR 5G status string should match
@@ -1132,10 +1159,11 @@
*/
private static final Map<String, Integer> NR_STATUS_STRING_TO_INDEX;
static {
- NR_STATUS_STRING_TO_INDEX = new HashMap<>(4);
+ NR_STATUS_STRING_TO_INDEX = new HashMap<>(5);
NR_STATUS_STRING_TO_INDEX.put("connected_mmwave", NR_CONNECTED_MMWAVE);
NR_STATUS_STRING_TO_INDEX.put("connected", NR_CONNECTED);
- NR_STATUS_STRING_TO_INDEX.put("not_restricted", NR_NOT_RESTRICTED);
+ NR_STATUS_STRING_TO_INDEX.put("not_restricted_rrc_idle", NR_NOT_RESTRICTED_RRC_IDLE);
+ NR_STATUS_STRING_TO_INDEX.put("not_restricted_rrc_con", NR_NOT_RESTRICTED_RRC_CON);
NR_STATUS_STRING_TO_INDEX.put("restricted", NR_RESTRICTED);
}
@@ -1176,6 +1204,9 @@
add5GIconMapping(pair, config);
}
}
+ setDisplayGraceTime(
+ b.getInt(CarrierConfigManager.KEY_5G_ICON_DISPLAY_GRACE_PERIOD_SEC_INT),
+ config);
}
return config;
@@ -1209,5 +1240,18 @@
TelephonyIcons.ICON_NAME_TO_ICON.get(value));
}
}
+
+ /**
+ * Set display gracefully period time(MS) depend on carrierConfig KEY
+ * KEY_5G_ICON_DISPLAY_GRACE_PERIOD_SEC_INT, and this function will convert to ms.
+ * {@link CarrierConfigManager}.
+ *
+ * @param time showing 5G icon gracefully in the period of the time(SECOND)
+ * @param config container that used to store the parsed configs.
+ */
+ @VisibleForTesting
+ static void setDisplayGraceTime(int time, Config config) {
+ config.nrIconDisplayGracePeriodMs = time * DateUtils.SECOND_IN_MILLIS;
+ }
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SignalController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SignalController.java
index 52f7ae0..952324c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SignalController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SignalController.java
@@ -259,6 +259,7 @@
boolean enabled;
boolean activityIn;
boolean activityOut;
+ public boolean activityDormant;
int level;
IconGroup iconGroup;
int inetCondition;
@@ -275,6 +276,7 @@
inetCondition = state.inetCondition;
activityIn = state.activityIn;
activityOut = state.activityOut;
+ activityDormant = state.activityDormant;
rssi = state.rssi;
time = state.time;
}
@@ -298,6 +300,7 @@
.append("iconGroup=").append(iconGroup).append(',')
.append("activityIn=").append(activityIn).append(',')
.append("activityOut=").append(activityOut).append(',')
+ .append("activityDormant=").append(activityDormant).append(',')
.append("rssi=").append(rssi).append(',')
.append("lastModified=").append(DateFormat.format("MM-dd HH:mm:ss", time));
}
@@ -315,6 +318,7 @@
&& other.iconGroup == iconGroup
&& other.activityIn == activityIn
&& other.activityOut == activityOut
+ && other.activityDormant == activityDormant
&& other.rssi == rssi;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java
index 282d28c..ed0b9d9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java
@@ -235,17 +235,17 @@
* Add smart actions to be shown next to smart replies. Only the actions that fit into the
* notification are shown.
*/
- public List<Button> inflateSmartActions(@NonNull SmartActions smartActions,
- SmartReplyController smartReplyController, NotificationEntry entry,
- HeadsUpManager headsUpManager, boolean delayOnClickListener) {
+ public List<Button> inflateSmartActions(Context packageContext,
+ @NonNull SmartActions smartActions, SmartReplyController smartReplyController,
+ NotificationEntry entry, HeadsUpManager headsUpManager, boolean delayOnClickListener) {
List<Button> buttons = new ArrayList<>();
int numSmartActions = smartActions.actions.size();
for (int n = 0; n < numSmartActions; n++) {
Notification.Action action = smartActions.actions.get(n);
if (action.actionIntent != null) {
buttons.add(inflateActionButton(
- this, getContext(), n, smartActions, smartReplyController, entry,
- headsUpManager, delayOnClickListener));
+ this, getContext(), packageContext, n, smartActions, smartReplyController,
+ entry, headsUpManager, delayOnClickListener));
}
}
return buttons;
@@ -327,7 +327,7 @@
@VisibleForTesting
static Button inflateActionButton(SmartReplyView smartReplyView, Context context,
- int actionIndex, SmartActions smartActions,
+ Context packageContext, int actionIndex, SmartActions smartActions,
SmartReplyController smartReplyController, NotificationEntry entry,
HeadsUpManager headsUpManager, boolean useDelayedOnClickListener) {
Notification.Action action = smartActions.actions.get(actionIndex);
@@ -335,7 +335,9 @@
R.layout.smart_action_button, smartReplyView, false);
button.setText(action.title);
- Drawable iconDrawable = action.getIcon().loadDrawable(context);
+ // We received the Icon from the application - so use the Context of the application to
+ // reference icon resources.
+ Drawable iconDrawable = action.getIcon().loadDrawable(packageContext);
// Add the action icon to the Smart Action button.
int newIconSize = context.getResources().getDimensionPixelSize(
R.dimen.smart_action_button_icon_size);
diff --git a/packages/SystemUI/src/com/android/systemui/tuner/TunerActivity.java b/packages/SystemUI/src/com/android/systemui/tuner/TunerActivity.java
index 1d4f9b3..9750790 100644
--- a/packages/SystemUI/src/com/android/systemui/tuner/TunerActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/tuner/TunerActivity.java
@@ -31,6 +31,7 @@
import com.android.systemui.Dependency;
import com.android.systemui.R;
+import com.android.systemui.SystemUIFactory;
import com.android.systemui.fragments.FragmentService;
public class TunerActivity extends Activity implements
@@ -50,7 +51,7 @@
setActionBar(toolbar);
}
- Dependency.initDependencies(this);
+ Dependency.initDependencies(SystemUIFactory.getInstance().getRootComponent());
if (getFragmentManager().findFragmentByTag(TAG_TUNER) == null) {
final String action = getIntent().getAction();
diff --git a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
index de86f3d..ff5bd03 100644
--- a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
+++ b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
@@ -628,6 +628,14 @@
final int requestKey = vol.getId().hashCode();
return PendingIntent.getActivityAsUser(mContext, requestKey, intent,
PendingIntent.FLAG_CANCEL_CURRENT, null, UserHandle.CURRENT);
+ } else if (isAutomotive()) {
+ intent.setClassName("com.android.car.settings",
+ "com.android.car.settings.storage.StorageUnmountReceiver");
+ intent.putExtra(VolumeInfo.EXTRA_VOLUME_ID, vol.getId());
+
+ final int requestKey = vol.getId().hashCode();
+ return PendingIntent.getBroadcastAsUser(mContext, requestKey, intent,
+ PendingIntent.FLAG_CANCEL_CURRENT, UserHandle.CURRENT);
} else {
intent.setClassName("com.android.settings",
"com.android.settings.deviceinfo.StorageUnmountReceiver");
@@ -749,6 +757,11 @@
PendingIntent.FLAG_CANCEL_CURRENT, null, UserHandle.CURRENT);
}
+ private boolean isAutomotive() {
+ PackageManager packageManager = mContext.getPackageManager();
+ return packageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE);
+ }
+
private boolean isTv() {
PackageManager packageManager = mContext.getPackageManager();
return packageManager.hasSystemFeature(PackageManager.FEATURE_LEANBACK);
diff --git a/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java b/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java
index ede3004..e44e58a 100644
--- a/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java
+++ b/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java
@@ -26,12 +26,13 @@
import com.android.keyguard.KeyguardClockSwitch;
import com.android.keyguard.KeyguardMessageArea;
import com.android.keyguard.KeyguardSliceView;
-import com.android.systemui.SystemUIFactory;
+import com.android.systemui.SystemUIRootComponent;
import com.android.systemui.qs.QSCarrierGroup;
import com.android.systemui.qs.QSFooterImpl;
import com.android.systemui.qs.QSPanel;
import com.android.systemui.qs.QuickQSPanel;
import com.android.systemui.qs.QuickStatusBarHeader;
+import com.android.systemui.qs.customize.QSCustomizer;
import com.android.systemui.statusbar.NotificationShelf;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.phone.LockIcon;
@@ -62,7 +63,7 @@
private final LayoutInflater.Factory2 mFactory = new InjectionFactory();
@Inject
- public InjectionInflationController(SystemUIFactory.SystemUIRootComponent rootComponent) {
+ public InjectionInflationController(SystemUIRootComponent rootComponent) {
mViewCreator = rootComponent.createViewCreator();
initInjectionMap();
}
@@ -172,6 +173,11 @@
* Creates the QuickQSPanel.
*/
QuickQSPanel createQuickQSPanel();
+
+ /**
+ * Creates the QSCustomizer.
+ */
+ QSCustomizer createQSCustomizer();
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/util/ProximitySensor.java b/packages/SystemUI/src/com/android/systemui/util/ProximitySensor.java
new file mode 100644
index 0000000..a905eba
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/util/ProximitySensor.java
@@ -0,0 +1,186 @@
+/*
+ * 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.
+ */
+
+package com.android.systemui.util;
+
+import android.content.Context;
+import android.hardware.Sensor;
+import android.hardware.SensorEvent;
+import android.hardware.SensorEventListener;
+import android.hardware.SensorManager;
+import android.util.Log;
+
+import com.android.systemui.R;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.inject.Inject;
+
+/**
+ * Simple wrapper around SensorManager customized for the Proximity sensor.
+ */
+public class ProximitySensor {
+ private static final String TAG = "ProxSensor";
+ private static final boolean DEBUG = false;
+
+ private final Sensor mSensor;
+ private final AsyncSensorManager mSensorManager;
+ private final boolean mUsingBrightnessSensor;
+ private final float mMaxRange;
+
+ private SensorEventListener mSensorEventListener = new SensorEventListener() {
+ @Override
+ public synchronized void onSensorChanged(SensorEvent event) {
+ onSensorEvent(event);
+ }
+
+ @Override
+ public void onAccuracyChanged(Sensor sensor, int accuracy) {
+ }
+ };
+ private boolean mNear;
+ private List<ProximitySensorListener> mListeners = new ArrayList<>();
+ private String mTag = null;
+
+ @Inject
+ public ProximitySensor(Context context, AsyncSensorManager sensorManager) {
+ mSensorManager = sensorManager;
+ Sensor sensor = findBrightnessSensor(context, sensorManager);
+
+ if (sensor == null) {
+ mUsingBrightnessSensor = false;
+ sensor = sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
+ } else {
+ mUsingBrightnessSensor = true;
+ }
+ mSensor = sensor;
+ if (mSensor != null) {
+ mMaxRange = mSensor.getMaximumRange();
+ } else {
+ mMaxRange = 0;
+ }
+ }
+
+ public void setTag(String tag) {
+ mTag = tag;
+ }
+
+ private Sensor findBrightnessSensor(Context context, SensorManager sensorManager) {
+ String sensorType = context.getString(R.string.doze_brightness_sensor_type);
+ List<Sensor> sensorList = sensorManager.getSensorList(Sensor.TYPE_ALL);
+ Sensor sensor = null;
+ for (Sensor s : sensorList) {
+ if (sensorType.equals(s.getStringType())) {
+ sensor = s;
+ break;
+ }
+ }
+
+ return sensor;
+ }
+
+ /**
+ * Returns {@code false} if a Proximity sensor is not available.
+ */
+ public boolean getSensorAvailable() {
+ return mSensor != null;
+ }
+
+ /**
+ * Add a listener.
+ *
+ * Registers itself with the {@link SensorManager} if this is the first listener
+ * added.
+ */
+ public boolean register(ProximitySensorListener listener) {
+ if (!getSensorAvailable()) {
+ return false;
+ }
+
+ logDebug("using brightness sensor? " + mUsingBrightnessSensor);
+ mListeners.add(listener);
+ if (mListeners.size() == 1) {
+ logDebug("registering sensor listener");
+ mSensorManager.registerListener(
+ mSensorEventListener, mSensor, SensorManager.SENSOR_DELAY_GAME);
+ }
+
+ return true;
+ }
+
+ /**
+ * Remove a listener.
+ *
+ * If all listeners are removed from an instance of this class,
+ * it will unregister itself with the SensorManager.
+ */
+ public void unregister(ProximitySensorListener listener) {
+ mListeners.remove(listener);
+ if (mListeners.size() == 0) {
+ logDebug("unregistering sensor listener");
+ mSensorManager.unregisterListener(mSensorEventListener);
+ }
+ }
+
+ public boolean isNear() {
+ return getSensorAvailable() && mNear;
+ }
+
+ private void onSensorEvent(SensorEvent event) {
+ boolean near = event.values[0] < mMaxRange;
+ if (mUsingBrightnessSensor) {
+ near = event.values[0] == 0;
+ }
+ mNear = near;
+ mListeners.forEach(proximitySensorListener ->
+ proximitySensorListener.onProximitySensorEvent(
+ new ProximityEvent(mNear, event.timestamp)));
+ }
+
+ /** Implement to be notified of ProximityEvents. */
+ public interface ProximitySensorListener {
+ /** Called when the ProximitySensor changes. */
+ void onProximitySensorEvent(ProximityEvent proximityEvent);
+ }
+
+ /**
+ * Returned when the near/far state of a {@link ProximitySensor} changes.
+ */
+ public static class ProximityEvent {
+ private final boolean mNear;
+ private final long mTimestampNs;
+
+ public ProximityEvent(boolean near, long timestampNs) {
+ mNear = near;
+ mTimestampNs = timestampNs;
+ }
+
+ public boolean getNear() {
+ return mNear;
+ }
+
+ public long getTimestampNs() {
+ return mTimestampNs;
+ }
+ }
+
+ private void logDebug(String msg) {
+ if (DEBUG) {
+ Log.d(TAG, (mTag != null ? "[" + mTag + "] " : "") + msg);
+ }
+ }
+}
diff --git a/packages/SystemUI/tests/Android.mk b/packages/SystemUI/tests/Android.mk
index 5412cde..81e2c22 100644
--- a/packages/SystemUI/tests/Android.mk
+++ b/packages/SystemUI/tests/Android.mk
@@ -39,7 +39,7 @@
telephony-common \
android.test.base \
-LOCAL_AAPT_FLAGS := --extra-packages com.android.systemui:com.android.keyguard
+LOCAL_AAPT_FLAGS := --extra-packages com.android.systemui
# sign this with platform cert, so this test is allowed to inject key events into
# UI it doesn't own. This is necessary to allow screenshots to be taken
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/CarrierTextControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/CarrierTextControllerTest.java
index 0044ca7..728debd 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/CarrierTextControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/CarrierTextControllerTest.java
@@ -22,11 +22,14 @@
import static android.telephony.SubscriptionManager.NAME_SOURCE_DEFAULT_SOURCE;
import static junit.framework.Assert.assertTrue;
+import static junit.framework.TestCase.assertFalse;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
@@ -34,18 +37,22 @@
import android.content.Context;
import android.net.ConnectivityManager;
+import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Handler;
import android.provider.Settings;
+import android.telephony.ServiceState;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.test.suitebuilder.annotation.SmallTest;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
+import android.text.TextUtils;
import com.android.internal.telephony.IccCardConstants;
import com.android.systemui.Dependency;
+import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.keyguard.WakefulnessLifecycle;
@@ -80,6 +87,9 @@
TEST_CARRIER, TEST_CARRIER_2, NAME_SOURCE_DEFAULT_SOURCE, 0xFFFFFF, "",
DATA_ROAMING_DISABLE, null, null, null, null, false, null, "", true, TEST_GROUP_UUID,
TEST_CARRIER_ID, 0);
+ private static final SubscriptionInfo TEST_SUBSCRIPTION_NULL = new SubscriptionInfo(0, "", 0,
+ TEST_CARRIER, null, NAME_SOURCE_DEFAULT_SOURCE, 0xFFFFFF, "", DATA_ROAMING_DISABLE,
+ null, null, null, null, false, null, "");
private static final SubscriptionInfo TEST_SUBSCRIPTION_ROAMING = new SubscriptionInfo(0, "", 0,
TEST_CARRIER, TEST_CARRIER, NAME_SOURCE_DEFAULT_SOURCE, 0xFFFFFF, "",
DATA_ROAMING_ENABLE, null, null, null, null, false, null, "");
@@ -285,6 +295,65 @@
}
@Test
+ public void testCarrierText_noTextOnReadySimWhenNull() {
+ reset(mCarrierTextCallback);
+ List<SubscriptionInfo> list = new ArrayList<>();
+ list.add(TEST_SUBSCRIPTION_NULL);
+ when(mKeyguardUpdateMonitor.getSimState(anyInt())).thenReturn(IccCardConstants.State.READY);
+ when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list);
+
+ mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
+
+ ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
+ ArgumentCaptor.forClass(
+ CarrierTextController.CarrierTextCallbackInfo.class);
+
+ mCarrierTextController.updateCarrierText();
+ mTestableLooper.processAllMessages();
+ verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
+
+ assertTrue("Carrier text should be empty, instead it's " + captor.getValue().carrierText,
+ TextUtils.isEmpty(captor.getValue().carrierText));
+ assertFalse("No SIM should be available", captor.getValue().anySimReady);
+ }
+
+ @Test
+ public void testCarrierText_noTextOnReadySimWhenNull_airplaneMode_wifiOn() {
+ Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 1);
+ reset(mCarrierTextCallback);
+ List<SubscriptionInfo> list = new ArrayList<>();
+ list.add(TEST_SUBSCRIPTION_NULL);
+ when(mKeyguardUpdateMonitor.getSimState(anyInt())).thenReturn(IccCardConstants.State.READY);
+ when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list);
+ mockWifi();
+
+ mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
+ ServiceState ss = mock(ServiceState.class);
+ when(ss.getDataRegState()).thenReturn(ServiceState.STATE_IN_SERVICE);
+ mKeyguardUpdateMonitor.mServiceStates.put(TEST_SUBSCRIPTION_NULL.getSubscriptionId(), ss);
+
+ ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
+ ArgumentCaptor.forClass(
+ CarrierTextController.CarrierTextCallbackInfo.class);
+
+ mCarrierTextController.updateCarrierText();
+ mTestableLooper.processAllMessages();
+ verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
+
+ assertFalse("No SIM should be available", captor.getValue().anySimReady);
+ // There's no airplane mode if at least one SIM is State.READY and there's wifi
+ assertFalse("Device should not be in airplane mode", captor.getValue().airplaneMode);
+ assertNotEquals(AIRPLANE_MODE_TEXT, captor.getValue().carrierText);
+ }
+
+ private void mockWifi() {
+ when(mWifiManager.isWifiEnabled()).thenReturn(true);
+ WifiInfo wifiInfo = mock(WifiInfo.class);
+ when(wifiInfo.getBSSID()).thenReturn("");
+ when(mWifiManager.getConnectionInfo()).thenReturn(wifiInfo);
+ }
+
+ @Test
public void testCreateInfo_noSubscriptions() {
reset(mCarrierTextCallback);
when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockAccessibilityDelegateTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockAccessibilityDelegateTest.java
index dcafa72..00f88bf 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockAccessibilityDelegateTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockAccessibilityDelegateTest.java
@@ -27,6 +27,7 @@
import androidx.test.filters.SmallTest;
+import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
import org.junit.Before;
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchTest.java
index f01c0b4..de7664c 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchTest.java
@@ -39,6 +39,7 @@
import android.widget.TextClock;
import com.android.keyguard.clock.ClockManager;
+import com.android.systemui.R;
import com.android.systemui.SystemUIFactory;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.plugins.ClockPlugin;
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPatternViewTest.kt b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPatternViewTest.kt
index 5f03bdb..42a8950 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPatternViewTest.kt
+++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPatternViewTest.kt
@@ -21,6 +21,7 @@
import android.testing.TestableLooper
import android.view.LayoutInflater
+import com.android.systemui.R
import com.android.systemui.SysuiTestCase
import com.android.systemui.statusbar.policy.ConfigurationController
import com.google.common.truth.Truth.assertThat
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinBasedInputViewTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinBasedInputViewTest.java
index eadb1b6..202fbd7 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinBasedInputViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinBasedInputViewTest.java
@@ -28,6 +28,7 @@
import androidx.test.filters.SmallTest;
+import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
import org.junit.Before;
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerTest.java
index 8db195a..d47fcee 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerTest.java
@@ -23,6 +23,7 @@
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
+import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
import org.junit.Test;
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSliceViewTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSliceViewTest.java
index b3accbc..116f8fc 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSliceViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSliceViewTest.java
@@ -27,6 +27,7 @@
import androidx.slice.SliceSpecs;
import androidx.slice.builders.ListBuilder;
+import com.android.systemui.R;
import com.android.systemui.SystemUIFactory;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.keyguard.KeyguardSliceProvider;
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewTest.java
index 31ea39c..87f2ef5 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewTest.java
@@ -24,6 +24,7 @@
import android.testing.TestableLooper.RunWithLooper;
import android.view.LayoutInflater;
+import com.android.systemui.R;
import com.android.systemui.SystemUIFactory;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.util.Assert;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/DependencyTest.java b/packages/SystemUI/tests/src/com/android/systemui/DependencyTest.java
index b1ca169..b9d09ce 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/DependencyTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/DependencyTest.java
@@ -74,6 +74,6 @@
@Test
public void testInitDependency() {
Dependency.clearDependencies();
- Dependency.initDependencies(mContext);
+ Dependency.initDependencies(SystemUIFactory.getInstance().getRootComponent());
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/IconPackOverlayTest.java b/packages/SystemUI/tests/src/com/android/systemui/IconPackOverlayTest.java
index ccc9afc..0fa7443 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/IconPackOverlayTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/IconPackOverlayTest.java
@@ -32,6 +32,7 @@
import androidx.test.runner.AndroidJUnit4;
import com.android.internal.util.XmlUtils;
+import com.android.systemui.tests.R;
import org.junit.After;
import org.junit.Before;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/TestableDependency.java b/packages/SystemUI/tests/src/com/android/systemui/TestableDependency.java
index 18bf75e..0c53b03 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/TestableDependency.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/TestableDependency.java
@@ -25,10 +25,6 @@
private final ArraySet<Object> mInstantiatedObjects = new ArraySet<>();
public TestableDependency(Context context) {
- if (context instanceof SysuiTestableContext) {
- mComponents = ((SysuiTestableContext) context).getComponents();
- }
- mContext = context;
SystemUIFactory.createFromConfig(context);
SystemUIFactory.getInstance().getRootComponent()
.createDependency()
diff --git a/packages/SystemUI/tests/src/com/android/systemui/assist/AssistHandleBehaviorControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/assist/AssistHandleBehaviorControllerTest.java
index a583b1c..20983fc 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/assist/AssistHandleBehaviorControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/assist/AssistHandleBehaviorControllerTest.java
@@ -37,10 +37,12 @@
import com.android.internal.app.AssistUtils;
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
+import com.android.systemui.DumpController;
import com.android.systemui.ScreenDecorations;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.recents.OverviewProxyService;
+import com.android.systemui.statusbar.phone.NavigationModeController;
import org.junit.After;
import org.junit.Before;
@@ -50,6 +52,9 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import java.util.EnumMap;
+import java.util.Map;
+
@SmallTest
@RunWith(AndroidTestingRunner.class)
@RunWithLooper
@@ -63,7 +68,12 @@
@Mock private AssistUtils mMockAssistUtils;
@Mock private Handler mMockHandler;
@Mock private PhenotypeHelper mMockPhenotypeHelper;
- @Mock private AssistHandleBehaviorController.BehaviorController mMockBehaviorController;
+ @Mock private AssistHandleOffBehavior mMockOffBehavior;
+ @Mock private AssistHandleLikeHomeBehavior mMockLikeHomeBehavior;
+ @Mock private AssistHandleReminderExpBehavior mMockReminderExpBehavior;
+ @Mock private AssistHandleBehaviorController.BehaviorController mMockTestBehavior;
+ @Mock private NavigationModeController mMockNavigationModeController;
+ @Mock private DumpController mMockDumpController;
@Before
public void setup() {
@@ -74,13 +84,23 @@
doAnswer(answerVoid(Runnable::run)).when(mMockHandler)
.postDelayed(any(Runnable.class), anyLong());
+ Map<AssistHandleBehavior, AssistHandleBehaviorController.BehaviorController> behaviorMap =
+ new EnumMap<>(AssistHandleBehavior.class);
+ behaviorMap.put(AssistHandleBehavior.OFF, mMockOffBehavior);
+ behaviorMap.put(AssistHandleBehavior.LIKE_HOME, mMockLikeHomeBehavior);
+ behaviorMap.put(AssistHandleBehavior.REMINDER_EXP, mMockReminderExpBehavior);
+ behaviorMap.put(AssistHandleBehavior.TEST, mMockTestBehavior);
+
mAssistHandleBehaviorController =
new AssistHandleBehaviorController(
mContext,
mMockAssistUtils,
- mMockHandler, () -> mMockScreenDecorations,
+ mMockHandler,
+ () -> mMockScreenDecorations,
mMockPhenotypeHelper,
- mMockBehaviorController);
+ behaviorMap,
+ mMockNavigationModeController,
+ mMockDumpController);
}
@After
@@ -314,8 +334,8 @@
mAssistHandleBehaviorController.setBehavior(AssistHandleBehavior.TEST);
// Assert
- verify(mMockBehaviorController).onModeActivated(mContext, mAssistHandleBehaviorController);
- verifyNoMoreInteractions(mMockBehaviorController);
+ verify(mMockTestBehavior).onModeActivated(mContext, mAssistHandleBehaviorController);
+ verifyNoMoreInteractions(mMockTestBehavior);
}
@Test
@@ -324,14 +344,14 @@
when(mMockAssistUtils.getAssistComponentForUser(anyInt())).thenReturn(COMPONENT_NAME);
mAssistHandleBehaviorController.setBehavior(AssistHandleBehavior.TEST);
mAssistHandleBehaviorController.setInGesturalModeForTest(true);
- reset(mMockBehaviorController);
+ reset(mMockTestBehavior);
// Act
mAssistHandleBehaviorController.setBehavior(AssistHandleBehavior.OFF);
// Assert
- verify(mMockBehaviorController).onModeDeactivated();
- verifyNoMoreInteractions(mMockBehaviorController);
+ verify(mMockTestBehavior).onModeDeactivated();
+ verifyNoMoreInteractions(mMockTestBehavior);
}
@Test
@@ -344,6 +364,6 @@
mAssistHandleBehaviorController.setBehavior(AssistHandleBehavior.TEST);
// Assert
- verifyNoMoreInteractions(mMockBehaviorController);
+ verifyNoMoreInteractions(mMockTestBehavior);
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/assist/AssistHandleLikeHomeBehaviorTest.java b/packages/SystemUI/tests/src/com/android/systemui/assist/AssistHandleLikeHomeBehaviorTest.java
new file mode 100644
index 0000000..21ef640
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/assist/AssistHandleLikeHomeBehaviorTest.java
@@ -0,0 +1,365 @@
+/*
+ * 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.
+ */
+
+package com.android.systemui.assist;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
+
+import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper;
+
+import androidx.test.filters.SmallTest;
+
+import com.android.systemui.SysuiTestCase;
+import com.android.systemui.keyguard.WakefulnessLifecycle;
+import com.android.systemui.plugins.statusbar.StatusBarStateController;
+import com.android.systemui.recents.OverviewProxyService;
+import com.android.systemui.shared.system.QuickStepContract;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+@SmallTest
+@RunWith(AndroidTestingRunner.class)
+@TestableLooper.RunWithLooper
+public class AssistHandleLikeHomeBehaviorTest extends SysuiTestCase {
+
+ private AssistHandleLikeHomeBehavior mAssistHandleLikeHomeBehavior;
+
+ @Mock private StatusBarStateController mMockStatusBarStateController;
+ @Mock private WakefulnessLifecycle mMockWakefulnessLifecycle;
+ @Mock private OverviewProxyService mMockOverviewProxyService;
+ @Mock private AssistHandleCallbacks mMockAssistHandleCallbacks;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ mAssistHandleLikeHomeBehavior = new AssistHandleLikeHomeBehavior(
+ () -> mMockStatusBarStateController,
+ () -> mMockWakefulnessLifecycle,
+ () -> mMockOverviewProxyService);
+ }
+
+ @Test
+ public void onModeActivated_beginsObserving() {
+ // Arrange
+
+ // Act
+ mAssistHandleLikeHomeBehavior.onModeActivated(mContext, mMockAssistHandleCallbacks);
+
+ // Assert
+ verify(mMockStatusBarStateController).isDozing();
+ verify(mMockStatusBarStateController).addCallback(
+ any(StatusBarStateController.StateListener.class));
+ verify(mMockWakefulnessLifecycle).getWakefulness();
+ verify(mMockWakefulnessLifecycle).addObserver(any(WakefulnessLifecycle.Observer.class));
+ verify(mMockOverviewProxyService).addCallback(any(
+ OverviewProxyService.OverviewProxyListener.class));
+ verifyNoMoreInteractions(mMockWakefulnessLifecycle, mMockOverviewProxyService);
+ }
+
+ @Test
+ public void onModeActivated_showsHandlesWhenFullyAwake() {
+ // Arrange
+ when(mMockStatusBarStateController.isDozing()).thenReturn(false);
+ when(mMockWakefulnessLifecycle.getWakefulness())
+ .thenReturn(WakefulnessLifecycle.WAKEFULNESS_AWAKE);
+
+ // Act
+ mAssistHandleLikeHomeBehavior.onModeActivated(mContext, mMockAssistHandleCallbacks);
+
+ // Assert
+ verify(mMockAssistHandleCallbacks).showAndStay();
+ verifyNoMoreInteractions(mMockAssistHandleCallbacks);
+ }
+
+ @Test
+ public void onModeActivated_hidesHandlesWhenNotAwake() {
+ // Arrange
+ when(mMockStatusBarStateController.isDozing()).thenReturn(true);
+ when(mMockWakefulnessLifecycle.getWakefulness())
+ .thenReturn(WakefulnessLifecycle.WAKEFULNESS_ASLEEP);
+
+ // Act
+ mAssistHandleLikeHomeBehavior.onModeActivated(mContext, mMockAssistHandleCallbacks);
+
+ // Assert
+ verify(mMockAssistHandleCallbacks).hide();
+ verifyNoMoreInteractions(mMockAssistHandleCallbacks);
+ }
+
+ @Test
+ public void onModeActivated_hidesHandlesWhenDozing() {
+ // Arrange
+ when(mMockStatusBarStateController.isDozing()).thenReturn(true);
+ when(mMockWakefulnessLifecycle.getWakefulness())
+ .thenReturn(WakefulnessLifecycle.WAKEFULNESS_AWAKE);
+
+ // Act
+ mAssistHandleLikeHomeBehavior.onModeActivated(mContext, mMockAssistHandleCallbacks);
+
+ // Assert
+ verify(mMockAssistHandleCallbacks).hide();
+ verifyNoMoreInteractions(mMockAssistHandleCallbacks);
+ }
+
+ @Test
+ public void onModeDeactivated_stopsObserving() {
+ // Arrange
+ mAssistHandleLikeHomeBehavior.onModeActivated(mContext, mMockAssistHandleCallbacks);
+ ArgumentCaptor<StatusBarStateController.StateListener> stateListener =
+ ArgumentCaptor.forClass(StatusBarStateController.StateListener.class);
+ ArgumentCaptor<WakefulnessLifecycle.Observer> observer =
+ ArgumentCaptor.forClass(WakefulnessLifecycle.Observer.class);
+ ArgumentCaptor<OverviewProxyService.OverviewProxyListener> overviewProxyListener =
+ ArgumentCaptor.forClass(OverviewProxyService.OverviewProxyListener.class);
+ verify(mMockStatusBarStateController).addCallback(stateListener.capture());
+ verify(mMockWakefulnessLifecycle).addObserver(observer.capture());
+ verify(mMockOverviewProxyService).addCallback(overviewProxyListener.capture());
+ reset(
+ mMockStatusBarStateController,
+ mMockWakefulnessLifecycle,
+ mMockOverviewProxyService,
+ mMockAssistHandleCallbacks);
+
+ // Act
+ mAssistHandleLikeHomeBehavior.onModeDeactivated();
+
+ // Assert
+ verify(mMockStatusBarStateController).removeCallback(eq(stateListener.getValue()));
+ verify(mMockWakefulnessLifecycle).removeObserver(eq(observer.getValue()));
+ verify(mMockOverviewProxyService).removeCallback(eq(overviewProxyListener.getValue()));
+ verifyNoMoreInteractions(
+ mMockStatusBarStateController,
+ mMockWakefulnessLifecycle,
+ mMockOverviewProxyService,
+ mMockAssistHandleCallbacks);
+ }
+
+ @Test
+ public void onAssistantGesturePerformed_doesNothing() {
+ // Arrange
+ mAssistHandleLikeHomeBehavior.onModeActivated(mContext, mMockAssistHandleCallbacks);
+ reset(
+ mMockStatusBarStateController,
+ mMockWakefulnessLifecycle,
+ mMockOverviewProxyService,
+ mMockAssistHandleCallbacks);
+
+ // Act
+ mAssistHandleLikeHomeBehavior.onAssistantGesturePerformed();
+
+ // Assert
+ verifyNoMoreInteractions(
+ mMockStatusBarStateController,
+ mMockWakefulnessLifecycle,
+ mMockOverviewProxyService,
+ mMockAssistHandleCallbacks);
+ }
+
+ @Test
+ public void onAssistHandlesRequested_doesNothing() {
+ // Arrange
+ mAssistHandleLikeHomeBehavior.onModeActivated(mContext, mMockAssistHandleCallbacks);
+ reset(
+ mMockStatusBarStateController,
+ mMockWakefulnessLifecycle,
+ mMockOverviewProxyService,
+ mMockAssistHandleCallbacks);
+
+ // Act
+ mAssistHandleLikeHomeBehavior.onAssistHandlesRequested();
+
+ // Assert
+ verifyNoMoreInteractions(
+ mMockStatusBarStateController,
+ mMockWakefulnessLifecycle,
+ mMockOverviewProxyService,
+ mMockAssistHandleCallbacks);
+ }
+
+ @Test
+ public void onBothAwakeAndUnDoze_handlesShow() {
+ // Arrange
+ when(mMockStatusBarStateController.isDozing()).thenReturn(true);
+ when(mMockWakefulnessLifecycle.getWakefulness())
+ .thenReturn(WakefulnessLifecycle.WAKEFULNESS_ASLEEP);
+ ArgumentCaptor<StatusBarStateController.StateListener> stateListener =
+ ArgumentCaptor.forClass(StatusBarStateController.StateListener.class);
+ ArgumentCaptor<WakefulnessLifecycle.Observer> observer =
+ ArgumentCaptor.forClass(WakefulnessLifecycle.Observer.class);
+ mAssistHandleLikeHomeBehavior.onModeActivated(mContext, mMockAssistHandleCallbacks);
+ verify(mMockStatusBarStateController).addCallback(stateListener.capture());
+ verify(mMockWakefulnessLifecycle).addObserver(observer.capture());
+ reset(
+ mMockStatusBarStateController,
+ mMockWakefulnessLifecycle,
+ mMockOverviewProxyService,
+ mMockAssistHandleCallbacks);
+
+ // Act
+ observer.getValue().onFinishedWakingUp();
+
+ // Assert
+ verify(mMockAssistHandleCallbacks).hide();
+ verifyNoMoreInteractions(
+ mMockStatusBarStateController,
+ mMockWakefulnessLifecycle,
+ mMockOverviewProxyService,
+ mMockAssistHandleCallbacks);
+
+ // Arrange
+ observer.getValue().onFinishedGoingToSleep();
+ reset(mMockAssistHandleCallbacks);
+
+ // Act
+ stateListener.getValue().onDozingChanged(false);
+
+ // Assert
+ verify(mMockAssistHandleCallbacks).hide();
+ verifyNoMoreInteractions(
+ mMockStatusBarStateController,
+ mMockWakefulnessLifecycle,
+ mMockOverviewProxyService,
+ mMockAssistHandleCallbacks);
+
+ // Act
+ observer.getValue().onFinishedWakingUp();
+
+ // Assert
+ verify(mMockAssistHandleCallbacks).showAndStay();
+ verifyNoMoreInteractions(
+ mMockStatusBarStateController,
+ mMockWakefulnessLifecycle,
+ mMockOverviewProxyService,
+ mMockAssistHandleCallbacks);
+ }
+
+ @Test
+ public void onSleepOrDoze_handlesHide() {
+ // Arrange
+ when(mMockStatusBarStateController.isDozing()).thenReturn(false);
+ when(mMockWakefulnessLifecycle.getWakefulness())
+ .thenReturn(WakefulnessLifecycle.WAKEFULNESS_AWAKE);
+ ArgumentCaptor<StatusBarStateController.StateListener> stateListener =
+ ArgumentCaptor.forClass(StatusBarStateController.StateListener.class);
+ ArgumentCaptor<WakefulnessLifecycle.Observer> observer =
+ ArgumentCaptor.forClass(WakefulnessLifecycle.Observer.class);
+ mAssistHandleLikeHomeBehavior.onModeActivated(mContext, mMockAssistHandleCallbacks);
+ verify(mMockStatusBarStateController).addCallback(stateListener.capture());
+ verify(mMockWakefulnessLifecycle).addObserver(observer.capture());
+ reset(
+ mMockStatusBarStateController,
+ mMockWakefulnessLifecycle,
+ mMockOverviewProxyService,
+ mMockAssistHandleCallbacks);
+
+ // Act
+ observer.getValue().onStartedGoingToSleep();
+
+ // Assert
+ verify(mMockAssistHandleCallbacks).hide();
+ verifyNoMoreInteractions(
+ mMockStatusBarStateController,
+ mMockWakefulnessLifecycle,
+ mMockOverviewProxyService,
+ mMockAssistHandleCallbacks);
+
+ // Arrange
+ observer.getValue().onFinishedWakingUp();
+ reset(mMockAssistHandleCallbacks);
+
+ // Act
+ stateListener.getValue().onDozingChanged(true);
+
+ // Assert
+ verify(mMockAssistHandleCallbacks).hide();
+ verifyNoMoreInteractions(
+ mMockStatusBarStateController,
+ mMockWakefulnessLifecycle,
+ mMockOverviewProxyService,
+ mMockAssistHandleCallbacks);
+ }
+
+ @Test
+ public void onHomeHandleHide_handlesHide() {
+ // Arrange
+ when(mMockStatusBarStateController.isDozing()).thenReturn(false);
+ when(mMockWakefulnessLifecycle.getWakefulness())
+ .thenReturn(WakefulnessLifecycle.WAKEFULNESS_AWAKE);
+ ArgumentCaptor<OverviewProxyService.OverviewProxyListener> sysUiStateCallback =
+ ArgumentCaptor.forClass(OverviewProxyService.OverviewProxyListener.class);
+ mAssistHandleLikeHomeBehavior.onModeActivated(mContext, mMockAssistHandleCallbacks);
+ verify(mMockOverviewProxyService).addCallback(sysUiStateCallback.capture());
+ reset(
+ mMockStatusBarStateController,
+ mMockWakefulnessLifecycle,
+ mMockOverviewProxyService,
+ mMockAssistHandleCallbacks);
+
+ // Act
+ sysUiStateCallback.getValue().onSystemUiStateChanged(
+ QuickStepContract.SYSUI_STATE_NAV_BAR_HIDDEN);
+
+ // Assert
+ verify(mMockAssistHandleCallbacks).hide();
+ verifyNoMoreInteractions(
+ mMockStatusBarStateController,
+ mMockWakefulnessLifecycle,
+ mMockOverviewProxyService,
+ mMockAssistHandleCallbacks);
+ }
+
+ @Test
+ public void onHomeHandleUnhide_handlesShow() {
+ // Arrange
+ when(mMockStatusBarStateController.isDozing()).thenReturn(false);
+ when(mMockWakefulnessLifecycle.getWakefulness())
+ .thenReturn(WakefulnessLifecycle.WAKEFULNESS_AWAKE);
+ ArgumentCaptor<OverviewProxyService.OverviewProxyListener> sysUiStateCallback =
+ ArgumentCaptor.forClass(OverviewProxyService.OverviewProxyListener.class);
+ mAssistHandleLikeHomeBehavior.onModeActivated(mContext, mMockAssistHandleCallbacks);
+ verify(mMockOverviewProxyService).addCallback(sysUiStateCallback.capture());
+ sysUiStateCallback.getValue().onSystemUiStateChanged(
+ QuickStepContract.SYSUI_STATE_NAV_BAR_HIDDEN);
+ reset(
+ mMockStatusBarStateController,
+ mMockWakefulnessLifecycle,
+ mMockOverviewProxyService,
+ mMockAssistHandleCallbacks);
+
+ // Act
+ sysUiStateCallback.getValue().onSystemUiStateChanged(
+ ~QuickStepContract.SYSUI_STATE_NAV_BAR_HIDDEN);
+
+ // Assert
+ verify(mMockAssistHandleCallbacks).showAndStay();
+ verifyNoMoreInteractions(
+ mMockStatusBarStateController,
+ mMockWakefulnessLifecycle,
+ mMockOverviewProxyService,
+ mMockAssistHandleCallbacks);
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/assist/AssistHandleOffBehaviorTest.java b/packages/SystemUI/tests/src/com/android/systemui/assist/AssistHandleOffBehaviorTest.java
new file mode 100644
index 0000000..15d4d5b
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/assist/AssistHandleOffBehaviorTest.java
@@ -0,0 +1,101 @@
+/*
+ * 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.
+ */
+
+package com.android.systemui.assist;
+
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+
+import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper;
+
+import androidx.test.filters.SmallTest;
+
+import com.android.systemui.SysuiTestCase;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+@SmallTest
+@RunWith(AndroidTestingRunner.class)
+@TestableLooper.RunWithLooper
+public class AssistHandleOffBehaviorTest extends SysuiTestCase {
+
+ private AssistHandleOffBehavior mAssistHandleOffBehavior;
+
+ @Mock private AssistHandleCallbacks mMockAssistHandleCallbacks;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ mAssistHandleOffBehavior = new AssistHandleOffBehavior();
+ }
+
+ @Test
+ public void onModeActivated_hidesHandles() {
+ // Arrange
+
+ // Act
+ mAssistHandleOffBehavior.onModeActivated(mContext, mMockAssistHandleCallbacks);
+
+ // Assert
+ verify(mMockAssistHandleCallbacks).hide();
+ verifyNoMoreInteractions(mMockAssistHandleCallbacks);
+ }
+
+ @Test
+ public void onModeDeactivated_doesNothing() {
+ // Arrange
+ mAssistHandleOffBehavior.onModeActivated(mContext, mMockAssistHandleCallbacks);
+ reset(mMockAssistHandleCallbacks);
+
+ // Act
+ mAssistHandleOffBehavior.onModeDeactivated();
+
+ // Assert
+ verifyNoMoreInteractions(mMockAssistHandleCallbacks);
+ }
+
+ @Test
+ public void onAssistantGesturePerformed_doesNothing() {
+ // Arrange
+ mAssistHandleOffBehavior.onModeActivated(mContext, mMockAssistHandleCallbacks);
+ reset(mMockAssistHandleCallbacks);
+
+ // Act
+ mAssistHandleOffBehavior.onAssistantGesturePerformed();
+
+ // Assert
+ verifyNoMoreInteractions(mMockAssistHandleCallbacks);
+ }
+
+ @Test
+ public void onAssistHandlesRequested_doesNothing() {
+ // Arrange
+ mAssistHandleOffBehavior.onModeActivated(mContext, mMockAssistHandleCallbacks);
+ reset(mMockAssistHandleCallbacks);
+
+ // Act
+ mAssistHandleOffBehavior.onAssistHandlesRequested();
+
+ // Assert
+ verifyNoMoreInteractions(mMockAssistHandleCallbacks);
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java
index 2221915..ba434d4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java
@@ -17,7 +17,6 @@
package com.android.systemui.bubbles;
import static android.app.Notification.FLAG_BUBBLE;
-import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static android.service.notification.NotificationListenerService.REASON_APP_CANCEL;
import static android.service.notification.NotificationListenerService.REASON_CANCEL;
import static android.service.notification.NotificationListenerService.REASON_CANCEL_ALL;
@@ -28,6 +27,8 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
@@ -42,11 +43,10 @@
import android.app.IActivityManager;
import android.app.Notification;
import android.app.PendingIntent;
-import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
-import android.content.IntentFilter;
import android.graphics.drawable.Icon;
+import android.hardware.face.FaceManager;
import android.service.notification.ZenModeConfig;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
@@ -57,17 +57,21 @@
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
+import com.android.systemui.plugins.statusbar.StatusBarStateController;
+import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationPresenter;
import com.android.systemui.statusbar.NotificationRemoveInterceptor;
import com.android.systemui.statusbar.NotificationTestHelper;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.notification.NotificationEntryListener;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
+import com.android.systemui.statusbar.notification.NotificationFilter;
import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider;
import com.android.systemui.statusbar.notification.collection.NotificationData;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.phone.DozeParameters;
+import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.StatusBarWindowController;
import com.android.systemui.statusbar.policy.ConfigurationController;
@@ -82,20 +86,16 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
@SmallTest
@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
public class BubbleControllerTest extends SysuiTestCase {
- // Some APIs rely on the app being foreground, check is via pkg name
- private static final String FOREGROUND_TEST_PKG_NAME = "com.android.systemui.tests";
-
@Mock
private NotificationEntryManager mNotificationEntryManager;
@Mock
+ private NotificationGroupManager mNotificationGroupManager;
+ @Mock
private WindowManager mWindowManager;
@Mock
private IActivityManager mActivityManager;
@@ -108,6 +108,10 @@
@Mock
private ZenModeConfig mZenModeConfig;
@Mock
+ private FaceManager mFaceManager;
+ @Mock
+ private NotificationLockscreenUserManager mLockscreenUserManager;
+ @Mock
private SysuiStatusBarStateController mStatusBarStateController;
@Mock
private KeyguardBypassController mKeyguardBypassController;
@@ -126,8 +130,6 @@
private NotificationTestHelper mNotificationTestHelper;
private ExpandableNotificationRow mRow;
private ExpandableNotificationRow mRow2;
- private ExpandableNotificationRow mAutoExpandRow;
- private ExpandableNotificationRow mSuppressNotifRow;
private ExpandableNotificationRow mNonBubbleNotifRow;
@Mock
@@ -146,6 +148,7 @@
MockitoAnnotations.initMocks(this);
mStatusBarView = new FrameLayout(mContext);
mDependency.injectTestDependency(NotificationEntryManager.class, mNotificationEntryManager);
+ mContext.addMockSystemService(FaceManager.class, mFaceManager);
// Bubbles get added to status bar window view
mStatusBarWindowController = new StatusBarWindowController(mContext, mWindowManager,
@@ -159,35 +162,31 @@
mRow2 = mNotificationTestHelper.createBubble(mDeleteIntent);
mNonBubbleNotifRow = mNotificationTestHelper.createRow();
- // Some bubbles want to auto expand
- Notification.BubbleMetadata autoExpandMetadata =
- getBuilder().setAutoExpandBubble(true).build();
- mAutoExpandRow = mNotificationTestHelper.createBubble(autoExpandMetadata,
- FOREGROUND_TEST_PKG_NAME);
-
- // Some bubbles want to suppress notifs
- Notification.BubbleMetadata suppressNotifMetadata =
- getBuilder().setSuppressNotification(true).build();
- mSuppressNotifRow = mNotificationTestHelper.createBubble(suppressNotifMetadata,
- FOREGROUND_TEST_PKG_NAME);
-
// Return non-null notification data from the NEM
when(mNotificationEntryManager.getNotificationData()).thenReturn(mNotificationData);
+ when(mNotificationData.get(mRow.getEntry().key)).thenReturn(mRow.getEntry());
when(mNotificationData.getChannel(mRow.getEntry().key)).thenReturn(mRow.getEntry().channel);
mZenModeConfig.suppressedVisualEffects = 0;
when(mZenModeController.getConfig()).thenReturn(mZenModeConfig);
TestableNotificationInterruptionStateProvider interruptionStateProvider =
- new TestableNotificationInterruptionStateProvider(mContext);
+ new TestableNotificationInterruptionStateProvider(mContext,
+ mock(NotificationFilter.class),
+ mock(StatusBarStateController.class));
interruptionStateProvider.setUpWithPresenter(
mock(NotificationPresenter.class),
mock(HeadsUpManager.class),
mock(NotificationInterruptionStateProvider.HeadsUpSuppressor.class));
mBubbleData = new BubbleData(mContext);
- mBubbleController = new TestableBubbleController(mContext, mStatusBarWindowController,
- mBubbleData, mConfigurationController, interruptionStateProvider,
- mZenModeController);
+ mBubbleController = new TestableBubbleController(mContext,
+ mStatusBarWindowController,
+ mBubbleData,
+ mConfigurationController,
+ interruptionStateProvider,
+ mZenModeController,
+ mLockscreenUserManager,
+ mNotificationGroupManager);
mBubbleController.setBubbleStateChangeListener(mBubbleStateChangeListener);
mBubbleController.setExpandListener(mBubbleExpandListener);
@@ -219,13 +218,14 @@
@Test
public void testRemoveBubble() {
mBubbleController.updateBubble(mRow.getEntry());
+ assertNotNull(mBubbleData.getBubbleWithKey(mRow.getEntry().key));
assertTrue(mBubbleController.hasBubbles());
verify(mNotificationEntryManager).updateNotifications();
verify(mBubbleStateChangeListener).onHasBubblesChanged(true);
mBubbleController.removeBubble(mRow.getEntry().key, BubbleController.DISMISS_USER_GESTURE);
assertFalse(mStatusBarWindowController.getBubblesShowing());
- assertTrue(mRow.getEntry().isBubbleDismissed());
+ assertNull(mBubbleData.getBubbleWithKey(mRow.getEntry().key));
verify(mNotificationEntryManager, times(2)).updateNotifications();
verify(mBubbleStateChangeListener).onHasBubblesChanged(false);
}
@@ -236,10 +236,10 @@
mBubbleController.updateBubble(mRow.getEntry());
assertTrue(mBubbleController.hasBubbles());
- assertTrue(mRow.getEntry().showInShadeWhenBubble());
+ assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key));
// Make it look like dismissed notif
- mRow.getEntry().setShowInShadeWhenBubble(false);
+ mBubbleData.getBubbleWithKey(mRow.getEntry().key).setShowInShadeWhenBubble(false);
// Now remove the bubble
mBubbleController.removeBubble(mRow.getEntry().key, BubbleController.DISMISS_USER_GESTURE);
@@ -255,15 +255,17 @@
public void testDismissStack() {
mBubbleController.updateBubble(mRow.getEntry());
verify(mNotificationEntryManager, times(1)).updateNotifications();
+ assertNotNull(mBubbleData.getBubbleWithKey(mRow.getEntry().key));
mBubbleController.updateBubble(mRow2.getEntry());
verify(mNotificationEntryManager, times(2)).updateNotifications();
+ assertNotNull(mBubbleData.getBubbleWithKey(mRow2.getEntry().key));
assertTrue(mBubbleController.hasBubbles());
mBubbleController.dismissStack(BubbleController.DISMISS_USER_GESTURE);
assertFalse(mStatusBarWindowController.getBubblesShowing());
verify(mNotificationEntryManager, times(3)).updateNotifications();
- assertTrue(mRow.getEntry().isBubbleDismissed());
- assertTrue(mRow2.getEntry().isBubbleDismissed());
+ assertNull(mBubbleData.getBubbleWithKey(mRow.getEntry().key));
+ assertNull(mBubbleData.getBubbleWithKey(mRow2.getEntry().key));
}
@Test
@@ -274,9 +276,9 @@
mEntryListener.onPendingEntryAdded(mRow.getEntry());
mBubbleController.updateBubble(mRow.getEntry());
- // We should have bubbles & their notifs should show in the shade
+ // We should have bubbles & their notifs should not be suppressed
assertTrue(mBubbleController.hasBubbles());
- assertTrue(mRow.getEntry().showInShadeWhenBubble());
+ assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key));
assertFalse(mStatusBarWindowController.getBubbleExpanded());
// Expand the stack
@@ -286,8 +288,8 @@
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().key);
assertTrue(mStatusBarWindowController.getBubbleExpanded());
- // Make sure it's no longer in the shade
- assertFalse(mRow.getEntry().showInShadeWhenBubble());
+ // Make sure the notif is suppressed
+ assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key));
// Collapse
mBubbleController.collapseStack();
@@ -304,10 +306,11 @@
mBubbleController.updateBubble(mRow.getEntry());
mBubbleController.updateBubble(mRow2.getEntry());
- // We should have bubbles & their notifs should show in the shade
+ // We should have bubbles & their notifs should not be suppressed
assertTrue(mBubbleController.hasBubbles());
- assertTrue(mRow.getEntry().showInShadeWhenBubble());
- assertTrue(mRow2.getEntry().showInShadeWhenBubble());
+ assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key));
+ assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade(
+ mRow2.getEntry().key));
// Expand
BubbleStackView stackView = mBubbleController.getStackView();
@@ -317,13 +320,13 @@
// Last added is the one that is expanded
assertEquals(mRow2.getEntry(), stackView.getExpandedBubbleView().getEntry());
- assertFalse(mRow2.getEntry().showInShadeWhenBubble());
+ assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow2.getEntry().key));
// Switch which bubble is expanded
mBubbleController.selectBubble(mRow.getEntry().key);
- stackView.setExpandedBubble(mRow.getEntry());
+ stackView.setExpandedBubble(mRow.getEntry().key);
assertEquals(mRow.getEntry(), stackView.getExpandedBubbleView().getEntry());
- assertFalse(mRow.getEntry().showInShadeWhenBubble());
+ assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key));
// collapse for previous bubble
verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow2.getEntry().key);
@@ -336,14 +339,37 @@
}
@Test
- public void testExpansionRemovesShowInShade() {
+ public void testExpansionRemovesShowInShadeAndDot() {
// Mark it as a bubble and add it explicitly
mEntryListener.onPendingEntryAdded(mRow.getEntry());
mBubbleController.updateBubble(mRow.getEntry());
- // We should have bubbles & their notifs should show in the shade
+ // We should have bubbles & their notifs should not be suppressed
assertTrue(mBubbleController.hasBubbles());
- assertTrue(mRow.getEntry().showInShadeWhenBubble());
+ assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key));
+ assertTrue(mBubbleData.getBubbleWithKey(mRow.getEntry().key).showBubbleDot());
+
+ // Expand
+ mBubbleController.expandStack();
+ assertTrue(mBubbleController.isStackExpanded());
+ verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().key);
+
+ // Notif is suppressed after expansion
+ assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key));
+ // Notif shouldn't show dot after expansion
+ assertFalse(mBubbleData.getBubbleWithKey(mRow.getEntry().key).showBubbleDot());
+ }
+
+ @Test
+ public void testUpdateWhileExpanded_DoesntChangeShowInShadeAndDot() {
+ // Mark it as a bubble and add it explicitly
+ mEntryListener.onPendingEntryAdded(mRow.getEntry());
+ mBubbleController.updateBubble(mRow.getEntry());
+
+ // We should have bubbles & their notifs should not be suppressed
+ assertTrue(mBubbleController.hasBubbles());
+ assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key));
+ assertTrue(mBubbleData.getBubbleWithKey(mRow.getEntry().key).showBubbleDot());
// Expand
BubbleStackView stackView = mBubbleController.getStackView();
@@ -351,8 +377,19 @@
assertTrue(mBubbleController.isStackExpanded());
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().key);
- // No longer show shade in notif after expansion
- assertFalse(mRow.getEntry().showInShadeWhenBubble());
+ // Notif is suppressed after expansion
+ assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key));
+ // Notif shouldn't show dot after expansion
+ assertFalse(mBubbleData.getBubbleWithKey(mRow.getEntry().key).showBubbleDot());
+
+ // Send update
+ mEntryListener.onPreEntryUpdated(mRow.getEntry());
+
+ // Nothing should have changed
+ // Notif is suppressed after expansion
+ assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key));
+ // Notif shouldn't show dot after expansion
+ assertFalse(mBubbleData.getBubbleWithKey(mRow.getEntry().key).showBubbleDot());
}
@Test
@@ -373,7 +410,7 @@
// Last added is the one that is expanded
assertEquals(mRow2.getEntry(), stackView.getExpandedBubbleView().getEntry());
- assertFalse(mRow2.getEntry().showInShadeWhenBubble());
+ assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow2.getEntry().key));
// Dismiss currently expanded
mBubbleController.removeBubble(stackView.getExpandedBubbleView().getKey(),
@@ -397,14 +434,16 @@
@Test
public void testAutoExpand_FailsNotForeground() {
assertFalse(mBubbleController.isStackExpanded());
+ setMetadataFlags(mRow.getEntry(),
+ Notification.BubbleMetadata.FLAG_AUTO_EXPAND_BUBBLE, false /* enableFlag */);
// Add the auto expand bubble
- mEntryListener.onPendingEntryAdded(mAutoExpandRow.getEntry());
- mBubbleController.updateBubble(mAutoExpandRow.getEntry());
+ mEntryListener.onPendingEntryAdded(mRow.getEntry());
+ mBubbleController.updateBubble(mRow.getEntry());
// Expansion shouldn't change
verify(mBubbleExpandListener, never()).onBubbleExpandChanged(false /* expanded */,
- mAutoExpandRow.getEntry().key);
+ mRow.getEntry().key);
assertFalse(mBubbleController.isStackExpanded());
// # of bubbles should change
@@ -413,91 +452,51 @@
@Test
public void testAutoExpand_SucceedsForeground() {
- final CountDownLatch latch = new CountDownLatch(1);
- BroadcastReceiver receiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- latch.countDown();
- }
- };
- IntentFilter filter = new IntentFilter(BubblesTestActivity.BUBBLE_ACTIVITY_OPENED);
- mContext.registerReceiver(receiver, filter);
-
- assertFalse(mBubbleController.isStackExpanded());
-
- // Make ourselves foreground
- Intent i = new Intent(mContext, BubblesTestActivity.class);
- i.setFlags(FLAG_ACTIVITY_NEW_TASK);
- mContext.startActivity(i);
-
- try {
- latch.await(100, TimeUnit.MILLISECONDS);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
+ setMetadataFlags(mRow.getEntry(),
+ Notification.BubbleMetadata.FLAG_AUTO_EXPAND_BUBBLE, true /* enableFlag */);
// Add the auto expand bubble
- mEntryListener.onPendingEntryAdded(mAutoExpandRow.getEntry());
- mBubbleController.updateBubble(mAutoExpandRow.getEntry());
+ mEntryListener.onPendingEntryAdded(mRow.getEntry());
+ mBubbleController.updateBubble(mRow.getEntry());
// Expansion should change
verify(mBubbleExpandListener).onBubbleExpandChanged(true /* expanded */,
- mAutoExpandRow.getEntry().key);
+ mRow.getEntry().key);
assertTrue(mBubbleController.isStackExpanded());
// # of bubbles should change
verify(mBubbleStateChangeListener).onHasBubblesChanged(true /* hasBubbles */);
- mContext.unregisterReceiver(receiver);
}
@Test
public void testSuppressNotif_FailsNotForeground() {
+ setMetadataFlags(mRow.getEntry(),
+ Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION, false /* enableFlag */);
+
// Add the suppress notif bubble
- mEntryListener.onPendingEntryAdded(mSuppressNotifRow.getEntry());
- mBubbleController.updateBubble(mSuppressNotifRow.getEntry());
+ mEntryListener.onPendingEntryAdded(mRow.getEntry());
+ mBubbleController.updateBubble(mRow.getEntry());
- // Should show in shade because we weren't forground
- assertTrue(mSuppressNotifRow.getEntry().showInShadeWhenBubble());
-
+ // Should not be suppressed because we weren't forground
+ assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key));
// # of bubbles should change
verify(mBubbleStateChangeListener).onHasBubblesChanged(true /* hasBubbles */);
}
@Test
public void testSuppressNotif_SucceedsForeground() {
- final CountDownLatch latch = new CountDownLatch(1);
- BroadcastReceiver receiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- latch.countDown();
- }
- };
- IntentFilter filter = new IntentFilter(BubblesTestActivity.BUBBLE_ACTIVITY_OPENED);
- mContext.registerReceiver(receiver, filter);
-
- assertFalse(mBubbleController.isStackExpanded());
-
- // Make ourselves foreground
- Intent i = new Intent(mContext, BubblesTestActivity.class);
- i.setFlags(FLAG_ACTIVITY_NEW_TASK);
- mContext.startActivity(i);
-
- try {
- latch.await(100, TimeUnit.MILLISECONDS);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
+ setMetadataFlags(mRow.getEntry(),
+ Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION, true /* enableFlag */);
// Add the suppress notif bubble
- mEntryListener.onPendingEntryAdded(mSuppressNotifRow.getEntry());
- mBubbleController.updateBubble(mSuppressNotifRow.getEntry());
+ mEntryListener.onPendingEntryAdded(mRow.getEntry());
+ mBubbleController.updateBubble(mRow.getEntry());
- // Should NOT show in shade because we were foreground
- assertFalse(mSuppressNotifRow.getEntry().showInShadeWhenBubble());
+ // Notif should be suppressed because we were foreground
+ assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key));
// # of bubbles should change
verify(mBubbleStateChangeListener).onHasBubblesChanged(true /* hasBubbles */);
- mContext.unregisterReceiver(receiver);
}
@Test
@@ -516,7 +515,8 @@
@Test
public void testMarkNewNotificationAsShowInShade() {
mEntryListener.onPendingEntryAdded(mRow.getEntry());
- assertTrue(mRow.getEntry().showInShadeWhenBubble());
+ assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key));
+ assertTrue(mBubbleData.getBubbleWithKey(mRow.getEntry().key).showBubbleDot());
}
@Test
@@ -584,7 +584,7 @@
mBubbleController.updateBubble(mRow.getEntry());
assertTrue(mBubbleController.hasBubbles());
- assertTrue(mRow.getEntry().showInShadeWhenBubble());
+ assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key));
boolean intercepted = mRemoveInterceptor.onNotificationRemoveRequested(
mRow.getEntry().key, REASON_CANCEL_ALL);
@@ -592,7 +592,7 @@
// Intercept!
assertTrue(intercepted);
// Should update show in shade state
- assertFalse(mRow.getEntry().showInShadeWhenBubble());
+ assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key));
verify(mNotificationEntryManager, never()).performRemoveNotification(
any(), anyInt());
@@ -605,7 +605,7 @@
mBubbleController.updateBubble(mRow.getEntry());
assertTrue(mBubbleController.hasBubbles());
- assertTrue(mRow.getEntry().showInShadeWhenBubble());
+ assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key));
boolean intercepted = mRemoveInterceptor.onNotificationRemoveRequested(
mRow.getEntry().key, REASON_CANCEL);
@@ -613,7 +613,7 @@
// Intercept!
assertTrue(intercepted);
// Should update show in shade state
- assertFalse(mRow.getEntry().showInShadeWhenBubble());
+ assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key));
verify(mNotificationEntryManager, never()).performRemoveNotification(
any(), anyInt());
@@ -626,7 +626,7 @@
mBubbleController.updateBubble(mRow.getEntry());
assertTrue(mBubbleController.hasBubbles());
- assertTrue(mRow.getEntry().showInShadeWhenBubble());
+ assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key));
// Dismiss the bubble
mBubbleController.removeBubble(mRow.getEntry().key, BubbleController.DISMISS_USER_GESTURE);
@@ -646,22 +646,21 @@
StatusBarWindowController statusBarWindowController, BubbleData data,
ConfigurationController configurationController,
NotificationInterruptionStateProvider interruptionStateProvider,
- ZenModeController zenModeController) {
+ ZenModeController zenModeController,
+ NotificationLockscreenUserManager lockscreenUserManager,
+ NotificationGroupManager groupManager) {
super(context, statusBarWindowController, data, Runnable::run,
- configurationController, interruptionStateProvider, zenModeController);
- }
-
- @Override
- public boolean shouldAutoBubbleForFlags(Context c, NotificationEntry entry) {
- return entry.notification.getNotification().getBubbleMetadata() != null;
+ configurationController, interruptionStateProvider, zenModeController,
+ lockscreenUserManager, groupManager);
}
}
- public static class TestableNotificationInterruptionStateProvider extends
+ static class TestableNotificationInterruptionStateProvider extends
NotificationInterruptionStateProvider {
- public TestableNotificationInterruptionStateProvider(Context context) {
- super(context);
+ TestableNotificationInterruptionStateProvider(Context context,
+ NotificationFilter filter, StatusBarStateController controller) {
+ super(context, filter, controller);
mUseHeadsUp = true;
}
}
@@ -676,4 +675,21 @@
.setIntent(bubbleIntent)
.setIcon(Icon.createWithResource(mContext, R.drawable.android));
}
+
+ /**
+ * Sets the bubble metadata flags for this entry. These flags are normally set by
+ * NotificationManagerService when the notification is sent, however, these tests do not
+ * go through that path so we set them explicitly when testing.
+ */
+ private void setMetadataFlags(NotificationEntry entry, int flag, boolean enableFlag) {
+ Notification.BubbleMetadata bubbleMetadata =
+ entry.notification.getNotification().getBubbleMetadata();
+ int flags = bubbleMetadata.getFlags();
+ if (enableFlag) {
+ flags |= flag;
+ } else {
+ flags &= ~flag;
+ }
+ bubbleMetadata.setFlags(flags);
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java
index 815a70a..f7d2743 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java
@@ -887,7 +887,7 @@
private void sendUpdatedEntryAtTime(NotificationEntry entry, long postTime) {
setPostTime(entry, postTime);
- mBubbleData.notificationEntryUpdated(entry);
+ mBubbleData.notificationEntryUpdated(entry, /* suppressFlyout=*/ false);
}
private void changeExpandedStateAtTime(boolean shouldBeExpanded, long time) {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleFlyoutViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleFlyoutViewTest.java
index 173237f..a8961a8 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleFlyoutViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleFlyoutViewTest.java
@@ -18,7 +18,6 @@
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotSame;
-import static junit.framework.Assert.assertTrue;
import static org.mockito.Mockito.verify;
@@ -46,6 +45,7 @@
public class BubbleFlyoutViewTest extends SysuiTestCase {
private BubbleFlyoutView mFlyout;
private TextView mFlyoutText;
+ private float[] mDotCenter = new float[2];
@Before
public void setUp() throws Exception {
@@ -53,20 +53,25 @@
mFlyout = new BubbleFlyoutView(getContext());
mFlyoutText = mFlyout.findViewById(R.id.bubble_flyout_text);
+ mDotCenter[0] = 30;
+ mDotCenter[1] = 30;
}
@Test
public void testShowFlyout_isVisible() {
- mFlyout.showFlyout("Hello", new PointF(100, 100), 500, true, Color.WHITE, null);
+ mFlyout.setupFlyoutStartingAsDot(
+ "Hello", new PointF(100, 100), 500, true, Color.WHITE, null, null, mDotCenter);
+ mFlyout.setVisibility(View.VISIBLE);
+
assertEquals("Hello", mFlyoutText.getText());
assertEquals(View.VISIBLE, mFlyout.getVisibility());
- assertEquals(1f, mFlyoutText.getAlpha(), .01f);
}
@Test
public void testFlyoutHide_runsCallback() {
Runnable after = Mockito.mock(Runnable.class);
- mFlyout.showFlyout("Hello", new PointF(100, 100), 500, true, Color.WHITE, after);
+ mFlyout.setupFlyoutStartingAsDot(
+ "Hello", new PointF(100, 100), 500, true, Color.WHITE, null, after, mDotCenter);
mFlyout.hideFlyout();
verify(after).run();
@@ -74,19 +79,16 @@
@Test
public void testSetCollapsePercent() {
- mFlyout.showFlyout("Hello", new PointF(100, 100), 500, true, Color.WHITE, null);
-
- float initialTranslationZ = mFlyout.getTranslationZ();
+ mFlyout.setupFlyoutStartingAsDot(
+ "Hello", new PointF(100, 100), 500, true, Color.WHITE, null, null, mDotCenter);
+ mFlyout.setVisibility(View.VISIBLE);
mFlyout.setCollapsePercent(1f);
assertEquals(0f, mFlyoutText.getAlpha(), 0.01f);
assertNotSame(0f, mFlyoutText.getTranslationX()); // Should have moved to collapse.
- assertTrue(mFlyout.getTranslationZ() < initialTranslationZ); // Should be descending.
mFlyout.setCollapsePercent(0f);
assertEquals(1f, mFlyoutText.getAlpha(), 0.01f);
assertEquals(0f, mFlyoutText.getTranslationX());
- assertEquals(initialTranslationZ, mFlyout.getTranslationZ());
-
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotificationEntryTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleTest.java
similarity index 83%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotificationEntryTest.java
rename to packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleTest.java
index cca9f28..e98662b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotificationEntryTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleTest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.systemui.statusbar.notification.collection;
+package com.android.systemui.bubbles;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
@@ -23,6 +23,7 @@
import android.app.Notification;
import android.os.Bundle;
+import android.os.UserHandle;
import android.service.notification.StatusBarNotification;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
@@ -30,6 +31,7 @@
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
+import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import org.junit.Before;
import org.junit.Test;
@@ -40,13 +42,14 @@
@SmallTest
@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
-public class NotificationEntryTest extends SysuiTestCase {
+public class BubbleTest extends SysuiTestCase {
@Mock
private StatusBarNotification mStatusBarNotification;
@Mock
private Notification mNotif;
private NotificationEntry mEntry;
+ private Bubble mBubble;
private Bundle mExtras;
@Before
@@ -55,11 +58,12 @@
when(mStatusBarNotification.getKey()).thenReturn("key");
when(mStatusBarNotification.getNotification()).thenReturn(mNotif);
-
+ when(mStatusBarNotification.getUser()).thenReturn(new UserHandle(0));
mExtras = new Bundle();
mNotif.extras = mExtras;
-
mEntry = new NotificationEntry(mStatusBarNotification);
+
+ mBubble = new Bubble(mContext, mEntry);
}
@Test
@@ -67,7 +71,7 @@
final String msg = "Hello there!";
doReturn(Notification.Style.class).when(mNotif).getNotificationStyle();
mExtras.putCharSequence(Notification.EXTRA_TEXT, msg);
- assertEquals(msg, mEntry.getUpdateMessage(mContext));
+ assertEquals(msg, mBubble.getUpdateMessage(mContext));
}
@Test
@@ -78,7 +82,7 @@
mExtras.putCharSequence(Notification.EXTRA_BIG_TEXT, msg);
// Should be big text, not the small text.
- assertEquals(msg, mEntry.getUpdateMessage(mContext));
+ assertEquals(msg, mBubble.getUpdateMessage(mContext));
}
@Test
@@ -86,7 +90,7 @@
doReturn(Notification.MediaStyle.class).when(mNotif).getNotificationStyle();
// Media notifs don't get update messages.
- assertNull(mEntry.getUpdateMessage(mContext));
+ assertNull(mBubble.getUpdateMessage(mContext));
}
@Test
@@ -101,7 +105,7 @@
"Really? I prefer them that way."});
// Should be the last one only.
- assertEquals("Really? I prefer them that way.", mEntry.getUpdateMessage(mContext));
+ assertEquals("Really? I prefer them that way.", mBubble.getUpdateMessage(mContext));
}
@Test
@@ -116,6 +120,6 @@
"Oh, hello!", 0, "Mady").toBundle()});
// Should be the last one only.
- assertEquals("Mady: Oh, hello!", mEntry.getUpdateMessage(mContext));
+ assertEquals("Mady: Oh, hello!", mBubble.getUpdateMessage(mContext));
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubblesTestActivity.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubblesTestActivity.java
index 43d2ad1..8bc2e2b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubblesTestActivity.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubblesTestActivity.java
@@ -20,7 +20,7 @@
import android.content.Intent;
import android.os.Bundle;
-import com.android.systemui.R;
+import com.android.systemui.tests.R;
/**
* Referenced by NotificationTestHelper#makeBubbleMetadata
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/ExpandedAnimationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/ExpandedAnimationControllerTest.java
index 1c4b009..ae4581a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/ExpandedAnimationControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/ExpandedAnimationControllerTest.java
@@ -20,6 +20,7 @@
import static org.junit.Assert.assertNotEquals;
import static org.mockito.Mockito.verify;
+import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.PointF;
@@ -45,14 +46,18 @@
private int mDisplayWidth = 500;
private int mDisplayHeight = 1000;
+ private int mExpandedViewPadding = 10;
+ private int mOrientation = Configuration.ORIENTATION_PORTRAIT;
+ private float mLauncherGridDiff = 30f;
@Spy
private ExpandedAnimationController mExpandedController =
new ExpandedAnimationController(
new Point(mDisplayWidth, mDisplayHeight) /* displaySize */,
- 0 /* expandedViewPadding */);
+ mExpandedViewPadding, mOrientation);
+
private int mStackOffset;
- private float mBubblePadding;
+ private float mBubblePaddingTop;
private float mBubbleSize;
private PointF mExpansionPoint;
@@ -65,7 +70,7 @@
Resources res = mLayout.getResources();
mStackOffset = res.getDimensionPixelSize(R.dimen.bubble_stack_offset);
- mBubblePadding = res.getDimensionPixelSize(R.dimen.bubble_padding);
+ mBubblePaddingTop = res.getDimensionPixelSize(R.dimen.bubble_padding_top);
mBubbleSize = res.getDimensionPixelSize(R.dimen.individual_bubble_size);
mExpansionPoint = new PointF(100, 100);
}
@@ -143,7 +148,6 @@
assertEquals(500f, draggedBubble.getTranslationX(), 1f);
assertEquals(500f, draggedBubble.getTranslationY(), 1f);
- // Snap it back and make sure it made it back correctly.
mLayout.removeView(draggedBubble);
waitForLayoutMessageQueue();
waitForPropertyAnimations(DynamicAnimation.TRANSLATION_X, DynamicAnimation.TRANSLATION_Y);
@@ -179,7 +183,7 @@
waitForPropertyAnimations(DynamicAnimation.TRANSLATION_X, DynamicAnimation.TRANSLATION_Y);
- assertEquals(mBubblePadding, mViews.get(1).getTranslationX(), 1f);
+ assertEquals(mBubblePaddingTop, mViews.get(1).getTranslationX(), 1f);
}
@Test
@@ -261,8 +265,8 @@
* @return Bubble left x from left edge of screen.
*/
public float getBubbleLeft(int index) {
- float bubbleLeftFromRowLeft = index * (mBubbleSize + mBubblePadding);
- return getRowLeft() + bubbleLeftFromRowLeft;
+ final float bubbleLeft = index * (mBubbleSize + getSpaceBetweenBubbles());
+ return getRowLeft() + bubbleLeft;
}
private float getRowLeft() {
@@ -270,16 +274,29 @@
return 0;
}
int bubbleCount = mLayout.getChildCount();
+ final float totalBubbleWidth = bubbleCount * mBubbleSize;
+ final float totalGapWidth = (bubbleCount - 1) * getSpaceBetweenBubbles();
+ final float rowWidth = totalGapWidth + totalBubbleWidth;
- // Width calculations.
- double bubble = bubbleCount * mBubbleSize;
- float gap = (bubbleCount - 1) * mBubblePadding;
- float row = gap + (float) bubble;
+ final float centerScreen = mDisplayWidth / 2f;
+ final float halfRow = rowWidth / 2f;
+ final float rowLeft = centerScreen - halfRow;
- float halfRow = row / 2f;
- float centerScreen = mDisplayWidth / 2;
- float rowLeftFromScreenLeft = centerScreen - halfRow;
+ return rowLeft;
+ }
- return rowLeftFromScreenLeft;
+ /**
+ * @return Space between bubbles in row above expanded view.
+ */
+ private float getSpaceBetweenBubbles() {
+ final float rowMargins = (mExpandedViewPadding + mLauncherGridDiff) * 2;
+ final float maxRowWidth = mDisplayWidth - rowMargins;
+
+ final float totalBubbleWidth = mMaxBubbles * mBubbleSize;
+ final float totalGapWidth = maxRowWidth - totalBubbleWidth;
+
+ final int gapCount = mMaxBubbles - 1;
+ final float gapWidth = totalGapWidth / gapCount;
+ return gapWidth;
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayoutTest.java
index 5650e1e..498330c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayoutTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayoutTest.java
@@ -161,8 +161,8 @@
});
// Set end listeners for both x and y.
- mLayout.setEndActionForProperty(xEndAction, DynamicAnimation.TRANSLATION_X);
- mLayout.setEndActionForProperty(yEndAction, DynamicAnimation.TRANSLATION_Y);
+ mTestableController.setEndActionForProperty(xEndAction, DynamicAnimation.TRANSLATION_X);
+ mTestableController.setEndActionForProperty(yEndAction, DynamicAnimation.TRANSLATION_Y);
// Animate x, and wait for it to finish.
mTestableController.animationForChildAtIndex(0)
@@ -196,7 +196,7 @@
});
// Set the end listener.
- mLayout.setEndActionForProperty(xEndListener, DynamicAnimation.TRANSLATION_X);
+ mTestableController.setEndActionForProperty(xEndListener, DynamicAnimation.TRANSLATION_X);
// Animate x, and wait for it to finish.
mTestableController.animationForChildAtIndex(0)
@@ -211,7 +211,7 @@
mTestableController.animationForChildAtIndex(0)
.translationX(1000)
.start();
- mLayout.removeEndActionForProperty(DynamicAnimation.TRANSLATION_X);
+ mTestableController.removeEndActionForProperty(DynamicAnimation.TRANSLATION_X);
xLatch.await(1, TimeUnit.SECONDS);
// Make sure the end listener was not called.
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayoutTestCase.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayoutTestCase.java
index f633f39..a5f2e8b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayoutTestCase.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayoutTestCase.java
@@ -68,7 +68,7 @@
@Mock
private DisplayCutout mCutout;
- private int mMaxBubbles;
+ protected int mMaxBubbles;
@Before
public void setUp() throws Exception {
@@ -195,14 +195,13 @@
private void setTestEndActionForProperty(
Runnable action, DynamicAnimation.ViewProperty property) {
final Runnable realEndAction = mEndActionForProperty.get(property);
-
- setEndActionForProperty(() -> {
+ mLayout.mEndActionForProperty.put(property, () -> {
if (realEndAction != null) {
realEndAction.run();
}
action.run();
- }, property);
+ });
}
/** PhysicsPropertyAnimator that posts its animations to the main thread. */
@@ -219,6 +218,11 @@
property, view, value, startVel, startDelay, stiffness, dampingRatio,
afterCallbacks));
}
+
+ @Override
+ protected void startPathAnimation() {
+ mMainThreadHandler.post(super::startPathAnimation);
+ }
}
/**
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/StackAnimationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/StackAnimationControllerTest.java
index 31a7d5a..d79128c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/StackAnimationControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/StackAnimationControllerTest.java
@@ -339,10 +339,10 @@
@Override
protected void springFirstBubbleWithStackFollowing(DynamicAnimation.ViewProperty property,
- SpringForce spring, float vel, float finalPosition) {
+ SpringForce spring, float vel, float finalPosition, Runnable... after) {
mMainThreadHandler.post(() ->
super.springFirstBubbleWithStackFollowing(
- property, spring, vel, finalPosition));
+ property, spring, vel, finalPosition, after));
}
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/classifier/FalsingManagerProxyTest.java b/packages/SystemUI/tests/src/com/android/systemui/classifier/FalsingManagerProxyTest.java
index 7ea6493..32cf842 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/classifier/FalsingManagerProxyTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/classifier/FalsingManagerProxyTest.java
@@ -31,6 +31,7 @@
import com.android.systemui.SysuiTestCase;
import com.android.systemui.classifier.brightline.BrightLineFalsingManager;
import com.android.systemui.shared.plugins.PluginManager;
+import com.android.systemui.util.ProximitySensor;
import org.junit.After;
import org.junit.Before;
@@ -43,8 +44,10 @@
@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
public class FalsingManagerProxyTest extends SysuiTestCase {
- @Mock
+ @Mock(stubOnly = true)
PluginManager mPluginManager;
+ @Mock(stubOnly = true)
+ ProximitySensor mProximitySensor;
private boolean mDefaultConfigValue;
private Handler mHandler;
private TestableLooper mTestableLooper;
@@ -69,7 +72,8 @@
@Test
public void test_brightLineFalsingManagerDisabled() {
- FalsingManagerProxy proxy = new FalsingManagerProxy(getContext(), mPluginManager, mHandler);
+ FalsingManagerProxy proxy = new FalsingManagerProxy(
+ getContext(), mPluginManager, mHandler, mProximitySensor);
assertThat(proxy.getInternalFalsingManager(), instanceOf(FalsingManagerImpl.class));
}
@@ -78,14 +82,16 @@
public void test_brightLineFalsingManagerEnabled() {
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SYSTEMUI,
BRIGHTLINE_FALSING_MANAGER_ENABLED, "true", false);
- FalsingManagerProxy proxy = new FalsingManagerProxy(getContext(), mPluginManager, mHandler);
+ FalsingManagerProxy proxy = new FalsingManagerProxy(
+ getContext(), mPluginManager, mHandler, mProximitySensor);
assertThat(proxy.getInternalFalsingManager(), instanceOf(BrightLineFalsingManager.class));
}
@Test
public void test_brightLineFalsingManagerToggled() {
- FalsingManagerProxy proxy = new FalsingManagerProxy(getContext(), mPluginManager, mHandler);
+ FalsingManagerProxy proxy = new FalsingManagerProxy(
+ getContext(), mPluginManager, mHandler, mProximitySensor);
assertThat(proxy.getInternalFalsingManager(), instanceOf(FalsingManagerImpl.class));
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SYSTEMUI,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/classifier/brightline/ProximityClassifierTest.java b/packages/SystemUI/tests/src/com/android/systemui/classifier/brightline/ProximityClassifierTest.java
index a6cabbf..49ba302 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/classifier/brightline/ProximityClassifierTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/classifier/brightline/ProximityClassifierTest.java
@@ -23,24 +23,21 @@
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when;
-import android.hardware.Sensor;
-import android.hardware.SensorEvent;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.MotionEvent;
import androidx.test.filters.SmallTest;
+import com.android.systemui.util.ProximitySensor;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
-import java.lang.reflect.Field;
-
@SmallTest
@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
@@ -78,8 +75,8 @@
@Test
public void testPass_mostlyUncovered() {
touchDown();
- mClassifier.onSensorEvent(createSensorEvent(true, 1));
- mClassifier.onSensorEvent(createSensorEvent(false, 2));
+ mClassifier.onProximityEvent(createSensorEvent(true, 1));
+ mClassifier.onProximityEvent(createSensorEvent(false, 2));
touchUp(20);
assertThat(mClassifier.isFalseTouch(), is(false));
}
@@ -88,8 +85,8 @@
public void testPass_quickSettings() {
touchDown();
when(mDataProvider.getInteractionType()).thenReturn(QUICK_SETTINGS);
- mClassifier.onSensorEvent(createSensorEvent(true, 1));
- mClassifier.onSensorEvent(createSensorEvent(false, 11));
+ mClassifier.onProximityEvent(createSensorEvent(true, 1));
+ mClassifier.onProximityEvent(createSensorEvent(false, 11));
touchUp(10);
assertThat(mClassifier.isFalseTouch(), is(false));
}
@@ -97,8 +94,8 @@
@Test
public void testFail_covered() {
touchDown();
- mClassifier.onSensorEvent(createSensorEvent(true, 1));
- mClassifier.onSensorEvent(createSensorEvent(false, 11));
+ mClassifier.onProximityEvent(createSensorEvent(true, 1));
+ mClassifier.onProximityEvent(createSensorEvent(false, 11));
touchUp(10);
assertThat(mClassifier.isFalseTouch(), is(true));
}
@@ -106,10 +103,10 @@
@Test
public void testFail_mostlyCovered() {
touchDown();
- mClassifier.onSensorEvent(createSensorEvent(true, 1));
- mClassifier.onSensorEvent(createSensorEvent(true, 95));
- mClassifier.onSensorEvent(createSensorEvent(true, 96));
- mClassifier.onSensorEvent(createSensorEvent(false, 100));
+ mClassifier.onProximityEvent(createSensorEvent(true, 1));
+ mClassifier.onProximityEvent(createSensorEvent(true, 95));
+ mClassifier.onProximityEvent(createSensorEvent(true, 96));
+ mClassifier.onProximityEvent(createSensorEvent(false, 100));
touchUp(100);
assertThat(mClassifier.isFalseTouch(), is(true));
}
@@ -117,8 +114,8 @@
@Test
public void testPass_coveredWithLongSwipe() {
touchDown();
- mClassifier.onSensorEvent(createSensorEvent(true, 1));
- mClassifier.onSensorEvent(createSensorEvent(false, 11));
+ mClassifier.onProximityEvent(createSensorEvent(true, 1));
+ mClassifier.onProximityEvent(createSensorEvent(false, 11));
touchUp(10);
when(mDistanceClassifier.isLongSwipe()).thenReturn(true);
assertThat(mClassifier.isFalseTouch(), is(false));
@@ -139,26 +136,7 @@
motionEvent.recycle();
}
- private SensorEvent createSensorEvent(boolean covered, long timestampMs) {
- SensorEvent sensorEvent = Mockito.mock(SensorEvent.class);
- Sensor sensor = Mockito.mock(Sensor.class);
- when(sensor.getType()).thenReturn(Sensor.TYPE_PROXIMITY);
- when(sensor.getMaximumRange()).thenReturn(1f);
- sensorEvent.sensor = sensor;
- sensorEvent.timestamp = timestampMs * NS_PER_MS;
- try {
- Field valuesField = SensorEvent.class.getField("values");
- valuesField.setAccessible(true);
- float[] sensorValue = {covered ? 0 : 1};
- try {
- valuesField.set(sensorEvent, sensorValue);
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- }
- } catch (NoSuchFieldException e) {
- e.printStackTrace();
- }
-
- return sensorEvent;
+ private ProximitySensor.ProximityEvent createSensorEvent(boolean covered, long timestampMs) {
+ return new ProximitySensor.ProximityEvent(covered, timestampMs * NS_PER_MS);
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeMachineTest.java b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeMachineTest.java
index 6dfb19e..1e18e51 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeMachineTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeMachineTest.java
@@ -45,11 +45,14 @@
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
+import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.util.wakelock.WakeLockFake;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
@SmallTest
@RunWith(AndroidTestingRunner.class)
@@ -58,6 +61,8 @@
DozeMachine mMachine;
+ @Mock
+ private WakefulnessLifecycle mWakefulnessLifecycle;
private DozeServiceFake mServiceFake;
private WakeLockFake mWakeLockFake;
private AmbientDisplayConfiguration mConfigMock;
@@ -65,12 +70,13 @@
@Before
public void setUp() {
+ MockitoAnnotations.initMocks(this);
mServiceFake = new DozeServiceFake();
mWakeLockFake = new WakeLockFake();
mConfigMock = mock(AmbientDisplayConfiguration.class);
mPartMock = mock(DozeMachine.Part.class);
- mMachine = new DozeMachine(mServiceFake, mConfigMock, mWakeLockFake);
+ mMachine = new DozeMachine(mServiceFake, mConfigMock, mWakeLockFake, mWakefulnessLifecycle);
mMachine.setParts(new DozeMachine.Part[]{mPartMock});
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/UserDetailViewAdapterTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/UserDetailViewAdapterTest.kt
new file mode 100644
index 0000000..b51e716
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/UserDetailViewAdapterTest.kt
@@ -0,0 +1,128 @@
+/*
+ * 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
+ */
+
+package com.android.systemui.qs.tiles
+
+import android.content.Context
+import android.content.pm.UserInfo
+import android.graphics.Bitmap
+import android.testing.AndroidTestingRunner
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.statusbar.policy.UserSwitcherController
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.ArgumentMatchers.any
+import org.mockito.ArgumentMatchers.anyBoolean
+import org.mockito.ArgumentMatchers.anyInt
+import org.mockito.Mock
+import org.mockito.Mockito.`when`
+import org.mockito.Mockito.verify
+import org.mockito.MockitoAnnotations
+
+@RunWith(AndroidTestingRunner::class)
+@SmallTest
+class UserDetailViewAdapterTest : SysuiTestCase() {
+
+ @Mock private lateinit var mUserSwitcherController: UserSwitcherController
+ @Mock private lateinit var mParent: ViewGroup
+ @Mock private lateinit var mUserDetailItemView: UserDetailItemView
+ @Mock private lateinit var mOtherView: View
+ @Mock private lateinit var mInflatedUserDetailItemView: UserDetailItemView
+ @Mock private lateinit var mUserInfo: UserInfo
+ @Mock private lateinit var mPicture: Bitmap
+ @Mock private lateinit var mLayoutInflater: LayoutInflater
+ private lateinit var adapter: UserDetailView.Adapter
+
+ @Before
+ fun setUp() {
+ MockitoAnnotations.initMocks(this)
+
+ mContext.addMockSystemService(Context.LAYOUT_INFLATER_SERVICE, mLayoutInflater)
+ `when`(mLayoutInflater.inflate(anyInt(), any(ViewGroup::class.java), anyBoolean()))
+ .thenReturn(mInflatedUserDetailItemView)
+ adapter = UserDetailView.Adapter(mContext, mUserSwitcherController)
+ }
+
+ private fun clickableTest(
+ current: Boolean,
+ guest: Boolean,
+ convertView: View,
+ shouldBeClickable: Boolean
+ ) {
+ val user = createUserRecord(current, guest)
+ val v = adapter.createUserDetailItemView(convertView, mParent, user)
+ if (shouldBeClickable) {
+ verify(v).setOnClickListener(adapter)
+ } else {
+ verify(v).setOnClickListener(null)
+ }
+ }
+
+ @Test
+ fun testGuestIsClickable_differentViews_notCurrent() {
+ clickableTest(false, true, mOtherView, true)
+ }
+
+ @Test
+ fun testGuestIsClickable_differentViews_Current() {
+ clickableTest(true, true, mOtherView, true)
+ }
+
+ @Test
+ fun testGuestIsClickable_sameView_notCurrent() {
+ clickableTest(false, true, mUserDetailItemView, true)
+ }
+
+ @Test
+ fun testGuestIsClickable_sameView_Current() {
+ clickableTest(true, true, mUserDetailItemView, true)
+ }
+
+ @Test
+ fun testNotGuestCurrentUserIsNotClickable_otherView() {
+ clickableTest(true, false, mOtherView, false)
+ }
+
+ @Test
+ fun testNotGuestCurrentUserIsNotClickable_sameView() {
+ clickableTest(true, false, mUserDetailItemView, false)
+ }
+
+ @Test
+ fun testNotGuestNotCurrentUserIsClickable_otherView() {
+ clickableTest(false, false, mOtherView, true)
+ }
+
+ @Test
+ fun testNotGuestNotCurrentUserIsClickable_sameView() {
+ clickableTest(false, false, mUserDetailItemView, true)
+ }
+
+ private fun createUserRecord(current: Boolean, guest: Boolean) =
+ UserSwitcherController.UserRecord(
+ mUserInfo,
+ mPicture,
+ guest,
+ current,
+ false /* isAddUser */,
+ false /* isRestricted */,
+ true /* isSwitchToEnabled */)
+}
\ No newline at end of file
diff --git a/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScreenshotStubActivity.java b/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScreenshotStubActivity.java
index 784d035..0b871e4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScreenshotStubActivity.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScreenshotStubActivity.java
@@ -15,11 +15,11 @@
*/
package com.android.systemui.screenshot;
-import com.android.systemui.R;
-
import android.app.Activity;
import android.os.Bundle;
+import com.android.systemui.tests.R;
+
/**
* A stub activity used in {@link ScreenshotTest}.
*/
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationInterruptionStateProviderTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationInterruptionStateProviderTest.java
new file mode 100644
index 0000000..a66cf84
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationInterruptionStateProviderTest.java
@@ -0,0 +1,589 @@
+/*
+ * 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.
+ */
+package com.android.systemui.statusbar;
+
+
+import static android.app.Notification.FLAG_BUBBLE;
+import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
+import static android.app.NotificationManager.IMPORTANCE_HIGH;
+import static android.app.NotificationManager.IMPORTANCE_LOW;
+import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_AMBIENT;
+import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK;
+
+import static com.android.systemui.statusbar.StatusBarState.SHADE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.Notification;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.drawable.Icon;
+import android.hardware.display.AmbientDisplayConfiguration;
+import android.os.PowerManager;
+import android.os.RemoteException;
+import android.os.UserHandle;
+import android.service.dreams.IDreamManager;
+import android.service.notification.StatusBarNotification;
+import android.testing.AndroidTestingRunner;
+
+import androidx.test.filters.SmallTest;
+
+import com.android.systemui.R;
+import com.android.systemui.SysuiTestCase;
+import com.android.systemui.plugins.statusbar.StatusBarStateController;
+import com.android.systemui.statusbar.notification.NotificationFilter;
+import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider;
+import com.android.systemui.statusbar.notification.collection.NotificationEntry;
+import com.android.systemui.statusbar.policy.HeadsUpManager;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Tests for the interruption state provider which understands whether the system & notification
+ * is in a state allowing a particular notification to hun, pulse, or bubble.
+ */
+@RunWith(AndroidTestingRunner.class)
+@SmallTest
+public class NotificationInterruptionStateProviderTest extends SysuiTestCase {
+
+ @Mock
+ PowerManager mPowerManager;
+ @Mock
+ IDreamManager mDreamManager;
+ @Mock
+ AmbientDisplayConfiguration mAmbientDisplayConfiguration;
+ @Mock
+ NotificationFilter mNotificationFilter;
+ @Mock
+ StatusBarStateController mStatusBarStateController;
+ @Mock
+ NotificationPresenter mPresenter;
+ @Mock
+ HeadsUpManager mHeadsUpManager;
+ @Mock
+ NotificationInterruptionStateProvider.HeadsUpSuppressor mHeadsUpSuppressor;
+
+ private NotificationInterruptionStateProvider mNotifInterruptionStateProvider;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+
+ mNotifInterruptionStateProvider =
+ new TestableNotificationInterruptionStateProvider(mContext,
+ mPowerManager,
+ mDreamManager,
+ mAmbientDisplayConfiguration,
+ mNotificationFilter,
+ mStatusBarStateController);
+
+ mNotifInterruptionStateProvider.setUpWithPresenter(
+ mPresenter,
+ mHeadsUpManager,
+ mHeadsUpSuppressor);
+ }
+
+ /**
+ * Sets up the state such that any requests to
+ * {@link NotificationInterruptionStateProvider#canAlertCommon(NotificationEntry)} will
+ * pass as long its provided NotificationEntry fulfills group suppression check.
+ */
+ private void ensureStateForAlertCommon() {
+ when(mNotificationFilter.shouldFilterOut(any())).thenReturn(false);
+ }
+
+ /**
+ * Sets up the state such that any requests to
+ * {@link NotificationInterruptionStateProvider#canAlertAwakeCommon(NotificationEntry)} will
+ * pass as long its provided NotificationEntry fulfills launch fullscreen check.
+ */
+ private void ensureStateForAlertAwakeCommon() {
+ when(mPresenter.isDeviceInVrMode()).thenReturn(false);
+ when(mHeadsUpManager.isSnoozed(any())).thenReturn(false);
+ }
+
+ /**
+ * Sets up the state such that any requests to
+ * {@link NotificationInterruptionStateProvider#shouldHeadsUp(NotificationEntry)} will
+ * pass as long its provided NotificationEntry fulfills importance & DND checks.
+ */
+ private void ensureStateForHeadsUpWhenAwake() throws RemoteException {
+ ensureStateForAlertCommon();
+ ensureStateForAlertAwakeCommon();
+
+ when(mStatusBarStateController.isDozing()).thenReturn(false);
+ when(mDreamManager.isDreaming()).thenReturn(false);
+ when(mPowerManager.isScreenOn()).thenReturn(true);
+ when(mHeadsUpSuppressor.canHeadsUp(any(), any())).thenReturn(true);
+ }
+
+ /**
+ * Sets up the state such that any requests to
+ * {@link NotificationInterruptionStateProvider#shouldHeadsUp(NotificationEntry)} will
+ * pass as long its provided NotificationEntry fulfills importance & DND checks.
+ */
+ private void ensureStateForHeadsUpWhenDozing() {
+ ensureStateForAlertCommon();
+
+ when(mStatusBarStateController.isDozing()).thenReturn(true);
+ when(mAmbientDisplayConfiguration.pulseOnNotificationEnabled(anyInt())).thenReturn(true);
+ }
+
+ /**
+ * Sets up the state such that any requests to
+ * {@link NotificationInterruptionStateProvider#shouldBubbleUp(NotificationEntry)} will
+ * pass as long its provided NotificationEntry fulfills importance & bubble checks.
+ */
+ private void ensureStateForBubbleUp() {
+ ensureStateForAlertCommon();
+ ensureStateForAlertAwakeCommon();
+ }
+
+ /**
+ * Ensure that the disabled state is set correctly.
+ */
+ @Test
+ public void testDisableNotificationAlerts() {
+ // Enabled by default
+ assertThat(mNotifInterruptionStateProvider.areNotificationAlertsDisabled()).isFalse();
+
+ // Disable alerts
+ mNotifInterruptionStateProvider.setDisableNotificationAlerts(true);
+ assertThat(mNotifInterruptionStateProvider.areNotificationAlertsDisabled()).isTrue();
+
+ // Enable alerts
+ mNotifInterruptionStateProvider.setDisableNotificationAlerts(false);
+ assertThat(mNotifInterruptionStateProvider.areNotificationAlertsDisabled()).isFalse();
+ }
+
+ /**
+ * Ensure that the disabled alert state effects whether HUNs are enabled.
+ */
+ @Test
+ public void testHunSettingsChange_enabled_butAlertsDisabled() {
+ // Set up but without a mock change observer
+ mNotifInterruptionStateProvider.setUpWithPresenter(
+ mPresenter,
+ mHeadsUpManager,
+ mHeadsUpSuppressor);
+
+ // HUNs enabled by default
+ assertThat(mNotifInterruptionStateProvider.getUseHeadsUp()).isTrue();
+
+ // Set alerts disabled
+ mNotifInterruptionStateProvider.setDisableNotificationAlerts(true);
+
+ // No more HUNs
+ assertThat(mNotifInterruptionStateProvider.getUseHeadsUp()).isFalse();
+ }
+
+ /**
+ * Alerts can happen.
+ */
+ @Test
+ public void testCanAlertCommon_true() {
+ ensureStateForAlertCommon();
+
+ NotificationEntry entry = createNotification(IMPORTANCE_DEFAULT);
+ assertThat(mNotifInterruptionStateProvider.canAlertCommon(entry)).isTrue();
+ }
+
+ /**
+ * Filtered out notifications don't alert.
+ */
+ @Test
+ public void testCanAlertCommon_false_filteredOut() {
+ ensureStateForAlertCommon();
+ when(mNotificationFilter.shouldFilterOut(any())).thenReturn(true);
+
+ NotificationEntry entry = createNotification(IMPORTANCE_DEFAULT);
+ assertThat(mNotifInterruptionStateProvider.canAlertCommon(entry)).isFalse();
+ }
+
+ /**
+ * Grouped notifications have different alerting behaviours, sometimes the alert for a
+ * grouped notification may be suppressed {@link android.app.Notification#GROUP_ALERT_CHILDREN}.
+ */
+ @Test
+ public void testCanAlertCommon_false_suppressedForGroups() {
+ ensureStateForAlertCommon();
+
+ Notification n = new Notification.Builder(getContext(), "a")
+ .setGroup("a")
+ .setGroupSummary(true)
+ .setGroupAlertBehavior(Notification.GROUP_ALERT_CHILDREN)
+ .build();
+ StatusBarNotification sbn = new StatusBarNotification("a", "a", 0, "a", 0, 0, n,
+ UserHandle.of(0), null, 0);
+ NotificationEntry entry = new NotificationEntry(sbn);
+ entry.importance = IMPORTANCE_DEFAULT;
+
+ assertThat(mNotifInterruptionStateProvider.canAlertCommon(entry)).isFalse();
+ }
+
+ /**
+ * HUNs while dozing can happen.
+ */
+ @Test
+ public void testShouldHeadsUpWhenDozing_true() {
+ ensureStateForHeadsUpWhenDozing();
+
+ NotificationEntry entry = createNotification(IMPORTANCE_DEFAULT);
+ assertThat(mNotifInterruptionStateProvider.shouldHeadsUp(entry)).isTrue();
+ }
+
+ /**
+ * Ambient display can show HUNs for new notifications, this may be disabled.
+ */
+ @Test
+ public void testShouldHeadsUpWhenDozing_false_pulseDisabled() {
+ ensureStateForHeadsUpWhenDozing();
+ when(mAmbientDisplayConfiguration.pulseOnNotificationEnabled(anyInt())).thenReturn(false);
+
+ NotificationEntry entry = createNotification(IMPORTANCE_DEFAULT);
+ assertThat(mNotifInterruptionStateProvider.shouldHeadsUp(entry)).isFalse();
+ }
+
+ /**
+ * If the device is not in ambient display or sleeping then we don't HUN.
+ */
+ @Test
+ public void testShouldHeadsUpWhenDozing_false_notDozing() {
+ ensureStateForHeadsUpWhenDozing();
+ when(mStatusBarStateController.isDozing()).thenReturn(false);
+
+ NotificationEntry entry = createNotification(IMPORTANCE_DEFAULT);
+ assertThat(mNotifInterruptionStateProvider.shouldHeadsUp(entry)).isFalse();
+ }
+
+ /**
+ * In DND ambient effects can be suppressed
+ * {@link android.app.NotificationManager.Policy#SUPPRESSED_EFFECT_AMBIENT}.
+ */
+ @Test
+ public void testShouldHeadsUpWhenDozing_false_suppressingAmbient() {
+ ensureStateForHeadsUpWhenDozing();
+
+ NotificationEntry entry = createNotification(IMPORTANCE_DEFAULT);
+ entry.suppressedVisualEffects = SUPPRESSED_EFFECT_AMBIENT;
+
+ assertThat(mNotifInterruptionStateProvider.shouldHeadsUp(entry)).isFalse();
+ }
+
+ /**
+ * Notifications that are < {@link android.app.NotificationManager#IMPORTANCE_DEFAULT} don't
+ * get to pulse.
+ */
+ @Test
+ public void testShouldHeadsUpWhenDozing_false_lessImportant() {
+ ensureStateForHeadsUpWhenDozing();
+
+ NotificationEntry entry = createNotification(IMPORTANCE_LOW);
+ assertThat(mNotifInterruptionStateProvider.shouldHeadsUp(entry)).isFalse();
+ }
+
+ /**
+ * Heads up can happen.
+ */
+ @Test
+ public void testShouldHeadsUp_true() throws RemoteException {
+ ensureStateForHeadsUpWhenAwake();
+
+ NotificationEntry entry = createNotification(IMPORTANCE_HIGH);
+ assertThat(mNotifInterruptionStateProvider.shouldHeadsUp(entry)).isTrue();
+ }
+
+ /**
+ * Heads up notifications can be disabled in general.
+ */
+ @Test
+ public void testShouldHeadsUp_false_noHunsAllowed() throws RemoteException {
+ ensureStateForHeadsUpWhenAwake();
+
+ // Set alerts disabled, this should cause heads up to be false
+ mNotifInterruptionStateProvider.setDisableNotificationAlerts(true);
+ assertThat(mNotifInterruptionStateProvider.getUseHeadsUp()).isFalse();
+
+ NotificationEntry entry = createNotification(IMPORTANCE_HIGH);
+ assertThat(mNotifInterruptionStateProvider.shouldHeadsUp(entry)).isFalse();
+ }
+
+ /**
+ * If the device is dozing, we don't show as heads up.
+ */
+ @Test
+ public void testShouldHeadsUp_false_dozing() throws RemoteException {
+ ensureStateForHeadsUpWhenAwake();
+ when(mStatusBarStateController.isDozing()).thenReturn(true);
+
+ NotificationEntry entry = createNotification(IMPORTANCE_HIGH);
+ assertThat(mNotifInterruptionStateProvider.shouldHeadsUp(entry)).isFalse();
+ }
+
+ /**
+ * If the notification is a bubble, and the user is not on AOD / lockscreen, then
+ * the bubble is shown rather than the heads up.
+ */
+ @Test
+ public void testShouldHeadsUp_false_bubble() throws RemoteException {
+ ensureStateForHeadsUpWhenAwake();
+
+ // Bubble bit only applies to interruption when we're in the shade
+ when(mStatusBarStateController.getState()).thenReturn(SHADE);
+
+ assertThat(mNotifInterruptionStateProvider.shouldHeadsUp(createBubble())).isFalse();
+ }
+
+ /**
+ * If we're not allowed to alert in general, we shouldn't be shown as heads up.
+ */
+ @Test
+ public void testShouldHeadsUp_false_alertCommonFalse() throws RemoteException {
+ ensureStateForHeadsUpWhenAwake();
+ // Make canAlertCommon false by saying it's filtered out
+ when(mNotificationFilter.shouldFilterOut(any())).thenReturn(true);
+
+ NotificationEntry entry = createNotification(IMPORTANCE_HIGH);
+ assertThat(mNotifInterruptionStateProvider.shouldHeadsUp(entry)).isFalse();
+ }
+
+ /**
+ * In DND HUN peek effects can be suppressed
+ * {@link android.app.NotificationManager.Policy#SUPPRESSED_EFFECT_PEEK}.
+ */
+ @Test
+ public void testShouldHeadsUp_false_suppressPeek() throws RemoteException {
+ ensureStateForHeadsUpWhenAwake();
+
+ NotificationEntry entry = createNotification(IMPORTANCE_HIGH);
+ entry.suppressedVisualEffects = SUPPRESSED_EFFECT_PEEK;
+
+ assertThat(mNotifInterruptionStateProvider.shouldHeadsUp(entry)).isFalse();
+ }
+
+ /**
+ * Notifications that are < {@link android.app.NotificationManager#IMPORTANCE_HIGH} don't get
+ * to show as a heads up.
+ */
+ @Test
+ public void testShouldHeadsUp_false_lessImportant() throws RemoteException {
+ ensureStateForHeadsUpWhenAwake();
+
+ NotificationEntry entry = createNotification(IMPORTANCE_DEFAULT);
+ assertThat(mNotifInterruptionStateProvider.shouldHeadsUp(entry)).isFalse();
+ }
+
+ /**
+ * If the device is not in use then we shouldn't be shown as heads up.
+ */
+ @Test
+ public void testShouldHeadsUp_false_deviceNotInUse() throws RemoteException {
+ ensureStateForHeadsUpWhenAwake();
+ NotificationEntry entry = createNotification(IMPORTANCE_HIGH);
+
+ // Device is not in use if screen is not on
+ when(mPowerManager.isScreenOn()).thenReturn(false);
+ assertThat(mNotifInterruptionStateProvider.shouldHeadsUp(entry)).isFalse();
+
+ // Also not in use if screen is on but we're showing screen saver / "dreaming"
+ when(mPowerManager.isDeviceIdleMode()).thenReturn(true);
+ when(mDreamManager.isDreaming()).thenReturn(true);
+ assertThat(mNotifInterruptionStateProvider.shouldHeadsUp(entry)).isFalse();
+ }
+
+ /**
+ * If something wants to suppress this heads up, then it shouldn't be shown as a heads up.
+ */
+ @Test
+ public void testShouldHeadsUp_false_suppressed() throws RemoteException {
+ ensureStateForHeadsUpWhenAwake();
+ when(mHeadsUpSuppressor.canHeadsUp(any(), any())).thenReturn(false);
+
+ NotificationEntry entry = createNotification(IMPORTANCE_HIGH);
+ assertThat(mNotifInterruptionStateProvider.shouldHeadsUp(entry)).isFalse();
+ verify(mHeadsUpSuppressor).canHeadsUp(any(), any());
+ }
+
+ /**
+ * On screen alerts don't happen when the device is in VR Mode.
+ */
+ @Test
+ public void testCanAlertAwakeCommon__false_vrMode() {
+ ensureStateForAlertAwakeCommon();
+ when(mPresenter.isDeviceInVrMode()).thenReturn(true);
+
+ NotificationEntry entry = createNotification(IMPORTANCE_DEFAULT);
+ assertThat(mNotifInterruptionStateProvider.canAlertAwakeCommon(entry)).isFalse();
+ }
+
+ /**
+ * On screen alerts don't happen when the notification is snoozed.
+ */
+ @Test
+ public void testCanAlertAwakeCommon_false_snoozedPackage() {
+ ensureStateForAlertAwakeCommon();
+ when(mHeadsUpManager.isSnoozed(any())).thenReturn(true);
+
+ NotificationEntry entry = createNotification(IMPORTANCE_DEFAULT);
+ assertThat(mNotifInterruptionStateProvider.canAlertAwakeCommon(entry)).isFalse();
+ }
+
+ /**
+ * On screen alerts don't happen when that package has just launched fullscreen.
+ */
+ @Test
+ public void testCanAlertAwakeCommon_false_justLaunchedFullscreen() {
+ ensureStateForAlertAwakeCommon();
+
+ NotificationEntry entry = createNotification(IMPORTANCE_DEFAULT);
+ entry.notifyFullScreenIntentLaunched();
+
+ assertThat(mNotifInterruptionStateProvider.canAlertAwakeCommon(entry)).isFalse();
+ }
+
+ /**
+ * Bubbles can happen.
+ */
+ @Test
+ public void testShouldBubbleUp_true() {
+ ensureStateForBubbleUp();
+ assertThat(mNotifInterruptionStateProvider.shouldBubbleUp(createBubble())).isTrue();
+ }
+
+ /**
+ * If the notification doesn't have permission to bubble, it shouldn't bubble.
+ */
+ @Test
+ public void shouldBubbleUp_false_notAllowedToBubble() {
+ ensureStateForBubbleUp();
+
+ NotificationEntry entry = createBubble();
+ entry.canBubble = false;
+
+ assertThat(mNotifInterruptionStateProvider.shouldBubbleUp(entry)).isFalse();
+ }
+
+ /**
+ * If the notification isn't a bubble, it should definitely not show as a bubble.
+ */
+ @Test
+ public void shouldBubbleUp_false_notABubble() {
+ ensureStateForBubbleUp();
+
+ NotificationEntry entry = createNotification(IMPORTANCE_HIGH);
+ entry.canBubble = true;
+
+ assertThat(mNotifInterruptionStateProvider.shouldBubbleUp(entry)).isFalse();
+ }
+
+ /**
+ * If the notification doesn't have bubble metadata, it shouldn't bubble.
+ */
+ @Test
+ public void shouldBubbleUp_false_invalidMetadata() {
+ ensureStateForBubbleUp();
+
+ NotificationEntry entry = createNotification(IMPORTANCE_HIGH);
+ entry.canBubble = true;
+ entry.notification.getNotification().flags |= FLAG_BUBBLE;
+
+ assertThat(mNotifInterruptionStateProvider.shouldBubbleUp(entry)).isFalse();
+ }
+
+ /**
+ * If the notification can't heads up in general, it shouldn't bubble.
+ */
+ @Test
+ public void shouldBubbleUp_false_alertAwakeCommonFalse() {
+ ensureStateForBubbleUp();
+
+ // Make alert common return false by pretending we're in VR mode
+ when(mPresenter.isDeviceInVrMode()).thenReturn(true);
+
+ assertThat(mNotifInterruptionStateProvider.shouldBubbleUp(createBubble())).isFalse();
+ }
+
+ /**
+ * If the notification can't heads up in general, it shouldn't bubble.
+ */
+ @Test
+ public void shouldBubbleUp_false_alertCommonFalse() {
+ ensureStateForBubbleUp();
+
+ // Make canAlertCommon false by saying it's filtered out
+ when(mNotificationFilter.shouldFilterOut(any())).thenReturn(true);
+
+ assertThat(mNotifInterruptionStateProvider.shouldBubbleUp(createBubble())).isFalse();
+ }
+
+ private NotificationEntry createBubble() {
+ Notification.BubbleMetadata data = new Notification.BubbleMetadata.Builder()
+ .setIntent(PendingIntent.getActivity(mContext, 0, new Intent(), 0))
+ .setIcon(Icon.createWithResource(mContext.getResources(), R.drawable.android))
+ .build();
+ Notification n = new Notification.Builder(getContext(), "a")
+ .setContentTitle("title")
+ .setContentText("content text")
+ .setBubbleMetadata(data)
+ .build();
+ StatusBarNotification sbn = new StatusBarNotification("a", "a", 0, "a", 0, 0, n,
+ UserHandle.of(0), null, 0);
+ NotificationEntry entry = new NotificationEntry(sbn);
+ entry.notification.getNotification().flags |= FLAG_BUBBLE;
+ entry.importance = IMPORTANCE_HIGH;
+ entry.canBubble = true;
+ return entry;
+ }
+
+ private NotificationEntry createNotification(int importance) {
+ Notification n = new Notification.Builder(getContext(), "a")
+ .setContentTitle("title")
+ .setContentText("content text")
+ .build();
+ StatusBarNotification sbn = new StatusBarNotification("a", "a", 0, "a", 0, 0, n,
+ UserHandle.of(0), null, 0);
+ NotificationEntry entry = new NotificationEntry(sbn);
+ entry.importance = importance;
+ return entry;
+ }
+
+ /**
+ * Testable class overriding constructor.
+ */
+ public class TestableNotificationInterruptionStateProvider extends
+ NotificationInterruptionStateProvider {
+
+ TestableNotificationInterruptionStateProvider(Context context,
+ PowerManager powerManager, IDreamManager dreamManager,
+ AmbientDisplayConfiguration ambientDisplayConfiguration,
+ NotificationFilter notificationFilter,
+ StatusBarStateController statusBarStateController) {
+ super(context, powerManager, dreamManager, ambientDisplayConfiguration,
+ notificationFilter,
+ statusBarStateController);
+ }
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java
index 7063ddf..ab207f8 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java
@@ -40,7 +40,6 @@
import androidx.test.InstrumentationRegistry;
-import com.android.systemui.R;
import com.android.systemui.bubbles.BubblesTestActivity;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
@@ -50,7 +49,7 @@
import com.android.systemui.statusbar.phone.HeadsUpManagerPhone;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
-import com.android.systemui.statusbar.policy.HeadsUpManager;
+import com.android.systemui.tests.R;
/**
* A helper class to create {@link ExpandableNotificationRow} (for both individual and group
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationViewHierarchyManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationViewHierarchyManagerTest.java
index 58fb53a..0248dc5 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationViewHierarchyManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationViewHierarchyManagerTest.java
@@ -41,7 +41,7 @@
import com.android.systemui.Dependency;
import com.android.systemui.InitController;
import com.android.systemui.SysuiTestCase;
-import com.android.systemui.bubbles.BubbleData;
+import com.android.systemui.bubbles.BubbleController;
import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper;
import com.android.systemui.statusbar.notification.DynamicPrivacyController;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
@@ -110,8 +110,9 @@
mViewHierarchyManager = new NotificationViewHierarchyManager(mContext,
mHandler, mLockscreenUserManager, mGroupManager, mVisualStabilityManager,
mock(StatusBarStateControllerImpl.class), mEntryManager,
- () -> mShadeController, new BubbleData(mContext),
+ () -> mShadeController,
mock(KeyguardBypassController.class),
+ mock(BubbleController.class),
mock(DynamicPrivacyController.class));
Dependency.get(InitController.class).executePostInitTasks();
mViewHierarchyManager.setUpWithPresenter(mPresenter, mListContainer);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/MediaNotificationProcessorTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/MediaNotificationProcessorTest.java
index 7eeae67..e6287e7 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/MediaNotificationProcessorTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/MediaNotificationProcessorTest.java
@@ -38,8 +38,8 @@
import androidx.palette.graphics.Palette;
import androidx.test.runner.AndroidJUnit4;
-import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
+import com.android.systemui.tests.R;
import org.junit.After;
import org.junit.Before;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentInflaterTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentInflaterTest.java
index 2ec125e..ccadcc3 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentInflaterTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentInflaterTest.java
@@ -23,7 +23,6 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
@@ -44,12 +43,12 @@
import androidx.test.filters.SmallTest;
-import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.statusbar.InflationTask;
import com.android.systemui.statusbar.NotificationTestHelper;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.row.NotificationContentInflater.InflationCallback;
+import com.android.systemui.tests.R;
import org.junit.Assert;
import org.junit.Before;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationCustomViewWrapperTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationCustomViewWrapperTest.java
index 63e18ce..49a6410 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationCustomViewWrapperTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationCustomViewWrapperTest.java
@@ -24,10 +24,10 @@
import androidx.test.filters.SmallTest;
-import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.statusbar.NotificationTestHelper;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
+import com.android.systemui.tests.R;
import org.junit.Assert;
import org.junit.Before;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java
index c851c91..31054260 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java
@@ -53,6 +53,7 @@
import com.android.systemui.InitController;
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
+import com.android.systemui.classifier.FalsingManagerFake;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.EmptyShadeView;
@@ -80,7 +81,6 @@
import com.android.systemui.statusbar.policy.ConfigurationController;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -165,7 +165,8 @@
mock(ActivityStarterDelegate.class),
mock(SysuiStatusBarStateController.class),
mHeadsUpManager,
- mKeyguardBypassController);
+ mKeyguardBypassController,
+ new FalsingManagerFake());
mStackScroller = spy(mStackScrollerInternal);
mStackScroller.setShelf(notificationShelf);
mStackScroller.setStatusBar(mBar);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelperTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelperTest.java
index b24c3dd..06a2eec 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelperTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelperTest.java
@@ -40,6 +40,7 @@
import com.android.systemui.SwipeHelper;
import com.android.systemui.SysuiTestCase;
+import com.android.systemui.classifier.FalsingManagerFake;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper.SnoozeOption;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
@@ -76,7 +77,8 @@
public void setUp() throws Exception {
mCallback = mock(NotificationSwipeHelper.NotificationCallback.class);
mListener = mock(NotificationMenuRowPlugin.OnMenuEventListener.class);
- mSwipeHelper = spy(new NotificationSwipeHelper(SwipeHelper.X, mCallback, mContext, mListener));
+ mSwipeHelper = spy(new NotificationSwipeHelper(
+ SwipeHelper.X, mCallback, mContext, mListener, new FalsingManagerFake()));
mView = mock(View.class);
mEvent = mock(MotionEvent.class);
mMenuRow = mock(NotificationMenuRowPlugin.class);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java
index d14b460..f94779d 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java
@@ -21,21 +21,26 @@
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.StatusBarManager;
+import android.hardware.biometrics.BiometricSourceType;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.MotionEvent;
+import android.view.View;
import android.view.ViewGroup;
import androidx.test.filters.SmallTest;
import com.android.keyguard.KeyguardStatusView;
+import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.SystemUIFactory;
import com.android.systemui.SysuiTestCase;
+import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.KeyguardAffordanceView;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
@@ -49,7 +54,6 @@
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.ZenModeController;
-import com.android.systemui.tuner.TunerService;
import com.android.systemui.util.InjectionInflationController;
import org.junit.Before;
@@ -98,6 +102,12 @@
private PanelBar mPanelBar;
@Mock
private KeyguardAffordanceHelper mAffordanceHelper;
+ @Mock
+ private KeyguardUpdateMonitor mUpdateMonitor;
+ @Mock
+ private FalsingManager mFalsingManager;
+ @Mock
+ private KeyguardBypassController mKeyguardBypassController;
private NotificationPanelView mNotificationPanelView;
@Before
@@ -112,18 +122,16 @@
mDependency.injectMockDependency(NotificationLockscreenUserManager.class);
mDependency.injectMockDependency(ConfigurationController.class);
mDependency.injectMockDependency(ZenModeController.class);
- KeyguardBypassController bypassController = new KeyguardBypassController(mContext,
- mock(TunerService.class), mStatusBarStateController,
- mock(NotificationLockscreenUserManager.class));
NotificationWakeUpCoordinator coordinator =
new NotificationWakeUpCoordinator(mContext,
mock(HeadsUpManagerPhone.class),
new StatusBarStateControllerImpl(),
- bypassController);
+ mKeyguardBypassController);
PulseExpansionHandler expansionHandler = new PulseExpansionHandler(mContext, coordinator,
- bypassController, mHeadsUpManager, mock(NotificationRoundnessManager.class));
+ mKeyguardBypassController, mHeadsUpManager,
+ mock(NotificationRoundnessManager.class), mStatusBarStateController);
mNotificationPanelView = new TestableNotificationPanelView(coordinator, expansionHandler,
- bypassController);
+ mKeyguardBypassController);
mNotificationPanelView.setHeadsUpManager(mHeadsUpManager);
mNotificationPanelView.setBar(mPanelBar);
@@ -183,6 +191,20 @@
assertThat(mNotificationPanelView.isTrackingBlocked()).isFalse();
}
+ @Test
+ public void testKeyguardStatusBarVisibility_hiddenForBypass() {
+ when(mUpdateMonitor.shouldListenForFace()).thenReturn(true);
+ mNotificationPanelView.mKeyguardUpdateCallback.onBiometricRunningStateChanged(true,
+ BiometricSourceType.FACE);
+ verify(mKeyguardStatusBar, never()).setVisibility(View.VISIBLE);
+
+ when(mKeyguardBypassController.getBypassEnabled()).thenReturn(true);
+ mNotificationPanelView.mKeyguardUpdateCallback.onFinishedGoingToSleep(0);
+ mNotificationPanelView.mKeyguardUpdateCallback.onBiometricRunningStateChanged(true,
+ BiometricSourceType.FACE);
+ verify(mKeyguardStatusBar, never()).setVisibility(View.VISIBLE);
+ }
+
private class TestableNotificationPanelView extends NotificationPanelView {
TestableNotificationPanelView(NotificationWakeUpCoordinator coordinator,
PulseExpansionHandler expansionHandler,
@@ -191,7 +213,8 @@
new InjectionInflationController(
SystemUIFactory.getInstance().getRootComponent()),
coordinator, expansionHandler, mock(DynamicPrivacyController.class),
- bypassController);
+ bypassController,
+ mFalsingManager);
mNotificationStackScroller = mNotificationStackScrollLayout;
mKeyguardStatusView = NotificationPanelViewTest.this.mKeyguardStatusView;
mKeyguardStatusBar = NotificationPanelViewTest.this.mKeyguardStatusBar;
@@ -199,6 +222,7 @@
mBigClockContainer = NotificationPanelViewTest.this.mBigClockContainer;
mQsFrame = NotificationPanelViewTest.this.mQsFrame;
mAffordanceHelper = NotificationPanelViewTest.this.mAffordanceHelper;
+ mUpdateMonitor = NotificationPanelViewTest.this.mUpdateMonitor;
initDependencies(NotificationPanelViewTest.this.mStatusBar,
NotificationPanelViewTest.this.mGroupManager,
NotificationPanelViewTest.this.mNotificationShelf,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java
index 97ad47e..e05ad09 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java
@@ -16,9 +16,9 @@
package com.android.systemui.statusbar.phone;
-import static com.android.systemui.statusbar.phone.ScrimController.VISIBILITY_FULLY_OPAQUE;
-import static com.android.systemui.statusbar.phone.ScrimController.VISIBILITY_FULLY_TRANSPARENT;
-import static com.android.systemui.statusbar.phone.ScrimController.VISIBILITY_SEMI_TRANSPARENT;
+import static com.android.systemui.statusbar.phone.ScrimController.OPAQUE;
+import static com.android.systemui.statusbar.phone.ScrimController.SEMI_TRANSPARENT;
+import static com.android.systemui.statusbar.phone.ScrimController.TRANSPARENT;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
@@ -69,6 +69,7 @@
private SynchronousScrimController mScrimController;
private ScrimView mScrimBehind;
private ScrimView mScrimInFront;
+ private ScrimView mScrimForBubble;
private ScrimState mScrimState;
private float mScrimBehindAlpha;
private GradientColors mScrimInFrontColor;
@@ -84,6 +85,7 @@
public void setup() {
mScrimBehind = spy(new ScrimView(getContext()));
mScrimInFront = new ScrimView(getContext());
+ mScrimForBubble = new ScrimView(getContext());
mWakeLock = mock(WakeLock.class);
mAlarmManager = mock(AlarmManager.class);
mAlwaysOnEnabled = true;
@@ -92,6 +94,7 @@
when(mDozeParamenters.getAlwaysOn()).thenAnswer(invocation -> mAlwaysOnEnabled);
when(mDozeParamenters.getDisplayNeedsBlanking()).thenReturn(true);
mScrimController = new SynchronousScrimController(mScrimBehind, mScrimInFront,
+ mScrimForBubble,
(scrimState, scrimBehindAlpha, scrimInFrontColor) -> {
mScrimState = scrimState;
mScrimBehindAlpha = scrimBehindAlpha;
@@ -114,21 +117,28 @@
public void transitionToKeyguard() {
mScrimController.transitionTo(ScrimState.KEYGUARD);
mScrimController.finishAnimationsImmediately();
- // Front scrim should be transparent
- // Back scrim should be visible without tint
- assertScrimVisibility(VISIBILITY_FULLY_TRANSPARENT, VISIBILITY_SEMI_TRANSPARENT);
- assertScrimTint(mScrimBehind, true /* tinted */);
+
+ assertScrimAlpha(TRANSPARENT /* front */,
+ SEMI_TRANSPARENT /* back */,
+ TRANSPARENT /* bubble */);
+
+ assertScrimTint(true /* front */,
+ true /* behind */,
+ false /* bubble */);
}
@Test
public void transitionToAod_withRegularWallpaper() {
mScrimController.transitionTo(ScrimState.AOD);
mScrimController.finishAnimationsImmediately();
- // Front scrim should be transparent
- // Back scrim should be visible with tint
- assertScrimVisibility(VISIBILITY_FULLY_TRANSPARENT, VISIBILITY_FULLY_OPAQUE);
- assertScrimTint(mScrimBehind, true /* tinted */);
- assertScrimTint(mScrimInFront, true /* tinted */);
+
+ assertScrimAlpha(TRANSPARENT /* front */,
+ OPAQUE /* back */,
+ TRANSPARENT /* bubble */);
+
+ assertScrimTint(true /* front */,
+ true /* behind */,
+ false /* bubble */);
}
@Test
@@ -136,14 +146,18 @@
mScrimController.setWallpaperSupportsAmbientMode(true);
mScrimController.transitionTo(ScrimState.AOD);
mScrimController.finishAnimationsImmediately();
- // Front scrim should be transparent
- // Back scrim should be transparent
- assertScrimVisibility(VISIBILITY_FULLY_TRANSPARENT, VISIBILITY_FULLY_TRANSPARENT);
+
+ assertScrimAlpha(TRANSPARENT /* front */,
+ TRANSPARENT /* back */,
+ TRANSPARENT /* bubble */);
// Pulsing notification should conserve AOD wallpaper.
mScrimController.transitionTo(ScrimState.PULSING);
mScrimController.finishAnimationsImmediately();
- assertScrimVisibility(VISIBILITY_FULLY_TRANSPARENT, VISIBILITY_FULLY_TRANSPARENT);
+
+ assertScrimAlpha(TRANSPARENT /* front */,
+ TRANSPARENT /* back */,
+ TRANSPARENT /* bubble */);
}
@Test
@@ -152,11 +166,14 @@
mScrimController.setWallpaperSupportsAmbientMode(true);
mScrimController.transitionTo(ScrimState.AOD);
mScrimController.finishAnimationsImmediately();
- // Front scrim should be transparent
- // Back scrim should be visible with tint
- assertScrimVisibility(VISIBILITY_FULLY_TRANSPARENT, VISIBILITY_FULLY_OPAQUE);
- assertScrimTint(mScrimBehind, true /* tinted */);
- assertScrimTint(mScrimInFront, true /* tinted */);
+
+ assertScrimAlpha(TRANSPARENT /* front */,
+ OPAQUE /* back */,
+ TRANSPARENT /* bubble */);
+
+ assertScrimTint(true /* front */,
+ true /* behind */,
+ false /* bubble */);
}
@Test
@@ -166,11 +183,14 @@
mScrimController.finishAnimationsImmediately();
mScrimController.setHasBackdrop(true);
mScrimController.finishAnimationsImmediately();
- // Front scrim should be transparent
- // Back scrim should be visible with tint
- assertScrimVisibility(VISIBILITY_FULLY_TRANSPARENT, VISIBILITY_FULLY_OPAQUE);
- assertScrimTint(mScrimBehind, true /* tinted */);
- assertScrimTint(mScrimInFront, true /* tinted */);
+
+ assertScrimAlpha(TRANSPARENT /* front */,
+ OPAQUE /* back */,
+ TRANSPARENT /* bubble */);
+
+ assertScrimTint(true /* front */,
+ true /* behind */,
+ false /* bubble */);
}
@Test
@@ -179,27 +199,32 @@
mScrimController.transitionTo(ScrimState.KEYGUARD);
mScrimController.setAodFrontScrimAlpha(0.5f);
mScrimController.finishAnimationsImmediately();
- // Front scrim should be transparent
- // Back scrim should be visible without tint
- assertScrimVisibility(VISIBILITY_FULLY_TRANSPARENT, VISIBILITY_SEMI_TRANSPARENT);
+
+ assertScrimAlpha(TRANSPARENT /* front */,
+ SEMI_TRANSPARENT /* back */,
+ TRANSPARENT /* bubble */);
// ... but that it does take effect once we enter the AOD state.
mScrimController.transitionTo(ScrimState.AOD);
mScrimController.finishAnimationsImmediately();
- // Front scrim should be semi-transparent
- // Back scrim should be visible
- assertScrimVisibility(VISIBILITY_SEMI_TRANSPARENT, VISIBILITY_FULLY_OPAQUE);
+ assertScrimAlpha(SEMI_TRANSPARENT /* front */,
+ OPAQUE /* back */,
+ TRANSPARENT /* bubble */);
// ... and that if we set it while we're in AOD, it does take immediate effect.
mScrimController.setAodFrontScrimAlpha(1f);
- assertScrimVisibility(VISIBILITY_FULLY_OPAQUE, VISIBILITY_FULLY_OPAQUE);
+ assertScrimAlpha(OPAQUE /* front */,
+ OPAQUE /* back */,
+ TRANSPARENT /* bubble */);
// ... and make sure we recall the previous front scrim alpha even if we transition away
// for a bit.
mScrimController.transitionTo(ScrimState.UNLOCKED);
mScrimController.transitionTo(ScrimState.AOD);
mScrimController.finishAnimationsImmediately();
- assertScrimVisibility(VISIBILITY_FULLY_OPAQUE, VISIBILITY_FULLY_OPAQUE);
+ assertScrimAlpha(OPAQUE /* front */,
+ OPAQUE /* back */,
+ TRANSPARENT /* bubble */);
// ... and alpha updates should be completely ignored if always_on is off.
// Passing it forward would mess up the wake-up transition.
@@ -216,27 +241,46 @@
}
@Test
- public void transitionToPulsing() {
+ public void transitionToPulsing_withFrontAlphaUpdates() {
// Pre-condition
// Need to go to AoD first because PULSING doesn't change
// the back scrim opacity - otherwise it would hide AoD wallpapers.
mScrimController.setWallpaperSupportsAmbientMode(false);
mScrimController.transitionTo(ScrimState.AOD);
mScrimController.finishAnimationsImmediately();
- assertScrimVisibility(VISIBILITY_FULLY_TRANSPARENT, VISIBILITY_FULLY_OPAQUE);
+ assertScrimAlpha(TRANSPARENT /* front */,
+ OPAQUE /* back */,
+ TRANSPARENT /* bubble */);
mScrimController.transitionTo(ScrimState.PULSING);
mScrimController.finishAnimationsImmediately();
// Front scrim should be transparent, but tinted
// Back scrim should be semi-transparent so the user can see the wallpaper
// Pulse callback should have been invoked
- assertScrimVisibility(VISIBILITY_FULLY_TRANSPARENT, VISIBILITY_FULLY_OPAQUE);
- assertScrimTint(mScrimBehind, true /* tinted */);
- assertScrimTint(mScrimInFront, true /* tinted */);
+ assertScrimAlpha(TRANSPARENT /* front */,
+ OPAQUE /* back */,
+ TRANSPARENT /* bubble */);
+
+ assertScrimTint(true /* front */,
+ true /* behind */,
+ false /* bubble */);
+
+ // ... and when ambient goes dark, front scrim should be semi-transparent
+ mScrimController.setAodFrontScrimAlpha(0.5f);
+ mScrimController.finishAnimationsImmediately();
+ // Front scrim should be semi-transparent
+ assertScrimAlpha(SEMI_TRANSPARENT /* front */,
+ OPAQUE /* back */,
+ TRANSPARENT /* bubble */);
mScrimController.setWakeLockScreenSensorActive(true);
mScrimController.finishAnimationsImmediately();
- assertScrimVisibility(VISIBILITY_FULLY_TRANSPARENT, VISIBILITY_SEMI_TRANSPARENT);
+ assertScrimAlpha(SEMI_TRANSPARENT /* front */,
+ SEMI_TRANSPARENT /* back */,
+ TRANSPARENT /* bubble */);
+
+ // Reset value since enums are static.
+ mScrimController.setAodFrontScrimAlpha(0f);
}
@Test
@@ -245,8 +289,13 @@
mScrimController.finishAnimationsImmediately();
// Front scrim should be transparent
// Back scrim should be visible without tint
- assertScrimVisibility(VISIBILITY_FULLY_TRANSPARENT, VISIBILITY_SEMI_TRANSPARENT);
- assertScrimTint(mScrimBehind, false /* tinted */);
+ assertScrimAlpha(TRANSPARENT /* front */,
+ SEMI_TRANSPARENT /* back */,
+ TRANSPARENT /* bubble */);
+
+ assertScrimTint(false /* front */,
+ false /* behind */,
+ false /* bubble */);
}
@Test
@@ -255,8 +304,12 @@
mScrimController.finishAnimationsImmediately();
// Front scrim should be transparent
// Back scrim should be visible without tint
- assertScrimVisibility(VISIBILITY_SEMI_TRANSPARENT, VISIBILITY_FULLY_TRANSPARENT);
- assertScrimTint(mScrimBehind, false /* tinted */);
+ assertScrimAlpha(SEMI_TRANSPARENT /* front */,
+ TRANSPARENT /* back */,
+ TRANSPARENT /* bubble */);
+ assertScrimTint(false /* front */,
+ false /* behind */,
+ false /* bubble */);
}
@Test
@@ -264,15 +317,19 @@
mScrimController.setPanelExpansion(0f);
mScrimController.transitionTo(ScrimState.UNLOCKED);
mScrimController.finishAnimationsImmediately();
- // Front scrim should be transparent
- // Back scrim should be transparent
- assertScrimVisibility(VISIBILITY_FULLY_TRANSPARENT, VISIBILITY_FULLY_TRANSPARENT);
- assertScrimTint(mScrimBehind, false /* tinted */);
- assertScrimTint(mScrimInFront, false /* tinted */);
+ assertScrimAlpha(TRANSPARENT /* front */,
+ TRANSPARENT /* back */,
+ TRANSPARENT /* bubble */);
+
+ assertScrimTint(false /* front */,
+ false /* behind */,
+ false /* bubble */);
// Back scrim should be visible after start dragging
mScrimController.setPanelExpansion(0.5f);
- assertScrimVisibility(VISIBILITY_FULLY_TRANSPARENT, VISIBILITY_SEMI_TRANSPARENT);
+ assertScrimAlpha(TRANSPARENT /* front */,
+ SEMI_TRANSPARENT /* back */,
+ TRANSPARENT /* bubble */);
}
@Test
@@ -280,12 +337,19 @@
mScrimController.transitionTo(ScrimState.BUBBLE_EXPANDED);
mScrimController.finishAnimationsImmediately();
+ assertScrimTint(false /* front */,
+ false /* behind */,
+ false /* bubble */);
+
// Front scrim should be transparent
- Assert.assertEquals(ScrimController.VISIBILITY_FULLY_TRANSPARENT,
+ Assert.assertEquals(ScrimController.TRANSPARENT,
mScrimInFront.getViewAlpha(), 0.0f);
// Back scrim should be visible
Assert.assertEquals(ScrimController.GRADIENT_SCRIM_ALPHA_BUSY,
mScrimBehind.getViewAlpha(), 0.0f);
+ // Bubble scrim should be visible
+ Assert.assertEquals(ScrimController.GRADIENT_SCRIM_ALPHA_BUSY,
+ mScrimBehind.getViewAlpha(), 0.0f);
}
@Test
@@ -354,16 +418,22 @@
mScrimController.setPanelExpansion(0f);
mScrimController.finishAnimationsImmediately();
mScrimController.transitionTo(ScrimState.UNLOCKED);
- // Immediately tinted after the transition starts
- assertScrimTint(mScrimInFront, true /* tinted */);
- assertScrimTint(mScrimBehind, true /* tinted */);
+
+ // Immediately tinted black after the transition starts
+ assertScrimTint(true /* front */,
+ true /* behind */,
+ true /* bubble */);
+
mScrimController.finishAnimationsImmediately();
- // Front scrim should be transparent
- // Back scrim should be transparent
- // Neither scrims should be tinted anymore after the animation.
- assertScrimVisibility(VISIBILITY_FULLY_TRANSPARENT, VISIBILITY_FULLY_TRANSPARENT);
- assertScrimTint(mScrimInFront, false /* tinted */);
- assertScrimTint(mScrimBehind, false /* tinted */);
+
+ // All scrims should be transparent at the end of fade transition.
+ assertScrimAlpha(TRANSPARENT /* front */,
+ TRANSPARENT /* behind */,
+ TRANSPARENT /* bubble */);
+
+ assertScrimTint(false /* front */,
+ false /* behind */,
+ false /* bubble */);
}
@Test
@@ -378,9 +448,11 @@
// Front scrim should be black in the middle of the transition
Assert.assertTrue("Scrim should be visible during transition. Alpha: "
+ mScrimInFront.getViewAlpha(), mScrimInFront.getViewAlpha() > 0);
- assertScrimTint(mScrimInFront, true /* tinted */);
+ assertScrimTint(true /* front */,
+ true /* behind */,
+ true /* bubble */);
Assert.assertSame("Scrim should be visible during transition.",
- mScrimVisibility, VISIBILITY_FULLY_OPAQUE);
+ mScrimVisibility, OPAQUE);
}
});
mScrimController.finishAnimationsImmediately();
@@ -588,11 +660,15 @@
mScrimController.setKeyguardOccluded(true);
mScrimController.transitionTo(ScrimState.AOD);
mScrimController.finishAnimationsImmediately();
- assertScrimVisibility(VISIBILITY_FULLY_TRANSPARENT, VISIBILITY_FULLY_OPAQUE);
+ assertScrimAlpha(TRANSPARENT /* front */,
+ OPAQUE /* behind */,
+ TRANSPARENT /* bubble */);
mScrimController.transitionTo(ScrimState.PULSING);
mScrimController.finishAnimationsImmediately();
- assertScrimVisibility(VISIBILITY_FULLY_TRANSPARENT, VISIBILITY_FULLY_OPAQUE);
+ assertScrimAlpha(TRANSPARENT /* front */,
+ OPAQUE /* behind */,
+ TRANSPARENT /* bubble */);
}
@Test
@@ -600,11 +676,15 @@
mScrimController.setWallpaperSupportsAmbientMode(true);
mScrimController.transitionTo(ScrimState.AOD);
mScrimController.finishAnimationsImmediately();
- assertScrimVisibility(VISIBILITY_FULLY_TRANSPARENT, VISIBILITY_FULLY_TRANSPARENT);
+ assertScrimAlpha(TRANSPARENT /* front */,
+ TRANSPARENT /* behind */,
+ TRANSPARENT /* bubble */);
mScrimController.setKeyguardOccluded(true);
mScrimController.finishAnimationsImmediately();
- assertScrimVisibility(VISIBILITY_FULLY_TRANSPARENT, VISIBILITY_FULLY_OPAQUE);
+ assertScrimAlpha(TRANSPARENT /* front */,
+ OPAQUE /* behind */,
+ TRANSPARENT /* bubble */);
}
@Test
@@ -643,33 +723,68 @@
mScrimInFront.getDefaultFocusHighlightEnabled());
Assert.assertFalse("Scrim shouldn't have focus highlight",
mScrimBehind.getDefaultFocusHighlightEnabled());
+ Assert.assertFalse("Scrim shouldn't have focus highlight",
+ mScrimForBubble.getDefaultFocusHighlightEnabled());
}
- private void assertScrimTint(ScrimView scrimView, boolean tinted) {
- final boolean viewIsTinted = scrimView.getTint() != Color.TRANSPARENT;
- final String name = scrimView == mScrimInFront ? "front" : "back";
+ private void assertScrimTint(boolean front, boolean behind, boolean bubble) {
Assert.assertEquals("Tint test failed at state " + mScrimController.getState()
- +" with scrim: " + name + " and tint: " + Integer.toHexString(scrimView.getTint()),
- tinted, viewIsTinted);
+ + " with scrim: " + getScrimName(mScrimInFront) + " and tint: "
+ + Integer.toHexString(mScrimInFront.getTint()),
+ front, mScrimInFront.getTint() != Color.TRANSPARENT);
+
+ Assert.assertEquals("Tint test failed at state " + mScrimController.getState()
+ + " with scrim: " + getScrimName(mScrimBehind) + " and tint: "
+ + Integer.toHexString(mScrimBehind.getTint()),
+ behind, mScrimBehind.getTint() != Color.TRANSPARENT);
+
+ Assert.assertEquals("Tint test failed at state " + mScrimController.getState()
+ + " with scrim: " + getScrimName(mScrimForBubble) + " and tint: "
+ + Integer.toHexString(mScrimForBubble.getTint()),
+ bubble, mScrimForBubble.getTint() != Color.TRANSPARENT);
}
- private void assertScrimVisibility(int inFront, int behind) {
- boolean inFrontVisible = inFront != ScrimController.VISIBILITY_FULLY_TRANSPARENT;
- boolean behindVisible = behind != ScrimController.VISIBILITY_FULLY_TRANSPARENT;
- Assert.assertEquals("Unexpected front scrim visibility. Alpha is "
- + mScrimInFront.getViewAlpha(), inFrontVisible, mScrimInFront.getViewAlpha() > 0);
- Assert.assertEquals("Unexpected back scrim visibility. Alpha is "
- + mScrimBehind.getViewAlpha(), behindVisible, mScrimBehind.getViewAlpha() > 0);
-
- final int visibility;
- if (inFront == VISIBILITY_FULLY_OPAQUE || behind == VISIBILITY_FULLY_OPAQUE) {
- visibility = VISIBILITY_FULLY_OPAQUE;
- } else if (inFront > VISIBILITY_FULLY_TRANSPARENT || behind > VISIBILITY_FULLY_TRANSPARENT) {
- visibility = VISIBILITY_SEMI_TRANSPARENT;
- } else {
- visibility = VISIBILITY_FULLY_TRANSPARENT;
+ private String getScrimName(ScrimView scrim) {
+ if (scrim == mScrimInFront) {
+ return "front";
+ } else if (scrim == mScrimBehind) {
+ return "back";
+ } else if (scrim == mScrimForBubble) {
+ return "bubble";
}
- Assert.assertEquals("Invalid visibility.", visibility, mScrimVisibility);
+ return "unknown_scrim";
+ }
+
+ private void assertScrimAlpha(int front, int behind, int bubble) {
+ // Check single scrim visibility.
+ Assert.assertEquals("Unexpected front scrim alpha: "
+ + mScrimInFront.getViewAlpha(),
+ front != TRANSPARENT /* expected */,
+ mScrimInFront.getViewAlpha() > TRANSPARENT /* actual */);
+
+ Assert.assertEquals("Unexpected back scrim alpha: "
+ + mScrimBehind.getViewAlpha(),
+ behind != TRANSPARENT /* expected */,
+ mScrimBehind.getViewAlpha() > TRANSPARENT /* actual */);
+
+ Assert.assertEquals(
+ "Unexpected bubble scrim alpha: "
+ + mScrimForBubble.getViewAlpha(), /* message */
+ bubble != TRANSPARENT /* expected */,
+ mScrimForBubble.getViewAlpha() > TRANSPARENT /* actual */);
+
+ // Check combined scrim visibility.
+ final int visibility;
+ if (front == OPAQUE || behind == OPAQUE || bubble == OPAQUE) {
+ visibility = OPAQUE;
+ } else if (front > TRANSPARENT || behind > TRANSPARENT || bubble > TRANSPARENT) {
+ visibility = SEMI_TRANSPARENT;
+ } else {
+ visibility = TRANSPARENT;
+ }
+ Assert.assertEquals("Invalid visibility.",
+ visibility /* expected */,
+ mScrimVisibility);
}
/**
@@ -681,11 +796,12 @@
boolean mOnPreDrawCalled;
SynchronousScrimController(ScrimView scrimBehind, ScrimView scrimInFront,
+ ScrimView scrimForBubble,
TriConsumer<ScrimState, Float, GradientColors> scrimStateListener,
Consumer<Integer> scrimVisibleListener, DozeParameters dozeParameters,
AlarmManager alarmManager, KeyguardMonitor keyguardMonitor) {
- super(scrimBehind, scrimInFront, scrimStateListener, scrimVisibleListener,
- dozeParameters, alarmManager, keyguardMonitor);
+ super(scrimBehind, scrimInFront, scrimForBubble, scrimStateListener,
+ scrimVisibleListener, dozeParameters, alarmManager, keyguardMonitor);
}
@Override
@@ -696,13 +812,14 @@
void finishAnimationsImmediately() {
boolean[] animationFinished = {false};
- setOnAnimationFinished(()-> animationFinished[0] = true);
+ setOnAnimationFinished(() -> animationFinished[0] = true);
// Execute code that will trigger animations.
onPreDraw();
// Force finish all animations.
mLooper.processAllMessages();
endAnimation(mScrimBehind, TAG_KEY_ANIM);
endAnimation(mScrimInFront, TAG_KEY_ANIM);
+ endAnimation(mScrimForBubble, TAG_KEY_ANIM);
if (!animationFinished[0]) {
throw new IllegalStateException("Animation never finished");
@@ -740,6 +857,7 @@
/**
* Do not wait for a frame since we're in a test environment.
+ *
* @param callback What to execute.
*/
@Override
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java
index da2e8dc..63f653b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java
@@ -39,8 +39,10 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.ViewMediatorCallback;
import com.android.systemui.SysuiTestCase;
+import com.android.systemui.classifier.FalsingManagerFake;
import com.android.systemui.keyguard.DismissCallbackRegistry;
import com.android.systemui.plugins.ActivityStarter.OnDismissAction;
+import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
@@ -93,7 +95,8 @@
mViewMediatorCallback, mLockPatternUtils);
mStatusBarKeyguardViewManager.registerStatusBar(mStatusBar, mContainer,
mNotificationPanelView, mBiometrucUnlockController, mDismissCallbackRegistry,
- mLockIconContainer, mNotificationContainer, mBypassController);
+ mLockIconContainer, mNotificationContainer, mBypassController,
+ new FalsingManagerFake());
mStatusBarKeyguardViewManager.show(null);
}
@@ -232,11 +235,11 @@
BiometricUnlockController fingerprintUnlockController,
DismissCallbackRegistry dismissCallbackRegistry,
ViewGroup lockIconContainer, View notificationContainer,
- KeyguardBypassController bypassController) {
+ KeyguardBypassController bypassController, FalsingManager falsingManager) {
super.registerStatusBar(statusBar, container, notificationPanelView,
fingerprintUnlockController, dismissCallbackRegistry, lockIconContainer,
- notificationContainer, bypassController);
+ notificationContainer, bypassController, falsingManager);
mBouncer = StatusBarKeyguardViewManagerTest.this.mBouncer;
}
}
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterTest.java
index 06d76eb..5a6f27d 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterTest.java
@@ -153,8 +153,6 @@
StatusBarNotification bubbleSbn = mBubbleNotificationRow.getStatusBarNotification();
bubbleSbn.getNotification().contentIntent = mContentIntent;
bubbleSbn.getNotification().flags |= Notification.FLAG_AUTO_CANCEL;
- // Do what BubbleController's NotificationEntryListener#onPendingEntryAdded does:
- mBubbleNotificationRow.getEntry().setShowInShadeWhenBubble(true);
mActiveNotifications = new ArrayList<>();
mActiveNotifications.add(mNotificationRow.getEntry());
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarRemoteInputCallbackTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarRemoteInputCallbackTest.java
index a97832f..4b6ca56 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarRemoteInputCallbackTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarRemoteInputCallbackTest.java
@@ -68,7 +68,7 @@
mDependency.injectTestDependency(ShadeController.class, mShadeController);
mDependency.injectTestDependency(NotificationLockscreenUserManager.class,
mNotificationLockscreenUserManager);
- mDependency.putComponent(CommandQueue.class, mock(CommandQueue.class));
+ mContext.putComponent(CommandQueue.class, mock(CommandQueue.class));
mRemoteInputCallback = spy(new StatusBarRemoteInputCallback(mContext,
mock(NotificationGroupManager.class)));
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java
index fa235bd..178ff22 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java
@@ -208,7 +208,8 @@
mNotificationInterruptionStateProvider =
new TestableNotificationInterruptionStateProvider(mContext, mPowerManager,
- mDreamManager, mAmbientDisplayConfiguration);
+ mDreamManager, mAmbientDisplayConfiguration, mNotificationFilter,
+ mStatusBarStateController);
mDependency.injectTestDependency(NotificationInterruptionStateProvider.class,
mNotificationInterruptionStateProvider);
mDependency.injectMockDependency(NavigationBarController.class);
@@ -870,8 +871,11 @@
Context context,
PowerManager powerManager,
IDreamManager dreamManager,
- AmbientDisplayConfiguration ambientDisplayConfiguration) {
- super(context, powerManager, dreamManager, ambientDisplayConfiguration);
+ AmbientDisplayConfiguration ambientDisplayConfiguration,
+ NotificationFilter filter,
+ StatusBarStateController controller) {
+ super(context, powerManager, dreamManager, ambientDisplayConfiguration, filter,
+ controller);
mUseHeadsUp = true;
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java
index edc513b..354aa83 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java
@@ -30,6 +30,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import android.app.Instrumentation;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.Network;
@@ -48,6 +49,8 @@
import android.testing.TestableResources;
import android.util.Log;
+import androidx.test.InstrumentationRegistry;
+
import com.android.internal.telephony.cdma.EriInfo;
import com.android.settingslib.graph.SignalDrawable;
import com.android.settingslib.net.DataUsageController;
@@ -95,6 +98,7 @@
protected SubscriptionDefaults mMockSubDefaults;
protected DeviceProvisionedController mMockProvisionController;
protected DeviceProvisionedListener mUserCallback;
+ protected Instrumentation mInstrumentation;
protected int mSubId;
@@ -116,6 +120,7 @@
@Before
public void setUp() throws Exception {
+ mInstrumentation = InstrumentationRegistry.getInstrumentation();
Settings.Global.putInt(mContext.getContentResolver(), Global.AIRPLANE_MODE_ON, 0);
TestableResources res = mContext.getOrCreateTestableResources();
res.addOverride(R.string.cell_data_off_content_description, NO_DATA_STRING);
@@ -228,6 +233,28 @@
NetworkControllerImpl.Config.add5GIconMapping("connected:5g", mConfig);
}
+ public void setupNr5GIconConfigurationForNotRestrictedRrcCon() {
+ NetworkControllerImpl.Config.add5GIconMapping("connected_mmwave:5g_plus", mConfig);
+ NetworkControllerImpl.Config.add5GIconMapping("connected:5g_plus", mConfig);
+ NetworkControllerImpl.Config.add5GIconMapping("not_restricted_rrc_con:5g", mConfig);
+ }
+
+ public void setupNr5GIconConfigurationForNotRestrictedRrcIdle() {
+ NetworkControllerImpl.Config.add5GIconMapping("connected_mmwave:5g_plus", mConfig);
+ NetworkControllerImpl.Config.add5GIconMapping("connected:5g_plus", mConfig);
+ NetworkControllerImpl.Config.add5GIconMapping("not_restricted_rrc_idle:5g", mConfig);
+ }
+
+ public void setupDefaultNr5GIconDisplayGracePeriodTime_enableThirtySeconds() {
+ final int enableDisplayGraceTimeSec = 30;
+ NetworkControllerImpl.Config.setDisplayGraceTime(enableDisplayGraceTimeSec, mConfig);
+ }
+
+ public void setupDefaultNr5GIconDisplayGracePeriodTime_disabled() {
+ final int disableDisplayGraceTimeSec = 0;
+ NetworkControllerImpl.Config.setDisplayGraceTime(disableDisplayGraceTimeSec, mConfig);
+ }
+
public void setConnectivityViaBroadcast(
int networkType, boolean validated, boolean isConnected) {
setConnectivityCommon(networkType, validated, isConnected);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java
index 5128675..aa4723a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java
@@ -1,5 +1,7 @@
package com.android.systemui.statusbar.policy;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -145,7 +147,7 @@
}
@Test
- public void testNoInternetIcon_withoutDefaultSub() {
+ public void testNonDefaultSIM_showsFullSignal_connected() {
setupNetworkController();
when(mMockTm.isDataCapable()).thenReturn(false);
setupDefaultSignal();
@@ -156,11 +158,11 @@
// Verify that a SignalDrawable with a cut out is used to display data disabled.
verifyLastMobileDataIndicators(true, DEFAULT_SIGNAL_STRENGTH, 0,
true, DEFAULT_QS_SIGNAL_STRENGTH, 0, false,
- false, true, NOT_DEFAULT_DATA_STRING);
+ false, false, NOT_DEFAULT_DATA_STRING);
}
@Test
- public void testDataDisabledIcon_withoutDefaultSub() {
+ public void testNonDefaultSIM_showsFullSignal_disconnected() {
setupNetworkController();
when(mMockTm.isDataCapable()).thenReturn(false);
setupDefaultSignal();
@@ -171,7 +173,36 @@
// Verify that a SignalDrawable with a cut out is used to display data disabled.
verifyLastMobileDataIndicators(true, DEFAULT_SIGNAL_STRENGTH, 0,
true, DEFAULT_QS_SIGNAL_STRENGTH, 0, false,
- false, true, NOT_DEFAULT_DATA_STRING);
+ false, false, NOT_DEFAULT_DATA_STRING);
+ }
+
+ @Test
+ public void testNr5GIcon_NrNotRestrictedRrcCon_show5GIcon() {
+ setupNr5GIconConfigurationForNotRestrictedRrcCon();
+ setupDefaultSignal();
+ updateDataConnectionState(TelephonyManager.DATA_CONNECTED,
+ TelephonyManager.NETWORK_TYPE_LTE);
+ updateDataActivity(TelephonyManager.DATA_ACTIVITY_INOUT);
+ ServiceState ss = Mockito.mock(ServiceState.class);
+ doReturn(NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED).when(ss).getNrState();
+ mPhoneStateListener.onServiceStateChanged(ss);
+
+ verifyLastMobileDataIndicators(true, DEFAULT_SIGNAL_STRENGTH, TelephonyIcons.ICON_5G,
+ true, DEFAULT_QS_SIGNAL_STRENGTH, TelephonyIcons.ICON_5G, true, true);
+ }
+
+ @Test
+ public void testNr5GIcon_NrNotRestrictedRrcIdle_show5GIcon() {
+ setupNr5GIconConfigurationForNotRestrictedRrcIdle();
+ setupDefaultSignal();
+ updateDataConnectionState(TelephonyManager.DATA_CONNECTED,
+ TelephonyManager.NETWORK_TYPE_LTE);
+ updateDataActivity(TelephonyManager.DATA_ACTIVITY_DORMANT);
+ ServiceState ss = Mockito.mock(ServiceState.class);
+ doReturn(NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED).when(ss).getNrState();
+ mPhoneStateListener.onServiceStateChanged(ss);
+
+ verifyDataIndicators(TelephonyIcons.ICON_5G);
}
@Test
@@ -216,6 +247,186 @@
}
@Test
+ public void testNr5GIcon_displayGracePeriodTime_enabled() {
+ setupDefaultNr5GIconConfiguration();
+ setupDefaultNr5GIconDisplayGracePeriodTime_enableThirtySeconds();
+ setupDefaultSignal();
+ mNetworkController.handleConfigurationChanged();
+ mPhoneStateListener.onServiceStateChanged(mServiceState);
+
+ ServiceState ss = Mockito.mock(ServiceState.class);
+ // While nrIconDisplayGracePeriodMs > 0 & is Nr5G, mIsShowingIconGracefully should be true
+ doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(ss).getNrState();
+ doReturn(ServiceState.FREQUENCY_RANGE_HIGH).when(ss).getNrFrequencyRange();
+ mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED,
+ TelephonyManager.NETWORK_TYPE_LTE);
+ mPhoneStateListener.onServiceStateChanged(ss);
+
+ assertTrue(mConfig.nrIconDisplayGracePeriodMs > 0);
+ assertTrue(mMobileSignalController.mIsShowingIconGracefully);
+ }
+
+ @Test
+ public void testNr5GIcon_displayGracePeriodTime_disabled() {
+ setupDefaultNr5GIconConfiguration();
+ setupDefaultNr5GIconDisplayGracePeriodTime_disabled();
+ setupDefaultSignal();
+
+ assertTrue(mConfig.nrIconDisplayGracePeriodMs == 0);
+
+ // While nrIconDisplayGracePeriodMs <= 0, mIsShowingIconGracefully should be false
+ doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(mServiceState).getNrState();
+ doReturn(ServiceState.FREQUENCY_RANGE_HIGH).when(mServiceState).getNrFrequencyRange();
+ mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED,
+ TelephonyManager.NETWORK_TYPE_LTE);
+
+ assertFalse(mMobileSignalController.mIsShowingIconGracefully);
+ }
+
+ @Test
+ public void testNr5GIcon_enableDisplayGracePeriodTime_showIconGracefully() {
+ setupDefaultNr5GIconConfiguration();
+ setupDefaultNr5GIconDisplayGracePeriodTime_enableThirtySeconds();
+ setupDefaultSignal();
+ mNetworkController.handleConfigurationChanged();
+ mPhoneStateListener.onServiceStateChanged(mServiceState);
+
+ ServiceState ss = Mockito.mock(ServiceState.class);
+ doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(ss).getNrState();
+ doReturn(ServiceState.FREQUENCY_RANGE_HIGH).when(ss).getNrFrequencyRange();
+ mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED,
+ TelephonyManager.NETWORK_TYPE_LTE);
+ mPhoneStateListener.onServiceStateChanged(ss);
+
+ verifyDataIndicators(TelephonyIcons.ICON_5G);
+
+ // Enabled timer Nr5G switch to None Nr5G, showing 5G icon gracefully
+ ServiceState ssLte = Mockito.mock(ServiceState.class);
+ doReturn(NetworkRegistrationInfo.NR_STATE_NONE).when(ssLte).getNrState();
+ doReturn(ServiceState.FREQUENCY_RANGE_UNKNOWN).when(ssLte).getNrFrequencyRange();
+ mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED,
+ TelephonyManager.NETWORK_TYPE_LTE);
+ mPhoneStateListener.onServiceStateChanged(ssLte);
+
+ verifyDataIndicators(TelephonyIcons.ICON_5G);
+ }
+
+ @Test
+ public void testNr5GIcon_disableDisplayGracePeriodTime_showLatestIconImmediately() {
+ setupDefaultNr5GIconConfiguration();
+ setupDefaultNr5GIconDisplayGracePeriodTime_disabled();
+ setupDefaultSignal();
+ mNetworkController.handleConfigurationChanged();
+
+ doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(mServiceState).getNrState();
+ doReturn(ServiceState.FREQUENCY_RANGE_HIGH).when(mServiceState).getNrFrequencyRange();
+ mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED,
+ TelephonyManager.NETWORK_TYPE_LTE);
+
+ verifyDataIndicators(TelephonyIcons.ICON_5G);
+
+ doReturn(NetworkRegistrationInfo.NR_STATE_NONE).when(mServiceState).getNrState();
+ doReturn(ServiceState.FREQUENCY_RANGE_UNKNOWN).when(mServiceState).getNrFrequencyRange();
+ mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED,
+ TelephonyManager.NETWORK_TYPE_LTE);
+
+ verifyDataIndicators(TelephonyIcons.ICON_LTE);
+ }
+
+ @Test
+ public void testNr5GIcon_resetDisplayGracePeriodTime_whenDataDisconnected() {
+ setupDefaultNr5GIconConfiguration();
+ setupDefaultNr5GIconDisplayGracePeriodTime_enableThirtySeconds();
+ setupDefaultSignal();
+ mNetworkController.handleConfigurationChanged();
+ doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(mServiceState).getNrState();
+ doReturn(ServiceState.FREQUENCY_RANGE_HIGH).when(mServiceState).getNrFrequencyRange();
+ mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED,
+ TelephonyManager.NETWORK_TYPE_LTE);
+
+ verifyDataIndicators(TelephonyIcons.ICON_5G);
+
+ // Disabled timer, when out of service, reset timer to display latest state
+ updateDataConnectionState(TelephonyManager.DATA_CONNECTED,
+ TelephonyManager.NETWORK_TYPE_LTE);
+ doReturn(NetworkRegistrationInfo.NR_STATE_NONE).when(mServiceState).getNrState();
+ doReturn(ServiceState.FREQUENCY_RANGE_UNKNOWN).when(mServiceState).getNrFrequencyRange();
+ mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_DISCONNECTED,
+ TelephonyManager.NETWORK_TYPE_UMTS);
+
+ verifyDataIndicators(0);
+ }
+
+ @Test
+ public void testNr5GIcon_enableDisplayGracePeriodTime_show5G_switching_5GPlus() {
+ setupDefaultNr5GIconConfiguration();
+ setupDefaultNr5GIconDisplayGracePeriodTime_enableThirtySeconds();
+ setupDefaultSignal();
+ mNetworkController.handleConfigurationChanged();
+ mPhoneStateListener.onServiceStateChanged(mServiceState);
+
+ ServiceState ss5G = Mockito.mock(ServiceState.class);
+ doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(ss5G).getNrState();
+ doReturn(ServiceState.FREQUENCY_RANGE_HIGH).when(ss5G).getNrFrequencyRange();
+ mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED,
+ TelephonyManager.NETWORK_TYPE_LTE);
+ mPhoneStateListener.onServiceStateChanged(ss5G);
+
+ verifyDataIndicators(TelephonyIcons.ICON_5G);
+
+ // When timeout enabled, 5G/5G+ switching should be updated immediately
+ ServiceState ss5GPlus = Mockito.mock(ServiceState.class);
+ doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(ss5GPlus).getNrState();
+ doReturn(ServiceState.FREQUENCY_RANGE_MMWAVE).when(ss5GPlus).getNrFrequencyRange();
+ mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED,
+ TelephonyManager.NETWORK_TYPE_LTE);
+ mPhoneStateListener.onServiceStateChanged(ss5GPlus);
+
+ verifyDataIndicators(TelephonyIcons.ICON_5G_PLUS);
+ }
+
+ @Test
+ public void testNr5GIcon_carrierDisabledDisplayGracePeriodTime_shouldUpdateIconImmediately() {
+ setupDefaultNr5GIconConfiguration();
+ setupDefaultNr5GIconDisplayGracePeriodTime_enableThirtySeconds();
+ setupDefaultSignal();
+ mNetworkController.handleConfigurationChanged();
+ mPhoneStateListener.onServiceStateChanged(mServiceState);
+
+ ServiceState ss5G = Mockito.mock(ServiceState.class);
+ doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(ss5G).getNrState();
+ doReturn(ServiceState.FREQUENCY_RANGE_HIGH).when(ss5G).getNrFrequencyRange();
+ mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED,
+ TelephonyManager.NETWORK_TYPE_LTE);
+ mPhoneStateListener.onServiceStateChanged(ss5G);
+
+ verifyDataIndicators(TelephonyIcons.ICON_5G);
+
+ // State from NR_5G to NONE NR_5G with timeout, should show previous 5G icon
+ ServiceState ssLte = Mockito.mock(ServiceState.class);
+ doReturn(NetworkRegistrationInfo.NR_STATE_NONE).when(ssLte).getNrState();
+ doReturn(ServiceState.FREQUENCY_RANGE_UNKNOWN).when(ssLte).getNrFrequencyRange();
+ mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED,
+ TelephonyManager.NETWORK_TYPE_LTE);
+ mPhoneStateListener.onServiceStateChanged(ssLte);
+
+ verifyDataIndicators(TelephonyIcons.ICON_5G);
+
+ // Update nrIconDisplayGracePeriodMs to 0
+ setupDefaultNr5GIconDisplayGracePeriodTime_disabled();
+ mNetworkController.handleConfigurationChanged();
+
+ // State from NR_5G to NONE NR_STATE_RESTRICTED, showing corresponding icon
+ doReturn(NetworkRegistrationInfo.NR_STATE_RESTRICTED).when(mServiceState).getNrState();
+ doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getDataNetworkType();
+ mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED,
+ TelephonyManager.NETWORK_TYPE_LTE);
+
+ assertTrue(mConfig.nrIconDisplayGracePeriodMs == 0);
+ verifyDataIndicators(TelephonyIcons.ICON_LTE);
+ }
+
+ @Test
public void testDataDisabledIcon_UserNotSetup() {
setupNetworkController();
when(mMockTm.isDataCapable()).thenReturn(false);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerWifiTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerWifiTest.java
index 6e3d906..3451183 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerWifiTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerWifiTest.java
@@ -1,5 +1,12 @@
package com.android.systemui.statusbar.policy;
+import static junit.framework.Assert.assertEquals;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyBoolean;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
import android.content.Intent;
import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
@@ -16,13 +23,6 @@
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
-import static junit.framework.Assert.assertEquals;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyBoolean;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
@SmallTest
@RunWith(AndroidTestingRunner.class)
@RunWithLooper
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyViewTest.java
index 0cb5754..6be7081 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyViewTest.java
@@ -494,6 +494,7 @@
private void setSmartActions(String[] actionTitles, boolean useDelayedOnClickListener) {
mView.resetSmartSuggestions(mContainer);
List<Button> actions = mView.inflateSmartActions(
+ getContext(),
new SmartReplyView.SmartActions(createActions(actionTitles), false),
mLogger,
mEntry,
@@ -514,6 +515,7 @@
List<Button> smartSuggestions = inflateSmartReplies(choices, fromAssistant,
useDelayedOnClickListener);
smartSuggestions.addAll(mView.inflateSmartActions(
+ getContext(),
new SmartReplyView.SmartActions(createActions(actionTitles), fromAssistant),
mLogger,
mEntry,
@@ -860,7 +862,7 @@
}
private Button inflateActionButton(Notification.Action action) {
- return SmartReplyView.inflateActionButton(mView, getContext(), 0,
+ return SmartReplyView.inflateActionButton(mView, getContext(), getContext(), 0,
new SmartReplyView.SmartActions(Collections.singletonList(action), false),
mLogger, mEntry, mHeadsUpManager, true /* useDelayedOnClickListener */);
}
diff --git a/packages/SystemUI/tools/lint/baseline.xml b/packages/SystemUI/tools/lint/baseline.xml
index 8c43222..096a639 100644
--- a/packages/SystemUI/tools/lint/baseline.xml
+++ b/packages/SystemUI/tools/lint/baseline.xml
@@ -2685,39 +2685,6 @@
<issue
id="UnusedResources"
- message="The resource `R.dimen.volume_dialog_base_margin` appears to be unused"
- errorLine1=" <dimen name="volume_dialog_base_margin">8dp</dimen>"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="res/values/dimens.xml"
- line="308"
- column="12"/>
- </issue>
-
- <issue
- id="UnusedResources"
- message="The resource `R.dimen.volume_dialog_row_height` appears to be unused"
- errorLine1=" <dimen name="volume_dialog_row_height">252dp</dimen>"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="res/values/dimens.xml"
- line="314"
- column="12"/>
- </issue>
-
- <issue
- id="UnusedResources"
- message="The resource `R.dimen.volume_dialog_settings_icon_size` appears to be unused"
- errorLine1=" <dimen name="volume_dialog_settings_icon_size">16dp</dimen>"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="res/values/dimens.xml"
- line="328"
- column="12"/>
- </issue>
-
- <issue
- id="UnusedResources"
message="The resource `R.dimen.carrier_label_height` appears to be unused"
errorLine1=" <dimen name="carrier_label_height">24dp</dimen>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
diff --git a/proto/src/gnss.proto b/proto/src/gnss.proto
index 1509fc0..33dbb26 100644
--- a/proto/src/gnss.proto
+++ b/proto/src/gnss.proto
@@ -48,6 +48,27 @@
// Hardware revision (EVT, DVT, PVT etc.)
optional string hardware_revision = 13;
+
+ // Total number of sv status messages processed
+ optional int32 num_sv_status_processed = 14;
+
+ // Total number of L5 sv status messages processed
+ optional int32 num_l5_sv_status_processed = 15;
+
+ // Total number of sv status messages processed, where sv is used in fix
+ optional int32 num_sv_status_used_in_fix = 16;
+
+ // Total number of L5 sv status messages processed, where sv is used in fix
+ optional int32 num_l5_sv_status_used_in_fix = 17;
+
+ // Number of l5 top 4 average CN0 processed
+ optional int32 num_l5_top_four_average_cn0_processed = 18;
+
+ // Mean of l5 top 4 average CN0 (dB-Hz)
+ optional double mean_l5_top_four_average_cn0_db_hz = 19;
+
+ // Standard deviation of l5 top 4 average CN0 (dB-Hz)
+ optional double standard_deviation_l5_top_four_average_cn0_db_hz = 20;
}
// Power metrics
diff --git a/proto/src/metrics_constants/metrics_constants.proto b/proto/src/metrics_constants/metrics_constants.proto
index 5a4892c..38154cb 100644
--- a/proto/src/metrics_constants/metrics_constants.proto
+++ b/proto/src/metrics_constants/metrics_constants.proto
@@ -7414,6 +7414,18 @@
// Note: Gear icon is shown next to gesture navigation preference and opens sensitivity dialog
SETTINGS_GESTURE_NAV_BACK_SENSITIVITY_DLG = 1748;
+
+
+ // ACTION: Chooser > User taps a system-provided target such as copy
+ // SUBTYPE: Index of target
+ // CATEGORY: GLOBAL_SYSTEM_UI
+ // OS: Q - QPR1
+ ACTION_ACTIVITY_CHOOSER_PICKED_SYSTEM_TARGET = 1749;
+
+ // OPEN: Settings > System > Aware > Aware Display
+ // CATEGORY: SETTINGS
+ // OS: Q
+ SETTINGS_AWARE_DISPLAY = 1750;
// ---- End Q Constants, all Q constants go above this line ----
// Add new aosp constants above this line.
// END OF AOSP CONSTANTS
diff --git a/proto/src/wifi.proto b/proto/src/wifi.proto
index 8ad2489..fbf6ca5 100644
--- a/proto/src/wifi.proto
+++ b/proto/src/wifi.proto
@@ -1792,6 +1792,25 @@
// Indicates if we are logging LinkSpeedCount in metrics
optional bool link_speed_counts_logging_enabled = 4;
+
+ // Duration for evaluating Wifi condition to trigger a data stall
+ // measured in milliseconds
+ optional int32 data_stall_duration_ms = 5;
+
+ // Threshold of Tx throughput below which to trigger a data stall
+ // measured in Kbps
+ optional int32 data_stall_tx_tput_thr_kbps = 6;
+
+ // Threshold of Rx throughput below which to trigger a data stall
+ // measured in Kbps
+ optional int32 data_stall_rx_tput_thr_kbps = 7;
+
+ // Threshold of Tx packet error rate above which to trigger a data stall
+ // in percentage
+ optional int32 data_stall_tx_per_thr = 8;
+
+ // Threshold of CCA level above which to trigger a data stall in percentage
+ optional int32 data_stall_cca_level_thr = 9;
}
message WifiIsUnusableEvent {
diff --git a/services/accessibility/java/com/android/server/accessibility/GlobalActionPerformer.java b/services/accessibility/java/com/android/server/accessibility/GlobalActionPerformer.java
index 672518c..b9b2654 100644
--- a/services/accessibility/java/com/android/server/accessibility/GlobalActionPerformer.java
+++ b/services/accessibility/java/com/android/server/accessibility/GlobalActionPerformer.java
@@ -24,10 +24,7 @@
import android.os.Handler;
import android.os.Looper;
import android.os.PowerManager;
-import android.os.RemoteException;
-import android.os.ServiceManager;
import android.os.SystemClock;
-import android.view.IWindowManager;
import android.view.InputDevice;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
@@ -191,7 +188,7 @@
ScreenshotHelper screenshotHelper = (mScreenshotHelperSupplier != null)
? mScreenshotHelperSupplier.get() : new ScreenshotHelper(mContext);
screenshotHelper.takeScreenshot(android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN,
- true, true, new Handler(Looper.getMainLooper()));
+ true, true, new Handler(Looper.getMainLooper()), null);
return true;
}
}
diff --git a/services/appprediction/java/com/android/server/appprediction/AppPredictionManagerService.java b/services/appprediction/java/com/android/server/appprediction/AppPredictionManagerService.java
index d7e68f8..5844f98 100644
--- a/services/appprediction/java/com/android/server/appprediction/AppPredictionManagerService.java
+++ b/services/appprediction/java/com/android/server/appprediction/AppPredictionManagerService.java
@@ -23,6 +23,7 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.UserIdInt;
import android.app.prediction.AppPredictionContext;
import android.app.prediction.AppPredictionSessionId;
import android.app.prediction.AppTargetEvent;
@@ -61,7 +62,8 @@
public AppPredictionManagerService(Context context) {
super(context, new FrameworkResourcesServiceNameResolver(context,
- com.android.internal.R.string.config_defaultAppPredictionService), null);
+ com.android.internal.R.string.config_defaultAppPredictionService), null,
+ PACKAGE_UPDATE_POLICY_NO_REFRESH | PACKAGE_RESTART_POLICY_NO_REFRESH);
mActivityTaskManagerInternal = LocalServices.getService(ActivityTaskManagerInternal.class);
}
@@ -80,6 +82,22 @@
getContext().enforceCallingPermission(MANAGE_APP_PREDICTIONS, TAG);
}
+ @Override // from AbstractMasterSystemService
+ protected void onServicePackageUpdatedLocked(@UserIdInt int userId) {
+ final AppPredictionPerUserService service = peekServiceForUserLocked(userId);
+ if (service != null) {
+ service.onPackageUpdatedLocked();
+ }
+ }
+
+ @Override // from AbstractMasterSystemService
+ protected void onServicePackageRestartedLocked(@UserIdInt int userId) {
+ final AppPredictionPerUserService service = peekServiceForUserLocked(userId);
+ if (service != null) {
+ service.onPackageRestartedLocked();
+ }
+ }
+
@Override
protected int getMaximumTemporaryServiceDurationMs() {
return MAX_TEMP_SERVICE_DURATION_MS;
diff --git a/services/appprediction/java/com/android/server/appprediction/AppPredictionPerUserService.java b/services/appprediction/java/com/android/server/appprediction/AppPredictionPerUserService.java
index 03c4542..4f49fb7 100644
--- a/services/appprediction/java/com/android/server/appprediction/AppPredictionPerUserService.java
+++ b/services/appprediction/java/com/android/server/appprediction/AppPredictionPerUserService.java
@@ -251,6 +251,40 @@
// Do nothing, eventually the system will bind to the remote service again...
}
+ void onPackageUpdatedLocked() {
+ if (isDebug()) {
+ Slog.v(TAG, "onPackageUpdatedLocked()");
+ }
+ destroyAndRebindRemoteService();
+ }
+
+ void onPackageRestartedLocked() {
+ if (isDebug()) {
+ Slog.v(TAG, "onPackageRestartedLocked()");
+ }
+ destroyAndRebindRemoteService();
+ }
+
+ private void destroyAndRebindRemoteService() {
+ if (mRemoteService == null) {
+ return;
+ }
+
+ if (isDebug()) {
+ Slog.d(TAG, "Destroying the old remote service.");
+ }
+ mRemoteService.destroy();
+ mRemoteService = null;
+
+ mRemoteService = getRemoteServiceLocked();
+ if (mRemoteService != null) {
+ if (isDebug()) {
+ Slog.d(TAG, "Rebinding to the new remote service.");
+ }
+ mRemoteService.reconnect();
+ }
+ }
+
/**
* Called after the remote service connected, it's used to restore state from a 'zombie'
* service (i.e., after it died).
diff --git a/services/appprediction/java/com/android/server/appprediction/RemoteAppPredictionService.java b/services/appprediction/java/com/android/server/appprediction/RemoteAppPredictionService.java
index c82e7a0..04e0e7f 100644
--- a/services/appprediction/java/com/android/server/appprediction/RemoteAppPredictionService.java
+++ b/services/appprediction/java/com/android/server/appprediction/RemoteAppPredictionService.java
@@ -135,6 +135,13 @@
}
/**
+ * Schedules a request to bind to the remote service.
+ */
+ public void reconnect() {
+ super.scheduleBind();
+ }
+
+ /**
* Failure callback
*/
public interface RemoteAppPredictionServiceCallbacks
diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java
index d260985..87991be 100644
--- a/services/autofill/java/com/android/server/autofill/Session.java
+++ b/services/autofill/java/com/android/server/autofill/Session.java
@@ -2407,7 +2407,9 @@
// Update the view states first...
mCurrentViewId = viewState.id;
- viewState.setCurrentValue(value);
+ if (value != null) {
+ viewState.setCurrentValue(value);
+ }
if (mCompatMode && (viewState.getState() & ViewState.STATE_URL_BAR) != 0) {
if (sDebug) Slog.d(TAG, "Ignoring VIEW_ENTERED on URL BAR (id=" + id + ")");
diff --git a/services/core/java/com/android/server/BluetoothService.java b/services/core/java/com/android/server/BluetoothService.java
index 5c5b477..6a6ddc8 100644
--- a/services/core/java/com/android/server/BluetoothService.java
+++ b/services/core/java/com/android/server/BluetoothService.java
@@ -54,8 +54,11 @@
@Override
public void onSwitchUser(int userHandle) {
- initialize();
- mBluetoothManagerService.handleOnSwitchUser(userHandle);
+ if (!mInitialized) {
+ initialize();
+ } else {
+ mBluetoothManagerService.handleOnSwitchUser(userHandle);
+ }
}
@Override
diff --git a/services/core/java/com/android/server/DeviceIdleController.java b/services/core/java/com/android/server/DeviceIdleController.java
index 52a4218..2ab46e6 100644
--- a/services/core/java/com/android/server/DeviceIdleController.java
+++ b/services/core/java/com/android/server/DeviceIdleController.java
@@ -2737,7 +2737,9 @@
resetIdleManagementLocked();
// Wait a small amount of time in case something (eg: background service from
// recently closed app) needs to finish running.
- scheduleAlarmLocked(mConstants.QUICK_DOZE_DELAY_TIMEOUT, false);
+ // Use a non-wakeup alarm for going into quick doze in case an AlarmClock alarm
+ // is scheduled soon. The non-wakeup alarm will be delayed by at most 2 minutes.
+ scheduleAlarmLocked(mConstants.QUICK_DOZE_DELAY_TIMEOUT, false, false);
EventLogTags.writeDeviceIdle(mState, "no activity");
} else if (mState == STATE_ACTIVE) {
mState = STATE_INACTIVE;
@@ -3362,6 +3364,10 @@
}
void scheduleAlarmLocked(long delay, boolean idleUntil) {
+ scheduleAlarmLocked(delay, idleUntil, true);
+ }
+
+ private void scheduleAlarmLocked(long delay, boolean idleUntil, boolean useWakeupAlarm) {
if (DEBUG) Slog.d(TAG, "scheduleAlarmLocked(" + delay + ", " + idleUntil + ")");
if (mUseMotionSensor && mMotionSensor == null
@@ -3377,12 +3383,14 @@
// can continue until the user interacts with the device.
return;
}
+ final int alarmType = useWakeupAlarm
+ ? AlarmManager.ELAPSED_REALTIME_WAKEUP : AlarmManager.ELAPSED_REALTIME;
mNextAlarmTime = SystemClock.elapsedRealtime() + delay;
if (idleUntil) {
- mAlarmManager.setIdleUntil(AlarmManager.ELAPSED_REALTIME_WAKEUP,
+ mAlarmManager.setIdleUntil(alarmType,
mNextAlarmTime, "DeviceIdleController.deep", mDeepAlarmListener, mHandler);
} else {
- mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
+ mAlarmManager.set(alarmType,
mNextAlarmTime, "DeviceIdleController.deep", mDeepAlarmListener, mHandler);
}
}
diff --git a/services/core/java/com/android/server/EventLogTags.logtags b/services/core/java/com/android/server/EventLogTags.logtags
index 4d39f9a..bec08f4 100644
--- a/services/core/java/com/android/server/EventLogTags.logtags
+++ b/services/core/java/com/android/server/EventLogTags.logtags
@@ -39,6 +39,12 @@
27391 user_activity_timeout_override (override|2|3)
27392 battery_saver_setting (threshold|1)
+
+# ---------------------------
+# ThermalManagerService.java
+# ---------------------------
+2737 thermal_changed (name|3),(type|1|5),(temperature|5),(sensor_status|1|5),(previous_system_status|1|5)
+
#
# Leave IDs through 2740 for more power logs (2730 used by battery_discharge above)
#
diff --git a/services/core/java/com/android/server/MountServiceIdler.java b/services/core/java/com/android/server/MountServiceIdler.java
index 1891ba9..6bc1a57 100644
--- a/services/core/java/com/android/server/MountServiceIdler.java
+++ b/services/core/java/com/android/server/MountServiceIdler.java
@@ -27,6 +27,7 @@
import android.content.Context;
import android.os.RemoteException;
import android.util.Slog;
+import java.util.concurrent.TimeUnit;
public class MountServiceIdler extends JobService {
private static final String TAG = "MountServiceIdler";
@@ -48,7 +49,7 @@
mStarted = false;
}
}
- // ... and try again tomorrow
+ // ... and try again right away or tomorrow
scheduleIdlePass(MountServiceIdler.this);
}
};
@@ -98,24 +99,32 @@
public static void scheduleIdlePass(Context context) {
JobScheduler tm = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
- Calendar calendar = tomorrowMidnight();
- final long timeToMidnight = calendar.getTimeInMillis() - System.currentTimeMillis();
+ final long today3AM = offsetFromTodayMidnight(0, 3).getTimeInMillis();
+ final long today4AM = offsetFromTodayMidnight(0, 4).getTimeInMillis();
+ final long tomorrow3AM = offsetFromTodayMidnight(1, 3).getTimeInMillis();
+
+ long nextScheduleTime;
+ if (System.currentTimeMillis() > today3AM && System.currentTimeMillis() < today4AM) {
+ nextScheduleTime = TimeUnit.SECONDS.toMillis(10);
+ } else {
+ nextScheduleTime = tomorrow3AM - System.currentTimeMillis(); // 3AM tomorrow
+ }
JobInfo.Builder builder = new JobInfo.Builder(MOUNT_JOB_ID, sIdleService);
builder.setRequiresDeviceIdle(true);
- builder.setRequiresCharging(true);
- builder.setMinimumLatency(timeToMidnight);
+ builder.setRequiresBatteryNotLow(true);
+ builder.setMinimumLatency(nextScheduleTime);
tm.schedule(builder.build());
}
- private static Calendar tomorrowMidnight() {
+ private static Calendar offsetFromTodayMidnight(int nDays, int nHours) {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
- calendar.set(Calendar.HOUR_OF_DAY, 3);
+ calendar.set(Calendar.HOUR_OF_DAY, nHours);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
- calendar.add(Calendar.DAY_OF_MONTH, 1);
+ calendar.add(Calendar.DAY_OF_MONTH, nDays);
return calendar;
}
}
diff --git a/services/core/java/com/android/server/UiModeManagerService.java b/services/core/java/com/android/server/UiModeManagerService.java
index 30a3563..6b03897 100644
--- a/services/core/java/com/android/server/UiModeManagerService.java
+++ b/services/core/java/com/android/server/UiModeManagerService.java
@@ -48,7 +48,6 @@
import android.os.ShellCommand;
import android.os.SystemProperties;
import android.os.UserHandle;
-import android.os.UserManager;
import android.provider.Settings.Secure;
import android.service.dreams.Sandman;
import android.service.vr.IVrManager;
@@ -218,6 +217,15 @@
}
};
+ private final ContentObserver mDarkThemeObserver = new ContentObserver(mHandler) {
+ @Override
+ public void onChange(boolean selfChange, Uri uri) {
+ final int mode = Secure.getIntForUser(getContext().getContentResolver(),
+ Secure.UI_NIGHT_MODE, mNightMode, 0);
+ SystemProperties.set(SYSTEM_PROPERTY_DEVICE_THEME, Integer.toString(mode));
+ }
+ };
+
@Override
public void onSwitchUser(int userHandle) {
super.onSwitchUser(userHandle);
@@ -293,6 +301,9 @@
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_USER_SWITCHED);
context.registerReceiver(new UserSwitchedReceiver(), filter, null, mHandler);
+
+ context.getContentResolver().registerContentObserver(Secure.getUriFor(Secure.UI_NIGHT_MODE),
+ false, mDarkThemeObserver, 0);
}
// Records whether setup wizard has happened or not and adds an observer for this user if not.
@@ -417,11 +428,6 @@
if (!mCarModeEnabled) {
Secure.putIntForUser(getContext().getContentResolver(),
Secure.UI_NIGHT_MODE, mode, user);
-
- if (UserManager.get(getContext()).isPrimaryUser()) {
- SystemProperties.set(SYSTEM_PROPERTY_DEVICE_THEME,
- Integer.toString(mode));
- }
}
mNightMode = mode;
diff --git a/services/core/java/com/android/server/accounts/AccountManagerServiceShellCommand.java b/services/core/java/com/android/server/accounts/AccountManagerServiceShellCommand.java
index 9e5f722..9bf0bd3 100644
--- a/services/core/java/com/android/server/accounts/AccountManagerServiceShellCommand.java
+++ b/services/core/java/com/android/server/accounts/AccountManagerServiceShellCommand.java
@@ -17,6 +17,7 @@
package com.android.server.accounts;
import android.annotation.NonNull;
+import android.app.ActivityManager;
import android.os.ShellCommand;
import android.os.UserHandle;
@@ -83,7 +84,7 @@
return null;
}
}
- return UserHandle.USER_SYSTEM;
+ return ActivityManager.getCurrentUser();
}
@Override
@@ -92,9 +93,11 @@
pw.println("Account manager service commands:");
pw.println(" help");
pw.println(" Print this help text.");
- pw.println(" set-bind-instant-service-allowed [--user <USER_ID>] true|false ");
+ pw.println(" set-bind-instant-service-allowed "
+ + "[--user <USER_ID> (current user if not specified)] true|false ");
pw.println(" Set whether binding to services provided by instant apps is allowed.");
- pw.println(" get-bind-instant-service-allowed [--user <USER_ID>]");
+ pw.println(" get-bind-instant-service-allowed "
+ + "[--user <USER_ID> (current user if not specified)]");
pw.println(" Get whether binding to services provided by instant apps is allowed.");
}
}
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index cc5932e..8c3f924 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -5263,11 +5263,14 @@
// Inform checkpointing systems of success
try {
+ // This line is needed to CTS test for the correct exception handling
+ // See b/138952436#comment36 for context
+ Slog.i(TAG, "About to commit checkpoint");
IStorageManager storageManager = PackageHelper.getStorageManager();
storageManager.commitChanges();
} catch (Exception e) {
PowerManager pm = (PowerManager)
- mContext.getSystemService(Context.POWER_SERVICE);
+ mInjector.getContext().getSystemService(Context.POWER_SERVICE);
pm.reboot("Checkpoint commit failed");
}
@@ -9031,7 +9034,16 @@
Integer.toString(currentUserId), currentUserId);
mBatteryStatsService.noteEvent(BatteryStats.HistoryItem.EVENT_USER_FOREGROUND_START,
Integer.toString(currentUserId), currentUserId);
- mSystemServiceManager.startUser(currentUserId);
+
+ // On Automotive, at this point the system user has already been started and unlocked,
+ // and some of the tasks we do here have already been done. So skip those in that case.
+ // TODO(b/132262830): this workdound shouldn't be necessary once we move the
+ // headless-user start logic to UserManager-land
+ final boolean bootingSystemUser = currentUserId == UserHandle.USER_SYSTEM;
+
+ if (bootingSystemUser) {
+ mSystemServiceManager.startUser(currentUserId);
+ }
synchronized (this) {
// Only start up encryption-aware persistent apps; once user is
@@ -9055,43 +9067,53 @@
throw e.rethrowAsRuntimeException();
}
}
- mAtmInternal.startHomeOnAllDisplays(currentUserId, "systemReady");
+
+ if (bootingSystemUser) {
+ mAtmInternal.startHomeOnAllDisplays(currentUserId, "systemReady");
+ }
mAtmInternal.showSystemReadyErrorDialogsIfNeeded();
- final int callingUid = Binder.getCallingUid();
- final int callingPid = Binder.getCallingPid();
- long ident = Binder.clearCallingIdentity();
- try {
- Intent intent = new Intent(Intent.ACTION_USER_STARTED);
- intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY
- | Intent.FLAG_RECEIVER_FOREGROUND);
- intent.putExtra(Intent.EXTRA_USER_HANDLE, currentUserId);
- broadcastIntentLocked(null, null, intent,
- null, null, 0, null, null, null, OP_NONE,
- null, false, false, MY_PID, SYSTEM_UID, callingUid, callingPid,
- currentUserId);
- intent = new Intent(Intent.ACTION_USER_STARTING);
- intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
- intent.putExtra(Intent.EXTRA_USER_HANDLE, currentUserId);
- broadcastIntentLocked(null, null, intent,
- null, new IIntentReceiver.Stub() {
- @Override
- public void performReceive(Intent intent, int resultCode, String data,
- Bundle extras, boolean ordered, boolean sticky, int sendingUser)
- throws RemoteException {
- }
- }, 0, null, null,
- new String[] {INTERACT_ACROSS_USERS}, OP_NONE,
- null, true, false, MY_PID, SYSTEM_UID, callingUid, callingPid,
- UserHandle.USER_ALL);
- } catch (Throwable t) {
- Slog.wtf(TAG, "Failed sending first user broadcasts", t);
- } finally {
- Binder.restoreCallingIdentity(ident);
+ if (bootingSystemUser) {
+ final int callingUid = Binder.getCallingUid();
+ final int callingPid = Binder.getCallingPid();
+ long ident = Binder.clearCallingIdentity();
+ try {
+ Intent intent = new Intent(Intent.ACTION_USER_STARTED);
+ intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY
+ | Intent.FLAG_RECEIVER_FOREGROUND);
+ intent.putExtra(Intent.EXTRA_USER_HANDLE, currentUserId);
+ broadcastIntentLocked(null, null, intent,
+ null, null, 0, null, null, null, OP_NONE,
+ null, false, false, MY_PID, SYSTEM_UID, callingUid, callingPid,
+ currentUserId);
+ intent = new Intent(Intent.ACTION_USER_STARTING);
+ intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
+ intent.putExtra(Intent.EXTRA_USER_HANDLE, currentUserId);
+ broadcastIntentLocked(null, null, intent,
+ null, new IIntentReceiver.Stub() {
+ @Override
+ public void performReceive(Intent intent, int resultCode, String data,
+ Bundle extras, boolean ordered, boolean sticky, int sendingUser)
+ throws RemoteException {
+ }
+ }, 0, null, null,
+ new String[] {INTERACT_ACROSS_USERS}, OP_NONE,
+ null, true, false, MY_PID, SYSTEM_UID, callingUid, callingPid,
+ UserHandle.USER_ALL);
+ } catch (Throwable t) {
+ Slog.wtf(TAG, "Failed sending first user broadcasts", t);
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ } else {
+ Slog.i(TAG, "Not sending multi-user broadcasts for non-system user "
+ + currentUserId);
}
mAtmInternal.resumeTopActivities(false /* scheduleIdle */);
- mUserController.sendUserSwitchBroadcasts(-1, currentUserId);
+ if (bootingSystemUser) {
+ mUserController.sendUserSwitchBroadcasts(-1, currentUserId);
+ }
BinderInternal.nSetBinderProxyCountWatermarks(BINDER_PROXY_HIGH_WATERMARK,
BINDER_PROXY_LOW_WATERMARK);
@@ -14983,7 +15005,12 @@
final int uid = getUidFromIntent(intent);
if (uid >= 0) {
mBatteryStatsService.removeUid(uid);
- mAppOpsService.uidRemoved(uid);
+ if (intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) {
+ mAppOpsService.resetAllModes(UserHandle.getUserId(uid),
+ intent.getStringExtra(Intent.EXTRA_PACKAGE_NAME));
+ } else {
+ mAppOpsService.uidRemoved(uid);
+ }
}
break;
case Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE:
diff --git a/services/core/java/com/android/server/am/BatteryStatsService.java b/services/core/java/com/android/server/am/BatteryStatsService.java
index c2f4529..a47ea4f 100644
--- a/services/core/java/com/android/server/am/BatteryStatsService.java
+++ b/services/core/java/com/android/server/am/BatteryStatsService.java
@@ -722,10 +722,10 @@
}
}
- public void notePhoneDataConnectionState(int dataType, boolean hasData) {
+ public void notePhoneDataConnectionState(int dataType, boolean hasData, int serviceType) {
enforceCallingPermission();
synchronized (mStats) {
- mStats.notePhoneDataConnectionStateLocked(dataType, hasData);
+ mStats.notePhoneDataConnectionStateLocked(dataType, hasData, serviceType);
}
}
@@ -756,7 +756,7 @@
}
public void noteStartAudio(int uid) {
- enforceSelfOrCallingPermission(uid);
+ enforceCallingPermission();
synchronized (mStats) {
mStats.noteAudioOnLocked(uid);
StatsLog.write_non_chained(StatsLog.AUDIO_STATE_CHANGED, uid, null,
@@ -765,7 +765,7 @@
}
public void noteStopAudio(int uid) {
- enforceSelfOrCallingPermission(uid);
+ enforceCallingPermission();
synchronized (mStats) {
mStats.noteAudioOffLocked(uid);
StatsLog.write_non_chained(StatsLog.AUDIO_STATE_CHANGED, uid, null,
@@ -774,7 +774,7 @@
}
public void noteStartVideo(int uid) {
- enforceSelfOrCallingPermission(uid);
+ enforceCallingPermission();
synchronized (mStats) {
mStats.noteVideoOnLocked(uid);
StatsLog.write_non_chained(StatsLog.MEDIA_CODEC_STATE_CHANGED, uid, null,
@@ -783,7 +783,7 @@
}
public void noteStopVideo(int uid) {
- enforceSelfOrCallingPermission(uid);
+ enforceCallingPermission();
synchronized (mStats) {
mStats.noteVideoOffLocked(uid);
StatsLog.write_non_chained(StatsLog.MEDIA_CODEC_STATE_CHANGED, uid,
@@ -1184,13 +1184,6 @@
Binder.getCallingPid(), Binder.getCallingUid(), null);
}
- private void enforceSelfOrCallingPermission(int uid) {
- if (Binder.getCallingUid() == uid) {
- return;
- }
- enforceCallingPermission();
- }
-
final class WakeupReasonThread extends Thread {
private static final int MAX_REASON_SIZE = 512;
private CharsetDecoder mDecoder;
diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java
index 3d598dd..3c098d1 100644
--- a/services/core/java/com/android/server/am/ProcessList.java
+++ b/services/core/java/com/android/server/am/ProcessList.java
@@ -2097,10 +2097,10 @@
}
}
}
- if (lrui <= mLruProcessActivityStart) {
+ if (lrui < mLruProcessActivityStart) {
mLruProcessActivityStart--;
}
- if (lrui <= mLruProcessServiceStart) {
+ if (lrui < mLruProcessServiceStart) {
mLruProcessServiceStart--;
}
mLruProcesses.remove(lrui);
@@ -2632,7 +2632,7 @@
if (!moved) {
// Goes to the end of the group.
mLruProcesses.remove(i);
- mLruProcesses.add(endIndex - 1, subProc);
+ mLruProcesses.add(endIndex, subProc);
if (DEBUG_LRU) Slog.d(TAG_LRU,
"Moving " + subProc
+ " from position " + i + " to end of group @ "
@@ -2877,15 +2877,6 @@
pos--;
}
mLruProcesses.add(pos, app);
- if (pos == mLruProcessActivityStart) {
- mLruProcessActivityStart++;
- }
- if (pos == mLruProcessServiceStart) {
- // Unless {@code #hasService} is implemented, currently the starting position
- // for activity and service are the same, so the incoming position may equal to
- // the starting position of service.
- mLruProcessServiceStart++;
- }
// If this process is part of a group, need to pull up any other processes
// in that group to be with it.
int endIndex = pos - 1;
diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java
index a35d2ee..50d5736 100644
--- a/services/core/java/com/android/server/appop/AppOpsService.java
+++ b/services/core/java/com/android/server/appop/AppOpsService.java
@@ -510,6 +510,10 @@
private void updateProxyState(long key, int proxyUid,
@Nullable String proxyPackageName) {
+ if (proxyUid == Process.INVALID_UID) {
+ return;
+ }
+
if (mProxyUids == null) {
mProxyUids = new LongSparseLongArray();
}
@@ -2984,17 +2988,40 @@
out.startTag(null, "app-ops");
out.attribute(null, "v", String.valueOf(CURRENT_VERSION));
- final int uidStateCount = mUidStates.size();
- for (int i = 0; i < uidStateCount; i++) {
- UidState uidState = mUidStates.valueAt(i);
- if (uidState.opModes != null && uidState.opModes.size() > 0) {
+ SparseArray<SparseIntArray> uidStatesClone;
+ synchronized (this) {
+ uidStatesClone = new SparseArray<>(mUidStates.size());
+
+ final int uidStateCount = mUidStates.size();
+ for (int uidStateNum = 0; uidStateNum < uidStateCount; uidStateNum++) {
+ UidState uidState = mUidStates.valueAt(uidStateNum);
+ int uid = mUidStates.keyAt(uidStateNum);
+
+ SparseIntArray opModes = uidState.opModes;
+ if (opModes != null && opModes.size() > 0) {
+ uidStatesClone.put(uid, new SparseIntArray(opModes.size()));
+
+ final int opCount = opModes.size();
+ for (int opCountNum = 0; opCountNum < opCount; opCountNum++) {
+ uidStatesClone.get(uid).put(
+ opModes.keyAt(opCountNum),
+ opModes.valueAt(opCountNum));
+ }
+ }
+ }
+ }
+
+ final int uidStateCount = uidStatesClone.size();
+ for (int uidStateNum = 0; uidStateNum < uidStateCount; uidStateNum++) {
+ SparseIntArray opModes = uidStatesClone.valueAt(uidStateNum);
+ if (opModes != null && opModes.size() > 0) {
out.startTag(null, "uid");
- out.attribute(null, "n", Integer.toString(uidState.uid));
- SparseIntArray uidOpModes = uidState.opModes;
- final int opCount = uidOpModes.size();
- for (int j = 0; j < opCount; j++) {
- final int op = uidOpModes.keyAt(j);
- final int mode = uidOpModes.valueAt(j);
+ out.attribute(null, "n",
+ Integer.toString(uidStatesClone.keyAt(uidStateNum)));
+ final int opCount = opModes.size();
+ for (int opCountNum = 0; opCountNum < opCount; opCountNum++) {
+ final int op = opModes.keyAt(opCountNum);
+ final int mode = opModes.valueAt(opCountNum);
out.startTag(null, "op");
out.attribute(null, "n", Integer.toString(op));
out.attribute(null, "m", Integer.toString(mode));
diff --git a/services/core/java/com/android/server/broadcastradio/hal2/RadioModule.java b/services/core/java/com/android/server/broadcastradio/hal2/RadioModule.java
index acb0207..85ca627 100644
--- a/services/core/java/com/android/server/broadcastradio/hal2/RadioModule.java
+++ b/services/core/java/com/android/server/broadcastradio/hal2/RadioModule.java
@@ -35,6 +35,8 @@
import android.hardware.broadcastradio.V2_0.VendorKeyValue;
import android.hardware.radio.RadioManager;
import android.os.DeadObjectException;
+import android.os.Handler;
+import android.os.Looper;
import android.os.RemoteException;
import android.util.MutableInt;
import android.util.Slog;
@@ -44,6 +46,7 @@
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
@@ -55,6 +58,7 @@
@NonNull public final RadioManager.ModuleProperties mProperties;
private final Object mLock = new Object();
+ @NonNull private final Handler mHandler;
@GuardedBy("mLock")
private ITunerSession mHalTunerSession;
@@ -70,38 +74,46 @@
private final ITunerCallback mHalTunerCallback = new ITunerCallback.Stub() {
@Override
public void onTuneFailed(int result, ProgramSelector programSelector) {
- fanoutAidlCallback(cb -> cb.onTuneFailed(result, Convert.programSelectorFromHal(
- programSelector)));
+ lockAndFireLater(() -> {
+ android.hardware.radio.ProgramSelector csel =
+ Convert.programSelectorFromHal(programSelector);
+ fanoutAidlCallbackLocked(cb -> cb.onTuneFailed(result, csel));
+ });
}
@Override
public void onCurrentProgramInfoChanged(ProgramInfo halProgramInfo) {
- RadioManager.ProgramInfo programInfo = Convert.programInfoFromHal(halProgramInfo);
- synchronized (mLock) {
- mProgramInfo = programInfo;
- fanoutAidlCallbackLocked(cb -> cb.onCurrentProgramInfoChanged(programInfo));
- }
+ lockAndFireLater(() -> {
+ mProgramInfo = Convert.programInfoFromHal(halProgramInfo);
+ fanoutAidlCallbackLocked(cb -> cb.onCurrentProgramInfoChanged(mProgramInfo));
+ });
}
@Override
public void onProgramListUpdated(ProgramListChunk programListChunk) {
// TODO: Cache per-AIDL client filters, send union of filters to HAL, use filters to fan
// back out to clients.
- fanoutAidlCallback(cb -> cb.onProgramListUpdated(Convert.programListChunkFromHal(
- programListChunk)));
+ lockAndFireLater(() -> {
+ android.hardware.radio.ProgramList.Chunk chunk =
+ Convert.programListChunkFromHal(programListChunk);
+ fanoutAidlCallbackLocked(cb -> cb.onProgramListUpdated(chunk));
+ });
}
@Override
public void onAntennaStateChange(boolean connected) {
- synchronized (mLock) {
+ lockAndFireLater(() -> {
mAntennaConnected = connected;
fanoutAidlCallbackLocked(cb -> cb.onAntennaState(connected));
- }
+ });
}
@Override
public void onParametersUpdated(ArrayList<VendorKeyValue> parameters) {
- fanoutAidlCallback(cb -> cb.onParametersUpdated(Convert.vendorInfoFromHal(parameters)));
+ lockAndFireLater(() -> {
+ Map<String, String> cparam = Convert.vendorInfoFromHal(parameters);
+ fanoutAidlCallbackLocked(cb -> cb.onParametersUpdated(cparam));
+ });
}
};
@@ -113,6 +125,7 @@
@NonNull RadioManager.ModuleProperties properties) throws RemoteException {
mProperties = Objects.requireNonNull(properties);
mService = Objects.requireNonNull(service);
+ mHandler = new Handler(Looper.getMainLooper());
}
public static @Nullable RadioModule tryLoadingModule(int idx, @NonNull String fqName) {
@@ -201,15 +214,22 @@
}
}
+ // add to mHandler queue, but ensure the runnable holds mLock when it gets executed
+ private void lockAndFireLater(Runnable r) {
+ mHandler.post(() -> {
+ synchronized (mLock) {
+ r.run();
+ }
+ });
+ }
+
interface AidlCallbackRunnable {
void run(android.hardware.radio.ITunerCallback callback) throws RemoteException;
}
// Invokes runnable with each TunerSession currently open.
void fanoutAidlCallback(AidlCallbackRunnable runnable) {
- synchronized (mLock) {
- fanoutAidlCallbackLocked(runnable);
- }
+ lockAndFireLater(() -> fanoutAidlCallbackLocked(runnable));
}
private void fanoutAidlCallbackLocked(AidlCallbackRunnable runnable) {
diff --git a/services/core/java/com/android/server/connectivity/DataConnectionStats.java b/services/core/java/com/android/server/connectivity/DataConnectionStats.java
index e6a4428..27f11ff 100644
--- a/services/core/java/com/android/server/connectivity/DataConnectionStats.java
+++ b/services/core/java/com/android/server/connectivity/DataConnectionStats.java
@@ -97,7 +97,8 @@
if (DEBUG) Log.d(TAG, String.format("Noting data connection for network type %s: %svisible",
networkType, visible ? "" : "not "));
try {
- mBatteryStats.notePhoneDataConnectionState(networkType, visible);
+ mBatteryStats.notePhoneDataConnectionState(networkType, visible,
+ mServiceState.getState());
} catch (RemoteException e) {
Log.w(TAG, "Error noting data connection state", e);
}
diff --git a/services/core/java/com/android/server/display/ColorFade.java b/services/core/java/com/android/server/display/ColorFade.java
index f613064..c46fc20 100644
--- a/services/core/java/com/android/server/display/ColorFade.java
+++ b/services/core/java/com/android/server/display/ColorFade.java
@@ -649,13 +649,8 @@
if (mSurfaceControl != null) {
mSurfaceLayout.dispose();
mSurfaceLayout = null;
- SurfaceControl.openTransaction();
- try {
- mSurfaceControl.remove();
- mSurface.release();
- } finally {
- SurfaceControl.closeTransaction();
- }
+ new Transaction().remove(mSurfaceControl).apply();
+ mSurface.release();
mSurfaceControl = null;
mSurfaceVisible = false;
mSurfaceAlpha = 0f;
diff --git a/services/core/java/com/android/server/display/DisplayModeDirector.java b/services/core/java/com/android/server/display/DisplayModeDirector.java
index 500a242..1fc0db3 100644
--- a/services/core/java/com/android/server/display/DisplayModeDirector.java
+++ b/services/core/java/com/android/server/display/DisplayModeDirector.java
@@ -766,6 +766,7 @@
@Override
public void onDisplayChanged(int displayId) {
updateDisplayModes(displayId);
+ mBrightnessObserver.onDisplayChanged(displayId);
}
private void updateDisplayModes(int displayId) {
@@ -820,7 +821,6 @@
private AmbientFilter mAmbientFilter;
private final Context mContext;
- private final ScreenStateReceiver mScreenStateReceiver;
// Enable light sensor only when mShouldObserveAmbientChange is true, screen is on, peak
// refresh rate changeable and low power mode off. After initialization, these states will
@@ -834,7 +834,6 @@
BrightnessObserver(Context context, Handler handler) {
super(handler);
mContext = context;
- mScreenStateReceiver = new ScreenStateReceiver(mContext);
mDisplayBrightnessThresholds = context.getResources().getIntArray(
R.array.config_brightnessThresholdsOfPeakRefreshRate);
mAmbientBrightnessThresholds = context.getResources().getIntArray(
@@ -919,12 +918,16 @@
}
}
+ public void onDisplayChanged(int displayId) {
+ if (displayId == Display.DEFAULT_DISPLAY) {
+ onScreenOn(isDefaultDisplayOn());
+ }
+ }
+
@Override
public void onChange(boolean selfChange, Uri uri, int userId) {
synchronized (mLock) {
- if (mRefreshRateChangeable) {
- onBrightnessChangedLocked();
- }
+ onBrightnessChangedLocked();
}
}
@@ -970,16 +973,11 @@
mAmbientFilter = DisplayWhiteBalanceFactory.createBrightnessFilter(res);
mLightSensor = lightSensor;
- // Intent.ACTION_SCREEN_ON is not sticky. Check current screen status.
- if (mContext.getSystemService(PowerManager.class).isInteractive()) {
- onScreenOn(true);
- }
- mScreenStateReceiver.register();
+ onScreenOn(isDefaultDisplayOn());
}
} else {
mAmbientFilter = null;
mLightSensor = null;
- mScreenStateReceiver.unregister();
}
if (mRefreshRateChangeable) {
@@ -1049,8 +1047,6 @@
}
private void onScreenOn(boolean on) {
- // Not check mShouldObserveAmbientChange because Screen status receiver is registered
- // only when it is true.
if (mScreenOn != on) {
mScreenOn = on;
updateSensorStatus();
@@ -1072,6 +1068,13 @@
}
}
+ private boolean isDefaultDisplayOn() {
+ final Display display = mContext.getSystemService(DisplayManager.class)
+ .getDisplay(Display.DEFAULT_DISPLAY);
+ return display.getState() != Display.STATE_OFF
+ && mContext.getSystemService(PowerManager.class).isInteractive();
+ }
+
private final class LightSensorEventListener implements SensorEventListener {
final private static int INJECT_EVENTS_INTERVAL_MS = LIGHT_SENSOR_RATE_MS;
private float mLastSensorData;
@@ -1149,38 +1152,6 @@
}
}
};
- };
-
- private final class ScreenStateReceiver extends BroadcastReceiver {
- final Context mContext;
- boolean mRegistered;
-
- public ScreenStateReceiver(Context context) {
- mContext = context;
- }
-
- @Override
- public void onReceive(Context context, Intent intent) {
- onScreenOn(Intent.ACTION_SCREEN_ON.equals(intent.getAction()));
- }
-
- public void register() {
- if (!mRegistered) {
- IntentFilter filter = new IntentFilter();
- filter.addAction(Intent.ACTION_SCREEN_OFF);
- filter.addAction(Intent.ACTION_SCREEN_ON);
- filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
- mContext.registerReceiver(this, filter, null, mHandler);
- mRegistered = true;
- }
- }
-
- public void unregister() {
- if (mRegistered) {
- mContext.unregisterReceiver(this);
- mRegistered = false;
- }
- }
}
}
diff --git a/services/core/java/com/android/server/display/color/ColorDisplayService.java b/services/core/java/com/android/server/display/color/ColorDisplayService.java
index 7fb5b19..0bf43b6 100644
--- a/services/core/java/com/android/server/display/color/ColorDisplayService.java
+++ b/services/core/java/com/android/server/display/color/ColorDisplayService.java
@@ -609,6 +609,9 @@
@Override
public void onAnimationEnd(Animator animator) {
+ Slog.d(TAG, tintController.getClass().getSimpleName()
+ + " Animation cancelled: " + mIsCancelled
+ + " to matrix: " + TintController.matrixToString(to, 16));
if (!mIsCancelled) {
// Ensure final color matrix is set at the end of the animation. If the
// animation is cancelled then don't set the final color matrix so the new
@@ -1314,8 +1317,10 @@
* Reset the CCT value for the display white balance transform to its default value.
*/
public boolean resetDisplayWhiteBalanceColorTemperature() {
- return setDisplayWhiteBalanceColorTemperature(getContext().getResources()
- .getInteger(R.integer.config_displayWhiteBalanceColorTemperatureDefault));
+ int temperatureDefault = getContext().getResources()
+ .getInteger(R.integer.config_displayWhiteBalanceColorTemperatureDefault);
+ Slog.d(TAG, "resetDisplayWhiteBalanceColorTemperature: " + temperatureDefault);
+ return setDisplayWhiteBalanceColorTemperature(temperatureDefault);
}
/**
diff --git a/services/core/java/com/android/server/display/color/DisplayWhiteBalanceTintController.java b/services/core/java/com/android/server/display/color/DisplayWhiteBalanceTintController.java
index d2c6cd9..3f1c222 100644
--- a/services/core/java/com/android/server/display/color/DisplayWhiteBalanceTintController.java
+++ b/services/core/java/com/android/server/display/color/DisplayWhiteBalanceTintController.java
@@ -149,8 +149,6 @@
cct = mTemperatureMax;
}
- Slog.d(ColorDisplayService.TAG, "setDisplayWhiteBalanceTemperatureMatrix: cct = " + cct);
-
synchronized (mLock) {
mCurrentColorTemperature = cct;
@@ -185,6 +183,9 @@
java.lang.System.arraycopy(result, 3, mMatrixDisplayWhiteBalance, 4, 3);
java.lang.System.arraycopy(result, 6, mMatrixDisplayWhiteBalance, 8, 3);
}
+
+ Slog.d(ColorDisplayService.TAG, "setDisplayWhiteBalanceTemperatureMatrix: cct = " + cct
+ + " matrix = " + matrixToString(mMatrixDisplayWhiteBalance, 16));
}
@Override
@@ -225,28 +226,6 @@
}
}
- /**
- * Format a given matrix into a string.
- *
- * @param matrix the matrix to format
- * @param columns number of columns in the matrix
- */
- private String matrixToString(float[] matrix, int columns) {
- if (matrix == null || columns <= 0) {
- Slog.e(ColorDisplayService.TAG, "Invalid arguments when formatting matrix to string");
- return "";
- }
-
- final StringBuilder sb = new StringBuilder("");
- for (int i = 0; i < matrix.length; i++) {
- if (i % columns == 0) {
- sb.append("\n ");
- }
- sb.append(String.format("%9.6f", matrix[i]));
- }
- return sb.toString();
- }
-
private ColorSpace.Rgb makeRgbColorSpaceFromXYZ(float[] redGreenBlueXYZ, float[] whiteXYZ) {
return new ColorSpace.Rgb(
"Display Color Space",
diff --git a/services/core/java/com/android/server/display/color/TintController.java b/services/core/java/com/android/server/display/color/TintController.java
index b291c64..8d8b9b2 100644
--- a/services/core/java/com/android/server/display/color/TintController.java
+++ b/services/core/java/com/android/server/display/color/TintController.java
@@ -18,6 +18,7 @@
import android.animation.ValueAnimator;
import android.content.Context;
+import android.util.Slog;
import java.io.PrintWriter;
@@ -95,4 +96,29 @@
* Returns whether or not this transform type is available on this device.
*/
public abstract boolean isAvailable(Context context);
+
+ /**
+ * Format a given matrix into a string.
+ *
+ * @param matrix the matrix to format
+ * @param columns number of columns in the matrix
+ */
+ static String matrixToString(float[] matrix, int columns) {
+ if (matrix == null || columns <= 0) {
+ Slog.e(ColorDisplayService.TAG, "Invalid arguments when formatting matrix to string,"
+ + " matrix is null: " + (matrix == null)
+ + " columns: " + columns);
+ return "";
+ }
+
+ final StringBuilder sb = new StringBuilder("");
+ for (int i = 0; i < matrix.length; i++) {
+ if (i % columns == 0) {
+ sb.append("\n ");
+ }
+ sb.append(String.format("%9.6f", matrix[i]));
+ }
+ return sb.toString();
+ }
+
}
diff --git a/services/core/java/com/android/server/display/whitebalance/DisplayWhiteBalanceController.java b/services/core/java/com/android/server/display/whitebalance/DisplayWhiteBalanceController.java
index 02ec10e..7b1f4c3 100644
--- a/services/core/java/com/android/server/display/whitebalance/DisplayWhiteBalanceController.java
+++ b/services/core/java/com/android/server/display/whitebalance/DisplayWhiteBalanceController.java
@@ -95,6 +95,11 @@
// A piecewise linear relationship between high light brightness and high light bias.
private Spline.LinearSpline mHighLightAmbientBrightnessToBiasSpline;
+ private float mLatestAmbientColorTemperature;
+ private float mLatestAmbientBrightness;
+ private float mLatestLowLightBias;
+ private float mLatestHighLightBias;
+
/**
* @param brightnessSensor
* The sensor used to detect changes in the ambient brightness.
@@ -348,6 +353,7 @@
public void updateAmbientColorTemperature() {
final long time = System.currentTimeMillis();
float ambientColorTemperature = mColorTemperatureFilter.getEstimate(time);
+ mLatestAmbientColorTemperature = ambientColorTemperature;
if (mAmbientToDisplayColorTemperatureSpline != null && ambientColorTemperature != -1.0f) {
ambientColorTemperature =
@@ -355,6 +361,7 @@
}
float ambientBrightness = mBrightnessFilter.getEstimate(time);
+ mLatestAmbientBrightness = ambientBrightness;
if (ambientColorTemperature != -1.0f &&
mLowLightAmbientBrightnessToBiasSpline != null) {
@@ -362,6 +369,7 @@
ambientColorTemperature =
bias * ambientColorTemperature + (1.0f - bias)
* mLowLightAmbientColorTemperature;
+ mLatestLowLightBias = bias;
}
if (ambientColorTemperature != -1.0f &&
mHighLightAmbientBrightnessToBiasSpline != null) {
@@ -369,6 +377,7 @@
ambientColorTemperature =
(1.0f - bias) * ambientColorTemperature + bias
* mHighLightAmbientColorTemperature;
+ mLatestHighLightBias = bias;
}
if (mAmbientColorTemperatureOverride != -1.0f) {
@@ -426,6 +435,11 @@
}
mPendingAmbientColorTemperature = -1.0f;
mAmbientColorTemperatureHistory.add(mAmbientColorTemperature);
+ Slog.d(TAG, "Display cct: " + mAmbientColorTemperature
+ + " Latest ambient cct: " + mLatestAmbientColorTemperature
+ + " Latest ambient lux: " + mLatestAmbientBrightness
+ + " Latest low light bias: " + mLatestLowLightBias
+ + " Latest high light bias: " + mLatestHighLightBias);
mColorDisplayServiceInternal.setDisplayWhiteBalanceColorTemperature(
(int) mAmbientColorTemperature);
mLastAmbientColorTemperature = mAmbientColorTemperature;
diff --git a/services/core/java/com/android/server/infra/AbstractMasterSystemService.java b/services/core/java/com/android/server/infra/AbstractMasterSystemService.java
index 9782f30..259527a 100644
--- a/services/core/java/com/android/server/infra/AbstractMasterSystemService.java
+++ b/services/core/java/com/android/server/infra/AbstractMasterSystemService.java
@@ -79,7 +79,7 @@
S extends AbstractPerUserSystemService<S, M>> extends SystemService {
/** On a package update, does not refresh the per-user service in the cache. */
- public static final int PACKAGE_UPDATE_POLICY_NO_REFRESH = 0;
+ public static final int PACKAGE_UPDATE_POLICY_NO_REFRESH = 0x00000001;
/**
* On a package update, removes any existing per-user services in the cache.
@@ -87,20 +87,40 @@
* <p>This does not immediately recreate these services. It is assumed they will be recreated
* for the next user request.
*/
- public static final int PACKAGE_UPDATE_POLICY_REFRESH_LAZY = 1;
+ public static final int PACKAGE_UPDATE_POLICY_REFRESH_LAZY = 0x00000002;
/**
* On a package update, removes and recreates any existing per-user services in the cache.
*/
- public static final int PACKAGE_UPDATE_POLICY_REFRESH_EAGER = 2;
+ public static final int PACKAGE_UPDATE_POLICY_REFRESH_EAGER = 0x00000004;
- @IntDef(flag = true, prefix = { "PACKAGE_UPDATE_POLICY_" }, value = {
+ /** On a package restart, does not refresh the per-user service in the cache. */
+ public static final int PACKAGE_RESTART_POLICY_NO_REFRESH = 0x00000010;
+
+ /**
+ * On a package restart, removes any existing per-user services in the cache.
+ *
+ * <p>This does not immediately recreate these services. It is assumed they will be recreated
+ * for the next user request.
+ */
+ public static final int PACKAGE_RESTART_POLICY_REFRESH_LAZY = 0x00000020;
+
+ /**
+ * On a package restart, removes and recreates any existing per-user services in the cache.
+ */
+ public static final int PACKAGE_RESTART_POLICY_REFRESH_EAGER = 0x00000040;
+
+ @IntDef(flag = true, prefix = { "PACKAGE_" }, value = {
PACKAGE_UPDATE_POLICY_NO_REFRESH,
PACKAGE_UPDATE_POLICY_REFRESH_LAZY,
- PACKAGE_UPDATE_POLICY_REFRESH_EAGER
+ PACKAGE_UPDATE_POLICY_REFRESH_EAGER,
+ PACKAGE_RESTART_POLICY_NO_REFRESH,
+ PACKAGE_RESTART_POLICY_REFRESH_LAZY,
+ PACKAGE_RESTART_POLICY_REFRESH_EAGER
})
+
@Retention(RetentionPolicy.SOURCE)
- public @interface PackageUpdatePolicy {}
+ public @interface ServicePackagePolicyFlags {}
/**
* Log tag
@@ -153,12 +173,10 @@
private final SparseArray<S> mServicesCache = new SparseArray<>();
/**
- * Whether the per-user service should be removed from the cache when its apk is updated.
- *
- * <p>One of {@link #PACKAGE_UPDATE_POLICY_NO_REFRESH},
- * {@link #PACKAGE_UPDATE_POLICY_REFRESH_LAZY} or {@link #PACKAGE_UPDATE_POLICY_REFRESH_EAGER}.
+ * Value that determines whether the per-user service should be removed from the cache when its
+ * apk is updated or restarted.
*/
- private final @PackageUpdatePolicy int mPackageUpdatePolicy;
+ private final @ServicePackagePolicyFlags int mServicePackagePolicyFlags;
/**
* Name of the service packages whose APK are being updated, keyed by user id.
@@ -184,11 +202,11 @@
@Nullable ServiceNameResolver serviceNameResolver,
@Nullable String disallowProperty) {
this(context, serviceNameResolver, disallowProperty,
- /*packageUpdatePolicy=*/ PACKAGE_UPDATE_POLICY_REFRESH_LAZY);
+ PACKAGE_UPDATE_POLICY_REFRESH_LAZY | PACKAGE_RESTART_POLICY_REFRESH_LAZY);
}
/**
- * Full constructor.
+ * Full Constructor.
*
* @param context system context.
* @param serviceNameResolver resolver for
@@ -197,19 +215,32 @@
* @param disallowProperty when not {@code null}, defines a {@link UserManager} restriction that
* disables the service. <b>NOTE: </b> you'll also need to add it to
* {@code UserRestrictionsUtils.USER_RESTRICTIONS}.
- * @param packageUpdatePolicy when {@link #PACKAGE_UPDATE_POLICY_REFRESH_LAZY}, the
- * {@link AbstractPerUserSystemService} is removed from the cache when the service
- * package is updated; when {@link #PACKAGE_UPDATE_POLICY_REFRESH_EAGER}, the
- * {@link AbstractPerUserSystemService} is removed from the cache and immediately
- * re-added when the service package is updated; when
- * {@link #PACKAGE_UPDATE_POLICY_NO_REFRESH}, the service is untouched during the update.
+ * @param servicePackagePolicyFlags a combination of
+ * {@link #PACKAGE_UPDATE_POLICY_NO_REFRESH},
+ * {@link #PACKAGE_UPDATE_POLICY_REFRESH_LAZY},
+ * {@link #PACKAGE_UPDATE_POLICY_REFRESH_EAGER},
+ * {@link #PACKAGE_RESTART_POLICY_NO_REFRESH},
+ * {@link #PACKAGE_RESTART_POLICY_REFRESH_LAZY} or
+ * {@link #PACKAGE_RESTART_POLICY_REFRESH_EAGER}
*/
protected AbstractMasterSystemService(@NonNull Context context,
- @Nullable ServiceNameResolver serviceNameResolver,
- @Nullable String disallowProperty, @PackageUpdatePolicy int packageUpdatePolicy) {
+ @Nullable ServiceNameResolver serviceNameResolver, @Nullable String disallowProperty,
+ @ServicePackagePolicyFlags int servicePackagePolicyFlags) {
super(context);
- mPackageUpdatePolicy = packageUpdatePolicy;
+ final int updatePolicyMask = PACKAGE_UPDATE_POLICY_NO_REFRESH
+ | PACKAGE_UPDATE_POLICY_REFRESH_LAZY | PACKAGE_UPDATE_POLICY_REFRESH_EAGER;
+ if ((servicePackagePolicyFlags & updatePolicyMask) == 0) {
+ // If the package update policy is not set, add the default flag
+ servicePackagePolicyFlags |= PACKAGE_UPDATE_POLICY_REFRESH_LAZY;
+ }
+ final int restartPolicyMask = PACKAGE_RESTART_POLICY_NO_REFRESH
+ | PACKAGE_RESTART_POLICY_REFRESH_LAZY | PACKAGE_RESTART_POLICY_REFRESH_EAGER;
+ if ((servicePackagePolicyFlags & restartPolicyMask) == 0) {
+ // If the package restart policy is not set, add the default flag
+ servicePackagePolicyFlags |= PACKAGE_RESTART_POLICY_REFRESH_LAZY;
+ }
+ mServicePackagePolicyFlags = servicePackagePolicyFlags;
mServiceNameResolver = serviceNameResolver;
if (mServiceNameResolver != null) {
@@ -606,6 +637,20 @@
}
/**
+ * Called after the package data that provides the service for the given user is cleared.
+ */
+ protected void onServicePackageDataClearedLocked(@UserIdInt int userId) {
+ if (verbose) Slog.v(mTag, "onServicePackageDataCleared(" + userId + ")");
+ }
+
+ /**
+ * Called after the package that provides the service for the given user is restarted.
+ */
+ protected void onServicePackageRestartedLocked(@UserIdInt int userId) {
+ if (verbose) Slog.v(mTag, "onServicePackageRestarted(" + userId + ")");
+ }
+
+ /**
* Called after the service is removed from the cache.
*/
@SuppressWarnings("unused")
@@ -677,7 +722,7 @@
final int size = mServicesCache.size();
pw.print(prefix); pw.print("Debug: "); pw.print(realDebug);
pw.print(" Verbose: "); pw.println(realVerbose);
- pw.print("Refresh on package update: "); pw.println(mPackageUpdatePolicy);
+ pw.print("Package policy flags: "); pw.println(mServicePackagePolicyFlags);
if (mUpdatingPackageNames != null) {
pw.print("Packages being updated: "); pw.println(mUpdatingPackageNames);
}
@@ -733,7 +778,12 @@
}
mUpdatingPackageNames.put(userId, packageName);
onServicePackageUpdatingLocked(userId);
- if (mPackageUpdatePolicy != PACKAGE_UPDATE_POLICY_NO_REFRESH) {
+ if ((mServicePackagePolicyFlags & PACKAGE_UPDATE_POLICY_NO_REFRESH) != 0) {
+ if (debug) {
+ Slog.d(mTag, "Holding service for user " + userId + " while package "
+ + activePackageName + " is being updated");
+ }
+ } else {
if (debug) {
Slog.d(mTag, "Removing service for user " + userId
+ " because package " + activePackageName
@@ -741,18 +791,14 @@
}
removeCachedServiceLocked(userId);
- if (mPackageUpdatePolicy == PACKAGE_UPDATE_POLICY_REFRESH_EAGER) {
+ if ((mServicePackagePolicyFlags & PACKAGE_UPDATE_POLICY_REFRESH_EAGER)
+ != 0) {
if (debug) {
Slog.d(mTag, "Eagerly recreating service for user "
+ userId);
}
getServiceForUserLocked(userId);
}
- } else {
- if (debug) {
- Slog.d(mTag, "Holding service for user " + userId + " while package "
- + activePackageName + " is being updated");
- }
}
}
}
@@ -804,7 +850,13 @@
if (!doit) {
return true;
}
- removeCachedServiceLocked(getChangingUserId());
+ final String action = intent.getAction();
+ final int userId = getChangingUserId();
+ if (Intent.ACTION_PACKAGE_RESTARTED.equals(action)) {
+ handleActiveServiceRestartedLocked(activePackageName, userId);
+ } else {
+ removeCachedServiceLocked(userId);
+ }
} else {
handlePackageUpdateLocked(pkg);
}
@@ -813,6 +865,23 @@
return false;
}
+ @Override
+ public void onPackageDataCleared(String packageName, int uid) {
+ if (verbose) Slog.v(mTag, "onPackageDataCleared(): " + packageName);
+ final int userId = getChangingUserId();
+ synchronized (mLock) {
+ final S service = peekServiceForUserLocked(userId);
+ if (service != null) {
+ final ComponentName componentName = service.getServiceComponentName();
+ if (componentName != null) {
+ if (packageName.equals(componentName.getPackageName())) {
+ onServicePackageDataClearedLocked(userId);
+ }
+ }
+ }
+ }
+ }
+
private void handleActiveServiceRemoved(@UserIdInt int userId) {
synchronized (mLock) {
removeCachedServiceLocked(userId);
@@ -824,6 +893,31 @@
}
}
+ private void handleActiveServiceRestartedLocked(String activePackageName,
+ @UserIdInt int userId) {
+ if ((mServicePackagePolicyFlags & PACKAGE_RESTART_POLICY_NO_REFRESH) != 0) {
+ if (debug) {
+ Slog.d(mTag, "Holding service for user " + userId + " while package "
+ + activePackageName + " is being restarted");
+ }
+ } else {
+ if (debug) {
+ Slog.d(mTag, "Removing service for user " + userId
+ + " because package " + activePackageName
+ + " is being restarted");
+ }
+ removeCachedServiceLocked(userId);
+
+ if ((mServicePackagePolicyFlags & PACKAGE_RESTART_POLICY_REFRESH_EAGER) != 0) {
+ if (debug) {
+ Slog.d(mTag, "Eagerly recreating service for user " + userId);
+ }
+ getServiceForUserLocked(userId);
+ }
+ }
+ onServicePackageRestartedLocked(userId);
+ }
+
private String getActiveServicePackageNameLocked() {
final int userId = getChangingUserId();
final S service = peekServiceForUserLocked(userId);
diff --git a/services/core/java/com/android/server/location/GnssLocationProvider.java b/services/core/java/com/android/server/location/GnssLocationProvider.java
index c312b76..181a435 100644
--- a/services/core/java/com/android/server/location/GnssLocationProvider.java
+++ b/services/core/java/com/android/server/location/GnssLocationProvider.java
@@ -1459,7 +1459,7 @@
info.mSvCarrierFreqs);
// Log CN0 as part of GNSS metrics
- mGnssMetrics.logCn0(info.mCn0s, info.mSvCount);
+ mGnssMetrics.logCn0(info.mCn0s, info.mSvCount, info.mSvCarrierFreqs);
if (VERBOSE) {
Log.v(TAG, "SV count: " + info.mSvCount);
@@ -1510,6 +1510,8 @@
SystemClock.elapsedRealtime() - mLastFixTime > RECENT_FIX_TIMEOUT) {
updateStatus(LocationProvider.TEMPORARILY_UNAVAILABLE);
}
+
+ mGnssMetrics.logSvStatus(info.mSvCount, info.mSvidWithFlags, info.mSvCarrierFreqs);
}
@NativeEntryPoint
diff --git a/services/core/java/com/android/server/notification/BubbleExtractor.java b/services/core/java/com/android/server/notification/BubbleExtractor.java
index 358bdb9..e59bf16 100644
--- a/services/core/java/com/android/server/notification/BubbleExtractor.java
+++ b/services/core/java/com/android/server/notification/BubbleExtractor.java
@@ -41,10 +41,9 @@
if (DBG) Slog.d(TAG, "missing config");
return null;
}
- boolean userWantsBubbles = mConfig.bubblesEnabled(record.sbn.getUser());
boolean appCanShowBubble =
mConfig.areBubblesAllowed(record.sbn.getPackageName(), record.sbn.getUid());
- if (!userWantsBubbles || !appCanShowBubble) {
+ if (!mConfig.bubblesEnabled() || !appCanShowBubble) {
record.setAllowBubble(false);
} else {
if (record.getChannel() != null) {
diff --git a/services/core/java/com/android/server/notification/ManagedServices.java b/services/core/java/com/android/server/notification/ManagedServices.java
index 4a6eb27..4828bbf 100644
--- a/services/core/java/com/android/server/notification/ManagedServices.java
+++ b/services/core/java/com/android/server/notification/ManagedServices.java
@@ -196,18 +196,20 @@
public void dump(PrintWriter pw, DumpFilter filter) {
pw.println(" Allowed " + getCaption() + "s:");
- final int N = mApproved.size();
- for (int i = 0 ; i < N; i++) {
- final int userId = mApproved.keyAt(i);
- final ArrayMap<Boolean, ArraySet<String>> approvedByType = mApproved.valueAt(i);
- if (approvedByType != null) {
- final int M = approvedByType.size();
- for (int j = 0; j < M; j++) {
- final boolean isPrimary = approvedByType.keyAt(j);
- final ArraySet<String> approved = approvedByType.valueAt(j);
- if (approvedByType != null && approvedByType.size() > 0) {
- pw.println(" " + String.join(ENABLED_SERVICES_SEPARATOR, approved)
- + " (user: " + userId + " isPrimary: " + isPrimary + ")");
+ synchronized (mApproved) {
+ final int N = mApproved.size();
+ for (int i = 0; i < N; i++) {
+ final int userId = mApproved.keyAt(i);
+ final ArrayMap<Boolean, ArraySet<String>> approvedByType = mApproved.valueAt(i);
+ if (approvedByType != null) {
+ final int M = approvedByType.size();
+ for (int j = 0; j < M; j++) {
+ final boolean isPrimary = approvedByType.keyAt(j);
+ final ArraySet<String> approved = approvedByType.valueAt(j);
+ if (approvedByType != null && approvedByType.size() > 0) {
+ pw.println(" " + String.join(ENABLED_SERVICES_SEPARATOR, approved)
+ + " (user: " + userId + " isPrimary: " + isPrimary + ")");
+ }
}
}
}
@@ -240,23 +242,25 @@
public void dump(ProtoOutputStream proto, DumpFilter filter) {
proto.write(ManagedServicesProto.CAPTION, getCaption());
- final int N = mApproved.size();
- for (int i = 0 ; i < N; i++) {
- final int userId = mApproved.keyAt(i);
- final ArrayMap<Boolean, ArraySet<String>> approvedByType = mApproved.valueAt(i);
- if (approvedByType != null) {
- final int M = approvedByType.size();
- for (int j = 0; j < M; j++) {
- final boolean isPrimary = approvedByType.keyAt(j);
- final ArraySet<String> approved = approvedByType.valueAt(j);
- if (approvedByType != null && approvedByType.size() > 0) {
- final long sToken = proto.start(ManagedServicesProto.APPROVED);
- for (String s : approved) {
- proto.write(ServiceProto.NAME, s);
+ synchronized (mApproved) {
+ final int N = mApproved.size();
+ for (int i = 0; i < N; i++) {
+ final int userId = mApproved.keyAt(i);
+ final ArrayMap<Boolean, ArraySet<String>> approvedByType = mApproved.valueAt(i);
+ if (approvedByType != null) {
+ final int M = approvedByType.size();
+ for (int j = 0; j < M; j++) {
+ final boolean isPrimary = approvedByType.keyAt(j);
+ final ArraySet<String> approved = approvedByType.valueAt(j);
+ if (approvedByType != null && approvedByType.size() > 0) {
+ final long sToken = proto.start(ManagedServicesProto.APPROVED);
+ for (String s : approved) {
+ proto.write(ServiceProto.NAME, s);
+ }
+ proto.write(ServiceProto.USER_ID, userId);
+ proto.write(ServiceProto.IS_PRIMARY, isPrimary);
+ proto.end(sToken);
}
- proto.write(ServiceProto.USER_ID, userId);
- proto.write(ServiceProto.IS_PRIMARY, isPrimary);
- proto.end(sToken);
}
}
}
@@ -315,33 +319,36 @@
trimApprovedListsAccordingToInstalledServices(userId);
}
- final int N = mApproved.size();
- for (int i = 0 ; i < N; i++) {
- final int approvedUserId = mApproved.keyAt(i);
- if (forBackup && approvedUserId != userId) {
- continue;
- }
- final ArrayMap<Boolean, ArraySet<String>> approvedByType = mApproved.valueAt(i);
- if (approvedByType != null) {
- final int M = approvedByType.size();
- for (int j = 0; j < M; j++) {
- final boolean isPrimary = approvedByType.keyAt(j);
- final Set<String> approved = approvedByType.valueAt(j);
- if (approved != null) {
- String allowedItems = String.join(ENABLED_SERVICES_SEPARATOR, approved);
- out.startTag(null, TAG_MANAGED_SERVICES);
- out.attribute(null, ATT_APPROVED_LIST, allowedItems);
- out.attribute(null, ATT_USER_ID, Integer.toString(approvedUserId));
- out.attribute(null, ATT_IS_PRIMARY, Boolean.toString(isPrimary));
- writeExtraAttributes(out, approvedUserId);
- out.endTag(null, TAG_MANAGED_SERVICES);
+ synchronized (mApproved) {
+ final int N = mApproved.size();
+ for (int i = 0; i < N; i++) {
+ final int approvedUserId = mApproved.keyAt(i);
+ if (forBackup && approvedUserId != userId) {
+ continue;
+ }
+ final ArrayMap<Boolean, ArraySet<String>> approvedByType = mApproved.valueAt(i);
+ if (approvedByType != null) {
+ final int M = approvedByType.size();
+ for (int j = 0; j < M; j++) {
+ final boolean isPrimary = approvedByType.keyAt(j);
+ final Set<String> approved = approvedByType.valueAt(j);
+ if (approved != null) {
+ String allowedItems = String.join(ENABLED_SERVICES_SEPARATOR, approved);
+ out.startTag(null, TAG_MANAGED_SERVICES);
+ out.attribute(null, ATT_APPROVED_LIST, allowedItems);
+ out.attribute(null, ATT_USER_ID, Integer.toString(approvedUserId));
+ out.attribute(null, ATT_IS_PRIMARY, Boolean.toString(isPrimary));
+ writeExtraAttributes(out, approvedUserId);
+ out.endTag(null, TAG_MANAGED_SERVICES);
- if (!forBackup && isPrimary) {
- // Also write values to settings, for observers who haven't migrated yet
- Settings.Secure.putStringForUser(mContext.getContentResolver(),
- getConfig().secureSettingName, allowedItems, approvedUserId);
+ if (!forBackup && isPrimary) {
+ // Also write values to settings, for observers who haven't migrated yet
+ Settings.Secure.putStringForUser(mContext.getContentResolver(),
+ getConfig().secureSettingName, allowedItems,
+ approvedUserId);
+ }
+
}
-
}
}
}
@@ -440,23 +447,25 @@
if (TextUtils.isEmpty(approved)) {
approved = "";
}
- ArrayMap<Boolean, ArraySet<String>> approvedByType = mApproved.get(userId);
- if (approvedByType == null) {
- approvedByType = new ArrayMap<>();
- mApproved.put(userId, approvedByType);
- }
+ synchronized (mApproved) {
+ ArrayMap<Boolean, ArraySet<String>> approvedByType = mApproved.get(userId);
+ if (approvedByType == null) {
+ approvedByType = new ArrayMap<>();
+ mApproved.put(userId, approvedByType);
+ }
- ArraySet<String> approvedList = approvedByType.get(isPrimary);
- if (approvedList == null) {
- approvedList = new ArraySet<>();
- approvedByType.put(isPrimary, approvedList);
- }
+ ArraySet<String> approvedList = approvedByType.get(isPrimary);
+ if (approvedList == null) {
+ approvedList = new ArraySet<>();
+ approvedByType.put(isPrimary, approvedList);
+ }
- String[] approvedArray = approved.split(ENABLED_SERVICES_SEPARATOR);
- for (String pkgOrComponent : approvedArray) {
- String approvedItem = getApprovedValue(pkgOrComponent);
- if (approvedItem != null) {
- approvedList.add(approvedItem);
+ String[] approvedArray = approved.split(ENABLED_SERVICES_SEPARATOR);
+ for (String pkgOrComponent : approvedArray) {
+ String approvedItem = getApprovedValue(pkgOrComponent);
+ if (approvedItem != null) {
+ approvedList.add(approvedItem);
+ }
}
}
}
@@ -469,23 +478,25 @@
boolean isPrimary, boolean enabled) {
Slog.i(TAG,
(enabled ? " Allowing " : "Disallowing ") + mConfig.caption + " " + pkgOrComponent);
- ArrayMap<Boolean, ArraySet<String>> allowedByType = mApproved.get(userId);
- if (allowedByType == null) {
- allowedByType = new ArrayMap<>();
- mApproved.put(userId, allowedByType);
- }
- ArraySet<String> approved = allowedByType.get(isPrimary);
- if (approved == null) {
- approved = new ArraySet<>();
- allowedByType.put(isPrimary, approved);
- }
- String approvedItem = getApprovedValue(pkgOrComponent);
+ synchronized (mApproved) {
+ ArrayMap<Boolean, ArraySet<String>> allowedByType = mApproved.get(userId);
+ if (allowedByType == null) {
+ allowedByType = new ArrayMap<>();
+ mApproved.put(userId, allowedByType);
+ }
+ ArraySet<String> approved = allowedByType.get(isPrimary);
+ if (approved == null) {
+ approved = new ArraySet<>();
+ allowedByType.put(isPrimary, approved);
+ }
+ String approvedItem = getApprovedValue(pkgOrComponent);
- if (approvedItem != null) {
- if (enabled) {
- approved.add(approvedItem);
- } else {
- approved.remove(approvedItem);
+ if (approvedItem != null) {
+ if (enabled) {
+ approved.add(approvedItem);
+ } else {
+ approved.remove(approvedItem);
+ }
}
}
@@ -504,22 +515,26 @@
}
protected String getApproved(int userId, boolean primary) {
- final ArrayMap<Boolean, ArraySet<String>> allowedByType =
- mApproved.getOrDefault(userId, new ArrayMap<>());
- ArraySet<String> approved = allowedByType.getOrDefault(primary, new ArraySet<>());
- return String.join(ENABLED_SERVICES_SEPARATOR, approved);
+ synchronized (mApproved) {
+ final ArrayMap<Boolean, ArraySet<String>> allowedByType =
+ mApproved.getOrDefault(userId, new ArrayMap<>());
+ ArraySet<String> approved = allowedByType.getOrDefault(primary, new ArraySet<>());
+ return String.join(ENABLED_SERVICES_SEPARATOR, approved);
+ }
}
protected List<ComponentName> getAllowedComponents(int userId) {
final List<ComponentName> allowedComponents = new ArrayList<>();
- final ArrayMap<Boolean, ArraySet<String>> allowedByType =
- mApproved.getOrDefault(userId, new ArrayMap<>());
- for (int i = 0; i < allowedByType.size(); i++) {
- final ArraySet<String> allowed = allowedByType.valueAt(i);
- for (int j = 0; j < allowed.size(); j++) {
- ComponentName cn = ComponentName.unflattenFromString(allowed.valueAt(j));
- if (cn != null) {
- allowedComponents.add(cn);
+ synchronized (mApproved) {
+ final ArrayMap<Boolean, ArraySet<String>> allowedByType =
+ mApproved.getOrDefault(userId, new ArrayMap<>());
+ for (int i = 0; i < allowedByType.size(); i++) {
+ final ArraySet<String> allowed = allowedByType.valueAt(i);
+ for (int j = 0; j < allowed.size(); j++) {
+ ComponentName cn = ComponentName.unflattenFromString(allowed.valueAt(j));
+ if (cn != null) {
+ allowedComponents.add(cn);
+ }
}
}
}
@@ -528,14 +543,16 @@
protected List<String> getAllowedPackages(int userId) {
final List<String> allowedPackages = new ArrayList<>();
- final ArrayMap<Boolean, ArraySet<String>> allowedByType =
- mApproved.getOrDefault(userId, new ArrayMap<>());
- for (int i = 0; i < allowedByType.size(); i++) {
- final ArraySet<String> allowed = allowedByType.valueAt(i);
- for (int j = 0; j < allowed.size(); j++) {
- String pkgName = getPackageName(allowed.valueAt(j));
- if (!TextUtils.isEmpty(pkgName)) {
- allowedPackages.add(pkgName);
+ synchronized (mApproved) {
+ final ArrayMap<Boolean, ArraySet<String>> allowedByType =
+ mApproved.getOrDefault(userId, new ArrayMap<>());
+ for (int i = 0; i < allowedByType.size(); i++) {
+ final ArraySet<String> allowed = allowedByType.valueAt(i);
+ for (int j = 0; j < allowed.size(); j++) {
+ String pkgName = getPackageName(allowed.valueAt(j));
+ if (!TextUtils.isEmpty(pkgName)) {
+ allowedPackages.add(pkgName);
+ }
}
}
}
@@ -543,12 +560,14 @@
}
protected boolean isPackageOrComponentAllowed(String pkgOrComponent, int userId) {
- ArrayMap<Boolean, ArraySet<String>> allowedByType =
- mApproved.getOrDefault(userId, new ArrayMap<>());
- for (int i = 0; i < allowedByType.size(); i++) {
- ArraySet<String> allowed = allowedByType.valueAt(i);
- if (allowed.contains(pkgOrComponent)) {
- return true;
+ synchronized (mApproved) {
+ ArrayMap<Boolean, ArraySet<String>> allowedByType =
+ mApproved.getOrDefault(userId, new ArrayMap<>());
+ for (int i = 0; i < allowedByType.size(); i++) {
+ ArraySet<String> allowed = allowedByType.valueAt(i);
+ if (allowed.contains(pkgOrComponent)) {
+ return true;
+ }
}
}
return false;
@@ -558,19 +577,21 @@
if (pkg == null) {
return false;
}
- ArrayMap<Boolean, ArraySet<String>> allowedByType =
- mApproved.getOrDefault(userId, new ArrayMap<>());
- for (int i = 0; i < allowedByType.size(); i++) {
- ArraySet<String> allowed = allowedByType.valueAt(i);
- for (String allowedEntry : allowed) {
- ComponentName component = ComponentName.unflattenFromString(allowedEntry);
- if (component != null) {
- if (pkg.equals(component.getPackageName())) {
- return true;
- }
- } else {
- if (pkg.equals(allowedEntry)) {
- return true;
+ synchronized (mApproved) {
+ ArrayMap<Boolean, ArraySet<String>> allowedByType =
+ mApproved.getOrDefault(userId, new ArrayMap<>());
+ for (int i = 0; i < allowedByType.size(); i++) {
+ ArraySet<String> allowed = allowedByType.valueAt(i);
+ for (String allowedEntry : allowed) {
+ ComponentName component = ComponentName.unflattenFromString(allowedEntry);
+ if (component != null) {
+ if (pkg.equals(component.getPackageName())) {
+ return true;
+ }
+ } else {
+ if (pkg.equals(allowedEntry)) {
+ return true;
+ }
}
}
}
@@ -616,7 +637,9 @@
public void onUserRemoved(int user) {
Slog.i(TAG, "Removing approved services for removed user " + user);
- mApproved.remove(user);
+ synchronized (mApproved) {
+ mApproved.remove(user);
+ }
rebindServices(true, user);
}
@@ -797,14 +820,16 @@
protected Set<String> getAllowedPackages() {
final Set<String> allowedPackages = new ArraySet<>();
- for (int k = 0; k < mApproved.size(); k++) {
- ArrayMap<Boolean, ArraySet<String>> allowedByType = mApproved.valueAt(k);
- for (int i = 0; i < allowedByType.size(); i++) {
- final ArraySet<String> allowed = allowedByType.valueAt(i);
- for (int j = 0; j < allowed.size(); j++) {
- String pkgName = getPackageName(allowed.valueAt(j));
- if (!TextUtils.isEmpty(pkgName)) {
- allowedPackages.add(pkgName);
+ synchronized (mApproved) {
+ for (int k = 0; k < mApproved.size(); k++) {
+ ArrayMap<Boolean, ArraySet<String>> allowedByType = mApproved.valueAt(k);
+ for (int i = 0; i < allowedByType.size(); i++) {
+ final ArraySet<String> allowed = allowedByType.valueAt(i);
+ for (int j = 0; j < allowed.size(); j++) {
+ String pkgName = getPackageName(allowed.valueAt(j));
+ if (!TextUtils.isEmpty(pkgName)) {
+ allowedPackages.add(pkgName);
+ }
}
}
}
@@ -813,22 +838,24 @@
}
private void trimApprovedListsAccordingToInstalledServices(int userId) {
- final ArrayMap<Boolean, ArraySet<String>> approvedByType = mApproved.get(userId);
- if (approvedByType == null) {
- return;
- }
- for (int i = 0; i < approvedByType.size(); i++) {
- final ArraySet<String> approved = approvedByType.valueAt(i);
- for (int j = approved.size() - 1; j >= 0; j--) {
- final String approvedPackageOrComponent = approved.valueAt(j);
- if (!isValidEntry(approvedPackageOrComponent, userId)){
- approved.removeAt(j);
- Slog.v(TAG, "Removing " + approvedPackageOrComponent
- + " from approved list; no matching services found");
- } else {
- if (DEBUG) {
- Slog.v(TAG, "Keeping " + approvedPackageOrComponent
- + " on approved list; matching services found");
+ synchronized (mApproved) {
+ final ArrayMap<Boolean, ArraySet<String>> approvedByType = mApproved.get(userId);
+ if (approvedByType == null) {
+ return;
+ }
+ for (int i = 0; i < approvedByType.size(); i++) {
+ final ArraySet<String> approved = approvedByType.valueAt(i);
+ for (int j = approved.size() - 1; j >= 0; j--) {
+ final String approvedPackageOrComponent = approved.valueAt(j);
+ if (!isValidEntry(approvedPackageOrComponent, userId)) {
+ approved.removeAt(j);
+ Slog.v(TAG, "Removing " + approvedPackageOrComponent
+ + " from approved list; no matching services found");
+ } else {
+ if (DEBUG) {
+ Slog.v(TAG, "Keeping " + approvedPackageOrComponent
+ + " on approved list; matching services found");
+ }
}
}
}
@@ -837,20 +864,23 @@
private boolean removeUninstalledItemsFromApprovedLists(int uninstalledUserId, String pkg) {
boolean removed = false;
- final ArrayMap<Boolean, ArraySet<String>> approvedByType = mApproved.get(uninstalledUserId);
- if (approvedByType != null) {
- int M = approvedByType.size();
- for (int j = 0; j < M; j++) {
- final ArraySet<String> approved = approvedByType.valueAt(j);
- int O = approved.size();
- for (int k = O - 1; k >= 0; k--) {
- final String packageOrComponent = approved.valueAt(k);
- final String packageName = getPackageName(packageOrComponent);
- if (TextUtils.equals(pkg, packageName)) {
- approved.removeAt(k);
- if (DEBUG) {
- Slog.v(TAG, "Removing " + packageOrComponent
- + " from approved list; uninstalled");
+ synchronized (mApproved) {
+ final ArrayMap<Boolean, ArraySet<String>> approvedByType = mApproved.get(
+ uninstalledUserId);
+ if (approvedByType != null) {
+ int M = approvedByType.size();
+ for (int j = 0; j < M; j++) {
+ final ArraySet<String> approved = approvedByType.valueAt(j);
+ int O = approved.size();
+ for (int k = O - 1; k >= 0; k--) {
+ final String packageOrComponent = approved.valueAt(k);
+ final String packageName = getPackageName(packageOrComponent);
+ if (TextUtils.equals(pkg, packageName)) {
+ approved.removeAt(k);
+ if (DEBUG) {
+ Slog.v(TAG, "Removing " + packageOrComponent
+ + " from approved list; uninstalled");
+ }
}
}
}
@@ -887,17 +917,19 @@
for (int i = 0; i < nUserIds; ++i) {
final int userId = userIds.get(i);
- final ArrayMap<Boolean, ArraySet<String>> approvedLists = mApproved.get(userId);
- if (approvedLists != null) {
- final int N = approvedLists.size();
- for (int j = 0; j < N; j++) {
- ArraySet<ComponentName> approvedByUser = componentsByUser.get(userId);
- if (approvedByUser == null) {
- approvedByUser = new ArraySet<>();
- componentsByUser.put(userId, approvedByUser);
+ synchronized (mApproved) {
+ final ArrayMap<Boolean, ArraySet<String>> approvedLists = mApproved.get(userId);
+ if (approvedLists != null) {
+ final int N = approvedLists.size();
+ for (int j = 0; j < N; j++) {
+ ArraySet<ComponentName> approvedByUser = componentsByUser.get(userId);
+ if (approvedByUser == null) {
+ approvedByUser = new ArraySet<>();
+ componentsByUser.put(userId, approvedByUser);
+ }
+ approvedByUser.addAll(
+ loadComponentNamesFromValues(approvedLists.valueAt(j), userId));
}
- approvedByUser.addAll(
- loadComponentNamesFromValues(approvedLists.valueAt(j), userId));
}
}
}
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index cc2df50..a91630e 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -91,6 +91,7 @@
import static com.android.server.am.PendingIntentRecord.FLAG_ACTIVITY_SENDER;
import static com.android.server.am.PendingIntentRecord.FLAG_BROADCAST_SENDER;
import static com.android.server.am.PendingIntentRecord.FLAG_SERVICE_SENDER;
+import static com.android.server.notification.PreferencesHelper.DEFAULT_ALLOW_BUBBLE;
import static com.android.server.utils.PriorityDump.PRIORITY_ARG;
import static com.android.server.utils.PriorityDump.PRIORITY_ARG_CRITICAL;
import static com.android.server.utils.PriorityDump.PRIORITY_ARG_NORMAL;
@@ -466,6 +467,8 @@
private MetricsLogger mMetricsLogger;
private TriPredicate<String, Integer, String> mAllowedManagedServicePackages;
+ private final SavePolicyFileRunnable mSavePolicyFile = new SavePolicyFileRunnable();
+
private static class Archive {
final int mBufferSize;
final ArrayDeque<StatusBarNotification> mBuffer;
@@ -659,7 +662,14 @@
@VisibleForTesting
protected void handleSavePolicyFile() {
- IoThread.getHandler().post(() -> {
+ if (!IoThread.getHandler().hasCallbacks(mSavePolicyFile)) {
+ IoThread.getHandler().post(mSavePolicyFile);
+ }
+ }
+
+ private final class SavePolicyFileRunnable implements Runnable {
+ @Override
+ public void run() {
if (DBG) Slog.d(TAG, "handleSavePolicyFile");
synchronized (mPolicyFile) {
final FileOutputStream stream;
@@ -679,7 +689,7 @@
}
}
BackupManager.dataChanged(getContext().getPackageName());
- });
+ }
}
private void writePolicyXml(OutputStream stream, boolean forBackup, int userId)
@@ -1372,7 +1382,9 @@
private final class SettingsObserver extends ContentObserver {
private final Uri NOTIFICATION_BADGING_URI
= Settings.Secure.getUriFor(Settings.Secure.NOTIFICATION_BADGING);
- private final Uri NOTIFICATION_BUBBLES_URI
+ private final Uri NOTIFICATION_BUBBLES_URI_GLOBAL
+ = Settings.Global.getUriFor(Settings.Global.NOTIFICATION_BUBBLES);
+ private final Uri NOTIFICATION_BUBBLES_URI_SECURE
= Settings.Secure.getUriFor(Settings.Secure.NOTIFICATION_BUBBLES);
private final Uri NOTIFICATION_LIGHT_PULSE_URI
= Settings.System.getUriFor(Settings.System.NOTIFICATION_LIGHT_PULSE);
@@ -1391,7 +1403,9 @@
false, this, UserHandle.USER_ALL);
resolver.registerContentObserver(NOTIFICATION_RATE_LIMIT_URI,
false, this, UserHandle.USER_ALL);
- resolver.registerContentObserver(NOTIFICATION_BUBBLES_URI,
+ resolver.registerContentObserver(NOTIFICATION_BUBBLES_URI_GLOBAL,
+ false, this, UserHandle.USER_ALL);
+ resolver.registerContentObserver(NOTIFICATION_BUBBLES_URI_SECURE,
false, this, UserHandle.USER_ALL);
update(null);
}
@@ -1418,9 +1432,41 @@
if (uri == null || NOTIFICATION_BADGING_URI.equals(uri)) {
mPreferencesHelper.updateBadgingEnabled();
}
- if (uri == null || NOTIFICATION_BUBBLES_URI.equals(uri)) {
+ // In QPR we moved the setting to Global rather than Secure so that the setting
+ // applied to work profiles. Unfortunately we need to maintain both to pass CTS without
+ // a change to CTS outside of a normal letter release.
+ if (uri == null || NOTIFICATION_BUBBLES_URI_GLOBAL.equals(uri)) {
+ syncBubbleSettings(resolver, NOTIFICATION_BUBBLES_URI_GLOBAL);
mPreferencesHelper.updateBubblesEnabled();
}
+ if (NOTIFICATION_BUBBLES_URI_SECURE.equals(uri)) {
+ syncBubbleSettings(resolver, NOTIFICATION_BUBBLES_URI_SECURE);
+ }
+ }
+
+ private void syncBubbleSettings(ContentResolver resolver, Uri settingToFollow) {
+ boolean followSecureSetting = settingToFollow.equals(NOTIFICATION_BUBBLES_URI_SECURE);
+
+ int secureSettingValue = Settings.Secure.getInt(resolver,
+ Settings.Secure.NOTIFICATION_BUBBLES, DEFAULT_ALLOW_BUBBLE ? 1 : 0);
+ int globalSettingValue = Settings.Global.getInt(resolver,
+ Settings.Global.NOTIFICATION_BUBBLES, DEFAULT_ALLOW_BUBBLE ? 1 : 0);
+
+ if (globalSettingValue == secureSettingValue) {
+ return;
+ }
+
+ if (followSecureSetting) {
+ // Global => secure
+ Settings.Global.putInt(resolver,
+ Settings.Global.NOTIFICATION_BUBBLES,
+ secureSettingValue);
+ } else {
+ // Secure => Global
+ Settings.Secure.putInt(resolver,
+ Settings.Secure.NOTIFICATION_BADGING,
+ globalSettingValue);
+ }
}
}
@@ -1838,6 +1884,7 @@
}
if (properties.getKeyset()
.contains(SystemUiDeviceConfigFlags.NAS_DEFAULT_SERVICE)) {
+ mAssistants.allowAdjustmentType(Adjustment.KEY_IMPORTANCE);
mAssistants.resetDefaultAssistantsIfNecessary();
}
});
@@ -2270,7 +2317,7 @@
final int callingUid = Binder.getCallingUid();
final boolean isSystemToast = isCallerSystemOrPhone()
|| PackageManagerService.PLATFORM_PACKAGE_NAME.equals(pkg);
- final boolean isPackageSuspended = isPackageSuspendedForUser(pkg, callingUid);
+ final boolean isPackageSuspended = isPackagePaused(pkg);
final boolean notificationsDisabledForPackage = !areNotificationsEnabledForPackage(pkg,
callingUid);
@@ -2419,9 +2466,25 @@
}
@Override
+ public void silenceNotificationSound() {
+ checkCallerIsSystem();
+
+ mNotificationDelegate.clearEffects();
+ }
+
+ @Override
public void setNotificationsEnabledForPackage(String pkg, int uid, boolean enabled) {
enforceSystemOrSystemUI("setNotificationsEnabledForPackage");
+ synchronized (mNotificationLock) {
+ boolean wasEnabled = mPreferencesHelper.getImportance(pkg, uid)
+ != NotificationManager.IMPORTANCE_NONE;
+
+ if (wasEnabled == enabled) {
+ return;
+ }
+ }
+
mPreferencesHelper.setEnabled(pkg, uid, enabled);
mMetricsLogger.write(new LogMaker(MetricsEvent.ACTION_BAN_APP_NOTES)
.setType(MetricsEvent.TYPE_ACTION)
@@ -4108,17 +4171,7 @@
Preconditions.checkNotNull(pkg);
checkCallerIsSameApp(pkg);
- boolean isPaused;
-
- final PackageManagerInternal pmi = LocalServices.getService(
- PackageManagerInternal.class);
- int flags = pmi.getDistractingPackageRestrictions(
- pkg, Binder.getCallingUserHandle().getIdentifier());
- isPaused = ((flags & PackageManager.RESTRICTION_HIDE_NOTIFICATIONS) != 0);
-
- isPaused |= isPackageSuspendedForUser(pkg, Binder.getCallingUid());
-
- return isPaused;
+ return isPackagePausedOrSuspended(pkg, Binder.getCallingUid());
}
private void verifyPrivilegedListener(INotificationListener token, UserHandle user,
@@ -4831,47 +4884,112 @@
} else {
notification.flags &= ~FLAG_BUBBLE;
}
+ // Is the app in the foreground?
+ final boolean appIsForeground =
+ mActivityManager.getPackageImportance(pkg) == IMPORTANCE_FOREGROUND;
+ Notification.BubbleMetadata metadata = notification.getBubbleMetadata();
+ if (!appIsForeground && metadata != null) {
+ // Remove any flags that only work when foregrounded
+ int flags = metadata.getFlags();
+ flags &= ~Notification.BubbleMetadata.FLAG_AUTO_EXPAND_BUBBLE;
+ flags &= ~Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION;
+ metadata.setFlags(flags);
+ }
}
/**
- * @return whether the provided notification record is allowed to be represented as a bubble.
+ * @return whether the provided notification record is allowed to be represented as a bubble,
+ * accounting for user choice & policy.
*/
private boolean isNotificationAppropriateToBubble(NotificationRecord r, String pkg, int userId,
NotificationRecord oldRecord) {
Notification notification = r.getNotification();
- Notification.BubbleMetadata metadata = notification.getBubbleMetadata();
- boolean intentCanBubble = metadata != null
- && canLaunchInActivityView(getContext(), metadata.getIntent(), pkg);
+ if (!canBubble(r, pkg, userId)) {
+ // no log: canBubble has its own
+ return false;
+ }
- // Does the app want to bubble & is able to bubble
- boolean canBubble = intentCanBubble
- && mPreferencesHelper.areBubblesAllowed(pkg, userId)
- && mPreferencesHelper.bubblesEnabled(r.sbn.getUser())
- && r.getChannel().canBubble()
- && !mActivityManager.isLowRamDevice();
+ if (mActivityManager.isLowRamDevice()) {
+ logBubbleError(r.getKey(), "low ram device");
+ return false;
+ }
- // Is the app in the foreground?
- final boolean appIsForeground =
- mActivityManager.getPackageImportance(pkg) == IMPORTANCE_FOREGROUND;
+ if (mActivityManager.getPackageImportance(pkg) == IMPORTANCE_FOREGROUND) {
+ // If the app is foreground it always gets to bubble
+ return true;
+ }
- // Is the notification something we'd allow to bubble?
- // A call with a foreground service + person
+ if (oldRecord != null && (oldRecord.getNotification().flags & FLAG_BUBBLE) != 0) {
+ // This is an update to an active bubble
+ return true;
+ }
+
+ // At this point the bubble must fulfill communication policy
+
+ // Communication always needs a person
ArrayList<Person> peopleList = notification.extras != null
? notification.extras.getParcelableArrayList(Notification.EXTRA_PEOPLE_LIST)
: null;
- boolean isForegroundCall = CATEGORY_CALL.equals(notification.category)
- && (notification.flags & FLAG_FOREGROUND_SERVICE) != 0;
- // OR message style (which always has a person) with any remote input
- Class<? extends Notification.Style> style = notification.getNotificationStyle();
- boolean isMessageStyle = Notification.MessagingStyle.class.equals(style);
- boolean notificationAppropriateToBubble =
- (isMessageStyle && hasValidRemoteInput(notification))
- || (peopleList != null && !peopleList.isEmpty() && isForegroundCall);
+ // Message style requires a person & it's not included in the list
+ boolean isMessageStyle = Notification.MessagingStyle.class.equals(
+ notification.getNotificationStyle());
+ if (!isMessageStyle && (peopleList == null || peopleList.isEmpty())) {
+ logBubbleError(r.getKey(), "if not foreground, must have a person and be "
+ + "Notification.MessageStyle or Notification.CATEGORY_CALL");
+ return false;
+ }
- // OR something that was previously a bubble & still exists
- boolean bubbleUpdate = oldRecord != null
- && (oldRecord.getNotification().flags & FLAG_BUBBLE) != 0;
- return canBubble && (notificationAppropriateToBubble || appIsForeground || bubbleUpdate);
+ // Communication is a message or a call
+ boolean isCall = CATEGORY_CALL.equals(notification.category);
+ boolean hasForegroundService = (notification.flags & FLAG_FOREGROUND_SERVICE) != 0;
+ if (isMessageStyle) {
+ if (hasValidRemoteInput(notification)) {
+ return true;
+ }
+ logBubbleError(r.getKey(), "messages require valid remote input");
+ return false;
+ } else if (isCall) {
+ if (hasForegroundService) {
+ return true;
+ }
+ logBubbleError(r.getKey(), "calls require foreground service");
+ return false;
+ }
+ logBubbleError(r.getKey(), "if not foreground, must be "
+ + "Notification.MessageStyle or Notification.CATEGORY_CALL");
+ return false;
+ }
+
+ /**
+ * @return whether the user has enabled the provided notification to bubble, does not account
+ * for policy.
+ */
+ private boolean canBubble(NotificationRecord r, String pkg, int userId) {
+ Notification notification = r.getNotification();
+ Notification.BubbleMetadata metadata = notification.getBubbleMetadata();
+ if (metadata == null) {
+ // no log: no need to inform dev if they didn't attach bubble metadata
+ return false;
+ }
+ if (!canLaunchInActivityView(getContext(), metadata.getIntent(), pkg)) {
+ // no log: method has the failure log
+ return false;
+ }
+ if (!mPreferencesHelper.bubblesEnabled()) {
+ logBubbleError(r.getKey(), "bubbles disabled for user: " + userId);
+ return false;
+ }
+ if (!mPreferencesHelper.areBubblesAllowed(pkg, userId)) {
+ logBubbleError(r.getKey(),
+ "bubbles for package: " + pkg + " disabled for user: " + userId);
+ return false;
+ }
+ if (!r.getChannel().canBubble()) {
+ logBubbleError(r.getKey(),
+ "bubbles for channel " + r.getChannel().getId() + " disabled");
+ return false;
+ }
+ return true;
}
private boolean hasValidRemoteInput(Notification n) {
@@ -4890,6 +5008,11 @@
return false;
}
+ private void logBubbleError(String key, String failureMessage) {
+ if (DBG) {
+ Log.w(TAG, "Bubble notification: " + key + " failed: " + failureMessage);
+ }
+ }
/**
* Whether an intent is properly configured to display in an {@link android.app.ActivityView}.
*
@@ -5252,12 +5375,26 @@
return;
}
+ // Bubbled children get to stick around if the summary was manually cancelled
+ // (user removed) from systemui.
+ FlagChecker childrenFlagChecker = null;
+ if (mReason == REASON_CANCEL
+ || mReason == REASON_CLICK
+ || mReason == REASON_CANCEL_ALL) {
+ childrenFlagChecker = (flags) -> {
+ if ((flags & FLAG_BUBBLE) != 0) {
+ return false;
+ }
+ return true;
+ };
+ }
+
// Cancel the notification.
boolean wasPosted = removeFromNotificationListsLocked(r);
cancelNotificationLocked(
r, mSendDelete, mReason, mRank, mCount, wasPosted, listenerName);
cancelGroupChildrenLocked(r, mCallingUid, mCallingPid, listenerName,
- mSendDelete, null);
+ mSendDelete, childrenFlagChecker);
updateLightsLocked();
} else {
// No notification was found, assume that it is snoozed and cancel it.
@@ -5340,11 +5477,18 @@
}
@GuardedBy("mNotificationLock")
- private boolean isPackageSuspendedLocked(NotificationRecord r) {
- final String pkg = r.sbn.getPackageName();
- final int callingUid = r.sbn.getUid();
+ boolean isPackagePausedOrSuspended(String pkg, int uid) {
+ boolean isPaused;
- return isPackageSuspendedForUser(pkg, callingUid);
+ final PackageManagerInternal pmi = LocalServices.getService(
+ PackageManagerInternal.class);
+ int flags = pmi.getDistractingPackageRestrictions(
+ pkg, Binder.getCallingUserHandle().getIdentifier());
+ isPaused = ((flags & PackageManager.RESTRICTION_HIDE_NOTIFICATIONS) != 0);
+
+ isPaused |= isPackageSuspendedForUser(pkg, uid);
+
+ return isPaused;
}
protected class PostNotificationRunnable implements Runnable {
@@ -5377,7 +5521,8 @@
return;
}
- final boolean isPackageSuspended = isPackageSuspendedLocked(r);
+ final boolean isPackageSuspended =
+ isPackagePausedOrSuspended(r.sbn.getPackageName(), r.getUid());
r.setHidden(isPackageSuspended);
if (isPackageSuspended) {
mUsageStats.registerSuspendedByAdmin(r);
diff --git a/services/core/java/com/android/server/notification/PreferencesHelper.java b/services/core/java/com/android/server/notification/PreferencesHelper.java
index 7b45a1b..4835c97 100644
--- a/services/core/java/com/android/server/notification/PreferencesHelper.java
+++ b/services/core/java/com/android/server/notification/PreferencesHelper.java
@@ -73,6 +73,9 @@
private static final String NON_BLOCKABLE_CHANNEL_DELIM = ":";
@VisibleForTesting
+ static final int NOTIFICATION_CHANNEL_COUNT_LIMIT = 50000;
+
+ @VisibleForTesting
static final String TAG_RANKING = "ranking";
private static final String TAG_PACKAGE = "package";
private static final String TAG_CHANNEL = "channel";
@@ -100,7 +103,7 @@
@VisibleForTesting
static final boolean DEFAULT_HIDE_SILENT_STATUS_BAR_ICONS = false;
private static final boolean DEFAULT_SHOW_BADGE = true;
- private static final boolean DEFAULT_ALLOW_BUBBLE = true;
+ static final boolean DEFAULT_ALLOW_BUBBLE = true;
private static final boolean DEFAULT_OEM_LOCKED_IMPORTANCE = false;
private static final boolean DEFAULT_APP_LOCKED_IMPORTANCE = false;
@@ -130,7 +133,7 @@
private final ZenModeHelper mZenModeHelper;
private SparseBooleanArray mBadgingEnabled;
- private SparseBooleanArray mBubblesEnabled;
+ private boolean mBubblesEnabled = DEFAULT_ALLOW_BUBBLE;
private boolean mAreChannelsBypassingDnd;
private boolean mHideSilentStatusBarIcons = DEFAULT_HIDE_SILENT_STATUS_BAR_ICONS;
@@ -179,6 +182,7 @@
// noop
}
}
+ boolean skipWarningLogged = false;
PackagePreferences r = getOrCreatePackagePreferencesLocked(name, uid,
XmlUtils.readIntAttribute(
@@ -225,6 +229,14 @@
}
// Channels
if (TAG_CHANNEL.equals(tagName)) {
+ if (r.channels.size() >= NOTIFICATION_CHANNEL_COUNT_LIMIT) {
+ if (!skipWarningLogged) {
+ Slog.w(TAG, "Skipping further channels for " + r.pkg
+ + "; app has too many");
+ skipWarningLogged = true;
+ }
+ continue;
+ }
String id = parser.getAttributeValue(null, ATT_ID);
String channelName = parser.getAttributeValue(null, ATT_NAME);
int channelImportance = XmlUtils.readIntAttribute(
@@ -690,6 +702,10 @@
return needsPolicyFileChange;
}
+ if (r.channels.size() >= NOTIFICATION_CHANNEL_COUNT_LIMIT) {
+ throw new IllegalStateException("Limit exceed; cannot create more channels");
+ }
+
needsPolicyFileChange = true;
if (channel.getImportance() < IMPORTANCE_NONE
@@ -1818,40 +1834,19 @@
}
public void updateBubblesEnabled() {
- if (mBubblesEnabled == null) {
- mBubblesEnabled = new SparseBooleanArray();
- }
- boolean changed = false;
- // update the cached values
- for (int index = 0; index < mBubblesEnabled.size(); index++) {
- int userId = mBubblesEnabled.keyAt(index);
- final boolean oldValue = mBubblesEnabled.get(userId);
- final boolean newValue = Settings.Secure.getIntForUser(mContext.getContentResolver(),
- Settings.Secure.NOTIFICATION_BUBBLES,
- DEFAULT_ALLOW_BUBBLE ? 1 : 0, userId) != 0;
- mBubblesEnabled.put(userId, newValue);
- changed |= oldValue != newValue;
- }
- if (changed) {
+ final boolean newValue = Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.NOTIFICATION_BUBBLES,
+ DEFAULT_ALLOW_BUBBLE ? 1 : 0) == 1;
+ if (newValue != mBubblesEnabled) {
+ mBubblesEnabled = newValue;
updateConfig();
}
}
- public boolean bubblesEnabled(UserHandle userHandle) {
- int userId = userHandle.getIdentifier();
- if (userId == UserHandle.USER_ALL) {
- return false;
- }
- if (mBubblesEnabled.indexOfKey(userId) < 0) {
- mBubblesEnabled.put(userId,
- Settings.Secure.getIntForUser(mContext.getContentResolver(),
- Settings.Secure.NOTIFICATION_BUBBLES,
- DEFAULT_ALLOW_BUBBLE ? 1 : 0, userId) != 0);
- }
- return mBubblesEnabled.get(userId, DEFAULT_ALLOW_BUBBLE);
+ public boolean bubblesEnabled() {
+ return mBubblesEnabled;
}
-
public void updateBadgingEnabled() {
if (mBadgingEnabled == null) {
mBadgingEnabled = new SparseBooleanArray();
diff --git a/services/core/java/com/android/server/notification/RankingConfig.java b/services/core/java/com/android/server/notification/RankingConfig.java
index 5de00e4..7816f36 100644
--- a/services/core/java/com/android/server/notification/RankingConfig.java
+++ b/services/core/java/com/android/server/notification/RankingConfig.java
@@ -30,7 +30,7 @@
boolean canShowBadge(String packageName, int uid);
boolean badgingEnabled(UserHandle userHandle);
boolean areBubblesAllowed(String packageName, int uid);
- boolean bubblesEnabled(UserHandle userHandle);
+ boolean bubblesEnabled();
boolean isGroupBlocked(String packageName, int uid, String groupId);
Collection<NotificationChannelGroup> getNotificationChannelGroups(String pkg,
diff --git a/services/core/java/com/android/server/notification/ZenLog.java b/services/core/java/com/android/server/notification/ZenLog.java
index c6af756..8f05636 100644
--- a/services/core/java/com/android/server/notification/ZenLog.java
+++ b/services/core/java/com/android/server/notification/ZenLog.java
@@ -179,6 +179,7 @@
case TYPE_SUPPRESSOR_CHANGED: return "suppressor_changed";
case TYPE_LISTENER_HINTS_CHANGED: return "listener_hints_changed";
case TYPE_SET_NOTIFICATION_POLICY: return "set_notification_policy";
+ case TYPE_SET_CONSOLIDATED_ZEN_POLICY: return "set_consolidated_policy";
default: return "unknown";
}
}
diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java
index f81015d..ebc4191 100644
--- a/services/core/java/com/android/server/notification/ZenModeHelper.java
+++ b/services/core/java/com/android/server/notification/ZenModeHelper.java
@@ -942,12 +942,11 @@
}
private void applyCustomPolicy(ZenPolicy policy, ZenRule rule) {
- if (rule.zenMode == NotificationManager.INTERRUPTION_FILTER_NONE) {
+ if (rule.zenMode == Global.ZEN_MODE_NO_INTERRUPTIONS) {
policy.apply(new ZenPolicy.Builder()
.disallowAllSounds()
.build());
- } else if (rule.zenMode
- == NotificationManager.INTERRUPTION_FILTER_ALARMS) {
+ } else if (rule.zenMode == Global.ZEN_MODE_ALARMS) {
policy.apply(new ZenPolicy.Builder()
.disallowAllSounds()
.allowAlarms(true)
diff --git a/services/core/java/com/android/server/om/OverlayManagerService.java b/services/core/java/com/android/server/om/OverlayManagerService.java
index da69986..965ddc9 100644
--- a/services/core/java/com/android/server/om/OverlayManagerService.java
+++ b/services/core/java/com/android/server/om/OverlayManagerService.java
@@ -751,7 +751,7 @@
@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
final DumpState dumpState = new DumpState();
- dumpState.setUserId(UserHandle.getUserId(Binder.getCallingUid()));
+ dumpState.setUserId(UserHandle.USER_ALL);
int opti = 0;
while (opti < args.length) {
@@ -771,13 +771,13 @@
pw.println(" so the following are equivalent: mState, mstate, State, state.");
return;
} else if ("--user".equals(opt)) {
- opti++;
if (opti >= args.length) {
pw.println("Error: user missing argument");
return;
}
try {
dumpState.setUserId(Integer.parseInt(args[opti]));
+ opti++;
} catch (NumberFormatException e) {
pw.println("Error: user argument is not a number: " + args[opti]);
return;
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 86fb00d..03e8f6b 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -198,6 +198,7 @@
import android.content.pm.dex.ArtManager;
import android.content.pm.dex.DexMetadataHelper;
import android.content.pm.dex.IArtManager;
+import android.content.pm.permission.SplitPermissionInfoParcelable;
import android.content.res.Resources;
import android.content.rollback.IRollbackManager;
import android.database.ContentObserver;
@@ -238,6 +239,7 @@
import android.os.storage.StorageManagerInternal;
import android.os.storage.VolumeInfo;
import android.os.storage.VolumeRecord;
+import android.permission.PermissionManager;
import android.provider.DeviceConfig;
import android.provider.MediaStore;
import android.provider.Settings.Global;
@@ -2023,6 +2025,14 @@
pkgList.add(packageName);
sendResourcesChangedBroadcast(true, true, pkgList, uidArray, null);
}
+ } else if (!ArrayUtils.isEmpty(res.libraryConsumers)) { // if static shared lib
+ for (int i = 0; i < res.libraryConsumers.size(); i++) {
+ PackageParser.Package pkg = res.libraryConsumers.get(i);
+ // send broadcast that all consumers of the static shared library have changed
+ sendPackageChangedBroadcast(pkg.packageName, false /*killFlag*/,
+ new ArrayList<>(Collections.singletonList(pkg.packageName)),
+ pkg.applicationInfo.uid);
+ }
}
// Work that needs to happen on first install within each user
@@ -2121,6 +2131,12 @@
}
}
+ @Override
+ public List<SplitPermissionInfoParcelable> getSplitPermissions() {
+ return PermissionManager.splitPermissionInfoListToParcelableList(
+ SystemConfig.getInstance().getSplitPermissions());
+ }
+
private void notifyInstallObserver(String packageName) {
Pair<PackageInstalledInfo, IPackageInstallObserver2> pair =
mNoKillInstallObservers.remove(packageName);
@@ -12194,6 +12210,9 @@
}
}
}
+ if (reconciledPkg.installResult != null) {
+ reconciledPkg.installResult.libraryConsumers = clientLibPkgs;
+ }
if ((scanFlags & SCAN_BOOTING) != 0) {
// No apps can run during boot scan, so they don't need to be frozen
@@ -16047,6 +16066,8 @@
String installerPackageName;
PackageRemovedInfo removedInfo;
ArrayMap<String, PackageInstalledInfo> addedChildPackages;
+ // The set of packages consuming this shared library or null if no consumers exist.
+ ArrayList<PackageParser.Package> libraryConsumers;
public void setError(int code, String msg) {
setReturnCode(code);
@@ -18801,8 +18822,14 @@
}
}
if (removedAppId >= 0) {
+ // If a system app's updates are uninstalled the UID is not actually removed. Some
+ // services need to know the package name affected.
+ if (extras.getBoolean(Intent.EXTRA_REPLACING, false)) {
+ extras.putString(Intent.EXTRA_PACKAGE_NAME, removedPackage);
+ }
+
packageSender.sendPackageBroadcast(Intent.ACTION_UID_REMOVED,
- null, extras, Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND,
+ null, extras, Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND,
null, null, broadcastUsers, instantUserIds);
}
}
@@ -18891,19 +18918,20 @@
// or packages running under the shared user of the removed
// package if revoking the permissions requested only by the removed
// package is successful and this causes a change in gids.
+ boolean shouldKill = false;
for (int userId : UserManagerService.getInstance().getUserIds()) {
final int userIdToKill = mSettings.updateSharedUserPermsLPw(deletedPs,
userId);
- if (userIdToKill == UserHandle.USER_ALL
- || userIdToKill >= UserHandle.USER_SYSTEM) {
- // If gids changed for this user, kill all affected packages.
- mHandler.post(() -> {
- // This has to happen with no lock held.
- killApplication(deletedPs.name, deletedPs.appId,
- KILL_APP_REASON_GIDS_CHANGED);
- });
- break;
- }
+ shouldKill |= userIdToKill == UserHandle.USER_ALL
+ || userIdToKill >= UserHandle.USER_SYSTEM;
+ }
+ // If gids changed, kill all affected packages.
+ if (shouldKill) {
+ mHandler.post(() -> {
+ // This has to happen with no lock held.
+ killApplication(deletedPs.name, deletedPs.appId,
+ KILL_APP_REASON_GIDS_CHANGED);
+ });
}
}
clearPackagePreferredActivitiesLPw(
@@ -20860,7 +20888,7 @@
public void sendSessionCommitBroadcast(PackageInstaller.SessionInfo sessionInfo, int userId) {
UserManagerService ums = UserManagerService.getInstance();
- if (ums != null) {
+ if (ums != null && !sessionInfo.isStaged()) {
final UserInfo parent = ums.getProfileParent(userId);
final int launcherUid = (parent != null) ? parent.id : userId;
final ComponentName launcherComponent = getDefaultHomeActivity(launcherUid);
diff --git a/services/core/java/com/android/server/pm/ProtectedPackages.java b/services/core/java/com/android/server/pm/ProtectedPackages.java
index a374e14..231168e 100644
--- a/services/core/java/com/android/server/pm/ProtectedPackages.java
+++ b/services/core/java/com/android/server/pm/ProtectedPackages.java
@@ -92,6 +92,9 @@
if (mDeviceOwnerUserId == userId) {
return mDeviceOwnerPackage;
}
+ if (mProfileOwnerPackages == null) {
+ return null;
+ }
return mProfileOwnerPackages.get(userId);
}
diff --git a/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java b/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
index 4550446..ecf6686 100644
--- a/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
+++ b/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
@@ -190,6 +190,7 @@
static {
STORAGE_PERMISSIONS.add(Manifest.permission.READ_EXTERNAL_STORAGE);
STORAGE_PERMISSIONS.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
+ STORAGE_PERMISSIONS.add(Manifest.permission.ACCESS_MEDIA_LOCATION);
}
private static final int MSG_READ_DEFAULT_PERMISSION_EXCEPTIONS = 1;
diff --git a/services/core/java/com/android/server/pm/permission/PermissionManagerService.java b/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
index 899f802..4c33bec 100644
--- a/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
+++ b/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
@@ -967,10 +967,12 @@
// or has updated its target SDK and AR is no longer implicit to it.
// This is a compatibility workaround for apps when AR permission was
// split in Q.
- int numSplitPerms = PermissionManager.SPLIT_PERMISSIONS.size();
+ final List<PermissionManager.SplitPermissionInfo> permissionList =
+ getSplitPermissions();
+ int numSplitPerms = permissionList.size();
for (int splitPermNum = 0; splitPermNum < numSplitPerms; splitPermNum++) {
PermissionManager.SplitPermissionInfo sp =
- PermissionManager.SPLIT_PERMISSIONS.get(splitPermNum);
+ permissionList.get(splitPermNum);
String splitPermName = sp.getSplitPermission();
if (sp.getNewPermissions().contains(permName)
&& origPermissions.hasInstallPermission(splitPermName)) {
@@ -1537,10 +1539,10 @@
String pkgName = pkg.packageName;
ArrayMap<String, ArraySet<String>> newToSplitPerms = new ArrayMap<>();
- int numSplitPerms = PermissionManager.SPLIT_PERMISSIONS.size();
+ final List<PermissionManager.SplitPermissionInfo> permissionList = getSplitPermissions();
+ int numSplitPerms = permissionList.size();
for (int splitPermNum = 0; splitPermNum < numSplitPerms; splitPermNum++) {
- PermissionManager.SplitPermissionInfo spi =
- PermissionManager.SPLIT_PERMISSIONS.get(splitPermNum);
+ PermissionManager.SplitPermissionInfo spi = permissionList.get(splitPermNum);
List<String> newPerms = spi.getNewPermissions();
int numNewPerms = newPerms.size();
@@ -1595,8 +1597,6 @@
Slog.i(TAG, newPerm + " does not inherit from " + sourcePerms
+ " for " + pkgName + " as split permission is also new");
}
-
- break;
} else {
// Inherit from new install or existing runtime permissions
inheritPermissionStateToNewImplicitPermissionLocked(sourcePerms,
@@ -1610,6 +1610,10 @@
return updatedUserIds;
}
+ private List<PermissionManager.SplitPermissionInfo> getSplitPermissions() {
+ return SystemConfig.getInstance().getSplitPermissions();
+ }
+
private boolean isNewPlatformPermissionForPackage(String perm, PackageParser.Package pkg) {
boolean allowed = false;
final int NP = PackageParser.NEW_PERMISSIONS.length;
@@ -2022,16 +2026,6 @@
return whitelistedPermissions;
}
- private void setWhitelistedRestrictedPermissions(@NonNull PackageParser.Package pkg,
- @NonNull int[] userIds, @Nullable List<String> permissions, int callingUid,
- @PackageManager.PermissionWhitelistFlags int whitelistFlags,
- @NonNull PermissionCallback callback) {
- for (int userId : userIds) {
- setWhitelistedRestrictedPermissionsForUser(pkg, userId, permissions,
- callingUid, whitelistFlags, callback);
- }
- }
-
private void grantRequestedRuntimePermissionsForUser(PackageParser.Package pkg, int userId,
String[] grantedPermissions, int callingUid, PermissionCallback callback) {
PackageSetting ps = (PackageSetting) pkg.mExtras;
@@ -2312,109 +2306,122 @@
}
}
- private void setWhitelistedRestrictedPermissionsForUser(@NonNull PackageParser.Package pkg,
- @UserIdInt int userId, @Nullable List<String> permissions, int callingUid,
- @PermissionWhitelistFlags int whitelistFlags, PermissionCallback callback) {
+ private void setWhitelistedRestrictedPermissions(@NonNull PackageParser.Package pkg,
+ @NonNull int[] userIds, @Nullable List<String> permissions, int callingUid,
+ @PackageManager.PermissionWhitelistFlags int whitelistFlags,
+ @NonNull PermissionCallback callback) {
+
final PackageSetting ps = (PackageSetting) pkg.mExtras;
if (ps == null) {
return;
}
final PermissionsState permissionsState = ps.getPermissionsState();
-
- ArraySet<String> oldGrantedRestrictedPermissions = null;
+ SparseArray<ArraySet<String>> oldGrantedRestrictedPermissionsByUser = new SparseArray<>();
boolean updatePermissions = false;
final int permissionCount = pkg.requestedPermissions.size();
- for (int i = 0; i < permissionCount; i++) {
- final String permissionName = pkg.requestedPermissions.get(i);
+ for (int userId : userIds) {
+ for (int i = 0; i < permissionCount; i++) {
+ final String permissionName = pkg.requestedPermissions.get(i);
- final BasePermission bp = mSettings.getPermissionLocked(permissionName);
- if (bp == null) {
- Slog.w(TAG, "Cannot whitelist unknown permission: " + permissionName);
- continue;
- }
-
- if (!bp.isHardOrSoftRestricted()) {
- continue;
- }
-
- if (permissionsState.hasPermission(permissionName, userId)) {
- if (oldGrantedRestrictedPermissions == null) {
- oldGrantedRestrictedPermissions = new ArraySet<>();
+ final BasePermission bp = mSettings.getPermissionLocked(permissionName);
+ if (bp == null) {
+ Slog.w(TAG, "Cannot whitelist unknown permission: " + permissionName);
+ continue;
}
- oldGrantedRestrictedPermissions.add(permissionName);
- }
- final int oldFlags = permissionsState.getPermissionFlags(permissionName, userId);
-
- int newFlags = oldFlags;
- int mask = 0;
- int whitelistFlagsCopy = whitelistFlags;
- while (whitelistFlagsCopy != 0) {
- final int flag = 1 << Integer.numberOfTrailingZeros(whitelistFlagsCopy);
- whitelistFlagsCopy &= ~flag;
- switch (flag) {
- case FLAG_PERMISSION_WHITELIST_SYSTEM: {
- mask |= PackageManager.FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT;
- if (permissions != null && permissions.contains(permissionName)) {
- newFlags |= PackageManager.FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT;
- } else {
- newFlags &= ~PackageManager.FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT;
- }
- } break;
- case FLAG_PERMISSION_WHITELIST_UPGRADE: {
- mask |= PackageManager.FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT;
- if (permissions != null && permissions.contains(permissionName)) {
- newFlags |= PackageManager.FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT;
- } else {
- newFlags &= ~PackageManager.FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT;
- }
- } break;
- case FLAG_PERMISSION_WHITELIST_INSTALLER: {
- mask |= PackageManager.FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT;
- if (permissions != null && permissions.contains(permissionName)) {
- newFlags |= PackageManager.FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT;
- } else {
- newFlags &= ~PackageManager.FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT;
- }
- } break;
+ if (!bp.isHardOrSoftRestricted()) {
+ continue;
}
- }
- if (oldFlags == newFlags) {
- continue;
- }
-
- updatePermissions = true;
-
- final boolean wasWhitelisted = (oldFlags
- & (PackageManager.FLAGS_PERMISSION_RESTRICTION_ANY_EXEMPT)) != 0;
- final boolean isWhitelisted = (newFlags
- & (PackageManager.FLAGS_PERMISSION_RESTRICTION_ANY_EXEMPT)) != 0;
-
- // If the permission is policy fixed as granted but it is no longer
- // on any of the whitelists we need to clear the policy fixed flag
- // as whitelisting trumps policy i.e. policy cannot grant a non
- // grantable permission.
- if ((oldFlags & PackageManager.FLAG_PERMISSION_POLICY_FIXED) != 0) {
- final boolean isGranted = permissionsState.hasPermission(permissionName, userId);
- if (!isWhitelisted && isGranted) {
- mask |= PackageManager.FLAG_PERMISSION_POLICY_FIXED;
- newFlags &= ~PackageManager.FLAG_PERMISSION_POLICY_FIXED;
+ if (permissionsState.hasPermission(permissionName, userId)) {
+ if (oldGrantedRestrictedPermissionsByUser.get(userId) == null) {
+ oldGrantedRestrictedPermissionsByUser.put(userId, new ArraySet<>());
+ }
+ oldGrantedRestrictedPermissionsByUser.get(userId).add(permissionName);
}
- }
- // If we are whitelisting an app that does not support runtime permissions
- // we need to make sure it goes through the permission review UI at launch.
- if (pkg.applicationInfo.targetSdkVersion < Build.VERSION_CODES.M
- && !wasWhitelisted && isWhitelisted) {
- mask |= PackageManager.FLAG_PERMISSION_REVIEW_REQUIRED;
- newFlags |= PackageManager.FLAG_PERMISSION_REVIEW_REQUIRED;
- }
+ final int oldFlags = permissionsState.getPermissionFlags(permissionName, userId);
- updatePermissionFlags(permissionName, pkg.packageName, mask, newFlags,
- callingUid, userId, false, null /*callback*/);
+ int newFlags = oldFlags;
+ int mask = 0;
+ int whitelistFlagsCopy = whitelistFlags;
+ while (whitelistFlagsCopy != 0) {
+ final int flag = 1 << Integer.numberOfTrailingZeros(whitelistFlagsCopy);
+ whitelistFlagsCopy &= ~flag;
+ switch (flag) {
+ case FLAG_PERMISSION_WHITELIST_SYSTEM: {
+ mask |= PackageManager.FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT;
+ if (permissions != null && permissions.contains(permissionName)) {
+ newFlags |=
+ PackageManager.FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT;
+ } else {
+ newFlags &=
+ ~PackageManager.FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT;
+ }
+ }
+ break;
+ case FLAG_PERMISSION_WHITELIST_UPGRADE: {
+ mask |= PackageManager.FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT;
+ if (permissions != null && permissions.contains(permissionName)) {
+ newFlags |=
+ PackageManager.FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT;
+ } else {
+ newFlags &=
+ ~PackageManager.FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT;
+ }
+ }
+ break;
+ case FLAG_PERMISSION_WHITELIST_INSTALLER: {
+ mask |= PackageManager.FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT;
+ if (permissions != null && permissions.contains(permissionName)) {
+ newFlags |=
+ PackageManager.FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT;
+ } else {
+ newFlags &= ~PackageManager
+ .FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT;
+ }
+ }
+ break;
+ }
+ }
+
+ if (oldFlags == newFlags) {
+ continue;
+ }
+
+ updatePermissions = true;
+
+ final boolean wasWhitelisted = (oldFlags
+ & (PackageManager.FLAGS_PERMISSION_RESTRICTION_ANY_EXEMPT)) != 0;
+ final boolean isWhitelisted = (newFlags
+ & (PackageManager.FLAGS_PERMISSION_RESTRICTION_ANY_EXEMPT)) != 0;
+
+ // If the permission is policy fixed as granted but it is no longer
+ // on any of the whitelists we need to clear the policy fixed flag
+ // as whitelisting trumps policy i.e. policy cannot grant a non
+ // grantable permission.
+ if ((oldFlags & PackageManager.FLAG_PERMISSION_POLICY_FIXED) != 0) {
+ final boolean isGranted = permissionsState.hasPermission(permissionName,
+ userId);
+ if (!isWhitelisted && isGranted) {
+ mask |= PackageManager.FLAG_PERMISSION_POLICY_FIXED;
+ newFlags &= ~PackageManager.FLAG_PERMISSION_POLICY_FIXED;
+ }
+ }
+
+ // If we are whitelisting an app that does not support runtime permissions
+ // we need to make sure it goes through the permission review UI at launch.
+ if (pkg.applicationInfo.targetSdkVersion < Build.VERSION_CODES.M
+ && !wasWhitelisted && isWhitelisted) {
+ mask |= PackageManager.FLAG_PERMISSION_REVIEW_REQUIRED;
+ newFlags |= PackageManager.FLAG_PERMISSION_REVIEW_REQUIRED;
+ }
+
+ updatePermissionFlags(permissionName, pkg.packageName, mask, newFlags,
+ callingUid, userId, false, null /*callback*/);
+ }
}
if (updatePermissions) {
@@ -2422,7 +2429,12 @@
restorePermissionState(pkg, false, pkg.packageName, callback);
// If this resulted in losing a permission we need to kill the app.
- if (oldGrantedRestrictedPermissions != null) {
+ int oldGrantedRestrictedPermissionsByUserCount =
+ oldGrantedRestrictedPermissionsByUser.size();
+ for (int j = 0; j < oldGrantedRestrictedPermissionsByUserCount; j++) {
+ final int userId = oldGrantedRestrictedPermissionsByUser.keyAt(j);
+ final ArraySet<String> oldGrantedRestrictedPermissions =
+ oldGrantedRestrictedPermissionsByUser.valueAt(j);
final int oldGrantedCount = oldGrantedRestrictedPermissions.size();
for (int i = 0; i < oldGrantedCount; i++) {
final String permission = oldGrantedRestrictedPermissions.valueAt(i);
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 21b13fe..48056b4 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -107,6 +107,7 @@
import android.app.ActivityTaskManager;
import android.app.AppOpsManager;
import android.app.IUiModeManager;
+import android.app.NotificationManager;
import android.app.ProgressDialog;
import android.app.SearchManager;
import android.app.UiModeManager;
@@ -2572,6 +2573,10 @@
return (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
}
+ NotificationManager getNotificationService() {
+ return mContext.getSystemService(NotificationManager.class);
+ }
+
static IAudioService getAudioService() {
IAudioService audioService = IAudioService.Stub.asInterface(
ServiceManager.checkService(Context.AUDIO_SERVICE));
@@ -3806,6 +3811,11 @@
if (down) {
sendSystemKeyToStatusBarAsync(event.getKeyCode());
+ NotificationManager nm = getNotificationService();
+ if (nm != null && !mHandleVolumeKeysInWM) {
+ nm.silenceNotificationSound();
+ }
+
TelecomManager telecomManager = getTelecommService();
if (telecomManager != null && !mHandleVolumeKeysInWM) {
// When {@link #mHandleVolumeKeysInWM} is set, volume key events
diff --git a/services/core/java/com/android/server/policy/role/LegacyRoleResolutionPolicy.java b/services/core/java/com/android/server/policy/role/LegacyRoleResolutionPolicy.java
index 77bf930..712012d 100644
--- a/services/core/java/com/android/server/policy/role/LegacyRoleResolutionPolicy.java
+++ b/services/core/java/com/android/server/policy/role/LegacyRoleResolutionPolicy.java
@@ -24,20 +24,17 @@
import android.content.pm.PackageManager;
import android.content.pm.PackageManagerInternal;
import android.content.pm.ResolveInfo;
-import android.os.Debug;
import android.provider.Settings;
-import android.telecom.TelecomManager;
import android.text.TextUtils;
-import android.util.Log;
import android.util.Slog;
+import com.android.internal.R;
import com.android.internal.telephony.SmsApplication;
import com.android.internal.util.CollectionUtils;
import com.android.server.LocalServices;
import com.android.server.role.RoleManagerService;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -67,14 +64,25 @@
public List<String> getRoleHolders(@NonNull String roleName, @UserIdInt int userId) {
switch (roleName) {
case RoleManager.ROLE_ASSISTANT: {
- String legacyAssistant = Settings.Secure.getStringForUser(
- mContext.getContentResolver(), Settings.Secure.ASSISTANT, userId);
- if (legacyAssistant == null || legacyAssistant.isEmpty()) {
- return Collections.emptyList();
+ String packageName;
+ String setting = Settings.Secure.getStringForUser(mContext.getContentResolver(),
+ Settings.Secure.ASSISTANT, userId);
+ // AssistUtils was using the default assistant app if Settings.Secure.ASSISTANT is
+ // null, while only an empty string means user selected "None".
+ if (setting != null) {
+ if (!setting.isEmpty()) {
+ ComponentName componentName = ComponentName.unflattenFromString(setting);
+ packageName = componentName != null ? componentName.getPackageName() : null;
+ } else {
+ packageName = null;
+ }
+ } else if (mContext.getPackageManager().isDeviceUpgrading()) {
+ String defaultAssistant = mContext.getString(R.string.config_defaultAssistant);
+ packageName = !TextUtils.isEmpty(defaultAssistant) ? defaultAssistant : null;
} else {
- return Collections.singletonList(
- ComponentName.unflattenFromString(legacyAssistant).getPackageName());
+ packageName = null;
}
+ return CollectionUtils.singletonOrEmpty(packageName);
}
case RoleManager.ROLE_BROWSER: {
PackageManagerInternal packageManagerInternal = LocalServices.getService(
@@ -84,44 +92,36 @@
return CollectionUtils.singletonOrEmpty(packageName);
}
case RoleManager.ROLE_DIALER: {
- String setting = Settings.Secure.getStringForUser(
- mContext.getContentResolver(),
+ String setting = Settings.Secure.getStringForUser(mContext.getContentResolver(),
Settings.Secure.DIALER_DEFAULT_APPLICATION, userId);
- return CollectionUtils.singletonOrEmpty(!TextUtils.isEmpty(setting)
- ? setting
- : mContext.getSystemService(TelecomManager.class).getSystemDialerPackage());
+ String packageName;
+ if (!TextUtils.isEmpty(setting)) {
+ packageName = setting;
+ } else if (mContext.getPackageManager().isDeviceUpgrading()) {
+ // DefaultDialerManager was using the default dialer app if
+ // Settings.Secure.DIALER_DEFAULT_APPLICATION is invalid.
+ // TelecomManager.getSystemDialerPackage() won't work because it might not
+ // be ready.
+ packageName = mContext.getString(R.string.config_defaultDialer);
+ } else {
+ packageName = null;
+ }
+ return CollectionUtils.singletonOrEmpty(packageName);
}
case RoleManager.ROLE_SMS: {
- // Moved over from SmsApplication#getApplication
- String result = Settings.Secure.getStringForUser(
- mContext.getContentResolver(),
+ String setting = Settings.Secure.getStringForUser(mContext.getContentResolver(),
Settings.Secure.SMS_DEFAULT_APPLICATION, userId);
- // TODO: STOPSHIP: Remove the following code once we read the value of
- // config_defaultSms in RoleControllerService.
- if (result == null) {
- Collection<SmsApplication.SmsApplicationData> applications =
- SmsApplication.getApplicationCollectionAsUser(mContext, userId);
- SmsApplication.SmsApplicationData applicationData;
- String defaultPackage = mContext.getResources()
- .getString(com.android.internal.R.string.default_sms_application);
- applicationData =
- SmsApplication.getApplicationForPackage(applications, defaultPackage);
-
- if (applicationData == null) {
- // Are there any applications?
- if (applications.size() != 0) {
- applicationData =
- (SmsApplication.SmsApplicationData) applications.toArray()[0];
- }
- }
- if (DEBUG) {
- Log.i(LOG_TAG, "Found default sms app: " + applicationData
- + " among: " + applications + " from " + Debug.getCallers(4));
- }
- SmsApplication.SmsApplicationData app = applicationData;
- result = app == null ? null : app.mPackageName;
+ String packageName;
+ if (!TextUtils.isEmpty(setting)) {
+ packageName = setting;
+ } else if (mContext.getPackageManager().isDeviceUpgrading()) {
+ // SmsApplication was using the default SMS app if
+ // Settings.Secure.DIALER_DEFAULT_APPLICATION is invalid.
+ packageName = mContext.getString(R.string.config_defaultSms);
+ } else {
+ packageName = null;
}
- return CollectionUtils.singletonOrEmpty(result);
+ return CollectionUtils.singletonOrEmpty(packageName);
}
case RoleManager.ROLE_HOME: {
PackageManager packageManager = mContext.getPackageManager();
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
index aa49ba6..e1b3e4d 100644
--- a/services/core/java/com/android/server/power/PowerManagerService.java
+++ b/services/core/java/com/android/server/power/PowerManagerService.java
@@ -542,6 +542,10 @@
// True if we in the process of performing a forceSuspend
private boolean mForceSuspendActive;
+ // Transition to Doze is in progress. We have transitioned to WAKEFULNESS_DOZING,
+ // but the DreamService has not yet been told to start (it's an async process).
+ private boolean mDozeStartInProgress;
+
private final class ForegroundProfileObserver extends SynchronousUserSwitchObserver {
@Override
public void onUserSwitching(int newUserId) throws RemoteException {}
@@ -1514,6 +1518,7 @@
mLastSleepTime = eventTime;
mLastSleepReason = reason;
mSandmanSummoned = true;
+ mDozeStartInProgress = true;
setWakefulnessLocked(WAKEFULNESS_DOZING, reason, eventTime);
// Report the number of wake locks that will be cleared by going to sleep.
@@ -1601,6 +1606,10 @@
mWakefulness = wakefulness;
mWakefulnessChanging = true;
mDirty |= DIRTY_WAKEFULNESS;
+
+ // This is only valid while we are in wakefulness dozing. Set to false otherwise.
+ mDozeStartInProgress &= (mWakefulness == WAKEFULNESS_DOZING);
+
if (mNotifier != null) {
mNotifier.onWakefulnessChangeStarted(wakefulness, reason, eventTime);
}
@@ -1631,6 +1640,9 @@
if (mWakefulness == WAKEFULNESS_DOZING
&& (mWakeLockSummary & WAKE_LOCK_DOZE) == 0) {
return; // wait until dream has enabled dozing
+ } else {
+ // Doze wakelock acquired (doze started) or device is no longer dozing.
+ mDozeStartInProgress = false;
}
if (mWakefulness == WAKEFULNESS_DOZING || mWakefulness == WAKEFULNESS_ASLEEP) {
logSleepTimeoutRecapturedLocked();
@@ -2309,6 +2321,10 @@
isDreaming = false;
}
+ // At this point, we either attempted to start the dream or no attempt will be made,
+ // so stop holding the display suspend blocker for Doze.
+ mDozeStartInProgress = false;
+
// Update dream state.
synchronized (mLock) {
// Remember the initial battery level when the dream started.
@@ -2735,6 +2751,16 @@
if (mScreenBrightnessBoostInProgress) {
return true;
}
+
+ // When we transition to DOZING, we have to keep the display suspend blocker
+ // up until the Doze service has a change to acquire the DOZE wakelock.
+ // Here we wait for mWakefulnessChanging to become false since the wakefulness
+ // transition to DOZING isn't considered "changed" until the doze wake lock is
+ // acquired.
+ if (mWakefulness == WAKEFULNESS_DOZING && mDozeStartInProgress) {
+ return true;
+ }
+
// Let the system suspend if the screen is off or dozing.
return false;
}
diff --git a/services/core/java/com/android/server/power/ThermalManagerService.java b/services/core/java/com/android/server/power/ThermalManagerService.java
index 1552fd5..491c5ab 100644
--- a/services/core/java/com/android/server/power/ThermalManagerService.java
+++ b/services/core/java/com/android/server/power/ThermalManagerService.java
@@ -38,11 +38,13 @@
import android.os.ShellCommand;
import android.os.Temperature;
import android.util.ArrayMap;
+import android.util.EventLog;
import android.util.Slog;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.DumpUtils;
+import com.android.server.EventLogTags;
import com.android.server.FgThread;
import com.android.server.SystemService;
@@ -250,6 +252,8 @@
} finally {
mThermalEventListeners.finishBroadcast();
}
+ EventLog.writeEvent(EventLogTags.THERMAL_CHANGED, temperature.getName(),
+ temperature.getType(), temperature.getValue(), temperature.getStatus(), mStatus);
}
private void shutdownIfNeeded(Temperature temperature) {
@@ -860,10 +864,10 @@
mThermalHal11.linkToDeath(new DeathRecipient(),
THERMAL_HAL_DEATH_COOKIE);
mThermalHal11.registerThermalCallback(mThermalCallback11);
+ Slog.i(TAG, "Thermal HAL 1.1 service connected, limited thermal functions "
+ + "due to legacy API.");
} catch (NoSuchElementException | RemoteException e) {
- Slog.e(TAG,
- "Thermal HAL 1.1 service not connected, no thermal call back will be "
- + "called.");
+ Slog.e(TAG, "Thermal HAL 1.1 service not connected.");
mThermalHal11 = null;
}
return (mThermalHal11 != null);
@@ -978,8 +982,9 @@
mThermalHal20.linkToDeath(new DeathRecipient(), THERMAL_HAL_DEATH_COOKIE);
mThermalHal20.registerThermalChangedCallback(mThermalCallback20, false,
0 /* not used */);
+ Slog.i(TAG, "Thermal HAL 2.0 service connected.");
} catch (NoSuchElementException | RemoteException e) {
- Slog.e(TAG, "Thermal HAL 2.0 service not connected, trying 1.1.");
+ Slog.e(TAG, "Thermal HAL 2.0 service not connected.");
mThermalHal20 = null;
}
return (mThermalHal20 != null);
diff --git a/services/core/java/com/android/server/webkit/WebViewUpdater.java b/services/core/java/com/android/server/webkit/WebViewUpdater.java
index a460040..3b58af2 100644
--- a/services/core/java/com/android/server/webkit/WebViewUpdater.java
+++ b/services/core/java/com/android/server/webkit/WebViewUpdater.java
@@ -87,19 +87,6 @@
newPackage = findPreferredWebViewPackage();
if (mCurrentWebViewPackage != null) {
oldProviderName = mCurrentWebViewPackage.packageName;
- if (changedState == WebViewUpdateService.PACKAGE_CHANGED
- && newPackage.packageName.equals(oldProviderName)) {
- // If we don't change package name we should only rerun the
- // preparation phase if the current package has been replaced
- // (not if it has been enabled/disabled).
- return;
- }
- if (newPackage.packageName.equals(oldProviderName)
- && (newPackage.lastUpdateTime
- == mCurrentWebViewPackage.lastUpdateTime)) {
- // If the chosen package hasn't been updated, then early-out
- return;
- }
}
// Only trigger update actions if the updated package is the one
// that will be used, or the one that was in use before the
diff --git a/services/core/java/com/android/server/wm/AccessibilityController.java b/services/core/java/com/android/server/wm/AccessibilityController.java
index 4cfc1d1..afd6674 100644
--- a/services/core/java/com/android/server/wm/AccessibilityController.java
+++ b/services/core/java/com/android/server/wm/AccessibilityController.java
@@ -907,7 +907,7 @@
}
public void releaseSurface() {
- mSurfaceControl.remove();
+ mService.mTransactionFactory.make().remove(mSurfaceControl).apply();
mSurface.release();
}
diff --git a/services/core/java/com/android/server/wm/ActivityStack.java b/services/core/java/com/android/server/wm/ActivityStack.java
index c5c53d8..56be335 100644
--- a/services/core/java/com/android/server/wm/ActivityStack.java
+++ b/services/core/java/com/android/server/wm/ActivityStack.java
@@ -5227,18 +5227,28 @@
* then skip running tasks that match those types.
*/
void getRunningTasks(List<TaskRecord> tasksOut, @ActivityType int ignoreActivityType,
- @WindowingMode int ignoreWindowingMode, int callingUid, boolean allowed) {
+ @WindowingMode int ignoreWindowingMode, int callingUid, boolean allowed,
+ boolean crossUser, ArraySet<Integer> profileIds) {
boolean focusedStack = mRootActivityContainer.getTopDisplayFocusedStack() == this;
boolean topTask = true;
+ int userId = UserHandle.getUserId(callingUid);
for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
final TaskRecord task = mTaskHistory.get(taskNdx);
if (task.getTopActivity() == null) {
// Skip if there are no activities in the task
continue;
}
- if (!allowed && !task.isActivityTypeHome() && task.effectiveUid != callingUid) {
- // Skip if the caller can't fetch this task
- continue;
+ if (task.effectiveUid != callingUid) {
+ if (task.userId != userId && !crossUser && !profileIds.contains(task.userId)) {
+ // Skip if the caller does not have cross user permission or cannot access
+ // the task's profile
+ continue;
+ }
+ if (!allowed && !task.isActivityTypeHome()) {
+ // Skip if the caller isn't allowed to fetch this task, except for the home
+ // task which we always return.
+ continue;
+ }
}
if (ignoreActivityType != ACTIVITY_TYPE_UNDEFINED
&& task.getActivityType() == ignoreActivityType) {
@@ -5454,6 +5464,7 @@
task.cleanUpResourcesForDestroy();
}
+ final ActivityDisplay display = getDisplay();
if (mTaskHistory.isEmpty()) {
if (DEBUG_STACK) Slog.i(TAG_STACK, "removeTask: removing stack=" + this);
// We only need to adjust focused stack if this stack is in focus and we are not in the
@@ -5462,11 +5473,11 @@
&& mRootActivityContainer.isTopDisplayFocusedStack(this)) {
String myReason = reason + " leftTaskHistoryEmpty";
if (!inMultiWindowMode() || adjustFocusToNextFocusableStack(myReason) == null) {
- getDisplay().moveHomeStackToFront(myReason);
+ display.moveHomeStackToFront(myReason);
}
}
if (isAttached()) {
- getDisplay().positionChildAtBottom(this);
+ display.positionChildAtBottom(this);
}
if (!isActivityTypeHome() || !isAttached()) {
remove();
@@ -5479,6 +5490,9 @@
if (inPinnedWindowingMode()) {
mService.getTaskChangeNotificationController().notifyActivityUnpinned();
}
+ if (display.isSingleTaskInstance()) {
+ mService.notifySingleTaskDisplayEmpty(display.mDisplayId);
+ }
}
TaskRecord createTaskRecord(int taskId, ActivityInfo info, Intent intent,
diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java
index 5a1eed8..5b697ee 100644
--- a/services/core/java/com/android/server/wm/ActivityStarter.java
+++ b/services/core/java/com/android/server/wm/ActivityStarter.java
@@ -2700,7 +2700,8 @@
|| mPreferredDisplayId != DEFAULT_DISPLAY) {
final boolean onTop = aOptions == null || !aOptions.getAvoidMoveToFront();
final ActivityStack stack =
- mRootActivityContainer.getLaunchStack(r, aOptions, task, onTop, mLaunchParams);
+ mRootActivityContainer.getLaunchStack(r, aOptions, task, onTop, mLaunchParams,
+ mRequest.realCallingPid, mRequest.realCallingUid);
return stack;
}
// Otherwise handle adjacent launch.
@@ -2818,11 +2819,24 @@
return this;
}
+ /**
+ * Sets the pid of the caller who originally started the activity.
+ *
+ * Normally, the pid/uid would be the calling pid from the binder call.
+ * However, in case of a {@link PendingIntent}, the pid/uid pair of the caller is considered
+ * the original entity that created the pending intent, in contrast to setRealCallingPid/Uid,
+ * which represents the entity who invoked pending intent via {@link PendingIntent#send}.
+ */
ActivityStarter setCallingPid(int pid) {
mRequest.callingPid = pid;
return this;
}
+ /**
+ * Sets the uid of the caller who originally started the activity.
+ *
+ * @see #setCallingPid
+ */
ActivityStarter setCallingUid(int uid) {
mRequest.callingUid = uid;
return this;
@@ -2833,11 +2847,25 @@
return this;
}
+ /**
+ * Sets the pid of the caller who requested to launch the activity.
+ *
+ * The pid/uid represents the caller who launches the activity in this request.
+ * It will almost same as setCallingPid/Uid except when processing {@link PendingIntent}:
+ * the pid/uid will be the caller who called {@link PendingIntent#send()}.
+ *
+ * @see #setCallingPid
+ */
ActivityStarter setRealCallingPid(int pid) {
mRequest.realCallingPid = pid;
return this;
}
+ /**
+ * Sets the uid of the caller who requested to launch the activity.
+ *
+ * @see #setRealCallingPid
+ */
ActivityStarter setRealCallingUid(int uid) {
mRequest.realCallingUid = uid;
return this;
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
index 747837b..2232053 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@@ -19,6 +19,8 @@
import static android.Manifest.permission.BIND_VOICE_INTERACTION;
import static android.Manifest.permission.CHANGE_CONFIGURATION;
import static android.Manifest.permission.CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS;
+import static android.Manifest.permission.INTERACT_ACROSS_USERS;
+import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
import static android.Manifest.permission.INTERNAL_SYSTEM_WINDOW;
import static android.Manifest.permission.MANAGE_ACTIVITY_STACKS;
import static android.Manifest.permission.READ_FRAME_BUFFER;
@@ -213,6 +215,7 @@
import android.text.TextUtils;
import android.text.format.Time;
import android.util.ArrayMap;
+import android.util.ArraySet;
import android.util.EventLog;
import android.util.Log;
import android.util.Slog;
@@ -2522,15 +2525,22 @@
@WindowConfiguration.ActivityType int ignoreActivityType,
@WindowConfiguration.WindowingMode int ignoreWindowingMode) {
final int callingUid = Binder.getCallingUid();
+ final int callingPid = Binder.getCallingPid();
+ final boolean crossUser = isCrossUserAllowed(callingPid, callingUid);
+ final int[] profileIds = getUserManager().getProfileIds(
+ UserHandle.getUserId(callingUid), true);
+ ArraySet<Integer> callingProfileIds = new ArraySet<>();
+ for (int i = 0; i < profileIds.length; i++) {
+ callingProfileIds.add(profileIds[i]);
+ }
ArrayList<ActivityManager.RunningTaskInfo> list = new ArrayList<>();
synchronized (mGlobalLock) {
if (DEBUG_ALL) Slog.v(TAG, "getTasks: max=" + maxNum);
- final boolean allowed = isGetTasksAllowed("getTasks", Binder.getCallingPid(),
- callingUid);
+ final boolean allowed = isGetTasksAllowed("getTasks", callingPid, callingUid);
mRootActivityContainer.getRunningTasks(maxNum, list, ignoreActivityType,
- ignoreWindowingMode, callingUid, allowed);
+ ignoreWindowingMode, callingUid, allowed, crossUser, callingProfileIds);
}
return list;
@@ -3587,6 +3597,11 @@
return allowed;
}
+ boolean isCrossUserAllowed(int pid, int uid) {
+ return checkPermission(INTERACT_ACROSS_USERS, pid, uid) == PERMISSION_GRANTED
+ || checkPermission(INTERACT_ACROSS_USERS_FULL, pid, uid) == PERMISSION_GRANTED;
+ }
+
private PendingAssistExtras enqueueAssistContext(int requestType, Intent intent, String hint,
IAssistDataReceiver receiver, Bundle receiverExtras, IBinder activityToken,
boolean focused, boolean newSessionId, int userHandle, Bundle args, long timeout,
@@ -6048,6 +6063,10 @@
return allUids.contains(uid);
}
+ void notifySingleTaskDisplayEmpty(int displayId) {
+ mTaskChangeNotificationController.notifySingleTaskDisplayEmpty(displayId);
+ }
+
final class H extends Handler {
static final int REPORT_TIME_TRACKER_MSG = 1;
diff --git a/services/core/java/com/android/server/wm/BlackFrame.java b/services/core/java/com/android/server/wm/BlackFrame.java
index 84ba5ca9..7fc17e1 100644
--- a/services/core/java/com/android/server/wm/BlackFrame.java
+++ b/services/core/java/com/android/server/wm/BlackFrame.java
@@ -97,6 +97,7 @@
final BlackSurface[] mBlackSurfaces = new BlackSurface[4];
final boolean mForceDefaultOrientation;
+ private final TransactionFactory mTransactionFactory;
public void printTo(String prefix, PrintWriter pw) {
pw.print(prefix); pw.print("Outer: "); mOuterRect.printShortString(pw);
@@ -111,11 +112,12 @@
}
}
- public BlackFrame(SurfaceControl.Transaction t,
- Rect outer, Rect inner, int layer, DisplayContent dc,
- boolean forceDefaultOrientation) throws OutOfResourcesException {
+ public BlackFrame(TransactionFactory factory, SurfaceControl.Transaction t, Rect outer,
+ Rect inner, int layer, DisplayContent dc, boolean forceDefaultOrientation)
+ throws OutOfResourcesException {
boolean success = false;
+ mTransactionFactory = factory;
mForceDefaultOrientation = forceDefaultOrientation;
// TODO: Why do we use 4 surfaces instead of just one big one behind the screenshot?
@@ -149,14 +151,16 @@
public void kill() {
if (mBlackSurfaces != null) {
+ SurfaceControl.Transaction t = mTransactionFactory.make();
for (int i=0; i<mBlackSurfaces.length; i++) {
if (mBlackSurfaces[i] != null) {
if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) Slog.i(TAG_WM,
" BLACK " + mBlackSurfaces[i].surface + ": DESTROY");
- mBlackSurfaces[i].surface.remove();
+ t.remove(mBlackSurfaces[i].surface);
mBlackSurfaces[i] = null;
}
}
+ t.apply();
}
}
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index e099a4f..3e7fea2 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -1072,9 +1072,10 @@
// removing from parent.
token.getParent().removeChild(token);
}
- if (prevDc.mLastFocus == mCurrentFocus) {
- // The window has become the focus of this display, so it should not be notified
- // that it lost focus from the previous display.
+ if (token.hasChild(prevDc.mLastFocus)) {
+ // If the reparent window token contains previous display's last focus window, means
+ // it will end up to gain window focus on the target display, so it should not be
+ // notified that it lost focus from the previous display.
prevDc.mLastFocus = null;
}
}
@@ -4589,13 +4590,15 @@
.show(mSplitScreenDividerAnchor);
scheduleAnimation();
} else {
- mAppAnimationLayer.remove();
+ mWmService.mTransactionFactory.make()
+ .remove(mAppAnimationLayer)
+ .remove(mBoostedAppAnimationLayer)
+ .remove(mHomeAppAnimationLayer)
+ .remove(mSplitScreenDividerAnchor)
+ .apply();
mAppAnimationLayer = null;
- mBoostedAppAnimationLayer.remove();
mBoostedAppAnimationLayer = null;
- mHomeAppAnimationLayer.remove();
mHomeAppAnimationLayer = null;
- mSplitScreenDividerAnchor.remove();
mSplitScreenDividerAnchor = null;
}
}
diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java
index ed7dbd0..99a9db3 100644
--- a/services/core/java/com/android/server/wm/DisplayPolicy.java
+++ b/services/core/java/com/android/server/wm/DisplayPolicy.java
@@ -3622,7 +3622,8 @@
if (mScreenshotHelper != null) {
mScreenshotHelper.takeScreenshot(screenshotType,
mStatusBar != null && mStatusBar.isVisibleLw(),
- mNavigationBar != null && mNavigationBar.isVisibleLw(), mHandler);
+ mNavigationBar != null && mNavigationBar.isVisibleLw(),
+ mHandler, null /* completionConsumer */);
}
}
diff --git a/services/core/java/com/android/server/wm/DisplayWindowSettings.java b/services/core/java/com/android/server/wm/DisplayWindowSettings.java
index a46fa13..207e8ef 100644
--- a/services/core/java/com/android/server/wm/DisplayWindowSettings.java
+++ b/services/core/java/com/android/server/wm/DisplayWindowSettings.java
@@ -30,6 +30,7 @@
import android.annotation.Nullable;
import android.app.WindowConfiguration;
import android.os.Environment;
+import android.os.FileUtils;
import android.provider.Settings;
import android.util.AtomicFile;
import android.util.Slog;
@@ -64,6 +65,11 @@
class DisplayWindowSettings {
private static final String TAG = TAG_WITH_CLASS_NAME ? "DisplayWindowSettings" : TAG_WM;
+ private static final String SYSTEM_DIRECTORY = "system";
+ private static final String DISPLAY_SETTINGS_FILE_NAME = "display_settings.xml";
+ private static final String VENDOR_DISPLAY_SETTINGS_PATH = "etc/" + DISPLAY_SETTINGS_FILE_NAME;
+ private static final String WM_DISPLAY_COMMIT_TAG = "wm-displays";
+
private static final int IDENTIFIER_UNIQUE_ID = 0;
private static final int IDENTIFIER_PORT = 1;
@IntDef(prefix = { "IDENTIFIER_" }, value = {
@@ -688,8 +694,26 @@
private final AtomicFile mAtomicFile;
AtomicFileStorage() {
- final File folder = new File(Environment.getDataDirectory(), "system");
- mAtomicFile = new AtomicFile(new File(folder, "display_settings.xml"), "wm-displays");
+ final File folder = new File(Environment.getDataDirectory(), SYSTEM_DIRECTORY);
+ final File settingsFile = new File(folder, DISPLAY_SETTINGS_FILE_NAME);
+ // If display_settings.xml doesn't exist, try to copy the vendor's one instead
+ // in order to provide the vendor specific initialization.
+ if (!settingsFile.exists()) {
+ copyVendorSettings(settingsFile);
+ }
+ mAtomicFile = new AtomicFile(settingsFile, WM_DISPLAY_COMMIT_TAG);
+ }
+
+ private static void copyVendorSettings(File target) {
+ final File vendorFile = new File(Environment.getVendorDirectory(),
+ VENDOR_DISPLAY_SETTINGS_PATH);
+ if (vendorFile.canRead()) {
+ try {
+ FileUtils.copy(vendorFile, target);
+ } catch (IOException e) {
+ Slog.e(TAG, "Failed to copy vendor display_settings.xml");
+ }
+ }
}
@Override
diff --git a/services/core/java/com/android/server/wm/Letterbox.java b/services/core/java/com/android/server/wm/Letterbox.java
index c3ea72f..bb035d5 100644
--- a/services/core/java/com/android/server/wm/Letterbox.java
+++ b/services/core/java/com/android/server/wm/Letterbox.java
@@ -261,7 +261,7 @@
public void remove() {
if (mSurface != null) {
- mSurface.remove();
+ new SurfaceControl.Transaction().remove(mSurface).apply();
mSurface = null;
}
if (mInputInterceptor != null) {
diff --git a/services/core/java/com/android/server/wm/RootActivityContainer.java b/services/core/java/com/android/server/wm/RootActivityContainer.java
index d58c613..ffbf688 100644
--- a/services/core/java/com/android/server/wm/RootActivityContainer.java
+++ b/services/core/java/com/android/server/wm/RootActivityContainer.java
@@ -1667,7 +1667,8 @@
<T extends ActivityStack> T getLaunchStack(@Nullable ActivityRecord r,
@Nullable ActivityOptions options, @Nullable TaskRecord candidateTask, boolean onTop) {
- return getLaunchStack(r, options, candidateTask, onTop, null /* launchParams */);
+ return getLaunchStack(r, options, candidateTask, onTop, null /* launchParams */,
+ -1 /* no realCallingPid */, -1 /* no realCallingUid */);
}
/**
@@ -1676,13 +1677,16 @@
* @param r The activity we are trying to launch. Can be null.
* @param options The activity options used to the launch. Can be null.
* @param candidateTask The possible task the activity might be launched in. Can be null.
- * @params launchParams The resolved launch params to use.
+ * @param launchParams The resolved launch params to use.
+ * @param realCallingPid The pid from {@link ActivityStarter#setRealCallingPid}
+ * @param realCallingUid The uid from {@link ActivityStarter#setRealCallingUid}
*
* @return The stack to use for the launch or INVALID_STACK_ID.
*/
<T extends ActivityStack> T getLaunchStack(@Nullable ActivityRecord r,
@Nullable ActivityOptions options, @Nullable TaskRecord candidateTask, boolean onTop,
- @Nullable LaunchParamsController.LaunchParams launchParams) {
+ @Nullable LaunchParamsController.LaunchParams launchParams, int realCallingPid,
+ int realCallingUid) {
int taskId = INVALID_TASK_ID;
int displayId = INVALID_DISPLAY;
//Rect bounds = null;
@@ -1713,7 +1717,14 @@
if (launchParams != null && launchParams.mPreferredDisplayId != INVALID_DISPLAY) {
displayId = launchParams.mPreferredDisplayId;
}
- if (displayId != INVALID_DISPLAY && canLaunchOnDisplay(r, displayId)) {
+ final boolean canLaunchOnDisplayFromStartRequest =
+ realCallingPid != 0 && realCallingUid > 0 && r != null
+ && mStackSupervisor.canPlaceEntityOnDisplay(displayId, realCallingPid,
+ realCallingUid, r.info);
+ // Checking if the activity's launch caller, or the realCallerId of the activity from
+ // start request (i.e. PendingIntent caller) is allowed to launch on the display.
+ if (displayId != INVALID_DISPLAY && (canLaunchOnDisplay(r, displayId)
+ || canLaunchOnDisplayFromStartRequest)) {
if (r != null) {
stack = (T) getValidLaunchStackOnDisplay(displayId, r, candidateTask, options,
launchParams);
@@ -2266,9 +2277,9 @@
void getRunningTasks(int maxNum, List<ActivityManager.RunningTaskInfo> list,
@WindowConfiguration.ActivityType int ignoreActivityType,
@WindowConfiguration.WindowingMode int ignoreWindowingMode, int callingUid,
- boolean allowed) {
+ boolean allowed, boolean crossUser, ArraySet<Integer> profileIds) {
mStackSupervisor.mRunningTasks.getTasks(maxNum, list, ignoreActivityType,
- ignoreWindowingMode, mActivityDisplays, callingUid, allowed);
+ ignoreWindowingMode, mActivityDisplays, callingUid, allowed, crossUser, profileIds);
}
void sendPowerHintForLaunchStartIfNeeded(boolean forceSend, ActivityRecord targetActivity) {
diff --git a/services/core/java/com/android/server/wm/RunningTasks.java b/services/core/java/com/android/server/wm/RunningTasks.java
index 3bf437d..81a8547 100644
--- a/services/core/java/com/android/server/wm/RunningTasks.java
+++ b/services/core/java/com/android/server/wm/RunningTasks.java
@@ -19,6 +19,7 @@
import android.app.ActivityManager.RunningTaskInfo;
import android.app.WindowConfiguration.ActivityType;
import android.app.WindowConfiguration.WindowingMode;
+import android.util.ArraySet;
import java.util.ArrayList;
import java.util.Comparator;
@@ -40,7 +41,7 @@
void getTasks(int maxNum, List<RunningTaskInfo> list, @ActivityType int ignoreActivityType,
@WindowingMode int ignoreWindowingMode, ArrayList<ActivityDisplay> activityDisplays,
- int callingUid, boolean allowed) {
+ int callingUid, boolean allowed, boolean crossUser, ArraySet<Integer> profileIds) {
// Return early if there are no tasks to fetch
if (maxNum <= 0) {
return;
@@ -55,7 +56,7 @@
final ActivityStack stack = display.getChildAt(stackNdx);
mTmpStackTasks.clear();
stack.getRunningTasks(mTmpStackTasks, ignoreActivityType, ignoreWindowingMode,
- callingUid, allowed);
+ callingUid, allowed, crossUser, profileIds);
mTmpSortedSet.addAll(mTmpStackTasks);
}
}
diff --git a/services/core/java/com/android/server/wm/ScreenRotationAnimation.java b/services/core/java/com/android/server/wm/ScreenRotationAnimation.java
index 0be9736..b94a7dc 100644
--- a/services/core/java/com/android/server/wm/ScreenRotationAnimation.java
+++ b/services/core/java/com/android/server/wm/ScreenRotationAnimation.java
@@ -558,7 +558,7 @@
Rect outer = new Rect(-mOriginalWidth*1, -mOriginalHeight*1,
mOriginalWidth*2, mOriginalHeight*2);
Rect inner = new Rect(0, 0, mOriginalWidth, mOriginalHeight);
- mCustomBlackFrame = new BlackFrame(t, outer, inner,
+ mCustomBlackFrame = new BlackFrame(mService.mTransactionFactory, t, outer, inner,
SCREEN_FREEZE_LAYER_CUSTOM, mDisplayContent, false);
mCustomBlackFrame.setMatrix(t, mFrameInitialMatrix);
} catch (OutOfResourcesException e) {
@@ -589,7 +589,7 @@
mOriginalWidth*2, mOriginalHeight*2);
inner = new Rect(0, 0, mOriginalWidth, mOriginalHeight);
}
- mExitingBlackFrame = new BlackFrame(t, outer, inner,
+ mExitingBlackFrame = new BlackFrame(mService.mTransactionFactory, t, outer, inner,
SCREEN_FREEZE_LAYER_EXIT, mDisplayContent, mForceDefaultOrientation);
mExitingBlackFrame.setMatrix(t, mFrameInitialMatrix);
} catch (OutOfResourcesException e) {
@@ -602,7 +602,7 @@
Rect outer = new Rect(-finalWidth*1, -finalHeight*1,
finalWidth*2, finalHeight*2);
Rect inner = new Rect(0, 0, finalWidth, finalHeight);
- mEnteringBlackFrame = new BlackFrame(t, outer, inner,
+ mEnteringBlackFrame = new BlackFrame(mService.mTransactionFactory, t, outer, inner,
SCREEN_FREEZE_LAYER_ENTER, mDisplayContent, false);
} catch (OutOfResourcesException e) {
Slog.w(TAG, "Unable to allocate black surface", e);
@@ -640,7 +640,7 @@
if (SHOW_TRANSACTIONS ||
SHOW_SURFACE_ALLOC) Slog.i(TAG_WM,
" FREEZE " + mSurfaceControl + ": DESTROY");
- mSurfaceControl.remove();
+ mService.mTransactionFactory.make().remove(mSurfaceControl).apply();
mSurfaceControl = null;
}
if (mCustomBlackFrame != null) {
diff --git a/services/core/java/com/android/server/wm/TaskChangeNotificationController.java b/services/core/java/com/android/server/wm/TaskChangeNotificationController.java
index f776062..4c50527 100644
--- a/services/core/java/com/android/server/wm/TaskChangeNotificationController.java
+++ b/services/core/java/com/android/server/wm/TaskChangeNotificationController.java
@@ -55,7 +55,8 @@
private static final int NOTIFY_SIZE_COMPAT_MODE_ACTIVITY_CHANGED_MSG = 20;
private static final int NOTIFY_BACK_PRESSED_ON_TASK_ROOT = 21;
private static final int NOTIFY_SINGLE_TASK_DISPLAY_DRAWN = 22;
- private static final int NOTIFY_TASK_DISPLAY_CHANGED_LISTENERS_MSG = 23;
+ private static final int NOTIFY_SINGLE_TASK_DISPLAY_EMPTY = 23;
+ private static final int NOTIFY_TASK_DISPLAY_CHANGED_LISTENERS_MSG = 24;
// Delay in notifying task stack change listeners (in millis)
private static final int NOTIFY_TASK_STACK_CHANGE_LISTENERS_DELAY = 100;
@@ -160,6 +161,10 @@
l.onSingleTaskDisplayDrawn(m.arg1);
};
+ private final TaskStackConsumer mNotifySingleTaskDisplayEmpty = (l, m) -> {
+ l.onSingleTaskDisplayEmpty(m.arg1);
+ };
+
private final TaskStackConsumer mNotifyTaskDisplayChanged = (l, m) -> {
l.onTaskDisplayChanged(m.arg1, m.arg2);
};
@@ -246,6 +251,9 @@
case NOTIFY_SINGLE_TASK_DISPLAY_DRAWN:
forAllRemoteListeners(mNotifySingleTaskDisplayDrawn, msg);
break;
+ case NOTIFY_SINGLE_TASK_DISPLAY_EMPTY:
+ forAllRemoteListeners(mNotifySingleTaskDisplayEmpty, msg);
+ break;
case NOTIFY_TASK_DISPLAY_CHANGED_LISTENERS_MSG:
forAllRemoteListeners(mNotifyTaskDisplayChanged, msg);
break;
@@ -505,6 +513,17 @@
}
/**
+ * Notify listeners that the last task is removed from a single task display.
+ */
+ void notifySingleTaskDisplayEmpty(int displayId) {
+ final Message msg = mHandler.obtainMessage(
+ NOTIFY_SINGLE_TASK_DISPLAY_EMPTY,
+ displayId, 0 /* unused */);
+ forAllLocalListeners(mNotifySingleTaskDisplayEmpty, msg);
+ msg.sendToTarget();
+ }
+
+ /**
* Notify listeners that a task is reparented to another display.
*/
void notifyTaskDisplayChanged(int taskId, int newDisplayId) {
diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java
index 114a56f..343a972 100644
--- a/services/core/java/com/android/server/wm/TaskStack.java
+++ b/services/core/java/com/android/server/wm/TaskStack.java
@@ -1012,7 +1012,7 @@
EventLog.writeEvent(EventLogTags.WM_STACK_REMOVED, mStackId);
if (mAnimationBackgroundSurface != null) {
- mAnimationBackgroundSurface.remove();
+ mWmService.mTransactionFactory.make().remove(mAnimationBackgroundSurface).apply();
mAnimationBackgroundSurface = null;
}
@@ -1747,6 +1747,11 @@
if (toBounds.width() == fromBounds.width()
&& toBounds.height() == fromBounds.height()) {
intendedAnimationType = BoundsAnimationController.BOUNDS;
+ } else if (!fromFullscreen && !toBounds.equals(fromBounds)) {
+ // intendedAnimationType may have been reset at the end of RecentsAnimation,
+ // force it to BOUNDS type if we know for certain we're animating to
+ // a different bounds, especially for expand and collapse of PiP window.
+ intendedAnimationType = BoundsAnimationController.BOUNDS;
}
}
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index ec970d2..e1f8544 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -1167,7 +1167,8 @@
new HandlerExecutor(mH), properties -> {
synchronized (mGlobalLock) {
final int exclusionLimitDp = Math.max(MIN_GESTURE_EXCLUSION_LIMIT_DP,
- properties.getInt(KEY_SYSTEM_GESTURE_EXCLUSION_LIMIT_DP, 0));
+ DeviceConfig.getInt(DeviceConfig.NAMESPACE_WINDOW_MANAGER,
+ KEY_SYSTEM_GESTURE_EXCLUSION_LIMIT_DP, 0));
final boolean excludedByPreQSticky = DeviceConfig.getBoolean(
DeviceConfig.NAMESPACE_WINDOW_MANAGER,
KEY_SYSTEM_GESTURES_EXCLUDED_BY_PRE_Q_STICKY_IMMERSIVE, false);
diff --git a/services/core/java/com/android/server/wm/WindowSurfaceController.java b/services/core/java/com/android/server/wm/WindowSurfaceController.java
index 53bbd70..f37209b 100644
--- a/services/core/java/com/android/server/wm/WindowSurfaceController.java
+++ b/services/core/java/com/android/server/wm/WindowSurfaceController.java
@@ -162,7 +162,7 @@
}
try {
if (mSurfaceControl != null) {
- mSurfaceControl.remove();
+ mTmpTransaction.remove(mSurfaceControl).apply();
}
} catch (RuntimeException e) {
Slog.w(TAG, "Error destroying surface in: " + this, e);
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index e6ed2ed..0034b3c 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -23,6 +23,7 @@
import static android.view.Display.DEFAULT_DISPLAY;
import android.annotation.NonNull;
+import android.annotation.StringRes;
import android.app.ActivityThread;
import android.app.INotificationManager;
import android.app.usage.UsageStatsManagerInternal;
@@ -1262,14 +1263,22 @@
startSystemCaptionsManagerService(context);
// App prediction manager service
- traceBeginAndSlog("StartAppPredictionService");
- mSystemServiceManager.startService(APP_PREDICTION_MANAGER_SERVICE_CLASS);
- traceEnd();
+ if (deviceHasConfigString(context, R.string.config_defaultAppPredictionService)) {
+ traceBeginAndSlog("StartAppPredictionService");
+ mSystemServiceManager.startService(APP_PREDICTION_MANAGER_SERVICE_CLASS);
+ traceEnd();
+ } else {
+ Slog.d(TAG, "AppPredictionService not defined by OEM");
+ }
// Content suggestions manager service
- traceBeginAndSlog("StartContentSuggestionsService");
- mSystemServiceManager.startService(CONTENT_SUGGESTIONS_SERVICE_CLASS);
- traceEnd();
+ if (deviceHasConfigString(context, R.string.config_defaultContentSuggestionsService)) {
+ traceBeginAndSlog("StartContentSuggestionsService");
+ mSystemServiceManager.startService(CONTENT_SUGGESTIONS_SERVICE_CLASS);
+ traceEnd();
+ } else {
+ Slog.d(TAG, "ContentSuggestionsService not defined by OEM");
+ }
traceBeginAndSlog("InitConnectivityModuleConnector");
try {
@@ -2260,10 +2269,13 @@
}, BOOT_TIMINGS_TRACE_LOG);
}
+ private boolean deviceHasConfigString(@NonNull Context context, @StringRes int resId) {
+ String serviceName = context.getString(resId);
+ return !TextUtils.isEmpty(serviceName);
+ }
+
private void startSystemCaptionsManagerService(@NonNull Context context) {
- String serviceName = context.getString(
- com.android.internal.R.string.config_defaultSystemCaptionsManagerService);
- if (TextUtils.isEmpty(serviceName)) {
+ if (!deviceHasConfigString(context, R.string.config_defaultSystemCaptionsManagerService)) {
Slog.d(TAG, "SystemCaptionsManagerService disabled because resource is not overlaid");
return;
}
@@ -2290,9 +2302,7 @@
// Then check if OEM overlaid the resource that defines the service.
if (!explicitlyEnabled) {
- final String serviceName = context
- .getString(com.android.internal.R.string.config_defaultContentCaptureService);
- if (TextUtils.isEmpty(serviceName)) {
+ if (!deviceHasConfigString(context, R.string.config_defaultContentCaptureService)) {
Slog.d(TAG, "ContentCaptureService disabled because resource is not overlaid");
return;
}
diff --git a/services/tests/servicestests/src/com/android/server/accessibility/GlobalActionPerformerTest.java b/services/tests/servicestests/src/com/android/server/accessibility/GlobalActionPerformerTest.java
index e72e460..c73be6f 100644
--- a/services/tests/servicestests/src/com/android/server/accessibility/GlobalActionPerformerTest.java
+++ b/services/tests/servicestests/src/com/android/server/accessibility/GlobalActionPerformerTest.java
@@ -35,6 +35,8 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import java.util.function.Consumer;
+
/**
* Tests for GlobalActionPerformer
*/
@@ -84,6 +86,6 @@
AccessibilityService.GLOBAL_ACTION_TAKE_SCREENSHOT);
verify(mMockScreenshotHelper).takeScreenshot(
eq(android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN), anyBoolean(),
- anyBoolean(), any(Handler.class));
+ anyBoolean(), any(Handler.class), any());
}
}
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/BubbleExtractorTest.java b/services/tests/uiservicestests/src/com/android/server/notification/BubbleExtractorTest.java
index 273a9e6..7459c4b 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/BubbleExtractorTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/BubbleExtractorTest.java
@@ -86,7 +86,7 @@
BubbleExtractor extractor = new BubbleExtractor();
extractor.setConfig(mConfig);
- when(mConfig.bubblesEnabled(mUser)).thenReturn(true);
+ when(mConfig.bubblesEnabled()).thenReturn(true);
when(mConfig.areBubblesAllowed(mPkg, mUid)).thenReturn(true);
NotificationRecord r = getNotificationRecord(false, IMPORTANCE_UNSPECIFIED);
@@ -100,7 +100,7 @@
BubbleExtractor extractor = new BubbleExtractor();
extractor.setConfig(mConfig);
- when(mConfig.bubblesEnabled(mUser)).thenReturn(true);
+ when(mConfig.bubblesEnabled()).thenReturn(true);
when(mConfig.areBubblesAllowed(mPkg, mUid)).thenReturn(false);
NotificationRecord r = getNotificationRecord(true, IMPORTANCE_HIGH);
@@ -114,7 +114,7 @@
BubbleExtractor extractor = new BubbleExtractor();
extractor.setConfig(mConfig);
- when(mConfig.bubblesEnabled(mUser)).thenReturn(true);
+ when(mConfig.bubblesEnabled()).thenReturn(true);
when(mConfig.areBubblesAllowed(mPkg, mUid)).thenReturn(true);
NotificationRecord r = getNotificationRecord(true, IMPORTANCE_UNSPECIFIED);
@@ -128,7 +128,7 @@
BubbleExtractor extractor = new BubbleExtractor();
extractor.setConfig(mConfig);
- when(mConfig.bubblesEnabled(mUser)).thenReturn(true);
+ when(mConfig.bubblesEnabled()).thenReturn(true);
when(mConfig.areBubblesAllowed(mPkg, mUid)).thenReturn(false);
NotificationRecord r = getNotificationRecord(false, IMPORTANCE_UNSPECIFIED);
@@ -142,7 +142,7 @@
BubbleExtractor extractor = new BubbleExtractor();
extractor.setConfig(mConfig);
- when(mConfig.bubblesEnabled(mUser)).thenReturn(false);
+ when(mConfig.bubblesEnabled()).thenReturn(false);
when(mConfig.areBubblesAllowed(mPkg, mUid)).thenReturn(true);
NotificationRecord r = getNotificationRecord(true, IMPORTANCE_HIGH);
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
index 5ba1eb2..dc5edcd 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
@@ -20,6 +20,7 @@
import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE;
import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE;
import static android.app.Notification.CATEGORY_CALL;
+import static android.app.Notification.FLAG_AUTO_CANCEL;
import static android.app.Notification.FLAG_BUBBLE;
import static android.app.Notification.FLAG_FOREGROUND_SERVICE;
import static android.app.NotificationManager.EXTRA_BLOCKED_STATE;
@@ -420,7 +421,7 @@
private void setUpPrefsForBubbles(boolean globalEnabled, boolean pkgEnabled,
boolean channelEnabled) {
mService.setPreferencesHelper(mPreferencesHelper);
- when(mPreferencesHelper.bubblesEnabled(any())).thenReturn(globalEnabled);
+ when(mPreferencesHelper.bubblesEnabled()).thenReturn(globalEnabled);
when(mPreferencesHelper.areBubblesAllowed(anyString(), anyInt())).thenReturn(pkgEnabled);
when(mPreferencesHelper.getNotificationChannel(
anyString(), anyInt(), anyString(), anyBoolean())).thenReturn(
@@ -439,14 +440,22 @@
return sbn;
}
+
private NotificationRecord generateNotificationRecord(NotificationChannel channel, int id,
String groupKey, boolean isSummary) {
+ return generateNotificationRecord(channel, id, groupKey, isSummary, false /* isBubble */);
+ }
+
+ private NotificationRecord generateNotificationRecord(NotificationChannel channel, int id,
+ String groupKey, boolean isSummary, boolean isBubble) {
Notification.Builder nb = new Notification.Builder(mContext, channel.getId())
.setContentTitle("foo")
.setSmallIcon(android.R.drawable.sym_def_app_icon)
.setGroup(groupKey)
.setGroupSummary(isSummary);
-
+ if (isBubble) {
+ nb.setBubbleMetadata(getBasicBubbleMetadataBuilder().build());
+ }
StatusBarNotification sbn = new StatusBarNotification(PKG, PKG, id, "tag", mUid, 0,
nb.build(), new UserHandle(mUid), null, 0);
return new NotificationRecord(mContext, sbn, channel);
@@ -542,6 +551,52 @@
.setIcon(Icon.createWithResource(mContext, android.R.drawable.sym_def_app_icon));
}
+ private NotificationRecord addGroupWithBubblesAndValidateAdded(boolean summaryAutoCancel)
+ throws RemoteException {
+
+ // Notification that has bubble metadata
+ NotificationRecord nrBubble = generateNotificationRecord(mTestNotificationChannel, 1,
+ "BUBBLE_GROUP", false /* isSummary */, true /* isBubble */);
+
+ // Make the package foreground so that we're allowed to be a bubble
+ when(mActivityManager.getPackageImportance(nrBubble.sbn.getPackageName())).thenReturn(
+ IMPORTANCE_FOREGROUND);
+
+ mBinderService.enqueueNotificationWithTag(PKG, PKG, "tag",
+ nrBubble.sbn.getId(), nrBubble.sbn.getNotification(), nrBubble.sbn.getUserId());
+ waitForIdle();
+
+ // Make sure we are a bubble
+ StatusBarNotification[] notifsAfter = mBinderService.getActiveNotifications(PKG);
+ assertEquals(1, notifsAfter.length);
+ assertTrue((notifsAfter[0].getNotification().flags & FLAG_BUBBLE) != 0);
+
+ // Plain notification without bubble metadata
+ NotificationRecord nrPlain = generateNotificationRecord(mTestNotificationChannel, 2,
+ "BUBBLE_GROUP", false /* isSummary */, false /* isBubble */);
+ mBinderService.enqueueNotificationWithTag(PKG, PKG, "tag",
+ nrPlain.sbn.getId(), nrPlain.sbn.getNotification(), nrPlain.sbn.getUserId());
+ waitForIdle();
+
+ notifsAfter = mBinderService.getActiveNotifications(PKG);
+ assertEquals(2, notifsAfter.length);
+
+ // Summary notification for both of those
+ NotificationRecord nrSummary = generateNotificationRecord(mTestNotificationChannel, 3,
+ "BUBBLE_GROUP", true /* isSummary */, false /* isBubble */);
+ if (summaryAutoCancel) {
+ nrSummary.getNotification().flags |= FLAG_AUTO_CANCEL;
+ }
+ mBinderService.enqueueNotificationWithTag(PKG, PKG, "tag",
+ nrSummary.sbn.getId(), nrSummary.sbn.getNotification(), nrSummary.sbn.getUserId());
+ waitForIdle();
+
+ notifsAfter = mBinderService.getActiveNotifications(PKG);
+ assertEquals(3, notifsAfter.length);
+
+ return nrSummary;
+ }
+
@Test
public void testCreateNotificationChannels_SingleChannel() throws Exception {
final NotificationChannel channel =
@@ -1508,14 +1563,22 @@
public void testUpdateAppNotifyCreatorBlock() throws Exception {
mService.setPreferencesHelper(mPreferencesHelper);
- mBinderService.setNotificationsEnabledForPackage(PKG, 0, false);
+ mBinderService.setNotificationsEnabledForPackage(PKG, 0, true);
ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
verify(mContext, times(1)).sendBroadcastAsUser(captor.capture(), any(), eq(null));
assertEquals(NotificationManager.ACTION_APP_BLOCK_STATE_CHANGED,
captor.getValue().getAction());
assertEquals(PKG, captor.getValue().getPackage());
- assertTrue(captor.getValue().getBooleanExtra(EXTRA_BLOCKED_STATE, false));
+ assertFalse(captor.getValue().getBooleanExtra(EXTRA_BLOCKED_STATE, true));
+ }
+
+ @Test
+ public void testUpdateAppNotifyCreatorBlock_notIfMatchesExistingSetting() throws Exception {
+ mService.setPreferencesHelper(mPreferencesHelper);
+
+ mBinderService.setNotificationsEnabledForPackage(PKG, 0, false);
+ verify(mContext, never()).sendBroadcastAsUser(any(), any(), eq(null));
}
@Test
@@ -5078,4 +5141,162 @@
assertEquals(1, notifsAfter.length);
assertEquals((notifsAfter[0].getNotification().flags & FLAG_BUBBLE), 0);
}
+
+ @Test
+ public void testNotificationBubbles_flagAutoExpandForeground_fails_notForeground()
+ throws Exception {
+ // Bubbles are allowed!
+ setUpPrefsForBubbles(true /* global */, true /* app */, true /* channel */);
+
+ // Give it bubble metadata
+ Notification.BubbleMetadata data = getBasicBubbleMetadataBuilder()
+ .setSuppressNotification(true)
+ .setAutoExpandBubble(true).build();
+ // Give it a person
+ Person person = new Person.Builder()
+ .setName("bubblebot")
+ .build();
+ // It needs remote input to be bubble-able
+ RemoteInput remoteInput = new RemoteInput.Builder("reply_key").setLabel("reply").build();
+ PendingIntent inputIntent = PendingIntent.getActivity(mContext, 0, new Intent(), 0);
+ Icon icon = Icon.createWithResource(mContext, android.R.drawable.sym_def_app_icon);
+ Notification.Action replyAction = new Notification.Action.Builder(icon, "Reply",
+ inputIntent).addRemoteInput(remoteInput)
+ .build();
+ // Make it messaging style
+ Notification.Builder nb = new Notification.Builder(mContext,
+ mTestNotificationChannel.getId())
+ .setContentTitle("foo")
+ .setBubbleMetadata(data)
+ .setStyle(new Notification.MessagingStyle(person)
+ .setConversationTitle("Bubble Chat")
+ .addMessage("Hello?",
+ SystemClock.currentThreadTimeMillis() - 300000, person)
+ .addMessage("Is it me you're looking for?",
+ SystemClock.currentThreadTimeMillis(), person)
+ )
+ .setActions(replyAction)
+ .setSmallIcon(android.R.drawable.sym_def_app_icon);
+
+ StatusBarNotification sbn = new StatusBarNotification(PKG, PKG, 1, null, mUid, 0,
+ nb.build(), new UserHandle(mUid), null, 0);
+ NotificationRecord nr = new NotificationRecord(mContext, sbn, mTestNotificationChannel);
+
+ // Ensure we're not foreground
+ when(mActivityManager.getPackageImportance(nr.sbn.getPackageName())).thenReturn(
+ IMPORTANCE_VISIBLE);
+
+ mBinderService.enqueueNotificationWithTag(PKG, PKG, null,
+ nr.sbn.getId(), nr.sbn.getNotification(), nr.sbn.getUserId());
+ waitForIdle();
+
+ // yes allowed, yes messaging, yes bubble
+ Notification notif = mService.getNotificationRecord(sbn.getKey()).getNotification();
+ assertTrue(notif.isBubbleNotification());
+
+ // Our flags should have failed since we're not foreground
+ assertFalse(notif.getBubbleMetadata().getAutoExpandBubble());
+ assertFalse(notif.getBubbleMetadata().isNotificationSuppressed());
+ }
+
+ @Test
+ public void testNotificationBubbles_flagAutoExpandForeground_succeeds_foreground()
+ throws RemoteException {
+ // Bubbles are allowed!
+ setUpPrefsForBubbles(true /* global */, true /* app */, true /* channel */);
+
+ // Give it bubble metadata
+ Notification.BubbleMetadata data = getBasicBubbleMetadataBuilder()
+ .setSuppressNotification(true)
+ .setAutoExpandBubble(true).build();
+ // Give it a person
+ Person person = new Person.Builder()
+ .setName("bubblebot")
+ .build();
+ // It needs remote input to be bubble-able
+ RemoteInput remoteInput = new RemoteInput.Builder("reply_key").setLabel("reply").build();
+ PendingIntent inputIntent = PendingIntent.getActivity(mContext, 0, new Intent(), 0);
+ Icon icon = Icon.createWithResource(mContext, android.R.drawable.sym_def_app_icon);
+ Notification.Action replyAction = new Notification.Action.Builder(icon, "Reply",
+ inputIntent).addRemoteInput(remoteInput)
+ .build();
+ // Make it messaging style
+ Notification.Builder nb = new Notification.Builder(mContext,
+ mTestNotificationChannel.getId())
+ .setContentTitle("foo")
+ .setBubbleMetadata(data)
+ .setStyle(new Notification.MessagingStyle(person)
+ .setConversationTitle("Bubble Chat")
+ .addMessage("Hello?",
+ SystemClock.currentThreadTimeMillis() - 300000, person)
+ .addMessage("Is it me you're looking for?",
+ SystemClock.currentThreadTimeMillis(), person)
+ )
+ .setActions(replyAction)
+ .setSmallIcon(android.R.drawable.sym_def_app_icon);
+
+ StatusBarNotification sbn = new StatusBarNotification(PKG, PKG, 1, null, mUid, 0,
+ nb.build(), new UserHandle(mUid), null, 0);
+ NotificationRecord nr = new NotificationRecord(mContext, sbn, mTestNotificationChannel);
+
+ // Ensure we are in the foreground
+ when(mActivityManager.getPackageImportance(nr.sbn.getPackageName())).thenReturn(
+ IMPORTANCE_FOREGROUND);
+
+ mBinderService.enqueueNotificationWithTag(PKG, PKG, null,
+ nr.sbn.getId(), nr.sbn.getNotification(), nr.sbn.getUserId());
+ waitForIdle();
+
+ // yes allowed, yes messaging, yes bubble
+ Notification notif = mService.getNotificationRecord(sbn.getKey()).getNotification();
+ assertTrue(notif.isBubbleNotification());
+
+ // Our flags should have failed since we are foreground
+ assertTrue(notif.getBubbleMetadata().getAutoExpandBubble());
+ assertTrue(notif.getBubbleMetadata().isNotificationSuppressed());
+ }
+
+ @Test
+ public void testNotificationBubbles_bubbleChildrenStay_whenGroupSummaryDismissed()
+ throws Exception {
+ // Bubbles are allowed!
+ setUpPrefsForBubbles(true /* global */, true /* app */, true /* channel */);
+
+ NotificationRecord nrSummary = addGroupWithBubblesAndValidateAdded(
+ true /* summaryAutoCancel */);
+
+ // Dismiss summary
+ final NotificationVisibility nv = NotificationVisibility.obtain(nrSummary.getKey(), 1, 2,
+ true);
+ mService.mNotificationDelegate.onNotificationClear(mUid, 0, PKG, nrSummary.sbn.getTag(),
+ nrSummary.sbn.getId(), nrSummary.getUserId(), nrSummary.getKey(),
+ NotificationStats.DISMISSAL_SHADE,
+ NotificationStats.DISMISS_SENTIMENT_NEUTRAL, nv);
+ waitForIdle();
+
+ // The bubble should still exist
+ StatusBarNotification[] notifsAfter = mBinderService.getActiveNotifications(PKG);
+ assertEquals(1, notifsAfter.length);
+ }
+
+ @Test
+ public void testNotificationBubbles_bubbleChildrenStay_whenGroupSummaryClicked()
+ throws Exception {
+ // Bubbles are allowed!
+ setUpPrefsForBubbles(true /* global */, true /* app */, true /* channel */);
+
+ NotificationRecord nrSummary = addGroupWithBubblesAndValidateAdded(
+ true /* summaryAutoCancel */);
+
+ // Click summary
+ final NotificationVisibility nv = NotificationVisibility.obtain(nrSummary.getKey(), 1, 2,
+ true);
+ mService.mNotificationDelegate.onNotificationClick(mUid, Binder.getCallingPid(),
+ nrSummary.getKey(), nv);
+ waitForIdle();
+
+ // The bubble should still exist
+ StatusBarNotification[] notifsAfter = mBinderService.getActiveNotifications(PKG);
+ assertEquals(1, notifsAfter.length);
+ }
}
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java
index 8f8b746..80439cf 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java
@@ -22,6 +22,8 @@
import static android.app.NotificationManager.IMPORTANCE_NONE;
import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED;
+import static com.android.server.notification.PreferencesHelper.NOTIFICATION_CHANNEL_COUNT_LIMIT;
+
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.fail;
@@ -58,7 +60,9 @@
import android.os.Build;
import android.os.UserHandle;
import android.provider.Settings;
+import android.provider.Settings.Global;
import android.provider.Settings.Secure;
+
import android.test.suitebuilder.annotation.SmallTest;
import android.testing.TestableContentResolver;
import android.util.ArrayMap;
@@ -152,8 +156,7 @@
contentResolver.setFallbackToExisting(false);
Secure.putIntForUser(contentResolver,
Secure.NOTIFICATION_BADGING, 1, UserHandle.getUserId(UID_N_MR1));
- Secure.putIntForUser(contentResolver,
- Secure.NOTIFICATION_BUBBLES, 1, UserHandle.getUserId(UID_N_MR1));
+ Global.putInt(contentResolver, Global.NOTIFICATION_BUBBLES, 1);
ContentProvider testContentProvider = mock(ContentProvider.class);
when(testContentProvider.getIContentProvider()).thenReturn(mTestIContentProvider);
@@ -1948,42 +1951,18 @@
@Test
public void testBubblesOverrideTrue() {
- Secure.putIntForUser(getContext().getContentResolver(),
- Secure.NOTIFICATION_BUBBLES, 1,
- USER.getIdentifier());
+ Global.putInt(getContext().getContentResolver(),
+ Global.NOTIFICATION_BUBBLES, 1);
mHelper.updateBubblesEnabled(); // would be called by settings observer
- assertTrue(mHelper.bubblesEnabled(USER));
+ assertTrue(mHelper.bubblesEnabled());
}
@Test
public void testBubblesOverrideFalse() {
- Secure.putIntForUser(getContext().getContentResolver(),
- Secure.NOTIFICATION_BUBBLES, 0,
- USER.getIdentifier());
+ Global.putInt(getContext().getContentResolver(),
+ Global.NOTIFICATION_BUBBLES, 0);
mHelper.updateBubblesEnabled(); // would be called by settings observer
- assertFalse(mHelper.bubblesEnabled(USER));
- }
-
- @Test
- public void testBubblesForUserAll() {
- try {
- mHelper.bubblesEnabled(UserHandle.ALL);
- } catch (Exception e) {
- fail("just don't throw");
- }
- }
-
- @Test
- public void testBubblesOverrideUserIsolation() {
- Secure.putIntForUser(getContext().getContentResolver(),
- Secure.NOTIFICATION_BUBBLES, 0,
- USER.getIdentifier());
- Secure.putIntForUser(getContext().getContentResolver(),
- Secure.NOTIFICATION_BUBBLES, 1,
- USER2.getIdentifier());
- mHelper.updateBubblesEnabled(); // would be called by settings observer
- assertFalse(mHelper.bubblesEnabled(USER));
- assertTrue(mHelper.bubblesEnabled(USER2));
+ assertFalse(mHelper.bubblesEnabled());
}
@Test
@@ -2690,4 +2669,51 @@
assertFalse(mHelper.areBubblesAllowed(PKG_O, UID_O));
verify(mHandler, times(1)).requestSort();
}
+
+ @Test
+ public void testTooManyChannels() {
+ for (int i = 0; i < NOTIFICATION_CHANNEL_COUNT_LIMIT; i++) {
+ NotificationChannel channel = new NotificationChannel(String.valueOf(i),
+ String.valueOf(i), NotificationManager.IMPORTANCE_HIGH);
+ mHelper.createNotificationChannel(PKG_O, UID_O, channel, true, true);
+ }
+ try {
+ NotificationChannel channel = new NotificationChannel(
+ String.valueOf(NOTIFICATION_CHANNEL_COUNT_LIMIT),
+ String.valueOf(NOTIFICATION_CHANNEL_COUNT_LIMIT),
+ NotificationManager.IMPORTANCE_HIGH);
+ mHelper.createNotificationChannel(PKG_O, UID_O, channel, true, true);
+ fail("Allowed to create too many notification channels");
+ } catch (IllegalStateException e) {
+ // great
+ }
+ }
+
+ @Test
+ public void testTooManyChannels_xml() throws Exception {
+ String extraChannel = "EXTRA";
+ String extraChannel1 = "EXTRA1";
+
+ // create first... many... directly so we don't need a big xml blob in this test
+ for (int i = 0; i < NOTIFICATION_CHANNEL_COUNT_LIMIT; i++) {
+ NotificationChannel channel = new NotificationChannel(String.valueOf(i),
+ String.valueOf(i), NotificationManager.IMPORTANCE_HIGH);
+ mHelper.createNotificationChannel(PKG_O, UID_O, channel, true, true);
+ }
+
+ final String xml = "<ranking version=\"1\">\n"
+ + "<package name=\"" + PKG_O + "\" uid=\"" + UID_O + "\" >\n"
+ + "<channel id=\"" + extraChannel + "\" name=\"hi\" importance=\"3\"/>"
+ + "<channel id=\"" + extraChannel1 + "\" name=\"hi\" importance=\"3\"/>"
+ + "</package>"
+ + "</ranking>";
+ XmlPullParser parser = Xml.newPullParser();
+ parser.setInput(new BufferedInputStream(new ByteArrayInputStream(xml.getBytes())),
+ null);
+ parser.nextTag();
+ mHelper.readXml(parser, false, UserHandle.USER_ALL);
+
+ assertNull(mHelper.getNotificationChannel(PKG_O, UID_O, extraChannel, true));
+ assertNull(mHelper.getNotificationChannel(PKG_O, UID_O, extraChannel1, true));
+ }
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
index 3d94467..07d9f80 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
@@ -341,7 +341,7 @@
doReturn(stack).when(mRootActivityContainer)
.getLaunchStack(any(), any(), any(), anyBoolean());
doReturn(stack).when(mRootActivityContainer)
- .getLaunchStack(any(), any(), any(), anyBoolean(), any());
+ .getLaunchStack(any(), any(), any(), anyBoolean(), any(), anyInt(), anyInt());
}
// Set up mock package manager internal and make sure no unmocked methods are called
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityTestsBase.java b/services/tests/wmtests/src/com/android/server/wm/ActivityTestsBase.java
index ecf3acd..84bdecb 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityTestsBase.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityTestsBase.java
@@ -40,6 +40,8 @@
import static com.android.server.wm.ActivityStack.REMOVE_TASK_MODE_DESTROYING;
import static com.android.server.wm.ActivityStackSupervisor.ON_TOP;
+import static org.mockito.ArgumentMatchers.eq;
+
import android.app.ActivityManagerInternal;
import android.app.ActivityOptions;
import android.app.AppOpsManager;
@@ -72,6 +74,7 @@
import com.android.server.am.PendingIntentController;
import com.android.server.appop.AppOpsService;
import com.android.server.firewall.IntentFirewall;
+import com.android.server.pm.UserManagerService;
import com.android.server.policy.PermissionPolicyInternal;
import com.android.server.uri.UriGrantsManagerInternal;
import com.android.server.wm.TaskRecord.TaskRecordFactory;
@@ -92,6 +95,7 @@
*/
class ActivityTestsBase {
private static int sNextDisplayId = DEFAULT_DISPLAY + 1;
+ private static final int[] TEST_USER_PROFILE_IDS = {};
@Rule
public final DexmakerShareClassLoaderRule mDexmakerShareClassLoaderRule =
@@ -204,6 +208,8 @@
private ActivityStack mStack;
private int mActivityFlags;
private int mLaunchMode;
+ private int mLaunchedFromPid;
+ private int mLaunchedFromUid;
ActivityBuilder(ActivityTaskManagerService service) {
mService = service;
@@ -254,6 +260,16 @@
return this;
}
+ ActivityBuilder setLaunchedFromPid(int pid) {
+ mLaunchedFromPid = pid;
+ return this;
+ }
+
+ ActivityBuilder setLaunchedFromUid(int uid) {
+ mLaunchedFromUid = uid;
+ return this;
+ }
+
ActivityRecord build() {
if (mComponent == null) {
final int id = sCurrentActivityId++;
@@ -281,10 +297,11 @@
aInfo.launchMode = mLaunchMode;
final ActivityRecord activity = new ActivityRecord(mService, null /* caller */,
- 0 /* launchedFromPid */, 0, null, intent, null,
- aInfo /*aInfo*/, new Configuration(), null /* resultTo */, null /* resultWho */,
- 0 /* reqCode */, false /*componentSpecified*/, false /* rootVoiceInteraction */,
- mService.mStackSupervisor, null /* options */, null /* sourceRecord */);
+ mLaunchedFromPid /* launchedFromPid */, mLaunchedFromUid /* launchedFromUid */,
+ null, intent, null, aInfo /*aInfo*/, new Configuration(), null /* resultTo */,
+ null /* resultWho */, 0 /* reqCode */, false /*componentSpecified*/,
+ false /* rootVoiceInteraction */, mService.mStackSupervisor,
+ null /* options */, null /* sourceRecord */);
spyOn(activity);
activity.mAppWindowToken = mock(AppWindowToken.class);
doCallRealMethod().when(activity.mAppWindowToken).getOrientationIgnoreVisibility();
@@ -471,6 +488,11 @@
// allow background activity starts by default
doReturn(true).when(this).isBackgroundActivityStartsEnabled();
doNothing().when(this).updateCpuStats();
+
+ // UserManager
+ final UserManagerService ums = mock(UserManagerService.class);
+ doReturn(ums).when(this).getUserManager();
+ doReturn(TEST_USER_PROFILE_IDS).when(ums).getProfileIds(anyInt(), eq(true));
}
void setup(IntentFirewall intentFirewall, PendingIntentController intentController,
diff --git a/services/tests/wmtests/src/com/android/server/wm/DimmerTests.java b/services/tests/wmtests/src/com/android/server/wm/DimmerTests.java
index 292a05b..a98f79c 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DimmerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DimmerTests.java
@@ -169,7 +169,7 @@
mDimmer.updateDims(mTransaction, new Rect());
verify(mTransaction).show(getDimLayer());
- verify(dimLayer, never()).remove();
+ verify(mTransaction, never()).remove(dimLayer);
}
@Test
@@ -231,7 +231,7 @@
mDimmer.updateDims(mTransaction, new Rect());
verify(mTransaction).show(dimLayer);
- verify(dimLayer, never()).remove();
+ verify(mTransaction, never()).remove(dimLayer);
}
@Test
diff --git a/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java b/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java
index a1999c90..e4f614d3 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java
@@ -62,6 +62,7 @@
import android.os.RemoteException;
import android.os.SystemClock;
import android.platform.test.annotations.Presubmit;
+import android.util.ArraySet;
import android.util.MutableLong;
import android.util.SparseBooleanArray;
@@ -952,7 +953,6 @@
public void testRecentsComponent_allowApiAccessWithoutPermissions() {
doReturn(PackageManager.PERMISSION_DENIED).when(mTestService)
.checkGetTasksPermission(anyString(), anyInt(), anyInt());
-
// Set the recents component and ensure that the following calls do not fail
mRecentTasks.setIsCallerRecentsOverride(TestRecentTasks.GRANT);
doTestRecentTasksApis(true /* expectNoSecurityException */);
@@ -1301,10 +1301,10 @@
@Override
void getTasks(int maxNum, List<RunningTaskInfo> list, int ignoreActivityType,
int ignoreWindowingMode, ArrayList<ActivityDisplay> activityDisplays,
- int callingUid, boolean allowed) {
+ int callingUid, boolean allowed, boolean crossUser, ArraySet<Integer> profileIds) {
mLastAllowed = allowed;
super.getTasks(maxNum, list, ignoreActivityType, ignoreWindowingMode, activityDisplays,
- callingUid, allowed);
+ callingUid, allowed, crossUser, profileIds);
}
}
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/RootActivityContainerTests.java b/services/tests/wmtests/src/com/android/server/wm/RootActivityContainerTests.java
index 8d2c3dd..baf1b08 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RootActivityContainerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RootActivityContainerTests.java
@@ -25,6 +25,7 @@
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
import static android.content.pm.ActivityInfo.FLAG_ALWAYS_FOCUSABLE;
import static android.view.Display.DEFAULT_DISPLAY;
+import static android.view.Display.TYPE_VIRTUAL;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock;
@@ -61,6 +62,7 @@
import android.graphics.Rect;
import android.platform.test.annotations.Presubmit;
import android.util.Pair;
+import android.view.DisplayInfo;
import androidx.test.filters.MediumTest;
@@ -817,6 +819,41 @@
}
/**
+ * Test that {@link RootActivityContainer#getLaunchStack} with the real caller id will get the
+ * expected stack when requesting the activity launch on the secondary display.
+ */
+ @Test
+ public void testGetLaunchStackWithRealCallerId() {
+ // Create a non-system owned virtual display.
+ final DisplayInfo info = new DisplayInfo();
+ mSupervisor.mService.mContext.getDisplay().getDisplayInfo(info);
+ info.type = TYPE_VIRTUAL;
+ info.ownerUid = 100;
+ final TestActivityDisplay secondaryDisplay = createNewActivityDisplay(info);
+ mRootActivityContainer.addChild(secondaryDisplay, POSITION_TOP);
+
+ // Create an activity with specify the original launch pid / uid.
+ final ActivityRecord r = new ActivityBuilder(mService).setLaunchedFromPid(200)
+ .setLaunchedFromUid(200).build();
+
+ // Simulate ActivityStarter to find a launch stack for requesting the activity to launch
+ // on the secondary display with realCallerId.
+ final ActivityOptions options = ActivityOptions.makeBasic();
+ options.setLaunchDisplayId(secondaryDisplay.mDisplayId);
+ options.setLaunchWindowingMode(WINDOWING_MODE_FULLSCREEN);
+ doReturn(true).when(mSupervisor).canPlaceEntityOnDisplay(secondaryDisplay.mDisplayId,
+ 300 /* test realCallerPid */, 300 /* test realCallerUid */, r.info);
+ final ActivityStack result = mRootActivityContainer.getLaunchStack(r, options,
+ null /* task */, true /* onTop */, null, 300 /* test realCallerPid */,
+ 300 /* test realCallerUid */);
+
+ // Assert that the stack is returned as expected.
+ assertNotNull(result);
+ assertEquals("The display ID of the stack should same as secondary display ",
+ secondaryDisplay.mDisplayId, result.mDisplayId);
+ }
+
+ /**
* Mock {@link RootActivityContainerTests#resolveHomeActivity} for returning consistent activity
* info for test cases (the original implementation will resolve from the real package manager).
*/
diff --git a/services/tests/wmtests/src/com/android/server/wm/RunningTasksTest.java b/services/tests/wmtests/src/com/android/server/wm/RunningTasksTest.java
index dc96480..3e316f6 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RunningTasksTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RunningTasksTest.java
@@ -29,6 +29,7 @@
import android.app.ActivityManager.RunningTaskInfo;
import android.content.ComponentName;
import android.platform.test.annotations.Presubmit;
+import android.util.ArraySet;
import androidx.test.filters.MediumTest;
@@ -45,6 +46,8 @@
@Presubmit
public class RunningTasksTest extends ActivityTestsBase {
+ private static final ArraySet<Integer> PROFILE_IDS = new ArraySet<>();
+
private RunningTasks mRunningTasks;
@Before
@@ -77,7 +80,8 @@
final int numFetchTasks = 5;
ArrayList<RunningTaskInfo> tasks = new ArrayList<>();
mRunningTasks.getTasks(5, tasks, ACTIVITY_TYPE_UNDEFINED, WINDOWING_MODE_UNDEFINED,
- displays, -1 /* callingUid */, true /* allowed */);
+ displays, -1 /* callingUid */, true /* allowed */, true /*crossUser */,
+ PROFILE_IDS);
assertThat(tasks).hasSize(numFetchTasks);
for (int i = 0; i < numFetchTasks; i++) {
assertEquals(numTasks - i - 1, tasks.get(i).id);
@@ -87,7 +91,8 @@
// and does not crash
tasks.clear();
mRunningTasks.getTasks(100, tasks, ACTIVITY_TYPE_UNDEFINED, WINDOWING_MODE_UNDEFINED,
- displays, -1 /* callingUid */, true /* allowed */);
+ displays, -1 /* callingUid */, true /* allowed */, true /* crossUser */,
+ PROFILE_IDS);
assertThat(tasks).hasSize(numTasks);
for (int i = 0; i < numTasks; i++) {
assertEquals(numTasks - i - 1, tasks.get(i).id);
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskStackChangedListenerTest.java b/services/tests/wmtests/src/com/android/server/wm/TaskStackChangedListenerTest.java
index 19fd93fe..6e41118 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskStackChangedListenerTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskStackChangedListenerTest.java
@@ -271,6 +271,54 @@
waitForCallback(singleTaskDisplayDrawnLatch);
}
+ @Test
+ public void testSingleTaskDisplayEmpty() throws Exception {
+ final Instrumentation instrumentation = getInstrumentation();
+
+ final CountDownLatch activityViewReadyLatch = new CountDownLatch(1);
+ final CountDownLatch activityViewDestroyedLatch = new CountDownLatch(1);
+ final CountDownLatch singleTaskDisplayDrawnLatch = new CountDownLatch(1);
+ final CountDownLatch singleTaskDisplayEmptyLatch = new CountDownLatch(1);
+
+ registerTaskStackChangedListener(new TaskStackListener() {
+ @Override
+ public void onSingleTaskDisplayDrawn(int displayId) throws RemoteException {
+ singleTaskDisplayDrawnLatch.countDown();
+ }
+ @Override
+ public void onSingleTaskDisplayEmpty(int displayId)
+ throws RemoteException {
+ singleTaskDisplayEmptyLatch.countDown();
+ }
+ });
+ final ActivityViewTestActivity activity =
+ (ActivityViewTestActivity) startTestActivity(ActivityViewTestActivity.class);
+ final ActivityView activityView = activity.getActivityView();
+ activityView.setCallback(new ActivityView.StateCallback() {
+ @Override
+ public void onActivityViewReady(ActivityView view) {
+ activityViewReadyLatch.countDown();
+ }
+
+ @Override
+ public void onActivityViewDestroyed(ActivityView view) {
+ activityViewDestroyedLatch.countDown();
+ }
+ });
+ waitForCallback(activityViewReadyLatch);
+
+ final Context context = instrumentation.getContext();
+ Intent intent = new Intent(context, ActivityInActivityView.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
+ activityView.startActivity(intent);
+ waitForCallback(singleTaskDisplayDrawnLatch);
+ assertEquals(1, singleTaskDisplayEmptyLatch.getCount());
+
+ activityView.release();
+ waitForCallback(activityViewDestroyedLatch);
+ waitForCallback(singleTaskDisplayEmptyLatch);
+ }
+
/**
* Starts the provided activity and returns the started instance.
*/
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java
index b93c994..acfc2ea 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java
@@ -114,16 +114,12 @@
@Test
public void testAddChildSetsSurfacePosition() {
try (MockSurfaceBuildingContainer top = new MockSurfaceBuildingContainer(mWm)) {
-
- final SurfaceControl.Transaction transaction = mock(SurfaceControl.Transaction.class);
- mWm.mTransactionFactory = () -> transaction;
-
WindowContainer child = new WindowContainer(mWm);
child.setBounds(1, 1, 10, 10);
- verify(transaction, never()).setPosition(any(), anyFloat(), anyFloat());
+ verify(mTransaction, never()).setPosition(any(), anyFloat(), anyFloat());
top.addChild(child, 0);
- verify(transaction, times(1)).setPosition(any(), eq(1.f), eq(1.f));
+ verify(mTransaction, times(1)).setPosition(any(), eq(1.f), eq(1.f));
}
}
diff --git a/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java b/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java
index 9933756..735b9a1 100644
--- a/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java
+++ b/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java
@@ -325,9 +325,8 @@
false /* Don't notify for synchronous calls */);
// Initialize power save, call active state monitoring logic.
- if (status == STATUS_OK && !mRecognitionRequested) {
+ if (status == STATUS_OK) {
initializeTelephonyAndPowerStateListeners();
- mRecognitionRequested = true;
}
return status;
@@ -481,6 +480,9 @@
if (unloadModel && modelData.isModelLoaded()) {
Slog.d(TAG, "Unloading previously loaded stale model.");
+ if (mModule == null) {
+ return STATUS_ERROR;
+ }
status = mModule.unloadSoundModel(modelData.getHandle());
MetricsLogger.count(mContext, "sth_unloading_stale_model", 1);
if (status != SoundTrigger.STATUS_OK) {
@@ -550,6 +552,9 @@
}
}
+ if (mModule == null) {
+ return STATUS_ERROR;
+ }
int status = mModule.unloadSoundModel(modelData.getHandle());
if (status != SoundTrigger.STATUS_OK) {
Slog.w(TAG, "unloadGenericSoundModel() call failed with " + status);
@@ -878,6 +883,7 @@
mContext.unregisterReceiver(mPowerSaveModeListener);
mPowerSaveModeListener = null;
}
+ mRecognitionRequested = false;
}
// Clears state for all models (generic and keyphrase).
@@ -924,6 +930,9 @@
}
private void initializeTelephonyAndPowerStateListeners() {
+ if (mRecognitionRequested) {
+ return;
+ }
long token = Binder.clearCallingIdentity();
try {
// Get the current call state synchronously for the first recognition.
@@ -941,6 +950,8 @@
}
mIsPowerSaveMode = mPowerManager.getPowerSaveState(ServiceType.SOUND)
.batterySaverEnabled;
+
+ mRecognitionRequested = true;
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -987,6 +998,9 @@
if (exception != null) {
Slog.e(TAG, "forceStopAndUnloadModel", exception);
}
+ if (mModule == null) {
+ return;
+ }
if (modelData.isModelStarted()) {
Slog.d(TAG, "Stopping previously started dangling model " + modelData.getHandle());
if (mModule.stopRecognition(modelData.getHandle()) != STATUS_OK) {
@@ -1093,6 +1107,13 @@
// a recognition include: no active phone call or not being in a power save mode. Also,
// the native service should be enabled.
private boolean isRecognitionAllowed() {
+ // if mRecognitionRequested is false, call and power state listeners are not registered so
+ // we read current state directly from services
+ if (!mRecognitionRequested) {
+ mCallActive = mTelephonyManager.getCallState() == TelephonyManager.CALL_STATE_OFFHOOK;
+ mIsPowerSaveMode =
+ mPowerManager.getPowerSaveState(ServiceType.SOUND).batterySaverEnabled;
+ }
return !mCallActive && !mServiceDisabled && !mIsPowerSaveMode;
}
@@ -1116,6 +1137,9 @@
return STATUS_OK;
}
+ if (mModule == null) {
+ return STATUS_ERROR;
+ }
int status = mModule.startRecognition(handle, config);
if (status != SoundTrigger.STATUS_OK) {
Slog.w(TAG, "startRecognition failed with " + status);
@@ -1152,8 +1176,11 @@
}
private int stopRecognitionLocked(ModelData modelData, boolean notify) {
- IRecognitionStatusCallback callback = modelData.getCallback();
+ if (mModule == null) {
+ return STATUS_ERROR;
+ }
+ IRecognitionStatusCallback callback = modelData.getCallback();
// Stop recognition.
int status = STATUS_OK;
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
index e1ffb0f..46d7509 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
@@ -1281,9 +1281,12 @@
RoleObserver(@NonNull @CallbackExecutor Executor executor) {
mRm.addOnRoleHoldersChangedListenerAsUser(executor, this, UserHandle.ALL);
- UserHandle currentUser = UserHandle.of(LocalServices.getService(
- ActivityManagerInternal.class).getCurrentUserId());
- onRoleHoldersChanged(RoleManager.ROLE_ASSISTANT, currentUser);
+ // Sync only if assistant role has been initialized.
+ if (mRm.isRoleAvailable(RoleManager.ROLE_ASSISTANT)) {
+ UserHandle currentUser = UserHandle.of(LocalServices.getService(
+ ActivityManagerInternal.class).getCurrentUserId());
+ onRoleHoldersChanged(RoleManager.ROLE_ASSISTANT, currentUser);
+ }
}
private @NonNull String getDefaultRecognizer(@NonNull UserHandle user) {
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java
index f16dec6..0ff9273 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java
@@ -194,7 +194,7 @@
if (!mFullyBound) {
mFullyBound = mContext.bindServiceAsUser(mBindIntent, mFullConnection,
Context.BIND_AUTO_CREATE | Context.BIND_TREAT_LIKE_ACTIVITY
- | Context.BIND_FOREGROUND_SERVICE
+ | Context.BIND_SCHEDULE_LIKE_TOP_APP
| Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS,
new UserHandle(mUser));
}
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index d675a21..0ed8775 100755
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -1416,6 +1416,13 @@
"read_only_apn_fields_string_array";
/**
+ * Default value of APN types field if not specified by user when adding/modifying an APN.
+ * @hide
+ */
+ public static final String KEY_APN_SETTINGS_DEFAULT_APN_TYPES_STRING_ARRAY =
+ "apn_settings_default_apn_types_string_array";
+
+ /**
* Boolean indicating if intent for emergency call state changes should be broadcast
* @hide
*/
@@ -2681,25 +2688,34 @@
"call_waiting_service_class_int";
/**
- * This configuration allow the system UI to display different 5G icon for different 5G status.
+ * This configuration allow the system UI to display different 5G icon for different 5G
+ * scenario.
*
- * There are four 5G status:
+ * There are five 5G scenarios:
* 1. connected_mmwave: device currently connected to 5G cell as the secondary cell and using
* millimeter wave.
* 2. connected: device currently connected to 5G cell as the secondary cell but not using
* millimeter wave.
- * 3. not_restricted: device camped on a network that has 5G capability(not necessary to connect
- * a 5G cell as a secondary cell) and the use of 5G is not restricted.
- * 4. restricted: device camped on a network that has 5G capability(not necessary to connect a
+ * 3. not_restricted_rrc_idle: device camped on a network that has 5G capability(not necessary
+ * to connect a 5G cell as a secondary cell) and the use of 5G is not restricted and RRC
+ * currently in IDLE state.
+ * 4. not_restricted_rrc_con: device camped on a network that has 5G capability(not necessary
+ * to connect a 5G cell as a secondary cell) and the use of 5G is not restricted and RRC
+ * currently in CONNECTED state.
+ * 5. restricted: device camped on a network that has 5G capability(not necessary to connect a
* 5G cell as a secondary cell) but the use of 5G is restricted.
*
* The configured string contains multiple key-value pairs separated by comma. For each pair,
* the key and value is separated by a colon. The key is corresponded to a 5G status above and
* the value is the icon name. Use "None" as the icon name if no icon should be shown in a
- * specific 5G status.
+ * specific 5G scenario. If the scenario is "None", config can skip this key and value.
*
- * Here is an example of the configuration:
- * "connected_mmwave:5GPlus,connected:5G,not_restricted:None,restricted:None"
+ * Icon name options: "5G_Plus", "5G".
+ *
+ * Here is an example:
+ * UE want to display 5G_Plus icon for scenario#1, and 5G icon for scenario#2; otherwise no
+ * define.
+ * The configuration is: "connected_mmwave:5G_Plus,connected:5G"
*
* @hide
*/
@@ -2707,6 +2723,22 @@
"5g_icon_configuration_string";
/**
+ * Timeout in second for displaying 5G icon, default value is 0 which means the timer is
+ * disabled.
+ *
+ * System UI will show the 5G icon and start a timer with the timeout from this config when the
+ * device connects to a 5G cell. System UI stops displaying 5G icon when both the device
+ * disconnects from 5G cell and the timer is expired.
+ *
+ * If 5G is reacquired during this timer, the timer is canceled and restarted when 5G is next
+ * lost. Allows us to momentarily lose 5G without blinking the icon.
+ *
+ * @hide
+ */
+ public static final String KEY_5G_ICON_DISPLAY_GRACE_PERIOD_SEC_INT =
+ "5g_icon_display_grace_period_sec_int";
+
+ /**
* Support ASCII 7-BIT encoding for long SMS. This carrier config is used to enable
* this feature.
* @hide
@@ -2758,12 +2790,28 @@
/**
* Controls hysteresis time in milli seconds for which OpportunisticNetworkService
- * will wait before switching data to a network.
+ * will wait before switching data to an opportunistic network.
*/
public static final String KEY_OPPORTUNISTIC_NETWORK_DATA_SWITCH_HYSTERESIS_TIME_LONG =
"opportunistic_network_data_switch_hysteresis_time_long";
/**
+ * Controls hysteresis time in milli seconds for which OpportunisticNetworkService
+ * will wait before switching data from opportunistic network to primary network.
+ * @hide
+ */
+ public static final String KEY_OPPORTUNISTIC_NETWORK_DATA_SWITCH_EXIT_HYSTERESIS_TIME_LONG =
+ "opportunistic_network_data_switch_exit_hysteresis_time_long";
+
+ /**
+ * Controls whether to do ping test before switching data to opportunistic network.
+ * This carrier config is used to disable this feature.
+ * @hide
+ */
+ public static final String KEY_PING_TEST_BEFORE_DATA_SWITCH_BOOL =
+ "ping_test_before_data_switch_bool";
+
+ /**
* Indicates zero or more emergency number prefix(es), because some carrier requires
* if users dial an emergency number address with a specific prefix, the combination of the
* prefix and the address is also a valid emergency number to dial. For example, an emergency
@@ -3133,6 +3181,13 @@
public static final String KEY_SUPPORT_WPS_OVER_IMS_BOOL =
"support_wps_over_ims_bool";
+ /**
+ * Holds the list of carrier certificate hashes. Note that each carrier has its own certificates
+ * @hide
+ */
+ public static final String KEY_CARRIER_CERTIFICATE_STRING_ARRAY =
+ "carrier_certificate_string_array";
+
/** The default value for every variable. */
private final static PersistableBundle sDefaults;
@@ -3250,6 +3305,7 @@
sDefaults.putBoolean(KEY_ALLOW_ADDING_APNS_BOOL, true);
sDefaults.putStringArray(KEY_READ_ONLY_APN_TYPES_STRING_ARRAY, new String[] {"dun"});
sDefaults.putStringArray(KEY_READ_ONLY_APN_FIELDS_STRING_ARRAY, null);
+ sDefaults.putStringArray(KEY_APN_SETTINGS_DEFAULT_APN_TYPES_STRING_ARRAY, null);
sDefaults.putBoolean(KEY_BROADCAST_EMERGENCY_CALL_STATE_CHANGES_BOOL, false);
sDefaults.putBoolean(KEY_ALWAYS_SHOW_EMERGENCY_ALERT_ONOFF_BOOL, false);
sDefaults.putBoolean(KEY_DISABLE_SEVERE_WHEN_EXTREME_DISABLED_BOOL, true);
@@ -3513,7 +3569,8 @@
sDefaults.putBoolean(KEY_USE_CALLER_ID_USSD_BOOL, false);
sDefaults.putInt(KEY_CALL_WAITING_SERVICE_CLASS_INT, 1 /* SERVICE_CLASS_VOICE */);
sDefaults.putString(KEY_5G_ICON_CONFIGURATION_STRING,
- "connected_mmwave:None,connected:5G,not_restricted:None,restricted:None");
+ "connected_mmwave:5G,connected:5G");
+ sDefaults.putInt(KEY_5G_ICON_DISPLAY_GRACE_PERIOD_SEC_INT, 0);
sDefaults.putBoolean(KEY_ASCII_7_BIT_SUPPORT_FOR_LONG_MESSAGE_BOOL, false);
/* Default value is minimum RSRP level needed for SIGNAL_STRENGTH_GOOD */
sDefaults.putInt(KEY_OPPORTUNISTIC_NETWORK_ENTRY_THRESHOLD_RSRP_INT, -108);
@@ -3529,6 +3586,9 @@
sDefaults.putLong(KEY_OPPORTUNISTIC_NETWORK_ENTRY_OR_EXIT_HYSTERESIS_TIME_LONG, 10000);
/* Default value is 10 seconds. */
sDefaults.putLong(KEY_OPPORTUNISTIC_NETWORK_DATA_SWITCH_HYSTERESIS_TIME_LONG, 10000);
+ /* Default value is 3 seconds. */
+ sDefaults.putLong(KEY_OPPORTUNISTIC_NETWORK_DATA_SWITCH_EXIT_HYSTERESIS_TIME_LONG, 3000);
+ sDefaults.putBoolean(KEY_PING_TEST_BEFORE_DATA_SWITCH_BOOL, true);
sDefaults.putAll(Gps.getDefaults());
sDefaults.putAll(Wifi.getDefaults());
sDefaults.putIntArray(KEY_CDMA_ENHANCED_ROAMING_INDICATOR_FOR_HOME_NETWORK_INT_ARRAY,
@@ -3538,7 +3598,7 @@
sDefaults.putStringArray(KEY_EMERGENCY_NUMBER_PREFIX_STRING_ARRAY, new String[0]);
sDefaults.putBoolean(KEY_USE_USIM_BOOL, false);
sDefaults.putBoolean(KEY_SHOW_WFC_LOCATION_PRIVACY_POLICY_BOOL, false);
- sDefaults.putBoolean(KEY_AUTO_CANCEL_CS_REJECT_NOTIFICATION, false);
+ sDefaults.putBoolean(KEY_AUTO_CANCEL_CS_REJECT_NOTIFICATION, true);
sDefaults.putString(KEY_SMART_FORWARDING_CONFIG_COMPONENT_NAME_STRING, "");
sDefaults.putBoolean(KEY_ALWAYS_SHOW_PRIMARY_SIGNAL_BAR_IN_OPPORTUNISTIC_NETWORK_BOOLEAN,
false);
@@ -3553,6 +3613,7 @@
});
sDefaults.putBoolean(KEY_SUPPORT_WPS_OVER_IMS_BOOL, true);
sDefaults.putAll(Ims.getDefaults());
+ sDefaults.putStringArray(KEY_CARRIER_CERTIFICATE_STRING_ARRAY, null);
}
/**
diff --git a/telephony/java/android/telephony/CellIdentity.java b/telephony/java/android/telephony/CellIdentity.java
index 258a873..432978d 100644
--- a/telephony/java/android/telephony/CellIdentity.java
+++ b/telephony/java/android/telephony/CellIdentity.java
@@ -17,6 +17,7 @@
package android.telephony;
import android.annotation.CallSuper;
+import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;
@@ -61,7 +62,7 @@
mType = type;
// Only allow INT_MAX if unknown string mcc/mnc
- if (mcc == null || mcc.matches("^[0-9]{3}$")) {
+ if (mcc == null || isMcc(mcc)) {
mMccStr = mcc;
} else if (mcc.isEmpty() || mcc.equals(String.valueOf(Integer.MAX_VALUE))) {
// If the mccStr is empty or unknown, set it as null.
@@ -73,7 +74,7 @@
log("invalid MCC format: " + mcc);
}
- if (mnc == null || mnc.matches("^[0-9]{2,3}$")) {
+ if (mnc == null || isMnc(mnc)) {
mMncStr = mnc;
} else if (mnc.isEmpty() || mnc.equals(String.valueOf(Integer.MAX_VALUE))) {
// If the mncStr is empty or unknown, set it as null.
@@ -262,4 +263,30 @@
if ((value < rangeMin || value > rangeMax) && value != special) return CellInfo.UNAVAILABLE;
return value;
}
+
+ /** @hide */
+ private static boolean isMcc(@NonNull String mcc) {
+ // ensure no out of bounds indexing
+ if (mcc.length() != 3) return false;
+
+ // Character.isDigit allows all unicode digits, not just [0-9]
+ for (int i = 0; i < 3; i++) {
+ if (mcc.charAt(i) < '0' || mcc.charAt(i) > '9') return false;
+ }
+
+ return true;
+ }
+
+ /** @hide */
+ private static boolean isMnc(@NonNull String mnc) {
+ // ensure no out of bounds indexing
+ if (mnc.length() < 2 || mnc.length() > 3) return false;
+
+ // Character.isDigit allows all unicode digits, not just [0-9]
+ for (int i = 0; i < mnc.length(); i++) {
+ if (mnc.charAt(i) < '0' || mnc.charAt(i) > '9') return false;
+ }
+
+ return true;
+ }
}
diff --git a/telephony/java/android/telephony/SubscriptionInfo.java b/telephony/java/android/telephony/SubscriptionInfo.java
index a8491d3..f527bc3 100644
--- a/telephony/java/android/telephony/SubscriptionInfo.java
+++ b/telephony/java/android/telephony/SubscriptionInfo.java
@@ -38,6 +38,7 @@
import android.util.DisplayMetrics;
import android.util.Log;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -147,7 +148,14 @@
* The access rules for this subscription, if it is embedded and defines any.
*/
@Nullable
- private UiccAccessRule[] mAccessRules;
+ private UiccAccessRule[] mNativeAccessRules;
+
+ /**
+ * The carrier certificates for this subscription that are saved in carrier configs.
+ * The other carrier certificates are embedded on Uicc and stored as part of mNativeAccessRules.
+ */
+ @Nullable
+ private UiccAccessRule[] mCarrierConfigAccessRules;
/**
* The string ID of the SIM card. It is the ICCID of the active profile for a UICC card and the
@@ -206,12 +214,12 @@
public SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName,
CharSequence carrierName, int nameSource, int iconTint, String number, int roaming,
Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded,
- @Nullable UiccAccessRule[] accessRules, String cardString) {
+ @Nullable UiccAccessRule[] nativeAccessRules, String cardString) {
this(id, iccId, simSlotIndex, displayName, carrierName, nameSource, iconTint, number,
- roaming, icon, mcc, mnc, countryIso, isEmbedded, accessRules, cardString, -1,
+ roaming, icon, mcc, mnc, countryIso, isEmbedded, nativeAccessRules, cardString, -1,
false, null, false, TelephonyManager.UNKNOWN_CARRIER_ID,
SubscriptionManager.PROFILE_CLASS_DEFAULT,
- SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, null);
+ SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, null, null);
}
/**
@@ -220,12 +228,12 @@
public SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName,
CharSequence carrierName, int nameSource, int iconTint, String number, int roaming,
Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded,
- @Nullable UiccAccessRule[] accessRules, String cardString, boolean isOpportunistic,
- @Nullable String groupUUID, int carrierId, int profileClass) {
+ @Nullable UiccAccessRule[] nativeAccessRules, String cardString,
+ boolean isOpportunistic, @Nullable String groupUUID, int carrierId, int profileClass) {
this(id, iccId, simSlotIndex, displayName, carrierName, nameSource, iconTint, number,
- roaming, icon, mcc, mnc, countryIso, isEmbedded, accessRules, cardString, -1,
+ roaming, icon, mcc, mnc, countryIso, isEmbedded, nativeAccessRules, cardString, -1,
isOpportunistic, groupUUID, false, carrierId, profileClass,
- SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, null);
+ SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, null, null);
}
/**
@@ -234,9 +242,10 @@
public SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName,
CharSequence carrierName, int nameSource, int iconTint, String number, int roaming,
Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded,
- @Nullable UiccAccessRule[] accessRules, String cardString, int cardId,
+ @Nullable UiccAccessRule[] nativeAccessRules, String cardString, int cardId,
boolean isOpportunistic, @Nullable String groupUUID, boolean isGroupDisabled,
- int carrierId, int profileClass, int subType, @Nullable String groupOwner) {
+ int carrierId, int profileClass, int subType, @Nullable String groupOwner,
+ @Nullable UiccAccessRule[] carrierConfigAccessRules) {
this.mId = id;
this.mIccId = iccId;
this.mSimSlotIndex = simSlotIndex;
@@ -251,7 +260,7 @@
this.mMnc = mnc;
this.mCountryIso = countryIso;
this.mIsEmbedded = isEmbedded;
- this.mAccessRules = accessRules;
+ this.mNativeAccessRules = nativeAccessRules;
this.mCardString = cardString;
this.mCardId = cardId;
this.mIsOpportunistic = isOpportunistic;
@@ -261,6 +270,7 @@
this.mProfileClass = profileClass;
this.mSubscriptionType = subType;
this.mGroupOwner = groupOwner;
+ this.mCarrierConfigAccessRules = carrierConfigAccessRules;
}
/**
@@ -541,7 +551,6 @@
*
* @param context Context of the application to check.
* @return whether the app is authorized to manage this subscription per its metadata.
- * @throws UnsupportedOperationException if this subscription is not embedded.
* @hide
* @deprecated - Do not use.
*/
@@ -557,26 +566,25 @@
* @param context Any context.
* @param packageName Package name of the app to check.
* @return whether the app is authorized to manage this subscription per its metadata.
- * @throws UnsupportedOperationException if this subscription is not embedded.
* @hide
* @deprecated - Do not use.
*/
@Deprecated
public boolean canManageSubscription(Context context, String packageName) {
- if (!isEmbedded()) {
- throw new UnsupportedOperationException("Not an embedded subscription");
- }
- if (mAccessRules == null) {
+ List<UiccAccessRule> allAccessRules = getAllAccessRules();
+ if (allAccessRules == null) {
return false;
}
PackageManager packageManager = context.getPackageManager();
PackageInfo packageInfo;
try {
- packageInfo = packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
+ packageInfo = packageManager.getPackageInfo(packageName,
+ PackageManager.GET_SIGNING_CERTIFICATES);
} catch (PackageManager.NameNotFoundException e) {
- throw new IllegalArgumentException("Unknown package: " + packageName, e);
+ Log.d("SubscriptionInfo", "canManageSubscription: Unknown package: " + packageName, e);
+ return false;
}
- for (UiccAccessRule rule : mAccessRules) {
+ for (UiccAccessRule rule : allAccessRules) {
if (rule.getCarrierPrivilegeStatus(packageInfo)
== TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
return true;
@@ -586,17 +594,33 @@
}
/**
- * @return the {@link UiccAccessRule}s dictating who is authorized to manage this subscription.
+ * @return the {@link UiccAccessRule}s that are stored in Uicc, dictating who
+ * is authorized to manage this subscription.
+ * TODO and fix it properly in R / master: either deprecate this and have 3 APIs
+ * native + carrier + all, or have this return all by default.
* @throws UnsupportedOperationException if this subscription is not embedded.
* @hide
*/
@SystemApi
public @Nullable List<UiccAccessRule> getAccessRules() {
- if (!isEmbedded()) {
- throw new UnsupportedOperationException("Not an embedded subscription");
+ if (mNativeAccessRules == null) return null;
+ return Arrays.asList(mNativeAccessRules);
+ }
+
+ /**
+ * @return the {@link UiccAccessRule}s that are both stored on Uicc and in carrierConfigs
+ * dictating who is authorized to manage this subscription.
+ * @hide
+ */
+ public @Nullable List<UiccAccessRule> getAllAccessRules() {
+ List<UiccAccessRule> merged = new ArrayList<>();
+ if (mNativeAccessRules != null) {
+ merged.addAll(getAccessRules());
}
- if (mAccessRules == null) return null;
- return Arrays.asList(mAccessRules);
+ if (mCarrierConfigAccessRules != null) {
+ merged.addAll(Arrays.asList(mCarrierConfigAccessRules));
+ }
+ return merged.isEmpty() ? null : merged;
}
/**
@@ -651,7 +675,7 @@
String countryIso = source.readString();
Bitmap iconBitmap = source.readParcelable(Bitmap.class.getClassLoader());
boolean isEmbedded = source.readBoolean();
- UiccAccessRule[] accessRules = source.createTypedArray(UiccAccessRule.CREATOR);
+ UiccAccessRule[] nativeAccessRules = source.createTypedArray(UiccAccessRule.CREATOR);
String cardString = source.readString();
int cardId = source.readInt();
boolean isOpportunistic = source.readBoolean();
@@ -663,11 +687,14 @@
String[] ehplmns = source.readStringArray();
String[] hplmns = source.readStringArray();
String groupOwner = source.readString();
+ UiccAccessRule[] carrierConfigAccessRules = source.createTypedArray(
+ UiccAccessRule.CREATOR);
SubscriptionInfo info = new SubscriptionInfo(id, iccId, simSlotIndex, displayName,
carrierName, nameSource, iconTint, number, dataRoaming, iconBitmap, mcc, mnc,
- countryIso, isEmbedded, accessRules, cardString, cardId, isOpportunistic,
- groupUUID, isGroupDisabled, carrierid, profileClass, subType, groupOwner);
+ countryIso, isEmbedded, nativeAccessRules, cardString, cardId, isOpportunistic,
+ groupUUID, isGroupDisabled, carrierid, profileClass, subType, groupOwner,
+ carrierConfigAccessRules);
info.setAssociatedPlmns(ehplmns, hplmns);
return info;
}
@@ -694,7 +721,7 @@
dest.writeString(mCountryIso);
dest.writeParcelable(mIconBitmap, flags);
dest.writeBoolean(mIsEmbedded);
- dest.writeTypedArray(mAccessRules, flags);
+ dest.writeTypedArray(mNativeAccessRules, flags);
dest.writeString(mCardString);
dest.writeInt(mCardId);
dest.writeBoolean(mIsOpportunistic);
@@ -706,6 +733,7 @@
dest.writeStringArray(mEhplmns);
dest.writeStringArray(mHplmns);
dest.writeString(mGroupOwner);
+ dest.writeTypedArray(mCarrierConfigAccessRules, flags);
}
@Override
@@ -736,9 +764,9 @@
+ " carrierId=" + mCarrierId + " displayName=" + mDisplayName
+ " carrierName=" + mCarrierName + " nameSource=" + mNameSource
+ " iconTint=" + mIconTint + " mNumber=" + Rlog.pii(Build.IS_DEBUGGABLE, mNumber)
- + " dataRoaming=" + mDataRoaming + " iconBitmap=" + mIconBitmap + " mcc=" + mMcc
- + " mnc=" + mMnc + " mCountryIso=" + mCountryIso + " isEmbedded=" + mIsEmbedded
- + " accessRules=" + Arrays.toString(mAccessRules)
+ + " dataRoaming=" + mDataRoaming + " iconBitmap=" + mIconBitmap + " mcc " + mMcc
+ + " mnc " + mMnc + "mCountryIso=" + mCountryIso + " isEmbedded " + mIsEmbedded
+ + " nativeAccessRules " + Arrays.toString(mNativeAccessRules)
+ " cardString=" + cardStringToPrint + " cardId=" + mCardId
+ " isOpportunistic=" + mIsOpportunistic + " mGroupUUID=" + mGroupUUID
+ " mIsGroupDisabled=" + mIsGroupDisabled
@@ -746,14 +774,15 @@
+ " ehplmns=" + Arrays.toString(mEhplmns)
+ " hplmns=" + Arrays.toString(mHplmns)
+ " subscriptionType=" + mSubscriptionType
- + " mGroupOwner=" + mGroupOwner + "}";
+ + " mGroupOwner=" + mGroupOwner
+ + " carrierConfigAccessRules=" + mCarrierConfigAccessRules + "}";
}
@Override
public int hashCode() {
return Objects.hash(mId, mSimSlotIndex, mNameSource, mIconTint, mDataRoaming, mIsEmbedded,
mIsOpportunistic, mGroupUUID, mIccId, mNumber, mMcc, mMnc,
- mCountryIso, mCardString, mCardId, mDisplayName, mCarrierName, mAccessRules,
+ mCountryIso, mCardString, mCardId, mDisplayName, mCarrierName, mNativeAccessRules,
mIsGroupDisabled, mCarrierId, mProfileClass, mGroupOwner);
}
@@ -789,7 +818,7 @@
&& Objects.equals(mGroupOwner, toCompare.mGroupOwner)
&& TextUtils.equals(mDisplayName, toCompare.mDisplayName)
&& TextUtils.equals(mCarrierName, toCompare.mCarrierName)
- && Arrays.equals(mAccessRules, toCompare.mAccessRules)
+ && Arrays.equals(mNativeAccessRules, toCompare.mNativeAccessRules)
&& mProfileClass == toCompare.mProfileClass
&& Arrays.equals(mEhplmns, toCompare.mEhplmns)
&& Arrays.equals(mHplmns, toCompare.mHplmns);
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index bd0f225..4fec98b 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -571,6 +571,16 @@
public static final String ACCESS_RULES = "access_rules";
/**
+ * TelephonyProvider column name for the encoded {@link UiccAccessRule}s from
+ * {@link UiccAccessRule#encodeRules} but for the rules that come from CarrierConfigs.
+ * Only present if there are access rules in CarrierConfigs
+ * <p>TYPE: BLOB
+ * @hide
+ */
+ public static final String ACCESS_RULES_FROM_CARRIER_CONFIGS =
+ "access_rules_from_carrier_configs";
+
+ /**
* TelephonyProvider column name identifying whether an embedded subscription is on a removable
* card. Such subscriptions are marked inaccessible as soon as the current card is removed.
* Otherwise, they will remain accessible unless explicitly deleted. Only present if
@@ -2583,7 +2593,6 @@
*
* @param info The subscription to check.
* @return whether the app is authorized to manage this subscription per its metadata.
- * @throws IllegalArgumentException if this subscription is not embedded.
*/
public boolean canManageSubscription(SubscriptionInfo info) {
return canManageSubscription(info, mContext.getPackageName());
@@ -2599,24 +2608,22 @@
* @param info The subscription to check.
* @param packageName Package name of the app to check.
* @return whether the app is authorized to manage this subscription per its access rules.
- * @throws IllegalArgumentException if this subscription is not embedded.
* @hide
*/
public boolean canManageSubscription(SubscriptionInfo info, String packageName) {
- if (!info.isEmbedded()) {
- throw new IllegalArgumentException("Not an embedded subscription");
- }
- if (info.getAccessRules() == null) {
+ if (info == null || info.getAllAccessRules() == null) {
return false;
}
PackageManager packageManager = mContext.getPackageManager();
PackageInfo packageInfo;
try {
- packageInfo = packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
+ packageInfo = packageManager.getPackageInfo(packageName,
+ PackageManager.GET_SIGNING_CERTIFICATES);
} catch (PackageManager.NameNotFoundException e) {
- throw new IllegalArgumentException("Unknown package: " + packageName, e);
+ logd("Unknown package: " + packageName);
+ return false;
}
- for (UiccAccessRule rule : info.getAccessRules()) {
+ for (UiccAccessRule rule : info.getAllAccessRules()) {
if (rule.getCarrierPrivilegeStatus(packageInfo)
== TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
return true;
@@ -3007,7 +3014,7 @@
// to the caller.
boolean hasCarrierPrivilegePermission = TelephonyManager.from(mContext)
.hasCarrierPrivileges(info.getSubscriptionId())
- || (info.isEmbedded() && canManageSubscription(info));
+ || canManageSubscription(info);
return hasCarrierPrivilegePermission;
}
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index e735033..484b407 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -11167,6 +11167,8 @@
* The {@link #EXTRA_NETWORK_COUNTRY} extra indicates the country code of the current
* network returned by {@link #getNetworkCountryIso()}.
*
+ * <p>There may be a delay of several minutes before reporting that no country is detected.
+ *
* @see #EXTRA_NETWORK_COUNTRY
* @see #getNetworkCountryIso()
*/
diff --git a/telephony/java/android/telephony/UiccAccessRule.java b/telephony/java/android/telephony/UiccAccessRule.java
index 811722f..93ccba1 100644
--- a/telephony/java/android/telephony/UiccAccessRule.java
+++ b/telephony/java/android/telephony/UiccAccessRule.java
@@ -20,6 +20,7 @@
import android.annotation.SystemApi;
import android.content.pm.PackageInfo;
import android.content.pm.Signature;
+import android.content.pm.SigningInfo;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
@@ -169,17 +170,28 @@
*
* @param packageInfo package info fetched from
* {@link android.content.pm.PackageManager#getPackageInfo}.
- * {@link android.content.pm.PackageManager#GET_SIGNATURES} must have been passed in.
+ * {@link android.content.pm.PackageManager#GET_SIGNING_CERTIFICATES} must have been
+ * passed in.
* @return either {@link TelephonyManager#CARRIER_PRIVILEGE_STATUS_HAS_ACCESS} or
* {@link TelephonyManager#CARRIER_PRIVILEGE_STATUS_NO_ACCESS}.
*/
public int getCarrierPrivilegeStatus(PackageInfo packageInfo) {
- if (packageInfo.signatures == null || packageInfo.signatures.length == 0) {
- throw new IllegalArgumentException(
- "Must use GET_SIGNATURES when looking up package info");
+ Signature[] signatures = packageInfo.signatures;
+ SigningInfo sInfo = packageInfo.signingInfo;
+
+ if (sInfo != null) {
+ signatures = sInfo.getSigningCertificateHistory();
+ if (sInfo.hasMultipleSigners()) {
+ signatures = sInfo.getApkContentsSigners();
+ }
}
- for (Signature sig : packageInfo.signatures) {
+ if (signatures == null || signatures.length == 0) {
+ throw new IllegalArgumentException(
+ "Must use GET_SIGNING_CERTIFICATES when looking up package info");
+ }
+
+ for (Signature sig : signatures) {
int accessStatus = getCarrierPrivilegeStatus(sig, packageInfo.packageName);
if (accessStatus != TelephonyManager.CARRIER_PRIVILEGE_STATUS_NO_ACCESS) {
return accessStatus;
diff --git a/tests/testables/src/android/testing/DexmakerShareClassLoaderRule.java b/tests/testables/src/android/testing/DexmakerShareClassLoaderRule.java
index 1b8e58c..7057a90 100644
--- a/tests/testables/src/android/testing/DexmakerShareClassLoaderRule.java
+++ b/tests/testables/src/android/testing/DexmakerShareClassLoaderRule.java
@@ -20,6 +20,8 @@
import com.android.internal.annotations.VisibleForTesting;
+import libcore.util.SneakyThrow;
+
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
@@ -55,7 +57,11 @@
* WARNING: This is absolutely incompatible with running tests in parallel!
*/
public static void runWithDexmakerShareClassLoader(Runnable r) {
- apply(r::run).run();
+ try {
+ apply(r::run).run();
+ } catch (Throwable t) {
+ SneakyThrow.sneakyThrow(t);
+ }
}
/**