diff options
author | Justin Klaassen <justinklaassen@google.com> | 2017-10-10 15:20:13 -0400 |
---|---|---|
committer | Justin Klaassen <justinklaassen@google.com> | 2017-10-10 15:20:13 -0400 |
commit | 93b7ee4fce01df52a6607f0b1965cbafdfeaf1a6 (patch) | |
tree | 49f76f879a89c256a4f65b674086be50760bdffb /android/app | |
parent | bc81c7ada5aab3806dd0b17498f5c9672c9b33c4 (diff) | |
download | android-28-93b7ee4fce01df52a6607f0b1965cbafdfeaf1a6.tar.gz |
Import Android SDK Platform P [4386628]
/google/data/ro/projects/android/fetch_artifact \
--bid 4386628 \
--target sdk_phone_armv7-win_sdk \
sdk-repo-linux-sources-4386628.zip
AndroidVersion.ApiLevel has been modified to appear as 28
Change-Id: I9b8400ac92116cae4f033d173f7a5682b26ccba9
Diffstat (limited to 'android/app')
-rw-r--r-- | android/app/Activity.java | 13 | ||||
-rw-r--r-- | android/app/ActivityManager.java | 243 | ||||
-rw-r--r-- | android/app/ActivityOptions.java | 51 | ||||
-rw-r--r-- | android/app/ActivityThread.java | 4 | ||||
-rw-r--r-- | android/app/ContextImpl.java | 15 | ||||
-rw-r--r-- | android/app/KeyguardManager.java | 2 | ||||
-rw-r--r-- | android/app/Notification.java | 64 | ||||
-rw-r--r-- | android/app/NotificationChannel.java | 119 | ||||
-rw-r--r-- | android/app/NotificationChannelGroup.java | 12 | ||||
-rw-r--r-- | android/app/NotificationManager.java | 22 | ||||
-rw-r--r-- | android/app/SharedElementCallback.java | 6 | ||||
-rw-r--r-- | android/app/StatusBarManager.java | 13 | ||||
-rw-r--r-- | android/app/SystemServiceRegistry.java | 16 | ||||
-rw-r--r-- | android/app/TaskStackListener.java | 3 | ||||
-rw-r--r-- | android/app/VrManager.java | 37 | ||||
-rw-r--r-- | android/app/WindowConfiguration.java | 82 | ||||
-rw-r--r-- | android/app/admin/DevicePolicyManager.java | 56 | ||||
-rw-r--r-- | android/app/assist/AssistStructure.java | 31 | ||||
-rw-r--r-- | android/app/job/JobInfo.java | 48 | ||||
-rw-r--r-- | android/app/timezone/RulesUpdaterContract.java | 7 |
20 files changed, 581 insertions, 263 deletions
diff --git a/android/app/Activity.java b/android/app/Activity.java index 4e258a3a..e0ac9113 100644 --- a/android/app/Activity.java +++ b/android/app/Activity.java @@ -114,6 +114,7 @@ import android.view.WindowManager; import android.view.WindowManagerGlobal; import android.view.accessibility.AccessibilityEvent; import android.view.autofill.AutofillManager; +import android.view.autofill.AutofillManager.AutofillClient; import android.view.autofill.AutofillPopupWindow; import android.view.autofill.IAutofillWindowPresenter; import android.widget.AdapterView; @@ -947,6 +948,18 @@ public class Activity extends ContextThemeWrapper return mAutofillManager; } + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(newBase); + newBase.setAutofillClient(this); + } + + /** @hide */ + @Override + public final AutofillClient getAutofillClient() { + return this; + } + /** * Called when the activity is starting. This is where most initialization * should go: calling {@link #setContentView(int)} to inflate the diff --git a/android/app/ActivityManager.java b/android/app/ActivityManager.java index a8665037..5e61727f 100644 --- a/android/app/ActivityManager.java +++ b/android/app/ActivityManager.java @@ -16,14 +16,10 @@ package android.app; -import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT; -import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; -import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS; -import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; -import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; +import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY; import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; @@ -46,6 +42,7 @@ import android.content.pm.IPackageDataObserver; import android.content.pm.PackageManager; import android.content.pm.ParceledListSlice; import android.content.pm.UserInfo; +import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Canvas; @@ -675,32 +672,27 @@ public class ActivityManager { /** First static stack ID. * @hide */ - public static final int FIRST_STATIC_STACK_ID = 0; + private static final int FIRST_STATIC_STACK_ID = 0; - /** Home activity stack ID. */ - public static final int HOME_STACK_ID = FIRST_STATIC_STACK_ID; - - /** ID of stack where fullscreen activities are normally launched into. */ + /** ID of stack where fullscreen activities are normally launched into. + * @hide */ public static final int FULLSCREEN_WORKSPACE_STACK_ID = 1; - /** ID of stack where freeform/resized activities are normally launched into. */ + /** ID of stack where freeform/resized activities are normally launched into. + * @hide */ public static final int FREEFORM_WORKSPACE_STACK_ID = FULLSCREEN_WORKSPACE_STACK_ID + 1; - /** ID of stack that occupies a dedicated region of the screen. */ + /** ID of stack that occupies a dedicated region of the screen. + * @hide */ public static final int DOCKED_STACK_ID = FREEFORM_WORKSPACE_STACK_ID + 1; - /** ID of stack that always on top (always visible) when it exist. */ + /** ID of stack that always on top (always visible) when it exist. + * @hide */ public static final int PINNED_STACK_ID = DOCKED_STACK_ID + 1; - /** ID of stack that contains the Recents activity. */ - public static final int RECENTS_STACK_ID = PINNED_STACK_ID + 1; - - /** ID of stack that contains activities launched by the assistant. */ - public static final int ASSISTANT_STACK_ID = RECENTS_STACK_ID + 1; - /** Last static stack stack ID. * @hide */ - public static final int LAST_STATIC_STACK_ID = ASSISTANT_STACK_ID; + private static final int LAST_STATIC_STACK_ID = PINNED_STACK_ID; /** Start of ID range used by stacks that are created dynamically. * @hide */ @@ -720,15 +712,6 @@ public class ActivityManager { } /** - * Returns true if dynamic stacks are allowed to be visible behind the input stack. - * @hide - */ - // TODO: Figure-out a way to remove. - public static boolean isDynamicStacksVisibleBehindAllowed(int stackId) { - return stackId == PINNED_STACK_ID || stackId == ASSISTANT_STACK_ID; - } - - /** * Returns true if we try to maintain focus in the current stack when the top activity * finishes. * @hide @@ -740,15 +723,6 @@ public class ActivityManager { } /** - * Returns true if the input stack is affected by drag resizing. - * @hide - */ - public static boolean isStackAffectedByDragResizing(int stackId) { - return isStaticStack(stackId) && stackId != PINNED_STACK_ID - && stackId != ASSISTANT_STACK_ID; - } - - /** * Returns true if the windows of tasks being moved to the target stack from the source * stack should be replaced, meaning that window manager will keep the old window around * until the new is ready. @@ -760,41 +734,6 @@ public class ActivityManager { } /** - * Return whether a stackId is a stack that be a backdrop to a translucent activity. These - * are generally fullscreen stacks. - * @hide - */ - public static boolean isBackdropToTranslucentActivity(int stackId) { - return stackId == FULLSCREEN_WORKSPACE_STACK_ID - || stackId == ASSISTANT_STACK_ID; - } - - /** - * Returns true if animation specs should be constructed for app transition that moves - * the task to the specified stack. - * @hide - */ - public static boolean useAnimationSpecForAppTransition(int stackId) { - // TODO: INVALID_STACK_ID is also animated because we don't persist stack id's across - // reboots. - return stackId == FREEFORM_WORKSPACE_STACK_ID - || stackId == FULLSCREEN_WORKSPACE_STACK_ID - || stackId == ASSISTANT_STACK_ID - || stackId == DOCKED_STACK_ID - || stackId == INVALID_STACK_ID; - } - - /** - * Returns true if activities from stasks in the given {@param stackId} are allowed to - * enter picture-in-picture. - * @hide - */ - public static boolean isAllowedToEnterPictureInPicture(int stackId) { - return stackId != HOME_STACK_ID && stackId != ASSISTANT_STACK_ID && - stackId != RECENTS_STACK_ID; - } - - /** * Returns true if the top task in the task is allowed to return home when finished and * there are other tasks in the stack. * @hide @@ -825,34 +764,18 @@ public class ActivityManager { && stackId != DOCKED_STACK_ID; } - /** - * Returns true if the input stack id should only be present on a device that supports - * multi-window mode. - * @see android.app.ActivityManager#supportsMultiWindow - * @hide - */ - // TODO: What about the other side of docked stack if we move this to WindowConfiguration? - public static boolean isMultiWindowStack(int stackId) { - return stackId == PINNED_STACK_ID || stackId == FREEFORM_WORKSPACE_STACK_ID - || stackId == DOCKED_STACK_ID; - } - - /** - * Returns true if the input {@param stackId} is HOME_STACK_ID or RECENTS_STACK_ID - * @hide - */ - public static boolean isHomeOrRecentsStack(int stackId) { - return stackId == HOME_STACK_ID || stackId == RECENTS_STACK_ID; - } - - /** Returns true if the input stack and its content can affect the device orientation. + /** Returns the stack id for the input windowing mode. * @hide */ - public static boolean canSpecifyOrientation(int stackId) { - return stackId == HOME_STACK_ID - || stackId == RECENTS_STACK_ID - || stackId == FULLSCREEN_WORKSPACE_STACK_ID - || stackId == ASSISTANT_STACK_ID - || isDynamicStack(stackId); + // TODO: To be removed once we are not using stack id for stuff... + public static int getStackIdForWindowingMode(int windowingMode) { + switch (windowingMode) { + case WINDOWING_MODE_PINNED: return PINNED_STACK_ID; + case WINDOWING_MODE_FREEFORM: return FREEFORM_WORKSPACE_STACK_ID; + case WINDOWING_MODE_SPLIT_SCREEN_PRIMARY: return DOCKED_STACK_ID; + case WINDOWING_MODE_SPLIT_SCREEN_SECONDARY: return FULLSCREEN_WORKSPACE_STACK_ID; + case WINDOWING_MODE_FULLSCREEN: return FULLSCREEN_WORKSPACE_STACK_ID; + default: return INVALID_STACK_ID; + } } /** Returns the windowing mode that should be used for this input stack id. @@ -862,14 +785,9 @@ public class ActivityManager { final int windowingMode; switch (stackId) { case FULLSCREEN_WORKSPACE_STACK_ID: - case HOME_STACK_ID: - case RECENTS_STACK_ID: windowingMode = inSplitScreenMode ? WINDOWING_MODE_SPLIT_SCREEN_SECONDARY : WINDOWING_MODE_FULLSCREEN; break; - case ASSISTANT_STACK_ID: - windowingMode = WINDOWING_MODE_FULLSCREEN; - break; case PINNED_STACK_ID: windowingMode = WINDOWING_MODE_PINNED; break; @@ -884,27 +802,6 @@ public class ActivityManager { } return windowingMode; } - - /** Returns the activity type that should be used for this input stack id. - * @hide */ - // TODO: To be removed once we are not using stack id for stuff... - public static int getActivityTypeForStackId(int stackId) { - final int activityType; - switch (stackId) { - case HOME_STACK_ID: - activityType = ACTIVITY_TYPE_HOME; - break; - case RECENTS_STACK_ID: - activityType = ACTIVITY_TYPE_RECENTS; - break; - case ASSISTANT_STACK_ID: - activityType = ACTIVITY_TYPE_ASSISTANT; - break; - default : - activityType = ACTIVITY_TYPE_STANDARD; - } - return activityType; - } } /** @@ -1143,6 +1040,7 @@ public class ActivityManager { * E.g. freeform, split-screen, picture-in-picture. * @hide */ + @TestApi static public boolean supportsMultiWindow(Context context) { // On watches, multi-window is used to present essential system UI, and thus it must be // supported regardless of device memory characteristics. @@ -1157,6 +1055,7 @@ public class ActivityManager { * Returns true if the system supports split screen multi-window. * @hide */ + @TestApi static public boolean supportsSplitScreenMultiWindow(Context context) { return supportsMultiWindow(context) && Resources.getSystem().getBoolean( @@ -1636,6 +1535,12 @@ public class ActivityManager { */ public int resizeMode; + /** + * The current configuration this task is in. + * @hide + */ + final public Configuration configuration = new Configuration(); + public RecentTaskInfo() { } @@ -1681,6 +1586,7 @@ public class ActivityManager { } dest.writeInt(supportsSplitScreenMultiWindow ? 1 : 0); dest.writeInt(resizeMode); + configuration.writeToParcel(dest, flags); } public void readFromParcel(Parcel source) { @@ -1705,6 +1611,7 @@ public class ActivityManager { Rect.CREATOR.createFromParcel(source) : null; supportsSplitScreenMultiWindow = source.readInt() == 1; resizeMode = source.readInt(); + configuration.readFromParcel(source); } public static final Creator<RecentTaskInfo> CREATOR @@ -1899,6 +1806,12 @@ public class ActivityManager { */ public int resizeMode; + /** + * The full configuration the task is currently running in. + * @hide + */ + final public Configuration configuration = new Configuration(); + public RunningTaskInfo() { } @@ -1923,6 +1836,7 @@ public class ActivityManager { dest.writeInt(numRunning); dest.writeInt(supportsSplitScreenMultiWindow ? 1 : 0); dest.writeInt(resizeMode); + configuration.writeToParcel(dest, flags); } public void readFromParcel(Parcel source) { @@ -1940,6 +1854,7 @@ public class ActivityManager { numRunning = source.readInt(); supportsSplitScreenMultiWindow = source.readInt() != 0; resizeMode = source.readInt(); + configuration.readFromParcel(source); } public static final Creator<RunningTaskInfo> CREATOR = new Creator<RunningTaskInfo>() { @@ -2122,6 +2037,73 @@ public class ActivityManager { } /** + * Sets the windowing mode for a specific task. Only works on tasks of type + * {@link WindowConfiguration#ACTIVITY_TYPE_STANDARD} + * @param taskId The id of the task to set the windowing mode for. + * @param windowingMode The windowing mode to set for the task. + * @param toTop If the task should be moved to the top once the windowing mode changes. + * @hide + */ + @TestApi + @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) + public void setTaskWindowingMode(int taskId, int windowingMode, boolean toTop) + throws SecurityException { + try { + getService().setTaskWindowingMode(taskId, windowingMode, toTop); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** + * Resizes the input stack id to the given bounds. + * @param stackId Id of the stack to resize. + * @param bounds Bounds to resize the stack to or {@code null} for fullscreen. + * @hide + */ + @TestApi + @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) + public void resizeStack(int stackId, Rect bounds) throws SecurityException { + try { + getService().resizeStack(stackId, bounds, false /* allowResizeInDockedMode */, + false /* preserveWindows */, false /* animate */, -1 /* animationDuration */); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** + * Removes stacks in the windowing modes from the system if they are of activity type + * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED + * + * @hide + */ + @TestApi + @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) + public void removeStacksInWindowingModes(int[] windowingModes) throws SecurityException { + try { + getService().removeStacksInWindowingModes(windowingModes); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** + * Removes stack of the activity types from the system. + * + * @hide + */ + @TestApi + @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) + public void removeStacksWithActivityTypes(int[] activityTypes) throws SecurityException { + try { + getService().removeStacksWithActivityTypes(activityTypes); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** * Represents a task snapshot. * @hide */ @@ -2599,6 +2581,11 @@ public class ActivityManager { public boolean visible; // Index of the stack in the display's stack list, can be used for comparison of stack order public int position; + /** + * The full configuration the stack is currently running in. + * @hide + */ + final public Configuration configuration = new Configuration(); @Override public int describeContents() { @@ -2633,6 +2620,7 @@ public class ActivityManager { } else { dest.writeInt(0); } + configuration.writeToParcel(dest, flags); } public void readFromParcel(Parcel source) { @@ -2660,6 +2648,7 @@ public class ActivityManager { if (source.readInt() > 0) { topActivity = ComponentName.readFromParcel(source); } + configuration.readFromParcel(source); } public static final Creator<StackInfo> CREATOR = new Creator<StackInfo>() { @@ -2687,6 +2676,8 @@ public class ActivityManager { sb.append(" displayId="); sb.append(displayId); sb.append(" userId="); sb.append(userId); sb.append("\n"); + sb.append(" configuration="); sb.append(configuration); + sb.append("\n"); prefix = prefix + " "; for (int i = 0; i < taskIds.length; ++i) { sb.append(prefix); sb.append("taskId="); sb.append(taskIds[i]); diff --git a/android/app/ActivityOptions.java b/android/app/ActivityOptions.java index 0bffc9e6..a68c3a5c 100644 --- a/android/app/ActivityOptions.java +++ b/android/app/ActivityOptions.java @@ -18,6 +18,8 @@ package android.app; import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT; import static android.app.ActivityManager.StackId.INVALID_STACK_ID; +import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; +import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; import static android.view.Display.INVALID_DISPLAY; import android.annotation.Nullable; @@ -164,10 +166,16 @@ public class ActivityOptions { private static final String KEY_LAUNCH_DISPLAY_ID = "android.activity.launchDisplayId"; /** - * The stack id the activity should be launched into. + * The windowing mode the activity should be launched into. * @hide */ - private static final String KEY_LAUNCH_STACK_ID = "android.activity.launchStackId"; + private static final String KEY_LAUNCH_WINDOWING_MODE = "android.activity.windowingMode"; + + /** + * The activity type the activity should be launched as. + * @hide + */ + private static final String KEY_LAUNCH_ACTIVITY_TYPE = "android.activity.activityType"; /** * The task id the activity should be launched into. @@ -272,7 +280,10 @@ public class ActivityOptions { private int mExitCoordinatorIndex; private PendingIntent mUsageTimeReport; private int mLaunchDisplayId = INVALID_DISPLAY; - private int mLaunchStackId = INVALID_STACK_ID; + @WindowConfiguration.WindowingMode + private int mLaunchWindowingMode = WINDOWING_MODE_UNDEFINED; + @WindowConfiguration.ActivityType + private int mLaunchActivityType = ACTIVITY_TYPE_UNDEFINED; private int mLaunchTaskId = -1; private int mDockCreateMode = DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT; private boolean mDisallowEnterPictureInPictureWhileLaunching; @@ -860,7 +871,8 @@ public class ActivityOptions { break; } mLaunchDisplayId = opts.getInt(KEY_LAUNCH_DISPLAY_ID, INVALID_DISPLAY); - mLaunchStackId = opts.getInt(KEY_LAUNCH_STACK_ID, INVALID_STACK_ID); + mLaunchWindowingMode = opts.getInt(KEY_LAUNCH_WINDOWING_MODE, WINDOWING_MODE_UNDEFINED); + mLaunchActivityType = opts.getInt(KEY_LAUNCH_ACTIVITY_TYPE, ACTIVITY_TYPE_UNDEFINED); mLaunchTaskId = opts.getInt(KEY_LAUNCH_TASK_ID, -1); mTaskOverlay = opts.getBoolean(KEY_TASK_OVERLAY, false); mTaskOverlayCanResume = opts.getBoolean(KEY_TASK_OVERLAY_CAN_RESUME, false); @@ -1070,14 +1082,34 @@ public class ActivityOptions { } /** @hide */ - public int getLaunchStackId() { - return mLaunchStackId; + public int getLaunchWindowingMode() { + return mLaunchWindowingMode; + } + + /** + * Sets the windowing mode the activity should launch into. If the input windowing mode is + * {@link android.app.WindowConfiguration#WINDOWING_MODE_SPLIT_SCREEN_SECONDARY} and the device + * isn't currently in split-screen windowing mode, then the activity will be launched in + * {@link android.app.WindowConfiguration#WINDOWING_MODE_FULLSCREEN} windowing mode. For clarity + * on this you can use + * {@link android.app.WindowConfiguration#WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY} + * + * @hide + */ + @TestApi + public void setLaunchWindowingMode(int windowingMode) { + mLaunchWindowingMode = windowingMode; + } + + /** @hide */ + public int getLaunchActivityType() { + return mLaunchActivityType; } /** @hide */ @TestApi - public void setLaunchStackId(int launchStackId) { - mLaunchStackId = launchStackId; + public void setLaunchActivityType(int activityType) { + mLaunchActivityType = activityType; } /** @@ -1291,7 +1323,8 @@ public class ActivityOptions { break; } b.putInt(KEY_LAUNCH_DISPLAY_ID, mLaunchDisplayId); - b.putInt(KEY_LAUNCH_STACK_ID, mLaunchStackId); + b.putInt(KEY_LAUNCH_WINDOWING_MODE, mLaunchWindowingMode); + b.putInt(KEY_LAUNCH_ACTIVITY_TYPE, mLaunchActivityType); b.putInt(KEY_LAUNCH_TASK_ID, mLaunchTaskId); b.putBoolean(KEY_TASK_OVERLAY, mTaskOverlay); b.putBoolean(KEY_TASK_OVERLAY_CAN_RESUME, mTaskOverlayCanResume); diff --git a/android/app/ActivityThread.java b/android/app/ActivityThread.java index 4e8d2400..2516a3e9 100644 --- a/android/app/ActivityThread.java +++ b/android/app/ActivityThread.java @@ -5281,7 +5281,7 @@ public final class ActivityThread { final ApplicationInfo aInfo = sPackageManager.getApplicationInfo( packageName, - 0 /*flags*/, + PackageManager.GET_SHARED_LIBRARY_FILES, UserHandle.myUserId()); if (mActivities.size() > 0) { @@ -5780,7 +5780,7 @@ public final class ActivityThread { final int preloadedFontsResource = info.metaData.getInt( ApplicationInfo.METADATA_PRELOADED_FONTS, 0); if (preloadedFontsResource != 0) { - data.info.mResources.preloadFonts(preloadedFontsResource); + data.info.getResources().preloadFonts(preloadedFontsResource); } } } catch (RemoteException e) { diff --git a/android/app/ContextImpl.java b/android/app/ContextImpl.java index c48be770..5f343226 100644 --- a/android/app/ContextImpl.java +++ b/android/app/ContextImpl.java @@ -74,6 +74,7 @@ import android.util.Log; import android.util.Slog; import android.view.Display; import android.view.DisplayAdjustments; +import android.view.autofill.AutofillManager.AutofillClient; import com.android.internal.annotations.GuardedBy; import com.android.internal.util.Preconditions; @@ -185,6 +186,8 @@ class ContextImpl extends Context { // The name of the split this Context is representing. May be null. private @Nullable String mSplitName = null; + private AutofillClient mAutofillClient = null; + private final Object mSync = new Object(); @GuardedBy("mSync") @@ -2225,6 +2228,18 @@ class ContextImpl extends Context { return mUser.getIdentifier(); } + /** @hide */ + @Override + public AutofillClient getAutofillClient() { + return mAutofillClient; + } + + /** @hide */ + @Override + public void setAutofillClient(AutofillClient client) { + mAutofillClient = client; + } + static ContextImpl createSystemContext(ActivityThread mainThread) { LoadedApk packageInfo = new LoadedApk(mainThread); ContextImpl context = new ContextImpl(null, mainThread, packageInfo, null, null, null, 0, diff --git a/android/app/KeyguardManager.java b/android/app/KeyguardManager.java index 76643d60..54f74b15 100644 --- a/android/app/KeyguardManager.java +++ b/android/app/KeyguardManager.java @@ -174,7 +174,7 @@ public class KeyguardManager { */ public Intent createConfirmFactoryResetCredentialIntent( CharSequence title, CharSequence description, CharSequence alternateButtonLabel) { - if (!LockPatternUtils.frpCredentialEnabled()) { + if (!LockPatternUtils.frpCredentialEnabled(mContext)) { Log.w(TAG, "Factory reset credentials not supported."); return null; } diff --git a/android/app/Notification.java b/android/app/Notification.java index ee6c1cba..fee7d6c8 100644 --- a/android/app/Notification.java +++ b/android/app/Notification.java @@ -67,7 +67,6 @@ import android.text.style.TextAppearanceSpan; import android.util.ArraySet; import android.util.Log; import android.util.SparseArray; -import android.util.TypedValue; import android.view.Gravity; import android.view.NotificationHeaderView; import android.view.View; @@ -3840,8 +3839,8 @@ public class Notification implements Parcelable contentView.setImageViewBitmap(R.id.profile_badge, profileBadge); contentView.setViewVisibility(R.id.profile_badge, View.VISIBLE); if (isColorized()) { - contentView.setDrawableParameters(R.id.profile_badge, false, -1, - getPrimaryTextColor(), PorterDuff.Mode.SRC_ATOP, -1); + contentView.setDrawableTint(R.id.profile_badge, false, + getPrimaryTextColor(), PorterDuff.Mode.SRC_ATOP); } } } @@ -3906,7 +3905,6 @@ public class Notification implements Parcelable if (p.title != null) { contentView.setViewVisibility(R.id.title, View.VISIBLE); contentView.setTextViewText(R.id.title, processTextSpans(p.title)); - updateTextSizePrimary(contentView, R.id.title); if (!p.ambient) { setTextViewColorPrimary(contentView, R.id.title); } @@ -3918,7 +3916,6 @@ public class Notification implements Parcelable int textId = showProgress ? com.android.internal.R.id.text_line_1 : com.android.internal.R.id.text; contentView.setTextViewText(textId, processTextSpans(p.text)); - updateTextSizeSecondary(contentView, textId); if (!p.ambient) { setTextViewColorSecondary(contentView, textId); } @@ -3930,25 +3927,6 @@ public class Notification implements Parcelable return contentView; } - private void updateTextSizeSecondary(RemoteViews contentView, int textId) { - updateTextSizeColorized(contentView, textId, - com.android.internal.R.dimen.notification_text_size_colorized, - com.android.internal.R.dimen.notification_text_size); - } - - private void updateTextSizePrimary(RemoteViews contentView, int textId) { - updateTextSizeColorized(contentView, textId, - com.android.internal.R.dimen.notification_title_text_size_colorized, - com.android.internal.R.dimen.notification_title_text_size); - } - - private void updateTextSizeColorized(RemoteViews contentView, int textId, - int colorizedDimen, int normalDimen) { - int size = mContext.getResources().getDimensionPixelSize(isColorized() - ? colorizedDimen : normalDimen); - contentView.setTextViewTextSize(textId, TypedValue.COMPLEX_UNIT_PX, size); - } - private CharSequence processTextSpans(CharSequence text) { if (hasForegroundColor()) { return NotificationColorUtil.clearColorSpans(text); @@ -4152,18 +4130,14 @@ public class Notification implements Parcelable if (action != null) { int contrastColor = resolveContrastColor(); - contentView.setDrawableParameters(R.id.reply_icon_action, + contentView.setDrawableTint(R.id.reply_icon_action, true /* targetBackground */, - -1, - contrastColor, - PorterDuff.Mode.SRC_ATOP, -1); + contrastColor, PorterDuff.Mode.SRC_ATOP); int iconColor = NotificationColorUtil.isColorLight(contrastColor) ? Color.BLACK : Color.WHITE; - contentView.setDrawableParameters(R.id.reply_icon_action, + contentView.setDrawableTint(R.id.reply_icon_action, false /* targetBackground */, - -1, - iconColor, - PorterDuff.Mode.SRC_ATOP, -1); + iconColor, PorterDuff.Mode.SRC_ATOP); contentView.setOnClickPendingIntent(R.id.right_icon, action.actionIntent); contentView.setOnClickPendingIntent(R.id.reply_icon_action, @@ -4207,8 +4181,8 @@ public class Notification implements Parcelable private void bindExpandButton(RemoteViews contentView) { int color = getPrimaryHighlightColor(); - contentView.setDrawableParameters(R.id.expand_button, false, -1, color, - PorterDuff.Mode.SRC_ATOP, -1); + contentView.setDrawableTint(R.id.expand_button, false, color, + PorterDuff.Mode.SRC_ATOP); contentView.setInt(R.id.notification_header, "setOriginalNotificationColor", color); } @@ -4315,8 +4289,7 @@ public class Notification implements Parcelable mN.mSmallIcon = Icon.createWithResource(mContext, mN.icon); } contentView.setImageViewIcon(R.id.icon, mN.mSmallIcon); - contentView.setDrawableParameters(R.id.icon, false /* targetBackground */, - -1 /* alpha */, -1 /* colorFilter */, null /* mode */, mN.iconLevel); + contentView.setInt(R.id.icon, "setImageLevel", mN.iconLevel); processSmallIconColor(mN.mSmallIcon, contentView, ambient); } @@ -4706,8 +4679,8 @@ public class Notification implements Parcelable bgColor = mContext.getColor(oddAction ? R.color.notification_action_list : R.color.notification_action_list_dark); } - button.setDrawableParameters(R.id.button_holder, true, -1, bgColor, - PorterDuff.Mode.SRC_ATOP, -1); + button.setDrawableTint(R.id.button_holder, true, + bgColor, PorterDuff.Mode.SRC_ATOP); CharSequence title = action.title; ColorStateList[] outResultColor = null; if (isLegacy()) { @@ -4840,8 +4813,8 @@ public class Notification implements Parcelable boolean colorable = !isLegacy() || getColorUtil().isGrayscaleIcon(mContext, smallIcon); int color = ambient ? resolveAmbientColor() : getPrimaryHighlightColor(); if (colorable) { - contentView.setDrawableParameters(R.id.icon, false, -1, color, - PorterDuff.Mode.SRC_ATOP, -1); + contentView.setDrawableTint(R.id.icon, false, color, + PorterDuff.Mode.SRC_ATOP); } contentView.setInt(R.id.notification_header, "setOriginalIconColor", @@ -4857,8 +4830,8 @@ public class Notification implements Parcelable if (largeIcon != null && isLegacy() && getColorUtil().isGrayscaleIcon(mContext, largeIcon)) { // resolve color will fall back to the default when legacy - contentView.setDrawableParameters(R.id.icon, false, -1, resolveContrastColor(), - PorterDuff.Mode.SRC_ATOP, -1); + contentView.setDrawableTint(R.id.icon, false, resolveContrastColor(), + PorterDuff.Mode.SRC_ATOP); } } @@ -5874,7 +5847,6 @@ public class Notification implements Parcelable builder.setTextViewColorSecondary(contentView, R.id.big_text); contentView.setViewVisibility(R.id.big_text, TextUtils.isEmpty(bigTextText) ? View.GONE : View.VISIBLE); - builder.updateTextSizeSecondary(contentView, R.id.big_text); contentView.setBoolean(R.id.big_text, "setHasImage", builder.mN.hasLargeIcon()); } } @@ -6208,7 +6180,6 @@ public class Notification implements Parcelable contentView.setViewVisibility(rowId, View.VISIBLE); contentView.setTextViewText(rowId, mBuilder.processTextSpans( makeMessageLine(m, mBuilder))); - mBuilder.updateTextSizeSecondary(contentView, rowId); mBuilder.setTextViewColorSecondary(contentView, rowId); if (contractedMessage == m) { @@ -6576,7 +6547,6 @@ public class Notification implements Parcelable contentView.setViewVisibility(rowIds[i], View.VISIBLE); contentView.setTextViewText(rowIds[i], mBuilder.processTextSpans(mBuilder.processLegacyText(str))); - mBuilder.updateTextSizeSecondary(contentView, rowIds[i]); mBuilder.setTextViewColorSecondary(contentView, rowIds[i]); contentView.setViewPadding(rowIds[i], 0, topPadding, 0, 0); handleInboxImageMargin(contentView, rowIds[i], first); @@ -6775,8 +6745,8 @@ public class Notification implements Parcelable : NotificationColorUtil.resolveColor(mBuilder.mContext, Notification.COLOR_DEFAULT); - button.setDrawableParameters(R.id.action0, false, -1, tintColor, - PorterDuff.Mode.SRC_ATOP, -1); + button.setDrawableTint(R.id.action0, false, tintColor, + PorterDuff.Mode.SRC_ATOP); if (!tombstone) { button.setOnClickPendingIntent(R.id.action0, action.actionIntent); } diff --git a/android/app/NotificationChannel.java b/android/app/NotificationChannel.java index 163a8dca..47063f08 100644 --- a/android/app/NotificationChannel.java +++ b/android/app/NotificationChannel.java @@ -15,8 +15,11 @@ */ package android.app; +import android.annotation.Nullable; import android.annotation.SystemApi; import android.app.NotificationManager.Importance; +import android.content.ContentResolver; +import android.content.Context; import android.content.Intent; import android.media.AudioAttributes; import android.net.Uri; @@ -25,6 +28,9 @@ import android.os.Parcelable; import android.provider.Settings; import android.service.notification.NotificationListenerService; import android.text.TextUtils; +import android.util.proto.ProtoOutputStream; + +import com.android.internal.util.Preconditions; import org.json.JSONException; import org.json.JSONObject; @@ -135,12 +141,15 @@ public final class NotificationChannel implements Parcelable { private boolean mLights; private int mLightColor = DEFAULT_LIGHT_COLOR; private long[] mVibration; + // Bitwise representation of fields that have been changed by the user, preventing the app from + // making changes to these fields. private int mUserLockedFields; private boolean mVibrationEnabled; private boolean mShowBadge = DEFAULT_SHOW_BADGE; private boolean mDeleted = DEFAULT_DELETED; private String mGroup; private AudioAttributes mAudioAttributes = Notification.AUDIO_ATTRIBUTES_DEFAULT; + // If this is a blockable system notification channel. private boolean mBlockableSystem = false; /** @@ -565,14 +574,35 @@ public final class NotificationChannel implements Parcelable { /** * @hide */ + public void populateFromXmlForRestore(XmlPullParser parser, Context context) { + populateFromXml(parser, true, context); + } + + /** + * @hide + */ @SystemApi public void populateFromXml(XmlPullParser parser) { + populateFromXml(parser, false, null); + } + + /** + * If {@param forRestore} is true, {@param Context} MUST be non-null. + */ + private void populateFromXml(XmlPullParser parser, boolean forRestore, + @Nullable Context context) { + Preconditions.checkArgument(!forRestore || context != null, + "forRestore is true but got null context"); + // Name, id, and importance are set in the constructor. setDescription(parser.getAttributeValue(null, ATT_DESC)); setBypassDnd(Notification.PRIORITY_DEFAULT != safeInt(parser, ATT_PRIORITY, Notification.PRIORITY_DEFAULT)); setLockscreenVisibility(safeInt(parser, ATT_VISIBILITY, DEFAULT_VISIBILITY)); - setSound(safeUri(parser, ATT_SOUND), safeAudioAttributes(parser)); + + Uri sound = safeUri(parser, ATT_SOUND); + setSound(forRestore ? restoreSoundUri(context, sound) : sound, safeAudioAttributes(parser)); + enableLights(safeBool(parser, ATT_LIGHTS, false)); setLightColor(safeInt(parser, ATT_LIGHT_COLOR, DEFAULT_LIGHT_COLOR)); setVibrationPattern(safeLongArray(parser, ATT_VIBRATION, null)); @@ -584,11 +614,62 @@ public final class NotificationChannel implements Parcelable { setBlockableSystem(safeBool(parser, ATT_BLOCKABLE_SYSTEM, false)); } + @Nullable + private Uri restoreSoundUri(Context context, @Nullable Uri uri) { + if (uri == null) { + return null; + } + ContentResolver contentResolver = context.getContentResolver(); + // There are backups out there with uncanonical uris (because we fixed this after + // shipping). If uncanonical uris are given to MediaProvider.uncanonicalize it won't + // verify the uri against device storage and we'll possibly end up with a broken uri. + // We then canonicalize the uri to uncanonicalize it back, which means we properly check + // the uri and in the case of not having the resource we end up with the default - better + // than broken. As a side effect we'll canonicalize already canonicalized uris, this is fine + // according to the docs because canonicalize method has to handle canonical uris as well. + Uri canonicalizedUri = contentResolver.canonicalize(uri); + if (canonicalizedUri == null) { + // We got a null because the uri in the backup does not exist here, so we return default + return Settings.System.DEFAULT_NOTIFICATION_URI; + } + return contentResolver.uncanonicalize(canonicalizedUri); + } + /** * @hide */ @SystemApi public void writeXml(XmlSerializer out) throws IOException { + writeXml(out, false, null); + } + + /** + * @hide + */ + public void writeXmlForBackup(XmlSerializer out, Context context) throws IOException { + writeXml(out, true, context); + } + + private Uri getSoundForBackup(Context context) { + Uri sound = getSound(); + if (sound == null) { + return null; + } + Uri canonicalSound = context.getContentResolver().canonicalize(sound); + if (canonicalSound == null) { + // The content provider does not support canonical uris so we backup the default + return Settings.System.DEFAULT_NOTIFICATION_URI; + } + return canonicalSound; + } + + /** + * If {@param forBackup} is true, {@param Context} MUST be non-null. + */ + private void writeXml(XmlSerializer out, boolean forBackup, @Nullable Context context) + throws IOException { + Preconditions.checkArgument(!forBackup || context != null, + "forBackup is true but got null context"); out.startTag(null, TAG_CHANNEL); out.attribute(null, ATT_ID, getId()); if (getName() != null) { @@ -609,8 +690,9 @@ public final class NotificationChannel implements Parcelable { out.attribute(null, ATT_VISIBILITY, Integer.toString(getLockscreenVisibility())); } - if (getSound() != null) { - out.attribute(null, ATT_SOUND, getSound().toString()); + Uri sound = forBackup ? getSoundForBackup(context) : getSound(); + if (sound != null) { + out.attribute(null, ATT_SOUND, sound.toString()); } if (getAudioAttributes() != null) { out.attribute(null, ATT_USAGE, Integer.toString(getAudioAttributes().getUsage())); @@ -850,4 +932,35 @@ public final class NotificationChannel implements Parcelable { + ", mBlockableSystem=" + mBlockableSystem + '}'; } + + /** @hide */ + public void toProto(ProtoOutputStream proto) { + proto.write(NotificationChannelProto.ID, mId); + proto.write(NotificationChannelProto.NAME, mName); + proto.write(NotificationChannelProto.DESCRIPTION, mDesc); + proto.write(NotificationChannelProto.IMPORTANCE, mImportance); + proto.write(NotificationChannelProto.CAN_BYPASS_DND, mBypassDnd); + proto.write(NotificationChannelProto.LOCKSCREEN_VISIBILITY, mLockscreenVisibility); + if (mSound != null) { + proto.write(NotificationChannelProto.SOUND, mSound.toString()); + } + proto.write(NotificationChannelProto.USE_LIGHTS, mLights); + proto.write(NotificationChannelProto.LIGHT_COLOR, mLightColor); + if (mVibration != null) { + for (long v : mVibration) { + proto.write(NotificationChannelProto.VIBRATION, v); + } + } + proto.write(NotificationChannelProto.USER_LOCKED_FIELDS, mUserLockedFields); + proto.write(NotificationChannelProto.IS_VIBRATION_ENABLED, mVibrationEnabled); + proto.write(NotificationChannelProto.SHOW_BADGE, mShowBadge); + proto.write(NotificationChannelProto.IS_DELETED, mDeleted); + proto.write(NotificationChannelProto.GROUP, mGroup); + if (mAudioAttributes != null) { + long aToken = proto.start(NotificationChannelProto.AUDIO_ATTRIBUTES); + mAudioAttributes.toProto(proto); + proto.end(aToken); + } + proto.write(NotificationChannelProto.IS_BLOCKABLE_SYSTEM, mBlockableSystem); + } } diff --git a/android/app/NotificationChannelGroup.java b/android/app/NotificationChannelGroup.java index 51733114..5cb7fb7a 100644 --- a/android/app/NotificationChannelGroup.java +++ b/android/app/NotificationChannelGroup.java @@ -21,6 +21,7 @@ import android.content.Intent; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; +import android.util.proto.ProtoOutputStream; import org.json.JSONException; import org.json.JSONObject; @@ -295,4 +296,15 @@ public final class NotificationChannelGroup implements Parcelable { + ", mChannels=" + mChannels + '}'; } + + /** @hide */ + public void toProto(ProtoOutputStream proto) { + proto.write(NotificationChannelGroupProto.ID, mId); + proto.write(NotificationChannelGroupProto.NAME, mName.toString()); + proto.write(NotificationChannelGroupProto.DESCRIPTION, mDescription); + proto.write(NotificationChannelGroupProto.IS_BLOCKED, mBlocked); + for (NotificationChannel channel : mChannels) { + channel.toProto(proto); + } + } } diff --git a/android/app/NotificationManager.java b/android/app/NotificationManager.java index 8fa7d6c3..eb52cb7f 100644 --- a/android/app/NotificationManager.java +++ b/android/app/NotificationManager.java @@ -41,6 +41,7 @@ import android.provider.Settings.Global; import android.service.notification.StatusBarNotification; import android.service.notification.ZenModeConfig; import android.util.Log; +import android.util.proto.ProtoOutputStream; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -1061,6 +1062,27 @@ public class NotificationManager { + "]"; } + /** @hide */ + public void toProto(ProtoOutputStream proto, long fieldId) { + final long pToken = proto.start(fieldId); + + bitwiseToProtoEnum(proto, PolicyProto.PRIORITY_CATEGORIES, priorityCategories); + proto.write(PolicyProto.PRIORITY_CALL_SENDER, priorityCallSenders); + proto.write(PolicyProto.PRIORITY_MESSAGE_SENDER, priorityMessageSenders); + bitwiseToProtoEnum( + proto, PolicyProto.SUPPRESSED_VISUAL_EFFECTS, suppressedVisualEffects); + + proto.end(pToken); + } + + private static void bitwiseToProtoEnum(ProtoOutputStream proto, long fieldId, int data) { + for (int i = 1; data > 0; ++i, data >>>= 1) { + if ((data & 1) == 1) { + proto.write(fieldId, i); + } + } + } + public static String suppressedEffectsToString(int effects) { if (effects <= 0) return ""; final StringBuilder sb = new StringBuilder(); diff --git a/android/app/SharedElementCallback.java b/android/app/SharedElementCallback.java index af13e695..80fb8058 100644 --- a/android/app/SharedElementCallback.java +++ b/android/app/SharedElementCallback.java @@ -27,6 +27,7 @@ import android.os.Bundle; import android.os.Parcelable; import android.transition.TransitionUtils; import android.view.View; +import android.view.ViewGroup; import android.widget.ImageView; import android.widget.ImageView.ScaleType; @@ -176,7 +177,7 @@ public abstract class SharedElementCallback { Drawable d = imageView.getDrawable(); Drawable bg = imageView.getBackground(); if (d != null && (bg == null || bg.getAlpha() == 0)) { - Bitmap bitmap = TransitionUtils.createDrawableBitmap(d); + Bitmap bitmap = TransitionUtils.createDrawableBitmap(d, imageView); if (bitmap != null) { Bundle bundle = new Bundle(); if (bitmap.getConfig() != Bitmap.Config.HARDWARE) { @@ -202,7 +203,8 @@ public abstract class SharedElementCallback { } else { mTempMatrix.set(viewToGlobalMatrix); } - return TransitionUtils.createViewBitmap(sharedElement, mTempMatrix, screenBounds); + ViewGroup parent = (ViewGroup) sharedElement.getParent(); + return TransitionUtils.createViewBitmap(sharedElement, mTempMatrix, screenBounds, parent); } /** diff --git a/android/app/StatusBarManager.java b/android/app/StatusBarManager.java index 4a092140..8987bc02 100644 --- a/android/app/StatusBarManager.java +++ b/android/app/StatusBarManager.java @@ -14,15 +14,14 @@ * limitations under the License. */ - package android.app; import android.annotation.IntDef; import android.annotation.SystemService; import android.content.Context; import android.os.Binder; -import android.os.RemoteException; import android.os.IBinder; +import android.os.RemoteException; import android.os.ServiceManager; import android.util.Slog; import android.view.View; @@ -71,14 +70,18 @@ public class StatusBarManager { * Setting this flag disables quick settings completely, but does not disable expanding the * notification shade. */ - public static final int DISABLE2_QUICK_SETTINGS = 0x00000001; + public static final int DISABLE2_QUICK_SETTINGS = 1; + public static final int DISABLE2_SYSTEM_ICONS = 1 << 1; + public static final int DISABLE2_NOTIFICATION_SHADE = 1 << 2; public static final int DISABLE2_NONE = 0x00000000; - public static final int DISABLE2_MASK = DISABLE2_QUICK_SETTINGS; + public static final int DISABLE2_MASK = DISABLE2_QUICK_SETTINGS | DISABLE2_SYSTEM_ICONS + | DISABLE2_NOTIFICATION_SHADE; @IntDef(flag = true, - value = {DISABLE2_NONE, DISABLE2_MASK, DISABLE2_QUICK_SETTINGS}) + value = {DISABLE2_NONE, DISABLE2_MASK, DISABLE2_QUICK_SETTINGS, DISABLE2_SYSTEM_ICONS, + DISABLE2_NOTIFICATION_SHADE}) @Retention(RetentionPolicy.SOURCE) public @interface Disable2Flags {} diff --git a/android/app/SystemServiceRegistry.java b/android/app/SystemServiceRegistry.java index ab70f0e7..50f1f364 100644 --- a/android/app/SystemServiceRegistry.java +++ b/android/app/SystemServiceRegistry.java @@ -81,10 +81,10 @@ import android.net.INetworkPolicyManager; import android.net.IpSecManager; import android.net.NetworkPolicyManager; import android.net.NetworkScoreManager; -import android.net.nsd.INsdManager; -import android.net.nsd.NsdManager; import android.net.lowpan.ILowpanManager; import android.net.lowpan.LowpanManager; +import android.net.nsd.INsdManager; +import android.net.nsd.NsdManager; import android.net.wifi.IRttManager; import android.net.wifi.IWifiManager; import android.net.wifi.IWifiScanner; @@ -95,6 +95,8 @@ import android.net.wifi.aware.IWifiAwareManager; import android.net.wifi.aware.WifiAwareManager; import android.net.wifi.p2p.IWifiP2pManager; import android.net.wifi.p2p.WifiP2pManager; +import android.net.wifi.rtt.IWifiRttManager; +import android.net.wifi.rtt.WifiRttManager; import android.nfc.NfcManager; import android.os.BatteryManager; import android.os.BatteryStats; @@ -603,6 +605,16 @@ final class SystemServiceRegistry { ConnectivityThread.getInstanceLooper()); }}); + registerService(Context.WIFI_RTT2_SERVICE, WifiRttManager.class, + new CachedServiceFetcher<WifiRttManager>() { + @Override + public WifiRttManager createService(ContextImpl ctx) + throws ServiceNotFoundException { + IBinder b = ServiceManager.getServiceOrThrow(Context.WIFI_RTT2_SERVICE); + IWifiRttManager service = IWifiRttManager.Stub.asInterface(b); + return new WifiRttManager(ctx.getOuterContext(), service); + }}); + registerService(Context.ETHERNET_SERVICE, EthernetManager.class, new CachedServiceFetcher<EthernetManager>() { @Override diff --git a/android/app/TaskStackListener.java b/android/app/TaskStackListener.java index a52ca0a6..402e2095 100644 --- a/android/app/TaskStackListener.java +++ b/android/app/TaskStackListener.java @@ -31,7 +31,8 @@ public abstract class TaskStackListener extends ITaskStackListener.Stub { } @Override - public void onActivityPinned(String packageName, int taskId) throws RemoteException { + public void onActivityPinned(String packageName, int userId, int taskId, int stackId) + throws RemoteException { } @Override diff --git a/android/app/VrManager.java b/android/app/VrManager.java index 363e20a7..5c6ffa39 100644 --- a/android/app/VrManager.java +++ b/android/app/VrManager.java @@ -4,6 +4,7 @@ import android.annotation.NonNull; import android.annotation.RequiresPermission; import android.annotation.SystemApi; import android.annotation.SystemService; +import android.content.ComponentName; import android.content.Context; import android.os.Handler; import android.os.RemoteException; @@ -62,7 +63,10 @@ public class VrManager { * @param callback The callback to register. * @hide */ - @RequiresPermission(android.Manifest.permission.RESTRICTED_VR_ACCESS) + @RequiresPermission(anyOf = { + android.Manifest.permission.RESTRICTED_VR_ACCESS, + android.Manifest.permission.ACCESS_VR_STATE + }) public void registerVrStateCallback(VrStateCallback callback, @NonNull Handler handler) { if (callback == null || mCallbackMap.containsKey(callback)) { return; @@ -88,7 +92,10 @@ public class VrManager { * @param callback The callback to deregister. * @hide */ - @RequiresPermission(android.Manifest.permission.RESTRICTED_VR_ACCESS) + @RequiresPermission(anyOf = { + android.Manifest.permission.RESTRICTED_VR_ACCESS, + android.Manifest.permission.ACCESS_VR_STATE + }) public void unregisterVrStateCallback(VrStateCallback callback) { CallbackEntry entry = mCallbackMap.remove(callback); if (entry != null) { @@ -110,7 +117,10 @@ public class VrManager { * Returns the current VrMode state. * @hide */ - @RequiresPermission(android.Manifest.permission.ACCESS_VR_STATE) + @RequiresPermission(anyOf = { + android.Manifest.permission.RESTRICTED_VR_ACCESS, + android.Manifest.permission.ACCESS_VR_STATE + }) public boolean getVrModeEnabled() { try { return mService.getVrModeState(); @@ -124,7 +134,10 @@ public class VrManager { * Returns the current VrMode state. * @hide */ - @RequiresPermission(android.Manifest.permission.ACCESS_VR_STATE) + @RequiresPermission(anyOf = { + android.Manifest.permission.RESTRICTED_VR_ACCESS, + android.Manifest.permission.ACCESS_VR_STATE + }) public boolean getPersistentVrModeEnabled() { try { return mService.getPersistentVrModeEnabled(); @@ -169,4 +182,20 @@ public class VrManager { e.rethrowFromSystemServer(); } } + + /** + * Set the component name of the compositor service to bind. + * + * @param componentName ComponentName of a Service in the application's compositor process to + * bind to, or null to clear the current binding. + */ + @RequiresPermission(android.Manifest.permission.RESTRICTED_VR_ACCESS) + public void setAndBindVrCompositor(ComponentName componentName) { + try { + mService.setAndBindCompositor( + (componentName == null) ? null : componentName.flattenToString()); + } catch (RemoteException e) { + e.rethrowFromSystemServer(); + } + } } diff --git a/android/app/WindowConfiguration.java b/android/app/WindowConfiguration.java index 5d87e1c2..6b405384 100644 --- a/android/app/WindowConfiguration.java +++ b/android/app/WindowConfiguration.java @@ -17,6 +17,9 @@ package android.app; import static android.app.ActivityThread.isSystem; +import static android.app.WindowConfigurationProto.ACTIVITY_TYPE; +import static android.app.WindowConfigurationProto.APP_BOUNDS; +import static android.app.WindowConfigurationProto.WINDOWING_MODE; import android.annotation.IntDef; import android.annotation.NonNull; @@ -25,6 +28,7 @@ import android.content.res.Configuration; import android.graphics.Rect; import android.os.Parcel; import android.os.Parcelable; +import android.util.proto.ProtoOutputStream; import android.view.DisplayInfo; /** @@ -48,26 +52,33 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu /** The current windowing mode of the configuration. */ private @WindowingMode int mWindowingMode; - /** Windowing mode is currently not defined. - * @hide */ + /** Windowing mode is currently not defined. */ public static final int WINDOWING_MODE_UNDEFINED = 0; - /** Occupies the full area of the screen or the parent container. - * @hide */ + /** Occupies the full area of the screen or the parent container. */ public static final int WINDOWING_MODE_FULLSCREEN = 1; - /** Always on-top (always visible). of other siblings in its parent container. - * @hide */ + /** Always on-top (always visible). of other siblings in its parent container. */ public static final int WINDOWING_MODE_PINNED = 2; - /** The primary container driving the screen to be in split-screen mode. - * @hide */ + /** The primary container driving the screen to be in split-screen mode. */ public static final int WINDOWING_MODE_SPLIT_SCREEN_PRIMARY = 3; /** * The containers adjacent to the {@link #WINDOWING_MODE_SPLIT_SCREEN_PRIMARY} container in * split-screen mode. - * @hide + * NOTE: Containers launched with the windowing mode with APIs like + * {@link ActivityOptions#setLaunchWindowingMode(int)} will be launched in + * {@link #WINDOWING_MODE_FULLSCREEN} if the display isn't currently in split-screen windowing + * mode + * @see #WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY */ public static final int WINDOWING_MODE_SPLIT_SCREEN_SECONDARY = 4; - /** Can be freely resized within its parent container. - * @hide */ + /** + * Alias for {@link #WINDOWING_MODE_SPLIT_SCREEN_SECONDARY} that makes it clear that the usage + * points for APIs like {@link ActivityOptions#setLaunchWindowingMode(int)} that the container + * will launch into fullscreen or split-screen secondary depending on if the device is currently + * in fullscreen mode or split-screen mode. + */ + public static final int WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY = + WINDOWING_MODE_SPLIT_SCREEN_SECONDARY; + /** Can be freely resized within its parent container. */ public static final int WINDOWING_MODE_FREEFORM = 5; /** @hide */ @@ -77,6 +88,7 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu WINDOWING_MODE_PINNED, WINDOWING_MODE_SPLIT_SCREEN_PRIMARY, WINDOWING_MODE_SPLIT_SCREEN_SECONDARY, + WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY, WINDOWING_MODE_FREEFORM, }) public @interface WindowingMode {} @@ -84,18 +96,15 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu /** The current activity type of the configuration. */ private @ActivityType int mActivityType; - /** Activity type is currently not defined. - * @hide */ + /** Activity type is currently not defined. */ public static final int ACTIVITY_TYPE_UNDEFINED = 0; - /** Standard activity type. Nothing special about the activity... - * @hide */ + /** Standard activity type. Nothing special about the activity... */ public static final int ACTIVITY_TYPE_STANDARD = 1; /** Home/Launcher activity type. */ public static final int ACTIVITY_TYPE_HOME = 2; /** Recents/Overview activity type. */ public static final int ACTIVITY_TYPE_RECENTS = 3; - /** Assistant activity type. - * @hide */ + /** Assistant activity type. */ public static final int ACTIVITY_TYPE_ASSISTANT = 4; /** @hide */ @@ -127,7 +136,6 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu }) public @interface WindowConfig {} - /** @hide */ public WindowConfiguration() { unset(); } @@ -176,7 +184,6 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu * Set {@link #mAppBounds} to the input Rect. * @param rect The rect value to set {@link #mAppBounds} to. * @see #getAppBounds() - * @hide */ public void setAppBounds(Rect rect) { if (rect == null) { @@ -200,26 +207,20 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu mAppBounds.set(left, top, right, bottom); } - /** - * @see #setAppBounds(Rect) - * @hide - */ + /** @see #setAppBounds(Rect) */ public Rect getAppBounds() { return mAppBounds; } - /** @hide */ public void setWindowingMode(@WindowingMode int windowingMode) { mWindowingMode = windowingMode; } - /** @hide */ @WindowingMode public int getWindowingMode() { return mWindowingMode; } - /** @hide */ public void setActivityType(@ActivityType int activityType) { if (mActivityType == activityType) { return; @@ -237,13 +238,11 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu mActivityType = activityType; } - /** @hide */ @ActivityType public int getActivityType() { return mActivityType; } - /** @hide */ public void setTo(WindowConfiguration other) { setAppBounds(other.mAppBounds); setWindowingMode(other.mWindowingMode); @@ -382,6 +381,24 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu } /** + * Write to a protocol buffer output stream. + * Protocol buffer message definition at {@link android.app.WindowConfigurationProto} + * + * @param protoOutputStream Stream to write the WindowConfiguration object to. + * @param fieldId Field Id of the WindowConfiguration as defined in the parent message + * @hide + */ + public void writeToProto(ProtoOutputStream protoOutputStream, long fieldId) { + final long token = protoOutputStream.start(fieldId); + if (mAppBounds != null) { + mAppBounds.writeToProto(protoOutputStream, APP_BOUNDS); + } + protoOutputStream.write(WINDOWING_MODE, mWindowingMode); + protoOutputStream.write(ACTIVITY_TYPE, mActivityType); + protoOutputStream.end(token); + } + + /** * Returns true if the activities associated with this window configuration display a shadow * around their border. * @hide @@ -483,10 +500,15 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu * @hide */ public boolean supportSplitScreenWindowingMode() { - if (mActivityType == ACTIVITY_TYPE_ASSISTANT) { + return supportSplitScreenWindowingMode(mWindowingMode, mActivityType); + } + + /** @hide */ + public static boolean supportSplitScreenWindowingMode(int windowingMode, int activityType) { + if (activityType == ACTIVITY_TYPE_ASSISTANT) { return false; } - return mWindowingMode != WINDOWING_MODE_FREEFORM && mWindowingMode != WINDOWING_MODE_PINNED; + return windowingMode != WINDOWING_MODE_FREEFORM && windowingMode != WINDOWING_MODE_PINNED; } private static String windowingModeToString(@WindowingMode int windowingMode) { diff --git a/android/app/admin/DevicePolicyManager.java b/android/app/admin/DevicePolicyManager.java index 6bccad9f..3c530633 100644 --- a/android/app/admin/DevicePolicyManager.java +++ b/android/app/admin/DevicePolicyManager.java @@ -63,7 +63,9 @@ import android.telephony.TelephonyManager; import android.util.ArraySet; import android.util.Log; +import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; +import com.android.internal.util.Preconditions; import com.android.org.conscrypt.TrustedCertificateStore; import java.io.ByteArrayInputStream; @@ -3142,6 +3144,7 @@ public class DevicePolicyManager { */ public static final int WIPE_EUICC = 0x0004; + /** * Ask that all user data be wiped. If called as a secondary user, the user will be removed and * other users will remain unaffected. Calling from the primary user will cause the device to @@ -3157,10 +3160,47 @@ public class DevicePolicyManager { * that uses {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA} */ public void wipeData(int flags) { - throwIfParentInstance("wipeData"); + final String wipeReasonForUser = mContext.getString( + R.string.work_profile_deleted_description_dpm_wipe); + wipeDataInternal(flags, wipeReasonForUser); + } + + /** + * Ask that all user data be wiped. If called as a secondary user, the user will be removed and + * other users will remain unaffected, the provided reason for wiping data can be shown to + * user. Calling from the primary user will cause the device to reboot, erasing all device data + * - including all the secondary users and their data - while booting up. In this case, we don't + * show the reason to the user since the device would be factory reset. + * <p> + * The calling device admin must have requested {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA} to + * be able to call this method; if it has not, a security exception will be thrown. + * + * @param flags Bit mask of additional options: currently supported flags are + * {@link #WIPE_EXTERNAL_STORAGE} and {@link #WIPE_RESET_PROTECTION_DATA}. + * @param reason a string that contains the reason for wiping data, which can be + * presented to the user. + * @throws SecurityException if the calling application does not own an active administrator + * that uses {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA} + * @throws IllegalArgumentException if the input reason string is null or empty. + */ + public void wipeDataWithReason(int flags, @NonNull CharSequence reason) { + Preconditions.checkNotNull(reason, "CharSequence is null"); + wipeDataInternal(flags, reason.toString()); + } + + /** + * Internal function for both {@link #wipeData(int)} and + * {@link #wipeDataWithReason(int, CharSequence)} to call. + * + * @see #wipeData(int) + * @see #wipeDataWithReason(int, CharSequence) + * @hide + */ + private void wipeDataInternal(int flags, @NonNull String wipeReasonForUser) { + throwIfParentInstance("wipeDataWithReason"); if (mService != null) { try { - mService.wipeData(flags); + mService.wipeDataWithReason(flags, wipeReasonForUser); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -7534,12 +7574,12 @@ public class DevicePolicyManager { } /** - * Called by the device owner or profile owner to set the name of the organization under - * management. - * <p> - * If the organization name needs to be localized, it is the responsibility of the - * {@link DeviceAdminReceiver} to listen to the {@link Intent#ACTION_LOCALE_CHANGED} broadcast - * and set a new version of this string accordingly. + * Called by the device owner (since API 26) or profile owner (since API 24) to set the name of + * the organization under management. + * + * <p>If the organization name needs to be localized, it is the responsibility of the {@link + * DeviceAdminReceiver} to listen to the {@link Intent#ACTION_LOCALE_CHANGED} broadcast and set + * a new version of this string accordingly. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param title The organization name or {@code null} to clear a previously set name. diff --git a/android/app/assist/AssistStructure.java b/android/app/assist/AssistStructure.java index 55c22de5..d9b7cd7e 100644 --- a/android/app/assist/AssistStructure.java +++ b/android/app/assist/AssistStructure.java @@ -674,6 +674,7 @@ public class AssistStructure implements Parcelable { ViewNodeText mText; int mInputType; + String mWebScheme; String mWebDomain; Bundle mExtras; LocaleList mLocaleList; @@ -751,6 +752,7 @@ public class AssistStructure implements Parcelable { mInputType = in.readInt(); } if ((flags&FLAGS_HAS_URL) != 0) { + mWebScheme = in.readString(); mWebDomain = in.readString(); } if ((flags&FLAGS_HAS_LOCALE_LIST) != 0) { @@ -813,7 +815,7 @@ public class AssistStructure implements Parcelable { if (mInputType != 0) { flags |= FLAGS_HAS_INPUT_TYPE; } - if (mWebDomain != null) { + if (mWebScheme != null || mWebDomain != null) { flags |= FLAGS_HAS_URL; } if (mLocaleList != null) { @@ -908,6 +910,7 @@ public class AssistStructure implements Parcelable { out.writeInt(mInputType); } if ((flags&FLAGS_HAS_URL) != 0) { + out.writeString(mWebScheme); out.writeString(mWebDomain); } if ((flags&FLAGS_HAS_LOCALE_LIST) != 0) { @@ -1260,18 +1263,31 @@ public class AssistStructure implements Parcelable { * <p>Typically used when the view associated with the view is a container for an HTML * document. * - * <strong>WARNING:</strong> a {@link android.service.autofill.AutofillService} should only - * use this domain for autofill purposes when it trusts the app generating it (i.e., the app - * defined by {@link AssistStructure#getActivityComponent()}). + * <p><b>Warning:</b> an autofill service cannot trust the value reported by this method + * without verifing its authenticity—see the "Web security" section of + * {@link android.service.autofill.AutofillService} for more details. * * @return domain-only part of the document. For example, if the full URL is - * {@code http://my.site/login?user=my_user}, it returns {@code my.site}. + * {@code https://example.com/login?user=my_user}, it returns {@code example.com}. */ @Nullable public String getWebDomain() { return mWebDomain; } /** + * Returns the scheme of the HTML document represented by this view. + * + * <p>Typically used when the view associated with the view is a container for an HTML + * document. + * + * @return scheme-only part of the document. For example, if the full URL is + * {@code https://example.com/login?user=my_user}, it returns {@code https}. + */ + @Nullable public String getWebScheme() { + return mWebScheme; + } + + /** * Returns the HTML properties associated with this view. * * <p>It's only relevant when the {@link AssistStructure} is used for autofill purposes, @@ -1767,10 +1783,13 @@ public class AssistStructure implements Parcelable { @Override public void setWebDomain(@Nullable String domain) { if (domain == null) { + mNode.mWebScheme = null; mNode.mWebDomain = null; return; } - mNode.mWebDomain = Uri.parse(domain).getHost(); + Uri uri = Uri.parse(domain); + mNode.mWebScheme = uri.getScheme(); + mNode.mWebDomain = uri.getHost(); } @Override diff --git a/android/app/job/JobInfo.java b/android/app/job/JobInfo.java index 87e516ca..1434c9ba 100644 --- a/android/app/job/JobInfo.java +++ b/android/app/job/JobInfo.java @@ -317,7 +317,8 @@ public class JobInfo implements Parcelable { } /** - * Whether this job needs the device to be plugged in. + * Whether this job requires that the device be charging (or be a non-battery-powered + * device connected to permanent power, such as Android TV devices). */ public boolean isRequireCharging() { return (constraintFlags & CONSTRAINT_FLAG_CHARGING) != 0; @@ -331,7 +332,10 @@ public class JobInfo implements Parcelable { } /** - * Whether this job needs the device to be in an Idle maintenance window. + * Whether this job requires that the user <em>not</em> be interacting with the device. + * + * <p class="note">This is <em>not</em> the same as "doze" or "device idle"; + * it is purely about the user's direct interactions.</p> */ public boolean isRequireDeviceIdle() { return (constraintFlags & CONSTRAINT_FLAG_DEVICE_IDLE) != 0; @@ -918,9 +922,19 @@ public class JobInfo implements Parcelable { } /** - * Specify that to run this job, the device needs to be plugged in. This defaults to - * false. - * @param requiresCharging Whether or not the device is plugged in. + * Specify that to run this job, the device must be charging (or be a + * non-battery-powered device connected to permanent power, such as Android TV + * devices). This defaults to {@code false}. + * + * <p class="note">For purposes of running jobs, a battery-powered device + * "charging" is not quite the same as simply being connected to power. If the + * device is so busy that the battery is draining despite a power connection, jobs + * with this constraint will <em>not</em> run. This can happen during some + * common use cases such as video chat, particularly if the device is plugged in + * to USB rather than to wall power. + * + * @param requiresCharging Pass {@code true} to require that the device be + * charging in order to run the job. */ public Builder setRequiresCharging(boolean requiresCharging) { mConstraintFlags = (mConstraintFlags&~CONSTRAINT_FLAG_CHARGING) @@ -942,14 +956,22 @@ public class JobInfo implements Parcelable { } /** - * Specify that to run, the job needs the device to be in idle mode. This defaults to - * false. - * <p>Idle mode is a loose definition provided by the system, which means that the device - * is not in use, and has not been in use for some time. As such, it is a good time to - * perform resource heavy jobs. Bear in mind that battery usage will still be attributed - * to your application, and surfaced to the user in battery stats.</p> - * @param requiresDeviceIdle Whether or not the device need be within an idle maintenance - * window. + * When set {@code true}, ensure that this job will not run if the device is in active use. + * The default state is {@code false}: that is, the for the job to be runnable even when + * someone is interacting with the device. + * + * <p>This state is a loose definition provided by the system. In general, it means that + * the device is not currently being used interactively, and has not been in use for some + * time. As such, it is a good time to perform resource heavy jobs. Bear in mind that + * battery usage will still be attributed to your application, and surfaced to the user in + * battery stats.</p> + * + * <p class="note">Despite the similar naming, this job constraint is <em>not</em> + * related to the system's "device idle" or "doze" states. This constraint only + * determines whether a job is allowed to run while the device is directly in use. + * + * @param requiresDeviceIdle Pass {@code true} to prevent the job from running + * while the device is being used interactively. */ public Builder setRequiresDeviceIdle(boolean requiresDeviceIdle) { mConstraintFlags = (mConstraintFlags&~CONSTRAINT_FLAG_DEVICE_IDLE) diff --git a/android/app/timezone/RulesUpdaterContract.java b/android/app/timezone/RulesUpdaterContract.java index 9c62f46b..74ed6588 100644 --- a/android/app/timezone/RulesUpdaterContract.java +++ b/android/app/timezone/RulesUpdaterContract.java @@ -51,7 +51,7 @@ public final class RulesUpdaterContract { * applies. */ public static final String ACTION_TRIGGER_RULES_UPDATE_CHECK = - "android.intent.action.timezone.TRIGGER_RULES_UPDATE_CHECK"; + "com.android.intent.action.timezone.TRIGGER_RULES_UPDATE_CHECK"; /** * The extra containing the {@code byte[]} that should be passed to @@ -61,7 +61,7 @@ public final class RulesUpdaterContract { * {@link #ACTION_TRIGGER_RULES_UPDATE_CHECK} intent has been processed. */ public static final String EXTRA_CHECK_TOKEN = - "android.intent.extra.timezone.CHECK_TOKEN"; + "com.android.intent.extra.timezone.CHECK_TOKEN"; /** * Creates an intent that would trigger a time zone rules update check. @@ -83,8 +83,7 @@ public final class RulesUpdaterContract { Intent intent = createUpdaterIntent(updaterAppPackageName); intent.putExtra(EXTRA_CHECK_TOKEN, checkTokenBytes); context.sendBroadcastAsUser( - intent, - UserHandle.of(UserHandle.myUserId()), + intent, UserHandle.SYSTEM, RulesUpdaterContract.UPDATE_TIME_ZONE_RULES_PERMISSION); } } |