Merge "Make ChooserActivity grid items focusable"
diff --git a/api/current.txt b/api/current.txt
index 47a5242..5361d0a 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -8088,6 +8088,7 @@
field public static final int BIND_ALLOW_OOM_MANAGEMENT = 16; // 0x10
field public static final int BIND_AUTO_CREATE = 1; // 0x1
field public static final int BIND_DEBUG_UNBIND = 2; // 0x2
+ field public static final int BIND_EXTERNAL_SERVICE = -2147483648; // 0x80000000
field public static final int BIND_IMPORTANT = 64; // 0x40
field public static final int BIND_NOT_FOREGROUND = 4; // 0x4
field public static final int BIND_WAIVE_PRIORITY = 32; // 0x20
@@ -9943,6 +9944,7 @@
method public int describeContents();
method public void dump(android.util.Printer, java.lang.String);
field public static final android.os.Parcelable.Creator<android.content.pm.ServiceInfo> CREATOR;
+ field public static final int FLAG_EXTERNAL_SERVICE = 4; // 0x4
field public static final int FLAG_ISOLATED_PROCESS = 2; // 0x2
field public static final int FLAG_SINGLE_USER = 1073741824; // 0x40000000
field public static final int FLAG_STOP_WITH_TASK = 1; // 0x1
@@ -32110,6 +32112,7 @@
field public static final java.lang.String ACTION_DISPLAY_SETTINGS = "android.settings.DISPLAY_SETTINGS";
field public static final java.lang.String ACTION_DREAM_SETTINGS = "android.settings.DREAM_SETTINGS";
field public static final java.lang.String ACTION_HOME_SETTINGS = "android.settings.HOME_SETTINGS";
+ field public static final java.lang.String ACTION_IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS = "android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS";
field public static final java.lang.String ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS = "android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS";
field public static final java.lang.String ACTION_INPUT_METHOD_SETTINGS = "android.settings.INPUT_METHOD_SETTINGS";
field public static final java.lang.String ACTION_INPUT_METHOD_SUBTYPE_SETTINGS = "android.settings.INPUT_METHOD_SUBTYPE_SETTINGS";
@@ -50205,13 +50208,16 @@
method public static java.lang.Class<?> forName(java.lang.String, boolean, java.lang.ClassLoader) throws java.lang.ClassNotFoundException;
method public A getAnnotation(java.lang.Class<A>);
method public java.lang.annotation.Annotation[] getAnnotations();
+ method public T[] getAnnotationsByType(java.lang.Class<T>);
method public java.lang.String getCanonicalName();
method public java.lang.ClassLoader getClassLoader();
method public java.lang.Class<?>[] getClasses();
method public java.lang.Class<?> getComponentType();
method public java.lang.reflect.Constructor<T> getConstructor(java.lang.Class<?>...) throws java.lang.NoSuchMethodException, java.lang.SecurityException;
method public java.lang.reflect.Constructor<?>[] getConstructors() throws java.lang.SecurityException;
+ method public T getDeclaredAnnotation(java.lang.Class<T>);
method public java.lang.annotation.Annotation[] getDeclaredAnnotations();
+ method public T[] getDeclaredAnnotationsByType(java.lang.Class<T>);
method public java.lang.Class<?>[] getDeclaredClasses();
method public java.lang.reflect.Constructor<T> getDeclaredConstructor(java.lang.Class<?>...) throws java.lang.NoSuchMethodException, java.lang.SecurityException;
method public java.lang.reflect.Constructor<?>[] getDeclaredConstructors() throws java.lang.SecurityException;
@@ -50742,7 +50748,10 @@
public class Package implements java.lang.reflect.AnnotatedElement {
method public A getAnnotation(java.lang.Class<A>);
method public java.lang.annotation.Annotation[] getAnnotations();
+ method public T[] getAnnotationsByType(java.lang.Class<T>);
+ method public java.lang.annotation.Annotation getDeclaredAnnotation(java.lang.Class<T>);
method public java.lang.annotation.Annotation[] getDeclaredAnnotations();
+ method public T[] getDeclaredAnnotationsByType(java.lang.Class<T>);
method public java.lang.String getImplementationTitle();
method public java.lang.String getImplementationVendor();
method public java.lang.String getImplementationVersion();
@@ -51436,7 +51445,10 @@
ctor protected AccessibleObject();
method public T getAnnotation(java.lang.Class<T>);
method public java.lang.annotation.Annotation[] getAnnotations();
+ method public T[] getAnnotationsByType(java.lang.Class<T>);
+ method public java.lang.annotation.Annotation getDeclaredAnnotation(java.lang.Class<T>);
method public java.lang.annotation.Annotation[] getDeclaredAnnotations();
+ method public T[] getDeclaredAnnotationsByType(java.lang.Class<T>);
method public boolean isAccessible();
method public boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation>);
method public static void setAccessible(java.lang.reflect.AccessibleObject[], boolean) throws java.lang.SecurityException;
@@ -51446,7 +51458,10 @@
public abstract interface AnnotatedElement {
method public abstract T getAnnotation(java.lang.Class<T>);
method public abstract java.lang.annotation.Annotation[] getAnnotations();
+ method public abstract T[] getAnnotationsByType(java.lang.Class<T>);
+ method public abstract java.lang.annotation.Annotation getDeclaredAnnotation(java.lang.Class<T>);
method public abstract java.lang.annotation.Annotation[] getDeclaredAnnotations();
+ method public abstract T[] getDeclaredAnnotationsByType(java.lang.Class<T>);
method public abstract boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation>);
}
diff --git a/api/system-current.txt b/api/system-current.txt
index edcd9e6..a43e3f6 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -10346,6 +10346,7 @@
method public int describeContents();
method public void dump(android.util.Printer, java.lang.String);
field public static final android.os.Parcelable.Creator<android.content.pm.ServiceInfo> CREATOR;
+ field public static final int FLAG_EXTERNAL_SERVICE = 4; // 0x4
field public static final int FLAG_ISOLATED_PROCESS = 2; // 0x2
field public static final int FLAG_SINGLE_USER = 1073741824; // 0x40000000
field public static final int FLAG_STOP_WITH_TASK = 1; // 0x1
@@ -34520,6 +34521,7 @@
field public static final java.lang.String ACTION_DISPLAY_SETTINGS = "android.settings.DISPLAY_SETTINGS";
field public static final java.lang.String ACTION_DREAM_SETTINGS = "android.settings.DREAM_SETTINGS";
field public static final java.lang.String ACTION_HOME_SETTINGS = "android.settings.HOME_SETTINGS";
+ field public static final java.lang.String ACTION_IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS = "android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS";
field public static final java.lang.String ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS = "android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS";
field public static final java.lang.String ACTION_INPUT_METHOD_SETTINGS = "android.settings.INPUT_METHOD_SETTINGS";
field public static final java.lang.String ACTION_INPUT_METHOD_SUBTYPE_SETTINGS = "android.settings.INPUT_METHOD_SUBTYPE_SETTINGS";
@@ -53190,13 +53192,16 @@
method public static java.lang.Class<?> forName(java.lang.String, boolean, java.lang.ClassLoader) throws java.lang.ClassNotFoundException;
method public A getAnnotation(java.lang.Class<A>);
method public java.lang.annotation.Annotation[] getAnnotations();
+ method public T[] getAnnotationsByType(java.lang.Class<T>);
method public java.lang.String getCanonicalName();
method public java.lang.ClassLoader getClassLoader();
method public java.lang.Class<?>[] getClasses();
method public java.lang.Class<?> getComponentType();
method public java.lang.reflect.Constructor<T> getConstructor(java.lang.Class<?>...) throws java.lang.NoSuchMethodException, java.lang.SecurityException;
method public java.lang.reflect.Constructor<?>[] getConstructors() throws java.lang.SecurityException;
+ method public T getDeclaredAnnotation(java.lang.Class<T>);
method public java.lang.annotation.Annotation[] getDeclaredAnnotations();
+ method public T[] getDeclaredAnnotationsByType(java.lang.Class<T>);
method public java.lang.Class<?>[] getDeclaredClasses();
method public java.lang.reflect.Constructor<T> getDeclaredConstructor(java.lang.Class<?>...) throws java.lang.NoSuchMethodException, java.lang.SecurityException;
method public java.lang.reflect.Constructor<?>[] getDeclaredConstructors() throws java.lang.SecurityException;
@@ -53727,7 +53732,10 @@
public class Package implements java.lang.reflect.AnnotatedElement {
method public A getAnnotation(java.lang.Class<A>);
method public java.lang.annotation.Annotation[] getAnnotations();
+ method public T[] getAnnotationsByType(java.lang.Class<T>);
+ method public java.lang.annotation.Annotation getDeclaredAnnotation(java.lang.Class<T>);
method public java.lang.annotation.Annotation[] getDeclaredAnnotations();
+ method public T[] getDeclaredAnnotationsByType(java.lang.Class<T>);
method public java.lang.String getImplementationTitle();
method public java.lang.String getImplementationVendor();
method public java.lang.String getImplementationVersion();
@@ -54421,7 +54429,10 @@
ctor protected AccessibleObject();
method public T getAnnotation(java.lang.Class<T>);
method public java.lang.annotation.Annotation[] getAnnotations();
+ method public T[] getAnnotationsByType(java.lang.Class<T>);
+ method public java.lang.annotation.Annotation getDeclaredAnnotation(java.lang.Class<T>);
method public java.lang.annotation.Annotation[] getDeclaredAnnotations();
+ method public T[] getDeclaredAnnotationsByType(java.lang.Class<T>);
method public boolean isAccessible();
method public boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation>);
method public static void setAccessible(java.lang.reflect.AccessibleObject[], boolean) throws java.lang.SecurityException;
@@ -54431,7 +54442,10 @@
public abstract interface AnnotatedElement {
method public abstract T getAnnotation(java.lang.Class<T>);
method public abstract java.lang.annotation.Annotation[] getAnnotations();
+ method public abstract T[] getAnnotationsByType(java.lang.Class<T>);
+ method public abstract java.lang.annotation.Annotation getDeclaredAnnotation(java.lang.Class<T>);
method public abstract java.lang.annotation.Annotation[] getDeclaredAnnotations();
+ method public abstract T[] getDeclaredAnnotationsByType(java.lang.Class<T>);
method public abstract boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation>);
}
diff --git a/api/test-current.txt b/api/test-current.txt
index 4dbad61..278a47d 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -8092,6 +8092,7 @@
field public static final int BIND_ALLOW_OOM_MANAGEMENT = 16; // 0x10
field public static final int BIND_AUTO_CREATE = 1; // 0x1
field public static final int BIND_DEBUG_UNBIND = 2; // 0x2
+ field public static final int BIND_EXTERNAL_SERVICE = -2147483648; // 0x80000000
field public static final int BIND_IMPORTANT = 64; // 0x40
field public static final int BIND_NOT_FOREGROUND = 4; // 0x4
field public static final int BIND_WAIVE_PRIORITY = 32; // 0x20
@@ -9951,6 +9952,7 @@
method public int describeContents();
method public void dump(android.util.Printer, java.lang.String);
field public static final android.os.Parcelable.Creator<android.content.pm.ServiceInfo> CREATOR;
+ field public static final int FLAG_EXTERNAL_SERVICE = 4; // 0x4
field public static final int FLAG_ISOLATED_PROCESS = 2; // 0x2
field public static final int FLAG_SINGLE_USER = 1073741824; // 0x40000000
field public static final int FLAG_STOP_WITH_TASK = 1; // 0x1
@@ -32123,6 +32125,7 @@
field public static final java.lang.String ACTION_DISPLAY_SETTINGS = "android.settings.DISPLAY_SETTINGS";
field public static final java.lang.String ACTION_DREAM_SETTINGS = "android.settings.DREAM_SETTINGS";
field public static final java.lang.String ACTION_HOME_SETTINGS = "android.settings.HOME_SETTINGS";
+ field public static final java.lang.String ACTION_IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS = "android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS";
field public static final java.lang.String ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS = "android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS";
field public static final java.lang.String ACTION_INPUT_METHOD_SETTINGS = "android.settings.INPUT_METHOD_SETTINGS";
field public static final java.lang.String ACTION_INPUT_METHOD_SUBTYPE_SETTINGS = "android.settings.INPUT_METHOD_SUBTYPE_SETTINGS";
@@ -50222,13 +50225,16 @@
method public static java.lang.Class<?> forName(java.lang.String, boolean, java.lang.ClassLoader) throws java.lang.ClassNotFoundException;
method public A getAnnotation(java.lang.Class<A>);
method public java.lang.annotation.Annotation[] getAnnotations();
+ method public T[] getAnnotationsByType(java.lang.Class<T>);
method public java.lang.String getCanonicalName();
method public java.lang.ClassLoader getClassLoader();
method public java.lang.Class<?>[] getClasses();
method public java.lang.Class<?> getComponentType();
method public java.lang.reflect.Constructor<T> getConstructor(java.lang.Class<?>...) throws java.lang.NoSuchMethodException, java.lang.SecurityException;
method public java.lang.reflect.Constructor<?>[] getConstructors() throws java.lang.SecurityException;
+ method public T getDeclaredAnnotation(java.lang.Class<T>);
method public java.lang.annotation.Annotation[] getDeclaredAnnotations();
+ method public T[] getDeclaredAnnotationsByType(java.lang.Class<T>);
method public java.lang.Class<?>[] getDeclaredClasses();
method public java.lang.reflect.Constructor<T> getDeclaredConstructor(java.lang.Class<?>...) throws java.lang.NoSuchMethodException, java.lang.SecurityException;
method public java.lang.reflect.Constructor<?>[] getDeclaredConstructors() throws java.lang.SecurityException;
@@ -50759,7 +50765,10 @@
public class Package implements java.lang.reflect.AnnotatedElement {
method public A getAnnotation(java.lang.Class<A>);
method public java.lang.annotation.Annotation[] getAnnotations();
+ method public T[] getAnnotationsByType(java.lang.Class<T>);
+ method public java.lang.annotation.Annotation getDeclaredAnnotation(java.lang.Class<T>);
method public java.lang.annotation.Annotation[] getDeclaredAnnotations();
+ method public T[] getDeclaredAnnotationsByType(java.lang.Class<T>);
method public java.lang.String getImplementationTitle();
method public java.lang.String getImplementationVendor();
method public java.lang.String getImplementationVersion();
@@ -51453,7 +51462,10 @@
ctor protected AccessibleObject();
method public T getAnnotation(java.lang.Class<T>);
method public java.lang.annotation.Annotation[] getAnnotations();
+ method public T[] getAnnotationsByType(java.lang.Class<T>);
+ method public java.lang.annotation.Annotation getDeclaredAnnotation(java.lang.Class<T>);
method public java.lang.annotation.Annotation[] getDeclaredAnnotations();
+ method public T[] getDeclaredAnnotationsByType(java.lang.Class<T>);
method public boolean isAccessible();
method public boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation>);
method public static void setAccessible(java.lang.reflect.AccessibleObject[], boolean) throws java.lang.SecurityException;
@@ -51463,7 +51475,10 @@
public abstract interface AnnotatedElement {
method public abstract T getAnnotation(java.lang.Class<T>);
method public abstract java.lang.annotation.Annotation[] getAnnotations();
+ method public abstract T[] getAnnotationsByType(java.lang.Class<T>);
+ method public abstract java.lang.annotation.Annotation getDeclaredAnnotation(java.lang.Class<T>);
method public abstract java.lang.annotation.Annotation[] getDeclaredAnnotations();
+ method public abstract T[] getDeclaredAnnotationsByType(java.lang.Class<T>);
method public abstract boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation>);
}
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java
index 9d81c43..a74a1ca 100644
--- a/cmds/am/src/com/android/commands/am/Am.java
+++ b/cmds/am/src/com/android/commands/am/Am.java
@@ -1774,18 +1774,33 @@
System.err.println("Error: invalid input bounds");
return;
}
- resizeStack(stackId, bounds, 0, false);
+ resizeStack(stackId, bounds, 0);
}
private void runStackResizeAnimated() throws Exception {
String stackIdStr = nextArgRequired();
int stackId = Integer.valueOf(stackIdStr);
- final Rect bounds = getBounds();
- if (bounds == null) {
- System.err.println("Error: invalid input bounds");
- return;
+ final Rect bounds;
+ if ("null".equals(mArgs.peekNextArg())) {
+ bounds = null;
+ } else {
+ bounds = getBounds();
+ if (bounds == null) {
+ System.err.println("Error: invalid input bounds");
+ return;
+ }
}
- resizeStack(stackId, bounds, 0, true);
+ resizeStackUnchecked(stackId, bounds, 0, true);
+ }
+
+ private void resizeStackUnchecked(int stackId, Rect bounds, int delayMs, boolean animate) {
+ try {
+ mAm.resizeStack(stackId, bounds, false, false, animate);
+ Thread.sleep(delayMs);
+ } catch (RemoteException e) {
+ showError("Error: resizing stack " + e);
+ } catch (InterruptedException e) {
+ }
}
private void runStackResizeDocked() throws Exception {
@@ -1802,20 +1817,13 @@
}
}
- private void resizeStack(int stackId, Rect bounds, int delayMs, boolean animate)
+ private void resizeStack(int stackId, Rect bounds, int delayMs)
throws Exception {
if (bounds == null) {
showError("Error: invalid input bounds");
return;
}
-
- try {
- mAm.resizeStack(stackId, bounds, false, false, animate);
- Thread.sleep(delayMs);
- } catch (RemoteException e) {
- showError("Error: resizing stack " + e);
- } catch (InterruptedException e) {
- }
+ resizeStackUnchecked(stackId, bounds, delayMs, false);
}
private void runStackPositionTask() throws Exception {
@@ -1924,7 +1932,7 @@
maxChange = Math.min(stepSize, currentPoint - minPoint);
currentPoint -= maxChange;
setBoundsSide(bounds, side, currentPoint);
- resizeStack(DOCKED_STACK_ID, bounds, delayMs, false);
+ resizeStack(DOCKED_STACK_ID, bounds, delayMs);
}
System.out.println("Growing docked stack side=" + side);
@@ -1932,7 +1940,7 @@
maxChange = Math.min(stepSize, maxPoint - currentPoint);
currentPoint += maxChange;
setBoundsSide(bounds, side, currentPoint);
- resizeStack(DOCKED_STACK_ID, bounds, delayMs, false);
+ resizeStack(DOCKED_STACK_ID, bounds, delayMs);
}
System.out.println("Back to Original size side=" + side);
@@ -1940,7 +1948,7 @@
maxChange = Math.min(stepSize, currentPoint - startPoint);
currentPoint -= maxChange;
setBoundsSide(bounds, side, currentPoint);
- resizeStack(DOCKED_STACK_ID, bounds, delayMs, false);
+ resizeStack(DOCKED_STACK_ID, bounds, delayMs);
}
}
diff --git a/core/java/android/animation/AnimatorSet.java b/core/java/android/animation/AnimatorSet.java
index 980329f..1ab55dd 100644
--- a/core/java/android/animation/AnimatorSet.java
+++ b/core/java/android/animation/AnimatorSet.java
@@ -1030,20 +1030,6 @@
}
}
- /**
- * @hide
- * TODO: For animatorSet defined in XML, we can use a flag to indicate what the play order
- * if defined (i.e. sequential or together), then we can use the flag instead of calculate
- * dynamically.
- * @return whether all the animators in the set are supposed to play together
- */
- public boolean shouldPlayTogether() {
- updateAnimatorsDuration();
- createDependencyGraph();
- // All the child nodes are set out to play right after the delay animation
- return mRootNode.mChildNodes.size() == mNodes.size() - 1;
- }
-
@Override
public long getTotalDuration() {
updateAnimatorsDuration();
diff --git a/core/java/android/animation/PathKeyframes.java b/core/java/android/animation/PathKeyframes.java
index 8230ac5..2a47b68 100644
--- a/core/java/android/animation/PathKeyframes.java
+++ b/core/java/android/animation/PathKeyframes.java
@@ -231,7 +231,7 @@
}
}
- abstract static class IntKeyframesBase extends SimpleKeyframes implements IntKeyframes {
+ private abstract static class IntKeyframesBase extends SimpleKeyframes implements IntKeyframes {
@Override
public Class getType() {
return Integer.class;
@@ -243,7 +243,7 @@
}
}
- abstract static class FloatKeyframesBase extends SimpleKeyframes
+ private abstract static class FloatKeyframesBase extends SimpleKeyframes
implements FloatKeyframes {
@Override
public Class getType() {
diff --git a/core/java/android/animation/PropertyValuesHolder.java b/core/java/android/animation/PropertyValuesHolder.java
index 6ba5b96..e993cca 100644
--- a/core/java/android/animation/PropertyValuesHolder.java
+++ b/core/java/android/animation/PropertyValuesHolder.java
@@ -21,7 +21,6 @@
import android.util.FloatProperty;
import android.util.IntProperty;
import android.util.Log;
-import android.util.PathParser;
import android.util.Property;
import java.lang.reflect.InvocationTargetException;
@@ -1047,43 +1046,6 @@
return mAnimatedValue;
}
- /**
- * PropertyValuesHolder is Animators use to hold internal animation related data.
- * Therefore, in order to replicate the animation behavior, we need to get data out of
- * PropertyValuesHolder.
- * @hide
- */
- public void getPropertyValues(PropertyValues values) {
- init();
- values.propertyName = mPropertyName;
- values.type = mValueType;
- values.startValue = mKeyframes.getValue(0);
- if (values.startValue instanceof PathParser.PathData) {
- // PathData evaluator returns the same mutable PathData object when query fraction,
- // so we have to make a copy here.
- values.startValue = new PathParser.PathData((PathParser.PathData) values.startValue);
- }
- values.endValue = mKeyframes.getValue(1);
- if (values.endValue instanceof PathParser.PathData) {
- // PathData evaluator returns the same mutable PathData object when query fraction,
- // so we have to make a copy here.
- values.endValue = new PathParser.PathData((PathParser.PathData) values.endValue);
- }
- // TODO: We need a better way to get data out of keyframes.
- if (mKeyframes instanceof PathKeyframes.FloatKeyframesBase
- || mKeyframes instanceof PathKeyframes.IntKeyframesBase) {
- // property values will animate based on external data source (e.g. Path)
- values.dataSource = new PropertyValues.DataSource() {
- @Override
- public Object getValueAtFraction(float fraction) {
- return mKeyframes.getValue(fraction);
- }
- };
- } else {
- values.dataSource = null;
- }
- }
-
@Override
public String toString() {
return mPropertyName + ": " + mKeyframes.toString();
@@ -1639,24 +1601,6 @@
}
};
- /**
- * @hide
- */
- public static class PropertyValues {
- public String propertyName;
- public Class type;
- public Object startValue;
- public Object endValue;
- public DataSource dataSource = null;
- public interface DataSource {
- Object getValueAtFraction(float fraction);
- }
- public String toString() {
- return ("property name: " + propertyName + ", type: " + type + ", startValue: "
- + startValue.toString() + ", endValue: " + endValue.toString());
- }
- }
-
native static private long nGetIntMethod(Class targetClass, String methodName);
native static private long nGetFloatMethod(Class targetClass, String methodName);
native static private long nGetMultipleIntMethod(Class targetClass, String methodName,
diff --git a/core/java/android/app/LoadedApk.java b/core/java/android/app/LoadedApk.java
index 1e22bef..da52c1e 100644
--- a/core/java/android/app/LoadedApk.java
+++ b/core/java/android/app/LoadedApk.java
@@ -382,6 +382,13 @@
libraryPermittedPath += File.pathSeparator +
System.getProperty("java.library.path");
}
+ // DO NOT SHIP: this is a workaround for apps loading native libraries
+ // provided by 3rd party apps using absolute path instead of corresponding
+ // classloader; see http://b/26954419 for example.
+ if (mApplicationInfo.targetSdkVersion <= 23) {
+ libraryPermittedPath += File.pathSeparator + "/data/app";
+ }
+ // -----------------------------------------------------------------------------
final String librarySearchPath = TextUtils.join(File.pathSeparator, libPaths);
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 1247afe..02eb115 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -4109,6 +4109,29 @@
}
/**
+ * Called by the system to check if a specific accessibility service is disabled by admin.
+ *
+ * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
+ * @param packageName Accessibility service package name that needs to be checked.
+ * @param userHandle user id the admin is running as.
+ * @return true if the accessibility service is permitted, otherwise false.
+ *
+ * @hide
+ */
+ public boolean isAccessibilityServicePermittedByAdmin(@NonNull ComponentName admin,
+ @NonNull String packageName, int userHandle) {
+ if (mService != null) {
+ try {
+ return mService.isAccessibilityServicePermittedByAdmin(admin, packageName,
+ userHandle);
+ } catch (RemoteException e) {
+ Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ }
+ }
+ return false;
+ }
+
+ /**
* Returns the list of accessibility services permitted by the device or profiles
* owners of this user.
*
@@ -4188,6 +4211,28 @@
}
/**
+ * Called by the system to check if a specific input method is disabled by admin.
+ *
+ * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
+ * @param packageName Input method package name that needs to be checked.
+ * @param userHandle user id the admin is running as.
+ * @return true if the input method is permitted, otherwise false.
+ *
+ * @hide
+ */
+ public boolean isInputMethodPermittedByAdmin(@NonNull ComponentName admin,
+ @NonNull String packageName, int userHandle) {
+ if (mService != null) {
+ try {
+ return mService.isInputMethodPermittedByAdmin(admin, packageName, userHandle);
+ } catch (RemoteException e) {
+ Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ }
+ }
+ return false;
+ }
+
+ /**
* Returns the list of input methods permitted by the device or profiles
* owners of the current user. (*Not* calling user, due to a limitation in InputMethodManager.)
*
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index b57e1b7..c6a5344 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -174,10 +174,12 @@
boolean setPermittedAccessibilityServices(in ComponentName admin,in List packageList);
List getPermittedAccessibilityServices(in ComponentName admin);
List getPermittedAccessibilityServicesForUser(int userId);
+ boolean isAccessibilityServicePermittedByAdmin(in ComponentName admin, String packageName, int userId);
boolean setPermittedInputMethods(in ComponentName admin,in List packageList);
List getPermittedInputMethods(in ComponentName admin);
List getPermittedInputMethodsForCurrentUser();
+ boolean isInputMethodPermittedByAdmin(in ComponentName admin, String packageName, int userId);
boolean setApplicationHidden(in ComponentName admin, in String packageName, boolean hidden);
boolean isApplicationHidden(in ComponentName admin, in String packageName);
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 622aad9..4918914 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -342,9 +342,7 @@
* {@link android.R.attr#isolatedProcess isolated},
* {@link android.R.attr#externalService external} service. This binds the service into the
* calling application's package, rather than the package in which the service is declared.
- * @hide
*/
- @SystemApi
public static final int BIND_EXTERNAL_SERVICE = 0x80000000;
/**
diff --git a/core/java/android/content/pm/ServiceInfo.java b/core/java/android/content/pm/ServiceInfo.java
index eecf0de..6bd285a 100644
--- a/core/java/android/content/pm/ServiceInfo.java
+++ b/core/java/android/content/pm/ServiceInfo.java
@@ -52,7 +52,6 @@
* Bit in {@link #flags}: If set, the service can be bound and run in the
* calling application's package, rather than the package in which it is
* declared. Set from {@link android.R.attr#externalService} attribute.
- * @hide
*/
public static final int FLAG_EXTERNAL_SERVICE = 0x0004;
diff --git a/core/java/android/os/ShellCommand.java b/core/java/android/os/ShellCommand.java
index 54d1090..fc804e5 100644
--- a/core/java/android/os/ShellCommand.java
+++ b/core/java/android/os/ShellCommand.java
@@ -234,6 +234,16 @@
}
}
+ public String peekNextArg() {
+ if (mCurArgData != null) {
+ return mCurArgData;
+ } else if (mArgPos < mArgs.length) {
+ return mArgs[mArgPos];
+ } else {
+ return null;
+ }
+ }
+
/**
* Return the next argument on the command line, whatever it is; if there are
* no arguments left, throws an IllegalArgumentException to report this to the user.
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 5535eaa..dfc8601 100755
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -670,14 +670,14 @@
"android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS";
/**
- * Activity Action: Ask the user to allow an to ignore battery optimizations (that is,
+ * Activity Action: Ask the user to allow an app to ignore battery optimizations (that is,
* put them on the whitelist of apps shown by
* {@link #ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS}). For an app to use this, it also
* must hold the {@link android.Manifest.permission#REQUEST_IGNORE_BATTERY_OPTIMIZATIONS}
* permission.
* <p><b>Note:</b> most applications should <em>not</em> use this; there are many facilities
* provided by the platform for applications to operate correctly in the various power
- * saving mode. This is only for unusual applications that need to deeply control their own
+ * saving modes. This is only for unusual applications that need to deeply control their own
* execution, at the potential expense of the user's battery life. Note that these applications
* greatly run the risk of showing to the user as high power consumers on their device.</p>
* <p>
@@ -695,6 +695,24 @@
"android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS";
/**
+ * Activity Action: Show screen for controlling which apps can ignore background data
+ * restrictions.
+ * <p>
+ * Input: if the Intent's data URI is set with an application name (using the "package" schema,
+ * like "package:com.my.app"), then when the screen is displayed it will focus on such app. If
+ * the data is not set, it will just open the screen.
+ * <p>
+ * Output: Nothing.
+ * <p>
+ * Applications can also use {@link android.net.ConnectivityManager#getRestrictBackgroundStatus
+ * ConnectivityManager#getRestrictBackgroundStatus()} to determine the status of the background
+ * data restrictions for them.
+ */
+ @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
+ public static final String ACTION_IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS =
+ "android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS";
+
+ /**
* @hide
* Activity Action: Show the "app ops" settings screen.
* <p>
diff --git a/core/java/android/text/BidiFormatter.java b/core/java/android/text/BidiFormatter.java
index a535480..675803c 100644
--- a/core/java/android/text/BidiFormatter.java
+++ b/core/java/android/text/BidiFormatter.java
@@ -293,7 +293,7 @@
* directionality is determined by scanning the end of the string, the overall directionality is
* given explicitly by a heuristic to estimate the {@code str}'s directionality.
*
- * @param str String after which the mark may need to appear.
+ * @param str CharSequence after which the mark may need to appear.
* @param heuristic The text direction heuristic that will be used to estimate the {@code str}'s
* directionality.
* @return LRM for RTL text in LTR context; RLM for LTR text in RTL context;
@@ -301,7 +301,7 @@
*
* @hide
*/
- public String markAfter(String str, TextDirectionHeuristic heuristic) {
+ public String markAfter(CharSequence str, TextDirectionHeuristic heuristic) {
final boolean isRtl = heuristic.isRtl(str, 0, str.length());
// getExitDir() is called only if needed (short-circuit).
if (!mIsRtlContext && (isRtl || getExitDir(str) == DIR_RTL)) {
@@ -322,7 +322,7 @@
* entry directionality is determined by scanning the beginning of the string, the overall
* directionality is given explicitly by a heuristic to estimate the {@code str}'s directionality.
*
- * @param str String before which the mark may need to appear.
+ * @param str CharSequence before which the mark may need to appear.
* @param heuristic The text direction heuristic that will be used to estimate the {@code str}'s
* directionality.
* @return LRM for RTL text in LTR context; RLM for LTR text in RTL context;
@@ -330,7 +330,7 @@
*
* @hide
*/
- public String markBefore(String str, TextDirectionHeuristic heuristic) {
+ public String markBefore(CharSequence str, TextDirectionHeuristic heuristic) {
final boolean isRtl = heuristic.isRtl(str, 0, str.length());
// getEntryDir() is called only if needed (short-circuit).
if (!mIsRtlContext && (isRtl || getEntryDir(str) == DIR_RTL)) {
@@ -350,6 +350,13 @@
* false.
*/
public boolean isRtl(String str) {
+ return isRtl((CharSequence) str);
+ }
+
+ /**
+ * @hide
+ */
+ public boolean isRtl(CharSequence str) {
return mDefaultTextDirectionHeuristic.isRtl(str, 0, str.length());
}
@@ -384,9 +391,16 @@
* {@code null}.
*/
public String unicodeWrap(String str, TextDirectionHeuristic heuristic, boolean isolate) {
+ return unicodeWrap((CharSequence) str, heuristic, isolate).toString();
+ }
+
+ /**
+ * @hide
+ */
+ public CharSequence unicodeWrap(CharSequence str, TextDirectionHeuristic heuristic, boolean isolate) {
if (str == null) return null;
final boolean isRtl = heuristic.isRtl(str, 0, str.length());
- StringBuilder result = new StringBuilder();
+ SpannableStringBuilder result = new SpannableStringBuilder();
if (getStereoReset() && isolate) {
result.append(markBefore(str,
isRtl ? TextDirectionHeuristics.RTL : TextDirectionHeuristics.LTR));
@@ -402,7 +416,7 @@
result.append(markAfter(str,
isRtl ? TextDirectionHeuristics.RTL : TextDirectionHeuristics.LTR));
}
- return result.toString();
+ return result;
}
/**
@@ -419,6 +433,14 @@
}
/**
+ * @hide
+ */
+ public CharSequence unicodeWrap(CharSequence str, TextDirectionHeuristic heuristic) {
+ return unicodeWrap(str, heuristic, true /* isolate */);
+ }
+
+
+ /**
* Operates like {@link #unicodeWrap(String, TextDirectionHeuristic, boolean)}, but uses the
* formatter's default direction estimation algorithm.
*
@@ -432,6 +454,13 @@
}
/**
+ * @hide
+ */
+ public CharSequence unicodeWrap(CharSequence str, boolean isolate) {
+ return unicodeWrap(str, mDefaultTextDirectionHeuristic, isolate);
+ }
+
+ /**
* Operates like {@link #unicodeWrap(String, TextDirectionHeuristic, boolean)}, but uses the
* formatter's default direction estimation algorithm and assumes {@code isolate} is true.
*
@@ -442,6 +471,13 @@
return unicodeWrap(str, mDefaultTextDirectionHeuristic, true /* isolate */);
}
+ /**
+ * @hide
+ */
+ public CharSequence unicodeWrap(CharSequence str) {
+ return unicodeWrap(str, mDefaultTextDirectionHeuristic, true /* isolate */);
+ }
+
private static BidiFormatter getDefaultInstanceFromContext(boolean isRtlContext) {
return isRtlContext ? DEFAULT_RTL_INSTANCE : DEFAULT_LTR_INSTANCE;
}
@@ -477,7 +513,7 @@
*
* @param str the string to check.
*/
- private static int getExitDir(String str) {
+ private static int getExitDir(CharSequence str) {
return new DirectionalityEstimator(str, false /* isHtml */).getExitDir();
}
@@ -494,7 +530,7 @@
*
* @param str the string to check.
*/
- private static int getEntryDir(String str) {
+ private static int getEntryDir(CharSequence str) {
return new DirectionalityEstimator(str, false /* isHtml */).getEntryDir();
}
@@ -532,7 +568,7 @@
/**
* The text to be scanned.
*/
- private final String text;
+ private final CharSequence text;
/**
* Whether the text to be scanned is to be treated as HTML, i.e. skipping over tags and
@@ -565,7 +601,7 @@
* @param isHtml Whether the text to be scanned is to be treated as HTML, i.e. skipping over
* tags and entities.
*/
- DirectionalityEstimator(String text, boolean isHtml) {
+ DirectionalityEstimator(CharSequence text, boolean isHtml) {
this.text = text;
this.isHtml = isHtml;
length = text.length();
@@ -896,4 +932,4 @@
return Character.DIRECTIONALITY_OTHER_NEUTRALS;
}
}
-}
\ No newline at end of file
+}
diff --git a/core/java/android/util/PathParser.java b/core/java/android/util/PathParser.java
index 29a72fd..78d5bcd 100644
--- a/core/java/android/util/PathParser.java
+++ b/core/java/android/util/PathParser.java
@@ -104,7 +104,6 @@
}
super.finalize();
}
-
}
/**
diff --git a/core/java/android/view/NotificationHeaderView.java b/core/java/android/view/NotificationHeaderView.java
index 501c6e9..b9a7421 100644
--- a/core/java/android/view/NotificationHeaderView.java
+++ b/core/java/android/view/NotificationHeaderView.java
@@ -21,7 +21,6 @@
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.ImageView;
-import android.widget.LinearLayout;
import android.widget.RemoteViews;
import android.widget.TextView;
@@ -35,7 +34,7 @@
@RemoteViews.RemoteView
public class NotificationHeaderView extends ViewGroup {
public static final int NO_COLOR = -1;
- private final int mHeaderMinWidth;
+ private final int mChildMinWidth;
private final int mExpandTopPadding;
private final int mContentEndMargin;
private View mAppName;
@@ -46,6 +45,7 @@
private View mIcon;
private TextView mChildCount;
private View mProfileBadge;
+ private View mInfo;
private int mIconColor;
private int mOriginalNotificationColor;
private boolean mGroupHeader;
@@ -66,7 +66,7 @@
public NotificationHeaderView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
- mHeaderMinWidth = getResources().getDimensionPixelSize(
+ mChildMinWidth = getResources().getDimensionPixelSize(
com.android.internal.R.dimen.notification_header_shrink_min_width);
mContentEndMargin = getResources().getDimensionPixelSize(
com.android.internal.R.dimen.notification_content_margin_end);
@@ -82,6 +82,7 @@
mIcon = findViewById(com.android.internal.R.id.icon);
mChildCount = (TextView) findViewById(com.android.internal.R.id.number_of_children);
mProfileBadge = findViewById(com.android.internal.R.id.profile_badge);
+ mInfo = findViewById(com.android.internal.R.id.header_content_info);
}
@Override
@@ -109,14 +110,23 @@
}
if (totalWidth > givenWidth) {
int overFlow = totalWidth - givenWidth;
- // We are overflowing, lets shrink
+ // We are overflowing, lets shrink the info first
+ final int infoWidth = mInfo.getMeasuredWidth();
+ if (mInfo.getVisibility() != GONE && infoWidth > mChildMinWidth) {
+ int newSize = infoWidth - Math.min(infoWidth - mChildMinWidth, overFlow);
+ int childWidthSpec = MeasureSpec.makeMeasureSpec(newSize, MeasureSpec.AT_MOST);
+ mInfo.measure(childWidthSpec, wrapContentHeightSpec);
+ overFlow -= infoWidth - newSize;
+ }
+ // still overflowing, lets shrink the app name now
final int appWidth = mAppName.getMeasuredWidth();
- if (mAppName.getVisibility() != GONE && appWidth > mHeaderMinWidth) {
- int newSize = appWidth - Math.min(appWidth - mHeaderMinWidth, overFlow);
+ if (overFlow > 0 && mAppName.getVisibility() != GONE && appWidth > mChildMinWidth) {
+ int newSize = appWidth - Math.min(appWidth - mChildMinWidth, overFlow);
int childWidthSpec = MeasureSpec.makeMeasureSpec(newSize, MeasureSpec.AT_MOST);
mAppName.measure(childWidthSpec, wrapContentHeightSpec);
overFlow -= appWidth - newSize;
}
+ // still overflowing, finaly we shrink the subtext
if (overFlow > 0 && mSubTextView.getVisibility() != GONE) {
// we're still too big
final int subTextWidth = mSubTextView.getMeasuredWidth();
@@ -124,12 +134,8 @@
int childWidthSpec = MeasureSpec.makeMeasureSpec(newSize, MeasureSpec.AT_MOST);
mSubTextView.measure(childWidthSpec, wrapContentHeightSpec);
}
- totalWidth = givenWidth;
}
- if (mProfileBadge.getVisibility() != View.GONE) {
- totalWidth = givenWidth;
- }
- setMeasuredDimension(totalWidth, givenHeight);
+ setMeasuredDimension(givenWidth, givenHeight);
}
@Override
@@ -275,18 +281,16 @@
mTouchRects.clear();
addRectAroundViewView(mIcon);
addRectAroundViewView(mExpandButton);
- addInBetweenRect();
+ addWidthRect();
mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
}
- private void addInBetweenRect() {
- final Rect r = new Rect();
+ private void addWidthRect() {
+ Rect r = new Rect();
r.top = 0;
r.bottom = (int) (32 * getResources().getDisplayMetrics().density);
- Rect leftRect = mTouchRects.get(0);
- r.left = leftRect.right;
- Rect rightRect = mTouchRects.get(1);
- r.right = rightRect.left;
+ r.left = 0;
+ r.right = getWidth();
mTouchRects.add(r);
}
diff --git a/core/java/android/view/RenderNode.java b/core/java/android/view/RenderNode.java
index 2aace0f..3122c0b 100644
--- a/core/java/android/view/RenderNode.java
+++ b/core/java/android/view/RenderNode.java
@@ -22,7 +22,6 @@
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.Rect;
-import android.graphics.drawable.AnimatedVectorDrawable;
/**
* <p>A display list records a series of graphics related operations and can replay
@@ -136,6 +135,9 @@
private RenderNode(String name, View owningView) {
mNativeRenderNode = nCreate(name);
mOwningView = owningView;
+ if (mOwningView instanceof SurfaceView) {
+ nRequestPositionUpdates(mNativeRenderNode, (SurfaceView) mOwningView);
+ }
}
/**
@@ -772,14 +774,6 @@
mOwningView.mAttachInfo.mViewRootImpl.registerAnimatingRenderNode(this);
}
- public void addAnimator(AnimatedVectorDrawable.VectorDrawableAnimator animatorSet) {
- if (mOwningView == null || mOwningView.mAttachInfo == null) {
- throw new IllegalStateException("Cannot start this animator on a detached view!");
- }
- nAddAnimator(mNativeRenderNode, animatorSet.getAnimatorNativePtr());
- mOwningView.mAttachInfo.mViewRootImpl.registerAnimatingRenderNode(this);
- }
-
public void endAllAnimators() {
nEndAllAnimators(mNativeRenderNode);
}
@@ -863,6 +857,8 @@
private static native void nOutput(long renderNode);
private static native int nGetDebugSize(long renderNode);
+ private static native void nRequestPositionUpdates(long renderNode, SurfaceView callback);
+
///////////////////////////////////////////////////////////////////////////
// Animations
///////////////////////////////////////////////////////////////////////////
diff --git a/core/java/android/view/RenderNodeAnimatorSetHelper.java b/core/java/android/view/RenderNodeAnimatorSetHelper.java
deleted file mode 100644
index ba592d29..0000000
--- a/core/java/android/view/RenderNodeAnimatorSetHelper.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package android.view;
-
-import android.animation.TimeInterpolator;
-import com.android.internal.view.animation.FallbackLUTInterpolator;
-import com.android.internal.view.animation.NativeInterpolatorFactory;
-import com.android.internal.view.animation.NativeInterpolatorFactoryHelper;
-
-/**
- * This is a helper class to get access to methods and fields needed for RenderNodeAnimatorSet
- * that are internal or package private to android.view package.
- *
- * @hide
- */
-public class RenderNodeAnimatorSetHelper {
-
- public static RenderNode getTarget(DisplayListCanvas recordingCanvas) {
- return recordingCanvas.mNode;
- }
-
- public static long createNativeInterpolator(TimeInterpolator interpolator, long
- duration) {
- if (interpolator == null) {
- // create LinearInterpolator
- return NativeInterpolatorFactoryHelper.createLinearInterpolator();
- } else if (RenderNodeAnimator.isNativeInterpolator(interpolator)) {
- return ((NativeInterpolatorFactory)interpolator).createNativeInterpolator();
- } else {
- return FallbackLUTInterpolator.createNativeInterpolator(interpolator, duration);
- }
- }
-
-}
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index 5b48e28..a296051 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -135,7 +135,7 @@
}
};
- final ViewTreeObserver.OnScrollChangedListener mScrollChangedListener
+ private final ViewTreeObserver.OnScrollChangedListener mScrollChangedListener
= new ViewTreeObserver.OnScrollChangedListener() {
@Override
public void onScrollChanged() {
@@ -143,6 +143,17 @@
}
};
+ private final ViewTreeObserver.OnPreDrawListener mDrawListener =
+ new ViewTreeObserver.OnPreDrawListener() {
+ @Override
+ public boolean onPreDraw() {
+ // reposition ourselves where the surface is
+ mHaveFrame = getWidth() > 0 && getHeight() > 0;
+ updateWindow(false, false);
+ return true;
+ }
+ };
+
boolean mRequestedVisible = false;
boolean mWindowVisibility = false;
boolean mViewVisibility = false;
@@ -168,17 +179,9 @@
boolean mUpdateWindowNeeded;
boolean mReportDrawNeeded;
private Translator mTranslator;
+ private int mWindowInsetLeft;
+ private int mWindowInsetTop;
- private final ViewTreeObserver.OnPreDrawListener mDrawListener =
- new ViewTreeObserver.OnPreDrawListener() {
- @Override
- public boolean onPreDraw() {
- // reposition ourselves where the surface is
- mHaveFrame = getWidth() > 0 && getHeight() > 0;
- updateWindow(false, false);
- return true;
- }
- };
private boolean mGlobalListenersAdded;
public SurfaceView(Context context) {
@@ -443,17 +446,17 @@
int myHeight = mRequestedHeight;
if (myHeight <= 0) myHeight = getHeight();
- getLocationInWindow(mLocation);
final boolean creating = mWindow == null;
final boolean formatChanged = mFormat != mRequestedFormat;
final boolean sizeChanged = mWindowSpaceWidth != myWidth || mWindowSpaceHeight != myHeight;
final boolean visibleChanged = mVisible != mRequestedVisible;
final boolean layoutSizeChanged = getWidth() != mLayout.width
|| getHeight() != mLayout.height;
- final boolean positionChanged = mWindowSpaceLeft != mLocation[0] || mWindowSpaceTop != mLocation[1];
if (force || creating || formatChanged || sizeChanged || visibleChanged
|| mUpdateWindowNeeded || mReportDrawNeeded || redrawNeeded) {
+ getLocationInWindow(mLocation);
+
if (DEBUG) Log.i(TAG, "Changes: creating=" + creating
+ " format=" + formatChanged + " size=" + sizeChanged
+ " visible=" + visibleChanged
@@ -643,27 +646,69 @@
TAG, "Layout: x=" + mLayout.x + " y=" + mLayout.y +
" w=" + mLayout.width + " h=" + mLayout.height +
", frame=" + mSurfaceFrame);
- } else if (positionChanged || layoutSizeChanged) { // Only the position has changed
- mWindowSpaceLeft = mLocation[0];
- mWindowSpaceTop = mLocation[1];
- // For our size changed check, we keep mLayout.width and mLayout.height
- // in view local space.
- mLocation[0] = mLayout.width = getWidth();
- mLocation[1] = mLayout.height = getHeight();
+ } else if (!isHardwareAccelerated()) {
+ getLocationInWindow(mLocation);
+ final boolean positionChanged = mWindowSpaceLeft != mLocation[0]
+ || mWindowSpaceTop != mLocation[1];
+ if (positionChanged || layoutSizeChanged) { // Only the position has changed
+ mWindowSpaceLeft = mLocation[0];
+ mWindowSpaceTop = mLocation[1];
+ // For our size changed check, we keep mLayout.width and mLayout.height
+ // in view local space.
+ mLocation[0] = mLayout.width = getWidth();
+ mLocation[1] = mLayout.height = getHeight();
- transformFromViewToWindowSpace(mLocation);
+ transformFromViewToWindowSpace(mLocation);
- try {
- mSession.repositionChild(mWindow, mWindowSpaceLeft, mWindowSpaceTop,
- mLocation[0], mLocation[1],
- viewRoot != null ? viewRoot.getNextFrameNumber() : -1,
- mWinFrame);
- } catch (RemoteException ex) {
- Log.e(TAG, "Exception from relayout", ex);
+ try {
+ Log.d(TAG, String.format("updateWindowPosition UI, " +
+ "postion = [%d, %d, %d, %d]", mWindowSpaceLeft, mWindowSpaceTop,
+ mLocation[0], mLocation[1]));
+ mSession.repositionChild(mWindow, mWindowSpaceLeft, mWindowSpaceTop,
+ mLocation[0], mLocation[1], -1, mWinFrame);
+ } catch (RemoteException ex) {
+ Log.e(TAG, "Exception from relayout", ex);
+ }
}
}
}
+ private Rect mRTLastReportedPosition = new Rect();
+
+ /**
+ * Called by native on RenderThread to update the window position
+ * @hide
+ */
+ public final void updateWindowPositionRT(long frameNumber,
+ int left, int top, int right, int bottom) {
+ IWindowSession session = mSession;
+ MyWindow window = mWindow;
+ if (session == null || window == null) {
+ // Guess we got detached, that sucks
+ return;
+ }
+ if (mRTLastReportedPosition.left == left
+ && mRTLastReportedPosition.top == top
+ && mRTLastReportedPosition.right == right
+ && mRTLastReportedPosition.bottom == bottom) {
+ return;
+ }
+ try {
+ if (DEBUG) {
+ Log.d(TAG, String.format("updateWindowPosition RT, frameNr = %d, " +
+ "postion = [%d, %d, %d, %d]", frameNumber, left, top,
+ right, bottom));
+ }
+ // Just using mRTLastReportedPosition as a dummy rect here
+ session.repositionChild(window, left, top, right, bottom, frameNumber,
+ mRTLastReportedPosition);
+ // Now overwrite mRTLastReportedPosition with our values
+ mRTLastReportedPosition.set(left, top, right, bottom);
+ } catch (RemoteException ex) {
+ Log.e(TAG, "Exception from repositionChild", ex);
+ }
+ }
+
private SurfaceHolder.Callback[] getSurfaceCallbacks() {
SurfaceHolder.Callback callbacks[];
synchronized (mCallbacks) {
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 4a0a0b0..127157b 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -4506,9 +4506,15 @@
}
break;
case R.styleable.View_pointerShape:
- final int pointerShape = a.getInt(attr, PointerIcon.STYLE_NOT_SPECIFIED);
- if (pointerShape != PointerIcon.STYLE_NOT_SPECIFIED) {
- setPointerIcon(PointerIcon.getSystemIcon(context, pointerShape));
+ final int resourceId = a.getResourceId(attr, 0);
+ if (resourceId != 0) {
+ setPointerIcon(PointerIcon.loadCustomIcon(
+ context.getResources(), resourceId));
+ } else {
+ final int pointerShape = a.getInt(attr, PointerIcon.STYLE_NOT_SPECIFIED);
+ if (pointerShape != PointerIcon.STYLE_NOT_SPECIFIED) {
+ setPointerIcon(PointerIcon.getSystemIcon(context, pointerShape));
+ }
}
break;
}
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 98e3289..96853e0 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -1811,7 +1811,9 @@
final boolean dragResizing = freeformResizing || dockedResizing;
if (mDragResizing != dragResizing) {
if (dragResizing) {
- startDragResizing(mPendingBackDropFrame);
+ startDragResizing(mPendingBackDropFrame,
+ mWinFrame.equals(mPendingBackDropFrame), mPendingVisibleInsets,
+ mPendingStableInsets);
mResizeMode = freeformResizing
? RESIZE_MODE_FREEFORM
: RESIZE_MODE_DOCKED_DIVIDER;
@@ -5845,9 +5847,11 @@
// Tell all listeners that we are resizing the window so that the chrome can get
// updated as fast as possible on a separate thread,
if (mDragResizing) {
+ boolean fullscreen = frame.equals(backDropFrame);
synchronized (mWindowCallbacks) {
for (int i = mWindowCallbacks.size() - 1; i >= 0; i--) {
- mWindowCallbacks.get(i).onWindowSizeIsChanging(backDropFrame);
+ mWindowCallbacks.get(i).onWindowSizeIsChanging(backDropFrame, fullscreen,
+ visibleInsets, stableInsets);
}
}
}
@@ -6815,20 +6819,6 @@
}
}
- long getNextFrameNumber() {
- long frameNumber = -1;
- if (mSurfaceHolder != null) {
- mSurfaceHolder.mSurfaceLock.lock();
- }
- if (mSurface.isValid()) {
- frameNumber = mSurface.getNextFrameNumber();
- }
- if (mSurfaceHolder != null) {
- mSurfaceHolder.mSurfaceLock.unlock();
- }
- return frameNumber;
- }
-
class TakenSurfaceHolder extends BaseSurfaceHolder {
@Override
public boolean onAllowLockCanvas() {
@@ -7060,12 +7050,14 @@
/**
* Start a drag resizing which will inform all listeners that a window resize is taking place.
*/
- private void startDragResizing(Rect initialBounds) {
+ private void startDragResizing(Rect initialBounds, boolean fullscreen, Rect systemInsets,
+ Rect stableInsets) {
if (!mDragResizing) {
mDragResizing = true;
synchronized (mWindowCallbacks) {
for (int i = mWindowCallbacks.size() - 1; i >= 0; i--) {
- mWindowCallbacks.get(i).onWindowDragResizeStart(initialBounds);
+ mWindowCallbacks.get(i).onWindowDragResizeStart(initialBounds, fullscreen,
+ systemInsets, stableInsets);
}
}
mFullRedrawNeeded = true;
diff --git a/core/java/android/view/WindowCallbacks.java b/core/java/android/view/WindowCallbacks.java
index def0236..d2bfca7 100644
--- a/core/java/android/view/WindowCallbacks.java
+++ b/core/java/android/view/WindowCallbacks.java
@@ -28,20 +28,30 @@
public interface WindowCallbacks {
/**
* Called by the system when the window got changed by the user, before the layouter got called.
- * It can be used to perform a "quick and dirty" resize which should never take more then 4ms to
- * complete.
+ * It also gets called when the insets changed, or when the window switched between a fullscreen
+ * layout or a non-fullscreen layout. It can be used to perform a "quick and dirty" resize which
+ * should never take more then 4ms to complete.
*
* <p>At the time the layouting has not happened yet.
*
* @param newBounds The new window frame bounds.
+ * @param fullscreen Whether the window is currently drawing in fullscreen.
+ * @param systemInsets The current visible system insets for the window.
+ * @param stableInsets The stable insets for the window.
*/
- void onWindowSizeIsChanging(Rect newBounds);
+ void onWindowSizeIsChanging(Rect newBounds, boolean fullscreen, Rect systemInsets,
+ Rect stableInsets);
/**
* Called when a drag resize starts.
+ *
* @param initialBounds The initial bounds where the window will be.
+ * @param fullscreen Whether the window is currently drawing in fullscreen.
+ * @param systemInsets The current visible system insets for the window.
+ * @param stableInsets The stable insets for the window.
*/
- void onWindowDragResizeStart(Rect initialBounds);
+ void onWindowDragResizeStart(Rect initialBounds, boolean fullscreen, Rect systemInsets,
+ Rect stableInsets);
/**
* Called when a drag resize ends.
diff --git a/core/java/android/view/WindowManagerInternal.java b/core/java/android/view/WindowManagerInternal.java
index 89b1eb9..c22d60d 100644
--- a/core/java/android/view/WindowManagerInternal.java
+++ b/core/java/android/view/WindowManagerInternal.java
@@ -268,4 +268,9 @@
/** Returns true if the stack with the input Id is currently visible. */
public abstract boolean isStackVisible(int stackId);
+
+ /**
+ * @return True if and only if the docked divider is currently in resize mode.
+ */
+ public abstract boolean isDockedDividerResizing();
}
diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java
index cf13a13..b0fb93b 100644
--- a/core/java/com/android/internal/app/ChooserActivity.java
+++ b/core/java/com/android/internal/app/ChooserActivity.java
@@ -761,6 +761,7 @@
public static final int TARGET_STANDARD = 2;
private static final int MAX_SERVICE_TARGETS = 8;
+ private static final int MAX_TARGETS_PER_SERVICE = 4;
private final List<ChooserTargetInfo> mServiceTargets = new ArrayList<>();
private final List<TargetInfo> mCallerTargets = new ArrayList<>();
@@ -925,7 +926,7 @@
final float parentScore = getScore(origTarget);
Collections.sort(targets, mBaseTargetComparator);
float lastScore = 0;
- for (int i = 0, N = targets.size(); i < N; i++) {
+ for (int i = 0, N = Math.min(targets.size(), MAX_TARGETS_PER_SERVICE); i < N; i++) {
final ChooserTarget target = targets.get(i);
float targetScore = target.getScore();
targetScore *= parentScore;
diff --git a/core/java/com/android/internal/app/ResolverComparator.java b/core/java/com/android/internal/app/ResolverComparator.java
index 0ae21c6..03a3a38 100644
--- a/core/java/com/android/internal/app/ResolverComparator.java
+++ b/core/java/com/android/internal/app/ResolverComparator.java
@@ -52,7 +52,7 @@
private static final long RECENCY_TIME_PERIOD = 1000 * 60 * 60 * 12;
- private static final float RECENCY_MULTIPLIER = 3.f;
+ private static final float RECENCY_MULTIPLIER = 2.f;
private final Collator mCollator;
private final boolean mHttp;
diff --git a/core/java/com/android/internal/policy/BackdropFrameRenderer.java b/core/java/com/android/internal/policy/BackdropFrameRenderer.java
index 5047c4c..6931193 100644
--- a/core/java/com/android/internal/policy/BackdropFrameRenderer.java
+++ b/core/java/com/android/internal/policy/BackdropFrameRenderer.java
@@ -24,7 +24,6 @@
import android.view.DisplayListCanvas;
import android.view.RenderNode;
import android.view.ThreadedRenderer;
-import android.view.View;
/**
* The thread which draws a fill in background while the app is resizing in areas where the app
@@ -49,6 +48,7 @@
private final Rect mOldTargetRect = new Rect();
private final Rect mNewTargetRect = new Rect();
+
private Choreographer mChoreographer;
// Cached size values from the last render for the case that the view hierarchy is gone
@@ -66,15 +66,23 @@
private Drawable mUserCaptionBackgroundDrawable;
private Drawable mResizingBackgroundDrawable;
private ColorDrawable mStatusBarColor;
+ private ColorDrawable mNavigationBarColor;
+ private boolean mOldFullscreen;
+ private boolean mFullscreen;
+ private final Rect mOldSystemInsets = new Rect();
+ private final Rect mOldStableInsets = new Rect();
+ private final Rect mSystemInsets = new Rect();
+ private final Rect mStableInsets = new Rect();
public BackdropFrameRenderer(DecorView decorView, ThreadedRenderer renderer, Rect initialBounds,
Drawable resizingBackgroundDrawable, Drawable captionBackgroundDrawable,
- Drawable userCaptionBackgroundDrawable, int statusBarColor) {
+ Drawable userCaptionBackgroundDrawable, int statusBarColor, int navigationBarColor,
+ boolean fullscreen, Rect systemInsets, Rect stableInsets) {
setName("ResizeFrame");
mRenderer = renderer;
onResourcesLoaded(decorView, resizingBackgroundDrawable, captionBackgroundDrawable,
- userCaptionBackgroundDrawable, statusBarColor);
+ userCaptionBackgroundDrawable, statusBarColor, navigationBarColor);
// Create a render node for the content and frame backdrop
// which can be resized independently from the content.
@@ -84,8 +92,14 @@
// Set the initial bounds and draw once so that we do not get a broken frame.
mTargetRect.set(initialBounds);
+ mFullscreen = fullscreen;
+ mOldFullscreen = fullscreen;
+ mSystemInsets.set(systemInsets);
+ mStableInsets.set(stableInsets);
+ mOldSystemInsets.set(systemInsets);
+ mOldStableInsets.set(stableInsets);
synchronized (this) {
- changeWindowSizeLocked(initialBounds);
+ redrawLocked(initialBounds, fullscreen, mSystemInsets, mStableInsets);
}
// Kick off our draw thread.
@@ -94,7 +108,7 @@
void onResourcesLoaded(DecorView decorView, Drawable resizingBackgroundDrawable,
Drawable captionBackgroundDrawableDrawable, Drawable userCaptionBackgroundDrawable,
- int statusBarColor) {
+ int statusBarColor, int navigationBarColor) {
mDecorView = decorView;
mResizingBackgroundDrawable = resizingBackgroundDrawable;
mCaptionBackgroundDrawable = captionBackgroundDrawableDrawable;
@@ -108,6 +122,12 @@
} else {
mStatusBarColor = null;
}
+ if (navigationBarColor != 0) {
+ mNavigationBarColor = new ColorDrawable(navigationBarColor);
+ addSystemBarNodeIfNeeded();
+ } else {
+ mNavigationBarColor = null;
+ }
}
private void addSystemBarNodeIfNeeded() {
@@ -119,13 +139,22 @@
}
/**
- * Call this function asynchronously when the window size has been changed. The change will
- * be picked up once per frame and the frame will be re-rendered accordingly.
+ * Call this function asynchronously when the window size has been changed or when the insets
+ * have changed or whether window switched between a fullscreen or non-fullscreen layout.
+ * The change will be picked up once per frame and the frame will be re-rendered accordingly.
+ *
* @param newTargetBounds The new target bounds.
+ * @param fullscreen Whether the window is currently drawing in fullscreen.
+ * @param systemInsets The current visible system insets for the window.
+ * @param stableInsets The stable insets for the window.
*/
- public void setTargetRect(Rect newTargetBounds) {
+ public void setTargetRect(Rect newTargetBounds, boolean fullscreen, Rect systemInsets,
+ Rect stableInsets) {
synchronized (this) {
+ mFullscreen = fullscreen;
mTargetRect.set(newTargetBounds);
+ mSystemInsets.set(systemInsets);
+ mStableInsets.set(stableInsets);
// Notify of a bounds change.
pingRenderLocked();
}
@@ -204,16 +233,23 @@
return;
}
mNewTargetRect.set(mTargetRect);
- if (!mNewTargetRect.equals(mOldTargetRect) || mReportNextDraw) {
+ if (!mNewTargetRect.equals(mOldTargetRect)
+ || mOldFullscreen != mFullscreen
+ || !mStableInsets.equals(mOldStableInsets)
+ || !mSystemInsets.equals(mOldSystemInsets)
+ || mReportNextDraw) {
+ mOldFullscreen = mFullscreen;
mOldTargetRect.set(mNewTargetRect);
- changeWindowSizeLocked(mNewTargetRect);
+ mOldSystemInsets.set(mSystemInsets);
+ mOldStableInsets.set(mStableInsets);
+ redrawLocked(mNewTargetRect, mFullscreen, mSystemInsets, mStableInsets);
}
}
}
/**
* The content is about to be drawn and we got the location of where it will be shown.
- * If a "changeWindowSizeLocked" call has already been processed, we will re-issue the call
+ * If a "redrawLocked" call has already been processed, we will re-issue the call
* if the previous call was ignored since the size was unknown.
* @param xOffset The x offset where the content is drawn to.
* @param yOffset The y offset where the content is drawn to.
@@ -235,8 +271,8 @@
mLastYOffset,
mLastXOffset + mLastContentWidth,
mLastYOffset + mLastCaptionHeight + mLastContentHeight);
- // If this was the first call and changeWindowSizeLocked got already called prior
- // to us, we should re-issue a changeWindowSizeLocked now.
+ // If this was the first call and redrawLocked got already called prior
+ // to us, we should re-issue a redrawLocked now.
return firstCall
&& (mLastCaptionHeight != 0 || !mDecorView.isShowingCaption());
}
@@ -251,16 +287,20 @@
}
/**
- * Resizing the frame to fit the new window size.
+ * Redraws the background, the caption and the system inset backgrounds if something changed.
+ *
* @param newBounds The window bounds which needs to be drawn.
+ * @param fullscreen Whether the window is currently drawing in fullscreen.
+ * @param systemInsets The current visible system insets for the window.
+ * @param stableInsets The stable insets for the window.
*/
- private void changeWindowSizeLocked(Rect newBounds) {
+ private void redrawLocked(Rect newBounds, boolean fullscreen, Rect systemInsets,
+ Rect stableInsets) {
// While a configuration change is taking place the view hierarchy might become
// inaccessible. For that case we remember the previous metrics to avoid flashes.
// Note that even when there is no visible caption, the caption child will exist.
final int captionHeight = mDecorView.getCaptionHeight();
- final int statusBarHeight = mDecorView.getStatusBarHeight();
// The caption height will probably never dynamically change while we are resizing.
// Once set to something other then 0 it should be kept that way.
@@ -302,14 +342,7 @@
}
mFrameAndBackdropNode.end(canvas);
- if (mSystemBarBackgroundNode != null && mStatusBarColor != null) {
- canvas = mSystemBarBackgroundNode.start(width, height);
- mSystemBarBackgroundNode.setLeftTopRightBottom(left, top, left + width, top + height);
- mStatusBarColor.setBounds(0, 0, left + width, statusBarHeight);
- mStatusBarColor.draw(canvas);
- mSystemBarBackgroundNode.end(canvas);
- mRenderer.drawRenderNode(mSystemBarBackgroundNode);
- }
+ drawColorViews(left, top, width, height, fullscreen, systemInsets, stableInsets);
// We need to render the node explicitly
mRenderer.drawRenderNode(mFrameAndBackdropNode);
@@ -317,6 +350,39 @@
reportDrawIfNeeded();
}
+ private void drawColorViews(int left, int top, int width, int height,
+ boolean fullscreen, Rect systemInsets, Rect stableInsets) {
+ if (mSystemBarBackgroundNode == null) {
+ return;
+ }
+ DisplayListCanvas canvas = mSystemBarBackgroundNode.start(width, height);
+ mSystemBarBackgroundNode.setLeftTopRightBottom(left, top, left + width, top + height);
+ final int topInset = DecorView.getColorViewTopInset(mStableInsets.top, mSystemInsets.top);
+ final int bottomInset = DecorView.getColorViewBottomInset(stableInsets.bottom,
+ systemInsets.bottom);
+ final int rightInset = DecorView.getColorViewRightInset(stableInsets.right,
+ systemInsets.right);
+ if (mStatusBarColor != null) {
+ mStatusBarColor.setBounds(0, 0, left + width, topInset);
+ mStatusBarColor.draw(canvas);
+ }
+
+ // We only want to draw the navigation bar if our window is currently fullscreen because we
+ // don't want the navigation bar background be moving around when resizing in docked mode.
+ // However, we need it for the transitions into/out of docked mode.
+ if (mNavigationBarColor != null && fullscreen) {
+ final int size = DecorView.getNavBarSize(bottomInset, rightInset);
+ if (DecorView.isNavBarToRightEdge(bottomInset, rightInset)) {
+ mNavigationBarColor.setBounds(width - size, 0, width, height);
+ } else {
+ mNavigationBarColor.setBounds(0, height - size, width, height);
+ }
+ mNavigationBarColor.draw(canvas);
+ }
+ mSystemBarBackgroundNode.end(canvas);
+ mRenderer.drawRenderNode(mSystemBarBackgroundNode);
+ }
+
/** Notify view root that a frame has been drawn by us, if it has requested so. */
private void reportDrawIfNeeded() {
if (mReportNextDraw) {
diff --git a/core/java/com/android/internal/policy/DecorView.java b/core/java/com/android/internal/policy/DecorView.java
index 1a20e5c..d4ada95 100644
--- a/core/java/com/android/internal/policy/DecorView.java
+++ b/core/java/com/android/internal/policy/DecorView.java
@@ -922,6 +922,26 @@
return false;
}
+ static int getColorViewTopInset(int stableTop, int systemTop) {
+ return Math.min(stableTop, systemTop);
+ }
+
+ static int getColorViewBottomInset(int stableBottom, int systemBottom) {
+ return Math.min(stableBottom, systemBottom);
+ }
+
+ static int getColorViewRightInset(int stableRight, int systemRight) {
+ return Math.min(stableRight, systemRight);
+ }
+
+ static boolean isNavBarToRightEdge(int bottomInset, int rightInset) {
+ return bottomInset == 0 && rightInset > 0;
+ }
+
+ static int getNavBarSize(int bottomInset, int rightInset) {
+ return isNavBarToRightEdge(bottomInset, rightInset) ? rightInset : bottomInset;
+ }
+
WindowInsets updateColorViews(WindowInsets insets, boolean animate) {
WindowManager.LayoutParams attrs = mWindow.getAttributes();
int sysUiVisibility = attrs.systemUiVisibility | getWindowSystemUiVisibility();
@@ -933,11 +953,11 @@
mLastWindowFlags = attrs.flags;
if (insets != null) {
- mLastTopInset = Math.min(insets.getStableInsetTop(),
+ mLastTopInset = getColorViewTopInset(insets.getStableInsetTop(),
insets.getSystemWindowInsetTop());
- mLastBottomInset = Math.min(insets.getStableInsetBottom(),
+ mLastBottomInset = getColorViewBottomInset(insets.getStableInsetBottom(),
insets.getSystemWindowInsetBottom());
- mLastRightInset = Math.min(insets.getStableInsetRight(),
+ mLastRightInset = getColorViewRightInset(insets.getStableInsetRight(),
insets.getSystemWindowInsetRight());
// Don't animate if the presence of stable insets has changed, because that
@@ -956,8 +976,8 @@
mLastHasRightStableInset = hasRightStableInset;
}
- boolean navBarToRightEdge = mLastBottomInset == 0 && mLastRightInset > 0;
- int navBarSize = navBarToRightEdge ? mLastRightInset : mLastBottomInset;
+ boolean navBarToRightEdge = isNavBarToRightEdge(mLastBottomInset, mLastRightInset);
+ int navBarSize = getNavBarSize(mLastBottomInset, mLastRightInset);
updateColorViewInt(mNavigationColorViewState, sysUiVisibility,
mWindow.mNavigationBarColor, navBarSize, navBarToRightEdge,
0 /* rightInset */, animate && !disallowAnimate, false /* force */);
@@ -1041,14 +1061,14 @@
*/
private void updateColorViewInt(final ColorViewState state, int sysUiVis, int color,
int size, boolean verticalBar, int rightMargin, boolean animate, boolean force) {
- state.present = size > 0 && (sysUiVis & state.systemUiHideFlag) == 0
+ state.present = (sysUiVis & state.systemUiHideFlag) == 0
&& (mWindow.getAttributes().flags & state.hideWindowFlag) == 0
&& ((mWindow.getAttributes().flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0
|| force);
boolean show = state.present
&& (color & Color.BLACK) != 0
&& ((mWindow.getAttributes().flags & state.translucentFlag) == 0 || force);
- boolean showView = show && !isResizing();
+ boolean showView = show && !isResizing() && size > 0;
boolean visibilityChanged = false;
View view = state.view;
@@ -1672,7 +1692,8 @@
loadBackgroundDrawablesIfNeeded();
mBackdropFrameRenderer.onResourcesLoaded(
this, mResizingBackgroundDrawable, mCaptionBackgroundDrawable,
- mUserCaptionBackgroundDrawable, getCurrentColor(mStatusColorViewState));
+ mUserCaptionBackgroundDrawable, getCurrentColor(mStatusColorViewState),
+ getCurrentColor(mNavigationColorViewState));
}
mDecorCaptionView = createDecorCaptionView(inflater);
@@ -1854,14 +1875,16 @@
}
@Override
- public void onWindowSizeIsChanging(Rect newBounds) {
+ public void onWindowSizeIsChanging(Rect newBounds, boolean fullscreen, Rect systemInsets,
+ Rect stableInsets) {
if (mBackdropFrameRenderer != null) {
- mBackdropFrameRenderer.setTargetRect(newBounds);
+ mBackdropFrameRenderer.setTargetRect(newBounds, fullscreen, systemInsets, stableInsets);
}
}
@Override
- public void onWindowDragResizeStart(Rect initialBounds) {
+ public void onWindowDragResizeStart(Rect initialBounds, boolean fullscreen, Rect systemInsets,
+ Rect stableInsets) {
if (mWindow.isDestroyed()) {
// If the owner's window is gone, we should not be able to come here anymore.
releaseThreadedRenderer();
@@ -1875,7 +1898,9 @@
loadBackgroundDrawablesIfNeeded();
mBackdropFrameRenderer = new BackdropFrameRenderer(this, renderer,
initialBounds, mResizingBackgroundDrawable, mCaptionBackgroundDrawable,
- mUserCaptionBackgroundDrawable, getCurrentColor(mStatusColorViewState));
+ mUserCaptionBackgroundDrawable, getCurrentColor(mStatusColorViewState),
+ getCurrentColor(mNavigationColorViewState), fullscreen, systemInsets,
+ stableInsets);
// Get rid of the shadow while we are resizing. Shadow drawing takes considerable time.
// If we want to get the shadow shown while resizing, we would need to elevate a new
@@ -1971,10 +1996,6 @@
return isShowingCaption() ? mDecorCaptionView.getCaptionHeight() : 0;
}
- int getStatusBarHeight() {
- return mStatusColorViewState.view != null ? mStatusColorViewState.view.getHeight() : 0;
- }
-
/**
* Converts a DIP measure into physical pixels.
* @param dip The dip value.
diff --git a/core/java/com/android/internal/widget/FloatingToolbar.java b/core/java/com/android/internal/widget/FloatingToolbar.java
index 02efcc6..ce03bb8 100644
--- a/core/java/com/android/internal/widget/FloatingToolbar.java
+++ b/core/java/com/android/internal/widget/FloatingToolbar.java
@@ -322,7 +322,7 @@
/* View components */
private final ViewGroup mContentContainer; // holds all contents.
private final ViewGroup mMainPanel; // holds menu items that are initially displayed.
- private final ListView mOverflowPanel; // holds menu items hidden in the overflow.
+ private final OverflowPanel mOverflowPanel; // holds menu items hidden in the overflow.
private final ImageButton mOverflowButton; // opens/closes the overflow.
/* overflow button drawables. */
private final Drawable mArrow;
@@ -895,6 +895,7 @@
private void setPanelsStatesAtRestingPosition() {
mOverflowButton.setEnabled(true);
+ mOverflowPanel.awakenScrollBars();
if (mIsOverflowOpen) {
// Set open state.
@@ -1333,27 +1334,8 @@
return overflowButton;
}
- private ListView createOverflowPanel() {
- final ListView overflowPanel = new ListView(FloatingToolbarPopup.this.mContext) {
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- // Update heightMeasureSpec to make sure that this view is not clipped
- // as we offset it's coordinates with respect to it's parent.
- heightMeasureSpec = MeasureSpec.makeMeasureSpec(
- mOverflowPanelSize.getHeight() - mOverflowButtonSize.getHeight(),
- MeasureSpec.EXACTLY);
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- }
-
- @Override
- public boolean dispatchTouchEvent(MotionEvent ev) {
- if (isOverflowAnimating()) {
- // Eat the touch event.
- return true;
- }
- return super.dispatchTouchEvent(ev);
- }
- };
+ private OverflowPanel createOverflowPanel() {
+ final OverflowPanel overflowPanel = new OverflowPanel(this);
overflowPanel.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
overflowPanel.setDivider(null);
@@ -1464,6 +1446,43 @@
}
/**
+ * A custom ListView for the overflow panel.
+ */
+ private static final class OverflowPanel extends ListView {
+
+ private final FloatingToolbarPopup mPopup;
+
+ OverflowPanel(FloatingToolbarPopup popup) {
+ super(Preconditions.checkNotNull(popup).mContext);
+ this.mPopup = popup;
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ // Update heightMeasureSpec to make sure that this view is not clipped
+ // as we offset it's coordinates with respect to it's parent.
+ int height = mPopup.mOverflowPanelSize.getHeight()
+ - mPopup.mOverflowButtonSize.getHeight();
+ heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ }
+
+ @Override
+ public boolean dispatchTouchEvent(MotionEvent ev) {
+ if (mPopup.isOverflowAnimating()) {
+ // Eat the touch event.
+ return true;
+ }
+ return super.dispatchTouchEvent(ev);
+ }
+
+ @Override
+ protected boolean awakenScrollBars() {
+ return super.awakenScrollBars();
+ }
+ }
+
+ /**
* A custom interpolator used for various floating toolbar animations.
*/
private static final class LogAccelerateInterpolator implements Interpolator {
diff --git a/core/jni/Android.mk b/core/jni/Android.mk
index 1b6b53a..ffa3fa6 100644
--- a/core/jni/Android.mk
+++ b/core/jni/Android.mk
@@ -51,7 +51,6 @@
android_database_SQLiteConnection.cpp \
android_database_SQLiteGlobal.cpp \
android_database_SQLiteDebug.cpp \
- android_graphics_drawable_AnimatedVectorDrawable.cpp \
android_graphics_drawable_VectorDrawable.cpp \
android_view_DisplayEventReceiver.cpp \
android_view_DisplayListCanvas.cpp \
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index 223fc1a..2e45f8c 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -131,7 +131,6 @@
extern int register_android_graphics_Region(JNIEnv* env);
extern int register_android_graphics_SurfaceTexture(JNIEnv* env);
extern int register_android_graphics_Xfermode(JNIEnv* env);
-extern int register_android_graphics_drawable_AnimatedVectorDrawable(JNIEnv* env);
extern int register_android_graphics_drawable_VectorDrawable(JNIEnv* env);
extern int register_android_graphics_pdf_PdfDocument(JNIEnv* env);
extern int register_android_graphics_pdf_PdfEditor(JNIEnv* env);
@@ -1322,7 +1321,6 @@
REG_JNI(register_android_graphics_Typeface),
REG_JNI(register_android_graphics_Xfermode),
REG_JNI(register_android_graphics_YuvImage),
- REG_JNI(register_android_graphics_drawable_AnimatedVectorDrawable),
REG_JNI(register_android_graphics_drawable_VectorDrawable),
REG_JNI(register_android_graphics_pdf_PdfDocument),
REG_JNI(register_android_graphics_pdf_PdfEditor),
diff --git a/core/jni/android_graphics_drawable_AnimatedVectorDrawable.cpp b/core/jni/android_graphics_drawable_AnimatedVectorDrawable.cpp
deleted file mode 100644
index 7a3c598..0000000
--- a/core/jni/android_graphics_drawable_AnimatedVectorDrawable.cpp
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright (C) 2016 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.
- */
-#define LOG_TAG "OpenGLRenderer"
-
-#include "jni.h"
-#include "GraphicsJNI.h"
-#include "core_jni_helpers.h"
-#include "log/log.h"
-
-#include "Animator.h"
-#include "Interpolator.h"
-#include "PropertyValuesAnimatorSet.h"
-#include "PropertyValuesHolder.h"
-#include "VectorDrawable.h"
-
-namespace android {
-using namespace uirenderer;
-using namespace VectorDrawable;
-
-static struct {
- jclass clazz;
- jmethodID callOnFinished;
-} gVectorDrawableAnimatorClassInfo;
-
-static JNIEnv* getEnv(JavaVM* vm) {
- JNIEnv* env;
- if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
- return 0;
- }
- return env;
-}
-
-static AnimationListener* createAnimationListener(JNIEnv* env, jobject finishListener) {
- class AnimationListenerBridge : public AnimationListener {
- public:
- AnimationListenerBridge(JNIEnv* env, jobject finishListener) {
- mFinishListener = env->NewGlobalRef(finishListener);
- env->GetJavaVM(&mJvm);
- }
-
- virtual ~AnimationListenerBridge() {
- if (mFinishListener) {
- onAnimationFinished(NULL);
- }
- }
-
- virtual void onAnimationFinished(BaseRenderNodeAnimator*) {
- LOG_ALWAYS_FATAL_IF(!mFinishListener, "Finished listener twice?");
- JNIEnv* env = getEnv(mJvm);
- env->CallStaticVoidMethod(
- gVectorDrawableAnimatorClassInfo.clazz,
- gVectorDrawableAnimatorClassInfo.callOnFinished,
- mFinishListener);
- releaseJavaObject();
- }
-
- private:
- void releaseJavaObject() {
- JNIEnv* env = getEnv(mJvm);
- env->DeleteGlobalRef(mFinishListener);
- mFinishListener = NULL;
- }
-
- JavaVM* mJvm;
- jobject mFinishListener;
- };
- return new AnimationListenerBridge(env, finishListener);
-}
-
-static void addAnimator(JNIEnv*, jobject, jlong animatorSetPtr, jlong propertyHolderPtr,
- jlong interpolatorPtr, jlong startDelay, jlong duration, jint repeatCount) {
- PropertyValuesAnimatorSet* set = reinterpret_cast<PropertyValuesAnimatorSet*>(animatorSetPtr);
- PropertyValuesHolder* holder = reinterpret_cast<PropertyValuesHolder*>(propertyHolderPtr);
- Interpolator* interpolator = reinterpret_cast<Interpolator*>(interpolatorPtr);
- set->addPropertyAnimator(holder, interpolator, startDelay, duration, repeatCount);
-}
-
-static jlong createAnimatorSet(JNIEnv*, jobject) {
- PropertyValuesAnimatorSet* animatorSet = new PropertyValuesAnimatorSet();
- return reinterpret_cast<jlong>(animatorSet);
-}
-
-static jlong createGroupPropertyHolder(JNIEnv*, jobject, jlong nativePtr, jint propertyId,
- jfloat startValue, jfloat endValue) {
- VectorDrawable::Group* group = reinterpret_cast<VectorDrawable::Group*>(nativePtr);
- GroupPropertyValuesHolder* newHolder = new GroupPropertyValuesHolder(group, propertyId,
- startValue, endValue);
- return reinterpret_cast<jlong>(newHolder);
-}
-
-static jlong createPathDataPropertyHolder(JNIEnv*, jobject, jlong nativePtr, jlong startValuePtr,
- jlong endValuePtr) {
- VectorDrawable::Path* path = reinterpret_cast<VectorDrawable::Path*>(nativePtr);
- PathData* startData = reinterpret_cast<PathData*>(startValuePtr);
- PathData* endData = reinterpret_cast<PathData*>(endValuePtr);
- PathDataPropertyValuesHolder* newHolder = new PathDataPropertyValuesHolder(path,
- startData, endData);
- return reinterpret_cast<jlong>(newHolder);
-}
-
-static jlong createPathColorPropertyHolder(JNIEnv*, jobject, jlong nativePtr, jint propertyId,
- int startValue, jint endValue) {
- VectorDrawable::FullPath* fullPath = reinterpret_cast<VectorDrawable::FullPath*>(nativePtr);
- FullPathColorPropertyValuesHolder* newHolder = new FullPathColorPropertyValuesHolder(fullPath,
- propertyId, startValue, endValue);
- return reinterpret_cast<jlong>(newHolder);
-}
-
-static jlong createPathPropertyHolder(JNIEnv*, jobject, jlong nativePtr, jint propertyId,
- float startValue, jfloat endValue) {
- VectorDrawable::FullPath* fullPath = reinterpret_cast<VectorDrawable::FullPath*>(nativePtr);
- FullPathPropertyValuesHolder* newHolder = new FullPathPropertyValuesHolder(fullPath,
- propertyId, startValue, endValue);
- return reinterpret_cast<jlong>(newHolder);
-}
-
-static jlong createRootAlphaPropertyHolder(JNIEnv*, jobject, jlong nativePtr, jfloat startValue,
- float endValue) {
- VectorDrawable::Tree* tree = reinterpret_cast<VectorDrawable::Tree*>(nativePtr);
- RootAlphaPropertyValuesHolder* newHolder = new RootAlphaPropertyValuesHolder(tree,
- startValue, endValue);
- return reinterpret_cast<jlong>(newHolder);
-}
-static void setPropertyHolderData(JNIEnv* env, jobject, jlong propertyHolderPtr,
- jfloatArray srcData, jint length) {
-
- jfloat* propertyData = env->GetFloatArrayElements(srcData, nullptr);
- PropertyValuesHolder* holder = reinterpret_cast<PropertyValuesHolder*>(propertyHolderPtr);
- holder->setPropertyDataSource(propertyData, length);
- env->ReleaseFloatArrayElements(srcData, propertyData, JNI_ABORT);
-}
-static void start(JNIEnv* env, jobject, jlong animatorSetPtr, jobject finishListener) {
- PropertyValuesAnimatorSet* set = reinterpret_cast<PropertyValuesAnimatorSet*>(animatorSetPtr);
- // TODO: keep a ref count in finish listener
- AnimationListener* listener = createAnimationListener(env, finishListener);
- set->start(listener);
-}
-
-static void reverse(JNIEnv* env, jobject, jlong animatorSetPtr, jobject finishListener) {
- // TODO: implement reverse
-}
-
-static void end(JNIEnv*, jobject, jlong animatorSetPtr) {
- PropertyValuesAnimatorSet* set = reinterpret_cast<PropertyValuesAnimatorSet*>(animatorSetPtr);
- set->end();
-}
-
-static void reset(JNIEnv*, jobject, jlong animatorSetPtr) {
- PropertyValuesAnimatorSet* set = reinterpret_cast<PropertyValuesAnimatorSet*>(animatorSetPtr);
- set->reset();
-}
-
-static const JNINativeMethod gMethods[] = {
- {"nCreateAnimatorSet", "()J", (void*)createAnimatorSet},
- {"nAddAnimator", "(JJJJJI)V", (void*)addAnimator},
- {"nCreateGroupPropertyHolder", "!(JIFF)J", (void*)createGroupPropertyHolder},
- {"nCreatePathDataPropertyHolder", "!(JJJ)J", (void*)createPathDataPropertyHolder},
- {"nCreatePathColorPropertyHolder", "!(JIII)J", (void*)createPathColorPropertyHolder},
- {"nCreatePathPropertyHolder", "!(JIFF)J", (void*)createPathPropertyHolder},
- {"nCreateRootAlphaPropertyHolder", "!(JFF)J", (void*)createRootAlphaPropertyHolder},
- {"nSetPropertyHolderData", "(J[FI)V", (void*)setPropertyHolderData},
- {"nStart", "(JLandroid/graphics/drawable/AnimatedVectorDrawable$VectorDrawableAnimator;)V", (void*)start},
- {"nReverse", "(JLandroid/graphics/drawable/AnimatedVectorDrawable$VectorDrawableAnimator;)V", (void*)reverse},
- {"nEnd", "!(J)V", (void*)end},
- {"nReset", "!(J)V", (void*)reset},
-};
-
-const char* const kClassPathName = "android/graphics/drawable/AnimatedVectorDrawable$VectorDrawableAnimator";
-int register_android_graphics_drawable_AnimatedVectorDrawable(JNIEnv* env) {
- gVectorDrawableAnimatorClassInfo.clazz = FindClassOrDie(env, kClassPathName);
- gVectorDrawableAnimatorClassInfo.clazz = MakeGlobalRefOrDie(env,
- gVectorDrawableAnimatorClassInfo.clazz);
-
- gVectorDrawableAnimatorClassInfo.callOnFinished = GetStaticMethodIDOrDie(
- env, gVectorDrawableAnimatorClassInfo.clazz, "callOnFinished",
- "(Landroid/graphics/drawable/AnimatedVectorDrawable$VectorDrawableAnimator;)V");
- return RegisterMethodsOrDie(env, "android/graphics/drawable/AnimatedVectorDrawable",
- gMethods, NELEM(gMethods));
-}
-
-}; // namespace android
diff --git a/core/jni/android_graphics_drawable_VectorDrawable.cpp b/core/jni/android_graphics_drawable_VectorDrawable.cpp
index e882876..563ec8b 100644
--- a/core/jni/android_graphics_drawable_VectorDrawable.cpp
+++ b/core/jni/android_graphics_drawable_VectorDrawable.cpp
@@ -32,6 +32,11 @@
return reinterpret_cast<jlong>(tree);
}
+static void deleteTree(JNIEnv*, jobject, jlong treePtr) {
+ VectorDrawable::Tree* tree = reinterpret_cast<VectorDrawable::Tree*>(treePtr);
+ delete tree;
+}
+
static void setTreeViewportSize(JNIEnv*, jobject, jlong treePtr,
jfloat viewportWidth, jfloat viewportHeight) {
VectorDrawable::Tree* tree = reinterpret_cast<VectorDrawable::Tree*>(treePtr);
@@ -328,6 +333,7 @@
static const JNINativeMethod gMethods[] = {
{"nCreateRenderer", "!(J)J", (void*)createTree},
+ {"nDestroyRenderer", "!(J)V", (void*)deleteTree},
{"nSetRendererViewportSize", "!(JFF)V", (void*)setTreeViewportSize},
{"nSetRootAlpha", "!(JF)Z", (void*)setRootAlpha},
{"nGetRootAlpha", "!(J)F", (void*)getRootAlpha},
diff --git a/core/jni/android_view_RenderNode.cpp b/core/jni/android_view_RenderNode.cpp
index b1d4e26..a9003c1 100644
--- a/core/jni/android_view_RenderNode.cpp
+++ b/core/jni/android_view_RenderNode.cpp
@@ -15,6 +15,7 @@
*/
#define LOG_TAG "OpenGLRenderer"
+#define ATRACE_TAG ATRACE_TAG_VIEW
#include <EGL/egl.h>
@@ -24,7 +25,10 @@
#include <android_runtime/AndroidRuntime.h>
#include <Animator.h>
+#include <DamageAccumulator.h>
+#include <Matrix.h>
#include <RenderNode.h>
+#include <TreeInfo.h>
#include <Paint.h>
#include "core_jni_helpers.h"
@@ -462,6 +466,69 @@
}
// ----------------------------------------------------------------------------
+// SurfaceView position callback
+// ----------------------------------------------------------------------------
+
+jmethodID gSurfaceViewPositionUpdateMethod;
+
+static void android_view_RenderNode_requestPositionUpdates(JNIEnv* env, jobject,
+ jlong renderNodePtr, jobject surfaceview) {
+ class SurfaceViewPositionUpdater : public RenderNode::PositionListener {
+ public:
+ SurfaceViewPositionUpdater(JNIEnv* env, jobject surfaceview) {
+ env->GetJavaVM(&mVm);
+ mWeakRef = env->NewWeakGlobalRef(surfaceview);
+ }
+
+ virtual ~SurfaceViewPositionUpdater() {
+ jnienv()->DeleteWeakGlobalRef(mWeakRef);
+ mWeakRef = nullptr;
+ }
+
+ virtual void onPositionUpdated(RenderNode& node, const TreeInfo& info) override {
+ if (CC_UNLIKELY(!mWeakRef || !info.updateWindowPositions)) return;
+ ATRACE_NAME("Update SurfaceView position");
+
+ JNIEnv* env = jnienv();
+ jobject localref = env->NewLocalRef(mWeakRef);
+ if (CC_UNLIKELY(!localref)) {
+ jnienv()->DeleteWeakGlobalRef(mWeakRef);
+ mWeakRef = nullptr;
+ return;
+ }
+ Matrix4 transform;
+ info.damageAccumulator->computeCurrentTransform(&transform);
+ const RenderProperties& props = node.properties();
+ uirenderer::Rect bounds(props.getWidth(), props.getHeight());
+ transform.mapRect(bounds);
+ bounds.left -= info.windowInsetLeft;
+ bounds.right -= info.windowInsetLeft;
+ bounds.top -= info.windowInsetTop;
+ bounds.bottom -= info.windowInsetTop;
+ env->CallVoidMethod(localref, gSurfaceViewPositionUpdateMethod,
+ (jlong) info.frameNumber, (jint) bounds.left, (jint) bounds.top,
+ (jint) bounds.right, (jint) bounds.bottom);
+ env->DeleteLocalRef(localref);
+ }
+
+ private:
+ JNIEnv* jnienv() {
+ JNIEnv* env;
+ if (mVm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
+ LOG_ALWAYS_FATAL("Failed to get JNIEnv for JavaVM: %p", mVm);
+ }
+ return env;
+ }
+
+ JavaVM* mVm;
+ jobject mWeakRef;
+ };
+
+ RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr);
+ renderNode->setPositionListener(new SurfaceViewPositionUpdater(env, surfaceview));
+}
+
+// ----------------------------------------------------------------------------
// JNI Glue
// ----------------------------------------------------------------------------
@@ -539,9 +606,14 @@
{ "nAddAnimator", "(JJ)V", (void*) android_view_RenderNode_addAnimator },
{ "nEndAllAnimators", "(J)V", (void*) android_view_RenderNode_endAllAnimators },
+
+ { "nRequestPositionUpdates", "(JLandroid/view/SurfaceView;)V", (void*) android_view_RenderNode_requestPositionUpdates },
};
int register_android_view_RenderNode(JNIEnv* env) {
+ jclass clazz = FindClassOrDie(env, "android/view/SurfaceView");
+ gSurfaceViewPositionUpdateMethod = GetMethodIDOrDie(env, clazz,
+ "updateWindowPositionRT", "(JIIII)V");
return RegisterMethodsOrDie(env, kClassPathName, gMethods, NELEM(gMethods));
}
diff --git a/core/jni/android_view_ThreadedRenderer.cpp b/core/jni/android_view_ThreadedRenderer.cpp
index 8c907dd..acd0501 100644
--- a/core/jni/android_view_ThreadedRenderer.cpp
+++ b/core/jni/android_view_ThreadedRenderer.cpp
@@ -134,7 +134,14 @@
virtual void prepareTree(TreeInfo& info) {
info.errorHandler = this;
+ // TODO: This is hacky
+ info.windowInsetLeft = -stagingProperties().getLeft();
+ info.windowInsetTop = -stagingProperties().getTop();
+ info.updateWindowPositions = true;
RenderNode::prepareTree(info);
+ info.updateWindowPositions = false;
+ info.windowInsetLeft = 0;
+ info.windowInsetTop = 0;
info.errorHandler = NULL;
}
@@ -369,28 +376,28 @@
static void android_view_ThreadedRenderer_initialize(JNIEnv* env, jobject clazz,
jlong proxyPtr, jobject jsurface) {
RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
- sp<ANativeWindow> window = android_view_Surface_getNativeWindow(env, jsurface);
- proxy->initialize(window);
+ sp<Surface> surface = android_view_Surface_getSurface(env, jsurface);
+ proxy->initialize(surface);
}
static void android_view_ThreadedRenderer_updateSurface(JNIEnv* env, jobject clazz,
jlong proxyPtr, jobject jsurface) {
RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
- sp<ANativeWindow> window;
+ sp<Surface> surface;
if (jsurface) {
- window = android_view_Surface_getNativeWindow(env, jsurface);
+ surface = android_view_Surface_getSurface(env, jsurface);
}
- proxy->updateSurface(window);
+ proxy->updateSurface(surface);
}
static jboolean android_view_ThreadedRenderer_pauseSurface(JNIEnv* env, jobject clazz,
jlong proxyPtr, jobject jsurface) {
RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
- sp<ANativeWindow> window;
+ sp<Surface> surface;
if (jsurface) {
- window = android_view_Surface_getNativeWindow(env, jsurface);
+ surface = android_view_Surface_getSurface(env, jsurface);
}
- return proxy->pauseSurface(window);
+ return proxy->pauseSurface(surface);
}
static void android_view_ThreadedRenderer_setup(JNIEnv* env, jobject clazz, jlong proxyPtr,
diff --git a/core/res/res/drawable/ic_close.xml b/core/res/res/drawable/ic_close.xml
new file mode 100644
index 0000000..7086959
--- /dev/null
+++ b/core/res/res/drawable/ic_close.xml
@@ -0,0 +1,24 @@
+<!--
+Copyright (C) 2016 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24.0dp"
+ android:height="24.0dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:pathData="M19.000000,6.400000l-1.400000,-1.400000 -5.600000,5.600000 -5.600000,-5.600000 -1.400000,1.400000 5.600000,5.600000 -5.600000,5.600000 1.400000,1.400000 5.600000,-5.600000 5.600000,5.600000 1.400000,-1.400000 -5.600000,-5.600000z"
+ android:fillColor="#FF000000"/>
+</vector>
diff --git a/core/res/res/drawable/ic_feedback.xml b/core/res/res/drawable/ic_feedback.xml
new file mode 100644
index 0000000..b2d1cb8
--- /dev/null
+++ b/core/res/res/drawable/ic_feedback.xml
@@ -0,0 +1,27 @@
+<!--
+Copyright (C) 2016 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24.0dp"
+ android:height="24.0dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:pathData="M0 0h24v24H0z"
+ android:fillColor="#00000000"/>
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M20.0,2.0L4.0,2.0c-1.1,0.0 -1.9,0.9 -1.99,2.0L2.0,22.0l4.0,-4.0l14.0,0.0c1.1,0.0 2.0,-0.9 2.0,-2.0L22.0,4.0c0.0,-1.1 -0.9,-2.0 -2.0,-2.0zm-7.0,12.0l-2.0,0.0l0.0,-2.0l2.0,0.0l0.0,2.0zm0.0,-4.0l-2.0,0.0L11.0,6.0l2.0,0.0l0.0,4.0z"/>
+</vector>
diff --git a/core/res/res/drawable/ic_refresh.xml b/core/res/res/drawable/ic_refresh.xml
new file mode 100644
index 0000000..1f67168
--- /dev/null
+++ b/core/res/res/drawable/ic_refresh.xml
@@ -0,0 +1,27 @@
+<!--
+Copyright (C) 2016 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24.0dp"
+ android:height="24.0dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M17.65,6.35C16.2,4.9 14.21,4.0 12.0,4.0c-4.42,0.0 -7.99,3.58 -7.99,8.0s3.57,8.0 7.99,8.0c3.73,0.0 6.84,-2.55 7.73,-6.0l-2.08,0.0c-0.82,2.33 -3.04,4.0 -5.65,4.0 -3.31,0.0 -6.0,-2.69 -6.0,-6.0s2.69,-6.0 6.0,-6.0c1.66,0.0 3.1,0.69 4.22,1.78L13.0,11.0l7.0,0.0L20.0,4.0l-2.35,2.35z"/>
+ <path
+ android:pathData="M0 0h24v24H0z"
+ android:fillColor="#00000000"/>
+</vector>
diff --git a/core/res/res/drawable/ic_schedule.xml b/core/res/res/drawable/ic_schedule.xml
new file mode 100644
index 0000000..899dc82
--- /dev/null
+++ b/core/res/res/drawable/ic_schedule.xml
@@ -0,0 +1,30 @@
+<!--
+Copyright (C) 2016 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24.0dp"
+ android:height="24.0dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M11.99,2.0C6.47,2.0 2.0,6.48 2.0,12.0s4.47,10.0 9.99,10.0C17.52,22.0 22.0,17.52 22.0,12.0S17.52,2.0 11.99,2.0zM12.0,20.0c-4.42,0.0 -8.0,-3.58 -8.0,-8.0s3.58,-8.0 8.0,-8.0 8.0,3.58 8.0,8.0 -3.58,8.0 -8.0,8.0z"/>
+ <path
+ android:pathData="M0 0h24v24H0z"
+ android:fillColor="#00000000"/>
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M12.5,7.0L11.0,7.0l0.0,6.0l5.25,3.1 0.75,-1.23 -4.5,-2.67z"/>
+</vector>
diff --git a/core/res/res/layout/app_anr_dialog.xml b/core/res/res/layout/app_anr_dialog.xml
index e8169ee..8bef116 100644
--- a/core/res/res/layout/app_anr_dialog.xml
+++ b/core/res/res/layout/app_anr_dialog.xml
@@ -18,28 +18,31 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
- android:paddingTop="@dimen/dialog_list_padding_vertical_material"
+ android:paddingTop="@dimen/aerr_padding_list_top"
android:paddingBottom="@dimen/dialog_list_padding_vertical_material">
- <TextView
+ <Button
android:id="@+id/aerr_close"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/aerr_close_app"
+ android:drawableStart="@drawable/ic_close"
style="@style/aerr_list_item" />
- <TextView
+ <Button
android:id="@+id/aerr_wait"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/aerr_wait"
+ android:drawableStart="@drawable/ic_schedule"
style="@style/aerr_list_item" />
- <TextView
+ <Button
android:id="@+id/aerr_report"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/aerr_report"
+ android:drawableStart="@drawable/ic_feedback"
style="@style/aerr_list_item" />
</LinearLayout>
diff --git a/core/res/res/layout/app_error_dialog.xml b/core/res/res/layout/app_error_dialog.xml
index 46a2b2a..824f97f 100644
--- a/core/res/res/layout/app_error_dialog.xml
+++ b/core/res/res/layout/app_error_dialog.xml
@@ -21,9 +21,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
- android:paddingTop="@dimen/dialog_list_padding_vertical_material"
- android:paddingBottom="@dimen/dialog_list_padding_vertical_material"
->
+ android:paddingTop="@dimen/aerr_padding_list_top"
+ android:paddingBottom="@dimen/dialog_list_padding_vertical_material">
<Button
@@ -31,6 +30,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/aerr_restart"
+ android:drawableStart="@drawable/ic_refresh"
style="@style/aerr_list_item"
/>
@@ -39,6 +39,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/aerr_reset"
+ android:drawableStart="@drawable/ic_refresh"
style="@style/aerr_list_item"
/>
@@ -47,6 +48,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/aerr_report"
+ android:drawableStart="@drawable/ic_feedback"
style="@style/aerr_list_item"
/>
@@ -55,6 +57,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/aerr_close"
+ android:drawableStart="@drawable/ic_close"
style="@style/aerr_list_item"
/>
@@ -63,6 +66,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/aerr_mute"
+ android:drawableStart="@drawable/ic_close"
style="@style/aerr_list_item"
/>
diff --git a/core/res/res/layout/notification_template_header.xml b/core/res/res/layout/notification_template_header.xml
index b45f8bb..6669bae 100644
--- a/core/res/res/layout/notification_template_header.xml
+++ b/core/res/res/layout/notification_template_header.xml
@@ -87,7 +87,6 @@
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:visibility="gone"
- android:maxWidth="72dp"
android:singleLine="true"/>
<TextView
android:id="@+id/time_divider"
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 7c6f338..8e86f78 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -449,5 +449,7 @@
<item type="dimen" format="integer" name="time_picker_column_start_material">0</item>
<item type="dimen" format="integer" name="time_picker_column_end_material">1</item>
+ <item type="dimen" name="aerr_padding_list_top">15dp</item>
+
<item type="fraction" name="docked_stack_divider_fixed_ratio">34.15%</item>
</resources>
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index f0960c7..86b9f1d 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -1403,8 +1403,12 @@
<item name="textAppearance">?attr/textAppearanceListItemSmall</item>
<item name="textColor">?attr/textColorAlertDialogListItem</item>
<item name="gravity">center_vertical</item>
- <item name="paddingStart">?attr/listPreferredItemPaddingStart</item>
- <item name="paddingEnd">?attr/listPreferredItemPaddingEnd</item>
+ <item name="paddingStart">?attr/dialogPreferredPadding</item>
+ <item name="paddingEnd">?attr/dialogPreferredPadding</item>
+ <item name="background">?attr/selectableItemBackground</item>
+ <item name="drawablePadding">32dp</item>
+ <item name="drawableTint">@color/accent_material_light</item>
+ <item name="drawableTintMode">src_atop</item>
</style>
<!-- Wifi dialog styles -->
diff --git a/data/fonts/Android.mk b/data/fonts/Android.mk
index d2bd106..de741b3 100644
--- a/data/fonts/Android.mk
+++ b/data/fonts/Android.mk
@@ -89,10 +89,7 @@
endef
font_src_files := \
- Clockopia.ttf \
- AndroidClock.ttf \
- AndroidClock_Highlight.ttf \
- AndroidClock_Solid.ttf
+ AndroidClock.ttf
$(foreach f, $(font_src_files), $(call build-one-font-module, $(f)))
diff --git a/data/fonts/AndroidClock_Highlight.ttf b/data/fonts/AndroidClock_Highlight.ttf
deleted file mode 100644
index 923bb30..0000000
--- a/data/fonts/AndroidClock_Highlight.ttf
+++ /dev/null
Binary files differ
diff --git a/data/fonts/AndroidClock_Solid.ttf b/data/fonts/AndroidClock_Solid.ttf
deleted file mode 100644
index 923bb30..0000000
--- a/data/fonts/AndroidClock_Solid.ttf
+++ /dev/null
Binary files differ
diff --git a/data/fonts/Clockopia.ttf b/data/fonts/Clockopia.ttf
deleted file mode 100644
index 3f7b6aa..0000000
--- a/data/fonts/Clockopia.ttf
+++ /dev/null
Binary files differ
diff --git a/data/fonts/MTLc3m.ttf b/data/fonts/MTLc3m.ttf
deleted file mode 100644
index e9018f6..0000000
--- a/data/fonts/MTLc3m.ttf
+++ /dev/null
Binary files differ
diff --git a/data/fonts/MTLmr3m.ttf b/data/fonts/MTLmr3m.ttf
deleted file mode 100644
index 14f27d4..0000000
--- a/data/fonts/MTLmr3m.ttf
+++ /dev/null
Binary files differ
diff --git a/data/fonts/fonts.mk b/data/fonts/fonts.mk
index 597a122..acd785e 100644
--- a/data/fonts/fonts.mk
+++ b/data/fonts/fonts.mk
@@ -20,7 +20,4 @@
PRODUCT_PACKAGES := \
DroidSansFallback.ttf \
DroidSansMono.ttf \
- Clockopia.ttf \
AndroidClock.ttf \
- AndroidClock_Highlight.ttf \
- AndroidClock_Solid.ttf \
diff --git a/graphics/java/android/graphics/Rect.java b/graphics/java/android/graphics/Rect.java
index 40dbe27..0cde0b9 100644
--- a/graphics/java/android/graphics/Rect.java
+++ b/graphics/java/android/graphics/Rect.java
@@ -335,6 +335,21 @@
}
/**
+ * Insets the rectangle on all sides specified by the insets.
+ * @hide
+ * @param left The amount to add from the rectangle's left
+ * @param top The amount to add from the rectangle's top
+ * @param right The amount to subtract from the rectangle's right
+ * @param bottom The amount to subtract from the rectangle's bottom
+ */
+ public void inset(int left, int top, int right, int bottom) {
+ this.left += left;
+ this.top += top;
+ this.right -= right;
+ this.bottom -= bottom;
+ }
+
+ /**
* Returns true if (x,y) is inside the rectangle. The left and top are
* considered to be inside, while the right and bottom are not. This means
* that for a x,y to be contained: left <= x < right and top <= y < bottom.
diff --git a/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java b/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java
index 21ed7dd..c48c371 100644
--- a/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java
+++ b/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java
@@ -19,10 +19,6 @@
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.Animator.AnimatorListener;
-import android.animation.PropertyValuesHolder;
-import android.animation.TimeInterpolator;
-import android.animation.ValueAnimator;
-import android.animation.ObjectAnimator;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.res.ColorStateList;
@@ -38,23 +34,14 @@
import android.util.ArrayMap;
import android.util.AttributeSet;
import android.util.Log;
-import android.util.LongArray;
-import android.util.PathParser;
-import android.util.TimeUtils;
-import android.view.Choreographer;
-import android.view.DisplayListCanvas;
-import android.view.RenderNode;
-import android.view.RenderNodeAnimatorSetHelper;
import android.view.View;
import com.android.internal.R;
-import com.android.internal.util.VirtualRefBasePtr;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
-import java.lang.ref.WeakReference;
import java.util.ArrayList;
/**
@@ -151,7 +138,7 @@
private static final boolean DBG_ANIMATION_VECTOR_DRAWABLE = false;
/** Local, mutable animator set. */
- private final VectorDrawableAnimator mAnimatorSet = new VectorDrawableAnimator();
+ private final AnimatorSet mAnimatorSet = new AnimatorSet();
/**
* The resources against which this drawable was created. Used to attempt
@@ -213,9 +200,6 @@
@Override
public void draw(Canvas canvas) {
- if (canvas.isHardwareAccelerated()) {
- mAnimatorSet.recordLastSeenTarget((DisplayListCanvas) canvas);
- }
mAnimatedVectorState.mVectorDrawable.draw(canvas);
if (isStarted()) {
invalidateSelf();
@@ -598,8 +582,9 @@
* Resets the AnimatedVectorDrawable to the start state as specified in the animators.
*/
public void reset() {
- mAnimatorSet.reset();
- invalidateSelf();
+ // TODO: Use reverse or seek to implement reset, when AnimatorSet supports them.
+ start();
+ mAnimatorSet.cancel();
}
@Override
@@ -618,12 +603,8 @@
@NonNull
private void ensureAnimatorSet() {
if (!mHasAnimatorSet) {
- // TODO: Skip the AnimatorSet creation and init the VectorDrawableAnimator directly
- // with a list of LocalAnimators.
- AnimatorSet set = new AnimatorSet();
- mAnimatedVectorState.prepareLocalAnimators(set, mRes);
+ mAnimatedVectorState.prepareLocalAnimators(mAnimatorSet, mRes);
mHasAnimatorSet = true;
- mAnimatorSet.initWithAnimatorSet(set);
mRes = null;
}
}
@@ -713,13 +694,13 @@
}
};
}
- mAnimatorSet.setListener(mAnimatorListener);
+ mAnimatorSet.addListener(mAnimatorListener);
}
// A helper function to clean up the animator listener in the mAnimatorSet.
private void removeAnimatorSetListener() {
if (mAnimatorListener != null) {
- mAnimatorSet.removeListener();
+ mAnimatorSet.removeListener(mAnimatorListener);
mAnimatorListener = null;
}
}
@@ -748,407 +729,4 @@
mAnimationCallbacks.clear();
}
-
- /**
- * @hide
- */
- public static class VectorDrawableAnimator {
- private AnimatorListener mListener = null;
- private final LongArray mStartDelays = new LongArray();
- private PropertyValuesHolder.PropertyValues mTmpValues =
- new PropertyValuesHolder.PropertyValues();
- private long mSetPtr = 0;
- private boolean mContainsSequentialAnimators = false;
- private boolean mStarted = false;
- private boolean mInitialized = false;
- private boolean mAnimationPending = false;
- private boolean mIsReversible = false;
- // TODO: Consider using NativeAllocationRegistery to track native allocation
- private final VirtualRefBasePtr mSetRefBasePtr;
- private WeakReference<RenderNode> mTarget = null;
- private WeakReference<RenderNode> mLastSeenTarget = null;
-
-
- VectorDrawableAnimator() {
- mSetPtr = nCreateAnimatorSet();
- // Increment ref count on native AnimatorSet, so it doesn't get released before Java
- // side is done using it.
- mSetRefBasePtr = new VirtualRefBasePtr(mSetPtr);
- }
-
- private void initWithAnimatorSet(AnimatorSet set) {
- if (mInitialized) {
- // Already initialized
- throw new UnsupportedOperationException("VectorDrawableAnimator cannot be " +
- "re-initialized");
- }
- parseAnimatorSet(set, 0);
- mInitialized = true;
-
- // Check reversible.
- if (mContainsSequentialAnimators) {
- mIsReversible = false;
- } else {
- // Check if there's any start delay set on child
- for (int i = 0; i < mStartDelays.size(); i++) {
- if (mStartDelays.get(i) > 0) {
- mIsReversible = false;
- return;
- }
- }
- }
- mIsReversible = true;
- }
-
- private void parseAnimatorSet(AnimatorSet set, long startTime) {
- ArrayList<Animator> animators = set.getChildAnimations();
-
- boolean playTogether = set.shouldPlayTogether();
- // Convert AnimatorSet to VectorDrawableAnimator
- for (int i = 0; i < animators.size(); i++) {
- Animator animator = animators.get(i);
- // Here we only support ObjectAnimator
- if (animator instanceof AnimatorSet) {
- parseAnimatorSet((AnimatorSet) animator, startTime);
- } else if (animator instanceof ObjectAnimator) {
- createRTAnimator((ObjectAnimator) animator, startTime);
- } // ignore ValueAnimators and others because they don't directly modify VD
- // therefore will be useless to AVD.
-
- if (!playTogether) {
- // Assume not play together means play sequentially
- startTime += animator.getTotalDuration();
- mContainsSequentialAnimators = true;
- }
- }
- }
-
- // TODO: This method reads animation data from already parsed Animators. We need to move
- // this step further up the chain in the parser to avoid the detour.
- private void createRTAnimator(ObjectAnimator animator, long startTime) {
- PropertyValuesHolder[] values = animator.getValues();
- Object target = animator.getTarget();
- if (target instanceof VectorDrawable.VGroup) {
- createRTAnimatorForGroup(values, animator, (VectorDrawable.VGroup) target,
- startTime);
- } else if (target instanceof VectorDrawable.VPath) {
- for (int i = 0; i < values.length; i++) {
- values[i].getPropertyValues(mTmpValues);
- if (mTmpValues.endValue instanceof PathParser.PathData &&
- mTmpValues.propertyName.equals("pathData")) {
- createRTAnimatorForPath(animator, (VectorDrawable.VPath) target,
- startTime);
- } else if (target instanceof VectorDrawable.VFullPath) {
- createRTAnimatorForFullPath(animator, (VectorDrawable.VFullPath) target,
- startTime);
- } else {
- throw new IllegalArgumentException("ClipPath only supports PathData " +
- "property");
- }
-
- }
- } else if (target instanceof VectorDrawable.VectorDrawableState) {
- createRTAnimatorForRootGroup(values, animator,
- (VectorDrawable.VectorDrawableState) target, startTime);
- } else {
- // Should never get here
- throw new UnsupportedOperationException("Target should be group, path or vector. " +
- target == null ? "Null target" : target.getClass() + " is not supported");
- }
- }
-
- private void createRTAnimatorForGroup(PropertyValuesHolder[] values,
- ObjectAnimator animator, VectorDrawable.VGroup target,
- long startTime) {
-
- long nativePtr = target.getNativePtr();
- int propertyId;
- for (int i = 0; i < values.length; i++) {
- // TODO: We need to support the rare case in AVD where no start value is provided
- values[i].getPropertyValues(mTmpValues);
- propertyId = VectorDrawable.VGroup.getPropertyIndex(mTmpValues.propertyName);
- if (mTmpValues.type != Float.class && mTmpValues.type != float.class) {
- if (DBG_ANIMATION_VECTOR_DRAWABLE) {
- Log.e(LOGTAG, "Unsupported type: " +
- mTmpValues.type + ". Only float value is supported for Groups.");
- }
- continue;
- }
- if (propertyId < 0) {
- if (DBG_ANIMATION_VECTOR_DRAWABLE) {
- Log.e(LOGTAG, "Unsupported property: " +
- mTmpValues.propertyName + " for Vector Drawable Group");
- }
- continue;
- }
- long propertyPtr = nCreateGroupPropertyHolder(nativePtr, propertyId,
- (Float) mTmpValues.startValue, (Float) mTmpValues.endValue);
- if (mTmpValues.dataSource != null) {
- float[] dataPoints = createDataPoints(mTmpValues.dataSource, animator
- .getDuration());
- nSetPropertyHolderData(propertyPtr, dataPoints, dataPoints.length);
- }
- createNativeChildAnimator(propertyPtr, startTime, animator);
- }
- }
- private void createRTAnimatorForPath( ObjectAnimator animator, VectorDrawable.VPath target,
- long startTime) {
-
- long nativePtr = target.getNativePtr();
- long startPathDataPtr = ((PathParser.PathData) mTmpValues.startValue)
- .getNativePtr();
- long endPathDataPtr = ((PathParser.PathData) mTmpValues.endValue)
- .getNativePtr();
- long propertyPtr = nCreatePathDataPropertyHolder(nativePtr, startPathDataPtr,
- endPathDataPtr);
- createNativeChildAnimator(propertyPtr, startTime, animator);
- }
-
- private void createRTAnimatorForFullPath(ObjectAnimator animator,
- VectorDrawable.VFullPath target, long startTime) {
-
- int propertyId = target.getPropertyIndex(mTmpValues.propertyName);
- long propertyPtr;
- long nativePtr = target.getNativePtr();
- if (mTmpValues.type == Float.class || mTmpValues.type == float.class) {
- if (propertyId < 0) {
- throw new IllegalArgumentException("Property: " + mTmpValues
- .propertyName + " is not supported for FullPath");
- }
- propertyPtr = nCreatePathPropertyHolder(nativePtr, propertyId,
- (Float) mTmpValues.startValue, (Float) mTmpValues.endValue);
-
- } else if (mTmpValues.type == Integer.class || mTmpValues.type == int.class) {
- propertyPtr = nCreatePathColorPropertyHolder(nativePtr, propertyId,
- (Integer) mTmpValues.startValue, (Integer) mTmpValues.endValue);
- } else {
- throw new UnsupportedOperationException("Unsupported type: " +
- mTmpValues.type + ". Only float, int or PathData value is " +
- "supported for Paths.");
- }
- if (mTmpValues.dataSource != null) {
- float[] dataPoints = createDataPoints(mTmpValues.dataSource, animator
- .getDuration());
- nSetPropertyHolderData(propertyPtr, dataPoints, dataPoints.length);
- }
- createNativeChildAnimator(propertyPtr, startTime, animator);
- }
-
- private void createRTAnimatorForRootGroup(PropertyValuesHolder[] values,
- ObjectAnimator animator, VectorDrawable.VectorDrawableState target,
- long startTime) {
- long nativePtr = target.getNativeRenderer();
- if (!animator.getPropertyName().equals("alpha")) {
- throw new UnsupportedOperationException("Only alpha is supported for root " +
- "group");
- }
- Float startValue = null;
- Float endValue = null;
- for (int i = 0; i < values.length; i++) {
- values[i].getPropertyValues(mTmpValues);
- if (mTmpValues.propertyName.equals("alpha")) {
- startValue = (Float) mTmpValues.startValue;
- endValue = (Float) mTmpValues.endValue;
- break;
- }
- }
- if (startValue == null && endValue == null) {
- throw new UnsupportedOperationException("No alpha values are specified");
- }
- long propertyPtr = nCreateRootAlphaPropertyHolder(nativePtr, startValue, endValue);
- createNativeChildAnimator(propertyPtr, startTime, animator);
- }
-
- // These are the data points that define the value of the animating properties.
- // e.g. translateX and translateY can animate along a Path, at any fraction in [0, 1]
- // a point on the path corresponds to the values of translateX and translateY.
- // TODO: (Optimization) We should pass the path down in native and chop it into segments
- // in native.
- private static float[] createDataPoints(
- PropertyValuesHolder.PropertyValues.DataSource dataSource, long duration) {
- long frameIntervalNanos = Choreographer.getInstance().getFrameIntervalNanos();
- int animIntervalMs = (int) (frameIntervalNanos / TimeUtils.NANOS_PER_MS);
- int numAnimFrames = (int) Math.ceil(((double) duration) / animIntervalMs);
- float values[] = new float[numAnimFrames];
- float lastFrame = numAnimFrames - 1;
- for (int i = 0; i < numAnimFrames; i++) {
- float fraction = i / lastFrame;
- values[i] = (Float) dataSource.getValueAtFraction(fraction);
- }
- return values;
- }
-
- private void createNativeChildAnimator(long propertyPtr, long extraDelay,
- ObjectAnimator animator) {
- long duration = animator.getDuration();
- int repeatCount = animator.getRepeatCount();
- long startDelay = extraDelay + animator.getStartDelay();
- TimeInterpolator interpolator = animator.getInterpolator();
- long nativeInterpolator =
- RenderNodeAnimatorSetHelper.createNativeInterpolator(interpolator, duration);
-
- startDelay *= ValueAnimator.getDurationScale();
- duration *= ValueAnimator.getDurationScale();
-
- mStartDelays.add(startDelay);
- nAddAnimator(mSetPtr, propertyPtr, nativeInterpolator, startDelay, duration,
- repeatCount);
- }
-
- /**
- * Holds a weak reference to the target that was last seen (through the DisplayListCanvas
- * in the last draw call), so that when animator set needs to start, we can add the animator
- * to the last seen RenderNode target and start right away.
- */
- protected void recordLastSeenTarget(DisplayListCanvas canvas) {
- if (mAnimationPending) {
- mLastSeenTarget = new WeakReference<RenderNode>(
- RenderNodeAnimatorSetHelper.getTarget(canvas));
- if (DBG_ANIMATION_VECTOR_DRAWABLE) {
- Log.d(LOGTAG, "Target is set in the next frame");
- }
- mAnimationPending = false;
- start();
- } else {
- mLastSeenTarget = new WeakReference<RenderNode>(
- RenderNodeAnimatorSetHelper.getTarget(canvas));
- }
-
- }
-
- private boolean setTarget(RenderNode node) {
- if (mTarget != null && mTarget.get() != null) {
- // TODO: Maybe we want to support target change.
- throw new IllegalStateException("Target already set!");
- }
-
- node.addAnimator(this);
- mTarget = new WeakReference<RenderNode>(node);
- return true;
- }
-
- private boolean useLastSeenTarget() {
- if (mLastSeenTarget != null && mLastSeenTarget.get() != null) {
- setTarget(mLastSeenTarget.get());
- return true;
- }
- return false;
- }
-
- public void start() {
- if (!mInitialized) {
- return;
- }
-
- if (mStarted) {
- return;
- }
-
- if (!useLastSeenTarget()) {
- mAnimationPending = true;
- return;
- }
-
- if (DBG_ANIMATION_VECTOR_DRAWABLE) {
- Log.d(LOGTAG, "Target is set. Starting VDAnimatorSet from java");
- }
-
- nStart(mSetPtr, this);
- if (mListener != null) {
- mListener.onAnimationStart(null);
- }
- mStarted = true;
- }
-
- public void end() {
- if (mInitialized && mStarted) {
- nEnd(mSetPtr);
- onAnimationEnd();
- }
- }
-
- void reset() {
- if (!mInitialized) {
- return;
- }
- // TODO: Need to implement reset.
- Log.w(LOGTAG, "Reset is yet to be implemented");
- nReset(mSetPtr);
- }
-
- // Current (imperfect) Java AnimatorSet cannot be reversed when the set contains sequential
- // animators or when the animator set has a start delay
- void reverse() {
- if (!mIsReversible) {
- return;
- }
- // TODO: Need to support reverse (non-public API)
- Log.w(LOGTAG, "Reverse is yet to be implemented");
- nReverse(mSetPtr, this);
- }
-
- public long getAnimatorNativePtr() {
- return mSetPtr;
- }
-
- boolean canReverse() {
- return mIsReversible;
- }
-
- boolean isStarted() {
- return mStarted;
- }
-
- boolean isRunning() {
- if (!mInitialized) {
- return false;
- }
- return mStarted;
- }
-
- void setListener(AnimatorListener listener) {
- mListener = listener;
- }
-
- void removeListener() {
- mListener = null;
- }
-
- private void onAnimationEnd() {
- mStarted = false;
- if (mListener != null) {
- mListener.onAnimationEnd(null);
- }
- mTarget = null;
- }
-
- // onFinished: should be called from native
- private static void callOnFinished(VectorDrawableAnimator set) {
- if (DBG_ANIMATION_VECTOR_DRAWABLE) {
- Log.d(LOGTAG, "on finished called from native");
- }
- set.onAnimationEnd();
- }
- }
-
- private static native long nCreateAnimatorSet();
- private static native void nAddAnimator(long setPtr, long propertyValuesHolder,
- long nativeInterpolator, long startDelay, long duration, int repeatCount);
-
- private static native long nCreateGroupPropertyHolder(long nativePtr, int propertyId,
- float startValue, float endValue);
-
- private static native long nCreatePathDataPropertyHolder(long nativePtr, long startValuePtr,
- long endValuePtr);
- private static native long nCreatePathColorPropertyHolder(long nativePtr, int propertyId,
- int startValue, int endValue);
- private static native long nCreatePathPropertyHolder(long nativePtr, int propertyId,
- float startValue, float endValue);
- private static native long nCreateRootAlphaPropertyHolder(long nativePtr, float startValue,
- float endValue);
- private static native void nSetPropertyHolderData(long nativePtr, float[] data, int length);
- private static native void nStart(long animatorSetPtr, VectorDrawableAnimator set);
- private static native void nReverse(long animatorSetPtr, VectorDrawableAnimator set);
- private static native void nEnd(long animatorSetPtr);
- private static native void nReset(long animatorSetPtr);
}
diff --git a/graphics/java/android/graphics/drawable/VectorDrawable.java b/graphics/java/android/graphics/drawable/VectorDrawable.java
index f4bbc8c..1fc1b83 100644
--- a/graphics/java/android/graphics/drawable/VectorDrawable.java
+++ b/graphics/java/android/graphics/drawable/VectorDrawable.java
@@ -39,7 +39,6 @@
import android.util.Xml;
import com.android.internal.R;
-import com.android.internal.util.VirtualRefBasePtr;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -48,7 +47,6 @@
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.Stack;
/**
@@ -524,13 +522,13 @@
public void inflate(@NonNull Resources r, @NonNull XmlPullParser parser,
@NonNull AttributeSet attrs, @Nullable Theme theme)
throws XmlPullParserException, IOException {
- if (mVectorState.mRootGroup != null || mVectorState.mNativeRendererRefBase != null) {
+ if (mVectorState.mRootGroup != null || mVectorState.mNativeRendererPtr != 0) {
// This VD has been used to display other VD resource content, clean up.
mVectorState.mRootGroup = new VGroup();
- if (mVectorState.mNativeRendererRefBase != null) {
- mVectorState.mNativeRendererRefBase.release();
+ if (mVectorState.mNativeRendererPtr != 0) {
+ nDestroyRenderer(mVectorState.mNativeRendererPtr);
}
- mVectorState.createNativeRenderer(mVectorState.mRootGroup.mNativePtr);
+ mVectorState.mNativeRendererPtr = nCreateRenderer(mVectorState.mRootGroup.mNativePtr);
}
final VectorDrawableState state = mVectorState;
state.setDensity(Drawable.resolveDensity(r, 0));
@@ -709,7 +707,7 @@
return mVectorState.mAutoMirrored;
}
- static class VectorDrawableState extends ConstantState {
+ private static class VectorDrawableState extends ConstantState {
// Variables below need to be copied (deep copy if applicable) for mutation.
int[] mThemeAttrs;
int mChangingConfigurations;
@@ -724,7 +722,7 @@
Insets mOpticalInsets = Insets.NONE;
String mRootName = null;
VGroup mRootGroup;
- VirtualRefBasePtr mNativeRendererRefBase = null;
+ long mNativeRendererPtr;
int mDensity = DisplayMetrics.DENSITY_DEFAULT;
final ArrayMap<String, Object> mVGTargetsMap = new ArrayMap<>();
@@ -745,7 +743,7 @@
mTintMode = copy.mTintMode;
mAutoMirrored = copy.mAutoMirrored;
mRootGroup = new VGroup(copy.mRootGroup, mVGTargetsMap);
- createNativeRenderer(mRootGroup.mNativePtr);
+ mNativeRendererPtr = nCreateRenderer(mRootGroup.mNativePtr);
mBaseWidth = copy.mBaseWidth;
mBaseHeight = copy.mBaseHeight;
@@ -760,15 +758,18 @@
}
}
- private void createNativeRenderer(long rootGroupPtr) {
- mNativeRendererRefBase = new VirtualRefBasePtr(nCreateRenderer(rootGroupPtr));
+ @Override
+ public void finalize() throws Throwable {
+ if (mNativeRendererPtr != 0) {
+ nDestroyRenderer(mNativeRendererPtr);
+ mNativeRendererPtr = 0;
+ }
+ super.finalize();
}
+
long getNativeRenderer() {
- if (mNativeRendererRefBase == null) {
- return 0;
- }
- return mNativeRendererRefBase.get();
+ return mNativeRendererPtr;
}
public boolean canReuseCache() {
@@ -807,7 +808,7 @@
public VectorDrawableState() {
mRootGroup = new VGroup();
- createNativeRenderer(mRootGroup.mNativePtr);
+ mNativeRendererPtr = nCreateRenderer(mRootGroup.mNativePtr);
}
@Override
@@ -871,16 +872,16 @@
* has changed.
*/
public boolean setAlpha(float alpha) {
- return nSetRootAlpha(mNativeRendererRefBase.get(), alpha);
+ return nSetRootAlpha(mNativeRendererPtr, alpha);
}
@SuppressWarnings("unused")
public float getAlpha() {
- return nGetRootAlpha(mNativeRendererRefBase.get());
+ return nGetRootAlpha(mNativeRendererPtr);
}
}
- static class VGroup implements VObject {
+ private static class VGroup implements VObject {
private static final int ROTATE_INDEX = 0;
private static final int PIVOT_X_INDEX = 1;
private static final int PIVOT_Y_INDEX = 2;
@@ -890,28 +891,6 @@
private static final int TRANSLATE_Y_INDEX = 6;
private static final int TRANSFORM_PROPERTY_COUNT = 7;
- private static final HashMap<String, Integer> sPropertyMap =
- new HashMap<String, Integer>() {
- {
- put("translateX", TRANSLATE_X_INDEX);
- put("translateY", TRANSLATE_Y_INDEX);
- put("scaleX", SCALE_X_INDEX);
- put("scaleY", SCALE_Y_INDEX);
- put("pivotX", PIVOT_X_INDEX);
- put("pivotY", PIVOT_Y_INDEX);
- put("rotation", ROTATE_INDEX);
- }
- };
-
- static int getPropertyIndex(String propertyName) {
- if (sPropertyMap.containsKey(propertyName)) {
- return sPropertyMap.get(propertyName);
- } else {
- // property not found
- return -1;
- }
- }
-
// Temp array to store transform values obtained from native.
private float[] mTransform;
/////////////////////////////////////////////////////
@@ -1170,7 +1149,7 @@
/**
* Common Path information for clip path and normal path.
*/
- static abstract class VPath implements VObject {
+ private static abstract class VPath implements VObject {
protected PathParser.PathData mPathData = null;
String mPathName;
@@ -1281,7 +1260,7 @@
/**
* Normal path, which contains all the fill / paint information.
*/
- static class VFullPath extends VPath {
+ private static class VFullPath extends VPath {
private static final int STROKE_WIDTH_INDEX = 0;
private static final int STROKE_COLOR_INDEX = 1;
private static final int STROKE_ALPHA_INDEX = 2;
@@ -1295,20 +1274,6 @@
private static final int STROKE_MITER_LIMIT_INDEX = 10;
private static final int TOTAL_PROPERTY_COUNT = 11;
- private final static HashMap<String, Integer> sPropertyMap
- = new HashMap<String, Integer> () {
- {
- put("strokeWidth", STROKE_WIDTH_INDEX);
- put("strokeColor", STROKE_COLOR_INDEX);
- put("strokeAlpha", STROKE_ALPHA_INDEX);
- put("fillColor", FILL_COLOR_INDEX);
- put("fillAlpha", FILL_ALPHA_INDEX);
- put("trimPathStart", TRIM_PATH_START_INDEX);
- put("trimPathEnd", TRIM_PATH_END_INDEX);
- put("trimPathOffset", TRIM_PATH_OFFSET_INDEX);
- }
- };
-
// Temp array to store property data obtained from native getter.
private byte[] mPropertyData;
/////////////////////////////////////////////////////
@@ -1332,14 +1297,6 @@
mFillColors = copy.mFillColors;
}
- int getPropertyIndex(String propertyName) {
- if (!sPropertyMap.containsKey(propertyName)) {
- return -1;
- } else {
- return sPropertyMap.get(propertyName);
- }
- }
-
@Override
public boolean onStateChange(int[] stateSet) {
boolean changed = false;
@@ -1638,6 +1595,7 @@
}
private static native long nCreateRenderer(long rootGroupPtr);
+ private static native void nDestroyRenderer(long rendererPtr);
private static native void nSetRendererViewportSize(long rendererPtr, float viewportWidth,
float viewportHeight);
private static native boolean nSetRootAlpha(long rendererPtr, float alpha);
diff --git a/libs/hwui/Android.mk b/libs/hwui/Android.mk
index 6988b02..54aafeaa 100644
--- a/libs/hwui/Android.mk
+++ b/libs/hwui/Android.mk
@@ -78,8 +78,6 @@
Program.cpp \
ProgramCache.cpp \
Properties.cpp \
- PropertyValuesHolder.cpp \
- PropertyValuesAnimatorSet.cpp \
RenderBufferCache.cpp \
RenderNode.cpp \
RenderProperties.cpp \
@@ -238,6 +236,7 @@
LOCAL_SRC_FILES += \
$(hwui_test_common_src_files) \
+ tests/unit/BufferPoolTests.cpp \
tests/unit/CanvasStateTests.cpp \
tests/unit/ClipAreaTests.cpp \
tests/unit/CrashHandlerInjector.cpp \
@@ -247,11 +246,11 @@
tests/unit/GpuMemoryTrackerTests.cpp \
tests/unit/LayerUpdateQueueTests.cpp \
tests/unit/LinearAllocatorTests.cpp \
- tests/unit/VectorDrawableTests.cpp \
tests/unit/OffscreenBufferPoolTests.cpp \
+ tests/unit/SkiaBehaviorTests.cpp \
tests/unit/StringUtilsTests.cpp \
- tests/unit/BufferPoolTests.cpp \
- tests/unit/TextDropShadowCacheTests.cpp
+ tests/unit/TextDropShadowCacheTests.cpp \
+ tests/unit/VectorDrawableTests.cpp
ifeq (true, $(HWUI_NEW_OPS))
LOCAL_SRC_FILES += \
@@ -315,7 +314,8 @@
tests/microbench/DisplayListCanvasBench.cpp \
tests/microbench/LinearAllocatorBench.cpp \
tests/microbench/PathParserBench.cpp \
- tests/microbench/ShadowBench.cpp
+ tests/microbench/ShadowBench.cpp \
+ tests/microbench/TaskManagerBench.cpp
ifeq (true, $(HWUI_NEW_OPS))
LOCAL_SRC_FILES += \
diff --git a/libs/hwui/Animator.cpp b/libs/hwui/Animator.cpp
index 7bd2b24..5ca2a2f 100644
--- a/libs/hwui/Animator.cpp
+++ b/libs/hwui/Animator.cpp
@@ -90,9 +90,6 @@
doSetStartValue(getValue(mTarget));
}
if (mStagingPlayState > mPlayState) {
- if (mStagingPlayState == PlayState::Restarted) {
- mStagingPlayState = PlayState::Running;
- }
mPlayState = mStagingPlayState;
// Oh boy, we're starting! Man the battle stations!
if (mPlayState == PlayState::Running) {
@@ -134,11 +131,6 @@
return true;
}
- // This should be set before setValue() so animators can query this time when setValue
- // is called.
- nsecs_t currentFrameTime = context.frameTimeMs();
- onPlayTimeChanged(currentFrameTime - mStartTime);
-
// If BaseRenderNodeAnimator is handling the delay (not typical), then
// because the staging properties reflect the final value, we always need
// to call setValue even if the animation isn't yet running or is still
@@ -149,9 +141,8 @@
}
float fraction = 1.0f;
-
if (mPlayState == PlayState::Running && mDuration > 0) {
- fraction = (float)(currentFrameTime - mStartTime) / mDuration;
+ fraction = (float)(context.frameTimeMs() - mStartTime) / mDuration;
}
if (fraction >= 1.0f) {
fraction = 1.0f;
diff --git a/libs/hwui/Animator.h b/libs/hwui/Animator.h
index 2c9c9c3..aea95bf 100644
--- a/libs/hwui/Animator.h
+++ b/libs/hwui/Animator.h
@@ -59,13 +59,7 @@
mMayRunAsync = mayRunAsync;
}
bool mayRunAsync() { return mMayRunAsync; }
- ANDROID_API void start() {
- if (mStagingPlayState == PlayState::NotStarted) {
- mStagingPlayState = PlayState::Running;
- } else {
- mStagingPlayState = PlayState::Restarted;
- }
- onStagingPlayStateChanged(); }
+ ANDROID_API void start() { mStagingPlayState = PlayState::Running; onStagingPlayStateChanged(); }
ANDROID_API void end() { mStagingPlayState = PlayState::Finished; onStagingPlayStateChanged(); }
void attach(RenderNode* target);
@@ -83,27 +77,10 @@
void forceEndNow(AnimationContext& context);
protected:
- // PlayState is used by mStagingPlayState and mPlayState to track the state initiated from UI
- // thread and Render Thread animation state, respectively.
- // From the UI thread, mStagingPlayState transition looks like
- // NotStarted -> Running -> Finished
- // ^ |
- // | |
- // Restarted <------
- // Note: For mStagingState, the Finished state (optional) is only set when the animation is
- // terminated by user.
- //
- // On Render Thread, mPlayState transition:
- // NotStart -> Running -> Finished
- // ^ |
- // | |
- // -------------
-
enum class PlayState {
NotStarted,
Running,
Finished,
- Restarted,
};
BaseRenderNodeAnimator(float finalValue);
@@ -116,7 +93,6 @@
void callOnFinishedListener(AnimationContext& context);
virtual void onStagingPlayStateChanged() {}
- virtual void onPlayTimeChanged(nsecs_t playTime) {}
RenderNode* mTarget;
diff --git a/libs/hwui/BakedOpDispatcher.cpp b/libs/hwui/BakedOpDispatcher.cpp
index 2184755..e3a5f3e 100644
--- a/libs/hwui/BakedOpDispatcher.cpp
+++ b/libs/hwui/BakedOpDispatcher.cpp
@@ -663,7 +663,7 @@
}
void BakedOpDispatcher::onShadowOp(BakedOpRenderer& renderer, const ShadowOp& op, const BakedOpState& state) {
- TessellationCache::vertexBuffer_pair_t buffers = *(op.shadowTask->getResult());
+ TessellationCache::vertexBuffer_pair_t buffers = op.shadowTask->getResult();
renderShadow(renderer, state, op.casterAlpha, buffers.first, buffers.second);
}
diff --git a/libs/hwui/Canvas.h b/libs/hwui/Canvas.h
index 27facdf..dbd502d 100644
--- a/libs/hwui/Canvas.h
+++ b/libs/hwui/Canvas.h
@@ -52,13 +52,6 @@
} // namespace SaveFlags
-namespace uirenderer {
-namespace VectorDrawable {
-class Tree;
-};
-};
-typedef uirenderer::VectorDrawable::Tree VectorDrawableRoot;
-
class ANDROID_API Canvas {
public:
virtual ~Canvas() {};
@@ -224,11 +217,6 @@
*/
virtual bool drawTextAbsolutePos() const = 0;
- /**
- * Draws a VectorDrawable onto the canvas.
- */
- virtual void drawVectorDrawable(VectorDrawableRoot* tree);
-
protected:
void drawTextDecorations(float x, float y, float length, const SkPaint& paint);
};
diff --git a/libs/hwui/ClipArea.cpp b/libs/hwui/ClipArea.cpp
index 160090d..9c08b4d 100644
--- a/libs/hwui/ClipArea.cpp
+++ b/libs/hwui/ClipArea.cpp
@@ -213,6 +213,7 @@
void ClipArea::clipRectWithTransform(const Rect& r, const mat4* transform,
SkRegion::Op op) {
+ if (!mPostViewportClipObserved && op == SkRegion::kIntersect_Op) op = SkRegion::kReplace_Op;
onClipUpdated();
switch (mMode) {
case ClipMode::Rectangle:
@@ -228,6 +229,7 @@
}
void ClipArea::clipRegion(const SkRegion& region, SkRegion::Op op) {
+ if (!mPostViewportClipObserved && op == SkRegion::kIntersect_Op) op = SkRegion::kReplace_Op;
onClipUpdated();
enterRegionMode();
mClipRegion.op(region, op);
@@ -236,6 +238,7 @@
void ClipArea::clipPathWithTransform(const SkPath& path, const mat4* transform,
SkRegion::Op op) {
+ if (!mPostViewportClipObserved && op == SkRegion::kIntersect_Op) op = SkRegion::kReplace_Op;
onClipUpdated();
SkMatrix skTransform;
transform->copyTo(skTransform);
diff --git a/libs/hwui/DamageAccumulator.h b/libs/hwui/DamageAccumulator.h
index e44fc20..250296e 100644
--- a/libs/hwui/DamageAccumulator.h
+++ b/libs/hwui/DamageAccumulator.h
@@ -57,7 +57,7 @@
// Returns the current dirty area, *NOT* transformed by pushed transforms
void peekAtDirty(SkRect* dest) const;
- void computeCurrentTransform(Matrix4* outMatrix) const;
+ ANDROID_API void computeCurrentTransform(Matrix4* outMatrix) const;
void finish(SkRect* totalDirty);
diff --git a/libs/hwui/DisplayListCanvas.cpp b/libs/hwui/DisplayListCanvas.cpp
index 3db14b5..7eaa785 100644
--- a/libs/hwui/DisplayListCanvas.cpp
+++ b/libs/hwui/DisplayListCanvas.cpp
@@ -16,12 +16,11 @@
#include "DisplayListCanvas.h"
+#include "ResourceCache.h"
#include "DeferredDisplayList.h"
#include "DeferredLayerUpdater.h"
#include "DisplayListOp.h"
-#include "ResourceCache.h"
#include "RenderNode.h"
-#include "VectorDrawable.h"
#include "utils/PaintUtils.h"
#include <SkCamera.h>
@@ -413,16 +412,6 @@
addDrawOp(new (alloc()) DrawPointsOp(points, count, refPaint(&paint)));
}
-void DisplayListCanvas::drawVectorDrawable(VectorDrawableRoot* tree) {
- mDisplayList->ref(tree);
- const SkBitmap& bitmap = tree->getBitmapUpdateIfDirty();
- SkPaint* paint = tree->getPaint();
- const SkRect bounds = tree->getBounds();
- addDrawOp(new (alloc()) DrawBitmapRectOp(refBitmap(bitmap),
- 0, 0, bitmap.width(), bitmap.height(),
- bounds.left(), bounds.top(), bounds.right(), bounds.bottom(), refPaint(paint)));
-}
-
void DisplayListCanvas::drawTextOnPath(const uint16_t* glyphs, int count,
const SkPath& path, float hOffset, float vOffset, const SkPaint& paint) {
if (!glyphs || count <= 0) return;
diff --git a/libs/hwui/DisplayListCanvas.h b/libs/hwui/DisplayListCanvas.h
index 06e72a0..ad93960 100644
--- a/libs/hwui/DisplayListCanvas.h
+++ b/libs/hwui/DisplayListCanvas.h
@@ -206,8 +206,6 @@
float dstLeft, float dstTop, float dstRight, float dstBottom,
const SkPaint* paint) override;
- virtual void drawVectorDrawable(VectorDrawableRoot* tree) override;
-
// Text
virtual void drawText(const uint16_t* glyphs, const float* positions, int count,
const SkPaint& paint, float x, float y, float boundsLeft, float boundsTop,
@@ -216,6 +214,7 @@
float hOffset, float vOffset, const SkPaint& paint) override;
virtual bool drawTextAbsolutePos() const override { return false; }
+
private:
CanvasState mState;
diff --git a/libs/hwui/FrameBuilder.cpp b/libs/hwui/FrameBuilder.cpp
index 57e5b9d..c8910cb 100644
--- a/libs/hwui/FrameBuilder.cpp
+++ b/libs/hwui/FrameBuilder.cpp
@@ -19,7 +19,6 @@
#include "Canvas.h"
#include "LayerUpdateQueue.h"
#include "RenderNode.h"
-#include "VectorDrawable.h"
#include "renderstate/OffscreenBufferPool.h"
#include "utils/FatVector.h"
#include "utils/PaintUtils.h"
@@ -203,7 +202,9 @@
mCanvasState.setClippingOutline(mAllocator, &(properties.getOutline()));
}
- if (!mCanvasState.quickRejectConservative(0, 0, width, height)) {
+ bool quickRejected = properties.getClipToBounds()
+ && mCanvasState.quickRejectConservative(0, 0, width, height);
+ if (!quickRejected) {
// not rejected, so defer render as either Layer, or direct (possibly wrapped in saveLayer)
if (node.getLayer()) {
// HW layer
@@ -544,18 +545,6 @@
currentLayer().deferUnmergeableOp(mAllocator, bakedState, OpBatchType::Bitmap);
}
-void FrameBuilder::deferVectorDrawableOp(const VectorDrawableOp& op) {
- const SkBitmap& bitmap = op.vectorDrawable->getBitmapUpdateIfDirty();
- SkPaint* paint = op.vectorDrawable->getPaint();
- const BitmapRectOp* resolvedOp = new (mAllocator) BitmapRectOp(op.unmappedBounds,
- op.localMatrix,
- op.localClip,
- paint,
- &bitmap,
- Rect(bitmap.width(), bitmap.height()));
- deferBitmapRectOp(*resolvedOp);
-}
-
void FrameBuilder::deferCirclePropsOp(const CirclePropsOp& op) {
// allocate a temporary oval op (with mAllocator, so it persists until render), so the
// renderer doesn't have to handle the RoundRectPropsOp type, and so state baking is simple.
diff --git a/libs/hwui/PropertyValuesAnimatorSet.cpp b/libs/hwui/PropertyValuesAnimatorSet.cpp
deleted file mode 100644
index eca1afcc..0000000
--- a/libs/hwui/PropertyValuesAnimatorSet.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (C) 2016 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 "PropertyValuesAnimatorSet.h"
-#include "RenderNode.h"
-
-namespace android {
-namespace uirenderer {
-
-void PropertyValuesAnimatorSet::addPropertyAnimator(PropertyValuesHolder* propertyValuesHolder,
- Interpolator* interpolator, nsecs_t startDelay,
- nsecs_t duration, int repeatCount) {
-
- PropertyAnimator* animator = new PropertyAnimator(propertyValuesHolder,
- interpolator, startDelay, duration, repeatCount);
- mAnimators.emplace_back(animator);
- setListener(new PropertyAnimatorSetListener(this));
-}
-
-PropertyValuesAnimatorSet::PropertyValuesAnimatorSet()
- : BaseRenderNodeAnimator(1.0f) {
- setStartValue(0);
- mLastFraction = 0.0f;
- setInterpolator(new LinearInterpolator());
-}
-
-void PropertyValuesAnimatorSet::onFinished(BaseRenderNodeAnimator* animator) {
- if (mOneShotListener.get()) {
- mOneShotListener->onAnimationFinished(animator);
- mOneShotListener = nullptr;
- }
-}
-
-float PropertyValuesAnimatorSet::getValue(RenderNode* target) const {
- return mLastFraction;
-}
-
-void PropertyValuesAnimatorSet::setValue(RenderNode* target, float value) {
- mLastFraction = value;
-}
-
-void PropertyValuesAnimatorSet::onPlayTimeChanged(nsecs_t playTime) {
- for (size_t i = 0; i < mAnimators.size(); i++) {
- mAnimators[i]->setCurrentPlayTime(playTime);
- }
-}
-
-void PropertyValuesAnimatorSet::reset() {
- // TODO: implement reset through adding a play state because we need to support reset() even
- // during an animation run.
-}
-
-void PropertyValuesAnimatorSet::start(AnimationListener* listener) {
- init();
- mOneShotListener = listener;
- BaseRenderNodeAnimator::start();
-}
-
-void PropertyValuesAnimatorSet::reverse(AnimationListener* listener) {
-// TODO: implement reverse
-}
-
-void PropertyValuesAnimatorSet::init() {
- if (mInitialized) {
- return;
- }
- nsecs_t maxDuration = 0;
- for (size_t i = 0; i < mAnimators.size(); i++) {
- if (maxDuration < mAnimators[i]->getTotalDuration()) {
- maxDuration = mAnimators[i]->getTotalDuration();
- }
- }
- mDuration = maxDuration;
- mInitialized = true;
-}
-
-uint32_t PropertyValuesAnimatorSet::dirtyMask() {
- return RenderNode::DISPLAY_LIST;
-}
-
-PropertyAnimator::PropertyAnimator(PropertyValuesHolder* holder, Interpolator* interpolator,
- nsecs_t startDelay, nsecs_t duration, int repeatCount)
- : mPropertyValuesHolder(holder), mInterpolator(interpolator), mStartDelay(startDelay),
- mDuration(duration) {
- if (repeatCount < 0) {
- mRepeatCount = UINT32_MAX;
- } else {
- mRepeatCount = repeatCount;
- }
- mTotalDuration = ((nsecs_t) mRepeatCount + 1) * mDuration + mStartDelay;
-}
-
-void PropertyAnimator::setCurrentPlayTime(nsecs_t playTime) {
- if (playTime >= mStartDelay && playTime < mTotalDuration) {
- nsecs_t currentIterationPlayTime = (playTime - mStartDelay) % mDuration;
- mLatestFraction = currentIterationPlayTime / (float) mDuration;
- } else if (mLatestFraction < 1.0f && playTime >= mTotalDuration) {
- mLatestFraction = 1.0f;
- } else {
- return;
- }
-
- setFraction(mLatestFraction);
-}
-
-void PropertyAnimator::setFraction(float fraction) {
- float interpolatedFraction = mInterpolator->interpolate(mLatestFraction);
- mPropertyValuesHolder->setFraction(interpolatedFraction);
-}
-
-void PropertyAnimatorSetListener::onAnimationFinished(BaseRenderNodeAnimator* animator) {
- mSet->onFinished(animator);
-}
-
-}
-}
diff --git a/libs/hwui/PropertyValuesAnimatorSet.h b/libs/hwui/PropertyValuesAnimatorSet.h
deleted file mode 100644
index 4c7ce52..0000000
--- a/libs/hwui/PropertyValuesAnimatorSet.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2016 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.
- */
-
-#pragma once
-
-#include "Animator.h"
-#include "PropertyValuesHolder.h"
-#include "Interpolator.h"
-
-namespace android {
-namespace uirenderer {
-
-class PropertyAnimator {
-public:
- PropertyAnimator(PropertyValuesHolder* holder, Interpolator* interpolator, nsecs_t startDelay,
- nsecs_t duration, int repeatCount);
- void setCurrentPlayTime(nsecs_t playTime);
- nsecs_t getTotalDuration() {
- return mTotalDuration;
- }
- void setFraction(float fraction);
-
-private:
- std::unique_ptr<PropertyValuesHolder> mPropertyValuesHolder;
- std::unique_ptr<Interpolator> mInterpolator;
- nsecs_t mStartDelay;
- nsecs_t mDuration;
- uint32_t mRepeatCount;
- nsecs_t mTotalDuration;
- float mLatestFraction = 0.0f;
-};
-
-class ANDROID_API PropertyValuesAnimatorSet : public BaseRenderNodeAnimator {
-public:
- friend class PropertyAnimatorSetListener;
- PropertyValuesAnimatorSet();
-
- void start(AnimationListener* listener);
- void reverse(AnimationListener* listener);
- void reset();
-
- void addPropertyAnimator(PropertyValuesHolder* propertyValuesHolder,
- Interpolator* interpolators, int64_t startDelays,
- nsecs_t durations, int repeatCount);
- virtual uint32_t dirtyMask();
-
-protected:
- virtual float getValue(RenderNode* target) const override;
- virtual void setValue(RenderNode* target, float value) override;
- virtual void onPlayTimeChanged(nsecs_t playTime) override;
-
-private:
- void init();
- void onFinished(BaseRenderNodeAnimator* animator);
- // Listener set from outside
- sp<AnimationListener> mOneShotListener;
- std::vector< std::unique_ptr<PropertyAnimator> > mAnimators;
- float mLastFraction = 0.0f;
- bool mInitialized = false;
-};
-
-class PropertyAnimatorSetListener : public AnimationListener {
-public:
- PropertyAnimatorSetListener(PropertyValuesAnimatorSet* set) : mSet(set) {}
- virtual void onAnimationFinished(BaseRenderNodeAnimator* animator) override;
-
-private:
- PropertyValuesAnimatorSet* mSet;
-};
-
-} // namespace uirenderer
-} // namespace android
diff --git a/libs/hwui/PropertyValuesHolder.cpp b/libs/hwui/PropertyValuesHolder.cpp
deleted file mode 100644
index 8f837f6..0000000
--- a/libs/hwui/PropertyValuesHolder.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2016 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 "PropertyValuesHolder.h"
-
-#include "utils/VectorDrawableUtils.h"
-
-#include <utils/Log.h>
-
-namespace android {
-namespace uirenderer {
-
-using namespace VectorDrawable;
-
-float PropertyValuesHolder::getValueFromData(float fraction) {
- if (mDataSource.size() == 0) {
- LOG_ALWAYS_FATAL("No data source is defined");
- return 0;
- }
- if (fraction <= 0.0f) {
- return mDataSource.front();
- }
- if (fraction >= 1.0f) {
- return mDataSource.back();
- }
-
- fraction *= mDataSource.size() - 1;
- int lowIndex = floor(fraction);
- fraction -= lowIndex;
-
- float value = mDataSource[lowIndex] * (1.0f - fraction)
- + mDataSource[lowIndex + 1] * fraction;
- return value;
-}
-
-void GroupPropertyValuesHolder::setFraction(float fraction) {
- float animatedValue;
- if (mDataSource.size() > 0) {
- animatedValue = getValueFromData(fraction);
- } else {
- animatedValue = mStartValue * (1 - fraction) + mEndValue * fraction;
- }
- mGroup->setPropertyValue(mPropertyId, animatedValue);
-}
-
-inline U8CPU lerp(U8CPU fromValue, U8CPU toValue, float fraction) {
- return (U8CPU) (fromValue * (1 - fraction) + toValue * fraction);
-}
-
-// TODO: Add a test for this
-SkColor FullPathColorPropertyValuesHolder::interpolateColors(SkColor fromColor, SkColor toColor,
- float fraction) {
- U8CPU alpha = lerp(SkColorGetA(fromColor), SkColorGetA(toColor), fraction);
- U8CPU red = lerp(SkColorGetR(fromColor), SkColorGetR(toColor), fraction);
- U8CPU green = lerp(SkColorGetG(fromColor), SkColorGetG(toColor), fraction);
- U8CPU blue = lerp(SkColorGetB(fromColor), SkColorGetB(toColor), fraction);
- return SkColorSetARGB(alpha, red, green, blue);
-}
-
-void FullPathColorPropertyValuesHolder::setFraction(float fraction) {
- SkColor animatedValue = interpolateColors(mStartValue, mEndValue, fraction);
- mFullPath->setColorPropertyValue(mPropertyId, animatedValue);
-}
-
-void FullPathPropertyValuesHolder::setFraction(float fraction) {
- float animatedValue;
- if (mDataSource.size() > 0) {
- animatedValue = getValueFromData(fraction);
- } else {
- animatedValue = mStartValue * (1 - fraction) + mEndValue * fraction;
- }
- mFullPath->setPropertyValue(mPropertyId, animatedValue);
-}
-
-void PathDataPropertyValuesHolder::setFraction(float fraction) {
- VectorDrawableUtils::interpolatePaths(&mPathData, mStartValue, mEndValue, fraction);
- mPath->setPathData(mPathData);
-}
-
-void RootAlphaPropertyValuesHolder::setFraction(float fraction) {
- float animatedValue = mStartValue * (1 - fraction) + mEndValue * fraction;
- mTree->setRootAlpha(animatedValue);
-}
-
-} // namepace uirenderer
-} // namespace android
diff --git a/libs/hwui/PropertyValuesHolder.h b/libs/hwui/PropertyValuesHolder.h
deleted file mode 100644
index b905fae..0000000
--- a/libs/hwui/PropertyValuesHolder.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2016 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.
- */
-
-#pragma once
-
-#include "VectorDrawable.h"
-
-#include <SkColor.h>
-
-namespace android {
-namespace uirenderer {
-
-/**
- * PropertyValues holder contains data needed to change a property of a Vector Drawable object.
- * When a fraction in [0f, 1f] is provided, the holder will calculate an interpolated value based
- * on its start and end value, and set the new value on the VectorDrawble's corresponding property.
- */
-class ANDROID_API PropertyValuesHolder {
-public:
- virtual void setFraction(float fraction) = 0;
- void setPropertyDataSource(float* dataSource, int length) {
- mDataSource.insert(mDataSource.begin(), dataSource, dataSource + length);
- }
- float getValueFromData(float fraction);
- virtual ~PropertyValuesHolder() {}
-protected:
- std::vector<float> mDataSource;
-};
-
-class ANDROID_API GroupPropertyValuesHolder : public PropertyValuesHolder {
-public:
- GroupPropertyValuesHolder(VectorDrawable::Group* ptr, int propertyId, float startValue,
- float endValue)
- : mGroup(ptr)
- , mPropertyId(propertyId)
- , mStartValue(startValue)
- , mEndValue(endValue){
- }
- void setFraction(float fraction) override;
-private:
- VectorDrawable::Group* mGroup;
- int mPropertyId;
- float mStartValue;
- float mEndValue;
-};
-
-class ANDROID_API FullPathColorPropertyValuesHolder : public PropertyValuesHolder {
-public:
- FullPathColorPropertyValuesHolder(VectorDrawable::FullPath* ptr, int propertyId, int32_t startValue,
- int32_t endValue)
- : mFullPath(ptr)
- , mPropertyId(propertyId)
- , mStartValue(startValue)
- , mEndValue(endValue) {};
- void setFraction(float fraction) override;
- static SkColor interpolateColors(SkColor fromColor, SkColor toColor, float fraction);
-private:
- VectorDrawable::FullPath* mFullPath;
- int mPropertyId;
- int32_t mStartValue;
- int32_t mEndValue;
-};
-
-class ANDROID_API FullPathPropertyValuesHolder : public PropertyValuesHolder {
-public:
- FullPathPropertyValuesHolder(VectorDrawable::FullPath* ptr, int propertyId, float startValue,
- float endValue)
- : mFullPath(ptr)
- , mPropertyId(propertyId)
- , mStartValue(startValue)
- , mEndValue(endValue) {};
- void setFraction(float fraction) override;
-private:
- VectorDrawable::FullPath* mFullPath;
- int mPropertyId;
- float mStartValue;
- float mEndValue;
-};
-
-class ANDROID_API PathDataPropertyValuesHolder : public PropertyValuesHolder {
-public:
- PathDataPropertyValuesHolder(VectorDrawable::Path* ptr, PathData* startValue,
- PathData* endValue)
- : mPath(ptr)
- , mStartValue(*startValue)
- , mEndValue(*endValue) {};
- void setFraction(float fraction) override;
-private:
- VectorDrawable::Path* mPath;
- PathData mPathData;
- PathData mStartValue;
- PathData mEndValue;
-};
-
-class ANDROID_API RootAlphaPropertyValuesHolder : public PropertyValuesHolder {
-public:
- RootAlphaPropertyValuesHolder(VectorDrawable::Tree* tree, float startValue, float endValue)
- : mTree(tree)
- , mStartValue(startValue)
- , mEndValue(endValue) {}
- void setFraction(float fraction) override;
-private:
- VectorDrawable::Tree* mTree;
- float mStartValue;
- float mEndValue;
-};
-}
-}
diff --git a/libs/hwui/RecordedOp.h b/libs/hwui/RecordedOp.h
index bb26e2e..593d690 100644
--- a/libs/hwui/RecordedOp.h
+++ b/libs/hwui/RecordedOp.h
@@ -17,7 +17,6 @@
#ifndef ANDROID_HWUI_RECORDED_OP_H
#define ANDROID_HWUI_RECORDED_OP_H
-#include "RecordedOp.h"
#include "font/FontUtil.h"
#include "Matrix.h"
#include "Rect.h"
@@ -40,10 +39,6 @@
class RenderNode;
struct Vertex;
-namespace VectorDrawable {
-class Tree;
-}
-
/**
* Authoritative op list, used for generating the op ID enum, ID based LUTS, and
* the functions to which they dispatch. Parameter macros are executed for each op,
@@ -80,7 +75,6 @@
PRE_RENDER_OP_FN(EndLayerOp) \
PRE_RENDER_OP_FN(BeginUnclippedLayerOp) \
PRE_RENDER_OP_FN(EndUnclippedLayerOp) \
- PRE_RENDER_OP_FN(VectorDrawableOp) \
\
RENDER_ONLY_OP_FN(ShadowOp) \
RENDER_ONLY_OP_FN(LayerOp) \
@@ -331,13 +325,6 @@
const float* ry;
};
-struct VectorDrawableOp : RecordedOp {
- VectorDrawableOp(VectorDrawable::Tree* tree, BASE_PARAMS_PAINTLESS)
- : SUPER_PAINTLESS(VectorDrawableOp)
- , vectorDrawable(tree) {}
- VectorDrawable::Tree* vectorDrawable;
-};
-
/**
* Real-time, dynamic-lit shadow.
*
diff --git a/libs/hwui/RecordingCanvas.cpp b/libs/hwui/RecordingCanvas.cpp
index 16929b8..2387962 100644
--- a/libs/hwui/RecordingCanvas.cpp
+++ b/libs/hwui/RecordingCanvas.cpp
@@ -19,7 +19,6 @@
#include "DeferredLayerUpdater.h"
#include "RecordedOp.h"
#include "RenderNode.h"
-#include "VectorDrawable.h"
namespace android {
namespace uirenderer {
@@ -396,6 +395,7 @@
&x->value, &y->value, &radius->value));
}
+
void RecordingCanvas::drawOval(float left, float top, float right, float bottom, const SkPaint& paint) {
addOp(new (alloc()) OvalOp(
Rect(left, top, right, bottom),
@@ -422,15 +422,6 @@
refPaint(&paint), refPath(&path)));
}
-void RecordingCanvas::drawVectorDrawable(VectorDrawableRoot* tree) {
- mDisplayList->ref(tree);
- addOp(new (alloc()) VectorDrawableOp(
- tree,
- Rect(tree->getBounds()),
- *(mState.currentSnapshot()->transform),
- getRecordedClip()));
-}
-
// Bitmap-based
void RecordingCanvas::drawBitmap(const SkBitmap& bitmap, float left, float top, const SkPaint* paint) {
save(SaveFlags::Matrix);
diff --git a/libs/hwui/RecordingCanvas.h b/libs/hwui/RecordingCanvas.h
index cc14e61..375760f 100644
--- a/libs/hwui/RecordingCanvas.h
+++ b/libs/hwui/RecordingCanvas.h
@@ -175,8 +175,6 @@
const uint16_t* indices, int indexCount, const SkPaint& paint) override
{ /* RecordingCanvas does not support drawVertices(); ignore */ }
- virtual void drawVectorDrawable(VectorDrawableRoot* tree) override;
-
// Bitmap-based
virtual void drawBitmap(const SkBitmap& bitmap, float left, float top, const SkPaint* paint) override;
virtual void drawBitmap(const SkBitmap& bitmap, const SkMatrix& matrix,
diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp
index d4588ed..bade216 100644
--- a/libs/hwui/RenderNode.cpp
+++ b/libs/hwui/RenderNode.cpp
@@ -381,6 +381,10 @@
bool childFunctorsNeedLayer = mProperties.prepareForFunctorPresence(
willHaveFunctor, functorsNeedLayer);
+ if (CC_UNLIKELY(mPositionListener.get())) {
+ mPositionListener->onPositionUpdated(*this, info);
+ }
+
prepareLayer(info, animatorDirtyMask);
if (info.mode == TreeInfo::MODE_FULL) {
pushStagingDisplayListChanges(info);
diff --git a/libs/hwui/RenderNode.h b/libs/hwui/RenderNode.h
index 8e4a3df..f248de54 100644
--- a/libs/hwui/RenderNode.h
+++ b/libs/hwui/RenderNode.h
@@ -209,6 +209,19 @@
OffscreenBuffer** getLayerHandle() { return &mLayer; } // ugh...
#endif
+ class ANDROID_API PositionListener {
+ public:
+ virtual ~PositionListener() {}
+ virtual void onPositionUpdated(RenderNode& node, const TreeInfo& info) = 0;
+ };
+
+ // Note this is not thread safe, this needs to be called
+ // before the RenderNode is used for drawing.
+ // RenderNode takes ownership of the pointer
+ ANDROID_API void setPositionListener(PositionListener* listener) {
+ mPositionListener.reset(listener);
+ }
+
private:
typedef key_value_pair_t<float, DrawRenderNodeOp*> ZDrawRenderNodeOpPair;
@@ -317,6 +330,8 @@
// This is *NOT* thread-safe, and should therefore only be tracking
// mDisplayList, not mStagingDisplayList.
uint32_t mParentCount;
+
+ std::unique_ptr<PositionListener> mPositionListener;
}; // class RenderNode
} /* namespace uirenderer */
diff --git a/libs/hwui/SkiaCanvas.cpp b/libs/hwui/SkiaCanvas.cpp
index bd4442d..d320a41 100644
--- a/libs/hwui/SkiaCanvas.cpp
+++ b/libs/hwui/SkiaCanvas.cpp
@@ -32,8 +32,6 @@
#include <SkTLazy.h>
#include <SkTemplates.h>
-#include "VectorDrawable.h"
-
#include <memory>
namespace android {
@@ -155,7 +153,6 @@
float hOffset, float vOffset, const SkPaint& paint) override;
virtual bool drawTextAbsolutePos() const override { return true; }
- virtual void drawVectorDrawable(VectorDrawableRoot* vectorDrawable) override;
virtual void drawRoundRect(uirenderer::CanvasPropertyPrimitive* left,
uirenderer::CanvasPropertyPrimitive* top, uirenderer::CanvasPropertyPrimitive* right,
@@ -745,14 +742,6 @@
NinePatch::Draw(mCanvas, bounds, bitmap, chunk, paint, nullptr);
}
-void SkiaCanvas::drawVectorDrawable(VectorDrawableRoot* vectorDrawable) {
- const SkBitmap& bitmap = vectorDrawable->getBitmapUpdateIfDirty();
- SkRect bounds = vectorDrawable->getBounds();
- drawBitmap(bitmap, 0, 0, bitmap.width(), bitmap.height(),
- bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom,
- vectorDrawable->getPaint());
-}
-
// ----------------------------------------------------------------------------
// Canvas draw operations: Text
// ----------------------------------------------------------------------------
diff --git a/libs/hwui/TessellationCache.cpp b/libs/hwui/TessellationCache.cpp
index 461e819..fd9fb852 100644
--- a/libs/hwui/TessellationCache.cpp
+++ b/libs/hwui/TessellationCache.cpp
@@ -242,23 +242,21 @@
spotBuffer);
}
-class ShadowProcessor : public TaskProcessor<TessellationCache::vertexBuffer_pair_t*> {
+class ShadowProcessor : public TaskProcessor<TessellationCache::vertexBuffer_pair_t> {
public:
ShadowProcessor(Caches& caches)
- : TaskProcessor<TessellationCache::vertexBuffer_pair_t*>(&caches.tasks) {}
+ : TaskProcessor<TessellationCache::vertexBuffer_pair_t>(&caches.tasks) {}
~ShadowProcessor() {}
- virtual void onProcess(const sp<Task<TessellationCache::vertexBuffer_pair_t*> >& task) override {
+ virtual void onProcess(const sp<Task<TessellationCache::vertexBuffer_pair_t> >& task) override {
TessellationCache::ShadowTask* t = static_cast<TessellationCache::ShadowTask*>(task.get());
ATRACE_NAME("shadow tessellation");
- VertexBuffer* ambientBuffer = new VertexBuffer;
- VertexBuffer* spotBuffer = new VertexBuffer;
tessellateShadows(&t->drawTransform, &t->localClip, t->opaque, &t->casterPerimeter,
&t->transformXY, &t->transformZ, t->lightCenter, t->lightRadius,
- *ambientBuffer, *spotBuffer);
+ t->ambientBuffer, t->spotBuffer);
- t->setResult(new TessellationCache::vertexBuffer_pair_t(ambientBuffer, spotBuffer));
+ t->setResult(TessellationCache::vertexBuffer_pair_t(&t->ambientBuffer, &t->spotBuffer));
}
};
@@ -373,7 +371,7 @@
task = static_cast<ShadowTask*>(mShadowCache.get(key));
}
LOG_ALWAYS_FATAL_IF(task == nullptr, "shadow not precached");
- outBuffers = *(task->getResult());
+ outBuffers = task->getResult();
}
sp<TessellationCache::ShadowTask> TessellationCache::getShadowTask(
@@ -392,13 +390,6 @@
return task;
}
-TessellationCache::ShadowTask::~ShadowTask() {
- TessellationCache::vertexBuffer_pair_t* bufferPair = getResult();
- delete bufferPair->getFirst();
- delete bufferPair->getSecond();
- delete bufferPair;
-}
-
///////////////////////////////////////////////////////////////////////////////
// Tessellation precaching
///////////////////////////////////////////////////////////////////////////////
diff --git a/libs/hwui/TessellationCache.h b/libs/hwui/TessellationCache.h
index 977c2d9e..6dcc812 100644
--- a/libs/hwui/TessellationCache.h
+++ b/libs/hwui/TessellationCache.h
@@ -21,6 +21,7 @@
#include "Matrix.h"
#include "Rect.h"
#include "Vector.h"
+#include "VertexBuffer.h"
#include "thread/TaskProcessor.h"
#include "utils/Macros.h"
#include "utils/Pair.h"
@@ -89,7 +90,7 @@
hash_t hash() const;
};
- class ShadowTask : public Task<TessellationCache::vertexBuffer_pair_t*> {
+ class ShadowTask : public Task<vertexBuffer_pair_t> {
public:
ShadowTask(const Matrix4* drawTransform, const Rect& localClip, bool opaque,
const SkPath* casterPerimeter, const Matrix4* transformXY, const Matrix4* transformZ,
@@ -104,13 +105,11 @@
, lightRadius(lightRadius) {
}
- ~ShadowTask();
-
/* Note - we deep copy all task parameters, because *even though* pointers into Allocator
* controlled objects (like the SkPath and Matrix4s) should be safe for the entire frame,
* certain Allocators are destroyed before trim() is called to flush incomplete tasks.
*
- * These deep copies could be avoided, long term, by cancelling or flushing outstanding
+ * These deep copies could be avoided, long term, by canceling or flushing outstanding
* tasks before tearing down single-frame LinearAllocators.
*/
const Matrix4 drawTransform;
@@ -121,6 +120,8 @@
const Matrix4 transformZ;
const Vector3 lightCenter;
const float lightRadius;
+ VertexBuffer ambientBuffer;
+ VertexBuffer spotBuffer;
};
TessellationCache();
@@ -217,12 +218,12 @@
///////////////////////////////////////////////////////////////////////////////
// Shadow tessellation caching
///////////////////////////////////////////////////////////////////////////////
- sp<TaskProcessor<vertexBuffer_pair_t*> > mShadowProcessor;
+ sp<TaskProcessor<vertexBuffer_pair_t> > mShadowProcessor;
// holds a pointer, and implicit strong ref to each shadow task of the frame
- LruCache<ShadowDescription, Task<vertexBuffer_pair_t*>*> mShadowCache;
- class BufferPairRemovedListener : public OnEntryRemoved<ShadowDescription, Task<vertexBuffer_pair_t*>*> {
- void operator()(ShadowDescription& description, Task<vertexBuffer_pair_t*>*& bufferPairTask) override {
+ LruCache<ShadowDescription, Task<vertexBuffer_pair_t>*> mShadowCache;
+ class BufferPairRemovedListener : public OnEntryRemoved<ShadowDescription, Task<vertexBuffer_pair_t>*> {
+ void operator()(ShadowDescription& description, Task<vertexBuffer_pair_t>*& bufferPairTask) override {
bufferPairTask->decStrong(nullptr);
}
};
diff --git a/libs/hwui/TreeInfo.h b/libs/hwui/TreeInfo.h
index be25516..accd303 100644
--- a/libs/hwui/TreeInfo.h
+++ b/libs/hwui/TreeInfo.h
@@ -86,6 +86,12 @@
#endif
ErrorHandler* errorHandler = nullptr;
+ // Frame number for use with synchronized surfaceview position updating
+ int64_t frameNumber = -1;
+ int32_t windowInsetLeft = 0;
+ int32_t windowInsetTop = 0;
+ bool updateWindowPositions = false;
+
struct Out {
bool hasFunctors = false;
// This is only updated if evaluateAnimations is true
diff --git a/libs/hwui/VectorDrawable.cpp b/libs/hwui/VectorDrawable.cpp
index 541c799..1cf15ac 100644
--- a/libs/hwui/VectorDrawable.cpp
+++ b/libs/hwui/VectorDrawable.cpp
@@ -138,7 +138,18 @@
}
FullPath::FullPath(const FullPath& path) : Path(path) {
- mProperties = path.mProperties;
+ mStrokeWidth = path.mStrokeWidth;
+ mStrokeColor = path.mStrokeColor;
+ mStrokeAlpha = path.mStrokeAlpha;
+ mFillColor = path.mFillColor;
+ mFillAlpha = path.mFillAlpha;
+ mTrimPathStart = path.mTrimPathStart;
+ mTrimPathEnd = path.mTrimPathEnd;
+ mTrimPathOffset = path.mTrimPathOffset;
+ mStrokeMiterLimit = path.mStrokeMiterLimit;
+ mStrokeLineCap = path.mStrokeLineCap;
+ mStrokeLineJoin = path.mStrokeLineJoin;
+
SkRefCnt_SafeAssign(mStrokeGradient, path.mStrokeGradient);
SkRefCnt_SafeAssign(mFillGradient, path.mFillGradient);
}
@@ -148,7 +159,7 @@
return mTrimmedSkPath;
}
Path::getUpdatedPath();
- if (mProperties.trimPathStart != 0.0f || mProperties.trimPathEnd != 1.0f) {
+ if (mTrimPathStart != 0.0f || mTrimPathEnd != 1.0f) {
applyTrim();
return mTrimmedSkPath;
} else {
@@ -159,14 +170,14 @@
void FullPath::updateProperties(float strokeWidth, SkColor strokeColor, float strokeAlpha,
SkColor fillColor, float fillAlpha, float trimPathStart, float trimPathEnd,
float trimPathOffset, float strokeMiterLimit, int strokeLineCap, int strokeLineJoin) {
- mProperties.strokeWidth = strokeWidth;
- mProperties.strokeColor = strokeColor;
- mProperties.strokeAlpha = strokeAlpha;
- mProperties.fillColor = fillColor;
- mProperties.fillAlpha = fillAlpha;
- mProperties.strokeMiterLimit = strokeMiterLimit;
- mProperties.strokeLineCap = strokeLineCap;
- mProperties.strokeLineJoin = strokeLineJoin;
+ mStrokeWidth = strokeWidth;
+ mStrokeColor = strokeColor;
+ mStrokeAlpha = strokeAlpha;
+ mFillColor = fillColor;
+ mFillAlpha = fillAlpha;
+ mStrokeMiterLimit = strokeMiterLimit;
+ mStrokeLineCap = SkPaint::Cap(strokeLineCap);
+ mStrokeLineJoin = SkPaint::Join(strokeLineJoin);
// If any trim property changes, mark trim dirty and update the trim path
setTrimPathStart(trimPathStart);
@@ -184,12 +195,12 @@
// Draw path's fill, if fill color or gradient is valid
bool needsFill = false;
if (mFillGradient != nullptr) {
- mPaint.setColor(applyAlpha(SK_ColorBLACK, mProperties.fillAlpha));
+ mPaint.setColor(applyAlpha(SK_ColorBLACK, mFillAlpha));
SkShader* newShader = mFillGradient->newWithLocalMatrix(matrix);
mPaint.setShader(newShader);
needsFill = true;
- } else if (mProperties.fillColor != SK_ColorTRANSPARENT) {
- mPaint.setColor(applyAlpha(mProperties.fillColor, mProperties.fillAlpha));
+ } else if (mFillColor != SK_ColorTRANSPARENT) {
+ mPaint.setColor(applyAlpha(mFillColor, mFillAlpha));
needsFill = true;
}
@@ -202,21 +213,21 @@
// Draw path's stroke, if stroke color or gradient is valid
bool needsStroke = false;
if (mStrokeGradient != nullptr) {
- mPaint.setColor(applyAlpha(SK_ColorBLACK, mProperties.strokeAlpha));
+ mPaint.setColor(applyAlpha(SK_ColorBLACK, mStrokeAlpha));
SkShader* newShader = mStrokeGradient->newWithLocalMatrix(matrix);
mPaint.setShader(newShader);
needsStroke = true;
- } else if (mProperties.strokeColor != SK_ColorTRANSPARENT) {
- mPaint.setColor(applyAlpha(mProperties.strokeColor, mProperties.strokeAlpha));
+ } else if (mStrokeColor != SK_ColorTRANSPARENT) {
+ mPaint.setColor(applyAlpha(mStrokeColor, mStrokeAlpha));
needsStroke = true;
}
if (needsStroke) {
mPaint.setStyle(SkPaint::Style::kStroke_Style);
mPaint.setAntiAlias(true);
- mPaint.setStrokeJoin(SkPaint::Join(mProperties.strokeLineJoin));
- mPaint.setStrokeCap(SkPaint::Cap(mProperties.strokeLineCap));
- mPaint.setStrokeMiter(mProperties.strokeMiterLimit);
- mPaint.setStrokeWidth(mProperties.strokeWidth * strokeScale);
+ mPaint.setStrokeJoin(mStrokeLineJoin);
+ mPaint.setStrokeCap(mStrokeLineCap);
+ mPaint.setStrokeMiter(mStrokeMiterLimit);
+ mPaint.setStrokeWidth(mStrokeWidth * strokeScale);
outCanvas->drawPath(renderPath, mPaint);
}
}
@@ -225,14 +236,14 @@
* Applies trimming to the specified path.
*/
void FullPath::applyTrim() {
- if (mProperties.trimPathStart == 0.0f && mProperties.trimPathEnd == 1.0f) {
+ if (mTrimPathStart == 0.0f && mTrimPathEnd == 1.0f) {
// No trimming necessary.
return;
}
SkPathMeasure measure(mSkPath, false);
float len = SkScalarToFloat(measure.getLength());
- float start = len * fmod((mProperties.trimPathStart + mProperties.trimPathOffset), 1.0f);
- float end = len * fmod((mProperties.trimPathEnd + mProperties.trimPathOffset), 1.0f);
+ float start = len * fmod((mTrimPathStart + mTrimPathOffset), 1.0f);
+ float end = len * fmod((mTrimPathEnd + mTrimPathOffset), 1.0f);
mTrimmedSkPath.reset();
if (start > end) {
@@ -244,69 +255,76 @@
mTrimDirty = false;
}
-REQUIRE_COMPATIBLE_LAYOUT(FullPath::Properties);
+inline int putData(int8_t* outBytes, int startIndex, float value) {
+ int size = sizeof(float);
+ memcpy(&outBytes[startIndex], &value, size);
+ return size;
+}
+
+inline int putData(int8_t* outBytes, int startIndex, int value) {
+ int size = sizeof(int);
+ memcpy(&outBytes[startIndex], &value, size);
+ return size;
+}
+
+struct FullPathProperties {
+ // TODO: Consider storing full path properties in this struct instead of the fields.
+ float strokeWidth;
+ SkColor strokeColor;
+ float strokeAlpha;
+ SkColor fillColor;
+ float fillAlpha;
+ float trimPathStart;
+ float trimPathEnd;
+ float trimPathOffset;
+ int32_t strokeLineCap;
+ int32_t strokeLineJoin;
+ float strokeMiterLimit;
+};
+
+REQUIRE_COMPATIBLE_LAYOUT(FullPathProperties);
static_assert(sizeof(float) == sizeof(int32_t), "float is not the same size as int32_t");
static_assert(sizeof(SkColor) == sizeof(int32_t), "SkColor is not the same size as int32_t");
bool FullPath::getProperties(int8_t* outProperties, int length) {
- int propertyDataSize = sizeof(Properties);
+ int propertyDataSize = sizeof(FullPathProperties);
if (length != propertyDataSize) {
LOG_ALWAYS_FATAL("Properties needs exactly %d bytes, a byte array of size %d is provided",
propertyDataSize, length);
return false;
}
- Properties* out = reinterpret_cast<Properties*>(outProperties);
- *out = mProperties;
+ // TODO: consider replacing the property fields with a FullPathProperties struct.
+ FullPathProperties properties;
+ properties.strokeWidth = mStrokeWidth;
+ properties.strokeColor = mStrokeColor;
+ properties.strokeAlpha = mStrokeAlpha;
+ properties.fillColor = mFillColor;
+ properties.fillAlpha = mFillAlpha;
+ properties.trimPathStart = mTrimPathStart;
+ properties.trimPathEnd = mTrimPathEnd;
+ properties.trimPathOffset = mTrimPathOffset;
+ properties.strokeLineCap = mStrokeLineCap;
+ properties.strokeLineJoin = mStrokeLineJoin;
+ properties.strokeMiterLimit = mStrokeMiterLimit;
+
+ memcpy(outProperties, &properties, length);
return true;
}
-void FullPath::setColorPropertyValue(int propertyId, int32_t value) {
- Property currentProperty = static_cast<Property>(propertyId);
- if (currentProperty == Property::StrokeColor) {
- mProperties.strokeColor = value;
- } else if (currentProperty == Property::FillColor) {
- mProperties.fillColor = value;
- } else {
- LOG_ALWAYS_FATAL("Error setting color property on FullPath: No valid property with id: %d",
- propertyId);
- }
-}
-
-void FullPath::setPropertyValue(int propertyId, float value) {
- Property property = static_cast<Property>(propertyId);
- switch (property) {
- case Property::StrokeWidth:
- setStrokeWidth(value);
- break;
- case Property::StrokeAlpha:
- setStrokeAlpha(value);
- break;
- case Property::FillAlpha:
- setFillAlpha(value);
- break;
- case Property::TrimPathStart:
- setTrimPathStart(value);
- break;
- case Property::TrimPathEnd:
- setTrimPathEnd(value);
- break;
- case Property::TrimPathOffset:
- setTrimPathOffset(value);
- break;
- default:
- LOG_ALWAYS_FATAL("Invalid property id: %d for animation", propertyId);
- break;
- }
-}
-
void ClipPath::drawPath(SkCanvas* outCanvas, const SkPath& renderPath,
float strokeScale, const SkMatrix& matrix){
outCanvas->clipPath(renderPath, SkRegion::kIntersect_Op);
}
Group::Group(const Group& group) : Node(group) {
- mProperties = group.mProperties;
+ mRotate = group.mRotate;
+ mPivotX = group.mPivotX;
+ mPivotY = group.mPivotY;
+ mScaleX = group.mScaleX;
+ mScaleY = group.mScaleY;
+ mTranslateX = group.mTranslateX;
+ mTranslateY = group.mTranslateY;
}
void Group::draw(SkCanvas* outCanvas, const SkMatrix& currentMatrix, float scaleX,
@@ -353,11 +371,10 @@
outMatrix->reset();
// TODO: use rotate(mRotate, mPivotX, mPivotY) and scale with pivot point, instead of
// translating to pivot for rotating and scaling, then translating back.
- outMatrix->postTranslate(-mProperties.pivotX, -mProperties.pivotY);
- outMatrix->postScale(mProperties.scaleX, mProperties.scaleY);
- outMatrix->postRotate(mProperties.rotate, 0, 0);
- outMatrix->postTranslate(mProperties.translateX + mProperties.pivotX,
- mProperties.translateY + mProperties.pivotY);
+ outMatrix->postTranslate(-mPivotX, -mPivotY);
+ outMatrix->postScale(mScaleX, mScaleY);
+ outMatrix->postRotate(mRotate, 0, 0);
+ outMatrix->postTranslate(mTranslateX + mPivotX, mTranslateY + mPivotY);
}
void Group::addChild(Node* child) {
@@ -371,68 +388,38 @@
propertyCount, length);
return false;
}
- Properties* out = reinterpret_cast<Properties*>(outProperties);
- *out = mProperties;
+ for (int i = 0; i < propertyCount; i++) {
+ Property currentProperty = static_cast<Property>(i);
+ switch (currentProperty) {
+ case Property::Rotate_Property:
+ outProperties[i] = mRotate;
+ break;
+ case Property::PivotX_Property:
+ outProperties[i] = mPivotX;
+ break;
+ case Property::PivotY_Property:
+ outProperties[i] = mPivotY;
+ break;
+ case Property::ScaleX_Property:
+ outProperties[i] = mScaleX;
+ break;
+ case Property::ScaleY_Property:
+ outProperties[i] = mScaleY;
+ break;
+ case Property::TranslateX_Property:
+ outProperties[i] = mTranslateX;
+ break;
+ case Property::TranslateY_Property:
+ outProperties[i] = mTranslateY;
+ break;
+ default:
+ LOG_ALWAYS_FATAL("Invalid input index: %d", i);
+ return false;
+ }
+ }
return true;
}
-// TODO: Consider animating the properties as float pointers
-float Group::getPropertyValue(int propertyId) const {
- Property currentProperty = static_cast<Property>(propertyId);
- switch (currentProperty) {
- case Property::Rotate:
- return mProperties.rotate;
- case Property::PivotX:
- return mProperties.pivotX;
- case Property::PivotY:
- return mProperties.pivotY;
- case Property::ScaleX:
- return mProperties.scaleX;
- case Property::ScaleY:
- return mProperties.scaleY;
- case Property::TranslateX:
- return mProperties.translateX;
- case Property::TranslateY:
- return mProperties.translateY;
- default:
- LOG_ALWAYS_FATAL("Invalid property index: %d", propertyId);
- return 0;
- }
-}
-
-void Group::setPropertyValue(int propertyId, float value) {
- Property currentProperty = static_cast<Property>(propertyId);
- switch (currentProperty) {
- case Property::Rotate:
- mProperties.rotate = value;
- break;
- case Property::PivotX:
- mProperties.pivotX = value;
- break;
- case Property::PivotY:
- mProperties.pivotY = value;
- break;
- case Property::ScaleX:
- mProperties.scaleX = value;
- break;
- case Property::ScaleY:
- mProperties.scaleY = value;
- break;
- case Property::TranslateX:
- mProperties.translateX = value;
- break;
- case Property::TranslateY:
- mProperties.translateY = value;
- break;
- default:
- LOG_ALWAYS_FATAL("Invalid property index: %d", propertyId);
- }
-}
-
-bool Group::isValidProperty(int propertyId) {
- return propertyId >= 0 && propertyId < static_cast<int>(Property::Count);
-}
-
void Tree::draw(Canvas* outCanvas, SkColorFilter* colorFilter,
const SkRect& bounds, bool needsMirroring, bool canReuseCache) {
// The imageView can scale the canvas in different ways, in order to
@@ -458,8 +445,6 @@
return;
}
- mPaint.setColorFilter(colorFilter);
-
int saveCount = outCanvas->save(SaveFlags::MatrixClip);
outCanvas->translate(mBounds.fLeft, mBounds.fTop);
@@ -473,33 +458,43 @@
// And we use this bound for the destination rect for the drawBitmap, so
// we offset to (0, 0);
mBounds.offsetTo(0, 0);
- createCachedBitmapIfNeeded(scaledWidth, scaledHeight);
- outCanvas->drawVectorDrawable(this);
+ createCachedBitmapIfNeeded(scaledWidth, scaledHeight);
+ if (!mAllowCaching) {
+ updateCachedBitmap(scaledWidth, scaledHeight);
+ } else {
+ if (!canReuseCache || mCacheDirty) {
+ updateCachedBitmap(scaledWidth, scaledHeight);
+ }
+ }
+ drawCachedBitmapWithRootAlpha(outCanvas, colorFilter, mBounds);
outCanvas->restoreToCount(saveCount);
}
-SkPaint* Tree::getPaint() {
+void Tree::drawCachedBitmapWithRootAlpha(Canvas* outCanvas, SkColorFilter* filter,
+ const SkRect& originalBounds) {
SkPaint* paint;
- if (mRootAlpha == 1.0f && mPaint.getColorFilter() == NULL) {
+ if (mRootAlpha == 1.0f && filter == NULL) {
paint = NULL;
} else {
mPaint.setFilterQuality(kLow_SkFilterQuality);
mPaint.setAlpha(mRootAlpha * 255);
+ mPaint.setColorFilter(filter);
paint = &mPaint;
}
- return paint;
+ outCanvas->drawBitmap(mCachedBitmap, 0, 0, mCachedBitmap.width(), mCachedBitmap.height(),
+ originalBounds.fLeft, originalBounds.fTop, originalBounds.fRight,
+ originalBounds.fBottom, paint);
}
-const SkBitmap& Tree::getBitmapUpdateIfDirty() {
+void Tree::updateCachedBitmap(int width, int height) {
mCachedBitmap.eraseColor(SK_ColorTRANSPARENT);
SkCanvas outCanvas(mCachedBitmap);
- float scaleX = (float) mCachedBitmap.width() / mViewportWidth;
- float scaleY = (float) mCachedBitmap.height() / mViewportHeight;
+ float scaleX = width / mViewportWidth;
+ float scaleY = height / mViewportHeight;
mRootNode->draw(&outCanvas, SkMatrix::I(), scaleX, scaleY);
mCacheDirty = false;
- return mCachedBitmap;
}
void Tree::createCachedBitmapIfNeeded(int width, int height) {
diff --git a/libs/hwui/VectorDrawable.h b/libs/hwui/VectorDrawable.h
index f8f1ea6..09bdce5 100644
--- a/libs/hwui/VectorDrawable.h
+++ b/libs/hwui/VectorDrawable.h
@@ -18,7 +18,6 @@
#define ANDROID_HWUI_VPATH_H
#include "Canvas.h"
-
#include <SkBitmap.h>
#include <SkColor.h>
#include <SkCanvas.h>
@@ -105,21 +104,6 @@
class ANDROID_API FullPath: public Path {
public:
-
-struct Properties {
- float strokeWidth = 0;
- SkColor strokeColor = SK_ColorTRANSPARENT;
- float strokeAlpha = 1;
- SkColor fillColor = SK_ColorTRANSPARENT;
- float fillAlpha = 1;
- float trimPathStart = 0;
- float trimPathEnd = 1;
- float trimPathOffset = 0;
- int32_t strokeLineCap = SkPaint::Cap::kButt_Cap;
- int32_t strokeLineJoin = SkPaint::Join::kMiter_Join;
- float strokeMiterLimit = 4;
-};
-
FullPath(const FullPath& path); // for cloning
FullPath(const char* path, size_t strLength) : Path(path, strLength) {}
FullPath() : Path() {}
@@ -134,58 +118,55 @@
float strokeAlpha, SkColor fillColor, float fillAlpha,
float trimPathStart, float trimPathEnd, float trimPathOffset,
float strokeMiterLimit, int strokeLineCap, int strokeLineJoin);
- // TODO: Cleanup: Remove the setter and getters below, and their counterparts in java and JNI
float getStrokeWidth() {
- return mProperties.strokeWidth;
+ return mStrokeWidth;
}
void setStrokeWidth(float strokeWidth) {
- mProperties.strokeWidth = strokeWidth;
+ mStrokeWidth = strokeWidth;
}
SkColor getStrokeColor() {
- return mProperties.strokeColor;
+ return mStrokeColor;
}
void setStrokeColor(SkColor strokeColor) {
- mProperties.strokeColor = strokeColor;
+ mStrokeColor = strokeColor;
}
float getStrokeAlpha() {
- return mProperties.strokeAlpha;
+ return mStrokeAlpha;
}
void setStrokeAlpha(float strokeAlpha) {
- mProperties.strokeAlpha = strokeAlpha;
+ mStrokeAlpha = strokeAlpha;
}
SkColor getFillColor() {
- return mProperties.fillColor;
+ return mFillColor;
}
void setFillColor(SkColor fillColor) {
- mProperties.fillColor = fillColor;
+ mFillColor = fillColor;
}
float getFillAlpha() {
- return mProperties.fillAlpha;
+ return mFillAlpha;
}
void setFillAlpha(float fillAlpha) {
- mProperties.fillAlpha = fillAlpha;
+ mFillAlpha = fillAlpha;
}
float getTrimPathStart() {
- return mProperties.trimPathStart;
+ return mTrimPathStart;
}
void setTrimPathStart(float trimPathStart) {
- VD_SET_PROP_WITH_FLAG(mProperties.trimPathStart, trimPathStart, mTrimDirty);
+ VD_SET_PROP_WITH_FLAG(mTrimPathStart, trimPathStart, mTrimDirty);
}
float getTrimPathEnd() {
- return mProperties.trimPathEnd;
+ return mTrimPathEnd;
}
void setTrimPathEnd(float trimPathEnd) {
- VD_SET_PROP_WITH_FLAG(mProperties.trimPathEnd, trimPathEnd, mTrimDirty);
+ VD_SET_PROP_WITH_FLAG(mTrimPathEnd, trimPathEnd, mTrimDirty);
}
float getTrimPathOffset() {
- return mProperties.trimPathOffset;
+ return mTrimPathOffset;
}
void setTrimPathOffset(float trimPathOffset) {
- VD_SET_PROP_WITH_FLAG(mProperties.trimPathOffset, trimPathOffset, mTrimDirty);
+ VD_SET_PROP_WITH_FLAG(mTrimPathOffset, trimPathOffset, mTrimDirty);
}
bool getProperties(int8_t* outProperties, int length);
- void setColorPropertyValue(int propertyId, int32_t value);
- void setPropertyValue(int propertyId, float value);
void setFillGradient(SkShader* fillGradient) {
SkRefCnt_SafeAssign(mFillGradient, fillGradient);
@@ -201,28 +182,24 @@
float strokeScale, const SkMatrix& matrix) override;
private:
- enum class Property {
- StrokeWidth = 0,
- StrokeColor,
- StrokeAlpha,
- FillColor,
- FillAlpha,
- TrimPathStart,
- TrimPathEnd,
- TrimPathOffset,
- StrokeLineCap,
- StrokeLineJoin,
- StrokeMiterLimit,
- Count,
- };
// Applies trimming to the specified path.
void applyTrim();
- Properties mProperties;
- bool mTrimDirty = true;
- SkPath mTrimmedSkPath;
- SkPaint mPaint;
+ float mStrokeWidth = 0;
+ SkColor mStrokeColor = SK_ColorTRANSPARENT;
+ float mStrokeAlpha = 1;
+ SkColor mFillColor = SK_ColorTRANSPARENT;
SkShader* mStrokeGradient = nullptr;
SkShader* mFillGradient = nullptr;
+ float mFillAlpha = 1;
+ float mTrimPathStart = 0;
+ float mTrimPathEnd = 1;
+ float mTrimPathOffset = 0;
+ bool mTrimDirty = true;
+ SkPaint::Cap mStrokeLineCap = SkPaint::Cap::kButt_Cap;
+ SkPaint::Join mStrokeLineJoin = SkPaint::Join::kMiter_Join;
+ float mStrokeMiterLimit = 4;
+ SkPath mTrimmedSkPath;
+ SkPaint mPaint;
};
class ANDROID_API ClipPath: public Path {
@@ -239,58 +216,49 @@
class ANDROID_API Group: public Node {
public:
- struct Properties {
- float rotate = 0;
- float pivotX = 0;
- float pivotY = 0;
- float scaleX = 1;
- float scaleY = 1;
- float translateX = 0;
- float translateY = 0;
- };
Group(const Group& group);
Group() {}
float getRotation() {
- return mProperties.rotate;
+ return mRotate;
}
void setRotation(float rotation) {
- mProperties.rotate = rotation;
+ mRotate = rotation;
}
float getPivotX() {
- return mProperties.pivotX;
+ return mPivotX;
}
void setPivotX(float pivotX) {
- mProperties.pivotX = pivotX;
+ mPivotX = pivotX;
}
float getPivotY() {
- return mProperties.pivotY;
+ return mPivotY;
}
void setPivotY(float pivotY) {
- mProperties.pivotY = pivotY;
+ mPivotY = pivotY;
}
float getScaleX() {
- return mProperties.scaleX;
+ return mScaleX;
}
void setScaleX(float scaleX) {
- mProperties.scaleX = scaleX;
+ mScaleX = scaleX;
}
float getScaleY() {
- return mProperties.scaleY;
+ return mScaleY;
}
void setScaleY(float scaleY) {
- mProperties.scaleY = scaleY;
+ mScaleY = scaleY;
}
float getTranslateX() {
- return mProperties.translateX;
+ return mTranslateX;
}
void setTranslateX(float translateX) {
- mProperties.translateX = translateX;
+ mTranslateX = translateX;
}
float getTranslateY() {
- return mProperties.translateY;
+ return mTranslateY;
}
void setTranslateY(float translateY) {
- mProperties.translateY = translateY;
+ mTranslateY = translateY;
}
virtual void draw(SkCanvas* outCanvas, const SkMatrix& currentMatrix,
float scaleX, float scaleY) override;
@@ -300,33 +268,38 @@
void addChild(Node* child);
void dump() override;
bool getProperties(float* outProperties, int length);
- float getPropertyValue(int propertyId) const;
- void setPropertyValue(int propertyId, float value);
- static bool isValidProperty(int propertyId);
private:
enum class Property {
- Rotate = 0,
- PivotX,
- PivotY,
- ScaleX,
- ScaleY,
- TranslateX,
- TranslateY,
+ Rotate_Property = 0,
+ PivotX_Property,
+ PivotY_Property,
+ ScaleX_Property,
+ ScaleY_Property,
+ TranslateX_Property,
+ TranslateY_Property,
// Count of the properties, must be at the end.
Count,
};
+ float mRotate = 0;
+ float mPivotX = 0;
+ float mPivotY = 0;
+ float mScaleX = 1;
+ float mScaleY = 1;
+ float mTranslateX = 0;
+ float mTranslateY = 0;
std::vector<Node*> mChildren;
- Properties mProperties;
};
-class ANDROID_API Tree : public VirtualLightRefBase {
+class ANDROID_API Tree {
public:
Tree(Group* rootNode) : mRootNode(rootNode) {}
void draw(Canvas* outCanvas, SkColorFilter* colorFilter,
const SkRect& bounds, bool needsMirroring, bool canReuseCache);
+ void drawCachedBitmapWithRootAlpha(Canvas* outCanvas, SkColorFilter* filter,
+ const SkRect& originalBounds);
- const SkBitmap& getBitmapUpdateIfDirty();
+ void updateCachedBitmap(int width, int height);
void createCachedBitmapIfNeeded(int width, int height);
bool canReuseBitmap(int width, int height);
void setAllowCaching(bool allowCaching) {
@@ -343,10 +316,6 @@
mViewportWidth = viewportWidth;
mViewportHeight = viewportHeight;
}
- SkPaint* getPaint();
- const SkRect& getBounds() const {
- return mBounds;
- }
private:
// Cap the bitmap size, such that it won't hurt the performance too much
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp
index d411621..ea702c0 100644
--- a/libs/hwui/renderthread/CanvasContext.cpp
+++ b/libs/hwui/renderthread/CanvasContext.cpp
@@ -92,18 +92,18 @@
}
}
-void CanvasContext::setSurface(ANativeWindow* window) {
+void CanvasContext::setSurface(Surface* surface) {
ATRACE_CALL();
- mNativeWindow = window;
+ mNativeSurface = surface;
if (mEglSurface != EGL_NO_SURFACE) {
mEglManager.destroySurface(mEglSurface);
mEglSurface = EGL_NO_SURFACE;
}
- if (window) {
- mEglSurface = mEglManager.createSurface(window);
+ if (surface) {
+ mEglSurface = mEglManager.createSurface(surface);
}
if (mEglSurface != EGL_NO_SURFACE) {
@@ -127,8 +127,8 @@
mSwapBehavior = swapBehavior;
}
-void CanvasContext::initialize(ANativeWindow* window) {
- setSurface(window);
+void CanvasContext::initialize(Surface* surface) {
+ setSurface(surface);
#if !HWUI_NEW_OPS
if (mCanvas) return;
mCanvas = new OpenGLRenderer(mRenderThread.renderState());
@@ -136,11 +136,11 @@
#endif
}
-void CanvasContext::updateSurface(ANativeWindow* window) {
- setSurface(window);
+void CanvasContext::updateSurface(Surface* surface) {
+ setSurface(surface);
}
-bool CanvasContext::pauseSurface(ANativeWindow* window) {
+bool CanvasContext::pauseSurface(Surface* surface) {
return mRenderThread.removeFrameCallback(this);
}
@@ -204,6 +204,10 @@
info.renderer = mCanvas;
#endif
+ if (CC_LIKELY(mNativeSurface.get())) {
+ info.frameNumber = static_cast<int64_t>(mNativeSurface->getNextFrameNumber());
+ }
+
mAnimationContext->startFrame(info.mode);
for (const sp<RenderNode>& node : mRenderNodes) {
// Only the primary target node will be drawn full - all other nodes would get drawn in
@@ -219,7 +223,7 @@
freePrefetechedLayers();
GL_CHECKPOINT(MODERATE);
- if (CC_UNLIKELY(!mNativeWindow.get())) {
+ if (CC_UNLIKELY(!mNativeSurface.get())) {
mCurrentFrameInfo->addFlag(FrameInfoFlags::SkippedFrame);
info.out.canDrawThisFrame = false;
return;
@@ -242,8 +246,9 @@
} else {
// We're maybe behind? Find out for sure
int runningBehind = 0;
- mNativeWindow->query(mNativeWindow.get(),
- NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND, &runningBehind);
+ // TODO: Have this method be on Surface, too, not just ANativeWindow...
+ ANativeWindow* window = mNativeSurface.get();
+ window->query(window, NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND, &runningBehind);
info.out.canDrawThisFrame = !runningBehind;
}
} else {
diff --git a/libs/hwui/renderthread/CanvasContext.h b/libs/hwui/renderthread/CanvasContext.h
index 63a7977..168166e 100644
--- a/libs/hwui/renderthread/CanvasContext.h
+++ b/libs/hwui/renderthread/CanvasContext.h
@@ -39,6 +39,7 @@
#include <SkBitmap.h>
#include <SkRect.h>
#include <utils/Functor.h>
+#include <gui/Surface.h>
#include <set>
#include <string>
@@ -75,10 +76,10 @@
// Won't take effect until next EGLSurface creation
void setSwapBehavior(SwapBehavior swapBehavior);
- void initialize(ANativeWindow* window);
- void updateSurface(ANativeWindow* window);
- bool pauseSurface(ANativeWindow* window);
- bool hasSurface() { return mNativeWindow.get(); }
+ void initialize(Surface* surface);
+ void updateSurface(Surface* surface);
+ bool pauseSurface(Surface* surface);
+ bool hasSurface() { return mNativeSurface.get(); }
void setup(int width, int height, float lightRadius,
uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha);
@@ -172,7 +173,7 @@
// lifecycle tracking
friend class android::uirenderer::RenderState;
- void setSurface(ANativeWindow* window);
+ void setSurface(Surface* window);
void requireSurface();
void freePrefetechedLayers();
@@ -182,7 +183,7 @@
RenderThread& mRenderThread;
EglManager& mEglManager;
- sp<ANativeWindow> mNativeWindow;
+ sp<Surface> mNativeSurface;
EGLSurface mEglSurface = EGL_NO_SURFACE;
bool mBufferPreserved = false;
SwapBehavior mSwapBehavior = kSwap_default;
diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp
index 1d1b144..7c6cd7e 100644
--- a/libs/hwui/renderthread/RenderProxy.cpp
+++ b/libs/hwui/renderthread/RenderProxy.cpp
@@ -139,38 +139,38 @@
postAndWait(task); // block since name/value pointers owned by caller
}
-CREATE_BRIDGE2(initialize, CanvasContext* context, ANativeWindow* window) {
- args->context->initialize(args->window);
+CREATE_BRIDGE2(initialize, CanvasContext* context, Surface* surface) {
+ args->context->initialize(args->surface);
return nullptr;
}
-void RenderProxy::initialize(const sp<ANativeWindow>& window) {
+void RenderProxy::initialize(const sp<Surface>& surface) {
SETUP_TASK(initialize);
args->context = mContext;
- args->window = window.get();
+ args->surface = surface.get();
post(task);
}
-CREATE_BRIDGE2(updateSurface, CanvasContext* context, ANativeWindow* window) {
- args->context->updateSurface(args->window);
+CREATE_BRIDGE2(updateSurface, CanvasContext* context, Surface* surface) {
+ args->context->updateSurface(args->surface);
return nullptr;
}
-void RenderProxy::updateSurface(const sp<ANativeWindow>& window) {
+void RenderProxy::updateSurface(const sp<Surface>& surface) {
SETUP_TASK(updateSurface);
args->context = mContext;
- args->window = window.get();
+ args->surface = surface.get();
postAndWait(task);
}
-CREATE_BRIDGE2(pauseSurface, CanvasContext* context, ANativeWindow* window) {
- return (void*) args->context->pauseSurface(args->window);
+CREATE_BRIDGE2(pauseSurface, CanvasContext* context, Surface* surface) {
+ return (void*) args->context->pauseSurface(args->surface);
}
-bool RenderProxy::pauseSurface(const sp<ANativeWindow>& window) {
+bool RenderProxy::pauseSurface(const sp<Surface>& surface) {
SETUP_TASK(pauseSurface);
args->context = mContext;
- args->window = window.get();
+ args->surface = surface.get();
return (bool) postAndWait(task);
}
diff --git a/libs/hwui/renderthread/RenderProxy.h b/libs/hwui/renderthread/RenderProxy.h
index 4180d802..178724a 100644
--- a/libs/hwui/renderthread/RenderProxy.h
+++ b/libs/hwui/renderthread/RenderProxy.h
@@ -67,9 +67,9 @@
ANDROID_API bool loadSystemProperties();
ANDROID_API void setName(const char* name);
- ANDROID_API void initialize(const sp<ANativeWindow>& window);
- ANDROID_API void updateSurface(const sp<ANativeWindow>& window);
- ANDROID_API bool pauseSurface(const sp<ANativeWindow>& window);
+ ANDROID_API void initialize(const sp<Surface>& surface);
+ ANDROID_API void updateSurface(const sp<Surface>& surface);
+ ANDROID_API bool pauseSurface(const sp<Surface>& surface);
ANDROID_API void setup(int width, int height, float lightRadius,
uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha);
ANDROID_API void setLightCenter(const Vector3& lightCenter);
diff --git a/libs/hwui/tests/microbench/TaskManagerBench.cpp b/libs/hwui/tests/microbench/TaskManagerBench.cpp
new file mode 100644
index 0000000..0ea30e47
--- /dev/null
+++ b/libs/hwui/tests/microbench/TaskManagerBench.cpp
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2016 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 <benchmark/Benchmark.h>
+
+#include "thread/Task.h"
+#include "thread/TaskManager.h"
+#include "thread/TaskProcessor.h"
+#include "tests/microbench/MicroBench.h"
+
+#include <vector>
+
+using namespace android;
+using namespace android::uirenderer;
+
+class TrivialTask : public Task<char> {};
+
+class TrivialProcessor : public TaskProcessor<char> {
+public:
+ TrivialProcessor(TaskManager* manager)
+ : TaskProcessor(manager) {}
+ virtual ~TrivialProcessor() {}
+ virtual void onProcess(const sp<Task<char> >& task) override {
+ TrivialTask* t = static_cast<TrivialTask*>(task.get());
+ t->setResult(reinterpret_cast<intptr_t>(t) % 16 == 0 ? 'a' : 'b');
+ }
+};
+
+BENCHMARK_NO_ARG(BM_TaskManager_allocateTask);
+void BM_TaskManager_allocateTask::Run(int iters) {
+ std::vector<sp<TrivialTask> > tasks;
+ tasks.reserve(iters);
+
+ StartBenchmarkTiming();
+ for (int i = 0; i < iters; i++) {
+ tasks.emplace_back(new TrivialTask);
+ MicroBench::DoNotOptimize(tasks.back());
+ }
+ StopBenchmarkTiming();
+}
+
+BENCHMARK_NO_ARG(BM_TaskManager_enqueueTask);
+void BM_TaskManager_enqueueTask::Run(int iters) {
+ TaskManager taskManager;
+ sp<TrivialProcessor> processor(new TrivialProcessor(&taskManager));
+ std::vector<sp<TrivialTask> > tasks;
+ tasks.reserve(iters);
+
+ StartBenchmarkTiming();
+ for (int i = 0; i < iters; i++) {
+ tasks.emplace_back(new TrivialTask);
+ MicroBench::DoNotOptimize(tasks.back());
+ processor->add(tasks.back());
+ }
+ StopBenchmarkTiming();
+
+ for (sp<TrivialTask>& task : tasks) {
+ task->getResult();
+ }
+}
+
+BENCHMARK_NO_ARG(BM_TaskManager_enqueueRunDeleteTask);
+void BM_TaskManager_enqueueRunDeleteTask::Run(int iters) {
+ TaskManager taskManager;
+ sp<TrivialProcessor> processor(new TrivialProcessor(&taskManager));
+ std::vector<sp<TrivialTask> > tasks;
+ tasks.reserve(iters);
+
+ StartBenchmarkTiming();
+ for (int i = 0; i < iters; i++) {
+ tasks.emplace_back(new TrivialTask);
+ MicroBench::DoNotOptimize(tasks.back());
+ processor->add(tasks.back());
+ }
+ for (sp<TrivialTask>& task : tasks) {
+ MicroBench::DoNotOptimize(task->getResult());
+ }
+ tasks.clear();
+ StopBenchmarkTiming();
+}
diff --git a/libs/hwui/tests/unit/RecordingCanvasTests.cpp b/libs/hwui/tests/unit/RecordingCanvasTests.cpp
index 01bfc5a..20d2f1f 100644
--- a/libs/hwui/tests/unit/RecordingCanvasTests.cpp
+++ b/libs/hwui/tests/unit/RecordingCanvasTests.cpp
@@ -455,6 +455,23 @@
}
}
+TEST(RecordingCanvas, firstClipWillReplace) {
+ auto dl = TestUtils::createDisplayList<RecordingCanvas>(200, 200, [](RecordingCanvas& canvas) {
+ canvas.save(SaveFlags::MatrixClip);
+ // since no explicit clip set on canvas, this should be the one observed on op:
+ canvas.clipRect(-100, -100, 300, 300, SkRegion::kIntersect_Op);
+
+ SkPaint paint;
+ paint.setColor(SK_ColorWHITE);
+ canvas.drawRect(0, 0, 100, 100, paint);
+
+ canvas.restore();
+ });
+ ASSERT_EQ(1u, dl->getOps().size()) << "Must have one op";
+ // first clip must be preserved, even if it extends beyond canvas bounds
+ EXPECT_CLIP_RECT(Rect(-100, -100, 300, 300), dl->getOps()[0]->localClip);
+}
+
TEST(RecordingCanvas, insertReorderBarrier) {
auto dl = TestUtils::createDisplayList<RecordingCanvas>(200, 200, [](RecordingCanvas& canvas) {
canvas.drawRect(0, 0, 400, 400, SkPaint());
diff --git a/libs/hwui/tests/unit/SkiaBehaviorTests.cpp b/libs/hwui/tests/unit/SkiaBehaviorTests.cpp
new file mode 100644
index 0000000..586625b
--- /dev/null
+++ b/libs/hwui/tests/unit/SkiaBehaviorTests.cpp
@@ -0,0 +1,43 @@
+/*
+ * 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 "tests/common/TestUtils.h"
+
+#include <gtest/gtest.h>
+#include <SkShader.h>
+
+using namespace android;
+using namespace android::uirenderer;
+
+/**
+ * 1x1 bitmaps must not be optimized into solid color shaders, since HWUI can't
+ * compose/render color shaders
+ */
+TEST(SkiaBehavior, CreateBitmapShader1x1) {
+ SkBitmap origBitmap = TestUtils::createSkBitmap(1, 1);
+ std::unique_ptr<SkShader> s(SkShader::CreateBitmapShader(
+ origBitmap,
+ SkShader::kClamp_TileMode,
+ SkShader::kRepeat_TileMode));
+
+ SkBitmap bitmap;
+ SkShader::TileMode xy[2];
+ ASSERT_TRUE(s->isABitmap(&bitmap, nullptr, xy))
+ << "1x1 bitmap shader must query as bitmap shader";
+ EXPECT_EQ(SkShader::kClamp_TileMode, xy[0]);
+ EXPECT_EQ(SkShader::kRepeat_TileMode, xy[1]);
+ EXPECT_EQ(origBitmap.pixelRef(), bitmap.pixelRef());
+}
diff --git a/libs/hwui/thread/TaskManager.cpp b/libs/hwui/thread/TaskManager.cpp
index a07845e..d346b85 100644
--- a/libs/hwui/thread/TaskManager.cpp
+++ b/libs/hwui/thread/TaskManager.cpp
@@ -103,7 +103,7 @@
return true;
}
-bool TaskManager::WorkerThread::addTask(TaskWrapper task) {
+bool TaskManager::WorkerThread::addTask(const TaskWrapper& task) {
if (!isRunning()) {
run(mName.string(), PRIORITY_DEFAULT);
} else if (exitPending()) {
diff --git a/libs/hwui/thread/TaskManager.h b/libs/hwui/thread/TaskManager.h
index d0eb304..e4808f7 100644
--- a/libs/hwui/thread/TaskManager.h
+++ b/libs/hwui/thread/TaskManager.h
@@ -80,7 +80,7 @@
public:
WorkerThread(const String8 name): mSignal(Condition::WAKE_UP_ONE), mName(name) { }
- bool addTask(TaskWrapper task);
+ bool addTask(const TaskWrapper& task);
size_t getTaskCount() const;
void exit();
diff --git a/packages/DocumentsUI/tests/src/com/android/documentsui/StubProvider.java b/packages/DocumentsUI/tests/src/com/android/documentsui/StubProvider.java
index 9855427..2527650 100644
--- a/packages/DocumentsUI/tests/src/com/android/documentsui/StubProvider.java
+++ b/packages/DocumentsUI/tests/src/com/android/documentsui/StubProvider.java
@@ -16,10 +16,6 @@
package com.android.documentsui;
-import static com.android.documentsui.Shared.TAG;
-
-import android.annotation.NonNull;
-import android.annotation.Nullable;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.ProviderInfo;
@@ -471,6 +467,14 @@
@Override
public Bundle call(String method, String arg, Bundle extras) {
+ // We're not supposed to override any of the default DocumentsProvider
+ // methods that are supported by "call", so javadoc asks that we
+ // always call super.call first and return if response is not null.
+ Bundle result = super.call(method, arg, extras);
+ if (result != null) {
+ return result;
+ }
+
switch (method) {
case "clear":
clearCacheAndBuildRoots();
@@ -484,11 +488,10 @@
simulateReadErrorsForFile(arg);
return null;
case "createDocumentWithFlags":
- Bundle bundle = dispatchCreateDocumentWithFlags(extras);
- return bundle;
- default:
- return super.call(method, arg, extras);
+ return dispatchCreateDocumentWithFlags(extras);
}
+
+ return null;
}
private Bundle createVirtualFileFromBundle(Bundle extras) {
diff --git a/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java b/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java
index 78c530c..f885110 100644
--- a/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java
+++ b/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java
@@ -155,7 +155,7 @@
for (UserInfo userInfo : um.getProfiles(userId)) {
final List<ComponentName> admins = dpm.getActiveAdminsAsUser(userInfo.id);
if (admins == null) {
- return null;
+ continue;
}
final boolean isSeparateProfileChallengeEnabled =
lockPatternUtils.isSeparateProfileChallengeEnabled(userInfo.id);
@@ -209,16 +209,7 @@
IPackageManager ipm = AppGlobals.getPackageManager();
try {
if (ipm.getBlockUninstallForUser(packageName, userId)) {
- DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(
- Context.DEVICE_POLICY_SERVICE);
- if (dpm == null) {
- return null;
- }
- ComponentName admin = dpm.getProfileOwner();
- if (admin == null) {
- admin = dpm.getDeviceOwnerComponentOnCallingUser();
- }
- return new EnforcedAdmin(admin, UserHandle.myUserId());
+ return getProfileOrDeviceOwner(context, userId);
}
} catch (RemoteException e) {
// Nothing to do
@@ -238,7 +229,7 @@
try {
ApplicationInfo ai = ipm.getApplicationInfo(packageName, 0, userId);
if (ai != null && ((ai.flags & ApplicationInfo.FLAG_SUSPENDED) != 0)) {
- return getProfileOrDeviceOwnerOnCallingUser(context);
+ return getProfileOrDeviceOwner(context, userId);
}
} catch (RemoteException e) {
// Nothing to do
@@ -246,6 +237,80 @@
return null;
}
+ public static EnforcedAdmin checkIfInputMethodDisallowed(Context context,
+ String packageName, int userId) {
+ DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(
+ Context.DEVICE_POLICY_SERVICE);
+ if (dpm == null) {
+ return null;
+ }
+ EnforcedAdmin admin = getProfileOrDeviceOwner(context, userId);
+ boolean permitted = true;
+ if (admin != null) {
+ permitted = dpm.isInputMethodPermittedByAdmin(admin.component,
+ packageName, userId);
+ }
+ int managedProfileId = getManagedProfileId(context, userId);
+ EnforcedAdmin profileAdmin = getProfileOrDeviceOwner(context, managedProfileId);
+ boolean permittedByProfileAdmin = true;
+ if (profileAdmin != null) {
+ permittedByProfileAdmin = dpm.isInputMethodPermittedByAdmin(profileAdmin.component,
+ packageName, managedProfileId);
+ }
+ if (!permitted && !permittedByProfileAdmin) {
+ return EnforcedAdmin.MULTIPLE_ENFORCED_ADMIN;
+ } else if (!permitted) {
+ return admin;
+ } else if (!permittedByProfileAdmin) {
+ return profileAdmin;
+ }
+ return null;
+ }
+
+ public static EnforcedAdmin checkIfAccessibilityServiceDisallowed(Context context,
+ String packageName, int userId) {
+ DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(
+ Context.DEVICE_POLICY_SERVICE);
+ if (dpm == null) {
+ return null;
+ }
+ EnforcedAdmin admin = getProfileOrDeviceOwner(context, userId);
+ boolean permitted = true;
+ if (admin != null) {
+ permitted = dpm.isAccessibilityServicePermittedByAdmin(admin.component,
+ packageName, userId);
+ }
+ int managedProfileId = getManagedProfileId(context, userId);
+ EnforcedAdmin profileAdmin = getProfileOrDeviceOwner(context, managedProfileId);
+ boolean permittedByProfileAdmin = true;
+ if (profileAdmin != null) {
+ permittedByProfileAdmin = dpm.isAccessibilityServicePermittedByAdmin(
+ profileAdmin.component, packageName, managedProfileId);
+ }
+ if (!permitted && !permittedByProfileAdmin) {
+ return EnforcedAdmin.MULTIPLE_ENFORCED_ADMIN;
+ } else if (!permitted) {
+ return admin;
+ } else if (!permittedByProfileAdmin) {
+ return profileAdmin;
+ }
+ return null;
+ }
+
+ private static int getManagedProfileId(Context context, int userId) {
+ UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
+ List<UserInfo> userProfiles = um.getProfiles(userId);
+ for (UserInfo uInfo : userProfiles) {
+ if (uInfo.id == userId) {
+ continue;
+ }
+ if (uInfo.isManagedProfile()) {
+ return uInfo.id;
+ }
+ }
+ return UserHandle.USER_NULL;
+ }
+
/**
* Check if account management for a specific type of account is disabled by admin.
* Only a profile or device owner can disable account management. So, we check if account
@@ -255,7 +320,7 @@
* or {@code null} if the account management is not disabled.
*/
public static EnforcedAdmin checkIfAccountManagementDisabled(Context context,
- String accountType) {
+ String accountType, int userId) {
if (accountType == null) {
return null;
}
@@ -265,7 +330,7 @@
return null;
}
boolean isAccountTypeDisabled = false;
- String[] disabledTypes = dpm.getAccountTypesWithManagementDisabled();
+ String[] disabledTypes = dpm.getAccountTypesWithManagementDisabledAsUser(userId);
for (String type : disabledTypes) {
if (accountType.equals(type)) {
isAccountTypeDisabled = true;
@@ -275,7 +340,7 @@
if (!isAccountTypeDisabled) {
return null;
}
- return getProfileOrDeviceOwnerOnCallingUser(context);
+ return getProfileOrDeviceOwner(context, userId);
}
/**
@@ -296,7 +361,7 @@
}
/**
- * Checks if an admin has enforced minimum password quality requirements on the device.
+ * Checks if an admin has enforced minimum password quality requirements on the given user.
*
* @return EnforcedAdmin Object containing the enforced admin component and admin user details,
* or {@code null} if no quality requirements are set. If the requirements are set by
@@ -304,35 +369,73 @@
* {@link UserHandle#USER_NULL}.
*
*/
- public static EnforcedAdmin checkIfPasswordQualityIsSet(Context context) {
+ public static EnforcedAdmin checkIfPasswordQualityIsSet(Context context, int userId) {
final DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(
Context.DEVICE_POLICY_SERVICE);
if (dpm == null) {
return null;
}
- boolean isDisabledByMultipleAdmins = false;
- ComponentName adminComponent = null;
- List<ComponentName> admins = dpm.getActiveAdmins();
- int quality;
- if (admins != null) {
+
+ LockPatternUtils lockPatternUtils = new LockPatternUtils(context);
+ EnforcedAdmin enforcedAdmin = null;
+ if (lockPatternUtils.isSeparateProfileChallengeEnabled(userId)) {
+ // userId is managed profile and has a separate challenge, only consider
+ // the admins in that user.
+ final List<ComponentName> admins = dpm.getActiveAdminsAsUser(userId);
+ if (admins == null) {
+ return null;
+ }
for (ComponentName admin : admins) {
- quality = dpm.getPasswordQuality(admin);
- if (quality >= DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
- if (adminComponent == null) {
- adminComponent = admin;
+ if (dpm.getPasswordQuality(admin, userId)
+ > DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
+ if (enforcedAdmin == null) {
+ enforcedAdmin = new EnforcedAdmin(admin, userId);
} else {
- isDisabledByMultipleAdmins = true;
- break;
+ return EnforcedAdmin.MULTIPLE_ENFORCED_ADMIN;
}
}
}
- }
- EnforcedAdmin enforcedAdmin = null;
- if (adminComponent != null) {
- if (!isDisabledByMultipleAdmins) {
- enforcedAdmin = new EnforcedAdmin(adminComponent, UserHandle.myUserId());
- } else {
- enforcedAdmin = new EnforcedAdmin();
+ } else {
+ // Return all admins for this user and the profiles that are visible from this
+ // user that do not use a separate work challenge.
+ final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
+ for (UserInfo userInfo : um.getProfiles(userId)) {
+ final List<ComponentName> admins = dpm.getActiveAdminsAsUser(userInfo.id);
+ if (admins == null) {
+ continue;
+ }
+ final boolean isSeparateProfileChallengeEnabled =
+ lockPatternUtils.isSeparateProfileChallengeEnabled(userInfo.id);
+ for (ComponentName admin : admins) {
+ if (!isSeparateProfileChallengeEnabled) {
+ if (dpm.getPasswordQuality(admin, userInfo.id)
+ > DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
+ if (enforcedAdmin == null) {
+ enforcedAdmin = new EnforcedAdmin(admin, userInfo.id);
+ } else {
+ return EnforcedAdmin.MULTIPLE_ENFORCED_ADMIN;
+ }
+ // This same admins could have set policies both on the managed profile
+ // and on the parent. So, if the admin has set the policy on the
+ // managed profile here, we don't need to further check if that admin
+ // has set policy on the parent admin.
+ continue;
+ }
+ }
+ if (userInfo.isManagedProfile()) {
+ // If userInfo.id is a managed profile, we also need to look at
+ // the policies set on the parent.
+ DevicePolicyManager parentDpm = dpm.getParentProfileInstance(userInfo);
+ if (parentDpm.getPasswordQuality(admin, userInfo.id)
+ > DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
+ if (enforcedAdmin == null) {
+ enforcedAdmin = new EnforcedAdmin(admin, userInfo.id);
+ } else {
+ return EnforcedAdmin.MULTIPLE_ENFORCED_ADMIN;
+ }
+ }
+ }
+ }
}
}
return enforcedAdmin;
@@ -352,7 +455,8 @@
EnforcedAdmin enforcedAdmin = null;
final int userId = UserHandle.myUserId();
if (lockPatternUtils.isSeparateProfileChallengeEnabled(userId)) {
- // If the user has a separate challenge, only consider the admins in that user.
+ // userId is managed profile and has a separate challenge, only consider
+ // the admins in that user.
final List<ComponentName> admins = dpm.getActiveAdminsAsUser(userId);
if (admins == null) {
return null;
@@ -373,7 +477,7 @@
for (UserInfo userInfo : um.getProfiles(userId)) {
final List<ComponentName> admins = dpm.getActiveAdminsAsUser(userInfo.id);
if (admins == null) {
- return null;
+ continue;
}
final boolean isSeparateProfileChallengeEnabled =
lockPatternUtils.isSeparateProfileChallengeEnabled(userInfo.id);
@@ -410,19 +514,24 @@
return enforcedAdmin;
}
- public static EnforcedAdmin getProfileOrDeviceOwnerOnCallingUser(Context context) {
+ public static EnforcedAdmin getProfileOrDeviceOwner(Context context, int userId) {
+ if (userId == UserHandle.USER_NULL) {
+ return null;
+ }
final DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(
Context.DEVICE_POLICY_SERVICE);
if (dpm == null) {
return null;
}
- ComponentName adminComponent = dpm.getDeviceOwnerComponentOnCallingUser();
+ ComponentName adminComponent = dpm.getProfileOwnerAsUser(userId);
if (adminComponent != null) {
- return new EnforcedAdmin(adminComponent, UserHandle.myUserId());
+ return new EnforcedAdmin(adminComponent, userId);
}
- adminComponent = dpm.getProfileOwner();
- if (adminComponent != null) {
- return new EnforcedAdmin(adminComponent, UserHandle.myUserId());
+ if (dpm.getDeviceOwnerUserId() == userId) {
+ adminComponent = dpm.getDeviceOwnerComponentOnAnyUser();
+ if (adminComponent != null) {
+ return new EnforcedAdmin(adminComponent, userId);
+ }
}
return null;
}
diff --git a/packages/SystemUI/res/layout/status_bar_no_notifications.xml b/packages/SystemUI/res/layout/status_bar_no_notifications.xml
index dd501d4..6f87184 100644
--- a/packages/SystemUI/res/layout/status_bar_no_notifications.xml
+++ b/packages/SystemUI/res/layout/status_bar_no_notifications.xml
@@ -25,9 +25,9 @@
android:id="@+id/no_notifications"
android:layout_width="match_parent"
android:layout_height="64dp"
- android:paddingTop="12dp"
+ android:paddingTop="28dp"
android:gravity="top|center_horizontal"
- android:textColor="#ffffff"
- android:textSize="20sp"
+ android:textColor="#e6ffffff"
+ android:textSize="16sp"
android:text="@string/empty_shade_text"/>
</com.android.systemui.statusbar.EmptyShadeView>
diff --git a/packages/SystemUI/res/layout/status_bar_notification_dismiss_all.xml b/packages/SystemUI/res/layout/status_bar_notification_dismiss_all.xml
index dc7577a..efb273f 100644
--- a/packages/SystemUI/res/layout/status_bar_notification_dismiss_all.xml
+++ b/packages/SystemUI/res/layout/status_bar_notification_dismiss_all.xml
@@ -19,15 +19,16 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:visibility="gone"
- android:clipChildren="false"
- android:clipToPadding="false">
+ android:paddingEnd="8dp"
+ android:visibility="gone">
<com.android.systemui.statusbar.DismissViewButton
+ style="@android:style/Widget.Material.Button.Borderless"
android:id="@+id/dismiss_text"
- android:layout_width="48dp"
- android:layout_height="48dp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
android:layout_gravity="end"
android:focusable="true"
- android:background="@drawable/ripple_drawable"
- android:contentDescription="@string/accessibility_clear_all"/>
+ android:contentDescription="@string/accessibility_clear_all"
+ android:text="@string/clear_all_notifications_text"
+ android:textAllCaps="true"/>
</com.android.systemui.statusbar.DismissView>
diff --git a/packages/SystemUI/res/values-sw600dp/dimens.xml b/packages/SystemUI/res/values-sw600dp/dimens.xml
index 71f92fd..c0652d8 100644
--- a/packages/SystemUI/res/values-sw600dp/dimens.xml
+++ b/packages/SystemUI/res/values-sw600dp/dimens.xml
@@ -93,4 +93,6 @@
<dimen name="navigation_key_width">128dp</dimen>
<dimen name="navigation_key_padding">25dp</dimen>
+
+ <dimen name="qs_expand_margin">0dp</dimen>
</resources>
diff --git a/packages/SystemUI/res/values-w550dp-land/dimens.xml b/packages/SystemUI/res/values-w550dp-land/dimens.xml
index eaca9d7..4160c83 100644
--- a/packages/SystemUI/res/values-w550dp-land/dimens.xml
+++ b/packages/SystemUI/res/values-w550dp-land/dimens.xml
@@ -18,4 +18,6 @@
<resources>
<!-- Standard notification width + gravity -->
<dimen name="notification_panel_width">544dp</dimen>
+
+ <dimen name="qs_expand_margin">32dp</dimen>
</resources>
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index e79a82a..e5e5710 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -186,6 +186,7 @@
<dimen name="qs_detail_empty_text_size">14sp</dimen>
<dimen name="qs_data_usage_text_size">14sp</dimen>
<dimen name="qs_data_usage_usage_text_size">36sp</dimen>
+ <dimen name="qs_expand_margin">0dp</dimen>
<dimen name="segmented_button_spacing">0dp</dimen>
<dimen name="borderless_button_radius">2dp</dimen>
@@ -606,4 +607,7 @@
<dimen name="docked_divider_handle_width">16dp</dimen>
<dimen name="docked_divider_handle_height">2dp</dimen>
+
+ <dimen name="battery_height">14.5dp</dimen>
+ <dimen name="battery_width">9.5dp</dimen>
</resources>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 9f10520..6ff9be1 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -1044,9 +1044,6 @@
<!-- VolumeUI restoration notification: text -->
<string name="volumeui_notification_text">Touch to restore the original.</string>
- <!-- Describes the way 2 names are concatenated. An example would be ", " to produce "Peter Muller, Paul Curry". Please also include a space here if it's appropriate in the language and if it's a RTL language include it on the left. The translation should start and end with " to keep the white space if desired [CHAR LIMIT=5] -->
- <string name="group_summary_concadenation">", "</string>
-
<!-- Toast shown when user unlocks screen and managed profile activity is in the foreground -->
<string name="managed_profile_foreground_toast">You\'re using your work profile</string>
@@ -1187,6 +1184,11 @@
<!-- Description for the toggle to set the initial scroll state to be paging or stack. DO NOT TRANSLATE -->
<string name="overview_initial_state_paging_desc">Determines whether Overview will initially be in a stacked or paged state</string>
+ <!-- Toggle to enable the gesture to enter split-screen by swiping up from the Overview button. [CHAR LIMIT=60]-->
+ <string name="overview_nav_bar_gesture">Enable split-screen swipe-up accelerator</string>
+ <!-- Description for the toggle to enable the gesture to enter split-screen by swiping up from the Overview button. [CHAR LIMIT=NONE]-->
+ <string name="overview_nav_bar_gesture_desc">Enable gesture to enter split-screen by swiping up from the Overview button</string>
+
<!-- Category in the System UI Tuner settings, where new/experimental
settings are -->
<string name="experimental">Experimental</string>
diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml
index 9931ab9..b078a68 100644
--- a/packages/SystemUI/res/values/styles.xml
+++ b/packages/SystemUI/res/values/styles.xml
@@ -241,6 +241,10 @@
parent="@*android:style/TextAppearance.Material.Notification.Info">
</style>
+ <style name="TextAppearance.Material.Notification.HybridNotificationDivider"
+ parent="@*android:style/TextAppearance.Material.Notification">
+ </style>
+
<style name="SearchPanelCircle">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
diff --git a/packages/SystemUI/res/xml/tuner_prefs.xml b/packages/SystemUI/res/xml/tuner_prefs.xml
index febe518..4de4ced 100644
--- a/packages/SystemUI/res/xml/tuner_prefs.xml
+++ b/packages/SystemUI/res/xml/tuner_prefs.xml
@@ -122,6 +122,11 @@
android:title="@string/overview_fast_toggle_via_button"
android:summary="@string/overview_fast_toggle_via_button_desc" />
+ <com.android.systemui.tuner.TunerSwitch
+ android:key="overview_nav_bar_gesture"
+ android:title="@string/overview_nav_bar_gesture"
+ android:summary="@string/overview_nav_bar_gesture_desc" />
+
</PreferenceScreen>
<SwitchPreference
diff --git a/packages/SystemUI/src/com/android/systemui/BatteryMeterDrawable.java b/packages/SystemUI/src/com/android/systemui/BatteryMeterDrawable.java
index a0dbad4..e770b5d 100755
--- a/packages/SystemUI/src/com/android/systemui/BatteryMeterDrawable.java
+++ b/packages/SystemUI/src/com/android/systemui/BatteryMeterDrawable.java
@@ -51,6 +51,8 @@
private static final float BOLT_LEVEL_THRESHOLD = 0.3f; // opaque bolt below this fraction
private final int[] mColors;
+ private final int mIntrinsicWidth;
+ private final int mIntrinsicHeight;
private boolean mShowPercent;
private float mButtonHeightFraction;
@@ -161,6 +163,19 @@
mLightModeBackgroundColor =
context.getColor(R.color.light_mode_icon_color_dual_tone_background);
mLightModeFillColor = context.getColor(R.color.light_mode_icon_color_dual_tone_fill);
+
+ mIntrinsicWidth = context.getResources().getDimensionPixelSize(R.dimen.battery_width);
+ mIntrinsicHeight = context.getResources().getDimensionPixelSize(R.dimen.battery_height);
+ }
+
+ @Override
+ public int getIntrinsicHeight() {
+ return mIntrinsicHeight;
+ }
+
+ @Override
+ public int getIntrinsicWidth() {
+ return mIntrinsicWidth;
}
public void startListening() {
diff --git a/packages/SystemUI/src/com/android/systemui/Interpolators.java b/packages/SystemUI/src/com/android/systemui/Interpolators.java
index cd6dce0..5e33a9f 100644
--- a/packages/SystemUI/src/com/android/systemui/Interpolators.java
+++ b/packages/SystemUI/src/com/android/systemui/Interpolators.java
@@ -34,4 +34,10 @@
public static final Interpolator LINEAR = new LinearInterpolator();
public static final Interpolator ACCELERATE_DECELERATE = new AccelerateDecelerateInterpolator();
public static final Interpolator DECELERATE_QUINT = new DecelerateInterpolator(2.5f);
+
+ /**
+ * Interpolator to be used when animating a move based on a click. Pair with enough duration.
+ */
+ public static final Interpolator TOUCH_RESPONSE =
+ new PathInterpolator(0.3f, 0f, 0.1f, 1f);
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSIconView.java b/packages/SystemUI/src/com/android/systemui/qs/QSIconView.java
index ed90904..1df372b 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSIconView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSIconView.java
@@ -24,6 +24,7 @@
import android.view.ViewGroup;
import android.widget.ImageView;
+import android.widget.ImageView.ScaleType;
import com.android.systemui.R;
import java.util.Objects;
@@ -96,7 +97,7 @@
protected View createIcon() {
final ImageView icon = new ImageView(mContext);
icon.setId(android.R.id.icon);
- icon.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
+ icon.setScaleType(ScaleType.FIT_CENTER);
return icon;
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java
index e4b8a6c..f208470 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java
@@ -18,6 +18,7 @@
import android.content.Context;
import android.content.res.ColorStateList;
+import android.content.res.Configuration;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
@@ -102,6 +103,8 @@
private static class HeaderTileLayout extends LinearLayout implements QSTileLayout {
+ private final ImageView mDownArrow;
+
public HeaderTileLayout(Context context) {
super(context);
setClipChildren(false);
@@ -111,17 +114,31 @@
int padding =
mContext.getResources().getDimensionPixelSize(R.dimen.qs_quick_tile_padding);
- ImageView downArrow = new ImageView(context);
- downArrow.setImageResource(R.drawable.ic_expand_more);
- downArrow.setImageTintList(ColorStateList.valueOf(context.getResources().getColor(
+ mDownArrow = new ImageView(context);
+ mDownArrow.setImageResource(R.drawable.ic_expand_more);
+ mDownArrow.setImageTintList(ColorStateList.valueOf(context.getResources().getColor(
android.R.color.white, null)));
- downArrow.setLayoutParams(generateLayoutParams());
- downArrow.setPadding(padding, padding, padding, padding);
- addView(downArrow);
+ mDownArrow.setLayoutParams(generateLayoutParams());
+ mDownArrow.setPadding(padding, padding, padding, padding);
+ updateDownArrowMargin();
+ addView(mDownArrow);
setOrientation(LinearLayout.HORIZONTAL);
}
@Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ updateDownArrowMargin();
+ }
+
+ private void updateDownArrowMargin() {
+ LayoutParams params = (LayoutParams) mDownArrow.getLayoutParams();
+ params.setMarginStart(mContext.getResources().getDimensionPixelSize(
+ R.dimen.qs_expand_margin));
+ mDownArrow.setLayoutParams(params);
+ }
+
+ @Override
public void addTile(TileRecord tile) {
addView(tile.tileView, getChildCount() - 1 /* Leave icon at end */,
generateLayoutParams());
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
index 1cceef4..dead0db 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
@@ -551,11 +551,14 @@
public void dockTopTask(int topTaskId, int dragMode,
int stackCreateMode, Rect initialBounds) {
SystemServicesProxy ssp = Recents.getSystemServices();
+
+ // Make sure we inform DividerView before we actually start the activity so we can change
+ // the resize mode already.
+ EventBus.getDefault().send(new DockingTopTaskEvent(dragMode));
ssp.moveTaskToDockedStack(topTaskId, stackCreateMode, initialBounds);
showRecents(false /* triggeredFromAltTab */,
dragMode == NavigationBarGestureHelper.DRAG_MODE_RECENTS, false /* animate */,
true /* reloadTasks*/);
- EventBus.getDefault().send(new DockingTopTaskEvent(dragMode));
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/recents/events/activity/UndockingTaskEvent.java b/packages/SystemUI/src/com/android/systemui/recents/events/activity/UndockingTaskEvent.java
new file mode 100644
index 0000000..d5083a8
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/recents/events/activity/UndockingTaskEvent.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.systemui.recents.events.activity;
+
+import com.android.systemui.recents.events.EventBus;
+
+/**
+ * Fires when the user invoked the gesture to undock the task in the docked stack.
+ */
+public class UndockingTaskEvent extends EventBus.Event {
+
+ public UndockingTaskEvent() {
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerHandleView.java b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerHandleView.java
index 5ef56f3..12e2713 100644
--- a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerHandleView.java
+++ b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerHandleView.java
@@ -26,10 +26,9 @@
import android.graphics.Paint;
import android.util.AttributeSet;
import android.util.Property;
-import android.view.animation.AnimationUtils;
-import android.view.animation.Interpolator;
import android.widget.ImageButton;
+import com.android.systemui.Interpolators;
import com.android.systemui.R;
/**
@@ -71,7 +70,6 @@
private final int mWidth;
private final int mHeight;
private final int mCircleDiameter;
- private final Interpolator mFastOutSlowInInterpolator;
private int mCurrentWidth;
private int mCurrentHeight;
private AnimatorSet mAnimator;
@@ -85,8 +83,6 @@
mCurrentWidth = mWidth;
mCurrentHeight = mHeight;
mCircleDiameter = (mWidth + mHeight) / 3;
- mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(getContext(),
- android.R.interpolator.fast_out_slow_in);
}
public void setTouching(boolean touching, boolean animate) {
@@ -120,8 +116,8 @@
? DividerView.TOUCH_ANIMATION_DURATION
: DividerView.TOUCH_RELEASE_ANIMATION_DURATION);
mAnimator.setInterpolator(touching
- ? DividerView.TOUCH_RESPONSE_INTERPOLATOR
- : mFastOutSlowInInterpolator);
+ ? Interpolators.TOUCH_RESPONSE
+ : Interpolators.FAST_OUT_SLOW_IN);
mAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
index 1e11fa8..83c22b1 100644
--- a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
+++ b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
@@ -48,10 +48,12 @@
import com.android.internal.policy.DividerSnapAlgorithm;
import com.android.internal.policy.DividerSnapAlgorithm.SnapTarget;
import com.android.internal.policy.DockedDividerUtils;
+import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.DockingTopTaskEvent;
import com.android.systemui.recents.events.activity.RecentsActivityStartingEvent;
+import com.android.systemui.recents.events.activity.UndockingTaskEvent;
import com.android.systemui.recents.events.ui.RecentsDrawnEvent;
import com.android.systemui.statusbar.FlingAnimationUtils;
import com.android.systemui.statusbar.phone.NavigationBarGestureHelper;
@@ -67,8 +69,6 @@
static final long TOUCH_ANIMATION_DURATION = 150;
static final long TOUCH_RELEASE_ANIMATION_DURATION = 200;
- static final Interpolator TOUCH_RESPONSE_INTERPOLATOR =
- new PathInterpolator(0.3f, 0f, 0.1f, 1f);
private static final String TAG = "DividerView";
@@ -116,7 +116,6 @@
private final Rect mOtherInsetRect = new Rect();
private final Rect mLastResizeRect = new Rect();
private final WindowManagerProxy mWindowManagerProxy = WindowManagerProxy.getInstance();
- private Interpolator mFastOutSlowInInterpolator;
private DividerWindowManager mWindowManager;
private VelocityTracker mVelocityTracker;
private FlingAnimationUtils mFlingAnimationUtils;
@@ -158,8 +157,6 @@
mTouchElevation = getResources().getDimensionPixelSize(
R.dimen.docked_stack_divider_lift_elevation);
mGrowRecents = getResources().getBoolean(R.bool.recents_grow_in_multiwindow);
- mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(getContext(),
- android.R.interpolator.fast_out_slow_in);
mTouchSlop = ViewConfiguration.get(mContext).getScaledTouchSlop();
mFlingAnimationUtils = new FlingAnimationUtils(getContext(), 0.3f);
updateDisplayInfo();
@@ -192,7 +189,7 @@
insets.getStableInsetRight(), insets.getStableInsetBottom());
if (mSnapAlgorithm != null) {
mSnapAlgorithm = null;
- getSnapAlgorithm();
+ initializeSnapAlgorithm();
}
}
return super.onApplyWindowInsets(insets);
@@ -211,17 +208,13 @@
mHandle.setTouching(true, animate);
}
mDockSide = mWindowManagerProxy.getDockSide();
- getSnapAlgorithm();
- if (mDockSide != WindowManager.DOCKED_INVALID) {
- mWindowManagerProxy.setResizing(true);
- mWindowManager.setSlippery(false);
- if (touching) {
- liftBackground();
- }
- return true;
- } else {
- return false;
+ initializeSnapAlgorithm();
+ mWindowManagerProxy.setResizing(true);
+ mWindowManager.setSlippery(false);
+ if (touching) {
+ liftBackground();
}
+ return mDockSide != WindowManager.DOCKED_INVALID;
}
public void stopDragging(int position, float velocity, boolean avoidDismissStart) {
@@ -233,17 +226,36 @@
public void stopDragging(int position, SnapTarget target, long duration,
Interpolator interpolator) {
+ stopDragging(position, target, duration, 0 /* startDelay*/, interpolator);
+ }
+
+ public void stopDragging(int position, SnapTarget target, long duration, long startDelay,
+ Interpolator interpolator) {
mHandle.setTouching(false, true /* animate */);
- flingTo(position, target, duration, interpolator);
+ flingTo(position, target, duration, startDelay, interpolator);
mWindowManager.setSlippery(true);
releaseBackground();
}
- public DividerSnapAlgorithm getSnapAlgorithm() {
+ private void stopDragging() {
+ mHandle.setTouching(false, true /* animate */);
+ mWindowManager.setSlippery(true);
+ releaseBackground();
+ }
+
+ private void updateDockSide() {
+ mDockSide = mWindowManagerProxy.getDockSide();
+ }
+
+ private void initializeSnapAlgorithm() {
if (mSnapAlgorithm == null) {
mSnapAlgorithm = new DividerSnapAlgorithm(getContext().getResources(), mDisplayWidth,
mDisplayHeight, mDividerSize, isHorizontalDivision(), mStableInsets);
}
+ }
+
+ public DividerSnapAlgorithm getSnapAlgorithm() {
+ initializeSnapAlgorithm();
return mSnapAlgorithm;
}
@@ -267,6 +279,11 @@
mStartX = (int) event.getX();
mStartY = (int) event.getY();
boolean result = startDragging(true /* animate */, true /* touching */);
+ if (!result) {
+
+ // Weren't able to start dragging successfully, so cancel it again.
+ stopDragging();
+ }
mStartPosition = getCurrentPosition();
mMoving = false;
return result;
@@ -320,10 +337,11 @@
anim.start();
}
- private void flingTo(int position, SnapTarget target, long duration,
+ private void flingTo(int position, SnapTarget target, long duration, long startDelay,
Interpolator interpolator) {
ValueAnimator anim = getFlingAnimator(position, target);
anim.setDuration(duration);
+ anim.setStartDelay(startDelay);
anim.setInterpolator(interpolator);
anim.start();
}
@@ -377,7 +395,7 @@
mBackground.animate().scaleX(1.4f);
}
mBackground.animate()
- .setInterpolator(TOUCH_RESPONSE_INTERPOLATOR)
+ .setInterpolator(Interpolators.TOUCH_RESPONSE)
.setDuration(TOUCH_ANIMATION_DURATION)
.translationZ(mTouchElevation)
.start();
@@ -385,7 +403,7 @@
// Lift handle as well so it doesn't get behind the background, even though it doesn't
// cast shadow.
mHandle.animate()
- .setInterpolator(TOUCH_RESPONSE_INTERPOLATOR)
+ .setInterpolator(Interpolators.TOUCH_RESPONSE)
.setDuration(TOUCH_ANIMATION_DURATION)
.translationZ(mTouchElevation)
.start();
@@ -393,14 +411,14 @@
private void releaseBackground() {
mBackground.animate()
- .setInterpolator(mFastOutSlowInInterpolator)
+ .setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
.setDuration(TOUCH_RELEASE_ANIMATION_DURATION)
.translationZ(0)
.scaleX(1f)
.scaleY(1f)
.start();
mHandle.animate()
- .setInterpolator(mFastOutSlowInInterpolator)
+ .setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
.setDuration(TOUCH_RELEASE_ANIMATION_DURATION)
.translationZ(0)
.start();
@@ -421,6 +439,7 @@
mDisplayWidth = info.logicalWidth;
mDisplayHeight = info.logicalHeight;
mSnapAlgorithm = null;
+ initializeSnapAlgorithm();
}
private int calculatePosition(int touchX, int touchY) {
@@ -725,13 +744,29 @@
public final void onBusEvent(RecentsDrawnEvent drawnEvent) {
if (mAnimateAfterRecentsDrawn) {
mAnimateAfterRecentsDrawn = false;
+ updateDockSide();
stopDragging(getCurrentPosition(), mSnapAlgorithm.getMiddleTarget(), 250,
- TOUCH_RESPONSE_INTERPOLATOR);
+ Interpolators.TOUCH_RESPONSE);
}
if (mGrowAfterRecentsDrawn) {
mGrowAfterRecentsDrawn = false;
+ updateDockSide();
stopDragging(getCurrentPosition(), mSnapAlgorithm.getMiddleTarget(), 250,
- TOUCH_RESPONSE_INTERPOLATOR);
+ Interpolators.TOUCH_RESPONSE);
+ }
+ }
+
+ public final void onBusEvent(UndockingTaskEvent undockingTaskEvent) {
+ int dockSide = mWindowManagerProxy.getDockSide();
+ if (dockSide != WindowManager.DOCKED_INVALID) {
+ startDragging(false /* animate */, false /* touching */);
+ SnapTarget target = dockSideTopLeft(dockSide)
+ ? mSnapAlgorithm.getDismissEndTarget()
+ : mSnapAlgorithm.getDismissStartTarget();
+
+ // Don't start immediately - give a little bit time to settle the drag resize change.
+ stopDragging(getCurrentPosition(), target, 336 /* duration */, 100 /* startDelay */,
+ Interpolators.TOUCH_RESPONSE);
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/WindowManagerProxy.java b/packages/SystemUI/src/com/android/systemui/stackdivider/WindowManagerProxy.java
index 24ab506..15bcaf8 100644
--- a/packages/SystemUI/src/com/android/systemui/stackdivider/WindowManagerProxy.java
+++ b/packages/SystemUI/src/com/android/systemui/stackdivider/WindowManagerProxy.java
@@ -97,7 +97,7 @@
@Override
public void run() {
try {
- ActivityManagerNative.getDefault().resizeStack(DOCKED_STACK_ID, null, true, false,
+ ActivityManagerNative.getDefault().resizeStack(DOCKED_STACK_ID, null, true, true,
false);
} catch (RemoteException e) {
Log.w(TAG, "Failed to resize stack: " + e);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/DismissView.java b/packages/SystemUI/src/com/android/systemui/statusbar/DismissView.java
index d9276bf..3067714 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/DismissView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/DismissView.java
@@ -17,14 +17,12 @@
package com.android.systemui.statusbar;
import android.content.Context;
-import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
import com.android.systemui.R;
public class DismissView extends StackScrollerDecorView {
- private boolean mDismissAllInProgress;
private DismissViewButton mDismissButton;
public DismissView(Context context, AttributeSet attrs) {
@@ -53,27 +51,7 @@
|| touchY > mContent.getY() + mContent.getHeight();
}
- public void showClearButton() {
- mDismissButton.showButton();
- }
-
- public void setDismissAllInProgress(boolean dismissAllInProgress) {
- if (dismissAllInProgress) {
- setClipBounds(null);
- }
- mDismissAllInProgress = dismissAllInProgress;
- }
-
- @Override
- public void setClipBounds(Rect clipBounds) {
- if (mDismissAllInProgress) {
- // we don't want any clipping to happen!
- return;
- }
- super.setClipBounds(clipBounds);
- }
-
public boolean isButtonVisible() {
- return mDismissButton.isButtonStatic();
+ return mDismissButton.getAlpha() != 0.0f;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/DismissViewButton.java b/packages/SystemUI/src/com/android/systemui/statusbar/DismissViewButton.java
index 46060f1..b608d67 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/DismissViewButton.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/DismissViewButton.java
@@ -17,22 +17,13 @@
package com.android.systemui.statusbar;
import android.content.Context;
-import android.graphics.Canvas;
import android.graphics.Rect;
-import android.graphics.drawable.AnimatedVectorDrawable;
-import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
-import android.view.View;
import android.view.ViewGroup;
-import android.widget.Button;
-import com.android.systemui.R;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
-public class DismissViewButton extends Button {
- private AnimatedVectorDrawable mAnimatedDismissDrawable;
- private final Drawable mStaticDismissDrawable;
- private Drawable mActiveDrawable;
+public class DismissViewButton extends AlphaOptimizedButton {
public DismissViewButton(Context context) {
this(context, null);
@@ -49,55 +40,6 @@
public DismissViewButton(Context context, AttributeSet attrs, int defStyleAttr,
int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
- mAnimatedDismissDrawable = (AnimatedVectorDrawable) getContext().getDrawable(
- R.drawable.dismiss_all_shape_animation).mutate();
- mAnimatedDismissDrawable.setCallback(this);
- mAnimatedDismissDrawable.setBounds(0,
- 0,
- mAnimatedDismissDrawable.getIntrinsicWidth(),
- mAnimatedDismissDrawable.getIntrinsicHeight());
- mStaticDismissDrawable = getContext().getDrawable(R.drawable.dismiss_all_shape);
- mStaticDismissDrawable.setBounds(0,
- 0,
- mStaticDismissDrawable.getIntrinsicWidth(),
- mStaticDismissDrawable.getIntrinsicHeight());
- mStaticDismissDrawable.setCallback(this);
- mActiveDrawable = mStaticDismissDrawable;
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- super.onDraw(canvas);
- canvas.save();
- int drawableHeight = mActiveDrawable.getBounds().height();
- boolean isRtl = (getLayoutDirection() == View.LAYOUT_DIRECTION_RTL);
- int dx = isRtl ? getWidth() / 2 + drawableHeight / 2 : getWidth() / 2 - drawableHeight / 2;
- canvas.translate(dx, getHeight() / 2.0f + drawableHeight /
- 2.0f);
- canvas.scale(isRtl ? -1.0f : 1.0f, -1.0f);
- mActiveDrawable.draw(canvas);
- canvas.restore();
- }
-
- @Override
- public boolean performClick() {
- if (!mAnimatedDismissDrawable.isRunning()) {
- mActiveDrawable = mAnimatedDismissDrawable;
- mAnimatedDismissDrawable.start();
- }
- return super.performClick();
- }
-
- @Override
- protected boolean verifyDrawable(Drawable who) {
- return super.verifyDrawable(who)
- || who == mAnimatedDismissDrawable
- || who == mStaticDismissDrawable;
- }
-
- @Override
- public boolean hasOverlappingRendering() {
- return false;
}
/**
@@ -118,16 +60,4 @@
outRect.top += translationY;
outRect.bottom += translationY;
}
-
- public void showButton() {
- mActiveDrawable = mStaticDismissDrawable;
- invalidate();
- }
-
- /**
- * @return Whether the button is currently static and not being animated.
- */
- public boolean isButtonStatic() {
- return mActiveDrawable == mStaticDismissDrawable;
- }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationHeaderUtil.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationHeaderUtil.java
index 98a37f9..c70aad2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationHeaderUtil.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationHeaderUtil.java
@@ -74,8 +74,7 @@
}
private void applyToChild(View view, boolean shouldApply, int originalColor) {
- if (view.getVisibility() == View.VISIBLE
- && originalColor != NotificationHeaderView.NO_COLOR) {
+ if (originalColor != NotificationHeaderView.NO_COLOR) {
ImageView imageView = (ImageView) view;
imageView.getDrawable().mutate();
if (shouldApply) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/HybridNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/HybridNotificationView.java
index ec73935..81144d5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/HybridNotificationView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/HybridNotificationView.java
@@ -107,12 +107,13 @@
public void bind(CharSequence title, CharSequence text) {
mTitleView.setText(title);
- if (TextUtils.isEmpty(title)) {
- mTitleView.setVisibility(GONE);
- }
- mTextView.setText(text);
+ mTitleView.setVisibility(TextUtils.isEmpty(title) ? GONE : VISIBLE);
if (TextUtils.isEmpty(text)) {
mTextView.setVisibility(GONE);
+ mTextView.setText(null);
+ } else {
+ mTextView.setVisibility(VISIBLE);
+ mTextView.setText(text.toString());
}
requestLayout();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/HybridNotificationViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/HybridNotificationViewManager.java
index 285d53f..28bb66f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/HybridNotificationViewManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/HybridNotificationViewManager.java
@@ -18,8 +18,13 @@
import android.app.Notification;
import android.content.Context;
+import android.text.BidiFormatter;
+import android.text.Spannable;
+import android.text.SpannableStringBuilder;
import android.text.TextUtils;
+import android.text.style.TextAppearanceSpan;
import android.view.LayoutInflater;
+import android.view.View;
import android.view.ViewGroup;
import com.android.systemui.R;
@@ -34,12 +39,12 @@
private final Context mContext;
private ViewGroup mParent;
- private String mConcadenationString;
+ private String mDivider;
public HybridNotificationViewManager(Context ctx, ViewGroup parent) {
mContext = ctx;
mParent = parent;
- mConcadenationString = mContext.getString(R.string.group_summary_concadenation);
+ mDivider = " • ";
}
private HybridNotificationView inflateHybridView() {
@@ -83,7 +88,7 @@
if (reusableView == null) {
reusableView = inflateHybridView();
}
- CharSequence summary = null;
+ SpannableStringBuilder summary = new SpannableStringBuilder();
int childCount = group.size();
for (int i = startIndex; i < childCount; i++) {
ExpandableNotificationRow child = group.get(i);
@@ -92,15 +97,18 @@
if (titleText == null) {
continue;
}
- if (TextUtils.isEmpty(summary)) {
- summary = titleText;
- } else if (reusableView.isLayoutRtl()) {
- summary = titleText + mConcadenationString + summary;
- } else {
- summary = summary + mConcadenationString + titleText;
+ if (!TextUtils.isEmpty(summary)) {
+ summary.append(mDivider,
+ new TextAppearanceSpan(mContext, R.style.
+ TextAppearance_Material_Notification_HybridNotificationDivider),
+ Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
+ summary.append(BidiFormatter.getInstance().unicodeWrap(titleText));
}
- reusableView.bind(summary);
+ // We want to force the same orientation as the layout RTL mode
+ BidiFormatter formater = BidiFormatter.getInstance(
+ reusableView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL);
+ reusableView.bind(formater.unicodeWrap(summary));
return reusableView;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationBigTextTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationBigTextTemplateViewWrapper.java
new file mode 100644
index 0000000..487a7a0
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationBigTextTemplateViewWrapper.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.systemui.statusbar.notification;
+
+import android.content.Context;
+import android.service.notification.StatusBarNotification;
+import android.view.View;
+
+import com.android.internal.widget.ImageFloatingTextView;
+import com.android.systemui.statusbar.TransformableView;
+
+/**
+ * Wraps a notification containing a big text template
+ */
+public class NotificationBigTextTemplateViewWrapper extends NotificationTemplateViewWrapper {
+
+ private ImageFloatingTextView mBigtext;
+
+ protected NotificationBigTextTemplateViewWrapper(Context ctx, View view) {
+ super(ctx, view);
+ }
+
+ private void resolveViews(StatusBarNotification notification) {
+ mBigtext = (ImageFloatingTextView) mView.findViewById(com.android.internal.R.id.big_text);
+ }
+
+ @Override
+ public void notifyContentUpdated(StatusBarNotification notification) {
+ // Reinspect the notification. Before the super call, because the super call also updates
+ // the transformation types and we need to have our values set by then.
+ resolveViews(notification);
+ super.notifyContentUpdated(notification);
+ }
+
+ @Override
+ protected void updateTransformedTypes() {
+ // This also clears the existing types
+ super.updateTransformedTypes();
+ if (mBigtext != null) {
+ mTransformationHelper.addTransformedView(TransformableView.TRANSFORMING_VIEW_TEXT,
+ mBigtext);
+ }
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java
index b060245..0c21f0b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java
@@ -55,11 +55,12 @@
}
TransformState otherState = notification.getCurrentState(
TRANSFORMING_VIEW_TITLE);
- CrossFadeHelper.fadeOut(mText, endRunnable);
+ final View text = ownState.getTransformedView();
+ CrossFadeHelper.fadeOut(text, endRunnable);
if (otherState != null) {
int[] otherStablePosition = otherState.getLaidOutLocationOnScreen();
int[] ownPosition = ownState.getLaidOutLocationOnScreen();
- mText.animate()
+ text.animate()
.translationY((otherStablePosition[1]
+ otherState.getTransformedView().getHeight()
- ownPosition[1]) * 0.33f)
@@ -72,11 +73,11 @@
if (endRunnable != null) {
endRunnable.run();
}
- TransformState.setClippingDeactivated(mText,
+ TransformState.setClippingDeactivated(text,
false);
}
});
- TransformState.setClippingDeactivated(mText, true);
+ TransformState.setClippingDeactivated(text, true);
otherState.recycle();
}
return true;
@@ -90,17 +91,18 @@
}
TransformState otherState = notification.getCurrentState(
TRANSFORMING_VIEW_TITLE);
- boolean isVisible = mText.getVisibility() == View.VISIBLE;
- CrossFadeHelper.fadeIn(mText);
+ final View text = ownState.getTransformedView();
+ boolean isVisible = text.getVisibility() == View.VISIBLE;
+ CrossFadeHelper.fadeIn(text);
if (otherState != null) {
int[] otherStablePosition = otherState.getLaidOutLocationOnScreen();
int[] ownStablePosition = ownState.getLaidOutLocationOnScreen();
if (!isVisible) {
- mText.setTranslationY((otherStablePosition[1]
+ text.setTranslationY((otherStablePosition[1]
+ otherState.getTransformedView().getHeight()
- ownStablePosition[1]) * 0.33f);
}
- mText.animate()
+ text.animate()
.translationY(0)
.setDuration(
StackStateAnimator.ANIMATION_DURATION_STANDARD)
@@ -108,11 +110,11 @@
.withEndAction(new Runnable() {
@Override
public void run() {
- TransformState.setClippingDeactivated(mText,
+ TransformState.setClippingDeactivated(text,
false);
}
});
- TransformState.setClippingDeactivated(mText, true);
+ TransformState.setClippingDeactivated(text, true);
otherState.recycle();
}
return true;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java
index f50b976..a2b4c5d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java
@@ -37,6 +37,8 @@
if (v.getId() == com.android.internal.R.id.status_bar_latest_event_content) {
if ("bigPicture".equals(v.getTag())) {
return new NotificationBigPictureTemplateViewWrapper(ctx, v);
+ } else if ("bigText".equals(v.getTag())) {
+ return new NotificationBigTextTemplateViewWrapper(ctx, v);
}
return new NotificationTemplateViewWrapper(ctx, v);
} else if (v instanceof NotificationHeaderView) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java
index a2586f1..bb03454 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java
@@ -304,8 +304,7 @@
public void onTuningChanged(String key, String newValue) {
switch (key) {
case KEY_DOCK_WINDOW_GESTURE:
- mDockWindowEnabled = (newValue == null) ||
- (Integer.parseInt(newValue) != 0);
+ mDockWindowEnabled = newValue != null && (Integer.parseInt(newValue) != 0);
break;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
index 3130eb9..d3681b7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
@@ -154,10 +154,14 @@
}
mBarState = newState;
if (mBarState == StatusBarState.KEYGUARD) {
- for (NotificationGroup group : mGroupMap.values()) {
- if (group.expanded) {
- setGroupExpanded(group, false);
- }
+ collapseAllGroups();
+ }
+ }
+
+ public void collapseAllGroups() {
+ for (NotificationGroup group : mGroupMap.values()) {
+ if (group.expanded) {
+ setGroupExpanded(group, false);
}
}
}
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 575eda7..f822bd5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -39,8 +39,6 @@
import android.view.ViewTreeObserver;
import android.view.WindowInsets;
import android.view.accessibility.AccessibilityEvent;
-import android.view.animation.Interpolator;
-import android.view.animation.PathInterpolator;
import android.widget.FrameLayout;
import android.widget.TextView;
@@ -212,10 +210,6 @@
}
};
- /** Interpolator to be used for animations that respond directly to a touch */
- private final Interpolator mTouchResponseInterpolator =
- new PathInterpolator(0.3f, 0f, 0.1f, 1f);
-
public NotificationPanelView(Context context, AttributeSet attrs) {
super(context, attrs);
setWillNotDraw(!DEBUG);
@@ -1447,7 +1441,7 @@
mScrollView.setBlockFlinging(true);
ValueAnimator animator = ValueAnimator.ofFloat(mQsExpansionHeight, target);
if (isClick) {
- animator.setInterpolator(mTouchResponseInterpolator);
+ animator.setInterpolator(Interpolators.TOUCH_RESPONSE);
animator.setDuration(368);
} else {
mFlingAnimationUtils.apply(animator, mQsExpansionHeight, target, vel);
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 07dc4fd..4dee51d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -118,7 +118,10 @@
import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.qs.QSPanel;
import com.android.systemui.recents.ScreenPinningRequest;
+import com.android.systemui.recents.events.EventBus;
+import com.android.systemui.recents.events.activity.UndockingTaskEvent;
import com.android.systemui.stackdivider.Divider;
+import com.android.systemui.stackdivider.WindowManagerProxy;
import com.android.systemui.statusbar.ActivatableNotificationView;
import com.android.systemui.statusbar.BackDropView;
import com.android.systemui.statusbar.BaseStatusBar;
@@ -1112,26 +1115,25 @@
@Override
public boolean onLongClick(View v) {
if (mRecents != null) {
- Point realSize = new Point();
- mContext.getSystemService(DisplayManager.class).getDisplay(Display.DEFAULT_DISPLAY)
- .getRealSize(realSize);
- Rect initialBounds;
-
- // Hack level over 9000: Make it one pixel smaller so activity manager doesn't
- // dismiss it immediately again. Remove once b/26777526 is fixed.
- if (mContext.getResources().getConfiguration().orientation
- == Configuration.ORIENTATION_LANDSCAPE) {
- initialBounds = new Rect(0, 0, realSize.x - 1, realSize.y);
+ int dockSide = WindowManagerProxy.getInstance().getDockSide();
+ if (dockSide == WindowManager.DOCKED_INVALID) {
+ Point realSize = new Point();
+ mContext.getSystemService(DisplayManager.class).getDisplay(Display.DEFAULT_DISPLAY)
+ .getRealSize(realSize);
+ Rect initialBounds= new Rect(0, 0, realSize.x, realSize.y);
+ boolean docked = mRecents.dockTopTask(NavigationBarGestureHelper.DRAG_MODE_NONE,
+ ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT,
+ initialBounds);
+ if (docked) {
+ MetricsLogger.action(mContext, MetricsEvent.ACTION_WINDOW_DOCK_LONGPRESS);
+ return true;
+ }
} else {
- initialBounds = new Rect(0, 0, realSize.x, realSize.y - 1);
- }
- boolean docked = mRecents.dockTopTask(NavigationBarGestureHelper.DRAG_MODE_NONE,
- ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT,
- initialBounds);
- if (docked) {
- MetricsLogger.action(mContext, MetricsEvent.ACTION_WINDOW_DOCK_LONGPRESS);
+ EventBus.getDefault().send(new UndockingTaskEvent());
+ MetricsLogger.action(mContext, MetricsEvent.ACTION_WINDOW_UNDOCK_LONGPRESS);
return true;
}
+
}
return false;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java
index 409dac1..5cfcd89 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.stack;
import android.content.Context;
+import android.content.res.Configuration;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
@@ -58,6 +59,7 @@
private HybridNotificationView mGroupOverflowContainer;
private ViewState mGroupOverFlowState;
private int mRealHeight;
+ private int mLayoutDirection = LAYOUT_DIRECTION_UNDEFINED;
public NotificationChildrenContainer(Context context) {
this(context, null);
@@ -209,6 +211,16 @@
}
}
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ int layoutDirection = getLayoutDirection();
+ if (layoutDirection != mLayoutDirection) {
+ updateGroupOverflow();
+ mLayoutDirection = layoutDirection;
+ }
+ }
+
private View inflateDivider() {
return LayoutInflater.from(mContext).inflate(
R.layout.notification_children_divider, this, false);
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 d6276b8..cc0e67d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -1648,6 +1648,9 @@
bottom = (int) (lastView.getTranslationY() + lastView.getActualHeight());
bottom = Math.min(bottom, getHeight());
}
+ } else if (mPhoneStatusBar.getBarState() == StatusBarState.KEYGUARD) {
+ top = mTopPadding;
+ bottom = top;
}
mBackgroundBounds.top = Math.max(0, top);
mBackgroundBounds.bottom = Math.min(getHeight(), bottom);
@@ -2093,12 +2096,6 @@
generateAddAnimation(child, false /* fromMoreCard */);
updateAnimationState(child);
updateChronometerForChild(child);
- if (canChildBeDismissed(child)) {
- // Make sure the dismissButton is visible and not in the animated state.
- // We need to do this to avoid a race where a clearable notification is added after the
- // dismiss animation is finished
- mDismissView.showClearButton();
- }
}
private void updateHideSensitiveForChild(View child) {
@@ -2608,6 +2605,9 @@
mIsExpanded = isExpanded;
mStackScrollAlgorithm.setIsExpanded(isExpanded);
if (changed) {
+ if (!mIsExpanded) {
+ mGroupManager.collapseAllGroups();
+ }
updateNotificationAnimationStates();
updateChronometers();
}
@@ -2977,7 +2977,6 @@
mDismissView.performVisibilityAnimation(false, dimissHideFinishRunnable);
} else {
dimissHideFinishRunnable.run();
- mDismissView.showClearButton();
}
}
}
@@ -2985,7 +2984,6 @@
public void setDismissAllInProgress(boolean dismissAllInProgress) {
mDismissAllInProgress = dismissAllInProgress;
- mDismissView.setDismissAllInProgress(dismissAllInProgress);
mAmbientState.setDismissAllInProgress(dismissAllInProgress);
if (dismissAllInProgress) {
disableClipOptimization();
diff --git a/proto/src/metrics_constants.proto b/proto/src/metrics_constants.proto
index 0e67a24..e1dd87f 100644
--- a/proto/src/metrics_constants.proto
+++ b/proto/src/metrics_constants.proto
@@ -348,5 +348,9 @@
// OS: 6.1
// GMS: 7.8.99
USER_CREDENTIALS = 285;
+
+ // Logged when the user undocks a previously docked window by long pressing recents while in
+ // docked mode.
+ ACTION_WINDOW_UNDOCK_LONGPRESS = 286;
}
}
diff --git a/services/core/java/com/android/server/DeviceIdleController.java b/services/core/java/com/android/server/DeviceIdleController.java
index 9bd79c9..423ef84 100644
--- a/services/core/java/com/android/server/DeviceIdleController.java
+++ b/services/core/java/com/android/server/DeviceIdleController.java
@@ -1649,6 +1649,7 @@
// Whoops, there is an upcoming alarm. We don't actually want to go idle.
if (mState != STATE_ACTIVE) {
becomeActiveLocked("alarm", Process.myUid());
+ becomeInactiveIfAppropriateLocked();
}
return;
}
diff --git a/services/core/java/com/android/server/am/ActivityManagerDebugConfig.java b/services/core/java/com/android/server/am/ActivityManagerDebugConfig.java
index 4f0d4d9..bef6f0a 100644
--- a/services/core/java/com/android/server/am/ActivityManagerDebugConfig.java
+++ b/services/core/java/com/android/server/am/ActivityManagerDebugConfig.java
@@ -62,7 +62,7 @@
static final boolean DEBUG_LRU = DEBUG_ALL || false;
static final boolean DEBUG_MU = DEBUG_ALL || false;
static final boolean DEBUG_OOM_ADJ = DEBUG_ALL || false;
- static final boolean DEBUG_PAUSE = DEBUG_ALL || false;
+ static final boolean DEBUG_PAUSE = DEBUG_ALL || true;
static final boolean DEBUG_POWER = DEBUG_ALL || false;
static final boolean DEBUG_POWER_QUICK = DEBUG_POWER || false;
static final boolean DEBUG_PROCESS_OBSERVERS = DEBUG_ALL || false;
@@ -77,7 +77,7 @@
static final boolean DEBUG_SERVICE = DEBUG_ALL || false;
static final boolean DEBUG_SERVICE_EXECUTING = DEBUG_ALL || false;
static final boolean DEBUG_STACK = DEBUG_ALL || false;
- static final boolean DEBUG_STATES = DEBUG_ALL_ACTIVITIES || false;
+ static final boolean DEBUG_STATES = DEBUG_ALL_ACTIVITIES || true;
static final boolean DEBUG_SWITCH = DEBUG_ALL || false;
static final boolean DEBUG_TASKS = DEBUG_ALL || false;
static final boolean DEBUG_THUMBNAILS = DEBUG_ALL || false;
@@ -85,7 +85,7 @@
static final boolean DEBUG_UID_OBSERVERS = DEBUG_ALL || false;
static final boolean DEBUG_URI_PERMISSION = DEBUG_ALL || false;
static final boolean DEBUG_USER_LEAVING = DEBUG_ALL || false;
- static final boolean DEBUG_VISIBILITY = DEBUG_ALL || false;
+ static final boolean DEBUG_VISIBILITY = DEBUG_ALL || true;
static final boolean DEBUG_VISIBLE_BEHIND = DEBUG_ALL_ACTIVITIES || false;
static final boolean DEBUG_USAGE_STATS = DEBUG_ALL || false;
static final boolean DEBUG_PERMISSIONS_REVIEW = DEBUG_ALL || false;
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 54c4ced..9874cc4 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -252,10 +252,12 @@
import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
import static android.app.ActivityManager.RESIZE_MODE_PRESERVE_WINDOW;
import static android.app.ActivityManager.StackId.DOCKED_STACK_ID;
+import static android.app.ActivityManager.StackId.FIRST_STATIC_STACK_ID;
import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.StackId.HOME_STACK_ID;
import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
+import static android.app.ActivityManager.StackId.LAST_STATIC_STACK_ID;
import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
import static android.content.pm.PackageManager.FEATURE_FREEFORM_WINDOW_MANAGEMENT;
import static android.content.pm.PackageManager.FEATURE_PICTURE_IN_PICTURE;
@@ -5303,28 +5305,42 @@
@Override
public void killAllBackgroundProcesses() {
+ killAllBackgroundProcesses(-1);
+ }
+
+ /**
+ * Kills all background processes with targetSdkVersion below the specified
+ * target SDK version.
+ *
+ * @param targetSdkVersion the target SDK version below which to kill
+ * processes, or {@code -1} to kill all processes
+ */
+ private void killAllBackgroundProcesses(int targetSdkVersion) {
if (checkCallingPermission(android.Manifest.permission.KILL_BACKGROUND_PROCESSES)
!= PackageManager.PERMISSION_GRANTED) {
- String msg = "Permission Denial: killAllBackgroundProcesses() from pid="
- + Binder.getCallingPid()
- + ", uid=" + Binder.getCallingUid()
+ final String msg = "Permission Denial: killAllBackgroundProcesses() from pid="
+ + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid()
+ " requires " + android.Manifest.permission.KILL_BACKGROUND_PROCESSES;
Slog.w(TAG, msg);
throw new SecurityException(msg);
}
- long callingId = Binder.clearCallingIdentity();
+ final long callingId = Binder.clearCallingIdentity();
try {
- synchronized(this) {
- ArrayList<ProcessRecord> procs = new ArrayList<ProcessRecord>();
+ synchronized (this) {
+ final ArrayList<ProcessRecord> procs = new ArrayList<>();
final int NP = mProcessNames.getMap().size();
- for (int ip=0; ip<NP; ip++) {
- SparseArray<ProcessRecord> apps = mProcessNames.getMap().valueAt(ip);
+ for (int ip = 0; ip < NP; ip++) {
+ final SparseArray<ProcessRecord> apps = mProcessNames.getMap().valueAt(ip);
final int NA = apps.size();
- for (int ia=0; ia<NA; ia++) {
- ProcessRecord app = apps.valueAt(ia);
+ for (int ia = 0; ia < NA; ia++) {
+ final ProcessRecord app = apps.valueAt(ia);
if (app.persistent) {
- // we don't kill persistent processes
+ // We don't kill persistent processes.
+ continue;
+ }
+ if (targetSdkVersion > 0
+ && app.info.targetSdkVersion >= targetSdkVersion) {
continue;
}
if (app.removed) {
@@ -5336,11 +5352,13 @@
}
}
- int N = procs.size();
- for (int i=0; i<N; i++) {
+ final int N = procs.size();
+ for (int i = 0; i < N; i++) {
removeProcessLocked(procs.get(i), false, true, "kill all background");
}
+
mAllowLowerMemLevel = true;
+
updateOomAdjLocked();
doLowMemReportIfNeededLocked(null);
}
@@ -17616,6 +17634,22 @@
final long origId = Binder.clearCallingIdentity();
final ActivityStack stack = mStackSupervisor.getStack(fromStackId);
if (stack != null) {
+ if (fromStackId == DOCKED_STACK_ID) {
+
+ // We are moving all tasks from the docked stack to the fullscreen stack, which
+ // is dismissing the docked stack, so resize all other stacks to fullscreen here
+ // already so we don't end up with resize trashing.
+ for (int i = FIRST_STATIC_STACK_ID; i <= LAST_STATIC_STACK_ID; i++) {
+ if (StackId.isResizeableByDockedStack(i)) {
+ ActivityStack otherStack = mStackSupervisor.getStack(i);
+ if (otherStack != null) {
+ mStackSupervisor.resizeStackLocked(i,
+ null, null, null, PRESERVE_WINDOWS,
+ true /* allowResizeInDockedMode */);
+ }
+ }
+ }
+ }
final ArrayList<TaskRecord> tasks = stack.getAllTasks();
final int size = tasks.size();
if (onTop) {
@@ -17805,6 +17839,11 @@
mHandler.sendMessage(msg);
}
+ final boolean isDensityChange = (changes & ActivityInfo.CONFIG_DENSITY) != 0;
+ if (isDensityChange) {
+ killAllBackgroundProcesses(Build.VERSION_CODES.N);
+ }
+
for (int i=mLruProcesses.size()-1; i>=0; i--) {
ProcessRecord app = mLruProcesses.get(i);
try {
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 5a0c1c1..c352fc8 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -2168,7 +2168,9 @@
if (DEBUG_SWITCH) Slog.v(TAG_SWITCH, "Resume running: " + next);
// This activity is now becoming visible.
- mWindowManager.setAppVisibility(next.appToken, true);
+ if (!next.visible) {
+ mWindowManager.setAppVisibility(next.appToken, true);
+ }
// schedule launch ticks to collect information about slow apps.
next.startLaunchTickingLocked();
@@ -4304,6 +4306,12 @@
oldTaskOverride = record.task.extractOverrideConfig(record.configuration);
}
+ // Conversely, do the same when going the other direction.
+ if (Configuration.EMPTY.equals(taskConfig)
+ && !Configuration.EMPTY.equals(oldTaskOverride)) {
+ taskConfig = record.task.extractOverrideConfig(record.configuration);
+ }
+
// Determine what has changed. May be nothing, if this is a config
// that has come back from the app after going idle. In that case
// we just want to leave the official config object now in the
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index 95bc95a..a07ed2e 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -1889,12 +1889,6 @@
private void resizeStackUncheckedLocked(ActivityStack stack, Rect bounds, Rect tempTaskBounds,
Rect tempTaskInsetBounds) {
- if (bounds != null && mWindowManager.isFullscreenBounds(stack.mStackId, bounds)) {
- // The bounds passed in corresponds to the fullscreen bounds which we normally
- // represent with null. Go ahead and set it to null so that all tasks configuration
- // can have the right fullscreen state.
- bounds = null;
- }
bounds = TaskRecord.validateBounds(bounds);
mTmpBounds.clear();
@@ -1913,7 +1907,8 @@
task.updateOverrideConfiguration(tempRect2);
} else {
task.updateOverrideConfiguration(
- tempTaskBounds != null ? tempTaskBounds : bounds);
+ tempTaskBounds != null ? tempTaskBounds : bounds,
+ tempTaskInsetBounds != null ? tempTaskInsetBounds : bounds);
}
}
@@ -2213,9 +2208,9 @@
// Temporarily disable resizeablility of task we are moving. We don't want it to be resized
// if a docked stack is created below which will lead to the stack we are moving from and
// its resizeable tasks being resized.
- task.mResizeMode = RESIZE_MODE_UNRESIZEABLE;
+ task.mTemporarilyUnresizable = true;
final ActivityStack stack = getStack(stackId, CREATE_IF_NEEDED, toTop);
- task.mResizeMode = resizeMode;
+ task.mTemporarilyUnresizable = false;
mWindowManager.moveTaskToStack(task.taskId, stack.mStackId, toTop);
stack.addTask(task, toTop, reason);
diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java
index a7d948c..703dfca 100644
--- a/services/core/java/com/android/server/am/TaskRecord.java
+++ b/services/core/java/com/android/server/am/TaskRecord.java
@@ -16,37 +16,7 @@
package com.android.server.am;
-import static android.app.ActivityManager.StackId.DOCKED_STACK_ID;
-import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID;
-import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID;
-import static android.app.ActivityManager.StackId.HOME_STACK_ID;
-import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
-import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
-import static android.content.Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
-import static android.content.Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS;
-import static android.content.pm.ActivityInfo.RESIZE_MODE_CROP_WINDOWS;
-import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE;
-import static android.content.pm.ActivityInfo.RESIZE_MODE_UNRESIZEABLE;
-import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_ALWAYS;
-import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_DEFAULT;
-import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_IF_WHITELISTED;
-import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_NEVER;
-import static android.content.pm.ApplicationInfo.PRIVATE_FLAG_PRIVILEGED;
-import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_ADD_REMOVE;
-import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_LOCKTASK;
-import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_RECENTS;
-import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_TASKS;
-import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_ADD_REMOVE;
-import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_LOCKTASK;
-import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_RECENTS;
-import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_TASKS;
-import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM;
-import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME;
-import static com.android.server.am.ActivityManagerService.LOCK_SCREEN_SHOWN;
-import static com.android.server.am.ActivityRecord.APPLICATION_ACTIVITY_TYPE;
-import static com.android.server.am.ActivityRecord.HOME_ACTIVITY_TYPE;
-import static com.android.server.am.ActivityRecord.RECENTS_ACTIVITY_TYPE;
-
+import android.annotation.Nullable;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.StackId;
@@ -55,6 +25,7 @@
import android.app.ActivityManager.TaskThumbnailInfo;
import android.app.ActivityOptions;
import android.app.AppGlobals;
+import android.app.IActivityManager;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.ActivityInfo;
@@ -86,6 +57,37 @@
import java.util.ArrayList;
import java.util.Objects;
+import static android.app.ActivityManager.StackId.DOCKED_STACK_ID;
+import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID;
+import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID;
+import static android.app.ActivityManager.StackId.HOME_STACK_ID;
+import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
+import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
+import static android.content.Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
+import static android.content.Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS;
+import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_ALWAYS;
+import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_DEFAULT;
+import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_IF_WHITELISTED;
+import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_NEVER;
+import static android.content.pm.ActivityInfo.RESIZE_MODE_CROP_WINDOWS;
+import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE;
+import static android.content.pm.ActivityInfo.RESIZE_MODE_UNRESIZEABLE;
+import static android.content.pm.ApplicationInfo.PRIVATE_FLAG_PRIVILEGED;
+import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_ADD_REMOVE;
+import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_LOCKTASK;
+import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_RECENTS;
+import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_TASKS;
+import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_ADD_REMOVE;
+import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_LOCKTASK;
+import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_RECENTS;
+import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_TASKS;
+import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM;
+import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME;
+import static com.android.server.am.ActivityManagerService.LOCK_SCREEN_SHOWN;
+import static com.android.server.am.ActivityRecord.APPLICATION_ACTIVITY_TYPE;
+import static com.android.server.am.ActivityRecord.HOME_ACTIVITY_TYPE;
+import static com.android.server.am.ActivityRecord.RECENTS_ACTIVITY_TYPE;
+
final class TaskRecord {
private static final String TAG = TAG_WITH_CLASS_NAME ? "TaskRecord" : TAG_AM;
private static final String TAG_ADD_REMOVE = TAG + POSTFIX_ADD_REMOVE;
@@ -160,6 +162,8 @@
int mResizeMode; // The resize mode of this task and its activities.
// Based on the {@link ActivityInfo#resizeMode} of the root activity.
+ boolean mTemporarilyUnresizable; // Separate flag from mResizeMode used to suppress resize
+ // changes on a temporary basis.
int mLockTaskMode; // Which tasklock mode to launch this task in. One of
// ActivityManager.LOCK_TASK_LAUNCH_MODE_*
private boolean mPrivileged; // The root activity application of this task holds
@@ -238,6 +242,9 @@
// Bounds of the Task. null for fullscreen tasks.
Rect mBounds = null;
+ private final Rect mTmpRect = new Rect();
+ private final Rect mTmpRect2 = new Rect();
+
// Last non-fullscreen bounds the task was launched in or resized to.
// The information is persisted and used to determine the appropriate stack to launch the
// task into on restore.
@@ -934,7 +941,7 @@
boolean isResizeable() {
return !isHomeTask() && (mService.mForceResizableActivities
- || ActivityInfo.isResizeableMode(mResizeMode));
+ || ActivityInfo.isResizeableMode(mResizeMode)) && !mTemporarilyUnresizable;
}
boolean inCropWindowsResizeMode() {
@@ -1291,9 +1298,22 @@
/**
* Update task's override configuration based on the bounds.
+ * @param bounds The bounds of the task.
* @return Update configuration or null if there is no change.
*/
Configuration updateOverrideConfiguration(Rect bounds) {
+ return updateOverrideConfiguration(bounds, null /* insetBounds */);
+ }
+
+ /**
+ * Update task's override configuration based on the bounds.
+ * @param bounds The bounds of the task.
+ * @param insetBounds The bounds used to calculate the system insets, which is used here to
+ * subtract the navigation bar/status bar size from the screen size reported
+ * to the application. See {@link IActivityManager#resizeDockedStack}.
+ * @return Update configuration or null if there is no change.
+ */
+ Configuration updateOverrideConfiguration(Rect bounds, @Nullable Rect insetBounds) {
if (Objects.equals(mBounds, bounds)) {
return null;
}
@@ -1316,7 +1336,12 @@
if (stack == null || StackId.persistTaskBounds(stack.mStackId)) {
mLastNonFullscreenBounds = mBounds;
}
- mOverrideConfig = calculateOverrideConfig(mBounds);
+
+ // Stable insets need to be subtracted because we also subtract it in the fullscreen
+ // configuration.
+ mTmpRect.set(bounds);
+ subtractStableInsets(mTmpRect, insetBounds != null ? insetBounds : mTmpRect);
+ mOverrideConfig = calculateOverrideConfig(mTmpRect);
}
if (mFullscreen != oldFullscreen) {
@@ -1326,6 +1351,16 @@
return !mOverrideConfig.equals(oldConfig) ? mOverrideConfig : null;
}
+ private void subtractStableInsets(Rect inOutBounds, Rect inInsetBounds) {
+ mTmpRect2.set(inInsetBounds);
+ mService.mWindowManager.subtractStableInsets(mTmpRect2);
+ int leftInset = mTmpRect2.left - inInsetBounds.left;
+ int topInset = mTmpRect2.top - inInsetBounds.top;
+ int rightInset = inInsetBounds.right - mTmpRect2.right;
+ int bottomInset = inInsetBounds.bottom - mTmpRect2.bottom;
+ inOutBounds.inset(leftInset, topInset, rightInset, bottomInset);
+ }
+
Configuration calculateOverrideConfig(Rect bounds) {
final Configuration serviceConfig = mService.mConfiguration;
final Configuration config = new Configuration(Configuration.EMPTY);
@@ -1341,8 +1376,9 @@
? Configuration.ORIENTATION_PORTRAIT
: Configuration.ORIENTATION_LANDSCAPE;
final int sl = Configuration.resetScreenLayout(serviceConfig.screenLayout);
- config.screenLayout = Configuration.reduceScreenLayout(
- sl, config.screenWidthDp, config.screenHeightDp);
+ int longSize = Math.max(config.screenWidthDp, config.screenHeightDp);
+ int shortSize = Math.min(config.screenWidthDp, config.screenHeightDp);
+ config.screenLayout = Configuration.reduceScreenLayout(sl, longSize, shortSize);
return config;
}
diff --git a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
index 544f255..7f8099e 100644
--- a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
+++ b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -192,7 +192,7 @@
* enforcement.
*/
public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
- private static final String TAG = "NetworkPolicy";
+ static final String TAG = "NetworkPolicy";
private static final boolean LOGD = false;
private static final boolean LOGV = false;
@@ -1689,6 +1689,7 @@
}
writePolicy = true;
}
+ updateRulesForGlobalChangeLocked(true);
// Remove associated UID policies
int[] uids = new int[0];
@@ -1862,8 +1863,8 @@
Slog.i(TAG, "adding uid " + uid + " to restrict background whitelist");
synchronized (mRulesLock) {
mRestrictBackgroundWhitelistUids.append(uid, true);
+ updateRulesForGlobalChangeLocked(true);
writePolicyLocked();
- // TODO: call other update methods like updateNetworkRulesLocked?
}
mHandler.obtainMessage(MSG_RESTRICT_BACKGROUND_WHITELIST_CHANGED, uid, 0).sendToTarget();
}
@@ -1878,9 +1879,10 @@
mHandler.obtainMessage(MSG_RESTRICT_BACKGROUND_WHITELIST_CHANGED, uid, 0).sendToTarget();
}
- private void removeRestrictBackgroundWhitelistedUidLocked(int uid, boolean writePolicy) {
+ private void removeRestrictBackgroundWhitelistedUidLocked(int uid, boolean updateNow) {
mRestrictBackgroundWhitelistUids.delete(uid);
- if (writePolicy) {
+ if (updateNow) {
+ updateRulesForGlobalChangeLocked(true);
writePolicyLocked();
}
}
diff --git a/services/core/java/com/android/server/net/NetworkPolicyManagerShellCommand.java b/services/core/java/com/android/server/net/NetworkPolicyManagerShellCommand.java
index 5830b0e..281c3d0 100644
--- a/services/core/java/com/android/server/net/NetworkPolicyManagerShellCommand.java
+++ b/services/core/java/com/android/server/net/NetworkPolicyManagerShellCommand.java
@@ -16,19 +16,24 @@
package com.android.server.net;
-import java.io.PrintWriter;
+import static com.android.server.net.NetworkPolicyManagerService.TAG;
-import android.content.Intent;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+
import android.net.INetworkPolicyManager;
+import android.net.NetworkPolicy;
import android.os.Binder;
import android.os.RemoteException;
import android.os.ShellCommand;
+import android.util.Log;
-public class NetworkPolicyManagerShellCommand extends ShellCommand {
+class NetworkPolicyManagerShellCommand extends ShellCommand {
final INetworkPolicyManager mInterface;
- NetworkPolicyManagerShellCommand(NetworkPolicyManagerService service) {
+ NetworkPolicyManagerShellCommand(INetworkPolicyManager service) {
mInterface = service;
}
@@ -66,16 +71,24 @@
pw.println(" help");
pw.println(" Print this help text.");
pw.println("");
- pw.println(" get restrict-background");
- pw.println(" Gets the global restrict background usage status.");
- pw.println(" set restrict-background BOOLEAN");
- pw.println(" Sets the global restrict background usage status.");
- pw.println(" list restrict-background-whitelist");
- pw.println(" Prints UID that are whitelisted for restrict background usage.");
pw.println(" add restrict-background-whitelist UID");
pw.println(" Adds a UID to the whitelist for restrict background usage.");
+ pw.println(" get metered-network ID");
+ pw.println(" Checks whether the given non-mobile network is metered or not.");
+ pw.println(" get restrict-background");
+ pw.println(" Gets the global restrict background usage status.");
+ pw.println(" list metered-networks [BOOLEAN]");
+ pw.println(" Lists all non-mobile networks and whether they are metered or not.");
+ pw.println(" If a boolean argument is passed, filters just the metered (or unmetered)");
+ pw.println(" networks.");
+ pw.println(" list restrict-background-whitelist");
+ pw.println(" Lists UIDs that are whitelisted for restrict background usage.");
pw.println(" remove restrict-background-whitelist UID");
pw.println(" Removes a UID from the whitelist for restrict background usage.");
+ pw.println(" set metered-network ID BOOLEAN");
+ pw.println(" Toggles whether the given non-mobile network is metered.");
+ pw.println(" set restrict-background BOOLEAN");
+ pw.println(" Sets the global restrict background usage status.");
}
private int runGet() throws RemoteException {
@@ -86,6 +99,8 @@
return -1;
}
switch(type) {
+ case "metered-network":
+ return getNonMobileMeteredNetwork();
case "restrict-background":
return getRestrictBackground();
}
@@ -101,6 +116,8 @@
return -1;
}
switch(type) {
+ case "metered-network":
+ return setNonMobileMeteredNetwork();
case "restrict-background":
return setRestrictBackground();
}
@@ -116,6 +133,8 @@
return -1;
}
switch(type) {
+ case "metered-networks":
+ return listNonMobileMeteredNetworks();
case "restrict-background-whitelist":
return runListRestrictBackgroundWhitelist();
}
@@ -196,7 +215,12 @@
if (uid < 0) {
return uid;
}
- mInterface.addRestrictBackgroundWhitelistedUid(uid);
+ final long token = Binder.clearCallingIdentity();
+ try {
+ mInterface.addRestrictBackgroundWhitelistedUid(uid);
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
return 0;
}
@@ -205,10 +229,95 @@
if (uid < 0) {
return uid;
}
- mInterface.removeRestrictBackgroundWhitelistedUid(uid);
+ final long token = Binder.clearCallingIdentity();
+ try {
+ mInterface.removeRestrictBackgroundWhitelistedUid(uid);
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
return 0;
}
+ private int listNonMobileMeteredNetworks() throws RemoteException {
+ final PrintWriter pw = getOutPrintWriter();
+ final String arg = getNextArg();
+ final Boolean filter = arg == null ? null : Boolean.valueOf(arg);
+ for (NetworkPolicy policy : getNonMobilePolicies()) {
+ if (filter != null && filter.booleanValue() != policy.metered) {
+ continue;
+ }
+ pw.print(getNetworkId(policy));
+ pw.print(';');
+ pw.println(policy.metered);
+ }
+ return 0;
+ }
+
+ private int getNonMobileMeteredNetwork() throws RemoteException {
+ final PrintWriter pw = getOutPrintWriter();
+ final String id = getNextArg();
+ if (id == null) {
+ pw.println("Error: didn't specify ID");
+ return -1;
+ }
+ final List<NetworkPolicy> policies = getNonMobilePolicies();
+ for (NetworkPolicy policy: policies) {
+ if (id.equals(getNetworkId(policy))) {
+ pw.println(policy.metered);
+ return 0;
+ }
+ }
+ return 0;
+ }
+
+ private int setNonMobileMeteredNetwork() throws RemoteException {
+ final PrintWriter pw = getOutPrintWriter();
+ final String id = getNextArg();
+ if (id == null) {
+ pw.println("Error: didn't specify ID");
+ return -1;
+ }
+ final String arg = getNextArg();
+ if (arg == null) {
+ pw.println("Error: didn't specify BOOLEAN");
+ return -1;
+ }
+ final boolean metered = Boolean.valueOf(arg);
+ final NetworkPolicy[] policies = mInterface.getNetworkPolicies(null);
+ boolean changed = false;
+ for (NetworkPolicy policy : policies) {
+ if (policy.template.isMatchRuleMobile() || policy.metered == metered) {
+ continue;
+ }
+ final String networkId = getNetworkId(policy);
+ if (id.equals(networkId)) {
+ Log.i(TAG, "Changing " + networkId + " metered status to " + metered);
+ policy.metered = metered;
+ changed = true;
+ }
+ }
+ if (changed) {
+ mInterface.setNetworkPolicies(policies);
+ }
+ return 0;
+ }
+
+ private List<NetworkPolicy> getNonMobilePolicies() throws RemoteException {
+ final NetworkPolicy[] policies = mInterface.getNetworkPolicies(null);
+ final List<NetworkPolicy> nonMobilePolicies = new ArrayList<NetworkPolicy>(policies.length);
+ for (NetworkPolicy policy: policies) {
+ if (!policy.template.isMatchRuleMobile()) {
+ nonMobilePolicies.add(policy);
+ }
+ }
+ return nonMobilePolicies;
+ }
+
+ private String getNetworkId(NetworkPolicy policy) {
+ // ids are typically enclosed on double quotes (")
+ return policy.template.getNetworkId().replaceAll("^\"|\"$", "");
+ }
+
private int getNextBooleanArg() {
final PrintWriter pw = getOutPrintWriter();
final String arg = getNextArg();
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 43b82e9..a92cc31 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -6877,7 +6877,12 @@
final boolean dockedStackVisible = mWindowManagerInternal.isStackVisible(DOCKED_STACK_ID);
final boolean freeformStackVisible =
mWindowManagerInternal.isStackVisible(FREEFORM_WORKSPACE_STACK_ID);
- final boolean forceShowSystemBars = dockedStackVisible || freeformStackVisible;
+ final boolean resizing = mWindowManagerInternal.isDockedDividerResizing();
+
+ // We need to force system bars when the docked stack is visible, when the freeform stack
+ // is visible but also when we are resizing for the transitions when docked stack
+ // visibility changes.
+ final boolean forceShowSystemBars = dockedStackVisible || freeformStackVisible || resizing;
final boolean forceOpaqueSystemBars = forceShowSystemBars && !mForceStatusBarFromKeyguard;
// apply translucent bar vis flags
diff --git a/services/core/java/com/android/server/wm/BoundsAnimationController.java b/services/core/java/com/android/server/wm/BoundsAnimationController.java
index 5f97478..1bfdcce 100644
--- a/services/core/java/com/android/server/wm/BoundsAnimationController.java
+++ b/services/core/java/com/android/server/wm/BoundsAnimationController.java
@@ -22,6 +22,7 @@
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.graphics.Rect;
import android.util.ArrayMap;
@@ -50,13 +51,15 @@
private final Rect mFrom;
private final Rect mTo;
private final Rect mTmpRect;
+ private final boolean mMoveToFullScreen;
- BoundsAnimator(AnimateBoundsUser target, Rect from, Rect to) {
+ BoundsAnimator(AnimateBoundsUser target, Rect from, Rect to, boolean moveToFullScreen) {
super();
mTarget = target;
mFrom = from;
mTo = to;
mTmpRect = new Rect();
+ mMoveToFullScreen = moveToFullScreen;
addUpdateListener(this);
addListener(this);
}
@@ -88,6 +91,9 @@
@Override
public void onAnimationEnd(Animator animation) {
finishAnimation();
+ if (mMoveToFullScreen) {
+ mTarget.moveToFullscreen();
+ }
}
@Override
@@ -125,14 +131,25 @@
* necessary cleanup.
*/
void finishBoundsAnimation();
+
+ void moveToFullscreen();
+
+ void getFullScreenBounds(Rect bounds);
}
- void animateBounds(AnimateBoundsUser target, Rect from, Rect to) {
+ void animateBounds(final AnimateBoundsUser target, Rect from, Rect to) {
+ boolean moveToFullscreen = false;
+ if (to == null) {
+ to = new Rect();
+ target.getFullScreenBounds(to);
+ moveToFullscreen = true;
+ }
+
final BoundsAnimator existing = mRunningAnimations.get(target);
if (existing != null) {
existing.cancel();
}
- BoundsAnimator animator = new BoundsAnimator(target, from, to);
+ BoundsAnimator animator = new BoundsAnimator(target, from, to, moveToFullscreen);
mRunningAnimations.put(target, animator);
animator.setFloatValues(0f, 1f);
animator.setDuration(DEFAULT_APP_TRANSITION_DURATION);
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index be1b85c..a06d3fc 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -289,11 +289,9 @@
if (displayContent != null) {
displayContent.getLogicalDisplayRect(mTmpRect);
rotation = displayContent.getDisplayInfo().rotation;
- if (bounds == null) {
+ mFullscreen = bounds == null;
+ if (mFullscreen) {
bounds = mTmpRect;
- mFullscreen = true;
- } else {
- mFullscreen = mTmpRect.equals(bounds);
}
}
diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java
index 4659131..5b93979 100644
--- a/services/core/java/com/android/server/wm/TaskStack.java
+++ b/services/core/java/com/android/server/wm/TaskStack.java
@@ -255,11 +255,9 @@
if (mDisplayContent != null) {
mDisplayContent.getLogicalDisplayRect(mTmpRect);
rotation = mDisplayContent.getDisplayInfo().rotation;
- if (bounds == null) {
+ mFullscreen = bounds == null;
+ if (mFullscreen) {
bounds = mTmpRect;
- mFullscreen = true;
- } else {
- mFullscreen = mTmpRect.equals(bounds);
}
}
@@ -865,14 +863,14 @@
final int orientation = mService.mCurConfiguration.orientation;
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
// Portrait mode, docked either at the top or the bottom.
- if (bounds.top - mTmpRect.top < mTmpRect.bottom - bounds.bottom) {
+ if (bounds.top - mTmpRect.top <= mTmpRect.bottom - bounds.bottom) {
return DOCKED_TOP;
} else {
return DOCKED_BOTTOM;
}
} else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
// Landscape mode, docked either on the left or on the right.
- if (bounds.left - mTmpRect.left < mTmpRect.right - bounds.right) {
+ if (bounds.left - mTmpRect.left <= mTmpRect.right - bounds.right) {
return DOCKED_LEFT;
} else {
return DOCKED_RIGHT;
@@ -927,4 +925,18 @@
}
}
}
+
+ @Override
+ public void moveToFullscreen() {
+ try {
+ mService.mActivityManager.moveTasksToFullscreenStack(mStackId, true);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void getFullScreenBounds(Rect bounds) {
+ getDisplayContent().getContentRect(bounds);
+ }
}
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index a26430e..f9a3790 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -464,6 +464,8 @@
EmulatorDisplayOverlay mEmulatorDisplayOverlay;
final float[] mTmpFloats = new float[9];
+ final Rect mTmpRect = new Rect();
+ final Rect mTmpRect2 = new Rect();
boolean mDisplayReady;
boolean mSafeMode;
@@ -4845,17 +4847,6 @@
}
}
- /** Returns true if the input bounds corresponds to the fullscreen bounds the stack is on. */
- public boolean isFullscreenBounds(int stackId, Rect bounds) {
- synchronized (mWindowMap) {
- final TaskStack stack = mStackIdToStack.get(stackId);
- if (stack == null || bounds == null) {
- return true;
- }
- return stack.isFullscreenBounds(bounds);
- }
- }
-
/**
* Re-sizes a stack and its containing tasks.
* @param stackId Id of stack to resize.
@@ -10394,8 +10385,28 @@
@Override
public void getStableInsets(Rect outInsets) throws RemoteException {
synchronized (mWindowMap) {
+ getStableInsetsLocked(outInsets);
+ }
+ }
+
+ private void getStableInsetsLocked(Rect outInsets) {
+ final DisplayInfo di = getDefaultDisplayInfoLocked();
+ mPolicy.getStableInsetsLw(di.rotation, di.logicalWidth, di.logicalHeight, outInsets);
+ }
+
+ /**
+ * Intersects the specified {@code inOutBounds} with the display frame that excludes the stable
+ * inset areas.
+ *
+ * @param inOutBounds The inOutBounds to subtract the stable inset areas from.
+ */
+ public void subtractStableInsets(Rect inOutBounds) {
+ synchronized (mWindowMap) {
+ getStableInsetsLocked(mTmpRect2);
final DisplayInfo di = getDefaultDisplayInfoLocked();
- mPolicy.getStableInsetsLw(di.rotation, di.logicalWidth, di.logicalHeight, outInsets);
+ mTmpRect.set(0, 0, di.logicalWidth, di.logicalHeight);
+ mTmpRect.inset(mTmpRect2);
+ inOutBounds.intersect(mTmpRect);
}
}
@@ -10599,5 +10610,12 @@
return WindowManagerService.this.isStackVisibleLocked(stackId);
}
}
+
+ @Override
+ public boolean isDockedDividerResizing() {
+ synchronized (mWindowMap) {
+ return getDefaultDisplayContentLocked().getDockedDividerController().isResizing();
+ }
+ }
}
}
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 465c7e0..1f7b810 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -16,8 +16,6 @@
package com.android.server.wm;
-import com.android.server.input.InputWindowHandle;
-
import android.app.ActivityManager;
import android.app.AppOpsManager;
import android.content.Context;
@@ -53,6 +51,8 @@
import android.view.WindowManager;
import android.view.WindowManagerPolicy;
+import com.android.server.input.InputWindowHandle;
+
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -75,8 +75,8 @@
import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW;
import static android.view.WindowManager.LayoutParams.MATCH_PARENT;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_COMPATIBLE_WINDOW;
-import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
+import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_WILL_NOT_REPLACE_ON_RELAUNCH;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST;
@@ -2133,7 +2133,8 @@
// background.
return (mDisplayContent.mDividerControllerLocked.isResizing()
|| mAppToken != null && !mAppToken.mFrozenBounds.isEmpty()) &&
- !task.inFreeformWorkspace() && !task.isFullscreen();
+ !task.inFreeformWorkspace();
+
}
void setDragResizing() {
@@ -2327,6 +2328,12 @@
if (mDrawLock != null) {
pw.print(prefix); pw.println("mDrawLock=" + mDrawLock);
}
+ if (isDragResizing()) {
+ pw.print(prefix); pw.println("isDragResizing=" + isDragResizing());
+ }
+ if (computeDragResizing()) {
+ pw.print(prefix); pw.println("computeDragResizing=" + computeDragResizing());
+ }
}
String makeInputChannelName() {
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 908d2f0..f296d68 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -4132,7 +4132,7 @@
public void choosePrivateKeyAlias(final int uid, final Uri uri, final String alias,
final IBinder response) {
// Caller UID needs to be trusted, so we restrict this method to SYSTEM_UID callers.
- if (!UserHandle.isSameApp(mInjector.binderGetCallingUid(), Process.SYSTEM_UID)) {
+ if (!isCallerWithSystemUid()) {
return;
}
@@ -5860,8 +5860,7 @@
}
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS, null);
- if (hasUserSetupCompleted(userHandle)
- && !UserHandle.isSameApp(callingUid, Process.SYSTEM_UID)) {
+ if (hasUserSetupCompleted(userHandle) && !isCallerWithSystemUid()) {
throw new IllegalStateException("Cannot set the profile owner on a user which is "
+ "already set-up");
}
@@ -5921,8 +5920,7 @@
private void enforceManageUsers() {
final int callingUid = mInjector.binderGetCallingUid();
- if (!(UserHandle.isSameApp(callingUid, Process.SYSTEM_UID)
- || callingUid == Process.ROOT_UID)) {
+ if (!(isCallerWithSystemUid() || callingUid == Process.ROOT_UID)) {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_USERS, null);
}
}
@@ -5945,8 +5943,7 @@
if (userHandle == UserHandle.getUserId(callingUid)) {
return;
}
- if (!(UserHandle.isSameApp(callingUid, Process.SYSTEM_UID)
- || callingUid == Process.ROOT_UID)) {
+ if (!(isCallerWithSystemUid() || callingUid == Process.ROOT_UID)) {
mContext.enforceCallingOrSelfPermission(permission,
"Must be system or have " + permission + " permission");
}
@@ -5964,6 +5961,10 @@
}
}
+ private boolean isCallerWithSystemUid() {
+ return UserHandle.isSameApp(mInjector.binderGetCallingUid(), Process.SYSTEM_UID);
+ }
+
private int getProfileParentId(int userHandle) {
final long ident = mInjector.binderClearCallingIdentity();
try {
@@ -6248,7 +6249,7 @@
@Override
public ComponentName getRestrictionsProvider(int userHandle) {
synchronized (this) {
- if (!UserHandle.isSameApp(mInjector.binderGetCallingUid(), Process.SYSTEM_UID)) {
+ if (!isCallerWithSystemUid()) {
throw new SecurityException("Only the system can query the permission provider");
}
DevicePolicyData userData = getUserData(userHandle);
@@ -6321,8 +6322,7 @@
* permittedList or are a system app.
*/
private boolean checkPackagesInPermittedListOrSystem(List<String> enabledPackages,
- List<String> permittedList) {
- int userIdToCheck = UserHandle.getCallingUserId();
+ List<String> permittedList, int userIdToCheck) {
long id = mInjector.binderClearCallingIdentity();
try {
// If we have an enabled packages list for a managed profile the packages
@@ -6389,7 +6389,8 @@
for (AccessibilityServiceInfo service : enabledServices) {
enabledPackages.add(service.getResolveInfo().serviceInfo.packageName);
}
- if (!checkPackagesInPermittedListOrSystem(enabledPackages, packageList)) {
+ if (!checkPackagesInPermittedListOrSystem(enabledPackages, packageList,
+ userId)) {
Slog.e(LOG_TAG, "Cannot set permitted accessibility services, "
+ "because it contains already enabled accesibility services.");
return false;
@@ -6481,6 +6482,28 @@
}
}
+ @Override
+ public boolean isAccessibilityServicePermittedByAdmin(ComponentName who, String packageName,
+ int userHandle) {
+ if (!mHasFeature) {
+ return true;
+ }
+ Preconditions.checkNotNull(who, "ComponentName is null");
+ Preconditions.checkStringNotEmpty(packageName, "packageName is null");
+ if (!isCallerWithSystemUid()){
+ throw new SecurityException(
+ "Only the system can query if an accessibility service is disabled by admin");
+ }
+ synchronized (this) {
+ ActiveAdmin admin = getActiveAdminUncheckedLocked(who, userHandle);
+ if (admin.permittedAccessiblityServices == null) {
+ return true;
+ }
+ return checkPackagesInPermittedListOrSystem(Arrays.asList(packageName),
+ admin.permittedAccessiblityServices, userHandle);
+ }
+ }
+
private boolean checkCallerIsCurrentUserOrProfile() {
int callingUserId = UserHandle.getCallingUserId();
long token = mInjector.binderClearCallingIdentity();
@@ -6536,7 +6559,8 @@
for (InputMethodInfo ime : enabledImes) {
enabledPackages.add(ime.getPackageName());
}
- if (!checkPackagesInPermittedListOrSystem(enabledPackages, packageList)) {
+ if (!checkPackagesInPermittedListOrSystem(enabledPackages, packageList,
+ mInjector.binderGetCallingUserHandle().getIdentifier())) {
Slog.e(LOG_TAG, "Cannot set permitted input methods, "
+ "because it contains already enabled input method.");
return false;
@@ -6629,6 +6653,28 @@
}
@Override
+ public boolean isInputMethodPermittedByAdmin(ComponentName who, String packageName,
+ int userHandle) {
+ if (!mHasFeature) {
+ return true;
+ }
+ Preconditions.checkNotNull(who, "ComponentName is null");
+ Preconditions.checkStringNotEmpty(packageName, "packageName is null");
+ if (!isCallerWithSystemUid()) {
+ throw new SecurityException(
+ "Only the system can query if an input method is disabled by admin");
+ }
+ synchronized (this) {
+ ActiveAdmin admin = getActiveAdminUncheckedLocked(who, userHandle);
+ if (admin.permittedInputMethods == null) {
+ return true;
+ }
+ return checkPackagesInPermittedListOrSystem(Arrays.asList(packageName),
+ admin.permittedInputMethods, userHandle);
+ }
+ }
+
+ @Override
public UserHandle createUser(ComponentName who, String name) {
Preconditions.checkNotNull(who, "ComponentName is null");
synchronized (this) {
@@ -7425,7 +7471,7 @@
@Override
public void notifyLockTaskModeChanged(boolean isEnabled, String pkg, int userHandle) {
- if (!UserHandle.isSameApp(mInjector.binderGetCallingUid(), Process.SYSTEM_UID)) {
+ if (!isCallerWithSystemUid()) {
throw new SecurityException("notifyLockTaskModeChanged can only be called by system");
}
synchronized (this) {
@@ -8180,7 +8226,7 @@
return null;
}
Preconditions.checkNotNull(who, "ComponentName is null");
- if (!UserHandle.isSameApp(mInjector.binderGetCallingUid(), Process.SYSTEM_UID)) {
+ if (!isCallerWithSystemUid()) {
throw new SecurityException("Only the system can query support message for user");
}
synchronized (this) {
@@ -8198,7 +8244,7 @@
return null;
}
Preconditions.checkNotNull(who, "ComponentName is null");
- if (!UserHandle.isSameApp(mInjector.binderGetCallingUid(), Process.SYSTEM_UID)) {
+ if (!isCallerWithSystemUid()) {
throw new SecurityException("Only the system can query support message for user");
}
synchronized (this) {
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index b64db57..0cf9328 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -496,6 +496,7 @@
boolean disableNonCoreServices = SystemProperties.getBoolean("config.disable_noncore", false);
boolean disableNetwork = SystemProperties.getBoolean("config.disable_network", false);
boolean disableNetworkTime = SystemProperties.getBoolean("config.disable_networktime", false);
+ boolean disableRtt = SystemProperties.getBoolean("config.disable_rtt", false);
boolean isEmulator = SystemProperties.get("ro.kernel.qemu").equals("1");
try {
@@ -788,7 +789,9 @@
mSystemServiceManager.startService(
"com.android.server.wifi.WifiScanningService");
- mSystemServiceManager.startService("com.android.server.wifi.RttService");
+ if (!disableRtt) {
+ mSystemServiceManager.startService("com.android.server.wifi.RttService");
+ }
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_ETHERNET) ||
mPackageManager.hasSystemFeature(PackageManager.FEATURE_USB_HOST)) {
@@ -1088,7 +1091,9 @@
mSystemServiceManager.startService(TrustManagerService.class);
- mSystemServiceManager.startService(FingerprintService.class);
+ if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) {
+ mSystemServiceManager.startService(FingerprintService.class);
+ }
traceBeginAndSlog("StartBackgroundDexOptService");
try {
diff --git a/telephony/java/android/telephony/SubscriptionInfo.java b/telephony/java/android/telephony/SubscriptionInfo.java
index d1d6e0d..6229ed9 100644
--- a/telephony/java/android/telephony/SubscriptionInfo.java
+++ b/telephony/java/android/telephony/SubscriptionInfo.java
@@ -25,6 +25,7 @@
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.graphics.Typeface;
+import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.DisplayMetrics;
@@ -338,7 +339,7 @@
public static String givePrintableIccid(String iccId) {
String iccIdToPrint = null;
if (iccId != null) {
- if (iccId.length() > 9) {
+ if (iccId.length() > 9 && !Build.IS_DEBUGGABLE) {
iccIdToPrint = iccId.substring(0, 9) + "XXXXXXXXXXX";
} else {
iccIdToPrint = iccId;
diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml
index b028ce6..de7b9c2 100644
--- a/tests/HwAccelerationTest/AndroidManifest.xml
+++ b/tests/HwAccelerationTest/AndroidManifest.xml
@@ -356,6 +356,15 @@
</activity>
<activity
+ android:name="MovingSurfaceViewActivity"
+ android:label="SurfaceView/Animated Movement">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="com.android.test.hwui.TEST" />
+ </intent-filter>
+ </activity>
+
+ <activity
android:name="GLTextureViewActivity"
android:label="TextureView/OpenGL">
<intent-filter>
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/MovingSurfaceViewActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/MovingSurfaceViewActivity.java
new file mode 100644
index 0000000..cd15ef1
--- /dev/null
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/MovingSurfaceViewActivity.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.test.hwui;
+
+import android.animation.ObjectAnimator;
+import android.app.Activity;
+import android.content.Context;
+import android.graphics.Canvas;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.SurfaceHolder;
+import android.view.SurfaceHolder.Callback;
+import android.view.SurfaceView;
+import android.view.View;
+import android.view.animation.LinearInterpolator;
+import android.widget.FrameLayout;
+
+public class MovingSurfaceViewActivity extends Activity implements Callback {
+ static final String TAG = "MovingSurfaceView";
+ SurfaceView mSurfaceView;
+ ObjectAnimator mAnimator;
+
+ class MySurfaceView extends SurfaceView {
+ boolean mSlowToggled;
+
+ public MySurfaceView(Context context) {
+ super(context);
+ setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ mSlowToggled = !mSlowToggled;
+ Log.d(TAG, "SLOW MODE: " + mSlowToggled);
+ invalidate();
+ }
+ });
+ setWillNotDraw(false);
+ }
+
+ @Override
+ public void draw(Canvas canvas) {
+ super.draw(canvas);
+ if (mSlowToggled) {
+ try {
+ Thread.sleep(16);
+ } catch (InterruptedException e) {}
+ }
+ }
+
+ public void setMyTranslationY(float ty) {
+ setTranslationY(ty);
+ if (mSlowToggled) {
+ invalidate();
+ }
+ }
+
+ public float getMyTranslationY() {
+ return getTranslationY();
+ }
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ FrameLayout content = new FrameLayout(this);
+
+ mSurfaceView = new MySurfaceView(this);
+ mSurfaceView.getHolder().addCallback(this);
+
+ final float density = getResources().getDisplayMetrics().density;
+ int size = (int) (200 * density);
+
+ content.addView(mSurfaceView, new FrameLayout.LayoutParams(
+ size, size, Gravity.CENTER));
+ mAnimator = ObjectAnimator.ofFloat(mSurfaceView, "myTranslationY",
+ 0, size);
+ mAnimator.setRepeatMode(ObjectAnimator.REVERSE);
+ mAnimator.setRepeatCount(ObjectAnimator.INFINITE);
+ mAnimator.setDuration(200);
+ mAnimator.setInterpolator(new LinearInterpolator());
+ setContentView(content);
+ }
+
+ @Override
+ public void surfaceCreated(SurfaceHolder holder) {
+ }
+
+ @Override
+ public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
+ Canvas canvas = holder.lockCanvas();
+ canvas.drawARGB(0xFF, 0x00, 0xFF, 0x00);
+ holder.unlockCanvasAndPost(canvas);
+ }
+
+ @Override
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ mAnimator.start();
+ }
+
+ @Override
+ protected void onPause() {
+ mAnimator.pause();
+ super.onPause();
+ }
+}