Merge "Move parseInputMethodsAndSubtypesString to InputMethodUtils."
diff --git a/Android.mk b/Android.mk
index b1ca0bc..769a555 100644
--- a/Android.mk
+++ b/Android.mk
@@ -752,6 +752,7 @@
-since $(SRC_API_DIR)/20.txt 20 \
-since $(SRC_API_DIR)/21.txt 21 \
-since $(SRC_API_DIR)/22.txt 22 \
+ -since $(SRC_API_DIR)/23.txt 23 \
-werror -hide 111 -hide 113 \
-overview $(LOCAL_PATH)/core/java/overview.html
@@ -790,7 +791,7 @@
## SDK version identifiers used in the published docs
# major[.minor] version for current SDK. (full releases only)
-framework_docs_SDK_VERSION:=5.1
+framework_docs_SDK_VERSION:=6.0
# release version (ie "Release x") (full releases only)
framework_docs_SDK_REL_ID:=1
diff --git a/api/current.txt b/api/current.txt
index 14babc8..0394d56 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -11276,6 +11276,7 @@
method public static int blue(int);
method public static void colorToHSV(int, float[]);
method public static int green(int);
+ method public static float luminance(int);
method public static int parseColor(java.lang.String);
method public static int red(int);
method public static int rgb(int, int, int);
@@ -12398,9 +12399,17 @@
ctor public GradientDrawable();
ctor public GradientDrawable(android.graphics.drawable.GradientDrawable.Orientation, int[]);
method public void draw(android.graphics.Canvas);
+ method public android.content.res.ColorStateList getColor();
+ method public int[] getColors();
+ method public float[] getCornerRadii();
+ method public float getCornerRadius();
+ method public float getGradientCenterX();
+ method public float getGradientCenterY();
method public float getGradientRadius();
+ method public int getGradientType();
method public int getOpacity();
method public android.graphics.drawable.GradientDrawable.Orientation getOrientation();
+ method public boolean isUseLevel();
method public void setAlpha(int);
method public void setColor(int);
method public void setColor(android.content.res.ColorStateList);
@@ -12534,10 +12543,12 @@
ctor public deprecated NinePatchDrawable(android.graphics.NinePatch);
ctor public NinePatchDrawable(android.content.res.Resources, android.graphics.NinePatch);
method public void draw(android.graphics.Canvas);
+ method public android.graphics.NinePatch getNinePatch();
method public int getOpacity();
method public android.graphics.Paint getPaint();
method public void setAlpha(int);
method public void setColorFilter(android.graphics.ColorFilter);
+ method public void setNinePatch(android.graphics.NinePatch);
method public void setTargetDensity(android.graphics.Canvas);
method public void setTargetDensity(android.util.DisplayMetrics);
method public void setTargetDensity(int);
@@ -41441,6 +41452,8 @@
method public void dispatchDraw(android.graphics.Canvas);
method public void focusCurrentTab(int);
method public android.view.View getChildTabViewAt(int);
+ method public android.graphics.drawable.Drawable getLeftStripDrawable();
+ method public android.graphics.drawable.Drawable getRightStripDrawable();
method public int getTabCount();
method public boolean isStripEnabled();
method public void onFocusChange(android.view.View, boolean);
diff --git a/api/system-current.txt b/api/system-current.txt
index 908bf3c..a1aa042 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -11613,6 +11613,7 @@
method public static int blue(int);
method public static void colorToHSV(int, float[]);
method public static int green(int);
+ method public static float luminance(int);
method public static int parseColor(java.lang.String);
method public static int red(int);
method public static int rgb(int, int, int);
@@ -12735,9 +12736,17 @@
ctor public GradientDrawable();
ctor public GradientDrawable(android.graphics.drawable.GradientDrawable.Orientation, int[]);
method public void draw(android.graphics.Canvas);
+ method public android.content.res.ColorStateList getColor();
+ method public int[] getColors();
+ method public float[] getCornerRadii();
+ method public float getCornerRadius();
+ method public float getGradientCenterX();
+ method public float getGradientCenterY();
method public float getGradientRadius();
+ method public int getGradientType();
method public int getOpacity();
method public android.graphics.drawable.GradientDrawable.Orientation getOrientation();
+ method public boolean isUseLevel();
method public void setAlpha(int);
method public void setColor(int);
method public void setColor(android.content.res.ColorStateList);
@@ -12871,10 +12880,12 @@
ctor public deprecated NinePatchDrawable(android.graphics.NinePatch);
ctor public NinePatchDrawable(android.content.res.Resources, android.graphics.NinePatch);
method public void draw(android.graphics.Canvas);
+ method public android.graphics.NinePatch getNinePatch();
method public int getOpacity();
method public android.graphics.Paint getPaint();
method public void setAlpha(int);
method public void setColorFilter(android.graphics.ColorFilter);
+ method public void setNinePatch(android.graphics.NinePatch);
method public void setTargetDensity(android.graphics.Canvas);
method public void setTargetDensity(android.util.DisplayMetrics);
method public void setTargetDensity(int);
@@ -44087,6 +44098,8 @@
method public void dispatchDraw(android.graphics.Canvas);
method public void focusCurrentTab(int);
method public android.view.View getChildTabViewAt(int);
+ method public android.graphics.drawable.Drawable getLeftStripDrawable();
+ method public android.graphics.drawable.Drawable getRightStripDrawable();
method public int getTabCount();
method public boolean isStripEnabled();
method public void onFocusChange(android.view.View, boolean);
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java
index 85de12f..b629435 100644
--- a/cmds/am/src/com/android/commands/am/Am.java
+++ b/cmds/am/src/com/android/commands/am/Am.java
@@ -77,6 +77,15 @@
private static final String SHELL_PACKAGE_NAME = "com.android.shell";
+ // Is the object moving in a positive direction?
+ private static final boolean MOVING_FORWARD = true;
+ // Is the object moving in the horizontal plan?
+ private static final boolean MOVING_HORIZONTALLY = true;
+ // Is the object current point great then its target point?
+ private static final boolean GREATER_THAN_TARGET = true;
+ // Amount we reduce the stack size by when testing a task re-size.
+ private static final int STACK_BOUNDS_INSET = 10;
+
private IActivityManager mAm;
private int mStartFlags = 0;
@@ -146,6 +155,8 @@
" am task lock stop\n" +
" am task resizeable <TASK_ID> [true|false]\n" +
" am task resize <TASK_ID> <LEFT,TOP,RIGHT,BOTTOM>\n" +
+ " am task drag-task-test <TASK_ID> <STEP_SIZE> [DELAY_MS] \n" +
+ " am task size-task-test <TASK_ID> <STEP_SIZE> [DELAY_MS] \n" +
" am get-config\n" +
" am set-inactive [--user <USER_ID>] <PACKAGE> true|false\n" +
" am get-inactive [--user <USER_ID>] <PACKAGE>\n" +
@@ -297,6 +308,14 @@
" Forces the task to be resizeable and creates a stack if no existing stack\n" +
" has the specified bounds.\n" +
"\n" +
+ "am task drag-task-test: test command for dragging/moving <TASK_ID> by\n" +
+ " <STEP_SIZE> increments around the screen applying the optional [DELAY_MS]\n" +
+ " between each step.\n" +
+ "\n" +
+ "am task size-task-test: test command for sizing <TASK_ID> by <STEP_SIZE>" +
+ " increments within the screen applying the optional [DELAY_MS] between\n" +
+ " each step.\n" +
+ "\n" +
"am get-config: retrieve the configuration and any recent configurations\n" +
" of the device.\n" +
"\n" +
@@ -2089,6 +2108,10 @@
runTaskResizeable();
} else if (op.equals("resize")) {
runTaskResize();
+ } else if (op.equals("drag-task-test")) {
+ runTaskDragTaskTest();
+ } else if (op.equals("size-task-test")) {
+ runTaskSizeTaskTest();
} else {
showError("Error: unknown command '" + op + "'");
return;
@@ -2130,12 +2153,260 @@
System.err.println("Error: invalid input bounds");
return;
}
+ taskResize(taskId, bounds, 0);
+ }
+
+ private void taskResize(int taskId, Rect bounds, int delay_ms) {
try {
mAm.resizeTask(taskId, bounds);
+ Thread.sleep(delay_ms);
} catch (RemoteException e) {
+ System.err.println("Error changing task bounds: " + e);
+ } catch (InterruptedException e) {
}
}
+ private void runTaskDragTaskTest() {
+ final int taskId = Integer.valueOf(nextArgRequired());
+ final int stepSize = Integer.valueOf(nextArgRequired());
+ final String delayStr = nextArg();
+ final int delay_ms = (delayStr != null) ? Integer.valueOf(delayStr) : 0;
+ final StackInfo stackInfo;
+ Rect taskBounds;
+ try {
+ stackInfo = mAm.getStackInfo(mAm.getFocusedStackId());
+ taskBounds = mAm.getTaskBounds(taskId);
+ } catch (RemoteException e) {
+ System.err.println("Error getting focus stack info or task bounds: " + e);
+ return;
+ }
+ final Rect stackBounds = stackInfo.bounds;
+ int travelRight = stackBounds.width() - taskBounds.width();
+ int travelLeft = -travelRight;
+ int travelDown = stackBounds.height() - taskBounds.height();
+ int travelUp = -travelDown;
+ int passes = 0;
+
+ // We do 2 passes to get back to the original location of the task.
+ while (passes < 2) {
+ // Move right
+ System.out.println("Moving right...");
+ travelRight = moveTask(taskId, taskBounds, stackBounds, stepSize,
+ travelRight, MOVING_FORWARD, MOVING_HORIZONTALLY, delay_ms);
+ System.out.println("Still need to travel right by " + travelRight);
+
+ // Move down
+ System.out.println("Moving down...");
+ travelDown = moveTask(taskId, taskBounds, stackBounds, stepSize,
+ travelDown, MOVING_FORWARD, !MOVING_HORIZONTALLY, delay_ms);
+ System.out.println("Still need to travel down by " + travelDown);
+
+ // Move left
+ System.out.println("Moving left...");
+ travelLeft = moveTask(taskId, taskBounds, stackBounds, stepSize,
+ travelLeft, !MOVING_FORWARD, MOVING_HORIZONTALLY, delay_ms);
+ System.out.println("Still need to travel left by " + travelLeft);
+
+ // Move up
+ System.out.println("Moving up...");
+ travelUp = moveTask(taskId, taskBounds, stackBounds, stepSize,
+ travelUp, !MOVING_FORWARD, !MOVING_HORIZONTALLY, delay_ms);
+ System.out.println("Still need to travel up by " + travelUp);
+
+ try {
+ taskBounds = mAm.getTaskBounds(taskId);
+ } catch (RemoteException e) {
+ System.err.println("Error getting task bounds: " + e);
+ return;
+ }
+ passes++;
+ }
+ }
+
+ private int moveTask(int taskId, Rect taskRect, Rect stackRect, int stepSize,
+ int maxToTravel, boolean movingForward, boolean horizontal, int delay_ms) {
+ int maxMove;
+ if (movingForward) {
+ while (maxToTravel > 0
+ && ((horizontal && taskRect.right < stackRect.right)
+ ||(!horizontal && taskRect.bottom < stackRect.bottom))) {
+ if (horizontal) {
+ maxMove = Math.min(stepSize, stackRect.right - taskRect.right);
+ maxToTravel -= maxMove;
+ taskRect.right += maxMove;
+ taskRect.left += maxMove;
+ } else {
+ maxMove = Math.min(stepSize, stackRect.bottom - taskRect.bottom);
+ maxToTravel -= maxMove;
+ taskRect.top += maxMove;
+ taskRect.bottom += maxMove;
+ }
+ taskResize(taskId, taskRect, delay_ms);
+ }
+ } else {
+ while (maxToTravel < 0
+ && ((horizontal && taskRect.left > stackRect.left)
+ ||(!horizontal && taskRect.top > stackRect.top))) {
+ if (horizontal) {
+ maxMove = Math.min(stepSize, taskRect.left - stackRect.left);
+ maxToTravel -= maxMove;
+ taskRect.right -= maxMove;
+ taskRect.left -= maxMove;
+ } else {
+ maxMove = Math.min(stepSize, taskRect.top - stackRect.top);
+ maxToTravel -= maxMove;
+ taskRect.top -= maxMove;
+ taskRect.bottom -= maxMove;
+ }
+ taskResize(taskId, taskRect, delay_ms);
+ }
+ }
+ // Return the remaining distance we didn't travel because we reached the target location.
+ return maxToTravel;
+ }
+
+ private void runTaskSizeTaskTest() {
+ final int taskId = Integer.valueOf(nextArgRequired());
+ final int stepSize = Integer.valueOf(nextArgRequired());
+ final String delayStr = nextArg();
+ final int delay_ms = (delayStr != null) ? Integer.valueOf(delayStr) : 0;
+ final StackInfo stackInfo;
+ final Rect initialTaskBounds;
+ try {
+ stackInfo = mAm.getStackInfo(mAm.getFocusedStackId());
+ initialTaskBounds = mAm.getTaskBounds(taskId);
+ } catch (RemoteException e) {
+ System.err.println("Error getting focus stack info or task bounds: " + e);
+ return;
+ }
+ final Rect stackBounds = stackInfo.bounds;
+ stackBounds.inset(STACK_BOUNDS_INSET, STACK_BOUNDS_INSET);
+ final Rect currentTaskBounds = new Rect(initialTaskBounds);
+
+ // Size by top-left
+ System.out.println("Growing top-left");
+ do {
+ currentTaskBounds.top -= getStepSize(
+ currentTaskBounds.top, stackBounds.top, stepSize, GREATER_THAN_TARGET);
+
+ currentTaskBounds.left -= getStepSize(
+ currentTaskBounds.left, stackBounds.left, stepSize, GREATER_THAN_TARGET);
+
+ taskResize(taskId, currentTaskBounds, delay_ms);
+ } while (stackBounds.top < currentTaskBounds.top
+ || stackBounds.left < currentTaskBounds.left);
+
+ // Back to original size
+ System.out.println("Shrinking top-left");
+ do {
+ currentTaskBounds.top += getStepSize(
+ currentTaskBounds.top, initialTaskBounds.top, stepSize, !GREATER_THAN_TARGET);
+
+ currentTaskBounds.left += getStepSize(
+ currentTaskBounds.left, initialTaskBounds.left, stepSize, !GREATER_THAN_TARGET);
+
+ taskResize(taskId, currentTaskBounds, delay_ms);
+ } while (initialTaskBounds.top > currentTaskBounds.top
+ || initialTaskBounds.left > currentTaskBounds.left);
+
+ // Size by top-right
+ System.out.println("Growing top-right");
+ do {
+ currentTaskBounds.top -= getStepSize(
+ currentTaskBounds.top, stackBounds.top, stepSize, GREATER_THAN_TARGET);
+
+ currentTaskBounds.right += getStepSize(
+ currentTaskBounds.right, stackBounds.right, stepSize, !GREATER_THAN_TARGET);
+
+ taskResize(taskId, currentTaskBounds, delay_ms);
+ } while (stackBounds.top < currentTaskBounds.top
+ || stackBounds.right > currentTaskBounds.right);
+
+ // Back to original size
+ System.out.println("Shrinking top-right");
+ do {
+ currentTaskBounds.top += getStepSize(
+ currentTaskBounds.top, initialTaskBounds.top, stepSize, !GREATER_THAN_TARGET);
+
+ currentTaskBounds.right -= getStepSize(currentTaskBounds.right, initialTaskBounds.right,
+ stepSize, GREATER_THAN_TARGET);
+
+ taskResize(taskId, currentTaskBounds, delay_ms);
+ } while (initialTaskBounds.top > currentTaskBounds.top
+ || initialTaskBounds.right < currentTaskBounds.right);
+
+ // Size by bottom-left
+ System.out.println("Growing bottom-left");
+ do {
+ currentTaskBounds.bottom += getStepSize(
+ currentTaskBounds.bottom, stackBounds.bottom, stepSize, !GREATER_THAN_TARGET);
+
+ currentTaskBounds.left -= getStepSize(
+ currentTaskBounds.left, stackBounds.left, stepSize, GREATER_THAN_TARGET);
+
+ taskResize(taskId, currentTaskBounds, delay_ms);
+ } while (stackBounds.bottom > currentTaskBounds.bottom
+ || stackBounds.left < currentTaskBounds.left);
+
+ // Back to original size
+ System.out.println("Shrinking bottom-left");
+ do {
+ currentTaskBounds.bottom -= getStepSize(currentTaskBounds.bottom,
+ initialTaskBounds.bottom, stepSize, GREATER_THAN_TARGET);
+
+ currentTaskBounds.left += getStepSize(
+ currentTaskBounds.left, initialTaskBounds.left, stepSize, !GREATER_THAN_TARGET);
+
+ taskResize(taskId, currentTaskBounds, delay_ms);
+ } while (initialTaskBounds.bottom < currentTaskBounds.bottom
+ || initialTaskBounds.left > currentTaskBounds.left);
+
+ // Size by bottom-right
+ System.out.println("Growing bottom-right");
+ do {
+ currentTaskBounds.bottom += getStepSize(
+ currentTaskBounds.bottom, stackBounds.bottom, stepSize, !GREATER_THAN_TARGET);
+
+ currentTaskBounds.right += getStepSize(
+ currentTaskBounds.right, stackBounds.right, stepSize, !GREATER_THAN_TARGET);
+
+ taskResize(taskId, currentTaskBounds, delay_ms);
+ } while (stackBounds.bottom > currentTaskBounds.bottom
+ || stackBounds.right > currentTaskBounds.right);
+
+ // Back to original size
+ System.out.println("Shrinking bottom-right");
+ do {
+ currentTaskBounds.bottom -= getStepSize(currentTaskBounds.bottom,
+ initialTaskBounds.bottom, stepSize, GREATER_THAN_TARGET);
+
+ currentTaskBounds.right -= getStepSize(currentTaskBounds.right, initialTaskBounds.right,
+ stepSize, GREATER_THAN_TARGET);
+
+ taskResize(taskId, currentTaskBounds, delay_ms);
+ } while (initialTaskBounds.bottom < currentTaskBounds.bottom
+ || initialTaskBounds.right < currentTaskBounds.right);
+ }
+
+ private int getStepSize(int current, int target, int inStepSize, boolean greaterThanTarget) {
+ int stepSize = 0;
+ if (greaterThanTarget && target < current) {
+ current -= inStepSize;
+ stepSize = inStepSize;
+ if (target > current) {
+ stepSize -= (target - current);
+ }
+ }
+ if (!greaterThanTarget && target > current) {
+ current += inStepSize;
+ stepSize = inStepSize;
+ if (target < current) {
+ stepSize += (current - target);
+ }
+ }
+ return stepSize;
+ }
+
private List<Configuration> getRecentConfigurations(int days) {
IUsageStatsManager usm = IUsageStatsManager.Stub.asInterface(ServiceManager.getService(
Context.USAGE_STATS_SERVICE));
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java
index 964b776..f66a4c7 100644
--- a/cmds/pm/src/com/android/commands/pm/Pm.java
+++ b/cmds/pm/src/com/android/commands/pm/Pm.java
@@ -19,6 +19,7 @@
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED;
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK;
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS;
+import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK;
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER;
import android.app.ActivityManager;
@@ -844,7 +845,7 @@
return Integer.toString(result);
}
- // pm set-app-link [--user USER_ID] PACKAGE {always|ask|never|undefined}
+ // pm set-app-link [--user USER_ID] PACKAGE {always|ask|always-ask|never|undefined}
private int runSetAppLink() {
int userId = UserHandle.USER_SYSTEM;
@@ -893,6 +894,10 @@
newMode = INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK;
break;
+ case "always-ask":
+ newMode = INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK;
+ break;
+
case "never":
newMode = INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER;
break;
diff --git a/core/java/android/app/DialogFragment.java b/core/java/android/app/DialogFragment.java
index 2fb8cc2..9caf752 100644
--- a/core/java/android/app/DialogFragment.java
+++ b/core/java/android/app/DialogFragment.java
@@ -230,6 +230,15 @@
ft.commit();
}
+ /** {@hide} */
+ public void showAllowingStateLoss(FragmentManager manager, String tag) {
+ mDismissed = false;
+ mShownByMe = true;
+ FragmentTransaction ft = manager.beginTransaction();
+ ft.add(this, tag);
+ ft.commitAllowingStateLoss();
+ }
+
/**
* Display the dialog, adding the fragment using an existing transaction
* and then committing the transaction.
diff --git a/core/java/android/app/IUiAutomationConnection.aidl b/core/java/android/app/IUiAutomationConnection.aidl
index 474154b..2caec369 100644
--- a/core/java/android/app/IUiAutomationConnection.aidl
+++ b/core/java/android/app/IUiAutomationConnection.aidl
@@ -43,6 +43,8 @@
void clearWindowAnimationFrameStats();
WindowAnimationFrameStats getWindowAnimationFrameStats();
void executeShellCommand(String command, in ParcelFileDescriptor fd);
+ void grantRuntimePermission(String packageName, String permission, int userId);
+ void revokeRuntimePermission(String packageName, String permission, int userId);
// Called from the system process.
oneway void shutdown();
diff --git a/core/java/android/app/UiAutomation.java b/core/java/android/app/UiAutomation.java
index a8494fb..efed2e0 100644
--- a/core/java/android/app/UiAutomation.java
+++ b/core/java/android/app/UiAutomation.java
@@ -30,6 +30,7 @@
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.os.SystemClock;
+import android.os.UserHandle;
import android.util.Log;
import android.view.Display;
import android.view.InputEvent;
@@ -846,6 +847,62 @@
}
/**
+ * Grants a runtime permission to a package for a user.
+ * @param packageName The package to which to grant.
+ * @param permission The permission to grant.
+ * @return Whether granting succeeded.
+ *
+ * @hide
+ */
+ public boolean grantRuntimePermission(String packageName, String permission,
+ UserHandle userHandle) {
+ synchronized (mLock) {
+ throwIfNotConnectedLocked();
+ }
+ try {
+ if (DEBUG) {
+ Log.i(LOG_TAG, "Granting runtime permission");
+ }
+ // Calling out without a lock held.
+ mUiAutomationConnection.grantRuntimePermission(packageName,
+ permission, userHandle.getIdentifier());
+ // TODO: The package manager API should return boolean.
+ return true;
+ } catch (RemoteException re) {
+ Log.e(LOG_TAG, "Error granting runtime permission", re);
+ }
+ return false;
+ }
+
+ /**
+ * Revokes a runtime permission from a package for a user.
+ * @param packageName The package from which to revoke.
+ * @param permission The permission to revoke.
+ * @return Whether revoking succeeded.
+ *
+ * @hide
+ */
+ public boolean revokeRuntimePermission(String packageName, String permission,
+ UserHandle userHandle) {
+ synchronized (mLock) {
+ throwIfNotConnectedLocked();
+ }
+ try {
+ if (DEBUG) {
+ Log.i(LOG_TAG, "Revoking runtime permission");
+ }
+ // Calling out without a lock held.
+ mUiAutomationConnection.revokeRuntimePermission(packageName,
+ permission, userHandle.getIdentifier());
+ // TODO: The package manager API should return boolean.
+ return true;
+ } catch (RemoteException re) {
+ Log.e(LOG_TAG, "Error revoking runtime permission", re);
+ }
+ return false;
+ }
+
+ /**
* Executes a shell command. This method returs a file descriptor that points
* to the standard output stream. The command execution is similar to running
* "adb shell <command>" from a host connected to the device.
diff --git a/core/java/android/app/UiAutomationConnection.java b/core/java/android/app/UiAutomationConnection.java
index 39cd3bc..13e27e2 100644
--- a/core/java/android/app/UiAutomationConnection.java
+++ b/core/java/android/app/UiAutomationConnection.java
@@ -19,6 +19,7 @@
import android.accessibilityservice.AccessibilityServiceInfo;
import android.accessibilityservice.IAccessibilityServiceClient;
import android.content.Context;
+import android.content.pm.IPackageManager;
import android.graphics.Bitmap;
import android.hardware.input.InputManager;
import android.os.Binder;
@@ -60,6 +61,9 @@
private final IAccessibilityManager mAccessibilityManager = IAccessibilityManager.Stub
.asInterface(ServiceManager.getService(Service.ACCESSIBILITY_SERVICE));
+ private final IPackageManager mPackageManager = IPackageManager.Stub
+ .asInterface(ServiceManager.getService("package"));
+
private final Object mLock = new Object();
private final Binder mToken = new Binder();
@@ -227,6 +231,38 @@
}
@Override
+ public void grantRuntimePermission(String packageName, String permission, int userId)
+ throws RemoteException {
+ synchronized (mLock) {
+ throwIfCalledByNotTrustedUidLocked();
+ throwIfShutdownLocked();
+ throwIfNotConnectedLocked();
+ }
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ mPackageManager.grantRuntimePermission(packageName, permission, userId);
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ @Override
+ public void revokeRuntimePermission(String packageName, String permission, int userId)
+ throws RemoteException {
+ synchronized (mLock) {
+ throwIfCalledByNotTrustedUidLocked();
+ throwIfShutdownLocked();
+ throwIfNotConnectedLocked();
+ }
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ mPackageManager.revokeRuntimePermission(packageName, permission, userId);
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ @Override
public void executeShellCommand(final String command, final ParcelFileDescriptor sink)
throws RemoteException {
synchronized (mLock) {
diff --git a/core/java/android/content/pm/IntentFilterVerificationInfo.java b/core/java/android/content/pm/IntentFilterVerificationInfo.java
index 4dbac05..953b051 100644
--- a/core/java/android/content/pm/IntentFilterVerificationInfo.java
+++ b/core/java/android/content/pm/IntentFilterVerificationInfo.java
@@ -19,6 +19,7 @@
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED;
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK;
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS;
+import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK;
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER;
import android.os.Parcel;
@@ -199,6 +200,10 @@
sb.append("never");
break;
+ case INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK:
+ sb.append("always-ask");
+ break;
+
case INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED:
default:
sb.append("undefined");
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 0f936fd..c8e9402 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -1073,6 +1073,18 @@
public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER = 3;
/**
+ * Used as the {@code status} argument for {@link PackageManager#updateIntentVerificationStatus}
+ * to indicate that this app should always be considered as an ambiguous candidate for
+ * handling the matching Intent even if there are other candidate apps in the "always"
+ * state. Put another way: if there are any 'always ask' apps in a set of more than
+ * one candidate app, then a disambiguation is *always* presented even if there is
+ * another candidate app with the 'always' state.
+ *
+ * @hide
+ */
+ public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK = 4;
+
+ /**
* Can be used as the {@code millisecondsToDelay} argument for
* {@link PackageManager#extendVerificationTimeout}. This is the
* maximum time {@code PackageManager} waits for the verification
diff --git a/core/java/android/os/UserHandle.java b/core/java/android/os/UserHandle.java
index dadec51..48ede4f 100644
--- a/core/java/android/os/UserHandle.java
+++ b/core/java/android/os/UserHandle.java
@@ -193,16 +193,16 @@
}
/**
- * Returns the app id for a given shared app gid.
+ * Returns the app id for a given shared app gid. Returns -1 if the ID is invalid.
* @hide
*/
public static final int getAppIdFromSharedAppGid(int gid) {
- final int noUserGid = getAppId(gid);
- if (noUserGid < Process.FIRST_SHARED_APPLICATION_GID ||
- noUserGid > Process.LAST_SHARED_APPLICATION_GID) {
- throw new IllegalArgumentException(Integer.toString(gid) + " is not a shared app gid");
+ final int appId = getAppId(gid) + Process.FIRST_APPLICATION_UID
+ - Process.FIRST_SHARED_APPLICATION_GID;
+ if (appId < 0 || appId >= Process.FIRST_SHARED_APPLICATION_GID) {
+ return -1;
}
- return (noUserGid + Process.FIRST_APPLICATION_UID) - Process.FIRST_SHARED_APPLICATION_GID;
+ return appId;
}
/**
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 8f0f2d2..d1744b4 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -8109,6 +8109,13 @@
* @hide
*/
public static final String CONTACT_METADATA_SYNC = "contact_metadata_sync";
+
+ /**
+ * Whether to enable cellular on boot.
+ * The value 1 - enable, 0 - disable
+ * @hide
+ */
+ public static final String ENABLE_CELLULAR_ON_BOOT = "enable_cellular_on_boot";
}
/**
diff --git a/core/java/android/widget/TabWidget.java b/core/java/android/widget/TabWidget.java
index d9cff4e..0cc630a 100644
--- a/core/java/android/widget/TabWidget.java
+++ b/core/java/android/widget/TabWidget.java
@@ -16,8 +16,10 @@
package android.widget;
-import android.R;
+import com.android.internal.R;
+
import android.annotation.DrawableRes;
+import android.annotation.Nullable;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
@@ -33,21 +35,25 @@
/**
*
* Displays a list of tab labels representing each page in the parent's tab
- * collection. The container object for this widget is
- * {@link android.widget.TabHost TabHost}. When the user selects a tab, this
- * object sends a message to the parent container, TabHost, to tell it to switch
- * the displayed page. You typically won't use many methods directly on this
- * object. The container TabHost is used to add labels, add the callback
- * handler, and manage callbacks. You might call this object to iterate the list
- * of tabs, or to tweak the layout of the tab list, but most methods should be
- * called on the containing TabHost object.
- *
+ * collection.
+ * <p>
+ * The container object for this widget is {@link android.widget.TabHost TabHost}.
+ * When the user selects a tab, this object sends a message to the parent
+ * container, TabHost, to tell it to switch the displayed page. You typically
+ * won't use many methods directly on this object. The container TabHost is
+ * used to add labels, add the callback handler, and manage callbacks. You
+ * might call this object to iterate the list of tabs, or to tweak the layout
+ * of the tab list, but most methods should be called on the containing TabHost
+ * object.
+ *
* @attr ref android.R.styleable#TabWidget_divider
* @attr ref android.R.styleable#TabWidget_tabStripEnabled
* @attr ref android.R.styleable#TabWidget_tabStripLeft
* @attr ref android.R.styleable#TabWidget_tabStripRight
*/
public class TabWidget extends LinearLayout implements OnFocusChangeListener {
+ private final Rect mBounds = new Rect();
+
private OnTabSelectionChanged mSelectionChangedListener;
// This value will be set to 0 as soon as the first tab is added to TabHost.
@@ -59,9 +65,8 @@
private boolean mDrawBottomStrips = true;
private boolean mStripMoved;
- private final Rect mBounds = new Rect();
-
- // When positive, the widths and heights of tabs will be imposed so that they fit in parent
+ // When positive, the widths and heights of tabs will be imposed so that
+ // they fit in parent.
private int mImposedTabsHeight = -1;
private int[] mImposedTabWidths;
@@ -81,20 +86,48 @@
super(context, attrs, defStyleAttr, defStyleRes);
final TypedArray a = context.obtainStyledAttributes(
- attrs, com.android.internal.R.styleable.TabWidget, defStyleAttr, defStyleRes);
+ attrs, R.styleable.TabWidget, defStyleAttr, defStyleRes);
- setStripEnabled(a.getBoolean(R.styleable.TabWidget_tabStripEnabled, true));
- setLeftStripDrawable(a.getDrawable(R.styleable.TabWidget_tabStripLeft));
- setRightStripDrawable(a.getDrawable(R.styleable.TabWidget_tabStripRight));
+ mDrawBottomStrips = a.getBoolean(R.styleable.TabWidget_tabStripEnabled, mDrawBottomStrips);
+
+ // Tests the target SDK version, as set in the Manifest. Could not be
+ // set using styles.xml in a values-v? directory which targets the
+ // current platform SDK version instead.
+ final boolean isTargetSdkDonutOrLower =
+ context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.DONUT;
+
+ final boolean hasExplicitLeft = a.hasValueOrEmpty(R.styleable.TabWidget_tabStripLeft);
+ if (hasExplicitLeft) {
+ mLeftStrip = a.getDrawable(R.styleable.TabWidget_tabStripLeft);
+ } else if (isTargetSdkDonutOrLower) {
+ mLeftStrip = context.getDrawable(R.drawable.tab_bottom_left_v4);
+ } else {
+ mLeftStrip = context.getDrawable(R.drawable.tab_bottom_left);
+ }
+
+ final boolean hasExplicitRight = a.hasValueOrEmpty(R.styleable.TabWidget_tabStripRight);
+ if (hasExplicitRight) {
+ mRightStrip = a.getDrawable(R.styleable.TabWidget_tabStripRight);
+ } else if (isTargetSdkDonutOrLower) {
+ mRightStrip = context.getDrawable(R.drawable.tab_bottom_right_v4);
+ } else {
+ mRightStrip = context.getDrawable(R.drawable.tab_bottom_right);
+ }
a.recycle();
- initTabWidget();
+ setChildrenDrawingOrderEnabled(true);
+
+ // Deal with focus, as we don't want the focus to go by default
+ // to a tab other than the current tab
+ setFocusable(true);
+ setOnFocusChangeListener(this);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
mStripMoved = true;
+
super.onSizeChanged(w, h, oldw, oldh);
}
@@ -115,44 +148,8 @@
}
}
- private void initTabWidget() {
- setChildrenDrawingOrderEnabled(true);
-
- final Context context = mContext;
-
- // Tests the target Sdk version, as set in the Manifest. Could not be set using styles.xml
- // in a values-v? directory which targets the current platform Sdk version instead.
- if (context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.DONUT) {
- // Donut apps get old color scheme
- if (mLeftStrip == null) {
- mLeftStrip = context.getDrawable(
- com.android.internal.R.drawable.tab_bottom_left_v4);
- }
- if (mRightStrip == null) {
- mRightStrip = context.getDrawable(
- com.android.internal.R.drawable.tab_bottom_right_v4);
- }
- } else {
- // Use modern color scheme for Eclair and beyond
- if (mLeftStrip == null) {
- mLeftStrip = context.getDrawable(
- com.android.internal.R.drawable.tab_bottom_left);
- }
- if (mRightStrip == null) {
- mRightStrip = context.getDrawable(
- com.android.internal.R.drawable.tab_bottom_right);
- }
- }
-
- // Deal with focus, as we don't want the focus to go by default
- // to a tab other than the current tab
- setFocusable(true);
- setOnFocusChangeListener(this);
- }
-
@Override
- void measureChildBeforeLayout(View child, int childIndex,
- int widthMeasureSpec, int totalWidth,
+ void measureChildBeforeLayout(View child, int childIndex, int widthMeasureSpec, int totalWidth,
int heightMeasureSpec, int totalHeight) {
if (!isMeasureWithLargestChildEnabled() && mImposedTabsHeight >= 0) {
widthMeasureSpec = MeasureSpec.makeMeasureSpec(
@@ -209,7 +206,8 @@
}
}
- // Measure again, this time with imposed tab widths and respecting initial spec request
+ // Measure again, this time with imposed tab widths and respecting
+ // initial spec request.
super.measureHorizontal(widthMeasureSpec, heightMeasureSpec);
}
@@ -225,7 +223,8 @@
/**
* Returns the number of tab indicator views.
- * @return the number of tab indicator views.
+ *
+ * @return the number of tab indicator views
*/
public int getTabCount() {
return getChildCount();
@@ -233,65 +232,104 @@
/**
* Sets the drawable to use as a divider between the tab indicators.
+ *
* @param drawable the divider drawable
+ * @attr ref android.R.styleable#TabWidget_divider
*/
@Override
- public void setDividerDrawable(Drawable drawable) {
+ public void setDividerDrawable(@Nullable Drawable drawable) {
super.setDividerDrawable(drawable);
}
/**
* Sets the drawable to use as a divider between the tab indicators.
- * @param resId the resource identifier of the drawable to use as a
- * divider.
+ *
+ * @param resId the resource identifier of the drawable to use as a divider
+ * @attr ref android.R.styleable#TabWidget_divider
*/
public void setDividerDrawable(@DrawableRes int resId) {
setDividerDrawable(mContext.getDrawable(resId));
}
-
+
/**
- * Sets the drawable to use as the left part of the strip below the
- * tab indicators.
+ * Sets the drawable to use as the left part of the strip below the tab
+ * indicators.
+ *
* @param drawable the left strip drawable
+ * @see #getLeftStripDrawable()
+ * @attr ref android.R.styleable#TabWidget_tabStripLeft
*/
- public void setLeftStripDrawable(Drawable drawable) {
+ public void setLeftStripDrawable(@Nullable Drawable drawable) {
mLeftStrip = drawable;
requestLayout();
invalidate();
}
/**
- * Sets the drawable to use as the left part of the strip below the
- * tab indicators.
- * @param resId the resource identifier of the drawable to use as the
- * left strip drawable
+ * Sets the drawable to use as the left part of the strip below the tab
+ * indicators.
+ *
+ * @param resId the resource identifier of the drawable to use as the left
+ * strip drawable
+ * @see #getLeftStripDrawable()
+ * @attr ref android.R.styleable#TabWidget_tabStripLeft
*/
public void setLeftStripDrawable(@DrawableRes int resId) {
setLeftStripDrawable(mContext.getDrawable(resId));
}
/**
- * Sets the drawable to use as the right part of the strip below the
- * tab indicators.
- * @param drawable the right strip drawable
+ * @return the drawable used as the left part of the strip below the tab
+ * indicators, may be {@code null}
+ * @see #setLeftStripDrawable(int)
+ * @see #setLeftStripDrawable(Drawable)
+ * @attr ref android.R.styleable#TabWidget_tabStripLeft
*/
- public void setRightStripDrawable(Drawable drawable) {
+ @Nullable
+ public Drawable getLeftStripDrawable() {
+ return mLeftStrip;
+ }
+
+ /**
+ * Sets the drawable to use as the right part of the strip below the tab
+ * indicators.
+ *
+ * @param drawable the right strip drawable
+ * @see #getRightStripDrawable()
+ * @attr ref android.R.styleable#TabWidget_tabStripRight
+ */
+ public void setRightStripDrawable(@Nullable Drawable drawable) {
mRightStrip = drawable;
requestLayout();
invalidate();
}
/**
- * Sets the drawable to use as the right part of the strip below the
- * tab indicators.
- * @param resId the resource identifier of the drawable to use as the
- * right strip drawable
+ * Sets the drawable to use as the right part of the strip below the tab
+ * indicators.
+ *
+ * @param resId the resource identifier of the drawable to use as the right
+ * strip drawable
+ * @see #getRightStripDrawable()
+ * @attr ref android.R.styleable#TabWidget_tabStripRight
*/
public void setRightStripDrawable(@DrawableRes int resId) {
setRightStripDrawable(mContext.getDrawable(resId));
}
/**
+ * @return the drawable used as the right part of the strip below the tab
+ * indicators, may be {@code null}
+ * @see #setRightStripDrawable(int)
+ * @see #setRightStripDrawable(Drawable)
+ * @attr ref android.R.styleable#TabWidget_tabStripRight
+ */
+ @Nullable
+ public Drawable getRightStripDrawable() {
+ return mRightStrip;
+ }
+
+ /**
* Controls whether the bottom strips on the tab indicators are drawn or
* not. The default is to draw them. If the user specifies a custom
* view for the tab indicators, then the TabHost class calls this method
@@ -360,13 +398,14 @@
/**
* Sets the current tab.
+ * <p>
* This method is used to bring a tab to the front of the Widget,
* and is used to post to the rest of the UI that a different tab
* has been brought to the foreground.
- *
+ * <p>
* Note, this is separate from the traditional "focus" that is
* employed from the view logic.
- *
+ * <p>
* For instance, if we have a list in a tabbed view, a user may be
* navigating up and down the list, moving the UI focus (orange
* highlighting) through the list items. The cursor movement does
@@ -374,16 +413,15 @@
* scrolled through is all on the same tab. The selected tab only
* changes when we navigate between tabs (moving from the list view
* to the next tabbed view, in this example).
- *
+ * <p>
* To move both the focus AND the selected tab at once, please use
* {@link #setCurrentTab}. Normally, the view logic takes care of
* adjusting the focus, so unless you're circumventing the UI,
* you'll probably just focus your interest here.
*
- * @param index The tab that you want to indicate as the selected
- * tab (tab brought to the front of the widget)
- *
- * @see #focusCurrentTab
+ * @param index the index of the tab that you want to indicate as the
+ * selected tab (tab brought to the front of the widget)
+ * @see #focusCurrentTab
*/
public void setCurrentTab(int index) {
if (index < 0 || index >= getTabCount() || index == mSelectedTab) {
@@ -473,7 +511,7 @@
final int count = getTabCount();
for (int i = 0; i < count; i++) {
- View child = getChildTabViewAt(i);
+ final View child = getChildTabViewAt(i);
child.setEnabled(enabled);
}
}
@@ -482,8 +520,7 @@
public void addView(View child) {
if (child.getLayoutParams() == null) {
final LinearLayout.LayoutParams lp = new LayoutParams(
- 0,
- ViewGroup.LayoutParams.MATCH_PARENT, 1.0f);
+ 0, ViewGroup.LayoutParams.MATCH_PARENT, 1.0f);
lp.setMargins(0, 0, 0, 0);
child.setLayoutParams(lp);
}
@@ -507,13 +544,13 @@
}
/**
- * Provides a way for {@link TabHost} to be notified that the user clicked on a tab indicator.
+ * Provides a way for {@link TabHost} to be notified that the user clicked
+ * on a tab indicator.
*/
void setTabSelectionListener(OnTabSelectionChanged listener) {
mSelectionChangedListener = listener;
}
- /** {@inheritDoc} */
public void onFocusChange(View v, boolean hasFocus) {
if (v == this && hasFocus && getTabCount() > 0) {
getChildTabViewAt(mSelectedTab).requestFocus();
@@ -540,7 +577,6 @@
// registered with each tab indicator so we can notify tab host
private class TabClickListener implements OnClickListener {
-
private final int mTabIndex;
private TabClickListener(int tabIndex) {
@@ -553,17 +589,18 @@
}
/**
- * Let {@link TabHost} know that the user clicked on a tab indicator.
+ * Lets {@link TabHost} know that the user clicked on a tab indicator.
*/
- static interface OnTabSelectionChanged {
+ interface OnTabSelectionChanged {
/**
* Informs the TabHost which tab was selected. It also indicates
* if the tab was clicked/pressed or just focused into.
*
* @param tabIndex index of the tab that was selected
- * @param clicked whether the selection changed due to a touch/click
- * or due to focus entering the tab through navigation. Pass true
- * if it was due to a press/click and false otherwise.
+ * @param clicked whether the selection changed due to a touch/click or
+ * due to focus entering the tab through navigation.
+ * {@code true} if it was due to a press/click and
+ * {@code false} otherwise.
*/
void onTabSelectionChanged(int tabIndex, boolean clicked);
}
diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java
index 33595f2..508cb01 100644
--- a/core/java/com/android/internal/policy/PhoneWindow.java
+++ b/core/java/com/android/internal/policy/PhoneWindow.java
@@ -4032,7 +4032,7 @@
// dark or the light button frame.
TypedValue value = new TypedValue();
getContext().getTheme().resolveAttribute(R.attr.colorPrimary, value, true);
- if (Color.brightness(value.data) < 0.5) {
+ if (Color.luminance(value.data) < 0.5) {
nonClientDecorView = (NonClientDecorView) mLayoutInflater.inflate(
R.layout.non_client_decor_dark, null);
} else {
diff --git a/core/java/com/android/internal/util/ArrayUtils.java b/core/java/com/android/internal/util/ArrayUtils.java
index 9d0636a..f190d8c 100644
--- a/core/java/com/android/internal/util/ArrayUtils.java
+++ b/core/java/com/android/internal/util/ArrayUtils.java
@@ -294,6 +294,29 @@
}
/**
+ * Removes value from given array if present, providing set-like behavior.
+ */
+ public static @Nullable String[] removeString(@Nullable String[] cur, String val) {
+ if (cur == null) {
+ return null;
+ }
+ final int N = cur.length;
+ for (int i = 0; i < N; i++) {
+ if (Objects.equals(cur[i], val)) {
+ String[] ret = new String[N - 1];
+ if (i > 0) {
+ System.arraycopy(cur, 0, ret, 0, i);
+ }
+ if (i < (N - 1)) {
+ System.arraycopy(cur, i + 1, ret, i, N - i - 1);
+ }
+ return ret;
+ }
+ }
+ return cur;
+ }
+
+ /**
* Adds value to given array if not already present, providing set-like
* behavior.
*/
diff --git a/core/java/com/android/internal/widget/ExploreByTouchHelper.java b/core/java/com/android/internal/widget/ExploreByTouchHelper.java
index 4a23df8..f5637dd 100644
--- a/core/java/com/android/internal/widget/ExploreByTouchHelper.java
+++ b/core/java/com/android/internal/widget/ExploreByTouchHelper.java
@@ -306,7 +306,7 @@
*/
private AccessibilityEvent createEventForHost(int eventType) {
final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
- onInitializeAccessibilityEvent(mView, event);
+ mView.onInitializeAccessibilityEvent(event);
return event;
}
@@ -368,7 +368,7 @@
*/
private AccessibilityNodeInfo createNodeForHost() {
final AccessibilityNodeInfo node = AccessibilityNodeInfo.obtain(mView);
- onInitializeAccessibilityNodeInfo(mView, node);
+ mView.onInitializeAccessibilityNodeInfo(node);
// Add the virtual descendants.
if (mTempArray == null) {
@@ -500,7 +500,7 @@
}
private boolean performActionForHost(int action, Bundle arguments) {
- return performAccessibilityAction(mView, action, arguments);
+ return mView.performAccessibilityAction(action, arguments);
}
private boolean performActionForChild(int virtualViewId, int action, Bundle arguments) {
diff --git a/core/res/res/values/arrays.xml b/core/res/res/values/arrays.xml
index a3cc4ae..33c41ef 100644
--- a/core/res/res/values/arrays.xml
+++ b/core/res/res/values/arrays.xml
@@ -77,50 +77,6 @@
<item>@drawable/btn_default_disabled_focused_holo_dark</item>
<item>@drawable/btn_default_holo_dark</item>
<item>@drawable/btn_default_holo_light</item>
- <item>@drawable/btn_star_off_normal_holo_light</item>
- <item>@drawable/btn_star_on_normal_holo_light</item>
- <item>@drawable/btn_star_on_disabled_holo_light</item>
- <item>@drawable/btn_star_off_disabled_holo_light</item>
- <item>@drawable/btn_star_on_pressed_holo_light</item>
- <item>@drawable/btn_star_off_pressed_holo_light</item>
- <item>@drawable/btn_star_on_focused_holo_light</item>
- <item>@drawable/btn_star_off_focused_holo_light</item>
- <item>@drawable/btn_star_on_disabled_focused_holo_light</item>
- <item>@drawable/btn_star_off_disabled_focused_holo_light</item>
- <item>@drawable/btn_star_holo_light</item>
- <item>@drawable/btn_star_off_normal_holo_dark</item>
- <item>@drawable/btn_star_on_normal_holo_dark</item>
- <item>@drawable/btn_star_on_disabled_holo_dark</item>
- <item>@drawable/btn_star_off_disabled_holo_dark</item>
- <item>@drawable/btn_star_on_pressed_holo_dark</item>
- <item>@drawable/btn_star_off_pressed_holo_dark</item>
- <item>@drawable/btn_star_on_focused_holo_dark</item>
- <item>@drawable/btn_star_off_focused_holo_dark</item>
- <item>@drawable/btn_star_on_disabled_focused_holo_dark</item>
- <item>@drawable/btn_star_off_disabled_focused_holo_dark</item>
- <item>@drawable/btn_star_holo_dark</item>
- <item>@drawable/btn_toggle_on_pressed_holo_light</item>
- <item>@drawable/btn_toggle_on_pressed_holo_dark</item>
- <item>@drawable/btn_toggle_on_normal_holo_light</item>
- <item>@drawable/btn_toggle_on_normal_holo_dark</item>
- <item>@drawable/btn_toggle_on_focused_holo_light</item>
- <item>@drawable/btn_toggle_on_focused_holo_dark</item>
- <item>@drawable/btn_toggle_on_disabled_holo_light</item>
- <item>@drawable/btn_toggle_on_disabled_holo_dark</item>
- <item>@drawable/btn_toggle_on_disabled_focused_holo_light</item>
- <item>@drawable/btn_toggle_on_disabled_focused_holo_dark</item>
- <item>@drawable/btn_toggle_off_pressed_holo_light</item>
- <item>@drawable/btn_toggle_off_pressed_holo_dark</item>
- <item>@drawable/btn_toggle_off_normal_holo_light</item>
- <item>@drawable/btn_toggle_off_normal_holo_dark</item>
- <item>@drawable/btn_toggle_off_focused_holo_light</item>
- <item>@drawable/btn_toggle_off_focused_holo_dark</item>
- <item>@drawable/btn_toggle_off_disabled_holo_light</item>
- <item>@drawable/btn_toggle_off_disabled_holo_dark</item>
- <item>@drawable/btn_toggle_off_disabled_focused_holo_light</item>
- <item>@drawable/btn_toggle_off_disabled_focused_holo_dark</item>
- <item>@drawable/btn_toggle_holo_light</item>
- <item>@drawable/btn_toggle_holo_dark</item>
<item>@drawable/edit_text_holo_light</item>
<item>@drawable/edit_text_holo_dark</item>
<item>@drawable/text_cursor_holo_light</item>
@@ -136,26 +92,18 @@
<item>@drawable/list_selector_holo_light</item>
<item>@drawable/list_section_divider_holo_light</item>
<item>@drawable/list_section_divider_holo_dark</item>
- <item>@drawable/menu_hardkey_panel_holo_dark</item>
- <item>@drawable/menu_hardkey_panel_holo_light</item>
- <item>@drawable/menu_submenu_background</item>
<item>@drawable/menu_dropdown_panel_holo_light</item>
<item>@drawable/menu_dropdown_panel_holo_dark</item>
- <item>@drawable/menu_popup_panel_holo_light</item>
- <item>@drawable/menu_popup_panel_holo_dark</item>
<item>@drawable/menu_panel_holo_light</item>
<item>@drawable/menu_panel_holo_dark</item>
<item>@drawable/spinner_16_outer_holo</item>
<item>@drawable/spinner_16_inner_holo</item>
<item>@drawable/spinner_48_outer_holo</item>
<item>@drawable/spinner_48_inner_holo</item>
- <item>@drawable/spinner_76_outer_holo</item>
- <item>@drawable/spinner_76_inner_holo</item>
<item>@drawable/progress_bg_holo_dark</item>
<item>@drawable/progress_bg_holo_light</item>
<item>@drawable/progress_horizontal_holo_dark</item>
<item>@drawable/progress_horizontal_holo_light</item>
- <item>@drawable/progress_indeterminate_horizontal_holo</item>
<item>@drawable/progress_large_holo</item>
<item>@drawable/progress_medium_holo</item>
<item>@drawable/progress_primary_holo_dark</item>
diff --git a/docs/html/guide/topics/manifest/uses-sdk-element.jd b/docs/html/guide/topics/manifest/uses-sdk-element.jd
index 3ac87ef..642b820 100644
--- a/docs/html/guide/topics/manifest/uses-sdk-element.jd
+++ b/docs/html/guide/topics/manifest/uses-sdk-element.jd
@@ -19,7 +19,6 @@
<li><a href="#testing">Testing against higher API Levels</a></li>
</ol>
</li>
- <li><a href="#provisional">Using a Provisional API Level</a></li>
<li><a href="#filtering">Filtering the Reference Documentation by API Level</a></li>
</ol>
</div>
@@ -227,6 +226,11 @@
<table>
<tr><th>Platform Version</th><th>API Level</th><th>VERSION_CODE</th><th>Notes</th></tr>
+ <tr><td>Android 6.0</td>
+ <td><a href="{@docRoot}sdk/api_diff/23/changes.html" title="Diff Report">23</a></td>
+ <td>{@link android.os.Build.VERSION_CODES#M}</td>
+ <td><a href="{@docRoot}preview/api-overview.html">API Changes</a></td></tr>
+
<tr><td><a href="{@docRoot}about/versions/android-5.1.html">Android 5.1</a></td>
<td><a href="{@docRoot}sdk/api_diff/22/changes.html" title="Diff Report">22</a></td>
<td>{@link android.os.Build.VERSION_CODES#LOLLIPOP_MR1}</td>
@@ -552,29 +556,6 @@
of the Android platform it runs. See the table at the top of this document for
a list of platform versions and their API Levels. </p>
-<h2 id="provisional">Using a Provisional API Level</h2>
-
-<p>In some cases, an "Early Look" Android SDK platform may be available. To let
-you begin developing on the platform although the APIs may not be final, the
-platform's API Level integer will not be specified. You must instead use the
-platform's <em>provisional API Level</em> in your application manifest, in order
-to build applications against the platform. A provisional API Level is not an
-integer, but a string matching the codename of the unreleased platform version.
-The provisional API Level will be specified in the release notes for the Early
-Look SDK release notes and is case-sensitive.</p>
-
-<p>The use of a provisional API Level is designed to protect developers and
-device users from inadvertently publishing or installing applications based on
-the Early Look framework API, which may not run properly on actual devices
-running the final system image.</p>
-
-<p>The provisional API Level will only be valid while using the Early Look SDK
-and can only be used to run applications in the emulator. An application using
-the provisional API Level can never be installed on an Android device. At the
-final release of the platform, you must replace any instances of the provisional
-API Level in your application manifest with the final platform's actual API
-Level integer.</p>
-
<h2 id="filtering">Filtering the Reference Documentation by API Level</h2>
diff --git a/docs/html/index.jd b/docs/html/index.jd
index c6dbbd5..eef7929 100644
--- a/docs/html/index.jd
+++ b/docs/html/index.jd
@@ -10,32 +10,31 @@
<section class="dac-hero-carousel">
<!-- <article class="dac-expand dac-hero dac-invert active" style="background-color: rgb(38, 50, 56);"> -->
-<article class="dac-expand dac-hero dac-invert active" style="background-color: #455A64;">
+<article class="dac-expand dac-hero dac-invert dac-darken mprev active" style="background-color: #75d1ff;">
<a href="/preview/index.html">
- <div class="wrap" style="max-width:1100px;">
+ <div class="wrap" style="max-width:1100px;margin-top:0">
<div class="cols dac-hero-content">
- <div class="col-10of16 col-push-6of16 dac-hero-figure">
- <img class="dac-hero-image" src="{@docRoot}images/home/devices-hero_620px_2x.png"
- srcset="{@docRoot}images/home/devices-hero_620px.png 1x,
- {@docRoot}images/home/devices-hero_620px_2x.png 2x">
+ <div class="col-8of16 col-push-6of16 dac-hero-figure mprev">
</div>
- <div class="col-6of16 col-pull-10of16">
+ <div class="col-8of16 col-pull-7of16">
<div class="dac-hero-tag"></div>
- <h1 class="dac-hero-title">Android M Developer Preview</h1>
- <p class="dac-hero-description">Get your apps ready for the next version
- of Android. Test on Nexus 5, 6, 9, and Player. </p>
+ <h1 class="dac-hero-title" style="white-space:nowrap;">Android 6.0 Marshmallow</h1>
+ </div>
+ <div class="col-6of16 col-push-1of16">
+ <p class="dac-hero-description"><strong>Final SDK is now available!</strong> Get your apps ready for the next version
+ of Android. Test on Nexus 5, 6, 9, and Player.</p>
- <a class="dac-hero-cta" href="{@docRoot}preview/index.html">
+ <a class="dac-hero-cta" href="/preview/index.html">
<span class="dac-sprite dac-auto-chevron"></span>
Get started
</a><br>
- <a class="dac-hero-cta" href="{@docRoot}preview/support.html">
+ <a class="dac-hero-cta" href="/preview/support.html">
<span class="dac-sprite dac-auto-chevron"></span>
- Update to Developer Preview 2
+ Update to Developer Preview 3 (final SDK)
</a>
-
+ </div>
</div>
</div>
</div>
diff --git a/docs/html/preview/download.jd b/docs/html/preview/download.jd
index 0dfabef..0b115f2 100644
--- a/docs/html/preview/download.jd
+++ b/docs/html/preview/download.jd
@@ -164,7 +164,7 @@
<div id="qv">
<h2>In this document</h2>
<ol>
- <li><a href="#sdk">Developer Preview 2 SDK</a></li>
+ <li><a href="#sdk">Developer Preview 3 SDK</a></li>
<li><a href="#docs">Developer Documentation</a></li>
<li><a href="#images">Hardware System Images</a></li>
</ol>
@@ -178,13 +178,13 @@
<p>
- The Android M Preview SDK includes development tools, Android system files, and library files to
+ The Android M Preview SDK includes development tools, Android system images, and library files to
help you test your app and the new APIs coming in the next release of the platform. This document
describes how to get the downloadable components of the preview for testing your app.
</p>
-<h2 id="sdk">Developer Preview 2 SDK</h2>
+<h2 id="sdk">Developer Preview 3 SDK</h2>
<p>
The Preview SDK is available for download through the <a href=
@@ -197,7 +197,10 @@
<h2 id="docs">Developer Documentation</h2>
<p>
- The developer documentation download package provides detailed API reference information and an API difference report for the preview.
+ The developer documentation download package provides detailed API reference information and
+ an API difference report for the preview. Note that <a href="{@docRoot}reference/packages.html">API
+ level 23 reference</a> and <a href="{@docRoot}sdk/api_diff/23/changes.html">diffs</a> are now
+ also available online.
</p>
<table>
@@ -206,11 +209,11 @@
<th scope="col">Download / Checksums</th>
</tr>
<tr id="docs-dl">
- <td>Android M Preview 2<br>Developer Docs</td>
+ <td>Android M Preview 3<br>Developer Docs</td>
<td><a href="#top" onclick="onDownload(this)"
- >m-preview-2-developer-docs.zip</a><br>
- MD5: 1db6fff9c722b0339757e1cdf43663a8<br>
- SHA-1: 5a4ae88d644e63824d21b0e18f8e3977a7665157
+ >m-preview-3-developer-docs.zip</a><br>
+ MD5: -<br>
+ SHA-1: -
</td>
</tr>
<table>
diff --git a/docs/html/preview/download_mp2.jd b/docs/html/preview/download_mp2.jd
new file mode 100644
index 0000000..0dfabef
--- /dev/null
+++ b/docs/html/preview/download_mp2.jd
@@ -0,0 +1,367 @@
+page.title=Downloads
+page.image=images/cards/card-download_16-9_2x.png
+
+@jd:body
+
+<div style="position:relative; min-height:600px">
+
+ <div class="wrap" id="tos" style="position:absolute;display:none;width:inherit;">
+
+ <p class="sdk-terms-intro">Before downloading and installing components of the Android Preview
+ SDK, you must agree to the following terms and conditions.</p>
+
+ <h2 class="norule">Terms and Conditions</h2>
+
+ <div class="sdk-terms" onfocus="this.blur()" style="width:678px">
+This is the Android SDK Preview License Agreement (the “License Agreement”).
+
+1. Introduction
+
+1.1 The Android SDK Preview (referred to in the License Agreement as the “Preview” and specifically including the Android system files, packaged APIs, and Preview library files, if and when they are made available) is licensed to you subject to the terms of the License Agreement. The License Agreement forms a legally binding contract between you and Google in relation to your use of the Preview.
+
+1.2 "Android" means the Android software stack for devices, as made available under the Android Open Source Project, which is located at the following URL: http://source.android.com/, as updated from time to time.
+
+1.3 "Google" means Google Inc., a Delaware corporation with principal place of business at 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States.
+
+2. Accepting the License Agreement
+
+2.1 In order to use the Preview, you must first agree to the License Agreement. You may not use the Preview if you do not accept the License Agreement.
+
+2.2 By clicking to accept and/or using the Preview, you hereby agree to the terms of the License Agreement.
+
+2.3 You may not use the Preview and may not accept the License Agreement if you are a person barred from receiving the Preview under the laws of the United States or other countries including the country in which you are resident or from which you use the Preview.
+
+2.4 If you will use the Preview internally within your company or organization you agree to be bound by the License Agreement on behalf of your employer or other entity, and you represent and warrant that you have full legal authority to bind your employer or such entity to the License Agreement. If you do not have the requisite authority, you may not accept the License Agreement or use the Preview on behalf of your employer or other entity.
+
+3. Preview License from Google
+
+3.1 Subject to the terms of the License Agreement, Google grants you a royalty-free, non-assignable, non-exclusive, non-sublicensable, limited, revocable license to use the Preview, personally or internally within your company or organization, solely to develop applications to run on the Android platform.
+
+3.2 You agree that Google or third parties owns all legal right, title and interest in and to the Preview, including any Intellectual Property Rights that subsist in the Preview. "Intellectual Property Rights" means any and all rights under patent law, copyright law, trade secret law, trademark law, and any and all other proprietary rights. Google reserves all rights not expressly granted to you.
+
+3.3 You may not use the Preview for any purpose not expressly permitted by the License Agreement. Except to the extent required by applicable third party licenses, you may not: (a) copy (except for backup purposes), modify, adapt, redistribute, decompile, reverse engineer, disassemble, or create derivative works of the Preview or any part of the Preview; or (b) load any part of the Preview onto a mobile handset or any other hardware device except a personal computer, combine any part of the Preview with other software, or distribute any software or device incorporating a part of the Preview.
+
+3.4 You agree that you will not take any actions that may cause or result in the fragmentation of Android, including but not limited to distributing, participating in the creation of, or promoting in any way a software development kit derived from the Preview.
+
+3.5 Use, reproduction and distribution of components of the Preview licensed under an open source software license are governed solely by the terms of that open source software license and not the License Agreement. You agree to remain a licensee in good standing in regard to such open source software licenses under all the rights granted and to refrain from any actions that may terminate, suspend, or breach such rights.
+
+3.6 You agree that the form and nature of the Preview that Google provides may change without prior notice to you and that future versions of the Preview may be incompatible with applications developed on previous versions of the Preview. You agree that Google may stop (permanently or temporarily) providing the Preview (or any features within the Preview) to you or to users generally at Google's sole discretion, without prior notice to you.
+
+3.7 Nothing in the License Agreement gives you a right to use any of Google's trade names, trademarks, service marks, logos, domain names, or other distinctive brand features.
+
+3.8 You agree that you will not remove, obscure, or alter any proprietary rights notices (including copyright and trademark notices) that may be affixed to or contained within the Preview.
+
+4. Use of the Preview by You
+
+4.1 Google agrees that nothing in the License Agreement gives Google any right, title or interest from you (or your licensors) under the License Agreement in or to any software applications that you develop using the Preview, including any intellectual property rights that subsist in those applications.
+
+4.2 You agree to use the Preview and write applications only for purposes that are permitted by (a) the License Agreement, and (b) any applicable law, regulation or generally accepted practices or guidelines in the relevant jurisdictions (including any laws regarding the export of data or software to and from the United States or other relevant countries).
+
+4.3 You agree that if you use the Preview to develop applications, you will protect the privacy and legal rights of users. If users provide you with user names, passwords, or other login information or personal information, you must make the users aware that the information will be available to your application, and you must provide legally adequate privacy notice and protection for those users. If your application stores personal or sensitive information provided by users, it must do so securely. If users provide you with Google Account information, your application may only use that information to access the user's Google Account when, and for the limited purposes for which, each user has given you permission to do so.
+
+4.4 You agree that you will not engage in any activity with the Preview, including the development or distribution of an application, that interferes with, disrupts, damages, or accesses in an unauthorized manner the servers, networks, or other properties or services of Google or any third party.
+
+4.5 You agree that you are solely responsible for (and that Google has no responsibility to you or to any third party for) any data, content, or resources that you create, transmit or display through Android and/or applications for Android, and for the consequences of your actions (including any loss or damage which Google may suffer) by doing so.
+
+4.6 You agree that you are solely responsible for (and that Google has no responsibility to you or to any third party for) any breach of your obligations under the License Agreement, any applicable third party contract or Terms of Service, or any applicable law or regulation, and for the consequences (including any loss or damage which Google or any third party may suffer) of any such breach.
+
+4.7 The Preview is in development, and your testing and feedback are an important part of the development process. By using the Preview, you acknowledge that implementation of some features are still under development and that you should not rely on the Preview having the full functionality of a stable release. You agree not to publicly distribute or ship any application using this Preview as this Preview will no longer be supported after the official Android SDK is released.
+
+5. Your Developer Credentials
+
+5.1 You agree that you are responsible for maintaining the confidentiality of any developer credentials that may be issued to you by Google or which you may choose yourself and that you will be solely responsible for all applications that are developed under your developer credentials.
+
+6. Privacy and Information
+
+6.1 In order to continually innovate and improve the Preview, Google may collect certain usage statistics from the software including but not limited to a unique identifier, associated IP address, version number of the software, and information on which tools and/or services in the Preview are being used and how they are being used. Before any of this information is collected, the Preview will notify you and seek your consent. If you withhold consent, the information will not be collected.
+
+6.2 The data collected is examined in the aggregate to improve the Preview and is maintained in accordance with Google's Privacy Policy located at http://www.google.com/policies/privacy/.
+
+7. Third Party Applications
+
+7.1 If you use the Preview to run applications developed by a third party or that access data, content or resources provided by a third party, you agree that Google is not responsible for those applications, data, content, or resources. You understand that all data, content or resources which you may access through such third party applications are the sole responsibility of the person from which they originated and that Google is not liable for any loss or damage that you may experience as a result of the use or access of any of those third party applications, data, content, or resources.
+
+7.2 You should be aware the data, content, and resources presented to you through such a third party application may be protected by intellectual property rights which are owned by the providers (or by other persons or companies on their behalf). You may not modify, rent, lease, loan, sell, distribute or create derivative works based on these data, content, or resources (either in whole or in part) unless you have been specifically given permission to do so by the relevant owners.
+
+7.3 You acknowledge that your use of such third party applications, data, content, or resources may be subject to separate terms between you and the relevant third party.
+
+8. Using Google APIs
+
+8.1 Google APIs
+
+8.1.1 If you use any API to retrieve data from Google, you acknowledge that the data may be protected by intellectual property rights which are owned by Google or those parties that provide the data (or by other persons or companies on their behalf). Your use of any such API may be subject to additional Terms of Service. You may not modify, rent, lease, loan, sell, distribute or create derivative works based on this data (either in whole or in part) unless allowed by the relevant Terms of Service.
+
+8.1.2 If you use any API to retrieve a user's data from Google, you acknowledge and agree that you shall retrieve data only with the user's explicit consent and only when, and for the limited purposes for which, the user has given you permission to do so.
+
+9. Terminating the License Agreement
+
+9.1 the License Agreement will continue to apply until terminated by either you or Google as set out below.
+
+9.2 If you want to terminate the License Agreement, you may do so by ceasing your use of the Preview and any relevant developer credentials.
+
+9.3 Google may at any time, terminate the License Agreement, with or without cause, upon notice to you.
+
+9.4 The License Agreement will automatically terminate without notice or other action upon the earlier of:
+(A) when Google ceases to provide the Preview or certain parts of the Preview to users in the country in which you are resident or from which you use the service; and
+(B) Google issues a final release version of the Android SDK.
+
+9.5 When the License Agreement is terminated, the license granted to you in the License Agreement will terminate, you will immediately cease all use of the Preview, and the provisions of paragraphs 10, 11, 12 and 14 shall survive indefinitely.
+
+10. DISCLAIMERS
+
+10.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT YOUR USE OF THE PREVIEW IS AT YOUR SOLE RISK AND THAT THE PREVIEW IS PROVIDED "AS IS" AND "AS AVAILABLE" WITHOUT WARRANTY OF ANY KIND FROM GOOGLE.
+
+10.2 YOUR USE OF THE PREVIEW AND ANY MATERIAL DOWNLOADED OR OTHERWISE OBTAINED THROUGH THE USE OF THE PREVIEW IS AT YOUR OWN DISCRETION AND RISK AND YOU ARE SOLELY RESPONSIBLE FOR ANY DAMAGE TO YOUR COMPUTER SYSTEM OR OTHER DEVICE OR LOSS OF DATA THAT RESULTS FROM SUCH USE. WITHOUT LIMITING THE FOREGOING, YOU UNDERSTAND THAT THE PREVIEW IS NOT A STABLE RELEASE AND MAY CONTAIN ERRORS, DEFECTS AND SECURITY VULNERABILITIES THAT CAN RESULT IN SIGNIFICANT DAMAGE, INCLUDING THE COMPLETE, IRRECOVERABLE LOSS OF USE OF YOUR COMPUTER SYSTEM OR OTHER DEVICE.
+
+10.3 GOOGLE FURTHER EXPRESSLY DISCLAIMS ALL WARRANTIES AND CONDITIONS OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+
+11. LIMITATION OF LIABILITY
+
+11.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT GOOGLE, ITS SUBSIDIARIES AND AFFILIATES, AND ITS LICENSORS SHALL NOT BE LIABLE TO YOU UNDER ANY THEORY OF LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL OR EXEMPLARY DAMAGES THAT MAY BE INCURRED BY YOU, INCLUDING ANY LOSS OF DATA, WHETHER OR NOT GOOGLE OR ITS REPRESENTATIVES HAVE BEEN ADVISED OF OR SHOULD HAVE BEEN AWARE OF THE POSSIBILITY OF ANY SUCH LOSSES ARISING.
+
+12. Indemnification
+
+12.1 To the maximum extent permitted by law, you agree to defend, indemnify and hold harmless Google, its affiliates and their respective directors, officers, employees and agents from and against any and all claims, actions, suits or proceedings, as well as any and all losses, liabilities, damages, costs and expenses (including reasonable attorneys’ fees) arising out of or accruing from (a) your use of the Preview, (b) any application you develop on the Preview that infringes any Intellectual Property Rights of any person or defames any person or violates their rights of publicity or privacy, and (c) any non-compliance by you of the License Agreement.
+
+13. Changes to the License Agreement
+
+13.1 Google may make changes to the License Agreement as it distributes new versions of the Preview. When these changes are made, Google will make a new version of the License Agreement available on the website where the Preview is made available.
+
+14. General Legal Terms
+
+14.1 the License Agreement constitutes the whole legal agreement between you and Google and governs your use of the Preview (excluding any services which Google may provide to you under a separate written agreement), and completely replaces any prior agreements between you and Google in relation to the Preview.
+
+14.2 You agree that if Google does not exercise or enforce any legal right or remedy which is contained in the License Agreement (or which Google has the benefit of under any applicable law), this will not be taken to be a formal waiver of Google's rights and that those rights or remedies will still be available to Google.
+
+14.3 If any court of law, having the jurisdiction to decide on this matter, rules that any provision of the License Agreement is invalid, then that provision will be removed from the License Agreement without affecting the rest of the License Agreement. The remaining provisions of the License Agreement will continue to be valid and enforceable.
+
+14.4 You acknowledge and agree that each member of the group of companies of which Google is the parent shall be third party beneficiaries to the License Agreement and that such other companies shall be entitled to directly enforce, and rely upon, any provision of the License Agreement that confers a benefit on (or rights in favor of) them. Other than this, no other person or company shall be third party beneficiaries to the License Agreement.
+
+14.5 EXPORT RESTRICTIONS. THE PREVIEW IS SUBJECT TO UNITED STATES EXPORT LAWS AND REGULATIONS. YOU MUST COMPLY WITH ALL DOMESTIC AND INTERNATIONAL EXPORT LAWS AND REGULATIONS THAT APPLY TO THE PREVIEW. THESE LAWS INCLUDE RESTRICTIONS ON DESTINATIONS, END USERS AND END USE.
+
+14.6 The License Agreement may not be assigned or transferred by you without the prior written approval of Google, and any attempted assignment without such approval will be void. You shall not delegate your responsibilities or obligations under the License Agreement without the prior written approval of Google.
+
+14.7 The License Agreement, and your relationship with Google under the License Agreement, shall be governed by the laws of the State of California without regard to its conflict of laws provisions. You and Google agree to submit to the exclusive jurisdiction of the courts located within the county of Santa Clara, California to resolve any legal matter arising from the License Agreement. Notwithstanding this, you agree that Google shall still be allowed to apply for injunctive remedies (or an equivalent type of urgent legal relief) in any jurisdiction.
+ </div><!-- sdk terms -->
+
+
+
+ <div id="sdk-terms-form">
+ <p>
+ <input id="agree" type="checkbox" name="agree" value="1" onclick="onAgreeChecked()" />
+ <label id="agreeLabel" for="agree">I have read and agree with the above terms and conditions</label>
+ </p>
+ <p><a href="" class="button disabled" id="downloadForRealz" onclick="return onDownloadForRealz(this);"></a></p>
+ </div>
+
+
+ </div><!-- end TOS -->
+
+
+ <div id="landing">
+
+<div id="qv-wrapper">
+ <div id="qv">
+ <h2>In this document</h2>
+ <ol>
+ <li><a href="#sdk">Developer Preview 2 SDK</a></li>
+ <li><a href="#docs">Developer Documentation</a></li>
+ <li><a href="#images">Hardware System Images</a></li>
+ </ol>
+
+ <h2>Legacy downloads</h2>
+ <ol>
+ <li><a href="{@docRoot}preview/download_mp1.html">Developer Preview Archive</a></li>
+ </ol>
+ </div>
+</div>
+
+
+<p>
+ The Android M Preview SDK includes development tools, Android system files, and library files to
+ help you test your app and the new APIs coming in the next release of the platform. This document
+ describes how to get the downloadable components of the preview for testing your app.
+</p>
+
+
+<h2 id="sdk">Developer Preview 2 SDK</h2>
+
+<p>
+ The Preview SDK is available for download through the <a href=
+ "{@docRoot}tools/help/sdk-manager.html">Android SDK Manager</a>. For more information on
+ downloading and configuring the Preview SDK, see <a href=
+ "{@docRoot}preview/setup-sdk.html#downloadSdk">Set Up the Preview SDK</a>.
+</p>
+
+
+<h2 id="docs">Developer Documentation</h2>
+
+<p>
+ The developer documentation download package provides detailed API reference information and an API difference report for the preview.
+</p>
+
+<table>
+ <tr>
+ <th scope="col">Description</th>
+ <th scope="col">Download / Checksums</th>
+ </tr>
+ <tr id="docs-dl">
+ <td>Android M Preview 2<br>Developer Docs</td>
+ <td><a href="#top" onclick="onDownload(this)"
+ >m-preview-2-developer-docs.zip</a><br>
+ MD5: 1db6fff9c722b0339757e1cdf43663a8<br>
+ SHA-1: 5a4ae88d644e63824d21b0e18f8e3977a7665157
+ </td>
+ </tr>
+<table>
+
+
+<h2 id="images">Hardware System Images</h2>
+
+<p>
+ These system images allow you to install a preview version of the platform on a physical device for
+ testing. By configuring a device with one of these images, you can install and test your app to
+ see how it performs on the next version of the platform. The process of installing a system image
+ on a device <em>removes all data from the device</em>, so you should backup your data before
+ installing a system image.
+</p>
+
+<p class="warning">
+ <b>Warning:</b> The following Android system images are previews and are subject to change. Your
+ use of these system images is governed by the Android SDK Preview License Agreement. The Android
+ preview system images are not stable releases, and may contain errors and defects that can result
+ in damage to your computer systems, devices, and data. The preview Android system images are not
+ subject to the same testing as the factory OS and can cause your phone and installed services and
+ applications to stop working.
+</p>
+
+<table>
+ <tr>
+ <th scope="col">Device</th>
+ <th scope="col">Download / Checksums</th>
+ </tr>
+ <tr id="hammerhead">
+ <td>Nexus 5 (GSM/LTE) <br>"hammerhead"</td>
+ <td><a href="#top" onclick="onDownload(this)"
+ >hammerhead-MPZ79M-preview-b1f4bde4.tgz</a><br>
+ MD5: 2ca9f18bf47a061b339bab52647ceb0d<br>
+ SHA-1: b1f4bde447eccbf8ce5d9b8b8ba954e3eac8e939
+ </td>
+ </tr>
+ <tr id="shamu">
+ <td>Nexus 6 <br>"shamu"</td>
+ <td><a href="#top" onclick="onDownload(this)"
+ >shamu-MPZ79M-preview-e1024040.tgz</a><br>
+ MD5: 24a2118da340b9afedfbdfc026f6ff81<br>
+ SHA-1: e10240408859d5188c4aae140e1c539130ba614b
+ </td>
+ </tr>
+ <tr id="volantis">
+ <td>Nexus 9 <br>"volantis"</td>
+ <td><a href="#top" onclick="onDownload(this)"
+ >volantis-MPZ79M-preview-9f305342.tgz</a><br>
+ MD5: 9edabf0a4c61b247f1cbb9dfdc0a899e<br>
+ SHA-1: 9f30534216f10899a6a75495fc7e92408ea333a7
+ </td>
+ </tr>
+
+ <tr id="fugu">
+ <td>Nexus Player <br>"fugu"</td>
+ <td><a href="#top" onclick="onDownload(this)"
+ >fugu-MPZ79N-preview-fb63af98.tgz</a><br>
+ MD5: e8d081137a20b66df595ee69523314b5<br>
+ SHA-1: fb63af98302dd97be8de9313734d389ccdcce250
+ </td>
+ </tr>
+
+</table>
+
+<h3 id="install-image">Install an Image to a Device</h3>
+
+<p>
+ In order to use a device image for testing, you must install it on a compatible device. Follow
+ the instructions below to install a system image:
+</p>
+
+<ol>
+ <li>Download and uncompress one of the system image packages listed here.</li>
+ <li>Backup any data you want to preserve from the device.</li>
+ <li>Follow the instructions at
+ <a href="https://developers.google.com/android/nexus/images#instructions">developers.google.com/android</a>
+ to flash the image onto your device.</li>
+</ol>
+
+<h3 id="update-image">Updating a Device with the Preview</h3>
+
+<p>
+ Once you have installed a preview system image on a development device, the device is upgraded
+ automatically with the next preview release through over-the-air (OTA) updates. When the update
+ is available, the device displays notification that an update is available and allows you to
+ install it. You can also manually install the next preview image by repeating the procedure in
+ the previous section.
+</p>
+
+<h3 id="revertDevice">Revert a Device to Factory Specifications</h3>
+
+<p>
+ If you want to uninstall the preview and revert the device to factory specifications, go to
+ <a href="http://developers.google.com/android/nexus/images">developers.google.com/android</a> and
+ download the image you want to flash to for your device. Follow the instructions on that page to
+ flash the image to your device.
+</p>
+
+ </div><!-- landing -->
+
+</div><!-- relative wrapper -->
+
+
+
+<script>
+ var urlRoot = "http://storage.googleapis.com/androiddevelopers/shareables/preview/";
+ function onDownload(link) {
+
+ $("#downloadForRealz").html("Download " + $(link).text());
+ $("#downloadForRealz").attr('href', urlRoot + $(link).text());
+
+ $("#tos").fadeIn('fast');
+ $("#landing").fadeOut('fast');
+
+ return true;
+ }
+
+
+ function onAgreeChecked() {
+ /* verify that the TOS is agreed */
+ if ($("input#agree").is(":checked")) {
+ /* reveal the download button */
+ $("a#downloadForRealz").removeClass('disabled');
+ } else {
+ $("a#downloadForRealz").addClass('disabled');
+ }
+ }
+
+ function onDownloadForRealz(link) {
+ if ($("input#agree").is(':checked')) {
+ /*
+ $("#tos").fadeOut('fast');
+ $("#landing").fadeIn('fast');
+ */
+
+ ga('send', 'event', 'M Preview', 'System Image', $("#downloadForRealz").html());
+
+ /*
+ location.hash = "";
+ */
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ $(window).hashchange( function(){
+ if (location.hash == "") {
+ location.reload();
+ }
+ });
+
+</script>
diff --git a/docs/html/preview/index.jd b/docs/html/preview/index.jd
index 022838b..5410e4f 100644
--- a/docs/html/preview/index.jd
+++ b/docs/html/preview/index.jd
@@ -18,6 +18,7 @@
<div class="col-7of16 col-pull-9of16">
<h1 class="dac-hero-title">Android M Developer Preview</h1>
<p class="dac-hero-description">
+ <strong>Final SDK is now available!</strong>
Get ready for the next version of Android. Test your apps on Nexus 5, 6, 9, and
Player. Explore what's new — <strong>runtime permissions</strong>,
<strong>Doze</strong> and <strong>App Standby</strong> power-saving features, new
@@ -30,7 +31,7 @@
</a><br>
<a class="dac-hero-cta" href="{@docRoot}preview/support.html">
<span class="dac-sprite dac-auto-chevron"></span>
- Update to Developer Preview 2
+ Update to Developer Preview 3 (final SDK)
</a><br>
</div>
</div>
diff --git a/docs/html/preview/overview.jd b/docs/html/preview/overview.jd
index 009e268..9793592 100644
--- a/docs/html/preview/overview.jd
+++ b/docs/html/preview/overview.jd
@@ -6,20 +6,21 @@
@jd:body
<div class="cols" style=
-"background-color:#ffebc3; padding: 5px 0;margin-bottom:1em; text-align:center;">
+"background-color:#f2daf5; padding: 5px 0;margin-bottom:1em; text-align:center;">
<h3>
- Developer Preview 2 is now available
+ Developer Preview 3 is now available
</h3>
-
+ <p>Includes final SDK and near-final system images</p>
+ <div style="margin:auto 1em">
<ul class="dac-section-links">
<li class="dac-section-link">
- <a href="{@docRoot}preview/support.html#preview2-notes">
+ <a href="{@docRoot}preview/support.html#preview3-notes">
<span class="dac-sprite dac-auto-chevron"></span>
Read the Notes</a>
</li>
<li class="dac-section-link">
- <a href="{@docRoot}preview/support.html#preview2-get">
+ <a href="{@docRoot}preview/support.html#preview3-get">
<span class="dac-sprite dac-auto-chevron"></span>
Get the Update</a>
</li>
@@ -30,6 +31,7 @@
Report Issues</a>
</li>
</ul>
+ </div>
</div>
<p>
@@ -143,14 +145,13 @@
<img src="{@docRoot}preview/images/m-preview-timeline-crop.png" alt=
"Preview program timeline" id="timeline">
<p>
- The M Developer Preview runs from May 28 until the final Android M SDK, which
- we’ll release shortly before the public release during Q3
+ The M Developer Preview runs from May 28 until the final Android M public release planned for Q3
2015.
</p>
<p>
At key development milestones, we’ll deliver updates for your test devices.
- The tentative milestones are
+ The milestones are
</p>
<ul>
@@ -163,12 +164,12 @@
</li>
<li>
- <strong>Preview 3</strong> (near final, late July).
+ <strong>Preview 3</strong> (final APIs and SDK, now available).
</li>
</ul>
<p>
- These updates culminate in the <strong>final SDK</strong> (later in Q3),
+ These updates culminate in the <strong>final SDK</strong> (available now),
which delivers the official APIs for the new version of Android, as well
as the final system behaviors and features.
</p>
@@ -181,8 +182,10 @@
providing system images that you can download and flash manually.
</p>
<p class="note">
- <strong>Note:</strong> The final SDK and system images can not be delivered
- by OTA, but will instead need to be <strong>flashed manually</strong> to
+ <strong>Note:</strong> Developer Preview 3 includes final APIs and near-final
+ system images available by both download and OTA. At the full public release of
+ Android M later in Q3, final system images will be available by download only,
+ so you'll need to <strong>flash manually</strong> to
your test devices.</strong>
</p>
@@ -316,40 +319,29 @@
<h2 id="preview_apis_and_publishing">
- Targeting, preview APIs, and publishing
+ Final SDK, targeting, and publishing
</h2>
<p>
- The Android M Developer Preview is a development-only release and
- <strong>does not have a standard API level</strong>. If you want to opt out
+ <p>With Developer Preview 3, the platform APIs are now official (API level 23) and the
+ <strong>final SDK is now available</strong>. We recommend updating your environment
+ right away through Android Studio. Once you've updated your environment, you can target
+ the new API level, compile against the new platform, and publish at your convenience
+ to Google Play (including alpha, beta, or release channels).
+
+ <p>If you want to opt out
of compatibility behaviors to test your app (which is strongly recommended),
you can target the M Developer Preview by setting your app's <code><a href=
"/guide/topics/manifest/uses-sdk-element.html">targetSdkVersion</a></code>
to <code>“MNC”</code>.
</p>
-<p>
- The Android M Developer Preview delivers <strong>preview APIs</strong>
- — the APIs will not be official until the final SDK is released,
- currently planned for the third quarter of 2015. This means that you can
- <strong>expect minor API changes</strong> over time, especially during
- initial weeks of the program. We’ll provide a summary of changes to you with
- each update of the Android M Developer Preview.
-</p>
-
-<p class="note">
- Note that although preview APIs may change, underlying system behaviors such
- as runtime permissions and power-saving features are stable and ready for
- testing right away.
-</p>
-
-<p>
- In terms of publishing, Google Play <strong>prevents publishing of apps
- targeting the M Developer Preview</strong>. When the Android M final SDK is
- available, you’ll be able to target the official Android M API level and
- publish your app to Google Play. Meanwhile, if you want to distribute an app
- targeting Android M to testers, you can do so via email or by direct download
- from your site.
+ <p>Before releasing your app targeting Android M, we strongly recommend distributing it
+ to a group of testers through the new <a
+ href="http://android-developers.blogspot.com/2015/07/iterate-faster-on-google-play-with.html">
+ beta testing features available in the Google Play Developer Console. See the
+ <a href="https://support.google.com/googleplay/android-developer/answer/3131213">Help
+ Center article</a> for more information.
</p>
<h2 id="get_started">
@@ -357,7 +349,7 @@
</h2>
<p>
- To get started testing your app:
+ To get started testing your app with Android M:
</p>
<ol>
@@ -379,7 +371,7 @@
Preview updates will be delivered through over-the-air (OTA) updates.</a>
</li>
- <li>Download the <a href="{@docRoot}preview/download.html#docs">M Preview API
+ <li>Review the <a href="{@docRoot}reference/packages.html">API
Reference</a> and <a href="{@docRoot}preview/samples.html">M Preview
samples</a> to gain more insight into new API features and how to use them in
your app.
diff --git a/docs/html/preview/support.jd b/docs/html/preview/support.jd
index d908f77..9ad9ac0 100644
--- a/docs/html/preview/support.jd
+++ b/docs/html/preview/support.jd
@@ -5,20 +5,21 @@
@jd:body
<div class="cols" style=
-"background-color:#ffebc3; padding: 5px 0;margin-bottom:1em; text-align:center;">
+"background-color:#f2daf5; padding: 5px 0;margin-bottom:1em; text-align:center;">
<h3>
- Developer Preview 2 is now available
+ Developer Preview 3 is now available
</h3>
-
+ <p>Includes final SDK and near-final system images</p>
+ <div style="margin:auto 1em">
<ul class="dac-section-links">
<li class="dac-section-link">
- <a href="#preview2-notes">
+ <a href="#preview3-notes">
<span class="dac-sprite dac-auto-chevron"></span>
Read the Notes</a>
</li>
<li class="dac-section-link">
- <a href="#preview2-get">
+ <a href="#preview3-get">
<span class="dac-sprite dac-auto-chevron"></span>
Get the Update</a>
</li>
@@ -29,6 +30,7 @@
Report Issues</a>
</li>
</ul>
+ </div>
</div>
<p>
@@ -46,6 +48,191 @@
community</a>.
</p>
+<h2 id="preview3-notes">
+ Developer Preview 3
+</h2>
+
+<div class="wrap">
+ <div class="cols">
+ <div class="col-9of16">
+ <p>
+ <em>Date: August 2015<br>
+ Builds: XXXXXX (Nexus 5, 6, 9), MPZ79N (Nexus Player)<br>
+ Hardware support: Nexus 5, 6, 9, Player<br>
+ Emulator support: x86 & ARM 32/64-bit<br>
+ Google Play services: 7.8</em>
+ </p>
+ </div>
+ </div>
+</div>
+
+<p>
+ Android M Developer Preview 3 is the <strong>final incremental update</strong>
+ to the Android M preview platform that was originally released in May 2015.
+ The update includes <strong>final APIs and final SDK</strong>, as well as
+ <strong>near-final system images</strong> for testing your apps. The
+ updated system images include a variety of fixes and enhancements across
+ the system, including those related to issues reported by developers
+ through the external issue tracker.
+</p>
+
+<p>
+ If you are currently developing or testing on Android M, you should <strong>update
+ your environment to Developer Preview 3</strong> as soon as possible, so that
+ you can begin <strong>final compatibility testing</strong> in preparation for the public
+ release to device manufacturers.</p>
+
+<p class="important">Updating to Developer Preview 3 ensures that
+ you are building against final platform APIs and testing against
+ the final behaviors. If you are just getting started with the Android
+ M Developer Preview SDK, follow the instructions in <a href=
+ "/preview/setup-sdk.html">Set up the Preview SDK</a>, then update your
+ environment for Developer Preview 3.
+</p>
+
+<h3>
+ What's included
+</h3>
+
+<p>
+ Developer Preview 3 includes an updated SDK and system images,
+ documentation, and samples for developing against the final Android M
+ development platform.
+</p>
+
+<ul>
+ <li>
+ <strong>SDK platform</strong> and <strong>system images</strong> (Nexus and
+ emulator) for building and testing. You can download the updated tools from
+ the SDK Manager, and the system images are available by over-the-air (OTA)
+ update or download (see below).
+ </li>
+
+ <li>
+ <strong>Updated documentation</strong>. The <a href=
+ "/preview/behavior-changes.html">Behavior Changes</a>, <a href=
+ "/preview/api-overview.html">API Overview</a>, and <a href=
+ "/preview/features/runtime-permissions.html">Permissions</a> documents have
+ been updated to reflect the latest changes in the platform. An updated
+ <a href="/preview/download.html">Developer Documentation download
+ package</a> is available, including full reference docs and API diff
+ reports.
+ </li>
+
+ <li>
+ <strong>Translations</strong> of the documentation are now available. Use
+ the language selector at the bottom right corner of any page to switch
+ languages. Note that some of the translated docs are not yet updated for
+ Developer Preview 3 (coming soon).
+ </li>
+
+ <li>The <a href="/preview/samples.html">Android M code samples</a> are also
+ updated to account for API and behavior changes:
+ <ul>
+ <li>
+ <a href=
+ "https://github.com/googlesamples/android-RuntimePermissions">RuntimePermissions</a>
+ / <a href=
+ "https://github.com/googlesamples/android-RuntimePermissionsBasic">RuntimePermissionsBasic</a>
+ are updated to reflect latest permissions API changes, including
+ <code>shouldShowRequestPermissionRationale()</code>.
+ </li>
+ <li>
+ <a href=
+ "https://github.com/googlesamples/android-FingerprintDialog">FingerprintDialog</a>
+ adds a flow to ask for passwords when new fingerprints are added as
+ well as a preference if the app will use fingerprints as a method of
+ authentication.
+ </li>
+ </ul>
+ </li>
+</ul>
+
+<h3 id="changes">
+ Key changes
+</h3>
+
+<ul>
+ <li>Add here
+ <ul>
+ <li>
+ </li>
+ </ul>
+ </li>
+
+ <li>Other changes
+ <ul>
+ <li>
+ </li>
+ </ul>
+ </li>
+</ul>
+
+<p>
+ For a complete list of changes, including renamed and removed APIs, please
+ refer to the API Diff reports below:</p>
+ <ul>
+ <li><a href="@docRoot"sdk/api_diff/mnc-preview-3/changes.html">API Differences: Preview 2 to Preview 3 (API level 23)</a></li>
+ <li><a href="@docRoot"sdk/api_diff/23/changes.html">API Differences: API level 22 to API level 23</a></li>
+ </ul>
+
+<h3 id="ki">
+ Known issues
+</h3>
+
+<ul>
+ <li>General issues:
+ <ul>
+ <li>Add
+ </li>
+ </ul>
+ </li>
+</ul>
+
+<p>
+ For a complete list of reported issues, please refer to the <a href=
+ "https://code.google.com/p/android/issues/list">open issues list</a> on the
+ Developer Preview <a href=
+ "https://code.google.com/p/android-developer-preview/">issue tracker</a>.
+</p>
+
+<h3 id="preview3-get">
+ Get Developer Preview 3
+</h3>
+
+<p>
+ You can download the Developer Preview 3 final SDK platform and
+ emulator images from the SDK Manager.
+</p>
+
+<p>
+ Developer Preview 3 system images for supported Nexus devices are available
+ by download and by over-the-air (OTA) update. The OTA update is available
+ only to supported devices that are currently running a Developer Preview build.
+ If your device is running a Developer Preview build, you should automatically receive
+ the OTA update within a few days of availability.
+</p>
+
+<p>
+ If you are just getting started with Android M Developer Preview and want
+ to receive Developer Preview 3 via OTA, download the
+ Developer Preview 2 <a href="{@docRoot}preview/download_mp2.html#images">
+ system image</a>, and flash it to your device. Then,
+ leave the device powered on for several hours. It registers with the
+ OTA service, and receives Developer Preview 3 by OTA.
+</p>
+
+<p>
+ For instructions on how to download and flash your device to the Developer
+ Preview, see the links and instructions on the <a href=
+ "/preview/download.html">Downloads</a> page.
+</p>
+
+<p>
+ For instructions on how to start developing and testing with Android M, read
+ <a href="/preview/setup-sdk.html">Setting up the SDK</a>.
+</p>
+
<h2 id="preview2-notes">
Developer Preview 2
</h2>
@@ -164,8 +351,8 @@
</li>
<li>Remote Bluetooth/Wi-Fi MAC's now require either the
- <code>android.permission.LOCATION_FINE</code> or
- <code>android.permission.LOCATION_COARSE</code> permission.
+ <code>android.permission.ACCESS_COARSE_LOCATION</code> or
+ <code>android.permission.ACCESS_FINE_LOCATION</code> permission.
</li>
<li>Some accounts and identity permissions are moved to
diff --git a/graphics/java/android/graphics/Color.java b/graphics/java/android/graphics/Color.java
index 2e3eec5..c627297 100644
--- a/graphics/java/android/graphics/Color.java
+++ b/graphics/java/android/graphics/Color.java
@@ -113,89 +113,21 @@
}
/**
- * Returns the hue component of a color int.
- *
- * @return A value between 0.0f and 1.0f
- *
- * @hide Pending API council
- */
- public static float hue(@ColorInt int color) {
- int r = (color >> 16) & 0xFF;
- int g = (color >> 8) & 0xFF;
- int b = color & 0xFF;
-
- int V = Math.max(b, Math.max(r, g));
- int temp = Math.min(b, Math.min(r, g));
-
- float H;
-
- if (V == temp) {
- H = 0;
- } else {
- final float vtemp = (float) (V - temp);
- final float cr = (V - r) / vtemp;
- final float cg = (V - g) / vtemp;
- final float cb = (V - b) / vtemp;
-
- if (r == V) {
- H = cb - cg;
- } else if (g == V) {
- H = 2 + cr - cb;
- } else {
- H = 4 + cg - cr;
- }
-
- H /= 6.f;
- if (H < 0) {
- H++;
- }
- }
-
- return H;
- }
-
- /**
- * Returns the saturation component of a color int.
- *
- * @return A value between 0.0f and 1.0f
- *
- * @hide Pending API council
- */
- public static float saturation(@ColorInt int color) {
- int r = (color >> 16) & 0xFF;
- int g = (color >> 8) & 0xFF;
- int b = color & 0xFF;
-
-
- int V = Math.max(b, Math.max(r, g));
- int temp = Math.min(b, Math.min(r, g));
-
- float S;
-
- if (V == temp) {
- S = 0;
- } else {
- S = (V - temp) / (float) V;
- }
-
- return S;
- }
-
- /**
- * Returns the brightness component of a color int.
+ * Returns the relative luminance of a color.
+ * <p>
+ * Assumes sRGB encoding. Based on the formula for relative luminance
+ * defined in WCAG 2.0, W3C Recommendation 11 December 2008.
*
- * @return A value between 0.0f and 1.0f
- *
- * @hide Pending API council
+ * @return a value between 0 (darkest black) and 1 (lightest white)
*/
- public static float brightness(@ColorInt int color) {
- int r = (color >> 16) & 0xFF;
- int g = (color >> 8) & 0xFF;
- int b = color & 0xFF;
-
- int V = Math.max(b, Math.max(r, g));
-
- return (V / 255.f);
+ public static float luminance(@ColorInt int color) {
+ double red = Color.red(color) / 255.0;
+ red = red < 0.03928 ? red / 12.92 : Math.pow((red + 0.055) / 1.055, 2.4);
+ double green = Color.green(color) / 255.0;
+ green = green < 0.03928 ? green / 12.92 : Math.pow((green + 0.055) / 1.055, 2.4);
+ double blue = Color.blue(color) / 255.0;
+ blue = blue < 0.03928 ? blue / 12.92 : Math.pow((blue + 0.055) / 1.055, 2.4);
+ return (float) ((0.2126 * red) + (0.7152 * green) + (0.0722 * blue));
}
/**
diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java
index a11b2cd..d7fd8a5 100644
--- a/graphics/java/android/graphics/drawable/GradientDrawable.java
+++ b/graphics/java/android/graphics/drawable/GradientDrawable.java
@@ -17,10 +17,11 @@
package android.graphics.drawable;
import android.annotation.ColorInt;
+import android.annotation.Nullable;
import android.content.res.ColorStateList;
import android.content.res.Resources;
-import android.content.res.TypedArray;
import android.content.res.Resources.Theme;
+import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
@@ -198,34 +199,54 @@
}
/**
- * <p>Specify radii for each of the 4 corners. For each corner, the array
- * contains 2 values, <code>[X_radius, Y_radius]</code>. The corners are ordered
- * top-left, top-right, bottom-right, bottom-left. This property
- * is honored only when the shape is of type {@link #RECTANGLE}.</p>
- * <p><strong>Note</strong>: changing this property will affect all instances
+ * Specifies radii for each of the 4 corners. For each corner, the array
+ * contains 2 values, <code>[X_radius, Y_radius]</code>. The corners are
+ * ordered top-left, top-right, bottom-right, bottom-left. This property
+ * is honored only when the shape is of type {@link #RECTANGLE}.
+ * <p>
+ * <strong>Note</strong>: changing this property will affect all instances
* of a drawable loaded from a resource. It is recommended to invoke
- * {@link #mutate()} before changing this property.</p>
+ * {@link #mutate()} before changing this property.
*
- * @param radii 4 pairs of X and Y radius for each corner, specified in pixels.
- * The length of this array must be >= 8
+ * @param radii an array of length >= 8 containing 4 pairs of X and Y
+ * radius for each corner, specified in pixels
*
* @see #mutate()
- * @see #setCornerRadii(float[])
* @see #setShape(int)
+ * @see #setCornerRadius(float)
*/
- public void setCornerRadii(float[] radii) {
+ public void setCornerRadii(@Nullable float[] radii) {
mGradientState.setCornerRadii(radii);
mPathIsDirty = true;
invalidateSelf();
}
/**
- * <p>Specify radius for the corners of the gradient. If this is > 0, then the
- * drawable is drawn in a round-rectangle, rather than a rectangle. This property
- * is honored only when the shape is of type {@link #RECTANGLE}.</p>
- * <p><strong>Note</strong>: changing this property will affect all instances
+ * Returns the radii for each of the 4 corners. For each corner, the array
+ * contains 2 values, <code>[X_radius, Y_radius]</code>. The corners are
+ * ordered top-left, top-right, bottom-right, bottom-left.
+ * <p>
+ * If the radius was previously set with {@link #setCornerRadius(float)},
+ * or if the corners are not rounded, this method will return {@code null}.
+ *
+ * @return an array containing the radii for each of the 4 corners, or
+ * {@code null}
+ * @see #setCornerRadii(float[])
+ */
+ @Nullable
+ public float[] getCornerRadii() {
+ return mGradientState.mRadiusArray.clone();
+ }
+
+ /**
+ * Specifies the radius for the corners of the gradient. If this is > 0,
+ * then the drawable is drawn in a round-rectangle, rather than a
+ * rectangle. This property is honored only when the shape is of type
+ * {@link #RECTANGLE}.
+ * <p>
+ * <strong>Note</strong>: changing this property will affect all instances
* of a drawable loaded from a resource. It is recommended to invoke
- * {@link #mutate()} before changing this property.</p>
+ * {@link #mutate()} before changing this property.
*
* @param radius The radius in pixels of the corners of the rectangle shape
*
@@ -240,6 +261,19 @@
}
/**
+ * Returns the radius for the corners of the gradient.
+ * <p>
+ * If the radius was previously set with {@link #setCornerRadii(float[])},
+ * or if the corners are not rounded, this method will return {@code null}.
+ *
+ * @return the radius in pixels of the corners of the rectangle shape, or 0
+ * @see #setCornerRadius
+ */
+ public float getCornerRadius() {
+ return mGradientState.mRadius;
+ }
+
+ /**
* <p>Set the stroke width and color for the drawable. If width is zero,
* then no stroke is drawn.</p>
* <p><strong>Note</strong>: changing this property will affect all instances
@@ -376,15 +410,17 @@
}
/**
- * <p>Sets the type of gradient used by this drawable..</p>
- * <p><strong>Note</strong>: changing this property will affect all instances
+ * Sets the type of gradient used by this drawable.
+ * <p>
+ * <strong>Note</strong>: changing this property will affect all instances
* of a drawable loaded from a resource. It is recommended to invoke
- * {@link #mutate()} before changing this property.</p>
+ * {@link #mutate()} before changing this property.
*
* @param gradient The type of the gradient: {@link #LINEAR_GRADIENT},
* {@link #RADIAL_GRADIENT} or {@link #SWEEP_GRADIENT}
*
* @see #mutate()
+ * @see #getGradientType()
*/
public void setGradientType(int gradient) {
mGradientState.setGradientType(gradient);
@@ -393,17 +429,33 @@
}
/**
- * <p>Sets the center location of the gradient. The radius is honored only when
- * the gradient type is set to {@link #RADIAL_GRADIENT} or {@link #SWEEP_GRADIENT}.</p>
- * <p><strong>Note</strong>: changing this property will affect all instances
- * of a drawable loaded from a resource. It is recommended to invoke
- * {@link #mutate()} before changing this property.</p>
+ * Returns the type of gradient used by this drawable, one of
+ * {@link #LINEAR_GRADIENT}, {@link #RADIAL_GRADIENT}, or
+ * {@link #SWEEP_GRADIENT}.
*
- * @param x The x coordinate of the gradient's center
- * @param y The y coordinate of the gradient's center
+ * @return the type of gradient used by this drawable
+ * @see #setGradientType(int)
+ */
+ public int getGradientType() {
+ return mGradientState.mGradient;
+ }
+
+ /**
+ * Sets the center location in pixels of the gradient. The radius is
+ * honored only when the gradient type is set to {@link #RADIAL_GRADIENT}
+ * or {@link #SWEEP_GRADIENT}.
+ * <p>
+ * <strong>Note</strong>: changing this property will affect all instances
+ * of a drawable loaded from a resource. It is recommended to invoke
+ * {@link #mutate()} before changing this property.
+ *
+ * @param x the x coordinate of the gradient's center in pixels
+ * @param y the y coordinate of the gradient's center in pixels
*
* @see #mutate()
* @see #setGradientType(int)
+ * @see #getGradientCenterX()
+ * @see #getGradientCenterY()
*/
public void setGradientCenter(float x, float y) {
mGradientState.setGradientCenter(x, y);
@@ -412,16 +464,38 @@
}
/**
- * <p>Sets the radius of the gradient. The radius is honored only when the
- * gradient type is set to {@link #RADIAL_GRADIENT}.</p>
- * <p><strong>Note</strong>: changing this property will affect all instances
- * of a drawable loaded from a resource. It is recommended to invoke
- * {@link #mutate()} before changing this property.</p>
+ * Returns the center X location of this gradient in pixels.
*
- * @param gradientRadius The radius of the gradient in pixels
+ * @return the center X location of this gradient in pixels
+ * @see #setGradientCenter(float, float)
+ */
+ public float getGradientCenterX() {
+ return mGradientState.mCenterX;
+ }
+
+ /**
+ * Returns the center Y location of this gradient in pixels.
+ *
+ * @return the center Y location of this gradient in pixels
+ * @see #setGradientCenter(float, float)
+ */
+ public float getGradientCenterY() {
+ return mGradientState.mCenterY;
+ }
+
+ /**
+ * Sets the radius of the gradient. The radius is honored only when the
+ * gradient type is set to {@link #RADIAL_GRADIENT}.
+ * <p>
+ * <strong>Note</strong>: changing this property will affect all instances
+ * of a drawable loaded from a resource. It is recommended to invoke
+ * {@link #mutate()} before changing this property.
+ *
+ * @param gradientRadius the radius of the gradient in pixels
*
* @see #mutate()
* @see #setGradientType(int)
+ * @see #getGradientRadius()
*/
public void setGradientRadius(float gradientRadius) {
mGradientState.setGradientRadius(gradientRadius, TypedValue.COMPLEX_UNIT_PX);
@@ -433,7 +507,8 @@
* Returns the radius of the gradient in pixels. The radius is valid only
* when the gradient type is set to {@link #RADIAL_GRADIENT}.
*
- * @return Radius in pixels.
+ * @return the radius of the gradient in pixels
+ * @see #setGradientRadius(float)
*/
public float getGradientRadius() {
if (mGradientState.mGradient != RADIAL_GRADIENT) {
@@ -445,17 +520,19 @@
}
/**
- * <p>Sets whether or not this drawable will honor its <code>level</code>
- * property.</p>
- * <p><strong>Note</strong>: changing this property will affect all instances
+ * Sets whether or not this drawable will honor its {@code level} property.
+ * <p>
+ * <strong>Note</strong>: changing this property will affect all instances
* of a drawable loaded from a resource. It is recommended to invoke
- * {@link #mutate()} before changing this property.</p>
+ * {@link #mutate()} before changing this property.
*
- * @param useLevel True if this drawable should honor its level, false otherwise
+ * @param useLevel {@code true} if this drawable should honor its level,
+ * {@code false} otherwise
*
* @see #mutate()
* @see #setLevel(int)
* @see #getLevel()
+ * @see #isUseLevel()
*/
public void setUseLevel(boolean useLevel) {
mGradientState.mUseLevel = useLevel;
@@ -463,6 +540,18 @@
invalidateSelf();
}
+ /**
+ * Returns whether or not this drawable will honor its {@code level}
+ * property.
+ *
+ * @return {@code true} if this drawable should honor its level,
+ * {@code false} otherwise
+ * @see #setUseLevel(boolean)
+ */
+ public boolean isUseLevel() {
+ return mGradientState.mUseLevel;
+ }
+
private int modulateAlpha(int alpha) {
int scale = mAlpha + (mAlpha >> 7);
return alpha * scale >> 8;
@@ -470,20 +559,25 @@
/**
* Returns the orientation of the gradient defined in this drawable.
+ *
+ * @return the orientation of the gradient defined in this drawable
+ * @see #setOrientation(Orientation)
*/
public Orientation getOrientation() {
return mGradientState.mOrientation;
}
/**
- * <p>Changes the orientation of the gradient defined in this drawable.</p>
- * <p><strong>Note</strong>: changing orientation will affect all instances
+ * Sets the orientation of the gradient defined in this drawable.
+ * <p>
+ * <strong>Note</strong>: changing orientation will affect all instances
* of a drawable loaded from a resource. It is recommended to invoke
- * {@link #mutate()} before changing the orientation.</p>
+ * {@link #mutate()} before changing the orientation.
*
- * @param orientation The desired orientation (angle) of the gradient
+ * @param orientation the desired orientation (angle) of the gradient
*
* @see #mutate()
+ * @see #getOrientation()
*/
public void setOrientation(Orientation orientation) {
mGradientState.mOrientation = orientation;
@@ -511,6 +605,18 @@
invalidateSelf();
}
+ /**
+ * Returns the colors used to draw the gradient, or {@code null} if the
+ * gradient is drawn using a single color or no colors.
+ *
+ * @return the colors used to draw the gradient, or {@code null}
+ * @see #setColors(int[] colors)
+ */
+ @Nullable
+ public int[] getColors() {
+ return mGradientState.mGradientColors.clone();
+ }
+
@Override
public void draw(Canvas canvas) {
if (!ensureValidRect()) {
@@ -707,15 +813,17 @@
}
/**
- * <p>Changes this drawable to use a single color instead of a gradient.</p>
- * <p><strong>Note</strong>: changing color will affect all instances
- * of a drawable loaded from a resource. It is recommended to invoke
- * {@link #mutate()} before changing the color.</p>
+ * Changes this drawable to use a single color instead of a gradient.
+ * <p>
+ * <strong>Note</strong>: changing color will affect all instances of a
+ * drawable loaded from a resource. It is recommended to invoke
+ * {@link #mutate()} before changing the color.
*
* @param argb The color used to fill the shape
*
* @see #mutate()
* @see #setColors(int[])
+ * @see #getColor
*/
public void setColor(@ColorInt int argb) {
mGradientState.setSolidColors(ColorStateList.valueOf(argb));
@@ -734,7 +842,9 @@
* {@link #mutate()} before changing the color.</p>
*
* @param colorStateList The color state list used to fill the shape
+ *
* @see #mutate()
+ * @see #getColor
*/
public void setColor(ColorStateList colorStateList) {
mGradientState.setSolidColors(colorStateList);
@@ -749,6 +859,19 @@
invalidateSelf();
}
+ /**
+ * Returns the color state list used to fill the shape, or {@code null} if
+ * the shape is filled with a gradient or has no fill color.
+ *
+ * @return the color state list used to fill this gradient, or {@code null}
+ *
+ * @see #setColor(int)
+ * @see #setColor(ColorStateList)
+ */
+ public ColorStateList getColor() {
+ return mGradientState.mSolidColors;
+ }
+
@Override
protected boolean onStateChange(int[] stateSet) {
boolean invalidateSelf = false;
diff --git a/graphics/java/android/graphics/drawable/NinePatchDrawable.java b/graphics/java/android/graphics/drawable/NinePatchDrawable.java
index 152fe6a..231405d 100644
--- a/graphics/java/android/graphics/drawable/NinePatchDrawable.java
+++ b/graphics/java/android/graphics/drawable/NinePatchDrawable.java
@@ -213,7 +213,12 @@
}
}
- private void setNinePatch(NinePatch ninePatch) {
+ /**
+ * Sets the nine patch used by this drawable.
+ *
+ * @param ninePatch the nine patch for this drawable
+ */
+ public void setNinePatch(NinePatch ninePatch) {
if (mNinePatch != ninePatch) {
mNinePatch = ninePatch;
if (ninePatch != null) {
@@ -226,6 +231,13 @@
}
}
+ /**
+ * @return the nine patch used by this drawable
+ */
+ public NinePatch getNinePatch() {
+ return mNinePatch;
+ }
+
@Override
public void draw(Canvas canvas) {
final Rect bounds = getBounds();
diff --git a/libs/androidfw/tests/BackupData_test.cpp b/libs/androidfw/tests/BackupData_test.cpp
index 92af7fe..e25b616 100644
--- a/libs/androidfw/tests/BackupData_test.cpp
+++ b/libs/androidfw/tests/BackupData_test.cpp
@@ -108,7 +108,7 @@
EXPECT_EQ(DATA1[i], dataBytes[i])
<< "data character " << i << " should be equal";
}
- delete dataBytes;
+ delete[] dataBytes;
delete writer;
delete reader;
}
diff --git a/libs/hwui/unit_tests/Android.mk b/libs/hwui/unit_tests/Android.mk
index 917e646..93cee4a 100644
--- a/libs/hwui/unit_tests/Android.mk
+++ b/libs/hwui/unit_tests/Android.mk
@@ -14,7 +14,6 @@
# limitations under the License.
#
-local_target_dir := $(TARGET_OUT_DATA)/local/tmp
LOCAL_PATH:= $(call my-dir)/..
include $(CLEAR_VARS)
@@ -28,8 +27,7 @@
LOCAL_SRC_FILES += \
unit_tests/ClipAreaTests.cpp \
unit_tests/DamageAccumulatorTests.cpp \
- unit_tests/LinearAllocatorTests.cpp \
- unit_tests/main.cpp
+ unit_tests/LinearAllocatorTests.cpp
include $(BUILD_NATIVE_TEST)
diff --git a/libs/hwui/unit_tests/main.cpp b/libs/hwui/unit_tests/main.cpp
deleted file mode 100644
index c9b9636..0000000
--- a/libs/hwui/unit_tests/main.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-#include <gtest/gtest.h>
-
-int main(int argc, char **argv) {
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java b/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java
index 7e6ec8b..5223d76 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java
@@ -85,7 +85,6 @@
import android.view.View.OnLayoutChangeListener;
import android.view.ViewGroup;
import android.widget.ImageView;
-import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
@@ -153,7 +152,6 @@
// These are lazily initialized.
private LinearLayoutManager mListLayout;
private GridLayoutManager mGridLayout;
- private OnLayoutChangeListener mRecyclerLayoutListener;
private int mColumnCount = 1; // This will get updated when layout changes.
public static void showNormal(FragmentManager fm, RootInfo root, DocumentInfo doc, int anim) {
@@ -294,7 +292,13 @@
}
};
- mSelectionManager = new MultiSelectManager(mRecView, listener);
+ mSelectionManager = new MultiSelectManager(
+ mRecView,
+ listener,
+ state.allowMultiple
+ ? MultiSelectManager.MODE_MULTIPLE
+ : MultiSelectManager.MODE_SINGLE);
+
mSelectionManager.addCallback(new SelectionModeListener());
mType = getArguments().getInt(EXTRA_TYPE);
@@ -431,7 +435,7 @@
}
private boolean onSingleTapUp(MotionEvent e) {
- if (!Events.isMouseEvent(e)) {
+ if (Events.isTouchEvent(e) && mSelectionManager.getSelection().isEmpty()) {
int position = getEventAdapterPosition(e);
if (position != RecyclerView.NO_POSITION) {
return handleViewItem(position);
@@ -531,13 +535,6 @@
updateLayout(state.derivedMode);
- final int choiceMode;
- if (state.allowMultiple) {
- choiceMode = ListView.CHOICE_MODE_MULTIPLE_MODAL;
- } else {
- choiceMode = ListView.CHOICE_MODE_NONE;
- }
-
final int thumbSize = getResources().getDimensionPixelSize(R.dimen.icon_size);
mThumbSize = new Point(thumbSize, thumbSize);
mRecView.setAdapter(mAdapter);
@@ -622,7 +619,10 @@
if ((docFlags & Document.FLAG_SUPPORTS_DELETE) == 0) {
mNoDeleteCount += selected ? 1 : -1;
}
+ }
+ @Override
+ public void onSelectionChanged() {
mSelectionManager.getSelection(mSelected);
if (mSelected.size() > 0) {
if (DEBUG) Log.d(TAG, "Maybe starting action mode.");
diff --git a/packages/DocumentsUI/src/com/android/documentsui/Events.java b/packages/DocumentsUI/src/com/android/documentsui/Events.java
index 2e06903..025b94f 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/Events.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/Events.java
@@ -28,7 +28,14 @@
* Returns true if event was triggered by a mouse.
*/
static boolean isMouseEvent(MotionEvent e) {
- return e.getToolType(0) == MotionEvent.TOOL_TYPE_MOUSE;
+ return isMouseType(e.getToolType(0));
+ }
+
+ /**
+ * Returns true if event was triggered by a finger or stylus touch.
+ */
+ static boolean isTouchEvent(MotionEvent e) {
+ return isTouchType(e.getToolType(0));
}
/**
@@ -39,6 +46,14 @@
}
/**
+ * Returns true if event was triggered by a finger or stylus touch.
+ */
+ static boolean isTouchType(int toolType) {
+ return toolType == MotionEvent.TOOL_TYPE_FINGER
+ || toolType == MotionEvent.TOOL_TYPE_STYLUS;
+ }
+
+ /**
* Returns true if the shift is pressed.
*/
boolean isShiftPressed(MotionEvent e) {
diff --git a/packages/DocumentsUI/src/com/android/documentsui/MultiSelectManager.java b/packages/DocumentsUI/src/com/android/documentsui/MultiSelectManager.java
index 91b4456..02edd0c 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/MultiSelectManager.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/MultiSelectManager.java
@@ -37,10 +37,18 @@
import java.util.List;
/**
- * MultiSelectManager adds traditional multi-item selection support to RecyclerView.
+ * MultiSelectManager provides support traditional multi-item selection support to RecyclerView.
+ * Additionally it can be configured to restrict selection to a single element, @see
+ * #setSelectMode.
*/
public final class MultiSelectManager {
+ /** Selection mode for multiple select. **/
+ public static final int MODE_MULTIPLE = 0;
+
+ /** Selection mode for multiple select. **/
+ public static final int MODE_SINGLE = 1;
+
private static final String TAG = "MultiSelectManager";
private static final boolean DEBUG = false;
@@ -54,15 +62,18 @@
private Adapter<?> mAdapter;
private RecyclerViewHelper mHelper;
+ private boolean mSingleSelect;
/**
* @param recyclerView
* @param gestureDelegate Option delage gesture listener.
+ * @param mode Selection mode
* @template A gestureDelegate that implements both {@link OnGestureListener}
* and {@link OnDoubleTapListener}
*/
public <L extends OnGestureListener & OnDoubleTapListener> MultiSelectManager(
- final RecyclerView recyclerView, L gestureDelegate) {
+ final RecyclerView recyclerView, L gestureDelegate, int mode) {
+
this(
recyclerView.getAdapter(),
new RecyclerViewHelper() {
@@ -73,7 +84,8 @@
? recyclerView.getChildAdapterPosition(view)
: RecyclerView.NO_POSITION;
}
- });
+ },
+ mode);
GestureDetector.SimpleOnGestureListener listener =
new GestureDetector.SimpleOnGestureListener() {
@@ -110,15 +122,15 @@
/**
* Constructs a new instance with {@code adapter} and {@code helper}.
- * @param adapter
- * @param helper
* @hide
*/
@VisibleForTesting
- MultiSelectManager(Adapter<?> adapter, RecyclerViewHelper helper) {
+ MultiSelectManager(Adapter<?> adapter, RecyclerViewHelper helper, int mode) {
checkNotNull(adapter, "'adapter' cannot be null.");
checkNotNull(helper, "'helper' cannot be null.");
+ mSingleSelect = mode == MODE_SINGLE;
+
mHelper = helper;
mAdapter = adapter;
@@ -196,34 +208,44 @@
* @return True if the selection state of the item changed.
*/
public boolean setItemSelected(int position, boolean selected) {
- boolean changed = (selected)
- ? mSelection.add(position)
- : mSelection.remove(position);
-
- if (changed) {
- notifyItemStateChanged(position, true);
+ if (mSingleSelect && !mSelection.isEmpty()) {
+ clearSelectionQuietly();
}
- return changed;
+ return setItemsSelected(position, 1, selected);
}
/**
- * @param position
- * @param length
- * @param selected
+ * Sets the selected state of the specified items. Note that the callback will NOT
+ * be consulted to see if an item can be selected.
+ *
* @return True if the selection state of any of the items changed.
*/
public boolean setItemsSelected(int position, int length, boolean selected) {
boolean changed = false;
for (int i = position; i < position + length; i++) {
- changed |= setItemSelected(i, selected);
+ boolean itemChanged = selected ? mSelection.add(i) : mSelection.remove(i);
+ if (itemChanged) {
+ notifyItemStateChanged(i, selected);
+ }
+ changed |= itemChanged;
}
+
+ notifySelectionChanged();
return changed;
}
/**
- * Clears the selection.
+ * Clears the selection and notifies (even if nothing changes).
*/
public void clearSelection() {
+ clearSelectionQuietly();
+ notifySelectionChanged();
+ }
+
+ /**
+ * Clears the selection, without notifying anyone.
+ */
+ private void clearSelectionQuietly() {
mRanger = null;
if (mSelection.isEmpty()) {
@@ -265,7 +287,9 @@
if (DEBUG) Log.i(TAG, "View is null. Cannot handle tap event.");
}
- toggleSelection(position);
+ if (toggleSelection(position)) {
+ notifySelectionChanged();
+ }
}
/**
@@ -309,6 +333,10 @@
toggleSelection(position);
}
+ // We're being lazy here notifying even when something might not have changed.
+ // To make this more correct, we'd need to update the Ranger class to return
+ // information about what has changed.
+ notifySelectionChanged();
return false;
}
@@ -327,20 +355,29 @@
return false;
}
+ boolean changed = false;
if (mSelection.contains(position)) {
- return attemptDeselect(position);
+ changed = attemptDeselect(position);
} else {
- boolean selected = attemptSelect(position);
+ boolean canSelect = notifyBeforeItemStateChange(position, true);
+ if (!canSelect) {
+ return false;
+ }
+ if (mSingleSelect && !mSelection.isEmpty()) {
+ clearSelectionQuietly();
+ }
+
// Here we're already in selection mode. In that case
// When a simple click/tap (without SHIFT) creates causes
// an item to be selected.
// By recreating Ranger at this point, we allow the user to create
// multiple separate contiguous ranges with SHIFT+Click & Click.
- if (selected) {
- setSelectionFocusBegin(position);
- }
- return selected;
+ selectAndNotify(position);
+ setSelectionFocusBegin(position);
+ changed = true;
}
+
+ return changed;
}
/**
@@ -367,10 +404,15 @@
*/
private void updateRange(int begin, int end, boolean selected) {
checkState(end >= begin);
- if (DEBUG) Log.i(TAG, String.format("Updating range begin=%d, end=%d, selected=%b.", begin, end, selected));
for (int i = begin; i <= end; i++) {
if (selected) {
- attemptSelect(i);
+ boolean canSelect = notifyBeforeItemStateChange(i, true);
+ if (canSelect) {
+ if (mSingleSelect && !mSelection.isEmpty()) {
+ clearSelectionQuietly();
+ }
+ selectAndNotify(i);
+ }
} else {
attemptDeselect(i);
}
@@ -381,16 +423,12 @@
* @param position
* @return True if the update was applied.
*/
- private boolean attemptSelect(int position) {
- if (notifyBeforeItemStateChange(position, true)) {
- mSelection.add(position);
+ private boolean selectAndNotify(int position) {
+ boolean changed = mSelection.add(position);
+ if (changed) {
notifyItemStateChanged(position, true);
- if (DEBUG) Log.d(TAG, "Selection after select: " + mSelection);
- return true;
- } else {
- if (DEBUG) Log.d(TAG, "Select cancelled by listener.");
- return false;
}
+ return changed;
}
/**
@@ -420,10 +458,8 @@
}
/**
- * Notifies registered listeners when a selection changes.
- *
- * @param position
- * @param selected
+ * Notifies registered listeners when the selection status of a single item
+ * (identified by {@code position}) changes.
*/
private void notifyItemStateChanged(int position, boolean selected) {
int lastListener = mCallbacks.size() - 1;
@@ -434,6 +470,19 @@
}
/**
+ * Notifies registered listeners when the selection has changed. This
+ * notification should be sent only once a full series of changes
+ * is complete, e.g. clearingSelection, or updating the single
+ * selection from one item to another.
+ */
+ private void notifySelectionChanged() {
+ int lastListener = mCallbacks.size() - 1;
+ for (int i = lastListener; i > -1; i--) {
+ mCallbacks.get(i).onSelectionChanged();
+ }
+ }
+
+ /**
* Class providing support for managing range selections.
*/
private final class Range {
@@ -443,7 +492,7 @@
int mEnd = UNDEFINED;
public Range(int begin) {
- if (DEBUG) Log.d(TAG, String.format("New Ranger(%d) created.", begin));
+ if (DEBUG) Log.d(TAG, "New Ranger created beginning @ " + begin);
mBegin = begin;
}
@@ -680,8 +729,10 @@
}
StringBuilder buffer = new StringBuilder(mSelection.size() * 28);
- buffer.append(String.format("{size=%d, ", mSelection.size()));
- buffer.append("items=[");
+ buffer.append("{size=")
+ .append(mSelection.size())
+ .append(", ")
+ .append("items=[");
for (int i=0; i < mSelection.size(); i++) {
if (i > 0) {
buffer.append(", ");
@@ -726,11 +777,19 @@
public void onItemStateChanged(int position, boolean selected);
/**
- * @param position
- * @param selected
- * @return false to cancel the change.
+ * Called prior to an item changing state. Callbacks can cancel
+ * the change at {@code position} by returning {@code false}.
+ *
+ * @param position Adapter position of the item that was checked or unchecked
+ * @param selected <code>true</code> if the item is to be selected, <code>false</code>
+ * if the item is to be unselected.
*/
public boolean onBeforeItemStateChange(int position, boolean selected);
+
+ /**
+ * Called immediately after completion of any set of changes.
+ */
+ public void onSelectionChanged();
}
/**
diff --git a/packages/DocumentsUI/tests/src/com/android/documentsui/MultiSelectManagerTest.java b/packages/DocumentsUI/tests/src/com/android/documentsui/MultiSelectManagerTest.java
index d9f2261..03ad3d4 100644
--- a/packages/DocumentsUI/tests/src/com/android/documentsui/MultiSelectManagerTest.java
+++ b/packages/DocumentsUI/tests/src/com/android/documentsui/MultiSelectManagerTest.java
@@ -60,7 +60,7 @@
mAdapter = new TestAdapter(items);
mCallback = new TestCallback();
mEventHelper = new EventHelper();
- mManager = new MultiSelectManager(mAdapter, mEventHelper);
+ mManager = new MultiSelectManager(mAdapter, mEventHelper, MultiSelectManager.MODE_MULTIPLE);
mManager.addCallback(mCallback);
}
@@ -188,6 +188,24 @@
assertRangeSelection(0, 7);
}
+ @Test
+ public void singleSelectMode() {
+ mManager = new MultiSelectManager(mAdapter, mEventHelper, MultiSelectManager.MODE_SINGLE);
+ mManager.addCallback(mCallback);
+ tap(20);
+ tap(13);
+ assertSelection(13);
+ }
+
+ @Test
+ public void singleSelectMode_ShiftTap() {
+ mManager = new MultiSelectManager(mAdapter, mEventHelper, MultiSelectManager.MODE_SINGLE);
+ mManager.addCallback(mCallback);
+ tap(13);
+ shiftTap(20);
+ assertSelection(20);
+ }
+
private void tap(int position) {
mManager.onSingleTapUp(position, 0, MotionEvent.TOOL_TYPE_MOUSE);
}
@@ -257,6 +275,9 @@
public boolean onBeforeItemStateChange(int position, boolean selected) {
return !ignored.contains(position);
}
+
+ @Override
+ public void onSelectionChanged() {}
}
private static final class TestHolder extends RecyclerView.ViewHolder {
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index ba7974c..daf42fb 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -261,12 +261,6 @@
<!-- Doze: pulse parameter - how long does it take to fade in after a pickup? -->
<integer name="doze_pulse_duration_in_pickup">300</integer>
- <!-- Doze: pulse parameter - delay to wait for the screen to wake up -->
- <integer name="doze_pulse_delay_in">200</integer>
-
- <!-- Doze: pulse parameter - delay to wait for the screen to wake up after a pickup -->
- <integer name="doze_pulse_delay_in_pickup">200</integer>
-
<!-- Doze: pulse parameter - once faded in, how long does it stay visible? -->
<integer name="doze_pulse_duration_visible">3000</integer>
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index 428ceca..9239eac 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -1585,6 +1585,7 @@
private void handleNotifyScreenTurningOn(IKeyguardDrawnCallback callback) {
synchronized (KeyguardViewMediator.this) {
if (DEBUG) Log.d(TAG, "handleNotifyScreenTurningOn");
+ mStatusBarKeyguardViewManager.onScreenTurningOn();
if (callback != null) {
if (mWakeAndUnlocking) {
mDrawnCallback = callback;
diff --git a/packages/SystemUI/src/com/android/systemui/media/RingtonePlayer.java b/packages/SystemUI/src/com/android/systemui/media/RingtonePlayer.java
index fe876d7..7f68e29 100644
--- a/packages/SystemUI/src/com/android/systemui/media/RingtonePlayer.java
+++ b/packages/SystemUI/src/com/android/systemui/media/RingtonePlayer.java
@@ -159,7 +159,9 @@
if (Binder.getCallingUid() != Process.SYSTEM_UID) {
throw new SecurityException("Async playback only available from system UID.");
}
-
+ if (UserHandle.ALL.equals(user)) {
+ user = UserHandle.OWNER;
+ }
mAsyncPlayer.play(getContextForUser(user), uri, looping, aa);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index a6cea62..a55256d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -171,13 +171,7 @@
// on-screen navigation buttons
protected NavigationBarView mNavigationBarView = null;
- protected Boolean mScreenOn;
-
- // The second field is a bit different from the first one because it only listens to screen on/
- // screen of events from Keyguard. We need this so we don't have a race condition with the
- // broadcast. In the future, we should remove the first field altogether and rename the second
- // field.
- protected boolean mScreenOnFromKeyguard;
+ protected boolean mDeviceInteractive;
protected boolean mVisible;
@@ -1722,7 +1716,7 @@
protected void updateVisibleToUser() {
boolean oldVisibleToUser = mVisibleToUser;
- mVisibleToUser = mVisible && mScreenOnFromKeyguard;
+ mVisibleToUser = mVisible && mDeviceInteractive;
if (oldVisibleToUser != mVisibleToUser) {
handleVisibleToUserChanged(mVisibleToUser);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/AppInfo.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/AppInfo.java
index 67dd673..5ec5147 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/AppInfo.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/AppInfo.java
@@ -22,11 +22,6 @@
* Navigation bar app information.
*/
class AppInfo {
- /**
- * Unspecified serial number for the app's user.
- */
- public static final long USER_UNSPECIFIED = -1;
-
private final ComponentName mComponentName;
private final long mUserSerialNumber;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java
index 6b167b4..5a2fa3b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java
@@ -50,8 +50,6 @@
pw.print(" getPulseDuration(pickup=true): "); pw.println(getPulseDuration(true));
pw.print(" getPulseInDuration(pickup=false): "); pw.println(getPulseInDuration(false));
pw.print(" getPulseInDuration(pickup=true): "); pw.println(getPulseInDuration(true));
- pw.print(" getPulseInDelay(pickup=false): "); pw.println(getPulseInDelay(false));
- pw.print(" getPulseInDelay(pickup=true): "); pw.println(getPulseInDelay(true));
pw.print(" getPulseInVisibleDuration(): "); pw.println(getPulseVisibleDuration());
pw.print(" getPulseOutDuration(): "); pw.println(getPulseOutDuration());
pw.print(" getPulseOnSigMotion(): "); pw.println(getPulseOnSigMotion());
@@ -80,12 +78,6 @@
: getInt("doze.pulse.duration.in", R.integer.doze_pulse_duration_in);
}
- public int getPulseInDelay(boolean pickup) {
- return pickup
- ? getInt("doze.pulse.delay.in.pickup", R.integer.doze_pulse_delay_in_pickup)
- : getInt("doze.pulse.delay.in", R.integer.doze_pulse_delay_in);
- }
-
public int getPulseVisibleDuration() {
return getInt("doze.pulse.duration.visible", R.integer.doze_pulse_duration_visible);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeScrimController.java
index 3e17328..86b8972 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeScrimController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeScrimController.java
@@ -100,6 +100,16 @@
mHandler.post(mPulseIn);
}
+ public void onScreenTurnedOn() {
+ if (isPulsing()) {
+ final boolean pickup = mPulseReason == DozeLog.PULSE_REASON_SENSOR_PICKUP;
+ startScrimAnimation(true /* inFront */, 0f,
+ mDozeParameters.getPulseInDuration(pickup),
+ pickup ? mPulseInInterpolatorPickup : mPulseInInterpolator,
+ mPulseInFinished);
+ }
+ }
+
public boolean isPulsing() {
return mPulseCallback != null;
}
@@ -138,12 +148,11 @@
private void startScrimAnimation(final boolean inFront, float target, long duration,
Interpolator interpolator) {
- startScrimAnimation(inFront, target, duration, interpolator, 0 /* delay */,
- null /* endRunnable */);
+ startScrimAnimation(inFront, target, duration, interpolator, null /* endRunnable */);
}
private void startScrimAnimation(final boolean inFront, float target, long duration,
- Interpolator interpolator, long delay, final Runnable endRunnable) {
+ Interpolator interpolator, final Runnable endRunnable) {
Animator current = getCurrentAnimator(inFront);
if (current != null) {
float currentTarget = getCurrentTarget(inFront);
@@ -162,7 +171,6 @@
});
anim.setInterpolator(interpolator);
anim.setDuration(duration);
- anim.setStartDelay(delay);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
@@ -222,12 +230,6 @@
+ DozeLog.pulseReasonToString(mPulseReason));
if (!mDozing) return;
DozeLog.tracePulseStart(mPulseReason);
- final boolean pickup = mPulseReason == DozeLog.PULSE_REASON_SENSOR_PICKUP;
- startScrimAnimation(true /* inFront */, 0f,
- mDozeParameters.getPulseInDuration(pickup),
- pickup ? mPulseInInterpolatorPickup : mPulseInInterpolator,
- mDozeParameters.getPulseInDelay(pickup),
- mPulseInFinished);
// Signal that the pulse is ready to turn the screen on and draw.
pulseStarted();
@@ -249,7 +251,7 @@
if (DEBUG) Log.d(TAG, "Pulse out, mDozing=" + mDozing);
if (!mDozing) return;
startScrimAnimation(true /* inFront */, 1f, mDozeParameters.getPulseOutDuration(),
- mPulseOutInterpolator, 0 /* delay */, mPulseOutFinished);
+ mPulseOutInterpolator, mPulseOutFinished);
}
};
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarApps.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarApps.java
index 41d30c7..d74c5b0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarApps.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarApps.java
@@ -136,9 +136,10 @@
transition.enableTransitionType(LayoutTransition.CHANGING);
parent.setLayoutTransition(transition);
+ int currentUserId = ActivityManager.getCurrentUser();
mCurrentUserSerialNumber = mUserManager.getSerialNumberForUser(
- new UserHandle(ActivityManager.getCurrentUser()));
- sAppsModel.setCurrentUser(mCurrentUserSerialNumber);
+ new UserHandle(currentUserId));
+ sAppsModel.setCurrentUser(currentUserId);
recreateAppButtons();
IntentFilter filter = new IntentFilter();
@@ -222,10 +223,7 @@
static void startAppDrag(ImageView icon, AppInfo appInfo) {
// The drag data is an Intent to launch the activity.
Intent mainIntent = Intent.makeMainActivity(appInfo.getComponentName());
- long userSerialNumber = appInfo.getUserSerialNumber();
- if (userSerialNumber != AppInfo.USER_UNSPECIFIED) {
- mainIntent.putExtra(EXTRA_PROFILE, userSerialNumber);
- }
+ mainIntent.putExtra(EXTRA_PROFILE, appInfo.getUserSerialNumber());
ClipData dragData = ClipData.newIntent("", mainIntent);
// Use the ImageView to create the shadow.
View.DragShadowBuilder shadow = new AppIconDragShadowBuilder(icon);
@@ -396,7 +394,14 @@
return null;
}
- long userSerialNumber = intent.getLongExtra(EXTRA_PROFILE, AppInfo.USER_UNSPECIFIED);
+ long userSerialNumber = intent.getLongExtra(EXTRA_PROFILE, -1);
+
+ // Validate the received user serial number.
+ UserHandle appUser = mUserManager.getUserForSerialNumber(userSerialNumber);
+ if (appUser == null) {
+ userSerialNumber = mCurrentUserSerialNumber;
+ }
+
return new AppInfo(intent.getComponent(), userSerialNumber);
}
@@ -466,18 +471,14 @@
long appUserSerialNumber = appInfo.getUserSerialNumber();
- UserHandle appUser = null;
- if (appUserSerialNumber != AppInfo.USER_UNSPECIFIED) {
- appUser = mUserManager.getUserForSerialNumber(appUserSerialNumber);
+ UserHandle appUser = mUserManager.getUserForSerialNumber(appUserSerialNumber);
+ if (appUser == null) {
+ Toast.makeText(getContext(), R.string.activity_not_found, Toast.LENGTH_SHORT).show();
+ Log.e(TAG, "Can't start activity " + component +
+ " because its user doesn't exist.");
+ return;
}
-
- int appUserId;
- if (appUser != null) {
- appUserId = appUser.getIdentifier();
- } else {
- appUserId = ActivityManager.getCurrentUser();
- appUser = new UserHandle(appUserId);
- }
+ int appUserId = appUser.getIdentifier();
// Play a scale-up animation while launching the activity.
// TODO: Consider playing a different animation, or no animation, if the activity is
@@ -545,7 +546,7 @@
if (newUserSerialNumber != mCurrentUserSerialNumber) {
mCurrentUserSerialNumber = newUserSerialNumber;
- sAppsModel.setCurrentUser(newUserSerialNumber);
+ sAppsModel.setCurrentUser(currentUserId);
recreateAppButtons();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarAppsModel.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarAppsModel.java
index 39f1304..b8764cf 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarAppsModel.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarAppsModel.java
@@ -16,18 +16,16 @@
package com.android.systemui.statusbar.phone;
-import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo;
+import android.os.UserHandle;
import android.os.UserManager;
import android.util.Slog;
-import com.android.internal.annotations.VisibleForTesting;
-
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -52,7 +50,7 @@
private final static String VERSION_PREF = "version";
// Current version number for preferences.
- private final static int CURRENT_VERSION = 2;
+ private final static int CURRENT_VERSION = 3;
// Preference name for the number of app icons.
private final static String APP_COUNT_PREF = "app_count";
@@ -68,18 +66,23 @@
// user serial of the third app of the logged-in user.
private final static char USER_SEPARATOR = '|';
- final Context mContext;
+ private final Context mContext;
+ private final UserManager mUserManager;
private final SharedPreferences mPrefs;
// Apps are represented as an ordered list of app infos.
private final List<AppInfo> mApps = new ArrayList<AppInfo>();
+ // Id of the current user.
+ private int mCurrentUserId = -1;
+
// Serial number of the current user.
- private long mCurrentUserSerialNumber = AppInfo.USER_UNSPECIFIED;
+ private long mCurrentUserSerialNumber = -1;
public NavigationBarAppsModel(Context context) {
mContext = context;
mPrefs = mContext.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
+ mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
int version = mPrefs.getInt(VERSION_PREF, -1);
if (version != CURRENT_VERSION) {
@@ -94,8 +97,9 @@
/**
* Reinitializes the model for a new user.
*/
- public void setCurrentUser(long userSerialNumber) {
- mCurrentUserSerialNumber = userSerialNumber;
+ public void setCurrentUser(int userId) {
+ mCurrentUserId = userId;
+ mCurrentUserSerialNumber = mUserManager.getSerialNumberForUser(new UserHandle(userId));
mApps.clear();
@@ -115,11 +119,8 @@
* Removes prefs for users that don't exist on the device.
*/
private void removePrefsForDeletedUsers() {
- UserManager userManager =
- (UserManager) mContext.getSystemService(Context.USER_SERVICE);
-
// Build a set of string representations of serial numbers of the device users.
- final List<UserInfo> users = userManager.getUsers();
+ final List<UserInfo> users = mUserManager.getUsers();
final int userCount = users.size();
final Set<String> userSerials = new HashSet<String> ();
@@ -207,31 +208,30 @@
continue;
}
ComponentName componentName = ComponentName.unflattenFromString(prefValue);
- long userSerialNumber = mPrefs.getLong(prefUserForApp(i), AppInfo.USER_UNSPECIFIED);
+ long userSerialNumber = mPrefs.getLong(prefUserForApp(i), -1);
+ if (userSerialNumber == -1) {
+ Slog.w(TAG, "Couldn't find pref " + prefUserForApp(i));
+ // Couldn't find the saved state. Just skip this item.
+ continue;
+ }
mApps.add(new AppInfo(componentName, userSerialNumber));
}
}
- @VisibleForTesting
- protected int getCurrentUser() {
- return ActivityManager.getCurrentUser();
- }
-
/** Adds the first few apps from the owner profile. Used for demo purposes. */
private void addDefaultApps() {
// Get a list of all app activities.
final Intent queryIntent = new Intent(Intent.ACTION_MAIN, null);
queryIntent.addCategory(Intent.CATEGORY_LAUNCHER);
- final int currentUser = getCurrentUser();
final List<ResolveInfo> apps = mContext.getPackageManager().queryIntentActivitiesAsUser(
- queryIntent, 0 /* flags */, currentUser);
+ queryIntent, 0 /* flags */, mCurrentUserId);
final int appCount = apps.size();
for (int i = 0; i < NUM_INITIAL_APPS && i < appCount; i++) {
ResolveInfo ri = apps.get(i);
ComponentName componentName = new ComponentName(
ri.activityInfo.packageName, ri.activityInfo.name);
- mApps.add(new AppInfo(componentName, AppInfo.USER_UNSPECIFIED));
+ mApps.add(new AppInfo(componentName, mCurrentUserSerialNumber));
}
savePrefs();
@@ -239,10 +239,6 @@
/** Returns a pref prefixed with the serial number of the current user. */
private String userPrefixed(String pref) {
- if (mCurrentUserSerialNumber == AppInfo.USER_UNSPECIFIED) {
- throw new RuntimeException("Current user is not yet set");
- }
-
return Long.toString(mCurrentUserSerialNumber) + USER_SEPARATOR + pref;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarRecents.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarRecents.java
index eaa1c20..b024ec4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarRecents.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarRecents.java
@@ -28,6 +28,7 @@
import android.os.Handler;
import android.os.RemoteException;
import android.os.UserHandle;
+import android.os.UserManager;
import android.util.AttributeSet;
import android.util.Slog;
import android.util.SparseBooleanArray;
@@ -88,8 +89,7 @@
MAX_RECENTS,
ActivityManager.RECENT_IGNORE_HOME_STACK_TASKS |
ActivityManager.RECENT_IGNORE_UNAVAILABLE |
- ActivityManager.RECENT_INCLUDE_PROFILES |
- ActivityManager.RECENT_WITH_EXCLUDED,
+ ActivityManager.RECENT_INCLUDE_PROFILES,
UserHandle.USER_CURRENT);
if (DEBUG) Slog.d(TAG, "Got recents " + recentTasks.size());
removeMissingRecents(recentTasks);
@@ -232,7 +232,11 @@
}
if (DEBUG) Slog.d(TAG, "Start drag with " + intent);
- NavigationBarApps.startAppDrag(icon, new AppInfo (intent.getComponent(), AppInfo.USER_UNSPECIFIED));
+
+ UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
+ long userSerialNumber = userManager.getSerialNumberForUser(new UserHandle(task.userId));
+ NavigationBarApps.startAppDrag(
+ icon, new AppInfo(intent.getComponent(), userSerialNumber));
return true;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index c4c8e3d..710c335 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -918,7 +918,7 @@
}
private int getFalsingThreshold() {
- float factor = mStatusBar.isScreenOnComingFromTouch() ? 1.5f : 1.0f;
+ float factor = mStatusBar.isWakeUpComingFromTouch() ? 1.5f : 1.0f;
return (int) (mQsFalsingThreshold * factor);
}
@@ -2075,7 +2075,7 @@
@Override
public float getAffordanceFalsingFactor() {
- return mStatusBar.isScreenOnComingFromTouch() ? 1.5f : 1.0f;
+ return mStatusBar.isWakeUpComingFromTouch() ? 1.5f : 1.0f;
}
@Override
@@ -2226,7 +2226,7 @@
}
};
- public void onScreenTurnedOn() {
+ public void onScreenTurningOn() {
mKeyguardStatusView.refreshTime();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index 5995fe1..9cd6ea3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -391,7 +391,7 @@
|| forceCancel;
DozeLog.traceFling(expand, mTouchAboveFalsingThreshold,
mStatusBar.isFalsingThresholdNeeded(),
- mStatusBar.isScreenOnComingFromTouch());
+ mStatusBar.isWakeUpComingFromTouch());
// Log collapse gesture if on lock screen.
if (!expand && mStatusBar.getBarState() == StatusBarState.KEYGUARD) {
float displayDensity = mStatusBar.getDisplayDensity();
@@ -420,7 +420,7 @@
}
private int getFalsingThreshold() {
- float factor = mStatusBar.isScreenOnComingFromTouch() ? 1.5f : 1.0f;
+ float factor = mStatusBar.isWakeUpComingFromTouch() ? 1.5f : 1.0f;
return (int) (mUnlockFalsingThreshold * factor);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 453b268..0635847 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -282,8 +282,8 @@
private StatusBarWindowManager mStatusBarWindowManager;
private UnlockMethodCache mUnlockMethodCache;
private DozeServiceHost mDozeServiceHost;
- private boolean mScreenOnComingFromTouch;
- private PointF mScreenOnTouchLocation;
+ private boolean mWakeUpComingFromTouch;
+ private PointF mWakeUpTouchLocation;
int mPixelFormat;
Object mQueueLock = new Object();
@@ -1933,8 +1933,8 @@
return mNotificationPanel.isQsExpanded();
}
- public boolean isScreenOnComingFromTouch() {
- return mScreenOnComingFromTouch;
+ public boolean isWakeUpComingFromTouch() {
+ return mWakeUpComingFromTouch;
}
public boolean isFalsingThresholdNeeded() {
@@ -2494,7 +2494,7 @@
private void checkBarMode(int mode, int windowState, BarTransitions transitions,
boolean noAnimation) {
final boolean powerSave = mBatteryController.isPowerSave();
- final boolean anim = !noAnimation && (mScreenOn == null || mScreenOn)
+ final boolean anim = !noAnimation && mDeviceInteractive
&& windowState != WINDOW_STATE_HIDDEN && !powerSave;
if (powerSave && getBarState() == StatusBarState.SHADE) {
mode = MODE_WARNING;
@@ -2902,14 +2902,12 @@
}
}
else if (Intent.ACTION_SCREEN_OFF.equals(action)) {
- mScreenOn = false;
notifyNavigationBarScreenOn(false);
notifyHeadsUpScreenOff();
finishBarAnimations();
resetUserExpandedStates();
}
else if (Intent.ACTION_SCREEN_ON.equals(action)) {
- mScreenOn = true;
notifyNavigationBarScreenOn(true);
}
}
@@ -3363,7 +3361,7 @@
mHandler.removeMessages(MSG_LAUNCH_TRANSITION_TIMEOUT);
setBarState(StatusBarState.KEYGUARD);
updateKeyguardState(false /* goingToFullShade */, false /* fromShadeLocked */);
- if (!mScreenOnFromKeyguard) {
+ if (!mDeviceInteractive) {
// If the screen is off already, we need to disable touch events because these might
// collapse the panel after we expanded it, and thus we would end up with a blank
@@ -3583,7 +3581,7 @@
private void updateDozingState() {
boolean animate = !mDozing && mDozeScrimController.isPulsing();
mNotificationPanel.setDozing(mDozing, animate);
- mStackScroller.setDark(mDozing, animate, mScreenOnTouchLocation);
+ mStackScroller.setDark(mDozing, animate, mWakeUpTouchLocation);
mScrimController.setDozing(mDozing);
mDozeScrimController.setDozing(mDozing, animate);
}
@@ -3636,7 +3634,7 @@
}
public boolean onSpacePressed() {
- if (mScreenOn != null && mScreenOn
+ if (mDeviceInteractive
&& (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED)) {
animateCollapsePanels(
CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL /* flags */, true /* force */);
@@ -3846,22 +3844,29 @@
disable(mDisabledUnmodified1, mDisabledUnmodified2, true /* animate */);
}
- public void onScreenTurnedOff() {
- mScreenOnFromKeyguard = false;
- mScreenOnComingFromTouch = false;
- mScreenOnTouchLocation = null;
+ public void onFinishedGoingToSleep() {
+ mDeviceInteractive = false;
+ mWakeUpComingFromTouch = false;
+ mWakeUpTouchLocation = null;
mStackScroller.setAnimationsEnabled(false);
updateVisibleToUser();
}
- public void onScreenTurnedOn() {
- mScreenOnFromKeyguard = true;
+ public void onStartedWakingUp() {
+ mDeviceInteractive = true;
mStackScroller.setAnimationsEnabled(true);
- mNotificationPanel.onScreenTurnedOn();
mNotificationPanel.setTouchDisabled(false);
updateVisibleToUser();
}
+ public void onScreenTurningOn() {
+ mNotificationPanel.onScreenTurningOn();
+ }
+
+ public void onScreenTurnedOn() {
+ mDozeScrimController.onScreenTurnedOn();
+ }
+
/**
* This handles long-press of both back and recents. They are
* handled together to capture them both being long-pressed
@@ -3976,8 +3981,8 @@
if (mDozing && mDozeScrimController.isPulsing()) {
PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
pm.wakeUp(time, "com.android.systemui:NODOZE");
- mScreenOnComingFromTouch = true;
- mScreenOnTouchLocation = new PointF(event.getX(), event.getY());
+ mWakeUpComingFromTouch = true;
+ mWakeUpTouchLocation = new PointF(event.getX(), event.getY());
mNotificationPanel.setTouchDisabled(false);
mStatusBarKeyguardViewManager.notifyDeviceWakeUpRequested();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
index 3c1272d..9d47713 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
@@ -162,14 +162,18 @@
public void onFinishedGoingToSleep() {
mDeviceInteractive = false;
- mPhoneStatusBar.onScreenTurnedOff();
+ mPhoneStatusBar.onFinishedGoingToSleep();
mBouncer.onScreenTurnedOff();
}
public void onStartedWakingUp() {
mDeviceInteractive = true;
mDeviceWillWakeUp = false;
- mPhoneStatusBar.onScreenTurnedOn();
+ mPhoneStatusBar.onStartedWakingUp();
+ }
+
+ public void onScreenTurningOn() {
+ mPhoneStatusBar.onScreenTurningOn();
}
public void onScreenTurnedOn() {
@@ -180,6 +184,7 @@
animateScrimControllerKeyguardFadingOut(0, 200);
updateStates();
}
+ mPhoneStatusBar.onScreenTurnedOn();
}
public void onScreenTurnedOff() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
index 6b30183..82c1aa8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -653,7 +653,7 @@
@Override
public float getFalsingThresholdFactor() {
- return mPhoneStatusBar.isScreenOnComingFromTouch() ? 1.5f : 1.0f;
+ return mPhoneStatusBar.isWakeUpComingFromTouch() ? 1.5f : 1.0f;
}
public View getChildAtPosition(MotionEvent ev) {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarAppsModelTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarAppsModelTest.java
index 31007ee..62213ab 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarAppsModelTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarAppsModelTest.java
@@ -31,6 +31,7 @@
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo;
+import android.os.UserHandle;
import android.os.UserManager;
import android.test.AndroidTestCase;
@@ -73,15 +74,12 @@
when(mMockUserManager.getUsers()).thenReturn(new ArrayList<UserInfo>());
// Assume the version pref is present and equal to the current version.
- when(mMockPrefs.getInt("version", -1)).thenReturn(2);
+ when(mMockPrefs.getInt("version", -1)).thenReturn(3);
when(mMockPrefs.edit()).thenReturn(mMockEdit);
- mModel = new NavigationBarAppsModel(context) {
- @Override
- protected int getCurrentUser() {
- return 0;
- }
- };
+ when(mMockUserManager.getSerialNumberForUser(new UserHandle(2))).thenReturn(22L);
+
+ mModel = new NavigationBarAppsModel(context);
}
/** Initializes the model from SharedPreferences for a few app activites. */
@@ -95,25 +93,23 @@
when(mMockPrefs.getString("22|app_2", null)).thenReturn("package2/class2");
when(mMockPrefs.getLong("22|app_user_2", -1)).thenReturn(239L);
- mModel.setCurrentUser(22L);
+ mModel.setCurrentUser(2);
}
/** Tests initializing the model from SharedPreferences. */
public void testInitializeFromPrefs() {
initializeModelFromPrefs();
- assertEquals(3, mModel.getAppCount());
- assertEquals("package0/class0", mModel.getApp(0).getComponentName().flattenToString());
- assertEquals(-1L, mModel.getApp(0).getUserSerialNumber());
- assertEquals("package1/class1", mModel.getApp(1).getComponentName().flattenToString());
- assertEquals(45L, mModel.getApp(1).getUserSerialNumber());
- assertEquals("package2/class2", mModel.getApp(2).getComponentName().flattenToString());
- assertEquals(239L, mModel.getApp(2).getUserSerialNumber());
+ assertEquals(2, mModel.getAppCount());
+ assertEquals("package1/class1", mModel.getApp(0).getComponentName().flattenToString());
+ assertEquals(45L, mModel.getApp(0).getUserSerialNumber());
+ assertEquals("package2/class2", mModel.getApp(1).getComponentName().flattenToString());
+ assertEquals(239L, mModel.getApp(1).getUserSerialNumber());
}
/** Tests initializing the model when the SharedPreferences aren't available. */
public void testInitializeDefaultApps() {
// Assume the user's app count pref isn't available.
- when(mMockPrefs.getInt("0|app_count", -1)).thenReturn(-1);
+ when(mMockPrefs.getInt("22|app_count", -1)).thenReturn(-1);
// Assume some installed activities.
ActivityInfo ai1 = new ActivityInfo();
@@ -127,16 +123,16 @@
ResolveInfo ri2 = new ResolveInfo();
ri2.activityInfo = ai2;
when(mMockPackageManager
- .queryIntentActivitiesAsUser(any(Intent.class), eq(0), eq(0)))
+ .queryIntentActivitiesAsUser(any(Intent.class), eq(0), eq(2)))
.thenReturn(Arrays.asList(ri1, ri2));
// Setting the user should load the installed activities.
- mModel.setCurrentUser(0L);
+ mModel.setCurrentUser(2);
assertEquals(2, mModel.getAppCount());
assertEquals("package1/class1", mModel.getApp(0).getComponentName().flattenToString());
- assertEquals(-1L, mModel.getApp(0).getUserSerialNumber());
+ assertEquals(22L, mModel.getApp(0).getUserSerialNumber());
assertEquals("package2/class2", mModel.getApp(1).getComponentName().flattenToString());
- assertEquals(-1L, mModel.getApp(1).getUserSerialNumber());
+ assertEquals(22L, mModel.getApp(1).getUserSerialNumber());
}
/** Tests initializing the model if one of the prefs is missing. */
@@ -150,7 +146,7 @@
when(mMockPrefs.getString("22|app_1", null)).thenReturn(null);
// Initializing the model should load from prefs and skip the missing one.
- mModel.setCurrentUser(22L);
+ mModel.setCurrentUser(2);
assertEquals(1, mModel.getAppCount());
assertEquals("package0/class0", mModel.getApp(0).getComponentName().flattenToString());
assertEquals(239L, mModel.getApp(0).getUserSerialNumber());
@@ -161,13 +157,11 @@
initializeModelFromPrefs();
mModel.savePrefs();
- verify(mMockEdit).putInt("22|app_count", 3);
- verify(mMockEdit).putString("22|app_0", "package0/class0");
- verify(mMockEdit).putLong("22|app_user_0", -1L);
- verify(mMockEdit).putString("22|app_1", "package1/class1");
- verify(mMockEdit).putLong("22|app_user_1", 45L);
- verify(mMockEdit).putString("22|app_2", "package2/class2");
- verify(mMockEdit).putLong("22|app_user_2", 239L);
+ verify(mMockEdit).putInt("22|app_count", 2);
+ verify(mMockEdit).putString("22|app_0", "package1/class1");
+ verify(mMockEdit).putLong("22|app_user_0", 45L);
+ verify(mMockEdit).putString("22|app_1", "package2/class2");
+ verify(mMockEdit).putLong("22|app_user_1", 239L);
verify(mMockEdit).apply();
verifyNoMoreInteractions(mMockEdit);
}
@@ -179,7 +173,7 @@
new NavigationBarAppsModel(getContext());
verify(mMockEdit).clear();
- verify(mMockEdit).putInt("version", 2);
+ verify(mMockEdit).putInt("version", 3);
verify(mMockEdit).apply();
verifyNoMoreInteractions(mMockEdit);
}
@@ -200,7 +194,7 @@
// Assume the user's app count pref isn't available. This will trigger clearing deleted
// users' prefs.
- when(mMockPrefs.getInt("0|app_count", -1)).thenReturn(-1);
+ when(mMockPrefs.getInt("22|app_count", -1)).thenReturn(-1);
final Map allPrefs = new HashMap<String, Object>();
allPrefs.put("version", null);
@@ -212,7 +206,7 @@
when(mMockPrefs.getAll()).thenReturn(allPrefs);
// Setting the user should remove prefs for deleted users.
- mModel.setCurrentUser(0L);
+ mModel.setCurrentUser(2);
verify(mMockEdit).remove("some_strange_pref");
verify(mMockEdit).remove("");
verify(mMockEdit).remove("|");
diff --git a/services/core/java/com/android/server/content/ContentService.java b/services/core/java/com/android/server/content/ContentService.java
index c13401f..b766894 100644
--- a/services/core/java/com/android/server/content/ContentService.java
+++ b/services/core/java/com/android/server/content/ContentService.java
@@ -157,7 +157,7 @@
mFactoryTest = factoryTest;
// Let the package manager query for the sync adapters for a given authority
- // as we grant default permissions to sync adapters for specifix authorities.
+ // as we grant default permissions to sync adapters for specific authorities.
PackageManagerInternal packageManagerInternal = LocalServices.getService(
PackageManagerInternal.class);
packageManagerInternal.setSyncAdapterPackagesprovider(
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 9426b76..4351798 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -3615,22 +3615,28 @@
public ArraySet<String> getGrantedPackages() {
final ArraySet<String> pkgs = new ArraySet<>();
- final String setting = Settings.Secure.getStringForUser(
- getContext().getContentResolver(),
- Settings.Secure.ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES,
- ActivityManager.getCurrentUser());
- if (setting != null) {
- final String[] tokens = setting.split(SEPARATOR);
- for (int i = 0; i < tokens.length; i++) {
- String token = tokens[i];
- if (token != null) {
- token.trim();
+
+ long identity = Binder.clearCallingIdentity();
+ try {
+ final String setting = Settings.Secure.getStringForUser(
+ getContext().getContentResolver(),
+ Settings.Secure.ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES,
+ ActivityManager.getCurrentUser());
+ if (setting != null) {
+ final String[] tokens = setting.split(SEPARATOR);
+ for (int i = 0; i < tokens.length; i++) {
+ String token = tokens[i];
+ if (token != null) {
+ token.trim();
+ }
+ if (TextUtils.isEmpty(token)) {
+ continue;
+ }
+ pkgs.add(token);
}
- if (TextUtils.isEmpty(token)) {
- continue;
- }
- pkgs.add(token);
}
+ } finally {
+ Binder.restoreCallingIdentity(identity);
}
return pkgs;
}
diff --git a/services/core/java/com/android/server/pm/BasePermission.java b/services/core/java/com/android/server/pm/BasePermission.java
index 18407c9..52d0928 100644
--- a/services/core/java/com/android/server/pm/BasePermission.java
+++ b/services/core/java/com/android/server/pm/BasePermission.java
@@ -88,4 +88,10 @@
return (protectionLevel & PermissionInfo.PROTECTION_MASK_BASE)
== PermissionInfo.PROTECTION_DANGEROUS;
}
+
+ public boolean isDevelopment() {
+ return (protectionLevel & PermissionInfo.PROTECTION_MASK_BASE)
+ == PermissionInfo.PROTECTION_SIGNATURE
+ && (protectionLevel & PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0;
+ }
}
diff --git a/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java b/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java
index 71a2d59..d2a70df 100644
--- a/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java
+++ b/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java
@@ -296,7 +296,7 @@
PackageParser.Package storagePackage = getDefaultProviderAuthorityPackageLPr(
"com.android.externalstorage.documents", userId);
if (storagePackage != null) {
- grantRuntimePermissionsLPw(storagePackage, STORAGE_PERMISSIONS, userId);
+ grantRuntimePermissionsLPw(storagePackage, STORAGE_PERMISSIONS, true, userId);
}
// CertInstaller
@@ -360,7 +360,7 @@
PackageParser.Package cbrPackage =
getDefaultSystemHandlerActivityPackageLPr(cbrIntent, userId);
if (cbrPackage != null && doesPackageSupportRuntimePermissions(cbrPackage)) {
- grantRuntimePermissionsLPw(cbrPackage, SMS_PERMISSIONS, false, userId);
+ grantRuntimePermissionsLPw(cbrPackage, SMS_PERMISSIONS, userId);
}
// Calendar
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index c0a3097..e8ec8b9 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -56,6 +56,7 @@
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK;
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER;
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED;
+import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK;
import static android.content.pm.PackageManager.MATCH_ALL;
import static android.content.pm.PackageManager.MOVE_FAILED_DOESNT_EXIST;
import static android.content.pm.PackageManager.MOVE_FAILED_INTERNAL_ERROR;
@@ -3451,14 +3452,14 @@
}
}
- private static void enforceDeclaredAsUsedAndRuntimePermission(PackageParser.Package pkg,
+ private static void enforceDeclaredAsUsedAndRuntimeOrDevelopmentPermission(PackageParser.Package pkg,
BasePermission bp) {
int index = pkg.requestedPermissions.indexOf(bp.name);
if (index == -1) {
throw new SecurityException("Package " + pkg.packageName
+ " has not requested permission " + bp.name);
}
- if (!bp.isRuntime()) {
+ if (!bp.isRuntime() && !bp.isDevelopment()) {
throw new SecurityException("Permission " + bp.name
+ " is not a changeable permission type");
}
@@ -3492,7 +3493,7 @@
throw new IllegalArgumentException("Unknown permission: " + name);
}
- enforceDeclaredAsUsedAndRuntimePermission(pkg, bp);
+ enforceDeclaredAsUsedAndRuntimeOrDevelopmentPermission(pkg, bp);
uid = UserHandle.getUid(userId, pkg.applicationInfo.uid);
sb = (SettingBase) pkg.mExtras;
@@ -3508,6 +3509,16 @@
+ name + " for package: " + packageName);
}
+ if (bp.isDevelopment()) {
+ // Development permissions must be handled specially, since they are not
+ // normal runtime permissions. For now they apply to all users.
+ if (permissionsState.grantInstallPermission(bp) !=
+ PermissionsState.PERMISSION_OPERATION_FAILURE) {
+ scheduleWriteSettingsLocked();
+ }
+ return;
+ }
+
final int result = permissionsState.grantRuntimePermission(bp, userId);
switch (result) {
case PermissionsState.PERMISSION_OPERATION_FAILURE: {
@@ -3576,7 +3587,7 @@
throw new IllegalArgumentException("Unknown permission: " + name);
}
- enforceDeclaredAsUsedAndRuntimePermission(pkg, bp);
+ enforceDeclaredAsUsedAndRuntimeOrDevelopmentPermission(pkg, bp);
SettingBase sb = (SettingBase) pkg.mExtras;
if (sb == null) {
@@ -3591,6 +3602,16 @@
+ name + " for package: " + packageName);
}
+ if (bp.isDevelopment()) {
+ // Development permissions must be handled specially, since they are not
+ // normal runtime permissions. For now they apply to all users.
+ if (permissionsState.revokeInstallPermission(bp) !=
+ PermissionsState.PERMISSION_OPERATION_FAILURE) {
+ scheduleWriteSettingsLocked();
+ }
+ return;
+ }
+
if (permissionsState.revokeRuntimePermission(bp, userId) ==
PermissionsState.PERMISSION_OPERATION_FAILURE) {
return;
@@ -3818,21 +3839,6 @@
return (flags & PackageManager.FLAG_PERMISSION_USER_SET) != 0;
}
- void grantInstallPermissionLPw(String permission, PackageParser.Package pkg) {
- BasePermission bp = mSettings.mPermissions.get(permission);
- if (bp == null) {
- throw new SecurityException("Missing " + permission + " permission");
- }
-
- SettingBase sb = (SettingBase) pkg.mExtras;
- PermissionsState permissionsState = sb.getPermissionsState();
-
- if (permissionsState.grantInstallPermission(bp) !=
- PermissionsState.PERMISSION_OPERATION_FAILURE) {
- scheduleWriteSettingsLocked();
- }
- }
-
@Override
public void addOnPermissionsChangeListener(IOnPermissionsChangeListener listener) {
mContext.enforceCallingOrSelfPermission(
@@ -4720,6 +4726,7 @@
ArrayList<ResolveInfo> result = new ArrayList<ResolveInfo>();
ArrayList<ResolveInfo> alwaysList = new ArrayList<ResolveInfo>();
ArrayList<ResolveInfo> undefinedList = new ArrayList<ResolveInfo>();
+ ArrayList<ResolveInfo> alwaysAskList = new ArrayList<ResolveInfo>();
ArrayList<ResolveInfo> neverList = new ArrayList<ResolveInfo>();
ArrayList<ResolveInfo> matchAllList = new ArrayList<ResolveInfo>();
@@ -4756,6 +4763,11 @@
Slog.i(TAG, " + never: " + info.activityInfo.packageName);
}
neverList.add(info);
+ } else if (status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK) {
+ if (DEBUG_DOMAIN_VERIFICATION) {
+ Slog.i(TAG, " + always-ask: " + info.activityInfo.packageName);
+ }
+ alwaysAskList.add(info);
} else if (status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED ||
status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK) {
if (DEBUG_DOMAIN_VERIFICATION) {
@@ -4765,6 +4777,10 @@
}
}
}
+
+ // We'll want to include browser possibilities in a few cases
+ boolean includeBrowser = false;
+
// First try to add the "always" resolution(s) for the current user, if any
if (alwaysList.size() > 0) {
result.addAll(alwaysList);
@@ -4773,7 +4789,7 @@
== INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS) {
result.add(xpDomainInfo.resolveInfo);
} else {
- // Add all undefined Apps as we want them to appear in the Disambiguation dialog.
+ // Add all undefined apps as we want them to appear in the disambiguation dialog.
result.addAll(undefinedList);
if (xpDomainInfo != null && (
xpDomainInfo.bestDomainVerificationStatus
@@ -4782,7 +4798,25 @@
== INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK)) {
result.add(xpDomainInfo.resolveInfo);
}
- // Also add Browsers (all of them or only the default one)
+ includeBrowser = true;
+ }
+
+ // The presence of any 'always ask' alternatives means we'll also offer browsers.
+ // If there were 'always' entries their preferred order has been set, so we also
+ // back that off to make the alternatives equivalent
+ if (alwaysAskList.size() > 0) {
+ for (ResolveInfo i : result) {
+ i.preferredOrder = 0;
+ }
+ result.addAll(alwaysAskList);
+ includeBrowser = true;
+ }
+
+ if (includeBrowser) {
+ // Also add browsers (all of them or only the default one)
+ if (DEBUG_DOMAIN_VERIFICATION) {
+ Slog.v(TAG, " ...including browsers in candidate set");
+ }
if ((matchFlags & MATCH_ALL) != 0) {
result.addAll(matchAllList);
} else {
@@ -14876,6 +14910,7 @@
pw.println(" version: print database version info");
pw.println(" write: write current settings now");
pw.println(" installs: details about install sessions");
+ pw.println(" check-permission <permission> <package> [<user>]: does pkg hold perm?");
pw.println(" <package.name>: info about given package");
return;
} else if ("--checkin".equals(opt)) {
@@ -14897,6 +14932,31 @@
// When dumping a single package, we always dump all of its
// filter information since the amount of data will be reasonable.
dumpState.setOptionEnabled(DumpState.OPTION_SHOW_FILTERS);
+ } else if ("check-permission".equals(cmd)) {
+ if (opti >= args.length) {
+ pw.println("Error: check-permission missing permission argument");
+ return;
+ }
+ String perm = args[opti];
+ opti++;
+ if (opti >= args.length) {
+ pw.println("Error: check-permission missing package argument");
+ return;
+ }
+ String pkg = args[opti];
+ opti++;
+ int user = UserHandle.getUserId(Binder.getCallingUid());
+ if (opti < args.length) {
+ try {
+ user = Integer.parseInt(args[opti]);
+ } catch (NumberFormatException e) {
+ pw.println("Error: check-permission user argument is not a number: "
+ + args[opti]);
+ return;
+ }
+ }
+ pw.println(checkPermission(perm, pkg, user));
+ return;
} else if ("l".equals(cmd) || "libraries".equals(cmd)) {
dumpState.setDump(DumpState.DUMP_LIBS);
} else if ("f".equals(cmd) || "features".equals(cmd)) {
diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java
index bd7ec31..943e649 100644
--- a/services/core/java/com/android/server/pm/Settings.java
+++ b/services/core/java/com/android/server/pm/Settings.java
@@ -3952,7 +3952,7 @@
void dumpPackageLPr(PrintWriter pw, String prefix, String checkinTag,
ArraySet<String> permissionNames, PackageSetting ps, SimpleDateFormat sdf,
- Date date, List<UserInfo> users) {
+ Date date, List<UserInfo> users, boolean dumpAll) {
if (checkinTag != null) {
pw.print(checkinTag);
pw.print(",");
@@ -4154,7 +4154,7 @@
pw.print(", COSTS_MONEY");
}
if ((perm.info.flags&PermissionInfo.FLAG_HIDDEN) != 0) {
- pw.print(", COSTS_HIDDEN");
+ pw.print(", HIDDEN");
}
if ((perm.info.flags&PermissionInfo.FLAG_INSTALLED) != 0) {
pw.print(", INSTALLED");
@@ -4163,7 +4163,21 @@
}
}
- if (ps.sharedUser == null || permissionNames != null) {
+ if ((permissionNames != null || dumpAll) && ps.pkg.requestedPermissions != null
+ && ps.pkg.requestedPermissions.size() > 0) {
+ final ArrayList<String> perms = ps.pkg.requestedPermissions;
+ pw.print(prefix); pw.println(" requested permissions:");
+ for (int i=0; i<perms.size(); i++) {
+ String perm = perms.get(i);
+ if (permissionNames != null
+ && !permissionNames.contains(perm)) {
+ continue;
+ }
+ pw.print(prefix); pw.print(" "); pw.println(perm);
+ }
+ }
+
+ if (ps.sharedUser == null || permissionNames != null || dumpAll) {
PermissionsState permissionsState = ps.getPermissionsState();
dumpInstallPermissionsLPr(pw, prefix + " ", permissionNames, permissionsState);
}
@@ -4190,7 +4204,7 @@
PermissionsState permissionsState = ps.getPermissionsState();
dumpGidsLPr(pw, prefix + " ", permissionsState.computeGids(user.id));
dumpRuntimePermissionsLPr(pw, prefix + " ", permissionNames, permissionsState
- .getRuntimePermissionStates(user.id));
+ .getRuntimePermissionStates(user.id), dumpAll);
}
if (permissionNames == null) {
@@ -4238,11 +4252,12 @@
pw.println("Packages:");
printedSomething = true;
}
- dumpPackageLPr(pw, " ", checkin ? "pkg" : null, permissionNames, ps, sdf, date, users);
+ dumpPackageLPr(pw, " ", checkin ? "pkg" : null, permissionNames, ps, sdf, date, users,
+ packageName != null);
}
printedSomething = false;
- if (!checkin && mRenamedPackages.size() > 0 && permissionNames == null) {
+ if (mRenamedPackages.size() > 0 && permissionNames == null) {
for (final Map.Entry<String, String> e : mRenamedPackages.entrySet()) {
if (packageName != null && !packageName.equals(e.getKey())
&& !packageName.equals(e.getValue())) {
@@ -4279,7 +4294,7 @@
printedSomething = true;
}
dumpPackageLPr(pw, " ", checkin ? "dis" : null, permissionNames, ps, sdf, date,
- users);
+ users, packageName != null);
}
}
}
@@ -4364,7 +4379,8 @@
if (!ArrayUtils.isEmpty(gids) || !permissions.isEmpty()) {
pw.print(prefix); pw.print("User "); pw.print(userId); pw.println(": ");
dumpGidsLPr(pw, prefix + " ", gids);
- dumpRuntimePermissionsLPr(pw, prefix + " ", permissionNames, permissions);
+ dumpRuntimePermissionsLPr(pw, prefix + " ", permissionNames, permissions,
+ packageName != null);
}
}
} else {
@@ -4410,8 +4426,8 @@
}
void dumpRuntimePermissionsLPr(PrintWriter pw, String prefix, ArraySet<String> permissionNames,
- List<PermissionState> permissionStates) {
- if (!permissionStates.isEmpty()) {
+ List<PermissionState> permissionStates, boolean dumpAll) {
+ if (!permissionStates.isEmpty() || dumpAll) {
pw.print(prefix); pw.println("runtime permissions:");
for (PermissionState permissionState : permissionStates) {
if (permissionNames != null
diff --git a/services/core/java/com/android/server/wm/AppTransition.java b/services/core/java/com/android/server/wm/AppTransition.java
index 7bd0635..a2307f9 100644
--- a/services/core/java/com/android/server/wm/AppTransition.java
+++ b/services/core/java/com/android/server/wm/AppTransition.java
@@ -16,6 +16,7 @@
package com.android.server.wm;
+import android.annotation.Nullable;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Bitmap;
@@ -651,7 +652,7 @@
* when a thumbnail is specified with the activity options.
*/
Animation createThumbnailAspectScaleAnimationLocked(int appWidth, int appHeight,
- int deviceWidth, int transit) {
+ int deviceWidth) {
Animation a;
final int thumbWidthI = mNextAppTransitionThumbnail.getWidth();
final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
@@ -659,7 +660,6 @@
final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
float scaleW = deviceWidth / thumbWidth;
- float unscaledWidth = deviceWidth;
float unscaledHeight = thumbHeight * scaleW;
float unscaledStartY = mNextAppTransitionStartY - (unscaledHeight - thumbHeight) / 2f;
if (mNextAppTransitionScaleUp) {
@@ -716,7 +716,7 @@
*/
Animation createAspectScaledThumbnailEnterExitAnimationLocked(int thumbTransitState,
int appWidth, int appHeight, int orientation, int transit, Rect containingFrame,
- Rect contentInsets) {
+ Rect contentInsets, @Nullable Rect surfaceInsets, boolean resizedWindow) {
Animation a;
final int thumbWidthI = mNextAppTransitionStartWidth;
final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
@@ -729,40 +729,45 @@
switch (thumbTransitState) {
case THUMBNAIL_TRANSITION_ENTER_SCALE_UP: {
- // App window scaling up to become full screen
- if (orientation == Configuration.ORIENTATION_PORTRAIT) {
- // In portrait, we scale the width and clip to the top/left square
- scale = thumbWidth / appWidth;
- scaledTopDecor = (int) (scale * contentInsets.top);
- int unscaledThumbHeight = (int) (thumbHeight / scale);
- mTmpFromClipRect.set(containingFrame);
- mTmpFromClipRect.bottom = (mTmpFromClipRect.top + unscaledThumbHeight);
- mTmpToClipRect.set(containingFrame);
+ if (resizedWindow) {
+ a = createAspectScaledThumbnailEnterNonFullscreenAnimationLocked(
+ containingFrame, surfaceInsets);
} else {
- // In landscape, we scale the height and clip to the top/left square
- scale = thumbHeight / (appHeight - contentInsets.top);
- scaledTopDecor = (int) (scale * contentInsets.top);
- int unscaledThumbWidth = (int) (thumbWidth / scale);
- mTmpFromClipRect.set(containingFrame);
- mTmpFromClipRect.right = (mTmpFromClipRect.left + unscaledThumbWidth);
- mTmpToClipRect.set(containingFrame);
+ // App window scaling up to become full screen
+ if (orientation == Configuration.ORIENTATION_PORTRAIT) {
+ // In portrait, we scale the width and clip to the top/left square
+ scale = thumbWidth / appWidth;
+ scaledTopDecor = (int) (scale * contentInsets.top);
+ int unscaledThumbHeight = (int) (thumbHeight / scale);
+ mTmpFromClipRect.set(containingFrame);
+ mTmpFromClipRect.bottom = (mTmpFromClipRect.top + unscaledThumbHeight);
+ mTmpToClipRect.set(containingFrame);
+ } else {
+ // In landscape, we scale the height and clip to the top/left square
+ scale = thumbHeight / (appHeight - contentInsets.top);
+ scaledTopDecor = (int) (scale * contentInsets.top);
+ int unscaledThumbWidth = (int) (thumbWidth / scale);
+ mTmpFromClipRect.set(containingFrame);
+ mTmpFromClipRect.right = (mTmpFromClipRect.left + unscaledThumbWidth);
+ mTmpToClipRect.set(containingFrame);
+ }
+ // exclude top screen decor (status bar) region from the source clip.
+ mTmpFromClipRect.top = contentInsets.top;
+
+ mNextAppTransitionInsets.set(contentInsets);
+
+ Animation scaleAnim = new ScaleAnimation(scale, 1, scale, 1,
+ computePivot(mNextAppTransitionStartX, scale),
+ computePivot(mNextAppTransitionStartY, scale));
+ Animation clipAnim = new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect);
+ Animation translateAnim = new TranslateAnimation(0, 0, -scaledTopDecor, 0);
+
+ AnimationSet set = new AnimationSet(true);
+ set.addAnimation(clipAnim);
+ set.addAnimation(scaleAnim);
+ set.addAnimation(translateAnim);
+ a = set;
}
- // exclude top screen decor (status bar) region from the source clip.
- mTmpFromClipRect.top = contentInsets.top;
-
- mNextAppTransitionInsets.set(contentInsets);
-
- Animation scaleAnim = new ScaleAnimation(scale, 1, scale, 1,
- computePivot(mNextAppTransitionStartX, scale),
- computePivot(mNextAppTransitionStartY, scale));
- Animation clipAnim = new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect);
- Animation translateAnim = new TranslateAnimation(0, 0, -scaledTopDecor, 0);
-
- AnimationSet set = new AnimationSet(true);
- set.addAnimation(clipAnim);
- set.addAnimation(scaleAnim);
- set.addAnimation(translateAnim);
- a = set;
break;
}
case THUMBNAIL_TRANSITION_EXIT_SCALE_UP: {
@@ -836,6 +841,31 @@
mTouchResponseInterpolator);
}
+ private Animation createAspectScaledThumbnailEnterNonFullscreenAnimationLocked(
+ Rect containingFrame, @Nullable Rect surfaceInsets) {
+ float width = containingFrame.width();
+ float height = containingFrame.height();
+ float scaleWidth = mNextAppTransitionStartWidth / width;
+ float scaleHeight = mNextAppTransitionStartHeight / height;
+ AnimationSet set = new AnimationSet(true);
+ int surfaceInsetsHorizontal = surfaceInsets == null
+ ? 0 : surfaceInsets.left + surfaceInsets.right;
+ int surfaceInsetsVertical = surfaceInsets == null
+ ? 0 : surfaceInsets.top + surfaceInsets.bottom;
+ // We want the scaling to happen from the center of the surface. In order to achieve that,
+ // we need to account for surface insets that will be used to enlarge the surface.
+ ScaleAnimation scale = new ScaleAnimation(scaleWidth, 1, scaleHeight, 1,
+ (width + surfaceInsetsHorizontal) / 2, (height + surfaceInsetsVertical) / 2);
+ int fromX = mNextAppTransitionStartX + mNextAppTransitionStartWidth / 2
+ - (containingFrame.left + containingFrame.width() / 2);
+ int fromY = mNextAppTransitionStartY + mNextAppTransitionStartHeight / 2
+ - (containingFrame.top + containingFrame.height() / 2);
+ TranslateAnimation translation = new TranslateAnimation(fromX, 0, fromY, 0);
+ set.addAnimation(scale);
+ set.addAnimation(translation);
+ return set;
+ }
+
/**
* This animation runs for the thumbnail that gets cross faded with the enter/exit activity
* when a thumbnail is specified with the activity options.
@@ -881,7 +911,7 @@
* leaving, and the activity that is entering.
*/
Animation createThumbnailEnterExitAnimationLocked(int thumbTransitState, int appWidth,
- int appHeight, int transit) {
+ int appHeight, int transit) {
Animation a;
final int thumbWidthI = mNextAppTransitionThumbnail.getWidth();
final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
@@ -954,7 +984,8 @@
Animation loadAnimation(WindowManager.LayoutParams lp, int transit, boolean enter,
int appWidth, int appHeight, int orientation, Rect containingFrame, Rect contentInsets,
- Rect appFrame, boolean isVoiceInteraction) {
+ @Nullable Rect surfaceInsets, Rect appFrame, boolean isVoiceInteraction,
+ boolean resizedWindow) {
Animation a;
if (isVoiceInteraction && (transit == TRANSIT_ACTIVITY_OPEN
|| transit == TRANSIT_TASK_OPEN
@@ -1023,8 +1054,8 @@
mNextAppTransitionScaleUp =
(mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP);
a = createAspectScaledThumbnailEnterExitAnimationLocked(
- getThumbnailTransitionState(enter), appWidth, appHeight, orientation,
- transit, containingFrame, contentInsets);
+ getThumbnailTransitionState(enter), appWidth, appHeight, orientation, transit,
+ containingFrame, contentInsets, surfaceInsets, resizedWindow);
if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
String animName = mNextAppTransitionScaleUp ?
"ANIM_THUMBNAIL_ASPECT_SCALE_UP" : "ANIM_THUMBNAIL_ASPECT_SCALE_DOWN";
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index 3ff5be1..1eddb04 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -19,6 +19,7 @@
import static com.android.server.wm.WindowManagerService.TAG;
import static com.android.server.wm.WindowManagerService.DEBUG_RESIZE;
import static com.android.server.wm.WindowManagerService.DEBUG_STACK;
+import static android.app.ActivityManager.FREEFORM_WORKSPACE_STACK_ID;
import android.content.res.Configuration;
import android.graphics.Rect;
@@ -176,10 +177,12 @@
bounds = mTmpRect;
mFullscreen = true;
} else {
- // ensure bounds are entirely within the display rect
- if (!bounds.intersect(mTmpRect)) {
- // Can't set bounds outside the containing display...Sorry!
- return false;
+ if (mStack.mStackId != FREEFORM_WORKSPACE_STACK_ID || bounds.isEmpty()) {
+ // ensure bounds are entirely within the display rect
+ if (!bounds.intersect(mTmpRect)) {
+ // Can't set bounds outside the containing display...Sorry!
+ return false;
+ }
}
mFullscreen = mTmpRect.equals(bounds);
}
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 9af5e14..5ec2137 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -3448,8 +3448,8 @@
}
}
- private boolean applyAnimationLocked(AppWindowToken atoken,
- WindowManager.LayoutParams lp, int transit, boolean enter, boolean isVoiceInteraction) {
+ private boolean applyAnimationLocked(AppWindowToken atoken, WindowManager.LayoutParams lp,
+ int transit, boolean enter, boolean isVoiceInteraction) {
// Only apply an animation if the display isn't frozen. If it is
// frozen, there is no reason to animate and it can cause strange
// artifacts when we unfreeze the display if some different animation
@@ -3466,24 +3466,36 @@
Rect containingFrame = new Rect(0, 0, width, height);
Rect contentInsets = new Rect();
Rect appFrame = new Rect(0, 0, width, height);
- if (win != null && win.isFullscreen(width, height)) {
- // For fullscreen windows use the window frames and insets to set the thumbnail
- // clip. For none-fullscreen windows we use the app display region so the clip
- // isn't affected by the window insets.
+ Rect surfaceInsets = null;
+ final boolean fullscreen = win != null && win.isFullscreen(width, height);
+ // Dialog activities have windows with containing frame being very large, but not
+ // exactly fullscreen and much smaller mFrame. We use this distinction to identify
+ // dialog activities.
+ final boolean dialogWindow = win != null && !win.mContainingFrame.equals(win.mFrame);
+ if (win != null) {
containingFrame.set(win.mContainingFrame);
- contentInsets.set(win.mContentInsets);
- appFrame.set(win.mFrame);
+ surfaceInsets = win.getAttrs().surfaceInsets;
+ if (fullscreen) {
+ // For fullscreen windows use the window frames and insets to set the thumbnail
+ // clip. For none-fullscreen windows we use the app display region so the clip
+ // isn't affected by the window insets.
+ contentInsets.set(win.mContentInsets);
+ appFrame.set(win.mFrame);
+ }
}
+ final int containingWidth = containingFrame.width();
+ final int containingHeight = containingFrame.height();
if (atoken.mLaunchTaskBehind) {
// Differentiate the two animations. This one which is briefly on the screen
// gets the !enter animation, and the other activity which remains on the
// screen gets the enter animation. Both appear in the mOpeningApps set.
enter = false;
}
- Animation a = mAppTransition.loadAnimation(lp, transit, enter, width, height,
- mCurConfiguration.orientation, containingFrame, contentInsets, appFrame,
- isVoiceInteraction);
+ final boolean resizedWindow = !fullscreen && !dialogWindow;
+ Animation a = mAppTransition.loadAnimation(lp, transit, enter, containingWidth,
+ containingHeight, mCurConfiguration.orientation, containingFrame, contentInsets,
+ surfaceInsets, appFrame, isVoiceInteraction, resizedWindow);
if (a != null) {
if (DEBUG_ANIM) {
RuntimeException e = null;
@@ -3493,7 +3505,7 @@
}
Slog.v(TAG, "Loaded animation " + a + " for " + atoken, e);
}
- atoken.mAppAnimator.setAnimation(a, width, height,
+ atoken.mAppAnimator.setAnimation(a, containingWidth, containingHeight,
mAppTransition.canSkipFirstFrame());
}
} else {
@@ -9533,7 +9545,7 @@
// open/close animation (only on the way down)
anim = mAppTransition.createThumbnailAspectScaleAnimationLocked(
displayInfo.appWidth, displayInfo.appHeight,
- displayInfo.logicalWidth, transit);
+ displayInfo.logicalWidth);
openingAppAnimator.thumbnailForceAboveLayer = Math.max(topOpeningLayer,
topClosingLayer);
openingAppAnimator.deferThumbnailDestruction =
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index 48f2a9d..5d33cbd 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -1090,7 +1090,6 @@
if (selfTransformation) {
tmpMatrix.postConcat(mTransformation.getMatrix());
}
- tmpMatrix.postTranslate(frame.left + mWin.mXOffset, frame.top + mWin.mYOffset);
if (attachedTransformation != null) {
tmpMatrix.postConcat(attachedTransformation.getMatrix());
}
@@ -1100,6 +1099,10 @@
if (screenAnimation) {
tmpMatrix.postConcat(screenRotationAnimation.getEnterTransformation().getMatrix());
}
+ // The translation that applies the position of the window needs to be applied at the
+ // end in case that other translations include scaling. Otherwise the scaling will
+ // affect this translation.
+ tmpMatrix.postTranslate(frame.left + mWin.mXOffset, frame.top + mWin.mYOffset);
//TODO (multidisplay): Magnification is supported only for the default display.
if (mService.mAccessibilityController != null && displayId == Display.DEFAULT_DISPLAY) {
diff --git a/telecomm/java/android/telecom/DefaultDialerManager.java b/telecomm/java/android/telecom/DefaultDialerManager.java
index 3d49308..5852b8e 100644
--- a/telecomm/java/android/telecom/DefaultDialerManager.java
+++ b/telecomm/java/android/telecom/DefaultDialerManager.java
@@ -97,7 +97,7 @@
* @hide
* */
public static String getDefaultDialerApplication(Context context) {
- return getDefaultDialerApplication(context, ActivityManager.getCurrentUser());
+ return getDefaultDialerApplication(context, context.getUserId());
}
/**
diff --git a/tests/VoiceInteraction/AndroidManifest.xml b/tests/VoiceInteraction/AndroidManifest.xml
index 36d5d98..fe17c6e 100644
--- a/tests/VoiceInteraction/AndroidManifest.xml
+++ b/tests/VoiceInteraction/AndroidManifest.xml
@@ -2,6 +2,7 @@
package="com.android.test.voiceinteraction">
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" />
+ <uses-permission android:name="android.permission.READ_LOGS" />
<application>
<activity android:name="VoiceInteractionMain" android:label="Voice Interaction"
diff --git a/tools/aapt2/XmlDom.cpp b/tools/aapt2/XmlDom.cpp
index 763029f..b8b2d12 100644
--- a/tools/aapt2/XmlDom.cpp
+++ b/tools/aapt2/XmlDom.cpp
@@ -312,7 +312,7 @@
}
}
}
- return std::move(root);
+ return root;
}
Node::Node(NodeType type) : type(type), parent(nullptr), lineNumber(0), columnNumber(0) {