Merge "Fix broken test RecoverySnapshotStorageTest" into pi-dev
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 4cb7f89..3015398 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -8610,6 +8610,7 @@
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
@UserProvisioningState
public int getUserProvisioningState() {
throwIfParentInstance("getUserProvisioningState");
@@ -8754,6 +8755,7 @@
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
public boolean isDeviceProvisioned() {
try {
return mService.isDeviceProvisioned();
@@ -9418,7 +9420,21 @@
* <p>This method may returns {@code -1} if {@code apnSetting} conflicts with an existing
* override APN. Update the existing conflicted APN with
* {@link #updateOverrideApn(ComponentName, int, ApnSetting)} instead of adding a new entry.
- * <p>See {@link ApnSetting} for the definition of conflict.
+ * <p>Two override APNs are considered to conflict when all the following APIs return
+ * the same values on both override APNs:
+ * <ul>
+ * <li>{@link ApnSetting#getOperatorNumeric()}</li>
+ * <li>{@link ApnSetting#getApnName()}</li>
+ * <li>{@link ApnSetting#getProxyAddress()}</li>
+ * <li>{@link ApnSetting#getProxyPort()}</li>
+ * <li>{@link ApnSetting#getMmsProxyAddress()}</li>
+ * <li>{@link ApnSetting#getMmsProxyPort()}</li>
+ * <li>{@link ApnSetting#getMmsc()}</li>
+ * <li>{@link ApnSetting#isEnabled()}</li>
+ * <li>{@link ApnSetting#getMvnoType()}</li>
+ * <li>{@link ApnSetting#getProtocol()}</li>
+ * <li>{@link ApnSetting#getRoamingProtocol()}</li>
+ * </ul>
*
* @param admin which {@link DeviceAdminReceiver} this request is associated with
* @param apnSetting the override APN to insert
@@ -9447,7 +9463,7 @@
* {@code apnId}.
* <p>This method may also returns {@code false} if {@code apnSetting} conflicts with an
* existing override APN. Update the existing conflicted APN instead.
- * <p>See {@link ApnSetting} for the definition of conflict.
+ * <p>See {@link #addOverrideApn} for the definition of conflict.
*
* @param admin which {@link DeviceAdminReceiver} this request is associated with
* @param apnId the {@code id} of the override APN to update
diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java
index 387a836..e85058d 100644
--- a/core/java/android/content/pm/ApplicationInfo.java
+++ b/core/java/android/content/pm/ApplicationInfo.java
@@ -1101,6 +1101,58 @@
/** @hide */
public String[] splitClassLoaderNames;
+ /**
+ * Represents the default policy. The actual policy used will depend on other properties of
+ * the application, e.g. the target SDK version.
+ * @hide
+ */
+ public static final int HIDDEN_API_ENFORCEMENT_DEFAULT = -1;
+ /**
+ * No API enforcement; the app can access the entire internal private API. Only for use by
+ * system apps.
+ * @hide
+ */
+ public static final int HIDDEN_API_ENFORCEMENT_NONE = 0;
+ /**
+ * Light grey list enforcement, the strictest option. Enforces the light grey, dark grey and
+ * black lists.
+ * @hide
+ * */
+ public static final int HIDDEN_API_ENFORCEMENT_ALL_LISTS = 1;
+ /**
+ * Dark grey list enforcement. Enforces the dark grey and black lists
+ * @hide
+ */
+ public static final int HIDDEN_API_ENFORCEMENT_DARK_GREY_AND_BLACK = 2;
+ /**
+ * Blacklist enforcement only.
+ * @hide
+ */
+ public static final int HIDDEN_API_ENFORCEMENT_BLACK = 3;
+
+ private static final int HIDDEN_API_ENFORCEMENT_MAX = HIDDEN_API_ENFORCEMENT_BLACK;
+
+ /**
+ * Values in this IntDef MUST be kept in sync with enum hiddenapi::EnforcementPolicy in
+ * art/runtime/hidden_api.h
+ * @hide
+ */
+ @IntDef(prefix = { "HIDDEN_API_ENFORCEMENT_" }, value = {
+ HIDDEN_API_ENFORCEMENT_DEFAULT,
+ HIDDEN_API_ENFORCEMENT_NONE,
+ HIDDEN_API_ENFORCEMENT_ALL_LISTS,
+ HIDDEN_API_ENFORCEMENT_DARK_GREY_AND_BLACK,
+ HIDDEN_API_ENFORCEMENT_BLACK,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface HiddenApiEnforcementPolicy {}
+
+ private boolean isValidHiddenApiEnforcementPolicy(int policy) {
+ return policy >= HIDDEN_API_ENFORCEMENT_DEFAULT && policy <= HIDDEN_API_ENFORCEMENT_MAX;
+ }
+
+ private int mHiddenApiPolicy = HIDDEN_API_ENFORCEMENT_DEFAULT;
+
public void dump(Printer pw, String prefix) {
dump(pw, prefix, DUMP_FLAG_ALL);
}
@@ -1188,7 +1240,7 @@
if (category != CATEGORY_UNDEFINED) {
pw.println(prefix + "category=" + category);
}
- pw.println(prefix + "isAllowedToUseHiddenApi=" + isAllowedToUseHiddenApi());
+ pw.println(prefix + "HiddenApiEnforcementPolicy=" + getHiddenApiEnforcementPolicy());
}
super.dumpBack(pw, prefix);
}
@@ -1386,6 +1438,7 @@
appComponentFactory = orig.appComponentFactory;
compileSdkVersion = orig.compileSdkVersion;
compileSdkVersionCodename = orig.compileSdkVersionCodename;
+ mHiddenApiPolicy = orig.mHiddenApiPolicy;
}
public String toString() {
@@ -1459,6 +1512,7 @@
dest.writeInt(compileSdkVersion);
dest.writeString(compileSdkVersionCodename);
dest.writeString(appComponentFactory);
+ dest.writeInt(mHiddenApiPolicy);
}
public static final Parcelable.Creator<ApplicationInfo> CREATOR
@@ -1529,6 +1583,7 @@
compileSdkVersion = source.readInt();
compileSdkVersionCodename = source.readString();
appComponentFactory = source.readString();
+ mHiddenApiPolicy = source.readInt();
}
/**
@@ -1599,13 +1654,31 @@
}
}
+ private boolean isPackageWhitelistedForHiddenApis() {
+ return SystemConfig.getInstance().getHiddenApiWhitelistedApps().contains(packageName);
+ }
+
/**
* @hide
*/
- public boolean isAllowedToUseHiddenApi() {
- boolean whitelisted =
- SystemConfig.getInstance().getHiddenApiWhitelistedApps().contains(packageName);
- return whitelisted && (isSystemApp() || isUpdatedSystemApp());
+ public @HiddenApiEnforcementPolicy int getHiddenApiEnforcementPolicy() {
+ if (mHiddenApiPolicy != HIDDEN_API_ENFORCEMENT_DEFAULT) {
+ return mHiddenApiPolicy;
+ }
+ if (isPackageWhitelistedForHiddenApis() && (isSystemApp() || isUpdatedSystemApp())) {
+ return HIDDEN_API_ENFORCEMENT_NONE;
+ }
+ return HIDDEN_API_ENFORCEMENT_BLACK;
+ }
+
+ /**
+ * @hide
+ */
+ public void setHiddenApiEnforcementPolicy(@HiddenApiEnforcementPolicy int policy) {
+ if (!isValidHiddenApiEnforcementPolicy(policy)) {
+ throw new IllegalArgumentException("Invalid API enforcement policy: " + policy);
+ }
+ mHiddenApiPolicy = policy;
}
/**
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index b58e5b3..9ecae8c 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -1348,10 +1348,18 @@
= "android.settings.NOTIFICATION_SETTINGS";
/**
+ * Activity Action: Show app listing settings, filtered by those that send notifications.
+ *
+ * @hide
+ */
+ @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
+ public static final String ACTION_ALL_APPS_NOTIFICATION_SETTINGS =
+ "android.settings.ALL_APPS_NOTIFICATION_SETTINGS";
+
+ /**
* Activity Action: Show notification settings for a single app.
* <p>
- * Input: {@link #EXTRA_APP_PACKAGE}, the package containing the channel to display.
- * Input: Optionally, {@link #EXTRA_CHANNEL_ID}, to highlight that channel.
+ * Input: {@link #EXTRA_APP_PACKAGE}, the package to display.
* <p>
* Output: Nothing.
*/
diff --git a/core/java/com/android/internal/os/Zygote.java b/core/java/com/android/internal/os/Zygote.java
index 28a7c12..cbd3ad5 100644
--- a/core/java/com/android/internal/os/Zygote.java
+++ b/core/java/com/android/internal/os/Zygote.java
@@ -53,10 +53,21 @@
public static final int DISABLE_VERIFIER = 1 << 9;
/** Only use oat files located in /system. Otherwise use dex/jar/apk . */
public static final int ONLY_USE_SYSTEM_OAT_FILES = 1 << 10;
- /** Do enfore hidden API access restrictions. */
- public static final int ENABLE_HIDDEN_API_CHECKS = 1 << 11;
/** Force generation of native debugging information for backtraces. */
- public static final int DEBUG_GENERATE_MINI_DEBUG_INFO = 1 << 12;
+ public static final int DEBUG_GENERATE_MINI_DEBUG_INFO = 1 << 11;
+ /**
+ * Hidden API access restrictions. This is a mask for bits representing the API enforcement
+ * policy, defined by {@code @ApplicationInfo.HiddenApiEnforcementPolicy}.
+ */
+ public static final int API_ENFORCEMENT_POLICY_MASK = (1 << 12) | (1 << 13);
+ /**
+ * Bit shift for use with {@link #API_ENFORCEMENT_POLICY_MASK}.
+ *
+ * (flags & API_ENFORCEMENT_POLICY_MASK) >> API_ENFORCEMENT_POLICY_SHIFT gives
+ * @ApplicationInfo.ApiEnforcementPolicy values.
+ */
+ public static final int API_ENFORCEMENT_POLICY_SHIFT =
+ Integer.numberOfTrailingZeros(API_ENFORCEMENT_POLICY_MASK);
/** No external storage should be mounted. */
public static final int MOUNT_EXTERNAL_NONE = IVold.REMOUNT_MODE_NONE;
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 55c17b9..b5e223c 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -1340,6 +1340,30 @@
<integer-array name="config_autoBrightnessKeyboardBacklightValues">
</integer-array>
+ <!-- Array of light sensor lux values to define the minimum brightness curve, which guarantees
+ that any curve that dips below it is rejected by the system.
+ This prevents auto-brightness from setting the screen so dark as to prevent the user from
+ disabling auto-brightness or reseting the brightness curve via ADB.
+
+ The control points must be strictly increasing. Each control point corresponds to an entry
+ in the minimum brightness nits array. -->
+ <integer-array name="config_autoBrightnessMinimumBrightnessCurveLux">
+ <item>2000</item>
+ <item>4000</item>
+ </integer-array>
+
+ <!-- Array of desired screen brightness in nits corresponding to the lux values
+ in the config_autoBrightnessMinimumBrightnessCurveLux array.
+
+ This array should have size one greater than the size of the
+ config_autoBrightnessMinimumBrightnessCurveLux array. The values must be non-negative and
+ non-decreasing. -->
+ <array name="config_autoBrightnessMinimumBrightnessCurveNits">
+ <item>1.0</item>
+ <item>50.0</item>
+ <item>90.0</item>
+ </array>
+
<!-- Array of hysteresis constraint values for brightening, represented as tenths of a
percent. The length of this array is assumed to be one greater than
config_dynamicHysteresisLuxLevels. The brightening threshold is calculated as
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 75f8013..5eeb418 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1794,6 +1794,8 @@
<java-symbol type="array" name="config_autoBrightnessKeyboardBacklightValues" />
<java-symbol type="array" name="config_autoBrightnessLcdBacklightValues" />
<java-symbol type="array" name="config_autoBrightnessLevels" />
+ <java-symbol type="array" name="config_autoBrightnessMinimumBrightnessCurveLux" />
+ <java-symbol type="array" name="config_autoBrightnessMinimumBrightnessCurveNits" />
<java-symbol type="array" name="config_dynamicHysteresisBrightLevels" />
<java-symbol type="array" name="config_dynamicHysteresisDarkLevels" />
<java-symbol type="array" name="config_dynamicHysteresisLuxLevels" />
diff --git a/data/keyboards/Android.mk b/data/keyboards/Android.mk
index 2daef0c..7949c77 100644
--- a/data/keyboards/Android.mk
+++ b/data/keyboards/Android.mk
@@ -28,7 +28,7 @@
validatekeymaps := $(HOST_OUT_EXECUTABLES)/validatekeymaps$(HOST_EXECUTABLE_SUFFIX)
$(LOCAL_BUILT_MODULE): PRIVATE_VALIDATEKEYMAPS := $(validatekeymaps)
$(LOCAL_BUILT_MODULE) : $(framework_keylayouts) $(framework_keycharmaps) $(framework_keyconfigs) | $(validatekeymaps)
- $(hide) -q $(PRIVATE_VALIDATEKEYMAPS) $^
+ $(hide) $(PRIVATE_VALIDATEKEYMAPS) -q $^
$(hide) mkdir -p $(dir $@) && touch $@
# Run validatekeymaps uncondionally for platform build.
diff --git a/graphics/java/android/graphics/drawable/AnimatedImageDrawable.java b/graphics/java/android/graphics/drawable/AnimatedImageDrawable.java
index 457e4aa..898939e 100644
--- a/graphics/java/android/graphics/drawable/AnimatedImageDrawable.java
+++ b/graphics/java/android/graphics/drawable/AnimatedImageDrawable.java
@@ -52,8 +52,20 @@
/**
* {@link Drawable} for drawing animated images (like GIF).
*
+ * <p>The framework handles decoding subsequent frames in another thread and
+ * updating when necessary. The drawable will only animate while it is being
+ * displayed.</p>
+ *
* <p>Created by {@link ImageDecoder#decodeDrawable}. A user needs to call
* {@link #start} to start the animation.</p>
+ *
+ * <p>It can also be defined in XML using the <code><animated-image></code>
+ * element.</p>
+ *
+ * @attr ref android.R.styleable#AnimatedImageDrawable_src
+ * @attr ref android.R.styleable#AnimatedImageDrawable_autoStart
+ * @attr ref android.R.styleable#AnimatedImageDrawable_repeatCount
+ * @attr ref android.R.styleable#AnimatedImageDrawable_autoMirrored
*/
public class AnimatedImageDrawable extends Drawable implements Animatable2 {
private int mIntrinsicWidth;
@@ -456,8 +468,8 @@
* <p>Does nothing if the animation is already running. If the animation is stopped,
* this will reset it.</p>
*
- * <p>If the animation starts, this will call
- * {@link Animatable2.AnimationCallback#onAnimationStart}.</p>
+ * <p>When the drawable is drawn, starting the animation,
+ * {@link Animatable2.AnimationCallback#onAnimationStart} will be called.</p>
*/
@Override
public void start() {
diff --git a/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java b/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java
index 4db0034..7828c4c 100644
--- a/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java
+++ b/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java
@@ -42,6 +42,7 @@
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
+import android.webkit.CookieManager;
import android.webkit.SslErrorHandler;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
@@ -147,6 +148,7 @@
final WebView webview = getWebview();
webview.clearCache(true);
+ CookieManager.getInstance().setAcceptThirdPartyCookies(webview, true);
WebSettings webSettings = webview.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
diff --git a/packages/SettingsLib/res/values/strings.xml b/packages/SettingsLib/res/values/strings.xml
index 24a6804..584fc34 100644
--- a/packages/SettingsLib/res/values/strings.xml
+++ b/packages/SettingsLib/res/values/strings.xml
@@ -97,6 +97,12 @@
<!-- Summary for Connected wifi network without internet -->
<string name="wifi_connected_no_internet">Connected, no internet</string>
+ <!-- Wi-Fi status indicating that the current network is connected, but has no internet access. -->
+ <string name="wifi_status_no_internet">No internet</string>
+
+ <!-- Wi-Fi status indicating that the current network is connected requires sign in to access the internet. -->
+ <string name="wifi_status_sign_in_required">Sign in required</string>
+
<!-- Summary for networks failing to connect due to association rejection status 17, AP full -->
<string name="wifi_ap_unable_to_handle_new_sta">Access point temporarily full</string>
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
index c5c1169..78045f9 100644
--- a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
+++ b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
@@ -1154,7 +1154,7 @@
@Nullable
@Speed
- private int roundToClosestSpeedEnum(int speed) {
+ private static int roundToClosestSpeedEnum(int speed) {
if (speed < Speed.SLOW) {
return Speed.NONE;
} else if (speed < (Speed.SLOW + Speed.MODERATE) / 2) {
@@ -1170,21 +1170,31 @@
@Nullable
String getSpeedLabel(@Speed int speed) {
+ return getSpeedLabel(mContext, speed);
+ }
+
+ private static String getSpeedLabel(Context context, int speed) {
switch (speed) {
case Speed.VERY_FAST:
- return mContext.getString(R.string.speed_label_very_fast);
+ return context.getString(R.string.speed_label_very_fast);
case Speed.FAST:
- return mContext.getString(R.string.speed_label_fast);
+ return context.getString(R.string.speed_label_fast);
case Speed.MODERATE:
- return mContext.getString(R.string.speed_label_okay);
+ return context.getString(R.string.speed_label_okay);
case Speed.SLOW:
- return mContext.getString(R.string.speed_label_slow);
+ return context.getString(R.string.speed_label_slow);
case Speed.NONE:
default:
return null;
}
}
+ /** Return the speed label for a {@link ScoredNetwork} at the specified {@code rssi} level. */
+ @Nullable
+ public static String getSpeedLabel(Context context, ScoredNetwork scoredNetwork, int rssi) {
+ return getSpeedLabel(context, roundToClosestSpeedEnum(scoredNetwork.calculateBadge(rssi)));
+ }
+
/** Return true if the current RSSI is reachable, and false otherwise. */
public boolean isReachable() {
return mRssi != UNREACHABLE_RSSI;
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiStatusTracker.java b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiStatusTracker.java
index 6e12e20..4cd23f9 100644
--- a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiStatusTracker.java
+++ b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiStatusTracker.java
@@ -10,28 +10,90 @@
package com.android.settingslib.wifi;
+import static android.net.NetworkCapabilities.NET_CAPABILITY_CAPTIVE_PORTAL;
+import static android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED;
+
+import android.content.Context;
import android.content.Intent;
+import android.net.ConnectivityManager;
+import android.net.Network;
+import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
+import android.net.NetworkKey;
+import android.net.NetworkRequest;
+import android.net.NetworkScoreManager;
+import android.net.ScoredNetwork;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
+import android.net.wifi.WifiNetworkScoreCache;
import android.net.wifi.WifiSsid;
+import android.os.Handler;
+import android.os.Looper;
+
+import com.android.settingslib.R;
import java.util.List;
-public class WifiStatusTracker {
-
+public class WifiStatusTracker extends ConnectivityManager.NetworkCallback {
+ private final Context mContext;
+ private final WifiNetworkScoreCache mWifiNetworkScoreCache;
private final WifiManager mWifiManager;
+ private final NetworkScoreManager mNetworkScoreManager;
+ private final ConnectivityManager mConnectivityManager;
+ private final WifiNetworkScoreCache.CacheListener mCacheListener =
+ new WifiNetworkScoreCache.CacheListener(new Handler(Looper.getMainLooper())) {
+ @Override
+ public void networkCacheUpdated(List<ScoredNetwork> updatedNetworks) {
+ updateStatusLabel();
+ mCallback.run();
+ }
+ };
+ private final NetworkRequest mNetworkRequest = new NetworkRequest.Builder()
+ .clearCapabilities().addTransportType(NetworkCapabilities.TRANSPORT_WIFI).build();
+ private final ConnectivityManager.NetworkCallback mNetworkCallback = new ConnectivityManager
+ .NetworkCallback() {
+ @Override
+ public void onCapabilitiesChanged(
+ Network network, NetworkCapabilities networkCapabilities) {
+ updateStatusLabel();
+ mCallback.run();
+ }
+ };
+ private final Runnable mCallback;
+
+ private WifiInfo mWifiInfo;
public boolean enabled;
public int state;
public boolean connected;
- public boolean connecting;
public String ssid;
public int rssi;
public int level;
+ public String statusLabel;
- public WifiStatusTracker(WifiManager wifiManager) {
+ public WifiStatusTracker(Context context, WifiManager wifiManager,
+ NetworkScoreManager networkScoreManager, ConnectivityManager connectivityManager,
+ Runnable callback) {
+ mContext = context;
mWifiManager = wifiManager;
+ mWifiNetworkScoreCache = new WifiNetworkScoreCache(context);
+ mNetworkScoreManager = networkScoreManager;
+ mConnectivityManager = connectivityManager;
+ mCallback = callback;
+ }
+
+ public void setListening(boolean listening) {
+ if (listening) {
+ mNetworkScoreManager.registerNetworkScoreCache(NetworkKey.TYPE_WIFI,
+ mWifiNetworkScoreCache, NetworkScoreManager.CACHE_FILTER_CURRENT_NETWORK);
+ mWifiNetworkScoreCache.registerListener(mCacheListener);
+ mConnectivityManager.registerNetworkCallback(mNetworkRequest, mNetworkCallback);
+ } else {
+ mNetworkScoreManager.unregisterNetworkScoreCache(NetworkKey.TYPE_WIFI,
+ mWifiNetworkScoreCache);
+ mWifiNetworkScoreCache.unregisterListener();
+ mConnectivityManager.unregisterNetworkCallback(mNetworkCallback);
+ }
}
public void handleBroadcast(Intent intent) {
@@ -40,34 +102,59 @@
state = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
WifiManager.WIFI_STATE_UNKNOWN);
enabled = state == WifiManager.WIFI_STATE_ENABLED;
-
-
- enabled = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
- WifiManager.WIFI_STATE_UNKNOWN) == WifiManager.WIFI_STATE_ENABLED;
} else if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
- final NetworkInfo networkInfo = (NetworkInfo)
+ final NetworkInfo networkInfo =
intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
- connecting = networkInfo != null && !networkInfo.isConnected()
- && networkInfo.isConnectedOrConnecting();
connected = networkInfo != null && networkInfo.isConnected();
- // If Connected grab the signal strength and ssid.
+ mWifiInfo = null;
+ ssid = null;
if (connected) {
- WifiInfo info = mWifiManager.getConnectionInfo();
- if (info != null) {
- ssid = getValidSsid(info);
- } else {
- ssid = null;
+ mWifiInfo = mWifiManager.getConnectionInfo();
+ if (mWifiInfo != null) {
+ ssid = getValidSsid(mWifiInfo);
+ updateRssi(mWifiInfo.getRssi());
+ maybeRequestNetworkScore();
}
- } else if (!connected) {
- ssid = null;
}
+ updateStatusLabel();
} else if (action.equals(WifiManager.RSSI_CHANGED_ACTION)) {
// Default to -200 as its below WifiManager.MIN_RSSI.
- rssi = intent.getIntExtra(WifiManager.EXTRA_NEW_RSSI, -200);
- level = WifiManager.calculateSignalLevel(rssi, 5);
+ updateRssi(intent.getIntExtra(WifiManager.EXTRA_NEW_RSSI, -200));
+ updateStatusLabel();
}
}
+ private void updateRssi(int newRssi) {
+ rssi = newRssi;
+ level = WifiManager.calculateSignalLevel(rssi, WifiManager.RSSI_LEVELS);
+ }
+
+ private void maybeRequestNetworkScore() {
+ NetworkKey networkKey = NetworkKey.createFromWifiInfo(mWifiInfo);
+ if (mWifiNetworkScoreCache.getScoredNetwork(networkKey) == null) {
+ mNetworkScoreManager.requestScores(new NetworkKey[]{ networkKey });
+ }
+ }
+
+ private void updateStatusLabel() {
+ final NetworkCapabilities networkCapabilities
+ = mConnectivityManager.getNetworkCapabilities(mWifiManager.getCurrentNetwork());
+ if (networkCapabilities != null) {
+ if (networkCapabilities.hasCapability(NET_CAPABILITY_CAPTIVE_PORTAL)) {
+ statusLabel = mContext.getString(R.string.wifi_status_sign_in_required);
+ return;
+ } else if (!networkCapabilities.hasCapability(NET_CAPABILITY_VALIDATED)) {
+ statusLabel = mContext.getString(R.string.wifi_status_no_internet);
+ return;
+ }
+ }
+
+ ScoredNetwork scoredNetwork =
+ mWifiNetworkScoreCache.getScoredNetwork(NetworkKey.createFromWifiInfo(mWifiInfo));
+ statusLabel = scoredNetwork == null
+ ? null : AccessPoint.getSpeedLabel(mContext, scoredNetwork, rssi);
+ }
+
private String getValidSsid(WifiInfo info) {
String ssid = info.getSSID();
if (ssid != null && !WifiSsid.NONE.equals(ssid)) {
diff --git a/packages/SystemUI/res/layout/qs_footer_impl.xml b/packages/SystemUI/res/layout/qs_footer_impl.xml
index ea1ad2d1..ef18725 100644
--- a/packages/SystemUI/res/layout/qs_footer_impl.xml
+++ b/packages/SystemUI/res/layout/qs_footer_impl.xml
@@ -22,6 +22,7 @@
android:layout_width="match_parent"
android:layout_height="@dimen/qs_footer_height"
android:elevation="4dp"
+ android:background="@android:color/transparent"
android:baselineAligned="false"
android:clickable="false"
android:clipChildren="false"
diff --git a/packages/SystemUI/res/layout/qs_panel.xml b/packages/SystemUI/res/layout/qs_panel.xml
index 1c9ce18..72ff653 100644
--- a/packages/SystemUI/res/layout/qs_panel.xml
+++ b/packages/SystemUI/res/layout/qs_panel.xml
@@ -56,9 +56,9 @@
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/qs_footer_height"
android:elevation="4dp"
+ android:background="@android:color/transparent"
/>
-
<include layout="@layout/quick_status_bar_expanded_header" />
<include layout="@layout/qs_footer_impl" />
diff --git a/packages/SystemUI/res/layout/qs_tile_label.xml b/packages/SystemUI/res/layout/qs_tile_label.xml
index b138df0..74c22b0 100644
--- a/packages/SystemUI/res/layout/qs_tile_label.xml
+++ b/packages/SystemUI/res/layout/qs_tile_label.xml
@@ -44,7 +44,7 @@
android:maxLines="2"
android:padding="0dp"
android:gravity="center"
- android:ellipsize="end"
+ android:ellipsize="marquee"
android:textAppearance="@style/TextAppearance.QS.TileLabel"
android:textColor="?android:attr/textColorPrimary"/>
@@ -75,6 +75,7 @@
android:layout_alignEnd="@id/label_group"
android:layout_below="@id/label_group"
android:clickable="false"
+ android:ellipsize="marquee"
android:maxLines="1"
android:padding="0dp"
android:visibility="gone"
diff --git a/packages/SystemUI/res/layout/status_bar_notification_dismiss_all.xml b/packages/SystemUI/res/layout/status_bar_notification_footer.xml
similarity index 63%
rename from packages/SystemUI/res/layout/status_bar_notification_dismiss_all.xml
rename to packages/SystemUI/res/layout/status_bar_notification_footer.xml
index 8dc4cb4..aa0d4a0 100644
--- a/packages/SystemUI/res/layout/status_bar_notification_dismiss_all.xml
+++ b/packages/SystemUI/res/layout/status_bar_notification_footer.xml
@@ -15,13 +15,27 @@
-->
<!-- Extends Framelayout -->
-<com.android.systemui.statusbar.DismissView
+<com.android.systemui.statusbar.FooterView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingEnd="8dp"
android:visibility="gone">
- <com.android.systemui.statusbar.DismissViewButton
+ <FrameLayout
+ android:id="@+id/content"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" >
+ <com.android.systemui.statusbar.FooterViewButton
+ style="@android:style/Widget.Material.Button.Borderless"
+ android:id="@+id/manage_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="start"
+ android:focusable="true"
+ android:text="@string/manage_notifications_text"
+ android:textColor="?attr/wallpaperTextColor"
+ android:textAllCaps="false"/>
+ <com.android.systemui.statusbar.FooterViewButton
style="@android:style/Widget.Material.Button.Borderless"
android:id="@+id/dismiss_text"
android:layout_width="wrap_content"
@@ -32,4 +46,5 @@
android:text="@string/clear_all_notifications_text"
android:textColor="?attr/wallpaperTextColor"
android:textAllCaps="true"/>
-</com.android.systemui.statusbar.DismissView>
+ </FrameLayout>
+</com.android.systemui.statusbar.FooterView>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index d3a55e8..909c18b 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -191,16 +191,14 @@
<string name="screenshot_saving_ticker">Saving screenshot\u2026</string>
<!-- Notification title displayed when a screenshot is being saved to the Gallery. [CHAR LIMIT=50] -->
<string name="screenshot_saving_title">Saving screenshot\u2026</string>
- <!-- Notification text displayed when a screenshot is being saved to the Gallery. [CHAR LIMIT=100] -->
- <string name="screenshot_saving_text">Screenshot is being saved</string>
<!-- Notification title displayed when a screenshot is saved to the Gallery. [CHAR LIMIT=50] -->
<string name="screenshot_saved_title">Screenshot saved</string>
<!-- Notification text displayed when a screenshot is saved to the Gallery. [CHAR LIMIT=100] -->
<string name="screenshot_saved_text">Tap to view your screenshot</string>
<!-- Notification title displayed when we fail to take a screenshot. [CHAR LIMIT=50] -->
- <string name="screenshot_failed_title">Couldn\'t capture screenshot</string>
+ <string name="screenshot_failed_title">Couldn\'t save screenshot</string>
<!-- Notification text displayed when we fail to save a screenshot for unknown reasons. [CHAR LIMIT=100] -->
- <string name="screenshot_failed_to_save_unknown_text">Problem encountered while saving screenshot</string>
+ <string name="screenshot_failed_to_save_unknown_text">Try taking screenshot again</string>
<!-- Notification text displayed when we fail to save a screenshot. [CHAR LIMIT=100] -->
<string name="screenshot_failed_to_save_text">Can\'t save screenshot due to limited storage space</string>
<!-- Notification text displayed when we fail to take a screenshot. [CHAR LIMIT=100] -->
@@ -1055,6 +1053,9 @@
<!-- The text to clear all notifications. [CHAR LIMIT=60] -->
<string name="clear_all_notifications_text">Clear all</string>
+ <!-- The text for the manage notifications link. [CHAR LIMIT=40] -->
+ <string name="manage_notifications_text">Manage notifications</string>
+
<!-- The text to show in the notifications shade when dnd is suppressing notifications. [CHAR LIMIT=100] -->
<string name="dnd_suppressing_shade_text">Do Not disturb is hiding notifications</string>
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileBaseView.java b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileBaseView.java
index c9c678c..a9defc8 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileBaseView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileBaseView.java
@@ -15,7 +15,6 @@
import static com.android.systemui.qs.tileimpl.QSIconViewImpl.QS_ANIM_LENGTH;
-import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.ColorStateList;
@@ -122,14 +121,14 @@
private void setRipple(RippleDrawable tileBackground) {
mRipple = tileBackground;
if (getWidth() != 0) {
- updateRippleSize(getWidth(), getHeight());
+ updateRippleSize();
}
}
- private void updateRippleSize(int width, int height) {
+ private void updateRippleSize() {
// center the touch feedback on the center of the icon, and dial it down a bit
- final int cx = width / 2;
- final int cy = mIconFrame.getMeasuredHeight() / 2;
+ final int cx = mIconFrame.getMeasuredWidth() / 2 + mIconFrame.getLeft();
+ final int cy = mIconFrame.getMeasuredHeight() / 2 + mIconFrame.getTop();
final int rad = (int) (mIcon.getHeight() * .85f);
mRipple.setHotspotBounds(cx - rad, cy - rad, cx + rad, cy + rad);
}
@@ -151,11 +150,8 @@
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
- final int w = getMeasuredWidth();
- final int h = getMeasuredHeight();
-
if (mRipple != null) {
- updateRippleSize(w, h);
+ updateRippleSize();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileView.java b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileView.java
index 4774785..3cb4c71 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileView.java
@@ -32,11 +32,12 @@
import com.android.systemui.plugins.qs.QSIconView;
import com.android.systemui.plugins.qs.QSTile;
+
import java.util.Objects;
/** View that represents a standard quick settings tile. **/
public class QSTileView extends QSTileBaseView {
-
+ private static final int DEFAULT_MAX_LINES = 2;
private static final boolean DUAL_TARGET_ALLOWED = false;
private View mDivider;
protected TextView mLabel;
@@ -61,7 +62,7 @@
setId(View.generateViewId());
createLabel();
setOrientation(VERTICAL);
- setGravity(Gravity.CENTER);
+ setGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP);
}
TextView getLabel() {
@@ -72,6 +73,7 @@
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
FontSizeUtils.updateFontSize(mLabel, R.dimen.qs_tile_text_size);
+ FontSizeUtils.updateFontSize(mSecondLine, R.dimen.qs_tile_text_size);
}
@Override
@@ -85,17 +87,33 @@
mLabelContainer.setClipChildren(false);
mLabelContainer.setClipToPadding(false);
mLabel = mLabelContainer.findViewById(R.id.tile_label);
+ mLabel.setSelected(true); // Allow marquee to work.
mPadLock = mLabelContainer.findViewById(R.id.restricted_padlock);
mDivider = mLabelContainer.findViewById(R.id.underline);
mExpandIndicator = mLabelContainer.findViewById(R.id.expand_indicator);
mExpandSpace = mLabelContainer.findViewById(R.id.expand_space);
mSecondLine = mLabelContainer.findViewById(R.id.app_label);
mSecondLine.setAlpha(.6f);
-
+ mSecondLine.setSelected(true); // Allow marquee to work.
addView(mLabelContainer);
}
@Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ if (mLabel.getMaxLines() != DEFAULT_MAX_LINES) {
+ mLabel.setMaxLines(DEFAULT_MAX_LINES);
+ }
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
+ // Remeasure view if the secondary label text will be cut off.
+ if (!TextUtils.isEmpty(mSecondLine.getText())
+ && mSecondLine.getLineHeight() > mSecondLine.getHeight()) {
+ mLabel.setSingleLine();
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ }
+ }
+
+ @Override
protected void handleStateChanged(QSTile.State state) {
super.handleStateChanged(state);
if (!Objects.equals(mLabel.getText(), state.label) || mState != state.state) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
index 28fdc11..8a1e4da 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
@@ -150,8 +150,8 @@
cb = mSignalCallback.mInfo;
}
boolean transientEnabling = arg == ARG_SHOW_TRANSIENT_ENABLING;
- boolean wifiConnected = cb.enabled && (cb.wifiSignalIconId > 0) && (cb.enabledDesc != null);
- boolean wifiNotConnected = (cb.wifiSignalIconId > 0) && (cb.enabledDesc == null);
+ boolean wifiConnected = cb.enabled && (cb.wifiSignalIconId > 0) && (cb.ssid != null);
+ boolean wifiNotConnected = (cb.wifiSignalIconId > 0) && (cb.ssid == null);
boolean enabledChanging = state.value != cb.enabled;
if (enabledChanging) {
mDetailAdapter.setItemsVisible(cb.enabled);
@@ -163,7 +163,7 @@
}
state.slash.isSlashed = false;
boolean isTransient = transientEnabling || cb.isTransient;
- state.secondaryLabel = getSecondaryLabel(isTransient);
+ state.secondaryLabel = getSecondaryLabel(isTransient, cb.statusLabel);
state.state = Tile.STATE_ACTIVE;
state.dualTarget = true;
state.value = transientEnabling || cb.enabled;
@@ -181,7 +181,7 @@
state.label = r.getString(R.string.quick_settings_wifi_label);
} else if (wifiConnected) {
state.icon = ResourceIcon.get(cb.wifiSignalIconId);
- state.label = removeDoubleQuotes(cb.enabledDesc);
+ state.label = removeDoubleQuotes(cb.ssid);
} else if (wifiNotConnected) {
state.icon = ResourceIcon.get(R.drawable.ic_qs_wifi_disconnected);
state.label = r.getString(R.string.quick_settings_wifi_label);
@@ -194,7 +194,7 @@
if (state.value) {
if (wifiConnected) {
minimalContentDescription.append(cb.wifiSignalContentDescription).append(",");
- minimalContentDescription.append(removeDoubleQuotes(cb.enabledDesc));
+ minimalContentDescription.append(removeDoubleQuotes(cb.ssid));
}
}
state.contentDescription = minimalContentDescription.toString();
@@ -203,10 +203,10 @@
state.expandedAccessibilityClassName = Switch.class.getName();
}
- private CharSequence getSecondaryLabel(boolean isTransient) {
+ private CharSequence getSecondaryLabel(boolean isTransient, String statusLabel) {
return isTransient
? mContext.getString(R.string.quick_settings_wifi_secondary_label_transient)
- : null;
+ : statusLabel;
}
@Override
@@ -246,11 +246,12 @@
boolean enabled;
boolean connected;
int wifiSignalIconId;
- String enabledDesc;
+ String ssid;
boolean activityIn;
boolean activityOut;
String wifiSignalContentDescription;
boolean isTransient;
+ public String statusLabel;
@Override
public String toString() {
@@ -258,7 +259,7 @@
.append("enabled=").append(enabled)
.append(",connected=").append(connected)
.append(",wifiSignalIconId=").append(wifiSignalIconId)
- .append(",enabledDesc=").append(enabledDesc)
+ .append(",ssid=").append(ssid)
.append(",activityIn=").append(activityIn)
.append(",activityOut=").append(activityOut)
.append(",wifiSignalContentDescription=").append(wifiSignalContentDescription)
@@ -272,16 +273,18 @@
@Override
public void setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon,
- boolean activityIn, boolean activityOut, String description, boolean isTransient) {
+ boolean activityIn, boolean activityOut, String description, boolean isTransient,
+ String statusLabel) {
if (DEBUG) Log.d(TAG, "onWifiSignalChanged enabled=" + enabled);
mInfo.enabled = enabled;
mInfo.connected = qsIcon.visible;
mInfo.wifiSignalIconId = qsIcon.icon;
- mInfo.enabledDesc = description;
+ mInfo.ssid = description;
mInfo.activityIn = activityIn;
mInfo.activityOut = activityOut;
mInfo.wifiSignalContentDescription = qsIcon.contentDescription;
mInfo.isTransient = isTransient;
+ mInfo.statusLabel = statusLabel;
if (isShowingDetail()) {
mDetailAdapter.updateItems();
}
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
index 068fd3f..227f2d2 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
@@ -189,7 +189,6 @@
mPublicNotificationBuilder =
new Notification.Builder(context, NotificationChannels.SCREENSHOTS_HEADSUP)
.setContentTitle(r.getString(R.string.screenshot_saving_title))
- .setContentText(r.getString(R.string.screenshot_saving_text))
.setSmallIcon(R.drawable.stat_notify_image)
.setCategory(Notification.CATEGORY_PROGRESS)
.setWhen(now)
@@ -203,7 +202,6 @@
.setTicker(r.getString(R.string.screenshot_saving_ticker)
+ (mTickerAddSpace ? " " : ""))
.setContentTitle(r.getString(R.string.screenshot_saving_title))
- .setContentText(r.getString(R.string.screenshot_saving_text))
.setSmallIcon(R.drawable.stat_notify_image)
.setWhen(now)
.setShowWhen(true)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/EmptyShadeView.java b/packages/SystemUI/src/com/android/systemui/statusbar/EmptyShadeView.java
index 3698c3a0..4388b41 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/EmptyShadeView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/EmptyShadeView.java
@@ -48,6 +48,11 @@
return findViewById(R.id.no_notifications);
}
+ @Override
+ protected View findSecondaryView() {
+ return null;
+ }
+
public void setTextColor(@ColorInt int color) {
mEmptyText.setTextColor(color);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/DismissView.java b/packages/SystemUI/src/com/android/systemui/statusbar/FooterView.java
similarity index 68%
rename from packages/SystemUI/src/com/android/systemui/statusbar/DismissView.java
rename to packages/SystemUI/src/com/android/systemui/statusbar/FooterView.java
index d7c6443..0f4b621 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/DismissView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/FooterView.java
@@ -26,11 +26,12 @@
import com.android.systemui.statusbar.stack.ExpandableViewState;
import com.android.systemui.statusbar.stack.StackScrollState;
-public class DismissView extends StackScrollerDecorView {
+public class FooterView extends StackScrollerDecorView {
private final int mClearAllTopPadding;
- private DismissViewButton mDismissButton;
+ private FooterViewButton mDismissButton;
+ private FooterViewButton mManageButton;
- public DismissView(Context context, AttributeSet attrs) {
+ public FooterView(Context context, AttributeSet attrs) {
super(context, attrs);
mClearAllTopPadding = context.getResources().getDimensionPixelSize(
R.dimen.clear_all_padding_top);
@@ -38,21 +39,31 @@
@Override
protected View findContentView() {
+ return findViewById(R.id.content);
+ }
+
+ protected View findSecondaryView() {
return findViewById(R.id.dismiss_text);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
- mDismissButton = (DismissViewButton) findContentView();
+ mDismissButton = (FooterViewButton) findSecondaryView();
+ mManageButton = findViewById(R.id.manage_text);
}
public void setTextColor(@ColorInt int color) {
+ mManageButton.setTextColor(color);
mDismissButton.setTextColor(color);
}
- public void setOnButtonClickListener(OnClickListener listener) {
- mContent.setOnClickListener(listener);
+ public void setManageButtonClickListener(OnClickListener listener) {
+ mManageButton.setOnClickListener(listener);
+ }
+
+ public void setDismissButtonClickListener(OnClickListener listener) {
+ mDismissButton.setOnClickListener(listener);
}
public boolean isOnEmptySpace(float touchX, float touchY) {
@@ -68,25 +79,26 @@
mDismissButton.setText(R.string.clear_all_notifications_text);
mDismissButton.setContentDescription(
mContext.getString(R.string.accessibility_clear_all));
+ mManageButton.setText(R.string.manage_notifications_text);
}
public boolean isButtonVisible() {
- return mDismissButton.getAlpha() != 0.0f;
+ return mManageButton.getAlpha() != 0.0f;
}
@Override
public ExpandableViewState createNewViewState(StackScrollState stackScrollState) {
- return new DismissViewState();
+ return new FooterViewState();
}
- public class DismissViewState extends ExpandableViewState {
+ public class FooterViewState extends ExpandableViewState {
@Override
public void applyToView(View view) {
super.applyToView(view);
- if (view instanceof DismissView) {
- DismissView dismissView = (DismissView) view;
+ if (view instanceof FooterView) {
+ FooterView footerView = (FooterView) view;
boolean visible = this.clipTopAmount < mClearAllTopPadding;
- dismissView.performVisibilityAnimation(visible && !dismissView.willBeGone());
+ footerView.performVisibilityAnimation(visible && !footerView.willBeGone());
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/DismissViewButton.java b/packages/SystemUI/src/com/android/systemui/statusbar/FooterViewButton.java
similarity index 84%
rename from packages/SystemUI/src/com/android/systemui/statusbar/DismissViewButton.java
rename to packages/SystemUI/src/com/android/systemui/statusbar/FooterViewButton.java
index b608d67..16ca0f2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/DismissViewButton.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/FooterViewButton.java
@@ -23,21 +23,21 @@
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
-public class DismissViewButton extends AlphaOptimizedButton {
+public class FooterViewButton extends AlphaOptimizedButton {
- public DismissViewButton(Context context) {
+ public FooterViewButton(Context context) {
this(context, null);
}
- public DismissViewButton(Context context, AttributeSet attrs) {
+ public FooterViewButton(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
- public DismissViewButton(Context context, AttributeSet attrs, int defStyleAttr) {
+ public FooterViewButton(Context context, AttributeSet attrs, int defStyleAttr) {
this(context, attrs, defStyleAttr, 0);
}
- public DismissViewButton(Context context, AttributeSet attrs, int defStyleAttr,
+ public FooterViewButton(Context context, AttributeSet attrs, int defStyleAttr,
int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
index 3cf7741..e7b768f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
@@ -55,7 +55,6 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.Objects;
// Intimately tied to the design of res/layout/signal_cluster_view.xml
public class SignalClusterView extends LinearLayout implements NetworkControllerImpl.SignalCallback,
@@ -277,7 +276,8 @@
@Override
public void setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon,
- boolean activityIn, boolean activityOut, String description, boolean isTransient) {
+ boolean activityIn, boolean activityOut, String description, boolean isTransient,
+ String secondaryLabel) {
mWifiVisible = statusIcon.visible && !mBlockWifi;
mWifiStrengthId = statusIcon.icon;
mWifiDescription = statusIcon.contentDescription;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StackScrollerDecorView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StackScrollerDecorView.java
index badc40d..14a6c42 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StackScrollerDecorView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StackScrollerDecorView.java
@@ -31,8 +31,11 @@
public abstract class StackScrollerDecorView extends ExpandableView {
protected View mContent;
+ protected View mSecondaryView;
private boolean mIsVisible;
+ private boolean mIsSecondaryVisible;
private boolean mAnimating;
+ private int mDuration = 260;
public StackScrollerDecorView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -42,6 +45,7 @@
protected void onFinishInflate() {
super.onFinishInflate();
mContent = findContentView();
+ mSecondaryView = findSecondaryView();
setInvisible();
}
@@ -57,17 +61,37 @@
}
public void performVisibilityAnimation(boolean nowVisible) {
- animateText(nowVisible, null /* onFinishedRunnable */);
+ animateText(mContent, nowVisible, null /* onFinishedRunnable */);
+ mIsVisible = nowVisible;
}
public void performVisibilityAnimation(boolean nowVisible, Runnable onFinishedRunnable) {
- animateText(nowVisible, onFinishedRunnable);
+ animateText(mContent, nowVisible, onFinishedRunnable);
+ mIsVisible = nowVisible;
+ }
+
+ public void performSecondaryVisibilityAnimation(boolean nowVisible) {
+ performSecondaryVisibilityAnimation(nowVisible, null /* onFinishedRunnable */);
+ }
+
+ public void performSecondaryVisibilityAnimation(boolean nowVisible,
+ Runnable onFinishedRunnable) {
+ animateText(mSecondaryView, nowVisible, onFinishedRunnable);
+ mIsSecondaryVisible = nowVisible;
+ }
+
+ public boolean isSecondaryVisible() {
+ return mSecondaryView != null && (mIsSecondaryVisible || mAnimating);
}
public boolean isVisible() {
return mIsVisible || mAnimating;
}
+ void setDuration(int duration) {
+ mDuration = duration;
+ }
+
/**
* Animate the text to a new visibility.
*
@@ -75,7 +99,10 @@
* @param onFinishedRunnable A runnable which should be run when the animation is
* finished.
*/
- private void animateText(boolean nowVisible, final Runnable onFinishedRunnable) {
+ private void animateText(View view, boolean nowVisible, final Runnable onFinishedRunnable) {
+ if (view == null) {
+ return;
+ }
if (nowVisible != mIsVisible) {
// Animate text
float endValue = nowVisible ? 1.0f : 0.0f;
@@ -86,10 +113,10 @@
interpolator = Interpolators.ALPHA_OUT;
}
mAnimating = true;
- mContent.animate()
+ view.animate()
.alpha(endValue)
.setInterpolator(interpolator)
- .setDuration(260)
+ .setDuration(mDuration)
.withEndAction(new Runnable() {
@Override
public void run() {
@@ -99,7 +126,6 @@
}
}
});
- mIsVisible = nowVisible;
} else {
if (onFinishedRunnable != null) {
onFinishedRunnable.run();
@@ -109,7 +135,11 @@
public void setInvisible() {
mContent.setAlpha(0.0f);
+ if (mSecondaryView != null) {
+ mSecondaryView.setAlpha(0.0f);
+ }
mIsVisible = false;
+ mIsSecondaryVisible = false;
}
@Override
@@ -134,7 +164,15 @@
public void cancelAnimation() {
mContent.animate().cancel();
+ if (mSecondaryView != null) {
+ mSecondaryView.animate().cancel();
+ }
}
protected abstract View findContentView();
+
+ /**
+ * Returns a view that might not always appear while the main content view is still visible.
+ */
+ protected abstract View findSecondaryView();
}
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 64e205d..cccda90 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -2165,18 +2165,18 @@
@Override
protected boolean fullyExpandedClearAllVisible() {
- return mNotificationStackScroller.isDismissViewNotGone()
+ return mNotificationStackScroller.isFooterViewNotGone()
&& mNotificationStackScroller.isScrolledToBottom() && !mQsExpandImmediate;
}
@Override
protected boolean isClearAllVisible() {
- return mNotificationStackScroller.isDismissViewVisible();
+ return mNotificationStackScroller.isFooterViewVisible();
}
@Override
protected int getClearAllHeight() {
- return mNotificationStackScroller.getDismissViewHeight();
+ return mNotificationStackScroller.getFooterViewHeight();
}
@Override
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 8246974..ddb67df 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -130,7 +130,6 @@
import com.android.internal.colorextraction.ColorExtractor;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.statusbar.StatusBarIcon;
import com.android.internal.widget.LockPatternUtils;
@@ -185,12 +184,11 @@
import com.android.systemui.statusbar.BackDropView;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.CrossFadeHelper;
-import com.android.systemui.statusbar.DismissView;
import com.android.systemui.statusbar.DragDownHelper;
import com.android.systemui.statusbar.EmptyShadeView;
import com.android.systemui.statusbar.ExpandableNotificationRow;
+import com.android.systemui.statusbar.FooterView;
import com.android.systemui.statusbar.GestureRecorder;
-import com.android.systemui.statusbar.HeadsUpStatusBarView;
import com.android.systemui.statusbar.KeyboardShortcuts;
import com.android.systemui.statusbar.KeyguardIndicationController;
import com.android.systemui.statusbar.NotificationData;
@@ -237,7 +235,6 @@
import com.android.systemui.statusbar.policy.UserSwitcherController;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
-import com.android.systemui.util.NotificationChannels;
import com.android.systemui.volume.VolumeComponent;
import java.io.FileDescriptor;
@@ -577,7 +574,7 @@
private final LockscreenGestureLogger mLockscreenGestureLogger = new LockscreenGestureLogger();
protected NotificationIconAreaController mNotificationIconAreaController;
private boolean mReinflateNotificationsOnUserSwitched;
- private boolean mClearAllEnabled;
+ protected boolean mClearAllEnabled;
@Nullable private View mAmbientIndicationContainer;
private SysuiColorExtractor mColorExtractor;
private ScreenLifecycle mScreenLifecycle;
@@ -868,7 +865,7 @@
mVisualStabilityManager.setVisibilityLocationProvider(mStackScroller);
inflateEmptyShadeView();
- inflateDismissView();
+ inflateFooterView();
mBackdrop = mStatusBarWindow.findViewById(R.id.backdrop);
mBackdropFront = mBackdrop.findViewById(R.id.backdrop_front);
@@ -1133,8 +1130,8 @@
protected void reevaluateStyles() {
inflateSignalClusters();
- inflateDismissView();
- updateClearAll();
+ inflateFooterView();
+ updateFooter();
inflateEmptyShadeView();
updateEmptyShadeView();
}
@@ -1186,18 +1183,21 @@
mStackScroller.setEmptyShadeView(mEmptyShadeView);
}
- private void inflateDismissView() {
- if (!mClearAllEnabled || mStackScroller == null) {
+ private void inflateFooterView() {
+ if (mStackScroller == null) {
return;
}
- mDismissView = (DismissView) LayoutInflater.from(mContext).inflate(
- R.layout.status_bar_notification_dismiss_all, mStackScroller, false);
- mDismissView.setOnButtonClickListener(v -> {
+ mFooterView = (FooterView) LayoutInflater.from(mContext).inflate(
+ R.layout.status_bar_notification_footer, mStackScroller, false);
+ mFooterView.setDismissButtonClickListener(v -> {
mMetricsLogger.action(MetricsEvent.ACTION_DISMISS_ALL_NOTES);
clearAllNotifications();
});
- mStackScroller.setDismissView(mDismissView);
+ mFooterView.setManageButtonClickListener(v -> {
+ manageNotifications();
+ });
+ mStackScroller.setFooterView(mFooterView);
}
protected void createUserSwitcher() {
@@ -1211,6 +1211,12 @@
R.layout.super_status_bar, null);
}
+ public void manageNotifications() {
+ Intent intent = new Intent(Settings.ACTION_ALL_APPS_NOTIFICATION_SETTINGS);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ startActivity(intent, true, true);
+ }
+
public void clearAllNotifications() {
// animate-swipe all dismissable notifications, then animate the shade closed
@@ -1393,7 +1399,7 @@
mViewHierarchyManager.updateNotificationViews();
updateSpeedBumpIndex();
- updateClearAll();
+ updateFooter();
updateEmptyShadeView();
updateQsExpansionEnabled();
@@ -1457,13 +1463,14 @@
mQSPanel.clickTile(tile);
}
- private void updateClearAll() {
- if (!mClearAllEnabled) {
- return;
- }
- boolean showDismissView = mState != StatusBarState.KEYGUARD
+ @VisibleForTesting
+ protected void updateFooter() {
+ boolean showFooterView = mState != StatusBarState.KEYGUARD
+ && mEntryManager.getNotificationData().getActiveNotifications().size() != 0;
+ boolean showDismissView = mClearAllEnabled && mState != StatusBarState.KEYGUARD
&& hasActiveClearableNotifications();
- mStackScroller.updateDismissView(showDismissView);
+
+ mStackScroller.updateFooterView(showFooterView, showDismissView);
}
/**
@@ -4938,7 +4945,7 @@
protected RecentsComponent mRecents;
protected NotificationShelf mNotificationShelf;
- protected DismissView mDismissView;
+ protected FooterView mFooterView;
protected EmptyShadeView mEmptyShadeView;
protected AssistManager mAssistManager;
@@ -5411,8 +5418,8 @@
// incremented in the following "changeViewPosition" calls so that its value is correct for
// subsequent calls.
int offsetFromEnd = 1;
- if (mDismissView != null) {
- mStackScroller.changeViewPosition(mDismissView,
+ if (mFooterView != null) {
+ mStackScroller.changeViewPosition(mFooterView,
mStackScroller.getChildCount() - offsetFromEnd++);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/CallbackHandler.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/CallbackHandler.java
index 5159e8d..b76d536 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/CallbackHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/CallbackHandler.java
@@ -109,13 +109,13 @@
@Override
public void setWifiIndicators(final boolean enabled, final IconState statusIcon,
final IconState qsIcon, final boolean activityIn, final boolean activityOut,
- final String description, boolean isTransient) {
+ final String description, boolean isTransient, String secondaryLabel) {
post(new Runnable() {
@Override
public void run() {
for (SignalCallback callback : mSignalCallbacks) {
callback.setWifiIndicators(enabled, statusIcon, qsIcon, activityIn, activityOut,
- description, isTransient);
+ description, isTransient, secondaryLabel);
}
}
});
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
index 76e3ad7..51fef7d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
@@ -47,7 +47,8 @@
public interface SignalCallback {
default void setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon,
- boolean activityIn, boolean activityOut, String description, boolean isTransient) {}
+ boolean activityIn, boolean activityOut, String description, boolean isTransient,
+ String statusLabel) {}
default void setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType,
int qsType, boolean activityIn, boolean activityOut, String typeContentDescription,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java
index 0f65421..e5e576d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java
@@ -17,12 +17,15 @@
import android.content.Context;
import android.content.Intent;
+import android.net.ConnectivityManager;
import android.net.NetworkCapabilities;
+import android.net.NetworkScoreManager;
import android.net.wifi.WifiManager;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Messenger;
+import android.text.TextUtils;
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
@@ -37,7 +40,6 @@
public class WifiSignalController extends
SignalController<WifiSignalController.WifiState, SignalController.IconGroup> {
- private final WifiManager mWifiManager;
private final AsyncChannel mWifiChannel;
private final boolean mHasMobileData;
private final WifiStatusTracker mWifiTracker;
@@ -47,12 +49,17 @@
WifiManager wifiManager) {
super("WifiSignalController", context, NetworkCapabilities.TRANSPORT_WIFI,
callbackHandler, networkController);
- mWifiManager = wifiManager;
- mWifiTracker = new WifiStatusTracker(mWifiManager);
+ NetworkScoreManager networkScoreManager =
+ context.getSystemService(NetworkScoreManager.class);
+ ConnectivityManager connectivityManager =
+ context.getSystemService(ConnectivityManager.class);
+ mWifiTracker = new WifiStatusTracker(mContext, wifiManager, networkScoreManager,
+ connectivityManager, this::handleStatusUpdated);
+ mWifiTracker.setListening(true);
mHasMobileData = hasMobileData;
Handler handler = new WifiHandler(Looper.getMainLooper());
mWifiChannel = new AsyncChannel();
- Messenger wifiMessenger = mWifiManager.getWifiServiceMessenger();
+ Messenger wifiMessenger = wifiManager.getWifiServiceMessenger();
if (wifiMessenger != null) {
mWifiChannel.connect(context, handler, wifiMessenger);
}
@@ -68,7 +75,6 @@
WifiIcons.QS_WIFI_NO_NETWORK,
AccessibilityContentDescriptions.WIFI_NO_CONNECTION
);
-
}
@Override
@@ -87,13 +93,12 @@
if (mCurrentState.inetCondition == 0) {
contentDescription += ("," + mContext.getString(R.string.data_connection_no_internet));
}
-
IconState statusIcon = new IconState(wifiVisible, getCurrentIconId(), contentDescription);
IconState qsIcon = new IconState(mCurrentState.connected, getQsCurrentIconId(),
contentDescription);
callback.setWifiIndicators(mCurrentState.enabled, statusIcon, qsIcon,
ssidPresent && mCurrentState.activityIn, ssidPresent && mCurrentState.activityOut,
- wifiDesc, mCurrentState.isTransient);
+ wifiDesc, mCurrentState.isTransient, mCurrentState.statusLabel);
}
/**
@@ -106,6 +111,12 @@
mCurrentState.ssid = mWifiTracker.ssid;
mCurrentState.rssi = mWifiTracker.rssi;
mCurrentState.level = mWifiTracker.level;
+ mCurrentState.statusLabel = mWifiTracker.statusLabel;
+ notifyListenersIfNecessary();
+ }
+
+ private void handleStatusUpdated() {
+ mCurrentState.statusLabel = mWifiTracker.statusLabel;
notifyListenersIfNecessary();
}
@@ -150,6 +161,7 @@
static class WifiState extends SignalController.State {
String ssid;
boolean isTransient;
+ String statusLabel;
@Override
public void copyFrom(State s) {
@@ -157,20 +169,26 @@
WifiState state = (WifiState) s;
ssid = state.ssid;
isTransient = state.isTransient;
+ statusLabel = state.statusLabel;
}
@Override
protected void toString(StringBuilder builder) {
super.toString(builder);
- builder.append(',').append("ssid=").append(ssid);
- builder.append(',').append("isTransient=").append(isTransient);
+ builder.append(",ssid=").append(ssid)
+ .append(",isTransient=").append(isTransient)
+ .append(",statusLabel=").append(statusLabel);
}
@Override
public boolean equals(Object o) {
- return super.equals(o)
- && Objects.equals(((WifiState) o).ssid, ssid)
- && (((WifiState) o).isTransient == isTransient);
+ if (!super.equals(o)) {
+ return false;
+ }
+ WifiState other = (WifiState) o;
+ return Objects.equals(other.ssid, ssid)
+ && other.isTransient == isTransient
+ && TextUtils.equals(other.statusLabel, statusLabel);
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
index dc94203..8f6fa49 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -16,7 +16,8 @@
package com.android.systemui.statusbar.stack;
-import static com.android.systemui.statusbar.notification.ActivityLaunchAnimator.ExpandAnimationParameters;
+import static com.android.systemui.statusbar.notification.ActivityLaunchAnimator
+ .ExpandAnimationParameters;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -43,6 +44,7 @@
import android.service.notification.StatusBarNotification;
import android.support.annotation.NonNull;
import android.support.annotation.VisibleForTesting;
+import android.support.v4.graphics.ColorUtils;
import android.util.AttributeSet;
import android.util.FloatProperty;
import android.util.Log;
@@ -77,10 +79,10 @@
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin.MenuItem;
import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper;
import com.android.systemui.statusbar.ActivatableNotificationView;
-import com.android.systemui.statusbar.DismissView;
import com.android.systemui.statusbar.EmptyShadeView;
import com.android.systemui.statusbar.ExpandableNotificationRow;
import com.android.systemui.statusbar.ExpandableView;
+import com.android.systemui.statusbar.FooterView;
import com.android.systemui.statusbar.NotificationData;
import com.android.systemui.statusbar.NotificationGuts;
import com.android.systemui.statusbar.NotificationListContainer;
@@ -99,8 +101,6 @@
import com.android.systemui.statusbar.policy.HeadsUpUtil;
import com.android.systemui.statusbar.policy.ScrollAdapter;
-import android.support.v4.graphics.ColorUtils;
-
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -109,7 +109,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.function.BiConsumer;
-import java.util.function.Consumer;
/**
* A layout which handles a dynamic amount of notifications and presents them in a scrollable stack.
@@ -226,7 +225,7 @@
private boolean mExpandingNotification;
private boolean mExpandedInThisMotion;
protected boolean mScrollingEnabled;
- protected DismissView mDismissView;
+ protected FooterView mFooterView;
protected EmptyShadeView mEmptyShadeView;
private boolean mDismissAllInProgress;
private boolean mFadeNotificationsOnDismiss;
@@ -3838,13 +3837,13 @@
Context context = new ContextThemeWrapper(mContext,
lightTheme ? R.style.Theme_SystemUI_Light : R.style.Theme_SystemUI);
final int textColor = Utils.getColorAttr(context, R.attr.wallpaperTextColor);
- mDismissView.setTextColor(textColor);
+ mFooterView.setTextColor(textColor);
mEmptyShadeView.setTextColor(textColor);
}
public void goToFullShade(long delay) {
- if (mDismissView != null) {
- mDismissView.setInvisible();
+ if (mFooterView != null) {
+ mFooterView.setInvisible();
}
mEmptyShadeView.setInvisible();
mGoToFullShadeNeedsAnimation = true;
@@ -3967,14 +3966,14 @@
return -1;
}
- public void setDismissView(@NonNull DismissView dismissView) {
+ public void setFooterView(@NonNull FooterView footerView) {
int index = -1;
- if (mDismissView != null) {
- index = indexOfChild(mDismissView);
- removeView(mDismissView);
+ if (mFooterView != null) {
+ index = indexOfChild(mFooterView);
+ removeView(mFooterView);
}
- mDismissView = dismissView;
- addView(mDismissView, index);
+ mFooterView = footerView;
+ addView(mFooterView, index);
}
public void setEmptyShadeView(EmptyShadeView emptyShadeView) {
@@ -3992,77 +3991,64 @@
int newVisibility = visible ? VISIBLE : GONE;
if (oldVisibility != newVisibility) {
if (newVisibility != GONE) {
- if (mEmptyShadeView.willBeGone()) {
- mEmptyShadeView.cancelAnimation();
- } else {
- mEmptyShadeView.setInvisible();
- }
if (mStatusBar.areNotificationsHidden()) {
mEmptyShadeView.setText(R.string.dnd_suppressing_shade_text);
} else {
mEmptyShadeView.setText(R.string.empty_shade_text);
}
- mEmptyShadeView.setVisibility(newVisibility);
- mEmptyShadeView.setWillBeGone(false);
- updateContentHeight();
- notifyHeightChangeListener(mEmptyShadeView);
+ showFooterView(mEmptyShadeView);
} else {
- Runnable onFinishedRunnable = new Runnable() {
- @Override
- public void run() {
- mEmptyShadeView.setVisibility(GONE);
- mEmptyShadeView.setWillBeGone(false);
- updateContentHeight();
- notifyHeightChangeListener(mEmptyShadeView);
- }
- };
- if (mAnimationsEnabled && mIsExpanded) {
- mEmptyShadeView.setWillBeGone(true);
- mEmptyShadeView.performVisibilityAnimation(false, onFinishedRunnable);
- } else {
- mEmptyShadeView.setInvisible();
- onFinishedRunnable.run();
- }
+ hideFooterView(mEmptyShadeView, true);
}
}
}
- public void updateDismissView(boolean visible) {
- if (mDismissView == null) {
+ public void updateFooterView(boolean visible, boolean showDismissView) {
+ if (mFooterView == null) {
return;
}
-
- int oldVisibility = mDismissView.willBeGone() ? GONE : mDismissView.getVisibility();
+ int oldVisibility = mFooterView.willBeGone() ? GONE : mFooterView.getVisibility();
int newVisibility = visible ? VISIBLE : GONE;
if (oldVisibility != newVisibility) {
if (newVisibility != GONE) {
- if (mDismissView.willBeGone()) {
- mDismissView.cancelAnimation();
- } else {
- mDismissView.setInvisible();
- }
- mDismissView.setVisibility(newVisibility);
- mDismissView.setWillBeGone(false);
- updateContentHeight();
- notifyHeightChangeListener(mDismissView);
+ showFooterView(mFooterView);
} else {
- Runnable dimissHideFinishRunnable = new Runnable() {
- @Override
- public void run() {
- mDismissView.setVisibility(GONE);
- mDismissView.setWillBeGone(false);
- updateContentHeight();
- notifyHeightChangeListener(mDismissView);
- }
- };
- if (mDismissView.isButtonVisible() && mIsExpanded && mAnimationsEnabled) {
- mDismissView.setWillBeGone(true);
- mDismissView.performVisibilityAnimation(false, dimissHideFinishRunnable);
- } else {
- dimissHideFinishRunnable.run();
- }
+ hideFooterView(mFooterView, mFooterView.isButtonVisible());
}
}
+ if (mFooterView.isSecondaryVisible() != showDismissView) {
+ mFooterView.performSecondaryVisibilityAnimation(showDismissView);
+ }
+ }
+
+ private void showFooterView(StackScrollerDecorView footerView) {
+ if (footerView.willBeGone()) {
+ footerView.cancelAnimation();
+ } else {
+ footerView.setInvisible();
+ }
+ footerView.setVisibility(VISIBLE);
+ footerView.setWillBeGone(false);
+ updateContentHeight();
+ notifyHeightChangeListener(footerView);
+ }
+
+ private void hideFooterView(StackScrollerDecorView footerView, boolean isButtonVisible) {
+ Runnable onHideFinishRunnable = new Runnable() {
+ @Override
+ public void run() {
+ footerView.setVisibility(GONE);
+ footerView.setWillBeGone(false);
+ updateContentHeight();
+ notifyHeightChangeListener(footerView);
+ }
+ };
+ if (isButtonVisible && mIsExpanded && mAnimationsEnabled) {
+ footerView.setWillBeGone(true);
+ footerView.performVisibilityAnimation(false, onHideFinishRunnable);
+ } else {
+ onHideFinishRunnable.run();
+ }
}
public void setDismissAllInProgress(boolean dismissAllInProgress) {
@@ -4088,18 +4074,18 @@
}
}
- public boolean isDismissViewNotGone() {
- return mDismissView != null
- && mDismissView.getVisibility() != View.GONE
- && !mDismissView.willBeGone();
+ public boolean isFooterViewNotGone() {
+ return mFooterView != null
+ && mFooterView.getVisibility() != View.GONE
+ && !mFooterView.willBeGone();
}
- public boolean isDismissViewVisible() {
- return mDismissView != null && mDismissView.isVisible();
+ public boolean isFooterViewVisible() {
+ return mFooterView != null && mFooterView.isVisible();
}
- public int getDismissViewHeight() {
- return mDismissView == null ? 0 : mDismissView.getHeight() + mPaddingBetweenElements;
+ public int getFooterViewHeight() {
+ return mFooterView == null ? 0 : mFooterView.getHeight() + mPaddingBetweenElements;
}
public int getEmptyShadeViewHeight() {
@@ -4155,8 +4141,8 @@
}
boolean belowChild = touchY > childTop + child.getActualHeight()
- child.getClipBottomAmount();
- if (child == mDismissView) {
- if(!belowChild && !mDismissView.isOnEmptySpace(touchX - mDismissView.getX(),
+ if (child == mFooterView) {
+ if(!belowChild && !mFooterView.isOnEmptySpace(touchX - mFooterView.getX(),
touchY - childTop)) {
// We clicked on the dismiss button
return false;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java
index 7c8e0fc..a8d2d98 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java
@@ -22,10 +22,10 @@
import android.view.View;
import android.view.ViewGroup;
import com.android.systemui.R;
-import com.android.systemui.statusbar.DismissView;
import com.android.systemui.statusbar.EmptyShadeView;
import com.android.systemui.statusbar.ExpandableNotificationRow;
import com.android.systemui.statusbar.ExpandableView;
+import com.android.systemui.statusbar.FooterView;
import com.android.systemui.statusbar.NotificationShelf;
import com.android.systemui.statusbar.notification.NotificationUtils;
@@ -390,7 +390,7 @@
int paddingAfterChild = getPaddingAfterChild(algorithmState, child);
int childHeight = getMaxAllowedChildHeight(child);
childViewState.yTranslation = currentYPosition;
- boolean isDismissView = child instanceof DismissView;
+ boolean isFooterView = child instanceof FooterView;
boolean isEmptyShadeView = child instanceof EmptyShadeView;
childViewState.location = ExpandableViewState.LOCATION_MAIN_AREA;
@@ -404,7 +404,7 @@
float end = childViewState.yTranslation + childViewState.height + inset;
childViewState.headsUpIsVisible = end < ambientState.getMaxHeadsUpTranslation();
}
- if (isDismissView) {
+ if (isFooterView) {
childViewState.yTranslation = Math.min(childViewState.yTranslation,
ambientState.getInnerHeight() - childHeight);
} else if (isEmptyShadeView) {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/FooterViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/FooterViewTest.java
new file mode 100644
index 0000000..96b0255
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/FooterViewTest.java
@@ -0,0 +1,123 @@
+/*
+ * 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.statusbar;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertNull;
+import static junit.framework.Assert.assertTrue;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.ContextWrapper;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.res.Resources;
+import android.graphics.Color;
+import android.graphics.drawable.Icon;
+import android.os.UserHandle;
+import android.support.test.filters.SmallTest;
+import android.support.test.runner.AndroidJUnit4;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+
+import com.android.internal.statusbar.StatusBarIcon;
+import com.android.internal.util.NotificationColorUtil;
+import com.android.systemui.R;
+import com.android.systemui.SysuiTestCase;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatcher;
+
+@SmallTest
+@RunWith(AndroidJUnit4.class)
+public class FooterViewTest extends SysuiTestCase {
+
+ FooterView mView;
+
+ @Before
+ public void setUp() {
+ mView = (FooterView) LayoutInflater.from(mContext).inflate(
+ R.layout.status_bar_notification_footer, null, false);
+ mView.setDuration(0);
+ }
+
+ @Test
+ public void testViewsNotNull() {
+ assertNotNull(mView.findContentView());
+ assertNotNull(mView.findSecondaryView());
+ }
+
+ @Test
+ public void setDismissOnClick() {
+ mView.setDismissButtonClickListener(mock(View.OnClickListener.class));
+ assertTrue(mView.findSecondaryView().hasOnClickListeners());
+ }
+
+ @Test
+ public void setManageOnClick() {
+ mView.setManageButtonClickListener(mock(View.OnClickListener.class));
+ assertTrue(mView.findViewById(R.id.manage_text).hasOnClickListeners());
+ }
+
+ @Test
+ public void testPerformVisibilityAnimation() {
+ mView.setInvisible();
+ assertFalse(mView.isVisible());
+
+ Runnable test = new Runnable() {
+ @Override
+ public void run() {
+ assertEquals(1.0f, mView.findContentView().getAlpha());
+ assertEquals(0.0f, mView.findSecondaryView().getAlpha());
+ assertTrue(mView.isVisible());
+ }
+ };
+ mView.performVisibilityAnimation(true, test);
+ }
+
+ @Test
+ public void testPerformSecondaryVisibilityAnimation() {
+ mView.setInvisible();
+ assertFalse(mView.isSecondaryVisible());
+
+ Runnable test = new Runnable() {
+ @Override
+ public void run() {
+ assertEquals(0.0f, mView.findContentView().getAlpha());
+ assertEquals(1.0f, mView.findSecondaryView().getAlpha());
+ assertTrue(mView.isSecondaryVisible());
+ }
+ };
+ mView.performSecondaryVisibilityAnimation(true, test);
+ }
+}
+
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 f13fa4e..f81ffd8 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
@@ -18,7 +18,9 @@
import static android.app.NotificationManager.IMPORTANCE_HIGH;
+import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertTrue;
import static junit.framework.TestCase.fail;
@@ -55,6 +57,8 @@
import android.testing.TestableLooper;
import android.testing.TestableLooper.RunWithLooper;
import android.util.SparseArray;
+import android.view.Gravity;
+import android.view.View;
import android.view.ViewGroup.LayoutParams;
import com.android.internal.logging.MetricsLogger;
@@ -65,13 +69,15 @@
import com.android.systemui.ForegroundServiceController;
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
-import com.android.systemui.UiOffloadThread;
import com.android.systemui.assist.AssistManager;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.statusbar.ActivatableNotificationView;
import com.android.systemui.statusbar.AppOpsListener;
import com.android.systemui.statusbar.CommandQueue;
+import com.android.systemui.statusbar.ExpandableNotificationRow;
+import com.android.systemui.statusbar.FooterView;
+import com.android.systemui.statusbar.FooterViewButton;
import com.android.systemui.statusbar.KeyguardIndicationController;
import com.android.systemui.statusbar.NotificationData;
import com.android.systemui.statusbar.NotificationData.Entry;
@@ -88,7 +94,6 @@
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.notification.ActivityLaunchAnimator;
import com.android.systemui.statusbar.notification.VisualStabilityManager;
-import com.android.systemui.statusbar.phone.HeadsUpManagerPhone;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.KeyguardMonitor;
import com.android.systemui.statusbar.policy.KeyguardMonitorImpl;
@@ -97,12 +102,14 @@
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;
import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
+import java.util.function.Predicate;
@SmallTest
@RunWith(AndroidTestingRunner.class)
@@ -558,6 +565,68 @@
verify(mScrimController).setKeyguardOccluded(eq(false));
}
+ @Test
+ public void testInflateFooterView() {
+ mStatusBar.reevaluateStyles();
+ ArgumentCaptor<FooterView> captor = ArgumentCaptor.forClass(FooterView.class);
+ verify(mStackScroller).setFooterView(captor.capture());
+
+ assertNotNull(captor.getValue().findViewById(R.id.manage_text).hasOnClickListeners());
+ assertNotNull(captor.getValue().findViewById(R.id.dismiss_text).hasOnClickListeners());
+ }
+
+ @Test
+ public void testUpdateFooter_noNotifications() {
+ mStatusBar.setBarStateForTest(StatusBarState.SHADE);
+ assertEquals(0, mEntryManager.getNotificationData().getActiveNotifications().size());
+
+ mStatusBar.updateFooter();
+ verify(mStackScroller).updateFooterView(false, false);
+ }
+
+ @Test
+ public void testUpdateFooter_oneClearableNotification() {
+ mStatusBar.setBarStateForTest(StatusBarState.SHADE);
+ ArrayList<Entry> entries = new ArrayList<>();
+ entries.add(mock(Entry.class));
+ when(mNotificationData.getActiveNotifications()).thenReturn(entries);
+
+ ExpandableNotificationRow row = mock(ExpandableNotificationRow.class);
+ when(row.canViewBeDismissed()).thenReturn(true);
+ when(mStackScroller.getChildCount()).thenReturn(1);
+ when(mStackScroller.getChildAt(anyInt())).thenReturn(row);
+
+ mStatusBar.updateFooter();
+ verify(mStackScroller).updateFooterView(true, true);
+ }
+
+ @Test
+ public void testUpdateFooter_oneNonClearableNotification() {
+ mStatusBar.setBarStateForTest(StatusBarState.SHADE);
+ ArrayList<Entry> entries = new ArrayList<>();
+ entries.add(mock(Entry.class));
+ when(mNotificationData.getActiveNotifications()).thenReturn(entries);
+
+ mStatusBar.updateFooter();
+ verify(mStackScroller).updateFooterView(true, false);
+ }
+
+ @Test
+ public void testUpdateFooter_atEnd() {
+ // add footer
+ mStatusBar.reevaluateStyles();
+
+ // add notification
+ ExpandableNotificationRow row = mock(ExpandableNotificationRow.class);
+ when(row.isClearable()).thenReturn(true);
+ mStackScroller.addContainerView(row);
+
+ mStatusBar.onUpdateRowStates();
+
+ // move footer to end
+ verify(mStackScroller).changeViewPosition(any(FooterView.class), eq(-1 /* end */));
+ }
+
static class TestableStatusBar extends StatusBar {
public TestableStatusBar(StatusBarKeyguardViewManager man,
UnlockMethodCache unlock, KeyguardIndicationController key,
@@ -587,6 +656,7 @@
mScrimController = scrimController;
mFingerprintUnlockController = fingerprintUnlockController;
mActivityLaunchAnimator = launchAnimator;
+ mClearAllEnabled = true;
}
private WakefulnessLifecycle createAwakeWakefulnessLifecycle() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CallbackHandlerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CallbackHandlerTest.java
index 2afb48c..ed0f9ab 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CallbackHandlerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CallbackHandlerTest.java
@@ -18,7 +18,6 @@
import android.os.HandlerThread;
import android.support.test.runner.AndroidJUnit4;
import android.telephony.SubscriptionInfo;
-import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
@@ -81,7 +80,8 @@
boolean in = true;
boolean out = true;
String description = "Test";
- mHandler.setWifiIndicators(enabled, status, qs, in, out, description, true);
+ String secondaryLabel = "Secondary label";
+ mHandler.setWifiIndicators(enabled, status, qs, in, out, description, true, secondaryLabel);
waitForCallbacks();
ArgumentCaptor<Boolean> enableArg = ArgumentCaptor.forClass(Boolean.class);
@@ -91,9 +91,10 @@
ArgumentCaptor<Boolean> outArg = ArgumentCaptor.forClass(Boolean.class);
ArgumentCaptor<String> descArg = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<Boolean> isTransient = ArgumentCaptor.forClass(Boolean.class);
+ ArgumentCaptor<String> secondary = ArgumentCaptor.forClass(String.class);
Mockito.verify(mSignalCallback).setWifiIndicators(enableArg.capture(),
statusArg.capture(), qsArg.capture(), inArg.capture(), outArg.capture(),
- descArg.capture(), isTransient.capture());
+ descArg.capture(), isTransient.capture(), secondary.capture());
assertEquals(enabled, (boolean) enableArg.getValue());
assertEquals(status, statusArg.getValue());
assertEquals(qs, qsArg.getValue());
@@ -101,6 +102,7 @@
assertEquals(out, (boolean) outArg.getValue());
assertEquals(description, descArg.getValue());
assertTrue(isTransient.getValue());
+ assertEquals(secondaryLabel, secondary.getValue());
}
@Test
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 fc3de84..d30e777 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
@@ -5,8 +5,6 @@
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
-import android.net.wifi.WifiSsid;
-import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper.RunWithLooper;
@@ -20,6 +18,7 @@
import static junit.framework.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Mockito.when;
@@ -39,6 +38,7 @@
verifyLastWifiIcon(false, WifiIcons.WIFI_NO_NETWORK);
setWifiState(true, testSsid);
+ setWifiLevel(0);
verifyLastWifiIcon(true, WifiIcons.WIFI_SIGNAL_STRENGTH[0][0]);
for (int testLevel = 0; testLevel < WifiIcons.WIFI_LEVEL_COUNT; testLevel++) {
@@ -160,7 +160,8 @@
ArgumentCaptor<Boolean> outArg = ArgumentCaptor.forClass(Boolean.class);
Mockito.verify(mCallbackHandler, Mockito.atLeastOnce()).setWifiIndicators(
- anyBoolean(), any(), any(), inArg.capture(), outArg.capture(), any(), anyBoolean());
+ anyBoolean(), any(), any(), inArg.capture(), outArg.capture(), any(), anyBoolean(),
+ any());
assertEquals("WiFi data in, in quick settings", in, (boolean) inArg.getValue());
assertEquals("WiFi data out, in quick settings", out, (boolean) outArg.getValue());
}
@@ -173,7 +174,7 @@
Mockito.verify(mCallbackHandler, Mockito.atLeastOnce()).setWifiIndicators(
enabledArg.capture(), any(), iconArg.capture(), anyBoolean(),
- anyBoolean(), descArg.capture(), anyBoolean());
+ anyBoolean(), descArg.capture(), anyBoolean(), any());
IconState iconState = iconArg.getValue();
assertEquals("WiFi enabled, in quick settings", enabled, (boolean) enabledArg.getValue());
assertEquals("WiFi connected, in quick settings", connected, iconState.visible);
@@ -186,7 +187,7 @@
Mockito.verify(mCallbackHandler, Mockito.atLeastOnce()).setWifiIndicators(
anyBoolean(), iconArg.capture(), any(), anyBoolean(), anyBoolean(),
- any(), anyBoolean());
+ any(), anyBoolean(), any());
IconState iconState = iconArg.getValue();
assertEquals("WiFi visible, in status bar", visible, iconState.visible);
assertEquals("WiFi signal, in status bar", icon, iconState.icon);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayoutTest.java
index 6fa91ff..42069e2 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayoutTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayoutTest.java
@@ -23,10 +23,12 @@
import android.support.test.annotation.UiThreadTest;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
+import android.view.View;
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.statusbar.EmptyShadeView;
+import com.android.systemui.statusbar.FooterView;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.phone.ScrimController;
import com.android.systemui.statusbar.phone.StatusBar;
@@ -94,4 +96,30 @@
verify(view).setText(R.string.empty_shade_text);
}
+
+ @Test
+ public void manageNotifications_visible() {
+ FooterView view = mock(FooterView.class);
+ mStackScroller.setFooterView(view);
+ when(view.willBeGone()).thenReturn(true);
+ when(view.isSecondaryVisible()).thenReturn(true);
+
+ mStackScroller.updateFooterView(true, false);
+
+ verify(view).setVisibility(View.VISIBLE);
+ verify(view).performSecondaryVisibilityAnimation(false);
+ }
+
+ @Test
+ public void clearAll_visible() {
+ FooterView view = mock(FooterView.class);
+ mStackScroller.setFooterView(view);
+ when(view.willBeGone()).thenReturn(true);
+ when(view.isSecondaryVisible()).thenReturn(false);
+
+ mStackScroller.updateFooterView(true, true);
+
+ verify(view).setVisibility(View.VISIBLE);
+ verify(view).performSecondaryVisibilityAnimation(true);
+ }
}
diff --git a/proto/src/metrics_constants.proto b/proto/src/metrics_constants.proto
index cfb5c6d..c6878d7 100644
--- a/proto/src/metrics_constants.proto
+++ b/proto/src/metrics_constants.proto
@@ -5557,6 +5557,10 @@
// OS: P
SETTINGS_CONDITION_DEVICE_VIBRATE = 1369;
+ // OPEN: Settings > Connected devices > previously connected devices
+ // CATEGORY: SETTINGS
+ // OS: P
+ PREVIOUSLY_CONNECTED_DEVICES = 1370;
// ---- End P Constants, all P constants go above this line ----
// Add new aosp constants above this line.
diff --git a/proto/src/wifi.proto b/proto/src/wifi.proto
index 39d0070..9c74188 100644
--- a/proto/src/wifi.proto
+++ b/proto/src/wifi.proto
@@ -382,6 +382,9 @@
// WifiWake statistics
optional WifiWakeStats wifi_wake_stats = 94;
+
+ // Histogram counting instances of scans with N many 802.11mc (RTT) supporting APs
+ repeated NumConnectableNetworksBucket observed_80211mc_supporting_aps_in_scan_histogram = 95;
}
// Information that gets logged for every WiFi connection.
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 706bbcf..5131a93 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -281,6 +281,7 @@
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
+import android.content.pm.ApplicationInfo.HiddenApiEnforcementPolicy;
import android.content.pm.ConfigurationInfo;
import android.content.pm.IPackageDataObserver;
import android.content.pm.IPackageManager;
@@ -4185,12 +4186,14 @@
runtimeFlags |= Zygote.ONLY_USE_SYSTEM_OAT_FILES;
}
- if (!app.info.isAllowedToUseHiddenApi() &&
- !disableHiddenApiChecks &&
- !mHiddenApiBlacklist.isDisabled()) {
- // This app is not allowed to use undocumented and private APIs, or blacklisting is
- // enabled. Set up its runtime with the appropriate flag.
- runtimeFlags |= Zygote.ENABLE_HIDDEN_API_CHECKS;
+ if (!disableHiddenApiChecks && !mHiddenApiBlacklist.isDisabled()) {
+ @HiddenApiEnforcementPolicy int policy =
+ app.info.getHiddenApiEnforcementPolicy();
+ int policyBits = (policy << Zygote.API_ENFORCEMENT_POLICY_SHIFT);
+ if ((policyBits & Zygote.API_ENFORCEMENT_POLICY_MASK) != policyBits) {
+ throw new IllegalStateException("Invalid API policy: " + policy);
+ }
+ runtimeFlags |= policyBits;
}
String invokeWith = null;
diff --git a/services/core/java/com/android/server/display/BrightnessMappingStrategy.java b/services/core/java/com/android/server/display/BrightnessMappingStrategy.java
index 4313d17..711d40b 100644
--- a/services/core/java/com/android/server/display/BrightnessMappingStrategy.java
+++ b/services/core/java/com/android/server/display/BrightnessMappingStrategy.java
@@ -60,8 +60,14 @@
int[] backlightRange = resources.getIntArray(
com.android.internal.R.array.config_screenBrightnessBacklight);
+ float[] minimumBrightnessCurveLux = getLuxLevels(resources.getIntArray(
+ com.android.internal.R.array.config_autoBrightnessMinimumBrightnessCurveLux));
+ float[] minimumBrightnessCurveNits = getFloatArray(resources.obtainTypedArray(
+ com.android.internal.R.array.config_autoBrightnessMinimumBrightnessCurveNits));
+
if (isValidMapping(nitsRange, backlightRange)
- && isValidMapping(luxLevels, brightnessLevelsNits)) {
+ && isValidMapping(luxLevels, brightnessLevelsNits)
+ && isValidMapping(minimumBrightnessCurveLux, minimumBrightnessCurveNits)) {
int minimumBacklight = resources.getInteger(
com.android.internal.R.integer.config_screenBrightnessSettingMinimum);
int maximumBacklight = resources.getInteger(
@@ -73,7 +79,8 @@
}
BrightnessConfiguration.Builder builder = new BrightnessConfiguration.Builder();
builder.setCurve(luxLevels, brightnessLevelsNits);
- return new PhysicalMappingStrategy(builder.build(), nitsRange, backlightRange);
+ return new PhysicalMappingStrategy(builder.build(), nitsRange, backlightRange,
+ minimumBrightnessCurveLux, minimumBrightnessCurveNits);
} else if (isValidMapping(luxLevels, brightnessLevelsBacklight)) {
return new SimpleMappingStrategy(luxLevels, brightnessLevelsBacklight);
} else {
@@ -448,8 +455,11 @@
private float mUserLux;
private float mUserBrightness;
+ private final Spline mMinimumBrightnessCurve;
+
public PhysicalMappingStrategy(BrightnessConfiguration config,
- float[] nits, int[] backlight) {
+ float[] nits, int[] backlight, float[] minimumBrightnessCurveLux,
+ float[] minimumBrightnessCurveNits) {
Preconditions.checkArgument(nits.length != 0 && backlight.length != 0,
"Nits and backlight arrays must not be empty!");
Preconditions.checkArgument(nits.length == backlight.length,
@@ -469,6 +479,9 @@
normalizedBacklight[i] = normalizeAbsoluteBrightness(backlight[i]);
}
+ mMinimumBrightnessCurve = Spline.createSpline(
+ minimumBrightnessCurveLux, minimumBrightnessCurveNits);
+
mNitsToBacklightSpline = createSpline(nits, normalizedBacklight);
mBacklightToNitsSpline = createSpline(normalizedBacklight, nits);
@@ -484,7 +497,7 @@
if (config.equals(mConfig)) {
return false;
}
-
+ validateBrightnessConfiguration(config);
Pair<float[], float[]> curve = config.getCurve();
mBrightnessSpline = createSpline(curve.first /*lux*/, curve.second /*nits*/);
mConfig = config;
@@ -549,5 +562,24 @@
pw.println(" mUserLux=" + mUserLux);
pw.println(" mUserBrightness=" + mUserBrightness);
}
+
+ private void validateBrightnessConfiguration(BrightnessConfiguration config) {
+ Pair<float[], float[]> curve = config.getCurve();
+ Spline brightnessSpline = Spline.createSpline(curve.first, curve.second);
+ if (isBrightnessSplineTooDark(brightnessSpline)) {
+ throw new IllegalArgumentException("brightness curve is too dark");
+ }
+ }
+
+ private boolean isBrightnessSplineTooDark(Spline brightnessSpline) {
+ float[] lux = mDefaultConfig.getCurve().first;
+ for (int i = 0; i < lux.length; i++) {
+ if (brightnessSpline.interpolate(lux[i]) <
+ mMinimumBrightnessCurve.interpolate(lux[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
}
}
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index ff8b88b..1784ef1 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -500,7 +500,7 @@
}
public void onSwitchUser(@UserIdInt int newUserId) {
- handleSettingsChange();
+ handleSettingsChange(true /* userSwitch */);
mBrightnessTracker.onSwitchUser(newUserId);
}
@@ -1420,8 +1420,12 @@
mHandler.post(mOnStateChangedRunnable);
}
- private void handleSettingsChange() {
+ private void handleSettingsChange(boolean userSwitch) {
mPendingScreenBrightnessSetting = getScreenBrightnessSetting();
+ if (userSwitch) {
+ // Don't treat user switches as user initiated change.
+ mCurrentScreenBrightnessSetting = mPendingScreenBrightnessSetting;
+ }
mPendingAutoBrightnessAdjustment = getAutoBrightnessAdjustmentSetting();
// We don't bother with a pending variable for VR screen brightness since we just
// immediately adapt to it.
@@ -1735,7 +1739,7 @@
@Override
public void onChange(boolean selfChange, Uri uri) {
- handleSettingsChange();
+ handleSettingsChange(false /* userSwitch */);
}
}
diff --git a/services/core/java/com/android/server/locksettings/LockSettingsService.java b/services/core/java/com/android/server/locksettings/LockSettingsService.java
index 7c56f4d..f617964 100644
--- a/services/core/java/com/android/server/locksettings/LockSettingsService.java
+++ b/services/core/java/com/android/server/locksettings/LockSettingsService.java
@@ -21,6 +21,7 @@
import static android.content.Context.KEYGUARD_SERVICE;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
+import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_BOOT;
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT;
import static com.android.internal.widget.LockPatternUtils.SYNTHETIC_PASSWORD_ENABLED_KEY;
import static com.android.internal.widget.LockPatternUtils.SYNTHETIC_PASSWORD_HANDLE_KEY;
@@ -524,6 +525,10 @@
public void onCleanupUser(int userId) {
hideEncryptionNotification(new UserHandle(userId));
+ // User is stopped with its CE key evicted. Require strong auth next time to be able to
+ // unlock the user's storage. Use STRONG_AUTH_REQUIRED_AFTER_BOOT since stopping and
+ // restarting a user later is equivalent to rebooting the device.
+ requireStrongAuth(STRONG_AUTH_REQUIRED_AFTER_BOOT, userId);
}
public void onStartUser(final int userId) {
diff --git a/services/core/java/com/android/server/net/watchlist/WatchlistConfig.java b/services/core/java/com/android/server/net/watchlist/WatchlistConfig.java
index 2714d5e..d793842 100644
--- a/services/core/java/com/android/server/net/watchlist/WatchlistConfig.java
+++ b/services/core/java/com/android/server/net/watchlist/WatchlistConfig.java
@@ -107,6 +107,10 @@
* Reload watchlist by reading config file.
*/
public void reloadConfig() {
+ if (!mXmlFile.exists()) {
+ // No config file
+ return;
+ }
try (FileInputStream stream = new FileInputStream(mXmlFile)){
final List<byte[]> crc32DomainList = new ArrayList<>();
final List<byte[]> sha256DomainList = new ArrayList<>();
diff --git a/services/core/java/com/android/server/net/watchlist/WatchlistSettings.java b/services/core/java/com/android/server/net/watchlist/WatchlistSettings.java
index f5ba889..e20a510 100644
--- a/services/core/java/com/android/server/net/watchlist/WatchlistSettings.java
+++ b/services/core/java/com/android/server/net/watchlist/WatchlistSettings.java
@@ -87,6 +87,10 @@
}
public void reloadSettings() {
+ if (!mXmlFile.exists()) {
+ // No settings config
+ return;
+ }
try (FileInputStream stream = mXmlFile.openRead()){
XmlPullParser parser = Xml.newPullParser();
parser.setInput(stream, StandardCharsets.UTF_8.name());
@@ -97,7 +101,7 @@
mPrivacySecretKey = parseSecretKey(parser);
}
}
- Log.i(TAG, "Reload watchlist settings done");
+ Slog.i(TAG, "Reload watchlist settings done");
} catch (IllegalStateException | NullPointerException | NumberFormatException |
XmlPullParserException | IOException | IndexOutOfBoundsException e) {
Slog.e(TAG, "Failed parsing xml", e);
diff --git a/services/core/java/com/android/server/pm/PackageDexOptimizer.java b/services/core/java/com/android/server/pm/PackageDexOptimizer.java
index 9e7ad47..61c6be7 100644
--- a/services/core/java/com/android/server/pm/PackageDexOptimizer.java
+++ b/services/core/java/com/android/server/pm/PackageDexOptimizer.java
@@ -47,6 +47,8 @@
import dalvik.system.DexFile;
+import static android.content.pm.ApplicationInfo.HIDDEN_API_ENFORCEMENT_NONE;
+
import static com.android.server.pm.Installer.DEXOPT_BOOTCOMPLETE;
import static com.android.server.pm.Installer.DEXOPT_DEBUGGABLE;
import static com.android.server.pm.Installer.DEXOPT_PROFILE_GUIDED;
@@ -532,7 +534,10 @@
int profileFlag = isProfileGuidedFilter ? DEXOPT_PROFILE_GUIDED : 0;
// Some apps are executed with restrictions on hidden API usage. If this app is one
// of them, pass a flag to dexopt to enable the same restrictions during compilation.
- int hiddenApiFlag = info.isAllowedToUseHiddenApi() ? 0 : DEXOPT_ENABLE_HIDDEN_API_CHECKS;
+ // TODO we should pass the actual flag value to dexopt, rather than assuming blacklist
+ int hiddenApiFlag = info.getHiddenApiEnforcementPolicy() == HIDDEN_API_ENFORCEMENT_NONE
+ ? 0
+ : DEXOPT_ENABLE_HIDDEN_API_CHECKS;
// Avoid generating CompactDex for modes that are latency critical.
final int compilationReason = options.getCompilationReason();
boolean generateCompactDex = true;
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index 3e47ea6..a7eac55 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -385,6 +385,11 @@
*/
private int mSurfaceSize;
+ /**
+ * Sequence number for the current layout pass.
+ */
+ int mLayoutSeq = 0;
+
/** Temporary float array to retrieve 3x3 matrix values. */
private final float[] mTmpFloats = new float[9];
@@ -554,7 +559,7 @@
w.prelayout();
final boolean firstLayout = !w.isLaidOut();
mService.mPolicy.layoutWindowLw(w, null, mDisplayFrames);
- w.mLayoutSeq = mService.mLayoutSeq;
+ w.mLayoutSeq = mLayoutSeq;
// If this is the first layout, we need to initialize the last inset values as
// otherwise we'd immediately cause an unnecessary resize.
@@ -593,7 +598,7 @@
w.mLayoutNeeded = false;
w.prelayout();
mService.mPolicy.layoutWindowLw(w, w.getParentWindow(), mDisplayFrames);
- w.mLayoutSeq = mService.mLayoutSeq;
+ w.mLayoutSeq = mLayoutSeq;
if (DEBUG_LAYOUT) Slog.v(TAG, " LAYOUT: mFrame=" + w.mFrame
+ " mContainingFrame=" + w.mContainingFrame
+ " mDisplayFrame=" + w.mDisplayFrame);
@@ -2219,6 +2224,9 @@
pw.println(" mTouchExcludeRegion=" + mTouchExcludeRegion);
pw.println();
+ pw.print(prefix); pw.print("mLayoutSeq="); pw.println(mLayoutSeq);
+
+ pw.println();
pw.println(prefix + "Application tokens in top down Z order:");
for (int stackNdx = mTaskStackContainers.getChildCount() - 1; stackNdx >= 0; --stackNdx) {
final TaskStack stack = mTaskStackContainers.getChildAt(stackNdx);
@@ -2927,9 +2935,9 @@
mService.mScreenRect.set(0, 0, dw, dh);
}
- int seq = mService.mLayoutSeq + 1;
+ int seq = mLayoutSeq + 1;
if (seq < 0) seq = 0;
- mService.mLayoutSeq = seq;
+ mLayoutSeq = seq;
// Used to indicate that we have processed the dream window and all additional windows are
// behind it.
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 56b314f..449aa2c 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -596,8 +596,6 @@
boolean mClientFreezingScreen = false;
int mAppsFreezingScreen = 0;
- int mLayoutSeq = 0;
-
// Last systemUiVisibility we received from status bar.
int mLastStatusBarVisibility = 0;
// Last systemUiVisibility we dispatched to windows.
@@ -6344,8 +6342,7 @@
if (mInputMethodTarget != null) {
pw.print(" mInputMethodTarget="); pw.println(mInputMethodTarget);
}
- pw.print(" mInTouchMode="); pw.print(mInTouchMode);
- pw.print(" mLayoutSeq="); pw.println(mLayoutSeq);
+ pw.print(" mInTouchMode="); pw.println(mInTouchMode);
pw.print(" mLastDisplayFreezeDuration=");
TimeUtils.formatDuration(mLastDisplayFreezeDuration, pw);
if ( mLastFinishedFreezeSource != null) {
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 993556f..30bbfe0 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -1236,7 +1236,7 @@
*/
void updateResizingWindowIfNeeded() {
final WindowStateAnimator winAnimator = mWinAnimator;
- if (!mHasSurface || mService.mLayoutSeq != mLayoutSeq || isGoneForLayoutLw()) {
+ if (!mHasSurface || getDisplayContent().mLayoutSeq != mLayoutSeq || isGoneForLayoutLw()) {
return;
}
@@ -1360,6 +1360,15 @@
return mToken.getDisplayContent();
}
+ @Override
+ void onDisplayChanged(DisplayContent dc) {
+ super.onDisplayChanged(dc);
+ // Window was not laid out for this display yet, so make sure mLayoutSeq does not match.
+ if (dc != null) {
+ mLayoutSeq = dc.mLayoutSeq - 1;
+ }
+ }
+
DisplayInfo getDisplayInfo() {
final DisplayContent displayContent = getDisplayContent();
return displayContent != null ? displayContent.getDisplayInfo() : null;
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 56c9807..1e216a3 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -566,9 +566,7 @@
}
public static class DevicePolicyData {
- @NonNull PasswordMetrics mActivePasswordMetrics = new PasswordMetrics();
int mFailedPasswordAttempts = 0;
- boolean mPasswordStateHasBeenSetSinceBoot = false;
boolean mPasswordValidAtLastCheckpoint = true;
int mUserHandle;
@@ -628,6 +626,8 @@
}
final SparseArray<DevicePolicyData> mUserData = new SparseArray<>();
+ @GuardedBy("DevicePolicyManagerService.this")
+ final SparseArray<PasswordMetrics> mUserPasswordMetrics = new SparseArray<>();
final Handler mHandler;
final Handler mBackgroundHandler;
@@ -2158,6 +2158,16 @@
}
/**
+ * Provides PasswordMetrics object corresponding to the given user.
+ * @param userHandle the user for whom to provide metrics.
+ * @return the user password metrics, or {@code null} if none have been associated with
+ * the user yet (for example, if the device has booted but not been unlocked).
+ */
+ PasswordMetrics getUserPasswordMetricsLocked(int userHandle) {
+ return mUserPasswordMetrics.get(userHandle);
+ }
+
+ /**
* Creates and loads the policy data from xml for data that is shared between
* various profiles of a user. In contrast to {@link #getUserData(int)}
* it allows access to data of users other than the calling user.
@@ -2191,6 +2201,10 @@
if (policy != null) {
mUserData.remove(userHandle);
}
+ if (mUserPasswordMetrics.get(userHandle) != null) {
+ mUserPasswordMetrics.remove(userHandle);
+ }
+
File policyFile = new File(mInjector.environmentGetUserSystemDirectory(userHandle),
DEVICE_POLICIES_XML);
policyFile.delete();
@@ -3907,9 +3921,15 @@
private void updatePasswordValidityCheckpointLocked(int userHandle, boolean parent) {
final int credentialOwner = getCredentialOwner(userHandle, parent);
DevicePolicyData policy = getUserData(credentialOwner);
+ PasswordMetrics metrics = getUserPasswordMetricsLocked(credentialOwner);
+ if (metrics == null) {
+ Slog.wtf(LOG_TAG, "Should have had a valid password metrics for updating checkpoint " +
+ "validity.");
+ metrics = new PasswordMetrics();
+ }
policy.mPasswordValidAtLastCheckpoint =
isPasswordSufficientForUserWithoutCheckpointLocked(
- policy.mActivePasswordMetrics, userHandle, parent);
+ metrics, userHandle, parent);
saveSettingsLocked(credentialOwner);
}
@@ -4532,8 +4552,11 @@
// This API can only be called by an active device admin,
// so try to retrieve it to check that the caller is one.
getActiveAdminForCallerLocked(null, DeviceAdminInfo.USES_POLICY_LIMIT_PASSWORD, parent);
- DevicePolicyData policy = getUserDataUnchecked(getCredentialOwner(userHandle, parent));
- return isActivePasswordSufficientForUserLocked(policy, userHandle, parent);
+ int credentialOwner = getCredentialOwner(userHandle, parent);
+ DevicePolicyData policy = getUserDataUnchecked(credentialOwner);
+ PasswordMetrics metrics = getUserPasswordMetricsLocked(credentialOwner);
+ return isActivePasswordSufficientForUserLocked(
+ policy.mPasswordValidAtLastCheckpoint, metrics, userHandle, parent);
}
}
@@ -4559,25 +4582,31 @@
synchronized (this) {
final int targetUser = getProfileParentId(userHandle);
enforceUserUnlocked(targetUser, false);
- DevicePolicyData policy = getUserDataUnchecked(getCredentialOwner(userHandle, false));
- return isActivePasswordSufficientForUserLocked(policy, targetUser, false);
+ int credentialOwner = getCredentialOwner(userHandle, false);
+ DevicePolicyData policy = getUserDataUnchecked(credentialOwner);
+ PasswordMetrics metrics = getUserPasswordMetricsLocked(credentialOwner);
+ return isActivePasswordSufficientForUserLocked(
+ policy.mPasswordValidAtLastCheckpoint, metrics, targetUser, false);
}
}
private boolean isActivePasswordSufficientForUserLocked(
- DevicePolicyData policy, int userHandle, boolean parent) {
- if (!mInjector.storageManagerIsFileBasedEncryptionEnabled()
- && !policy.mPasswordStateHasBeenSetSinceBoot) {
+ boolean passwordValidAtLastCheckpoint, PasswordMetrics metrics, int userHandle,
+ boolean parent) {
+ if (!mInjector.storageManagerIsFileBasedEncryptionEnabled() && (metrics == null)) {
// Before user enters their password for the first time after a reboot, return the
// value of this flag, which tells us whether the password was valid the last time
// settings were saved. If DPC changes password requirements on boot so that the
// current password no longer meets the requirements, this value will be stale until
// the next time the password is entered.
- return policy.mPasswordValidAtLastCheckpoint;
+ return passwordValidAtLastCheckpoint;
}
- return isPasswordSufficientForUserWithoutCheckpointLocked(
- policy.mActivePasswordMetrics, userHandle, parent);
+ if (metrics == null) {
+ Slog.wtf(LOG_TAG, "FBE device, should have been unlocked and had valid metrics.");
+ metrics = new PasswordMetrics();
+ }
+ return isPasswordSufficientForUserWithoutCheckpointLocked(metrics, userHandle, parent);
}
/**
@@ -6123,10 +6152,8 @@
}
validateQualityConstant(metrics.quality);
- DevicePolicyData policy = getUserData(userHandle);
synchronized (this) {
- policy.mActivePasswordMetrics = metrics;
- policy.mPasswordStateHasBeenSetSinceBoot = true;
+ mUserPasswordMetrics.put(userHandle, metrics);
}
}
@@ -7640,6 +7667,7 @@
if (!mHasFeature) {
return DevicePolicyManager.STATE_USER_UNMANAGED;
}
+ enforceManageUsers();
int userHandle = mInjector.userHandleGetCallingUserId();
return getUserProvisioningState(userHandle);
}
@@ -11815,6 +11843,7 @@
@Override
public boolean isDeviceProvisioned() {
+ enforceManageUsers();
synchronized (this) {
return getUserDataUnchecked(UserHandle.USER_SYSTEM).mUserSetupComplete;
}
diff --git a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
index 43490d3..a64efb7 100644
--- a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
@@ -2387,12 +2387,12 @@
}
public void testGetUserProvisioningState_defaultResult() {
+ mContext.callerPermissions.add(permission.MANAGE_USERS);
assertEquals(DevicePolicyManager.STATE_USER_UNMANAGED, dpm.getUserProvisioningState());
}
public void testSetUserProvisioningState_permission() throws Exception {
setupProfileOwner();
- mContext.callerPermissions.add(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS);
exerciseUserProvisioningTransitions(DpmMockContext.CALLER_USER_HANDLE,
DevicePolicyManager.STATE_USER_SETUP_FINALIZED);
@@ -2407,6 +2407,7 @@
public void testSetUserProvisioningState_noManagement() {
mContext.callerPermissions.add(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS);
+ mContext.callerPermissions.add(permission.MANAGE_USERS);
assertExpectException(IllegalStateException.class,
/* messageRegex= */ "change provisioning state unless a .* owner is set",
() -> dpm.setUserProvisioningState(DevicePolicyManager.STATE_USER_SETUP_FINALIZED,
@@ -2417,7 +2418,6 @@
public void testSetUserProvisioningState_deviceOwnerFromSetupWizard() throws Exception {
mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
setupDeviceOwner();
- mContext.callerPermissions.add(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS);
exerciseUserProvisioningTransitions(UserHandle.USER_SYSTEM,
DevicePolicyManager.STATE_USER_SETUP_COMPLETE,
@@ -2428,7 +2428,6 @@
throws Exception {
mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
setupDeviceOwner();
- mContext.callerPermissions.add(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS);
exerciseUserProvisioningTransitions(UserHandle.USER_SYSTEM,
DevicePolicyManager.STATE_USER_SETUP_INCOMPLETE,
@@ -2438,7 +2437,6 @@
public void testSetUserProvisioningState_deviceOwnerWithoutSetupWizard() throws Exception {
mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
setupDeviceOwner();
- mContext.callerPermissions.add(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS);
exerciseUserProvisioningTransitions(UserHandle.USER_SYSTEM,
DevicePolicyManager.STATE_USER_SETUP_FINALIZED);
@@ -2447,7 +2445,6 @@
public void testSetUserProvisioningState_managedProfileFromSetupWizard_primaryUser()
throws Exception {
setupProfileOwner();
- mContext.callerPermissions.add(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS);
exerciseUserProvisioningTransitions(DpmMockContext.CALLER_USER_HANDLE,
DevicePolicyManager.STATE_USER_PROFILE_COMPLETE,
@@ -2457,7 +2454,6 @@
public void testSetUserProvisioningState_managedProfileFromSetupWizard_managedProfile()
throws Exception {
setupProfileOwner();
- mContext.callerPermissions.add(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS);
exerciseUserProvisioningTransitions(DpmMockContext.CALLER_USER_HANDLE,
DevicePolicyManager.STATE_USER_SETUP_COMPLETE,
@@ -2466,7 +2462,6 @@
public void testSetUserProvisioningState_managedProfileWithoutSetupWizard() throws Exception {
setupProfileOwner();
- mContext.callerPermissions.add(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS);
exerciseUserProvisioningTransitions(DpmMockContext.CALLER_USER_HANDLE,
DevicePolicyManager.STATE_USER_SETUP_FINALIZED);
@@ -2474,7 +2469,6 @@
public void testSetUserProvisioningState_illegalTransitionOutOfFinalized1() throws Exception {
setupProfileOwner();
- mContext.callerPermissions.add(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS);
assertExpectException(IllegalStateException.class,
/* messageRegex= */ "Cannot move to user provisioning state",
@@ -2486,7 +2480,6 @@
public void testSetUserProvisioningState_illegalTransitionToAnotherInProgressState()
throws Exception {
setupProfileOwner();
- mContext.callerPermissions.add(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS);
assertExpectException(IllegalStateException.class,
/* messageRegex= */ "Cannot move to user provisioning state",
@@ -2496,6 +2489,9 @@
}
private void exerciseUserProvisioningTransitions(int userId, int... states) {
+ mContext.callerPermissions.add(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS);
+ mContext.callerPermissions.add(permission.MANAGE_USERS);
+
assertEquals(DevicePolicyManager.STATE_USER_UNMANAGED, dpm.getUserProvisioningState());
for (int state : states) {
dpm.setUserProvisioningState(state, userId);
diff --git a/services/tests/servicestests/src/com/android/server/display/BrightnessMappingStrategyTest.java b/services/tests/servicestests/src/com/android/server/display/BrightnessMappingStrategyTest.java
index fb25cf3..d922df3 100644
--- a/services/tests/servicestests/src/com/android/server/display/BrightnessMappingStrategyTest.java
+++ b/services/tests/servicestests/src/com/android/server/display/BrightnessMappingStrategyTest.java
@@ -85,6 +85,9 @@
255
};
+ private static final int[] MINIMUM_BRIGHTNESS_CURVE_LUX = { 2000, 4000 };
+ private static final float[] MINIMUM_BRIGHTNESS_CURVE_NITS = { 1.0f, 50.0f, 90.0f };
+
private static final float[] DISPLAY_RANGE_NITS = { 2.685f, 478.5f };
private static final int[] BACKLIGHT_RANGE = { 1, 255 };
@@ -381,6 +384,19 @@
com.android.internal.R.array.config_autoBrightnessDisplayValuesNits))
.thenReturn(mockBrightnessLevelNits);
+ int[] mockMinimumBrightnessCurveLux = new int[MINIMUM_BRIGHTNESS_CURVE_LUX.length];
+ for (int i = 0; i < mockMinimumBrightnessCurveLux.length; i++) {
+ mockMinimumBrightnessCurveLux[i] = (int) MINIMUM_BRIGHTNESS_CURVE_LUX[i];
+ }
+ when(mockResources.getIntArray(
+ com.android.internal.R.array.config_autoBrightnessMinimumBrightnessCurveLux))
+ .thenReturn(mockMinimumBrightnessCurveLux);
+ TypedArray mockMinimumBrightnessCurveNits = createFloatTypedArray(
+ MINIMUM_BRIGHTNESS_CURVE_NITS);
+ when(mockResources.obtainTypedArray(
+ com.android.internal.R.array.config_autoBrightnessMinimumBrightnessCurveNits))
+ .thenReturn(mockMinimumBrightnessCurveNits);
+
TypedArray mockNitsRange = createFloatTypedArray(nitsRange);
when(mockResources.obtainTypedArray(
com.android.internal.R.array.config_screenBrightnessNits))
@@ -419,4 +435,78 @@
return mockArray;
}
+ private float[] getNearMinimumNits(float epsilon) {
+ float[] lux = new float[MINIMUM_BRIGHTNESS_CURVE_LUX.length + 1];
+ for (int i = 0; i < MINIMUM_BRIGHTNESS_CURVE_LUX.length; i++) {
+ lux[i+1] = MINIMUM_BRIGHTNESS_CURVE_LUX[i];
+ }
+ Spline minimumBrightnessCurve = Spline.createSpline(lux, MINIMUM_BRIGHTNESS_CURVE_NITS);
+ float[] nits = new float[LUX_LEVELS.length];
+ for (int i = 0; i < nits.length; i++) {
+ nits[i] = minimumBrightnessCurve.interpolate(LUX_LEVELS[i]) + epsilon;
+ }
+ return nits;
+ }
+
+ @Test
+ public void testCreateWithTooDarkBrightnessConfigurationThrowsException() {
+ float[] nits = getNearMinimumNits(-0.1f);
+ Resources res = createResources(LUX_LEVELS, nits, DISPLAY_RANGE_NITS, BACKLIGHT_RANGE);
+ Exception thrown = null;
+ try {
+ BrightnessMappingStrategy.create(res);
+ } catch (IllegalArgumentException e) {
+ thrown = e;
+ }
+ assertNotNull("Failed to throw IllegalArgumentException", thrown);
+ }
+
+ @Test
+ public void testCreationWithBrightEnoughBrightnessConfigurationDoesNotThrowException() {
+ float[] nits = getNearMinimumNits(0);
+ Resources res = createResources(LUX_LEVELS, nits, DISPLAY_RANGE_NITS, BACKLIGHT_RANGE);
+ assertNotNull("Failed to create BrightnessMappingStrategy",
+ BrightnessMappingStrategy.create(res));
+ }
+
+ @Test
+ public void testSettingTooDarkBrightnessConfigurationThrowsException() {
+ Resources res = createResources(LUX_LEVELS, DISPLAY_LEVELS_NITS, DISPLAY_RANGE_NITS,
+ BACKLIGHT_RANGE);
+ BrightnessMappingStrategy strategy = BrightnessMappingStrategy.create(res);
+ assertNotNull("Failed to create BrightnessMappingStrategy", strategy);
+ float[] lux = new float[LUX_LEVELS.length];
+ for (int i = 0; i < lux.length; i++) {
+ lux[i] = LUX_LEVELS[i];
+ }
+ float[] nits = getNearMinimumNits(-0.1f);
+ BrightnessConfiguration config = new BrightnessConfiguration.Builder()
+ .setCurve(lux, nits)
+ .build();
+ Exception thrown = null;
+ try {
+ strategy.setBrightnessConfiguration(config);
+ } catch (IllegalArgumentException e) {
+ thrown = e;
+ }
+ assertNotNull("Failed to throw IllegalArgumentException", thrown);
+ }
+
+ @Test
+ public void testSettingBrightEnouhgBrightnessConfigurationDoesNotThrowException() {
+ Resources res = createResources(LUX_LEVELS, DISPLAY_LEVELS_NITS, DISPLAY_RANGE_NITS,
+ BACKLIGHT_RANGE);
+ BrightnessMappingStrategy strategy = BrightnessMappingStrategy.create(res);
+ assertNotNull("Failed to create BrightnessMappingStrategy", strategy);
+ float[] lux = new float[LUX_LEVELS.length];
+ for (int i = 0; i < lux.length; i++) {
+ lux[i] = LUX_LEVELS[i];
+ }
+ float[] nits = getNearMinimumNits(0);
+ BrightnessConfiguration config = new BrightnessConfiguration.Builder()
+ .setCurve(lux, nits)
+ .build();
+ assertTrue("failed to set brightness configuration",
+ strategy.setBrightnessConfiguration(config));
+ }
}
diff --git a/services/tests/servicestests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/servicestests/src/com/android/server/wm/DisplayContentTests.java
index b645700..7f1bcac 100644
--- a/services/tests/servicestests/src/com/android/server/wm/DisplayContentTests.java
+++ b/services/tests/servicestests/src/com/android/server/wm/DisplayContentTests.java
@@ -30,8 +30,10 @@
import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION;
import static com.android.server.wm.WindowContainer.POSITION_TOP;
+import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -436,6 +438,20 @@
}
@Test
+ public void testLayoutSeq_assignedDuringLayout() throws Exception {
+ synchronized (sWm.getWindowManagerLock()) {
+
+ final DisplayContent dc = createNewDisplay();
+ final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, dc, "w");
+
+ dc.setLayoutNeeded();
+ dc.performLayout(true /* initial */, false /* updateImeWindows */);
+
+ assertThat(win.mLayoutSeq, is(dc.mLayoutSeq));
+ }
+ }
+
+ @Test
@SuppressLint("InlinedApi")
public void testOrientationDefinedByKeyguard() {
final DisplayContent dc = createNewDisplay();
diff --git a/services/tests/servicestests/src/com/android/server/wm/WindowStateTests.java b/services/tests/servicestests/src/com/android/server/wm/WindowStateTests.java
index 56b7d9f..1248eae 100644
--- a/services/tests/servicestests/src/com/android/server/wm/WindowStateTests.java
+++ b/services/tests/servicestests/src/com/android/server/wm/WindowStateTests.java
@@ -40,9 +40,12 @@
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
@@ -312,6 +315,17 @@
assertTrue(child2.isSelfOrAncestorWindowAnimatingExit());
}
+ @Test
+ public void testLayoutSeqResetOnReparent() throws Exception {
+ final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
+ app.mLayoutSeq = 1;
+ mDisplayContent.mLayoutSeq = 1;
+
+ app.onDisplayChanged(mDisplayContent);
+
+ assertThat(app.mLayoutSeq, not(is(mDisplayContent.mLayoutSeq)));
+ }
+
private void testPrepareWindowToDisplayDuringRelayout(boolean wasVisible) {
reset(mPowerManagerWrapper);
final WindowState root = createWindow(null, TYPE_APPLICATION, "root");