Merge "Send widget registration broadcasts before BOOT_COMPLETE" into pi-dev
diff --git a/core/java/android/accessibilityservice/AccessibilityServiceInfo.java b/core/java/android/accessibilityservice/AccessibilityServiceInfo.java
index ed684d7..ecf6f12 100644
--- a/core/java/android/accessibilityservice/AccessibilityServiceInfo.java
+++ b/core/java/android/accessibilityservice/AccessibilityServiceInfo.java
@@ -29,7 +29,6 @@
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.hardware.fingerprint.FingerprintManager;
-import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
@@ -189,12 +188,10 @@
* content and also the accessibility service will receive accessibility events from
* them.
* <p>
- * <strong>Note:</strong> For accessibility services targeting API version
- * {@link Build.VERSION_CODES#JELLY_BEAN} or higher this flag has to be explicitly
- * set for the system to regard views that are not important for accessibility. For
- * accessibility services targeting API version lower than
- * {@link Build.VERSION_CODES#JELLY_BEAN} this flag is ignored and all views are
- * regarded for accessibility purposes.
+ * <strong>Note:</strong> For accessibility services targeting Android 4.1 (API level 16) or
+ * higher, this flag has to be explicitly set for the system to regard views that are not
+ * important for accessibility. For accessibility services targeting Android 4.0.4 (API level
+ * 15) or lower, this flag is ignored and all views are regarded for accessibility purposes.
* </p>
* <p>
* Usually views not important for accessibility are layout managers that do not
@@ -219,19 +216,19 @@
* flag does not guarantee that the device will not be in touch exploration
* mode since there may be another enabled service that requested it.
* <p>
- * For accessibility services targeting API version higher than
- * {@link Build.VERSION_CODES#JELLY_BEAN_MR1} that want to set
- * this flag have to declare this capability in their meta-data by setting
- * the attribute {@link android.R.attr#canRequestTouchExplorationMode
- * canRequestTouchExplorationMode} to true, otherwise this flag will
+ * For accessibility services targeting Android 4.3 (API level 18) or higher
+ * that want to set this flag have to declare this capability in their
+ * meta-data by setting the attribute
+ * {@link android.R.attr#canRequestTouchExplorationMode
+ * canRequestTouchExplorationMode} to true. Otherwise, this flag will
* be ignored. For how to declare the meta-data of a service refer to
* {@value AccessibilityService#SERVICE_META_DATA}.
* </p>
* <p>
- * Services targeting API version equal to or lower than
- * {@link Build.VERSION_CODES#JELLY_BEAN_MR1} will work normally, i.e.
- * the first time they are run, if this flag is specified, a dialog is
- * shown to the user to confirm enabling explore by touch.
+ * Services targeting Android 4.2.2 (API level 17) or lower will work
+ * normally. In other words, the first time they are run, if this flag is
+ * specified, a dialog is shown to the user to confirm enabling explore by
+ * touch.
* </p>
* @see android.R.styleable#AccessibilityService_canRequestTouchExplorationMode
*/
@@ -387,10 +384,10 @@
public int feedbackType;
/**
- * The timeout after the most recent event of a given type before an
+ * The timeout, in milliseconds, after the most recent event of a given type before an
* {@link AccessibilityService} is notified.
* <p>
- * <strong>Can be dynamically set at runtime.</strong>.
+ * <strong>Can be dynamically set at runtime.</strong>
* </p>
* <p>
* <strong>Note:</strong> The event notification timeout is useful to avoid propagating
diff --git a/core/java/android/app/ResourcesManager.java b/core/java/android/app/ResourcesManager.java
index 30256b4..8d0ad33 100644
--- a/core/java/android/app/ResourcesManager.java
+++ b/core/java/android/app/ResourcesManager.java
@@ -121,10 +121,13 @@
}
}
+ private static final boolean ENABLE_APK_ASSETS_CACHE = false;
+
/**
* The ApkAssets we are caching and intend to hold strong references to.
*/
- private final LruCache<ApkKey, ApkAssets> mLoadedApkAssets = new LruCache<>(3);
+ private final LruCache<ApkKey, ApkAssets> mLoadedApkAssets =
+ (ENABLE_APK_ASSETS_CACHE) ? new LruCache<>(3) : null;
/**
* The ApkAssets that are being referenced in the wild that we can reuse, even if they aren't
@@ -310,9 +313,12 @@
private @NonNull ApkAssets loadApkAssets(String path, boolean sharedLib, boolean overlay)
throws IOException {
final ApkKey newKey = new ApkKey(path, sharedLib, overlay);
- ApkAssets apkAssets = mLoadedApkAssets.get(newKey);
- if (apkAssets != null) {
- return apkAssets;
+ ApkAssets apkAssets = null;
+ if (mLoadedApkAssets != null) {
+ apkAssets = mLoadedApkAssets.get(newKey);
+ if (apkAssets != null) {
+ return apkAssets;
+ }
}
// Optimistically check if this ApkAssets exists somewhere else.
@@ -320,7 +326,10 @@
if (apkAssetsRef != null) {
apkAssets = apkAssetsRef.get();
if (apkAssets != null) {
- mLoadedApkAssets.put(newKey, apkAssets);
+ if (mLoadedApkAssets != null) {
+ mLoadedApkAssets.put(newKey, apkAssets);
+ }
+
return apkAssets;
} else {
// Clean up the reference.
@@ -335,7 +344,11 @@
} else {
apkAssets = ApkAssets.loadFromPath(path, false /*system*/, sharedLib);
}
- mLoadedApkAssets.put(newKey, apkAssets);
+
+ if (mLoadedApkAssets != null) {
+ mLoadedApkAssets.put(newKey, apkAssets);
+ }
+
mCachedApkAssets.put(newKey, new WeakReference<>(apkAssets));
return apkAssets;
}
@@ -434,18 +447,22 @@
pw.println("ResourcesManager:");
pw.increaseIndent();
- pw.print("cached apks: total=");
- pw.print(mLoadedApkAssets.size());
- pw.print(" created=");
- pw.print(mLoadedApkAssets.createCount());
- pw.print(" evicted=");
- pw.print(mLoadedApkAssets.evictionCount());
- pw.print(" hit=");
- pw.print(mLoadedApkAssets.hitCount());
- pw.print(" miss=");
- pw.print(mLoadedApkAssets.missCount());
- pw.print(" max=");
- pw.print(mLoadedApkAssets.maxSize());
+ if (mLoadedApkAssets != null) {
+ pw.print("cached apks: total=");
+ pw.print(mLoadedApkAssets.size());
+ pw.print(" created=");
+ pw.print(mLoadedApkAssets.createCount());
+ pw.print(" evicted=");
+ pw.print(mLoadedApkAssets.evictionCount());
+ pw.print(" hit=");
+ pw.print(mLoadedApkAssets.hitCount());
+ pw.print(" miss=");
+ pw.print(mLoadedApkAssets.missCount());
+ pw.print(" max=");
+ pw.print(mLoadedApkAssets.maxSize());
+ } else {
+ pw.print("cached apks: 0 [cache disabled]");
+ }
pw.println();
pw.print("total apks: ");
diff --git a/core/java/android/app/assist/AssistStructure.java b/core/java/android/app/assist/AssistStructure.java
index d568662..dd61f28 100644
--- a/core/java/android/app/assist/AssistStructure.java
+++ b/core/java/android/app/assist/AssistStructure.java
@@ -41,18 +41,23 @@
import java.util.List;
/**
- * Assist data automatically created by the platform's implementation of assist and autofill.
+ * <p>This API automatically creates assist data from the platform's
+ * implementation of assist and autofill.
*
* <p>The structure is used for assist purposes when created by
* {@link android.app.Activity#onProvideAssistData}, {@link View#onProvideStructure(ViewStructure)},
* or {@link View#onProvideVirtualStructure(ViewStructure)}.
*
- * <p>The structure is used for autofill purposes when created by
+ * <p>The structure is also used for autofill purposes when created by
* {@link View#onProvideAutofillStructure(ViewStructure, int)},
* or {@link View#onProvideAutofillVirtualStructure(ViewStructure, int)}.
*
- * <p>For performance reasons, some properties of the assist data might be available just for assist
- * or autofill purposes; in those case, the property availability will be document in its javadoc.
+ * <p>For performance reasons, some properties of the assist data might only be available for
+ * assist or autofill purposes. In those cases, a property's availability will be documented
+ * in its javadoc.
+ *
+ * <p>To learn about using Autofill in your app, read the
+ * <a href="/guide/topics/text/autofill">Autofill Framework</a> guides.
*/
public class AssistStructure implements Parcelable {
static final String TAG = "AssistStructure";
diff --git a/core/java/android/content/pm/ShortcutManager.java b/core/java/android/content/pm/ShortcutManager.java
index 25e0ccd..36849e6 100644
--- a/core/java/android/content/pm/ShortcutManager.java
+++ b/core/java/android/content/pm/ShortcutManager.java
@@ -20,7 +20,6 @@
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.annotation.UserIdInt;
-import android.app.Activity;
import android.app.usage.UsageStatsManager;
import android.content.Context;
import android.content.Intent;
@@ -29,256 +28,23 @@
import android.os.Build.VERSION_CODES;
import android.os.RemoteException;
import android.os.ServiceManager;
-import android.os.UserHandle;
import com.android.internal.annotations.VisibleForTesting;
import java.util.List;
/**
- * The ShortcutManager performs operations on an app's set of <em>shortcuts</em>. The
- * {@link ShortcutInfo} class contains information about each of the shortcuts themselves.
+ * <p><code>ShortcutManager</code> executes operations on an app's set of <i>shortcuts</i>, which
+ * represent specific tasks and actions that users can perform within your app. This page lists
+ * components of the <code>ShortcutManager</code> class that you can use to create and manage
+ * sets of shortcuts.
*
- * <p>An app's shortcuts represent specific tasks and actions that users can perform within your
- * app. When a user selects a shortcut in the currently-active launcher, your app opens an activity
- * other than the app's starting activity, provided that the currently-active launcher supports app
- * shortcuts.</p>
+ * <p>To learn about methods that retrieve information about a single shortcut—including
+ * identifiers, type, and status—read the <code>
+ * <a href="/reference/android/content/pm/ShortcutInfo.html">ShortcutInfo</a></code> reference.
*
- * <p>The types of shortcuts that you create for your app depend on the app's key use cases. For
- * example, an email app may publish the "compose new email" shortcut, which allows the app to
- * directly open the compose activity.</p>
- *
- * <p class="note"><b>Note:</b> Only main activities—activities that handle the
- * {@link Intent#ACTION_MAIN} action and the {@link Intent#CATEGORY_LAUNCHER} category—can
- * have shortcuts. If an app has multiple main activities, you need to define the set of shortcuts
- * for <em>each</em> activity.
- *
- * <p>This page discusses the implementation details of the <code>ShortcutManager</code> class. For
- * definitions of key terms and guidance on performing operations on shortcuts within your app, see
- * the <a href="/guide/topics/ui/shortcuts.html">App Shortcuts</a> feature guide.
- *
- * <h3>Shortcut characteristics</h3>
- *
- * This section describes in-depth details about each shortcut type's usage and availability.
- *
- * <p class="note"><b>Important security note:</b> All shortcut information is stored in
- * <a href="/training/articles/direct-boot.html">credential encrypted storage</a>, so your app
- * cannot access a user's shortcuts until after they've unlocked the device.
- *
- * <h4>Static and dynamic shortcuts</h4>
- *
- * <p>Static shortcuts and dynamic shortcuts are shown in a supported launcher when the user
- * performs a specific gesture. On currently-supported launchers, the gesture is a long-press on the
- * app's launcher icon, but the actual gesture may be different on other launcher apps.
- *
- * <p>The {@link LauncherApps} class provides APIs for launcher apps to access shortcuts.
- *
- * <h4>Pinned shortcuts</h4>
- *
- * <p>Because pinned shortcuts appear in the launcher itself, they're always visible. A pinned
- * shortcut is removed from the launcher only in the following situations:
- * <ul>
- * <li>The user removes it.
- * <li>The publisher app associated with the shortcut is uninstalled.
- * <li>The user selects <b>Clear data</b> from the publisher app's <i>Storage</i> screen, within
- * the system's <b>Settings</b> app.
- * </ul>
- *
- * <p>Because the system performs
- * <a href="/guide/topics/ui/shortcuts.html#backup-and-restore">backup and restore</a> on pinned
- * shortcuts automatically, these shortcuts' IDs should contain either stable, constant strings or
- * server-side identifiers, rather than identifiers generated locally that might not make sense on
- * other devices.
- *
- * <h3>Shortcut display order</h3>
- *
- * <p>When the launcher displays an app's shortcuts, they should appear in the following order:
- *
- * <ol>
- * <li><b>Static shortcuts:</b> Shortcuts whose {@link ShortcutInfo#isDeclaredInManifest()} method
- * returns {@code true}.</li>
- * <li><b>Dynamic shortcuts:</b> Shortcuts whose {@link ShortcutInfo#isDynamic()} method returns
- * {@code true}.</li>
- * </ol>
- *
- * <p>Within each shortcut type (static and dynamic), shortcuts are sorted in order of increasing
- * rank according to {@link ShortcutInfo#getRank()}.</p>
- *
- * <h4>Shortcut ranks</h4>
- *
- * <p>Shortcut ranks are non-negative, sequential integers that determine the order in which
- * shortcuts appear, assuming that the shortcuts are all in the same category. You can update ranks
- * of existing shortcuts when you call {@link #updateShortcuts(List)},
- * {@link #addDynamicShortcuts(List)}, or {@link #setDynamicShortcuts(List)}.
- *
- * <p class="note"><b>Note:</b> Ranks are auto-adjusted so that they're unique for each type of
- * shortcut (static or dynamic). For example, if there are 3 dynamic shortcuts with ranks 0, 1 and
- * 2, adding another dynamic shortcut with a rank of 1 represents a request to place this shortcut
- * at the second position. In response, the third and fourth shortcuts move closer to the bottom of
- * the shortcut list, with their ranks changing to 2 and 3, respectively.
- *
- * <h3>Options for static shortcuts</h3>
- *
- * The following list includes descriptions for the different attributes within a static shortcut.
- * You must provide a value for {@code android:shortcutId} and {@code android:shortcutShortLabel};
- * all other values are optional.
- *
- * <dl>
- * <dt>{@code android:shortcutId}</dt>
- * <dd><p>A string literal, which represents the shortcut when a {@code ShortcutManager} object
- * performs operations on it.</p>
- * <p class="note"><b>Note: </b>You cannot set this attribute's value to a resource string, such
- * as <code>@string/foo</code>.</p>
- * </dd>
- *
- * <dt>{@code android:enabled}</dt>
- * <dd><p>Whether the user can interact with the shortcut from a supported launcher.</p>
- * <p>The default value is {@code true}. If you set it to {@code false}, you should also set
- * {@code android:shortcutDisabledMessage} to a message that explains why you've disabled the
- * shortcut. If you don't think you need to provide such a message, it's easiest to just remove
- * the shortcut from the XML file entirely, rather than changing the values of the shortcut's
- * {@code android:enabled} and {@code android:shortcutDisabledMessage} attributes.
- * </dd>
- *
- * <dt>{@code android:icon}</dt>
- * <dd><p>The <a href="/topic/performance/graphics/index.html">bitmap</a> or
- * <a href="/guide/practices/ui_guidelines/icon_design_adaptive.html">adaptive icon</a> that the
- * launcher uses when displaying the shortcut to the user. This value can be either the path to an
- * image or the resource file that contains the image. Use adaptive icons whenever possible to
- * improve performance and consistency.</p>
- * <p class="note"><b>Note: </b>Shortcut icons cannot include
- * <a href="/training/material/drawables.html#DrawableTint">tints</a>.
- * </dd>
- *
- * <dt>{@code android:shortcutShortLabel}</dt>
- * <dd><p>A concise phrase that describes the shortcut's purpose. For more information, see
- * {@link ShortcutInfo.Builder#setShortLabel(CharSequence)}.</p>
- * <p class="note"><b>Note: </b>This attribute's value must be a resource string, such as
- * <code>@string/shortcut_short_label</code>.</p>
- * </dd>
- *
- * <dt>{@code android:shortcutLongLabel}</dt>
- * <dd><p>An extended phrase that describes the shortcut's purpose. If there's enough space, the
- * launcher displays this value instead of {@code android:shortcutShortLabel}. For more
- * information, see {@link ShortcutInfo.Builder#setLongLabel(CharSequence)}.</p>
- * <p class="note"><b>Note: </b>This attribute's value must be a resource string, such as
- * <code>@string/shortcut_long_label</code>.</p>
- * </dd>
- *
- * <dt>{@code android:shortcutDisabledMessage}</dt>
- * <dd><p>The message that appears in a supported launcher when the user attempts to launch a
- * disabled shortcut. The message should explain to the user why the shortcut is now disabled.
- * This attribute's value has no effect if {@code android:enabled} is {@code true}.</p>
- * <p class="note"><b>Note: </b>This attribute's value must be a resource string, such as
- * <code>@string/shortcut_disabled_message</code>.</p>
- * </dd>
- * </dl>
- *
- * <h3>Inner elements that define static shortcuts</h3>
- *
- * <p>The XML file that lists an app's static shortcuts supports the following elements inside each
- * {@code <shortcut>} element. You must include an {@code intent} inner element for each
- * static shortcut that you define.</p>
- *
- * <dl>
- * <dt>{@code intent}</dt>
- * <dd><p>The action that the system launches when the user selects the shortcut. This intent must
- * provide a value for the {@code android:action} attribute.</p>
- * <p>You can provide multiple intents for a single shortcut. If you do so, the last defined
- * activity is launched, and the other activities are placed in the
- * <a href="/guide/components/tasks-and-back-stack.html">back stack</a>. See
- * <a href="/guide/topics/ui/shortcuts.html#static">Using Static Shortcuts</a> and the
- * {@link android.app.TaskStackBuilder} class reference for details.</p>
- * <p class="note"><b>Note:</b> This {@code intent} element cannot include string resources.</p>
- * <p>To learn more about how to configure intents, see
- * <a href="{@docRoot}guide/topics/ui/settings.html#Intents">Using intents</a>.</p>
- * </dd>
- *
- * <dt>{@code categories}</dt>
- * <dd><p>Provides a grouping for the types of actions that your app's shortcuts perform, such as
- * creating new chat messages.</p>
- * <p>For a list of supported shortcut categories, see the {@link ShortcutInfo} class reference
- * for a list of supported shortcut categories.
- * </dd>
- * </dl>
- *
- * <h3>Updating shortcuts</h3>
- *
- * <p>Each app's launcher icon can contain at most {@link #getMaxShortcutCountPerActivity()} number
- * of static and dynamic shortcuts combined. There is no limit to the number of pinned shortcuts
- * that an app can create, though.
- *
- * <p>When a dynamic shortcut is pinned, even when the publisher removes it as a dynamic shortcut,
- * the pinned shortcut is still visible and launchable. This allows an app to have more than
- * {@link #getMaxShortcutCountPerActivity()} number of shortcuts.
- *
- * <p>As an example, suppose {@link #getMaxShortcutCountPerActivity()} is 5:
- * <ol>
- * <li>A chat app publishes 5 dynamic shortcuts for the 5 most recent
- * conversations (c1, c2, ..., c5).
- *
- * <li>The user pins all 5 of the shortcuts.
- *
- * <li>Later, the user has started 3 additional conversations (c6, c7, and c8), so the publisher
- * app re-publishes its dynamic shortcuts. The new dynamic shortcut list is: c4, c5, ..., c8.
- * <p>The publisher app has to remove c1, c2, and c3 because it can't have more than 5 dynamic
- * shortcuts. However, c1, c2, and c3 are still pinned shortcuts that the user can access and
- * launch.
- * <p>At this point, the user can access a total of 8 shortcuts that link to activities in the
- * publisher app, including the 3 pinned shortcuts, even though an app can have at most 5
- * dynamic shortcuts.
- *
- * <li>The app can use {@link #updateShortcuts(List)} to update <em>any</em> of the existing
- * 8 shortcuts, when, for example, the chat peers' icons have changed.
- * <p>The {@link #addDynamicShortcuts(List)} and {@link #setDynamicShortcuts(List)} methods
- * can also be used to update existing shortcuts with the same IDs, but they <b>cannot</b> be
- * used for updating non-dynamic, pinned shortcuts because these 2 methods try to convert the
- * given lists of shortcuts to dynamic shortcuts.
- * </ol>
- *
- * <h3>Shortcut intents</h3>
- *
- * <p>
- * Dynamic shortcuts can be published with any set of {@link Intent#addFlags Intent} flags.
- * Typically, {@link Intent#FLAG_ACTIVITY_CLEAR_TASK} is specified, possibly along with other
- * flags; otherwise, if the app is already running, the app is simply brought to
- * the foreground, and the target activity might not appear.
- *
- * <p>Static shortcuts <b>cannot</b> have custom intent flags.
- * The first intent of a static shortcut will always have {@link Intent#FLAG_ACTIVITY_NEW_TASK}
- * and {@link Intent#FLAG_ACTIVITY_CLEAR_TASK} set. This means, when the app is already running, all
- * the existing activities in your app are destroyed when a static shortcut is launched.
- * If this behavior is not desirable, you can use a <em>trampoline activity</em>, or an invisible
- * activity that starts another activity in {@link Activity#onCreate}, then calls
- * {@link Activity#finish()}:
- * <ol>
- * <li>In the <code>AndroidManifest.xml</code> file, the trampoline activity should include the
- * attribute assignment {@code android:taskAffinity=""}.
- * <li>In the shortcuts resource file, the intent within the static shortcut should reference
- * the trampoline activity.
- * </ol>
- *
- * <h3>Rate limiting</h3>
- *
- * <p>When <a href="/guide/topics/ui/shortcuts.html#rate-limit">rate limiting</a> is active,
- * {@link #isRateLimitingActive()} returns {@code true}.
- *
- * <p>Rate limiting is reset upon certain events, so even background apps can call these APIs until
- * the rate limit is reached again. These events include the following:
- * <ul>
- * <li>An app comes to the foreground.
- * <li>The system locale changes.
- * <li>The user performs the <a href="/guide/topics/ui/notifiers/notifications.html#direct">inline
- * reply</a> action on a notification.
- * </ul>
- *
- * <h3>Handling system locale changes</h3>
- *
- * <p>Apps should update dynamic and pinned shortcuts when they receive the
- * {@link Intent#ACTION_LOCALE_CHANGED} broadcast, indicating that the system locale has changed.
- * <p>When the system locale changes, <a href="/guide/topics/ui/shortcuts.html#rate-limit">rate
- * limiting</a> is reset, so even background apps can add and update dynamic shortcuts until the
- * rate limit is reached again.
+ * <p>For guidance about using shortcuts, see
+ * <a href="/guide/topics/ui/shortcuts/index.html">App shortcuts</a>.
*
* <h3>Retrieving class instances</h3>
* <!-- Provides a heading for the content filled in by the @SystemService annotation below -->
@@ -458,8 +224,9 @@
}
/**
- * Disable pinned shortcuts. For more details, see the Javadoc for the {@link ShortcutManager}
- * class.
+ * Disable pinned shortcuts. For more details, read
+ * <a href="/guide/topics/ui/shortcuts/managing-shortcuts.html#disable-shortcuts">
+ * Disable shortcuts</a>.
*
* @throws IllegalArgumentException If trying to disable immutable shortcuts.
*
@@ -498,7 +265,9 @@
/**
* Disable pinned shortcuts, showing the user a custom error message when they try to select
* the disabled shortcuts.
- * For more details, see the Javadoc for the {@link ShortcutManager} class.
+ * For more details, read
+ * <a href="/guide/topics/ui/shortcuts/managing-shortcuts.html#disable-shortcuts">
+ * Disable shortcuts</a>.
*
* @throws IllegalArgumentException If trying to disable immutable shortcuts.
*
@@ -586,7 +355,8 @@
/**
* Return {@code true} when rate-limiting is active for the caller app.
*
- * <p>See the class level javadoc for details.
+ * <p>For details, see <a href="/guide/topics/ui/shortcuts/managing-shortcuts#rate-limiting">
+ * Rate limiting</a>.
*
* @throws IllegalStateException when the user is locked.
*/
@@ -632,7 +402,9 @@
* Apps that publish shortcuts should call this method whenever the user
* selects the shortcut containing the given ID or when the user completes
* an action in the app that is equivalent to selecting the shortcut.
- * For more details, see the Javadoc for the {@link ShortcutManager} class
+ * For more details, read about
+ * <a href="/guide/topics/ui/shortcuts/managing-shortcuts.html#track-usage">
+ * tracking shortcut usage</a>.
*
* <p>The information is accessible via {@link UsageStatsManager#queryEvents}
* Typically, launcher apps use this information to build a prediction model
@@ -700,7 +472,9 @@
* @param resultIntent If not null, this intent will be sent when the shortcut is pinned.
* Use {@link android.app.PendingIntent#getIntentSender()} to create an {@link IntentSender}.
* To avoid background execution limits, use an unexported, manifest-declared receiver.
- * For more details, see the overview documentation for the {@link ShortcutManager} class.
+ * For more details, see
+ * <a href="/guide/topics/ui/shortcuts/creating-shortcuts.html#pinned">
+ * Creating pinned shortcuts</a>.
*
* @return {@code TRUE} if the launcher supports this feature. Note the API will return without
* waiting for the user to respond, so getting {@code TRUE} from this API does *not* mean
diff --git a/core/java/android/database/sqlite/SQLiteDatabase.java b/core/java/android/database/sqlite/SQLiteDatabase.java
index 6adae25..96cd043 100644
--- a/core/java/android/database/sqlite/SQLiteDatabase.java
+++ b/core/java/android/database/sqlite/SQLiteDatabase.java
@@ -1748,7 +1748,8 @@
executeSql(sql, bindArgs);
}
- private int executeSql(String sql, Object[] bindArgs) throws SQLException {
+ /** {@hide} */
+ public int executeSql(String sql, Object[] bindArgs) throws SQLException {
acquireReference();
try {
final int statementType = DatabaseUtils.getSqlStatementType(sql);
diff --git a/core/java/android/database/sqlite/SQLiteGlobal.java b/core/java/android/database/sqlite/SQLiteGlobal.java
index d6d9764..e6b6acf 100644
--- a/core/java/android/database/sqlite/SQLiteGlobal.java
+++ b/core/java/android/database/sqlite/SQLiteGlobal.java
@@ -39,11 +39,18 @@
public final class SQLiteGlobal {
private static final String TAG = "SQLiteGlobal";
+ /** @hide */
+ public static final String SYNC_MODE_FULL = "FULL";
+
private static final Object sLock = new Object();
+
private static int sDefaultPageSize;
private static native int nativeReleaseMemory();
+ /** @hide */
+ public static volatile String sDefaultSyncMode;
+
private SQLiteGlobal() {
}
@@ -103,6 +110,11 @@
* Gets the default database synchronization mode when WAL is not in use.
*/
public static String getDefaultSyncMode() {
+ // Use the FULL synchronous mode for system processes by default.
+ String defaultMode = sDefaultSyncMode;
+ if (defaultMode != null) {
+ return defaultMode;
+ }
return SystemProperties.get("debug.sqlite.syncmode",
Resources.getSystem().getString(
com.android.internal.R.string.db_default_sync_mode));
@@ -112,6 +124,11 @@
* Gets the database synchronization mode when in WAL mode.
*/
public static String getWALSyncMode() {
+ // Use the FULL synchronous mode for system processes by default.
+ String defaultMode = sDefaultSyncMode;
+ if (defaultMode != null) {
+ return defaultMode;
+ }
return SystemProperties.get("debug.sqlite.wal.syncmode",
Resources.getSystem().getString(
com.android.internal.R.string.db_wal_sync_mode));
diff --git a/core/java/android/database/sqlite/SQLiteQueryBuilder.java b/core/java/android/database/sqlite/SQLiteQueryBuilder.java
index c6c676f..442e4cf 100644
--- a/core/java/android/database/sqlite/SQLiteQueryBuilder.java
+++ b/core/java/android/database/sqlite/SQLiteQueryBuilder.java
@@ -16,17 +16,25 @@
package android.database.sqlite;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.content.ContentValues;
import android.database.Cursor;
import android.database.DatabaseUtils;
+import android.os.Build;
import android.os.CancellationSignal;
import android.os.OperationCanceledException;
import android.provider.BaseColumns;
import android.text.TextUtils;
import android.util.Log;
+import libcore.util.EmptyArray;
+
+import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Objects;
import java.util.Set;
import java.util.regex.Pattern;
@@ -95,9 +103,6 @@
if (mWhereClause == null) {
mWhereClause = new StringBuilder(inWhere.length() + 16);
}
- if (mWhereClause.length() == 0) {
- mWhereClause.append('(');
- }
mWhereClause.append(inWhere);
}
@@ -115,9 +120,6 @@
if (mWhereClause == null) {
mWhereClause = new StringBuilder(inWhere.length() + 16);
}
- if (mWhereClause.length() == 0) {
- mWhereClause.append('(');
- }
DatabaseUtils.appendEscapedSQLString(mWhereClause, inWhere);
}
@@ -376,6 +378,11 @@
return null;
}
+ final String sql;
+ final String unwrappedSql = buildQuery(
+ projectionIn, selection, groupBy, having,
+ sortOrder, limit);
+
if (mStrict && selection != null && selection.length() > 0) {
// Validate the user-supplied selection to detect syntactic anomalies
// in the selection string that could indicate a SQL injection attempt.
@@ -384,25 +391,167 @@
// originally specified. An attacker cannot create an expression that
// would escape the SQL expression while maintaining balanced parentheses
// in both the wrapped and original forms.
- String sqlForValidation = buildQuery(projectionIn, "(" + selection + ")", groupBy,
+
+ // NOTE: The ordering of the below operations is important; we must
+ // execute the wrapped query to ensure the untrusted clause has been
+ // fully isolated.
+
+ // Validate the unwrapped query
+ db.validateSql(unwrappedSql, cancellationSignal); // will throw if query is invalid
+
+ // Execute wrapped query for extra protection
+ final String wrappedSql = buildQuery(projectionIn, wrap(selection), groupBy,
having, sortOrder, limit);
- db.validateSql(sqlForValidation, cancellationSignal); // will throw if query is invalid
+ sql = wrappedSql;
+ } else {
+ // Execute unwrapped query
+ sql = unwrappedSql;
}
- String sql = buildQuery(
- projectionIn, selection, groupBy, having,
- sortOrder, limit);
-
+ final String[] sqlArgs = selectionArgs;
if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Performing query: " + sql);
+ if (Build.IS_DEBUGGABLE) {
+ Log.d(TAG, sql + " with args " + Arrays.toString(sqlArgs));
+ } else {
+ Log.d(TAG, sql);
+ }
}
return db.rawQueryWithFactory(
- mFactory, sql, selectionArgs,
+ mFactory, sql, sqlArgs,
SQLiteDatabase.findEditTable(mTables),
cancellationSignal); // will throw if query is invalid
}
/**
+ * Perform an update by combining all current settings and the
+ * information passed into this method.
+ *
+ * @param db the database to update on
+ * @param selection A filter declaring which rows to return,
+ * formatted as an SQL WHERE clause (excluding the WHERE
+ * itself). Passing null will return all rows for the given URL.
+ * @param selectionArgs You may include ?s in selection, which
+ * will be replaced by the values from selectionArgs, in order
+ * that they appear in the selection. The values will be bound
+ * as Strings.
+ * @return the number of rows updated
+ * @hide
+ */
+ public int update(@NonNull SQLiteDatabase db, @NonNull ContentValues values,
+ @Nullable String selection, @Nullable String[] selectionArgs) {
+ Objects.requireNonNull(mTables, "No tables defined");
+ Objects.requireNonNull(db, "No database defined");
+ Objects.requireNonNull(values, "No values defined");
+
+ final String sql;
+ final String unwrappedSql = buildUpdate(values, selection);
+
+ if (mStrict) {
+ // Validate the user-supplied selection to detect syntactic anomalies
+ // in the selection string that could indicate a SQL injection attempt.
+ // The idea is to ensure that the selection clause is a valid SQL expression
+ // by compiling it twice: once wrapped in parentheses and once as
+ // originally specified. An attacker cannot create an expression that
+ // would escape the SQL expression while maintaining balanced parentheses
+ // in both the wrapped and original forms.
+
+ // NOTE: The ordering of the below operations is important; we must
+ // execute the wrapped query to ensure the untrusted clause has been
+ // fully isolated.
+
+ // Validate the unwrapped query
+ db.validateSql(unwrappedSql, null); // will throw if query is invalid
+
+ // Execute wrapped query for extra protection
+ final String wrappedSql = buildUpdate(values, wrap(selection));
+ sql = wrappedSql;
+ } else {
+ // Execute unwrapped query
+ sql = unwrappedSql;
+ }
+
+ if (selectionArgs == null) {
+ selectionArgs = EmptyArray.STRING;
+ }
+ final String[] rawKeys = values.keySet().toArray(EmptyArray.STRING);
+ final int valuesLength = rawKeys.length;
+ final Object[] sqlArgs = new Object[valuesLength + selectionArgs.length];
+ for (int i = 0; i < sqlArgs.length; i++) {
+ if (i < valuesLength) {
+ sqlArgs[i] = values.get(rawKeys[i]);
+ } else {
+ sqlArgs[i] = selectionArgs[i - valuesLength];
+ }
+ }
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ if (Build.IS_DEBUGGABLE) {
+ Log.d(TAG, sql + " with args " + Arrays.toString(sqlArgs));
+ } else {
+ Log.d(TAG, sql);
+ }
+ }
+ return db.executeSql(sql, sqlArgs);
+ }
+
+ /**
+ * Perform a delete by combining all current settings and the
+ * information passed into this method.
+ *
+ * @param db the database to delete on
+ * @param selection A filter declaring which rows to return,
+ * formatted as an SQL WHERE clause (excluding the WHERE
+ * itself). Passing null will return all rows for the given URL.
+ * @param selectionArgs You may include ?s in selection, which
+ * will be replaced by the values from selectionArgs, in order
+ * that they appear in the selection. The values will be bound
+ * as Strings.
+ * @return the number of rows deleted
+ * @hide
+ */
+ public int delete(@NonNull SQLiteDatabase db, @Nullable String selection,
+ @Nullable String[] selectionArgs) {
+ Objects.requireNonNull(mTables, "No tables defined");
+ Objects.requireNonNull(db, "No database defined");
+
+ final String sql;
+ final String unwrappedSql = buildDelete(selection);
+
+ if (mStrict) {
+ // Validate the user-supplied selection to detect syntactic anomalies
+ // in the selection string that could indicate a SQL injection attempt.
+ // The idea is to ensure that the selection clause is a valid SQL expression
+ // by compiling it twice: once wrapped in parentheses and once as
+ // originally specified. An attacker cannot create an expression that
+ // would escape the SQL expression while maintaining balanced parentheses
+ // in both the wrapped and original forms.
+
+ // NOTE: The ordering of the below operations is important; we must
+ // execute the wrapped query to ensure the untrusted clause has been
+ // fully isolated.
+
+ // Validate the unwrapped query
+ db.validateSql(unwrappedSql, null); // will throw if query is invalid
+
+ // Execute wrapped query for extra protection
+ final String wrappedSql = buildDelete(wrap(selection));
+ sql = wrappedSql;
+ } else {
+ // Execute unwrapped query
+ sql = unwrappedSql;
+ }
+
+ final String[] sqlArgs = selectionArgs;
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ if (Build.IS_DEBUGGABLE) {
+ Log.d(TAG, sql + " with args " + Arrays.toString(sqlArgs));
+ } else {
+ Log.d(TAG, sql);
+ }
+ }
+ return db.executeSql(sql, sqlArgs);
+ }
+
+ /**
* Construct a SELECT statement suitable for use in a group of
* SELECT statements that will be joined through UNION operators
* in buildUnionQuery.
@@ -434,28 +583,10 @@
String[] projectionIn, String selection, String groupBy,
String having, String sortOrder, String limit) {
String[] projection = computeProjection(projectionIn);
-
- StringBuilder where = new StringBuilder();
- boolean hasBaseWhereClause = mWhereClause != null && mWhereClause.length() > 0;
-
- if (hasBaseWhereClause) {
- where.append(mWhereClause.toString());
- where.append(')');
- }
-
- // Tack on the user's selection, if present.
- if (selection != null && selection.length() > 0) {
- if (hasBaseWhereClause) {
- where.append(" AND ");
- }
-
- where.append('(');
- where.append(selection);
- where.append(')');
- }
+ String where = computeWhere(selection);
return buildQueryString(
- mDistinct, mTables, projection, where.toString(),
+ mDistinct, mTables, projection, where,
groupBy, having, sortOrder, limit);
}
@@ -472,6 +603,42 @@
return buildQuery(projectionIn, selection, groupBy, having, sortOrder, limit);
}
+ /** {@hide} */
+ public String buildUpdate(ContentValues values, String selection) {
+ if (values == null || values.size() == 0) {
+ throw new IllegalArgumentException("Empty values");
+ }
+
+ StringBuilder sql = new StringBuilder(120);
+ sql.append("UPDATE ");
+ sql.append(mTables);
+ sql.append(" SET ");
+
+ final String[] rawKeys = values.keySet().toArray(EmptyArray.STRING);
+ for (int i = 0; i < rawKeys.length; i++) {
+ if (i > 0) {
+ sql.append(',');
+ }
+ sql.append(rawKeys[i]);
+ sql.append("=?");
+ }
+
+ final String where = computeWhere(selection);
+ appendClause(sql, " WHERE ", where);
+ return sql.toString();
+ }
+
+ /** {@hide} */
+ public String buildDelete(String selection) {
+ StringBuilder sql = new StringBuilder(120);
+ sql.append("DELETE FROM ");
+ sql.append(mTables);
+
+ final String where = computeWhere(selection);
+ appendClause(sql, " WHERE ", where);
+ return sql.toString();
+ }
+
/**
* Construct a SELECT statement suitable for use in a group of
* SELECT statements that will be joined through UNION operators
@@ -645,4 +812,37 @@
}
return null;
}
+
+ private @Nullable String computeWhere(@Nullable String selection) {
+ final boolean hasInternal = !TextUtils.isEmpty(mWhereClause);
+ final boolean hasExternal = !TextUtils.isEmpty(selection);
+
+ if (hasInternal || hasExternal) {
+ final StringBuilder where = new StringBuilder();
+ if (hasInternal) {
+ where.append('(').append(mWhereClause).append(')');
+ }
+ if (hasInternal && hasExternal) {
+ where.append(" AND ");
+ }
+ if (hasExternal) {
+ where.append('(').append(selection).append(')');
+ }
+ return where.toString();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Wrap given argument in parenthesis, unless it's {@code null} or
+ * {@code ()}, in which case return it verbatim.
+ */
+ private @Nullable String wrap(@Nullable String arg) {
+ if (TextUtils.isEmpty(arg)) {
+ return arg;
+ } else {
+ return "(" + arg + ")";
+ }
+ }
}
diff --git a/core/java/android/hardware/camera2/CameraMetadata.java b/core/java/android/hardware/camera2/CameraMetadata.java
index 1275a85..caa99d5 100644
--- a/core/java/android/hardware/camera2/CameraMetadata.java
+++ b/core/java/android/hardware/camera2/CameraMetadata.java
@@ -819,11 +819,11 @@
* camera in the list of supported camera devices.</p>
* <p>This capability requires the camera device to support the following:</p>
* <ul>
- * <li>This camera device must list the following static metadata entries in {@link android.hardware.camera2.CameraCharacteristics }:<ul>
- * <li>android.logicalMultiCamera.physicalIds</li>
- * <li>{@link CameraCharacteristics#LOGICAL_MULTI_CAMERA_SENSOR_SYNC_TYPE android.logicalMultiCamera.sensorSyncType}</li>
- * </ul>
- * </li>
+ * <li>The IDs of underlying physical cameras are returned via
+ * {@link android.hardware.camera2.CameraCharacteristics#getPhysicalCameraIds }.</li>
+ * <li>This camera device must list static metadata
+ * {@link CameraCharacteristics#LOGICAL_MULTI_CAMERA_SENSOR_SYNC_TYPE android.logicalMultiCamera.sensorSyncType} in
+ * {@link android.hardware.camera2.CameraCharacteristics }.</li>
* <li>The underlying physical cameras' static metadata must list the following entries,
* so that the application can correlate pixels from the physical streams:<ul>
* <li>{@link CameraCharacteristics#LENS_POSE_REFERENCE android.lens.poseReference}</li>
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index 2de07b5..de25fd2 100644
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -624,7 +624,8 @@
* October 2013: Android 4.4, KitKat, another tasty treat.
*
* <p>Applications targeting this or a later release will get these
- * new changes in behavior:</p>
+ * new changes in behavior. For more information about this release, see the
+ * <a href="/about/versions/kitkat/">Android KitKat overview</a>.</p>
* <ul>
* <li> The default result of
* {@link android.preference.PreferenceActivity#isValidFragment(String)
@@ -674,7 +675,8 @@
* November 2014: Lollipop. A flat one with beautiful shadows. But still tasty.
*
* <p>Applications targeting this or a later release will get these
- * new changes in behavior:</p>
+ * new changes in behavior. For more information about this release, see the
+ * <a href="/about/versions/lollipop/">Android Lollipop overview</a>.</p>
* <ul>
* <li> {@link android.content.Context#bindService Context.bindService} now
* requires an explicit Intent, and will throw an exception if given an implicit
@@ -703,6 +705,8 @@
/**
* March 2015: Lollipop with an extra sugar coating on the outside!
+ * For more information about this release, see the
+ * <a href="/about/versions/android-5.1">Android 5.1 APIs</a>.
*/
public static final int LOLLIPOP_MR1 = 22;
@@ -710,7 +714,8 @@
* M is for Marshmallow!
*
* <p>Applications targeting this or a later release will get these
- * new changes in behavior:</p>
+ * new changes in behavior. For more information about this release, see the
+ * <a href="/about/versions/marshmallow/">Android 6.0 Marshmallow overview</a>.</p>
* <ul>
* <li> Runtime permissions. Dangerous permissions are no longer granted at
* install time, but must be requested by the application at runtime through
@@ -741,7 +746,8 @@
* N is for Nougat.
*
* <p>Applications targeting this or a later release will get these
- * new changes in behavior:</p>
+ * new changes in behavior. For more information about this release, see
+ * the <a href="/about/versions/nougat/">Android Nougat overview</a>.</p>
* <ul>
* <li> {@link android.app.DownloadManager.Request#setAllowedNetworkTypes
* DownloadManager.Request.setAllowedNetworkTypes}
@@ -791,7 +797,9 @@
public static final int N = 24;
/**
- * N MR1: Nougat++.
+ * N MR1: Nougat++. For more information about this release, see
+ * <a href="/about/versions/nougat/android-7.1">Android 7.1 for
+ * Developers</a>.
*/
public static final int N_MR1 = 25;
@@ -799,7 +807,8 @@
* O.
*
* <p>Applications targeting this or a later release will get these
- * new changes in behavior:</p>
+ * new changes in behavior. For more information about this release, see
+ * the <a href="/about/versions/oreo/">Android Oreo overview</a>.</p>
* <ul>
* <li><a href="{@docRoot}about/versions/oreo/background.html">Background execution limits</a>
* are applied to the application.</li>
@@ -888,13 +897,16 @@
* O MR1.
*
* <p>Applications targeting this or a later release will get these
- * new changes in behavior:</p>
+ * new changes in behavior. For more information about this release, see
+ * <a href="/about/versions/oreo/android-8.1">Android 8.1 features and
+ * APIs</a>.</p>
* <ul>
* <li>Apps exporting and linking to apk shared libraries must explicitly
* enumerate all signing certificates in a consistent order.</li>
* <li>{@link android.R.attr#screenOrientation} can not be used to request a fixed
* orientation if the associated activity is not fullscreen and opaque.</li>
* </ul>
+ *
*/
public static final int O_MR1 = 27;
@@ -902,7 +914,8 @@
* P.
*
* <p>Applications targeting this or a later release will get these
- * new changes in behavior:</p>
+ * new changes in behavior. For more information about this release, see the
+ * <a href="/about/versions/pie/">Android 9 Pie overview</a>.</p>
* <ul>
* <li>{@link android.app.Service#startForeground Service.startForeground} requires
* that apps hold the permission
@@ -910,6 +923,7 @@
* <li>{@link android.widget.LinearLayout} will always remeasure weighted children,
* even if there is no excess space.</li>
* </ul>
+ *
*/
public static final int P = 28;
}
diff --git a/core/java/android/os/Message.java b/core/java/android/os/Message.java
index b303e10..455d8ed 100644
--- a/core/java/android/os/Message.java
+++ b/core/java/android/os/Message.java
@@ -349,7 +349,7 @@
}
/**
- * Retrieve the a {@link android.os.Handler Handler} implementation that
+ * Retrieve the {@link android.os.Handler Handler} implementation that
* will receive this message. The object must implement
* {@link android.os.Handler#handleMessage(android.os.Message)
* Handler.handleMessage()}. Each Handler has its own name-space for
diff --git a/core/java/android/preference/PreferenceActivity.java b/core/java/android/preference/PreferenceActivity.java
index 02fa7ed..257f2cf 100644
--- a/core/java/android/preference/PreferenceActivity.java
+++ b/core/java/android/preference/PreferenceActivity.java
@@ -79,7 +79,7 @@
* <li>On a small screen it may display only the headers as a single list when first launched.
* Selecting one of the header items will only show the PreferenceFragment of that header (on
* Android N and lower a new Activity is launched).
- * <li>On a large screen in may display both the headers and current PreferenceFragment together as
+ * <li>On a large screen it may display both the headers and current PreferenceFragment together as
* panes. Selecting a header item switches to showing the correct PreferenceFragment for that item.
* </ul>
*
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 68c3111..fbe6f3e 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -10510,6 +10510,15 @@
public static final String ACTIVITY_MANAGER_CONSTANTS = "activity_manager_constants";
/**
+ * Feature flag to enable or disable the activity starts logging feature.
+ * Type: int (0 for false, 1 for true)
+ * Default: 0
+ * @hide
+ */
+ public static final String ACTIVITY_STARTS_LOGGING_ENABLED
+ = "activity_starts_logging_enabled";
+
+ /**
* App ops specific settings.
* This is encoded as a key=value list, separated by commas. Ex:
*
diff --git a/core/java/android/service/autofill/Dataset.java b/core/java/android/service/autofill/Dataset.java
index 5211767..f8408be 100644
--- a/core/java/android/service/autofill/Dataset.java
+++ b/core/java/android/service/autofill/Dataset.java
@@ -33,8 +33,13 @@
import java.util.regex.Pattern;
/**
- * A dataset object represents a group of fields (key / value pairs) used to autofill parts of a
- * screen.
+ * <p>A <code>Dataset</code> object represents a group of fields (key / value pairs) used
+ * to autofill parts of a screen.
+ *
+ * <p>For more information about the role of datasets in the autofill workflow, read
+ * <a href="/guide/topics/text/autofill-services">Build autofill services</a> and the
+ * <code><a href="/reference/android/service/autofill/AutofillService">AutofillService</a></code>
+ * documentation.
*
* <a name="BasicUsage"></a>
* <h3>Basic usage</h3>
@@ -88,10 +93,6 @@
* <li>All other datasets are hidden.
* </ol>
*
- * <a name="MoreInfo"></a>
- * <h3>More information</h3>
- * <p>See {@link android.service.autofill.AutofillService} for more information and examples about
- * the role of datasets in the autofill workflow.
*/
public final class Dataset implements Parcelable {
diff --git a/core/java/android/service/autofill/FillCallback.java b/core/java/android/service/autofill/FillCallback.java
index 0257891..1695c13 100644
--- a/core/java/android/service/autofill/FillCallback.java
+++ b/core/java/android/service/autofill/FillCallback.java
@@ -21,8 +21,11 @@
import android.os.RemoteException;
/**
- * Handles autofill requests from the {@link AutofillService} into the {@link Activity} being
- * autofilled.
+ * <p><code>FillCallback</code> handles autofill requests from the {@link AutofillService} into
+ * the {@link Activity} being autofilled.
+ *
+ * <p>To learn about using Autofill services in your app, read
+ * <a href="/guide/topics/text/autofill-services">Build autofill services</a>.
*/
public final class FillCallback {
private final IFillCallback mCallback;
diff --git a/core/java/android/text/Layout.java b/core/java/android/text/Layout.java
index 09af85d..c6f73cb 100644
--- a/core/java/android/text/Layout.java
+++ b/core/java/android/text/Layout.java
@@ -1583,7 +1583,8 @@
}
float get(final int offset) {
- if (mHorizontals == null) {
+ if (mHorizontals == null || offset < mLineStartOffset
+ || offset >= mLineStartOffset + mHorizontals.length) {
return getHorizontal(offset, mPrimary);
} else {
return mHorizontals[offset - mLineStartOffset];
diff --git a/core/java/android/view/ViewStructure.java b/core/java/android/view/ViewStructure.java
index 3f7ab2a..38dcdd3 100644
--- a/core/java/android/view/ViewStructure.java
+++ b/core/java/android/view/ViewStructure.java
@@ -33,9 +33,14 @@
import java.util.List;
/**
- * Container for storing additional per-view data generated by {@link View#onProvideStructure
+ * <p><code>ViewStructure</code> is a container for storing additional
+ * per-view data generated by {@link View#onProvideStructure
* View.onProvideStructure} and {@link View#onProvideAutofillStructure
* View.onProvideAutofillStructure}.
+ *
+ * <p>To learn more about using Autofill in your app, read the
+ * <a href="/guide/topics/text/autofill">Autofill Framework</a> guides.
+ *
*/
public abstract class ViewStructure {
diff --git a/core/java/android/view/accessibility/AccessibilityRecord.java b/core/java/android/view/accessibility/AccessibilityRecord.java
index 0a709f8..c2ddc92 100644
--- a/core/java/android/view/accessibility/AccessibilityRecord.java
+++ b/core/java/android/view/accessibility/AccessibilityRecord.java
@@ -625,7 +625,7 @@
}
/**
- * Sets the text before a change.
+ * Gets the text before a change.
*
* @return The text before the change.
*/
diff --git a/core/java/android/view/autofill/AutofillManager.java b/core/java/android/view/autofill/AutofillManager.java
index 7555fff..1b8660c 100644
--- a/core/java/android/view/autofill/AutofillManager.java
+++ b/core/java/android/view/autofill/AutofillManager.java
@@ -77,11 +77,16 @@
import sun.misc.Cleaner;
/**
- * The {@link AutofillManager} provides ways for apps and custom views to integrate with the
- * Autofill Framework lifecycle.
+ * <p>The {@link AutofillManager} class provides ways for apps and custom views to
+ * integrate with the Autofill Framework lifecycle.
+ *
+ * <p>To learn about using Autofill in your app, read
+ * the <a href="/guide/topics/text/autofill">Autofill Framework</a> guides.
+ *
+ * <h3 id="autofill-lifecycle">Autofill lifecycle</h3>
*
* <p>The autofill lifecycle starts with the creation of an autofill context associated with an
- * activity context; the autofill context is created when one of the following methods is called for
+ * activity context. The autofill context is created when one of the following methods is called for
* the first time in an activity context, and the current user has an enabled autofill service:
*
* <ul>
@@ -90,7 +95,7 @@
* <li>{@link #requestAutofill(View)}
* </ul>
*
- * <p>Tipically, the context is automatically created when the first view of the activity is
+ * <p>Typically, the context is automatically created when the first view of the activity is
* focused because {@code View.onFocusChanged()} indirectly calls
* {@link #notifyViewEntered(View)}. App developers can call {@link #requestAutofill(View)} to
* explicitly create it (for example, a custom view developer could offer a contextual menu action
@@ -134,7 +139,9 @@
* shows an autofill save UI if the value of savable views have changed. If the user selects the
* option to Save, the current value of the views is then sent to the autofill service.
*
- * <p>It is safe to call into its methods from any thread.
+ * <h3 id="additional-notes">Additional notes</h3>
+ *
+ * <p>It is safe to call <code>AutofillManager</code> methods from any thread.
*/
@SystemService(Context.AUTOFILL_MANAGER_SERVICE)
@RequiresFeature(PackageManager.FEATURE_AUTOFILL)
@@ -2292,7 +2299,15 @@
@Override
public AccessibilityEvent onAccessibilityEvent(AccessibilityEvent event,
boolean accessibilityEnabled, int relevantEventTypes) {
- switch (event.getEventType()) {
+ final int type = event.getEventType();
+ if (sVerbose) {
+ // NOTE: this is waaay spammy, but that's life.
+ Log.v(TAG, "onAccessibilityEvent(" + AccessibilityEvent.eventTypeToString(type)
+ + "): virtualId="
+ + AccessibilityNodeInfo.getVirtualDescendantId(event.getSourceNodeId())
+ + ", client=" + getClient());
+ }
+ switch (type) {
case AccessibilityEvent.TYPE_VIEW_FOCUSED: {
synchronized (mLock) {
if (mFocusedWindowId == event.getWindowId()
diff --git a/core/java/android/webkit/WebBackForwardList.java b/core/java/android/webkit/WebBackForwardList.java
index 0c34e3c..4d3bbe4 100644
--- a/core/java/android/webkit/WebBackForwardList.java
+++ b/core/java/android/webkit/WebBackForwardList.java
@@ -57,7 +57,8 @@
/**
* Clone the entire object to be used in the UI thread by clients of
* WebView. This creates a copy that should never be modified by any of the
- * webkit package classes.
+ * webkit package classes. On Android 4.4 and later there is no need to use
+ * this, as the object is already a read-only copy of the internal state.
*/
protected abstract WebBackForwardList clone();
}
diff --git a/core/java/android/webkit/WebHistoryItem.java b/core/java/android/webkit/WebHistoryItem.java
index 74db039..b9e7042 100644
--- a/core/java/android/webkit/WebHistoryItem.java
+++ b/core/java/android/webkit/WebHistoryItem.java
@@ -23,7 +23,7 @@
/**
* A convenience class for accessing fields in an entry in the back/forward list
* of a WebView. Each WebHistoryItem is a snapshot of the requested history
- * item. Each history item may be updated during the load of a page.
+ * item.
* @see WebBackForwardList
*/
public abstract class WebHistoryItem implements Cloneable {
@@ -44,8 +44,6 @@
* history item. See getTargetUrl() for the url that is the actual target of
* this history item.
* @return The base url of this history item.
- * Note: The VM ensures 32-bit atomic read/write operations so we don't have
- * to synchronize this method.
*/
public abstract String getUrl();
@@ -60,22 +58,20 @@
/**
* Return the document title of this history item.
* @return The document title of this history item.
- * Note: The VM ensures 32-bit atomic read/write operations so we don't have
- * to synchronize this method.
*/
public abstract String getTitle();
/**
* Return the favicon of this history item or {@code null} if no favicon was found.
* @return A Bitmap containing the favicon for this history item or {@code null}.
- * Note: The VM ensures 32-bit atomic read/write operations so we don't have
- * to synchronize this method.
*/
@Nullable
public abstract Bitmap getFavicon();
/**
- * Clone the history item for use by clients of WebView.
+ * Clone the history item for use by clients of WebView. On Android 4.4 and later
+ * there is no need to use this, as the object is already a read-only copy of the
+ * internal state.
*/
protected abstract WebHistoryItem clone();
}
diff --git a/core/java/android/webkit/WebSettings.java b/core/java/android/webkit/WebSettings.java
index cba11a8..a085395 100644
--- a/core/java/android/webkit/WebSettings.java
+++ b/core/java/android/webkit/WebSettings.java
@@ -987,7 +987,9 @@
* {@link PluginState#OFF}.
*
* @param state a PluginState value
- * @deprecated Plugins will not be supported in future, and should not be used.
+ * @deprecated Plugins are not supported in API level
+ * {@link android.os.Build.VERSION_CODES#KITKAT} or later;
+ * enabling plugins is a no-op.
*/
@Deprecated
public abstract void setPluginState(PluginState state);
@@ -1182,7 +1184,9 @@
*
* @return the plugin state as a {@link PluginState} value
* @see #setPluginState
- * @deprecated Plugins will not be supported in future, and should not be used.
+ * @deprecated Plugins are not supported in API level
+ * {@link android.os.Build.VERSION_CODES#KITKAT} or later;
+ * enabling plugins is a no-op.
*/
@Deprecated
public abstract PluginState getPluginState();
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 3452b0c..9371342 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -41,7 +41,6 @@
import android.os.RemoteException;
import android.os.StrictMode;
import android.print.PrintDocumentAdapter;
-import android.security.KeyChain;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseArray;
@@ -1419,9 +1418,8 @@
/**
* Clears the client certificate preferences stored in response
* to proceeding/cancelling client cert requests. Note that WebView
- * automatically clears these preferences when it receives a
- * {@link KeyChain#ACTION_STORAGE_CHANGED} intent. The preferences are
- * shared by all the WebViews that are created by the embedder application.
+ * automatically clears these preferences when the system keychain is updated.
+ * The preferences are shared by all the WebViews that are created by the embedder application.
*
* @param onCleared A runnable to be invoked when client certs are cleared.
* The runnable will be called in UI thread.
diff --git a/core/java/android/webkit/WebViewClient.java b/core/java/android/webkit/WebViewClient.java
index f686b66..bdd7a09 100644
--- a/core/java/android/webkit/WebViewClient.java
+++ b/core/java/android/webkit/WebViewClient.java
@@ -31,18 +31,25 @@
public class WebViewClient {
/**
- * Give the host application a chance to take over the control when a new
- * url is about to be loaded in the current WebView. If WebViewClient is not
- * provided, by default WebView will ask Activity Manager to choose the
- * proper handler for the url. If WebViewClient is provided, return {@code true}
- * means the host application handles the url, while return {@code false} means the
- * current WebView handles the url.
- * This method is not called for requests using the POST "method".
+ * Give the host application a chance to take control when a URL is about to be loaded in the
+ * current WebView. If a WebViewClient is not provided, by default WebView will ask Activity
+ * Manager to choose the proper handler for the URL. If a WebViewClient is provided, returning
+ * {@code true} causes the current WebView to abort loading the URL, while returning
+ * {@code false} causes the WebView to continue loading the URL as usual.
+ *
+ * <p class="note"><b>Note:</b> Do not call {@link WebView#loadUrl(String)} with the same
+ * URL and then return {@code true}. This unnecessarily cancels the current load and starts a
+ * new load with the same URL. The correct way to continue loading a given URL is to simply
+ * return {@code false}, without calling {@link WebView#loadUrl(String)}.
+ *
+ * <p class="note"><b>Note:</b> This method is not called for POST requests.
+ *
+ * <p class="note"><b>Note:</b> This method may be called for subframes and with non-HTTP(S)
+ * schemes; calling {@link WebView#loadUrl(String)} with such a URL will fail.
*
* @param view The WebView that is initiating the callback.
- * @param url The url to be loaded.
- * @return {@code true} if the host application wants to leave the current WebView
- * and handle the url itself, otherwise return {@code false}.
+ * @param url The URL to be loaded.
+ * @return {@code true} to cancel the current load, otherwise return {@code false}.
* @deprecated Use {@link #shouldOverrideUrlLoading(WebView, WebResourceRequest)
* shouldOverrideUrlLoading(WebView, WebResourceRequest)} instead.
*/
@@ -52,26 +59,25 @@
}
/**
- * Give the host application a chance to take over the control when a new
- * url is about to be loaded in the current WebView. If WebViewClient is not
- * provided, by default WebView will ask Activity Manager to choose the
- * proper handler for the url. If WebViewClient is provided, return {@code true}
- * means the host application handles the url, while return {@code false} means the
- * current WebView handles the url.
+ * Give the host application a chance to take control when a URL is about to be loaded in the
+ * current WebView. If a WebViewClient is not provided, by default WebView will ask Activity
+ * Manager to choose the proper handler for the URL. If a WebViewClient is provided, returning
+ * {@code true} causes the current WebView to abort loading the URL, while returning
+ * {@code false} causes the WebView to continue loading the URL as usual.
*
- * <p>Notes:
- * <ul>
- * <li>This method is not called for requests using the POST "method".</li>
- * <li>This method is also called for subframes with non-http schemes, thus it is
- * strongly disadvised to unconditionally call {@link WebView#loadUrl(String)}
- * with the request's url from inside the method and then return {@code true},
- * as this will make WebView to attempt loading a non-http url, and thus fail.</li>
- * </ul>
+ * <p class="note"><b>Note:</b> Do not call {@link WebView#loadUrl(String)} with the request's
+ * URL and then return {@code true}. This unnecessarily cancels the current load and starts a
+ * new load with the same URL. The correct way to continue loading a given URL is to simply
+ * return {@code false}, without calling {@link WebView#loadUrl(String)}.
+ *
+ * <p class="note"><b>Note:</b> This method is not called for POST requests.
+ *
+ * <p class="note"><b>Note:</b> This method may be called for subframes and with non-HTTP(S)
+ * schemes; calling {@link WebView#loadUrl(String)} with such a URL will fail.
*
* @param view The WebView that is initiating the callback.
* @param request Object containing the details of the request.
- * @return {@code true} if the host application wants to leave the current WebView
- * and handle the url itself, otherwise return {@code false}.
+ * @return {@code true} to cancel the current load, otherwise return {@code false}.
*/
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
return shouldOverrideUrlLoading(view, request.getUrl().toString());
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index 298c61e..6238e16 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -781,7 +781,7 @@
* @param firstVisibleItem the index of the first visible cell (ignore if
* visibleItemCount == 0)
* @param visibleItemCount the number of visible cells
- * @param totalItemCount the number of items in the list adaptor
+ * @param totalItemCount the number of items in the list adapter
*/
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
int totalItemCount);
diff --git a/core/java/com/android/internal/widget/MessagingLinearLayout.java b/core/java/com/android/internal/widget/MessagingLinearLayout.java
index 64b1f24..0c8613b 100644
--- a/core/java/com/android/internal/widget/MessagingLinearLayout.java
+++ b/core/java/com/android/internal/widget/MessagingLinearLayout.java
@@ -111,14 +111,16 @@
final int childHeight = child.getMeasuredHeight();
int newHeight = Math.max(totalHeight, totalHeight + childHeight + lp.topMargin +
lp.bottomMargin + spacing);
- first = false;
int measureType = MessagingChild.MEASURED_NORMAL;
if (messagingChild != null) {
measureType = messagingChild.getMeasuredType();
linesRemaining -= messagingChild.getConsumedLines();
}
- boolean isShortened = measureType == MessagingChild.MEASURED_SHORTENED;
- boolean isTooSmall = measureType == MessagingChild.MEASURED_TOO_SMALL;
+
+ // We never measure the first item as too small, we want to at least show something.
+ boolean isTooSmall = measureType == MessagingChild.MEASURED_TOO_SMALL && !first;
+ boolean isShortened = measureType == MessagingChild.MEASURED_SHORTENED
+ || measureType == MessagingChild.MEASURED_TOO_SMALL && first;
if (newHeight <= targetHeight && !isTooSmall) {
totalHeight = newHeight;
measuredWidth = Math.max(measuredWidth,
@@ -131,6 +133,7 @@
} else {
break;
}
+ first = false;
}
setMeasuredDimension(
diff --git a/core/res/res/values-mcc214-mnc01/config.xml b/core/res/res/values-mcc214-mnc01/config.xml
index 24150a7..41e24d7 100644
--- a/core/res/res/values-mcc214-mnc01/config.xml
+++ b/core/res/res/values-mcc214-mnc01/config.xml
@@ -40,4 +40,7 @@
<item>INTERNET,airtelnet.es,,,vodafone,vodafone,,,,,214,01,1,DUN</item>
</string-array>
+ <!-- Whether safe headphone volume warning dialog is disabled on Vol+ (operator specific). -->
+ <bool name="config_safe_media_disable_on_volume_up">false</bool>
+
</resources>
diff --git a/core/res/res/values-mcc222-mnc10/config.xml b/core/res/res/values-mcc222-mnc10/config.xml
index c819de2..0085a1b 100644
--- a/core/res/res/values-mcc222-mnc10/config.xml
+++ b/core/res/res/values-mcc222-mnc10/config.xml
@@ -28,4 +28,8 @@
<string-array translatable="false" name="config_tether_apndata">
<item>Tethering Internet,web.omnitel.it,,,,,,,,,222,10,,DUN</item>
</string-array>
+
+ <!-- Whether safe headphone volume warning dialog is disabled on Vol+ (operator specific). -->
+ <bool name="config_safe_media_disable_on_volume_up">false</bool>
+
</resources>
diff --git a/core/res/res/values-mcc234-mnc15/config.xml b/core/res/res/values-mcc234-mnc15/config.xml
new file mode 100644
index 0000000..84e779d
--- /dev/null
+++ b/core/res/res/values-mcc234-mnc15/config.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2018, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <!-- Whether safe headphone volume warning dialog is disabled on Vol+ (operator specific). -->
+ <bool name="config_safe_media_disable_on_volume_up">false</bool>
+
+</resources>
diff --git a/core/res/res/values-mcc234-mnc91/config.xml b/core/res/res/values-mcc234-mnc91/config.xml
new file mode 100644
index 0000000..84e779d
--- /dev/null
+++ b/core/res/res/values-mcc234-mnc91/config.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2018, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <!-- Whether safe headphone volume warning dialog is disabled on Vol+ (operator specific). -->
+ <bool name="config_safe_media_disable_on_volume_up">false</bool>
+
+</resources>
diff --git a/core/res/res/values-mcc262-mnc02/config.xml b/core/res/res/values-mcc262-mnc02/config.xml
new file mode 100644
index 0000000..84e779d
--- /dev/null
+++ b/core/res/res/values-mcc262-mnc02/config.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2018, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <!-- Whether safe headphone volume warning dialog is disabled on Vol+ (operator specific). -->
+ <bool name="config_safe_media_disable_on_volume_up">false</bool>
+
+</resources>
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 8f56ef9..fb7cd3d 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -2361,6 +2361,9 @@
<!-- Whether safe headphone volume is enabled or not (country specific). -->
<bool name="config_safe_media_volume_enabled">true</bool>
+ <!-- Whether safe headphone volume warning dialog is disabled on Vol+ (operator specific). -->
+ <bool name="config_safe_media_disable_on_volume_up">true</bool>
+
<!-- Set to true if the wifi display supports compositing content stored
in gralloc protected buffers. For this to be true, there must exist
a protected hardware path for surface flinger to composite and send
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 00bd77d..cf624ac 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -309,6 +309,7 @@
<java-symbol type="bool" name="config_allowAnimationsInLowPowerMode" />
<java-symbol type="bool" name="config_useDevInputEventForAudioJack" />
<java-symbol type="bool" name="config_safe_media_volume_enabled" />
+ <java-symbol type="bool" name="config_safe_media_disable_on_volume_up" />
<java-symbol type="bool" name="config_camera_sound_forced" />
<java-symbol type="bool" name="config_dontPreferApn" />
<java-symbol type="bool" name="config_restartRadioAfterProvisioning" />
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index 4833816..090f9af 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -306,6 +306,7 @@
<item name="quickContactBadgeStyleSmallWindowLarge">@style/Widget.QuickContactBadgeSmall.WindowLarge</item>
<item name="listPopupWindowStyle">@style/Widget.ListPopupWindow</item>
<item name="popupMenuStyle">@style/Widget.PopupMenu</item>
+ <item name="popupTheme">@null</item>
<item name="activityChooserViewStyle">@style/Widget.ActivityChooserView</item>
<item name="fragmentBreadCrumbsStyle">@style/Widget.FragmentBreadCrumbs</item>
<item name="contextPopupMenuStyle">?attr/popupMenuStyle</item>
diff --git a/core/res/res/values/themes_holo.xml b/core/res/res/values/themes_holo.xml
index cb5b93d..33832d4 100644
--- a/core/res/res/values/themes_holo.xml
+++ b/core/res/res/values/themes_holo.xml
@@ -296,6 +296,7 @@
<item name="quickContactBadgeStyleSmallWindowLarge">@style/Widget.Holo.QuickContactBadgeSmall.WindowLarge</item>
<item name="listPopupWindowStyle">@style/Widget.Holo.ListPopupWindow</item>
<item name="popupMenuStyle">@style/Widget.Holo.PopupMenu</item>
+ <item name="popupTheme">@null</item>
<item name="stackViewStyle">@style/Widget.Holo.StackView</item>
<item name="activityChooserViewStyle">@style/Widget.Holo.ActivityChooserView</item>
<item name="fragmentBreadCrumbsStyle">@style/Widget.Holo.FragmentBreadCrumbs</item>
@@ -658,9 +659,11 @@
<item name="quickContactBadgeStyleSmallWindowLarge">@style/Widget.Holo.QuickContactBadgeSmall.WindowLarge</item>
<item name="listPopupWindowStyle">@style/Widget.Holo.Light.ListPopupWindow</item>
<item name="popupMenuStyle">@style/Widget.Holo.Light.PopupMenu</item>
+ <item name="popupTheme">@null</item>
<item name="stackViewStyle">@style/Widget.Holo.StackView</item>
<item name="activityChooserViewStyle">@style/Widget.Holo.Light.ActivityChooserView</item>
<item name="fragmentBreadCrumbsStyle">@style/Widget.Holo.Light.FragmentBreadCrumbs</item>
+ <item name="contextPopupMenuStyle">?attr/popupMenuStyle</item>
<!-- Preference styles -->
<item name="preferenceScreenStyle">@style/Preference.Holo.PreferenceScreen</item>
diff --git a/core/tests/coretests/src/android/provider/SettingsBackupTest.java b/core/tests/coretests/src/android/provider/SettingsBackupTest.java
index cad0b85..616fb2c 100644
--- a/core/tests/coretests/src/android/provider/SettingsBackupTest.java
+++ b/core/tests/coretests/src/android/provider/SettingsBackupTest.java
@@ -98,6 +98,7 @@
private static final Set<String> BACKUP_BLACKLISTED_GLOBAL_SETTINGS =
newHashSet(
Settings.Global.ACTIVITY_MANAGER_CONSTANTS,
+ Settings.Global.ACTIVITY_STARTS_LOGGING_ENABLED,
Settings.Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED,
Settings.Global.ADB_ENABLED,
Settings.Global.ADD_USERS_WHEN_LOCKED,
diff --git a/keystore/java/android/security/keystore/AndroidKeyStoreKeyGeneratorSpi.java b/keystore/java/android/security/keystore/AndroidKeyStoreKeyGeneratorSpi.java
index 419eb24..953cef7d 100644
--- a/keystore/java/android/security/keystore/AndroidKeyStoreKeyGeneratorSpi.java
+++ b/keystore/java/android/security/keystore/AndroidKeyStoreKeyGeneratorSpi.java
@@ -301,6 +301,9 @@
KeyStoreCryptoOperationUtils.getRandomBytesToMixIntoKeystoreRng(
mRng, (mKeySizeBits + 7) / 8);
int flags = 0;
+ if (spec.isStrongBoxBacked()) {
+ flags |= KeyStore.FLAG_STRONGBOX;
+ }
String keyAliasInKeystore = Credentials.USER_PRIVATE_KEY + spec.getKeystoreAlias();
KeyCharacteristics resultingKeyCharacteristics = new KeyCharacteristics();
boolean success = false;
@@ -314,8 +317,12 @@
flags,
resultingKeyCharacteristics);
if (errorCode != KeyStore.NO_ERROR) {
- throw new ProviderException(
- "Keystore operation failed", KeyStore.getKeyStoreException(errorCode));
+ if (errorCode == KeyStore.HARDWARE_TYPE_UNAVAILABLE) {
+ throw new StrongBoxUnavailableException("Failed to generate key");
+ } else {
+ throw new ProviderException(
+ "Keystore operation failed", KeyStore.getKeyStoreException(errorCode));
+ }
}
@KeyProperties.KeyAlgorithmEnum String keyAlgorithmJCA;
try {
diff --git a/location/java/com/android/internal/location/gnssmetrics/GnssMetrics.java b/location/java/com/android/internal/location/gnssmetrics/GnssMetrics.java
index 3643ca4..8a02a82 100644
--- a/location/java/com/android/internal/location/gnssmetrics/GnssMetrics.java
+++ b/location/java/com/android/internal/location/gnssmetrics/GnssMetrics.java
@@ -18,6 +18,7 @@
import android.os.SystemClock;
import android.os.connectivity.GpsBatteryStats;
+import android.os.SystemProperties;
import android.text.format.DateUtils;
import android.util.Base64;
@@ -175,6 +176,7 @@
= topFourAverageCn0Statistics.getStandardDeviation();
}
msg.powerMetrics = mGnssPowerMetrics.buildProto();
+ msg.hardwareRevision = SystemProperties.get("ro.boot.revision", "");
String s = Base64.encodeToString(GnssLog.toByteArray(msg), Base64.DEFAULT);
reset();
return s;
@@ -239,6 +241,7 @@
s.append(" Energy consumed while on battery (mAh): ").append(
stats.getEnergyConsumedMaMs() / ((double) DateUtils.HOUR_IN_MILLIS)).append("\n");
}
+ s.append("Hardware Version: " + SystemProperties.get("ro.boot.revision", "")).append("\n");
return s.toString();
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java b/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java
index 093b1bd..15cb9bd 100644
--- a/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java
+++ b/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java
@@ -25,6 +25,7 @@
import android.arch.lifecycle.Lifecycle;
import android.arch.lifecycle.LifecycleObserver;
import android.arch.lifecycle.OnLifecycleEvent;
+
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -62,6 +63,7 @@
import java.io.IOException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.lang.ref.WeakReference;
import java.text.Collator;
import java.text.Normalizer;
import java.text.Normalizer.Form;
@@ -132,7 +134,7 @@
boolean mSessionsChanged;
// Temporary for dispatching session callbacks. Only touched by main thread.
- final ArrayList<Session> mActiveSessions = new ArrayList<Session>();
+ final ArrayList<WeakReference<Session>> mActiveSessions = new ArrayList<>();
final HandlerThread mThread;
final BackgroundHandler mBackgroundHandler;
@@ -618,7 +620,7 @@
for (int i=0; i<mSessions.size(); i++) {
Session s = mSessions.get(i);
if (s.mResumed) {
- mActiveSessions.add(s);
+ mActiveSessions.add(new WeakReference<>(s));
}
}
}
@@ -830,46 +832,70 @@
rebuildActiveSessions();
switch (msg.what) {
case MSG_REBUILD_COMPLETE: {
- Session s = (Session)msg.obj;
- if (mActiveSessions.contains(s)) {
- s.mCallbacks.onRebuildComplete(s.mLastAppList);
+ Session s = (Session) msg.obj;
+ for (WeakReference<Session> sessionRef : mActiveSessions) {
+ final Session session = sessionRef.get();
+ if (session != null && session == s) {
+ s.mCallbacks.onRebuildComplete(s.mLastAppList);
+ }
}
} break;
case MSG_PACKAGE_LIST_CHANGED: {
- for (int i=0; i<mActiveSessions.size(); i++) {
- mActiveSessions.get(i).mCallbacks.onPackageListChanged();
+ for (WeakReference<Session> sessionRef : mActiveSessions) {
+ final Session session = sessionRef.get();
+ if (session != null) {
+ session.mCallbacks.onPackageListChanged();
+ }
}
} break;
case MSG_PACKAGE_ICON_CHANGED: {
- for (int i=0; i<mActiveSessions.size(); i++) {
- mActiveSessions.get(i).mCallbacks.onPackageIconChanged();
+ for (WeakReference<Session> sessionRef : mActiveSessions) {
+ final Session session = sessionRef.get();
+ if (session != null) {
+ session.mCallbacks.onPackageIconChanged();
+ }
}
} break;
case MSG_PACKAGE_SIZE_CHANGED: {
- for (int i=0; i<mActiveSessions.size(); i++) {
- mActiveSessions.get(i).mCallbacks.onPackageSizeChanged(
- (String)msg.obj);
+ for (WeakReference<Session> sessionRef : mActiveSessions) {
+ final Session session = sessionRef.get();
+ if (session != null) {
+ session.mCallbacks.onPackageSizeChanged(
+ (String) msg.obj);
+ }
}
} break;
case MSG_ALL_SIZES_COMPUTED: {
- for (int i=0; i<mActiveSessions.size(); i++) {
- mActiveSessions.get(i).mCallbacks.onAllSizesComputed();
+ for (WeakReference<Session> sessionRef : mActiveSessions) {
+ final Session session = sessionRef.get();
+ if (session != null) {
+ session.mCallbacks.onAllSizesComputed();
+ }
}
} break;
case MSG_RUNNING_STATE_CHANGED: {
- for (int i=0; i<mActiveSessions.size(); i++) {
- mActiveSessions.get(i).mCallbacks.onRunningStateChanged(
- msg.arg1 != 0);
+ for (WeakReference<Session> sessionRef : mActiveSessions) {
+ final Session session = sessionRef.get();
+ if (session != null) {
+ session.mCallbacks.onRunningStateChanged(
+ msg.arg1 != 0);
+ }
}
} break;
case MSG_LAUNCHER_INFO_CHANGED: {
- for (int i=0; i<mActiveSessions.size(); i++) {
- mActiveSessions.get(i).mCallbacks.onLauncherInfoChanged();
+ for (WeakReference<Session> sessionRef : mActiveSessions) {
+ final Session session = sessionRef.get();
+ if (session != null) {
+ session.mCallbacks.onLauncherInfoChanged();
+ }
}
} break;
case MSG_LOAD_ENTRIES_COMPLETE: {
- for (int i=0; i<mActiveSessions.size(); i++) {
- mActiveSessions.get(i).mCallbacks.onLoadEntriesCompleted();
+ for (WeakReference<Session> sessionRef : mActiveSessions) {
+ final Session session = sessionRef.get();
+ if (session != null) {
+ session.mCallbacks.onLoadEntriesCompleted();
+ }
}
} break;
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothManager.java
index 3732471..1c50953 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothManager.java
@@ -19,6 +19,8 @@
import android.content.Context;
import android.util.Log;
+import java.lang.ref.WeakReference;
+
/**
* LocalBluetoothManager provides a simplified interface on top of a subset of
* the Bluetooth API. Note that {@link #getInstance} will return null
@@ -34,7 +36,7 @@
private final Context mContext;
/** If a BT-related activity is in the foreground, this will be it. */
- private Context mForegroundActivity;
+ private WeakReference<Context> mForegroundActivity;
private final LocalBluetoothAdapter mLocalAdapter;
@@ -85,17 +87,19 @@
}
public Context getForegroundActivity() {
- return mForegroundActivity;
+ return mForegroundActivity == null
+ ? null
+ : mForegroundActivity.get();
}
public boolean isForegroundActivity() {
- return mForegroundActivity != null;
+ return mForegroundActivity != null && mForegroundActivity.get() != null;
}
public synchronized void setForegroundActivity(Context context) {
if (context != null) {
Log.d(TAG, "setting foreground activity to non-null context");
- mForegroundActivity = context;
+ mForegroundActivity = new WeakReference<>(context);
} else {
if (mForegroundActivity != null) {
Log.d(TAG, "setting foreground activity to null");
diff --git a/packages/SettingsLib/src/com/android/settingslib/dream/DreamBackend.java b/packages/SettingsLib/src/com/android/settingslib/dream/DreamBackend.java
index 988060e..e5d97c9 100644
--- a/packages/SettingsLib/src/com/android/settingslib/dream/DreamBackend.java
+++ b/packages/SettingsLib/src/com/android/settingslib/dream/DreamBackend.java
@@ -36,12 +36,12 @@
import android.util.Log;
import android.util.Xml;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -97,15 +97,15 @@
}
public DreamBackend(Context context) {
- mContext = context;
+ mContext = context.getApplicationContext();
mDreamManager = IDreamManager.Stub.asInterface(
ServiceManager.getService(DreamService.DREAM_SERVICE));
mComparator = new DreamInfoComparator(getDefaultDream());
- mDreamsEnabledByDefault = context.getResources()
+ mDreamsEnabledByDefault = mContext.getResources()
.getBoolean(com.android.internal.R.bool.config_dreamsEnabledByDefault);
- mDreamsActivatedOnSleepByDefault = context.getResources()
+ mDreamsActivatedOnSleepByDefault = mContext.getResources()
.getBoolean(com.android.internal.R.bool.config_dreamsActivatedOnSleepByDefault);
- mDreamsActivatedOnDockByDefault = context.getResources()
+ mDreamsActivatedOnDockByDefault = mContext.getResources()
.getBoolean(com.android.internal.R.bool.config_dreamsActivatedOnDockByDefault);
}
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java
index b1a247a..ff383dd 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java
@@ -15,7 +15,6 @@
*/
package com.android.keyguard;
-import android.R.style;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager;
@@ -26,7 +25,6 @@
import android.util.Log;
import android.util.Slog;
import android.util.StatsLog;
-import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
@@ -210,7 +208,7 @@
if (messageId != 0) {
final String message = mContext.getString(messageId,
- KeyguardUpdateMonitor.getInstance(mContext).getFailedUnlockAttempts(userId),
+ mLockPatternUtils.getCurrentFailedPasswordAttempts(userId),
timeoutInSeconds);
showDialog(null, message);
}
@@ -255,8 +253,8 @@
}
private void reportFailedUnlockAttempt(int userId, int timeoutMs) {
- final KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
- final int failedAttempts = monitor.getFailedUnlockAttempts(userId) + 1; // +1 for this time
+ // +1 for this time
+ final int failedAttempts = mLockPatternUtils.getCurrentFailedPasswordAttempts(userId) + 1;
if (DEBUG) Log.d(TAG, "reportFailedPatternAttempt: #" + failedAttempts);
@@ -290,7 +288,6 @@
showWipeDialog(failedAttempts, userType);
}
}
- monitor.reportFailedStrongAuthUnlockAttempt(userId);
mLockPatternUtils.reportFailedPasswordAttempt(userId);
if (timeoutMs > 0) {
mLockPatternUtils.reportPasswordLockout(timeoutMs, userId);
@@ -434,7 +431,6 @@
if (success) {
StatsLog.write(StatsLog.KEYGUARD_BOUNCER_PASSWORD_ENTERED,
StatsLog.KEYGUARD_BOUNCER_PASSWORD_ENTERED__RESULT__SUCCESS);
- monitor.clearFailedUnlockAttempts();
mLockPatternUtils.reportSuccessfulPasswordAttempt(userId);
} else {
StatsLog.write(StatsLog.KEYGUARD_BOUNCER_PASSWORD_ENTERED,
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
index ef3aa42..0e21815 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -209,9 +209,6 @@
// Battery status
private BatteryStatus mBatteryStatus;
- // Password attempts
- private SparseIntArray mFailedAttempts = new SparseIntArray();
-
private final StrongAuthTracker mStrongAuthTracker;
private final ArrayList<WeakReference<KeyguardUpdateMonitorCallback>>
@@ -1800,22 +1797,10 @@
return mDeviceProvisioned;
}
- public void clearFailedUnlockAttempts() {
- mFailedAttempts.delete(sCurrentUser);
- }
-
public ServiceState getServiceState(int subId) {
return mServiceStates.get(subId);
}
- public int getFailedUnlockAttempts(int userId) {
- return mFailedAttempts.get(userId, 0);
- }
-
- public void reportFailedStrongAuthUnlockAttempt(int userId) {
- mFailedAttempts.put(userId, getFailedUnlockAttempts(userId) + 1);
- }
-
public void clearFingerprintRecognized() {
mUserFingerprintAuthenticated.clear();
mTrustManager.clearAllFingerprints();
diff --git a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
index 194679c..71cf9b5 100644
--- a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
+++ b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
@@ -39,10 +39,13 @@
import android.graphics.Rect;
import android.graphics.Region;
import android.hardware.display.DisplayManager;
+import android.os.Handler;
+import android.os.HandlerThread;
import android.os.SystemProperties;
import android.provider.Settings.Secure;
import android.support.annotation.VisibleForTesting;
import android.util.DisplayMetrics;
+import android.util.Log;
import android.view.DisplayCutout;
import android.view.DisplayInfo;
import android.view.Gravity;
@@ -57,6 +60,7 @@
import android.widget.FrameLayout;
import android.widget.ImageView;
+import com.android.internal.util.Preconditions;
import com.android.systemui.RegionInterceptingFrameLayout.RegionInterceptableView;
import com.android.systemui.fragments.FragmentHostManager;
import com.android.systemui.fragments.FragmentHostManager.FragmentListener;
@@ -74,6 +78,9 @@
* for antialiasing and emulation purposes.
*/
public class ScreenDecorations extends SystemUI implements Tunable {
+ private static final boolean DEBUG = false;
+ private static final String TAG = "ScreenDecorations";
+
public static final String SIZE = "sysui_rounded_size";
public static final String PADDING = "sysui_rounded_content_padding";
private static final boolean DEBUG_SCREENSHOT_ROUNDED_CORNERS =
@@ -93,9 +100,24 @@
private DisplayCutoutView mCutoutTop;
private DisplayCutoutView mCutoutBottom;
private boolean mPendingRotationChange;
+ private Handler mHandler;
@Override
public void start() {
+ mHandler = startHandlerThread();
+ mHandler.post(this::startOnScreenDecorationsThread);
+ setupStatusBarPaddingIfNeeded();
+ }
+
+ @VisibleForTesting
+ Handler startHandlerThread() {
+ HandlerThread thread = new HandlerThread("ScreenDecorations");
+ thread.start();
+ return thread.getThreadHandler();
+ }
+
+ private void startOnScreenDecorationsThread() {
+ mRotation = RotationUtils.getExactRotation(mContext);
mWindowManager = mContext.getSystemService(WindowManager.class);
mRoundedDefault = mContext.getResources().getDimensionPixelSize(
R.dimen.rounded_corner_radius);
@@ -107,12 +129,6 @@
setupDecorations();
}
- int padding = mContext.getResources().getDimensionPixelSize(
- R.dimen.rounded_corner_content_padding);
- if (padding != 0) {
- setupPadding(padding);
- }
-
mDisplayListener = new DisplayManager.DisplayListener() {
@Override
public void onDisplayAdded(int displayId) {
@@ -126,8 +142,8 @@
@Override
public void onDisplayChanged(int displayId) {
- if (mOverlay != null && mBottomOverlay != null
- && mRotation != RotationUtils.getExactRotation(mContext)) {
+ final int newRotation = RotationUtils.getExactRotation(mContext);
+ if (mOverlay != null && mBottomOverlay != null && mRotation != newRotation) {
// We cannot immediately update the orientation. Otherwise
// WindowManager is still deferring layout until it has finished dispatching
// the config changes, which may cause divergence between what we draw
@@ -136,20 +152,24 @@
// - we are trying to redraw. This because WM resized our window and told us to.
// - the config change has been dispatched, so WM is no longer deferring layout.
mPendingRotationChange = true;
- mOverlay.getViewTreeObserver().addOnPreDrawListener(
- new RestartingPreDrawListener(mOverlay));
- mBottomOverlay.getViewTreeObserver().addOnPreDrawListener(
- new RestartingPreDrawListener(mBottomOverlay));
+ if (DEBUG) {
+ Log.i(TAG, "Rotation changed, deferring " + newRotation + ", staying at "
+ + mRotation);
+ }
+ mOverlay.getViewTreeObserver().addOnPreDrawListener(
+ new RestartingPreDrawListener(mOverlay, newRotation));
+ mBottomOverlay.getViewTreeObserver().addOnPreDrawListener(
+ new RestartingPreDrawListener(mBottomOverlay, newRotation));
}
updateOrientation();
}
};
- mRotation = -1;
mDisplayManager = (DisplayManager) mContext.getSystemService(
Context.DISPLAY_SERVICE);
- mDisplayManager.registerDisplayListener(mDisplayListener, null);
+ mDisplayManager.registerDisplayListener(mDisplayListener, mHandler);
+ updateOrientation();
}
private void setupDecorations() {
@@ -179,10 +199,11 @@
mWindowManager.getDefaultDisplay().getMetrics(metrics);
mDensity = metrics.density;
- Dependency.get(TunerService.class).addTunable(this, SIZE);
+ Dependency.get(Dependency.MAIN_HANDLER).post(
+ () -> Dependency.get(TunerService.class).addTunable(this, SIZE));
// Watch color inversion and invert the overlay as needed.
- SecureSetting setting = new SecureSetting(mContext, Dependency.get(Dependency.MAIN_HANDLER),
+ SecureSetting setting = new SecureSetting(mContext, mHandler,
Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED) {
@Override
protected void handleValueChanged(int value, boolean observedChange) {
@@ -215,18 +236,37 @@
.start();
}
});
+
+ mOverlay.getViewTreeObserver().addOnPreDrawListener(
+ new ValidatingPreDrawListener(mOverlay));
+ mBottomOverlay.getViewTreeObserver().addOnPreDrawListener(
+ new ValidatingPreDrawListener(mBottomOverlay));
}
@Override
protected void onConfigurationChanged(Configuration newConfig) {
- mPendingRotationChange = false;
- updateOrientation();
- if (shouldDrawCutout() && mOverlay == null) {
- setupDecorations();
- }
+ mHandler.post(() -> {
+ int oldRotation = mRotation;
+ mPendingRotationChange = false;
+ updateOrientation();
+ if (DEBUG) Log.i(TAG, "onConfigChanged from rot " + oldRotation + " to " + mRotation);
+ if (shouldDrawCutout() && mOverlay == null) {
+ setupDecorations();
+ }
+ if (mOverlay != null) {
+ // Updating the layout params ensures that ViewRootImpl will call relayoutWindow(),
+ // which ensures that the forced seamless rotation will end, even if we updated
+ // the rotation before window manager was ready (and was still waiting for sending
+ // the updated rotation).
+ updateLayoutParams();
+ }
+ });
}
- protected void updateOrientation() {
+ private void updateOrientation() {
+ Preconditions.checkState(mHandler.getLooper().getThread() == Thread.currentThread(),
+ "must call on " + mHandler.getLooper().getThread()
+ + ", but was " + Thread.currentThread());
if (mPendingRotationChange) {
return;
}
@@ -306,7 +346,19 @@
com.android.internal.R.bool.config_fillMainBuiltInDisplayCutout);
}
- private void setupPadding(int padding) {
+
+ private void setupStatusBarPaddingIfNeeded() {
+ // TODO: This should be moved to a more appropriate place, as it is not related to the
+ // screen decorations overlay.
+ int padding = mContext.getResources().getDimensionPixelSize(
+ R.dimen.rounded_corner_content_padding);
+ if (padding != 0) {
+ setupStatusBarPadding(padding);
+ }
+
+ }
+
+ private void setupStatusBarPadding(int padding) {
// Add some padding to all the content near the edge of the screen.
StatusBar sb = getComponent(StatusBar.class);
View statusBar = (sb != null ? sb.getStatusBarWindow() : null);
@@ -375,30 +427,32 @@
@Override
public void onTuningChanged(String key, String newValue) {
- if (mOverlay == null) return;
- if (SIZE.equals(key)) {
- int size = mRoundedDefault;
- int sizeTop = mRoundedDefaultTop;
- int sizeBottom = mRoundedDefaultBottom;
- if (newValue != null) {
- try {
- size = (int) (Integer.parseInt(newValue) * mDensity);
- } catch (Exception e) {
+ mHandler.post(() -> {
+ if (mOverlay == null) return;
+ if (SIZE.equals(key)) {
+ int size = mRoundedDefault;
+ int sizeTop = mRoundedDefaultTop;
+ int sizeBottom = mRoundedDefaultBottom;
+ if (newValue != null) {
+ try {
+ size = (int) (Integer.parseInt(newValue) * mDensity);
+ } catch (Exception e) {
+ }
}
- }
- if (sizeTop == 0) {
- sizeTop = size;
- }
- if (sizeBottom == 0) {
- sizeBottom = size;
- }
+ if (sizeTop == 0) {
+ sizeTop = size;
+ }
+ if (sizeBottom == 0) {
+ sizeBottom = size;
+ }
- setSize(mOverlay.findViewById(R.id.left), sizeTop);
- setSize(mOverlay.findViewById(R.id.right), sizeTop);
- setSize(mBottomOverlay.findViewById(R.id.left), sizeBottom);
- setSize(mBottomOverlay.findViewById(R.id.right), sizeBottom);
- }
+ setSize(mOverlay.findViewById(R.id.left), sizeTop);
+ setSize(mOverlay.findViewById(R.id.right), sizeTop);
+ setSize(mBottomOverlay.findViewById(R.id.left), sizeBottom);
+ setSize(mBottomOverlay.findViewById(R.id.right), sizeBottom);
+ }
+ });
}
private void setSize(View view, int pixelSize) {
@@ -457,6 +511,11 @@
mVisibilityChangedListener = visibilityChangedListener;
mDecorations = decorations;
setId(R.id.display_cutout);
+ if (DEBUG) {
+ getViewTreeObserver().addOnDrawListener(() -> Log.i(TAG,
+ (mInitialStart ? "OverlayTop" : "OverlayBottom")
+ + " drawn in rot " + mRotation));
+ }
}
public void setColor(int color) {
@@ -692,20 +751,66 @@
private class RestartingPreDrawListener implements ViewTreeObserver.OnPreDrawListener {
private final View mView;
+ private final int mTargetRotation;
- private RestartingPreDrawListener(View view) {
+ private RestartingPreDrawListener(View view, int targetRotation) {
+ mView = view;
+ mTargetRotation = targetRotation;
+ }
+
+ @Override
+ public boolean onPreDraw() {
+ mView.getViewTreeObserver().removeOnPreDrawListener(this);
+
+ if (mTargetRotation == mRotation) {
+ if (DEBUG) {
+ Log.i(TAG, (mView == mOverlay ? "OverlayTop" : "OverlayBottom")
+ + " already in target rot "
+ + mTargetRotation + ", allow draw without restarting it");
+ }
+ return true;
+ }
+
+ mPendingRotationChange = false;
+ // This changes the window attributes - we need to restart the traversal for them to
+ // take effect.
+ updateOrientation();
+ if (DEBUG) {
+ Log.i(TAG, (mView == mOverlay ? "OverlayTop" : "OverlayBottom")
+ + " restarting listener fired, restarting draw for rot " + mRotation);
+ }
+ mView.invalidate();
+ return false;
+ }
+ }
+
+ /**
+ * A pre-draw listener, that validates that the rotation we draw in matches the displays
+ * rotation before continuing the draw.
+ *
+ * This is to prevent a race condition, where we have not received the display changed event
+ * yet, and would thus draw in an old orientation.
+ */
+ private class ValidatingPreDrawListener implements ViewTreeObserver.OnPreDrawListener {
+
+ private final View mView;
+
+ public ValidatingPreDrawListener(View view) {
mView = view;
}
@Override
public boolean onPreDraw() {
- mPendingRotationChange = false;
- mView.getViewTreeObserver().removeOnPreDrawListener(this);
- // This changes the window attributes - we need to restart the traversal for them to
- // take effect.
- updateOrientation();
- mView.invalidate();
- return false;
+ final int displayRotation = RotationUtils.getExactRotation(mContext);
+ if (displayRotation != mRotation && !mPendingRotationChange) {
+ if (DEBUG) {
+ Log.i(TAG, "Drawing rot " + mRotation + ", but display is at rot "
+ + displayRotation + ". Restarting draw");
+ }
+ mView.invalidate();
+ return false;
+ }
+ return true;
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index 89688fb..33db2c8 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -1647,7 +1647,6 @@
resetKeyguardDonePendingLocked();
}
- mUpdateMonitor.clearFailedUnlockAttempts();
mUpdateMonitor.clearFingerprintRecognized();
if (mGoingToSleep) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationEntryManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationEntryManager.java
index 06f26c9..469c3c2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationEntryManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationEntryManager.java
@@ -667,9 +667,15 @@
entry.row.getNotificationChildren();
for (int i = 0; i < notificationChildren.size(); i++) {
ExpandableNotificationRow row = notificationChildren.get(i);
- if ((row.getStatusBarNotification().getNotification().flags
- & Notification.FLAG_FOREGROUND_SERVICE) != 0) {
- // the child is a foreground service notification which we can't remove!
+ NotificationData.Entry childEntry = row.getEntry();
+ boolean isForeground = (row.getStatusBarNotification().getNotification().flags
+ & Notification.FLAG_FOREGROUND_SERVICE) != 0;
+ boolean keepForReply = FORCE_REMOTE_INPUT_HISTORY
+ && (shouldKeepForRemoteInput(childEntry)
+ || shouldKeepForSmartReply(childEntry));
+ if (isForeground || keepForReply) {
+ // the child is a foreground service notification which we can't remove or it's
+ // a child we're keeping around for reply!
continue;
}
row.setKeepInParent(true);
diff --git a/packages/SystemUI/src/com/android/systemui/volume/SafetyWarningDialog.java b/packages/SystemUI/src/com/android/systemui/volume/SafetyWarningDialog.java
index d7c4bbf..c97095e 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/SafetyWarningDialog.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/SafetyWarningDialog.java
@@ -21,11 +21,13 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.res.Resources.NotFoundException;
import android.media.AudioManager;
import android.util.Log;
import android.view.KeyEvent;
import android.view.WindowManager;
+
import com.android.systemui.statusbar.phone.SystemUIDialog;
abstract public class SafetyWarningDialog extends SystemUIDialog
@@ -40,12 +42,18 @@
private long mShowTime;
private boolean mNewVolumeUp;
+ private boolean mDisableOnVolumeUp;
public SafetyWarningDialog(Context context, AudioManager audioManager) {
super(context);
mContext = context;
mAudioManager = audioManager;
-
+ try {
+ mDisableOnVolumeUp = mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_safe_media_disable_on_volume_up);
+ } catch (NotFoundException e) {
+ mDisableOnVolumeUp = true;
+ }
getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR);
setShowForAllUsers(true);
setMessage(mContext.getString(com.android.internal.R.string.safe_media_volume_warning));
@@ -63,7 +71,8 @@
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_VOLUME_UP && event.getRepeatCount() == 0) {
+ if (mDisableOnVolumeUp && keyCode == KeyEvent.KEYCODE_VOLUME_UP
+ && event.getRepeatCount() == 0) {
mNewVolumeUp = true;
}
return super.onKeyDown(keyCode, event);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java b/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java
index f1bf31d..644c0b3 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java
@@ -34,8 +34,10 @@
import android.app.Fragment;
import android.content.res.Configuration;
+import android.os.Handler;
import android.support.test.filters.SmallTest;
import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper;
import android.testing.TestableLooper.RunWithLooper;
import android.view.Display;
import android.view.View;
@@ -60,6 +62,7 @@
@SmallTest
public class ScreenDecorationsTest extends SysuiTestCase {
+ private TestableLooper mTestableLooper;
private ScreenDecorations mScreenDecorations;
private StatusBar mStatusBar;
private WindowManager mWindowManager;
@@ -71,6 +74,10 @@
@Before
public void setup() {
+ mTestableLooper = TestableLooper.get(this);
+ mDependency.injectTestDependency(Dependency.MAIN_HANDLER,
+ new Handler(mTestableLooper.getLooper()));
+
mStatusBar = mock(StatusBar.class);
mWindowManager = mock(WindowManager.class);
mView = spy(new StatusBarWindowView(mContext, null));
@@ -88,7 +95,31 @@
mTunerService = mDependency.injectMockDependency(TunerService.class);
- mScreenDecorations = new ScreenDecorations();
+
+ mScreenDecorations = new ScreenDecorations() {
+ @Override
+ public void start() {
+ super.start();
+ mTestableLooper.processAllMessages();
+ }
+
+ @Override
+ Handler startHandlerThread() {
+ return new Handler(mTestableLooper.getLooper());
+ }
+
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ mTestableLooper.processAllMessages();
+ }
+
+ @Override
+ public void onTuningChanged(String key, String newValue) {
+ super.onTuningChanged(key, newValue);
+ mTestableLooper.processAllMessages();
+ }
+ };
mScreenDecorations.mContext = mContext;
mScreenDecorations.mComponents = mContext.getComponents();
diff --git a/proto/src/gnss.proto b/proto/src/gnss.proto
index 0168392..1509fc0 100644
--- a/proto/src/gnss.proto
+++ b/proto/src/gnss.proto
@@ -45,6 +45,9 @@
// Power metrics
optional PowerMetrics power_metrics = 12;
+
+ // Hardware revision (EVT, DVT, PVT etc.)
+ optional string hardware_revision = 13;
}
// Power metrics
diff --git a/proto/src/metrics_constants.proto b/proto/src/metrics_constants.proto
index 143fa86..0833e34 100644
--- a/proto/src/metrics_constants.proto
+++ b/proto/src/metrics_constants.proto
@@ -941,9 +941,10 @@
// OS: 6.0
NOTIFICATION_ZEN_MODE_EVENT_RULE = 146;
- // ACTION: App notification settings > Block Notifications
+ // ACTION: App notification settings > Block Notifications or long press on
+ // notification blocks.
// CATEGORY: SETTINGS
- // OS: 6.0
+ // OS: 9.0
ACTION_BAN_APP_NOTES = 147;
// ACTION: Notification shade > Dismiss all button
@@ -6129,6 +6130,305 @@
// CATEGORY: NOTIFICATION
NOTIFICATION_INTERRUPTION = 1501;
+ // OPEN: Settings
+ // CATEGORY: SETTINGS
+ // OS: Q
+ SETTINGS_HOMEPAGE = 1502;
+
+ // OPEN: Settings > Create shortcut(widget)
+ // CATEGORY: SETTINGS
+ // OS: Q
+ SETTINGS_CREATE_SHORTCUT = 1503;
+
+ // ACTION: Authenticate using fingerprint
+ // CATEGORY: SETTINGS
+ // OS: Q
+ ACTION_FACE_AUTH = 1504;
+
+ // ACTION: Add fingerprint > Enroll fingerprint
+ // CATEGORY: SETTINGS
+ // OS: Q
+ ACTION_FACE_ENROLL = 1505;
+
+ // OPEN: Face Enroll introduction
+ // CATEGORY: SETTINGS
+ // OS: Q
+ FACE_ENROLL_INTRO = 1506;
+
+ // OPEN: Face Enroll introduction
+ // CATEGORY: SETTINGS
+ // OS: Q
+ FACE_ENROLL_ENROLLING = 1507;
+
+ // OPEN: Face Enroll introduction
+ // CATEGORY: SETTINGS
+ // OS: Q
+ FACE_ENROLL_FINISHED = 1508;
+
+ // OPEN: Face Enroll sidecar
+ // CATEGORY: SETTINGS
+ // OS: Q
+ FACE_ENROLL_SIDECAR = 1509;
+
+ // OPEN: Settings > Add face > Error dialog
+ // OS: Q
+ DIALOG_FACE_ERROR = 1510;
+
+ // OPEN: Settings > Security > Face
+ // CATEGORY: SETTINGS
+ // OS: Q
+ FACE = 1511;
+
+ // OPEN: Settings > Acessibility > HearingAid pairing instructions dialog
+ // CATEGORY: SETTINGS
+ // OS: Q
+ DIALOG_ACCESSIBILITY_HEARINGAID = 1512;
+
+ // ACTION: Activity start
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ ACTION_ACTIVITY_START = 1513;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Calling UID
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_CALLING_UID = 1514;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Calling package name
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_CALLING_PACKAGE_NAME = 1515;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Calling UID proc state
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_CALLING_UID_PROC_STATE = 1516;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Calling UID has any visible window
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_CALLING_UID_HAS_ANY_VISIBLE_WINDOW = 1517;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Real calling UID
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_REAL_CALLING_UID = 1518;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Real calling UID proc state
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_REAL_CALLING_UID_PROC_STATE = 1519;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Real calling UID has any visible window
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_REAL_CALLING_UID_HAS_ANY_VISIBLE_WINDOW = 1520;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Target UID
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_TARGET_UID = 1521;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Target UID package name
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_TARGET_PACKAGE_NAME = 1522;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Target UID proc state
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_TARGET_UID_PROC_STATE = 1523;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Target UID has any visible window
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_TARGET_UID_HAS_ANY_VISIBLE_WINDOW = 1524;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Target doze whitelist tag
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_TARGET_WHITELIST_TAG = 1525;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Target short component name
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_TARGET_SHORT_COMPONENT_NAME = 1526;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Coming from pending intent
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_COMING_FROM_PENDING_INTENT = 1527;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Intent action
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_INTENT_ACTION = 1528;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Caller app process record process name
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_PROCESS_RECORD_PROCESS_NAME = 1529;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Caller app process record current proc state
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_PROCESS_RECORD_CUR_PROC_STATE = 1530;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Caller app process record has client activities
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_PROCESS_RECORD_HAS_CLIENT_ACTIVITIES = 1531;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Caller app process record has foreground services
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_PROCESS_RECORD_HAS_FOREGROUND_SERVICES = 1532;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Caller app process record has foreground activities
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_PROCESS_RECORD_HAS_FOREGROUND_ACTIVITIES = 1533;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Caller app process record has top UI
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_PROCESS_RECORD_HAS_TOP_UI = 1534;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Caller app process record has overlay UI
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_PROCESS_RECORD_HAS_OVERLAY_UI = 1535;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Caller app process record pending UI clean
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_PROCESS_RECORD_PENDING_UI_CLEAN = 1536;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Millis since caller app's process record last interaction event
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_PROCESS_RECORD_MILLIS_SINCE_LAST_INTERACTION_EVENT = 1537;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Millis since caller app's process record fg interaction
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_PROCESS_RECORD_MILLIS_SINCE_FG_INTERACTION = 1538;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Millis since caller app's process record last became unimportant
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_PROCESS_RECORD_MILLIS_SINCE_UNIMPORTANT = 1539;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Activity record launch mode
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_ACTIVITY_RECORD_LAUNCH_MODE = 1540;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Activity record target activity
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_ACTIVITY_RECORD_TARGET_ACTIVITY = 1541;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Activity record flags
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_ACTIVITY_RECORD_FLAGS = 1542;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Activity record real activity
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_ACTIVITY_RECORD_REAL_ACTIVITY = 1543;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Activity record short component name
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_ACTIVITY_RECORD_SHORT_COMPONENT_NAME = 1544;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Activity record process name
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_ACTIVITY_RECORD_PROCESS_NAME = 1545;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Activity record is fullscreen
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_ACTIVITY_RECORD_IS_FULLSCREEN = 1546;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Activity record is no display
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_ACTIVITY_RECORD_IS_NO_DISPLAY = 1547;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Millis since activity was last visible
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_ACTIVITY_RECORD_MILLIS_SINCE_LAST_VISIBLE = 1548;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Activity record's resultTo packageName
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_ACTIVITY_RECORD_RESULT_TO_PKG_NAME = 1549;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Activity record's resultTo shortComponentName
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_ACTIVITY_RECORD_RESULT_TO_SHORT_COMPONENT_NAME = 1550;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Activity record is visible
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_ACTIVITY_RECORD_IS_VISIBLE = 1551;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Activity record is visible ignoring keyguard
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_ACTIVITY_RECORD_IS_VISIBLE_IGNORING_KEYGUARD = 1552;
+
+ // Tagged data for ACTION_ACTIVITY_START.
+ // FIELD: Millis since activity's last launch
+ // CATEGORY: OTHER
+ // OS: Q (will also ship in PQ1A)
+ FIELD_ACTIVITY_RECORD_MILLIS_SINCE_LAST_LAUNCH = 1553;
+
// ---- End Q Constants, all Q constants go above this line ----
// Add new aosp constants above this line.
diff --git a/proto/src/wifi.proto b/proto/src/wifi.proto
index 72f11e0..b29c992 100644
--- a/proto/src/wifi.proto
+++ b/proto/src/wifi.proto
@@ -457,6 +457,11 @@
// Identifier for experimental scoring parameter settings.
optional string score_experiment_id = 117;
+ // Histogram of the EAP method type of all installed Passpoint profiles
+ repeated PasspointProfileTypeCount installed_passpoint_profile_type = 123;
+
+ // Hardware revision (EVT, DVT, PVT etc.)
+ optional string hardware_revision = 124;
}
// Information that gets logged for every WiFi connection.
@@ -1503,3 +1508,31 @@
optional int32 count = 2;
}
}
+
+message PasspointProfileTypeCount {
+ enum EapMethod {
+ // Unknown Type
+ TYPE_UNKNOWN = 0;
+
+ // EAP_TLS (13)
+ TYPE_EAP_TLS = 1;
+
+ // EAP_TTLS (21)
+ TYPE_EAP_TTLS = 2;
+
+ // EAP_SIM (18)
+ TYPE_EAP_SIM = 3;
+
+ // EAP_AKA (23)
+ TYPE_EAP_AKA = 4;
+
+ // EAP_AKA_PRIME (50)
+ TYPE_EAP_AKA_PRIME = 5;
+ }
+
+ // Eap method type set in Passpoint profile
+ optional EapMethod eap_method_type = 1;
+
+ // Num of installed Passpoint profile with same eap method
+ optional int32 count = 2;
+}
diff --git a/services/autofill/java/com/android/server/autofill/ui/SaveUi.java b/services/autofill/java/com/android/server/autofill/ui/SaveUi.java
index dc84498..5882303 100644
--- a/services/autofill/java/com/android/server/autofill/ui/SaveUi.java
+++ b/services/autofill/java/com/android/server/autofill/ui/SaveUi.java
@@ -81,6 +81,13 @@
void onDestroy();
}
+ /**
+ * Wrapper that guarantees that only one callback is triggered by ignoring further calls after
+ * it's destroyed.
+ *
+ * <p>It's needed becase {@link #onCancel(IntentSender)} is always called when the Save UI
+ * dialog is dismissed.
+ */
private class OneTimeListener implements OnSaveListener {
private final OnSaveListener mRealListener;
@@ -96,7 +103,6 @@
if (mDone) {
return;
}
- mDone = true;
mRealListener.onSave();
}
@@ -106,7 +112,6 @@
if (mDone) {
return;
}
- mDone = true;
mRealListener.onCancel(listener);
}
diff --git a/services/core/java/com/android/server/BatteryService.java b/services/core/java/com/android/server/BatteryService.java
index 87647ca..155dcee 100644
--- a/services/core/java/com/android/server/BatteryService.java
+++ b/services/core/java/com/android/server/BatteryService.java
@@ -625,7 +625,7 @@
// them will get the new sequence number at that point. (See for example how testing
// of JobScheduler's BatteryController works.)
sendBatteryChangedIntentLocked();
- if (mLastBatteryLevel != mHealthInfo.batteryLevel) {
+ if (mLastBatteryLevel != mHealthInfo.batteryLevel || mLastPlugType != mPlugType) {
sendBatteryLevelChangedIntentLocked();
}
diff --git a/services/core/java/com/android/server/PinnerService.java b/services/core/java/com/android/server/PinnerService.java
index a05a3e7..0deaee7 100644
--- a/services/core/java/com/android/server/PinnerService.java
+++ b/services/core/java/com/android/server/PinnerService.java
@@ -43,6 +43,7 @@
import android.os.Message;
import android.os.RemoteException;
import android.os.UserHandle;
+import android.os.UserManager;
import android.provider.MediaStore;
import android.provider.Settings;
import android.system.ErrnoException;
@@ -104,6 +105,7 @@
private final Context mContext;
private final ActivityManagerInternal mAmInternal;
private final IActivityManager mAm;
+ private final UserManager mUserManager;
/** The list of the statically pinned files. */
@GuardedBy("this")
@@ -165,6 +167,8 @@
mAmInternal = LocalServices.getService(ActivityManagerInternal.class);
mAm = ActivityManager.getService();
+ mUserManager = mContext.getSystemService(UserManager.class);
+
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
filter.addDataScheme("package");
@@ -195,12 +199,16 @@
*/
@Override
public void onSwitchUser(int userHandle) {
- sendPinAppsMessage(userHandle);
+ if (!mUserManager.isManagedProfile(userHandle)) {
+ sendPinAppsMessage(userHandle);
+ }
}
@Override
public void onUnlockUser(int userHandle) {
- sendPinAppsMessage(userHandle);
+ if (!mUserManager.isManagedProfile(userHandle)) {
+ sendPinAppsMessage(userHandle);
+ }
}
/**
diff --git a/services/core/java/com/android/server/am/ActivityManagerConstants.java b/services/core/java/com/android/server/am/ActivityManagerConstants.java
index 6550d06..9bf72fb 100644
--- a/services/core/java/com/android/server/am/ActivityManagerConstants.java
+++ b/services/core/java/com/android/server/am/ActivityManagerConstants.java
@@ -207,6 +207,10 @@
// Indicates if the processes need to be started asynchronously.
public boolean FLAG_PROCESS_START_ASYNC = DEFAULT_PROCESS_START_ASYNC;
+ // Indicates whether the activity starts logging is enabled.
+ // Controlled by Settings.Global.ACTIVITY_STARTS_LOGGING_ENABLED
+ boolean mFlagActivityStartsLoggingEnabled;
+
private final ActivityManagerService mService;
private ContentResolver mResolver;
private final KeyValueListParser mParser = new KeyValueListParser(',');
@@ -235,6 +239,12 @@
// memory trimming.
public int CUR_TRIM_CACHED_PROCESSES;
+ private static final Uri ACTIVITY_MANAGER_CONSTANTS_URI = Settings.Global.getUriFor(
+ Settings.Global.ACTIVITY_MANAGER_CONSTANTS);
+
+ private static final Uri ACTIVITY_STARTS_LOGGING_ENABLED_URI = Settings.Global.getUriFor(
+ Settings.Global.ACTIVITY_STARTS_LOGGING_ENABLED);
+
public ActivityManagerConstants(ActivityManagerService service, Handler handler) {
super(handler);
mService = service;
@@ -243,9 +253,10 @@
public void start(ContentResolver resolver) {
mResolver = resolver;
- mResolver.registerContentObserver(Settings.Global.getUriFor(
- Settings.Global.ACTIVITY_MANAGER_CONSTANTS), false, this);
+ mResolver.registerContentObserver(ACTIVITY_MANAGER_CONSTANTS_URI, false, this);
+ mResolver.registerContentObserver(ACTIVITY_STARTS_LOGGING_ENABLED_URI, false, this);
updateConstants();
+ updateActivityStartsLoggingEnabled();
}
public void setOverrideMaxCachedProcesses(int value) {
@@ -263,7 +274,12 @@
@Override
public void onChange(boolean selfChange, Uri uri) {
- updateConstants();
+ if (uri == null) return;
+ if (ACTIVITY_MANAGER_CONSTANTS_URI.equals(uri)) {
+ updateConstants();
+ } else if (ACTIVITY_STARTS_LOGGING_ENABLED_URI.equals(uri)) {
+ updateActivityStartsLoggingEnabled();
+ }
}
private void updateConstants() {
@@ -337,6 +353,11 @@
}
}
+ private void updateActivityStartsLoggingEnabled() {
+ mFlagActivityStartsLoggingEnabled = Settings.Global.getInt(mResolver,
+ Settings.Global.ACTIVITY_STARTS_LOGGING_ENABLED, 0) == 1;
+ }
+
private void updateMaxCachedProcesses() {
CUR_MAX_CACHED_PROCESSES = mOverrideMaxCachedProcesses < 0
? MAX_CACHED_PROCESSES : mOverrideMaxCachedProcesses;
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 189506c..2861600 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -5591,7 +5591,7 @@
// TODO: Switch to user app stacks here.
int ret = mActivityStartController.startActivities(caller, -1, callingPackage,
intents, resolvedTypes, resultTo, SafeActivityOptions.fromBundle(bOptions), userId,
- reason);
+ reason, null /* originatingPendingIntent */);
return ret;
}
@@ -9629,10 +9629,17 @@
}
}
- // If we're extending a persistable grant, then we always need to create
- // the grant data structure so that take/release APIs work
+ // Figure out the value returned when access is allowed
+ final int allowedResult;
if ((modeFlags & Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION) != 0) {
- return targetUid;
+ // If we're extending a persistable grant, then we need to return
+ // "targetUid" so that we always create a grant data structure to
+ // support take/release APIs
+ allowedResult = targetUid;
+ } else {
+ // Otherwise, we can return "-1" to indicate that no grant data
+ // structures need to be created
+ allowedResult = -1;
}
if (targetUid >= 0) {
@@ -9641,7 +9648,7 @@
// No need to grant the target this permission.
if (DEBUG_URI_PERMISSION) Slog.v(TAG_URI_PERMISSION,
"Target " + targetPkg + " already has full permission to " + grantUri);
- return -1;
+ return allowedResult;
}
} else {
// First... there is no target package, so can anyone access it?
@@ -9676,7 +9683,7 @@
}
}
if (allowed) {
- return -1;
+ return allowedResult;
}
}
@@ -11058,6 +11065,20 @@
}
}
+ /**
+ * @return whitelist tag for a uid from mPendingTempWhitelist, null if not currently on
+ * the whitelist
+ */
+ String getPendingTempWhitelistTagForUidLocked(int uid) {
+ final PendingTempWhitelist ptw = mPendingTempWhitelist.get(uid);
+ return ptw != null ? ptw.tag : null;
+ }
+
+ @VisibleForTesting
+ boolean isActivityStartsLoggingEnabled() {
+ return mConstants.mFlagActivityStartsLoggingEnabled;
+ }
+
@Override
public void moveStackToDisplay(int stackId, int displayId) {
enforceCallingPermission(INTERNAL_SYSTEM_WINDOW, "moveStackToDisplay()");
@@ -26510,7 +26531,7 @@
packageUid, packageName,
intents, resolvedTypes, null /* resultTo */,
SafeActivityOptions.fromBundle(bOptions), userId,
- false /* validateIncomingUser */);
+ false /* validateIncomingUser */, null /* originatingPendingIntent */);
}
}
diff --git a/services/core/java/com/android/server/am/ActivityMetricsLogger.java b/services/core/java/com/android/server/am/ActivityMetricsLogger.java
index 47d0423..9ffa662 100644
--- a/services/core/java/com/android/server/am/ActivityMetricsLogger.java
+++ b/services/core/java/com/android/server/am/ActivityMetricsLogger.java
@@ -2,6 +2,7 @@
import static android.app.ActivityManager.START_SUCCESS;
import static android.app.ActivityManager.START_TASK_TO_FRONT;
+import static android.app.ActivityManager.processStateAmToProto;
import static android.app.ActivityManagerInternal.APP_TRANSITION_TIMEOUT;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
@@ -9,6 +10,7 @@
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.ACTION_ACTIVITY_START;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.APP_TRANSITION;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.APP_TRANSITION_BIND_APPLICATION_DELAY_MS;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.APP_TRANSITION_CALLING_PACKAGE_NAME;
@@ -21,8 +23,48 @@
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.APP_TRANSITION_REPORTED_DRAWN_MS;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.APP_TRANSITION_STARTING_WINDOW_DELAY_MS;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.APP_TRANSITION_WINDOWS_DRAWN_DELAY_MS;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_ACTIVITY_RECORD_FLAGS;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_ACTIVITY_RECORD_IS_FULLSCREEN;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_ACTIVITY_RECORD_IS_NO_DISPLAY;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_ACTIVITY_RECORD_IS_VISIBLE;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_ACTIVITY_RECORD_IS_VISIBLE_IGNORING_KEYGUARD;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_ACTIVITY_RECORD_MILLIS_SINCE_LAST_LAUNCH;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_ACTIVITY_RECORD_MILLIS_SINCE_LAST_VISIBLE;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_ACTIVITY_RECORD_LAUNCH_MODE;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_ACTIVITY_RECORD_PROCESS_NAME;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_ACTIVITY_RECORD_REAL_ACTIVITY;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_ACTIVITY_RECORD_RESULT_TO_PKG_NAME;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_ACTIVITY_RECORD_RESULT_TO_SHORT_COMPONENT_NAME;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_ACTIVITY_RECORD_SHORT_COMPONENT_NAME;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_ACTIVITY_RECORD_TARGET_ACTIVITY;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_CALLING_PACKAGE_NAME;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_CALLING_UID;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_CALLING_UID_HAS_ANY_VISIBLE_WINDOW;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_CALLING_UID_PROC_STATE;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_CLASS_NAME;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_COMING_FROM_PENDING_INTENT;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_INSTANT_APP_LAUNCH_TOKEN;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_INTENT_ACTION;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_PROCESS_RECORD_CUR_PROC_STATE;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_PROCESS_RECORD_HAS_CLIENT_ACTIVITIES;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_PROCESS_RECORD_HAS_FOREGROUND_ACTIVITIES;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_PROCESS_RECORD_HAS_FOREGROUND_SERVICES;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_PROCESS_RECORD_HAS_OVERLAY_UI;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_PROCESS_RECORD_HAS_TOP_UI;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_PROCESS_RECORD_MILLIS_SINCE_FG_INTERACTION;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_PROCESS_RECORD_MILLIS_SINCE_LAST_INTERACTION_EVENT;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_PROCESS_RECORD_MILLIS_SINCE_UNIMPORTANT;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_PROCESS_RECORD_PENDING_UI_CLEAN;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_PROCESS_RECORD_PROCESS_NAME;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_REAL_CALLING_UID;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_REAL_CALLING_UID_PROC_STATE;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_REAL_CALLING_UID_HAS_ANY_VISIBLE_WINDOW;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_TARGET_PACKAGE_NAME;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_TARGET_SHORT_COMPONENT_NAME;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_TARGET_UID;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_TARGET_UID_HAS_ANY_VISIBLE_WINDOW;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_TARGET_UID_PROC_STATE;
+import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_TARGET_WHITELIST_TAG;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.PACKAGE_OPTIMIZATION_COMPILATION_REASON;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.PACKAGE_OPTIMIZATION_COMPILATION_FILTER;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.TYPE_TRANSITION_COLD_LAUNCH;
@@ -37,6 +79,7 @@
import static com.android.server.am.MemoryStatUtil.readMemoryStatFromFilesystem;
import android.content.Context;
+import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.dex.ArtManagerInternal;
import android.content.pm.dex.PackageOptimizationInfo;
@@ -622,6 +665,95 @@
startupTimeMs);
}
+ void logActivityStart(Intent intent, ProcessRecord callerApp, ActivityRecord r,
+ int callingUid, String callingPackage, int callingUidProcState,
+ boolean callingUidHasAnyVisibleWindow,
+ int realCallingUid, int realCallingUidProcState,
+ boolean realCallingUidHasAnyVisibleWindow,
+ int targetUid, String targetPackage, int targetUidProcState,
+ boolean targetUidHasAnyVisibleWindow, String targetWhitelistTag,
+ boolean comingFromPendingIntent) {
+
+ final long nowElapsed = SystemClock.elapsedRealtime();
+ final long nowUptime = SystemClock.uptimeMillis();
+ final LogMaker builder = new LogMaker(ACTION_ACTIVITY_START);
+ builder.setTimestamp(System.currentTimeMillis());
+ builder.addTaggedData(FIELD_CALLING_UID, callingUid);
+ builder.addTaggedData(FIELD_CALLING_PACKAGE_NAME, callingPackage);
+ builder.addTaggedData(FIELD_CALLING_UID_PROC_STATE,
+ processStateAmToProto(callingUidProcState));
+ builder.addTaggedData(FIELD_CALLING_UID_HAS_ANY_VISIBLE_WINDOW,
+ callingUidHasAnyVisibleWindow ? 1 : 0);
+ builder.addTaggedData(FIELD_REAL_CALLING_UID, realCallingUid);
+ builder.addTaggedData(FIELD_REAL_CALLING_UID_PROC_STATE,
+ processStateAmToProto(realCallingUidProcState));
+ builder.addTaggedData(FIELD_REAL_CALLING_UID_HAS_ANY_VISIBLE_WINDOW,
+ realCallingUidHasAnyVisibleWindow ? 1 : 0);
+ builder.addTaggedData(FIELD_TARGET_UID, targetUid);
+ builder.addTaggedData(FIELD_TARGET_PACKAGE_NAME, targetPackage);
+ builder.addTaggedData(FIELD_TARGET_UID_PROC_STATE,
+ processStateAmToProto(targetUidProcState));
+ builder.addTaggedData(FIELD_TARGET_UID_HAS_ANY_VISIBLE_WINDOW,
+ targetUidHasAnyVisibleWindow ? 1 : 0);
+ builder.addTaggedData(FIELD_TARGET_WHITELIST_TAG, targetWhitelistTag);
+ builder.addTaggedData(FIELD_TARGET_SHORT_COMPONENT_NAME, r.shortComponentName);
+ builder.addTaggedData(FIELD_COMING_FROM_PENDING_INTENT, comingFromPendingIntent ? 1 : 0);
+ builder.addTaggedData(FIELD_INTENT_ACTION, intent.getAction());
+ if (callerApp != null) {
+ builder.addTaggedData(FIELD_PROCESS_RECORD_PROCESS_NAME, callerApp.processName);
+ builder.addTaggedData(FIELD_PROCESS_RECORD_CUR_PROC_STATE,
+ processStateAmToProto(callerApp.curProcState));
+ builder.addTaggedData(FIELD_PROCESS_RECORD_HAS_CLIENT_ACTIVITIES,
+ callerApp.hasClientActivities ? 1 : 0);
+ builder.addTaggedData(FIELD_PROCESS_RECORD_HAS_FOREGROUND_SERVICES,
+ callerApp.hasForegroundServices() ? 1 : 0);
+ builder.addTaggedData(FIELD_PROCESS_RECORD_HAS_FOREGROUND_ACTIVITIES,
+ callerApp.foregroundActivities ? 1 : 0);
+ builder.addTaggedData(FIELD_PROCESS_RECORD_HAS_TOP_UI, callerApp.hasTopUi ? 1 : 0);
+ builder.addTaggedData(FIELD_PROCESS_RECORD_HAS_OVERLAY_UI,
+ callerApp.hasOverlayUi ? 1 : 0);
+ builder.addTaggedData(FIELD_PROCESS_RECORD_PENDING_UI_CLEAN,
+ callerApp.pendingUiClean ? 1 : 0);
+ if (callerApp.interactionEventTime != 0) {
+ builder.addTaggedData(FIELD_PROCESS_RECORD_MILLIS_SINCE_LAST_INTERACTION_EVENT,
+ (nowElapsed - callerApp.interactionEventTime));
+ }
+ if (callerApp.fgInteractionTime != 0) {
+ builder.addTaggedData(FIELD_PROCESS_RECORD_MILLIS_SINCE_FG_INTERACTION,
+ (nowElapsed - callerApp.fgInteractionTime));
+ }
+ if (callerApp.whenUnimportant != 0) {
+ builder.addTaggedData(FIELD_PROCESS_RECORD_MILLIS_SINCE_UNIMPORTANT,
+ (nowUptime - callerApp.whenUnimportant));
+ }
+ }
+ builder.addTaggedData(FIELD_ACTIVITY_RECORD_LAUNCH_MODE, r.info.launchMode);
+ builder.addTaggedData(FIELD_ACTIVITY_RECORD_TARGET_ACTIVITY, r.info.targetActivity);
+ builder.addTaggedData(FIELD_ACTIVITY_RECORD_FLAGS, r.info.flags);
+ builder.addTaggedData(FIELD_ACTIVITY_RECORD_REAL_ACTIVITY, r.realActivity.toShortString());
+ builder.addTaggedData(FIELD_ACTIVITY_RECORD_SHORT_COMPONENT_NAME, r.shortComponentName);
+ builder.addTaggedData(FIELD_ACTIVITY_RECORD_PROCESS_NAME, r.processName);
+ builder.addTaggedData(FIELD_ACTIVITY_RECORD_IS_FULLSCREEN, r.fullscreen ? 1 : 0);
+ builder.addTaggedData(FIELD_ACTIVITY_RECORD_IS_NO_DISPLAY, r.noDisplay ? 1 : 0);
+ if (r.lastVisibleTime != 0) {
+ builder.addTaggedData(FIELD_ACTIVITY_RECORD_MILLIS_SINCE_LAST_VISIBLE,
+ (nowUptime - r.lastVisibleTime));
+ }
+ if (r.resultTo != null) {
+ builder.addTaggedData(FIELD_ACTIVITY_RECORD_RESULT_TO_PKG_NAME, r.resultTo.packageName);
+ builder.addTaggedData(FIELD_ACTIVITY_RECORD_RESULT_TO_SHORT_COMPONENT_NAME,
+ r.resultTo.shortComponentName);
+ }
+ builder.addTaggedData(FIELD_ACTIVITY_RECORD_IS_VISIBLE, r.visible ? 1 : 0);
+ builder.addTaggedData(FIELD_ACTIVITY_RECORD_IS_VISIBLE_IGNORING_KEYGUARD,
+ r.visibleIgnoringKeyguard ? 1 : 0);
+ if (r.lastLaunchTime != 0) {
+ builder.addTaggedData(FIELD_ACTIVITY_RECORD_MILLIS_SINCE_LAST_LAUNCH,
+ (nowUptime - r.lastLaunchTime));
+ }
+ mMetricsLogger.write(builder);
+ }
+
private int getTransitionType(WindowingModeTransitionInfo info) {
if (info.currentTransitionProcessRunning) {
if (info.startResult == START_SUCCESS) {
diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java
index 75f2723..60f79f72 100644
--- a/services/core/java/com/android/server/am/ActivityRecord.java
+++ b/services/core/java/com/android/server/am/ActivityRecord.java
@@ -694,9 +694,13 @@
final boolean inPictureInPictureMode = inPinnedWindowingMode() && targetStackBounds != null;
if (inPictureInPictureMode != mLastReportedPictureInPictureMode || forceUpdate) {
// Picture-in-picture mode changes also trigger a multi-window mode change as well, so
- // update that here in order
+ // update that here in order. Set the last reported MW state to the same as the PiP
+ // state since we haven't yet actually resized the task (these callbacks need to
+ // preceed the configuration change from the resiez.
+ // TODO(110009072): Once we move these callbacks to the client, remove all logic related
+ // to forcing the update of the picture-in-picture mode as a part of the PiP animation.
mLastReportedPictureInPictureMode = inPictureInPictureMode;
- mLastReportedMultiWindowMode = inMultiWindowMode();
+ mLastReportedMultiWindowMode = inPictureInPictureMode;
final Configuration newConfig = task.computeNewOverrideConfigurationForBounds(
targetStackBounds, null);
schedulePictureInPictureModeChanged(newConfig);
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index c520101..2ae056f 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -4853,7 +4853,7 @@
return mService.getActivityStartController().startActivityInPackage(
task.mCallingUid, callingPid, callingUid, callingPackage, intent, null, null,
null, 0, 0, options, userId, task, "startActivityFromRecents",
- false /* validateIncomingUser */);
+ false /* validateIncomingUser */, null /* originatingPendingIntent */);
} finally {
if (windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY && task != null) {
// If we are launching the task in the docked stack, put it into resizing mode so
diff --git a/services/core/java/com/android/server/am/ActivityStartController.java b/services/core/java/com/android/server/am/ActivityStartController.java
index a7c3200..edcf6e7 100644
--- a/services/core/java/com/android/server/am/ActivityStartController.java
+++ b/services/core/java/com/android/server/am/ActivityStartController.java
@@ -248,7 +248,8 @@
final int startActivityInPackage(int uid, int realCallingPid, int realCallingUid,
String callingPackage, Intent intent, String resolvedType, IBinder resultTo,
String resultWho, int requestCode, int startFlags, SafeActivityOptions options,
- int userId, TaskRecord inTask, String reason, boolean validateIncomingUser) {
+ int userId, TaskRecord inTask, String reason, boolean validateIncomingUser,
+ PendingIntentRecord originatingPendingIntent) {
userId = checkTargetUser(userId, validateIncomingUser, realCallingPid, realCallingUid,
reason);
@@ -267,6 +268,7 @@
.setActivityOptions(options)
.setMayWait(userId)
.setInTask(inTask)
+ .setOriginatingPendingIntent(originatingPendingIntent)
.execute();
}
@@ -278,10 +280,12 @@
* @param intents Intents to start.
* @param userId Start the intents on this user.
* @param validateIncomingUser Set true to skip checking {@code userId} with the calling UID.
+ * @param originatingPendingIntent PendingIntentRecord that originated this activity start or
+ * null if not originated by PendingIntent
*/
final int startActivitiesInPackage(int uid, String callingPackage, Intent[] intents,
String[] resolvedTypes, IBinder resultTo, SafeActivityOptions options, int userId,
- boolean validateIncomingUser) {
+ boolean validateIncomingUser, PendingIntentRecord originatingPendingIntent) {
final String reason = "startActivityInPackage";
@@ -290,12 +294,12 @@
// TODO: Switch to user app stacks here.
return startActivities(null, uid, callingPackage, intents, resolvedTypes, resultTo, options,
- userId, reason);
+ userId, reason, originatingPendingIntent);
}
int startActivities(IApplicationThread caller, int callingUid, String callingPackage,
Intent[] intents, String[] resolvedTypes, IBinder resultTo, SafeActivityOptions options,
- int userId, String reason) {
+ int userId, String reason, PendingIntentRecord originatingPendingIntent) {
if (intents == null) {
throw new NullPointerException("intents is null");
}
@@ -374,6 +378,7 @@
// Top activity decides on animation being run, so we allow only for the
// top one as otherwise an activity below might consume it.
.setAllowPendingRemoteAnimationRegistryLookup(top /* allowLookup*/)
+ .setOriginatingPendingIntent(originatingPendingIntent)
.execute();
if (res < 0) {
diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java
index 73e3d33..00ba3a6 100644
--- a/services/core/java/com/android/server/am/ActivityStarter.java
+++ b/services/core/java/com/android/server/am/ActivityStarter.java
@@ -99,6 +99,7 @@
import android.os.IBinder;
import android.os.RemoteException;
import android.os.SystemClock;
+import android.os.Trace;
import android.os.UserHandle;
import android.os.UserManager;
import android.service.voice.IVoiceInteractionSession;
@@ -313,6 +314,7 @@
int userId;
WaitResult waitResult;
int filterCallingUid;
+ PendingIntentRecord originatingPendingIntent;
/**
* If set to {@code true}, allows this activity start to look into
@@ -369,6 +371,7 @@
avoidMoveToFront = false;
allowPendingRemoteAnimationRegistryLookup = true;
filterCallingUid = UserHandle.USER_NULL;
+ originatingPendingIntent = null;
}
/**
@@ -407,6 +410,7 @@
allowPendingRemoteAnimationRegistryLookup
= request.allowPendingRemoteAnimationRegistryLookup;
filterCallingUid = request.filterCallingUid;
+ originatingPendingIntent = request.originatingPendingIntent;
}
}
@@ -490,7 +494,8 @@
mRequest.profilerInfo, mRequest.waitResult, mRequest.globalConfig,
mRequest.activityOptions, mRequest.ignoreTargetSecurity, mRequest.userId,
mRequest.inTask, mRequest.reason,
- mRequest.allowPendingRemoteAnimationRegistryLookup);
+ mRequest.allowPendingRemoteAnimationRegistryLookup,
+ mRequest.originatingPendingIntent);
} else {
return startActivity(mRequest.caller, mRequest.intent, mRequest.ephemeralIntent,
mRequest.resolvedType, mRequest.activityInfo, mRequest.resolveInfo,
@@ -500,7 +505,8 @@
mRequest.realCallingUid, mRequest.startFlags, mRequest.activityOptions,
mRequest.ignoreTargetSecurity, mRequest.componentSpecified,
mRequest.outActivity, mRequest.inTask, mRequest.reason,
- mRequest.allowPendingRemoteAnimationRegistryLookup);
+ mRequest.allowPendingRemoteAnimationRegistryLookup,
+ mRequest.originatingPendingIntent);
}
} finally {
onExecutionComplete();
@@ -532,7 +538,8 @@
String callingPackage, int realCallingPid, int realCallingUid, int startFlags,
SafeActivityOptions options, boolean ignoreTargetSecurity, boolean componentSpecified,
ActivityRecord[] outActivity, TaskRecord inTask, String reason,
- boolean allowPendingRemoteAnimationRegistryLookup) {
+ boolean allowPendingRemoteAnimationRegistryLookup,
+ PendingIntentRecord originatingPendingIntent) {
if (TextUtils.isEmpty(reason)) {
throw new IllegalArgumentException("Need to specify a reason.");
@@ -545,7 +552,7 @@
aInfo, rInfo, voiceSession, voiceInteractor, resultTo, resultWho, requestCode,
callingPid, callingUid, callingPackage, realCallingPid, realCallingUid, startFlags,
options, ignoreTargetSecurity, componentSpecified, mLastStartActivityRecord,
- inTask, allowPendingRemoteAnimationRegistryLookup);
+ inTask, allowPendingRemoteAnimationRegistryLookup, originatingPendingIntent);
if (outActivity != null) {
// mLastStartActivityRecord[0] is set in the call to startActivity above.
@@ -575,7 +582,8 @@
String callingPackage, int realCallingPid, int realCallingUid, int startFlags,
SafeActivityOptions options,
boolean ignoreTargetSecurity, boolean componentSpecified, ActivityRecord[] outActivity,
- TaskRecord inTask, boolean allowPendingRemoteAnimationRegistryLookup) {
+ TaskRecord inTask, boolean allowPendingRemoteAnimationRegistryLookup,
+ PendingIntentRecord originatingPendingIntent) {
int err = ActivityManager.START_SUCCESS;
// Pull the optional Ephemeral Installer-only bundle out of the options early.
final Bundle verificationBundle
@@ -865,10 +873,58 @@
mController.doPendingActivityLaunches(false);
+ maybeLogActivityStart(callingUid, callingPackage, realCallingUid, intent, callerApp, r,
+ originatingPendingIntent);
+
return startActivity(r, sourceRecord, voiceSession, voiceInteractor, startFlags,
true /* doResume */, checkedOptions, inTask, outActivity);
}
+ private void maybeLogActivityStart(int callingUid, String callingPackage, int realCallingUid,
+ Intent intent, ProcessRecord callerApp, ActivityRecord r,
+ PendingIntentRecord originatingPendingIntent) {
+ boolean callerAppHasForegroundActivity = (callerApp != null)
+ ? callerApp.foregroundActivities
+ : false;
+ if (!mService.isActivityStartsLoggingEnabled() || callerAppHasForegroundActivity
+ || r == null) {
+ // skip logging in this case
+ return;
+ }
+
+ try {
+ Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "logActivityStart");
+ final int callingUidProcState = mService.getUidStateLocked(callingUid);
+ final boolean callingUidHasAnyVisibleWindow =
+ mService.mWindowManager.isAnyWindowVisibleForUid(callingUid);
+ final int realCallingUidProcState = (callingUid == realCallingUid)
+ ? callingUidProcState
+ : mService.getUidStateLocked(realCallingUid);
+ final boolean realCallingUidHasAnyVisibleWindow = (callingUid == realCallingUid)
+ ? callingUidHasAnyVisibleWindow
+ : mService.mWindowManager.isAnyWindowVisibleForUid(realCallingUid);
+ final String targetPackage = r.packageName;
+ final int targetUid = (r.appInfo != null) ? r.appInfo.uid : -1;
+ final int targetUidProcState = mService.getUidStateLocked(targetUid);
+ final boolean targetUidHasAnyVisibleWindow = (targetUid != -1)
+ ? mService.mWindowManager.isAnyWindowVisibleForUid(targetUid)
+ : false;
+ final String targetWhitelistTag = (targetUid != -1)
+ ? mService.getPendingTempWhitelistTagForUidLocked(targetUid)
+ : null;
+
+ mSupervisor.getActivityMetricsLogger().logActivityStart(intent, callerApp, r,
+ callingUid, callingPackage, callingUidProcState,
+ callingUidHasAnyVisibleWindow,
+ realCallingUid, realCallingUidProcState,
+ realCallingUidHasAnyVisibleWindow,
+ targetUid, targetPackage, targetUidProcState,
+ targetUidHasAnyVisibleWindow, targetWhitelistTag,
+ (originatingPendingIntent != null));
+ } finally {
+ Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
+ }
+ }
/**
* Creates a launch intent for the given auxiliary resolution data.
@@ -949,7 +1005,8 @@
ProfilerInfo profilerInfo, WaitResult outResult,
Configuration globalConfig, SafeActivityOptions options, boolean ignoreTargetSecurity,
int userId, TaskRecord inTask, String reason,
- boolean allowPendingRemoteAnimationRegistryLookup) {
+ boolean allowPendingRemoteAnimationRegistryLookup,
+ PendingIntentRecord originatingPendingIntent) {
// Refuse possible leaked file descriptors
if (intent != null && intent.hasFileDescriptors()) {
throw new IllegalArgumentException("File descriptors passed in Intent");
@@ -1100,7 +1157,7 @@
voiceSession, voiceInteractor, resultTo, resultWho, requestCode, callingPid,
callingUid, callingPackage, realCallingPid, realCallingUid, startFlags, options,
ignoreTargetSecurity, componentSpecified, outRecord, inTask, reason,
- allowPendingRemoteAnimationRegistryLookup);
+ allowPendingRemoteAnimationRegistryLookup, originatingPendingIntent);
Binder.restoreCallingIdentity(origId);
@@ -2625,6 +2682,11 @@
return this;
}
+ ActivityStarter setOriginatingPendingIntent(PendingIntentRecord originatingPendingIntent) {
+ mRequest.originatingPendingIntent = originatingPendingIntent;
+ return this;
+ }
+
void dump(PrintWriter pw, String prefix) {
prefix = prefix + " ";
pw.print(prefix);
diff --git a/services/core/java/com/android/server/am/AppErrors.java b/services/core/java/com/android/server/am/AppErrors.java
index a6dafbb..f0e2876 100644
--- a/services/core/java/com/android/server/am/AppErrors.java
+++ b/services/core/java/com/android/server/am/AppErrors.java
@@ -484,7 +484,8 @@
task.intent, null, null, null, 0, 0,
new SafeActivityOptions(ActivityOptions.makeBasic()),
task.userId, null,
- "AppErrors", false /*validateIncomingUser*/);
+ "AppErrors", false /*validateIncomingUser*/,
+ null /* originatingPendingIntent */);
}
}
}
diff --git a/services/core/java/com/android/server/am/PendingIntentRecord.java b/services/core/java/com/android/server/am/PendingIntentRecord.java
index e0aa2a2..4e00304 100644
--- a/services/core/java/com/android/server/am/PendingIntentRecord.java
+++ b/services/core/java/com/android/server/am/PendingIntentRecord.java
@@ -307,7 +307,7 @@
} else if (finalIntent.getComponent() != null) {
finalIntent.getComponent().appendShortString(tag);
} else if (finalIntent.getData() != null) {
- tag.append(finalIntent.getData());
+ tag.append(finalIntent.getData().toSafeString());
}
owner.tempWhitelistForPendingIntentLocked(callingPid,
callingUid, uid, duration, tag.toString());
@@ -346,13 +346,15 @@
res = owner.getActivityStartController().startActivitiesInPackage(
uid, key.packageName, allIntents, allResolvedTypes,
resultTo, mergedOptions, userId,
- false /* validateIncomingUser */);
+ false /* validateIncomingUser */,
+ this /* originatingPendingIntent */);
} else {
res = owner.getActivityStartController().startActivityInPackage(uid,
callingPid, callingUid, key.packageName, finalIntent,
resolvedType, resultTo, resultWho, requestCode, 0,
mergedOptions, userId, null, "PendingIntentRecord",
- false /* validateIncomingUser */);
+ false /* validateIncomingUser */,
+ this /* originatingPendingIntent */);
}
} catch (RuntimeException e) {
Slog.w(TAG, "Unable to send startActivity intent", e);
diff --git a/services/core/java/com/android/server/am/ProcessRecord.java b/services/core/java/com/android/server/am/ProcessRecord.java
index caf52e3..28ebbb8 100644
--- a/services/core/java/com/android/server/am/ProcessRecord.java
+++ b/services/core/java/com/android/server/am/ProcessRecord.java
@@ -856,4 +856,8 @@
}
return list;
}
+
+ boolean hasForegroundServices() {
+ return foregroundServices;
+ }
}
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 3ed8e2e0..8304e26 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -2119,6 +2119,10 @@
enforceSystemOrSystemUI("setNotificationsEnabledForPackage");
mRankingHelper.setEnabled(pkg, uid, enabled);
+ mMetricsLogger.write(new LogMaker(MetricsEvent.ACTION_BAN_APP_NOTES)
+ .setType(MetricsEvent.TYPE_ACTION)
+ .setPackageName(pkg)
+ .setSubtype(enabled ? 1 : 0));
// Now, cancel any outstanding notifications that are part of a just-disabled app
if (!enabled) {
cancelAllNotificationsInt(MY_UID, MY_PID, pkg, null, 0, 0, true,
diff --git a/services/core/java/com/android/server/notification/ZenModeConditions.java b/services/core/java/com/android/server/notification/ZenModeConditions.java
index 8013f7a..b080a73 100644
--- a/services/core/java/com/android/server/notification/ZenModeConditions.java
+++ b/services/core/java/com/android/server/notification/ZenModeConditions.java
@@ -19,7 +19,6 @@
import android.content.ComponentName;
import android.net.Uri;
import android.service.notification.Condition;
-import android.service.notification.IConditionListener;
import android.service.notification.IConditionProvider;
import android.service.notification.ZenModeConfig;
import android.service.notification.ZenModeConfig.ZenRule;
@@ -27,6 +26,8 @@
import android.util.ArraySet;
import android.util.Log;
+import com.android.internal.annotations.VisibleForTesting;
+
import java.io.PrintWriter;
import java.util.Objects;
@@ -36,7 +37,9 @@
private final ZenModeHelper mHelper;
private final ConditionProviders mConditionProviders;
- private final ArrayMap<Uri, ComponentName> mSubscriptions = new ArrayMap<>();
+
+ @VisibleForTesting
+ protected final ArrayMap<Uri, ComponentName> mSubscriptions = new ArrayMap<>();
private boolean mFirstEvaluation = true;
@@ -152,7 +155,8 @@
if (current != null) {
current.add(id);
}
- if (processSubscriptions && trigger != null && trigger.equals(rule.component)) {
+ if (processSubscriptions && ((trigger != null && trigger.equals(rule.component))
+ || isSystemCondition)) {
if (DEBUG) Log.d(TAG, "Subscribing to " + rule.component);
if (mConditionProviders.subscribeIfNecessary(rule.component, rule.conditionId)) {
synchronized (mSubscriptions) {
diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java
index 6ab2c43..0c42f8a 100644
--- a/services/core/java/com/android/server/notification/ZenModeHelper.java
+++ b/services/core/java/com/android/server/notification/ZenModeHelper.java
@@ -102,7 +102,7 @@
private final ZenModeFiltering mFiltering;
protected final RingerModeDelegate mRingerModeDelegate = new
RingerModeDelegate();
- private final ZenModeConditions mConditions;
+ @VisibleForTesting protected final ZenModeConditions mConditions;
private final SparseArray<ZenModeConfig> mConfigs = new SparseArray<>();
private final Metrics mMetrics = new Metrics();
private final ConditionProviders.Config mServiceConfig;
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index f30372b..670c1af 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -12344,7 +12344,8 @@
if (DEBUG_REMOVE) Log.d(TAG, " Activities: " + r);
}
- mPermissionManager.removeAllPermissions(pkg, chatty);
+ final ArrayList<String> allPackageNames = new ArrayList<>(mPackages.keySet());
+ mPermissionManager.removeAllPermissions(pkg, allPackageNames, mPermissionCallback, chatty);
N = pkg.instrumentation.size();
r = null;
@@ -21952,9 +21953,6 @@
//TODO: b/111402650
private void disableSkuSpecificApps() {
- if (!mIsUpgrade && !mFirstBoot) {
- return;
- }
String apkList[] = mContext.getResources().getStringArray(
R.array.config_disableApksUnlessMatchedSku_apk_list);
String skuArray[] = mContext.getResources().getStringArray(
@@ -21968,7 +21966,9 @@
}
for (String packageName : apkList) {
setSystemAppHiddenUntilInstalled(packageName, true);
- setSystemAppInstallState(packageName, false, ActivityManager.getCurrentUser());
+ for (UserInfo user : sUserManager.getUsers(false)) {
+ setSystemAppInstallState(packageName, false, user.id);
+ }
}
}
diff --git a/services/core/java/com/android/server/pm/permission/PermissionManagerInternal.java b/services/core/java/com/android/server/pm/permission/PermissionManagerInternal.java
index a042fed..c3f23a8 100644
--- a/services/core/java/com/android/server/pm/permission/PermissionManagerInternal.java
+++ b/services/core/java/com/android/server/pm/permission/PermissionManagerInternal.java
@@ -115,7 +115,11 @@
*/
public abstract void addAllPermissions(@NonNull PackageParser.Package pkg, boolean chatty);
public abstract void addAllPermissionGroups(@NonNull PackageParser.Package pkg, boolean chatty);
- public abstract void removeAllPermissions(@NonNull PackageParser.Package pkg, boolean chatty);
+ public abstract void removeAllPermissions(
+ @NonNull PackageParser.Package pkg,
+ @NonNull List<String> allPackageNames,
+ @Nullable PermissionCallback permissionCallback,
+ boolean chatty);
public abstract boolean addDynamicPermission(@NonNull PermissionInfo info, boolean async,
int callingUid, @Nullable PermissionCallback callback);
public abstract void removeDynamicPermission(@NonNull String permName, int callingUid,
@@ -189,4 +193,4 @@
/** HACK HACK methods to allow for partial migration of data to the PermissionManager class */
public abstract @Nullable BasePermission getPermissionTEMP(@NonNull String permName);
-}
\ No newline at end of file
+}
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 c51a724..02c9049 100644
--- a/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
+++ b/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
@@ -30,6 +30,7 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
+import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManagerInternal;
import android.content.pm.PackageParser;
@@ -37,6 +38,7 @@
import android.content.pm.PermissionInfo;
import android.content.pm.PackageParser.Package;
import android.metrics.LogMaker;
+import android.os.AsyncTask;
import android.os.Binder;
import android.os.Build;
import android.os.Handler;
@@ -455,8 +457,9 @@
" to " + newPermissionGroupName);
try {
- revokeRuntimePermission(permissionName, packageName, false,
- Process.SYSTEM_UID, userId, permissionCallback);
+ revokeRuntimePermission(permissionName, packageName,
+ mSettings.getPermission(permissionName), false,
+ Process.SYSTEM_UID, userId, permissionCallback, false);
} catch (IllegalArgumentException e) {
Slog.e(TAG, "Could not revoke " + permissionName + " from "
+ packageName, e);
@@ -549,9 +552,59 @@
}
- private void removeAllPermissions(PackageParser.Package pkg, boolean chatty) {
+ private void revokeAllPermissions(
+ @NonNull List<BasePermission> bps,
+ @NonNull List<String> allPackageNames,
+ @Nullable PermissionCallback permissionCallback) {
+ AsyncTask.execute(() -> {
+ final int numRemovedPermissions = bps.size();
+ for (int permissionNum = 0; permissionNum < numRemovedPermissions; permissionNum++) {
+ final int[] userIds = mUserManagerInt.getUserIds();
+ final int numUserIds = userIds.length;
+
+ final int numPackages = allPackageNames.size();
+ for (int packageNum = 0; packageNum < numPackages; packageNum++) {
+ final String packageName = allPackageNames.get(packageNum);
+ final ApplicationInfo applicationInfo = mPackageManagerInt.getApplicationInfo(
+ packageName, 0, Process.SYSTEM_UID, UserHandle.USER_SYSTEM);
+ if (applicationInfo != null
+ && applicationInfo.targetSdkVersion < Build.VERSION_CODES.M) {
+ continue;
+ }
+ for (int userIdNum = 0; userIdNum < numUserIds; userIdNum++) {
+ final int userId = userIds[userIdNum];
+ final String permissionName = bps.get(permissionNum).getName();
+ if (checkPermission(permissionName, packageName, UserHandle.USER_SYSTEM,
+ userId) == PackageManager.PERMISSION_GRANTED) {
+ try {
+ revokeRuntimePermission(
+ permissionName,
+ packageName,
+ bps.get(permissionNum),
+ false,
+ Process.SYSTEM_UID,
+ userId,
+ permissionCallback,
+ true);
+ } catch (IllegalArgumentException e) {
+ Slog.e(TAG, "Could not revoke " + permissionName + " from "
+ + packageName, e);
+ }
+ }
+ }
+ }
+ }
+ });
+ }
+
+ private void removeAllPermissions(
+ @NonNull PackageParser.Package pkg,
+ @NonNull List<String> allPackageNames,
+ @Nullable PermissionCallback permissionCallback,
+ boolean chatty) {
synchronized (mLock) {
int N = pkg.permissions.size();
+ List<BasePermission> bps = new ArrayList<BasePermission>(N);
StringBuilder r = null;
for (int i=0; i<N; i++) {
PackageParser.Permission p = pkg.permissions.get(i);
@@ -560,6 +613,9 @@
bp = mSettings.mPermissionTrees.get(p.info.name);
}
if (bp != null && bp.isPermission(p)) {
+ if ((p.info.getProtection() & PermissionInfo.PROTECTION_DANGEROUS) != 0) {
+ bps.add(bp);
+ }
bp.setPermission(null);
if (DEBUG_REMOVE && chatty) {
if (r == null) {
@@ -578,6 +634,7 @@
}
}
}
+ revokeAllPermissions(bps, allPackageNames, permissionCallback);
if (r != null) {
if (DEBUG_REMOVE) Log.d(TAG, " Permissions: " + r);
}
@@ -1490,9 +1547,10 @@
}
}
-
- private void revokeRuntimePermission(String permName, String packageName,
- boolean overridePolicy, int callingUid, int userId, PermissionCallback callback) {
+
+ private void revokeRuntimePermission(String permName, String packageName, BasePermission bp,
+ boolean overridePolicy, int callingUid, int userId, PermissionCallback callback,
+ boolean permissionRemoved) {
if (!mUserManagerInt.exists(userId)) {
Log.e(TAG, "No such user:" + userId);
return;
@@ -1517,7 +1575,7 @@
if (mPackageManagerInt.filterAppAccess(pkg, Binder.getCallingUid(), userId)) {
throw new IllegalArgumentException("Unknown package: " + packageName);
}
- final BasePermission bp = mSettings.getPermissionLocked(permName);
+
if (bp == null) {
throw new IllegalArgumentException("Unknown permission: " + permName);
}
@@ -2073,8 +2131,10 @@
PermissionManagerService.this.addAllPermissionGroups(pkg, chatty);
}
@Override
- public void removeAllPermissions(Package pkg, boolean chatty) {
- PermissionManagerService.this.removeAllPermissions(pkg, chatty);
+ public void removeAllPermissions(Package pkg, List<String> allPackageNames,
+ PermissionCallback permissionCallback, boolean chatty) {
+ PermissionManagerService.this.removeAllPermissions(
+ pkg, allPackageNames, permissionCallback, chatty);
}
@Override
public boolean addDynamicPermission(PermissionInfo info, boolean async, int callingUid,
@@ -2110,7 +2170,8 @@
boolean overridePolicy, int callingUid, int userId,
PermissionCallback callback) {
PermissionManagerService.this.revokeRuntimePermission(permName, packageName,
- overridePolicy, callingUid, userId, callback);
+ mSettings.getPermission(permName), overridePolicy, callingUid, userId,
+ callback, false);
}
@Override
public void updatePermissions(String packageName, Package pkg, boolean replaceGrant,
diff --git a/services/core/java/com/android/server/wm/BoundsAnimationController.java b/services/core/java/com/android/server/wm/BoundsAnimationController.java
index b2a12be..86f328d 100644
--- a/services/core/java/com/android/server/wm/BoundsAnimationController.java
+++ b/services/core/java/com/android/server/wm/BoundsAnimationController.java
@@ -31,11 +31,13 @@
import android.os.Debug;
import android.util.ArrayMap;
import android.util.Slog;
+import android.view.Choreographer;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.graphics.SfVsyncFrameCallbackProvider;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -112,6 +114,7 @@
private final Interpolator mFastOutSlowInInterpolator;
private boolean mFinishAnimationAfterTransition = false;
private final AnimationHandler mAnimationHandler;
+ private Choreographer mChoreographer;
private static final int WAIT_FOR_DRAW_TIMEOUT_MS = 3000;
@@ -123,6 +126,12 @@
mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
com.android.internal.R.interpolator.fast_out_slow_in);
mAnimationHandler = animationHandler;
+ if (animationHandler != null) {
+ // If an animation handler is provided, then ensure that it runs on the sf vsync tick
+ handler.runWithScissors(() -> mChoreographer = Choreographer.getSfInstance(),
+ 0 /* timeout */);
+ animationHandler.setProvider(new SfVsyncFrameCallbackProvider(mChoreographer));
+ }
}
@VisibleForTesting
diff --git a/services/core/java/com/android/server/wm/ForcedSeamlessRotator.java b/services/core/java/com/android/server/wm/ForcedSeamlessRotator.java
index bebc565..efb43a6 100644
--- a/services/core/java/com/android/server/wm/ForcedSeamlessRotator.java
+++ b/services/core/java/com/android/server/wm/ForcedSeamlessRotator.java
@@ -21,6 +21,7 @@
import android.graphics.Matrix;
import android.view.DisplayInfo;
+import android.view.Surface.Rotation;
import com.android.server.wm.utils.CoordinateTransforms;
@@ -65,6 +66,16 @@
}
/**
+ * Returns the rotation of the display before it started rotating.
+ *
+ * @return the old rotation of the display
+ */
+ @Rotation
+ public int getOldRotation() {
+ return mOldRotation;
+ }
+
+ /**
* Removes the transform to the window token's surface that undoes the effect of the global
* display rotation.
*
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 8bc2246..8b4a2dd 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -1005,7 +1005,6 @@
mAppTransition.registerListenerLocked(mActivityManagerAppTransitionNotifier);
final AnimationHandler animationHandler = new AnimationHandler();
- animationHandler.setProvider(new SfVsyncFrameCallbackProvider());
mBoundsAnimationController = new BoundsAnimationController(context, mAppTransition,
AnimationThread.getHandler(), animationHandler);
@@ -6221,6 +6220,17 @@
}
/**
+ * Returns true if the callingUid has any window currently visible to the user.
+ */
+ public boolean isAnyWindowVisibleForUid(int callingUid) {
+ synchronized (mWindowMap) {
+ return mRoot.forAllWindows(w -> {
+ return w.getOwningUid() == callingUid && w.isVisible();
+ }, true /* traverseTopToBottom */);
+ }
+ }
+
+ /**
* Called when a task has been removed from the recent tasks list.
* <p>
* Note: This doesn't go through {@link TaskWindowContainerController} yet as the window
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 009f393..1ae680f 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -681,6 +681,10 @@
void forceSeamlesslyRotateIfAllowed(int oldRotation, int rotation) {
if (mForceSeamlesslyRotate) {
+ if (mPendingForcedSeamlessRotate != null) {
+ oldRotation = mPendingForcedSeamlessRotate.getOldRotation();
+ }
+
mPendingForcedSeamlessRotate = new ForcedSeamlessRotator(
oldRotation, rotation, getDisplayInfo());
mPendingForcedSeamlessRotate.unrotate(this.mToken);
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index b74a582..6ee7d49 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -4572,10 +4572,12 @@
enforceFullCrossUsersPermission(userHandle);
synchronized (getLockObject()) {
if (!isCallerWithSystemUid()) {
- // This API can only be called by an active device admin,
- // so try to retrieve it to check that the caller is one.
- getActiveAdminForCallerLocked(
- null, DeviceAdminInfo.USES_POLICY_WATCH_LOGIN, parent);
+ // This API can be called by an active device admin or by keyguard code.
+ if (mContext.checkCallingPermission(permission.ACCESS_KEYGUARD_SECURE_STORAGE)
+ != PackageManager.PERMISSION_GRANTED) {
+ getActiveAdminForCallerLocked(
+ null, DeviceAdminInfo.USES_POLICY_WATCH_LOGIN, parent);
+ }
}
DevicePolicyData policy = getUserDataUnchecked(getCredentialOwner(userHandle, parent));
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 1880e9f..3c833d8 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -28,6 +28,7 @@
import android.content.res.Configuration;
import android.content.res.Resources.Theme;
import android.database.sqlite.SQLiteCompatibilityWalFlags;
+import android.database.sqlite.SQLiteGlobal;
import android.os.BaseBundle;
import android.os.Binder;
import android.os.Build;
@@ -346,6 +347,10 @@
Binder.setWarnOnBlocking(true);
// The system server should always load safe labels
PackageItemInfo.setForceSafeLabels(true);
+
+ // Default to FULL within the system server.
+ SQLiteGlobal.sDefaultSyncMode = SQLiteGlobal.SYNC_MODE_FULL;
+
// Deactivate SQLiteCompatibilityWalFlags until settings provider is initialized
SQLiteCompatibilityWalFlags.init(null);
diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java b/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java
index 1520859..8d056fc 100644
--- a/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java
+++ b/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java
@@ -53,6 +53,7 @@
import org.junit.runner.RunWith;
import org.junit.Test;
+import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static android.content.Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED;
import static com.android.server.am.ActivityManagerService.ANIMATE;
@@ -62,11 +63,13 @@
import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.anyObject;
+import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.times;
@@ -91,6 +94,7 @@
private ActivityManagerService mService;
private ActivityStarter mStarter;
private ActivityStartController mController;
+ private ActivityMetricsLogger mActivityMetricsLogger;
private static final int PRECONDITION_NO_CALLER_APP = 1;
private static final int PRECONDITION_NO_INTENT_COMPONENT = 1 << 1;
@@ -104,11 +108,17 @@
private static final int PRECONDITION_CANNOT_START_ANY_ACTIVITY = 1 << 9;
private static final int PRECONDITION_DISALLOW_APP_SWITCHING = 1 << 10;
+ private static final int FAKE_CALLING_UID = 666;
+ private static final int FAKE_REAL_CALLING_UID = 667;
+ private static final String FAKE_CALLING_PACKAGE = "com.whatever.dude";
+
@Override
public void setUp() throws Exception {
super.setUp();
mService = createActivityManagerService();
mController = mock(ActivityStartController.class);
+ mActivityMetricsLogger = mock(ActivityMetricsLogger.class);
+ clearInvocations(mActivityMetricsLogger);
mStarter = new ActivityStarter(mController, mService, mService.mStackSupervisor,
mock(ActivityStartInterceptor.class));
}
@@ -471,4 +481,46 @@
assertTrue(stack.getAllTasks().isEmpty());
}
}
+
+ /**
+ * This test ensures that activity starts are not being logged when the logging is disabled.
+ */
+ @Test
+ public void testActivityStartsLogging_noLoggingWhenDisabled() {
+ doReturn(false).when(mService).isActivityStartsLoggingEnabled();
+ doReturn(mActivityMetricsLogger).when(mService.mStackSupervisor).getActivityMetricsLogger();
+
+ ActivityStarter starter = prepareStarter(FLAG_ACTIVITY_NEW_TASK);
+ starter.setReason("testActivityStartsLogging_noLoggingWhenDisabled").execute();
+
+ // verify logging wasn't done
+ verify(mActivityMetricsLogger, never()).logActivityStart(any(), any(), any(), anyInt(),
+ any(), anyInt(), anyBoolean(), anyInt(), anyInt(), anyBoolean(), anyInt(), any(),
+ anyInt(), anyBoolean(), any(), anyBoolean());
+ }
+
+ /**
+ * This test ensures that activity starts are being logged when the logging is enabled.
+ */
+ @Test
+ public void testActivityStartsLogging_logsWhenEnabled() {
+ // note: conveniently this package doesn't have any activity visible
+ doReturn(true).when(mService).isActivityStartsLoggingEnabled();
+ doReturn(mActivityMetricsLogger).when(mService.mStackSupervisor).getActivityMetricsLogger();
+
+ ActivityStarter starter = prepareStarter(FLAG_ACTIVITY_NEW_TASK)
+ .setCallingUid(FAKE_CALLING_UID)
+ .setRealCallingUid(FAKE_REAL_CALLING_UID)
+ .setCallingPackage(FAKE_CALLING_PACKAGE)
+ .setOriginatingPendingIntent(null);
+
+ starter.setReason("testActivityStartsLogging_logsWhenEnabled").execute();
+
+ // verify the above activity start was logged
+ verify(mActivityMetricsLogger, times(1)).logActivityStart(any(), any(), any(),
+ eq(FAKE_CALLING_UID), eq(FAKE_CALLING_PACKAGE), anyInt(), anyBoolean(),
+ eq(FAKE_REAL_CALLING_UID), anyInt(), anyBoolean(), anyInt(),
+ eq(ActivityBuilder.getDefaultComponent().getPackageName()), anyInt(), anyBoolean(),
+ any(), eq(false));
+ }
}
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java
index 63a60a4..8222c38 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java
@@ -38,6 +38,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.app.AppGlobals;
import android.app.AppOpsManager;
import android.app.NotificationManager;
import android.content.ComponentName;
@@ -49,8 +50,10 @@
import android.media.AudioManagerInternal;
import android.media.VolumePolicy;
import android.media.AudioSystem;
+import android.net.Uri;
import android.provider.Settings;
import android.provider.Settings.Global;
+import android.service.notification.Condition;
import android.service.notification.ZenModeConfig;
import android.service.notification.ZenModeConfig.ScheduleInfo;
import android.test.suitebuilder.annotation.SmallTest;
@@ -61,6 +64,7 @@
import com.android.internal.R;
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
+import com.android.server.notification.ManagedServices.UserProfiles;
import com.android.internal.util.FastXmlSerializer;
import com.android.server.UiServiceTestCase;
import android.util.Slog;
@@ -83,7 +87,7 @@
@TestableLooper.RunWithLooper
public class ZenModeHelperTest extends UiServiceTestCase {
- @Mock ConditionProviders mConditionProviders;
+ ConditionProviders mConditionProviders;
@Mock NotificationManager mNotificationManager;
@Mock private Resources mResources;
private TestableLooper mTestableLooper;
@@ -103,6 +107,9 @@
when(mResources.getString(R.string.zen_mode_default_events_name)).thenReturn("events");
when(mContext.getSystemService(NotificationManager.class)).thenReturn(mNotificationManager);
+ mConditionProviders = new ConditionProviders(mContext, new UserProfiles(),
+ AppGlobals.getPackageManager());
+ mConditionProviders.addSystemProvider(new CountdownConditionProvider());
mZenModeHelperSpy = spy(new ZenModeHelper(mContext, mTestableLooper.getLooper(),
mConditionProviders));
}
@@ -813,6 +820,30 @@
setupZenConfigMaintained();
}
+ @Test
+ public void testCountdownConditionSubscription() throws Exception {
+ ZenModeConfig config = new ZenModeConfig();
+ mZenModeHelperSpy.mConfig = config;
+ mZenModeHelperSpy.mConditions.evaluateConfig(mZenModeHelperSpy.mConfig, null, true);
+ assertEquals(0, mZenModeHelperSpy.mConditions.mSubscriptions.size());
+
+ mZenModeHelperSpy.mConfig.manualRule = new ZenModeConfig.ZenRule();
+ Uri conditionId = ZenModeConfig.toCountdownConditionId(9000000, false);
+ mZenModeHelperSpy.mConfig.manualRule.conditionId = conditionId;
+ mZenModeHelperSpy.mConfig.manualRule.component = new ComponentName("android",
+ CountdownConditionProvider.class.getName());
+ mZenModeHelperSpy.mConfig.manualRule.condition = new Condition(conditionId, "", "", "", 0,
+ Condition.STATE_TRUE, Condition.FLAG_RELEVANT_NOW);
+ mZenModeHelperSpy.mConfig.manualRule.enabled = true;
+ ZenModeConfig originalConfig = mZenModeHelperSpy.mConfig.copy();
+
+ mZenModeHelperSpy.mConditions.evaluateConfig(mZenModeHelperSpy.mConfig, null, true);
+
+ assertEquals(true, ZenModeConfig.isValidCountdownConditionId(conditionId));
+ assertEquals(originalConfig, mZenModeHelperSpy.mConfig);
+ assertEquals(1, mZenModeHelperSpy.mConditions.mSubscriptions.size());
+ }
+
private void setupZenConfig() {
mZenModeHelperSpy.mZenMode = Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
mZenModeHelperSpy.mConfig.allowAlarms = false;
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index e0696b3..a8b39e3 100644
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -1489,6 +1489,15 @@
"always_play_remote_hold_tone_bool";
/**
+ * When true, the Telephony stack will automatically turn off airplane mode and retry a wifi
+ * emergency call over the cell network if the initial attempt at dialing was met with a SIP 308
+ * error.
+ * @hide
+ */
+ public static final String KEY_AUTO_RETRY_FAILED_WIFI_EMERGENCY_CALL =
+ "auto_retry_failed_wifi_emergency_call";
+
+ /**
* When true, indicates that adding a call is disabled when there is an ongoing video call
* or when there is an ongoing call on wifi which was downgraded from video and VoWifi is
* turned off.
@@ -2016,6 +2025,7 @@
sDefaults.putBoolean(KEY_ALLOW_HOLD_IN_IMS_CALL_BOOL, true);
sDefaults.putBoolean(KEY_CARRIER_ALLOW_DEFLECT_IMS_CALL_BOOL, false);
sDefaults.putBoolean(KEY_ALWAYS_PLAY_REMOTE_HOLD_TONE_BOOL, false);
+ sDefaults.putBoolean(KEY_AUTO_RETRY_FAILED_WIFI_EMERGENCY_CALL, false);
sDefaults.putBoolean(KEY_ADDITIONAL_CALL_SETTING_BOOL, true);
sDefaults.putBoolean(KEY_ALLOW_EMERGENCY_NUMBERS_IN_CALL_LOG_BOOL, false);
sDefaults.putStringArray(KEY_UNLOGGABLE_NUMBERS_STRING_ARRAY, null);