Merge "Fixes long press the a11y shortcut no response" into rvc-dev
diff --git a/apex/media/framework/java/android/media/MediaParser.java b/apex/media/framework/java/android/media/MediaParser.java
index b3c82bc..073fddf 100644
--- a/apex/media/framework/java/android/media/MediaParser.java
+++ b/apex/media/framework/java/android/media/MediaParser.java
@@ -850,7 +850,7 @@
private final InputReadingDataSource mDataSource;
private final DataReaderAdapter mScratchDataReaderAdapter;
private final ParsableByteArrayAdapter mScratchParsableByteArrayAdapter;
- private String mExtractorName;
+ private String mParserName;
private Extractor mExtractor;
private ExtractorInput mExtractorInput;
private long mPendingSeekPosition;
@@ -924,7 +924,7 @@
@NonNull
@ParserName
public String getParserName() {
- return mExtractorName;
+ return mParserName;
}
/**
@@ -958,15 +958,15 @@
// TODO: Apply parameters when creating extractor instances.
if (mExtractor == null) {
- if (!mExtractorName.equals(PARSER_NAME_UNKNOWN)) {
- mExtractor = EXTRACTOR_FACTORIES_BY_NAME.get(mExtractorName).createInstance();
+ if (!mParserName.equals(PARSER_NAME_UNKNOWN)) {
+ mExtractor = createExtractor(mParserName);
mExtractor.init(new ExtractorOutputAdapter());
} else {
for (String parserName : mParserNamesPool) {
Extractor extractor = createExtractor(parserName);
try {
if (extractor.sniff(mExtractorInput)) {
- mExtractorName = parserName;
+ mParserName = parserName;
mExtractor = extractor;
mExtractor.init(new ExtractorOutputAdapter());
break;
@@ -1044,7 +1044,7 @@
mParserParameters = new HashMap<>();
mOutputConsumer = outputConsumer;
mParserNamesPool = parserNamesPool;
- mExtractorName = sniff ? PARSER_NAME_UNKNOWN : parserNamesPool[0];
+ mParserName = sniff ? PARSER_NAME_UNKNOWN : parserNamesPool[0];
mPositionHolder = new PositionHolder();
mDataSource = new InputReadingDataSource();
removePendingSeek();
@@ -1090,7 +1090,7 @@
getBooleanParameter(PARAMETER_MP4_IGNORE_EDIT_LISTS)
? Mp4Extractor.FLAG_WORKAROUND_IGNORE_EDIT_LISTS
: 0;
- return new Mp4Extractor();
+ return new Mp4Extractor(flags);
case PARSER_NAME_MP3:
flags |=
getBooleanParameter(PARAMETER_MP3_DISABLE_ID3)
diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java
index 3a708a6..8e0d939 100644
--- a/core/java/android/app/AppOpsManager.java
+++ b/core/java/android/app/AppOpsManager.java
@@ -2586,6 +2586,44 @@
}
/**
+ * Returns a listenerId suitable for use with {@link #noteOp(int, int, String, String, String)}.
+ *
+ * This is intended for use client side, when the receiver id must be created before the
+ * associated call is made to the system server. If using {@link PendingIntent} as the receiver,
+ * avoid using this method as it will include a pointless additional x-process call. Instead to
+ * prefer passing the PendingIntent to the system server, and then invoking
+ * {@link #toReceiverId(PendingIntent)} instead.
+ *
+ * @param obj the receiver in use
+ * @return a string representation of the receiver suitable for app ops use
+ * @hide
+ */
+ // TODO: this should probably be @SystemApi as well
+ public static @NonNull String toReceiverId(@NonNull Object obj) {
+ if (obj instanceof PendingIntent) {
+ return toReceiverId((PendingIntent) obj);
+ } else {
+ return obj.getClass().getName() + "@" + System.identityHashCode(obj);
+ }
+ }
+
+ /**
+ * Returns a listenerId suitable for use with {@link #noteOp(int, int, String, String, String)}.
+ *
+ * This is intended for use server side, where ActivityManagerService can be referenced without
+ * an additional x-process call.
+ *
+ * @param pendingIntent the pendingIntent in use
+ * @return a string representation of the pending intent suitable for app ops use
+ * @see #toReceiverId(Object)
+ * @hide
+ */
+ // TODO: this should probably be @SystemApi as well
+ public static @NonNull String toReceiverId(@NonNull PendingIntent pendingIntent) {
+ return pendingIntent.getTag("");
+ }
+
+ /**
* When to not enforce {@link #setUserRestriction restrictions}.
*
* @hide
diff --git a/core/java/android/app/TEST_MAPPING b/core/java/android/app/TEST_MAPPING
index ab86860..344a4d7 100644
--- a/core/java/android/app/TEST_MAPPING
+++ b/core/java/android/app/TEST_MAPPING
@@ -20,6 +20,10 @@
},
{
"file_patterns": ["(/|^)AppOpsManager.java"],
+ "name": "UidAtomTests:testAppOps"
+ },
+ {
+ "file_patterns": ["(/|^)AppOpsManager.java"],
"name": "FrameworksServicesTests",
"options": [
{
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index fb9adb7..41e2dc0 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -3666,6 +3666,28 @@
}
/**
+ * Returns whether the given user's credential will be sufficient for all password policy
+ * requirement, once the user's profile has switched to unified challenge.
+ *
+ * <p>This is different from {@link #isActivePasswordSufficient()} since once the profile
+ * switches to unified challenge, policies set explicitly on the profile will start to affect
+ * the parent user.
+ * @param userHandle the user whose password requirement will be checked
+ * @param profileUser the profile user whose lockscreen challenge will be unified.
+ * @hide
+ */
+ public boolean isPasswordSufficientAfterProfileUnification(int userHandle, int profileUser) {
+ if (mService != null) {
+ try {
+ return mService.isPasswordSufficientAfterProfileUnification(userHandle,
+ profileUser);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+ return false;
+ }
+ /**
* Retrieve the number of times the user has failed at entering a password since that last
* successful password entry.
* <p>
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index 591a3f6..d10153c 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -85,6 +85,7 @@
boolean isActivePasswordSufficient(int userHandle, boolean parent);
boolean isProfileActivePasswordSufficientForParent(int userHandle);
+ boolean isPasswordSufficientAfterProfileUnification(int userHandle, int profileUser);
int getPasswordComplexity(boolean parent);
boolean isUsingUnifiedPassword(in ComponentName admin);
int getCurrentFailedPasswordAttempts(int userHandle, boolean parent);
diff --git a/core/java/android/app/admin/PasswordMetrics.java b/core/java/android/app/admin/PasswordMetrics.java
index 86ebb47..39e1f0d 100644
--- a/core/java/android/app/admin/PasswordMetrics.java
+++ b/core/java/android/app/admin/PasswordMetrics.java
@@ -350,7 +350,7 @@
*
* TODO: move to PasswordPolicy
*/
- private void maxWith(PasswordMetrics other) {
+ public void maxWith(PasswordMetrics other) {
credType = Math.max(credType, other.credType);
if (credType != CREDENTIAL_TYPE_PASSWORD) {
return;
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 9ca2db9..d36d583 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -3158,6 +3158,23 @@
"android.content.pm.extra.VERIFICATION_LONG_VERSION_CODE";
/**
+ * Extra field name for the Merkle tree root hash of a package.
+ * <p>Passed to a package verifier both prior to verification and as a result
+ * of verification.
+ * <p>The value of the extra is a specially formatted list:
+ * {@code filename1:HASH_1;filename2:HASH_2;...;filenameN:HASH_N}
+ * <p>The extra must include an entry for every APK within an installation. If
+ * a hash is not physically present, a hash value of {@code 0} will be used.
+ * <p>The root hash is generated using SHA-256, no salt with a 4096 byte block
+ * size. See the description of the
+ * <a href="https://www.kernel.org/doc/html/latest/filesystems/fsverity.html#merkle-tree">fs-verity merkle-tree</a>
+ * for more details.
+ * @hide
+ */
+ public static final String EXTRA_VERIFICATION_ROOT_HASH =
+ "android.content.pm.extra.EXTRA_VERIFICATION_ROOT_HASH";
+
+ /**
* Extra field name for the ID of a intent filter pending verification.
* Passed to an intent filter verifier and is used to call back to
* {@link #verifyIntentFilter}
diff --git a/core/java/android/net/UrlQuerySanitizer.java b/core/java/android/net/UrlQuerySanitizer.java
index cf08b65..b1cf044 100644
--- a/core/java/android/net/UrlQuerySanitizer.java
+++ b/core/java/android/net/UrlQuerySanitizer.java
@@ -306,7 +306,7 @@
return null;
}
int length = value.length();
- if ((mFlags & SCRIPT_URL_OK) != 0) {
+ if ((mFlags & SCRIPT_URL_OK) == 0) {
if (length >= MIN_SCRIPT_PREFIX_LENGTH) {
String asLower = value.toLowerCase(Locale.ROOT);
if (asLower.startsWith(JAVASCRIPT_PREFIX) ||
diff --git a/core/java/android/os/incremental/V4Signature.java b/core/java/android/os/incremental/V4Signature.java
index 5cc73ca..d35ce5b 100644
--- a/core/java/android/os/incremental/V4Signature.java
+++ b/core/java/android/os/incremental/V4Signature.java
@@ -16,6 +16,8 @@
package android.os.incremental;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.os.ParcelFileDescriptor;
import java.io.ByteArrayInputStream;
@@ -45,8 +47,8 @@
public static class HashingInfo {
public final int hashAlgorithm; // only 1 == SHA256 supported
public final byte log2BlockSize; // only 12 (block size 4096) supported now
- public final byte[] salt; // used exactly as in fs-verity, 32 bytes max
- public final byte[] rawRootHash; // salted digest of the first Merkle tree page
+ @Nullable public final byte[] salt; // used exactly as in fs-verity, 32 bytes max
+ @Nullable public final byte[] rawRootHash; // salted digest of the first Merkle tree page
HashingInfo(int hashAlgorithm, byte log2BlockSize, byte[] salt, byte[] rawRootHash) {
this.hashAlgorithm = hashAlgorithm;
@@ -58,7 +60,8 @@
/**
* Constructs HashingInfo from byte array.
*/
- public static HashingInfo fromByteArray(byte[] bytes) throws IOException {
+ @NonNull
+ public static HashingInfo fromByteArray(@NonNull byte[] bytes) throws IOException {
ByteBuffer buffer = ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN);
final int hashAlgorithm = buffer.getInt();
final byte log2BlockSize = buffer.get();
@@ -106,8 +109,18 @@
}
public final int version; // Always 2 for now.
- public final byte[] hashingInfo;
- public final byte[] signingInfo; // Passed as-is to the kernel. Can be retrieved later.
+ /**
+ * Raw byte array containing the IncFS hashing data.
+ * @see HashingInfo#fromByteArray(byte[])
+ */
+ @Nullable public final byte[] hashingInfo;
+
+ /**
+ * Raw byte array containing the V4 signature data.
+ * <p>Passed as-is to the kernel. Can be retrieved later.
+ * @see SigningInfo#fromByteArray(byte[])
+ */
+ @Nullable public final byte[] signingInfo;
/**
* Construct a V4Signature from .idsig file.
@@ -121,7 +134,8 @@
/**
* Construct a V4Signature from a byte array.
*/
- public static V4Signature readFrom(byte[] bytes) throws IOException {
+ @NonNull
+ public static V4Signature readFrom(@NonNull byte[] bytes) throws IOException {
try (InputStream stream = new ByteArrayInputStream(bytes)) {
return readFrom(stream);
}
@@ -169,7 +183,7 @@
return this.version == SUPPORTED_VERSION;
}
- private V4Signature(int version, byte[] hashingInfo, byte[] signingInfo) {
+ private V4Signature(int version, @Nullable byte[] hashingInfo, @Nullable byte[] signingInfo) {
this.version = version;
this.hashingInfo = hashingInfo;
this.signingInfo = signingInfo;
diff --git a/core/java/android/service/autofill/InlinePresentation.java b/core/java/android/service/autofill/InlinePresentation.java
index 63b3804..9cf1b87 100644
--- a/core/java/android/service/autofill/InlinePresentation.java
+++ b/core/java/android/service/autofill/InlinePresentation.java
@@ -19,7 +19,6 @@
import android.annotation.NonNull;
import android.annotation.Size;
import android.app.slice.Slice;
-import android.compat.annotation.UnsupportedAppUsage;
import android.os.Parcel;
import android.os.Parcelable;
import android.widget.inline.InlinePresentationSpec;
@@ -67,18 +66,6 @@
return hints.toArray(new String[hints.size()]);
}
- /**
- * @hide
- * @removed
- */
- @UnsupportedAppUsage
- public InlinePresentation(
- @NonNull Slice slice,
- @NonNull android.view.inline.InlinePresentationSpec inlinePresentationSpec,
- boolean pinned) {
- this(slice, inlinePresentationSpec.toWidget(), pinned);
- }
-
// Code below generated by codegen v1.0.15.
@@ -245,7 +232,7 @@
};
@DataClass.Generated(
- time = 1585633564226L,
+ time = 1586992400667L,
codegenVersion = "1.0.15",
sourceFile = "frameworks/base/core/java/android/service/autofill/InlinePresentation.java",
inputSignatures = "private final @android.annotation.NonNull android.app.slice.Slice mSlice\nprivate final @android.annotation.NonNull android.widget.inline.InlinePresentationSpec mInlinePresentationSpec\nprivate final boolean mPinned\npublic @android.annotation.NonNull @android.annotation.Size(min=0L) java.lang.String[] getAutofillHints()\nclass InlinePresentation extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genHiddenConstDefs=true, genEqualsHashCode=true)")
diff --git a/core/java/android/service/dreams/DreamService.java b/core/java/android/service/dreams/DreamService.java
index 3f07873..337027e 100644
--- a/core/java/android/service/dreams/DreamService.java
+++ b/core/java/android/service/dreams/DreamService.java
@@ -182,7 +182,6 @@
private Window mWindow;
private Activity mActivity;
private boolean mInteractive;
- private boolean mLowProfile = true;
private boolean mFullscreen;
private boolean mScreenBright = true;
private boolean mStarted;
@@ -530,32 +529,6 @@
}
/**
- * Sets View.SYSTEM_UI_FLAG_LOW_PROFILE on the content view.
- *
- * @param lowProfile True to set View.SYSTEM_UI_FLAG_LOW_PROFILE
- * @hide There is no reason to have this -- dreams can set this flag
- * on their own content view, and from there can actually do the
- * correct interactions with it (seeing when it is cleared etc).
- */
- public void setLowProfile(boolean lowProfile) {
- if (mLowProfile != lowProfile) {
- mLowProfile = lowProfile;
- int flag = View.SYSTEM_UI_FLAG_LOW_PROFILE;
- applySystemUiVisibilityFlags(mLowProfile ? flag : 0, flag);
- }
- }
-
- /**
- * Returns whether or not this dream is in low profile mode. Defaults to true.
- *
- * @see #setLowProfile(boolean)
- * @hide
- */
- public boolean isLowProfile() {
- return getSystemUiVisibilityFlagValue(View.SYSTEM_UI_FLAG_LOW_PROFILE, mLowProfile);
- }
-
- /**
* Controls {@link android.view.WindowManager.LayoutParams#FLAG_FULLSCREEN}
* on the dream's window.
*
@@ -1094,10 +1067,6 @@
// along well. Dreams usually don't need such bars anyways, so disable them by default.
mWindow.clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
- applySystemUiVisibilityFlags(
- (mLowProfile ? View.SYSTEM_UI_FLAG_LOW_PROFILE : 0),
- View.SYSTEM_UI_FLAG_LOW_PROFILE);
-
mWindow.getDecorView().addOnAttachStateChangeListener(
new View.OnAttachStateChangeListener() {
@Override
@@ -1126,18 +1095,6 @@
}
}
- private boolean getSystemUiVisibilityFlagValue(int flag, boolean defaultValue) {
- View v = mWindow == null ? null : mWindow.getDecorView();
- return v == null ? defaultValue : (v.getSystemUiVisibility() & flag) != 0;
- }
-
- private void applySystemUiVisibilityFlags(int flags, int mask) {
- View v = mWindow == null ? null : mWindow.getDecorView();
- if (v != null) {
- v.setSystemUiVisibility(applyFlags(v.getSystemUiVisibility(), flags, mask));
- }
- }
-
private int applyFlags(int oldFlags, int flags, int mask) {
return (oldFlags&~mask) | (flags&mask);
}
@@ -1163,7 +1120,6 @@
pw.println(" window: " + mWindow);
pw.print(" flags:");
if (isInteractive()) pw.print(" interactive");
- if (isLowProfile()) pw.print(" lowprofile");
if (isFullscreen()) pw.print(" fullscreen");
if (isScreenBright()) pw.print(" bright");
if (isWindowless()) pw.print(" windowless");
diff --git a/core/java/android/service/notification/StatusBarNotification.java b/core/java/android/service/notification/StatusBarNotification.java
index 21b83c6..5c43f8f 100644
--- a/core/java/android/service/notification/StatusBarNotification.java
+++ b/core/java/android/service/notification/StatusBarNotification.java
@@ -292,6 +292,18 @@
return this.user.getIdentifier();
}
+ /**
+ * Like {@link #getUserId()} but handles special users.
+ * @hide
+ */
+ public int getNormalizedUserId() {
+ int userId = getUserId();
+ if (userId == UserHandle.USER_ALL) {
+ userId = UserHandle.USER_SYSTEM;
+ }
+ return userId;
+ }
+
/** The package that the notification belongs to. */
public String getPackageName() {
return pkg;
diff --git a/core/java/android/speech/RecognizerIntent.java b/core/java/android/speech/RecognizerIntent.java
index 362b94b..3b5a6d5 100644
--- a/core/java/android/speech/RecognizerIntent.java
+++ b/core/java/android/speech/RecognizerIntent.java
@@ -413,6 +413,10 @@
* {@link #ACTION_VOICE_SEARCH_HANDS_FREE}, {@link #ACTION_WEB_SEARCH} to indicate whether to
* only use an offline speech recognition engine. The default is false, meaning that either
* network or offline recognition engines may be used.
+ *
+ * <p>Depending on the recognizer implementation, these values may have
+ * no effect.</p>
+ *
*/
public static final String EXTRA_PREFER_OFFLINE = "android.speech.extra.PREFER_OFFLINE";
}
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java
index 1086774..76ed37c 100644
--- a/core/java/android/view/SurfaceControl.java
+++ b/core/java/android/view/SurfaceControl.java
@@ -228,6 +228,7 @@
*/
public long mNativeObject;
private long mNativeHandle;
+ private Throwable mReleaseStack = null;
// TODO: Move this to native.
private final Object mSizeLock = new Object();
@@ -426,11 +427,18 @@
if (mNativeObject != 0) {
release();
}
- if (nativeObject != 0) {
+ if (nativeObject != 0) {
mCloseGuard.open("release");
}
mNativeObject = nativeObject;
mNativeHandle = mNativeObject != 0 ? nativeGetHandle(nativeObject) : 0;
+ if (mNativeObject == 0) {
+ if (Build.IS_DEBUGGABLE) {
+ mReleaseStack = new Throwable("assigned zero nativeObject here");
+ }
+ } else {
+ mReleaseStack = null;
+ }
}
/**
@@ -989,11 +997,22 @@
nativeRelease(mNativeObject);
mNativeObject = 0;
mNativeHandle = 0;
+ if (Build.IS_DEBUGGABLE) {
+ mReleaseStack = new Throwable("released here");
+ }
mCloseGuard.close();
}
}
/**
+ * Returns the call stack that assigned mNativeObject to zero.
+ * @hide
+ */
+ public Throwable getReleaseStack() {
+ return mReleaseStack;
+ }
+
+ /**
* Disconnect any client still connected to the surface.
* @hide
*/
@@ -1004,8 +1023,11 @@
}
private void checkNotReleased() {
- if (mNativeObject == 0) throw new NullPointerException(
- "mNativeObject is null. Have you called release() already?");
+ if (mNativeObject == 0) {
+ Log.wtf(TAG, "Invalid " + this + " caused by:", mReleaseStack);
+ throw new NullPointerException(
+ "mNativeObject of " + this + " is null. Have you called release() already?");
+ }
}
/**
diff --git a/core/java/android/view/autofill/AutofillManager.java b/core/java/android/view/autofill/AutofillManager.java
index 83a7934..6d3dbfe 100644
--- a/core/java/android/view/autofill/AutofillManager.java
+++ b/core/java/android/view/autofill/AutofillManager.java
@@ -1258,13 +1258,6 @@
}
}
- if (mForAugmentedAutofillOnly) {
- if (sVerbose) {
- Log.v(TAG, "notifyValueChanged(): not notifying system server on "
- + "augmented-only mode");
- }
- return;
- }
if (!mEnabled || !isActiveLocked()) {
if (!startAutofillIfNeededLocked(view)) {
if (sVerbose) {
@@ -1299,10 +1292,6 @@
return;
}
synchronized (mLock) {
- if (mForAugmentedAutofillOnly) {
- if (sVerbose) Log.v(TAG, "notifyValueChanged(): ignoring on augmented only mode");
- return;
- }
if (!mEnabled || !isActiveLocked()) {
if (sVerbose) {
Log.v(TAG, "notifyValueChanged(" + view.getAutofillId() + ":" + virtualId
diff --git a/core/java/android/view/inline/InlineContentView.java b/core/java/android/view/inline/InlineContentView.java
deleted file mode 100644
index 3df201c..0000000
--- a/core/java/android/view/inline/InlineContentView.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.view.inline;
-
-import android.annotation.NonNull;
-import android.annotation.Nullable;
-import android.content.Context;
-import android.graphics.PixelFormat;
-import android.util.AttributeSet;
-import android.view.SurfaceControl;
-import android.view.SurfaceControlViewHost;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-import android.view.ViewGroup;
-
-/**
- * This class represents a view that holds opaque content from another app that
- * you can inline in your UI.
- *
- * <p>Since the content presented by this view is from another security domain,it is
- * shown on a remote surface preventing the host application from accessing that content.
- * Also the host application cannot interact with the inlined content by injecting touch
- * events or clicking programmatically.
- *
- * <p>This view can be overlaid by other windows, i.e. redressed, but if this is the case
- * the inined UI would not be interactive. Sometimes this is desirable, e.g. animating
- * transitions.
- *
- * <p>By default the surface backing this view is shown on top of the hosting window such
- * that the inlined content is interactive. However, you can temporarily move the surface
- * under the hosting window which could be useful in some cases, e.g. animating transitions.
- * At this point the inlined content will not be interactive and the touch events would
- * be delivered to your app.
- *
- * @hide
- * @removed
- */
-public class InlineContentView extends ViewGroup {
-
- /**
- * Callback for observing the lifecycle of the surface control
- * that manipulates the backing secure embedded UI surface.
- */
- public interface SurfaceControlCallback {
- /**
- * Called when the backing surface is being created.
- *
- * @param surfaceControl The surface control to manipulate the surface.
- */
- void onCreated(@NonNull SurfaceControl surfaceControl);
-
- /**
- * Called when the backing surface is being destroyed.
- *
- * @param surfaceControl The surface control to manipulate the surface.
- */
- void onDestroyed(@NonNull SurfaceControl surfaceControl);
- }
-
- private final @NonNull SurfaceHolder.Callback mSurfaceCallback = new SurfaceHolder.Callback() {
- @Override
- public void surfaceCreated(@NonNull SurfaceHolder holder) {
- mSurfaceControlCallback.onCreated(mSurfaceView.getSurfaceControl());
- }
-
- @Override
- public void surfaceChanged(@NonNull SurfaceHolder holder,
- int format, int width, int height) {
- /* do nothing */
- }
-
- @Override
- public void surfaceDestroyed(@NonNull SurfaceHolder holder) {
- mSurfaceControlCallback.onDestroyed(mSurfaceView.getSurfaceControl());
- }
- };
-
- private final @NonNull SurfaceView mSurfaceView;
-
- private @Nullable SurfaceControlCallback mSurfaceControlCallback;
-
- /**
- * @inheritDoc
- *
- * @hide
- */
- public InlineContentView(@NonNull Context context) {
- this(context, null);
- }
-
- /**
- * @inheritDoc
- *
- * @hide
- */
- public InlineContentView(@NonNull Context context, @Nullable AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- /**
- * @inheritDoc
- *
- * @hide
- */
- public InlineContentView(@NonNull Context context, @Nullable AttributeSet attrs,
- int defStyleAttr) {
- this(context, attrs, defStyleAttr, 0);
- }
-
- /**
- * Gets the surface control. If the surface is not created this method
- * returns {@code null}.
- *
- * @return The surface control.
- *
- * @see #setSurfaceControlCallback(SurfaceControlCallback)
- */
- public @Nullable SurfaceControl getSurfaceControl() {
- return mSurfaceView.getSurfaceControl();
- }
-
- /**
- * @inheritDoc
- *
- * @hide
- */
- public InlineContentView(@NonNull Context context, @Nullable AttributeSet attrs,
- int defStyleAttr, int defStyleRes) {
- super(context, attrs, defStyleAttr, defStyleRes);
- mSurfaceView = new SurfaceView(context, attrs, defStyleAttr, defStyleRes);
- mSurfaceView.setZOrderOnTop(true);
- mSurfaceView.getHolder().setFormat(PixelFormat.TRANSPARENT);
- addView(mSurfaceView);
- }
-
- /**
- * Sets the embedded UI.
- * @param surfacePackage The embedded UI.
- *
- * @hide
- */
- public void setChildSurfacePackage(
- @Nullable SurfaceControlViewHost.SurfacePackage surfacePackage) {
- mSurfaceView.setChildSurfacePackage(surfacePackage);
- }
-
- @Override
- public void onLayout(boolean changed, int l, int t, int r, int b) {
- mSurfaceView.layout(0, 0, getMeasuredWidth(), getMeasuredHeight());
- }
-
- /**
- * Sets a callback to observe the lifecycle of the surface control for
- * managing the backing surface.
- *
- * @param callback The callback to set or {@code null} to clear.
- */
- public void setSurfaceControlCallback(@Nullable SurfaceControlCallback callback) {
- if (mSurfaceControlCallback != null) {
- mSurfaceView.getHolder().removeCallback(mSurfaceCallback);
- }
- mSurfaceControlCallback = callback;
- if (mSurfaceControlCallback != null) {
- mSurfaceView.getHolder().addCallback(mSurfaceCallback);
- }
- }
-
- /**
- * @return Whether the surface backing this view appears on top of its parent.
- *
- * @see #setZOrderedOnTop(boolean)
- */
- public boolean isZOrderedOnTop() {
- return mSurfaceView.isZOrderedOnTop();
- }
-
- /**
- * Controls whether the backing surface is placed on top of this view's window.
- * Normally, it is placed on top of the window, to allow interaction
- * with the inlined UI. Via this method, you can place the surface below the
- * window. This means that all of the contents of the window this view is in
- * will be visible on top of its surface.
- *
- * <p> The Z ordering can be changed dynamically if the backing surface is
- * created, otherwise the ordering would be applied at surface construction time.
- *
- * @param onTop Whether to show the surface on top of this view's window.
- *
- * @see #isZOrderedOnTop()
- */
- public boolean setZOrderedOnTop(boolean onTop) {
- return mSurfaceView.setZOrderedOnTop(onTop, /*allowDynamicChange*/ true);
- }
-}
diff --git a/core/java/android/view/inline/InlinePresentationSpec.aidl b/core/java/android/view/inline/InlinePresentationSpec.aidl
deleted file mode 100644
index 680ee4e..0000000
--- a/core/java/android/view/inline/InlinePresentationSpec.aidl
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.view.inline;
-
-/**
- * @hide
- * @removed
- */
-parcelable InlinePresentationSpec;
diff --git a/core/java/android/view/inline/InlinePresentationSpec.java b/core/java/android/view/inline/InlinePresentationSpec.java
deleted file mode 100644
index d777cb8..0000000
--- a/core/java/android/view/inline/InlinePresentationSpec.java
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.view.inline;
-
-import android.annotation.NonNull;
-import android.annotation.Nullable;
-import android.compat.annotation.UnsupportedAppUsage;
-import android.os.Bundle;
-import android.os.Parcelable;
-import android.util.Size;
-
-import com.android.internal.util.DataClass;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * This class represents the presentation specification by which an inline suggestion
- * should abide when constructing its UI. Since suggestions are inlined in a
- * host application while provided by another source, they need to be consistent
- * with the host's look at feel to allow building smooth and integrated UIs.
- *
- * @hide
- * @removed
- */
-@DataClass(genEqualsHashCode = true, genToString = true, genBuilder = true)
-public final class InlinePresentationSpec implements Parcelable {
-
- /** The minimal size of the suggestion. */
- @NonNull
- private final Size mMinSize;
- /** The maximal size of the suggestion. */
- @NonNull
- private final Size mMaxSize;
-
- /**
- * The extras encoding the UI style information. Defaults to {@code Bundle.EMPTY} in which case
- * the default system UI style will be used.
- */
- @NonNull
- private final Bundle mStyle;
-
- private static Bundle defaultStyle() {
- return Bundle.EMPTY;
- }
-
- /** @hide */
- @DataClass.Suppress({"setMaxSize", "setMinSize"})
- abstract static class BaseBuilder {
- }
-
- /**
- * @hide
- */
- public android.widget.inline.InlinePresentationSpec toWidget() {
- final android.widget.inline.InlinePresentationSpec.Builder builder =
- new android.widget.inline.InlinePresentationSpec.Builder(
- getMinSize(), getMaxSize());
- final Bundle style = getStyle();
- if (style != null) {
- builder.setStyle(style);
- }
- return builder.build();
- }
-
- /**
- * @hide
- */
- public static android.view.inline.InlinePresentationSpec fromWidget(
- android.widget.inline.InlinePresentationSpec widget) {
- final android.view.inline.InlinePresentationSpec.Builder builder =
- new android.view.inline.InlinePresentationSpec.Builder(
- widget.getMinSize(), widget.getMaxSize());
- final Bundle style = widget.getStyle();
- if (style != null) {
- builder.setStyle(style);
- }
- return builder.build();
- }
-
- /**
- * @hide
- */
- public static List<android.view.inline.InlinePresentationSpec> fromWidgets(
- List<android.widget.inline.InlinePresentationSpec> widgets) {
- final ArrayList<android.view.inline.InlinePresentationSpec> convertedSpecs =
- new ArrayList<>();
- for (int i = 0; i < widgets.size(); i++) {
- convertedSpecs.add(fromWidget(widgets.get(i)));
- }
- return convertedSpecs;
- }
-
-
-
- // Code below generated by codegen v1.0.15.
- //
- // DO NOT MODIFY!
- // CHECKSTYLE:OFF Generated code
- //
- // To regenerate run:
- // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/view/inline/InlinePresentationSpec.java
- //
- // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
- // Settings > Editor > Code Style > Formatter Control
- //@formatter:off
-
-
- @DataClass.Generated.Member
- /* package-private */ InlinePresentationSpec(
- @NonNull Size minSize,
- @NonNull Size maxSize,
- @NonNull Bundle style) {
- this.mMinSize = minSize;
- com.android.internal.util.AnnotationValidations.validate(
- NonNull.class, null, mMinSize);
- this.mMaxSize = maxSize;
- com.android.internal.util.AnnotationValidations.validate(
- NonNull.class, null, mMaxSize);
- this.mStyle = style;
- com.android.internal.util.AnnotationValidations.validate(
- NonNull.class, null, mStyle);
-
- // onConstructed(); // You can define this method to get a callback
- }
-
- /**
- * The minimal size of the suggestion.
- */
- @UnsupportedAppUsage
- @DataClass.Generated.Member
- public @NonNull Size getMinSize() {
- return mMinSize;
- }
-
- /**
- * The maximal size of the suggestion.
- */
- @UnsupportedAppUsage
- @DataClass.Generated.Member
- public @NonNull Size getMaxSize() {
- return mMaxSize;
- }
-
- /**
- * The extras encoding the UI style information. Defaults to {@code Bundle.EMPTY} in which case
- * the default system UI style will be used.
- */
- @DataClass.Generated.Member
- public @NonNull Bundle getStyle() {
- return mStyle;
- }
-
- @Override
- @DataClass.Generated.Member
- public String toString() {
- // You can override field toString logic by defining methods like:
- // String fieldNameToString() { ... }
-
- return "InlinePresentationSpec { " +
- "minSize = " + mMinSize + ", " +
- "maxSize = " + mMaxSize + ", " +
- "style = " + mStyle +
- " }";
- }
-
- @Override
- @DataClass.Generated.Member
- public boolean equals(@Nullable Object o) {
- // You can override field equality logic by defining either of the methods like:
- // boolean fieldNameEquals(InlinePresentationSpec other) { ... }
- // boolean fieldNameEquals(FieldType otherValue) { ... }
-
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- @SuppressWarnings("unchecked")
- InlinePresentationSpec that = (InlinePresentationSpec) o;
- //noinspection PointlessBooleanExpression
- return true
- && java.util.Objects.equals(mMinSize, that.mMinSize)
- && java.util.Objects.equals(mMaxSize, that.mMaxSize)
- && java.util.Objects.equals(mStyle, that.mStyle);
- }
-
- @Override
- @DataClass.Generated.Member
- public int hashCode() {
- // You can override field hashCode logic by defining methods like:
- // int fieldNameHashCode() { ... }
-
- int _hash = 1;
- _hash = 31 * _hash + java.util.Objects.hashCode(mMinSize);
- _hash = 31 * _hash + java.util.Objects.hashCode(mMaxSize);
- _hash = 31 * _hash + java.util.Objects.hashCode(mStyle);
- return _hash;
- }
-
- @Override
- @DataClass.Generated.Member
- public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
- // You can override field parcelling by defining methods like:
- // void parcelFieldName(Parcel dest, int flags) { ... }
-
- dest.writeSize(mMinSize);
- dest.writeSize(mMaxSize);
- dest.writeBundle(mStyle);
- }
-
- @Override
- @DataClass.Generated.Member
- public int describeContents() { return 0; }
-
- /** @hide */
- @SuppressWarnings({"unchecked", "RedundantCast"})
- @DataClass.Generated.Member
- /* package-private */ InlinePresentationSpec(@NonNull android.os.Parcel in) {
- // You can override field unparcelling by defining methods like:
- // static FieldType unparcelFieldName(Parcel in) { ... }
-
- Size minSize = (Size) in.readSize();
- Size maxSize = (Size) in.readSize();
- Bundle style = in.readBundle();
-
- this.mMinSize = minSize;
- com.android.internal.util.AnnotationValidations.validate(
- NonNull.class, null, mMinSize);
- this.mMaxSize = maxSize;
- com.android.internal.util.AnnotationValidations.validate(
- NonNull.class, null, mMaxSize);
- this.mStyle = style;
- com.android.internal.util.AnnotationValidations.validate(
- NonNull.class, null, mStyle);
-
- // onConstructed(); // You can define this method to get a callback
- }
-
- @DataClass.Generated.Member
- public static final @NonNull Parcelable.Creator<InlinePresentationSpec> CREATOR
- = new Parcelable.Creator<InlinePresentationSpec>() {
- @Override
- public InlinePresentationSpec[] newArray(int size) {
- return new InlinePresentationSpec[size];
- }
-
- @Override
- public InlinePresentationSpec createFromParcel(@NonNull android.os.Parcel in) {
- return new InlinePresentationSpec(in);
- }
- };
-
- /**
- * A builder for {@link InlinePresentationSpec}
- */
- @SuppressWarnings("WeakerAccess")
- @DataClass.Generated.Member
- public static final class Builder extends BaseBuilder {
-
- private @NonNull Size mMinSize;
- private @NonNull Size mMaxSize;
- private @NonNull Bundle mStyle;
-
- private long mBuilderFieldsSet = 0L;
-
- /**
- * Creates a new Builder.
- *
- * @param minSize
- * The minimal size of the suggestion.
- * @param maxSize
- * The maximal size of the suggestion.
- */
- @UnsupportedAppUsage
- public Builder(
- @NonNull Size minSize,
- @NonNull Size maxSize) {
- mMinSize = minSize;
- com.android.internal.util.AnnotationValidations.validate(
- NonNull.class, null, mMinSize);
- mMaxSize = maxSize;
- com.android.internal.util.AnnotationValidations.validate(
- NonNull.class, null, mMaxSize);
- }
-
- /**
- * The extras encoding the UI style information. Defaults to {@code Bundle.EMPTY} in which case
- * the default system UI style will be used.
- */
- @DataClass.Generated.Member
- public @NonNull Builder setStyle(@NonNull Bundle value) {
- checkNotUsed();
- mBuilderFieldsSet |= 0x4;
- mStyle = value;
- return this;
- }
-
- /** Builds the instance. This builder should not be touched after calling this! */
- @UnsupportedAppUsage
- @NonNull
- public InlinePresentationSpec build() {
- checkNotUsed();
- mBuilderFieldsSet |= 0x8; // Mark builder used
-
- if ((mBuilderFieldsSet & 0x4) == 0) {
- mStyle = defaultStyle();
- }
- InlinePresentationSpec o = new InlinePresentationSpec(
- mMinSize,
- mMaxSize,
- mStyle);
- return o;
- }
-
- private void checkNotUsed() {
- if ((mBuilderFieldsSet & 0x8) != 0) {
- throw new IllegalStateException(
- "This Builder should not be reused. Use a new Builder instance instead");
- }
- }
- }
-
- @DataClass.Generated(
- time = 1585691139012L,
- codegenVersion = "1.0.15",
- sourceFile = "frameworks/base/core/java/android/view/inline/InlinePresentationSpec.java",
- inputSignatures = "private final @android.annotation.NonNull android.util.Size mMinSize\nprivate final @android.annotation.NonNull android.util.Size mMaxSize\nprivate final @android.annotation.NonNull android.os.Bundle mStyle\nprivate static android.os.Bundle defaultStyle()\npublic android.widget.inline.InlinePresentationSpec toWidget()\npublic static android.view.inline.InlinePresentationSpec fromWidget(android.widget.inline.InlinePresentationSpec)\npublic static java.util.List<android.view.inline.InlinePresentationSpec> fromWidgets(java.util.List<android.widget.inline.InlinePresentationSpec>)\nclass InlinePresentationSpec extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genBuilder=true)\nclass BaseBuilder extends java.lang.Object implements []")
- @Deprecated
- private void __metadata() {}
-
-
- //@formatter:on
- // End of generated code
-
-}
diff --git a/core/java/android/view/inputmethod/InlineSuggestionInfo.java b/core/java/android/view/inputmethod/InlineSuggestionInfo.java
index 3e9ffa7..1c703ec 100644
--- a/core/java/android/view/inputmethod/InlineSuggestionInfo.java
+++ b/core/java/android/view/inputmethod/InlineSuggestionInfo.java
@@ -20,7 +20,6 @@
import android.annotation.Nullable;
import android.annotation.SuppressLint;
import android.annotation.TestApi;
-import android.compat.annotation.UnsupportedAppUsage;
import android.os.Parcelable;
import android.widget.inline.InlinePresentationSpec;
@@ -87,17 +86,6 @@
return new InlineSuggestionInfo(presentationSpec, source, autofillHints, type, isPinned);
}
- /**
- * The presentation spec to which the inflated suggestion view abides.
- *
- * @hide
- * @removed
- */
- @UnsupportedAppUsage
- public @NonNull android.view.inline.InlinePresentationSpec getPresentationSpec() {
- return android.view.inline.InlinePresentationSpec.fromWidget(mInlinePresentationSpec);
- }
-
// Code below generated by codegen v1.0.15.
@@ -358,10 +346,10 @@
};
@DataClass.Generated(
- time = 1585633580662L,
+ time = 1586992414034L,
codegenVersion = "1.0.15",
sourceFile = "frameworks/base/core/java/android/view/inputmethod/InlineSuggestionInfo.java",
- inputSignatures = "public static final @android.view.inputmethod.InlineSuggestionInfo.Source java.lang.String SOURCE_AUTOFILL\npublic static final @android.view.inputmethod.InlineSuggestionInfo.Source java.lang.String SOURCE_PLATFORM\npublic static final @android.view.inputmethod.InlineSuggestionInfo.Type java.lang.String TYPE_SUGGESTION\npublic static final @android.annotation.SuppressLint({\"IntentName\"}) @android.view.inputmethod.InlineSuggestionInfo.Type java.lang.String TYPE_ACTION\nprivate final @android.annotation.NonNull android.widget.inline.InlinePresentationSpec mInlinePresentationSpec\nprivate final @android.annotation.NonNull @android.view.inputmethod.InlineSuggestionInfo.Source java.lang.String mSource\nprivate final @android.annotation.Nullable java.lang.String[] mAutofillHints\nprivate final @android.annotation.NonNull @android.view.inputmethod.InlineSuggestionInfo.Type java.lang.String mType\nprivate final boolean mPinned\npublic static @android.annotation.TestApi @android.annotation.NonNull android.view.inputmethod.InlineSuggestionInfo newInlineSuggestionInfo(android.widget.inline.InlinePresentationSpec,java.lang.String,java.lang.String[],java.lang.String,boolean)\npublic @android.compat.annotation.UnsupportedAppUsage @android.annotation.NonNull android.view.inline.InlinePresentationSpec getPresentationSpec()\nclass InlineSuggestionInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genHiddenConstDefs=true, genHiddenConstructor=true)")
+ inputSignatures = "public static final @android.view.inputmethod.InlineSuggestionInfo.Source java.lang.String SOURCE_AUTOFILL\npublic static final @android.view.inputmethod.InlineSuggestionInfo.Source java.lang.String SOURCE_PLATFORM\npublic static final @android.view.inputmethod.InlineSuggestionInfo.Type java.lang.String TYPE_SUGGESTION\npublic static final @android.annotation.SuppressLint({\"IntentName\"}) @android.view.inputmethod.InlineSuggestionInfo.Type java.lang.String TYPE_ACTION\nprivate final @android.annotation.NonNull android.widget.inline.InlinePresentationSpec mInlinePresentationSpec\nprivate final @android.annotation.NonNull @android.view.inputmethod.InlineSuggestionInfo.Source java.lang.String mSource\nprivate final @android.annotation.Nullable java.lang.String[] mAutofillHints\nprivate final @android.annotation.NonNull @android.view.inputmethod.InlineSuggestionInfo.Type java.lang.String mType\nprivate final boolean mPinned\npublic static @android.annotation.TestApi @android.annotation.NonNull android.view.inputmethod.InlineSuggestionInfo newInlineSuggestionInfo(android.widget.inline.InlinePresentationSpec,java.lang.String,java.lang.String[],java.lang.String,boolean)\nclass InlineSuggestionInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genHiddenConstDefs=true, genHiddenConstructor=true)")
@Deprecated
private void __metadata() {}
diff --git a/core/java/android/view/inputmethod/InlineSuggestionsRequest.java b/core/java/android/view/inputmethod/InlineSuggestionsRequest.java
index af896fc..d282b56 100644
--- a/core/java/android/view/inputmethod/InlineSuggestionsRequest.java
+++ b/core/java/android/view/inputmethod/InlineSuggestionsRequest.java
@@ -19,7 +19,6 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityThread;
-import android.compat.annotation.UnsupportedAppUsage;
import android.os.Bundle;
import android.os.IBinder;
import android.os.LocaleList;
@@ -93,20 +92,6 @@
private int mHostDisplayId;
/**
- * The {@link InlinePresentationSpec} for each suggestion in the response. If the max suggestion
- * count is larger than the number of specs in the list, then the last spec is used for the
- * remainder of the suggestions. The list should not be empty.
- *
- * @hide
- * @removed
- */
- @UnsupportedAppUsage
- @NonNull
- public List<android.view.inline.InlinePresentationSpec> getPresentationSpecs() {
- return android.view.inline.InlinePresentationSpec.fromWidgets(mInlinePresentationSpecs);
- }
-
- /**
* @hide
* @see {@link #mHostInputToken}.
*/
@@ -170,17 +155,6 @@
/** @hide */
abstract static class BaseBuilder {
- /**
- * @hide
- * @removed
- */
- @UnsupportedAppUsage
- @NonNull
- public Builder addPresentationSpecs(
- @NonNull android.view.inline.InlinePresentationSpec value) {
- return ((Builder) this).addInlinePresentationSpecs(value.toWidget());
- }
-
abstract Builder setInlinePresentationSpecs(
@NonNull List<android.widget.inline.InlinePresentationSpec> specs);
@@ -608,10 +582,10 @@
}
@DataClass.Generated(
- time = 1585768018462L,
+ time = 1586992395497L,
codegenVersion = "1.0.15",
sourceFile = "frameworks/base/core/java/android/view/inputmethod/InlineSuggestionsRequest.java",
- inputSignatures = "public static final int SUGGESTION_COUNT_UNLIMITED\nprivate final int mMaxSuggestionCount\nprivate final @android.annotation.NonNull java.util.List<android.widget.inline.InlinePresentationSpec> mInlinePresentationSpecs\nprivate @android.annotation.NonNull java.lang.String mHostPackageName\nprivate @android.annotation.NonNull android.os.LocaleList mSupportedLocales\nprivate @android.annotation.NonNull android.os.Bundle mExtras\nprivate @android.annotation.Nullable android.os.IBinder mHostInputToken\nprivate int mHostDisplayId\npublic @android.compat.annotation.UnsupportedAppUsage @android.annotation.NonNull java.util.List<android.view.inline.InlinePresentationSpec> getPresentationSpecs()\npublic void setHostInputToken(android.os.IBinder)\nprivate boolean extrasEquals(android.os.Bundle)\nprivate void parcelHostInputToken(android.os.Parcel,int)\nprivate @android.annotation.Nullable android.os.IBinder unparcelHostInputToken(android.os.Parcel)\npublic void setHostDisplayId(int)\nprivate void onConstructed()\nprivate static int defaultMaxSuggestionCount()\nprivate static java.lang.String defaultHostPackageName()\nprivate static android.os.LocaleList defaultSupportedLocales()\nprivate static @android.annotation.Nullable android.os.IBinder defaultHostInputToken()\nprivate static @android.annotation.Nullable int defaultHostDisplayId()\nprivate static @android.annotation.NonNull android.os.Bundle defaultExtras()\nclass InlineSuggestionsRequest extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genBuilder=true)\npublic @android.compat.annotation.UnsupportedAppUsage @android.annotation.NonNull android.view.inputmethod.InlineSuggestionsRequest.Builder addPresentationSpecs(android.view.inline.InlinePresentationSpec)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setInlinePresentationSpecs(java.util.List<android.widget.inline.InlinePresentationSpec>)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setHostPackageName(java.lang.String)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setHostInputToken(android.os.IBinder)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setHostDisplayId(int)\nclass BaseBuilder extends java.lang.Object implements []")
+ inputSignatures = "public static final int SUGGESTION_COUNT_UNLIMITED\nprivate final int mMaxSuggestionCount\nprivate final @android.annotation.NonNull java.util.List<android.widget.inline.InlinePresentationSpec> mInlinePresentationSpecs\nprivate @android.annotation.NonNull java.lang.String mHostPackageName\nprivate @android.annotation.NonNull android.os.LocaleList mSupportedLocales\nprivate @android.annotation.NonNull android.os.Bundle mExtras\nprivate @android.annotation.Nullable android.os.IBinder mHostInputToken\nprivate int mHostDisplayId\npublic void setHostInputToken(android.os.IBinder)\nprivate boolean extrasEquals(android.os.Bundle)\nprivate void parcelHostInputToken(android.os.Parcel,int)\nprivate @android.annotation.Nullable android.os.IBinder unparcelHostInputToken(android.os.Parcel)\npublic void setHostDisplayId(int)\nprivate void onConstructed()\nprivate static int defaultMaxSuggestionCount()\nprivate static java.lang.String defaultHostPackageName()\nprivate static android.os.LocaleList defaultSupportedLocales()\nprivate static @android.annotation.Nullable android.os.IBinder defaultHostInputToken()\nprivate static @android.annotation.Nullable int defaultHostDisplayId()\nprivate static @android.annotation.NonNull android.os.Bundle defaultExtras()\nclass InlineSuggestionsRequest extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genBuilder=true)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setInlinePresentationSpecs(java.util.List<android.widget.inline.InlinePresentationSpec>)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setHostPackageName(java.lang.String)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setHostInputToken(android.os.IBinder)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setHostDisplayId(int)\nclass BaseBuilder extends java.lang.Object implements []")
@Deprecated
private void __metadata() {}
diff --git a/core/proto/android/server/windowmanagerservice.proto b/core/proto/android/server/windowmanagerservice.proto
index 608925578..55ea315 100644
--- a/core/proto/android/server/windowmanagerservice.proto
+++ b/core/proto/android/server/windowmanagerservice.proto
@@ -250,7 +250,7 @@
reserved 3; // activity
optional bool fills_parent = 4;
optional .android.graphics.RectProto bounds = 5;
- optional .android.graphics.RectProto displayed_bounds = 6;
+ optional .android.graphics.RectProto displayed_bounds = 6 [deprecated=true];
optional bool defer_removal = 7;
optional int32 surface_width = 8;
optional int32 surface_height = 9;
diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java
index d1b41df..9b4aebc 100644
--- a/location/java/android/location/LocationManager.java
+++ b/location/java/android/location/LocationManager.java
@@ -34,6 +34,7 @@
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.app.AlarmManager;
+import android.app.AppOpsManager;
import android.app.PendingIntent;
import android.app.PropertyInvalidatedCache;
import android.compat.Compatibility;
@@ -2561,7 +2562,7 @@
}
public String getListenerId() {
- return mConsumer.getClass().getName() + "@" + System.identityHashCode(mConsumer);
+ return AppOpsManager.toReceiverId(mConsumer);
}
public synchronized void register(AlarmManager alarmManager,
@@ -2690,7 +2691,7 @@
}
public String getListenerId() {
- return mListener.getClass().getName() + "@" + System.identityHashCode(mListener);
+ return AppOpsManager.toReceiverId(mListener);
}
public void register(@NonNull Executor executor) {
diff --git a/packages/CarSystemUI/src/com/android/systemui/car/keyguard/CarKeyguardViewController.java b/packages/CarSystemUI/src/com/android/systemui/car/keyguard/CarKeyguardViewController.java
index 1814fd0..a4bb916 100644
--- a/packages/CarSystemUI/src/com/android/systemui/car/keyguard/CarKeyguardViewController.java
+++ b/packages/CarSystemUI/src/com/android/systemui/car/keyguard/CarKeyguardViewController.java
@@ -26,6 +26,8 @@
import android.view.ViewGroup;
import android.view.ViewRootImpl;
+import androidx.annotation.VisibleForTesting;
+
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardViewController;
@@ -332,6 +334,11 @@
getLayout().setVisibility(View.INVISIBLE);
}
+ @VisibleForTesting
+ void setKeyguardBouncer(KeyguardBouncer keyguardBouncer) {
+ mBouncer = keyguardBouncer;
+ }
+
private void revealKeyguardIfBouncerPrepared() {
int reattemptDelayMillis = 50;
Runnable revealKeyguard = () -> {
diff --git a/packages/CarSystemUI/tests/src/com/android/systemui/car/keyguard/CarKeyguardViewControllerTest.java b/packages/CarSystemUI/tests/src/com/android/systemui/car/keyguard/CarKeyguardViewControllerTest.java
new file mode 100644
index 0000000..d4cf6cc
--- /dev/null
+++ b/packages/CarSystemUI/tests/src/com/android/systemui/car/keyguard/CarKeyguardViewControllerTest.java
@@ -0,0 +1,209 @@
+/*
+ * Copyright (C) 2020 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.car.keyguard;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.os.Handler;
+import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.android.internal.widget.LockPatternUtils;
+import com.android.keyguard.KeyguardUpdateMonitor;
+import com.android.keyguard.ViewMediatorCallback;
+import com.android.systemui.R;
+import com.android.systemui.SysuiTestCase;
+import com.android.systemui.car.CarServiceProvider;
+import com.android.systemui.keyguard.DismissCallbackRegistry;
+import com.android.systemui.navigationbar.car.CarNavigationBarController;
+import com.android.systemui.plugins.FalsingManager;
+import com.android.systemui.statusbar.phone.BiometricUnlockController;
+import com.android.systemui.statusbar.phone.KeyguardBouncer;
+import com.android.systemui.statusbar.phone.KeyguardBypassController;
+import com.android.systemui.statusbar.policy.KeyguardStateController;
+import com.android.systemui.window.OverlayViewGlobalStateController;
+import com.android.systemui.window.SystemUIOverlayWindowController;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+@RunWith(AndroidTestingRunner.class)
+@TestableLooper.RunWithLooper
+public class CarKeyguardViewControllerTest extends SysuiTestCase {
+
+ private TestableCarKeyguardViewController mCarKeyguardViewController;
+ private OverlayViewGlobalStateController mOverlayViewGlobalStateController;
+ private ViewGroup mBaseLayout;
+
+ @Mock
+ private KeyguardBouncer mBouncer;
+ @Mock
+ private CarNavigationBarController mCarNavigationBarController;
+ @Mock
+ private SystemUIOverlayWindowController mSystemUIOverlayWindowController;
+ @Mock
+ private CarKeyguardViewController.OnKeyguardCancelClickedListener mCancelClickedListener;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ mOverlayViewGlobalStateController = new OverlayViewGlobalStateController(
+ mCarNavigationBarController, mSystemUIOverlayWindowController);
+ mBaseLayout = (ViewGroup) LayoutInflater.from(mContext).inflate(
+ R.layout.sysui_overlay_window, /* root= */ null);
+ when(mSystemUIOverlayWindowController.getBaseLayout()).thenReturn(mBaseLayout);
+
+ mCarKeyguardViewController = new TestableCarKeyguardViewController(
+ mContext,
+ Handler.getMain(),
+ mock(CarServiceProvider.class),
+ mOverlayViewGlobalStateController,
+ mock(KeyguardStateController.class),
+ mock(KeyguardUpdateMonitor.class),
+ mock(BiometricUnlockController.class),
+ mock(ViewMediatorCallback.class),
+ mock(CarNavigationBarController.class),
+ mock(LockPatternUtils.class),
+ mock(DismissCallbackRegistry.class),
+ mock(FalsingManager.class),
+ mock(KeyguardBypassController.class)
+ );
+ }
+
+ @Test
+ public void onShow_bouncerIsSecure_showsBouncerWithSecuritySelectionReset() {
+ when(mBouncer.isSecure()).thenReturn(true);
+ mCarKeyguardViewController.show(/* options= */ null);
+
+ verify(mBouncer).show(/* resetSecuritySelection= */ true);
+ }
+
+ @Test
+ public void onShow_bouncerIsSecure_keyguardIsVisible() {
+ when(mBouncer.isSecure()).thenReturn(true);
+ mCarKeyguardViewController.show(/* options= */ null);
+
+ assertThat(mBaseLayout.findViewById(R.id.keyguard_container).getVisibility()).isEqualTo(
+ View.VISIBLE);
+ }
+
+ @Test
+ public void onShow_bouncerNotSecure_hidesBouncerAndDestroysTheView() {
+ when(mBouncer.isSecure()).thenReturn(false);
+ mCarKeyguardViewController.show(/* options= */ null);
+
+ verify(mBouncer).hide(/* destroyView= */ true);
+ }
+
+ @Test
+ public void onShow_bouncerNotSecure_keyguardIsNotVisible() {
+ when(mBouncer.isSecure()).thenReturn(false);
+ mCarKeyguardViewController.show(/* options= */ null);
+
+ assertThat(mBaseLayout.findViewById(R.id.keyguard_container).getVisibility()).isEqualTo(
+ View.GONE);
+ }
+
+ @Test
+ public void onHide_keyguardShowing_hidesBouncerAndDestroysTheView() {
+ when(mBouncer.isSecure()).thenReturn(true);
+ mCarKeyguardViewController.show(/* options= */ null);
+ mCarKeyguardViewController.hide(/* startTime= */ 0, /* fadeoutDelay= */ 0);
+
+ verify(mBouncer).hide(/* destroyView= */ true);
+ }
+
+ @Test
+ public void onHide_keyguardNotShown_doesNotHideOrDestroyBouncer() {
+ mCarKeyguardViewController.hide(/* startTime= */ 0, /* fadeoutDelay= */ 0);
+
+ verify(mBouncer, never()).hide(anyBoolean());
+ }
+
+ @Test
+ public void onHide_KeyguardNotVisible() {
+ when(mBouncer.isSecure()).thenReturn(true);
+ mCarKeyguardViewController.show(/* options= */ null);
+ mCarKeyguardViewController.hide(/* startTime= */ 0, /* fadeoutDelay= */ 0);
+
+ assertThat(mBaseLayout.findViewById(R.id.keyguard_container).getVisibility()).isEqualTo(
+ View.GONE);
+ }
+
+ @Test
+ public void onCancelClicked_callsCancelClickedListener() {
+ when(mBouncer.isSecure()).thenReturn(true);
+ mCarKeyguardViewController.show(/* options= */ null);
+ mCarKeyguardViewController.registerOnKeyguardCancelClickedListener(mCancelClickedListener);
+ mCarKeyguardViewController.onCancelClicked();
+
+ verify(mCancelClickedListener).onCancelClicked();
+ }
+
+ @Test
+ public void onCancelClicked_hidesBouncerAndDestroysTheView() {
+ when(mBouncer.isSecure()).thenReturn(true);
+ mCarKeyguardViewController.show(/* options= */ null);
+ mCarKeyguardViewController.registerOnKeyguardCancelClickedListener(mCancelClickedListener);
+ mCarKeyguardViewController.onCancelClicked();
+
+ verify(mBouncer).hide(/* destroyView= */ true);
+ }
+
+ private class TestableCarKeyguardViewController extends CarKeyguardViewController {
+
+ TestableCarKeyguardViewController(Context context,
+ Handler mainHandler,
+ CarServiceProvider carServiceProvider,
+ OverlayViewGlobalStateController overlayViewGlobalStateController,
+ KeyguardStateController keyguardStateController,
+ KeyguardUpdateMonitor keyguardUpdateMonitor,
+ BiometricUnlockController biometricUnlockController,
+ ViewMediatorCallback viewMediatorCallback,
+ CarNavigationBarController carNavigationBarController,
+ LockPatternUtils lockPatternUtils,
+ DismissCallbackRegistry dismissCallbackRegistry,
+ FalsingManager falsingManager,
+ KeyguardBypassController keyguardBypassController) {
+ super(context, mainHandler, carServiceProvider, overlayViewGlobalStateController,
+ keyguardStateController, keyguardUpdateMonitor, biometricUnlockController,
+ viewMediatorCallback, carNavigationBarController, lockPatternUtils,
+ dismissCallbackRegistry, falsingManager, keyguardBypassController);
+ }
+
+ @Override
+ public void onFinishInflate() {
+ super.onFinishInflate();
+ setKeyguardBouncer(CarKeyguardViewControllerTest.this.mBouncer);
+ }
+ }
+
+}
diff --git a/packages/PackageInstaller/src/com/android/packageinstaller/InstallStart.java b/packages/PackageInstaller/src/com/android/packageinstaller/InstallStart.java
index c11e1a0..6fbee16 100644
--- a/packages/PackageInstaller/src/com/android/packageinstaller/InstallStart.java
+++ b/packages/PackageInstaller/src/com/android/packageinstaller/InstallStart.java
@@ -30,13 +30,17 @@
import android.content.pm.PackageInstaller;
import android.content.pm.PackageManager;
import android.content.pm.ProviderInfo;
+import android.content.pm.UserInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.RemoteException;
+import android.os.UserManager;
import android.permission.IPermissionManager;
import android.util.Log;
+import java.util.List;
+
/**
* Select which activity is the first visible activity of the installation and forward the intent to
* it.
@@ -47,6 +51,7 @@
private static final String DOWNLOADS_AUTHORITY = "downloads";
private IPackageManager mIPackageManager;
private IPermissionManager mIPermissionManager;
+ private UserManager mUserManager;
private boolean mAbortInstall = false;
@Override
@@ -54,6 +59,7 @@
super.onCreate(savedInstanceState);
mIPackageManager = AppGlobals.getPackageManager();
mIPermissionManager = AppGlobals.getPermissionManager();
+ mUserManager = getSystemService(UserManager.class);
Intent intent = getIntent();
String callingPackage = getCallingPackage();
@@ -144,13 +150,16 @@
if (packages == null) {
return false;
}
+ final List<UserInfo> users = mUserManager.getUsers();
for (String packageName : packages) {
- try {
- if (uid == getPackageManager().getPackageUid(packageName, 0)) {
- return true;
+ for (UserInfo user : users) {
+ try {
+ if (uid == getPackageManager().getPackageUidAsUser(packageName, user.id)) {
+ return true;
+ }
+ } catch (PackageManager.NameNotFoundException e) {
+ // Ignore and try the next package
}
- } catch (PackageManager.NameNotFoundException e) {
- // Ignore and try the next package
}
}
} catch (RemoteException rexc) {
diff --git a/packages/SettingsLib/RestrictedLockUtils/src/com/android/settingslib/RestrictedLockUtils.java b/packages/SettingsLib/RestrictedLockUtils/src/com/android/settingslib/RestrictedLockUtils.java
index fa2ec55..a77e34b 100644
--- a/packages/SettingsLib/RestrictedLockUtils/src/com/android/settingslib/RestrictedLockUtils.java
+++ b/packages/SettingsLib/RestrictedLockUtils/src/com/android/settingslib/RestrictedLockUtils.java
@@ -147,6 +147,28 @@
public EnforcedAdmin() {
}
+ /**
+ * Combines two {@link EnforcedAdmin} into one: if one of them is null, then just return
+ * the other. If both of them are the same, then return that. Otherwise return the symbolic
+ * {@link #MULTIPLE_ENFORCED_ADMIN}
+ */
+ public static EnforcedAdmin combine(EnforcedAdmin admin1, EnforcedAdmin admin2) {
+ if (admin1 == null) {
+ return admin2;
+ }
+ if (admin2 == null) {
+ return admin1;
+ }
+ if (admin1.equals(admin2)) {
+ return admin1;
+ }
+ if (!admin1.enforcedRestriction.equals(admin2.enforcedRestriction)) {
+ throw new IllegalArgumentException(
+ "Admins with different restriction cannot be combined");
+ }
+ return MULTIPLE_ENFORCED_ADMIN;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
diff --git a/packages/SystemUI/res/anim/control_state_list_animator.xml b/packages/SystemUI/res/anim/control_state_list_animator.xml
index 7940b88..a20a925 100644
--- a/packages/SystemUI/res/anim/control_state_list_animator.xml
+++ b/packages/SystemUI/res/anim/control_state_list_animator.xml
@@ -18,11 +18,13 @@
<item android:state_pressed="true">
<set>
<objectAnimator
+ android:interpolator="@interpolator/control_state"
android:duration="50"
android:propertyName="scaleX"
android:valueTo="0.97"
android:valueType="floatType" />
<objectAnimator
+ android:interpolator="@interpolator/control_state"
android:duration="50"
android:propertyName="scaleY"
android:valueTo="0.97"
@@ -33,11 +35,13 @@
<item>
<set>
<objectAnimator
+ android:interpolator="@interpolator/control_state"
android:duration="250"
android:propertyName="scaleX"
android:valueTo="1"
android:valueType="floatType" />
<objectAnimator
+ android:interpolator="@interpolator/control_state"
android:duration="250"
android:propertyName="scaleY"
android:valueTo="1"
diff --git a/packages/SystemUI/res/drawable/control_background.xml b/packages/SystemUI/res/drawable/control_background.xml
index 29b4efa..cf298b7 100644
--- a/packages/SystemUI/res/drawable/control_background.xml
+++ b/packages/SystemUI/res/drawable/control_background.xml
@@ -17,7 +17,8 @@
*/
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item>
+ <item
+ android:id="@+id/background">
<shape>
<solid android:color="@color/control_default_background" />
<corners android:radius="@dimen/control_corner_radius" />
diff --git a/packages/SystemUI/res/interpolator/control_state.xml b/packages/SystemUI/res/interpolator/control_state.xml
new file mode 100644
index 0000000..66106d4
--- /dev/null
+++ b/packages/SystemUI/res/interpolator/control_state.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2020 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.
+ -->
+<pathInterpolator
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:controlX1="0"
+ android:controlY1="0"
+ android:controlX2="1"
+ android:controlY2="1"/>
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index e7ef8cc..622e4cc 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -1252,6 +1252,7 @@
<dimen name="control_status_expanded">18sp</dimen>
<dimen name="control_base_item_margin">2dp</dimen>
<dimen name="control_status_padding">3dp</dimen>
+ <fraction name="controls_toggle_bg_intensity">5%</fraction>
<!-- Home Controls activity view detail panel-->
<dimen name="controls_activity_view_top_padding">25dp</dimen>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index d2654d6..49420e8 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -1829,15 +1829,15 @@
<!-- [CHAR LIMIT=150] Notification Importance title: normal importance level summary -->
<string name="notification_channel_summary_default">Gets your attention with sound or vibration.</string>
+ <!-- [CHAR LIMIT=150] Conversation Notification Importance title: normal conversation level, with bubbling summary -->
+ <string name="notification_channel_summary_default_with_bubbles">Gets your attention with sound or vibration. Conversations from <xliff:g id="app_name" example="YouTube">%1$s</xliff:g> bubble by default.</string>
+
<!-- [CHAR LIMIT=150] Notification Importance title: bubble level summary -->
<string name="notification_channel_summary_bubble">Keeps your attention with a floating shortcut to this content.</string>
<!-- [CHAR LIMIT=150] Notification Importance title: important conversation level summary -->
<string name="notification_channel_summary_priority">Shows at top of conversation section and appears as a bubble.</string>
- <!--[CHAR LIMIT=150] Conversation inline controls footer shown when all conversations from the app are allowed to show as bubbles -->
- <string name="notification_conversation_channel_all_bubble">All conversations from <xliff:g id="app_name" example="YouTube">%1$s</xliff:g> bubble by default. Manage in <xliff:g id="app_name" example="Settings">%2$s</xliff:g>.</string>
-
<!--[CHAR LIMIT=30] Linkable text to Settings app -->
<string name="notification_conversation_channel_settings">Settings</string>
diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml
index 118aa5b..7e24f5d 100644
--- a/packages/SystemUI/res/values/styles.xml
+++ b/packages/SystemUI/res/values/styles.xml
@@ -564,7 +564,7 @@
<style name="TextAppearance.NotificationImportanceButton">
<item name="android:textSize">@dimen/notification_importance_button_text</item>
<item name="android:fontFamily">@*android:string/config_headlineFontFamilyMedium</item>
- <item name="android:textColor">?android:attr/colorAccent</item>
+ <item name="android:textColor">@color/notification_guts_priority_contents</item>
<item name="android:gravity">center</item>
</style>
diff --git a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
index 8df3dd2..7861211 100644
--- a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
+++ b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
@@ -54,8 +54,10 @@
import android.graphics.drawable.VectorDrawable;
import android.hardware.display.DisplayManager;
import android.os.Handler;
+import android.os.HandlerExecutor;
import android.os.HandlerThread;
import android.os.SystemProperties;
+import android.os.UserHandle;
import android.provider.Settings.Secure;
import android.util.DisplayMetrics;
import android.util.Log;
@@ -298,13 +300,15 @@
updateColorInversion(value);
}
};
+
+ mColorInversionSetting.setListening(true);
+ mColorInversionSetting.onChange(false);
}
- mColorInversionSetting.setListening(true);
- mColorInversionSetting.onChange(false);
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_USER_SWITCHED);
- mBroadcastDispatcher.registerReceiverWithHandler(mIntentReceiver, filter, mHandler);
+ mBroadcastDispatcher.registerReceiver(mUserSwitchIntentReceiver, filter,
+ new HandlerExecutor(mHandler), UserHandle.ALL);
mIsRegistered = true;
} else {
mMainHandler.post(() -> mTunerService.removeTunable(this));
@@ -313,7 +317,7 @@
mColorInversionSetting.setListening(false);
}
- mBroadcastDispatcher.unregisterReceiver(mIntentReceiver);
+ mBroadcastDispatcher.unregisterReceiver(mUserSwitchIntentReceiver);
mIsRegistered = false;
}
}
@@ -503,17 +507,16 @@
}
}
- private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
+ private final BroadcastReceiver mUserSwitchIntentReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if (action.equals(Intent.ACTION_USER_SWITCHED)) {
- int newUserId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE,
- ActivityManager.getCurrentUser());
- // update color inversion setting to the new user
- mColorInversionSetting.setUserId(newUserId);
- updateColorInversion(mColorInversionSetting.getValue());
+ int newUserId = ActivityManager.getCurrentUser();
+ if (DEBUG) {
+ Log.d(TAG, "UserSwitched newUserId=" + newUserId);
}
+ // update color inversion setting to the new user
+ mColorInversionSetting.setUserId(newUserId);
+ updateColorInversion(mColorInversionSetting.getValue());
}
};
@@ -945,7 +948,12 @@
int dw = flipped ? lh : lw;
int dh = flipped ? lw : lh;
- mBoundingPath.set(DisplayCutout.pathFromResources(getResources(), dw, dh));
+ Path path = DisplayCutout.pathFromResources(getResources(), dw, dh);
+ if (path != null) {
+ mBoundingPath.set(path);
+ } else {
+ mBoundingPath.reset();
+ }
Matrix m = new Matrix();
transformPhysicalToLogicalCoordinates(mInfo.rotation, dw, dh, m);
mBoundingPath.transform(m);
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialPasswordView.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialPasswordView.java
index d8a11d3..e6a62c2 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialPasswordView.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialPasswordView.java
@@ -17,6 +17,7 @@
package com.android.systemui.biometrics;
import android.content.Context;
+import android.os.UserHandle;
import android.text.InputType;
import android.util.AttributeSet;
import android.view.KeyEvent;
@@ -68,6 +69,7 @@
protected void onAttachedToWindow() {
super.onAttachedToWindow();
+ mPasswordField.setTextOperationUser(UserHandle.of(mUserId));
if (mCredentialType == Utils.CREDENTIAL_PIN) {
mPasswordField.setInputType(
InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD);
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialView.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialView.java
index 8bf2591..496e60d 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialView.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialView.java
@@ -286,6 +286,7 @@
if (matched) {
mClearErrorRunnable.run();
+ mLockPatternUtils.userPresent(mEffectiveUserId);
mCallback.onCredentialMatched(attestation);
} else {
if (timeoutMs > 0) {
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
index da5c296..c8e9a68 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
@@ -108,7 +108,6 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import java.util.ArrayList;
-import java.util.HashSet;
import java.util.List;
/**
@@ -162,14 +161,6 @@
// Used when ranking updates occur and we check if things should bubble / unbubble
private NotificationListenerService.Ranking mTmpRanking;
- // Saves notification keys of user created "fake" bubbles so that we can allow notifications
- // like these to bubble by default. Doesn't persist across reboots, not a long-term solution.
- private final HashSet<String> mUserCreatedBubbles;
- // If we're auto-bubbling bubbles via a whitelist, we need to track which notifs from that app
- // have been "demoted" back to a notification so that we don't auto-bubbles those again.
- // Doesn't persist across reboots, not a long-term solution.
- private final HashSet<String> mUserBlockedBubbles;
-
// Bubbles get added to the status bar view
private final NotificationShadeWindowController mNotificationShadeWindowController;
private final ZenModeController mZenModeController;
@@ -412,9 +403,6 @@
}
});
- mUserCreatedBubbles = new HashSet<>();
- mUserBlockedBubbles = new HashSet<>();
-
mBubbleIconFactory = new BubbleIconFactory(context);
}
@@ -474,8 +462,7 @@
(entry != null && entry.isRowDismissed() && !isAppCancel)
|| isClearAll || isUserDimiss || isSummaryCancel;
- if (userRemovedNotif || isUserCreatedBubble(key)
- || isSummaryOfUserCreatedBubble(entry)) {
+ if (userRemovedNotif) {
return handleDismissalInterception(entry);
}
@@ -860,27 +847,6 @@
}
/**
- * Whether this bubble was explicitly created by the user via a SysUI affordance.
- */
- boolean isUserCreatedBubble(String key) {
- return mUserCreatedBubbles.contains(key);
- }
-
- boolean isSummaryOfUserCreatedBubble(NotificationEntry entry) {
- if (isSummaryOfBubbles(entry)) {
- List<Bubble> bubbleChildren =
- mBubbleData.getBubblesInGroup(entry.getSbn().getGroupKey());
- for (int i = 0; i < bubbleChildren.size(); i++) {
- // Check if any are user-created (i.e. experimental bubbles)
- if (isUserCreatedBubble(bubbleChildren.get(i).getKey())) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
* Removes the bubble with the given NotificationEntry.
* <p>
* Must be called from the main thread.
@@ -893,37 +859,19 @@
}
private void onEntryAdded(NotificationEntry entry) {
- boolean previouslyUserCreated = mUserCreatedBubbles.contains(entry.getKey());
- boolean userBlocked = mUserBlockedBubbles.contains(entry.getKey());
- boolean wasAdjusted = BubbleExperimentConfig.adjustForExperiments(
- mContext, entry, previouslyUserCreated, userBlocked);
-
if (mNotificationInterruptStateProvider.shouldBubbleUp(entry)
- && (canLaunchInActivityView(mContext, entry) || wasAdjusted)) {
- if (wasAdjusted && !previouslyUserCreated) {
- // Gotta treat the auto-bubbled / whitelisted packaged bubbles as usercreated
- mUserCreatedBubbles.add(entry.getKey());
- }
+ && canLaunchInActivityView(mContext, entry)) {
updateBubble(entry);
}
}
private void onEntryUpdated(NotificationEntry entry) {
- boolean previouslyUserCreated = mUserCreatedBubbles.contains(entry.getKey());
- boolean userBlocked = mUserBlockedBubbles.contains(entry.getKey());
- boolean wasAdjusted = BubbleExperimentConfig.adjustForExperiments(
- mContext, entry, previouslyUserCreated, userBlocked);
-
boolean shouldBubble = mNotificationInterruptStateProvider.shouldBubbleUp(entry)
- && (canLaunchInActivityView(mContext, entry) || wasAdjusted);
+ && canLaunchInActivityView(mContext, entry);
if (!shouldBubble && mBubbleData.hasBubbleWithKey(entry.getKey())) {
// It was previously a bubble but no longer a bubble -- lets remove it
removeBubble(entry, DISMISS_NO_LONGER_BUBBLE);
} else if (shouldBubble) {
- if (wasAdjusted && !previouslyUserCreated) {
- // Gotta treat the auto-bubbled / whitelisted packaged bubbles as usercreated
- mUserCreatedBubbles.add(entry.getKey());
- }
updateBubble(entry);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
index 93fb697..3524696 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
@@ -193,7 +193,7 @@
+ " mActivityViewStatus=" + mActivityViewStatus
+ " bubble=" + getBubbleKey());
}
- if (mBubble != null && !mBubbleController.isUserCreatedBubble(mBubble.getKey())) {
+ if (mBubble != null) {
// Must post because this is called from a binder thread.
post(() -> mBubbleController.removeBubble(mBubble.getEntry(),
BubbleController.DISMISS_TASK_FINISHED));
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java
index 41dbb48..2060391 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java
@@ -57,16 +57,13 @@
public class BubbleExperimentConfig {
private static final String TAG = TAG_WITH_CLASS_NAME ? "BubbleController" : TAG_BUBBLES;
- private static final String SHORTCUT_DUMMY_INTENT = "bubble_experiment_shortcut_intent";
- private static PendingIntent sDummyShortcutIntent;
-
private static final int BUBBLE_HEIGHT = 10000;
private static final String ALLOW_ANY_NOTIF_TO_BUBBLE = "allow_any_notif_to_bubble";
private static final boolean ALLOW_ANY_NOTIF_TO_BUBBLE_DEFAULT = false;
private static final String ALLOW_MESSAGE_NOTIFS_TO_BUBBLE = "allow_message_notifs_to_bubble";
- private static final boolean ALLOW_MESSAGE_NOTIFS_TO_BUBBLE_DEFAULT = true;
+ private static final boolean ALLOW_MESSAGE_NOTIFS_TO_BUBBLE_DEFAULT = false;
private static final String ALLOW_SHORTCUTS_TO_BUBBLE = "allow_shortcuts_to_bubble";
private static final boolean ALLOW_SHORTCUT_TO_BUBBLE_DEFAULT = false;
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleViewInfoTask.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleViewInfoTask.java
index 501e502..c96f9a4 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleViewInfoTask.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleViewInfoTask.java
@@ -139,22 +139,11 @@
StatusBarNotification sbn = b.getEntry().getSbn();
String packageName = sbn.getPackageName();
- // Real shortcut info for this bubble
String bubbleShortcutId = b.getEntry().getBubbleMetadata().getShortcutId();
if (bubbleShortcutId != null) {
- info.shortcutInfo = BubbleExperimentConfig.getShortcutInfo(c, packageName,
- sbn.getUser(), bubbleShortcutId);
- } else {
- // Check for experimental shortcut
- String shortcutId = sbn.getNotification().getShortcutId();
- if (BubbleExperimentConfig.useShortcutInfoToBubble(c) && shortcutId != null) {
- info.shortcutInfo = BubbleExperimentConfig.getShortcutInfo(c,
- packageName,
- sbn.getUser(), shortcutId);
- }
+ info.shortcutInfo = b.getEntry().getRanking().getShortcutInfo();
}
-
// App name & app icon
PackageManager pm = c.getPackageManager();
ApplicationInfo appInfo;
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt
index 055adc6f..93e1bd4 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt
@@ -66,7 +66,10 @@
)
}
+ private val toggleBackgroundIntensity: Float = layout.context.resources
+ .getFraction(R.fraction.controls_toggle_bg_intensity, 1, 1)
private var stateAnimator: ValueAnimator? = null
+ private val baseLayer: GradientDrawable
val icon: ImageView = layout.requireViewById(R.id.icon)
val status: TextView = layout.requireViewById(R.id.status)
val title: TextView = layout.requireViewById(R.id.title)
@@ -85,6 +88,7 @@
ld.mutate()
clipLayer = ld.findDrawableByLayerId(R.id.clip_layer) as ClipDrawable
clipLayer.alpha = ALPHA_DISABLED
+ baseLayer = ld.findDrawableByLayerId(R.id.background) as GradientDrawable
// needed for marquee to start
status.setSelected(true)
}
@@ -171,11 +175,12 @@
val ri = RenderInfo.lookup(context, cws.componentName, deviceType, enabled, offset)
- val fg = context.getResources().getColorStateList(ri.foreground, context.getTheme())
- val (bg, newAlpha) = if (enabled) {
- Pair(ri.enabledBackground, ALPHA_ENABLED)
+ val fg = context.resources.getColorStateList(ri.foreground, context.theme)
+ val bg = context.resources.getColor(R.color.control_default_background, context.theme)
+ val (clip, newAlpha) = if (enabled) {
+ listOf(ri.enabledBackground, ALPHA_ENABLED)
} else {
- Pair(R.color.control_default_background, ALPHA_DISABLED)
+ listOf(R.color.control_default_background, ALPHA_DISABLED)
}
status.setTextColor(fg)
@@ -187,14 +192,22 @@
}
(clipLayer.getDrawable() as GradientDrawable).apply {
- val newColor = context.resources.getColor(bg, context.theme)
+ val newClipColor = context.resources.getColor(clip, context.theme)
+ val newBaseColor = if (behavior is ToggleRangeBehavior) {
+ ColorUtils.blendARGB(bg, newClipColor, toggleBackgroundIntensity)
+ } else {
+ bg
+ }
stateAnimator?.cancel()
if (animated) {
- val oldColor = color?.defaultColor ?: newColor
+ val oldColor = color?.defaultColor ?: newClipColor
+ val oldBaseColor = baseLayer.color?.defaultColor ?: newBaseColor
stateAnimator = ValueAnimator.ofInt(clipLayer.alpha, newAlpha).apply {
addUpdateListener {
alpha = it.animatedValue as Int
- setColor(ColorUtils.blendARGB(oldColor, newColor, it.animatedFraction))
+ setColor(ColorUtils.blendARGB(oldColor, newClipColor, it.animatedFraction))
+ baseLayer.setColor(ColorUtils.blendARGB(oldBaseColor,
+ newBaseColor, it.animatedFraction))
}
addListener(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator?) {
@@ -207,7 +220,8 @@
}
} else {
alpha = newAlpha
- setColor(newColor)
+ setColor(newClipColor)
+ baseLayer.setColor(newBaseColor)
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
index e6af36b..2c080b8 100644
--- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
+++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
@@ -43,7 +43,6 @@
import android.content.res.Resources;
import android.database.ContentObserver;
import android.graphics.Color;
-import android.graphics.Insets;
import android.graphics.drawable.Drawable;
import android.media.AudioManager;
import android.net.ConnectivityManager;
@@ -2178,8 +2177,10 @@
ViewGroup root = (ViewGroup) mGlobalActionsLayout.getRootView();
root.setOnApplyWindowInsetsListener((v, windowInsets) -> {
if (mControlsUiController != null) {
- Insets insets = windowInsets.getInsets(WindowInsets.Type.all());
- root.setPadding(insets.left, insets.top, insets.right, insets.bottom);
+ root.setPadding(windowInsets.getStableInsetLeft(),
+ windowInsets.getStableInsetTop(),
+ windowInsets.getStableInsetRight(),
+ windowInsets.getStableInsetBottom());
}
return WindowInsets.CONSUMED;
});
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java b/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
index 62efd8c..8492fef 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
@@ -82,6 +82,7 @@
protected ComponentName mRecvComponent;
private MediaDevice mDevice;
private boolean mIsRegistered = false;
+ private String mKey;
private final int[] mActionIds;
@@ -203,14 +204,15 @@
* @param bgColor
* @param contentIntent
* @param appNameString
- * @param device
+ * @param key
*/
public void setMediaSession(MediaSession.Token token, Icon icon, int iconColor,
- int bgColor, PendingIntent contentIntent, String appNameString) {
+ int bgColor, PendingIntent contentIntent, String appNameString, String key) {
mToken = token;
mForegroundColor = iconColor;
mBackgroundColor = bgColor;
mController = new MediaController(mContext, mToken);
+ mKey = key;
MediaMetadata mediaMetadata = mController.getMetadata();
@@ -326,6 +328,14 @@
}
/**
+ * Return the original notification's key
+ * @return The notification key
+ */
+ public String getKey() {
+ return mKey;
+ }
+
+ /**
* Check whether this player has an attached media session.
* @return whether there is a controller with a current media session.
*/
diff --git a/packages/SystemUI/src/com/android/systemui/media/SeekBarObserver.kt b/packages/SystemUI/src/com/android/systemui/media/SeekBarObserver.kt
index b7658a9..51c157a 100644
--- a/packages/SystemUI/src/com/android/systemui/media/SeekBarObserver.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/SeekBarObserver.kt
@@ -61,6 +61,7 @@
if (!data.enabled) {
seekBarView.setEnabled(false)
seekBarView.getThumb().setAlpha(0)
+ seekBarView.setProgress(0)
elapsedTimeView.setText("")
totalTimeView.setText("")
return
diff --git a/packages/SystemUI/src/com/android/systemui/media/SeekBarViewModel.kt b/packages/SystemUI/src/com/android/systemui/media/SeekBarViewModel.kt
index dd83e42..1425100 100644
--- a/packages/SystemUI/src/com/android/systemui/media/SeekBarViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/SeekBarViewModel.kt
@@ -77,13 +77,25 @@
val seekAvailable = ((playbackState?.actions ?: 0L) and PlaybackState.ACTION_SEEK_TO) != 0L
val position = playbackState?.position?.toInt()
val duration = mediaMetadata?.getLong(MediaMetadata.METADATA_KEY_DURATION)?.toInt()
- val enabled = if (duration != null && duration <= 0) false else true
+ val enabled = if (playbackState == null ||
+ playbackState?.getState() == PlaybackState.STATE_NONE ||
+ (duration != null && duration <= 0)) false else true
_data = Progress(enabled, seekAvailable, position, duration, color)
if (shouldPollPlaybackPosition()) {
checkPlaybackPosition()
}
}
+ /**
+ * Puts the seek bar into a resumption state.
+ *
+ * This should be called when the media session behind the controller has been destroyed.
+ */
+ @AnyThread
+ fun clearController() = bgExecutor.execute {
+ _data = _data.copy(enabled = false)
+ }
+
@AnyThread
private fun checkPlaybackPosition(): Runnable = bgExecutor.executeDelayed({
val currentPosition = controller?.playbackState?.position?.toInt()
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java
index c3779ef..ba9a30f 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java
@@ -339,18 +339,18 @@
@Override
public void onPipTransitionFinished(ComponentName activity, int direction) {
- onPipTransitionFinishedOrCanceled();
+ onPipTransitionFinishedOrCanceled(direction);
}
@Override
public void onPipTransitionCanceled(ComponentName activity, int direction) {
- onPipTransitionFinishedOrCanceled();
+ onPipTransitionFinishedOrCanceled(direction);
}
- private void onPipTransitionFinishedOrCanceled() {
+ private void onPipTransitionFinishedOrCanceled(int direction) {
// Re-enable touches after the animation completes
mTouchHandler.setTouchEnabled(true);
- mTouchHandler.onPinnedStackAnimationEnded();
+ mTouchHandler.onPinnedStackAnimationEnded(direction);
mMenuController.onPinnedStackAnimationEnded();
}
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java
index 2b9b171..ec15dd1 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java
@@ -54,6 +54,7 @@
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
+import android.os.Looper;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
@@ -129,9 +130,7 @@
}
};
- private Handler mHandler = new Handler();
- private Messenger mToControllerMessenger;
- private Messenger mMessenger = new Messenger(new Handler() {
+ private Handler mHandler = new Handler(Looper.getMainLooper()) {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
@@ -174,7 +173,9 @@
}
}
}
- });
+ };
+ private Messenger mToControllerMessenger;
+ private Messenger mMessenger = new Messenger(mHandler);
private final Runnable mFinishRunnable = new Runnable() {
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java
index d660b67..61ed40d 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java
@@ -30,6 +30,7 @@
import android.os.Bundle;
import android.os.Debug;
import android.os.Handler;
+import android.os.Looper;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
@@ -122,7 +123,7 @@
private boolean mStartActivityRequested;
private long mStartActivityRequestedTime;
private Messenger mToActivityMessenger;
- private Handler mHandler = new Handler() {
+ private Handler mHandler = new Handler(Looper.getMainLooper()) {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
@@ -133,15 +134,15 @@
break;
}
case MESSAGE_EXPAND_PIP: {
- mListeners.forEach(l -> l.onPipExpand());
+ mListeners.forEach(Listener::onPipExpand);
break;
}
case MESSAGE_DISMISS_PIP: {
- mListeners.forEach(l -> l.onPipDismiss());
+ mListeners.forEach(Listener::onPipDismiss);
break;
}
case MESSAGE_SHOW_MENU: {
- mListeners.forEach(l -> l.onPipShowMenu());
+ mListeners.forEach(Listener::onPipShowMenu);
break;
}
case MESSAGE_UPDATE_ACTIVITY_CALLBACK: {
@@ -259,6 +260,8 @@
if (DEBUG) {
Log.d(TAG, "showMenu() state=" + menuState
+ " hasActivity=" + (mToActivityMessenger != null)
+ + " allowMenuTimeout=" + allowMenuTimeout
+ + " willResizeMenu=" + willResizeMenu
+ " callers=\n" + Debug.getCallers(5, " "));
}
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java
index 0b07655..d80f18a 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java
@@ -56,7 +56,6 @@
private final DisplayMetrics mDisplayMetrics = new DisplayMetrics();
private final PipBoundsHandler mPipBoundsHandler;
- private final PipTouchHandler mPipTouchHandler;
private final PipMotionHelper mMotionHelper;
private final int mDisplayId;
private final Executor mMainExecutor;
@@ -70,10 +69,10 @@
private final Rect mTmpBounds = new Rect();
private final int mDelta;
- private boolean mAllowGesture = false;
+ private boolean mAllowGesture;
private boolean mIsAttached;
private boolean mIsEnabled;
- private boolean mEnablePipResize;
+ private boolean mEnableUserResize;
private InputMonitor mInputMonitor;
private InputEventReceiver mInputEventReceiver;
@@ -82,21 +81,20 @@
private int mCtrlType;
public PipResizeGestureHandler(Context context, PipBoundsHandler pipBoundsHandler,
- PipTouchHandler pipTouchHandler, PipMotionHelper motionHelper,
- DeviceConfigProxy deviceConfig, PipTaskOrganizer pipTaskOrganizer) {
+ PipMotionHelper motionHelper, DeviceConfigProxy deviceConfig,
+ PipTaskOrganizer pipTaskOrganizer) {
final Resources res = context.getResources();
context.getDisplay().getMetrics(mDisplayMetrics);
mDisplayId = context.getDisplayId();
mMainExecutor = context.getMainExecutor();
mPipBoundsHandler = pipBoundsHandler;
- mPipTouchHandler = pipTouchHandler;
mMotionHelper = motionHelper;
mPipTaskOrganizer = pipTaskOrganizer;
context.getDisplay().getRealSize(mMaxSize);
mDelta = res.getDimensionPixelSize(R.dimen.pip_resize_edge_size);
- mEnablePipResize = DeviceConfig.getBoolean(
+ mEnableUserResize = DeviceConfig.getBoolean(
DeviceConfig.NAMESPACE_SYSTEMUI,
PIP_USER_RESIZE,
/* defaultValue = */ true);
@@ -105,7 +103,7 @@
@Override
public void onPropertiesChanged(DeviceConfig.Properties properties) {
if (properties.getKeyset().contains(PIP_USER_RESIZE)) {
- mEnablePipResize = properties.getBoolean(
+ mEnableUserResize = properties.getBoolean(
PIP_USER_RESIZE, /* defaultValue = */ true);
}
}
@@ -134,7 +132,7 @@
}
private void updateIsEnabled() {
- boolean isEnabled = mIsAttached && mEnablePipResize;
+ boolean isEnabled = mIsAttached && mEnableUserResize;
if (isEnabled == mIsEnabled) {
return;
}
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
index 350ce29..f5c83c1 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
@@ -16,6 +16,7 @@
package com.android.systemui.pip.phone;
+import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_TO_PIP;
import static com.android.systemui.pip.phone.PipMenuActivityController.MENU_STATE_CLOSE;
import static com.android.systemui.pip.phone.PipMenuActivityController.MENU_STATE_FULL;
import static com.android.systemui.pip.phone.PipMenuActivityController.MENU_STATE_NONE;
@@ -56,6 +57,7 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.logging.MetricsLoggerWrapper;
import com.android.systemui.R;
+import com.android.systemui.pip.PipAnimationController;
import com.android.systemui.pip.PipBoundsHandler;
import com.android.systemui.pip.PipSnapAlgorithm;
import com.android.systemui.pip.PipTaskOrganizer;
@@ -229,7 +231,7 @@
mMotionHelper = new PipMotionHelper(mContext, activityTaskManager, pipTaskOrganizer,
mMenuController, mSnapAlgorithm, mFlingAnimationUtils, floatingContentCoordinator);
mPipResizeGestureHandler =
- new PipResizeGestureHandler(context, pipBoundsHandler, this, mMotionHelper,
+ new PipResizeGestureHandler(context, pipBoundsHandler, mMotionHelper,
deviceConfig, pipTaskOrganizer);
mTouchState = new PipTouchState(ViewConfiguration.get(context), mHandler,
() -> mMenuController.showMenu(MENU_STATE_FULL, mMotionHelper.getBounds(),
@@ -266,6 +268,10 @@
mMagnetizedPip = mMotionHelper.getMagnetizedPip();
mMagneticTarget = mMagnetizedPip.addTarget(mTargetView, 0);
+
+ // Set the magnetic field radius equal to twice the size of the target.
+ mMagneticTarget.setMagneticFieldRadiusPx(targetSize * 2);
+
mMagnetizedPip.setPhysicsAnimatorUpdateListener(mMotionHelper.mResizePipUpdateListener);
mMagnetizedPip.setMagnetListener(new MagnetizedObject.MagnetListener() {
@Override
@@ -339,11 +345,16 @@
mPipResizeGestureHandler.onActivityUnpinned();
}
- public void onPinnedStackAnimationEnded() {
+ public void onPinnedStackAnimationEnded(
+ @PipAnimationController.TransitionDirection int direction) {
// Always synchronize the motion helper bounds once PiP animations finish
mMotionHelper.synchronizePinnedStackBounds();
updateMovementBounds();
- mResizedBounds.set(mMotionHelper.getBounds());
+ if (direction == TRANSITION_DIRECTION_TO_PIP) {
+ // updates mResizedBounds only if it's an entering PiP animation
+ // mResized should be otherwise updated in setMenuState.
+ mResizedBounds.set(mMotionHelper.getBounds());
+ }
if (mShowPipMenuOnAnimationEnd) {
mMenuController.showMenu(MENU_STATE_CLOSE, mMotionHelper.getBounds(),
@@ -504,9 +515,6 @@
mTargetView.setTranslationY(mTargetViewContainer.getHeight());
mTargetViewContainer.setVisibility(View.VISIBLE);
- // Set the magnetic field radius to half of PIP's width.
- mMagneticTarget.setMagneticFieldRadiusPx(mMotionHelper.getBounds().width());
-
// Cancel in case we were in the middle of animating it out.
mMagneticTargetAnimator.cancel();
mMagneticTargetAnimator
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSMediaPlayer.java b/packages/SystemUI/src/com/android/systemui/qs/QSMediaPlayer.java
index e636707..e4bcb09 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSMediaPlayer.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSMediaPlayer.java
@@ -99,15 +99,14 @@
* @param bgColor background color
* @param actionsContainer a LinearLayout containing the media action buttons
* @param notif reference to original notification
- * @param device current playback device
+ * @param key original notification's key
*/
public void setMediaSession(MediaSession.Token token, Icon icon, int iconColor,
- int bgColor, View actionsContainer, Notification notif) {
+ int bgColor, View actionsContainer, Notification notif, String key) {
String appName = Notification.Builder.recoverBuilder(getContext(), notif)
.loadHeaderAppName();
- super.setMediaSession(token, icon, iconColor, bgColor, notif.contentIntent,
- appName);
+ super.setMediaSession(token, icon, iconColor, bgColor, notif.contentIntent, appName, key);
// Media controls
LinearLayout parentActionsLayout = (LinearLayout) actionsContainer;
@@ -171,6 +170,8 @@
public void clearControls() {
super.clearControls();
+ mSeekBarViewModel.clearController();
+
View guts = mMediaNotifView.findViewById(R.id.media_guts);
View options = mMediaNotifView.findViewById(R.id.qs_media_controls_options);
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
index 0566b2e..40c8aad 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
@@ -208,9 +208,10 @@
* @param bgColor
* @param actionsContainer
* @param notif
+ * @param key
*/
public void addMediaSession(MediaSession.Token token, Icon icon, int iconColor, int bgColor,
- View actionsContainer, StatusBarNotification notif) {
+ View actionsContainer, StatusBarNotification notif, String key) {
if (!useQsMediaPlayer(mContext)) {
// Shouldn't happen, but just in case
Log.e(TAG, "Tried to add media session without player!");
@@ -225,13 +226,12 @@
String packageName = notif.getPackageName();
for (QSMediaPlayer p : mMediaPlayers) {
if (p.getMediaSessionToken().equals(token)) {
- Log.d(TAG, "a player for this session already exists");
+ Log.d(TAG, "Found matching player by token " + packageName);
player = p;
break;
- }
-
- if (packageName.equals(p.getMediaPlayerPackage())) {
- Log.d(TAG, "found an old session for this app");
+ } else if (packageName.equals(p.getMediaPlayerPackage()) && key.equals(p.getKey())) {
+ // Also match if it's the same package and notification key
+ Log.d(TAG, "Found matching player by package " + packageName + ", " + key);
player = p;
break;
}
@@ -267,7 +267,7 @@
Log.d(TAG, "setting player session");
player.setMediaSession(token, icon, iconColor, bgColor, actionsContainer,
- notif.getNotification());
+ notif.getNotification(), key);
if (mMediaPlayers.size() > 0) {
((View) mMediaCarousel.getParent()).setVisibility(View.VISIBLE);
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QuickQSMediaPlayer.java b/packages/SystemUI/src/com/android/systemui/qs/QuickQSMediaPlayer.java
index 0ba4cb1..7946779 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QuickQSMediaPlayer.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QuickQSMediaPlayer.java
@@ -67,9 +67,10 @@
* @param actionsToShow indices of which actions to display in the mini player
* (max 3: Notification.MediaStyle.MAX_MEDIA_BUTTONS_IN_COMPACT)
* @param contentIntent Intent to send when user taps on the view
+ * @param key original notification's key
*/
public void setMediaSession(MediaSession.Token token, Icon icon, int iconColor, int bgColor,
- View actionsContainer, int[] actionsToShow, PendingIntent contentIntent) {
+ View actionsContainer, int[] actionsToShow, PendingIntent contentIntent, String key) {
// Only update if this is a different session and currently playing
String oldPackage = "";
if (getController() != null) {
@@ -84,7 +85,7 @@
return;
}
- super.setMediaSession(token, icon, iconColor, bgColor, contentIntent, null);
+ super.setMediaSession(token, icon, iconColor, bgColor, contentIntent, null, key);
LinearLayout parentActionsLayout = (LinearLayout) actionsContainer;
int i = 0;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt
index 0d77159..25f1a97 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt
@@ -250,7 +250,8 @@
private fun updateShadeBlur() {
var newBlur = 0
val state = statusBarStateController.state
- if (state == StatusBarState.SHADE || state == StatusBarState.SHADE_LOCKED) {
+ if ((state == StatusBarState.SHADE || state == StatusBarState.SHADE_LOCKED) &&
+ !keyguardStateController.isKeyguardFadingAway) {
newBlur = blurUtils.blurRadiusOfRatio(shadeExpansion)
}
shadeSpring.animateTo(newBlur)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationConversationInfo.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationConversationInfo.java
index a271993..ab2cffa 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationConversationInfo.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationConversationInfo.java
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.notification.row;
import static android.app.Notification.EXTRA_IS_GROUP_CONVERSATION;
+import static android.app.NotificationManager.BUBBLE_PREFERENCE_ALL;
import static android.app.NotificationManager.BUBBLE_PREFERENCE_NONE;
import static android.app.NotificationManager.BUBBLE_PREFERENCE_SELECTED;
import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
@@ -33,6 +34,7 @@
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationChannelGroup;
+import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
@@ -51,6 +53,7 @@
import android.transition.TransitionSet;
import android.util.AttributeSet;
import android.util.Log;
+import android.util.Slog;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
import android.widget.ImageView;
@@ -91,6 +94,7 @@
private String mConversationId;
private StatusBarNotification mSbn;
private boolean mIsDeviceProvisioned;
+ private int mAppBubble;
private TextView mPriorityDescriptionView;
private TextView mDefaultDescriptionView;
@@ -206,6 +210,13 @@
mNotificationChannel = NotificationChannelHelper.createConversationChannelIfNeeded(
getContext(), mINotificationManager, entry, mNotificationChannel);
+ try {
+ mAppBubble = mINotificationManager.getBubblePreferenceForPackage(mPackageName, mAppUid);
+ } catch (RemoteException e) {
+ Slog.e(TAG, "can't reach OS", e);
+ mAppBubble = BUBBLE_PREFERENCE_SELECTED;
+ }
+
bindHeader();
bindActions();
@@ -227,6 +238,11 @@
snooze.setOnClickListener(mOnSnoozeClick);
*/
+ if (mAppBubble == BUBBLE_PREFERENCE_ALL) {
+ ((TextView) findViewById(R.id.default_summary)).setText(getResources().getString(
+ R.string.notification_channel_summary_default_with_bubbles, mAppName));
+ }
+
findViewById(R.id.priority).setOnClickListener(mOnFavoriteClick);
findViewById(R.id.default_behavior).setOnClickListener(mOnDefaultClick);
findViewById(R.id.silence).setOnClickListener(mOnMuteClick);
@@ -264,7 +280,6 @@
// bindName();
bindPackage();
bindIcon(mNotificationChannel.isImportantConversation());
-
}
private void bindIcon(boolean important) {
@@ -560,10 +575,7 @@
!mChannelToUpdate.isImportantConversation());
if (mChannelToUpdate.isImportantConversation()) {
mChannelToUpdate.setAllowBubbles(true);
- int currentPref =
- mINotificationManager.getBubblePreferenceForPackage(
- mAppPkg, mAppUid);
- if (currentPref == BUBBLE_PREFERENCE_NONE) {
+ if (mAppBubble == BUBBLE_PREFERENCE_NONE) {
mINotificationManager.setBubblesAllowed(mAppPkg, mAppUid,
BUBBLE_PREFERENCE_SELECTED);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationMediaTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationMediaTemplateViewWrapper.java
index 874d81d..2da2724 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationMediaTemplateViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationMediaTemplateViewWrapper.java
@@ -193,7 +193,8 @@
mBackgroundColor,
mActions,
compactActions,
- notif.contentIntent);
+ notif.contentIntent,
+ sbn.getKey());
QSPanel bigPanel = ctrl.getNotificationShadeView().findViewById(
com.android.systemui.R.id.quick_settings_panel);
bigPanel.addMediaSession(token,
@@ -201,7 +202,8 @@
tintColor,
mBackgroundColor,
mActions,
- sbn);
+ sbn,
+ sbn.getKey());
}
boolean showCompactSeekbar = mMediaManager.getShowCompactMediaSeekbar();
diff --git a/packages/SystemUI/src/com/android/systemui/util/magnetictarget/MagnetizedObject.kt b/packages/SystemUI/src/com/android/systemui/util/magnetictarget/MagnetizedObject.kt
index f27bdbf..e905e67 100644
--- a/packages/SystemUI/src/com/android/systemui/util/magnetictarget/MagnetizedObject.kt
+++ b/packages/SystemUI/src/com/android/systemui/util/magnetictarget/MagnetizedObject.kt
@@ -27,6 +27,7 @@
import android.view.MotionEvent
import android.view.VelocityTracker
import android.view.View
+import android.view.ViewConfiguration
import androidx.dynamicanimation.animation.DynamicAnimation
import androidx.dynamicanimation.animation.FloatPropertyCompat
import androidx.dynamicanimation.animation.SpringForce
@@ -146,6 +147,10 @@
private val velocityTracker: VelocityTracker = VelocityTracker.obtain()
private val vibrator: Vibrator = context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
+ private var touchDown = PointF()
+ private var touchSlop = 0
+ private var movedBeyondSlop = false
+
/** Whether touch events are presently occurring within the magnetic field area of a target. */
val objectStuckToTarget: Boolean
get() = targetObjectIsStuckTo != null
@@ -324,15 +329,32 @@
// When a gesture begins, recalculate target views' positions on the screen in case they
// have changed. Also, clear state.
if (ev.action == MotionEvent.ACTION_DOWN) {
- updateTargetViewLocations()
+ updateTargetViews()
- // Clear the velocity tracker and assume we're not stuck to a target yet.
+ // Clear the velocity tracker and stuck target.
velocityTracker.clear()
targetObjectIsStuckTo = null
+
+ // Set the touch down coordinates and reset movedBeyondSlop.
+ touchDown.set(ev.rawX, ev.rawY)
+ movedBeyondSlop = false
}
+ // Always pass events to the VelocityTracker.
addMovement(ev)
+ // If we haven't yet moved beyond the slop distance, check if we have.
+ if (!movedBeyondSlop) {
+ val dragDistance = hypot(ev.rawX - touchDown.x, ev.rawY - touchDown.y)
+ if (dragDistance > touchSlop) {
+ // If we're beyond the slop distance, save that and continue.
+ movedBeyondSlop = true
+ } else {
+ // Otherwise, don't do anything yet.
+ return false
+ }
+ }
+
val targetObjectIsInMagneticFieldOf = associatedTargets.firstOrNull { target ->
val distanceFromTargetCenter = hypot(
ev.rawX - target.centerOnScreen.x,
@@ -559,8 +581,14 @@
}
/** Updates the locations on screen of all of the [associatedTargets]. */
- internal fun updateTargetViewLocations() {
+ internal fun updateTargetViews() {
associatedTargets.forEach { it.updateLocationOnScreen() }
+
+ // Update the touch slop, since the configuration may have changed.
+ if (associatedTargets.size > 0) {
+ touchSlop =
+ ViewConfiguration.get(associatedTargets[0].targetView.context).scaledTouchSlop
+ }
}
/**
diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/SeekBarViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/SeekBarViewModelTest.kt
index f316d04..28a3d6a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/media/SeekBarViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/media/SeekBarViewModelTest.kt
@@ -86,7 +86,29 @@
}
@Test
- fun updateDuration() {
+ fun updateDurationWithPlayback() {
+ // GIVEN that the duration is contained within the metadata
+ val duration = 12000L
+ val metadata = MediaMetadata.Builder().run {
+ putLong(MediaMetadata.METADATA_KEY_DURATION, duration)
+ build()
+ }
+ whenever(mockController.getMetadata()).thenReturn(metadata)
+ // AND a valid playback state (ie. media session is not destroyed)
+ val state = PlaybackState.Builder().run {
+ setState(PlaybackState.STATE_PLAYING, 200L, 1f)
+ build()
+ }
+ whenever(mockController.getPlaybackState()).thenReturn(state)
+ // WHEN the controller is updated
+ viewModel.updateController(mockController, Color.RED)
+ // THEN the duration is extracted
+ assertThat(viewModel.progress.value!!.duration).isEqualTo(duration)
+ assertThat(viewModel.progress.value!!.enabled).isTrue()
+ }
+
+ @Test
+ fun updateDurationWithoutPlayback() {
// GIVEN that the duration is contained within the metadata
val duration = 12000L
val metadata = MediaMetadata.Builder().run {
@@ -98,7 +120,7 @@
viewModel.updateController(mockController, Color.RED)
// THEN the duration is extracted
assertThat(viewModel.progress.value!!.duration).isEqualTo(duration)
- assertThat(viewModel.progress.value!!.enabled).isTrue()
+ assertThat(viewModel.progress.value!!.enabled).isFalse()
}
@Test
@@ -110,6 +132,12 @@
build()
}
whenever(mockController.getMetadata()).thenReturn(metadata)
+ // AND a valid playback state (ie. media session is not destroyed)
+ val state = PlaybackState.Builder().run {
+ setState(PlaybackState.STATE_PLAYING, 200L, 1f)
+ build()
+ }
+ whenever(mockController.getPlaybackState()).thenReturn(state)
// WHEN the controller is updated
viewModel.updateController(mockController, Color.RED)
// THEN the seek bar is disabled
@@ -125,6 +153,12 @@
build()
}
whenever(mockController.getMetadata()).thenReturn(metadata)
+ // AND a valid playback state (ie. media session is not destroyed)
+ val state = PlaybackState.Builder().run {
+ setState(PlaybackState.STATE_PLAYING, 200L, 1f)
+ build()
+ }
+ whenever(mockController.getPlaybackState()).thenReturn(state)
// WHEN the controller is updated
viewModel.updateController(mockController, Color.RED)
// THEN the seek bar is disabled
@@ -372,4 +406,30 @@
// THEN an update task is queued
assertThat(fakeExecutor.numPending()).isEqualTo(1)
}
+
+ @Test
+ fun clearSeekBar() {
+ // GIVEN that the duration is contained within the metadata
+ val metadata = MediaMetadata.Builder().run {
+ putLong(MediaMetadata.METADATA_KEY_DURATION, 12000L)
+ build()
+ }
+ whenever(mockController.getMetadata()).thenReturn(metadata)
+ // AND a valid playback state (ie. media session is not destroyed)
+ val state = PlaybackState.Builder().run {
+ setState(PlaybackState.STATE_PLAYING, 200L, 1f)
+ build()
+ }
+ whenever(mockController.getPlaybackState()).thenReturn(state)
+ // AND the controller has been updated
+ viewModel.updateController(mockController, Color.RED)
+ // WHEN the controller is cleared on the event when the session is destroyed
+ viewModel.clearController()
+ with(fakeExecutor) {
+ advanceClockToNext()
+ runAllReady()
+ }
+ // THEN the seek bar is disabled
+ assertThat(viewModel.progress.value!!.enabled).isFalse()
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationConversationInfoTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationConversationInfoTest.java
index b6bd5e2..6bcaee1 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationConversationInfoTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationConversationInfoTest.java
@@ -17,6 +17,8 @@
package com.android.systemui.statusbar.notification.row;
import static android.app.Notification.FLAG_BUBBLE;
+import static android.app.NotificationManager.BUBBLE_PREFERENCE_ALL;
+import static android.app.NotificationManager.BUBBLE_PREFERENCE_SELECTED;
import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
import static android.app.NotificationManager.IMPORTANCE_HIGH;
import static android.app.NotificationManager.IMPORTANCE_LOW;
@@ -458,7 +460,9 @@
}
@Test
- public void testBindNotification_defaultSelected_notFave_notSilent() {
+ public void testBindNotification_defaultSelected_notFave_notSilent() throws Exception {
+ when(mMockINotificationManager.getBubblePreferenceForPackage(anyString(), anyInt()))
+ .thenReturn(BUBBLE_PREFERENCE_SELECTED);
mConversationChannel.setImportance(IMPORTANCE_HIGH);
mConversationChannel.setImportantConversation(false);
mConversationChannel.setAllowBubbles(true);
@@ -476,6 +480,35 @@
true);
View view = mNotificationInfo.findViewById(R.id.default_behavior);
assertThat(view.isSelected()).isTrue();
+ assertThat(((TextView) view.findViewById(R.id.default_summary)).getText()).isEqualTo(
+ mContext.getString(R.string.notification_channel_summary_default));
+ }
+
+ @Test
+ public void testBindNotification_default_allCanBubble() throws Exception {
+ when(mMockINotificationManager.getBubblePreferenceForPackage(anyString(), anyInt()))
+ .thenReturn(BUBBLE_PREFERENCE_ALL);
+ when(mMockPackageManager.getApplicationLabel(any())).thenReturn("App Name");
+ mConversationChannel.setImportance(IMPORTANCE_HIGH);
+ mConversationChannel.setImportantConversation(false);
+ mConversationChannel.setAllowBubbles(true);
+ mNotificationInfo.bindNotification(
+ mShortcutManager,
+ mMockPackageManager,
+ mMockINotificationManager,
+ mVisualStabilityManager,
+ TEST_PACKAGE_NAME,
+ mNotificationChannel,
+ mEntry,
+ null,
+ null,
+ mIconFactory,
+ true);
+ View view = mNotificationInfo.findViewById(R.id.default_behavior);
+ assertThat(view.isSelected()).isTrue();
+ assertThat(((TextView) view.findViewById(R.id.default_summary)).getText()).isEqualTo(
+ mContext.getString(R.string.notification_channel_summary_default_with_bubbles,
+ "App Name"));
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/util/magnetictarget/MagnetizedObjectTest.kt b/packages/SystemUI/tests/src/com/android/systemui/util/magnetictarget/MagnetizedObjectTest.kt
index f6b7b74..251ca9c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/util/magnetictarget/MagnetizedObjectTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/util/magnetictarget/MagnetizedObjectTest.kt
@@ -186,8 +186,8 @@
@Test
fun testMotionEventConsumption_downInMagneticField() {
- // We should consume DOWN events if they occur in the field.
- assertTrue(magnetizedObject.maybeConsumeMotionEvent(getMotionEvent(
+ // We should not consume DOWN events even if they occur in the field.
+ assertFalse(magnetizedObject.maybeConsumeMotionEvent(getMotionEvent(
x = targetCenterX, y = targetCenterY, action = MotionEvent.ACTION_DOWN)))
}
@@ -342,10 +342,14 @@
// Trigger the magnet animation, and block the test until it ends.
PhysicsAnimatorTestUtils.setAllAnimationsBlock(true)
magnetizedObject.maybeConsumeMotionEvent(getMotionEvent(
- x = targetCenterX,
- y = targetCenterY,
+ x = targetCenterX - 250,
+ y = targetCenterY - 250,
action = MotionEvent.ACTION_DOWN))
+ magnetizedObject.maybeConsumeMotionEvent(getMotionEvent(
+ x = targetCenterX,
+ y = targetCenterY))
+
// The object's (top-left) position should now position it centered over the target.
assertEquals(targetCenterX - objectSize / 2, objectX)
assertEquals(targetCenterY - objectSize / 2, objectY)
diff --git a/packages/Tethering/src/com/android/networkstack/tethering/Tethering.java b/packages/Tethering/src/com/android/networkstack/tethering/Tethering.java
index f3cead9..bae54a5 100644
--- a/packages/Tethering/src/com/android/networkstack/tethering/Tethering.java
+++ b/packages/Tethering/src/com/android/networkstack/tethering/Tethering.java
@@ -922,8 +922,10 @@
case WifiManager.WIFI_AP_STATE_ENABLED:
enableWifiIpServingLocked(ifname, ipmode);
break;
- case WifiManager.WIFI_AP_STATE_DISABLED:
case WifiManager.WIFI_AP_STATE_DISABLING:
+ // We can see this state on the way to disabled.
+ break;
+ case WifiManager.WIFI_AP_STATE_DISABLED:
case WifiManager.WIFI_AP_STATE_FAILED:
default:
disableWifiIpServingLocked(ifname, curState);
diff --git a/read-snapshot.txt b/read-snapshot.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/read-snapshot.txt
diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java
index 3d68618..9d1ad42 100644
--- a/services/autofill/java/com/android/server/autofill/Session.java
+++ b/services/autofill/java/com/android/server/autofill/Session.java
@@ -2653,6 +2653,11 @@
} else if (viewState.id.equals(this.mCurrentViewId)
&& (viewState.getState() & ViewState.STATE_INLINE_SHOWN) != 0) {
requestShowInlineSuggestionsLocked(viewState.getResponse(), filterText);
+ } else if (viewState.id.equals(this.mCurrentViewId)
+ && (viewState.getState() & ViewState.STATE_TRIGGERED_AUGMENTED_AUTOFILL) != 0) {
+ if (!TextUtils.isEmpty(filterText)) {
+ mInlineSessionController.hideInlineSuggestionsUiLocked(mCurrentViewId);
+ }
}
viewState.setState(ViewState.STATE_CHANGED);
diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java
index 89fa02b..cce749d 100644
--- a/services/core/java/com/android/server/am/ProcessList.java
+++ b/services/core/java/com/android/server/am/ProcessList.java
@@ -1668,6 +1668,33 @@
return gidArray;
}
+ private boolean shouldEnableTaggedPointers(ProcessRecord app) {
+ // Ensure we have platform + kernel support for TBI.
+ if (!Zygote.nativeSupportsTaggedPointers()) {
+ return false;
+ }
+
+ // Check to ensure the app hasn't explicitly opted-out of TBI via. the manifest attribute.
+ if (!app.info.allowsNativeHeapPointerTagging()) {
+ return false;
+ }
+
+ // Check to see that the compat feature for TBI is enabled.
+ if (!mPlatformCompat.isChangeEnabled(NATIVE_HEAP_POINTER_TAGGING, app.info)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ private int decideTaggingLevel(ProcessRecord app) {
+ if (shouldEnableTaggedPointers(app)) {
+ return Zygote.MEMORY_TAG_LEVEL_TBI;
+ }
+
+ return 0;
+ }
+
private int decideGwpAsanLevel(ProcessRecord app) {
// Look at the process attribute first.
if (app.processInfo != null
@@ -1856,15 +1883,6 @@
runtimeFlags |= Zygote.USE_APP_IMAGE_STARTUP_CACHE;
}
- if (Zygote.nativeSupportsTaggedPointers()) {
- // Enable heap pointer tagging if supported by the kernel, unless disabled by the
- // app manifest, target sdk level, or compat feature.
- if (app.info.allowsNativeHeapPointerTagging()
- && mPlatformCompat.isChangeEnabled(NATIVE_HEAP_POINTER_TAGGING, app.info)) {
- runtimeFlags |= Zygote.MEMORY_TAG_LEVEL_TBI;
- }
- }
-
runtimeFlags |= decideGwpAsanLevel(app);
String invokeWith = null;
@@ -1895,6 +1913,20 @@
app.setRequiredAbi(requiredAbi);
app.instructionSet = instructionSet;
+ // If instructionSet is non-null, this indicates that the system_server is spawning a
+ // process with an ISA that may be different from its own. System (kernel and hardware)
+ // compatililty for these features is checked in the decideTaggingLevel in the
+ // system_server process (not the child process). As TBI is only supported in aarch64,
+ // we can simply ensure that the new process is also aarch64. This prevents the mismatch
+ // where a 64-bit system server spawns a 32-bit child that thinks it should enable some
+ // tagging variant. Theoretically, a 32-bit system server could exist that spawns 64-bit
+ // processes, in which case the new process won't get any tagging. This is fine as we
+ // haven't seen this configuration in practice, and we can reasonable assume that if
+ // tagging is desired, the system server will be 64-bit.
+ if (instructionSet == null || instructionSet.equals("arm64")) {
+ runtimeFlags |= decideTaggingLevel(app);
+ }
+
// the per-user SELinux context must be set
if (TextUtils.isEmpty(app.info.seInfoUser)) {
Slog.wtf(ActivityManagerService.TAG, "SELinux tag not defined",
diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java
index 31bccea..8ecda8f 100644
--- a/services/core/java/com/android/server/appop/AppOpsService.java
+++ b/services/core/java/com/android/server/appop/AppOpsService.java
@@ -2830,7 +2830,6 @@
private int checkOperationImpl(int code, int uid, String packageName,
boolean raw) {
- verifyIncomingUid(uid);
verifyIncomingOp(code);
String resolvedPackageName = resolvePackageName(uid, packageName);
if (resolvedPackageName == null) {
diff --git a/services/core/java/com/android/server/appop/TEST_MAPPING b/services/core/java/com/android/server/appop/TEST_MAPPING
index 9c03a36..604b9f1 100644
--- a/services/core/java/com/android/server/appop/TEST_MAPPING
+++ b/services/core/java/com/android/server/appop/TEST_MAPPING
@@ -38,6 +38,9 @@
},
{
"name": "CtsAppTestCases:ActivityManagerApi29Test"
+ },
+ {
+ "name": "UidAtomTests:testAppOps"
}
]
}
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index 4687a51..48e30bf 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -390,6 +390,10 @@
private ObjectAnimator mColorFadeOffAnimator;
private RampAnimator<DisplayPowerState> mScreenBrightnessRampAnimator;
+ // The brightness synchronizer to allow changes in the int brightness value to be reflected in
+ // the float brightness value and vice versa.
+ @Nullable
+ private final BrightnessSynchronizer mBrightnessSynchronizer;
/**
* Creates the display power controller.
@@ -406,6 +410,7 @@
mWindowManagerPolicy = LocalServices.getService(WindowManagerPolicy.class);
mBlanker = blanker;
mContext = context;
+ mBrightnessSynchronizer = new BrightnessSynchronizer(context);
mDisplayDevice = displayDevice;
PowerManager pm = context.getSystemService(PowerManager.class);
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
index e6cb371..b949d6b 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
@@ -784,6 +784,7 @@
private static final AtomicInteger sSequenceNumber = new AtomicInteger(0);
private static final class Entry {
+ final int mSequenceNumber = sSequenceNumber.getAndIncrement();
final ClientState mClientState;
@SoftInputModeFlags
final int mFocusedWindowSoftInputMode;
@@ -831,7 +832,7 @@
continue;
}
pw.print(prefix);
- pw.println("SoftInputShowHideHistory #" + sSequenceNumber.getAndIncrement() + ":");
+ pw.println("SoftInputShowHideHistory #" + entry.mSequenceNumber + ":");
pw.print(prefix);
pw.println(" time=" + dataFormat.format(new Date(entry.mWallTime))
diff --git a/services/core/java/com/android/server/location/GeofenceManager.java b/services/core/java/com/android/server/location/GeofenceManager.java
index 195b059..095cd14 100644
--- a/services/core/java/com/android/server/location/GeofenceManager.java
+++ b/services/core/java/com/android/server/location/GeofenceManager.java
@@ -253,7 +253,7 @@
int op = CallerIdentity.asAppOp(identity.permissionLevel);
if (op >= 0) {
if (mAppOps.noteOpNoThrow(AppOpsManager.OP_FINE_LOCATION, identity.uid,
- identity.packageName, identity.featureId, null)
+ identity.packageName, identity.featureId, identity.listenerId)
!= AppOpsManager.MODE_ALLOWED) {
continue;
}
diff --git a/services/core/java/com/android/server/location/LocationManagerService.java b/services/core/java/com/android/server/location/LocationManagerService.java
index 72cc13a..4f8708a 100644
--- a/services/core/java/com/android/server/location/LocationManagerService.java
+++ b/services/core/java/com/android/server/location/LocationManagerService.java
@@ -36,6 +36,7 @@
import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.app.ActivityManager;
+import android.app.AppOpsManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -1827,6 +1828,9 @@
if (request == null) {
request = DEFAULT_LOCATION_REQUEST;
}
+ if (listenerId == null && intent != null) {
+ listenerId = AppOpsManager.toReceiverId(intent);
+ }
CallerIdentity identity = CallerIdentity.fromBinder(mContext, packageName, featureId,
listenerId);
@@ -2093,7 +2097,8 @@
request = DEFAULT_LOCATION_REQUEST;
}
- CallerIdentity identity = CallerIdentity.fromBinder(mContext, packageName, featureId);
+ CallerIdentity identity = CallerIdentity.fromBinder(mContext, packageName, featureId,
+ AppOpsManager.toReceiverId(intent));
identity.enforceLocationPermission();
Objects.requireNonNull(intent);
diff --git a/services/core/java/com/android/server/locksettings/LockSettingsService.java b/services/core/java/com/android/server/locksettings/LockSettingsService.java
index 9297a43..7972f24 100644
--- a/services/core/java/com/android/server/locksettings/LockSettingsService.java
+++ b/services/core/java/com/android/server/locksettings/LockSettingsService.java
@@ -366,10 +366,15 @@
if (mStorage.hasChildProfileLock(managedUserId)) {
return;
}
- // Do not tie it to parent when parent does not have a screen lock
+ // If parent does not have a screen lock, simply clear credential from the managed profile,
+ // to maintain the invariant that unified profile should always have the same secure state
+ // as its parent.
final int parentId = mUserManager.getProfileParent(managedUserId).id;
- if (!isUserSecure(parentId)) {
- if (DEBUG) Slog.v(TAG, "Parent does not have a screen lock");
+ if (!isUserSecure(parentId) && !managedUserPassword.isNone()) {
+ if (DEBUG) Slog.v(TAG, "Parent does not have a screen lock but profile has one");
+
+ setLockCredentialInternal(LockscreenCredential.createNone(), managedUserPassword,
+ managedUserId, /* isLockTiedToParent= */ true);
return;
}
// Do not tie when the parent has no SID (but does have a screen lock).
@@ -3161,6 +3166,21 @@
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(timestamp));
}
+ private static String credentialTypeToString(int credentialType) {
+ switch (credentialType) {
+ case CREDENTIAL_TYPE_NONE:
+ return "None";
+ case CREDENTIAL_TYPE_PATTERN:
+ return "Pattern";
+ case CREDENTIAL_TYPE_PIN:
+ return "Pin";
+ case CREDENTIAL_TYPE_PASSWORD:
+ return "Password";
+ default:
+ return "Unknown " + credentialType;
+ }
+ }
+
@Override
protected void dump(FileDescriptor fd, PrintWriter printWriter, String[] args) {
if (!DumpUtils.checkDumpPermission(mContext, TAG, printWriter)) return;
@@ -3192,7 +3212,8 @@
// It's OK to dump the password type since anyone with physical access can just
// observe it from the keyguard directly.
pw.println("Quality: " + getKeyguardStoredQuality(userId));
- pw.println("CredentialType: " + getCredentialTypeInternal(userId));
+ pw.println("CredentialType: " + credentialTypeToString(
+ getCredentialTypeInternal(userId)));
pw.println("SeparateChallenge: " + getSeparateProfileChallengeEnabledInternal(userId));
pw.println(String.format("Metrics: %s",
getUserPasswordMetrics(userId) != null ? "known" : "unknown"));
diff --git a/services/core/java/com/android/server/media/SystemMediaRoute2Provider.java b/services/core/java/com/android/server/media/SystemMediaRoute2Provider.java
index 6e2feeb..1345e37 100644
--- a/services/core/java/com/android/server/media/SystemMediaRoute2Provider.java
+++ b/services/core/java/com/android/server/media/SystemMediaRoute2Provider.java
@@ -261,8 +261,10 @@
.build();
builder.addSelectedRoute(mSelectedRouteId);
- for (MediaRoute2Info route : mBtRouteProvider.getTransferableRoutes()) {
- builder.addTransferableRoute(route.getId());
+ if (mBtRouteProvider != null) {
+ for (MediaRoute2Info route : mBtRouteProvider.getTransferableRoutes()) {
+ builder.addTransferableRoute(route.getId());
+ }
}
RoutingSessionInfo newSessionInfo = builder.setProviderId(mUniqueId).build();
diff --git a/services/core/java/com/android/server/net/NetworkStatsService.java b/services/core/java/com/android/server/net/NetworkStatsService.java
index d8264b3..f7d0d4e 100644
--- a/services/core/java/com/android/server/net/NetworkStatsService.java
+++ b/services/core/java/com/android/server/net/NetworkStatsService.java
@@ -46,7 +46,6 @@
import static android.net.NetworkStatsHistory.FIELD_ALL;
import static android.net.NetworkTemplate.buildTemplateMobileWildcard;
import static android.net.NetworkTemplate.buildTemplateWifiWildcard;
-import static android.net.NetworkTemplate.getCollapsedRatType;
import static android.net.TrafficStats.KB_IN_BYTES;
import static android.net.TrafficStats.MB_IN_BYTES;
import static android.os.Trace.TRACE_TAG_NETWORK;
@@ -67,9 +66,6 @@
import static android.provider.Settings.Global.NETSTATS_UID_TAG_DELETE_AGE;
import static android.provider.Settings.Global.NETSTATS_UID_TAG_PERSIST_BYTES;
import static android.provider.Settings.Global.NETSTATS_UID_TAG_ROTATE_AGE;
-import static android.telephony.PhoneStateListener.LISTEN_NONE;
-import static android.telephony.PhoneStateListener.LISTEN_SERVICE_STATE;
-import static android.telephony.TelephonyManager.NETWORK_TYPE_UNKNOWN;
import static android.text.format.DateUtils.DAY_IN_MILLIS;
import static android.text.format.DateUtils.HOUR_IN_MILLIS;
import static android.text.format.DateUtils.MINUTE_IN_MILLIS;
@@ -133,9 +129,7 @@
import android.service.NetworkInterfaceProto;
import android.service.NetworkStatsServiceDumpProto;
import android.telephony.PhoneStateListener;
-import android.telephony.ServiceState;
import android.telephony.SubscriptionPlan;
-import android.telephony.TelephonyManager;
import android.text.format.DateUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
@@ -206,7 +200,6 @@
private final NetworkStatsFactory mStatsFactory;
private final AlarmManager mAlarmManager;
private final Clock mClock;
- private final TelephonyManager mTeleManager;
private final NetworkStatsSettings mSettings;
private final NetworkStatsObservers mStatsObservers;
@@ -352,6 +345,9 @@
@NonNull
private final Dependencies mDeps;
+ @NonNull
+ private final NetworkStatsSubscriptionsMonitor mNetworkStatsSubscriptionsMonitor;
+
private static @NonNull File getDefaultSystemDir() {
return new File(Environment.getDataDirectory(), "system");
}
@@ -401,8 +397,8 @@
PowerManager.WakeLock wakeLock =
powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
- NetworkStatsService service = new NetworkStatsService(context, networkManager, alarmManager,
- wakeLock, getDefaultClock(), context.getSystemService(TelephonyManager.class),
+ final NetworkStatsService service = new NetworkStatsService(context, networkManager,
+ alarmManager, wakeLock, getDefaultClock(),
new DefaultNetworkStatsSettings(context), new NetworkStatsFactory(),
new NetworkStatsObservers(), getDefaultSystemDir(), getDefaultBaseDir(),
new Dependencies());
@@ -416,16 +412,15 @@
@VisibleForTesting
NetworkStatsService(Context context, INetworkManagementService networkManager,
AlarmManager alarmManager, PowerManager.WakeLock wakeLock, Clock clock,
- TelephonyManager teleManager, NetworkStatsSettings settings,
- NetworkStatsFactory factory, NetworkStatsObservers statsObservers, File systemDir,
- File baseDir, @NonNull Dependencies deps) {
+ NetworkStatsSettings settings, NetworkStatsFactory factory,
+ NetworkStatsObservers statsObservers, File systemDir, File baseDir,
+ @NonNull Dependencies deps) {
mContext = Objects.requireNonNull(context, "missing Context");
mNetworkManager = Objects.requireNonNull(networkManager,
- "missing INetworkManagementService");
+ "missing INetworkManagementService");
mAlarmManager = Objects.requireNonNull(alarmManager, "missing AlarmManager");
mClock = Objects.requireNonNull(clock, "missing Clock");
mSettings = Objects.requireNonNull(settings, "missing NetworkStatsSettings");
- mTeleManager = Objects.requireNonNull(teleManager, "missing TelephonyManager");
mWakeLock = Objects.requireNonNull(wakeLock, "missing WakeLock");
mStatsFactory = Objects.requireNonNull(factory, "missing factory");
mStatsObservers = Objects.requireNonNull(statsObservers, "missing NetworkStatsObservers");
@@ -437,7 +432,8 @@
final HandlerThread handlerThread = mDeps.makeHandlerThread();
handlerThread.start();
mHandler = new NetworkStatsHandler(handlerThread.getLooper());
- mPhoneListener = new NetworkTypeListener(new HandlerExecutor(mHandler));
+ mNetworkStatsSubscriptionsMonitor = deps.makeSubscriptionsMonitor(mContext,
+ new HandlerExecutor(mHandler), this);
}
/**
@@ -453,6 +449,19 @@
public HandlerThread makeHandlerThread() {
return new HandlerThread(TAG);
}
+
+ /**
+ * Create a {@link NetworkStatsSubscriptionsMonitor}, can be used to monitor RAT change
+ * event in NetworkStatsService.
+ */
+ @NonNull
+ public NetworkStatsSubscriptionsMonitor makeSubscriptionsMonitor(@NonNull Context context,
+ @NonNull Executor executor, @NonNull NetworkStatsService service) {
+ // TODO: Update RatType passively in NSS, instead of querying into the monitor
+ // when forceUpdateIface.
+ return new NetworkStatsSubscriptionsMonitor(context, executor, (subscriberId, type) ->
+ service.handleOnCollapsedRatTypeChanged());
+ }
}
private void registerLocalService() {
@@ -517,11 +526,10 @@
mAlarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME, currentRealtime,
mSettings.getPollInterval(), pollIntent);
- // TODO: 1. listen to changes from all subscriptions.
- // 2. listen to settings changed to support dynamically enable/disable.
+ // TODO: listen to settings changed to support dynamically enable/disable.
// watch for networkType changes
if (!mSettings.getCombineSubtypeEnabled()) {
- mTeleManager.listen(mPhoneListener, LISTEN_SERVICE_STATE);
+ mNetworkStatsSubscriptionsMonitor.start();
}
registerGlobalAlert();
@@ -544,7 +552,9 @@
mContext.unregisterReceiver(mUserReceiver);
mContext.unregisterReceiver(mShutdownReceiver);
- mTeleManager.listen(mPhoneListener, LISTEN_NONE);
+ if (!mSettings.getCombineSubtypeEnabled()) {
+ mNetworkStatsSubscriptionsMonitor.stop();
+ }
final long currentTime = mClock.millis();
@@ -1197,35 +1207,14 @@
};
/**
- * Receiver that watches for {@link TelephonyManager} changes, such as
- * transitioning between Radio Access Technology(RAT) types.
+ * Handle collapsed RAT type changed event.
*/
- @NonNull
- private final NetworkTypeListener mPhoneListener;
-
- class NetworkTypeListener extends PhoneStateListener {
- private volatile int mLastCollapsedRatType = NETWORK_TYPE_UNKNOWN;
-
- NetworkTypeListener(@NonNull Executor executor) {
- super(executor);
- }
-
- @Override
- public void onServiceStateChanged(@NonNull ServiceState ss) {
- final int networkType = ss.getDataNetworkType();
- final int collapsedRatType = getCollapsedRatType(networkType);
- if (collapsedRatType == mLastCollapsedRatType) return;
-
- if (LOGD) {
- Log.d(TAG, "subtype changed for mobile: "
- + mLastCollapsedRatType + " -> " + collapsedRatType);
- }
- // Protect service from frequently updating. Remove pending messages if any.
- mHandler.removeMessages(MSG_UPDATE_IFACES);
- mLastCollapsedRatType = collapsedRatType;
- mHandler.sendMessageDelayed(
- mHandler.obtainMessage(MSG_UPDATE_IFACES), mSettings.getPollDelay());
- }
+ @VisibleForTesting
+ public void handleOnCollapsedRatTypeChanged() {
+ // Protect service from frequently updating. Remove pending messages if any.
+ mHandler.removeMessages(MSG_UPDATE_IFACES);
+ mHandler.sendMessageDelayed(
+ mHandler.obtainMessage(MSG_UPDATE_IFACES), mSettings.getPollDelay());
}
private void updateIfaces(
@@ -1352,8 +1341,7 @@
return 0;
}
- // TODO: return different subType for different subscriptions.
- return mPhoneListener.mLastCollapsedRatType;
+ return mNetworkStatsSubscriptionsMonitor.getRatTypeForSubscriberId(state.subscriberId);
}
private static <K> NetworkIdentitySet findOrCreateNetworkIdentitySet(
diff --git a/services/core/java/com/android/server/notification/ConditionProviders.java b/services/core/java/com/android/server/notification/ConditionProviders.java
index aed2927..e98326b 100644
--- a/services/core/java/com/android/server/notification/ConditionProviders.java
+++ b/services/core/java/com/android/server/notification/ConditionProviders.java
@@ -30,6 +30,7 @@
import android.service.notification.Condition;
import android.service.notification.ConditionProviderService;
import android.service.notification.IConditionProvider;
+import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Slog;
@@ -54,7 +55,6 @@
private final ArraySet<String> mSystemConditionProviderNames;
private final ArraySet<SystemConditionProviderService> mSystemConditionProviders
= new ArraySet<>();
-
private Callback mCallback;
public ConditionProviders(Context context, UserProfiles userProfiles, IPackageManager pm) {
@@ -195,6 +195,21 @@
}
@Override
+ protected void loadDefaultsFromConfig() {
+ String defaultDndAccess = mContext.getResources().getString(
+ R.string.config_defaultDndAccessPackages);
+ if (defaultDndAccess != null) {
+ String[] dnds = defaultDndAccess.split(ManagedServices.ENABLED_SERVICES_SEPARATOR);
+ for (int i = 0; i < dnds.length; i++) {
+ if (TextUtils.isEmpty(dnds[i])) {
+ continue;
+ }
+ addDefaultComponentOrPackage(dnds[i]);
+ }
+ }
+ }
+
+ @Override
protected void onServiceRemovedLocked(ManagedServiceInfo removed) {
if (removed == null) return;
for (int i = mRecords.size() - 1; i >= 0; i--) {
diff --git a/services/core/java/com/android/server/notification/ManagedServices.java b/services/core/java/com/android/server/notification/ManagedServices.java
index 45df368..5d3dc5f 100644
--- a/services/core/java/com/android/server/notification/ManagedServices.java
+++ b/services/core/java/com/android/server/notification/ManagedServices.java
@@ -21,6 +21,7 @@
import static android.content.Context.BIND_FOREGROUND_SERVICE;
import static android.content.Context.DEVICE_POLICY_SERVICE;
import static android.os.UserHandle.USER_ALL;
+import static android.os.UserHandle.USER_SYSTEM;
import android.annotation.NonNull;
import android.app.ActivityManager;
@@ -96,6 +97,8 @@
private static final int ON_BINDING_DIED_REBIND_DELAY_MS = 10000;
protected static final String ENABLED_SERVICES_SEPARATOR = ":";
+ private static final String DB_VERSION_1 = "1";
+
/**
* List of components and apps that can have running {@link ManagedServices}.
@@ -107,7 +110,7 @@
static final String ATT_VERSION = "version";
static final String ATT_DEFAULTS = "defaults";
- static final int DB_VERSION = 1;
+ static final int DB_VERSION = 2;
static final int APPROVAL_BY_PACKAGE = 0;
static final int APPROVAL_BY_COMPONENT = 1;
@@ -187,17 +190,22 @@
protected void addDefaultComponentOrPackage(String packageOrComponent) {
if (!TextUtils.isEmpty(packageOrComponent)) {
synchronized (mDefaultsLock) {
- ComponentName cn = ComponentName.unflattenFromString(packageOrComponent);
- if (cn == null) {
+ if (mApprovalLevel == APPROVAL_BY_PACKAGE) {
mDefaultPackages.add(packageOrComponent);
- } else {
+ return;
+ }
+ ComponentName cn = ComponentName.unflattenFromString(packageOrComponent);
+ if (cn != null && mApprovalLevel == APPROVAL_BY_COMPONENT) {
mDefaultPackages.add(cn.getPackageName());
mDefaultComponents.add(cn);
+ return;
}
}
}
}
+ protected abstract void loadDefaultsFromConfig();
+
boolean isDefaultComponentOrPackage(String packageOrComponent) {
synchronized (mDefaultsLock) {
ComponentName cn = ComponentName.unflattenFromString(packageOrComponent);
@@ -504,19 +512,19 @@
void readDefaults(XmlPullParser parser) {
String defaultComponents = XmlUtils.readStringAttribute(parser, ATT_DEFAULTS);
- if (defaultComponents == null) {
- return;
- }
- String[] components = defaultComponents.split(ENABLED_SERVICES_SEPARATOR);
- synchronized (mDefaultsLock) {
- for (int i = 0; i < components.length; i++) {
- if (!TextUtils.isEmpty(components[i])) {
- ComponentName cn = ComponentName.unflattenFromString(components[i]);
- if (cn != null) {
- mDefaultPackages.add(cn.getPackageName());
- mDefaultComponents.add(cn);
- } else {
- mDefaultPackages.add(components[i]);
+
+ if (!TextUtils.isEmpty(defaultComponents)) {
+ String[] components = defaultComponents.split(ENABLED_SERVICES_SEPARATOR);
+ synchronized (mDefaultsLock) {
+ for (int i = 0; i < components.length; i++) {
+ if (!TextUtils.isEmpty(components[i])) {
+ ComponentName cn = ComponentName.unflattenFromString(components[i]);
+ if (cn != null) {
+ mDefaultPackages.add(cn.getPackageName());
+ mDefaultComponents.add(cn);
+ } else {
+ mDefaultPackages.add(components[i]);
+ }
}
}
}
@@ -531,9 +539,11 @@
throws XmlPullParserException, IOException {
// read grants
int type;
+ String version = "";
readDefaults(parser);
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT) {
String tag = parser.getName();
+ version = XmlUtils.readStringAttribute(parser, ATT_VERSION);
if (type == XmlPullParser.END_TAG
&& getConfig().xmlTag.equals(tag)) {
break;
@@ -561,9 +571,38 @@
}
}
}
+ boolean isVersionOne = TextUtils.isEmpty(version) || DB_VERSION_1.equals(version);
+ if (isVersionOne) {
+ upgradeToVersionTwo();
+ }
rebindServices(false, USER_ALL);
}
+ private void upgradeToVersionTwo() {
+ // check if any defaults are loaded
+ int defaultsSize = mDefaultComponents.size() + mDefaultPackages.size();
+ if (defaultsSize == 0) {
+ // load defaults from current allowed
+ if (this.mApprovalLevel == APPROVAL_BY_COMPONENT) {
+ List<ComponentName> approvedComponents = getAllowedComponents(USER_SYSTEM);
+ for (int i = 0; i < approvedComponents.size(); i++) {
+ addDefaultComponentOrPackage(approvedComponents.get(i).flattenToString());
+ }
+ }
+ if (this.mApprovalLevel == APPROVAL_BY_PACKAGE) {
+ List<String> approvedPkgs = getAllowedPackages(USER_SYSTEM);
+ for (int i = 0; i < approvedPkgs.size(); i++) {
+ addDefaultComponentOrPackage(approvedPkgs.get(i));
+ }
+ }
+ }
+ // if no defaults are loaded, then load from config
+ defaultsSize = mDefaultComponents.size() + mDefaultPackages.size();
+ if (defaultsSize == 0) {
+ loadDefaultsFromConfig();
+ }
+ }
+
/**
* Read extra attributes in the {@link #TAG_MANAGED_SERVICES} tag.
*/
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 54efe54..9b02b48 100755
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -108,6 +108,7 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
+import android.annotation.UserIdInt;
import android.annotation.WorkerThread;
import android.app.ActivityManager;
import android.app.ActivityManagerInternal;
@@ -156,6 +157,7 @@
import android.content.pm.PackageManagerInternal;
import android.content.pm.ParceledListSlice;
import android.content.pm.ShortcutInfo;
+import android.content.pm.ShortcutServiceInternal;
import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.database.ContentObserver;
@@ -220,6 +222,7 @@
import android.util.Pair;
import android.util.Slog;
import android.util.SparseArray;
+import android.util.SparseArrayMap;
import android.util.StatsEvent;
import android.util.Xml;
import android.util.proto.ProtoOutputStream;
@@ -291,6 +294,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
import java.util.Objects;
@@ -528,13 +532,15 @@
private NotificationRecordLogger mNotificationRecordLogger;
private InstanceIdSequence mNotificationInstanceIdSequence;
- private static class Archive {
+ static class Archive {
+ final SparseArray<Boolean> mEnabled;
final int mBufferSize;
- final ArrayDeque<Pair<StatusBarNotification, Integer>> mBuffer;
+ final LinkedList<Pair<StatusBarNotification, Integer>> mBuffer;
public Archive(int size) {
mBufferSize = size;
- mBuffer = new ArrayDeque<>(mBufferSize);
+ mBuffer = new LinkedList<>();
+ mEnabled = new SparseArray<>();
}
public String toString() {
@@ -547,7 +553,10 @@
return sb.toString();
}
- public void record(StatusBarNotification nr, int reason) {
+ public void record(StatusBarNotification sbn, int reason) {
+ if (!mEnabled.get(sbn.getNormalizedUserId(), false)) {
+ return;
+ }
if (mBuffer.size() == mBufferSize) {
mBuffer.removeFirst();
}
@@ -555,7 +564,7 @@
// We don't want to store the heavy bits of the notification in the archive,
// but other clients in the system process might be using the object, so we
// store a (lightened) copy.
- mBuffer.addLast(new Pair<>(nr.cloneLight(), reason));
+ mBuffer.addLast(new Pair<>(sbn.cloneLight(), reason));
}
public Iterator<Pair<StatusBarNotification, Integer>> descendingIterator() {
@@ -577,60 +586,25 @@
return a.toArray(new StatusBarNotification[a.size()]);
}
+ public void updateHistoryEnabled(@UserIdInt int userId, boolean enabled) {
+ mEnabled.put(userId, enabled);
+
+ if (!enabled) {
+ for (int i = mBuffer.size() - 1; i >= 0; i--) {
+ if (userId == mBuffer.get(i).first.getNormalizedUserId()) {
+ mBuffer.remove(i);
+ }
+ }
+ }
+ }
}
void loadDefaultApprovedServices(int userId) {
- String defaultListenerAccess = getContext().getResources().getString(
- com.android.internal.R.string.config_defaultListenerAccessPackages);
- if (defaultListenerAccess != null) {
- String[] listeners =
- defaultListenerAccess.split(ManagedServices.ENABLED_SERVICES_SEPARATOR);
- for (int i = 0; i < listeners.length; i++) {
- if (TextUtils.isEmpty(listeners[i])) {
- continue;
- }
- ArraySet<ComponentName> approvedListeners =
- mListeners.queryPackageForServices(listeners[i],
- MATCH_DIRECT_BOOT_AWARE
- | MATCH_DIRECT_BOOT_UNAWARE, userId);
- for (int k = 0; k < approvedListeners.size(); k++) {
- ComponentName cn = approvedListeners.valueAt(k);
- mListeners.addDefaultComponentOrPackage(cn.flattenToString());
- }
- }
- }
+ mListeners.loadDefaultsFromConfig();
- String defaultDndAccess = getContext().getResources().getString(
- com.android.internal.R.string.config_defaultDndAccessPackages);
- if (defaultDndAccess != null) {
- String[] dnds = defaultDndAccess.split(ManagedServices.ENABLED_SERVICES_SEPARATOR);
- for (int i = 0; i < dnds.length; i++) {
- if (TextUtils.isEmpty(dnds[i])) {
- continue;
- }
- mConditionProviders.addDefaultComponentOrPackage(dnds[i]);
- }
- }
+ mConditionProviders.loadDefaultsFromConfig();
-
- ArraySet<String> assistants = new ArraySet<>();
- String deviceAssistant = DeviceConfig.getProperty(
- DeviceConfig.NAMESPACE_SYSTEMUI,
- SystemUiDeviceConfigFlags.NAS_DEFAULT_SERVICE);
- if (deviceAssistant != null) {
- assistants.addAll(Arrays.asList(deviceAssistant.split(
- ManagedServices.ENABLED_SERVICES_SEPARATOR)));
- }
- assistants.addAll(Arrays.asList(getContext().getResources().getString(
- com.android.internal.R.string.config_defaultAssistantAccessComponent)
- .split(ManagedServices.ENABLED_SERVICES_SEPARATOR)));
- for (int i = 0; i < assistants.size(); i++) {
- String cnString = assistants.valueAt(i);
- if (TextUtils.isEmpty(cnString)) {
- continue;
- }
- mAssistants.addDefaultComponentOrPackage(cnString);
- }
+ mAssistants.loadDefaultsFromConfig();
}
protected void allowDefaultApprovedServices(int userId) {
@@ -653,11 +627,14 @@
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.NAS_DEFAULT_SERVICE);
if (overrideDefaultAssistantString != null) {
- ComponentName overrideDefaultAssistant =
- ComponentName.unflattenFromString(overrideDefaultAssistantString);
- if (allowAssistant(userId, overrideDefaultAssistant)) return;
+ ArraySet<ComponentName> approved = mAssistants.queryPackageForServices(
+ overrideDefaultAssistantString,
+ MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE,
+ userId);
+ for (int i = 0; i < approved.size(); i++) {
+ if (allowAssistant(userId, approved.valueAt(i))) return;
+ }
}
-
ArraySet<ComponentName> defaults = mAssistants.getDefaultComponents();
// We should have only one default assistant by default
// allowAssistant should execute once in practice
@@ -1638,6 +1615,9 @@
= Settings.System.getUriFor(Settings.System.NOTIFICATION_LIGHT_PULSE);
private final Uri NOTIFICATION_RATE_LIMIT_URI
= Settings.Global.getUriFor(Settings.Global.MAX_NOTIFICATION_ENQUEUE_RATE);
+ private final Uri NOTIFICATION_HISTORY_ENABLED
+ = Settings.Secure.getUriFor(Settings.Secure.NOTIFICATION_HISTORY_ENABLED);
+
SettingsObserver(Handler handler) {
super(handler);
@@ -1653,10 +1633,12 @@
false, this, UserHandle.USER_ALL);
resolver.registerContentObserver(NOTIFICATION_BUBBLES_URI,
false, this, UserHandle.USER_ALL);
+ resolver.registerContentObserver(NOTIFICATION_HISTORY_ENABLED,
+ false, this, UserHandle.USER_ALL);
update(null);
}
- @Override public void onChange(boolean selfChange, Uri uri) {
+ @Override public void onChange(boolean selfChange, Uri uri, int userId) {
update(uri);
}
@@ -1681,6 +1663,14 @@
if (uri == null || NOTIFICATION_BUBBLES_URI.equals(uri)) {
mPreferencesHelper.updateBubblesEnabled();
}
+ if (uri == null || NOTIFICATION_HISTORY_ENABLED.equals(uri)) {
+ final IntArray userIds = mUserProfiles.getCurrentProfileIds();
+
+ for (int i = 0; i < userIds.size(); i++) {
+ mArchive.updateHistoryEnabled(userIds.get(i), Settings.Secure.getInt(resolver,
+ Settings.Secure.NOTIFICATION_HISTORY_ENABLED, 0) == 1);
+ }
+ }
}
}
@@ -1959,7 +1949,8 @@
mPackageManagerClient,
mRankingHandler,
mZenModeHelper,
- new NotificationChannelLoggerImpl());
+ new NotificationChannelLoggerImpl(),
+ mAppOps);
mRankingHelper = new RankingHelper(getContext(),
mRankingHandler,
mPreferencesHelper,
@@ -2300,7 +2291,8 @@
mRoleObserver.init();
LauncherApps launcherApps =
(LauncherApps) getContext().getSystemService(Context.LAUNCHER_APPS_SERVICE);
- mShortcutHelper = new ShortcutHelper(launcherApps, mShortcutListener);
+ mShortcutHelper = new ShortcutHelper(launcherApps, mShortcutListener, getLocalService(
+ ShortcutServiceInternal.class));
BubbleExtractor bubbsExtractor = mRankingHelper.findExtractor(BubbleExtractor.class);
if (bubbsExtractor != null) {
bubbsExtractor.setShortcutHelper(mShortcutHelper);
@@ -8568,6 +8560,26 @@
private ArrayMap<Integer, Boolean> mUserSetMap = new ArrayMap<>();
private Set<String> mAllowedAdjustments = new ArraySet<>();
+ @Override
+ protected void loadDefaultsFromConfig() {
+ ArraySet<String> assistants = new ArraySet<>();
+ assistants.addAll(Arrays.asList(mContext.getResources().getString(
+ com.android.internal.R.string.config_defaultAssistantAccessComponent)
+ .split(ManagedServices.ENABLED_SERVICES_SEPARATOR)));
+ for (int i = 0; i < assistants.size(); i++) {
+ String cnString = assistants.valueAt(i);
+ if (TextUtils.isEmpty(cnString)) {
+ continue;
+ }
+ ArraySet<ComponentName> approved = queryPackageForServices(cnString,
+ MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE, USER_SYSTEM);
+ for (int k = 0; k < approved.size(); k++) {
+ ComponentName cn = approved.valueAt(k);
+ addDefaultComponentOrPackage(cn.flattenToString());
+ }
+ }
+ }
+
public NotificationAssistants(Context context, Object lock, UserProfiles up,
IPackageManager pm) {
super(context, lock, up, pm);
@@ -9005,7 +9017,29 @@
public NotificationListeners(IPackageManager pm) {
super(getContext(), mNotificationLock, mUserProfiles, pm);
+ }
+ @Override
+ protected void loadDefaultsFromConfig() {
+ String defaultListenerAccess = mContext.getResources().getString(
+ R.string.config_defaultListenerAccessPackages);
+ if (defaultListenerAccess != null) {
+ String[] listeners =
+ defaultListenerAccess.split(ManagedServices.ENABLED_SERVICES_SEPARATOR);
+ for (int i = 0; i < listeners.length; i++) {
+ if (TextUtils.isEmpty(listeners[i])) {
+ continue;
+ }
+ ArraySet<ComponentName> approvedListeners =
+ this.queryPackageForServices(listeners[i],
+ MATCH_DIRECT_BOOT_AWARE
+ | MATCH_DIRECT_BOOT_UNAWARE, USER_SYSTEM);
+ for (int k = 0; k < approvedListeners.size(); k++) {
+ ComponentName cn = approvedListeners.valueAt(k);
+ addDefaultComponentOrPackage(cn.flattenToString());
+ }
+ }
+ }
}
@Override
diff --git a/services/core/java/com/android/server/notification/NotificationRecord.java b/services/core/java/com/android/server/notification/NotificationRecord.java
index 192df41..2bbbffc 100644
--- a/services/core/java/com/android/server/notification/NotificationRecord.java
+++ b/services/core/java/com/android/server/notification/NotificationRecord.java
@@ -590,6 +590,8 @@
pw.println(prefix + "snoozeCriteria=" + TextUtils.join(",", getSnoozeCriteria()));
}
pw.println(prefix + "mAdjustments=" + mAdjustments);
+ pw.println(prefix + "shortcut=" + notification.getShortcutId()
+ + " found valid? " + (mShortcutInfo != null));
}
@Override
diff --git a/services/core/java/com/android/server/notification/PreferencesHelper.java b/services/core/java/com/android/server/notification/PreferencesHelper.java
index b3d373f..d432fc8 100644
--- a/services/core/java/com/android/server/notification/PreferencesHelper.java
+++ b/services/core/java/com/android/server/notification/PreferencesHelper.java
@@ -16,7 +16,9 @@
package com.android.server.notification;
+import static android.app.AppOpsManager.OP_SYSTEM_ALERT_WINDOW;
import static android.app.NotificationChannel.PLACEHOLDER_CONVERSATION_ID;
+import static android.app.NotificationManager.BUBBLE_PREFERENCE_ALL;
import static android.app.NotificationManager.BUBBLE_PREFERENCE_NONE;
import static android.app.NotificationManager.IMPORTANCE_NONE;
import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED;
@@ -30,6 +32,7 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
+import android.app.AppOpsManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationChannelGroup;
@@ -79,7 +82,9 @@
public class PreferencesHelper implements RankingConfig {
private static final String TAG = "NotificationPrefHelper";
- private static final int XML_VERSION = 1;
+ private static final int XML_VERSION = 2;
+ /** What version to check to do the upgrade for bubbles. */
+ private static final int XML_VERSION_BUBBLES_UPGRADE = 1;
private static final int UNKNOWN_UID = UserHandle.USER_NULL;
private static final String NON_BLOCKABLE_CHANNEL_DELIM = ":";
@@ -151,6 +156,7 @@
private final RankingHandler mRankingHandler;
private final ZenModeHelper mZenModeHelper;
private final NotificationChannelLogger mNotificationChannelLogger;
+ private final AppOpsManager mAppOps;
private SparseBooleanArray mBadgingEnabled;
private boolean mBubblesEnabledGlobally = DEFAULT_GLOBAL_ALLOW_BUBBLE;
@@ -167,12 +173,14 @@
}
public PreferencesHelper(Context context, PackageManager pm, RankingHandler rankingHandler,
- ZenModeHelper zenHelper, NotificationChannelLogger notificationChannelLogger) {
+ ZenModeHelper zenHelper, NotificationChannelLogger notificationChannelLogger,
+ AppOpsManager appOpsManager) {
mContext = context;
mZenModeHelper = zenHelper;
mRankingHandler = rankingHandler;
mPm = pm;
mNotificationChannelLogger = notificationChannelLogger;
+ mAppOps = appOpsManager;
// STOPSHIP (b/142218092) this should be removed before ship
if (!wasBadgingForcedTrue(context)) {
@@ -195,6 +203,15 @@
if (type != XmlPullParser.START_TAG) return;
String tag = parser.getName();
if (!TAG_RANKING.equals(tag)) return;
+
+ boolean upgradeForBubbles = false;
+ if (parser.getAttributeCount() > 0) {
+ String attribute = parser.getAttributeName(0);
+ if (ATT_VERSION.equals(attribute)) {
+ int xmlVersion = Integer.parseInt(parser.getAttributeValue(0));
+ upgradeForBubbles = xmlVersion == XML_VERSION_BUBBLES_UPGRADE;
+ }
+ }
synchronized (mPackagePreferences) {
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT) {
tag = parser.getName();
@@ -220,6 +237,16 @@
}
}
boolean skipWarningLogged = false;
+ boolean hasSAWPermission = false;
+ if (upgradeForBubbles) {
+ hasSAWPermission = mAppOps.noteOpNoThrow(
+ OP_SYSTEM_ALERT_WINDOW, uid, name, null,
+ "check-notif-bubble") == AppOpsManager.MODE_ALLOWED;
+ }
+ int bubblePref = hasSAWPermission
+ ? BUBBLE_PREFERENCE_ALL
+ : XmlUtils.readIntAttribute(parser, ATT_ALLOW_BUBBLE,
+ DEFAULT_BUBBLE_PREFERENCE);
PackagePreferences r = getOrCreatePackagePreferencesLocked(
name, userId, uid,
@@ -231,8 +258,7 @@
parser, ATT_VISIBILITY, DEFAULT_VISIBILITY),
XmlUtils.readBooleanAttribute(
parser, ATT_SHOW_BADGE, DEFAULT_SHOW_BADGE),
- XmlUtils.readIntAttribute(
- parser, ATT_ALLOW_BUBBLE, DEFAULT_BUBBLE_PREFERENCE));
+ bubblePref);
r.importance = XmlUtils.readIntAttribute(
parser, ATT_IMPORTANCE, DEFAULT_IMPORTANCE);
r.priority = XmlUtils.readIntAttribute(
diff --git a/services/core/java/com/android/server/notification/ShortcutHelper.java b/services/core/java/com/android/server/notification/ShortcutHelper.java
index f1ce3a7..1d48438 100644
--- a/services/core/java/com/android/server/notification/ShortcutHelper.java
+++ b/services/core/java/com/android/server/notification/ShortcutHelper.java
@@ -21,11 +21,15 @@
import static android.content.pm.LauncherApps.ShortcutQuery.FLAG_MATCH_PINNED;
import android.annotation.NonNull;
+import android.content.Intent;
+import android.content.IntentFilter;
import android.content.pm.LauncherApps;
import android.content.pm.ShortcutInfo;
+import android.content.pm.ShortcutServiceInternal;
import android.os.Binder;
import android.os.Handler;
import android.os.UserHandle;
+import android.util.Slog;
import com.android.internal.annotations.VisibleForTesting;
@@ -38,6 +42,7 @@
* Helper for querying shortcuts.
*/
class ShortcutHelper {
+ private static final String TAG = "ShortcutHelper";
/**
* Listener to call when a shortcut we're tracking has been removed.
@@ -48,6 +53,8 @@
private LauncherApps mLauncherAppsService;
private ShortcutListener mShortcutListener;
+ private ShortcutServiceInternal mShortcutServiceInternal;
+ private IntentFilter mSharingFilter;
// Key: packageName Value: <shortcutId, notifId>
private HashMap<String, HashMap<String, String>> mActiveShortcutBubbles = new HashMap<>();
@@ -111,9 +118,17 @@
}
};
- ShortcutHelper(LauncherApps launcherApps, ShortcutListener listener) {
+ ShortcutHelper(LauncherApps launcherApps, ShortcutListener listener,
+ ShortcutServiceInternal shortcutServiceInternal) {
mLauncherAppsService = launcherApps;
mShortcutListener = listener;
+ mSharingFilter = new IntentFilter();
+ try {
+ mSharingFilter.addDataType("*/*");
+ } catch (IntentFilter.MalformedMimeTypeException e) {
+ Slog.e(TAG, "Bad mime type", e);
+ }
+ mShortcutServiceInternal = shortcutServiceInternal;
}
@VisibleForTesting
@@ -121,6 +136,11 @@
mLauncherAppsService = launcherApps;
}
+ @VisibleForTesting
+ void setShortcutServiceInternal(ShortcutServiceInternal shortcutServiceInternal) {
+ mShortcutServiceInternal = shortcutServiceInternal;
+ }
+
/**
* Only returns shortcut info if it's found and if it's {@link ShortcutInfo#isLongLived()}.
*/
@@ -141,7 +161,14 @@
ShortcutInfo info = shortcuts != null && shortcuts.size() > 0
? shortcuts.get(0)
: null;
- return info != null && info.isLongLived() ? info : null;
+ if (info == null || !info.isLongLived() || !info.isEnabled()) {
+ return null;
+ }
+ if (mShortcutServiceInternal.isSharingShortcut(user.getIdentifier(),
+ "android", packageName, shortcutId, user.getIdentifier(), mSharingFilter)) {
+ return info;
+ }
+ return null;
} finally {
Binder.restoreCallingIdentity(token);
}
diff --git a/services/core/java/com/android/server/pm/Installer.java b/services/core/java/com/android/server/pm/Installer.java
index 9fb468e..7cee286 100644
--- a/services/core/java/com/android/server/pm/Installer.java
+++ b/services/core/java/com/android/server/pm/Installer.java
@@ -71,6 +71,8 @@
public static final int DEXOPT_GENERATE_COMPACT_DEX = 1 << 11;
/** Indicates that dexopt should generate an app image */
public static final int DEXOPT_GENERATE_APP_IMAGE = 1 << 12;
+ /** Indicates that dexopt may be run with different performance / priority tuned for restore */
+ public static final int DEXOPT_FOR_RESTORE = 1 << 13; // TODO(b/135202722): remove
public static final int FLAG_STORAGE_DE = IInstalld.FLAG_STORAGE_DE;
public static final int FLAG_STORAGE_CE = IInstalld.FLAG_STORAGE_CE;
diff --git a/services/core/java/com/android/server/pm/PackageDexOptimizer.java b/services/core/java/com/android/server/pm/PackageDexOptimizer.java
index 1951e74..4b8a242 100644
--- a/services/core/java/com/android/server/pm/PackageDexOptimizer.java
+++ b/services/core/java/com/android/server/pm/PackageDexOptimizer.java
@@ -22,6 +22,7 @@
import static com.android.server.pm.Installer.DEXOPT_DEBUGGABLE;
import static com.android.server.pm.Installer.DEXOPT_ENABLE_HIDDEN_API_CHECKS;
import static com.android.server.pm.Installer.DEXOPT_FORCE;
+import static com.android.server.pm.Installer.DEXOPT_FOR_RESTORE;
import static com.android.server.pm.Installer.DEXOPT_GENERATE_APP_IMAGE;
import static com.android.server.pm.Installer.DEXOPT_GENERATE_COMPACT_DEX;
import static com.android.server.pm.Installer.DEXOPT_IDLE_BACKGROUND_JOB;
@@ -706,6 +707,7 @@
| (options.isDexoptIdleBackgroundJob() ? DEXOPT_IDLE_BACKGROUND_JOB : 0)
| (generateCompactDex ? DEXOPT_GENERATE_COMPACT_DEX : 0)
| (generateAppImage ? DEXOPT_GENERATE_APP_IMAGE : 0)
+ | (options.isDexoptInstallForRestore() ? DEXOPT_FOR_RESTORE : 0)
| hiddenApiFlag;
return adjustDexoptFlags(dexFlags);
}
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 59ac603..d2481b7 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -66,6 +66,8 @@
import static android.content.pm.PackageManager.INSTALL_INTERNAL;
import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES;
import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_NO_CERTIFICATES;
+import static android.content.pm.PackageManager.INSTALL_REASON_DEVICE_RESTORE;
+import static android.content.pm.PackageManager.INSTALL_REASON_DEVICE_SETUP;
import static android.content.pm.PackageManager.INSTALL_SUCCEEDED;
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS;
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK;
@@ -94,6 +96,7 @@
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.content.pm.PackageManager.RESTRICTION_NONE;
import static android.content.pm.PackageManager.UNINSTALL_REASON_UNKNOWN;
+import static android.content.pm.PackageParser.SigningDetails.SignatureSchemeVersion.SIGNING_BLOCK_V4;
import static android.content.pm.PackageParser.isApkFile;
import static android.os.Trace.TRACE_TAG_PACKAGE_MANAGER;
import static android.os.incremental.IncrementalManager.isIncrementalPath;
@@ -1820,10 +1823,12 @@
state.setVerifierResponse(Binder.getCallingUid(),
PackageManager.VERIFICATION_ALLOW_WITHOUT_SUFFICIENT);
broadcastPackageVerified(verificationId, originUri,
- PackageManager.VERIFICATION_ALLOW, user);
+ PackageManager.VERIFICATION_ALLOW, null, args.mDataLoaderType,
+ user);
} else {
broadcastPackageVerified(verificationId, originUri,
- PackageManager.VERIFICATION_REJECT, user);
+ PackageManager.VERIFICATION_REJECT, null, args.mDataLoaderType,
+ user);
params.setReturnCode(
PackageManager.INSTALL_FAILED_VERIFICATION_FAILURE);
state.setVerifierResponse(Binder.getCallingUid(),
@@ -1899,7 +1904,7 @@
if (state.isInstallAllowed()) {
broadcastPackageVerified(verificationId, originUri,
- response.code, args.getUser());
+ response.code, null, args.mDataLoaderType, args.getUser());
} else {
params.setReturnCode(
PackageManager.INSTALL_FAILED_VERIFICATION_FAILURE);
@@ -3576,7 +3581,8 @@
// Prepare a supplier of package parser for the staging manager to parse apex file
// during the staging installation.
final Supplier<PackageParser2> apexParserSupplier = () -> new PackageParser2(
- mSeparateProcesses, mOnlyCore, mMetrics, mCacheDir, mPackageParserCallback);
+ mSeparateProcesses, mOnlyCore, mMetrics, null /* cacheDir */,
+ mPackageParserCallback);
mInstallerService = new PackageInstallerService(mContext, this, apexParserSupplier);
final Pair<ComponentName, String> instantAppResolverComponent =
getInstantAppResolverLPr();
@@ -13575,12 +13581,17 @@
}
private void broadcastPackageVerified(int verificationId, Uri packageUri,
- int verificationCode, UserHandle user) {
+ int verificationCode, @Nullable String rootHashString, int dataLoaderType,
+ UserHandle user) {
final Intent intent = new Intent(Intent.ACTION_PACKAGE_VERIFIED);
intent.setDataAndType(packageUri, PACKAGE_MIME_TYPE);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.putExtra(PackageManager.EXTRA_VERIFICATION_ID, verificationId);
intent.putExtra(PackageManager.EXTRA_VERIFICATION_RESULT, verificationCode);
+ if (rootHashString != null) {
+ intent.putExtra(PackageManager.EXTRA_VERIFICATION_ROOT_HASH, rootHashString);
+ }
+ intent.putExtra(PackageInstaller.EXTRA_DATA_LOADER_TYPE, dataLoaderType);
mContext.sendBroadcastAsUser(intent, user,
android.Manifest.permission.PACKAGE_VERIFICATION_AGENT);
@@ -14952,8 +14963,17 @@
verificationState.setRequiredVerifierUid(requiredUid);
final int installerUid =
verificationInfo == null ? -1 : verificationInfo.installerUid;
- if (!origin.existing && isVerificationEnabled(pkgLite, verifierUser.getIdentifier(),
- installFlags, installerUid)) {
+ final boolean isVerificationEnabled = isVerificationEnabled(
+ pkgLite, verifierUser.getIdentifier(), installFlags, installerUid);
+ final boolean isV4Signed =
+ (mArgs.signingDetails.signatureSchemeVersion == SIGNING_BLOCK_V4);
+ final boolean isIncrementalInstall =
+ (mArgs.mDataLoaderType == DataLoaderType.INCREMENTAL);
+ // NOTE: We purposefully skip verification for only incremental installs when there's
+ // a v4 signature block. Otherwise, proceed with verification as usual.
+ if (!origin.existing
+ && isVerificationEnabled
+ && (!isIncrementalInstall || !isV4Signed)) {
final Intent verification = new Intent(
Intent.ACTION_PACKAGE_NEEDS_VERIFICATION);
verification.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
@@ -16569,7 +16589,29 @@
}
executePostCommitSteps(commitRequest);
} finally {
- if (!success) {
+ if (success) {
+ for (InstallRequest request : requests) {
+ final InstallArgs args = request.args;
+ if (args.mDataLoaderType != DataLoaderType.INCREMENTAL) {
+ continue;
+ }
+ if (args.signingDetails.signatureSchemeVersion != SIGNING_BLOCK_V4) {
+ continue;
+ }
+ // For incremental installs, we bypass the verifier prior to install. Now
+ // that we know the package is valid, send a notice to the verifier with
+ // the root hash of the base.apk.
+ final String baseCodePath = request.installResult.pkg.getBaseCodePath();
+ final String[] splitCodePaths = request.installResult.pkg.getSplitCodePaths();
+ final Uri originUri = Uri.fromFile(args.origin.resolvedFile);
+ final int verificationId = mPendingVerificationToken++;
+ final String rootHashString = PackageManagerServiceUtils
+ .buildVerificationRootHashString(baseCodePath, splitCodePaths);
+ broadcastPackageVerified(verificationId, originUri,
+ PackageManager.VERIFICATION_ALLOW, rootHashString,
+ args.mDataLoaderType, args.getUser());
+ }
+ } else {
for (ScanResult result : preparedScans.values()) {
if (createdAppId.getOrDefault(result.request.parsedPackage.getPackageName(),
false)) {
@@ -16670,10 +16712,15 @@
// method because `pkg` may not be in `mPackages` yet.
//
// Also, don't fail application installs if the dexopt step fails.
+ int flags = DexoptOptions.DEXOPT_BOOT_COMPLETE
+ | DexoptOptions.DEXOPT_INSTALL_WITH_DEX_METADATA_FILE;
+ if (reconciledPkg.installArgs.installReason == INSTALL_REASON_DEVICE_RESTORE
+ || reconciledPkg.installArgs.installReason == INSTALL_REASON_DEVICE_SETUP) {
+ flags |= DexoptOptions.DEXOPT_FOR_RESTORE;
+ }
DexoptOptions dexoptOptions = new DexoptOptions(packageName,
REASON_INSTALL,
- DexoptOptions.DEXOPT_BOOT_COMPLETE
- | DexoptOptions.DEXOPT_INSTALL_WITH_DEX_METADATA_FILE);
+ flags);
ScanResult result = reconciledPkg.scanResult;
// This mirrors logic from commitReconciledScanResultLocked, where the library files
@@ -16911,7 +16958,6 @@
if (args.signingDetails != PackageParser.SigningDetails.UNKNOWN) {
parsedPackage.setSigningDetails(args.signingDetails);
} else {
- // TODO(b/136132412): skip for Incremental installation
parsedPackage.setSigningDetails(
ParsingPackageUtils.collectCertificates(parsedPackage, false /* skipVerify */));
}
diff --git a/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java b/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java
index 91afd84..5c175a6 100644
--- a/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java
+++ b/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java
@@ -32,7 +32,6 @@
import android.app.AppGlobals;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfoLite;
import android.content.pm.PackageManager;
import android.content.pm.PackageManagerInternal;
@@ -40,7 +39,6 @@
import android.content.pm.PackageParser.PackageParserException;
import android.content.pm.ResolveInfo;
import android.content.pm.Signature;
-import android.content.pm.parsing.ParsingPackageUtils;
import android.os.Build;
import android.os.Debug;
import android.os.Environment;
@@ -50,6 +48,9 @@
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManagerInternal;
+import android.os.incremental.IncrementalManager;
+import android.os.incremental.V4Signature;
+import android.os.incremental.V4Signature.HashingInfo;
import android.service.pm.PackageServiceDumpProto;
import android.system.ErrnoException;
import android.system.Os;
@@ -62,6 +63,7 @@
import com.android.internal.content.PackageHelper;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.FastPrintWriter;
+import com.android.internal.util.HexDump;
import com.android.server.EventLogTags;
import com.android.server.pm.dex.DexManager;
import com.android.server.pm.dex.PackageDexUsage;
@@ -94,8 +96,6 @@
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
-import java.util.Set;
import java.util.function.Predicate;
import java.util.zip.GZIPInputStream;
@@ -943,4 +943,71 @@
Os.chmod(currentDir.getAbsolutePath(), mode);
}
}
+
+ /**
+ * Returns a string that's compatible with the verification root hash extra.
+ * @see PackageManager#EXTRA_VERIFICATION_ROOT_HASH
+ */
+ @NonNull
+ public static String buildVerificationRootHashString(@NonNull String baseFilename,
+ @Nullable String[] splitFilenameArray) {
+ final StringBuilder sb = new StringBuilder();
+ final String baseFilePath =
+ baseFilename.substring(baseFilename.lastIndexOf(File.separator) + 1);
+ sb.append(baseFilePath).append(":");
+ final byte[] baseRootHash = getRootHash(baseFilename);
+ if (baseRootHash == null) {
+ sb.append("0");
+ } else {
+ sb.append(HexDump.toHexString(baseRootHash));
+ }
+ if (splitFilenameArray == null || splitFilenameArray.length == 0) {
+ return sb.toString();
+ }
+
+ for (int i = splitFilenameArray.length - 1; i >= 0; i--) {
+ final String splitFilename = splitFilenameArray[i];
+ final String splitFilePath =
+ splitFilename.substring(splitFilename.lastIndexOf(File.separator) + 1);
+ final byte[] splitRootHash = getRootHash(splitFilename);
+ sb.append(";").append(splitFilePath).append(":");
+ if (splitRootHash == null) {
+ sb.append("0");
+ } else {
+ sb.append(HexDump.toHexString(splitRootHash));
+ }
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Returns the root has for the given file.
+ * <p>Otherwise, returns {@code null} if the root hash could not be found or calculated.
+ * <p>NOTE: This currently only works on files stored on the incremental file system. The
+ * eventual goal is that this hash [among others] can be retrieved for any file.
+ */
+ @Nullable
+ private static byte[] getRootHash(String filename) {
+ try {
+ final byte[] baseFileSignature =
+ IncrementalManager.unsafeGetFileSignature(filename);
+ if (baseFileSignature == null) {
+ throw new IOException("File signature not present");
+ }
+ final V4Signature signature =
+ V4Signature.readFrom(baseFileSignature);
+ if (signature.hashingInfo == null) {
+ throw new IOException("Hashing info not present");
+ }
+ final HashingInfo hashInfo =
+ HashingInfo.fromByteArray(signature.hashingInfo);
+ if (ArrayUtils.isEmpty(hashInfo.rawRootHash)) {
+ throw new IOException("Root has not present");
+ }
+ return hashInfo.rawRootHash;
+ } catch (IOException ignore) {
+ Slog.e(TAG, "ERROR: could not load root hash from incremental install");
+ }
+ return null;
+ }
}
diff --git a/services/core/java/com/android/server/pm/dex/DexoptOptions.java b/services/core/java/com/android/server/pm/dex/DexoptOptions.java
index b453c89..68f3886 100644
--- a/services/core/java/com/android/server/pm/dex/DexoptOptions.java
+++ b/services/core/java/com/android/server/pm/dex/DexoptOptions.java
@@ -61,6 +61,10 @@
// should get the dex metdata file if present.
public static final int DEXOPT_INSTALL_WITH_DEX_METADATA_FILE = 1 << 10;
+ // When set, indicates that dexopt is being invoked from the install flow during device restore
+ // or device setup and should be scheduled appropriately.
+ public static final int DEXOPT_FOR_RESTORE = 1 << 11; // TODO(b/135202722): remove
+
// The name of package to optimize.
private final String mPackageName;
@@ -99,7 +103,8 @@
DEXOPT_DOWNGRADE |
DEXOPT_AS_SHARED_LIBRARY |
DEXOPT_IDLE_BACKGROUND_JOB |
- DEXOPT_INSTALL_WITH_DEX_METADATA_FILE;
+ DEXOPT_INSTALL_WITH_DEX_METADATA_FILE |
+ DEXOPT_FOR_RESTORE;
if ((flags & (~validityMask)) != 0) {
throw new IllegalArgumentException("Invalid flags : " + Integer.toHexString(flags));
}
@@ -155,6 +160,10 @@
return (mFlags & DEXOPT_INSTALL_WITH_DEX_METADATA_FILE) != 0;
}
+ public boolean isDexoptInstallForRestore() {
+ return (mFlags & DEXOPT_FOR_RESTORE) != 0;
+ }
+
public String getSplitName() {
return mSplitName;
}
diff --git a/services/core/java/com/android/server/pm/permission/OneTimePermissionUserManager.java b/services/core/java/com/android/server/pm/permission/OneTimePermissionUserManager.java
index 1c45680..4bbe373 100644
--- a/services/core/java/com/android/server/pm/permission/OneTimePermissionUserManager.java
+++ b/services/core/java/com/android/server/pm/permission/OneTimePermissionUserManager.java
@@ -81,9 +81,6 @@
mAlarmManager = context.getSystemService(AlarmManager.class);
mPermissionControllerManager = context.getSystemService(PermissionControllerManager.class);
mHandler = context.getMainThreadHandler();
-
- // Listen for tracked uid being uninstalled
- context.registerReceiver(mUninstallListener, new IntentFilter(Intent.ACTION_UID_REMOVED));
}
/**
@@ -171,6 +168,14 @@
}
/**
+ * Register to listen for Uids being uninstalled. This must be done outside of the
+ * PermissionManagerService lock.
+ */
+ void registerUninstallListener() {
+ mContext.registerReceiver(mUninstallListener, new IntentFilter(Intent.ACTION_UID_REMOVED));
+ }
+
+ /**
* A class which watches a package for inactivity and notifies the permission controller when
* the package becomes inactive
*/
diff --git a/services/core/java/com/android/server/pm/permission/PermissionManagerService.java b/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
index ccc7492..bacc7ac 100644
--- a/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
+++ b/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
@@ -26,6 +26,7 @@
import static android.content.pm.PackageManager.FLAGS_PERMISSION_RESTRICTION_ANY_EXEMPT;
import static android.content.pm.PackageManager.FLAG_PERMISSION_APPLY_RESTRICTION;
import static android.content.pm.PackageManager.FLAG_PERMISSION_GRANTED_BY_DEFAULT;
+import static android.content.pm.PackageManager.FLAG_PERMISSION_ONE_TIME;
import static android.content.pm.PackageManager.FLAG_PERMISSION_POLICY_FIXED;
import static android.content.pm.PackageManager.FLAG_PERMISSION_REVIEW_REQUIRED;
import static android.content.pm.PackageManager.FLAG_PERMISSION_REVOKED_COMPAT;
@@ -1656,7 +1657,8 @@
final int userSettableMask = FLAG_PERMISSION_USER_SET
| FLAG_PERMISSION_USER_FIXED
| FLAG_PERMISSION_REVOKED_COMPAT
- | FLAG_PERMISSION_REVIEW_REQUIRED;
+ | FLAG_PERMISSION_REVIEW_REQUIRED
+ | FLAG_PERMISSION_ONE_TIME;
final int policyOrSystemFlags = FLAG_PERMISSION_SYSTEM_FIXED
| FLAG_PERMISSION_POLICY_FIXED;
@@ -3210,16 +3212,19 @@
}
private OneTimePermissionUserManager getOneTimePermissionUserManager(@UserIdInt int userId) {
+ OneTimePermissionUserManager oneTimePermissionUserManager;
synchronized (mLock) {
- OneTimePermissionUserManager oneTimePermissionUserManager =
+ oneTimePermissionUserManager =
mOneTimePermissionUserManagers.get(userId);
- if (oneTimePermissionUserManager == null) {
- oneTimePermissionUserManager = new OneTimePermissionUserManager(
- mContext.createContextAsUser(UserHandle.of(userId), /*flags*/ 0));
- mOneTimePermissionUserManagers.put(userId, oneTimePermissionUserManager);
+ if (oneTimePermissionUserManager != null) {
+ return oneTimePermissionUserManager;
}
- return oneTimePermissionUserManager;
+ oneTimePermissionUserManager = new OneTimePermissionUserManager(
+ mContext.createContextAsUser(UserHandle.of(userId), /*flags*/ 0));
+ mOneTimePermissionUserManagers.put(userId, oneTimePermissionUserManager);
}
+ oneTimePermissionUserManager.registerUninstallListener();
+ return oneTimePermissionUserManager;
}
@Override
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index e79b804..521ffa5 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -1374,8 +1374,8 @@
final Rect spaceToFill = transformedBounds != null
? transformedBounds
: inMultiWindowMode()
- ? task.getDisplayedBounds()
- : getRootTask().getParent().getDisplayedBounds();
+ ? task.getBounds()
+ : getRootTask().getParent().getBounds();
mLetterbox.layout(spaceToFill, w.getFrameLw(), mTmpPoint);
} else if (mLetterbox != null) {
mLetterbox.hide();
@@ -6663,17 +6663,6 @@
return super.getBounds();
}
- @Override
- Rect getDisplayedBounds() {
- if (task != null) {
- final Rect overrideDisplayedBounds = task.getOverrideDisplayedBounds();
- if (!overrideDisplayedBounds.isEmpty()) {
- return overrideDisplayedBounds;
- }
- }
- return getBounds();
- }
-
@VisibleForTesting
@Override
Rect getAnimationBounds(int appStackClipMode) {
diff --git a/services/core/java/com/android/server/wm/ActivityStack.java b/services/core/java/com/android/server/wm/ActivityStack.java
index 8bf46bc..5968eede 100644
--- a/services/core/java/com/android/server/wm/ActivityStack.java
+++ b/services/core/java/com/android/server/wm/ActivityStack.java
@@ -91,7 +91,6 @@
import static com.android.server.wm.TaskProto.BOUNDS;
import static com.android.server.wm.TaskProto.CREATED_BY_ORGANIZER;
import static com.android.server.wm.TaskProto.DEFER_REMOVAL;
-import static com.android.server.wm.TaskProto.DISPLAYED_BOUNDS;
import static com.android.server.wm.TaskProto.DISPLAY_ID;
import static com.android.server.wm.TaskProto.FILLS_PARENT;
import static com.android.server.wm.TaskProto.LAST_NON_FULLSCREEN_BOUNDS;
@@ -660,8 +659,7 @@
setBounds(newBounds);
} else if (overrideWindowingMode != WINDOWING_MODE_PINNED) {
// For pinned stack, resize is now part of the {@link WindowContainerTransaction}
- resize(new Rect(newBounds), null /* configBounds */,
- PRESERVE_WINDOWS, true /* deferResume */);
+ resize(new Rect(newBounds), PRESERVE_WINDOWS, true /* deferResume */);
}
}
if (prevIsAlwaysOnTop != isAlwaysOnTop()) {
@@ -835,8 +833,7 @@
}
if (!Objects.equals(getRequestedOverrideBounds(), mTmpRect2)) {
- resize(mTmpRect2, null /*configBounds*/,
- false /*preserveWindows*/, true /*deferResume*/);
+ resize(mTmpRect2, false /*preserveWindows*/, true /*deferResume*/);
}
} finally {
mAtmService.continueWindowLayout();
@@ -894,9 +891,6 @@
setTaskBounds(mDeferredBounds);
setBounds(mDeferredBounds);
}
- if (mUpdateDisplayedBoundsDeferredCalled) {
- setTaskDisplayedBounds(mDeferredDisplayedBounds);
- }
}
}
@@ -2966,8 +2960,7 @@
// TODO: Can only be called from special methods in ActivityStackSupervisor.
// Need to consolidate those calls points into this resize method so anyone can call directly.
- void resize(Rect displayedBounds, Rect configBounds, boolean preserveWindows,
- boolean deferResume) {
+ void resize(Rect displayedBounds, boolean preserveWindows, boolean deferResume) {
if (!updateBoundsAllowed(displayedBounds)) {
return;
}
@@ -2979,7 +2972,7 @@
// Update override configurations of all tasks in the stack.
final PooledConsumer c = PooledLambda.obtainConsumer(
ActivityStack::processTaskResizeBounds, PooledLambda.__(Task.class),
- displayedBounds, configBounds);
+ displayedBounds);
forAllTasks(c, true /* traverseTopToBottom */);
c.recycle();
@@ -3000,17 +2993,10 @@
}
}
- private static void processTaskResizeBounds(
- Task task, Rect displayedBounds, Rect configBounds) {
+ private static void processTaskResizeBounds(Task task, Rect displayedBounds) {
if (!task.isResizeable()) return;
- if (configBounds != null && !configBounds.isEmpty()) {
- task.setOverrideDisplayedBounds(displayedBounds);
- task.setBounds(configBounds);
- } else {
- task.setOverrideDisplayedBounds(null);
- task.setBounds(displayedBounds);
- }
+ task.setBounds(displayedBounds);
}
/**
@@ -3032,22 +3018,6 @@
task.setBounds(task.isResizeable() ? bounds : null);
}
- /** Helper to setDisplayedBounds on all child tasks */
- private void setTaskDisplayedBounds(Rect bounds) {
- if (!updateDisplayedBoundsAllowed(bounds)) {
- return;
- }
-
- final PooledConsumer c = PooledLambda.obtainConsumer(ActivityStack::setTaskDisplayedBounds,
- PooledLambda.__(Task.class), bounds);
- forAllLeafTasks(c, true /* traverseTopToBottom */);
- c.recycle();
- }
-
- private static void setTaskDisplayedBounds(Task task, Rect bounds) {
- task.setOverrideDisplayedBounds(bounds == null || bounds.isEmpty() ? null : bounds);
- }
-
/**
* Returns the top-most activity that occludes the given one, or @{code null} if none.
*/
@@ -3569,8 +3539,8 @@
}
@Override
- void getRelativeDisplayedPosition(Point outPos) {
- super.getRelativeDisplayedPosition(outPos);
+ void getRelativePosition(Point outPos) {
+ super.getRelativePosition(outPos);
final int outset = getStackOutset();
outPos.x -= outset;
outPos.y -= outset;
@@ -3581,7 +3551,7 @@
return;
}
- final Rect stackBounds = getDisplayedBounds();
+ final Rect stackBounds = getBounds();
int width = stackBounds.width();
int height = stackBounds.height();
@@ -3776,7 +3746,6 @@
proto.write(FILLS_PARENT, matchParentBounds());
getRawBounds().dumpDebug(proto, BOUNDS);
- getOverrideDisplayedBounds().dumpDebug(proto, DISPLAYED_BOUNDS);
if (mLastNonFullscreenBounds != null) {
mLastNonFullscreenBounds.dumpDebug(proto, LAST_NON_FULLSCREEN_BOUNDS);
}
diff --git a/services/core/java/com/android/server/wm/ActivityStackSupervisor.java b/services/core/java/com/android/server/wm/ActivityStackSupervisor.java
index f924bd4..3bccced 100644
--- a/services/core/java/com/android/server/wm/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/wm/ActivityStackSupervisor.java
@@ -1357,7 +1357,7 @@
// still need moveTaskToFrontLocked() below for any transition settings.
}
if (stack.shouldResizeStackWithLaunchBounds()) {
- stack.resize(bounds, null /* configBounds */, !PRESERVE_WINDOWS, !DEFER_RESUME);
+ stack.resize(bounds, !PRESERVE_WINDOWS, !DEFER_RESUME);
} else {
// WM resizeTask must be done after the task is moved to the correct stack,
// because Task's setBounds() also updates dim layer's bounds, but that has
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index 2a676e1..f2d1a41 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -26,6 +26,7 @@
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
+import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
@@ -141,6 +142,7 @@
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityManagerInternal;
+import android.app.WindowConfiguration;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.ActivityInfo.ScreenOrientation;
@@ -3370,34 +3372,18 @@
}
}
+ private boolean isImeControlledByApp() {
+ return mInputMethodTarget != null && !WindowConfiguration.isSplitScreenWindowingMode(
+ mInputMethodTarget.getWindowingMode());
+ }
+
boolean isImeAttachedToApp() {
- return (mInputMethodTarget != null && mInputMethodTarget.mActivityRecord != null
+ return isImeControlledByApp()
+ && mInputMethodTarget.mActivityRecord != null
&& mInputMethodTarget.getWindowingMode() == WINDOWING_MODE_FULLSCREEN
// An activity with override bounds should be letterboxed inside its parent bounds,
// so it doesn't fill the screen.
- && mInputMethodTarget.mActivityRecord.matchParentBounds());
- }
-
- /**
- * Get IME target that should host IME when this display that is reparented to another
- * WindowState.
- * IME is never displayed in a child display.
- * Use {@link WindowState#getImeControlTarget()} when IME target window
- * which originally called
- * {@link android.view.inputmethod.InputMethodManager#showSoftInput(View, int)} is known.
- *
- * @return {@link WindowState} of host that controls IME.
- * {@code null} when {@param dc} is not a virtual display.
- * @see DisplayContent#reparent
- */
- @Nullable
- WindowState getImeControlTarget() {
- WindowState imeTarget = mInputMethodTarget;
- if (imeTarget != null) {
- return imeTarget.getImeControlTarget();
- }
-
- return getInsetsStateController().getImeSourceProvider().getControlTarget().getWindow();
+ && mInputMethodTarget.mActivityRecord.matchParentBounds();
}
/**
@@ -3407,7 +3393,6 @@
*
* @param target current IME target.
* @return {@link WindowState} that can host IME.
- * @see DisplayContent#getImeControlTarget()
*/
WindowState getImeHostOrFallback(WindowState target) {
if (target != null && target.getDisplayContent().canShowIme()) {
@@ -3448,8 +3433,6 @@
/**
* The IME input target is the window which receives input from IME. It is also a candidate
* which controls the visibility and animation of the input method window.
- *
- * @param target the window that receives input from IME.
*/
void setInputMethodInputTarget(WindowState target) {
if (mInputMethodInputTarget != target) {
@@ -3459,12 +3442,7 @@
}
private void updateImeControlTarget() {
- if (!isImeAttachedToApp() && mRemoteInsetsControlTarget != null) {
- mInputMethodControlTarget = mRemoteInsetsControlTarget;
- } else {
- // Otherwise, we just use the ime input target
- mInputMethodControlTarget = mInputMethodInputTarget;
- }
+ mInputMethodControlTarget = computeImeControlTarget();
mInsetsStateController.onImeControlTargetChanged(mInputMethodControlTarget);
}
@@ -3477,6 +3455,19 @@
}
/**
+ * Computes the window where we hand IME control to.
+ */
+ @VisibleForTesting
+ InsetsControlTarget computeImeControlTarget() {
+ if (!isImeControlledByApp() && mRemoteInsetsControlTarget != null) {
+ return mRemoteInsetsControlTarget;
+ } else {
+ // Otherwise, we just use the ime target as received from IME.
+ return mInputMethodInputTarget;
+ }
+ }
+
+ /**
* Computes the window the IME should be attached to.
*/
@VisibleForTesting
diff --git a/services/core/java/com/android/server/wm/InsetsSourceProvider.java b/services/core/java/com/android/server/wm/InsetsSourceProvider.java
index cb0d853..1ca82ce 100644
--- a/services/core/java/com/android/server/wm/InsetsSourceProvider.java
+++ b/services/core/java/com/android/server/wm/InsetsSourceProvider.java
@@ -266,7 +266,7 @@
if (getSource().getType() == ITYPE_IME) {
setClientVisible(InsetsState.getDefaultVisibility(mSource.getType()));
}
- final Transaction t = mDisplayContent.getPendingTransaction();
+ final Transaction t = mDisplayContent.mWmService.mTransactionFactory.get();
mWin.startAnimation(t, mAdapter, !mClientVisible /* hidden */,
ANIMATION_TYPE_INSETS_CONTROL, null /* animationFinishedCallback */);
final SurfaceControl leash = mAdapter.mCapturedLeash;
@@ -281,6 +281,9 @@
t.deferTransactionUntil(mWin.getSurfaceControl(), barrier, frameNumber);
t.deferTransactionUntil(leash, barrier, frameNumber);
}
+ // Applying the transaction here can prevent the client from applying its transaction sooner
+ // than us which makes us overwrite the client's operation to the leash.
+ t.apply();
mControlTarget = target;
mControl = new InsetsSourceControl(mSource.getType(), leash,
new Point(mWin.getWindowFrames().mFrame.left, mWin.getWindowFrames().mFrame.top));
diff --git a/services/core/java/com/android/server/wm/RecentsAnimationController.java b/services/core/java/com/android/server/wm/RecentsAnimationController.java
index 54210ae..2ce10a7 100644
--- a/services/core/java/com/android/server/wm/RecentsAnimationController.java
+++ b/services/core/java/com/android/server/wm/RecentsAnimationController.java
@@ -898,11 +898,11 @@
TaskAnimationAdapter(Task task, boolean isRecentTaskInvisible) {
mTask = task;
mIsRecentTaskInvisible = isRecentTaskInvisible;
- mBounds.set(mTask.getDisplayedBounds());
+ mBounds.set(mTask.getBounds());
mLocalBounds.set(mBounds);
Point tmpPos = new Point();
- mTask.getRelativeDisplayedPosition(tmpPos);
+ mTask.getRelativePosition(tmpPos);
mLocalBounds.offsetTo(tmpPos.x, tmpPos.y);
}
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index ad1a205..1ffa01c 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -52,7 +52,6 @@
import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE_AND_PIPABLE_DEPRECATED;
import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
-import static android.content.res.Configuration.EMPTY;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
import static android.content.res.Configuration.ORIENTATION_UNDEFINED;
@@ -353,10 +352,6 @@
final Rect mPreparedFrozenBounds = new Rect();
final Configuration mPreparedFrozenMergedConfig = new Configuration();
- // If non-empty, bounds used to display the task during animations/interactions.
- // TODO(b/119687367): This member is temporary.
- private final Rect mOverrideDisplayedBounds = new Rect();
-
// Id of the previous display the stack was on.
int mPrevDisplayId = INVALID_DISPLAY;
@@ -2795,29 +2790,6 @@
}
}
- /**
- * Displayed bounds are used to set where the task is drawn at any given time. This is
- * separate from its actual bounds so that the app doesn't see any meaningful configuration
- * changes during transitionary periods.
- */
- void setOverrideDisplayedBounds(Rect overrideDisplayedBounds) {
- if (overrideDisplayedBounds != null) {
- adjustForMinimalTaskDimensions(overrideDisplayedBounds, mOverrideDisplayedBounds);
- mOverrideDisplayedBounds.set(overrideDisplayedBounds);
- } else {
- mOverrideDisplayedBounds.setEmpty();
- }
- updateSurfacePosition();
- }
-
- /**
- * Gets the bounds that override where the task is displayed. See
- * {@link android.app.IActivityTaskManager#resizeDockedStack} why this is needed.
- */
- Rect getOverrideDisplayedBounds() {
- return mOverrideDisplayedBounds;
- }
-
boolean isResizeable(boolean checkSupportsPip) {
return (mAtmService.mForceResizableActivities || ActivityInfo.isResizeableMode(mResizeMode)
|| (checkSupportsPip && mSupportsPictureInPicture));
@@ -2851,49 +2823,6 @@
mPreparedFrozenMergedConfig.setTo(getConfiguration());
}
- /**
- * Align the task to the adjusted bounds.
- *
- * @param adjustedBounds Adjusted bounds to which the task should be aligned.
- * @param tempInsetBounds Insets bounds for the task.
- * @param alignBottom True if the task's bottom should be aligned to the adjusted
- * bounds's bottom; false if the task's top should be aligned
- * the adjusted bounds's top.
- */
- void alignToAdjustedBounds(Rect adjustedBounds, Rect tempInsetBounds, boolean alignBottom) {
- if (!isResizeable() || EMPTY.equals(getRequestedOverrideConfiguration())) {
- return;
- }
-
- getBounds(mTmpRect2);
- if (alignBottom) {
- int offsetY = adjustedBounds.bottom - mTmpRect2.bottom;
- mTmpRect2.offset(0, offsetY);
- } else {
- mTmpRect2.offsetTo(adjustedBounds.left, adjustedBounds.top);
- }
- if (tempInsetBounds == null || tempInsetBounds.isEmpty()) {
- setOverrideDisplayedBounds(null);
- setBounds(mTmpRect2);
- } else {
- setOverrideDisplayedBounds(mTmpRect2);
- setBounds(tempInsetBounds);
- }
- }
-
- /**
- * Gets the current overridden displayed bounds. These will be empty if the task is not
- * currently overriding where it is displayed.
- */
- @Override
- public Rect getDisplayedBounds() {
- if (mOverrideDisplayedBounds.isEmpty()) {
- return super.getDisplayedBounds();
- } else {
- return mOverrideDisplayedBounds;
- }
- }
-
@Override
void getAnimationFrames(Rect outFrame, Rect outInsets, Rect outStableInsets,
Rect outSurfaceInsets) {
@@ -3431,7 +3360,6 @@
pw.println(prefix + "taskId=" + mTaskId);
pw.println(doublePrefix + "mBounds=" + getBounds().toShortString());
pw.println(doublePrefix + "appTokens=" + mChildren);
- pw.println(doublePrefix + "mDisplayedBounds=" + mOverrideDisplayedBounds.toShortString());
final String triplePrefix = doublePrefix + " ";
final String quadruplePrefix = triplePrefix + " ";
diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java
index 7219164..899ab24 100644
--- a/services/core/java/com/android/server/wm/WindowContainer.java
+++ b/services/core/java/com/android/server/wm/WindowContainer.java
@@ -2062,7 +2062,7 @@
// TODO: Remove this and use #getBounds() instead once we set an app transition animation
// on TaskStack.
Rect getAnimationBounds(int appStackClipMode) {
- return getDisplayedBounds();
+ return getBounds();
}
/**
@@ -2124,7 +2124,7 @@
// Separate position and size for use in animators.
mTmpRect.set(getAnimationBounds(appStackClipMode));
if (sHierarchicalAnimations) {
- getRelativeDisplayedPosition(mTmpPoint);
+ getRelativePosition(mTmpPoint);
} else {
mTmpPoint.set(mTmpRect.left, mTmpRect.top);
}
@@ -2304,14 +2304,18 @@
}
}
+ void resetSurfacePositionForAnimationLeash(Transaction t) {
+ t.setPosition(mSurfaceControl, 0, 0);
+ mLastSurfacePosition.set(0, 0);
+ }
+
@Override
public void onAnimationLeashCreated(Transaction t, SurfaceControl leash) {
mLastLayer = -1;
reassignLayer(t);
// Leash is now responsible for position, so set our position to 0.
- t.setPosition(mSurfaceControl, 0, 0);
- mLastSurfacePosition.set(0, 0);
+ resetSurfacePositionForAnimationLeash(t);
}
@Override
@@ -2395,7 +2399,7 @@
return;
}
- getRelativeDisplayedPosition(mTmpPos);
+ getRelativePosition(mTmpPos);
if (mTmpPos.equals(mLastSurfacePosition)) {
return;
}
@@ -2410,16 +2414,6 @@
}
/**
- * Displayed bounds specify where to display this container at. It differs from bounds during
- * certain operations (like animation or interactive dragging).
- *
- * @return the bounds to display this container at.
- */
- Rect getDisplayedBounds() {
- return getBounds();
- }
-
- /**
* The {@code outFrame} retrieved by this method specifies where the animation will finish
* the entrance animation, as the next frame will display the window at these coordinates. In
* case of exit animation, this is where the animation will start, as the frame before the
@@ -2439,7 +2433,7 @@
outSurfaceInsets.setEmpty();
}
- void getRelativeDisplayedPosition(Point outPos) {
+ void getRelativePosition(Point outPos) {
// In addition to updateSurfacePosition, we keep other code that sets
// position from fighting with the organizer
if (isOrganized()) {
@@ -2447,11 +2441,11 @@
return;
}
- final Rect dispBounds = getDisplayedBounds();
+ final Rect dispBounds = getBounds();
outPos.set(dispBounds.left, dispBounds.top);
final WindowContainer parent = getParent();
if (parent != null) {
- final Rect parentBounds = parent.getDisplayedBounds();
+ final Rect parentBounds = parent.getBounds();
outPos.offset(-parentBounds.left, -parentBounds.top);
}
}
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index a488af7..84cc19d 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -2445,8 +2445,17 @@
if (controls != null) {
final int length = Math.min(controls.length, outControls.length);
for (int i = 0; i < length; i++) {
- outControls[i] = win.isClientLocal()
- ? new InsetsSourceControl(controls[i]) : controls[i];
+ final InsetsSourceControl control = controls[i];
+
+ // Check if we are sending invalid leashes.
+ final SurfaceControl leash = control != null ? control.getLeash() : null;
+ if (leash != null && !leash.isValid()) {
+ Slog.wtf(TAG, leash + " is not valid before sending to " + win,
+ leash.getReleaseStack());
+ }
+
+ outControls[i] = win.isClientLocal() && control != null
+ ? new InsetsSourceControl(control) : control;
}
}
}
diff --git a/services/core/java/com/android/server/wm/WindowOrganizerController.java b/services/core/java/com/android/server/wm/WindowOrganizerController.java
index d9c0219..8b27667 100644
--- a/services/core/java/com/android/server/wm/WindowOrganizerController.java
+++ b/services/core/java/com/android/server/wm/WindowOrganizerController.java
@@ -320,7 +320,7 @@
final ActivityStack stack = (ActivityStack) container;
if (stack.inPinnedWindowingMode()) {
stack.resize(config.windowConfiguration.getBounds(),
- null /* configBounds */, PRESERVE_WINDOWS, true /* deferResume */);
+ PRESERVE_WINDOWS, true /* deferResume */);
}
}
}
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 2e1b907..af68070 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -999,18 +999,6 @@
frame.inset(left, top, right, bottom);
}
- @Override
- public Rect getDisplayedBounds() {
- final Task task = getTask();
- if (task != null) {
- Rect bounds = task.getOverrideDisplayedBounds();
- if (!bounds.isEmpty()) {
- return bounds;
- }
- }
- return super.getDisplayedBounds();
- }
-
void computeFrame(DisplayFrames displayFrames) {
getLayoutingWindowFrames().setDisplayCutout(displayFrames.mDisplayCutout);
computeFrameLw();
@@ -1065,7 +1053,7 @@
layoutXDiff = 0;
layoutYDiff = 0;
} else {
- windowFrames.mContainingFrame.set(getDisplayedBounds());
+ windowFrames.mContainingFrame.set(getBounds());
if (mActivityRecord != null && !mActivityRecord.mFrozenBounds.isEmpty()) {
// If the bounds are frozen, we still want to translate the window freely and only
@@ -1223,7 +1211,7 @@
parentLeft = ((WindowState) parent).mWindowFrames.mFrame.left;
parentTop = ((WindowState) parent).mWindowFrames.mFrame.top;
} else if (parent != null) {
- final Rect parentBounds = parent.getDisplayedBounds();
+ final Rect parentBounds = parent.getBounds();
parentLeft = parentBounds.left;
parentTop = parentBounds.top;
}
@@ -5250,16 +5238,6 @@
}
@Override
- public void onAnimationLeashCreated(Transaction t, SurfaceControl leash) {
- super.onAnimationLeashCreated(t, leash);
- }
-
- @Override
- public void onAnimationLeashLost(Transaction t) {
- super.onAnimationLeashLost(t);
- }
-
- @Override
@VisibleForTesting
void updateSurfacePosition(Transaction t) {
if (mSurfaceControl == null) {
@@ -5300,7 +5278,7 @@
outPoint.offset(-parent.mWindowFrames.mFrame.left + mTmpPoint.x,
-parent.mWindowFrames.mFrame.top + mTmpPoint.y);
} else if (parentWindowContainer != null) {
- final Rect parentBounds = parentWindowContainer.getDisplayedBounds();
+ final Rect parentBounds = parentWindowContainer.getBounds();
outPoint.offset(-parentBounds.left, -parentBounds.top);
}
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index d4470f8..9957707 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -1030,7 +1030,7 @@
mTmpPos.x = 0;
mTmpPos.y = 0;
if (stack != null) {
- stack.getRelativeDisplayedPosition(mTmpPos);
+ stack.getRelativePosition(mTmpPos);
}
xOffset = -mTmpPos.x;
diff --git a/services/core/java/com/android/server/wm/WindowToken.java b/services/core/java/com/android/server/wm/WindowToken.java
index b4e770f..21c7687 100644
--- a/services/core/java/com/android/server/wm/WindowToken.java
+++ b/services/core/java/com/android/server/wm/WindowToken.java
@@ -632,6 +632,15 @@
}
}
+ @Override
+ void resetSurfacePositionForAnimationLeash(SurfaceControl.Transaction t) {
+ // Keep the transformed position to animate because the surface will show in different
+ // rotation than the animator of leash.
+ if (!isFixedRotationTransforming()) {
+ super.resetSurfacePositionForAnimationLeash(t);
+ }
+ }
+
/**
* Gives a chance to this {@link WindowToken} to adjust the {@link
* android.view.WindowManager.LayoutParams} of its windows.
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 1da0740..2c0d4c0 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -4733,33 +4733,13 @@
if (!parent && isSeparateProfileChallengeEnabled(userHandle)) {
// If this user has a separate challenge, only return its restrictions.
return getUserDataUnchecked(userHandle).mAdminList;
- } else {
- // Return all admins for this user and the profiles that are visible from this
- // user that do not use a separate work challenge.
- ArrayList<ActiveAdmin> admins = new ArrayList<ActiveAdmin>();
- for (UserInfo userInfo : mUserManager.getProfiles(userHandle)) {
- DevicePolicyData policy = getUserData(userInfo.id);
- if (!userInfo.isManagedProfile()) {
- admins.addAll(policy.mAdminList);
- } else {
- // For managed profiles, we always include the policies set on the parent
- // profile. Additionally, we include the ones set on the managed profile
- // if no separate challenge is in place.
- boolean hasSeparateChallenge = isSeparateProfileChallengeEnabled(userInfo.id);
- final int N = policy.mAdminList.size();
- for (int i = 0; i < N; i++) {
- ActiveAdmin admin = policy.mAdminList.get(i);
- if (admin.hasParentActiveAdmin()) {
- admins.add(admin.getParentActiveAdmin());
- }
- if (!hasSeparateChallenge) {
- admins.add(admin);
- }
- }
- }
- }
- return admins;
}
+ // Either parent == true, or isSeparateProfileChallengeEnabled == false
+ // If parent is true, query the parent user of userHandle by definition,
+ // If isSeparateProfileChallengeEnabled is false, userHandle points to a managed profile
+ // with unified challenge so also need to query the parent user who owns the credential.
+ return getActiveAdminsForUserAndItsManagedProfilesLocked(getProfileParentId(userHandle),
+ (user) -> !mLockPatternUtils.isSeparateProfileChallengeEnabled(user.id));
}
/**
@@ -4777,6 +4757,19 @@
if (isManagedProfile(userHandle)) {
return getUserDataUnchecked(userHandle).mAdminList;
}
+ return getActiveAdminsForUserAndItsManagedProfilesLocked(userHandle,
+ /* shouldIncludeProfileAdmins */ (user) -> false);
+ }
+
+ /**
+ * Returns the list of admins on the given user, as well as parent admins for each managed
+ * profile associated with the given user. Optionally also include the admin of each managed
+ * profile.
+ * <p> Should not be called on a profile user.
+ */
+ @GuardedBy("getLockObject()")
+ private List<ActiveAdmin> getActiveAdminsForUserAndItsManagedProfilesLocked(int userHandle,
+ Predicate<UserInfo> shouldIncludeProfileAdmins) {
ArrayList<ActiveAdmin> admins = new ArrayList<>();
mInjector.binderWithCleanCallingIdentity(() -> {
for (UserInfo userInfo : mUserManager.getProfiles(userHandle)) {
@@ -4784,12 +4777,14 @@
if (userInfo.id == userHandle) {
admins.addAll(policy.mAdminList);
} else if (userInfo.isManagedProfile()) {
- // For managed profiles, policies set on the parent profile will be included
for (int i = 0; i < policy.mAdminList.size(); i++) {
ActiveAdmin admin = policy.mAdminList.get(i);
if (admin.hasParentActiveAdmin()) {
admins.add(admin.getParentActiveAdmin());
}
+ if (shouldIncludeProfileAdmins.test(userInfo)) {
+ admins.add(admin);
+ }
}
} else {
Slog.w(LOG_TAG, "Unknown user type: " + userInfo);
@@ -5366,6 +5361,32 @@
}
}
+ @Override
+ public boolean isPasswordSufficientAfterProfileUnification(int userHandle, int profileUser) {
+ if (!mHasFeature) {
+ return true;
+ }
+ enforceFullCrossUsersPermission(userHandle);
+ enforceNotManagedProfile(userHandle, "check password sufficiency");
+ enforceUserUnlocked(userHandle);
+
+ synchronized (getLockObject()) {
+ PasswordMetrics metrics = mLockSettingsInternal.getUserPasswordMetrics(userHandle);
+
+ // Combine password policies across the user and its profiles. Profile admins are
+ // included if the profile is to be unified or currently has unified challenge
+ List<ActiveAdmin> admins = getActiveAdminsForUserAndItsManagedProfilesLocked(userHandle,
+ /* shouldIncludeProfileAdmins */ (user) -> user.id == profileUser
+ || !mLockPatternUtils.isSeparateProfileChallengeEnabled(user.id));
+ ArrayList<PasswordMetrics> adminMetrics = new ArrayList<>(admins.size());
+ for (ActiveAdmin admin : admins) {
+ adminMetrics.add(admin.mPasswordPolicy.getMinMetrics());
+ }
+ return PasswordMetrics.validatePasswordMetrics(PasswordMetrics.merge(adminMetrics),
+ PASSWORD_COMPLEXITY_NONE, false, metrics).isEmpty();
+ }
+ }
+
private boolean isActivePasswordSufficientForUserLocked(
boolean passwordValidAtLastCheckpoint, @Nullable PasswordMetrics metrics,
int userHandle, boolean parent) {
diff --git a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
index fe224ce..4faed65 100644
--- a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
@@ -4841,6 +4841,33 @@
assertFalse(dpm.isActivePasswordSufficient());
}
+ public void testIsPasswordSufficientAfterProfileUnification() throws Exception {
+ final int managedProfileUserId = DpmMockContext.CALLER_USER_HANDLE;
+ final int managedProfileAdminUid =
+ UserHandle.getUid(managedProfileUserId, DpmMockContext.SYSTEM_UID);
+ mContext.binder.callingUid = managedProfileAdminUid;
+
+ addManagedProfile(admin1, managedProfileAdminUid, admin1);
+ doReturn(true).when(getServices().lockPatternUtils)
+ .isSeparateProfileChallengeEnabled(managedProfileUserId);
+
+ dpm.setPasswordQuality(admin1, DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC);
+ parentDpm.setPasswordQuality(admin1, DevicePolicyManager.PASSWORD_QUALITY_NUMERIC);
+
+ when(getServices().lockSettingsInternal.getUserPasswordMetrics(UserHandle.USER_SYSTEM))
+ .thenReturn(computeForPassword("1234".getBytes()));
+
+ // Numeric password is compliant with current requirement (QUALITY_NUMERIC set explicitly
+ // on the parent admin)
+ assertTrue(dpm.isPasswordSufficientAfterProfileUnification(UserHandle.USER_SYSTEM,
+ UserHandle.USER_NULL));
+ // Numeric password is not compliant if profile is to be unified: the profile has a
+ // QUALITY_ALPHABETIC policy on itself which will be enforced on the password after
+ // unification.
+ assertFalse(dpm.isPasswordSufficientAfterProfileUnification(UserHandle.USER_SYSTEM,
+ managedProfileUserId));
+ }
+
private void setActivePasswordState(PasswordMetrics passwordMetrics)
throws Exception {
final int userHandle = UserHandle.getUserId(mContext.binder.callingUid);
diff --git a/services/tests/servicestests/src/com/android/server/locksettings/LockSettingsServiceTests.java b/services/tests/servicestests/src/com/android/server/locksettings/LockSettingsServiceTests.java
index 07d7830..12b144f 100644
--- a/services/tests/servicestests/src/com/android/server/locksettings/LockSettingsServiceTests.java
+++ b/services/tests/servicestests/src/com/android/server/locksettings/LockSettingsServiceTests.java
@@ -209,6 +209,26 @@
}
@Test
+ public void testManagedProfileChallengeUnification_parentUserNoPassword() throws Exception {
+ // Start with a profile with unified challenge, parent user has not password
+ mService.setSeparateProfileChallengeEnabled(MANAGED_PROFILE_USER_ID, false, null);
+ assertEquals(0, mGateKeeperService.getSecureUserId(MANAGED_PROFILE_USER_ID));
+ assertEquals(CREDENTIAL_TYPE_NONE, mService.getCredentialType(MANAGED_PROFILE_USER_ID));
+
+ // Set a separate challenge on the profile
+ assertTrue(mService.setLockCredential(
+ newPassword("12345678"), nonePassword(), MANAGED_PROFILE_USER_ID));
+ assertNotEquals(0, mGateKeeperService.getSecureUserId(MANAGED_PROFILE_USER_ID));
+ assertEquals(CREDENTIAL_TYPE_PASSWORD, mService.getCredentialType(MANAGED_PROFILE_USER_ID));
+
+ // Now unify again, profile should become passwordless again
+ mService.setSeparateProfileChallengeEnabled(MANAGED_PROFILE_USER_ID, false,
+ newPassword("12345678"));
+ assertEquals(0, mGateKeeperService.getSecureUserId(MANAGED_PROFILE_USER_ID));
+ assertEquals(CREDENTIAL_TYPE_NONE, mService.getCredentialType(MANAGED_PROFILE_USER_ID));
+ }
+
+ @Test
public void testSetLockCredential_forPrimaryUser_sendsCredentials() throws Exception {
assertTrue(mService.setLockCredential(
newPassword("password"),
diff --git a/services/tests/servicestests/src/com/android/server/pm/dex/DexoptOptionsTests.java b/services/tests/servicestests/src/com/android/server/pm/dex/DexoptOptionsTests.java
index 62589eb..22020ad 100644
--- a/services/tests/servicestests/src/com/android/server/pm/dex/DexoptOptionsTests.java
+++ b/services/tests/servicestests/src/com/android/server/pm/dex/DexoptOptionsTests.java
@@ -54,6 +54,7 @@
assertFalse(opt.isForce());
assertFalse(opt.isDexoptIdleBackgroundJob());
assertFalse(opt.isDexoptInstallWithDexMetadata());
+ assertFalse(opt.isDexoptInstallForRestore());
}
@Test
@@ -67,7 +68,8 @@
DexoptOptions.DEXOPT_DOWNGRADE |
DexoptOptions.DEXOPT_AS_SHARED_LIBRARY |
DexoptOptions.DEXOPT_IDLE_BACKGROUND_JOB |
- DexoptOptions.DEXOPT_INSTALL_WITH_DEX_METADATA_FILE;
+ DexoptOptions.DEXOPT_INSTALL_WITH_DEX_METADATA_FILE |
+ DexoptOptions.DEXOPT_FOR_RESTORE;
DexoptOptions opt = new DexoptOptions(mPackageName, mCompilerFilter, flags);
assertEquals(mPackageName, opt.getPackageName());
@@ -82,6 +84,7 @@
assertTrue(opt.isDexoptAsSharedLibrary());
assertTrue(opt.isDexoptIdleBackgroundJob());
assertTrue(opt.isDexoptInstallWithDexMetadata());
+ assertTrue(opt.isDexoptInstallForRestore());
}
@Test
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/ArchiveTest.java b/services/tests/uiservicestests/src/com/android/server/notification/ArchiveTest.java
new file mode 100644
index 0000000..c69ef8d
--- /dev/null
+++ b/services/tests/uiservicestests/src/com/android/server/notification/ArchiveTest.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2020 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.notification;
+
+import static android.os.UserHandle.USER_CURRENT;
+import static android.os.UserHandle.USER_SYSTEM;
+import static android.service.notification.NotificationListenerService.REASON_CANCEL;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.app.Notification;
+import android.os.UserHandle;
+import android.service.notification.StatusBarNotification;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import androidx.test.runner.AndroidJUnit4;
+
+import com.android.server.UiServiceTestCase;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+@SmallTest
+@RunWith(AndroidJUnit4.class)
+public class ArchiveTest extends UiServiceTestCase {
+ private static final int SIZE = 5;
+
+ private NotificationManagerService.Archive mArchive;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ mArchive = new NotificationManagerService.Archive(SIZE);
+ mArchive.updateHistoryEnabled(USER_SYSTEM, true);
+ mArchive.updateHistoryEnabled(USER_CURRENT, true);
+ }
+
+ private StatusBarNotification getNotification(String pkg, int id, UserHandle user) {
+ Notification n = new Notification.Builder(getContext(), "test")
+ .setContentTitle("A")
+ .setWhen(1205)
+ .build();
+ return new StatusBarNotification(
+ pkg, pkg, id, null, 0, 0, n, user, null, System.currentTimeMillis());
+ }
+
+
+ @Test
+ public void testRecordAndRead() {
+ List<String> expected = new ArrayList<>();
+ for (int i = 0; i < SIZE; i++) {
+ StatusBarNotification sbn = getNotification("pkg" + i, i,
+ UserHandle.of(i % 2 ==0 ? USER_SYSTEM : USER_CURRENT));
+ expected.add(sbn.getKey());
+ mArchive.record(sbn, REASON_CANCEL);
+ }
+
+ List<StatusBarNotification> actual = Arrays.asList(mArchive.getArray(SIZE, true));
+ assertThat(actual).hasSize(expected.size());
+ for (StatusBarNotification sbn : actual) {
+ assertThat(expected).contains(sbn.getKey());
+ }
+ }
+
+ @Test
+ public void testRecordAndRead_overLimit() {
+ List<String> expected = new ArrayList<>();
+ for (int i = 0; i < (SIZE * 2); i++) {
+ StatusBarNotification sbn = getNotification("pkg" + i, i, UserHandle.of(USER_SYSTEM));
+ mArchive.record(sbn, REASON_CANCEL);
+ if (i >= SIZE) {
+ expected.add(sbn.getKey());
+ }
+ }
+
+ List<StatusBarNotification> actual = Arrays.asList(mArchive.getArray((SIZE * 2), true));
+ assertThat(actual).hasSize(expected.size());
+ for (StatusBarNotification sbn : actual) {
+ assertThat(expected).contains(sbn.getKey());
+ }
+ }
+
+ @Test
+ public void testDoesNotRecordIfHistoryDisabled() {
+ mArchive.updateHistoryEnabled(USER_CURRENT, false);
+ List<String> expected = new ArrayList<>();
+ for (int i = 0; i < SIZE; i++) {
+ StatusBarNotification sbn = getNotification("pkg" + i, i,
+ UserHandle.of(i % 2 ==0 ? USER_SYSTEM : USER_CURRENT));
+ mArchive.record(sbn, REASON_CANCEL);
+ if (i % 2 ==0) {
+ expected.add(sbn.getKey());
+ }
+ }
+
+ List<StatusBarNotification> actual = Arrays.asList(mArchive.getArray(SIZE, true));
+ assertThat(actual).hasSize(expected.size());
+ for (StatusBarNotification sbn : actual) {
+ assertThat(expected).contains(sbn.getKey());
+ }
+ }
+
+ @Test
+ public void testRemovesEntriesWhenHistoryDisabled() {
+ mArchive.updateHistoryEnabled(USER_CURRENT, true);
+ List<String> expected = new ArrayList<>();
+ for (int i = 0; i < SIZE; i++) {
+ StatusBarNotification sbn = getNotification("pkg" + i, i,
+ UserHandle.of(i % 2 ==0 ? USER_SYSTEM : USER_CURRENT));
+ mArchive.record(sbn, REASON_CANCEL);
+ if (i % 2 ==0) {
+ expected.add(sbn.getKey());
+ }
+ }
+ mArchive.updateHistoryEnabled(USER_CURRENT, false);
+
+ List<StatusBarNotification> actual = Arrays.asList(mArchive.getArray(SIZE, true));
+ assertThat(actual).hasSize(expected.size());
+ for (StatusBarNotification sbn : actual) {
+ assertThat(expected).contains(sbn.getKey());
+ }
+ }
+}
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/ManagedServicesTest.java b/services/tests/uiservicestests/src/com/android/server/notification/ManagedServicesTest.java
index 7b7470c..28ff9a5 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/ManagedServicesTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/ManagedServicesTest.java
@@ -77,6 +77,7 @@
import java.io.ByteArrayOutputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -96,6 +97,10 @@
UserInfo mZero = new UserInfo(0, "zero", 0);
UserInfo mTen = new UserInfo(10, "ten", 0);
+ private String mDefaultsString;
+ private String mVersionString;
+ private final Set<ComponentName> mDefaults = new ArraySet();
+ private ManagedServices mService;
private static final String SETTING = "setting";
private static final String SECONDARY_SETTING = "secondary_setting";
@@ -106,8 +111,8 @@
private ArrayMap<Integer, String> mExpectedSecondaryComponentNames;
// type : user : list of approved
- private ArrayMap<Integer, ArrayMap<Integer, String>> mExpectedPrimary = new ArrayMap<>();
- private ArrayMap<Integer, ArrayMap<Integer, String>> mExpectedSecondary = new ArrayMap<>();
+ private ArrayMap<Integer, ArrayMap<Integer, String>> mExpectedPrimary;
+ private ArrayMap<Integer, ArrayMap<Integer, String>> mExpectedSecondary;
@Before
public void setUp() throws Exception {
@@ -132,6 +137,9 @@
profileIds.add(12);
when(mUserProfiles.getCurrentProfileIds()).thenReturn(profileIds);
+ mVersionString = "2";
+ mExpectedPrimary = new ArrayMap<>();
+ mExpectedSecondary = new ArrayMap<>();
mExpectedPrimaryPackages = new ArrayMap<>();
mExpectedPrimaryPackages.put(0, "this.is.a.package.name:another.package");
mExpectedPrimaryPackages.put(10, "this.is.another.package");
@@ -155,6 +163,8 @@
"this.is.another.package:component:package");
mExpectedSecondary.put(APPROVAL_BY_PACKAGE, mExpectedSecondaryPackages);
mExpectedSecondary.put(APPROVAL_BY_COMPONENT, mExpectedSecondaryComponentNames);
+ mService = new TestManagedServices(getContext(), mLock, mUserProfiles,
+ mIpm, APPROVAL_BY_COMPONENT);
}
@Test
@@ -1178,9 +1188,99 @@
}
}
+ @Test
+ public void loadDefaults_noVersionNoDefaults() throws Exception {
+ resetComponentsAndPackages();
+ loadXml(mService);
+ assertEquals(mService.getDefaultComponents().size(), 0);
+ }
+
+ @Test
+ public void loadDefaults_noVersionNoDefaultsOneActive() throws Exception {
+ resetComponentsAndPackages();
+ mService.addDefaultComponentOrPackage("package/class");
+ loadXml(mService);
+ assertEquals(1, mService.getDefaultComponents().size());
+ assertTrue(mService.getDefaultComponents()
+ .contains(ComponentName.unflattenFromString("package/class")));
+ }
+
+ @Test
+ public void loadDefaults_noVersionWithDefaults() throws Exception {
+ resetComponentsAndPackages();
+ mDefaults.add(new ComponentName("default", "class"));
+ loadXml(mService);
+ assertEquals(mService.getDefaultComponents(), mDefaults);
+ }
+
+ @Test
+ public void loadDefaults_versionOneWithDefaultsWithActive() throws Exception {
+ resetComponentsAndPackages();
+ mDefaults.add(new ComponentName("default", "class"));
+ mExpectedPrimaryComponentNames.put(0, "package/class");
+ mVersionString = "1";
+ loadXml(mService);
+ assertEquals(mService.getDefaultComponents(),
+ new ArraySet(Arrays.asList(new ComponentName("package", "class"))));
+ }
+
+ @Test
+ public void loadDefaults_versionTwoWithDefaultsWithActive() throws Exception {
+ resetComponentsAndPackages();
+ mDefaults.add(new ComponentName("default", "class"));
+ mDefaultsString = "default/class";
+ mExpectedPrimaryComponentNames.put(0, "package/class");
+ mVersionString = "2";
+ loadXml(mService);
+ assertEquals(1, mService.getDefaultComponents().size());
+ mDefaults.forEach(pkg -> {
+ assertTrue(mService.getDefaultComponents().contains(pkg));
+ });
+ }
+
+ @Test
+ public void loadDefaults_versionOneWithXMLDefaultsWithActive() throws Exception {
+ resetComponentsAndPackages();
+ mDefaults.add(new ComponentName("default", "class"));
+ mDefaultsString = "xml/class";
+ mExpectedPrimaryComponentNames.put(0, "package/class");
+ mVersionString = "1";
+ loadXml(mService);
+ assertEquals(mService.getDefaultComponents(),
+ new ArraySet(Arrays.asList(new ComponentName("xml", "class"))));
+ }
+
+ @Test
+ public void loadDefaults_versionTwoWithXMLDefaultsWithActive() throws Exception {
+ resetComponentsAndPackages();
+ mDefaults.add(new ComponentName("default", "class"));
+ mDefaultsString = "xml/class";
+ mExpectedPrimaryComponentNames.put(0, "package/class");
+ mVersionString = "2";
+ loadXml(mService);
+ assertEquals(mService.getDefaultComponents(),
+ new ArraySet(Arrays.asList(new ComponentName("xml", "class"))));
+ }
+
+ private void resetComponentsAndPackages() {
+ ArrayMap<Integer, ArrayMap<Integer, String>> empty = new ArrayMap(1);
+ ArrayMap<Integer, String> emptyPkgs = new ArrayMap(0);
+ empty.append(mService.mApprovalLevel, emptyPkgs);
+ mExpectedPrimary = empty;
+ mExpectedPrimaryComponentNames = emptyPkgs;
+ mExpectedPrimaryPackages = emptyPkgs;
+ mExpectedSecondary = empty;
+ mExpectedSecondaryComponentNames = emptyPkgs;
+ mExpectedSecondaryPackages = emptyPkgs;
+ }
+
private void loadXml(ManagedServices service) throws Exception {
final StringBuffer xml = new StringBuffer();
- xml.append("<" + service.getConfig().xmlTag + ">\n");
+ String xmlTag = service.getConfig().xmlTag;
+ xml.append("<" + xmlTag
+ + (mDefaultsString != null ? " defaults=\"" + mDefaultsString + "\" " : "")
+ + (mVersionString != null ? " version=\"" + mVersionString + "\" " : "")
+ + ">\n");
for (int userId : mExpectedPrimary.get(service.mApprovalLevel).keySet()) {
xml.append(getXmlEntry(
mExpectedPrimary.get(service.mApprovalLevel).get(userId), userId, true));
@@ -1197,7 +1297,7 @@
+ ManagedServices.ATT_USER_ID + "=\"98\" "
+ ManagedServices.ATT_IS_PRIMARY + "=\"false\" "
+ ManagedServices.ATT_APPROVED_LIST + "=\"98\" />\n");
- xml.append("</" + service.getConfig().xmlTag + ">");
+ xml.append("</" + xmlTag + ">");
XmlPullParser parser = Xml.newPullParser();
parser.setInput(new BufferedInputStream(
@@ -1224,6 +1324,7 @@
private void addExpectedServices(final ManagedServices service, final List<String> packages,
int userId) {
+ ManagedServices.Config config = service.getConfig();
when(mPm.queryIntentServicesAsUser(any(), anyInt(), eq(userId))).
thenAnswer(new Answer<List<ResolveInfo>>() {
@Override
@@ -1233,7 +1334,7 @@
Intent invocationIntent = (Intent) args[0];
if (invocationIntent != null) {
if (invocationIntent.getAction().equals(
- service.getConfig().serviceInterface)
+ config.serviceInterface)
&& packages.contains(invocationIntent.getPackage())) {
List<ResolveInfo> dummyServices = new ArrayList<>();
for (int i = 1; i <= 3; i ++) {
@@ -1431,6 +1532,11 @@
}
@Override
+ protected void loadDefaultsFromConfig() {
+ mDefaultComponents.addAll(mDefaults);
+ }
+
+ @Override
protected String getRequiredPermission() {
return null;
}
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationAssistantsTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationAssistantsTest.java
index 88186cd..ab4dc47 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationAssistantsTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationAssistantsTest.java
@@ -72,13 +72,13 @@
Object mLock = new Object();
+
UserInfo mZero = new UserInfo(0, "zero", 0);
UserInfo mTen = new UserInfo(10, "ten", 0);
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
-
getContext().setMockPackageManager(mPm);
getContext().addMockSystemService(Context.USER_SERVICE, mUm);
mAssistants = spy(mNm.new NotificationAssistants(getContext(), mLock, mUserProfiles, miPm));
@@ -122,7 +122,7 @@
@Test
public void testXmlUpgradeExistingApprovedComponents() throws Exception {
- String xml = "<enabled_assistants>"
+ String xml = "<enabled_assistants version=\"2\" defaults=\"b\\b\">"
+ "<service_listing approved=\"b/b\" user=\"10\" primary=\"true\" />"
+ "</enabled_assistants>";
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
index 3cd0e92..ecdd9e5 100755
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
@@ -113,6 +113,7 @@
import android.content.pm.PackageManager;
import android.content.pm.ParceledListSlice;
import android.content.pm.ShortcutInfo;
+import android.content.pm.ShortcutServiceInternal;
import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.graphics.Color;
@@ -234,6 +235,8 @@
@Mock
private LauncherApps mLauncherApps;
@Mock
+ private ShortcutServiceInternal mShortcutServiceInternal;
+ @Mock
ActivityManager mActivityManager;
@Mock
Resources mResources;
@@ -466,6 +469,7 @@
mShortcutHelper = mService.getShortcutHelper();
mShortcutHelper.setLauncherApps(mLauncherApps);
+ mShortcutHelper.setShortcutServiceInternal(mShortcutServiceInternal);
// Set the testable bubble extractor
RankingHelper rankingHelper = mService.getRankingHelper();
@@ -782,33 +786,16 @@
userInfos.add(new UserInfo(0, "", 0));
final ArraySet<ComponentName> validAssistants = new ArraySet<>();
validAssistants.add(ComponentName.unflattenFromString(testComponent));
- final String originalComponent = DeviceConfig.getProperty(
- DeviceConfig.NAMESPACE_SYSTEMUI,
- SystemUiDeviceConfigFlags.NAS_DEFAULT_SERVICE
- );
- DeviceConfig.setProperty(
- DeviceConfig.NAMESPACE_SYSTEMUI,
- SystemUiDeviceConfigFlags.NAS_DEFAULT_SERVICE,
- testComponent,
- false
- );
when(mActivityManager.isLowRamDevice()).thenReturn(false);
when(mAssistants.queryPackageForServices(isNull(), anyInt(), anyInt()))
.thenReturn(validAssistants);
- when(mAssistants.getDefaultComponents()).thenReturn(new ArraySet<>());
+ when(mAssistants.getDefaultComponents()).thenReturn(validAssistants);
when(mUm.getEnabledProfiles(anyInt())).thenReturn(userInfos);
mService.setDefaultAssistantForUser(userId);
verify(mAssistants).setPackageOrComponentEnabled(
eq(testComponent), eq(userId), eq(true), eq(true));
-
- DeviceConfig.setProperty(
- DeviceConfig.NAMESPACE_SYSTEMUI,
- SystemUiDeviceConfigFlags.NAS_DEFAULT_SERVICE,
- originalComponent,
- false
- );
}
@Test
@@ -6088,8 +6075,11 @@
List<ShortcutInfo> shortcutInfos = new ArrayList<>();
ShortcutInfo info = mock(ShortcutInfo.class);
when(info.isLongLived()).thenReturn(true);
+ when(info.isEnabled()).thenReturn(true);
shortcutInfos.add(info);
when(mLauncherApps.getShortcuts(any(), any())).thenReturn(shortcutInfos);
+ when(mShortcutServiceInternal.isSharingShortcut(anyInt(), anyString(), anyString(),
+ anyString(), anyInt(), any())).thenReturn(true);
// Test: Send the bubble notification
mBinderService.enqueueNotificationWithTag(PKG, PKG, nr.getSbn().getTag(),
@@ -6148,8 +6138,11 @@
List<ShortcutInfo> shortcutInfos = new ArrayList<>();
ShortcutInfo info = mock(ShortcutInfo.class);
when(info.isLongLived()).thenReturn(true);
+ when(info.isEnabled()).thenReturn(true);
shortcutInfos.add(info);
when(mLauncherApps.getShortcuts(any(), any())).thenReturn(shortcutInfos);
+ when(mShortcutServiceInternal.isSharingShortcut(anyInt(), anyString(), anyString(),
+ anyString(), anyInt(), any())).thenReturn(true);
// Test: Send the bubble notification
mBinderService.enqueueNotificationWithTag(PKG, PKG, nr.getSbn().getTag(),
@@ -6289,7 +6282,7 @@
mService.loadDefaultApprovedServices(USER_SYSTEM);
- verify(mConditionProviders, times(1)).addDefaultComponentOrPackage("test");
+ verify(mConditionProviders, times(1)).loadDefaultsFromConfig();
}
// TODO: add tests for the rest of the non-empty cases
@@ -6492,7 +6485,10 @@
ShortcutInfo si = mock(ShortcutInfo.class);
when(si.getShortLabel()).thenReturn("Hello");
when(si.isLongLived()).thenReturn(true);
+ when(si.isEnabled()).thenReturn(true);
when(mLauncherApps.getShortcuts(any(), any())).thenReturn(Arrays.asList(si));
+ when(mShortcutServiceInternal.isSharingShortcut(anyInt(), anyString(), anyString(),
+ anyString(), anyInt(), any())).thenReturn(true);
List<ConversationChannelWrapper> conversations =
mBinderService.getConversationsForPackage(PKG_P, mUid).getList();
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java
index 427237c..ac51750 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java
@@ -15,6 +15,9 @@
*/
package com.android.server.notification;
+import static android.app.AppOpsManager.MODE_ALLOWED;
+import static android.app.AppOpsManager.MODE_DEFAULT;
+import static android.app.AppOpsManager.OP_SYSTEM_ALERT_WINDOW;
import static android.app.NotificationChannel.CONVERSATION_CHANNEL_ID_FORMAT;
import static android.app.NotificationManager.BUBBLE_PREFERENCE_ALL;
import static android.app.NotificationManager.BUBBLE_PREFERENCE_NONE;
@@ -50,6 +53,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.app.AppOpsManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationChannelGroup;
@@ -132,6 +136,7 @@
@Spy IContentProvider mTestIContentProvider = new MockIContentProvider();
@Mock Context mContext;
@Mock ZenModeHelper mMockZenModeHelper;
+ @Mock AppOpsManager mAppOpsManager;
private NotificationManager.Policy mTestNotificationPolicy;
@@ -187,7 +192,10 @@
mTestNotificationPolicy = new NotificationManager.Policy(0, 0, 0, 0,
NotificationManager.Policy.STATE_CHANNELS_BYPASSING_DND, 0);
when(mMockZenModeHelper.getNotificationPolicy()).thenReturn(mTestNotificationPolicy);
- mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger);
+ when(mAppOpsManager.noteOpNoThrow(anyInt(), anyInt(),
+ anyString(), eq(null), anyString())).thenReturn(MODE_DEFAULT);
+ mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger,
+ mAppOpsManager);
resetZenModeHelper();
mAudioAttributes = new AudioAttributes.Builder()
@@ -1464,7 +1472,8 @@
mTestNotificationPolicy = new NotificationManager.Policy(0, 0, 0, 0,
NotificationManager.Policy.STATE_CHANNELS_BYPASSING_DND, 0);
when(mMockZenModeHelper.getNotificationPolicy()).thenReturn(mTestNotificationPolicy);
- mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger);
+ mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger,
+ mAppOpsManager);
assertFalse(mHelper.areChannelsBypassingDnd());
verify(mMockZenModeHelper, times(1)).setNotificationPolicy(any());
resetZenModeHelper();
@@ -1475,7 +1484,8 @@
// start notification policy off with mAreChannelsBypassingDnd = false
mTestNotificationPolicy = new NotificationManager.Policy(0, 0, 0, 0, 0, 0);
when(mMockZenModeHelper.getNotificationPolicy()).thenReturn(mTestNotificationPolicy);
- mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger);
+ mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger,
+ mAppOpsManager);
assertFalse(mHelper.areChannelsBypassingDnd());
verify(mMockZenModeHelper, never()).setNotificationPolicy(any());
resetZenModeHelper();
@@ -2241,7 +2251,8 @@
+ "content_type=\"4\" flags=\"0\" show_badge=\"true\" />\n"
+ "</package>\n"
+ "</ranking>\n";
- mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger);
+ mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger,
+ mAppOpsManager);
loadByteArrayXml(preQXml.getBytes(), true, UserHandle.USER_SYSTEM);
assertEquals(PreferencesHelper.DEFAULT_HIDE_SILENT_STATUS_BAR_ICONS,
@@ -2253,7 +2264,8 @@
mHelper.setHideSilentStatusIcons(!PreferencesHelper.DEFAULT_HIDE_SILENT_STATUS_BAR_ICONS);
ByteArrayOutputStream baos = writeXmlAndPurge(PKG_O, UID_O, false, UserHandle.USER_ALL);
- mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger);
+ mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger,
+ mAppOpsManager);
loadStreamXml(baos, false, UserHandle.USER_ALL);
assertEquals(!PreferencesHelper.DEFAULT_HIDE_SILENT_STATUS_BAR_ICONS,
@@ -2349,7 +2361,8 @@
mHelper.setImportance(PKG_O, UID_O, IMPORTANCE_UNSPECIFIED);
ByteArrayOutputStream baos = writeXmlAndPurge(PKG_O, UID_O, false, UserHandle.USER_ALL);
- mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger);
+ mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger,
+ mAppOpsManager);
loadStreamXml(baos, false, UserHandle.USER_ALL);
assertNull(mHelper.getNotificationDelegate(PKG_O, UID_O));
@@ -2360,7 +2373,8 @@
mHelper.setNotificationDelegate(PKG_O, UID_O, "other", 53);
ByteArrayOutputStream baos = writeXmlAndPurge(PKG_O, UID_O, false, UserHandle.USER_ALL);
- mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger);
+ mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger,
+ mAppOpsManager);
loadStreamXml(baos, false, UserHandle.USER_ALL);
assertEquals("other", mHelper.getNotificationDelegate(PKG_O, UID_O));
@@ -2372,7 +2386,8 @@
mHelper.revokeNotificationDelegate(PKG_O, UID_O);
ByteArrayOutputStream baos = writeXmlAndPurge(PKG_O, UID_O, false, UserHandle.USER_ALL);
- mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger);
+ mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger,
+ mAppOpsManager);
loadStreamXml(baos, false, UserHandle.USER_ALL);
assertNull(mHelper.getNotificationDelegate(PKG_O, UID_O));
@@ -2384,7 +2399,8 @@
mHelper.toggleNotificationDelegate(PKG_O, UID_O, false);
ByteArrayOutputStream baos = writeXmlAndPurge(PKG_O, UID_O, false, UserHandle.USER_ALL);
- mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger);
+ mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger,
+ mAppOpsManager);
loadStreamXml(baos, false, UserHandle.USER_ALL);
// appears disabled
@@ -2402,7 +2418,8 @@
mHelper.revokeNotificationDelegate(PKG_O, UID_O);
ByteArrayOutputStream baos = writeXmlAndPurge(PKG_O, UID_O, false, UserHandle.USER_ALL);
- mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger);
+ mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger,
+ mAppOpsManager);
loadStreamXml(baos, false, UserHandle.USER_ALL);
// appears disabled
@@ -2417,17 +2434,74 @@
@Test
public void testBubblePreference_defaults() throws Exception {
- assertEquals(mHelper.getBubblePreference(PKG_O, UID_O), BUBBLE_PREFERENCE_NONE);
+ assertEquals(BUBBLE_PREFERENCE_NONE, mHelper.getBubblePreference(PKG_O, UID_O));
ByteArrayOutputStream baos = writeXmlAndPurge(PKG_O, UID_O, false, UserHandle.USER_ALL);
- mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger);
+ mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger,
+ mAppOpsManager);
loadStreamXml(baos, false, UserHandle.USER_ALL);
- assertEquals(mHelper.getBubblePreference(PKG_O, UID_O), BUBBLE_PREFERENCE_NONE);
+ assertEquals(BUBBLE_PREFERENCE_NONE, mHelper.getBubblePreference(PKG_O, UID_O));
assertEquals(0, mHelper.getAppLockedFields(PKG_O, UID_O));
}
@Test
+ public void testBubblePreference_upgradeWithSAWPermission() throws Exception {
+ when(mAppOpsManager.noteOpNoThrow(eq(OP_SYSTEM_ALERT_WINDOW), anyInt(),
+ anyString(), eq(null), anyString())).thenReturn(MODE_ALLOWED);
+
+ final String xml = "<ranking version=\"1\">\n"
+ + "<package name=\"" + PKG_O + "\" uid=\"" + UID_O + "\">\n"
+ + "<channel id=\"someId\" name=\"hi\""
+ + " importance=\"3\"/>"
+ + "</package>"
+ + "</ranking>";
+ XmlPullParser parser = Xml.newPullParser();
+ parser.setInput(new BufferedInputStream(new ByteArrayInputStream(xml.getBytes())),
+ null);
+ parser.nextTag();
+ mHelper.readXml(parser, false, UserHandle.USER_ALL);
+
+ assertEquals(BUBBLE_PREFERENCE_ALL, mHelper.getBubblePreference(PKG_O, UID_O));
+ assertEquals(0, mHelper.getAppLockedFields(PKG_O, UID_O));
+ }
+
+ @Test
+ public void testBubblePreference_upgradeWithSAWThenUserOverride() throws Exception {
+ when(mAppOpsManager.noteOpNoThrow(eq(OP_SYSTEM_ALERT_WINDOW), anyInt(),
+ anyString(), eq(null), anyString())).thenReturn(MODE_ALLOWED);
+
+ final String xml = "<ranking version=\"1\">\n"
+ + "<package name=\"" + PKG_O + "\" uid=\"" + UID_O + "\">\n"
+ + "<channel id=\"someId\" name=\"hi\""
+ + " importance=\"3\"/>"
+ + "</package>"
+ + "</ranking>";
+ XmlPullParser parser = Xml.newPullParser();
+ parser.setInput(new BufferedInputStream(new ByteArrayInputStream(xml.getBytes())),
+ null);
+ parser.nextTag();
+ mHelper.readXml(parser, false, UserHandle.USER_ALL);
+
+ assertEquals(BUBBLE_PREFERENCE_ALL, mHelper.getBubblePreference(PKG_O, UID_O));
+ assertEquals(0, mHelper.getAppLockedFields(PKG_O, UID_O));
+
+ mHelper.setBubblesAllowed(PKG_O, UID_O, BUBBLE_PREFERENCE_SELECTED);
+ assertEquals(BUBBLE_PREFERENCE_SELECTED, mHelper.getBubblePreference(PKG_O, UID_O));
+ assertEquals(PreferencesHelper.LockableAppFields.USER_LOCKED_BUBBLE,
+ mHelper.getAppLockedFields(PKG_O, UID_O));
+
+ ByteArrayOutputStream baos = writeXmlAndPurge(PKG_O, UID_O, false, UserHandle.USER_ALL);
+ mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger,
+ mAppOpsManager);
+ loadStreamXml(baos, false, UserHandle.USER_ALL);
+
+ assertEquals(BUBBLE_PREFERENCE_SELECTED, mHelper.getBubblePreference(PKG_O, UID_O));
+ assertEquals(PreferencesHelper.LockableAppFields.USER_LOCKED_BUBBLE,
+ mHelper.getAppLockedFields(PKG_O, UID_O));
+ }
+
+ @Test
public void testBubblePreference_xml() throws Exception {
mHelper.setBubblesAllowed(PKG_O, UID_O, BUBBLE_PREFERENCE_NONE);
assertEquals(mHelper.getBubblePreference(PKG_O, UID_O), BUBBLE_PREFERENCE_NONE);
@@ -2435,7 +2509,8 @@
mHelper.getAppLockedFields(PKG_O, UID_O));
ByteArrayOutputStream baos = writeXmlAndPurge(PKG_O, UID_O, false, UserHandle.USER_ALL);
- mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger);
+ mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger,
+ mAppOpsManager);
loadStreamXml(baos, false, UserHandle.USER_ALL);
assertEquals(mHelper.getBubblePreference(PKG_O, UID_O), BUBBLE_PREFERENCE_NONE);
@@ -2949,7 +3024,8 @@
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.REQUIRE_SHORTCUTS_FOR_CONVERSATIONS, 0);
- mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger);
+ mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger,
+ mAppOpsManager);
final String xml = "<ranking version=\"1\">\n"
+ "<package name=\"" + PKG_O + "\" uid=\"" + UID_O + "\" >\n"
@@ -2969,7 +3045,8 @@
public void testPlaceholderConversationId_shortcutRequired() throws Exception {
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.REQUIRE_SHORTCUTS_FOR_CONVERSATIONS, 1);
- mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger);
+ mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger,
+ mAppOpsManager);
final String xml = "<ranking version=\"1\">\n"
+ "<package name=\"" + PKG_O + "\" uid=\"" + UID_O + "\" >\n"
@@ -2989,7 +3066,8 @@
public void testNormalConversationId_shortcutRequired() throws Exception {
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.REQUIRE_SHORTCUTS_FOR_CONVERSATIONS, 1);
- mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger);
+ mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger,
+ mAppOpsManager);
final String xml = "<ranking version=\"1\">\n"
+ "<package name=\"" + PKG_O + "\" uid=\"" + UID_O + "\" >\n"
@@ -3009,7 +3087,8 @@
public void testNoConversationId_shortcutRequired() throws Exception {
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.REQUIRE_SHORTCUTS_FOR_CONVERSATIONS, 1);
- mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger);
+ mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper, mLogger,
+ mAppOpsManager);
final String xml = "<ranking version=\"1\">\n"
+ "<package name=\"" + PKG_O + "\" uid=\"" + UID_O + "\" >\n"
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/ShortcutHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/ShortcutHelperTest.java
index 50fb9b4..f7304bd 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/ShortcutHelperTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/ShortcutHelperTest.java
@@ -16,7 +16,11 @@
package com.android.server.notification;
+import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -25,6 +29,7 @@
import android.app.Notification;
import android.content.pm.LauncherApps;
import android.content.pm.ShortcutInfo;
+import android.content.pm.ShortcutServiceInternal;
import android.os.UserHandle;
import android.service.notification.StatusBarNotification;
import android.test.suitebuilder.annotation.SmallTest;
@@ -58,6 +63,8 @@
@Mock
ShortcutHelper.ShortcutListener mShortcutListener;
@Mock
+ ShortcutServiceInternal mShortcutServiceInternal;
+ @Mock
NotificationRecord mNr;
@Mock
Notification mNotif;
@@ -72,7 +79,8 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
- mShortcutHelper = new ShortcutHelper(mLauncherApps, mShortcutListener);
+ mShortcutHelper = new ShortcutHelper(
+ mLauncherApps, mShortcutListener, mShortcutServiceInternal);
when(mNr.getKey()).thenReturn(KEY);
when(mNr.getSbn()).thenReturn(mSbn);
when(mSbn.getPackageName()).thenReturn(PKG);
@@ -138,4 +146,80 @@
callback.onShortcutsChanged(PKG, shortcutInfos, mock(UserHandle.class));
verify(mShortcutListener).onShortcutRemoved(mNr.getKey());
}
+
+ @Test
+ public void testGetValidShortcutInfo_noMatchingShortcut() {
+ when(mLauncherApps.getShortcuts(any(), any())).thenReturn(null);
+ when(mShortcutServiceInternal.isSharingShortcut(anyInt(), anyString(), anyString(),
+ anyString(), anyInt(), any())).thenReturn(true);
+
+ assertThat(mShortcutHelper.getValidShortcutInfo("a", "p", UserHandle.SYSTEM)).isNull();
+ }
+
+ @Test
+ public void testGetValidShortcutInfo_nullShortcut() {
+ ArrayList<ShortcutInfo> shortcuts = new ArrayList<>();
+ shortcuts.add(null);
+ when(mLauncherApps.getShortcuts(any(), any())).thenReturn(shortcuts);
+ when(mShortcutServiceInternal.isSharingShortcut(anyInt(), anyString(), anyString(),
+ anyString(), anyInt(), any())).thenReturn(true);
+
+ assertThat(mShortcutHelper.getValidShortcutInfo("a", "p", UserHandle.SYSTEM)).isNull();
+ }
+
+ @Test
+ public void testGetValidShortcutInfo_notLongLived() {
+ ShortcutInfo si = mock(ShortcutInfo.class);
+ when(si.isLongLived()).thenReturn(false);
+ when(si.isEnabled()).thenReturn(true);
+ ArrayList<ShortcutInfo> shortcuts = new ArrayList<>();
+ shortcuts.add(si);
+ when(mLauncherApps.getShortcuts(any(), any())).thenReturn(shortcuts);
+ when(mShortcutServiceInternal.isSharingShortcut(anyInt(), anyString(), anyString(),
+ anyString(), anyInt(), any())).thenReturn(true);
+
+ assertThat(mShortcutHelper.getValidShortcutInfo("a", "p", UserHandle.SYSTEM)).isNull();
+ }
+
+ @Test
+ public void testGetValidShortcutInfo_notSharingShortcut() {
+ ShortcutInfo si = mock(ShortcutInfo.class);
+ when(si.isLongLived()).thenReturn(true);
+ when(si.isEnabled()).thenReturn(true);
+ ArrayList<ShortcutInfo> shortcuts = new ArrayList<>();
+ shortcuts.add(si);
+ when(mLauncherApps.getShortcuts(any(), any())).thenReturn(shortcuts);
+ when(mShortcutServiceInternal.isSharingShortcut(anyInt(), anyString(), anyString(),
+ anyString(), anyInt(), any())).thenReturn(false);
+
+ assertThat(mShortcutHelper.getValidShortcutInfo("a", "p", UserHandle.SYSTEM)).isNull();
+ }
+
+ @Test
+ public void testGetValidShortcutInfo_notEnabled() {
+ ShortcutInfo si = mock(ShortcutInfo.class);
+ when(si.isLongLived()).thenReturn(true);
+ when(si.isEnabled()).thenReturn(false);
+ ArrayList<ShortcutInfo> shortcuts = new ArrayList<>();
+ shortcuts.add(si);
+ when(mLauncherApps.getShortcuts(any(), any())).thenReturn(shortcuts);
+ when(mShortcutServiceInternal.isSharingShortcut(anyInt(), anyString(), anyString(),
+ anyString(), anyInt(), any())).thenReturn(true);
+
+ assertThat(mShortcutHelper.getValidShortcutInfo("a", "p", UserHandle.SYSTEM)).isNull();
+ }
+
+ @Test
+ public void testGetValidShortcutInfo_isValid() {
+ ShortcutInfo si = mock(ShortcutInfo.class);
+ when(si.isLongLived()).thenReturn(true);
+ when(si.isEnabled()).thenReturn(true);
+ ArrayList<ShortcutInfo> shortcuts = new ArrayList<>();
+ shortcuts.add(si);
+ when(mLauncherApps.getShortcuts(any(), any())).thenReturn(shortcuts);
+ when(mShortcutServiceInternal.isSharingShortcut(anyInt(), anyString(), anyString(),
+ anyString(), anyInt(), any())).thenReturn(true);
+
+ assertThat(mShortcutHelper.getValidShortcutInfo("a", "p", UserHandle.SYSTEM)).isSameAs(si);
+ }
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
index bc66fa7..5bbb4d9 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
@@ -1324,7 +1324,7 @@
display.rotateInDifferentOrientationIfNeeded(mActivity);
display.mFixedRotationLaunchingApp = mActivity;
- displayRotation.updateRotationUnchecked(false /* forceUpdate */);
+ displayRotation.updateRotationUnchecked(true /* forceUpdate */);
assertTrue(displayRotation.isRotatingSeamlessly());
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java
index 4532400..17dd26e 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java
@@ -89,13 +89,13 @@
public void testOnPictureInPictureRequested() throws RemoteException {
final ActivityStack stack = new StackBuilder(mRootWindowContainer).build();
final ActivityRecord activity = stack.getBottomMostTask().getTopNonFinishingActivity();
- ClientLifecycleManager lifecycleManager = mService.getLifecycleManager();
- doNothing().when(lifecycleManager).scheduleTransaction(any());
+ final ClientLifecycleManager mockLifecycleManager = mock(ClientLifecycleManager.class);
+ doReturn(mockLifecycleManager).when(mService).getLifecycleManager();
doReturn(true).when(activity).checkEnterPictureInPictureState(anyString(), anyBoolean());
mService.requestPictureInPictureMode(activity.token);
- verify(lifecycleManager).scheduleTransaction(mClientTransactionCaptor.capture());
+ verify(mockLifecycleManager).scheduleTransaction(mClientTransactionCaptor.capture());
final ClientTransaction transaction = mClientTransactionCaptor.getValue();
// Check that only an enter pip request item callback was scheduled.
assertEquals(1, transaction.getCallbacks().size());
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
index 3f47b87..daff149 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
@@ -65,6 +65,7 @@
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
@@ -84,12 +85,16 @@
import android.util.DisplayMetrics;
import android.view.DisplayCutout;
import android.view.Gravity;
+import android.view.IDisplayWindowInsetsController;
import android.view.IDisplayWindowRotationCallback;
import android.view.IDisplayWindowRotationController;
import android.view.ISystemGestureExclusionListener;
import android.view.IWindowManager;
+import android.view.InsetsSourceControl;
+import android.view.InsetsState;
import android.view.MotionEvent;
import android.view.Surface;
+import android.view.SurfaceControl.Transaction;
import android.view.ViewRootImpl;
import android.view.WindowManager;
import android.view.test.InsetsModeSession;
@@ -809,25 +814,19 @@
@Test
public void testComputeImeParent_app() throws Exception {
- try (final InsetsModeSession session =
- new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_IME)) {
- final DisplayContent dc = createNewDisplay();
- dc.mInputMethodTarget = createWindow(null, TYPE_BASE_APPLICATION, "app");
- assertEquals(dc.mInputMethodTarget.mActivityRecord.getSurfaceControl(),
- dc.computeImeParent());
- }
+ final DisplayContent dc = createNewDisplay();
+ dc.mInputMethodTarget = createWindow(null, TYPE_BASE_APPLICATION, "app");
+ assertEquals(dc.mInputMethodTarget.mActivityRecord.getSurfaceControl(),
+ dc.computeImeParent());
}
@Test
public void testComputeImeParent_app_notFullscreen() throws Exception {
- try (final InsetsModeSession session =
- new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_IME)) {
- final DisplayContent dc = createNewDisplay();
- dc.mInputMethodTarget = createWindow(null, TYPE_STATUS_BAR, "app");
- dc.mInputMethodTarget.setWindowingMode(
- WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY);
- assertEquals(dc.getImeContainer().getParentSurfaceControl(), dc.computeImeParent());
- }
+ final DisplayContent dc = createNewDisplay();
+ dc.mInputMethodTarget = createWindow(null, TYPE_STATUS_BAR, "app");
+ dc.mInputMethodTarget.setWindowingMode(
+ WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY);
+ assertEquals(dc.getImeContainer().getParentSurfaceControl(), dc.computeImeParent());
}
@Test
@@ -842,12 +841,61 @@
@Test
public void testComputeImeParent_noApp() throws Exception {
- try (final InsetsModeSession session =
- new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_IME)) {
- final DisplayContent dc = createNewDisplay();
- dc.mInputMethodTarget = createWindow(null, TYPE_STATUS_BAR, "statusBar");
- assertEquals(dc.getImeContainer().getParentSurfaceControl(), dc.computeImeParent());
- }
+ final DisplayContent dc = createNewDisplay();
+ dc.mInputMethodTarget = createWindow(null, TYPE_STATUS_BAR, "statusBar");
+ assertEquals(dc.getImeContainer().getParentSurfaceControl(), dc.computeImeParent());
+ }
+
+ @Test
+ public void testComputeImeControlTarget() throws Exception {
+ final DisplayContent dc = createNewDisplay();
+ dc.setRemoteInsetsController(createDisplayWindowInsetsController());
+ dc.mInputMethodInputTarget = createWindow(null, TYPE_BASE_APPLICATION, "app");
+ dc.mInputMethodTarget = dc.mInputMethodInputTarget;
+ assertEquals(dc.mInputMethodInputTarget, dc.computeImeControlTarget());
+ }
+
+ @Test
+ public void testComputeImeControlTarget_splitscreen() throws Exception {
+ final DisplayContent dc = createNewDisplay();
+ dc.mInputMethodInputTarget = createWindow(null, TYPE_BASE_APPLICATION, "app");
+ dc.mInputMethodInputTarget.setWindowingMode(
+ WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY);
+ dc.mInputMethodTarget = dc.mInputMethodInputTarget;
+ dc.setRemoteInsetsController(createDisplayWindowInsetsController());
+ assertNotEquals(dc.mInputMethodInputTarget, dc.computeImeControlTarget());
+ }
+
+ @Test
+ public void testComputeImeControlTarget_notMatchParentBounds() throws Exception {
+ spyOn(mAppWindow.mActivityRecord);
+ doReturn(false).when(mAppWindow.mActivityRecord).matchParentBounds();
+ mDisplayContent.mInputMethodInputTarget = mAppWindow;
+ mDisplayContent.mInputMethodTarget = mDisplayContent.mInputMethodInputTarget;
+ mDisplayContent.setRemoteInsetsController(createDisplayWindowInsetsController());
+ assertEquals(mAppWindow, mDisplayContent.computeImeControlTarget());
+ }
+
+ private IDisplayWindowInsetsController createDisplayWindowInsetsController() {
+ return new IDisplayWindowInsetsController.Stub() {
+
+ @Override
+ public void insetsChanged(InsetsState insetsState) throws RemoteException {
+ }
+
+ @Override
+ public void insetsControlChanged(InsetsState insetsState,
+ InsetsSourceControl[] insetsSourceControls) throws RemoteException {
+ }
+
+ @Override
+ public void showInsets(int i, boolean b) throws RemoteException {
+ }
+
+ @Override
+ public void hideInsets(int i, boolean b) throws RemoteException {
+ }
+ };
}
@Test
@@ -1040,6 +1088,12 @@
assertEquals(config90.orientation, app.getConfiguration().orientation);
assertEquals(config90.windowConfiguration.getBounds(), app.getBounds());
+ // Make wallaper laid out with the fixed rotation transform.
+ final WindowToken wallpaperToken = mWallpaperWindow.mToken;
+ wallpaperToken.linkFixedRotationTransform(app);
+ mWallpaperWindow.mLayoutNeeded = true;
+ performLayout(mDisplayContent);
+
// Force the negative offset to verify it can be updated.
mWallpaperWindow.mWinAnimator.mXOffset = mWallpaperWindow.mWinAnimator.mYOffset = -1;
assertTrue(mDisplayContent.mWallpaperController.updateWallpaperOffset(mWallpaperWindow,
@@ -1047,6 +1101,13 @@
assertThat(mWallpaperWindow.mWinAnimator.mXOffset).isGreaterThan(-1);
assertThat(mWallpaperWindow.mWinAnimator.mYOffset).isGreaterThan(-1);
+ // The wallpaper need to animate with transformed position, so its surface position should
+ // not be reset.
+ final Transaction t = wallpaperToken.getPendingTransaction();
+ spyOn(t);
+ mWallpaperWindow.mToken.onAnimationLeashCreated(t, null /* leash */);
+ verify(t, never()).setPosition(any(), eq(0), eq(0));
+
mDisplayContent.mAppTransition.notifyAppTransitionFinishedLocked(app.token);
// The animation in old rotation should be cancelled.
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
index ec77be8..473c1c5 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
@@ -145,9 +145,5 @@
Rect bounds = new Rect(10, 10, 100, 200);
task.setBounds(bounds);
assertEquals(new Point(bounds.left, bounds.top), task.getLastSurfacePosition());
-
- Rect dispBounds = new Rect(20, 30, 110, 220);
- task.setOverrideDisplayedBounds(dispBounds);
- assertEquals(new Point(dispBounds.left, dispBounds.top), task.getLastSurfacePosition());
}
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowFrameTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowFrameTests.java
index 7be05a3..eb2aa41 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowFrameTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowFrameTests.java
@@ -310,27 +310,6 @@
assertContentFrame(w, new Rect(resolvedTaskBounds.left, resolvedTaskBounds.top,
resolvedTaskBounds.right - contentInsetRight,
resolvedTaskBounds.bottom - contentInsetBottom));
-
- pf.set(0, 0, logicalWidth, logicalHeight);
- // If we set displayed bounds, the insets will be computed with the main task bounds
- // but the frame will be positioned according to the displayed bounds.
- final int insetLeft = logicalWidth / 5;
- final int insetTop = logicalHeight / 5;
- final int insetRight = insetLeft + (resolvedTaskBounds.right - resolvedTaskBounds.left);
- final int insetBottom = insetTop + (resolvedTaskBounds.bottom - resolvedTaskBounds.top);
- task.setOverrideDisplayedBounds(resolvedTaskBounds);
- task.setBounds(insetLeft, insetTop, insetRight, insetBottom);
- windowFrames.setFrames(pf, pf, cf, cf, pf, cf);
- w.computeFrameLw();
- assertEquals(resolvedTaskBounds, w.getFrameLw());
- assertEquals(0, w.getRelativeFrameLw().left);
- assertEquals(0, w.getRelativeFrameLw().top);
- contentInsetRight = insetRight - cfRight;
- contentInsetBottom = insetBottom - cfBottom;
- assertContentInset(w, 0, 0, contentInsetRight, contentInsetBottom);
- assertContentFrame(w, new Rect(resolvedTaskBounds.left, resolvedTaskBounds.top,
- resolvedTaskBounds.right - contentInsetRight,
- resolvedTaskBounds.bottom - contentInsetBottom));
}
@Test
@@ -460,33 +439,6 @@
}
@Test
- @FlakyTest(bugId = 130388666)
- public void testDisplayCutout_tempDisplayedBounds() {
- // Regular fullscreen task and window
- WindowState w = createWindow();
- final Task task = w.getTask();
- task.setBounds(new Rect(0, 0, 1000, 2000));
- task.setOverrideDisplayedBounds(new Rect(0, -500, 1000, 1500));
- w.mAttrs.gravity = Gravity.LEFT | Gravity.TOP;
-
- final Rect pf = new Rect(0, -500, 1000, 1500);
- // Create a display cutout of size 50x50, aligned top-center
- final WmDisplayCutout cutout = WmDisplayCutout.computeSafeInsets(
- fromBoundingRect(500, 0, 550, 50, BOUNDS_POSITION_TOP),
- pf.width(), pf.height());
-
- final WindowFrames windowFrames = w.getWindowFrames();
- windowFrames.setFrames(pf, pf, pf, pf, pf, pf);
- windowFrames.setDisplayCutout(cutout);
- w.computeFrameLw();
-
- assertEquals(w.getWmDisplayCutout().getDisplayCutout().getSafeInsetTop(), 50);
- assertEquals(w.getWmDisplayCutout().getDisplayCutout().getSafeInsetBottom(), 0);
- assertEquals(w.getWmDisplayCutout().getDisplayCutout().getSafeInsetLeft(), 0);
- assertEquals(w.getWmDisplayCutout().getDisplayCutout().getSafeInsetRight(), 0);
- }
-
- @Test
public void testFreeformContentInsets() {
removeGlobalMinSizeRestriction();
// fullscreen task doesn't use bounds for computeFrame
diff --git a/startop/iorap/functional_tests/src/com/google/android/startop/iorap/IorapWorkFlowTest.java b/startop/iorap/functional_tests/src/com/google/android/startop/iorap/IorapWorkFlowTest.java
index c35dd3b..5352be6 100644
--- a/startop/iorap/functional_tests/src/com/google/android/startop/iorap/IorapWorkFlowTest.java
+++ b/startop/iorap/functional_tests/src/com/google/android/startop/iorap/IorapWorkFlowTest.java
@@ -397,7 +397,7 @@
public LogcatTimestamp() throws Exception{
long currentTimeMillis = System.currentTimeMillis();
epochTime = String.format(
- "%d.%d", currentTimeMillis/1000, currentTimeMillis%1000);
+ "%d.%03d", currentTimeMillis/1000, currentTimeMillis%1000);
Log.i(TAG, "Current logcat timestamp is " + epochTime);
}
diff --git a/telephony/java/android/telephony/data/DataCallResponse.java b/telephony/java/android/telephony/data/DataCallResponse.java
index a116c07..242c2e9 100644
--- a/telephony/java/android/telephony/data/DataCallResponse.java
+++ b/telephony/java/android/telephony/data/DataCallResponse.java
@@ -80,7 +80,6 @@
private final int mMtu;
private final int mMtuV4;
private final int mMtuV6;
- private final int mVersion;
/**
* @param cause Data call fail cause. {@link DataFailCause#NONE} indicates no error.
@@ -126,9 +125,7 @@
? new ArrayList<>() : new ArrayList<>(gatewayAddresses);
mPcscfAddresses = (pcscfAddresses == null)
? new ArrayList<>() : new ArrayList<>(pcscfAddresses);
- mMtu = mtu;
- mMtuV4 = mMtuV6 = 0;
- mVersion = 0;
+ mMtu = mMtuV4 = mMtuV6 = mtu;
}
/** @hide */
@@ -136,7 +133,7 @@
@LinkStatus int linkStatus, @ProtocolType int protocolType,
@Nullable String interfaceName, @Nullable List<LinkAddress> addresses,
@Nullable List<InetAddress> dnsAddresses, @Nullable List<InetAddress> gatewayAddresses,
- @Nullable List<InetAddress> pcscfAddresses, int mtuV4, int mtuV6, int version) {
+ @Nullable List<InetAddress> pcscfAddresses, int mtu, int mtuV4, int mtuV6) {
mCause = cause;
mSuggestedRetryTime = suggestedRetryTime;
mId = id;
@@ -151,10 +148,9 @@
? new ArrayList<>() : new ArrayList<>(gatewayAddresses);
mPcscfAddresses = (pcscfAddresses == null)
? new ArrayList<>() : new ArrayList<>(pcscfAddresses);
- mMtu = 0;
+ mMtu = mtu;
mMtuV4 = mtuV4;
mMtuV6 = mtuV6;
- mVersion = version;
}
/** @hide */
@@ -177,7 +173,6 @@
mMtu = source.readInt();
mMtuV4 = source.readInt();
mMtuV6 = source.readInt();
- mVersion = source.readInt();
}
/**
@@ -247,7 +242,7 @@
*/
@Deprecated
public int getMtu() {
- return mVersion < 5 ? mMtu : 0;
+ return mMtu;
}
/**
@@ -256,7 +251,7 @@
* Zero or negative values means network has either not sent a value or sent an invalid value.
*/
public int getMtuV4() {
- return mVersion < 5 ? 0 : mMtuV4;
+ return mMtuV4;
}
/**
@@ -264,7 +259,7 @@
* Zero or negative values means network has either not sent a value or sent an invalid value.
*/
public int getMtuV6() {
- return mVersion < 5 ? 0 : mMtuV6;
+ return mMtuV6;
}
@NonNull
@@ -282,10 +277,9 @@
.append(" dnses=").append(mDnsAddresses)
.append(" gateways=").append(mGatewayAddresses)
.append(" pcscf=").append(mPcscfAddresses)
- .append(" mtu=").append(mMtu)
- .append(" mtuV4=").append(mMtuV4)
- .append(" mtuV6=").append(mMtuV6)
- .append(" version=").append(mVersion)
+ .append(" mtu=").append(getMtu())
+ .append(" mtuV4=").append(getMtuV4())
+ .append(" mtuV6=").append(getMtuV6())
.append("}");
return sb.toString();
}
@@ -315,15 +309,14 @@
&& mPcscfAddresses.containsAll(other.mPcscfAddresses)
&& mMtu == other.mMtu
&& mMtuV4 == other.mMtuV4
- && mMtuV6 == other.mMtuV6
- && mVersion == other.mVersion;
+ && mMtuV6 == other.mMtuV6;
}
@Override
public int hashCode() {
return Objects.hash(mCause, mSuggestedRetryTime, mId, mLinkStatus, mProtocolType,
mInterfaceName, mAddresses, mDnsAddresses, mGatewayAddresses, mPcscfAddresses,
- mMtu, mMtuV4, mMtuV6, mVersion);
+ mMtu, mMtuV4, mMtuV6);
}
@Override
@@ -346,7 +339,6 @@
dest.writeInt(mMtu);
dest.writeInt(mMtuV4);
dest.writeInt(mMtuV6);
- dest.writeInt(mVersion);
}
public static final @android.annotation.NonNull Parcelable.Creator<DataCallResponse> CREATOR =
@@ -403,8 +395,6 @@
private int mMtuV6;
- private int mVersion;
-
/**
* Default constructor for Builder.
*/
@@ -563,29 +553,14 @@
}
/**
- * Set the IRadio version for this DataCallResponse
- * @hide
- */
- public @NonNull Builder setVersion(int version) {
- mVersion = version;
- return this;
- }
-
- /**
* Build the DataCallResponse.
*
* @return the DataCallResponse object.
*/
public @NonNull DataCallResponse build() {
- if (mVersion >= 5) {
- return new DataCallResponse(mCause, mSuggestedRetryTime, mId, mLinkStatus,
- mProtocolType, mInterfaceName, mAddresses, mDnsAddresses, mGatewayAddresses,
- mPcscfAddresses, mMtuV4, mMtuV6, mVersion);
- } else {
- return new DataCallResponse(mCause, mSuggestedRetryTime, mId, mLinkStatus,
- mProtocolType, mInterfaceName, mAddresses, mDnsAddresses, mGatewayAddresses,
- mPcscfAddresses, mMtu);
- }
+ return new DataCallResponse(mCause, mSuggestedRetryTime, mId, mLinkStatus,
+ mProtocolType, mInterfaceName, mAddresses, mDnsAddresses, mGatewayAddresses,
+ mPcscfAddresses, mMtu, mMtuV4, mMtuV6);
}
}
}
diff --git a/tests/AppLaunch/Android.bp b/tests/AppLaunch/Android.bp
index f90f26f..75db551 100644
--- a/tests/AppLaunch/Android.bp
+++ b/tests/AppLaunch/Android.bp
@@ -8,6 +8,8 @@
"android.test.base",
"android.test.runner",
],
- static_libs: ["androidx.test.rules"],
+ static_libs: [
+ "androidx.test.rules",
+ "ub-uiautomator"],
test_suites: ["device-tests"],
}
diff --git a/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java b/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java
index 2d2f4db..7d750b7 100644
--- a/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java
+++ b/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java
@@ -15,6 +15,8 @@
*/
package com.android.tests.applaunch;
+import static org.junit.Assert.assertNotNull;
+
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.ActivityManager;
@@ -29,7 +31,9 @@
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
+import android.os.SystemClock;
import android.os.UserHandle;
+import android.support.test.uiautomator.UiDevice;
import android.test.InstrumentationTestCase;
import android.test.InstrumentationTestRunner;
import android.util.Log;
@@ -46,6 +50,7 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
+import java.nio.file.Paths;
import java.time.format.DateTimeFormatter;
import java.time.ZonedDateTime;
import java.time.ZoneOffset;
@@ -67,6 +72,7 @@
* in the following format:
* -e apps <app name>^<result key>|<app name>^<result key>
*/
+@Deprecated
public class AppLaunch extends InstrumentationTestCase {
private static final int JOIN_TIMEOUT = 10000;
@@ -94,6 +100,9 @@
private static final String KEY_TRACE_DUMPINTERVAL = "tracedump_interval";
private static final String KEY_COMPILER_FILTERS = "compiler_filters";
private static final String KEY_FORCE_STOP_APP = "force_stop_app";
+ private static final String ENABLE_SCREEN_RECORDING = "enable_screen_recording";
+ private static final int MAX_RECORDING_PARTS = 5;
+ private static final long VIDEO_TAIL_BUFFER = 500;
private static final String SIMPLEPERF_APP_CMD =
"simpleperf --log fatal stat --csv -e cpu-cycles,major-faults --app %s & %s";
@@ -144,14 +153,17 @@
private Map<String, Intent> mNameToIntent;
private List<LaunchOrder> mLaunchOrderList = new ArrayList<LaunchOrder>();
+ private RecordingThread mCurrentThread;
private Map<String, String> mNameToResultKey;
private Map<String, Map<String, List<AppLaunchResult>>> mNameToLaunchTime;
private IActivityManager mAm;
+ private File launchSubDir = null;
private String mSimplePerfCmd = null;
private String mLaunchOrder = null;
private boolean mDropCache = false;
private int mLaunchIterations = 10;
private boolean mForceStopApp = true;
+ private boolean mEnableRecording = false;
private int mTraceLaunchCount = 0;
private String mTraceDirectoryStr = null;
private Bundle mResult = new Bundle();
@@ -166,6 +178,7 @@
private boolean mCycleCleanUp = false;
private boolean mTraceAll = false;
private boolean mIterationCycle = false;
+ private UiDevice mDevice;
enum IorapStatus {
UNDEFINED,
@@ -222,7 +235,7 @@
}
try {
- File launchSubDir = new File(launchRootDir, LAUNCH_SUB_DIRECTORY);
+ launchSubDir = new File(launchRootDir, LAUNCH_SUB_DIRECTORY);
if (!launchSubDir.exists() && !launchSubDir.mkdirs()) {
throw new IOException("Unable to create the lauch file sub directory "
@@ -923,9 +936,16 @@
mLaunchIterations = Integer.parseInt(launchIterations);
}
String forceStopApp = args.getString(KEY_FORCE_STOP_APP);
+
if (forceStopApp != null) {
mForceStopApp = Boolean.parseBoolean(forceStopApp);
}
+
+ String enableRecording = args.getString(ENABLE_SCREEN_RECORDING);
+
+ if (enableRecording != null) {
+ mEnableRecording = Boolean.parseBoolean(enableRecording);
+ }
String appList = args.getString(KEY_APPS);
if (appList == null)
return;
@@ -1038,6 +1058,9 @@
private AppLaunchResult startApp(String appName, String launchReason)
throws NameNotFoundException, RemoteException {
Log.i(TAG, "Starting " + appName);
+ if(mEnableRecording) {
+ startRecording(appName, launchReason);
+ }
Intent startIntent = mNameToIntent.get(appName);
if (startIntent == null) {
@@ -1053,6 +1076,10 @@
} catch (InterruptedException e) {
// ignore
}
+
+ if(mEnableRecording) {
+ stopRecording();
+ }
return runnable.getResult();
}
@@ -1360,4 +1387,126 @@
}
}
+
+ /**
+ * Start the screen recording while launching the app.
+ *
+ * @param appName
+ * @param launchReason
+ */
+ private void startRecording(String appName, String launchReason) {
+ Log.v(TAG, "Started Recording");
+ mCurrentThread = new RecordingThread("test-screen-record",
+ String.format("%s_%s", appName, launchReason));
+ mCurrentThread.start();
+ }
+
+ /**
+ * Stop already started screen recording.
+ */
+ private void stopRecording() {
+ // Skip if not directory.
+ if (launchSubDir == null) {
+ return;
+ }
+
+ // Add some extra time to the video end.
+ SystemClock.sleep(VIDEO_TAIL_BUFFER);
+ // Ctrl + C all screen record processes.
+ mCurrentThread.cancel();
+ // Wait for the thread to completely die.
+ try {
+ mCurrentThread.join();
+ } catch (InterruptedException ex) {
+ Log.e(TAG, "Interrupted when joining the recording thread.", ex);
+ }
+ Log.v(TAG, "Stopped Recording");
+ }
+
+ /** Returns the recording's name for part {@code part} of launch description. */
+ private File getOutputFile(String description, int part) {
+ // Omit the iteration number for the first iteration.
+ final String fileName =
+ String.format(
+ "%s-video%s.mp4", description, part == 1 ? "" : part);
+ return Paths.get(launchSubDir.getAbsolutePath(), description).toFile();
+ }
+
+
+ /**
+ * Encapsulates the start and stop screen recording logic.
+ * Copied from ScreenRecordCollector.
+ */
+ private class RecordingThread extends Thread {
+ private final String mDescription;
+ private final List<File> mRecordings;
+
+ private boolean mContinue;
+
+ public RecordingThread(String name, String description) {
+ super(name);
+
+ mContinue = true;
+ mRecordings = new ArrayList<>();
+
+ assertNotNull("No test description provided for recording.", description);
+ mDescription = description;
+ }
+
+ @Override
+ public void run() {
+ try {
+ // Start at i = 1 to encode parts as X.mp4, X2.mp4, X3.mp4, etc.
+ for (int i = 1; i <= MAX_RECORDING_PARTS && mContinue; i++) {
+ File output = getOutputFile(mDescription, i);
+ Log.d(
+ TAG,
+ String.format("Recording screen to %s", output.getAbsolutePath()));
+ mRecordings.add(output);
+ // Make sure not to block on this background command in the main thread so
+ // that the test continues to run, but block in this thread so it does not
+ // trigger a new screen recording session before the prior one completes.
+ getDevice().executeShellCommand(
+ String.format("screenrecord %s", output.getAbsolutePath()));
+ }
+ } catch (IOException e) {
+ throw new RuntimeException("Caught exception while screen recording.");
+ }
+ }
+
+ public void cancel() {
+ mContinue = false;
+
+ // Identify the screenrecord PIDs and send SIGINT 2 (Ctrl + C) to each.
+ try {
+ String[] pids = getDevice().executeShellCommand(
+ "pidof screenrecord").split(" ");
+ for (String pid : pids) {
+ // Avoid empty process ids, because of weird splitting behavior.
+ if (pid.isEmpty()) {
+ continue;
+ }
+
+ getDevice().executeShellCommand(
+ String.format("kill -2 %s", pid));
+ Log.d(
+ TAG,
+ String.format("Sent SIGINT 2 to screenrecord process (%s)", pid));
+ }
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to kill screen recording process.");
+ }
+ }
+
+ public List<File> getRecordings() {
+ return mRecordings;
+ }
+ }
+
+ public UiDevice getDevice() {
+ if (mDevice == null) {
+ mDevice = UiDevice.getInstance(getInstrumentation());
+ }
+ return mDevice;
+ }
}
diff --git a/tests/DozeTest/src/com/android/dreams/dozetest/DozeTestDream.java b/tests/DozeTest/src/com/android/dreams/dozetest/DozeTestDream.java
index f4f610b..fa292bd 100644
--- a/tests/DozeTest/src/com/android/dreams/dozetest/DozeTestDream.java
+++ b/tests/DozeTest/src/com/android/dreams/dozetest/DozeTestDream.java
@@ -100,7 +100,6 @@
public void onAttachedToWindow() {
super.onAttachedToWindow();
setInteractive(false);
- setLowProfile(true);
setFullscreen(true);
setContentView(R.layout.dream);
setScreenBright(false);
diff --git a/tests/net/java/com/android/server/net/NetworkStatsServiceTest.java b/tests/net/java/com/android/server/net/NetworkStatsServiceTest.java
index 6e63313..a1bb0d5 100644
--- a/tests/net/java/com/android/server/net/NetworkStatsServiceTest.java
+++ b/tests/net/java/com/android/server/net/NetworkStatsServiceTest.java
@@ -60,14 +60,13 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.annotation.NonNull;
-import android.annotation.Nullable;
import android.app.AlarmManager;
import android.app.usage.NetworkStatsManager;
import android.content.Context;
@@ -95,8 +94,6 @@
import android.os.Messenger;
import android.os.PowerManager;
import android.os.SimpleClock;
-import android.telephony.PhoneStateListener;
-import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import androidx.test.InstrumentationRegistry;
@@ -109,7 +106,7 @@
import com.android.server.net.NetworkStatsService.NetworkStatsSettings;
import com.android.server.net.NetworkStatsService.NetworkStatsSettings.Config;
import com.android.testutils.HandlerUtilsKt;
-import com.android.testutils.TestableNetworkStatsProvider;
+import com.android.testutils.TestableNetworkStatsProviderBinder;
import libcore.io.IoUtils;
@@ -126,6 +123,7 @@
import java.time.Clock;
import java.time.ZoneOffset;
import java.util.Objects;
+import java.util.concurrent.Executor;
/**
* Tests for {@link NetworkStatsService}.
@@ -168,14 +166,13 @@
private @Mock NetworkStatsSettings mSettings;
private @Mock IBinder mBinder;
private @Mock AlarmManager mAlarmManager;
- private @Mock TelephonyManager mTelephonyManager;
+ @Mock
+ private NetworkStatsSubscriptionsMonitor mNetworkStatsSubscriptionsMonitor;
private HandlerThread mHandlerThread;
private NetworkStatsService mService;
private INetworkStatsSession mSession;
private INetworkManagementEventObserver mNetworkObserver;
- @Nullable
- private PhoneStateListener mPhoneStateListener;
private final Clock mClock = new SimpleClock(ZoneOffset.UTC) {
@Override
@@ -203,8 +200,8 @@
mHandlerThread = new HandlerThread("HandlerThread");
final NetworkStatsService.Dependencies deps = makeDependencies();
mService = new NetworkStatsService(mServiceContext, mNetManager, mAlarmManager, wakeLock,
- mClock, mTelephonyManager, mSettings,
- mStatsFactory, new NetworkStatsObservers(), mStatsDir, getBaseDir(mStatsDir), deps);
+ mClock, mSettings, mStatsFactory, new NetworkStatsObservers(), mStatsDir,
+ getBaseDir(mStatsDir), deps);
mElapsedRealtime = 0L;
@@ -224,12 +221,6 @@
ArgumentCaptor.forClass(INetworkManagementEventObserver.class);
verify(mNetManager).registerObserver(networkObserver.capture());
mNetworkObserver = networkObserver.getValue();
-
- // Capture the phone state listener that created by service.
- final ArgumentCaptor<PhoneStateListener> phoneStateListenerCaptor =
- ArgumentCaptor.forClass(PhoneStateListener.class);
- verify(mTelephonyManager).listen(phoneStateListenerCaptor.capture(), anyInt());
- mPhoneStateListener = phoneStateListenerCaptor.getValue();
}
@NonNull
@@ -239,6 +230,14 @@
public HandlerThread makeHandlerThread() {
return mHandlerThread;
}
+
+ @Override
+ public NetworkStatsSubscriptionsMonitor makeSubscriptionsMonitor(
+ @NonNull Context context, @NonNull Executor executor,
+ @NonNull NetworkStatsService service) {
+
+ return mNetworkStatsSubscriptionsMonitor;
+ }
};
}
@@ -678,10 +677,9 @@
// TODO: support per IMSI state
private void setMobileRatTypeAndWaitForIdle(int ratType) {
- final ServiceState mockSs = mock(ServiceState.class);
- when(mockSs.getDataNetworkType()).thenReturn(ratType);
- mPhoneStateListener.onServiceStateChanged(mockSs);
-
+ when(mNetworkStatsSubscriptionsMonitor.getRatTypeForSubscriberId(anyString()))
+ .thenReturn(ratType);
+ mService.handleOnCollapsedRatTypeChanged();
HandlerUtilsKt.waitForIdle(mHandlerThread, WAIT_TIMEOUT);
}
@@ -1118,7 +1116,8 @@
expectNetworkStatsUidDetail(buildEmptyStats());
// Register custom provider and retrieve callback.
- final TestableNetworkStatsProvider provider = new TestableNetworkStatsProvider();
+ final TestableNetworkStatsProviderBinder provider =
+ new TestableNetworkStatsProviderBinder();
final INetworkStatsProviderCallback cb =
mService.registerNetworkStatsProvider("TEST", provider);
assertNotNull(cb);
@@ -1176,7 +1175,8 @@
mService.forceUpdateIfaces(NETWORKS_WIFI, states, getActiveIface(states), new VpnInfo[0]);
// Register custom provider and retrieve callback.
- final TestableNetworkStatsProvider provider = new TestableNetworkStatsProvider();
+ final TestableNetworkStatsProviderBinder provider =
+ new TestableNetworkStatsProviderBinder();
final INetworkStatsProviderCallback cb =
mService.registerNetworkStatsProvider("TEST", provider);
assertNotNull(cb);