Merge "Clear calling identity in finish callback" into pi-dev
diff --git a/api/current.txt b/api/current.txt
index be5e3e7..64b2d58 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -7041,7 +7041,8 @@
method public int getBackoffPolicy();
method public android.content.ClipData getClipData();
method public int getClipGrantFlags();
- method public long getEstimatedNetworkBytes();
+ method public long getEstimatedNetworkDownloadBytes();
+ method public long getEstimatedNetworkUploadBytes();
method public android.os.PersistableBundle getExtras();
method public long getFlexMillis();
method public int getId();
@@ -7058,8 +7059,10 @@
method public long getTriggerContentMaxDelay();
method public long getTriggerContentUpdateDelay();
method public android.app.job.JobInfo.TriggerContentUri[] getTriggerContentUris();
+ method public boolean isImportantWhileForeground();
method public boolean isPeriodic();
method public boolean isPersisted();
+ method public boolean isPrefetch();
method public boolean isRequireBatteryNotLow();
method public boolean isRequireCharging();
method public boolean isRequireDeviceIdle();
@@ -7085,15 +7088,15 @@
method public android.app.job.JobInfo build();
method public android.app.job.JobInfo.Builder setBackoffCriteria(long, int);
method public android.app.job.JobInfo.Builder setClipData(android.content.ClipData, int);
- method public android.app.job.JobInfo.Builder setEstimatedNetworkBytes(long);
+ method public android.app.job.JobInfo.Builder setEstimatedNetworkBytes(long, long);
method public android.app.job.JobInfo.Builder setExtras(android.os.PersistableBundle);
method public android.app.job.JobInfo.Builder setImportantWhileForeground(boolean);
- method public android.app.job.JobInfo.Builder setIsPrefetch(boolean);
method public android.app.job.JobInfo.Builder setMinimumLatency(long);
method public android.app.job.JobInfo.Builder setOverrideDeadline(long);
method public android.app.job.JobInfo.Builder setPeriodic(long);
method public android.app.job.JobInfo.Builder setPeriodic(long, long);
method public android.app.job.JobInfo.Builder setPersisted(boolean);
+ method public android.app.job.JobInfo.Builder setPrefetch(boolean);
method public android.app.job.JobInfo.Builder setRequiredNetwork(android.net.NetworkRequest);
method public android.app.job.JobInfo.Builder setRequiredNetworkType(int);
method public android.app.job.JobInfo.Builder setRequiresBatteryNotLow(boolean);
@@ -7163,10 +7166,11 @@
public final class JobWorkItem implements android.os.Parcelable {
ctor public JobWorkItem(android.content.Intent);
- ctor public JobWorkItem(android.content.Intent, long);
+ ctor public JobWorkItem(android.content.Intent, long, long);
method public int describeContents();
method public int getDeliveryCount();
- method public long getEstimatedNetworkBytes();
+ method public long getEstimatedNetworkDownloadBytes();
+ method public long getEstimatedNetworkUploadBytes();
method public android.content.Intent getIntent();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.app.job.JobWorkItem> CREATOR;
diff --git a/api/removed.txt b/api/removed.txt
index 64a9c3f..4279c31 100644
--- a/api/removed.txt
+++ b/api/removed.txt
@@ -54,6 +54,24 @@
}
+package android.app.job {
+
+ public class JobInfo implements android.os.Parcelable {
+ method public deprecated long getEstimatedNetworkBytes();
+ }
+
+ public static final class JobInfo.Builder {
+ method public deprecated android.app.job.JobInfo.Builder setEstimatedNetworkBytes(long);
+ method public deprecated android.app.job.JobInfo.Builder setIsPrefetch(boolean);
+ }
+
+ public final class JobWorkItem implements android.os.Parcelable {
+ ctor public deprecated JobWorkItem(android.content.Intent, long);
+ method public deprecated long getEstimatedNetworkBytes();
+ }
+
+}
+
package android.app.usage {
public final class StorageStats implements android.os.Parcelable {
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 8dbb9f0..3015398 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -8755,6 +8755,7 @@
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
public boolean isDeviceProvisioned() {
try {
return mService.isDeviceProvisioned();
diff --git a/core/java/android/app/job/JobInfo.java b/core/java/android/app/job/JobInfo.java
index ee13880..02afcc7 100644
--- a/core/java/android/app/job/JobInfo.java
+++ b/core/java/android/app/job/JobInfo.java
@@ -65,7 +65,6 @@
NETWORK_TYPE_UNMETERED,
NETWORK_TYPE_NOT_ROAMING,
NETWORK_TYPE_CELLULAR,
- NETWORK_TYPE_METERED,
})
@Retention(RetentionPolicy.SOURCE)
public @interface NetworkType {}
@@ -253,7 +252,7 @@
/**
* @hide
*/
- public static final int FLAG_IS_PREFETCH = 1 << 2;
+ public static final int FLAG_PREFETCH = 1 << 2;
/**
* This job needs to be exempted from the app standby throttling. Only the system (UID 1000)
@@ -296,7 +295,8 @@
private final boolean hasEarlyConstraint;
private final boolean hasLateConstraint;
private final NetworkRequest networkRequest;
- private final long networkBytes;
+ private final long networkDownloadBytes;
+ private final long networkUploadBytes;
private final long minLatencyMillis;
private final long maxExecutionDelayMillis;
private final boolean isPeriodic;
@@ -317,30 +317,28 @@
}
/**
- * Bundle of extras which are returned to your application at execution time.
+ * @see JobInfo.Builder#setExtras(PersistableBundle)
*/
public @NonNull PersistableBundle getExtras() {
return extras;
}
/**
- * Bundle of transient extras which are returned to your application at execution time,
- * but not persisted by the system.
+ * @see JobInfo.Builder#setTransientExtras(Bundle)
*/
public @NonNull Bundle getTransientExtras() {
return transientExtras;
}
/**
- * ClipData of information that is returned to your application at execution time,
- * but not persisted by the system.
+ * @see JobInfo.Builder#setClipData(ClipData, int)
*/
public @Nullable ClipData getClipData() {
return clipData;
}
/**
- * Permission grants that go along with {@link #getClipData}.
+ * @see JobInfo.Builder#setClipData(ClipData, int)
*/
public int getClipGrantFlags() {
return clipGrantFlags;
@@ -369,32 +367,28 @@
}
/**
- * Whether this job requires that the device be charging (or be a non-battery-powered
- * device connected to permanent power, such as Android TV devices).
+ * @see JobInfo.Builder#setRequiresCharging(boolean)
*/
public boolean isRequireCharging() {
return (constraintFlags & CONSTRAINT_FLAG_CHARGING) != 0;
}
/**
- * Whether this job needs the device's battery level to not be at below the critical threshold.
+ * @see JobInfo.Builder#setRequiresBatteryNotLow(boolean)
*/
public boolean isRequireBatteryNotLow() {
return (constraintFlags & CONSTRAINT_FLAG_BATTERY_NOT_LOW) != 0;
}
/**
- * Whether this job requires that the user <em>not</em> be interacting with the device.
- *
- * <p class="note">This is <em>not</em> the same as "doze" or "device idle";
- * it is purely about the user's direct interactions.</p>
+ * @see JobInfo.Builder#setRequiresDeviceIdle(boolean)
*/
public boolean isRequireDeviceIdle() {
return (constraintFlags & CONSTRAINT_FLAG_DEVICE_IDLE) != 0;
}
/**
- * Whether this job needs the device's storage to not be low.
+ * @see JobInfo.Builder#setRequiresStorageNotLow(boolean)
*/
public boolean isRequireStorageNotLow() {
return (constraintFlags & CONSTRAINT_FLAG_STORAGE_NOT_LOW) != 0;
@@ -410,6 +404,7 @@
/**
* Which content: URIs must change for the job to be scheduled. Returns null
* if there are none required.
+ * @see JobInfo.Builder#addTriggerContentUri(TriggerContentUri)
*/
public @Nullable TriggerContentUri[] getTriggerContentUris() {
return triggerContentUris;
@@ -418,6 +413,7 @@
/**
* When triggering on content URI changes, this is the delay from when a change
* is detected until the job is scheduled.
+ * @see JobInfo.Builder#setTriggerContentUpdateDelay(long)
*/
public long getTriggerContentUpdateDelay() {
return triggerContentUpdateDelay;
@@ -426,6 +422,7 @@
/**
* When triggering on content URI changes, this is the maximum delay we will
* use before scheduling the job.
+ * @see JobInfo.Builder#setTriggerContentMaxDelay(long)
*/
public long getTriggerContentMaxDelay() {
return triggerContentMaxDelay;
@@ -466,28 +463,59 @@
}
/**
- * Return the estimated size of network traffic that will be performed by
+ * @deprecated replaced by {@link #getEstimatedNetworkDownloadBytes()} and
+ * {@link #getEstimatedNetworkUploadBytes()}.
+ * @removed
+ */
+ @Deprecated
+ public @BytesLong long getEstimatedNetworkBytes() {
+ if (networkDownloadBytes == NETWORK_BYTES_UNKNOWN
+ && networkUploadBytes == NETWORK_BYTES_UNKNOWN) {
+ return NETWORK_BYTES_UNKNOWN;
+ } else if (networkDownloadBytes == NETWORK_BYTES_UNKNOWN) {
+ return networkUploadBytes;
+ } else if (networkUploadBytes == NETWORK_BYTES_UNKNOWN) {
+ return networkDownloadBytes;
+ } else {
+ return networkDownloadBytes + networkUploadBytes;
+ }
+ }
+
+ /**
+ * Return the estimated size of download traffic that will be performed by
* this job, in bytes.
*
- * @return Estimated size of network traffic, or
+ * @return Estimated size of download traffic, or
* {@link #NETWORK_BYTES_UNKNOWN} when unknown.
- * @see Builder#setEstimatedNetworkBytes(long)
+ * @see Builder#setEstimatedNetworkBytes(long, long)
*/
- public @BytesLong long getEstimatedNetworkBytes() {
- return networkBytes;
+ public @BytesLong long getEstimatedNetworkDownloadBytes() {
+ return networkDownloadBytes;
+ }
+
+ /**
+ * Return the estimated size of upload traffic that will be performed by
+ * this job, in bytes.
+ *
+ * @return Estimated size of upload traffic, or
+ * {@link #NETWORK_BYTES_UNKNOWN} when unknown.
+ * @see Builder#setEstimatedNetworkBytes(long, long)
+ */
+ public @BytesLong long getEstimatedNetworkUploadBytes() {
+ return networkUploadBytes;
}
/**
* Set for a job that does not recur periodically, to specify a delay after which the job
* will be eligible for execution. This value is not set if the job recurs periodically.
+ * @see JobInfo.Builder#setMinimumLatency(long)
*/
public long getMinLatencyMillis() {
return minLatencyMillis;
}
/**
- * See {@link Builder#setOverrideDeadline(long)}. This value is not set if the job recurs
- * periodically.
+ * @see JobInfo.Builder#setOverrideDeadline(long)
*/
public long getMaxExecutionDelayMillis() {
return maxExecutionDelayMillis;
@@ -495,13 +523,15 @@
/**
* Track whether this job will repeat with a given period.
+ * @see JobInfo.Builder#setPeriodic(long)
+ * @see JobInfo.Builder#setPeriodic(long, long)
*/
public boolean isPeriodic() {
return isPeriodic;
}
/**
- * @return Whether or not this job should be persisted across device reboots.
+ * @see JobInfo.Builder#setPersisted(boolean)
*/
public boolean isPersisted() {
return isPersisted;
@@ -510,6 +540,8 @@
/**
* Set to the interval between occurrences of this job. This value is <b>not</b> set if the
* job does not recur periodically.
+ * @see JobInfo.Builder#setPeriodic(long)
+ * @see JobInfo.Builder#setPeriodic(long, long)
*/
public long getIntervalMillis() {
return intervalMillis;
@@ -518,6 +550,8 @@
/**
* Flex time for this job. Only valid if this is a periodic job. The job can
* execute at any time in a window of flex length at the end of the period.
+ * @see JobInfo.Builder#setPeriodic(long)
+ * @see JobInfo.Builder#setPeriodic(long, long)
*/
public long getFlexMillis() {
return flexMillis;
@@ -527,6 +561,7 @@
* The amount of time the JobScheduler will wait before rescheduling a failed job. This value
* will be increased depending on the backoff policy specified at job creation time. Defaults
* to 30 seconds, minimum is currently 10 seconds.
+ * @see JobInfo.Builder#setBackoffCriteria(long, int)
*/
public long getInitialBackoffMillis() {
return initialBackoffMillis;
@@ -534,12 +569,27 @@
/**
* Return the backoff policy of this job.
+ * @see JobInfo.Builder#setBackoffCriteria(long, int)
*/
public @BackoffPolicy int getBackoffPolicy() {
return backoffPolicy;
}
/**
+ * @see JobInfo.Builder#setImportantWhileForeground(boolean)
+ */
+ public boolean isImportantWhileForeground() {
+ return (flags & FLAG_IMPORTANT_WHILE_FOREGROUND) != 0;
+ }
+
+ /**
+ * @see JobInfo.Builder#setPrefetch(boolean)
+ */
+ public boolean isPrefetch() {
+ return (flags & FLAG_PREFETCH) != 0;
+ }
+
+ /**
* User can specify an early constraint of 0L, which is valid, so we keep track of whether the
* function was called at all.
* @hide
@@ -610,7 +660,10 @@
if (!Objects.equals(networkRequest, j.networkRequest)) {
return false;
}
- if (networkBytes != j.networkBytes) {
+ if (networkDownloadBytes != j.networkDownloadBytes) {
+ return false;
+ }
+ if (networkUploadBytes != j.networkUploadBytes) {
return false;
}
if (minLatencyMillis != j.minLatencyMillis) {
@@ -673,7 +726,8 @@
if (networkRequest != null) {
hashCode = 31 * hashCode + networkRequest.hashCode();
}
- hashCode = 31 * hashCode + Long.hashCode(networkBytes);
+ hashCode = 31 * hashCode + Long.hashCode(networkDownloadBytes);
+ hashCode = 31 * hashCode + Long.hashCode(networkUploadBytes);
hashCode = 31 * hashCode + Long.hashCode(minLatencyMillis);
hashCode = 31 * hashCode + Long.hashCode(maxExecutionDelayMillis);
hashCode = 31 * hashCode + Boolean.hashCode(isPeriodic);
@@ -708,7 +762,8 @@
} else {
networkRequest = null;
}
- networkBytes = in.readLong();
+ networkDownloadBytes = in.readLong();
+ networkUploadBytes = in.readLong();
minLatencyMillis = in.readLong();
maxExecutionDelayMillis = in.readLong();
isPeriodic = in.readInt() == 1;
@@ -737,7 +792,8 @@
triggerContentUpdateDelay = b.mTriggerContentUpdateDelay;
triggerContentMaxDelay = b.mTriggerContentMaxDelay;
networkRequest = b.mNetworkRequest;
- networkBytes = b.mNetworkBytes;
+ networkDownloadBytes = b.mNetworkDownloadBytes;
+ networkUploadBytes = b.mNetworkUploadBytes;
minLatencyMillis = b.mMinLatencyMillis;
maxExecutionDelayMillis = b.mMaxExecutionDelayMillis;
isPeriodic = b.mIsPeriodic;
@@ -780,7 +836,8 @@
} else {
out.writeInt(0);
}
- out.writeLong(networkBytes);
+ out.writeLong(networkDownloadBytes);
+ out.writeLong(networkUploadBytes);
out.writeLong(minLatencyMillis);
out.writeLong(maxExecutionDelayMillis);
out.writeInt(isPeriodic ? 1 : 0);
@@ -914,7 +971,8 @@
// Requirements.
private int mConstraintFlags;
private NetworkRequest mNetworkRequest;
- private long mNetworkBytes = NETWORK_BYTES_UNKNOWN;
+ private long mNetworkDownloadBytes = NETWORK_BYTES_UNKNOWN;
+ private long mNetworkUploadBytes = NETWORK_BYTES_UNKNOWN;
private ArrayList<TriggerContentUri> mTriggerContentUris;
private long mTriggerContentUpdateDelay = -1;
private long mTriggerContentMaxDelay = -1;
@@ -965,6 +1023,7 @@
/**
* Set optional extras. This is persisted, so we only allow primitive types.
* @param extras Bundle containing extras you want the scheduler to hold on to for you.
+ * @see JobInfo#getExtras()
*/
public Builder setExtras(@NonNull PersistableBundle extras) {
mExtras = extras;
@@ -979,6 +1038,7 @@
* {@link android.app.job.JobInfo.Builder#build()} is called.</p>
*
* @param extras Bundle containing extras you want the scheduler to hold on to for you.
+ * @see JobInfo#getTransientExtras()
*/
public Builder setTransientExtras(@NonNull Bundle extras) {
mTransientExtras = extras;
@@ -1006,6 +1066,8 @@
* a combination of {@link android.content.Intent#FLAG_GRANT_READ_URI_PERMISSION},
* {@link android.content.Intent#FLAG_GRANT_WRITE_URI_PERMISSION}, and
* {@link android.content.Intent#FLAG_GRANT_PREFIX_URI_PERMISSION}.
+ * @see JobInfo#getClipData()
+ * @see JobInfo#getClipGrantFlags()
*/
public Builder setClipData(@Nullable ClipData clip, int grantFlags) {
mClipData = clip;
@@ -1096,6 +1158,16 @@
}
/**
+ * @deprecated replaced by
+ * {@link #setEstimatedNetworkBytes(long, long)}.
+ * @removed
+ */
+ @Deprecated
+ public Builder setEstimatedNetworkBytes(@BytesLong long networkBytes) {
+ return setEstimatedNetworkBytes(networkBytes, NETWORK_BYTES_UNKNOWN);
+ }
+
+ /**
* Set the estimated size of network traffic that will be performed by
* this job, in bytes.
* <p>
@@ -1112,23 +1184,30 @@
* <li>A job that synchronizes email could end up using an extreme range
* of data, from under 1KB when nothing has changed, to dozens of MB
* when there are new emails with attachments. Jobs that cannot provide
- * reasonable estimates should leave this estimated value undefined.
+ * reasonable estimates should use the sentinel value
+ * {@link JobInfo#NETWORK_BYTES_UNKNOWN}.
* </ul>
* Note that the system may choose to delay jobs with large network
* usage estimates when the device has a poor network connection, in
* order to save battery.
+ * <p>
+ * The values provided here only reflect the traffic that will be
+ * performed by the base job; if you're using {@link JobWorkItem} then
+ * you also need to define the network traffic used by each work item
+ * when constructing them.
*
- * @param networkBytes The estimated size of network traffic that will
- * be performed by this job, in bytes. This value only
- * reflects the traffic that will be performed by the base
- * job; if you're using {@link JobWorkItem} then you also
- * need to define the network traffic used by each work item
- * when constructing them.
- * @see JobInfo#getEstimatedNetworkBytes()
- * @see JobWorkItem#JobWorkItem(android.content.Intent, long)
+ * @param downloadBytes The estimated size of network traffic that will
+ * be downloaded by this job, in bytes.
+ * @param uploadBytes The estimated size of network traffic that will be
+ * uploaded by this job, in bytes.
+ * @see JobInfo#getEstimatedNetworkDownloadBytes()
+ * @see JobInfo#getEstimatedNetworkUploadBytes()
+ * @see JobWorkItem#JobWorkItem(android.content.Intent, long, long)
*/
- public Builder setEstimatedNetworkBytes(@BytesLong long networkBytes) {
- mNetworkBytes = networkBytes;
+ public Builder setEstimatedNetworkBytes(@BytesLong long downloadBytes,
+ @BytesLong long uploadBytes) {
+ mNetworkDownloadBytes = downloadBytes;
+ mNetworkUploadBytes = uploadBytes;
return this;
}
@@ -1146,6 +1225,7 @@
*
* @param requiresCharging Pass {@code true} to require that the device be
* charging in order to run the job.
+ * @see JobInfo#isRequireCharging()
*/
public Builder setRequiresCharging(boolean requiresCharging) {
mConstraintFlags = (mConstraintFlags&~CONSTRAINT_FLAG_CHARGING)
@@ -1159,6 +1239,7 @@
* is not low, which is generally the point where the user is given a "low battery"
* warning.
* @param batteryNotLow Whether or not the device's battery level must not be low.
+ * @see JobInfo#isRequireBatteryNotLow()
*/
public Builder setRequiresBatteryNotLow(boolean batteryNotLow) {
mConstraintFlags = (mConstraintFlags&~CONSTRAINT_FLAG_BATTERY_NOT_LOW)
@@ -1183,6 +1264,7 @@
*
* @param requiresDeviceIdle Pass {@code true} to prevent the job from running
* while the device is being used interactively.
+ * @see JobInfo#isRequireDeviceIdle()
*/
public Builder setRequiresDeviceIdle(boolean requiresDeviceIdle) {
mConstraintFlags = (mConstraintFlags&~CONSTRAINT_FLAG_DEVICE_IDLE)
@@ -1196,6 +1278,7 @@
* in a low storage state, which is generally the point where the user is given a
* "low storage" warning.
* @param storageNotLow Whether or not the device's available storage must not be low.
+ * @see JobInfo#isRequireStorageNotLow()
*/
public Builder setRequiresStorageNotLow(boolean storageNotLow) {
mConstraintFlags = (mConstraintFlags&~CONSTRAINT_FLAG_STORAGE_NOT_LOW)
@@ -1228,6 +1311,7 @@
* job}
*
* @param uri The content: URI to monitor.
+ * @see JobInfo#getTriggerContentUris()
*/
public Builder addTriggerContentUri(@NonNull TriggerContentUri uri) {
if (mTriggerContentUris == null) {
@@ -1242,6 +1326,7 @@
* the job is scheduled. If there are more changes during that time, the delay
* will be reset to start at the time of the most recent change.
* @param durationMs Delay after most recent content change, in milliseconds.
+ * @see JobInfo#getTriggerContentUpdateDelay()
*/
public Builder setTriggerContentUpdateDelay(long durationMs) {
mTriggerContentUpdateDelay = durationMs;
@@ -1252,6 +1337,7 @@
* Set the maximum total delay (in milliseconds) that is allowed from the first
* time a content change is detected until the job is scheduled.
* @param durationMs Delay after initial content change, in milliseconds.
+ * @see JobInfo#getTriggerContentMaxDelay()
*/
public Builder setTriggerContentMaxDelay(long durationMs) {
mTriggerContentMaxDelay = durationMs;
@@ -1265,6 +1351,8 @@
* Setting this function on the builder with {@link #setMinimumLatency(long)} or
* {@link #setOverrideDeadline(long)} will result in an error.
* @param intervalMillis Millisecond interval for which this job will repeat.
+ * @see JobInfo#getIntervalMillis()
+ * @see JobInfo#getFlexMillis()
*/
public Builder setPeriodic(long intervalMillis) {
return setPeriodic(intervalMillis, intervalMillis);
@@ -1278,6 +1366,8 @@
* @param flexMillis Millisecond flex for this job. Flex is clamped to be at least
* {@link #getMinFlexMillis()} or 5 percent of the period, whichever is
* higher.
+ * @see JobInfo#getIntervalMillis()
+ * @see JobInfo#getFlexMillis()
*/
public Builder setPeriodic(long intervalMillis, long flexMillis) {
final long minPeriod = getMinPeriodMillis();
@@ -1309,6 +1399,7 @@
* {@link android.app.job.JobInfo.Builder#build()} is called.
* @param minLatencyMillis Milliseconds before which this job will not be considered for
* execution.
+ * @see JobInfo#getMinLatencyMillis()
*/
public Builder setMinimumLatency(long minLatencyMillis) {
mMinLatencyMillis = minLatencyMillis;
@@ -1322,6 +1413,7 @@
* this property on a periodic job, doing so will throw an
* {@link java.lang.IllegalArgumentException} when
* {@link android.app.job.JobInfo.Builder#build()} is called.
+ * @see JobInfo#getMaxExecutionDelayMillis()
*/
public Builder setOverrideDeadline(long maxExecutionDelayMillis) {
mMaxExecutionDelayMillis = maxExecutionDelayMillis;
@@ -1341,6 +1433,8 @@
* mode.
* @param initialBackoffMillis Millisecond time interval to wait initially when job has
* failed.
+ * @see JobInfo#getInitialBackoffMillis()
+ * @see JobInfo#getBackoffPolicy()
*/
public Builder setBackoffCriteria(long initialBackoffMillis,
@BackoffPolicy int backoffPolicy) {
@@ -1371,6 +1465,7 @@
*
* @param importantWhileForeground whether to relax doze restrictions for this job when the
* app is in the foreground. False by default.
+ * @see JobInfo#isImportantWhileForeground()
*/
public Builder setImportantWhileForeground(boolean importantWhileForeground) {
if (importantWhileForeground) {
@@ -1382,6 +1477,15 @@
}
/**
+ * @removed
+ * @deprecated replaced with {@link #setPrefetch(boolean)}
+ */
+ @Deprecated
+ public Builder setIsPrefetch(boolean isPrefetch) {
+ return setPrefetch(isPrefetch);
+ }
+
+ /**
* Setting this to true indicates that this job is designed to prefetch
* content that will make a material improvement to the experience of
* the specific user of this device. For example, fetching top headlines
@@ -1393,12 +1497,13 @@
* network when there is a surplus of metered data available. The system
* may also use this signal in combination with end user usage patterns
* to ensure data is prefetched before the user launches your app.
+ * @see JobInfo#isPrefetch()
*/
- public Builder setIsPrefetch(boolean isPrefetch) {
- if (isPrefetch) {
- mFlags |= FLAG_IS_PREFETCH;
+ public Builder setPrefetch(boolean prefetch) {
+ if (prefetch) {
+ mFlags |= FLAG_PREFETCH;
} else {
- mFlags &= (~FLAG_IS_PREFETCH);
+ mFlags &= (~FLAG_PREFETCH);
}
return this;
}
@@ -1408,6 +1513,7 @@
*
* @param isPersisted True to indicate that the job will be written to
* disk and loaded at boot.
+ * @see JobInfo#isPersisted()
*/
@RequiresPermission(android.Manifest.permission.RECEIVE_BOOT_COMPLETED)
public Builder setPersisted(boolean isPersisted) {
@@ -1427,7 +1533,7 @@
"constraints, this is not allowed.");
}
// Check that network estimates require network type
- if (mNetworkBytes > 0 && mNetworkRequest == null) {
+ if ((mNetworkDownloadBytes > 0 || mNetworkUploadBytes > 0) && mNetworkRequest == null) {
throw new IllegalArgumentException(
"Can't provide estimated network usage without requiring a network");
}
diff --git a/core/java/android/app/job/JobWorkItem.java b/core/java/android/app/job/JobWorkItem.java
index 1c46e8e..995f522 100644
--- a/core/java/android/app/job/JobWorkItem.java
+++ b/core/java/android/app/job/JobWorkItem.java
@@ -16,6 +16,8 @@
package android.app.job;
+import static android.app.job.JobInfo.NETWORK_BYTES_UNKNOWN;
+
import android.annotation.BytesLong;
import android.content.Intent;
import android.os.Parcel;
@@ -28,7 +30,8 @@
*/
final public class JobWorkItem implements Parcelable {
final Intent mIntent;
- final long mNetworkBytes;
+ final long mNetworkDownloadBytes;
+ final long mNetworkUploadBytes;
int mDeliveryCount;
int mWorkId;
Object mGrants;
@@ -41,22 +44,36 @@
*/
public JobWorkItem(Intent intent) {
mIntent = intent;
- mNetworkBytes = JobInfo.NETWORK_BYTES_UNKNOWN;
+ mNetworkDownloadBytes = NETWORK_BYTES_UNKNOWN;
+ mNetworkUploadBytes = NETWORK_BYTES_UNKNOWN;
+ }
+
+ /**
+ * @deprecated replaced by {@link #JobWorkItem(Intent, long, long)}
+ * @removed
+ */
+ @Deprecated
+ public JobWorkItem(Intent intent, @BytesLong long networkBytes) {
+ this(intent, networkBytes, NETWORK_BYTES_UNKNOWN);
}
/**
* Create a new piece of work, which can be submitted to
* {@link JobScheduler#enqueue JobScheduler.enqueue}.
+ * <p>
+ * See {@link JobInfo.Builder#setEstimatedNetworkBytes(long, long)} for
+ * details about how to estimate network traffic.
*
* @param intent The general Intent describing this work.
- * @param networkBytes The estimated size of network traffic that will be
- * performed by this job work item, in bytes. See
- * {@link JobInfo.Builder#setEstimatedNetworkBytes(long)} for
- * details about how to estimate.
+ * @param downloadBytes The estimated size of network traffic that will be
+ * downloaded by this job work item, in bytes.
+ * @param uploadBytes The estimated size of network traffic that will be
+ * uploaded by this job work item, in bytes.
*/
- public JobWorkItem(Intent intent, @BytesLong long networkBytes) {
+ public JobWorkItem(Intent intent, @BytesLong long downloadBytes, @BytesLong long uploadBytes) {
mIntent = intent;
- mNetworkBytes = networkBytes;
+ mNetworkDownloadBytes = downloadBytes;
+ mNetworkUploadBytes = uploadBytes;
}
/**
@@ -67,14 +84,44 @@
}
/**
- * Return the estimated size of network traffic that will be performed by
+ * @deprecated replaced by {@link #getEstimatedNetworkDownloadBytes()} and
+ * {@link #getEstimatedNetworkUploadBytes()}.
+ * @removed
+ */
+ @Deprecated
+ public @BytesLong long getEstimatedNetworkBytes() {
+ if (mNetworkDownloadBytes == NETWORK_BYTES_UNKNOWN
+ && mNetworkUploadBytes == NETWORK_BYTES_UNKNOWN) {
+ return NETWORK_BYTES_UNKNOWN;
+ } else if (mNetworkDownloadBytes == NETWORK_BYTES_UNKNOWN) {
+ return mNetworkUploadBytes;
+ } else if (mNetworkUploadBytes == NETWORK_BYTES_UNKNOWN) {
+ return mNetworkDownloadBytes;
+ } else {
+ return mNetworkDownloadBytes + mNetworkUploadBytes;
+ }
+ }
+
+ /**
+ * Return the estimated size of download traffic that will be performed by
+ * this job, in bytes.
+ *
+ * @return Estimated size of download traffic, or
+ * {@link JobInfo#NETWORK_BYTES_UNKNOWN} when unknown.
+ */
+ public @BytesLong long getEstimatedNetworkDownloadBytes() {
+ return mNetworkDownloadBytes;
+ }
+
+ /**
+ * Return the estimated size of upload traffic that will be performed by
* this job work item, in bytes.
*
- * @return estimated size, or {@link JobInfo#NETWORK_BYTES_UNKNOWN} when
- * unknown.
+ * @return Estimated size of upload traffic, or
+ * {@link JobInfo#NETWORK_BYTES_UNKNOWN} when unknown.
*/
- public @BytesLong long getEstimatedNetworkBytes() {
- return mNetworkBytes;
+ public @BytesLong long getEstimatedNetworkUploadBytes() {
+ return mNetworkUploadBytes;
}
/**
@@ -128,9 +175,13 @@
sb.append(mWorkId);
sb.append(" intent=");
sb.append(mIntent);
- if (mNetworkBytes != JobInfo.NETWORK_BYTES_UNKNOWN) {
- sb.append(" networkBytes=");
- sb.append(mNetworkBytes);
+ if (mNetworkDownloadBytes != NETWORK_BYTES_UNKNOWN) {
+ sb.append(" downloadBytes=");
+ sb.append(mNetworkDownloadBytes);
+ }
+ if (mNetworkUploadBytes != NETWORK_BYTES_UNKNOWN) {
+ sb.append(" uploadBytes=");
+ sb.append(mNetworkUploadBytes);
}
if (mDeliveryCount != 0) {
sb.append(" dcount=");
@@ -151,7 +202,8 @@
} else {
out.writeInt(0);
}
- out.writeLong(mNetworkBytes);
+ out.writeLong(mNetworkDownloadBytes);
+ out.writeLong(mNetworkUploadBytes);
out.writeInt(mDeliveryCount);
out.writeInt(mWorkId);
}
@@ -173,7 +225,8 @@
} else {
mIntent = null;
}
- mNetworkBytes = in.readLong();
+ mNetworkDownloadBytes = in.readLong();
+ mNetworkUploadBytes = in.readLong();
mDeliveryCount = in.readInt();
mWorkId = in.readInt();
}
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/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/etc/hiddenapi-package-whitelist.xml b/data/etc/hiddenapi-package-whitelist.xml
index bacddf14..a4a1b94 100644
--- a/data/etc/hiddenapi-package-whitelist.xml
+++ b/data/etc/hiddenapi-package-whitelist.xml
@@ -64,6 +64,7 @@
<hidden-api-whitelisted-app package="com.android.gallery" />
<hidden-api-whitelisted-app package="com.android.hotspot2" />
<hidden-api-whitelisted-app package="com.android.keychain" />
+ <hidden-api-whitelisted-app package="com.android.launcher3" />
<hidden-api-whitelisted-app package="com.android.location.fused" />
<hidden-api-whitelisted-app package="com.android.managedprovisioning" />
<hidden-api-whitelisted-app package="com.android.mms.service" />
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-land/dimens.xml b/packages/SystemUI/res/values-land/dimens.xml
index e37ca1c..c59492f 100644
--- a/packages/SystemUI/res/values-land/dimens.xml
+++ b/packages/SystemUI/res/values-land/dimens.xml
@@ -24,6 +24,8 @@
<dimen name="brightness_mirror_height">96dp</dimen>
+ <!-- Width for the spacer, used between QS tiles. -->
+ <dimen name="qs_quick_tile_space_width">38dp</dimen>
<dimen name="qs_tile_margin_top">2dp</dimen>
<dimen name="qs_header_tooltip_height">24dp</dimen>
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index ff3f696..91c8724 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -317,6 +317,8 @@
<dimen name="qs_tile_margin_vertical">24dp</dimen>
<dimen name="qs_tile_margin_top">18dp</dimen>
<dimen name="qs_quick_tile_size">48dp</dimen>
+ <!-- Width for the spacer, used between QS tiles. -->
+ <dimen name="qs_quick_tile_space_width">0dp</dimen>
<dimen name="qs_quick_tile_padding">12dp</dimen>
<dimen name="qs_header_gear_translation">16dp</dimen>
<dimen name="qs_header_tile_margin_horizontal">0dp</dimen>
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/QuickQSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java
index 2270b60..c9c04d9 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java
@@ -17,6 +17,7 @@
package com.android.systemui.qs;
import android.content.Context;
+import android.content.res.Configuration;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
@@ -179,16 +180,56 @@
protected final ArrayList<TileRecord> mRecords = new ArrayList<>();
private boolean mListening;
+ /** Size of the QS tile (width & height). */
+ private int mTileDimensionSize;
public HeaderTileLayout(Context context) {
super(context);
setClipChildren(false);
setClipToPadding(false);
- setGravity(Gravity.CENTER_VERTICAL);
+
+ mTileDimensionSize = mContext.getResources().getDimensionPixelSize(
+ R.dimen.qs_quick_tile_size);
+
+ setGravity(Gravity.CENTER);
setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
}
@Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+
+ setGravity(Gravity.CENTER);
+ LayoutParams staticSpaceLayoutParams = generateSpaceLayoutParams(
+ mContext.getResources().getDimensionPixelSize(
+ R.dimen.qs_quick_tile_space_width));
+
+ // Update space params since they fill any open space in portrait orientation and have
+ // a static width in landscape orientation.
+ final int childViewCount = getChildCount();
+ for (int i = 0; i < childViewCount; i++) {
+ View childView = getChildAt(i);
+ if (childView instanceof Space) {
+ childView.setLayoutParams(staticSpaceLayoutParams);
+ }
+ }
+ }
+
+ /**
+ * Returns {@link LayoutParams} based on the given {@code spaceWidth}. If the width is 0,
+ * then we're going to have the space expand to take up as much space as possible. If the
+ * width is non-zero, we want the inter-tile spacers to be fixed.
+ */
+ private LayoutParams generateSpaceLayoutParams(int spaceWidth) {
+ LayoutParams lp = new LayoutParams(spaceWidth, mTileDimensionSize);
+ if (spaceWidth == 0) {
+ lp.weight = 1;
+ }
+ lp.gravity = Gravity.CENTER;
+ return lp;
+ }
+
+ @Override
public void setListening(boolean listening) {
if (mListening == listening) return;
mListening = listening;
@@ -200,25 +241,22 @@
@Override
public void addTile(TileRecord tile) {
if (getChildCount() != 0) {
- // Add a spacer.
- addView(new Space(mContext), getChildCount(), generateSpaceParams());
+ // Add a spacer between tiles. We want static-width spaces if we're in landscape to
+ // keep the tiles close. For portrait, we stick with spaces that fill up any
+ // available space.
+ LayoutParams spaceLayoutParams = generateSpaceLayoutParams(
+ mContext.getResources().getDimensionPixelSize(
+ R.dimen.qs_quick_tile_space_width));
+ addView(new Space(mContext), getChildCount(), spaceLayoutParams);
}
- addView(tile.tileView, getChildCount(), generateLayoutParams());
+
+ addView(tile.tileView, getChildCount(), generateTileLayoutParams());
mRecords.add(tile);
tile.tile.setListening(this, mListening);
}
- private LayoutParams generateSpaceParams() {
- int size = mContext.getResources().getDimensionPixelSize(R.dimen.qs_quick_tile_size);
- LayoutParams lp = new LayoutParams(0, size);
- lp.weight = 1;
- lp.gravity = Gravity.CENTER;
- return lp;
- }
-
- private LayoutParams generateLayoutParams() {
- int size = mContext.getResources().getDimensionPixelSize(R.dimen.qs_quick_tile_size);
- LayoutParams lp = new LayoutParams(size, size);
+ private LayoutParams generateTileLayoutParams() {
+ LayoutParams lp = new LayoutParams(mTileDimensionSize, mTileDimensionSize);
lp.gravity = Gravity.CENTER;
return lp;
}
@@ -237,8 +275,8 @@
}
private int getChildIndex(QSTileView tileView) {
- final int N = getChildCount();
- for (int i = 0; i < N; i++) {
+ final int childViewCount = getChildCount();
+ for (int i = 0; i < childViewCount; i++) {
if (getChildAt(i) == tileView) {
return i;
}
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/NavigationBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
index a39800d..58f8baa 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
@@ -171,7 +171,7 @@
private final OverviewProxyListener mOverviewProxyListener = new OverviewProxyListener() {
@Override
public void onConnectionChanged(boolean isConnected) {
- mNavigationBarView.onOverviewProxyConnectionChanged(isConnected);
+ mNavigationBarView.updateStates();
updateScreenPinningGestures();
WindowManagerWrapper.getInstance()
.setNavBarVirtualKeyHapticFeedbackEnabled(!isConnected);
@@ -188,6 +188,7 @@
@Override
public void onInteractionFlagsChanged(@InteractionType int flags) {
mNavigationBarView.updateStates();
+ updateScreenPinningGestures();
}
};
@@ -925,7 +926,9 @@
private boolean onLongPressRecents() {
if (mRecents == null || !ActivityManager.supportsMultiWindow(getContext())
|| !mDivider.getView().getSnapAlgorithm().isSplitScreenFeasible()
- || Recents.getConfiguration().isLowRamDevice) {
+ || Recents.getConfiguration().isLowRamDevice
+ // If we are connected to the overview service, then disable the recents button
+ || mOverviewProxyService.getProxy() != null) {
return false;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index 88bc6ea..b4cb088 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -681,6 +681,7 @@
updateSlippery();
reloadNavIcons();
updateNavButtonIcons();
+ setUpSwipeUpOnboarding(isQuickStepSwipeUpEnabled());
}
private void updateSlippery() {
@@ -816,11 +817,6 @@
}
}
- public void onOverviewProxyConnectionChanged(boolean isConnected) {
- updateStates();
- setUpSwipeUpOnboarding(isQuickStepSwipeUpEnabled());
- }
-
@Override
protected void onDraw(Canvas canvas) {
mGestureHelper.onDraw(canvas);
@@ -1045,7 +1041,7 @@
onPluginDisconnected(null); // Create default gesture helper
Dependency.get(PluginManager.class).addPluginListener(this,
NavGesture.class, false /* Only one */);
- setUpSwipeUpOnboarding(mOverviewProxyService.getProxy() != null);
+ setUpSwipeUpOnboarding(isQuickStepSwipeUpEnabled());
}
@Override
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/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/job/controllers/ConnectivityController.java b/services/core/java/com/android/server/job/controllers/ConnectivityController.java
index abe55bb..8365fd2 100644
--- a/services/core/java/com/android/server/job/controllers/ConnectivityController.java
+++ b/services/core/java/com/android/server/job/controllers/ConnectivityController.java
@@ -160,7 +160,7 @@
private static boolean isRelaxedSatisfied(JobStatus jobStatus, Network network,
NetworkCapabilities capabilities, Constants constants) {
// Only consider doing this for prefetching jobs
- if ((jobStatus.getJob().getFlags() & JobInfo.FLAG_IS_PREFETCH) == 0) {
+ if (!jobStatus.getJob().isPrefetch()) {
return false;
}
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/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/RecentsAnimationController.java b/services/core/java/com/android/server/wm/RecentsAnimationController.java
index 19d6691..87a7a74 100644
--- a/services/core/java/com/android/server/wm/RecentsAnimationController.java
+++ b/services/core/java/com/android/server/wm/RecentsAnimationController.java
@@ -51,6 +51,7 @@
import com.google.android.collect.Sets;
import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback;
+import com.android.server.wm.utils.InsetUtils;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -400,9 +401,11 @@
if (mainWindow == null) {
return null;
}
+ final Rect insets = new Rect(mainWindow.mContentInsets);
+ InsetUtils.addInsets(insets, mainWindow.mAppToken.getLetterboxInsets());
mTarget = new RemoteAnimationTarget(mTask.mTaskId, MODE_CLOSING, mCapturedLeash,
!mTask.fillsParent(), mainWindow.mWinAnimator.mLastClipRect,
- mainWindow.mContentInsets, mTask.getPrefixOrderIndex(), position, bounds,
+ insets, mTask.getPrefixOrderIndex(), position, bounds,
mTask.getWindowConfiguration(), mIsRecentTaskInvisible);
return mTarget;
}
diff --git a/services/core/java/com/android/server/wm/RemoteAnimationController.java b/services/core/java/com/android/server/wm/RemoteAnimationController.java
index b02a74e..3e7feda 100644
--- a/services/core/java/com/android/server/wm/RemoteAnimationController.java
+++ b/services/core/java/com/android/server/wm/RemoteAnimationController.java
@@ -38,6 +38,7 @@
import com.android.internal.util.FastPrintWriter;
import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback;
+import com.android.server.wm.utils.InsetUtils;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -241,9 +242,11 @@
|| mCapturedLeash == null) {
return null;
}
+ final Rect insets = new Rect(mainWindow.mContentInsets);
+ InsetUtils.addInsets(insets, mAppWindowToken.getLetterboxInsets());
mTarget = new RemoteAnimationTarget(task.mTaskId, getMode(),
mCapturedLeash, !mAppWindowToken.fillsParent(),
- mainWindow.mWinAnimator.mLastClipRect, mainWindow.mContentInsets,
+ mainWindow.mWinAnimator.mLastClipRect, insets,
mAppWindowToken.getPrefixOrderIndex(), mPosition, mStackBounds,
task.getWindowConfiguration(), false /*isNotInRecents*/);
return mTarget;
diff --git a/services/core/java/com/android/server/wm/TaskSnapshotController.java b/services/core/java/com/android/server/wm/TaskSnapshotController.java
index 970a8d7..5f9d679 100644
--- a/services/core/java/com/android/server/wm/TaskSnapshotController.java
+++ b/services/core/java/com/android/server/wm/TaskSnapshotController.java
@@ -27,7 +27,6 @@
import android.app.ActivityManager.TaskSnapshot;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
-import android.graphics.Color;
import android.graphics.GraphicBuffer;
import android.graphics.Rect;
import android.os.Environment;
@@ -45,6 +44,7 @@
import com.android.server.policy.WindowManagerPolicy.ScreenOffListener;
import com.android.server.policy.WindowManagerPolicy.StartingSurface;
import com.android.server.wm.TaskSnapshotSurface.SystemBarBackgroundPainter;
+import com.android.server.wm.utils.InsetUtils;
import com.google.android.collect.Sets;
@@ -273,7 +273,7 @@
return null;
}
return new TaskSnapshot(buffer, top.getConfiguration().orientation,
- getInsetsFromTaskBounds(mainWindow, task),
+ getInsets(mainWindow),
isLowRamDevice /* reduced */, scaleFraction /* scale */,
true /* isRealSnapshot */);
}
@@ -282,11 +282,11 @@
return mIsRunningOnWear || mIsRunningOnTv || mIsRunningOnIoT;
}
- private Rect getInsetsFromTaskBounds(WindowState state, Task task) {
+ private Rect getInsets(WindowState state) {
// XXX(b/72757033): These are insets relative to the window frame, but we're really
// interested in the insets relative to the task bounds.
- Rect insets = minRect(state.mContentInsets, state.mStableInsets);
- insets = maxRect(insets, state.mAppToken.getLetterboxInsets());
+ final Rect insets = minRect(state.mContentInsets, state.mStableInsets);
+ InsetUtils.addInsets(insets, state.mAppToken.getLetterboxInsets());
return insets;
}
@@ -297,13 +297,6 @@
Math.min(rect1.bottom, rect2.bottom));
}
- private Rect maxRect(Rect rect1, Rect rect2) {
- return new Rect(Math.max(rect1.left, rect2.left),
- Math.max(rect1.top, rect2.top),
- Math.max(rect1.right, rect2.right),
- Math.max(rect1.bottom, rect2.bottom));
- }
-
/**
* Retrieves all closing tasks based on the list of closing apps during an app transition.
*/
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/core/java/com/android/server/wm/utils/InsetUtils.java b/services/core/java/com/android/server/wm/utils/InsetUtils.java
new file mode 100644
index 0000000..b4a998a
--- /dev/null
+++ b/services/core/java/com/android/server/wm/utils/InsetUtils.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.server.wm.utils;
+
+import android.graphics.Rect;
+
+/**
+ * Utility methods to handle insets represented as rects.
+ */
+public class InsetUtils {
+
+ private InsetUtils() {
+ }
+
+ /**
+ * Adds {@code insetsToAdd} to {@code inOutInsets}.
+ */
+ public static void addInsets(Rect inOutInsets, Rect insetsToAdd) {
+ inOutInsets.left += insetsToAdd.left;
+ inOutInsets.top += insetsToAdd.top;
+ inOutInsets.right += insetsToAdd.right;
+ inOutInsets.bottom += insetsToAdd.bottom;
+ }
+}
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 44634ab..1e216a3 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -11843,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/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/locksettings/recoverablekeystore/storage/RecoverySnapshotStorageTest.java b/services/tests/servicestests/src/com/android/server/locksettings/recoverablekeystore/storage/RecoverySnapshotStorageTest.java
index ead817a..c772956 100644
--- a/services/tests/servicestests/src/com/android/server/locksettings/recoverablekeystore/storage/RecoverySnapshotStorageTest.java
+++ b/services/tests/servicestests/src/com/android/server/locksettings/recoverablekeystore/storage/RecoverySnapshotStorageTest.java
@@ -7,23 +7,19 @@
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
+import com.android.server.locksettings.recoverablekeystore.TestData;
+
import org.junit.Test;
import org.junit.runner.RunWith;
+import java.security.cert.CertificateException;
import java.util.ArrayList;
@SmallTest
@RunWith(AndroidJUnit4.class)
public class RecoverySnapshotStorageTest {
- private static final KeyChainSnapshot MINIMAL_KEYCHAIN_SNAPSHOT = new KeyChainSnapshot.Builder()
- .setCounterId(1)
- .setSnapshotVersion(1)
- .setServerParams(new byte[0])
- .setMaxAttempts(10)
- .setEncryptedRecoveryKeyBlob(new byte[0])
- .setKeyChainProtectionParams(new ArrayList<>())
- .setWrappedApplicationKeys(new ArrayList<>())
- .build();
+ private static final KeyChainSnapshot MINIMAL_KEYCHAIN_SNAPSHOT =
+ createMinimalKeyChainSnapshot();
private final RecoverySnapshotStorage mRecoverySnapshotStorage = new RecoverySnapshotStorage();
@@ -50,4 +46,21 @@
assertNull(mRecoverySnapshotStorage.get(1000));
}
+
+ private static KeyChainSnapshot createMinimalKeyChainSnapshot() {
+ try {
+ return new KeyChainSnapshot.Builder()
+ .setCounterId(1)
+ .setSnapshotVersion(1)
+ .setServerParams(new byte[0])
+ .setMaxAttempts(10)
+ .setEncryptedRecoveryKeyBlob(new byte[0])
+ .setKeyChainProtectionParams(new ArrayList<>())
+ .setWrappedApplicationKeys(new ArrayList<>())
+ .setTrustedHardwareCertPath(TestData.CERT_PATH_1)
+ .build();
+ } catch (CertificateException e) {
+ throw new RuntimeException(e);
+ }
+ }
}
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");
diff --git a/services/tests/servicestests/src/com/android/server/wm/utils/InsetUtilsTest.java b/services/tests/servicestests/src/com/android/server/wm/utils/InsetUtilsTest.java
new file mode 100644
index 0000000..d0f0fe3
--- /dev/null
+++ b/services/tests/servicestests/src/com/android/server/wm/utils/InsetUtilsTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.server.wm.utils;
+
+import static junit.framework.Assert.assertEquals;
+
+import android.graphics.Rect;
+import android.platform.test.annotations.Presubmit;
+import android.support.test.filters.SmallTest;
+import android.support.test.runner.AndroidJUnit4;
+import android.util.Pair;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+@SmallTest
+@Presubmit
+public class InsetUtilsTest {
+
+ @Test
+ public void testAdd() throws Exception {
+ final Rect rect1 = new Rect(10, 20, 30, 40);
+ final Rect rect2 = new Rect(50, 60, 70, 80);
+ InsetUtils.addInsets(rect1, rect2);
+ assertEquals(new Rect(60, 80, 100, 120), rect1);
+ }
+}
+