Merge "New INotificationListener interface."
diff --git a/api/current.txt b/api/current.txt
index 50438e6..bbf9302 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -1174,6 +1174,7 @@
field public static final int windowMinWidthMinor = 16843607; // 0x1010357
field public static final int windowNoDisplay = 16843294; // 0x101021e
field public static final int windowNoTitle = 16842838; // 0x1010056
+ field public static final int windowOverscan = 16843727; // 0x10103cf
field public static final int windowShowAnimation = 16842934; // 0x10100b6
field public static final int windowShowWallpaper = 16843410; // 0x1010292
field public static final int windowSoftInputMode = 16843307; // 0x101022b
@@ -1693,6 +1694,7 @@
field public static final int Theme_Black = 16973832; // 0x1030008
field public static final int Theme_Black_NoTitleBar = 16973833; // 0x1030009
field public static final int Theme_Black_NoTitleBar_Fullscreen = 16973834; // 0x103000a
+ field public static final int Theme_Black_NoTitleBar_Overscan = 16974303; // 0x10301df
field public static final int Theme_DeviceDefault = 16974120; // 0x1030128
field public static final int Theme_DeviceDefault_Dialog = 16974126; // 0x103012e
field public static final int Theme_DeviceDefault_DialogWhenLarge = 16974134; // 0x1030136
@@ -1711,9 +1713,11 @@
field public static final int Theme_DeviceDefault_Light_Dialog_NoActionBar_MinWidth = 16974133; // 0x1030135
field public static final int Theme_DeviceDefault_Light_NoActionBar = 16974124; // 0x103012c
field public static final int Theme_DeviceDefault_Light_NoActionBar_Fullscreen = 16974125; // 0x103012d
+ field public static final int Theme_DeviceDefault_Light_NoActionBar_Overscan = 16974307; // 0x10301e3
field public static final int Theme_DeviceDefault_Light_Panel = 16974139; // 0x103013b
field public static final int Theme_DeviceDefault_NoActionBar = 16974121; // 0x1030129
field public static final int Theme_DeviceDefault_NoActionBar_Fullscreen = 16974122; // 0x103012a
+ field public static final int Theme_DeviceDefault_NoActionBar_Overscan = 16974306; // 0x10301e2
field public static final int Theme_DeviceDefault_Panel = 16974138; // 0x103013a
field public static final int Theme_DeviceDefault_Wallpaper = 16974140; // 0x103013c
field public static final int Theme_DeviceDefault_Wallpaper_NoTitleBar = 16974141; // 0x103013d
@@ -1736,9 +1740,11 @@
field public static final int Theme_Holo_Light_Dialog_NoActionBar_MinWidth = 16973942; // 0x1030076
field public static final int Theme_Holo_Light_NoActionBar = 16974064; // 0x10300f0
field public static final int Theme_Holo_Light_NoActionBar_Fullscreen = 16974065; // 0x10300f1
+ field public static final int Theme_Holo_Light_NoActionBar_Overscan = 16974305; // 0x10301e1
field public static final int Theme_Holo_Light_Panel = 16973948; // 0x103007c
field public static final int Theme_Holo_NoActionBar = 16973932; // 0x103006c
field public static final int Theme_Holo_NoActionBar_Fullscreen = 16973933; // 0x103006d
+ field public static final int Theme_Holo_NoActionBar_Overscan = 16974304; // 0x10301e0
field public static final int Theme_Holo_Panel = 16973947; // 0x103007b
field public static final int Theme_Holo_Wallpaper = 16973949; // 0x103007d
field public static final int Theme_Holo_Wallpaper_NoTitleBar = 16973950; // 0x103007e
@@ -1746,12 +1752,14 @@
field public static final int Theme_Light = 16973836; // 0x103000c
field public static final int Theme_Light_NoTitleBar = 16973837; // 0x103000d
field public static final int Theme_Light_NoTitleBar_Fullscreen = 16973838; // 0x103000e
+ field public static final int Theme_Light_NoTitleBar_Overscan = 16974302; // 0x10301de
field public static final int Theme_Light_Panel = 16973914; // 0x103005a
field public static final int Theme_Light_WallpaperSettings = 16973922; // 0x1030062
field public static final int Theme_NoDisplay = 16973909; // 0x1030055
field public static final int Theme_NoTitleBar = 16973830; // 0x1030006
field public static final int Theme_NoTitleBar_Fullscreen = 16973831; // 0x1030007
field public static final int Theme_NoTitleBar_OverlayActionModes = 16973930; // 0x103006a
+ field public static final int Theme_NoTitleBar_Overscan = 16974301; // 0x10301dd
field public static final int Theme_Panel = 16973913; // 0x1030059
field public static final int Theme_Translucent = 16973839; // 0x103000f
field public static final int Theme_Translucent_NoTitleBar = 16973840; // 0x1030010
@@ -22961,9 +22969,14 @@
public class EasyEditSpan implements android.text.ParcelableSpan {
ctor public EasyEditSpan();
+ ctor public EasyEditSpan(android.app.PendingIntent);
+ ctor public EasyEditSpan(android.os.Parcel);
method public int describeContents();
method public int getSpanTypeId();
method public void writeToParcel(android.os.Parcel, int);
+ field public static final java.lang.String EXTRA_TEXT_CHANGED_TYPE = "android.text.style.EXTRA_TEXT_CHANGED_TYPE";
+ field public static final int TEXT_DELETED = 1; // 0x1
+ field public static final int TEXT_MODIFIED = 2; // 0x2
}
public class ForegroundColorSpan extends android.text.style.CharacterStyle implements android.text.ParcelableSpan android.text.style.UpdateAppearance {
@@ -26245,6 +26258,7 @@
field public static final int FLAG_IGNORE_CHEEK_PRESSES = 32768; // 0x8000
field public static final int FLAG_KEEP_SCREEN_ON = 128; // 0x80
field public static final int FLAG_LAYOUT_INSET_DECOR = 65536; // 0x10000
+ field public static final int FLAG_LAYOUT_IN_OVERSCAN = 33554432; // 0x2000000
field public static final int FLAG_LAYOUT_IN_SCREEN = 256; // 0x100
field public static final int FLAG_LAYOUT_NO_LIMITS = 512; // 0x200
field public static final int FLAG_NOT_FOCUSABLE = 8; // 0x8
diff --git a/cmds/am/Android.mk b/cmds/am/Android.mk
index 8b321b3..f8350dc 100644
--- a/cmds/am/Android.mk
+++ b/cmds/am/Android.mk
@@ -1,31 +1,15 @@
# Copyright 2008 The Android Open Source Project
#
LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
+include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_MODULE := am
include $(BUILD_JAVA_LIBRARY)
include $(CLEAR_VARS)
-ALL_PREBUILT += $(TARGET_OUT)/bin/am
-$(TARGET_OUT)/bin/am : $(LOCAL_PATH)/am | $(ACP)
- $(transform-prebuilt-to-target)
-
-NOTICE_FILE := NOTICE
-files_noticed := bin/am
-
-# Generate rules for a single file. The argument is the file path relative to
-# the installation root
-define make-notice-file
-
-$(TARGET_OUT_NOTICE_FILES)/src/$(1).txt: $(LOCAL_PATH)/$(NOTICE_FILE)
- @echo Notice file: $$< -- $$@
- @mkdir -p $$(dir $$@)
- @cat $$< >> $$@
-
-$(TARGET_OUT_NOTICE_FILES)/hash-timestamp: $(TARGET_OUT_NOTICE_FILES)/src/$(1).txt
-
-endef
-
-$(foreach file,$(files_noticed),$(eval $(call make-notice-file,$(file))))
+LOCAL_MODULE := am
+LOCAL_SRC_FILES := am
+LOCAL_MODULE_CLASS := EXECUTABLES
+LOCAL_MODULE_TAGS := optional
+include $(BUILD_PREBUILT)
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java
index 3c1fbfe..9fa7dbb 100644
--- a/cmds/am/src/com/android/commands/am/Am.java
+++ b/cmds/am/src/com/android/commands/am/Am.java
@@ -26,7 +26,6 @@
import android.app.Instrumentation;
import android.app.UiAutomationConnection;
import android.content.ComponentName;
-import android.content.Context;
import android.content.IIntentReceiver;
import android.content.Intent;
import android.content.pm.IPackageManager;
@@ -39,7 +38,6 @@
import android.os.SystemProperties;
import android.os.UserHandle;
import android.util.AndroidException;
-import android.view.Display;
import android.view.IWindowManager;
import java.io.BufferedReader;
@@ -134,10 +132,6 @@
runMonitor();
} else if (op.equals("screen-compat")) {
runScreenCompat();
- } else if (op.equals("display-size")) {
- runDisplaySize();
- } else if (op.equals("display-density")) {
- runDisplayDensity();
} else if (op.equals("to-uri")) {
runToUri(false);
} else if (op.equals("to-intent-uri")) {
@@ -1201,82 +1195,6 @@
} while (packageName != null);
}
- private void runDisplaySize() throws Exception {
- String size = nextArgRequired();
- int w, h;
- if ("reset".equals(size)) {
- w = h = -1;
- } else {
- int div = size.indexOf('x');
- if (div <= 0 || div >= (size.length()-1)) {
- System.err.println("Error: bad size " + size);
- return;
- }
- String wstr = size.substring(0, div);
- String hstr = size.substring(div+1);
- try {
- w = Integer.parseInt(wstr);
- h = Integer.parseInt(hstr);
- } catch (NumberFormatException e) {
- System.err.println("Error: bad number " + e);
- return;
- }
- }
-
- IWindowManager wm = IWindowManager.Stub.asInterface(ServiceManager.checkService(
- Context.WINDOW_SERVICE));
- if (wm == null) {
- System.err.println(NO_SYSTEM_ERROR_CODE);
- throw new AndroidException("Can't connect to window manager; is the system running?");
- }
-
- try {
- if (w >= 0 && h >= 0) {
- // TODO(multidisplay): For now Configuration only applies to main screen.
- wm.setForcedDisplaySize(Display.DEFAULT_DISPLAY, w, h);
- } else {
- wm.clearForcedDisplaySize(Display.DEFAULT_DISPLAY);
- }
- } catch (RemoteException e) {
- }
- }
-
- private void runDisplayDensity() throws Exception {
- String densityStr = nextArgRequired();
- int density;
- if ("reset".equals(densityStr)) {
- density = -1;
- } else {
- try {
- density = Integer.parseInt(densityStr);
- } catch (NumberFormatException e) {
- System.err.println("Error: bad number " + e);
- return;
- }
- if (density < 72) {
- System.err.println("Error: density must be >= 72");
- return;
- }
- }
-
- IWindowManager wm = IWindowManager.Stub.asInterface(ServiceManager.checkService(
- Context.WINDOW_SERVICE));
- if (wm == null) {
- System.err.println(NO_SYSTEM_ERROR_CODE);
- throw new AndroidException("Can't connect to window manager; is the system running?");
- }
-
- try {
- if (density > 0) {
- // TODO(multidisplay): For now Configuration only applies to main screen.
- wm.setForcedDisplayDensity(Display.DEFAULT_DISPLAY, density);
- } else {
- wm.clearForcedDisplayDensity(Display.DEFAULT_DISPLAY);
- }
- } catch (RemoteException e) {
- }
- }
-
private void runToUri(boolean intentScheme) throws Exception {
Intent intent = makeIntent(UserHandle.USER_CURRENT);
System.out.println(intent.toUri(intentScheme ? Intent.URI_INTENT_SCHEME : 0));
@@ -1454,8 +1372,6 @@
" am clear-debug-app\n" +
" am monitor [--gdb <port>]\n" +
" am screen-compat [on|off] <PACKAGE>\n" +
- " am display-size [reset|WxH]\n" +
- " am display-density [reset|DENSITY]\n" +
" am to-uri [INTENT]\n" +
" am to-intent-uri [INTENT]\n" +
" am switch-user <USER_ID>\n" +
@@ -1524,17 +1440,13 @@
"am clear-debug-app: clear the previously set-debug-app.\n" +
"\n" +
"am bug-report: request bug report generation; will launch UI\n" +
- " when done to select where it should be delivered." +
+ " when done to select where it should be delivered.\n" +
"\n" +
"am monitor: start monitoring for crashes or ANRs.\n" +
" --gdb: start gdbserv on the given port at crash/ANR\n" +
"\n" +
"am screen-compat: control screen compatibility mode of <PACKAGE>.\n" +
"\n" +
- "am display-size: override display size.\n" +
- "\n" +
- "am display-density: override display density.\n" +
- "\n" +
"am to-uri: print the given Intent specification as a URI.\n" +
"\n" +
"am to-intent-uri: print the given Intent specification as an intent: URI.\n" +
diff --git a/cmds/content/Android.mk b/cmds/content/Android.mk
index 88c46f2..9302e2f 100644
--- a/cmds/content/Android.mk
+++ b/cmds/content/Android.mk
@@ -1,33 +1,15 @@
# Copyright 2012 The Android Open Source Project
LOCAL_PATH:= $(call my-dir)
+
include $(CLEAR_VARS)
-
LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
LOCAL_MODULE := content
-
include $(BUILD_JAVA_LIBRARY)
include $(CLEAR_VARS)
-ALL_PREBUILT += $(TARGET_OUT)/bin/content
-$(TARGET_OUT)/bin/content : $(LOCAL_PATH)/content | $(ACP)
- $(transform-prebuilt-to-target)
-
-NOTICE_FILE := NOTICE
-files_noticed := bin/content
-
-# Generate rules for a single file. The argument is the file path relative to
-# the installation root
-define make-notice-file
-
-$(TARGET_OUT_NOTICE_FILES)/src/$(1).txt: $(LOCAL_PATH)/$(NOTICE_FILE)
- @echo Notice file: $$< -- $$@
- @mkdir -p $$(dir $$@)
- @cat $$< >> $$@
-
-$(TARGET_OUT_NOTICE_FILES)/hash-timestamp: $(TARGET_OUT_NOTICE_FILES)/src/$(1).txt
-
-endef
-
-$(foreach file,$(files_noticed),$(eval $(call make-notice-file,$(file))))
+LOCAL_MODULE := content
+LOCAL_SRC_FILES := content
+LOCAL_MODULE_CLASS := EXECUTABLES
+LOCAL_MODULE_TAGS := optional
+include $(BUILD_PREBUILT)
diff --git a/cmds/wm/Android.mk b/cmds/wm/Android.mk
new file mode 100644
index 0000000..3f3795f
--- /dev/null
+++ b/cmds/wm/Android.mk
@@ -0,0 +1,15 @@
+# Copyright 2013 The Android Open Source Project
+#
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+LOCAL_MODULE := wm
+include $(BUILD_JAVA_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := wm
+LOCAL_SRC_FILES := wm
+LOCAL_MODULE_CLASS := EXECUTABLES
+LOCAL_MODULE_TAGS := optional
+include $(BUILD_PREBUILT)
diff --git a/cmds/wm/MODULE_LICENSE_APACHE2 b/cmds/wm/MODULE_LICENSE_APACHE2
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/cmds/wm/MODULE_LICENSE_APACHE2
diff --git a/cmds/wm/NOTICE b/cmds/wm/NOTICE
new file mode 100644
index 0000000..c5b1efa
--- /dev/null
+++ b/cmds/wm/NOTICE
@@ -0,0 +1,190 @@
+
+ Copyright (c) 2005-2008, 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.
+
+ 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.
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
diff --git a/cmds/wm/src/com/android/commands/wm/Wm.java b/cmds/wm/src/com/android/commands/wm/Wm.java
new file mode 100644
index 0000000..f48764f
--- /dev/null
+++ b/cmds/wm/src/com/android/commands/wm/Wm.java
@@ -0,0 +1,241 @@
+/*
+**
+** Copyright 2013, 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.commands.wm;
+
+import android.content.Context;
+import android.graphics.Rect;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.util.AndroidException;
+import android.view.Display;
+import android.view.IWindowManager;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class Wm {
+
+ private IWindowManager mWm;
+ private String[] mArgs;
+ private int mNextArg;
+ private String mCurArgData;
+
+ // These are magic strings understood by the Eclipse plugin.
+ private static final String FATAL_ERROR_CODE = "Error type 1";
+ private static final String NO_SYSTEM_ERROR_CODE = "Error type 2";
+ private static final String NO_CLASS_ERROR_CODE = "Error type 3";
+
+ /**
+ * Command-line entry point.
+ *
+ * @param args The command-line arguments
+ */
+ public static void main(String[] args) {
+ try {
+ (new Wm()).run(args);
+ } catch (IllegalArgumentException e) {
+ showUsage();
+ System.err.println("Error: " + e.getMessage());
+ } catch (Exception e) {
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+ }
+
+ private void run(String[] args) throws Exception {
+ if (args.length < 1) {
+ showUsage();
+ return;
+ }
+
+ mWm = IWindowManager.Stub.asInterface(ServiceManager.checkService(
+ Context.WINDOW_SERVICE));
+ if (mWm == null) {
+ System.err.println(NO_SYSTEM_ERROR_CODE);
+ throw new AndroidException("Can't connect to window manager; is the system running?");
+ }
+
+ mArgs = args;
+ String op = args[0];
+ mNextArg = 1;
+
+ if (op.equals("size")) {
+ runDisplaySize();
+ } else if (op.equals("density")) {
+ runDisplayDensity();
+ } else if (op.equals("overscan")) {
+ runDisplayOverscan();
+ } else {
+ throw new IllegalArgumentException("Unknown command: " + op);
+ }
+ }
+
+ private void runDisplaySize() throws Exception {
+ String size = nextArgRequired();
+ int w, h;
+ if ("reset".equals(size)) {
+ w = h = -1;
+ } else {
+ int div = size.indexOf('x');
+ if (div <= 0 || div >= (size.length()-1)) {
+ System.err.println("Error: bad size " + size);
+ return;
+ }
+ String wstr = size.substring(0, div);
+ String hstr = size.substring(div+1);
+ try {
+ w = Integer.parseInt(wstr);
+ h = Integer.parseInt(hstr);
+ } catch (NumberFormatException e) {
+ System.err.println("Error: bad number " + e);
+ return;
+ }
+ }
+
+ try {
+ if (w >= 0 && h >= 0) {
+ // TODO(multidisplay): For now Configuration only applies to main screen.
+ mWm.setForcedDisplaySize(Display.DEFAULT_DISPLAY, w, h);
+ } else {
+ mWm.clearForcedDisplaySize(Display.DEFAULT_DISPLAY);
+ }
+ } catch (RemoteException e) {
+ }
+ }
+
+ private void runDisplayDensity() throws Exception {
+ String densityStr = nextArgRequired();
+ int density;
+ if ("reset".equals(densityStr)) {
+ density = -1;
+ } else {
+ try {
+ density = Integer.parseInt(densityStr);
+ } catch (NumberFormatException e) {
+ System.err.println("Error: bad number " + e);
+ return;
+ }
+ if (density < 72) {
+ System.err.println("Error: density must be >= 72");
+ return;
+ }
+ }
+
+ try {
+ if (density > 0) {
+ // TODO(multidisplay): For now Configuration only applies to main screen.
+ mWm.setForcedDisplayDensity(Display.DEFAULT_DISPLAY, density);
+ } else {
+ mWm.clearForcedDisplayDensity(Display.DEFAULT_DISPLAY);
+ }
+ } catch (RemoteException e) {
+ }
+ }
+
+ private void runDisplayOverscan() throws Exception {
+ String overscanStr = nextArgRequired();
+ Rect rect = new Rect();
+ int density;
+ if ("reset".equals(overscanStr)) {
+ rect.set(0, 0, 0, 0);
+ } else {
+ final Pattern FLATTENED_PATTERN = Pattern.compile(
+ "(-?\\d+),(-?\\d+),(-?\\d+),(-?\\d+)");
+ Matcher matcher = FLATTENED_PATTERN.matcher(overscanStr);
+ if (!matcher.matches()) {
+ System.err.println("Error: bad rectangle arg: " + overscanStr);
+ return;
+ }
+ rect.left = Integer.parseInt(matcher.group(1));
+ rect.top = Integer.parseInt(matcher.group(2));
+ rect.right = Integer.parseInt(matcher.group(3));
+ rect.bottom = Integer.parseInt(matcher.group(4));
+ }
+
+ try {
+ mWm.setOverscan(Display.DEFAULT_DISPLAY, rect.left, rect.top, rect.right, rect.bottom);
+ } catch (RemoteException e) {
+ }
+ }
+
+ private String nextOption() {
+ if (mCurArgData != null) {
+ String prev = mArgs[mNextArg - 1];
+ throw new IllegalArgumentException("No argument expected after \"" + prev + "\"");
+ }
+ if (mNextArg >= mArgs.length) {
+ return null;
+ }
+ String arg = mArgs[mNextArg];
+ if (!arg.startsWith("-")) {
+ return null;
+ }
+ mNextArg++;
+ if (arg.equals("--")) {
+ return null;
+ }
+ if (arg.length() > 1 && arg.charAt(1) != '-') {
+ if (arg.length() > 2) {
+ mCurArgData = arg.substring(2);
+ return arg.substring(0, 2);
+ } else {
+ mCurArgData = null;
+ return arg;
+ }
+ }
+ mCurArgData = null;
+ return arg;
+ }
+
+ private String nextArg() {
+ if (mCurArgData != null) {
+ String arg = mCurArgData;
+ mCurArgData = null;
+ return arg;
+ } else if (mNextArg < mArgs.length) {
+ return mArgs[mNextArg++];
+ } else {
+ return null;
+ }
+ }
+
+ private String nextArgRequired() {
+ String arg = nextArg();
+ if (arg == null) {
+ String prev = mArgs[mNextArg - 1];
+ throw new IllegalArgumentException("Argument expected after \"" + prev + "\"");
+ }
+ return arg;
+ }
+
+ private static void showUsage() {
+ System.err.println(
+ "usage: wm [subcommand] [options]\n" +
+ " wm size [reset|WxH]\n" +
+ " wm density [reset|DENSITY]\n" +
+ " wm overscan [reset|LEFT,TOP,RIGHT,BOTTOM]\n" +
+ "\n" +
+ "wm size: override display size.\n" +
+ "\n" +
+ "wm density: override display density.\n" +
+ "\n" +
+ "wm overscan: set overscan area for display.\n"
+ );
+ }
+}
diff --git a/cmds/wm/wm b/cmds/wm/wm
new file mode 100755
index 0000000..f7a5bc7
--- /dev/null
+++ b/cmds/wm/wm
@@ -0,0 +1,6 @@
+# Script to start "wm" on the device, which has a very rudimentary
+# shell.
+#
+base=/system
+export CLASSPATH=$base/framework/wm.jar
+exec app_process $base/bin com.android.commands.wm.Wm "$@"
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index a40fe75..734d435 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -460,7 +460,8 @@
registerService(STORAGE_SERVICE, new ServiceFetcher() {
public Object createService(ContextImpl ctx) {
try {
- return new StorageManager(ctx.mMainThread.getHandler().getLooper());
+ return new StorageManager(
+ ctx.getContentResolver(), ctx.mMainThread.getHandler().getLooper());
} catch (RemoteException rex) {
Log.e(TAG, "Failed to create StorageManager", rex);
return null;
diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java
index 862a95c..f5e728d 100644
--- a/core/java/android/os/storage/StorageManager.java
+++ b/core/java/android/os/storage/StorageManager.java
@@ -16,7 +16,9 @@
package android.os.storage;
-import android.app.NotificationManager;
+import static android.net.TrafficStats.MB_IN_BYTES;
+
+import android.content.ContentResolver;
import android.content.Context;
import android.os.Environment;
import android.os.Handler;
@@ -25,6 +27,7 @@
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.ServiceManager;
+import android.provider.Settings;
import android.util.Log;
import android.util.SparseArray;
@@ -54,20 +57,20 @@
* {@link android.content.Context#getSystemService(java.lang.String)} with an
* argument of {@link android.content.Context#STORAGE_SERVICE}.
*/
-
-public class StorageManager
-{
+public class StorageManager {
private static final String TAG = "StorageManager";
+ private final ContentResolver mResolver;
+
/*
* Our internal MountService binder reference
*/
- final private IMountService mMountService;
+ private final IMountService mMountService;
/*
* The looper target for callbacks
*/
- Looper mTgtLooper;
+ private final Looper mTgtLooper;
/*
* Target listener for binder callbacks
@@ -308,16 +311,16 @@
*
* @hide
*/
- public StorageManager(Looper tgtLooper) throws RemoteException {
+ public StorageManager(ContentResolver resolver, Looper tgtLooper) throws RemoteException {
+ mResolver = resolver;
+ mTgtLooper = tgtLooper;
mMountService = IMountService.Stub.asInterface(ServiceManager.getService("mount"));
if (mMountService == null) {
Log.e(TAG, "Unable to connect to mount service! - is it running yet?");
return;
}
- mTgtLooper = tgtLooper;
}
-
/**
* Registers a {@link android.os.storage.StorageEventListener StorageEventListener}.
*
@@ -610,4 +613,36 @@
Log.w(TAG, "No primary storage defined");
return null;
}
+
+ private static final int DEFAULT_THRESHOLD_PERCENTAGE = 10;
+ private static final long DEFAULT_THRESHOLD_MAX_BYTES = 500 * MB_IN_BYTES;
+ private static final long DEFAULT_FULL_THRESHOLD_BYTES = MB_IN_BYTES;
+
+ /**
+ * Return the number of available bytes at which the given path is
+ * considered running low on storage.
+ *
+ * @hide
+ */
+ public long getStorageLowBytes(File path) {
+ final long lowPercent = Settings.Global.getInt(mResolver,
+ Settings.Global.SYS_STORAGE_THRESHOLD_PERCENTAGE, DEFAULT_THRESHOLD_PERCENTAGE);
+ final long lowBytes = (path.getTotalSpace() * lowPercent) / 100;
+
+ final long maxLowBytes = Settings.Global.getLong(mResolver,
+ Settings.Global.SYS_STORAGE_THRESHOLD_MAX_BYTES, DEFAULT_THRESHOLD_MAX_BYTES);
+
+ return Math.min(lowBytes, maxLowBytes);
+ }
+
+ /**
+ * Return the number of available bytes at which the given path is
+ * considered full.
+ *
+ * @hide
+ */
+ public long getStorageFullBytes(File path) {
+ return Settings.Global.getLong(mResolver, Settings.Global.SYS_STORAGE_FULL_THRESHOLD_BYTES,
+ DEFAULT_FULL_THRESHOLD_BYTES);
+ }
}
diff --git a/core/java/android/text/TextUtils.java b/core/java/android/text/TextUtils.java
index 1508d10..2ab9bf8 100644
--- a/core/java/android/text/TextUtils.java
+++ b/core/java/android/text/TextUtils.java
@@ -757,7 +757,7 @@
break;
case EASY_EDIT_SPAN:
- readSpan(p, sp, new EasyEditSpan());
+ readSpan(p, sp, new EasyEditSpan(p));
break;
case LOCALE_SPAN:
diff --git a/core/java/android/text/style/EasyEditSpan.java b/core/java/android/text/style/EasyEditSpan.java
index 2feb719..03b4f60 100644
--- a/core/java/android/text/style/EasyEditSpan.java
+++ b/core/java/android/text/style/EasyEditSpan.java
@@ -16,6 +16,7 @@
package android.text.style;
+import android.app.PendingIntent;
import android.os.Parcel;
import android.text.ParcelableSpan;
import android.text.TextUtils;
@@ -25,12 +26,62 @@
* Provides an easy way to edit a portion of text.
* <p>
* The {@link TextView} uses this span to allow the user to delete a chuck of text in one click.
- * the text. {@link TextView} removes this span as soon as the text is edited, or the cursor moves.
+ * <p>
+ * {@link TextView} removes the span when the user deletes the whole text or modifies it.
+ * <p>
+ * This span can be also used to receive notification when the user deletes or modifies the text;
*/
public class EasyEditSpan implements ParcelableSpan {
+ /**
+ * The extra key field in the pending intent that describes how the text changed.
+ *
+ * @see #TEXT_DELETED
+ * @see #TEXT_MODIFIED
+ * @see #getPendingIntent()
+ */
+ public static final String EXTRA_TEXT_CHANGED_TYPE =
+ "android.text.style.EXTRA_TEXT_CHANGED_TYPE";
+
+ /**
+ * The value of {@link #EXTRA_TEXT_CHANGED_TYPE} when the text wrapped by this span is deleted.
+ */
+ public static final int TEXT_DELETED = 1;
+
+ /**
+ * The value of {@link #EXTRA_TEXT_CHANGED_TYPE} when the text wrapped by this span is modified.
+ */
+ public static final int TEXT_MODIFIED = 2;
+
+ private final PendingIntent mPendingIntent;
+
+ private boolean mDeleteEnabled;
+
+ /**
+ * Creates the span. No intent is sent when the wrapped text is modified or
+ * deleted.
+ */
public EasyEditSpan() {
- // Empty
+ mPendingIntent = null;
+ mDeleteEnabled = true;
+ }
+
+ /**
+ * @param pendingIntent The intent will be sent when the wrapped text is deleted or modified.
+ * When the pending intent is sent, {@link #EXTRA_TEXT_CHANGED_TYPE} is
+ * added in the intent to describe how the text changed.
+ */
+ public EasyEditSpan(PendingIntent pendingIntent) {
+ mPendingIntent = pendingIntent;
+ mDeleteEnabled = true;
+ }
+
+ /**
+ * Constructor called from {@link TextUtils} to restore the span.
+ */
+ public EasyEditSpan(Parcel source) {
+ mPendingIntent = source.readParcelable(null);
+ mDeleteEnabled = (source.readByte() == 1);
}
@Override
@@ -40,11 +91,39 @@
@Override
public void writeToParcel(Parcel dest, int flags) {
- // Empty
+ dest.writeParcelable(mPendingIntent, 0);
+ dest.writeByte((byte) (mDeleteEnabled ? 1 : 0));
}
@Override
public int getSpanTypeId() {
return TextUtils.EASY_EDIT_SPAN;
}
+
+ /**
+ * @return True if the {@link TextView} should offer the ability to delete the text.
+ *
+ * @hide
+ */
+ public boolean isDeleteEnabled() {
+ return mDeleteEnabled;
+ }
+
+ /**
+ * Enables or disables the deletion of the text.
+ *
+ * @hide
+ */
+ public void setDeleteEnabled(boolean value) {
+ mDeleteEnabled = value;
+ }
+
+ /**
+ * @return the pending intent to send when the wrapped text is deleted or modified.
+ *
+ * @hide
+ */
+ public PendingIntent getPendingIntent() {
+ return mPendingIntent;
+ }
}
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java
index 758abb5..e6a7950 100644
--- a/core/java/android/view/Display.java
+++ b/core/java/android/view/Display.java
@@ -437,6 +437,20 @@
}
/**
+ * @hide
+ * Return a rectangle defining the insets of the overscan region of the display.
+ * Each field of the rectangle is the number of pixels the overscan area extends
+ * into the display on that side.
+ */
+ public void getOverscanInsets(Rect outRect) {
+ synchronized (this) {
+ updateDisplayInfoLocked();
+ outRect.set(mDisplayInfo.overscanLeft, mDisplayInfo.overscanTop,
+ mDisplayInfo.overscanRight, mDisplayInfo.overscanBottom);
+ }
+ }
+
+ /**
* Returns the rotation of the screen from its "natural" orientation.
* The returned value may be {@link Surface#ROTATION_0 Surface.ROTATION_0}
* (no rotation), {@link Surface#ROTATION_90 Surface.ROTATION_90},
diff --git a/core/java/android/view/DisplayInfo.java b/core/java/android/view/DisplayInfo.java
index 305fd5c..9fcd9b1 100644
--- a/core/java/android/view/DisplayInfo.java
+++ b/core/java/android/view/DisplayInfo.java
@@ -109,6 +109,30 @@
public int logicalHeight;
/**
+ * @hide
+ * Number of overscan pixels on the left side of the display.
+ */
+ public int overscanLeft;
+
+ /**
+ * @hide
+ * Number of overscan pixels on the top side of the display.
+ */
+ public int overscanTop;
+
+ /**
+ * @hide
+ * Number of overscan pixels on the right side of the display.
+ */
+ public int overscanRight;
+
+ /**
+ * @hide
+ * Number of overscan pixels on the bottom side of the display.
+ */
+ public int overscanBottom;
+
+ /**
* The rotation of the display relative to its natural orientation.
* May be one of {@link android.view.Surface#ROTATION_0},
* {@link android.view.Surface#ROTATION_90}, {@link android.view.Surface#ROTATION_180},
@@ -196,6 +220,10 @@
&& largestNominalAppHeight == other.largestNominalAppHeight
&& logicalWidth == other.logicalWidth
&& logicalHeight == other.logicalHeight
+ && overscanLeft == other.overscanLeft
+ && overscanTop == other.overscanTop
+ && overscanRight == other.overscanRight
+ && overscanBottom == other.overscanBottom
&& rotation == other.rotation
&& refreshRate == other.refreshRate
&& logicalDensityDpi == other.logicalDensityDpi
@@ -222,6 +250,10 @@
largestNominalAppHeight = other.largestNominalAppHeight;
logicalWidth = other.logicalWidth;
logicalHeight = other.logicalHeight;
+ overscanLeft = other.overscanLeft;
+ overscanTop = other.overscanTop;
+ overscanRight = other.overscanRight;
+ overscanBottom = other.overscanBottom;
rotation = other.rotation;
refreshRate = other.refreshRate;
logicalDensityDpi = other.logicalDensityDpi;
@@ -243,6 +275,10 @@
largestNominalAppHeight = source.readInt();
logicalWidth = source.readInt();
logicalHeight = source.readInt();
+ overscanLeft = source.readInt();
+ overscanTop = source.readInt();
+ overscanRight = source.readInt();
+ overscanBottom = source.readInt();
rotation = source.readInt();
refreshRate = source.readFloat();
logicalDensityDpi = source.readInt();
@@ -265,6 +301,10 @@
dest.writeInt(largestNominalAppHeight);
dest.writeInt(logicalWidth);
dest.writeInt(logicalHeight);
+ dest.writeInt(overscanLeft);
+ dest.writeInt(overscanTop);
+ dest.writeInt(overscanRight);
+ dest.writeInt(overscanBottom);
dest.writeInt(rotation);
dest.writeFloat(refreshRate);
dest.writeInt(logicalDensityDpi);
@@ -318,18 +358,55 @@
// For debugging purposes
@Override
public String toString() {
- return "DisplayInfo{\"" + name + "\", app " + appWidth + " x " + appHeight
- + ", real " + logicalWidth + " x " + logicalHeight
- + ", largest app " + largestNominalAppWidth + " x " + largestNominalAppHeight
- + ", smallest app " + smallestNominalAppWidth + " x " + smallestNominalAppHeight
- + ", " + refreshRate + " fps"
- + ", rotation " + rotation
- + ", density " + logicalDensityDpi
- + ", " + physicalXDpi + " x " + physicalYDpi + " dpi"
- + ", layerStack " + layerStack
- + ", type " + Display.typeToString(type)
- + ", address " + address
- + flagsToString(flags) + "}";
+ StringBuilder sb = new StringBuilder();
+ sb.append("DisplayInfo{\"");
+ sb.append(name);
+ sb.append("\", app ");
+ sb.append(appWidth);
+ sb.append(" x ");
+ sb.append(appHeight);
+ sb.append(", real ");
+ sb.append(logicalWidth);
+ sb.append(" x ");
+ sb.append(logicalHeight);
+ if (overscanLeft != 0 || overscanTop != 0 || overscanRight != 0 || overscanBottom != 0) {
+ sb.append(", overscan (");
+ sb.append(overscanLeft);
+ sb.append(",");
+ sb.append(overscanTop);
+ sb.append(",");
+ sb.append(overscanRight);
+ sb.append(",");
+ sb.append(overscanBottom);
+ sb.append(")");
+ }
+ sb.append(", largest app ");
+ sb.append(largestNominalAppWidth);
+ sb.append(" x ");
+ sb.append(largestNominalAppHeight);
+ sb.append(", smallest app ");
+ sb.append(smallestNominalAppWidth);
+ sb.append(" x ");
+ sb.append(smallestNominalAppHeight);
+ sb.append(", ");
+ sb.append(refreshRate);
+ sb.append(" fps, rotation");
+ sb.append(rotation);
+ sb.append(", density ");
+ sb.append(logicalDensityDpi);
+ sb.append(" (");
+ sb.append(physicalXDpi);
+ sb.append(" x ");
+ sb.append(physicalYDpi);
+ sb.append(") dpi, layerStack ");
+ sb.append(layerStack);
+ sb.append(", type ");
+ sb.append(Display.typeToString(type));
+ sb.append(", address ");
+ sb.append(address);
+ sb.append(flagsToString(flags));
+ sb.append("}");
+ return sb.toString();
}
private static String flagsToString(int flags) {
diff --git a/core/java/android/view/DisplayList.java b/core/java/android/view/DisplayList.java
index e996e67..3bad98e 100644
--- a/core/java/android/view/DisplayList.java
+++ b/core/java/android/view/DisplayList.java
@@ -19,13 +19,109 @@
import android.graphics.Matrix;
/**
- * A display lists records a series of graphics related operation and can replay
+ * <p>A display list records a series of graphics related operations and can replay
* them later. Display lists are usually built by recording operations on a
- * {@link android.graphics.Canvas}. Replaying the operations from a display list
- * avoids executing views drawing code on every frame, and is thus much more
- * efficient.
+ * {@link HardwareCanvas}. Replaying the operations from a display list avoids
+ * executing application code on every frame, and is thus much more efficient.</p>
*
- * @hide
+ * <p>Display lists are used internally for all views by default, and are not
+ * typically used directly. One reason to consider using a display is a custom
+ * {@link View} implementation that needs to issue a large number of drawing commands.
+ * When the view invalidates, all the drawing commands must be reissued, even if
+ * large portions of the drawing command stream stay the same frame to frame, which
+ * can become a performance bottleneck. To solve this issue, a custom View might split
+ * its content into several display lists. A display list is updated only when its
+ * content, and only its content, needs to be updated.</p>
+ *
+ * <p>A text editor might for instance store each paragraph into its own display list.
+ * Thus when the user inserts or removes characters, only the display list of the
+ * affected paragraph needs to be recorded again.</p>
+ *
+ * <h3>Hardware acceleration</h3>
+ * <p>Display lists can only be replayed using a {@link HardwareCanvas}. They are not
+ * supported in software. Always make sure that the {@link android.graphics.Canvas}
+ * you are using to render a display list is hardware accelerated using
+ * {@link android.graphics.Canvas#isHardwareAccelerated()}.</p>
+ *
+ * <h3>Creating a display list</h3>
+ * <pre class="prettyprint">
+ * HardwareRenderer renderer = myView.getHardwareRenderer();
+ * if (renderer != null) {
+ * DisplayList displayList = renderer.createDisplayList();
+ * HardwareCanvas canvas = displayList.start(width, height);
+ * try {
+ * // Draw onto the canvas
+ * // For instance: canvas.drawBitmap(...);
+ * } finally {
+ * displayList.end();
+ * }
+ * }
+ * </pre>
+ *
+ * <h3>Rendering a display list on a View</h3>
+ * <pre class="prettyprint">
+ * protected void onDraw(Canvas canvas) {
+ * if (canvas.isHardwareAccelerated()) {
+ * HardwareCanvas hardwareCanvas = (HardwareCanvas) canvas;
+ * hardwareCanvas.drawDisplayList(mDisplayList);
+ * }
+ * }
+ * </pre>
+ *
+ * <h3>Releasing resources</h3>
+ * <p>This step is not mandatory but recommended if you want to release resources
+ * held by a display list as soon as possible.</p>
+ * <pre class="prettyprint">
+ * // Mark this display list invalid, it cannot be used for drawing anymore,
+ * // and release resources held by this display list
+ * displayList.clear();
+ * </pre>
+ *
+ * <h3>Properties</h3>
+ * <p>In addition, a display list offers several properties, such as
+ * {@link #setScaleX(float)} or {@link #setLeft(int)}, that can be used to affect all
+ * the drawing commands recorded within. For instance, these properties can be used
+ * to move around a large number of images without re-issuing all the individual
+ * <code>drawBitmap()</code> calls.</p>
+ *
+ * <pre class="prettyprint">
+ * private void createDisplayList() {
+ * HardwareRenderer renderer = getHardwareRenderer();
+ * if (renderer != null) {
+ * mDisplayList = renderer.createDisplayList();
+ * HardwareCanvas canvas = mDisplayList.start(width, height);
+ * try {
+ * for (Bitmap b : mBitmaps) {
+ * canvas.drawBitmap(b, 0.0f, 0.0f, null);
+ * canvas.translate(0.0f, b.getHeight());
+ * }
+ * } finally {
+ * displayList.end();
+ * }
+ * }
+ * }
+ *
+ * protected void onDraw(Canvas canvas) {
+ * if (canvas.isHardwareAccelerated()) {
+ * HardwareCanvas hardwareCanvas = (HardwareCanvas) canvas;
+ * hardwareCanvas.drawDisplayList(mDisplayList);
+ * }
+ * }
+ *
+ * private void moveContentBy(int x) {
+ * // This will move all the bitmaps recorded inside the display list
+ * // by x pixels to the right and redraw this view. All the commands
+ * // recorded in createDisplayList() won't be re-issued, only onDraw()
+ * // will be invoked and will execute very quickly
+ * mDisplayList.offsetLeftAndRight(x);
+ * invalidate();
+ * }
+ * </pre>
+ *
+ * <h3>Threading</h3>
+ * <p>Display lists must be created on and manipulated from the UI thread only.</p>
+ *
+ * @hide
*/
public abstract class DisplayList {
private boolean mDirty;
@@ -36,6 +132,8 @@
* When this flag is set, draw operations lying outside of the bounds of the
* display list will be culled early. It is recommeneded to always set this
* flag.
+ *
+ * @hide
*/
public static final int FLAG_CLIP_CHILDREN = 0x1;
@@ -44,14 +142,18 @@
/**
* Indicates that the display list is done drawing.
*
- * @see HardwareCanvas#drawDisplayList(DisplayList, android.graphics.Rect, int)
+ * @see HardwareCanvas#drawDisplayList(DisplayList, android.graphics.Rect, int)
+ *
+ * @hide
*/
public static final int STATUS_DONE = 0x0;
/**
* Indicates that the display list needs another drawing pass.
*
- * @see HardwareCanvas#drawDisplayList(DisplayList, android.graphics.Rect, int)
+ * @see HardwareCanvas#drawDisplayList(DisplayList, android.graphics.Rect, int)
+ *
+ * @hide
*/
public static final int STATUS_DRAW = 0x1;
@@ -59,7 +161,9 @@
* Indicates that the display list needs to re-execute its GL functors.
*
* @see HardwareCanvas#drawDisplayList(DisplayList, android.graphics.Rect, int)
- * @see HardwareCanvas#callDrawGLFunction(int)
+ * @see HardwareCanvas#callDrawGLFunction(int)
+ *
+ * @hide
*/
public static final int STATUS_INVOKE = 0x2;
@@ -67,53 +171,79 @@
* Indicates that the display list performed GL drawing operations.
*
* @see HardwareCanvas#drawDisplayList(DisplayList, android.graphics.Rect, int)
+ *
+ * @hide
*/
public static final int STATUS_DREW = 0x4;
/**
* Starts recording the display list. All operations performed on the
* returned canvas are recorded and stored in this display list.
- *
+ *
+ * Calling this method will mark the display list invalid until
+ * {@link #end()} is called. Only valid display lists can be replayed.
+ *
+ * @param width The width of the display list's viewport
+ * @param height The height of the display list's viewport
+ *
* @return A canvas to record drawing operations.
+ *
+ * @see #end()
+ * @see #isValid()
*/
- public abstract HardwareCanvas start();
+ public abstract HardwareCanvas start(int width, int height);
/**
* Ends the recording for this display list. A display list cannot be
- * replayed if recording is not finished.
+ * replayed if recording is not finished. Calling this method marks
+ * the display list valid and {@link #isValid()} will return true.
+ *
+ * @see #start(int, int)
+ * @see #isValid()
*/
public abstract void end();
/**
- * Invalidates the display list, indicating that it should be repopulated
- * with new drawing commands prior to being used again. Calling this method
- * causes calls to {@link #isValid()} to return <code>false</code>.
- */
- public abstract void invalidate();
-
- /**
- * Clears additional resources held onto by this display list. You should
- * only invoke this method after {@link #invalidate()}.
+ * Clears resources held onto by this display list. After calling this method
+ * {@link #isValid()} will return false.
+ *
+ * @see #isValid()
*/
public abstract void clear();
/**
- * Sets the dirty flag. When a display list is dirty, both
- * {@link #invalidate()} and {@link #clear()} should be invoked whenever
- * possible.
- *
- * @param dirty True to mark the display list dirty, false otherwise
+ * Sets the dirty flag. When a display list is dirty, {@link #clear()} should
+ * be invoked whenever possible.
*
* @see #isDirty()
+ * @see #clear()
+ *
+ * @hide
*/
- public void setDirty(boolean dirty) {
- mDirty = dirty;
+ public void markDirty() {
+ mDirty = true;
+ }
+
+ /**
+ * Removes the dirty flag. This method can be used to cancel a cleanup
+ * previously scheduled by setting the dirty flag.
+ *
+ * @see #isDirty()
+ * @see #clear()
+ *
+ * @hide
+ */
+ protected void clearDirty() {
+ mDirty = false;
}
/**
* Indicates whether the display list is dirty.
*
- * @see #setDirty(boolean)
+ * @see #markDirty()
+ * @see #clear()
+ *
+ * @hide
*/
public boolean isDirty() {
return mDirty;
@@ -131,6 +261,8 @@
* Return the amount of memory used by this display list.
*
* @return The size of this display list in bytes
+ *
+ * @hide
*/
public abstract int getSize();
@@ -139,228 +271,412 @@
///////////////////////////////////////////////////////////////////////////
/**
- * Set the caching property on the DisplayList, which indicates whether the DisplayList
- * holds a layer. Layer DisplayLists should avoid creating an alpha layer, since alpha is
+ * Set the caching property on the display list, which indicates whether the display list
+ * holds a layer. Layer display lists should avoid creating an alpha layer, since alpha is
* handled in the drawLayer operation directly (and more efficiently).
*
- * @param caching true if the DisplayList represents a hardware layer, false otherwise.
+ * @param caching true if the display list represents a hardware layer, false otherwise.
+ *
+ * @hide
*/
public abstract void setCaching(boolean caching);
/**
- * Set whether the DisplayList should clip itself to its bounds. This property is controlled by
+ * Set whether the display list should clip itself to its bounds. This property is controlled by
* the view's parent.
*
- * @param clipChildren true if the DisplayList should clip to its bounds
+ * @param clipChildren true if the display list should clip to its bounds
*/
public abstract void setClipChildren(boolean clipChildren);
/**
- * Set the static matrix on the DisplayList. This matrix exists if a custom ViewGroup
- * overrides
- * {@link ViewGroup#getChildStaticTransformation(View, android.view.animation.Transformation)}
- * and also has {@link ViewGroup#setStaticTransformationsEnabled(boolean)} set to true.
- * This matrix will be concatenated with any other matrices in the DisplayList to position
- * the view appropriately.
+ * Set the static matrix on the display list. The specified matrix is combined with other
+ * transforms (such as {@link #setScaleX(float)}, {@link #setRotation(float)}, etc.)
*
- * @param matrix The matrix
+ * @param matrix A transform matrix to apply to this display list
+ *
+ * @see #getMatrix(android.graphics.Matrix)
+ * @see #getMatrix()
*/
- public abstract void setStaticMatrix(Matrix matrix);
+ public abstract void setMatrix(Matrix matrix);
/**
- * Set the Animation matrix on the DisplayList. This matrix exists if an Animation is
- * currently playing on a View, and is set on the DisplayList during at draw() time. When
+ * Returns the static matrix set on this display list.
+ *
+ * @return A new {@link Matrix} instance populated with this display list's static
+ * matrix
+ *
+ * @see #getMatrix(android.graphics.Matrix)
+ * @see #setMatrix(android.graphics.Matrix)
+ */
+ public Matrix getMatrix() {
+ return getMatrix(new Matrix());
+ }
+
+ /**
+ * Copies this display list's static matrix into the specified matrix.
+ *
+ * @param matrix The {@link Matrix} instance in which to copy this display
+ * list's static matrix. Cannot be null
+ *
+ * @return The <code>matrix</code> parameter, for convenience
+ *
+ * @see #getMatrix()
+ * @see #setMatrix(android.graphics.Matrix)
+ */
+ public abstract Matrix getMatrix(Matrix matrix);
+
+ /**
+ * Set the Animation matrix on the display list. This matrix exists if an Animation is
+ * currently playing on a View, and is set on the display list during at draw() time. When
* the Animation finishes, the matrix should be cleared by sending <code>null</code>
* for the matrix parameter.
*
* @param matrix The matrix, null indicates that the matrix should be cleared.
+ *
+ * @hide
*/
public abstract void setAnimationMatrix(Matrix matrix);
/**
- * Sets the alpha value for the DisplayList
+ * Sets the translucency level for the display list.
*
- * @param alpha The translucency of the DisplayList
+ * @param alpha The translucency of the display list, must be a value between 0.0f and 1.0f
+ *
* @see View#setAlpha(float)
+ * @see #getAlpha()
*/
public abstract void setAlpha(float alpha);
/**
- * Sets whether the DisplayList renders content which overlaps. Non-overlapping rendering
- * can use a fast path for alpha that avoids rendering to an offscreen buffer.
+ * Returns the translucency level of this display list.
*
- * @param hasOverlappingRendering
+ * @return A value between 0.0f and 1.0f
+ *
+ * @see #setAlpha(float)
+ */
+ public abstract float getAlpha();
+
+ /**
+ * Sets whether the display list renders content which overlaps. Non-overlapping rendering
+ * can use a fast path for alpha that avoids rendering to an offscreen buffer. By default
+ * display lists consider they do not have overlapping content.
+ *
+ * @param hasOverlappingRendering False if the content is guaranteed to be non-overlapping,
+ * true otherwise.
+ *
* @see android.view.View#hasOverlappingRendering()
+ * @see #hasOverlappingRendering()
*/
public abstract void setHasOverlappingRendering(boolean hasOverlappingRendering);
/**
- * Sets the translationX value for the DisplayList
+ * Indicates whether the content of this display list overlaps.
*
- * @param translationX The translationX value of the DisplayList
+ * @return True if this display list renders content which overlaps, false otherwise.
+ *
+ * @see #setHasOverlappingRendering(boolean)
+ */
+ public abstract boolean hasOverlappingRendering();
+
+ /**
+ * Sets the translation value for the display list on the X axis
+ *
+ * @param translationX The X axis translation value of the display list, in pixels
+ *
* @see View#setTranslationX(float)
+ * @see #getTranslationX()
*/
public abstract void setTranslationX(float translationX);
/**
- * Sets the translationY value for the DisplayList
+ * Returns the translation value for this display list on the X axis, in pixels.
*
- * @param translationY The translationY value of the DisplayList
+ * @see #setTranslationX(float)
+ */
+ public abstract float getTranslationX();
+
+ /**
+ * Sets the translation value for the display list on the Y axis
+ *
+ * @param translationY The Y axis translation value of the display list, in pixels
+ *
* @see View#setTranslationY(float)
+ * @see #getTranslationY()
*/
public abstract void setTranslationY(float translationY);
/**
- * Sets the rotation value for the DisplayList
+ * Returns the translation value for this display list on the Y axis, in pixels.
*
- * @param rotation The rotation value of the DisplayList
+ * @see #setTranslationY(float)
+ */
+ public abstract float getTranslationY();
+
+ /**
+ * Sets the rotation value for the display list around the Z axis
+ *
+ * @param rotation The rotation value of the display list, in degrees
+ *
* @see View#setRotation(float)
+ * @see #getRotation()
*/
public abstract void setRotation(float rotation);
/**
- * Sets the rotationX value for the DisplayList
+ * Returns the rotation value for this display list around the Z axis, in degrees.
*
- * @param rotationX The rotationX value of the DisplayList
+ * @see #setRotation(float)
+ */
+ public abstract float getRotation();
+
+ /**
+ * Sets the rotation value for the display list around the X axis
+ *
+ * @param rotationX The rotation value of the display list, in degrees
+ *
* @see View#setRotationX(float)
+ * @see #getRotationX()
*/
public abstract void setRotationX(float rotationX);
/**
- * Sets the rotationY value for the DisplayList
+ * Returns the rotation value for this display list around the X axis, in degrees.
*
- * @param rotationY The rotationY value of the DisplayList
+ * @see #setRotationX(float)
+ */
+ public abstract float getRotationX();
+
+ /**
+ * Sets the rotation value for the display list around the Y axis
+ *
+ * @param rotationY The rotation value of the display list, in degrees
+ *
* @see View#setRotationY(float)
+ * @see #getRotationY()
*/
public abstract void setRotationY(float rotationY);
/**
- * Sets the scaleX value for the DisplayList
+ * Returns the rotation value for this display list around the Y axis, in degrees.
*
- * @param scaleX The scaleX value of the DisplayList
+ * @see #setRotationY(float)
+ */
+ public abstract float getRotationY();
+
+ /**
+ * Sets the scale value for the display list on the X axis
+ *
+ * @param scaleX The scale value of the display list
+ *
* @see View#setScaleX(float)
+ * @see #getScaleX()
*/
public abstract void setScaleX(float scaleX);
/**
- * Sets the scaleY value for the DisplayList
+ * Returns the scale value for this display list on the X axis.
*
- * @param scaleY The scaleY value of the DisplayList
+ * @see #setScaleX(float)
+ */
+ public abstract float getScaleX();
+
+ /**
+ * Sets the scale value for the display list on the Y axis
+ *
+ * @param scaleY The scale value of the display list
+ *
* @see View#setScaleY(float)
+ * @see #getScaleY()
*/
public abstract void setScaleY(float scaleY);
/**
- * Sets all of the transform-related values of the View onto the DisplayList
+ * Returns the scale value for this display list on the Y axis.
*
- * @param alpha The alpha value of the DisplayList
- * @param translationX The translationX value of the DisplayList
- * @param translationY The translationY value of the DisplayList
- * @param rotation The rotation value of the DisplayList
- * @param rotationX The rotationX value of the DisplayList
- * @param rotationY The rotationY value of the DisplayList
- * @param scaleX The scaleX value of the DisplayList
- * @param scaleY The scaleY value of the DisplayList
+ * @see #setScaleY(float)
+ */
+ public abstract float getScaleY();
+
+ /**
+ * Sets all of the transform-related values of the display list
+ *
+ * @param alpha The alpha value of the display list
+ * @param translationX The translationX value of the display list
+ * @param translationY The translationY value of the display list
+ * @param rotation The rotation value of the display list
+ * @param rotationX The rotationX value of the display list
+ * @param rotationY The rotationY value of the display list
+ * @param scaleX The scaleX value of the display list
+ * @param scaleY The scaleY value of the display list
+ *
+ * @hide
*/
public abstract void setTransformationInfo(float alpha, float translationX, float translationY,
float rotation, float rotationX, float rotationY, float scaleX, float scaleY);
/**
- * Sets the pivotX value for the DisplayList
+ * Sets the pivot value for the display list on the X axis
*
- * @param pivotX The pivotX value of the DisplayList
+ * @param pivotX The pivot value of the display list on the X axis, in pixels
+ *
* @see View#setPivotX(float)
+ * @see #getPivotX()
*/
public abstract void setPivotX(float pivotX);
/**
- * Sets the pivotY value for the DisplayList
+ * Returns the pivot value for this display list on the X axis, in pixels.
*
- * @param pivotY The pivotY value of the DisplayList
+ * @see #setPivotX(float)
+ */
+ public abstract float getPivotX();
+
+ /**
+ * Sets the pivot value for the display list on the Y axis
+ *
+ * @param pivotY The pivot value of the display list on the Y axis, in pixels
+ *
* @see View#setPivotY(float)
+ * @see #getPivotY()
*/
public abstract void setPivotY(float pivotY);
/**
- * Sets the camera distance for the DisplayList
+ * Returns the pivot value for this display list on the Y axis, in pixels.
*
- * @param distance The distance in z of the camera of the DisplayList
+ * @see #setPivotY(float)
+ */
+ public abstract float getPivotY();
+
+ /**
+ * Sets the camera distance for the display list. Refer to
+ * {@link View#setCameraDistance(float)} for more information on how to
+ * use this property.
+ *
+ * @param distance The distance in Z of the camera of the display list
+ *
* @see View#setCameraDistance(float)
+ * @see #getCameraDistance()
*/
public abstract void setCameraDistance(float distance);
/**
- * Sets the left value for the DisplayList
+ * Returns the distance in Z of the camera of the display list.
*
- * @param left The left value of the DisplayList
+ * @see #setCameraDistance(float)
+ */
+ public abstract float getCameraDistance();
+
+ /**
+ * Sets the left position for the display list.
+ *
+ * @param left The left position, in pixels, of the display list
+ *
* @see View#setLeft(int)
+ * @see #getLeft()
*/
public abstract void setLeft(int left);
/**
- * Sets the top value for the DisplayList
+ * Returns the left position for the display list in pixels.
*
- * @param top The top value of the DisplayList
+ * @see #setLeft(int)
+ */
+ public abstract float getLeft();
+
+ /**
+ * Sets the top position for the display list.
+ *
+ * @param top The top position, in pixels, of the display list
+ *
* @see View#setTop(int)
+ * @see #getTop()
*/
public abstract void setTop(int top);
/**
- * Sets the right value for the DisplayList
+ * Returns the top position for the display list in pixels.
*
- * @param right The right value of the DisplayList
+ * @see #setTop(int)
+ */
+ public abstract float getTop();
+
+ /**
+ * Sets the right position for the display list.
+ *
+ * @param right The right position, in pixels, of the display list
+ *
* @see View#setRight(int)
+ * @see #getRight()
*/
public abstract void setRight(int right);
/**
- * Sets the bottom value for the DisplayList
+ * Returns the right position for the display list in pixels.
*
- * @param bottom The bottom value of the DisplayList
+ * @see #setRight(int)
+ */
+ public abstract float getRight();
+
+ /**
+ * Sets the bottom position for the display list.
+ *
+ * @param bottom The bottom position, in pixels, of the display list
+ *
* @see View#setBottom(int)
+ * @see #getBottom()
*/
public abstract void setBottom(int bottom);
/**
- * Sets the left and top values for the DisplayList
+ * Returns the bottom position for the display list in pixels.
*
- * @param left The left value of the DisplayList
- * @param top The top value of the DisplayList
- * @see View#setLeft(int)
- * @see View#setTop(int)
+ * @see #setBottom(int)
*/
- public abstract void setLeftTop(int left, int top);
+ public abstract float getBottom();
/**
- * Sets the left and top values for the DisplayList
+ * Sets the left and top positions for the display list
*
- * @param left The left value of the DisplayList
- * @param top The top value of the DisplayList
+ * @param left The left position of the display list, in pixels
+ * @param top The top position of the display list, in pixels
+ * @param right The right position of the display list, in pixels
+ * @param bottom The bottom position of the display list, in pixels
+ *
* @see View#setLeft(int)
* @see View#setTop(int)
+ * @see View#setRight(int)
+ * @see View#setBottom(int)
*/
public abstract void setLeftTopRightBottom(int left, int top, int right, int bottom);
/**
- * Offsets the left and right values for the DisplayList
+ * Offsets the left and right positions for the display list
*
- * @param offset The amount that the left and right values of the DisplayList are offset
+ * @param offset The amount that the left and right positions of the display
+ * list are offset, in pixels
+ *
* @see View#offsetLeftAndRight(int)
*/
- public abstract void offsetLeftRight(int offset);
+ public abstract void offsetLeftAndRight(float offset);
/**
- * Offsets the top and bottom values for the DisplayList
+ * Offsets the top and bottom values for the display list
*
- * @param offset The amount that the top and bottom values of the DisplayList are offset
+ * @param offset The amount that the top and bottom positions of the display
+ * list are offset, in pixels
+ *
* @see View#offsetTopAndBottom(int)
*/
- public abstract void offsetTopBottom(int offset);
+ public abstract void offsetTopAndBottom(float offset);
/**
- * Reset native resources. This is called when cleaning up the state of DisplayLists
+ * Reset native resources. This is called when cleaning up the state of display lists
* during destruction of hardware resources, to ensure that we do not hold onto
* obsolete resources after related resources are gone.
+ *
+ * @hide
*/
public abstract void reset();
}
diff --git a/core/java/android/view/GLES20Canvas.java b/core/java/android/view/GLES20Canvas.java
index 40f2261..9c44737 100644
--- a/core/java/android/view/GLES20Canvas.java
+++ b/core/java/android/view/GLES20Canvas.java
@@ -377,24 +377,13 @@
}
private static native int nGetDisplayList(int renderer, int displayList);
-
- static void destroyDisplayList(int displayList) {
- nDestroyDisplayList(displayList);
+
+ @Override
+ void outputDisplayList(DisplayList displayList) {
+ nOutputDisplayList(mRenderer, ((GLES20DisplayList) displayList).getNativeDisplayList());
}
- private static native void nDestroyDisplayList(int displayList);
-
- static int getDisplayListSize(int displayList) {
- return nGetDisplayListSize(displayList);
- }
-
- private static native int nGetDisplayListSize(int displayList);
-
- static void setDisplayListName(int displayList, String name) {
- nSetDisplayListName(displayList, name);
- }
-
- private static native void nSetDisplayListName(int displayList, String name);
+ private static native void nOutputDisplayList(int renderer, int displayList);
@Override
public int drawDisplayList(DisplayList displayList, Rect dirty, int flags) {
@@ -405,13 +394,6 @@
private static native int nDrawDisplayList(int renderer, int displayList,
Rect dirty, int flags);
- @Override
- void outputDisplayList(DisplayList displayList) {
- nOutputDisplayList(mRenderer, ((GLES20DisplayList) displayList).getNativeDisplayList());
- }
-
- private static native void nOutputDisplayList(int renderer, int displayList);
-
///////////////////////////////////////////////////////////////////////////
// Hardware layer
///////////////////////////////////////////////////////////////////////////
diff --git a/core/java/android/view/GLES20DisplayList.java b/core/java/android/view/GLES20DisplayList.java
index e9bd0c4..9c5cdb2 100644
--- a/core/java/android/view/GLES20DisplayList.java
+++ b/core/java/android/view/GLES20DisplayList.java
@@ -58,7 +58,7 @@
}
@Override
- public HardwareCanvas start() {
+ public HardwareCanvas start(int width, int height) {
if (mCanvas != null) {
throw new IllegalStateException("Recording has already started");
}
@@ -66,24 +66,25 @@
mValid = false;
mCanvas = GLES20RecordingCanvas.obtain(this);
mCanvas.start();
+
+ mCanvas.setViewport(width, height);
+ // The dirty rect should always be null for a display list
+ mCanvas.onPreDraw(null);
+
return mCanvas;
}
-
@Override
- public void invalidate() {
+ public void clear() {
+ clearDirty();
+
if (mCanvas != null) {
mCanvas.recycle();
mCanvas = null;
}
mValid = false;
- }
- @Override
- public void clear() {
- if (!mValid) {
- mBitmaps.clear();
- mChildDisplayLists.clear();
- }
+ mBitmaps.clear();
+ mChildDisplayLists.clear();
}
@Override
@@ -101,11 +102,12 @@
@Override
public void end() {
if (mCanvas != null) {
+ mCanvas.onPostDraw();
if (mFinalizer != null) {
mCanvas.end(mFinalizer.mNativeDisplayList);
} else {
mFinalizer = new DisplayListFinalizer(mCanvas.end(0));
- GLES20Canvas.setDisplayListName(mFinalizer.mNativeDisplayList, mName);
+ nSetDisplayListName(mFinalizer.mNativeDisplayList, mName);
}
mCanvas.recycle();
mCanvas = null;
@@ -116,9 +118,13 @@
@Override
public int getSize() {
if (mFinalizer == null) return 0;
- return GLES20Canvas.getDisplayListSize(mFinalizer.mNativeDisplayList);
+ return nGetDisplayListSize(mFinalizer.mNativeDisplayList);
}
+ private static native void nDestroyDisplayList(int displayList);
+ private static native int nGetDisplayListSize(int displayList);
+ private static native void nSetDisplayListName(int displayList, String name);
+
///////////////////////////////////////////////////////////////////////////
// Native View Properties
///////////////////////////////////////////////////////////////////////////
@@ -138,13 +144,21 @@
}
@Override
- public void setStaticMatrix(Matrix matrix) {
+ public void setMatrix(Matrix matrix) {
if (hasNativeDisplayList()) {
nSetStaticMatrix(mFinalizer.mNativeDisplayList, matrix.native_instance);
}
}
@Override
+ public Matrix getMatrix(Matrix matrix) {
+ if (hasNativeDisplayList()) {
+ nGetMatrix(mFinalizer.mNativeDisplayList, matrix.native_instance);
+ }
+ return matrix;
+ }
+
+ @Override
public void setAnimationMatrix(Matrix matrix) {
if (hasNativeDisplayList()) {
nSetAnimationMatrix(mFinalizer.mNativeDisplayList,
@@ -160,6 +174,14 @@
}
@Override
+ public float getAlpha() {
+ if (hasNativeDisplayList()) {
+ return nGetAlpha(mFinalizer.mNativeDisplayList);
+ }
+ return 1.0f;
+ }
+
+ @Override
public void setHasOverlappingRendering(boolean hasOverlappingRendering) {
if (hasNativeDisplayList()) {
nSetHasOverlappingRendering(mFinalizer.mNativeDisplayList, hasOverlappingRendering);
@@ -167,6 +189,15 @@
}
@Override
+ public boolean hasOverlappingRendering() {
+ //noinspection SimplifiableIfStatement
+ if (hasNativeDisplayList()) {
+ return nHasOverlappingRendering(mFinalizer.mNativeDisplayList);
+ }
+ return true;
+ }
+
+ @Override
public void setTranslationX(float translationX) {
if (hasNativeDisplayList()) {
nSetTranslationX(mFinalizer.mNativeDisplayList, translationX);
@@ -174,6 +205,14 @@
}
@Override
+ public float getTranslationX() {
+ if (hasNativeDisplayList()) {
+ return nGetTranslationX(mFinalizer.mNativeDisplayList);
+ }
+ return 0.0f;
+ }
+
+ @Override
public void setTranslationY(float translationY) {
if (hasNativeDisplayList()) {
nSetTranslationY(mFinalizer.mNativeDisplayList, translationY);
@@ -181,6 +220,14 @@
}
@Override
+ public float getTranslationY() {
+ if (hasNativeDisplayList()) {
+ return nGetTranslationY(mFinalizer.mNativeDisplayList);
+ }
+ return 0.0f;
+ }
+
+ @Override
public void setRotation(float rotation) {
if (hasNativeDisplayList()) {
nSetRotation(mFinalizer.mNativeDisplayList, rotation);
@@ -188,6 +235,14 @@
}
@Override
+ public float getRotation() {
+ if (hasNativeDisplayList()) {
+ return nGetRotation(mFinalizer.mNativeDisplayList);
+ }
+ return 0.0f;
+ }
+
+ @Override
public void setRotationX(float rotationX) {
if (hasNativeDisplayList()) {
nSetRotationX(mFinalizer.mNativeDisplayList, rotationX);
@@ -195,6 +250,14 @@
}
@Override
+ public float getRotationX() {
+ if (hasNativeDisplayList()) {
+ return nGetRotationX(mFinalizer.mNativeDisplayList);
+ }
+ return 0.0f;
+ }
+
+ @Override
public void setRotationY(float rotationY) {
if (hasNativeDisplayList()) {
nSetRotationY(mFinalizer.mNativeDisplayList, rotationY);
@@ -202,6 +265,14 @@
}
@Override
+ public float getRotationY() {
+ if (hasNativeDisplayList()) {
+ return nGetRotationY(mFinalizer.mNativeDisplayList);
+ }
+ return 0.0f;
+ }
+
+ @Override
public void setScaleX(float scaleX) {
if (hasNativeDisplayList()) {
nSetScaleX(mFinalizer.mNativeDisplayList, scaleX);
@@ -209,6 +280,14 @@
}
@Override
+ public float getScaleX() {
+ if (hasNativeDisplayList()) {
+ return nGetScaleX(mFinalizer.mNativeDisplayList);
+ }
+ return 1.0f;
+ }
+
+ @Override
public void setScaleY(float scaleY) {
if (hasNativeDisplayList()) {
nSetScaleY(mFinalizer.mNativeDisplayList, scaleY);
@@ -216,6 +295,14 @@
}
@Override
+ public float getScaleY() {
+ if (hasNativeDisplayList()) {
+ return nGetScaleY(mFinalizer.mNativeDisplayList);
+ }
+ return 1.0f;
+ }
+
+ @Override
public void setTransformationInfo(float alpha, float translationX, float translationY,
float rotation, float rotationX, float rotationY, float scaleX, float scaleY) {
if (hasNativeDisplayList()) {
@@ -232,6 +319,14 @@
}
@Override
+ public float getPivotX() {
+ if (hasNativeDisplayList()) {
+ return nGetPivotX(mFinalizer.mNativeDisplayList);
+ }
+ return 0.0f;
+ }
+
+ @Override
public void setPivotY(float pivotY) {
if (hasNativeDisplayList()) {
nSetPivotY(mFinalizer.mNativeDisplayList, pivotY);
@@ -239,6 +334,14 @@
}
@Override
+ public float getPivotY() {
+ if (hasNativeDisplayList()) {
+ return nGetPivotY(mFinalizer.mNativeDisplayList);
+ }
+ return 0.0f;
+ }
+
+ @Override
public void setCameraDistance(float distance) {
if (hasNativeDisplayList()) {
nSetCameraDistance(mFinalizer.mNativeDisplayList, distance);
@@ -246,6 +349,14 @@
}
@Override
+ public float getCameraDistance() {
+ if (hasNativeDisplayList()) {
+ return nGetCameraDistance(mFinalizer.mNativeDisplayList);
+ }
+ return 0.0f;
+ }
+
+ @Override
public void setLeft(int left) {
if (hasNativeDisplayList()) {
nSetLeft(mFinalizer.mNativeDisplayList, left);
@@ -253,6 +364,14 @@
}
@Override
+ public float getLeft() {
+ if (hasNativeDisplayList()) {
+ return nGetLeft(mFinalizer.mNativeDisplayList);
+ }
+ return 0.0f;
+ }
+
+ @Override
public void setTop(int top) {
if (hasNativeDisplayList()) {
nSetTop(mFinalizer.mNativeDisplayList, top);
@@ -260,6 +379,14 @@
}
@Override
+ public float getTop() {
+ if (hasNativeDisplayList()) {
+ return nGetTop(mFinalizer.mNativeDisplayList);
+ }
+ return 0.0f;
+ }
+
+ @Override
public void setRight(int right) {
if (hasNativeDisplayList()) {
nSetRight(mFinalizer.mNativeDisplayList, right);
@@ -267,6 +394,14 @@
}
@Override
+ public float getRight() {
+ if (hasNativeDisplayList()) {
+ return nGetRight(mFinalizer.mNativeDisplayList);
+ }
+ return 0.0f;
+ }
+
+ @Override
public void setBottom(int bottom) {
if (hasNativeDisplayList()) {
nSetBottom(mFinalizer.mNativeDisplayList, bottom);
@@ -274,10 +409,11 @@
}
@Override
- public void setLeftTop(int left, int top) {
+ public float getBottom() {
if (hasNativeDisplayList()) {
- nSetLeftTop(mFinalizer.mNativeDisplayList, left, top);
+ return nGetBottom(mFinalizer.mNativeDisplayList);
}
+ return 0.0f;
}
@Override
@@ -288,25 +424,24 @@
}
@Override
- public void offsetLeftRight(int offset) {
+ public void offsetLeftAndRight(float offset) {
if (hasNativeDisplayList()) {
- nOffsetLeftRight(mFinalizer.mNativeDisplayList, offset);
+ nOffsetLeftAndRight(mFinalizer.mNativeDisplayList, offset);
}
}
@Override
- public void offsetTopBottom(int offset) {
+ public void offsetTopAndBottom(float offset) {
if (hasNativeDisplayList()) {
- nOffsetTopBottom(mFinalizer.mNativeDisplayList, offset);
+ nOffsetTopAndBottom(mFinalizer.mNativeDisplayList, offset);
}
}
private static native void nReset(int displayList);
- private static native void nOffsetTopBottom(int displayList, int offset);
- private static native void nOffsetLeftRight(int displayList, int offset);
+ private static native void nOffsetTopAndBottom(int displayList, float offset);
+ private static native void nOffsetLeftAndRight(int displayList, float offset);
private static native void nSetLeftTopRightBottom(int displayList, int left, int top,
int right, int bottom);
- private static native void nSetLeftTop(int displayList, int left, int top);
private static native void nSetBottom(int displayList, int bottom);
private static native void nSetRight(int displayList, int right);
private static native void nSetTop(int displayList, int top);
@@ -332,6 +467,23 @@
private static native void nSetStaticMatrix(int displayList, int nativeMatrix);
private static native void nSetAnimationMatrix(int displayList, int animationMatrix);
+ private static native boolean nHasOverlappingRendering(int displayList);
+ private static native void nGetMatrix(int displayList, int matrix);
+ private static native float nGetAlpha(int displayList);
+ private static native float nGetLeft(int displayList);
+ private static native float nGetTop(int displayList);
+ private static native float nGetRight(int displayList);
+ private static native float nGetBottom(int displayList);
+ private static native float nGetCameraDistance(int displayList);
+ private static native float nGetScaleX(int displayList);
+ private static native float nGetScaleY(int displayList);
+ private static native float nGetTranslationX(int displayList);
+ private static native float nGetTranslationY(int displayList);
+ private static native float nGetRotation(int displayList);
+ private static native float nGetRotationX(int displayList);
+ private static native float nGetRotationY(int displayList);
+ private static native float nGetPivotX(int displayList);
+ private static native float nGetPivotY(int displayList);
///////////////////////////////////////////////////////////////////////////
// Finalization
@@ -347,7 +499,7 @@
@Override
protected void finalize() throws Throwable {
try {
- GLES20Canvas.destroyDisplayList(mNativeDisplayList);
+ nDestroyDisplayList(mNativeDisplayList);
} finally {
super.finalize();
}
diff --git a/core/java/android/view/GLES20Layer.java b/core/java/android/view/GLES20Layer.java
index 812fb97..7ee628b 100644
--- a/core/java/android/view/GLES20Layer.java
+++ b/core/java/android/view/GLES20Layer.java
@@ -53,12 +53,12 @@
}
@Override
- boolean copyInto(Bitmap bitmap) {
+ public boolean copyInto(Bitmap bitmap) {
return GLES20Canvas.nCopyLayer(mLayer, bitmap.mNativeBitmap);
}
@Override
- void destroy() {
+ public void destroy() {
if (mFinalizer != null) {
mFinalizer.destroy();
mFinalizer = null;
diff --git a/core/java/android/view/GLES20RenderLayer.java b/core/java/android/view/GLES20RenderLayer.java
index 44d4719..086e78c 100644
--- a/core/java/android/view/GLES20RenderLayer.java
+++ b/core/java/android/view/GLES20RenderLayer.java
@@ -92,6 +92,10 @@
if (currentCanvas instanceof GLES20Canvas) {
((GLES20Canvas) currentCanvas).resume();
}
+ HardwareCanvas canvas = getCanvas();
+ if (canvas != null) {
+ canvas.onPostDraw();
+ }
}
@Override
@@ -99,7 +103,10 @@
if (currentCanvas instanceof GLES20Canvas) {
((GLES20Canvas) currentCanvas).interrupt();
}
- return getCanvas();
+ HardwareCanvas canvas = getCanvas();
+ canvas.setViewport(mWidth, mHeight);
+ canvas.onPreDraw(null);
+ return canvas;
}
/**
diff --git a/core/java/android/view/HardwareCanvas.java b/core/java/android/view/HardwareCanvas.java
index 3d19260..0dfed69 100644
--- a/core/java/android/view/HardwareCanvas.java
+++ b/core/java/android/view/HardwareCanvas.java
@@ -23,8 +23,8 @@
/**
* Hardware accelerated canvas.
- *
- * @hide
+ *
+ * @hide
*/
public abstract class HardwareCanvas extends Canvas {
private String mName;
@@ -46,6 +46,8 @@
* @param name The name of the canvas, can be null
*
* @see #getName()
+ *
+ * @hide
*/
public void setName(String name) {
mName = name;
@@ -57,6 +59,8 @@
* @return The name of the canvas or null
*
* @see #setName(String)
+ *
+ * @hide
*/
public String getName() {
return mName;
@@ -67,27 +71,43 @@
*
* @param dirty The dirty rectangle to update, can be null.
* @return {@link DisplayList#STATUS_DREW} if anything was drawn (such as a call to clear
- * the canvas).
+ * the canvas).
+ *
+ * @hide
*/
public abstract int onPreDraw(Rect dirty);
/**
* Invoked after all drawing operation have been performed.
+ *
+ * @hide
*/
public abstract void onPostDraw();
/**
+ * Draws the specified display list onto this canvas. The display list can only
+ * be drawn if {@link android.view.DisplayList#isValid()} returns true.
+ *
+ * @param displayList The display list to replay.
+ */
+ public void drawDisplayList(DisplayList displayList) {
+ drawDisplayList(displayList, null, DisplayList.FLAG_CLIP_CHILDREN);
+ }
+
+ /**
* Draws the specified display list onto this canvas.
*
* @param displayList The display list to replay.
* @param dirty The dirty region to redraw in the next pass, matters only
- * if this method returns true, can be null.
+ * if this method returns {@link DisplayList#STATUS_DRAW}, can be null.
* @param flags Optional flags about drawing, see {@link DisplayList} for
* the possible flags.
*
* @return One of {@link DisplayList#STATUS_DONE}, {@link DisplayList#STATUS_DRAW}, or
* {@link DisplayList#STATUS_INVOKE}, or'd with {@link DisplayList#STATUS_DREW}
* if anything was drawn.
+ *
+ * @hide
*/
public abstract int drawDisplayList(DisplayList displayList, Rect dirty, int flags);
@@ -96,6 +116,8 @@
* tools to output display lists for selected nodes to the log.
*
* @param displayList The display list to be logged.
+ *
+ * @hide
*/
abstract void outputDisplayList(DisplayList displayList);
@@ -106,6 +128,8 @@
* @param x The left coordinate of the layer
* @param y The top coordinate of the layer
* @param paint The paint used to draw the layer
+ *
+ * @hide
*/
abstract void drawHardwareLayer(HardwareLayer layer, float x, float y, Paint paint);
@@ -118,6 +142,8 @@
*
* @return One of {@link DisplayList#STATUS_DONE}, {@link DisplayList#STATUS_DRAW} or
* {@link DisplayList#STATUS_INVOKE}
+ *
+ * @hide
*/
public int callDrawGLFunction(int drawGLFunction) {
// Noop - this is done in the display list recorder subclass
@@ -131,6 +157,8 @@
*
* @return One of {@link DisplayList#STATUS_DONE}, {@link DisplayList#STATUS_DRAW} or
* {@link DisplayList#STATUS_INVOKE}
+ *
+ * @hide
*/
public int invokeFunctors(Rect dirty) {
return DisplayList.STATUS_DONE;
@@ -143,7 +171,9 @@
*
* @see #invokeFunctors(android.graphics.Rect)
* @see #callDrawGLFunction(int)
- * @see #detachFunctor(int)
+ * @see #detachFunctor(int)
+ *
+ * @hide
*/
abstract void detachFunctor(int functor);
@@ -154,7 +184,9 @@
*
* @see #invokeFunctors(android.graphics.Rect)
* @see #callDrawGLFunction(int)
- * @see #detachFunctor(int)
+ * @see #detachFunctor(int)
+ *
+ * @hide
*/
abstract void attachFunctor(int functor);
@@ -164,13 +196,17 @@
* @param layer The layer to update
*
* @see #clearLayerUpdates()
+ *
+ * @hide
*/
abstract void pushLayerUpdate(HardwareLayer layer);
/**
* Removes all enqueued layer updates.
*
- * @see #pushLayerUpdate(HardwareLayer)
+ * @see #pushLayerUpdate(HardwareLayer)
+ *
+ * @hide
*/
abstract void clearLayerUpdates();
}
diff --git a/core/java/android/view/HardwareLayer.java b/core/java/android/view/HardwareLayer.java
index d3bc35a..18b838b 100644
--- a/core/java/android/view/HardwareLayer.java
+++ b/core/java/android/view/HardwareLayer.java
@@ -24,7 +24,7 @@
/**
* A hardware layer can be used to render graphics operations into a hardware
- * friendly buffer. For instance, with an OpenGL backend, a hardware layer
+ * friendly buffer. For instance, with an OpenGL backend a hardware layer
* would use a Frame Buffer Object (FBO.) The hardware layer can be used as
* a drawing cache when a complex set of graphics operations needs to be
* drawn several times.
@@ -68,7 +68,7 @@
* @param paint The paint used when the layer is drawn into the destination canvas.
* @see View#setLayerPaint(android.graphics.Paint)
*/
- void setLayerPaint(Paint paint) {}
+ void setLayerPaint(Paint paint) { }
/**
* Returns the minimum width of the layer.
@@ -144,6 +144,9 @@
* this layer.
*
* @return A hardware canvas, or null if a canvas cannot be created
+ *
+ * @see #start(android.graphics.Canvas)
+ * @see #end(android.graphics.Canvas)
*/
abstract HardwareCanvas getCanvas();
@@ -154,12 +157,14 @@
/**
* This must be invoked before drawing onto this layer.
+ *
* @param currentCanvas
*/
abstract HardwareCanvas start(Canvas currentCanvas);
-
+
/**
* This must be invoked after drawing onto this layer.
+ *
* @param currentCanvas
*/
abstract void end(Canvas currentCanvas);
diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java
index 7c4bcfd..7929112 100644
--- a/core/java/android/view/HardwareRenderer.java
+++ b/core/java/android/view/HardwareRenderer.java
@@ -49,7 +49,7 @@
/**
* Interface for rendering a view hierarchy using hardware acceleration.
- *
+ *
* @hide
*/
public abstract class HardwareRenderer {
@@ -63,9 +63,9 @@
/**
* Turn on to only refresh the parts of the screen that need updating.
* When turned on the property defined by {@link #RENDER_DIRTY_REGIONS_PROPERTY}
- * must also have the value "true".
+ * must also have the value "true".
*/
- public static final boolean RENDER_DIRTY_REGIONS = true;
+ static final boolean RENDER_DIRTY_REGIONS = true;
/**
* System property used to enable or disable dirty regions invalidation.
@@ -353,6 +353,8 @@
* resources.
*
* @param cacheDir A directory the current process can write to
+ *
+ * @hide
*/
public static void setupDiskCache(File cacheDir) {
nSetupShadersDiskCache(new File(cacheDir, CACHE_PATH_SHADERS).getAbsolutePath());
@@ -443,10 +445,11 @@
* Creates a new display list that can be used to record batches of
* drawing operations.
*
- * @param name The name of the display list, used for debugging purpose.
- * May be null
+ * @param name The name of the display list, used for debugging purpose. May be null.
*
* @return A new display list.
+ *
+ * @hide
*/
public abstract DisplayList createDisplayList(String name);
@@ -474,7 +477,6 @@
/**
* Creates a new {@link SurfaceTexture} that can be used to render into the
* specified hardware layer.
- *
*
* @param layer The layer to render into using a {@link android.graphics.SurfaceTexture}
*
@@ -1344,31 +1346,25 @@
dirty = beginFrame(canvas, dirty, surfaceState);
+ DisplayList displayList = buildDisplayList(view, canvas);
+
int saveCount = 0;
int status = DisplayList.STATUS_DONE;
try {
- view.mRecreateDisplayList = (view.mPrivateFlags & View.PFLAG_INVALIDATED)
- == View.PFLAG_INVALIDATED;
- view.mPrivateFlags &= ~View.PFLAG_INVALIDATED;
-
- long buildDisplayListStartTime = startBuildDisplayListProfiling();
- canvas.clearLayerUpdates();
-
- DisplayList displayList = buildDisplayList(view);
status = prepareFrame(dirty);
saveCount = canvas.save();
callbacks.onHardwarePreDraw(canvas);
- endBuildDisplayListProfiling(buildDisplayListStartTime);
-
if (displayList != null) {
status = drawDisplayList(attachInfo, canvas, displayList, status);
} else {
// Shouldn't reach here
view.draw(canvas);
}
+ } catch (Exception e) {
+ Log.e(LOG_TAG, "An error has occurred while drawing:", e);
} finally {
callbacks.onHardwarePostDraw(canvas);
canvas.restoreToCount(saveCount);
@@ -1396,6 +1392,23 @@
return false;
}
+ private DisplayList buildDisplayList(View view, HardwareCanvas canvas) {
+ view.mRecreateDisplayList = (view.mPrivateFlags & View.PFLAG_INVALIDATED)
+ == View.PFLAG_INVALIDATED;
+ view.mPrivateFlags &= ~View.PFLAG_INVALIDATED;
+
+ long buildDisplayListStartTime = startBuildDisplayListProfiling();
+ canvas.clearLayerUpdates();
+
+ Trace.traceBegin(Trace.TRACE_TAG_VIEW, "getDisplayList");
+ DisplayList displayList = view.getDisplayList();
+ Trace.traceEnd(Trace.TRACE_TAG_VIEW);
+
+ endBuildDisplayListProfiling(buildDisplayListStartTime);
+
+ return displayList;
+ }
+
abstract void drawProfileData(View.AttachInfo attachInfo);
private Rect beginFrame(HardwareCanvas canvas, Rect dirty, int surfaceState) {
@@ -1443,17 +1456,6 @@
}
}
- private static DisplayList buildDisplayList(View view) {
- DisplayList displayList;
- Trace.traceBegin(Trace.TRACE_TAG_VIEW, "getDisplayList");
- try {
- displayList = view.getDisplayList();
- } finally {
- Trace.traceEnd(Trace.TRACE_TAG_VIEW);
- }
- return displayList;
- }
-
private int prepareFrame(Rect dirty) {
int status;
Trace.traceBegin(Trace.TRACE_TAG_VIEW, "prepareFrame");
@@ -1971,12 +1973,12 @@
}
@Override
- HardwareLayer createHardwareLayer(int width, int height, boolean isOpaque) {
+ public HardwareLayer createHardwareLayer(int width, int height, boolean isOpaque) {
return new GLES20RenderLayer(width, height, isOpaque);
}
@Override
- SurfaceTexture createSurfaceTexture(HardwareLayer layer) {
+ public SurfaceTexture createSurfaceTexture(HardwareLayer layer) {
return ((GLES20TextureLayer) layer).getSurfaceTexture();
}
diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl
index 885327c..e4ecb5c 100644
--- a/core/java/android/view/IWindowManager.aidl
+++ b/core/java/android/view/IWindowManager.aidl
@@ -65,6 +65,8 @@
void setForcedDisplayDensity(int displayId, int density);
void clearForcedDisplayDensity(int displayId);
+ void setOverscan(int displayId, int left, int top, int right, int bottom);
+
// Is the device configured to have a full system bar for larger screens?
boolean hasSystemNavBar();
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 25cad87..dcf51e4 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -16,7 +16,6 @@
package android.view;
-import android.app.ActivityThread;
import android.content.ClipData;
import android.content.Context;
import android.content.res.Configuration;
@@ -10050,7 +10049,7 @@
mTop += offset;
mBottom += offset;
if (mDisplayList != null) {
- mDisplayList.offsetTopBottom(offset);
+ mDisplayList.offsetTopAndBottom(offset);
invalidateViewProperty(false, false);
} else {
if (!matrixIsIdentity) {
@@ -10098,7 +10097,7 @@
mLeft += offset;
mRight += offset;
if (mDisplayList != null) {
- mDisplayList.offsetLeftRight(offset);
+ mDisplayList.offsetLeftAndRight(offset);
invalidateViewProperty(false, false);
} else {
if (!matrixIsIdentity) {
@@ -11687,7 +11686,7 @@
}
if (mDisplayList != null) {
- mDisplayList.setDirty(false);
+ mDisplayList.clearDirty();
}
}
@@ -11966,7 +11965,7 @@
if (mAttachInfo != null) {
if (mDisplayList != null) {
- mDisplayList.setDirty(true);
+ mDisplayList.markDirty();
mAttachInfo.mViewRootImpl.enqueueDisplayList(mDisplayList);
}
mAttachInfo.mViewRootImpl.cancelInvalidate(this);
@@ -12670,8 +12669,9 @@
}
/**
- * @return The HardwareRenderer associated with that view or null if hardware rendering
- * is not supported or this this has not been attached to a window.
+ * @return The {@link HardwareRenderer} associated with that view or null if
+ * hardware rendering is not supported or this view is not attached
+ * to a window.
*
* @hide
*/
@@ -12726,15 +12726,13 @@
}
boolean caching = false;
- final HardwareCanvas canvas = displayList.start();
int width = mRight - mLeft;
int height = mBottom - mTop;
int layerType = getLayerType();
+ final HardwareCanvas canvas = displayList.start(width, height);
+
try {
- canvas.setViewport(width, height);
- // The dirty rect should always be null for a display list
- canvas.onPreDraw(null);
if (!isLayer && layerType != LAYER_TYPE_NONE) {
if (layerType == LAYER_TYPE_HARDWARE) {
final HardwareLayer layer = getHardwareLayer();
@@ -12772,8 +12770,6 @@
}
}
} finally {
- canvas.onPostDraw();
-
displayList.end();
displayList.setCaching(caching);
if (isLayer) {
@@ -12818,7 +12814,6 @@
private void clearDisplayList() {
if (mDisplayList != null) {
- mDisplayList.invalidate();
mDisplayList.clear();
}
}
@@ -13394,7 +13389,7 @@
alpha = transform.getAlpha();
}
if ((transformType & Transformation.TYPE_MATRIX) != 0) {
- displayList.setStaticMatrix(transform.getMatrix());
+ displayList.setMatrix(transform.getMatrix());
}
}
}
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index a4898fc..5105fda 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -4413,7 +4413,7 @@
v.mTop += offset;
v.mBottom += offset;
if (v.mDisplayList != null) {
- v.mDisplayList.offsetTopBottom(offset);
+ v.mDisplayList.offsetTopAndBottom(offset);
invalidateViewProperty(false, false);
}
}
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 1d86361..9b6dafb 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -1437,8 +1437,6 @@
}
// TODO: should handle create/resize failure
layerCanvas = mResizeBuffer.start(hwRendererCanvas);
- layerCanvas.setViewport(mWidth, mHeight);
- layerCanvas.onPreDraw(null);
final int restoreCount = layerCanvas.save();
int yoff;
@@ -1475,9 +1473,6 @@
} catch (OutOfMemoryError e) {
Log.w(TAG, "Not enough memory for content change anim buffer", e);
} finally {
- if (layerCanvas != null) {
- layerCanvas.onPostDraw();
- }
if (mResizeBuffer != null) {
mResizeBuffer.end(hwRendererCanvas);
if (!completed) {
@@ -2506,9 +2501,7 @@
for (int i = 0; i < count; i++) {
final DisplayList displayList = displayLists.get(i);
if (displayList.isDirty()) {
- displayList.invalidate();
displayList.clear();
- displayList.setDirty(false);
}
}
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index 6a67d8b..d236561 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -735,20 +735,20 @@
/**
* <p>Indicates whether this window should be hardware accelerated.
* Requesting hardware acceleration does not guarantee it will happen.</p>
- *
+ *
* <p>This flag can be controlled programmatically <em>only</em> to enable
* hardware acceleration. To enable hardware acceleration for a given
* window programmatically, do the following:</p>
- *
+ *
* <pre>
* Window w = activity.getWindow(); // in Activity's onCreate() for instance
* w.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
* WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
* </pre>
- *
+ *
* <p>It is important to remember that this flag <strong>must</strong>
* be set before setting the content view of your activity or dialog.</p>
- *
+ *
* <p>This flag cannot be used to disable hardware acceleration after it
* was enabled in your manifest using
* {@link android.R.attr#hardwareAccelerated}. If you need to selectively
@@ -756,13 +756,19 @@
* for instance), make sure it is turned off in your manifest and enable it
* on your activity or dialog when you need it instead, using the method
* described above.</p>
- *
+ *
* <p>This flag is automatically set by the system if the
* {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated}
* XML attribute is set to true on an activity or on the application.</p>
*/
public static final int FLAG_HARDWARE_ACCELERATED = 0x01000000;
+ /** Window flag: allow window contents to extend in to the screen's
+ * overscan area, if there is one. The window should still correctly
+ * position its contents to take the overscan area into account.
+ */
+ public static final int FLAG_LAYOUT_IN_OVERSCAN = 0x02000000;
+
// ----- HIDDEN FLAGS.
// These start at the high bit and go down.
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java
index b5d216a..192eded 100644
--- a/core/java/android/view/WindowManagerPolicy.java
+++ b/core/java/android/view/WindowManagerPolicy.java
@@ -458,6 +458,12 @@
public void setInitialDisplaySize(Display display, int width, int height, int density);
/**
+ * Called by window manager to set the overscan region that should be used for the
+ * given display.
+ */
+ public void setDisplayOverscan(Display display, int left, int top, int right, int bottom);
+
+ /**
* Check permissions when adding a window.
*
* @param attrs The window's LayoutParams.
diff --git a/core/java/android/webkit/WebViewClassic.java b/core/java/android/webkit/WebViewClassic.java
index a4347a4..3ded1cd 100644
--- a/core/java/android/webkit/WebViewClassic.java
+++ b/core/java/android/webkit/WebViewClassic.java
@@ -1254,6 +1254,40 @@
mAutoFillData = new WebViewCore.AutoFillData();
mEditTextScroller = new Scroller(context);
+
+ // Calculate channel distance
+ calculateChannelDistance(context);
+ }
+
+ /**
+ * Calculate sChannelDistance based on the screen information.
+ * @param context A Context object used to access application assets.
+ */
+ private void calculateChannelDistance(Context context) {
+ // The channel distance is adjusted for density and screen size
+ final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
+ final double screenSize = Math.hypot((double)(metrics.widthPixels/metrics.densityDpi),
+ (double)(metrics.heightPixels/metrics.densityDpi));
+ if (screenSize < 3.0) {
+ sChannelDistance = 16;
+ } else if (screenSize < 5.0) {
+ sChannelDistance = 22;
+ } else if (screenSize < 7.0) {
+ sChannelDistance = 28;
+ } else {
+ sChannelDistance = 34;
+ }
+ sChannelDistance = (int)(sChannelDistance * metrics.density);
+ if (sChannelDistance < 16) sChannelDistance = 16;
+
+ if (DebugFlags.WEB_VIEW) {
+ Log.v(LOGTAG, "sChannelDistance : " + sChannelDistance
+ + ", density : " + metrics.density
+ + ", screenSize : " + screenSize
+ + ", metrics.heightPixels : " + metrics.heightPixels
+ + ", metrics.widthPixels : " + metrics.widthPixels
+ + ", metrics.densityDpi : " + metrics.densityDpi);
+ }
}
// WebViewProvider bindings
@@ -5718,32 +5752,13 @@
}
return mWebViewPrivate.super_dispatchKeyEvent(event);
}
-
- /*
- * Here is the snap align logic:
- * 1. If it starts nearly horizontally or vertically, snap align;
- * 2. If there is a dramitic direction change, let it go;
- *
- * Adjustable parameters. Angle is the radians on a unit circle, limited
- * to quadrant 1. Values range from 0f (horizontal) to PI/2 (vertical)
- */
- private static final float HSLOPE_TO_START_SNAP = .25f;
- private static final float HSLOPE_TO_BREAK_SNAP = .4f;
- private static final float VSLOPE_TO_START_SNAP = 1.25f;
- private static final float VSLOPE_TO_BREAK_SNAP = .95f;
- /*
- * These values are used to influence the average angle when entering
- * snap mode. If is is the first movement entering snap, we set the average
- * to the appropriate ideal. If the user is entering into snap after the
- * first movement, then we average the average angle with these values.
- */
- private static final float ANGLE_VERT = 2f;
- private static final float ANGLE_HORIZ = 0f;
- /*
- * The modified moving average weight.
- * Formula: MAV[t]=MAV[t-1] + (P[t]-MAV[t-1])/n
- */
- private static final float MMA_WEIGHT_N = 5;
+
+ private static final int SNAP_BOUND = 16;
+ private static int sChannelDistance = 16;
+ private int mFirstTouchX = -1; // the first touched point
+ private int mFirstTouchY = -1;
+ private int mDistanceX = 0;
+ private int mDistanceY = 0;
private boolean inFullScreenMode() {
return mFullScreenHolder != null;
@@ -5833,12 +5848,6 @@
}
}
- private float calculateDragAngle(int dx, int dy) {
- dx = Math.abs(dx);
- dy = Math.abs(dy);
- return (float) Math.atan2(dy, dx);
- }
-
/*
* Common code for single touch and multi-touch.
* (x, y) denotes current focus point, which is the touch point for single touch
@@ -5864,6 +5873,12 @@
switch (action) {
case MotionEvent.ACTION_DOWN: {
mConfirmMove = false;
+
+ // Channel Scrolling
+ mFirstTouchX = x;
+ mFirstTouchY = y;
+ mDistanceX = mDistanceY = 0;
+
if (!mEditTextScroller.isFinished()) {
mEditTextScroller.abortAnimation();
}
@@ -6001,20 +6016,16 @@
break;
}
- // Only lock dragging to one axis if we don't have a scale in progress.
- // Scaling implies free-roaming movement. Note this is only ever a question
- // if mZoomManager.supportsPanDuringZoom() is true.
- mAverageAngle = calculateDragAngle(deltaX, deltaY);
- if (detector == null || !detector.isInProgress()) {
- // if it starts nearly horizontal or vertical, enforce it
- if (mAverageAngle < HSLOPE_TO_START_SNAP) {
- mSnapScrollMode = SNAP_X;
- mSnapPositive = deltaX > 0;
- mAverageAngle = ANGLE_HORIZ;
- } else if (mAverageAngle > VSLOPE_TO_START_SNAP) {
+ if ((detector == null || !detector.isInProgress())
+ && SNAP_NONE == mSnapScrollMode) {
+ int ax = Math.abs(x - mFirstTouchX);
+ int ay = Math.abs(y - mFirstTouchY);
+ if (ax < SNAP_BOUND && ay < SNAP_BOUND) {
+ break;
+ } else if (ax < SNAP_BOUND) {
mSnapScrollMode = SNAP_Y;
- mSnapPositive = deltaY > 0;
- mAverageAngle = ANGLE_VERT;
+ } else if (ay < SNAP_BOUND) {
+ mSnapScrollMode = SNAP_X;
}
}
@@ -6033,31 +6044,21 @@
if (deltaX == 0 && deltaY == 0) {
keepScrollBarsVisible = true;
} else {
- mAverageAngle +=
- (calculateDragAngle(deltaX, deltaY) - mAverageAngle)
- / MMA_WEIGHT_N;
- if (mSnapScrollMode != SNAP_NONE) {
- if (mSnapScrollMode == SNAP_Y) {
- // radical change means getting out of snap mode
- if (mAverageAngle < VSLOPE_TO_BREAK_SNAP) {
- mSnapScrollMode = SNAP_NONE;
- }
- }
+ if (mSnapScrollMode == SNAP_X || mSnapScrollMode == SNAP_Y) {
+ mDistanceX += Math.abs(deltaX);
+ mDistanceY += Math.abs(deltaY);
if (mSnapScrollMode == SNAP_X) {
- // radical change means getting out of snap mode
- if (mAverageAngle > HSLOPE_TO_BREAK_SNAP) {
+ if (mDistanceY > sChannelDistance) {
mSnapScrollMode = SNAP_NONE;
- }
+ } else if (mDistanceX > sChannelDistance) {
+ mDistanceX = mDistanceY = 0;
}
} else {
- if (mAverageAngle < HSLOPE_TO_START_SNAP) {
- mSnapScrollMode = SNAP_X;
- mSnapPositive = deltaX > 0;
- mAverageAngle = (mAverageAngle + ANGLE_HORIZ) / 2;
- } else if (mAverageAngle > VSLOPE_TO_START_SNAP) {
- mSnapScrollMode = SNAP_Y;
- mSnapPositive = deltaY > 0;
- mAverageAngle = (mAverageAngle + ANGLE_VERT) / 2;
+ if (mDistanceX > sChannelDistance) {
+ mSnapScrollMode = SNAP_NONE;
+ } else if (mDistanceY > sChannelDistance) {
+ mDistanceX = mDistanceY = 0;
+ }
}
}
if (mSnapScrollMode != SNAP_NONE) {
@@ -6092,6 +6093,7 @@
break;
}
case MotionEvent.ACTION_UP: {
+ mFirstTouchX = mFirstTouchY = -1;
if (mIsEditingText && mSelectionStarted) {
endScrollEdit();
mPrivateHandler.sendEmptyMessageDelayed(SCROLL_HANDLE_INTO_VIEW,
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index c270e9d..dc305a5 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -20,6 +20,8 @@
import com.android.internal.widget.EditableInputConnection;
import android.R;
+import android.app.PendingIntent;
+import android.app.PendingIntent.CanceledException;
import android.content.ClipData;
import android.content.ClipData.Item;
import android.content.Context;
@@ -1314,7 +1316,7 @@
blockDisplayList = mTextDisplayLists[blockIndex] =
mTextView.getHardwareRenderer().createDisplayList("Text " + blockIndex);
} else {
- if (blockIsInvalid) blockDisplayList.invalidate();
+ if (blockIsInvalid) blockDisplayList.clear();
}
final boolean blockDisplayListIsInvalid = !blockDisplayList.isValid();
@@ -1337,19 +1339,16 @@
// Rebuild display list if it is invalid
if (blockDisplayListIsInvalid) {
- final HardwareCanvas hardwareCanvas = blockDisplayList.start();
+ final HardwareCanvas hardwareCanvas = blockDisplayList.start(
+ right - left, bottom - top);
try {
- // Tighten the bounds of the viewport to the actual text size
- hardwareCanvas.setViewport(right - left, bottom - top);
- // The dirty rect should always be null for a display list
- hardwareCanvas.onPreDraw(null);
- // drawText is always relative to TextView's origin, this translation brings
- // this range of text back to the top left corner of the viewport
+ // drawText is always relative to TextView's origin, this translation
+ // brings this range of text back to the top left corner of the viewport
hardwareCanvas.translate(-left, -top);
layout.drawText(hardwareCanvas, blockBeginLine, blockEndLine);
- // No need to untranslate, previous context is popped after drawDisplayList
+ // No need to untranslate, previous context is popped after
+ // drawDisplayList
} finally {
- hardwareCanvas.onPostDraw();
blockDisplayList.end();
// Same as drawDisplayList below, handled by our TextView's parent
blockDisplayList.setClipChildren(false);
@@ -1430,7 +1429,7 @@
while (i < numberOfBlocks) {
final int blockIndex = blockIndices[i];
if (blockIndex != DynamicLayout.INVALID_BLOCK_INDEX) {
- mTextDisplayLists[blockIndex].invalidate();
+ mTextDisplayLists[blockIndex].clear();
}
if (blockEndLines[i] >= lastLine) break;
i++;
@@ -1441,7 +1440,7 @@
void invalidateTextDisplayList() {
if (mTextDisplayLists != null) {
for (int i = 0; i < mTextDisplayLists.length; i++) {
- if (mTextDisplayLists[i] != null) mTextDisplayLists[i].invalidate();
+ if (mTextDisplayLists[i] != null) mTextDisplayLists[i].clear();
}
}
}
@@ -1893,10 +1892,23 @@
// Make sure there is only at most one EasyEditSpan in the text
if (mPopupWindow.mEasyEditSpan != null) {
- text.removeSpan(mPopupWindow.mEasyEditSpan);
+ mPopupWindow.mEasyEditSpan.setDeleteEnabled(false);
}
mPopupWindow.setEasyEditSpan((EasyEditSpan) span);
+ mPopupWindow.setOnDeleteListener(new EasyEditDeleteListener() {
+ @Override
+ public void onDeleteClick(EasyEditSpan span) {
+ Editable editable = (Editable) mTextView.getText();
+ int start = editable.getSpanStart(span);
+ int end = editable.getSpanEnd(span);
+ if (start >= 0 && end >= 0) {
+ sendNotification(EasyEditSpan.TEXT_DELETED, span);
+ mTextView.deleteText_internal(start, end);
+ }
+ editable.removeSpan(span);
+ }
+ });
if (mTextView.getWindowVisibility() != View.VISIBLE) {
// The window is not visible yet, ignore the text change.
@@ -1930,8 +1942,10 @@
@Override
public void onSpanChanged(Spannable text, Object span, int previousStart, int previousEnd,
int newStart, int newEnd) {
- if (mPopupWindow != null && span == mPopupWindow.mEasyEditSpan) {
- text.removeSpan(mPopupWindow.mEasyEditSpan);
+ if (mPopupWindow != null && span instanceof EasyEditSpan) {
+ EasyEditSpan easyEditSpan = (EasyEditSpan) span;
+ sendNotification(EasyEditSpan.TEXT_MODIFIED, easyEditSpan);
+ text.removeSpan(easyEditSpan);
}
}
@@ -1941,6 +1955,31 @@
mTextView.removeCallbacks(mHidePopup);
}
}
+
+ private void sendNotification(int textChangedType, EasyEditSpan span) {
+ try {
+ PendingIntent pendingIntent = span.getPendingIntent();
+ if (pendingIntent != null) {
+ Intent intent = new Intent();
+ intent.putExtra(EasyEditSpan.EXTRA_TEXT_CHANGED_TYPE, textChangedType);
+ pendingIntent.send(mTextView.getContext(), 0, intent);
+ }
+ } catch (CanceledException e) {
+ // This should not happen, as we should try to send the intent only once.
+ Log.w(TAG, "PendingIntent for notification cannot be sent", e);
+ }
+ }
+ }
+
+ /**
+ * Listens for the delete event triggered by {@link EasyEditPopupWindow}.
+ */
+ private interface EasyEditDeleteListener {
+
+ /**
+ * Clicks the delete pop-up.
+ */
+ void onDeleteClick(EasyEditSpan span);
}
/**
@@ -1953,6 +1992,7 @@
com.android.internal.R.layout.text_edit_action_popup_text;
private TextView mDeleteTextView;
private EasyEditSpan mEasyEditSpan;
+ private EasyEditDeleteListener mOnDeleteListener;
@Override
protected void createPopupWindow() {
@@ -1987,19 +2027,29 @@
mEasyEditSpan = easyEditSpan;
}
+ private void setOnDeleteListener(EasyEditDeleteListener listener) {
+ mOnDeleteListener = listener;
+ }
+
@Override
public void onClick(View view) {
- if (view == mDeleteTextView) {
- Editable editable = (Editable) mTextView.getText();
- int start = editable.getSpanStart(mEasyEditSpan);
- int end = editable.getSpanEnd(mEasyEditSpan);
- if (start >= 0 && end >= 0) {
- mTextView.deleteText_internal(start, end);
- }
+ if (view == mDeleteTextView
+ && mEasyEditSpan != null && mEasyEditSpan.isDeleteEnabled()
+ && mOnDeleteListener != null) {
+ mOnDeleteListener.onDeleteClick(mEasyEditSpan);
}
}
@Override
+ public void hide() {
+ if (mEasyEditSpan != null) {
+ mEasyEditSpan.setDeleteEnabled(false);
+ }
+ mOnDeleteListener = null;
+ super.hide();
+ }
+
+ @Override
protected int getTextOffset() {
// Place the pop-up at the end of the span
Editable editable = (Editable) mTextView.getText();
diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp
index 80573a7..a6bb7c7 100644
--- a/core/jni/android_view_GLES20Canvas.cpp
+++ b/core/jni/android_view_GLES20Canvas.cpp
@@ -41,6 +41,7 @@
#include <SkTemplates.h>
#include <SkXfermode.h>
+#include <DisplayList.h>
#include <DisplayListRenderer.h>
#include <LayerRenderer.h>
#include <OpenGLRenderer.h>
@@ -716,20 +717,6 @@
return renderer->getDisplayList(displayList);
}
-static jint android_view_GLES20Canvas_getDisplayListSize(JNIEnv* env,
- jobject clazz, DisplayList* displayList) {
- return displayList->getSize();
-}
-
-static void android_view_GLES20Canvas_setDisplayListName(JNIEnv* env,
- jobject clazz, DisplayList* displayList, jstring name) {
- if (name != NULL) {
- const char* textArray = env->GetStringUTFChars(name, NULL);
- displayList->setName(textArray);
- env->ReleaseStringUTFChars(name, textArray);
- }
-}
-
static OpenGLRenderer* android_view_GLES20Canvas_createDisplayListRenderer(JNIEnv* env,
jobject clazz) {
return new DisplayListRenderer;
@@ -740,11 +727,6 @@
renderer->reset();
}
-static void android_view_GLES20Canvas_destroyDisplayList(JNIEnv* env,
- jobject clazz, DisplayList* displayList) {
- DisplayList::destroyDisplayListDeferred(displayList);
-}
-
static jint android_view_GLES20Canvas_drawDisplayList(JNIEnv* env,
jobject clazz, OpenGLRenderer* renderer, DisplayList* displayList,
jobject dirty, jint flags) {
@@ -1044,17 +1026,13 @@
(void*) android_view_GLES20Canvas_getClipBounds },
{ "nGetDisplayList", "(II)I", (void*) android_view_GLES20Canvas_getDisplayList },
- { "nDestroyDisplayList", "(I)V", (void*) android_view_GLES20Canvas_destroyDisplayList },
- { "nGetDisplayListSize", "(I)I", (void*) android_view_GLES20Canvas_getDisplayListSize },
- { "nSetDisplayListName", "(ILjava/lang/String;)V",
- (void*) android_view_GLES20Canvas_setDisplayListName },
+ { "nOutputDisplayList", "(II)V", (void*) android_view_GLES20Canvas_outputDisplayList },
{ "nDrawDisplayList", "(IILandroid/graphics/Rect;I)I",
(void*) android_view_GLES20Canvas_drawDisplayList },
{ "nCreateDisplayListRenderer", "()I", (void*) android_view_GLES20Canvas_createDisplayListRenderer },
{ "nResetDisplayListRenderer", "(I)V", (void*) android_view_GLES20Canvas_resetDisplayListRenderer },
- { "nOutputDisplayList", "(II)V", (void*) android_view_GLES20Canvas_outputDisplayList },
{ "nInterrupt", "(I)V", (void*) android_view_GLES20Canvas_interrupt },
{ "nResume", "(I)V", (void*) android_view_GLES20Canvas_resume },
diff --git a/core/jni/android_view_GLES20DisplayList.cpp b/core/jni/android_view_GLES20DisplayList.cpp
index c5f52df..f7a5302 100644
--- a/core/jni/android_view_GLES20DisplayList.cpp
+++ b/core/jni/android_view_GLES20DisplayList.cpp
@@ -23,6 +23,7 @@
#include <nativehelper/JNIHelp.h>
#include <android_runtime/AndroidRuntime.h>
+#include <DisplayList.h>
#include <DisplayListRenderer.h>
namespace android {
@@ -36,11 +37,34 @@
*/
#ifdef USE_OPENGL_RENDERER
+// ----------------------------------------------------------------------------
+// DisplayList view properties
+// ----------------------------------------------------------------------------
+
static void android_view_GLES20DisplayList_reset(JNIEnv* env,
jobject clazz, DisplayList* displayList) {
displayList->reset();
}
+static jint android_view_GLES20DisplayList_getDisplayListSize(JNIEnv* env,
+ jobject clazz, DisplayList* displayList) {
+ return displayList->getSize();
+}
+
+static void android_view_GLES20DisplayList_setDisplayListName(JNIEnv* env,
+ jobject clazz, DisplayList* displayList, jstring name) {
+ if (name != NULL) {
+ const char* textArray = env->GetStringUTFChars(name, NULL);
+ displayList->setName(textArray);
+ env->ReleaseStringUTFChars(name, textArray);
+ }
+}
+
+static void android_view_GLES20DisplayList_destroyDisplayList(JNIEnv* env,
+ jobject clazz, DisplayList* displayList) {
+ DisplayList::destroyDisplayListDeferred(displayList);
+}
+
// ----------------------------------------------------------------------------
// DisplayList view properties
// ----------------------------------------------------------------------------
@@ -159,27 +183,112 @@
displayList->setBottom(bottom);
}
-static void android_view_GLES20DisplayList_setLeftTop(JNIEnv* env,
- jobject clazz, DisplayList* displayList, int left, int top) {
- displayList->setLeftTop(left, top);
-}
-
static void android_view_GLES20DisplayList_setLeftTopRightBottom(JNIEnv* env,
jobject clazz, DisplayList* displayList, int left, int top,
int right, int bottom) {
displayList->setLeftTopRightBottom(left, top, right, bottom);
}
-static void android_view_GLES20DisplayList_offsetLeftRight(JNIEnv* env,
- jobject clazz, DisplayList* displayList, int offset) {
+static void android_view_GLES20DisplayList_offsetLeftAndRight(JNIEnv* env,
+ jobject clazz, DisplayList* displayList, float offset) {
displayList->offsetLeftRight(offset);
}
-static void android_view_GLES20DisplayList_offsetTopBottom(JNIEnv* env,
- jobject clazz, DisplayList* displayList, int offset) {
+static void android_view_GLES20DisplayList_offsetTopAndBottom(JNIEnv* env,
+ jobject clazz, DisplayList* displayList, float offset) {
displayList->offsetTopBottom(offset);
}
+static void android_view_GLES20DisplayList_getMatrix(JNIEnv* env,
+ jobject clazz, DisplayList* displayList, SkMatrix* matrix) {
+ SkMatrix* source = displayList->getStaticMatrix();
+ if (source) {
+ matrix->setConcat(SkMatrix::I(), *source);
+ } else {
+ matrix->setIdentity();
+ }
+}
+
+static jboolean android_view_GLES20DisplayList_hasOverlappingRendering(JNIEnv* env,
+ jobject clazz, DisplayList* displayList) {
+ return displayList->hasOverlappingRendering();
+}
+
+static jfloat android_view_GLES20DisplayList_getAlpha(JNIEnv* env,
+ jobject clazz, DisplayList* displayList) {
+ return displayList->getAlpha();
+}
+
+static jfloat android_view_GLES20DisplayList_getLeft(JNIEnv* env,
+ jobject clazz, DisplayList* displayList) {
+ return displayList->getLeft();
+}
+
+static jfloat android_view_GLES20DisplayList_getTop(JNIEnv* env,
+ jobject clazz, DisplayList* displayList) {
+ return displayList->getTop();
+}
+
+static jfloat android_view_GLES20DisplayList_getRight(JNIEnv* env,
+ jobject clazz, DisplayList* displayList) {
+ return displayList->getRight();
+}
+
+static jfloat android_view_GLES20DisplayList_getBottom(JNIEnv* env,
+ jobject clazz, DisplayList* displayList) {
+ return displayList->getBottom();
+}
+
+static jfloat android_view_GLES20DisplayList_getCameraDistance(JNIEnv* env,
+ jobject clazz, DisplayList* displayList) {
+ return displayList->getCameraDistance();
+}
+
+static jfloat android_view_GLES20DisplayList_getScaleX(JNIEnv* env,
+ jobject clazz, DisplayList* displayList) {
+ return displayList->getScaleX();
+}
+
+static jfloat android_view_GLES20DisplayList_getScaleY(JNIEnv* env,
+ jobject clazz, DisplayList* displayList) {
+ return displayList->getScaleY();
+}
+
+static jfloat android_view_GLES20DisplayList_getTranslationX(JNIEnv* env,
+ jobject clazz, DisplayList* displayList) {
+ return displayList->getTranslationX();
+}
+
+static jfloat android_view_GLES20DisplayList_getTranslationY(JNIEnv* env,
+ jobject clazz, DisplayList* displayList) {
+ return displayList->getTranslationY();
+}
+
+static jfloat android_view_GLES20DisplayList_getRotation(JNIEnv* env,
+ jobject clazz, DisplayList* displayList) {
+ return displayList->getRotation();
+}
+
+static jfloat android_view_GLES20DisplayList_getRotationX(JNIEnv* env,
+ jobject clazz, DisplayList* displayList) {
+ return displayList->getRotationX();
+}
+
+static jfloat android_view_GLES20DisplayList_getRotationY(JNIEnv* env,
+ jobject clazz, DisplayList* displayList) {
+ return displayList->getRotationY();
+}
+
+static jfloat android_view_GLES20DisplayList_getPivotX(JNIEnv* env,
+ jobject clazz, DisplayList* displayList) {
+ return displayList->getPivotX();
+}
+
+static jfloat android_view_GLES20DisplayList_getPivotY(JNIEnv* env,
+ jobject clazz, DisplayList* displayList) {
+ return displayList->getPivotY();
+}
+
#endif // USE_OPENGL_RENDERER
// ----------------------------------------------------------------------------
@@ -190,6 +299,11 @@
static JNINativeMethod gMethods[] = {
#ifdef USE_OPENGL_RENDERER
+ { "nDestroyDisplayList", "(I)V", (void*) android_view_GLES20DisplayList_destroyDisplayList },
+ { "nGetDisplayListSize", "(I)I", (void*) android_view_GLES20DisplayList_getDisplayListSize },
+ { "nSetDisplayListName", "(ILjava/lang/String;)V",
+ (void*) android_view_GLES20DisplayList_setDisplayListName },
+
{ "nReset", "(I)V", (void*) android_view_GLES20DisplayList_reset },
{ "nSetCaching", "(IZ)V", (void*) android_view_GLES20DisplayList_setCaching },
{ "nSetStaticMatrix", "(II)V", (void*) android_view_GLES20DisplayList_setStaticMatrix },
@@ -214,12 +328,29 @@
{ "nSetTop", "(II)V", (void*) android_view_GLES20DisplayList_setTop },
{ "nSetRight", "(II)V", (void*) android_view_GLES20DisplayList_setRight },
{ "nSetBottom", "(II)V", (void*) android_view_GLES20DisplayList_setBottom },
- { "nSetLeftTop", "(III)V", (void*) android_view_GLES20DisplayList_setLeftTop },
{ "nSetLeftTopRightBottom","(IIIII)V",
(void*) android_view_GLES20DisplayList_setLeftTopRightBottom },
- { "nOffsetLeftRight", "(II)V", (void*) android_view_GLES20DisplayList_offsetLeftRight },
- { "nOffsetTopBottom", "(II)V", (void*) android_view_GLES20DisplayList_offsetTopBottom },
+ { "nOffsetLeftAndRight", "(IF)V", (void*) android_view_GLES20DisplayList_offsetLeftAndRight },
+ { "nOffsetTopAndBottom", "(IF)V", (void*) android_view_GLES20DisplayList_offsetTopAndBottom },
+
+ { "nGetMatrix", "(II)V", (void*) android_view_GLES20DisplayList_getMatrix },
+ { "nHasOverlappingRendering", "(I)Z", (void*) android_view_GLES20DisplayList_hasOverlappingRendering },
+ { "nGetAlpha", "(I)F", (void*) android_view_GLES20DisplayList_getAlpha },
+ { "nGetLeft", "(I)F", (void*) android_view_GLES20DisplayList_getLeft },
+ { "nGetTop", "(I)F", (void*) android_view_GLES20DisplayList_getTop },
+ { "nGetRight", "(I)F", (void*) android_view_GLES20DisplayList_getRight },
+ { "nGetBottom", "(I)F", (void*) android_view_GLES20DisplayList_getBottom },
+ { "nGetCameraDistance", "(I)F", (void*) android_view_GLES20DisplayList_getCameraDistance },
+ { "nGetScaleX", "(I)F", (void*) android_view_GLES20DisplayList_getScaleX },
+ { "nGetScaleY", "(I)F", (void*) android_view_GLES20DisplayList_getScaleY },
+ { "nGetTranslationX", "(I)F", (void*) android_view_GLES20DisplayList_getTranslationX },
+ { "nGetTranslationY", "(I)F", (void*) android_view_GLES20DisplayList_getTranslationY },
+ { "nGetRotation", "(I)F", (void*) android_view_GLES20DisplayList_getRotation },
+ { "nGetRotationX", "(I)F", (void*) android_view_GLES20DisplayList_getRotationX },
+ { "nGetRotationY", "(I)F", (void*) android_view_GLES20DisplayList_getRotationY },
+ { "nGetPivotX", "(I)F", (void*) android_view_GLES20DisplayList_getPivotX },
+ { "nGetPivotY", "(I)F", (void*) android_view_GLES20DisplayList_getPivotY },
#endif
};
diff --git a/core/res/res/values-vi/strings.xml b/core/res/res/values-vi/strings.xml
index 70797cb..7edb530 100644
--- a/core/res/res/values-vi/strings.xml
+++ b/core/res/res/values-vi/strings.xml
@@ -776,7 +776,7 @@
<string name="lockscreen_password_wrong" msgid="5737815393253165301">"Thử lại"</string>
<string name="faceunlock_multiple_failures" msgid="754137583022792429">"Đã vượt quá số lần Mở khóa bằng khuôn mặt tối đa"</string>
<string name="lockscreen_plugged_in" msgid="8057762828355572315">"Đang sạc, <xliff:g id="NUMBER">%d</xliff:g><xliff:g id="PERCENT">%%</xliff:g>"</string>
- <string name="lockscreen_charged" msgid="321635745684060624">"Bị tính phí"</string>
+ <string name="lockscreen_charged" msgid="321635745684060624">"Pin đầy"</string>
<string name="lockscreen_battery_short" msgid="4477264849386850266">"<xliff:g id="NUMBER">%d</xliff:g><xliff:g id="PERCENT">%%</xliff:g>"</string>
<string name="lockscreen_low_battery" msgid="1482873981919249740">"Kết nối bộ sạc của bạn."</string>
<string name="lockscreen_missing_sim_message_short" msgid="5099439277819215399">"Không có thẻ SIM nào"</string>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index a3e5b2c..c73ff81 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -312,6 +312,8 @@
<attr name="windowNoTitle" format="boolean" />
<!-- Flag indicating whether this window should fill the entire screen. -->
<attr name="windowFullscreen" format="boolean" />
+ <!-- Flag indicating whether this window should extend into overscan region. -->
+ <attr name="windowOverscan" format="boolean" />
<!-- Flag indicating whether this is a floating window. -->
<attr name="windowIsFloating" format="boolean" />
<!-- Flag indicating whether this is a translucent window. -->
@@ -1562,6 +1564,7 @@
<attr name="windowFrame" />
<attr name="windowNoTitle" />
<attr name="windowFullscreen" />
+ <attr name="windowOverscan" />
<attr name="windowIsFloating" />
<attr name="windowIsTranslucent" />
<attr name="windowShowWallpaper" />
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 0d80082..42e5cf1 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -2036,4 +2036,18 @@
<public type="attr" name="mipMap" id="0x010103cd" />
<public type="attr" name="mirrorForRtl" id="0x010103ce" />
+ <!-- ===============================================================
+ Resources added in version 19 of the platform
+ =============================================================== -->
+ <eat-comment />
+
+ <public type="attr" name="windowOverscan" />
+ <public type="style" name="Theme.NoTitleBar.Overscan" />
+ <public type="style" name="Theme.Light.NoTitleBar.Overscan" />
+ <public type="style" name="Theme.Black.NoTitleBar.Overscan" />
+ <public type="style" name="Theme.Holo.NoActionBar.Overscan" />
+ <public type="style" name="Theme.Holo.Light.NoActionBar.Overscan" />
+ <public type="style" name="Theme.DeviceDefault.NoActionBar.Overscan" />
+ <public type="style" name="Theme.DeviceDefault.Light.NoActionBar.Overscan" />
+
</resources>
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index 75850dd..411419b 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -166,6 +166,7 @@
<item name="windowFrame">@null</item>
<item name="windowNoTitle">false</item>
<item name="windowFullscreen">false</item>
+ <item name="windowOverscan">false</item>
<item name="windowIsFloating">false</item>
<item name="windowContentOverlay">@null</item>
<item name="windowShowWallpaper">false</item>
@@ -403,6 +404,14 @@
<item name="android:windowContentOverlay">@null</item>
</style>
+ <!-- Variant of {@link #Theme} that has no title bar and no status bar and extending
+ into the display overscan region. -->
+ <style name="Theme.NoTitleBar.Overscan">
+ <item name="android:windowFullscreen">true</item>
+ <item name="android:windowOverscan">true</item>
+ <item name="android:windowContentOverlay">@null</item>
+ </style>
+
<!-- Theme for a light background with dark text on top. Set your activity
to this theme if you would like such an appearance. As with the
default theme, you should try to assume little more than that the
@@ -495,6 +504,14 @@
<item name="android:windowContentOverlay">@null</item>
</style>
+ <!-- Variant of {@link #Theme_Light} that has no title bar and
+ no status bar and extending into the display overscan region. -->
+ <style name="Theme.Light.NoTitleBar.Overscan">
+ <item name="android:windowFullscreen">true</item>
+ <item name="android:windowOverscan">true</item>
+ <item name="android:windowContentOverlay">@null</item>
+ </style>
+
<!-- Variant on {@link #Theme} that ensures the background is
completely black. This is useful for things like image viewers and
media players. If you want the normal (dark background) theme
@@ -516,6 +533,14 @@
<item name="android:windowContentOverlay">@null</item>
</style>
+ <!-- Variant of {@link #Theme_Black} that has no title bar and
+ no status bar and extending into the display overscan region. -->
+ <style name="Theme.Black.NoTitleBar.Overscan">
+ <item name="android:windowFullscreen">true</item>
+ <item name="android:windowOverscan">true</item>
+ <item name="android:windowContentOverlay">@null</item>
+ </style>
+
<!-- Theme for windows that want to have the user's selected
wallpaper appear behind them (for API level 10 and lower). -->
<style name="Theme.Wallpaper">
@@ -1010,6 +1035,7 @@
<item name="windowFrame">@null</item>
<item name="windowNoTitle">false</item>
<item name="windowFullscreen">false</item>
+ <item name="windowOverscan">false</item>
<item name="windowIsFloating">false</item>
<item name="windowContentOverlay">@null</item>
<item name="windowShowWallpaper">false</item>
@@ -1324,6 +1350,7 @@
<item name="windowFrame">@null</item>
<item name="windowNoTitle">false</item>
<item name="windowFullscreen">false</item>
+ <item name="windowOverscan">false</item>
<item name="windowIsFloating">false</item>
<item name="android:windowContentOverlay">@android:drawable/ab_solid_shadow_holo</item>
<item name="windowShowWallpaper">false</item>
@@ -1563,6 +1590,14 @@
<item name="android:windowContentOverlay">@null</item>
</style>
+ <!-- Variant of the holographic (dark) theme that has no title bar and fills
+ the entire screen and extends into the display overscan region. -->
+ <style name="Theme.Holo.NoActionBar.Overscan">
+ <item name="android:windowFullscreen">true</item>
+ <item name="android:windowOverscan">true</item>
+ <item name="android:windowContentOverlay">@null</item>
+ </style>
+
<!-- Variant of the holographic (light) theme with no action bar. -->
<style name="Theme.Holo.Light.NoActionBar">
<item name="android:windowActionBar">false</item>
@@ -1576,6 +1611,14 @@
<item name="android:windowContentOverlay">@null</item>
</style>
+ <!-- Variant of the holographic (light) theme that has no title bar and fills
+ the entire screen and extends into the display overscan region. -->
+ <style name="Theme.Holo.Light.NoActionBar.Overscan">
+ <item name="android:windowFullscreen">true</item>
+ <item name="android:windowOverscan">true</item>
+ <item name="android:windowContentOverlay">@null</item>
+ </style>
+
<!-- Dialog themes for Holo -->
<eat-comment />
diff --git a/core/res/res/values/themes_device_defaults.xml b/core/res/res/values/themes_device_defaults.xml
index 4178cc4..71aa5e6 100644
--- a/core/res/res/values/themes_device_defaults.xml
+++ b/core/res/res/values/themes_device_defaults.xml
@@ -202,12 +202,17 @@
<!-- Variant of {@link #Theme_DeviceDefault} with no action bar -->
<style name="Theme.DeviceDefault.NoActionBar" parent="Theme.Holo.NoActionBar" >
-
</style>
+
<!-- Variant of {@link #Theme_DeviceDefault} with no action bar and no status bar -->
<style name="Theme.DeviceDefault.NoActionBar.Fullscreen" parent="Theme.Holo.NoActionBar.Fullscreen" >
-
</style>
+
+ <!-- Variant of {@link #Theme_DeviceDefault} with no action bar and no status bar and
+ extending in to overscan region. -->
+ <style name="Theme.DeviceDefault.NoActionBar.Overscan" parent="Theme.Holo.NoActionBar.Overscan" >
+ </style>
+
<!-- Variant of {@link #Theme_DeviceDefault} with a light-colored style -->
<style name="Theme.DeviceDefault.Light" parent="Theme.Holo.Light" >
<!-- Text styles -->
@@ -356,11 +361,14 @@
</style>
<!-- Variant of {@link #Theme_DeviceDefault_Light} with no action bar -->
<style name="Theme.DeviceDefault.Light.NoActionBar" parent="Theme.Holo.Light.NoActionBar" >
-
</style>
<!-- Variant of {@link #Theme_DeviceDefault_Light} with no action bar and no status bar -->
<style name="Theme.DeviceDefault.Light.NoActionBar.Fullscreen" parent="Theme.Holo.Light.NoActionBar.Fullscreen" >
-
+ </style>
+ <!-- Variant of {@link #Theme_DeviceDefault_Light} with no action bar and no status bar
+ and extending in to overscan region-->
+ <style name="Theme.DeviceDefault.Light.NoActionBar.Overscan"
+ parent="Theme.Holo.Light.NoActionBar.Overscan" >
</style>
<!-- DeviceDefault theme for dialog windows and activities. This changes the window to be
floating (not fill the entire screen), and puts a frame around its contents. You can set this
diff --git a/docs/html/distribute/googleplay/promote/badges.jd b/docs/html/distribute/googleplay/promote/badges.jd
index 23a116d..738e76b 100644
--- a/docs/html/distribute/googleplay/promote/badges.jd
+++ b/docs/html/distribute/googleplay/promote/badges.jd
@@ -86,10 +86,11 @@
if (form["package"].value != "com.example.android") {
$("#preview").show();
- $("#snippet").show().html(linkStartCode + "apps/details?id=" + form["package"].value
+ var packageName = escapeHTML(form["package"].value);
+ $("#snippet").show().html(linkStartCode + "apps/details?id=" + packageName
+ imageStartCode + altText + imageSrcCode
+ selectedValue + imageEndCode);
- $("#button-preview").html(linkStart + "apps/details?id=" + form["package"].value
+ $("#button-preview").html(linkStart + "apps/details?id=" + packageName
+ imageStart + altText + imageSrc
+ selectedValue + imageEnd);
@@ -97,10 +98,11 @@
_gaq.push(['_trackEvent', 'Distribute', 'Create Google Play Badge', 'Package ' + selectedValue]);
} else if (form["publisher"].value != "Example, Inc.") {
$("#preview").show();
- $("#snippet").show().html(linkStartCode + "search?q=pub:" + form["publisher"].value
+ var publisherName = escapeHTML(form["publisher"].value);
+ $("#snippet").show().html(linkStartCode + "search?q=pub:" + publisherName
+ imageStartCode + altText + imageSrcCode
+ selectedValue + imageEndCode);
- $("#button-preview").html(linkStart + "search?q=pub:" + form["publisher"].value
+ $("#button-preview").html(linkStart + "search?q=pub:" + publisherName
+ imageStart + altText + imageSrc
+ selectedValue + imageEnd);
diff --git a/libs/hwui/Android.mk b/libs/hwui/Android.mk
index db64c99..5f2a4d5 100644
--- a/libs/hwui/Android.mk
+++ b/libs/hwui/Android.mk
@@ -12,6 +12,7 @@
GammaFontRenderer.cpp \
Caches.cpp \
DisplayList.cpp \
+ DeferredDisplayList.cpp \
DisplayListLogBuffer.cpp \
DisplayListRenderer.cpp \
Dither.cpp \
diff --git a/libs/hwui/Debug.h b/libs/hwui/Debug.h
index 20eb5e1..9a6494f 100644
--- a/libs/hwui/Debug.h
+++ b/libs/hwui/Debug.h
@@ -74,6 +74,9 @@
// Turn on to enable additional debugging in the font renderers
#define DEBUG_FONT_RENDERER 0
+// Turn on to log draw operation batching and deferral information
+#define DEBUG_DEFER 0
+
// Turn on to dump display list state
#define DEBUG_DISPLAY_LIST 0
diff --git a/libs/hwui/DeferredDisplayList.cpp b/libs/hwui/DeferredDisplayList.cpp
new file mode 100644
index 0000000..8962964
--- /dev/null
+++ b/libs/hwui/DeferredDisplayList.cpp
@@ -0,0 +1,176 @@
+/*
+ * Copyright (C) 2013 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"
+#define ATRACE_TAG ATRACE_TAG_VIEW
+
+#include <utils/Trace.h>
+
+#include "Debug.h"
+#include "DisplayListOp.h"
+#include "OpenGLRenderer.h"
+
+#if DEBUG_DEFER
+ #define DEFER_LOGD(...) ALOGD(__VA_ARGS__)
+#else
+ #define DEFER_LOGD(...)
+#endif
+
+namespace android {
+namespace uirenderer {
+
+class DrawOpBatch {
+public:
+ DrawOpBatch() {
+ mOps.clear();
+ }
+
+ ~DrawOpBatch() {
+ mOps.clear();
+ }
+
+ void add(DrawOp* op) {
+ // NOTE: ignore empty bounds special case, since we don't merge across those ops
+ mBounds.unionWith(op->state.mBounds);
+ mOps.add(op);
+ }
+
+ bool intersects(Rect& rect) {
+ if (!rect.intersects(mBounds)) return false;
+ for (unsigned int i = 0; i < mOps.size(); i++) {
+ if (rect.intersects(mOps[i]->state.mBounds)) {
+#if DEBUG_DEFER
+ DEFER_LOGD("op intersects with op %p with bounds %f %f %f %f:", mOps[i],
+ mOps[i]->state.mBounds.left, mOps[i]->state.mBounds.top,
+ mOps[i]->state.mBounds.right, mOps[i]->state.mBounds.bottom);
+ mOps[i]->output(2);
+#endif
+ return true;
+ }
+ }
+ return false;
+ }
+
+ Vector<DrawOp*> mOps;
+private:
+ Rect mBounds;
+};
+
+void DeferredDisplayList::clear() {
+ for (int i = 0; i < kOpBatch_Count; i++) {
+ mBatchIndices[i] = -1;
+ }
+ for (unsigned int i = 0; i < mBatches.size(); i++) {
+ delete mBatches[i];
+ }
+ mBatches.clear();
+}
+
+void DeferredDisplayList::add(DrawOp* op, bool disallowReorder) {
+ if (CC_UNLIKELY(disallowReorder)) {
+ if (!mBatches.isEmpty()) {
+ mBatches[0]->add(op);
+ return;
+ }
+ DrawOpBatch* b = new DrawOpBatch();
+ b->add(op);
+ mBatches.add(b);
+ return;
+ }
+
+ // disallowReorder isn't set, so find the latest batch of the new op's type, and try to merge
+ // the new op into it
+ DrawOpBatch* targetBatch = NULL;
+ int batchId = op->getBatchId();
+
+ if (!mBatches.isEmpty()) {
+ if (op->state.mBounds.isEmpty()) {
+ // don't know the bounds for op, so add to last batch and start from scratch on next op
+ mBatches.top()->add(op);
+ for (int i = 0; i < kOpBatch_Count; i++) {
+ mBatchIndices[i] = -1;
+ }
+#if DEBUG_DEFER
+ DEFER_LOGD("Warning: Encountered op with empty bounds, resetting batches");
+ op->output(2);
+#endif
+ return;
+ }
+
+ if (batchId >= 0 && mBatchIndices[batchId] != -1) {
+ int targetIndex = mBatchIndices[batchId];
+ targetBatch = mBatches[targetIndex];
+ // iterate back toward target to see if anything drawn since should overlap the new op
+ for (int i = mBatches.size() - 1; i > targetIndex; i--) {
+ DrawOpBatch* overBatch = mBatches[i];
+ if (overBatch->intersects(op->state.mBounds)) {
+ targetBatch = NULL;
+#if DEBUG_DEFER
+ DEFER_LOGD("op couldn't join batch %d, was intersected by batch %d",
+ targetIndex, i);
+ op->output(2);
+#endif
+ break;
+ }
+ }
+ }
+ }
+ if (!targetBatch) {
+ targetBatch = new DrawOpBatch();
+ mBatches.add(targetBatch);
+ if (batchId >= 0) {
+ mBatchIndices[batchId] = mBatches.size() - 1;
+ }
+ }
+ targetBatch->add(op);
+}
+
+status_t DeferredDisplayList::flush(OpenGLRenderer& renderer, Rect& dirty, int32_t flags,
+ uint32_t level) {
+ ATRACE_CALL();
+ status_t status = DrawGlInfo::kStatusDone;
+
+ if (isEmpty()) return status; // nothing to flush
+
+ DEFER_LOGD("--flushing");
+ DrawModifiers restoreDrawModifiers = renderer.getDrawModifiers();
+ int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
+ int opCount = 0;
+ for (unsigned int i = 0; i < mBatches.size(); i++) {
+ DrawOpBatch* batch = mBatches[i];
+ for (unsigned int j = 0; j < batch->mOps.size(); j++) {
+ DrawOp* op = batch->mOps[j];
+
+ renderer.restoreDisplayState(op->state);
+
+#if DEBUG_DEFER
+ op->output(2);
+#endif
+ status |= op->applyDraw(renderer, dirty, level,
+ op->state.mMultipliedAlpha >= 0, op->state.mMultipliedAlpha);
+ opCount++;
+ }
+ }
+
+ DEFER_LOGD("--flushed, drew %d batches (total %d ops)", mBatches.size(), opCount);
+ renderer.restoreToCount(restoreTo);
+ renderer.setDrawModifiers(restoreDrawModifiers);
+ clear();
+ return status;
+}
+
+}; // namespace uirenderer
+}; // namespace android
diff --git a/libs/hwui/DeferredDisplayList.h b/libs/hwui/DeferredDisplayList.h
new file mode 100644
index 0000000..4fcb297
--- /dev/null
+++ b/libs/hwui/DeferredDisplayList.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+#ifndef ANDROID_HWUI_DEFERRED_DISPLAY_LIST_H
+#define ANDROID_HWUI_DEFERRED_DISPLAY_LIST_H
+
+#include <utils/Errors.h>
+#include <utils/Vector.h>
+
+#include "Matrix.h"
+#include "Rect.h"
+
+namespace android {
+namespace uirenderer {
+
+class DrawOp;
+class DrawOpBatch;
+class OpenGLRenderer;
+class SkiaShader;
+
+class DeferredDisplayList {
+public:
+ DeferredDisplayList() { clear(); }
+ ~DeferredDisplayList() { clear(); }
+
+ enum OpBatchId {
+ kOpBatch_None = -1, // Don't batch
+ kOpBatch_Bitmap,
+ kOpBatch_Patch,
+ kOpBatch_AlphaVertices,
+ kOpBatch_Vertices,
+ kOpBatch_AlphaMaskTexture,
+ kOpBatch_Text,
+ kOpBatch_ColorText,
+
+ kOpBatch_Count, // Add other batch ids before this
+ };
+
+ bool isEmpty() { return mBatches.isEmpty(); }
+
+ /**
+ * Plays back all of the draw ops recorded into batches to the renderer.
+ * Adjusts the state of the renderer as necessary, and restores it when complete
+ */
+ status_t flush(OpenGLRenderer& renderer, Rect& dirty, int32_t flags,
+ uint32_t level);
+
+ /**
+ * Add a draw op into the DeferredDisplayList, reordering as needed (for performance) if
+ * disallowReorder is false, respecting draw order when overlaps occur
+ */
+ void add(DrawOp* op, bool disallowReorder);
+
+private:
+ void clear();
+
+
+ Vector<DrawOpBatch*> mBatches;
+ int mBatchIndices[kOpBatch_Count];
+};
+
+}; // namespace uirenderer
+}; // namespace android
+
+#endif // ANDROID_HWUI_DEFERRED_DISPLAY_LIST_H
diff --git a/libs/hwui/DisplayList.cpp b/libs/hwui/DisplayList.cpp
index a52ea98..6fab8da 100644
--- a/libs/hwui/DisplayList.cpp
+++ b/libs/hwui/DisplayList.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include "Debug.h"
#include "DisplayList.h"
#include "DisplayListOp.h"
#include "DisplayListLogBuffer.h"
@@ -262,6 +263,16 @@
ALOGD("%*sDone (%p, %s)", level * 2, "", this, mName.string());
}
+float DisplayList::getPivotX() {
+ updateMatrix();
+ return mPivotX;
+}
+
+float DisplayList::getPivotY() {
+ updateMatrix();
+ return mPivotY;
+}
+
void DisplayList::updateMatrix() {
if (mMatrixDirty) {
if (!mTransformMatrix) {
@@ -386,7 +397,8 @@
}
}
-status_t DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flags, uint32_t level) {
+status_t DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flags, uint32_t level,
+ DeferredDisplayList* deferredList) {
status_t drawGlStatus = DrawGlInfo::kStatusDone;
#if DEBUG_DISPLAY_LIST
@@ -401,6 +413,12 @@
int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
DISPLAY_LIST_LOGD("%*sSave %d %d", level * 2, "",
SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag, restoreTo);
+
+ if (mAlpha < 1 && !mCaching && CC_LIKELY(deferredList)) {
+ // flush before a saveLayerAlpha/setAlpha
+ // TODO: make this cleaner
+ drawGlStatus |= deferredList->flush(renderer, dirty, flags, level);
+ }
setViewProperties(renderer, level);
if (renderer.quickRejectNoScissor(0, 0, mWidth, mHeight)) {
@@ -418,8 +436,13 @@
Caches::getInstance().eventMark(strlen(op->name()), op->name());
#endif
- drawGlStatus |= op->replay(renderer, dirty, flags,
- saveCount, level, mCaching, mMultipliedAlpha);
+ if (deferredList) {
+ drawGlStatus |= op->replay(renderer, dirty, flags,
+ saveCount, level, mCaching, mMultipliedAlpha, *deferredList);
+ } else {
+ drawGlStatus |= op->replay(renderer, dirty, flags,
+ saveCount, level, mCaching, mMultipliedAlpha);
+ }
logBuffer.writeCommand(level, op->name());
}
@@ -429,6 +452,11 @@
DISPLAY_LIST_LOGD("%*sDone (%p, %s), returning %d", (level + 1) * 2, "", this, mName.string(),
drawGlStatus);
+
+ if (!level && CC_LIKELY(deferredList)) {
+ drawGlStatus |= deferredList->flush(renderer, dirty, flags, level);
+ }
+
return drawGlStatus;
}
diff --git a/libs/hwui/DisplayList.h b/libs/hwui/DisplayList.h
index 70a9755..86c9ec0 100644
--- a/libs/hwui/DisplayList.h
+++ b/libs/hwui/DisplayList.h
@@ -44,6 +44,7 @@
namespace android {
namespace uirenderer {
+class DeferredDisplayList;
class DisplayListOp;
class DisplayListRenderer;
class OpenGLRenderer;
@@ -83,7 +84,8 @@
void initFromDisplayListRenderer(const DisplayListRenderer& recorder, bool reusing = false);
- status_t replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flags, uint32_t level = 0);
+ status_t replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flags, uint32_t level = 0,
+ DeferredDisplayList* deferredList = NULL);
void output(uint32_t level = 0);
@@ -103,6 +105,10 @@
}
}
+ const char* getName() const {
+ return mName.string();
+ }
+
void setClipChildren(bool clipChildren) {
mClipChildren = clipChildren;
}
@@ -112,6 +118,11 @@
mStaticMatrix = new SkMatrix(*matrix);
}
+ // Can return NULL
+ SkMatrix* getStaticMatrix() {
+ return mStaticMatrix;
+ }
+
void setAnimationMatrix(SkMatrix* matrix) {
delete mAnimationMatrix;
if (matrix) {
@@ -129,10 +140,18 @@
}
}
+ float getAlpha() const {
+ return mAlpha;
+ }
+
void setHasOverlappingRendering(bool hasOverlappingRendering) {
mHasOverlappingRendering = hasOverlappingRendering;
}
+ bool hasOverlappingRendering() const {
+ return mHasOverlappingRendering;
+ }
+
void setTranslationX(float translationX) {
if (translationX != mTranslationX) {
mTranslationX = translationX;
@@ -145,6 +164,10 @@
}
}
+ float getTranslationX() const {
+ return mTranslationX;
+ }
+
void setTranslationY(float translationY) {
if (translationY != mTranslationY) {
mTranslationY = translationY;
@@ -157,6 +180,10 @@
}
}
+ float getTranslationY() const {
+ return mTranslationY;
+ }
+
void setRotation(float rotation) {
if (rotation != mRotation) {
mRotation = rotation;
@@ -169,6 +196,10 @@
}
}
+ float getRotation() const {
+ return mRotation;
+ }
+
void setRotationX(float rotationX) {
if (rotationX != mRotationX) {
mRotationX = rotationX;
@@ -181,6 +212,10 @@
}
}
+ float getRotationX() const {
+ return mRotationX;
+ }
+
void setRotationY(float rotationY) {
if (rotationY != mRotationY) {
mRotationY = rotationY;
@@ -193,6 +228,10 @@
}
}
+ float getRotationY() const {
+ return mRotationY;
+ }
+
void setScaleX(float scaleX) {
if (scaleX != mScaleX) {
mScaleX = scaleX;
@@ -205,6 +244,10 @@
}
}
+ float getScaleX() const {
+ return mScaleX;
+ }
+
void setScaleY(float scaleY) {
if (scaleY != mScaleY) {
mScaleY = scaleY;
@@ -217,6 +260,10 @@
}
}
+ float getScaleY() const {
+ return mScaleY;
+ }
+
void setPivotX(float pivotX) {
mPivotX = pivotX;
mMatrixDirty = true;
@@ -228,6 +275,8 @@
mPivotExplicitlySet = true;
}
+ ANDROID_API float getPivotX();
+
void setPivotY(float pivotY) {
mPivotY = pivotY;
mMatrixDirty = true;
@@ -239,6 +288,8 @@
mPivotExplicitlySet = true;
}
+ ANDROID_API float getPivotY();
+
void setCameraDistance(float distance) {
if (distance != mCameraDistance) {
mCameraDistance = distance;
@@ -251,6 +302,10 @@
}
}
+ float getCameraDistance() const {
+ return mCameraDistance;
+ }
+
void setLeft(int left) {
if (left != mLeft) {
mLeft = left;
@@ -261,6 +316,10 @@
}
}
+ float getLeft() const {
+ return mLeft;
+ }
+
void setTop(int top) {
if (top != mTop) {
mTop = top;
@@ -271,6 +330,10 @@
}
}
+ float getTop() const {
+ return mTop;
+ }
+
void setRight(int right) {
if (right != mRight) {
mRight = right;
@@ -281,6 +344,10 @@
}
}
+ float getRight() const {
+ return mRight;
+ }
+
void setBottom(int bottom) {
if (bottom != mBottom) {
mBottom = bottom;
@@ -291,6 +358,10 @@
}
}
+ float getBottom() const {
+ return mBottom;
+ }
+
void setLeftTop(int left, int top) {
if (left != mLeft || top != mTop) {
mLeft = left;
@@ -317,7 +388,7 @@
}
}
- void offsetLeftRight(int offset) {
+ void offsetLeftRight(float offset) {
if (offset != 0) {
mLeft += offset;
mRight += offset;
@@ -327,7 +398,7 @@
}
}
- void offsetTopBottom(int offset) {
+ void offsetTopBottom(float offset) {
if (offset != 0) {
mTop += offset;
mBottom += offset;
diff --git a/libs/hwui/DisplayListOp.h b/libs/hwui/DisplayListOp.h
index 78b432c..8e80647 100644
--- a/libs/hwui/DisplayListOp.h
+++ b/libs/hwui/DisplayListOp.h
@@ -22,6 +22,7 @@
#include <private/hwui/DrawGlInfo.h>
#include "OpenGLRenderer.h"
+#include "DeferredDisplayList.h"
#include "DisplayListRenderer.h"
#include "utils/LinearAllocator.h"
@@ -43,7 +44,6 @@
#define OP_LOGS(s) OP_LOG("%s", s)
#define OP_LOG(s, ...) ALOGD( "%*s" s, level * 2, "", __VA_ARGS__ )
-
namespace android {
namespace uirenderer {
@@ -74,11 +74,15 @@
kOpLogFlag_JSON = 0x2 // TODO: add?
};
- //TODO: for draw batching, DrawOps should override a virtual sub-method, with
- // DrawOps::apply deferring operations to a different list if possible
virtual status_t replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flags, int saveCount,
uint32_t level, bool caching, int multipliedAlpha) = 0;
+ // same as replay above, but draw operations will defer into the deferredList if possible
+ // NOTE: colorfilters, paintfilters, shaders, shadow, and complex clips prevent deferral
+ virtual status_t replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flags, int saveCount,
+ uint32_t level, bool caching, int multipliedAlpha,
+ DeferredDisplayList& deferredList) = 0;
+
virtual void output(int level, uint32_t flags = 0) = 0;
// NOTE: it would be nice to declare constants and overriding the implementation in each op to
@@ -98,7 +102,28 @@
return DrawGlInfo::kStatusDone;
}
+ /**
+ * State operations are applied directly to the renderer, but can cause the deferred drawing op
+ * list to flush
+ */
+ virtual status_t replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flags, int saveCount,
+ uint32_t level, bool caching, int multipliedAlpha, DeferredDisplayList& deferredList) {
+ status_t status = DrawGlInfo::kStatusDone;
+ if (requiresDrawOpFlush()) {
+ // will be setting renderer state that affects ops in deferredList, so flush list first
+ status |= deferredList.flush(renderer, dirty, flags, level);
+ }
+ applyState(renderer, saveCount);
+ return status;
+ }
+
virtual void applyState(OpenGLRenderer& renderer, int saveCount) = 0;
+
+ /**
+ * Returns true if it affects renderer drawing state in such a way to break deferral
+ * see OpenGLRenderer::disallowDeferral()
+ */
+ virtual bool requiresDrawOpFlush() { return false; }
};
class DrawOp : public DisplayListOp {
@@ -115,6 +140,33 @@
return applyDraw(renderer, dirty, level, caching, multipliedAlpha);
}
+ /** Draw operations are stored in the deferredList with information necessary for playback */
+ virtual status_t replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flags, int saveCount,
+ uint32_t level, bool caching, int multipliedAlpha, DeferredDisplayList& deferredList) {
+ if (mQuickRejected && CC_LIKELY(flags & DisplayList::kReplayFlag_ClipChildren)) {
+ return DrawGlInfo::kStatusDone;
+ }
+
+ if (renderer.disallowDeferral()) {
+ // dispatch draw immediately, since the renderer's state is too complex for deferral
+ return applyDraw(renderer, dirty, level, caching, multipliedAlpha);
+ }
+
+ if (!caching) multipliedAlpha = -1;
+ state.mMultipliedAlpha = multipliedAlpha;
+ if (!getLocalBounds(state.mBounds)) {
+ // empty bounds signify bounds can't be calculated
+ state.mBounds.setEmpty();
+ }
+
+ if (!renderer.storeDisplayState(state)) {
+ // op wasn't quick-rejected, so defer
+ deferredList.add(this, renderer.disallowReorder());
+ }
+
+ return DrawGlInfo::kStatusDone;
+ }
+
virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
bool caching, int multipliedAlpha) = 0;
@@ -125,6 +177,19 @@
void setQuickRejected(bool quickRejected) { mQuickRejected = quickRejected; }
bool getQuickRejected() { return mQuickRejected; }
+ /** Batching disabled by default, turned on for individual ops */
+ virtual DeferredDisplayList::OpBatchId getBatchId() {
+ return DeferredDisplayList::kOpBatch_None;
+ }
+
+ float strokeWidthOutset() { return mPaint->getStrokeWidth() * 0.5f; }
+
+public:
+ /**
+ * Stores the relevant canvas state of the object between deferral and replay (if the canvas
+ * state supports being stored) See OpenGLRenderer::simpleClipAndState()
+ */
+ DeferredDisplayState state;
protected:
SkPaint* getPaint(OpenGLRenderer& renderer) {
return renderer.filterPaint(mPaint);
@@ -191,6 +256,8 @@
}
virtual const char* name() { return "RestoreToCount"; }
+ // Note: don't have to return true for requiresDrawOpFlush - even though restore can create a
+ // complex clip, the clip and matrix are overridden by DeferredDisplayList::flush()
private:
int mCount;
@@ -211,6 +278,7 @@
}
virtual const char* name() { return "SaveLayer"; }
+ virtual bool requiresDrawOpFlush() { return true; }
private:
Rect mArea;
@@ -232,6 +300,8 @@
}
virtual const char* name() { return "SaveLayerAlpha"; }
+ virtual bool requiresDrawOpFlush() { return true; }
+
private:
Rect mArea;
int mAlpha;
@@ -391,6 +461,7 @@
}
virtual const char* name() { return "ClipPath"; }
+ virtual bool requiresDrawOpFlush() { return true; }
private:
SkPath* mPath;
@@ -413,6 +484,7 @@
}
virtual const char* name() { return "ClipRegion"; }
+ virtual bool requiresDrawOpFlush() { return true; }
private:
SkRegion* mRegion;
@@ -582,6 +654,9 @@
}
virtual const char* name() { return "DrawBitmap"; }
+ virtual DeferredDisplayList::OpBatchId getBatchId() {
+ return DeferredDisplayList::kOpBatch_Bitmap;
+ }
protected:
SkBitmap* mBitmap;
@@ -606,6 +681,9 @@
}
virtual const char* name() { return "DrawBitmap"; }
+ virtual DeferredDisplayList::OpBatchId getBatchId() {
+ return DeferredDisplayList::kOpBatch_Bitmap;
+ }
private:
SkBitmap* mBitmap;
@@ -632,6 +710,9 @@
}
virtual const char* name() { return "DrawBitmapRect"; }
+ virtual DeferredDisplayList::OpBatchId getBatchId() {
+ return DeferredDisplayList::kOpBatch_Bitmap;
+ }
private:
SkBitmap* mBitmap;
@@ -654,6 +735,9 @@
}
virtual const char* name() { return "DrawBitmapData"; }
+ virtual DeferredDisplayList::OpBatchId getBatchId() {
+ return DeferredDisplayList::kOpBatch_Bitmap;
+ }
};
class DrawBitmapMeshOp : public DrawOp {
@@ -674,6 +758,9 @@
}
virtual const char* name() { return "DrawBitmapMesh"; }
+ virtual DeferredDisplayList::OpBatchId getBatchId() {
+ return DeferredDisplayList::kOpBatch_Bitmap;
+ }
private:
SkBitmap* mBitmap;
@@ -708,6 +795,9 @@
}
virtual const char* name() { return "DrawPatch"; }
+ virtual DeferredDisplayList::OpBatchId getBatchId() {
+ return DeferredDisplayList::kOpBatch_Patch;
+ }
private:
SkBitmap* mBitmap;
@@ -748,15 +838,21 @@
: DrawBoundedOp(left, top, right, bottom, paint) {};
bool getLocalBounds(Rect& localBounds) {
+ localBounds.set(mLocalBounds);
if (mPaint && mPaint->getStyle() != SkPaint::kFill_Style) {
- float outset = mPaint->getStrokeWidth() * 0.5f;
- localBounds.set(mLocalBounds.left - outset, mLocalBounds.top - outset,
- mLocalBounds.right + outset, mLocalBounds.bottom + outset);
- } else {
- localBounds.set(mLocalBounds);
+ localBounds.outset(strokeWidthOutset());
}
return true;
}
+
+ virtual DeferredDisplayList::OpBatchId getBatchId() {
+ if (mPaint->getPathEffect()) {
+ return DeferredDisplayList::kOpBatch_AlphaMaskTexture;
+ }
+ return mPaint->isAntiAlias() ?
+ DeferredDisplayList::kOpBatch_AlphaVertices :
+ DeferredDisplayList::kOpBatch_Vertices;
+ }
};
class DrawRectOp : public DrawStrokableOp {
@@ -793,6 +889,10 @@
virtual const char* name() { return "DrawRects"; }
+ virtual DeferredDisplayList::OpBatchId getBatchId() {
+ return DeferredDisplayList::kOpBatch_Vertices;
+ }
+
private:
const float* mRects;
int mCount;
@@ -912,22 +1012,24 @@
virtual const char* name() { return "DrawPath"; }
+ virtual DeferredDisplayList::OpBatchId getBatchId() {
+ return DeferredDisplayList::kOpBatch_AlphaMaskTexture;
+ }
private:
SkPath* mPath;
};
-class DrawLinesOp : public DrawOp {
+class DrawLinesOp : public DrawBoundedOp {
public:
DrawLinesOp(float* points, int count, SkPaint* paint)
- : DrawOp(paint), mPoints(points), mCount(count) {
- /* TODO: inherit from DrawBoundedOp and calculate localbounds something like:
+ : DrawBoundedOp(paint), mPoints(points), mCount(count) {
for (int i = 0; i < count; i += 2) {
mLocalBounds.left = fminf(mLocalBounds.left, points[i]);
mLocalBounds.right = fmaxf(mLocalBounds.right, points[i]);
mLocalBounds.top = fminf(mLocalBounds.top, points[i+1]);
mLocalBounds.bottom = fmaxf(mLocalBounds.bottom, points[i+1]);
}
- */
+ mLocalBounds.outset(strokeWidthOutset());
}
virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
@@ -941,6 +1043,12 @@
virtual const char* name() { return "DrawLines"; }
+ virtual DeferredDisplayList::OpBatchId getBatchId() {
+ return mPaint->isAntiAlias() ?
+ DeferredDisplayList::kOpBatch_AlphaVertices :
+ DeferredDisplayList::kOpBatch_Vertices;
+ }
+
protected:
float* mPoints;
int mCount;
@@ -971,6 +1079,12 @@
virtual void output(int level, uint32_t flags) {
OP_LOG("Draw some text, %d bytes", mBytesCount);
}
+
+ virtual DeferredDisplayList::OpBatchId getBatchId() {
+ return mPaint->getColor() == 0xff000000 ?
+ DeferredDisplayList::kOpBatch_Text :
+ DeferredDisplayList::kOpBatch_ColorText;
+ }
protected:
const char* mText;
int mBytesCount;
@@ -1042,6 +1156,12 @@
virtual const char* name() { return "DrawText"; }
+ virtual DeferredDisplayList::OpBatchId getBatchId() {
+ return mPaint->getColor() == 0xff000000 ?
+ DeferredDisplayList::kOpBatch_Text :
+ DeferredDisplayList::kOpBatch_ColorText;
+ }
+
private:
const char* mText;
int mBytesCount;
@@ -1083,9 +1203,21 @@
public:
DrawDisplayListOp(DisplayList* displayList, int flags)
: DrawOp(0), mDisplayList(displayList), mFlags(flags) {}
+
+ virtual status_t replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flags, int saveCount,
+ uint32_t level, bool caching, int multipliedAlpha, DeferredDisplayList& deferredList) {
+ if (mDisplayList && mDisplayList->isRenderable()) {
+ return mDisplayList->replay(renderer, dirty, mFlags, level + 1, &deferredList);
+ }
+ return DrawGlInfo::kStatusDone;
+ }
+
virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
bool caching, int multipliedAlpha) {
- return renderer.drawDisplayList(mDisplayList, dirty, mFlags, level + 1);
+ if (mDisplayList && mDisplayList->isRenderable()) {
+ return mDisplayList->replay(renderer, dirty, mFlags, level + 1);
+ }
+ return DrawGlInfo::kStatusDone;
}
virtual void output(int level, uint32_t flags) {
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp
index 31291b1..710f12f 100644
--- a/libs/hwui/DisplayListRenderer.cpp
+++ b/libs/hwui/DisplayListRenderer.cpp
@@ -21,6 +21,7 @@
#include <private/hwui/DrawGlInfo.h>
#include "DisplayList.h"
+#include "DeferredDisplayList.h"
#include "DisplayListLogBuffer.h"
#include "DisplayListOp.h"
#include "DisplayListRenderer.h"
@@ -239,7 +240,7 @@
}
status_t DisplayListRenderer::drawDisplayList(DisplayList* displayList,
- Rect& dirty, int32_t flags, uint32_t level) {
+ Rect& dirty, int32_t flags) {
// dirty is an out parameter and should not be recorded,
// it matters only when replaying the display list
diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h
index 97a2508..bff3b97 100644
--- a/libs/hwui/DisplayListRenderer.h
+++ b/libs/hwui/DisplayListRenderer.h
@@ -47,15 +47,12 @@
// Display list
///////////////////////////////////////////////////////////////////////////////
+class DeferredDisplayList;
class DisplayListRenderer;
class DisplayListOp;
class DrawOp;
class StateOp;
-///////////////////////////////////////////////////////////////////////////////
-// Renderer
-///////////////////////////////////////////////////////////////////////////////
-
/**
* Records drawing commands in a display list for latter playback.
*/
@@ -98,8 +95,7 @@
virtual bool clipPath(SkPath* path, SkRegion::Op op);
virtual bool clipRegion(SkRegion* region, SkRegion::Op op);
- virtual status_t drawDisplayList(DisplayList* displayList, Rect& dirty, int32_t flags,
- uint32_t level = 0);
+ virtual status_t drawDisplayList(DisplayList* displayList, Rect& dirty, int32_t flags);
virtual status_t drawLayer(Layer* layer, float x, float y, SkPaint* paint);
virtual status_t drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint);
virtual status_t drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint);
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 57d16ae..e5fd7b9 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -32,6 +32,7 @@
#include <ui/Rect.h>
#include "OpenGLRenderer.h"
+#include "DeferredDisplayList.h"
#include "DisplayListRenderer.h"
#include "PathTessellator.h"
#include "Properties.h"
@@ -111,16 +112,18 @@
OpenGLRenderer::OpenGLRenderer():
mCaches(Caches::getInstance()), mExtensions(Extensions::getInstance()) {
- mShader = NULL;
- mColorFilter = NULL;
- mHasShadow = false;
- mHasDrawFilter = false;
+ mDrawModifiers.mShader = NULL;
+ mDrawModifiers.mColorFilter = NULL;
+ mDrawModifiers.mHasShadow = false;
+ mDrawModifiers.mHasDrawFilter = false;
memcpy(mMeshVertices, gMeshVertices, sizeof(gMeshVertices));
mFirstSnapshot = new Snapshot;
mScissorOptimizationDisabled = false;
+ mDrawDeferDisabled = false;
+ mDrawReorderDisabled = false;
}
OpenGLRenderer::~OpenGLRenderer() {
@@ -137,6 +140,20 @@
} else {
INIT_LOGD(" Scissor optimization enabled");
}
+
+ if (property_get(PROPERTY_DISABLE_DRAW_DEFER, property, "false")) {
+ mDrawDeferDisabled = !strcasecmp(property, "true");
+ INIT_LOGD(" Draw defer %s", mDrawDeferDisabled ? "disabled" : "enabled");
+ } else {
+ INIT_LOGD(" Draw defer enabled");
+ }
+
+ if (property_get(PROPERTY_DISABLE_DRAW_REORDER, property, "false")) {
+ mDrawReorderDisabled = !strcasecmp(property, "true");
+ INIT_LOGD(" Draw reorder %s", mDrawReorderDisabled ? "disabled" : "enabled");
+ } else {
+ INIT_LOGD(" Draw reorder enabled");
+ }
}
///////////////////////////////////////////////////////////////////////////////
@@ -263,7 +280,7 @@
void OpenGLRenderer::startTiling(const Rect& clip, int windowHeight, bool opaque) {
if (!mSuppressTiling) {
mCaches.startTiling(clip.left, windowHeight - clip.bottom,
- clip.right - clip.left, clip.bottom - clip.top, opaque);
+ clip.right - clip.left, clip.bottom - clip.top, opaque);
}
}
@@ -770,7 +787,7 @@
layer->layer.set(bounds);
layer->texCoords.set(0.0f, bounds.getHeight() / float(layer->getHeight()),
bounds.getWidth() / float(layer->getWidth()), 0.0f);
- layer->setColorFilter(mColorFilter);
+ layer->setColorFilter(mDrawModifiers.mColorFilter);
layer->setBlend(true);
layer->setDirty(false);
@@ -1204,6 +1221,40 @@
}
///////////////////////////////////////////////////////////////////////////////
+// State Deferral
+///////////////////////////////////////////////////////////////////////////////
+
+bool OpenGLRenderer::storeDisplayState(DeferredDisplayState& state) {
+ const Rect& currentClip = *(mSnapshot->clipRect);
+ const mat4& currentMatrix = *(mSnapshot->transform);
+
+ // state only has bounds initialized in local coordinates
+ if (!state.mBounds.isEmpty()) {
+ currentMatrix.mapRect(state.mBounds);
+ if (!state.mBounds.intersect(currentClip)) {
+ // quick rejected
+ return true;
+ }
+ }
+
+ state.mClip.set(currentClip);
+ state.mMatrix.load(currentMatrix);
+ state.mDrawModifiers = mDrawModifiers;
+ return false;
+}
+
+void OpenGLRenderer::restoreDisplayState(const DeferredDisplayState& state) {
+ mSnapshot->transform->load(state.mMatrix);
+
+ // NOTE: a clip RECT will be saved and restored, but DeferredDisplayState doesn't support
+ // complex clips. In the future, we should add support for deferral of operations clipped by
+ // these. for now, we don't defer with complex clips (see OpenGLRenderer::disallowDeferral())
+ mSnapshot->setClip(state.mClip.left, state.mClip.top, state.mClip.right, state.mClip.bottom);
+ dirtyClip();
+ mDrawModifiers = state.mDrawModifiers;
+}
+
+///////////////////////////////////////////////////////////////////////////////
// Transforms
///////////////////////////////////////////////////////////////////////////////
@@ -1452,7 +1503,7 @@
if (clear) clearLayerRegions();
// Make sure setScissor & setStencil happen at the beginning of
// this method
- if (mDirtyClip) {
+ if (mDirtyClip && mCaches.scissorEnabled) {
setScissorFromClip();
setStencilFromClip();
}
@@ -1524,14 +1575,14 @@
}
void OpenGLRenderer::setupDrawShader() {
- if (mShader) {
- mShader->describe(mDescription, mExtensions);
+ if (mDrawModifiers.mShader) {
+ mDrawModifiers.mShader->describe(mDescription, mExtensions);
}
}
void OpenGLRenderer::setupDrawColorFilter() {
- if (mColorFilter) {
- mColorFilter->describe(mDescription, mExtensions);
+ if (mDrawModifiers.mColorFilter) {
+ mDrawModifiers.mColorFilter->describe(mDescription, mExtensions);
}
}
@@ -1547,16 +1598,19 @@
// When the blending mode is kClear_Mode, we need to use a modulate color
// argb=1,0,0,0
accountForClear(mode);
- chooseBlending((mColorSet && mColorA < 1.0f) || (mShader && mShader->blend()), mode,
- mDescription, swapSrcDst);
+ bool blend = (mColorSet && mColorA < 1.0f) ||
+ (mDrawModifiers.mShader && mDrawModifiers.mShader->blend());
+ chooseBlending(blend, mode, mDescription, swapSrcDst);
}
void OpenGLRenderer::setupDrawBlending(bool blend, SkXfermode::Mode mode, bool swapSrcDst) {
// When the blending mode is kClear_Mode, we need to use a modulate color
// argb=1,0,0,0
accountForClear(mode);
- chooseBlending(blend || (mColorSet && mColorA < 1.0f) || (mShader && mShader->blend()) ||
- (mColorFilter && mColorFilter->blend()), mode, mDescription, swapSrcDst);
+ blend |= (mColorSet && mColorA < 1.0f) ||
+ (mDrawModifiers.mShader && mDrawModifiers.mShader->blend()) ||
+ (mDrawModifiers.mColorFilter && mDrawModifiers.mColorFilter->blend());
+ chooseBlending(blend, mode, mDescription, swapSrcDst);
}
void OpenGLRenderer::setupDrawProgram() {
@@ -1609,7 +1663,7 @@
}
void OpenGLRenderer::setupDrawColorUniforms() {
- if ((mColorSet && !mShader) || (mShader && mSetShaderColor)) {
+ if ((mColorSet && !mDrawModifiers.mShader) || (mDrawModifiers.mShader && mSetShaderColor)) {
mCaches.currentProgram->setColor(mColorR, mColorG, mColorB, mColorA);
}
}
@@ -1621,23 +1675,25 @@
}
void OpenGLRenderer::setupDrawShaderUniforms(bool ignoreTransform) {
- if (mShader) {
+ if (mDrawModifiers.mShader) {
if (ignoreTransform) {
mModelView.loadInverse(*mSnapshot->transform);
}
- mShader->setupProgram(mCaches.currentProgram, mModelView, *mSnapshot, &mTextureUnit);
+ mDrawModifiers.mShader->setupProgram(mCaches.currentProgram,
+ mModelView, *mSnapshot, &mTextureUnit);
}
}
void OpenGLRenderer::setupDrawShaderIdentityUniforms() {
- if (mShader) {
- mShader->setupProgram(mCaches.currentProgram, mIdentity, *mSnapshot, &mTextureUnit);
+ if (mDrawModifiers.mShader) {
+ mDrawModifiers.mShader->setupProgram(mCaches.currentProgram,
+ mIdentity, *mSnapshot, &mTextureUnit);
}
}
void OpenGLRenderer::setupDrawColorFilterUniforms() {
- if (mColorFilter) {
- mColorFilter->setupProgram(mCaches.currentProgram);
+ if (mDrawModifiers.mColorFilter) {
+ mDrawModifiers.mColorFilter->setupProgram(mCaches.currentProgram);
}
}
@@ -1726,21 +1782,24 @@
// Drawing
///////////////////////////////////////////////////////////////////////////////
-status_t OpenGLRenderer::drawDisplayList(DisplayList* displayList,
- Rect& dirty, int32_t flags, uint32_t level) {
-
+status_t OpenGLRenderer::drawDisplayList(DisplayList* displayList, Rect& dirty, int32_t flags) {
// All the usual checks and setup operations (quickReject, setupDraw, etc.)
// will be performed by the display list itself
if (displayList && displayList->isRenderable()) {
- return displayList->replay(*this, dirty, flags, level);
+ if (CC_UNLIKELY(mDrawDeferDisabled)) {
+ return displayList->replay(*this, dirty, flags, 0);
+ }
+
+ DeferredDisplayList deferredList;
+ return displayList->replay(*this, dirty, flags, 0, &deferredList);
}
return DrawGlInfo::kStatusDone;
}
-void OpenGLRenderer::outputDisplayList(DisplayList* displayList, uint32_t level) {
+void OpenGLRenderer::outputDisplayList(DisplayList* displayList) {
if (displayList) {
- displayList->output(level);
+ displayList->output(0);
}
}
@@ -1990,7 +2049,7 @@
// Apply a scale transform on the canvas only when a shader is in use
// Skia handles the ratio between the dst and src rects as a scale factor
// when a shader is set
- bool useScaleTransform = mShader && scaled;
+ bool useScaleTransform = mDrawModifiers.mShader && scaled;
bool ignoreTransform = false;
if (CC_LIKELY(mSnapshot->transform->isPureTranslate() && !useScaleTransform)) {
@@ -2445,15 +2504,15 @@
// if shader-based correction is enabled
mCaches.dropShadowCache.setFontRenderer(fontRenderer);
const ShadowTexture* shadow = mCaches.dropShadowCache.get(
- paint, text, bytesCount, count, mShadowRadius, positions);
+ paint, text, bytesCount, count, mDrawModifiers.mShadowRadius, positions);
const AutoTexture autoCleanup(shadow);
- const float sx = x - shadow->left + mShadowDx;
- const float sy = y - shadow->top + mShadowDy;
+ const float sx = x - shadow->left + mDrawModifiers.mShadowDx;
+ const float sy = y - shadow->top + mDrawModifiers.mShadowDy;
- const int shadowAlpha = ((mShadowColor >> 24) & 0xFF) * mSnapshot->alpha;
- int shadowColor = mShadowColor;
- if (mShader) {
+ const int shadowAlpha = ((mDrawModifiers.mShadowColor >> 24) & 0xFF) * mSnapshot->alpha;
+ int shadowColor = mDrawModifiers.mShadowColor;
+ if (mDrawModifiers.mShader) {
shadowColor = 0xffffffff;
}
@@ -2501,7 +2560,7 @@
SkXfermode::Mode mode;
getAlphaAndMode(paint, &alpha, &mode);
- if (CC_UNLIKELY(mHasShadow)) {
+ if (CC_UNLIKELY(mDrawModifiers.mHasShadow)) {
drawTextShadow(paint, text, bytesCount, count, positions, fontRenderer,
alpha, mode, 0.0f, 0.0f);
}
@@ -2592,7 +2651,7 @@
SkXfermode::Mode mode;
getAlphaAndMode(paint, &alpha, &mode);
- if (CC_UNLIKELY(mHasShadow)) {
+ if (CC_UNLIKELY(mDrawModifiers.mHasShadow)) {
drawTextShadow(paint, text, bytesCount, count, positions, fontRenderer, alpha, mode,
oldX, oldY);
}
@@ -2748,8 +2807,8 @@
mCaches.activeTexture(0);
if (CC_LIKELY(!layer->region.isEmpty())) {
- SkiaColorFilter* oldFilter = mColorFilter;
- mColorFilter = layer->getColorFilter();
+ SkiaColorFilter* oldFilter = mDrawModifiers.mColorFilter;
+ mDrawModifiers.mColorFilter = layer->getColorFilter();
if (layer->region.isRect()) {
composeLayerRect(layer, layer->regionRect);
@@ -2788,7 +2847,7 @@
#endif
}
- mColorFilter = oldFilter;
+ mDrawModifiers.mColorFilter = oldFilter;
if (layer->debugDrawUpdate) {
layer->debugDrawUpdate = false;
@@ -2809,13 +2868,13 @@
///////////////////////////////////////////////////////////////////////////////
void OpenGLRenderer::resetShader() {
- mShader = NULL;
+ mDrawModifiers.mShader = NULL;
}
void OpenGLRenderer::setupShader(SkiaShader* shader) {
- mShader = shader;
- if (mShader) {
- mShader->set(&mCaches.textureCache, &mCaches.gradientCache);
+ mDrawModifiers.mShader = shader;
+ if (mDrawModifiers.mShader) {
+ mDrawModifiers.mShader->set(&mCaches.textureCache, &mCaches.gradientCache);
}
}
@@ -2824,11 +2883,11 @@
///////////////////////////////////////////////////////////////////////////////
void OpenGLRenderer::resetColorFilter() {
- mColorFilter = NULL;
+ mDrawModifiers.mColorFilter = NULL;
}
void OpenGLRenderer::setupColorFilter(SkiaColorFilter* filter) {
- mColorFilter = filter;
+ mDrawModifiers.mColorFilter = filter;
}
///////////////////////////////////////////////////////////////////////////////
@@ -2836,15 +2895,15 @@
///////////////////////////////////////////////////////////////////////////////
void OpenGLRenderer::resetShadow() {
- mHasShadow = false;
+ mDrawModifiers.mHasShadow = false;
}
void OpenGLRenderer::setupShadow(float radius, float dx, float dy, int color) {
- mHasShadow = true;
- mShadowRadius = radius;
- mShadowDx = dx;
- mShadowDy = dy;
- mShadowColor = color;
+ mDrawModifiers.mHasShadow = true;
+ mDrawModifiers.mShadowRadius = radius;
+ mDrawModifiers.mShadowDx = dx;
+ mDrawModifiers.mShadowDy = dy;
+ mDrawModifiers.mShadowColor = color;
}
///////////////////////////////////////////////////////////////////////////////
@@ -2852,22 +2911,23 @@
///////////////////////////////////////////////////////////////////////////////
void OpenGLRenderer::resetPaintFilter() {
- mHasDrawFilter = false;
+ mDrawModifiers.mHasDrawFilter = false;
}
void OpenGLRenderer::setupPaintFilter(int clearBits, int setBits) {
- mHasDrawFilter = true;
- mPaintFilterClearBits = clearBits & SkPaint::kAllFlags;
- mPaintFilterSetBits = setBits & SkPaint::kAllFlags;
+ mDrawModifiers.mHasDrawFilter = true;
+ mDrawModifiers.mPaintFilterClearBits = clearBits & SkPaint::kAllFlags;
+ mDrawModifiers.mPaintFilterSetBits = setBits & SkPaint::kAllFlags;
}
SkPaint* OpenGLRenderer::filterPaint(SkPaint* paint) {
- if (CC_LIKELY(!mHasDrawFilter || !paint)) return paint;
+ if (CC_LIKELY(!mDrawModifiers.mHasDrawFilter || !paint)) return paint;
uint32_t flags = paint->getFlags();
mFilteredPaint = *paint;
- mFilteredPaint.setFlags((flags & ~mPaintFilterClearBits) | mPaintFilterSetBits);
+ mFilteredPaint.setFlags((flags & ~mDrawModifiers.mPaintFilterClearBits) |
+ mDrawModifiers.mPaintFilterSetBits);
return &mFilteredPaint;
}
@@ -2967,7 +3027,7 @@
int color = paint->getColor();
// If a shader is set, preserve only the alpha
- if (mShader) {
+ if (mDrawModifiers.mShader) {
color |= 0x00ffffff;
}
SkXfermode::Mode mode = getXfermode(paint->getXfermode());
@@ -3040,7 +3100,7 @@
void OpenGLRenderer::drawColorRect(float left, float top, float right, float bottom,
int color, SkXfermode::Mode mode, bool ignoreTransform) {
// If a shader is set, preserve only the alpha
- if (mShader) {
+ if (mDrawModifiers.mShader) {
color |= 0x00ffffff;
}
diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h
index ad80d36..e12083c 100644
--- a/libs/hwui/OpenGLRenderer.h
+++ b/libs/hwui/OpenGLRenderer.h
@@ -48,6 +48,34 @@
namespace android {
namespace uirenderer {
+struct DrawModifiers {
+ SkiaShader* mShader;
+ SkiaColorFilter* mColorFilter;
+
+ // Drop shadow
+ bool mHasShadow;
+ float mShadowRadius;
+ float mShadowDx;
+ float mShadowDy;
+ int mShadowColor;
+
+ // Draw filters
+ bool mHasDrawFilter;
+ int mPaintFilterClearBits;
+ int mPaintFilterSetBits;
+};
+
+struct DeferredDisplayState {
+ Rect mBounds; // local bounds, mapped with matrix to be in screen space coordinates, clipped.
+ int mMultipliedAlpha; // -1 if invalid (because caching not set)
+
+ // the below are set and used by the OpenGLRenderer at record and deferred playback
+ Rect mClip;
+ mat4 mMatrix;
+ SkiaShader* mShader;
+ DrawModifiers mDrawModifiers;
+};
+
///////////////////////////////////////////////////////////////////////////////
// Renderer
///////////////////////////////////////////////////////////////////////////////
@@ -182,9 +210,8 @@
virtual bool clipRegion(SkRegion* region, SkRegion::Op op);
virtual Rect* getClipRect();
- virtual status_t drawDisplayList(DisplayList* displayList, Rect& dirty, int32_t flags,
- uint32_t level = 0);
- virtual void outputDisplayList(DisplayList* displayList, uint32_t level = 0);
+ virtual status_t drawDisplayList(DisplayList* displayList, Rect& dirty, int32_t flags);
+ virtual void outputDisplayList(DisplayList* displayList);
virtual status_t drawLayer(Layer* layer, float x, float y, SkPaint* paint);
virtual status_t drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint);
virtual status_t drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint);
@@ -233,6 +260,23 @@
SkPaint* filterPaint(SkPaint* paint);
+ bool disallowDeferral() {
+ // returns true if the OpenGLRenderer's state can be completely represented by
+ // a DeferredDisplayState object
+ return !mSnapshot->clipRegion->isEmpty() ||
+ mSnapshot->alpha < 1.0 ||
+ (mSnapshot->flags & Snapshot::kFlagIsLayer) ||
+ (mSnapshot->flags & Snapshot::kFlagFboTarget); // ensure we're not in a layer
+ }
+
+ bool disallowReorder() { return mDrawReorderDisabled; }
+
+ bool storeDisplayState(DeferredDisplayState& state);
+ void restoreDisplayState(const DeferredDisplayState& state);
+
+ const DrawModifiers& getDrawModifiers() { return mDrawModifiers; }
+ void setDrawModifiers(const DrawModifiers& drawModifiers) { mDrawModifiers = drawModifiers; }
+
ANDROID_API bool isCurrentTransformSimple() {
return mSnapshot->transform->isSimple();
}
@@ -868,26 +912,11 @@
// State used to define the clipping region
sp<Snapshot> mTilingSnapshot;
- // Shaders
- SkiaShader* mShader;
-
- // Color filters
- SkiaColorFilter* mColorFilter;
-
// Used to draw textured quads
TextureVertex mMeshVertices[4];
- // Drop shadow
- bool mHasShadow;
- float mShadowRadius;
- float mShadowDx;
- float mShadowDy;
- int mShadowColor;
-
- // Draw filters
- bool mHasDrawFilter;
- int mPaintFilterClearBits;
- int mPaintFilterSetBits;
+ // shader, filters, and shadow
+ DrawModifiers mDrawModifiers;
SkPaint mFilteredPaint;
// Various caches
@@ -925,6 +954,8 @@
// See PROPERTY_DISABLE_SCISSOR_OPTIMIZATION in
// Properties.h
bool mScissorOptimizationDisabled;
+ bool mDrawDeferDisabled;
+ bool mDrawReorderDisabled;
// No-ops start/endTiling when set
bool mSuppressTiling;
diff --git a/libs/hwui/Properties.h b/libs/hwui/Properties.h
index 0c75242..f3957cf 100644
--- a/libs/hwui/Properties.h
+++ b/libs/hwui/Properties.h
@@ -82,6 +82,19 @@
*/
#define PROPERTY_DISABLE_SCISSOR_OPTIMIZATION "ro.hwui.disable_scissor_opt"
+/**
+ * Disables draw operation deferral if set to "true", forcing draw
+ * commands to be issued to OpenGL in order, and processed in sequence
+ * with state-manipulation canvas commands.
+ */
+#define PROPERTY_DISABLE_DRAW_DEFER "debug.hwui.disable_draw_defer"
+
+/**
+ * Used to disable draw operation reordering when deferring draw operations
+ * Has no effect if PROPERTY_DISABLE_DRAW_DEFER is set to "true"
+ */
+#define PROPERTY_DISABLE_DRAW_REORDER "debug.hwui.disable_draw_reorder"
+
// These properties are defined in mega-bytes
#define PROPERTY_TEXTURE_CACHE_SIZE "ro.hwui.texture_cache_size"
#define PROPERTY_LAYER_CACHE_SIZE "ro.hwui.layer_cache_size"
diff --git a/libs/hwui/Rect.h b/libs/hwui/Rect.h
index 5f4bb5a..f50ac3c 100644
--- a/libs/hwui/Rect.h
+++ b/libs/hwui/Rect.h
@@ -159,6 +159,13 @@
bottom += dy;
}
+ void outset(float delta) {
+ left -= delta;
+ top -= delta;
+ right += delta;
+ bottom += delta;
+ }
+
void snapToPixelBoundaries() {
left = floorf(left + 0.5f);
top = floorf(top + 0.5f);
diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java
index 7bd9049..11f4180 100644
--- a/media/java/android/media/MediaPlayer.java
+++ b/media/java/android/media/MediaPlayer.java
@@ -948,7 +948,12 @@
private void setDataSource(String path, String[] keys, String[] values)
throws IOException, IllegalArgumentException, SecurityException, IllegalStateException {
- File file = new File(path);
+ final Uri uri = Uri.parse(path);
+ if ("file".equals(uri.getScheme())) {
+ path = uri.getPath();
+ }
+
+ final File file = new File(path);
if (file.exists()) {
FileInputStream is = new FileInputStream(file);
FileDescriptor fd = is.getFD();
diff --git a/packages/BackupRestoreConfirmation/res/values-sw/strings.xml b/packages/BackupRestoreConfirmation/res/values-sw/strings.xml
index 493c168..24d9c39 100644
--- a/packages/BackupRestoreConfirmation/res/values-sw/strings.xml
+++ b/packages/BackupRestoreConfirmation/res/values-sw/strings.xml
@@ -17,7 +17,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="backup_confirm_title" msgid="827563724209303345">"Kuhifadhi kikamilifu"</string>
- <string name="restore_confirm_title" msgid="5469365809567486602">"Kurejeza kamili"</string>
+ <string name="restore_confirm_title" msgid="5469365809567486602">"Kurejesha kila kitu"</string>
<string name="backup_confirm_text" msgid="1878021282758896593">"Chelezo kamili la data iliyounganishwa kwenye eneo kazi la kompyuta limeombwa. Unataka kuruhusu hii kutendeka?"\n\n" Ikiwa hukuomba chelezo mwenyewe, usikubali uendeshaji kuendelea."</string>
<string name="allow_backup_button_label" msgid="4217228747769644068">"Cheleza data yangu"</string>
<string name="deny_backup_button_label" msgid="6009119115581097708">"Usicheleze"</string>
@@ -32,7 +32,7 @@
<string name="restore_enc_password_text" msgid="6140898525580710823">"Ikiwa data iliyorejeshwa upya, tafadhali ingiza nenosiri lililo hapo chini:"</string>
<string name="toast_backup_started" msgid="550354281452756121">"Inaanza kuhifadhi..."</string>
<string name="toast_backup_ended" msgid="3818080769548726424">"Imemaliza kuhifadhi"</string>
- <string name="toast_restore_started" msgid="7881679218971277385">"Inaanza kurejeza..."</string>
- <string name="toast_restore_ended" msgid="1764041639199696132">"Kurejeza kumekamilika"</string>
+ <string name="toast_restore_started" msgid="7881679218971277385">"Inaanza kurejesha..."</string>
+ <string name="toast_restore_ended" msgid="1764041639199696132">"Kurejesha kumekamilika"</string>
<string name="toast_timeout" msgid="5276598587087626877">"Muda wa uendeshaji umeisha"</string>
</resources>
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index b85121e..66080f3 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -10,6 +10,7 @@
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INJECT_EVENTS" />
+ <uses-permission android:name="android.permission.DUMP" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.STATUS_BAR_SERVICE" />
diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
index ceb8654..8e1773a 100644
--- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
@@ -154,6 +154,13 @@
return Math.max(mMinAlpha, result);
}
+ private void updateAlphaFromOffset(View animView, boolean dismissable) {
+ if (FADE_OUT_DURING_SWIPE && dismissable) {
+ animView.setAlpha(getAlphaForOffset(animView));
+ }
+ invalidateGlobalRegion(animView);
+ }
+
// invalidate the view's own bounds all the way up the view hierarchy
public static void invalidateGlobalRegion(View view) {
invalidateGlobalRegion(
@@ -290,10 +297,7 @@
});
anim.addUpdateListener(new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
- if (FADE_OUT_DURING_SWIPE && canAnimViewBeDismissed) {
- animView.setAlpha(getAlphaForOffset(animView));
- }
- invalidateGlobalRegion(animView);
+ updateAlphaFromOffset(animView, canAnimViewBeDismissed);
}
});
anim.start();
@@ -307,10 +311,12 @@
anim.setDuration(duration);
anim.addUpdateListener(new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
- if (FADE_OUT_DURING_SWIPE && canAnimViewBeDismissed) {
- animView.setAlpha(getAlphaForOffset(animView));
- }
- invalidateGlobalRegion(animView);
+ updateAlphaFromOffset(animView, canAnimViewBeDismissed);
+ }
+ });
+ anim.addListener(new AnimatorListenerAdapter() {
+ public void onAnimationEnd(Animator animator) {
+ updateAlphaFromOffset(animView, canAnimViewBeDismissed);
}
});
anim.start();
@@ -347,10 +353,8 @@
}
}
setTranslation(mCurrAnimView, delta);
- if (FADE_OUT_DURING_SWIPE && mCanCurrViewBeDimissed) {
- mCurrAnimView.setAlpha(getAlphaForOffset(mCurrAnimView));
- }
- invalidateGlobalRegion(mCurrView);
+
+ updateAlphaFromOffset(mCurrAnimView, mCanCurrViewBeDimissed);
}
break;
case MotionEvent.ACTION_UP:
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index 7b80abc..988951c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -149,9 +149,17 @@
}
}
public float getXVelocity() {
+ if (Float.isNaN(mVX)) {
+ Slog.v("FlingTracker", "warning: vx=NaN");
+ // XXX: should return 0
+ }
return mVX;
}
public float getYVelocity() {
+ if (Float.isNaN(mVY)) {
+ Slog.v("FlingTracker", "warning: vx=NaN");
+ // XXX: should return 0
+ }
return mVY;
}
public void recycle() {
@@ -284,6 +292,9 @@
|| ((mRubberbanding || !mClosing) && mExpandedHeight == fh)) {
post(mStopAnimator);
}
+ } else {
+ Slog.v(TAG, "animationTick called with dtms=" + dtms + "; nothing to do (h="
+ + mExpandedHeight + " v=" + mVel + ")");
}
}
@@ -374,7 +385,7 @@
case MotionEvent.ACTION_MOVE:
final float h = rawY - mAbsPos[1] - mTouchOffset;
if (h > mPeekHeight) {
- if (mPeekAnimator != null && mPeekAnimator.isRunning()) {
+ if (mPeekAnimator != null && mPeekAnimator.isStarted()) {
mPeekAnimator.cancel();
}
mJustPeeked = false;
@@ -505,7 +516,7 @@
public void setExpandedHeight(float height) {
if (DEBUG) LOG("setExpandedHeight(%.1f)", height);
mRubberbanding = false;
- if (mTimeAnimator.isRunning()) {
+ if (mTimeAnimator.isStarted()) {
post(mStopAnimator);
}
setExpandedHeightInternal(height);
@@ -519,6 +530,11 @@
}
public void setExpandedHeightInternal(float h) {
+ if (Float.isNaN(h)) {
+ Slog.v(TAG, "setExpandedHeightInternal: warning: h=NaN");
+ // XXX: should set h to 0
+ }
+
float fh = getFullHeight();
if (fh == 0) {
// Hmm, full height hasn't been computed yet
@@ -526,6 +542,7 @@
if (h < 0) h = 0;
if (!(mRubberbandingEnabled && (mTracking || mRubberbanding)) && h > fh) h = fh;
+
mExpandedHeight = h;
if (DEBUG) LOG("setExpansion: height=%.1f fh=%.1f tracking=%s rubber=%s", h, fh, mTracking?"T":"f", mRubberbanding?"T":"f");
@@ -548,6 +565,10 @@
}
public void setExpandedFraction(float frac) {
+ if (Float.isNaN(frac)) {
+ Slog.v(TAG, "setExpandedFraction: frac=NaN");
+ // XXX: set frac to 0 to defend
+ }
setExpandedHeight(getFullHeight() * frac);
}
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
index 88a0ef3..e1d9b73 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
@@ -20,11 +20,7 @@
import static android.view.View.MeasureSpec.getMode;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
-import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
-import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
-import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
-import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
-import static android.view.WindowManager.LayoutParams.FLAG_SPLIT_TOUCH;
+import static android.view.WindowManager.LayoutParams.*;
import com.android.internal.view.RootViewSurfaceTaker;
import com.android.internal.view.StandaloneActionMode;
@@ -2639,7 +2635,11 @@
}
if (a.getBoolean(com.android.internal.R.styleable.Window_windowFullscreen, false)) {
- setFlags(FLAG_FULLSCREEN, FLAG_FULLSCREEN&(~getForcedWindowFlags()));
+ setFlags(FLAG_FULLSCREEN, FLAG_FULLSCREEN & (~getForcedWindowFlags()));
+ }
+
+ if (a.getBoolean(com.android.internal.R.styleable.Window_windowOverscan, false)) {
+ setFlags(FLAG_LAYOUT_IN_OVERSCAN, FLAG_LAYOUT_IN_OVERSCAN&(~getForcedWindowFlags()));
}
if (a.getBoolean(com.android.internal.R.styleable.Window_windowShowWallpaper, false)) {
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 9cb54a9..4e5825e 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -101,55 +101,7 @@
import java.io.IOException;
import java.io.PrintWriter;
-import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW;
-import static android.view.WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON;
-import static android.view.WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD;
-import static android.view.WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN;
-import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
-import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
-import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
-import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
-import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
-import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
-import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
-import static android.view.WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST;
-import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
-import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
-import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
-import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA;
-import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY;
-import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
-import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
-import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL;
-import static android.view.WindowManager.LayoutParams.TYPE_BOOT_PROGRESS;
-import static android.view.WindowManager.LayoutParams.TYPE_DISPLAY_OVERLAY;
-import static android.view.WindowManager.LayoutParams.TYPE_DRAG;
-import static android.view.WindowManager.LayoutParams.TYPE_DREAM;
-import static android.view.WindowManager.LayoutParams.TYPE_HIDDEN_NAV_CONSUMER;
-import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
-import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG;
-import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD;
-import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG;
-import static android.view.WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY;
-import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR;
-import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL;
-import static android.view.WindowManager.LayoutParams.TYPE_PHONE;
-import static android.view.WindowManager.LayoutParams.TYPE_POINTER;
-import static android.view.WindowManager.LayoutParams.TYPE_PRIORITY_PHONE;
-import static android.view.WindowManager.LayoutParams.TYPE_RECENTS_OVERLAY;
-import static android.view.WindowManager.LayoutParams.TYPE_SEARCH_BAR;
-import static android.view.WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY;
-import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR;
-import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL;
-import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL;
-import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
-import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG;
-import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
-import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY;
-import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
-import static android.view.WindowManager.LayoutParams.TYPE_UNIVERSE_BACKGROUND;
-import static android.view.WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY;
-import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
+import static android.view.WindowManager.LayoutParams.*;
import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_ABSENT;
import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_OPEN;
import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_CLOSED;
@@ -353,8 +305,12 @@
PointerLocationView mPointerLocationView;
InputChannel mPointerLocationInputChannel;
- // The current size of the screen; really; (ir)regardless of whether the status
- // bar can be hidden or not
+ // The current size of the screen; really; extends into the overscan area of
+ // the screen and doesn't account for any system elements like the status bar.
+ int mOverscanScreenLeft, mOverscanScreenTop;
+ int mOverscanScreenWidth, mOverscanScreenHeight;
+ // The current visible size of the screen; really; (ir)regardless of whether the status
+ // bar can be hidden but not extending into the overscan area.
int mUnrestrictedScreenLeft, mUnrestrictedScreenTop;
int mUnrestrictedScreenWidth, mUnrestrictedScreenHeight;
// The current size of the screen; these may be different than (0,0)-(dw,dh)
@@ -455,6 +411,11 @@
int mPortraitRotation = 0; // default portrait rotation
int mUpsideDownRotation = 0; // "other" portrait rotation
+ int mOverscanLeft = 0;
+ int mOverscanTop = 0;
+ int mOverscanRight = 0;
+ int mOverscanBottom = 0;
+
// What we do when the user long presses on home
private int mLongPressOnHomeBehavior = -1;
@@ -946,6 +907,9 @@
@Override
public void setInitialDisplaySize(Display display, int width, int height, int density) {
+ if (display.getDisplayId() != Display.DEFAULT_DISPLAY) {
+ throw new IllegalArgumentException("Can only set the default display");
+ }
mDisplay = display;
int shortSize, longSize;
@@ -1056,6 +1020,16 @@
mHdmiRotationLock = SystemProperties.getBoolean("persist.demo.hdmirotationlock", false);
}
+ @Override
+ public void setDisplayOverscan(Display display, int left, int top, int right, int bottom) {
+ if (display.getDisplayId() == Display.DEFAULT_DISPLAY) {
+ mOverscanLeft = left;
+ mOverscanTop = top;
+ mOverscanRight = right;
+ mOverscanBottom = bottom;
+ }
+ }
+
public void updateSettings() {
ContentResolver resolver = mContext.getContentResolver();
boolean updateRotation = false;
@@ -2388,7 +2362,7 @@
contentInset.set(mStableLeft, mStableTop,
availRight - mStableRight, availBottom - mStableBottom);
}
- } else if ((fl & FLAG_FULLSCREEN) != 0) {
+ } else if ((fl & FLAG_FULLSCREEN) != 0 || (fl & FLAG_LAYOUT_IN_OVERSCAN) != 0) {
contentInset.setEmpty();
} else if ((systemUiVisibility & (View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)) == 0) {
@@ -2407,20 +2381,64 @@
@Override
public void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight,
int displayRotation) {
- mUnrestrictedScreenLeft = mUnrestrictedScreenTop = 0;
- mUnrestrictedScreenWidth = displayWidth;
- mUnrestrictedScreenHeight = displayHeight;
- mRestrictedScreenLeft = mRestrictedScreenTop = 0;
- mRestrictedScreenWidth = displayWidth;
- mRestrictedScreenHeight = displayHeight;
+ final int overscanLeft, overscanTop, overscanRight, overscanBottom;
+ if (isDefaultDisplay) {
+ switch (displayRotation) {
+ case Surface.ROTATION_90:
+ overscanLeft = mOverscanTop;
+ overscanTop = mOverscanRight;
+ overscanRight = mOverscanBottom;
+ overscanBottom = mOverscanLeft;
+ break;
+ case Surface.ROTATION_180:
+ overscanLeft = mOverscanRight;
+ overscanTop = mOverscanBottom;
+ overscanRight = mOverscanLeft;
+ overscanBottom = mOverscanTop;
+ break;
+ case Surface.ROTATION_270:
+ overscanLeft = mOverscanBottom;
+ overscanTop = mOverscanLeft;
+ overscanRight = mOverscanTop;
+ overscanBottom = mOverscanRight;
+ break;
+ default:
+ overscanLeft = mOverscanLeft;
+ overscanTop = mOverscanTop;
+ overscanRight = mOverscanRight;
+ overscanBottom = mOverscanBottom;
+ break;
+ }
+ } else {
+ overscanLeft = 0;
+ overscanTop = 0;
+ overscanRight = 0;
+ overscanBottom = 0;
+ }
+ mOverscanScreenLeft = 0;
+ mOverscanScreenTop = 0;
+ mOverscanScreenWidth = displayWidth;
+ mOverscanScreenHeight = displayHeight;
+ mSystemLeft = 0;
+ mSystemTop = 0;
+ mSystemRight = displayWidth;
+ mSystemBottom = displayHeight;
+ mUnrestrictedScreenLeft = overscanLeft;
+ mUnrestrictedScreenTop = overscanTop;
+ mUnrestrictedScreenWidth = displayWidth - overscanLeft - overscanRight;
+ mUnrestrictedScreenHeight = displayHeight - overscanTop - overscanBottom;
+ mRestrictedScreenLeft = mUnrestrictedScreenLeft;
+ mRestrictedScreenTop = mUnrestrictedScreenTop;
+ mRestrictedScreenWidth = mUnrestrictedScreenWidth;
+ mRestrictedScreenHeight = mUnrestrictedScreenHeight;
mDockLeft = mContentLeft = mStableLeft = mStableFullscreenLeft
- = mSystemLeft = mCurLeft = 0;
+ = mCurLeft = mUnrestrictedScreenLeft;
mDockTop = mContentTop = mStableTop = mStableFullscreenTop
- = mSystemTop = mCurTop = 0;
+ = mCurTop = mUnrestrictedScreenTop;
mDockRight = mContentRight = mStableRight = mStableFullscreenRight
- = mSystemRight = mCurRight = displayWidth;
+ = mCurRight = displayWidth - overscanRight;
mDockBottom = mContentBottom = mStableBottom = mStableFullscreenBottom
- = mSystemBottom = mCurBottom = displayHeight;
+ = mCurBottom = displayHeight - overscanBottom;
mDockLayer = 0x10000000;
mStatusBarLayer = -1;
@@ -2467,8 +2485,9 @@
mNavigationBarOnBottom = (!mNavigationBarCanMove || displayWidth < displayHeight);
if (mNavigationBarOnBottom) {
// It's a system nav bar or a portrait screen; nav bar goes on bottom.
- int top = displayHeight - mNavigationBarHeightForRotation[displayRotation];
- mTmpNavigationFrame.set(0, top, displayWidth, displayHeight);
+ int top = displayHeight - overscanBottom
+ - mNavigationBarHeightForRotation[displayRotation];
+ mTmpNavigationFrame.set(0, top, displayWidth, displayHeight - overscanBottom);
mStableBottom = mStableFullscreenBottom = mTmpNavigationFrame.top;
if (navVisible) {
mNavigationBar.showLw(true);
@@ -2486,8 +2505,9 @@
}
} else {
// Landscape screen; nav bar goes to the right.
- int left = displayWidth - mNavigationBarWidthForRotation[displayRotation];
- mTmpNavigationFrame.set(left, 0, displayWidth, displayHeight);
+ int left = displayWidth - overscanRight
+ - mNavigationBarWidthForRotation[displayRotation];
+ mTmpNavigationFrame.set(left, 0, displayWidth - overscanRight, displayHeight);
mStableRight = mStableFullscreenRight = mTmpNavigationFrame.left;
if (navVisible) {
mNavigationBar.showLw(true);
@@ -2524,8 +2544,8 @@
// apply any navigation bar insets
pf.left = df.left = mUnrestrictedScreenLeft;
pf.top = df.top = mUnrestrictedScreenTop;
- pf.right = df.right = mUnrestrictedScreenWidth - mUnrestrictedScreenLeft;
- pf.bottom = df.bottom = mUnrestrictedScreenHeight - mUnrestrictedScreenTop;
+ pf.right = df.right = mUnrestrictedScreenWidth + mUnrestrictedScreenLeft;
+ pf.bottom = df.bottom = mUnrestrictedScreenHeight + mUnrestrictedScreenTop;
vf.left = mStableLeft;
vf.top = mStableTop;
vf.right = mStableRight;
@@ -2685,12 +2705,12 @@
setAttachedWindowFrames(win, fl, adjust, attached, true, pf, df, cf, vf);
} else {
// Give the window full screen.
- pf.left = df.left = cf.left = mUnrestrictedScreenLeft;
- pf.top = df.top = cf.top = mUnrestrictedScreenTop;
+ pf.left = df.left = cf.left = mOverscanScreenLeft;
+ pf.top = df.top = cf.top = mOverscanScreenTop;
pf.right = df.right = cf.right
- = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth;
+ = mOverscanScreenLeft + mOverscanScreenWidth;
pf.bottom = df.bottom = cf.bottom
- = mUnrestrictedScreenTop + mUnrestrictedScreenHeight;
+ = mOverscanScreenTop + mOverscanScreenHeight;
}
} else if (attrs.type == TYPE_INPUT_METHOD) {
pf.left = df.left = cf.left = vf.left = mDockLeft;
@@ -2729,28 +2749,37 @@
pf.top = df.top = mUnrestrictedScreenTop;
pf.right = df.right = hasNavBar
? mRestrictedScreenLeft+mRestrictedScreenWidth
- : mUnrestrictedScreenLeft+mUnrestrictedScreenWidth;
+ : mUnrestrictedScreenLeft + mUnrestrictedScreenWidth;
pf.bottom = df.bottom = hasNavBar
? mRestrictedScreenTop+mRestrictedScreenHeight
- : mUnrestrictedScreenTop+mUnrestrictedScreenHeight;
+ : mUnrestrictedScreenTop + mUnrestrictedScreenHeight;
if (DEBUG_LAYOUT) {
Log.v(TAG, String.format(
"Laying out status bar window: (%d,%d - %d,%d)",
pf.left, pf.top, pf.right, pf.bottom));
}
+ } else if ((attrs.flags&FLAG_LAYOUT_IN_OVERSCAN) != 0
+ && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW
+ && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) {
+ // Asking to layout into the overscan region, so give it that pure
+ // unrestricted area.
+ pf.left = df.left = mOverscanScreenLeft;
+ pf.top = df.top = mOverscanScreenTop;
+ pf.right = df.right = mOverscanScreenLeft + mOverscanScreenWidth;
+ pf.bottom = df.bottom = mOverscanScreenTop + mOverscanScreenHeight;
} else if (mCanHideNavigationBar
&& (sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0
&& attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW
&& attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) {
// Asking for layout as if the nav bar is hidden, lets the
- // application extend into the unrestricted screen area. We
+ // application extend into the unrestricted overscan screen area. We
// only do this for application windows to ensure no window that
// can be above the nav bar can do this.
pf.left = df.left = mUnrestrictedScreenLeft;
pf.top = df.top = mUnrestrictedScreenTop;
- pf.right = df.right = mUnrestrictedScreenLeft+mUnrestrictedScreenWidth;
- pf.bottom = df.bottom = mUnrestrictedScreenTop+mUnrestrictedScreenHeight;
+ pf.right = df.right = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth;
+ pf.bottom = df.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight;
} else {
pf.left = df.left = mRestrictedScreenLeft;
pf.top = df.top = mRestrictedScreenTop;
@@ -2793,10 +2822,10 @@
pf.top = df.top = cf.top = mUnrestrictedScreenTop;
pf.right = df.right = cf.right = hasNavBar
? mRestrictedScreenLeft+mRestrictedScreenWidth
- : mUnrestrictedScreenLeft+mUnrestrictedScreenWidth;
+ : mUnrestrictedScreenLeft + mUnrestrictedScreenWidth;
pf.bottom = df.bottom = cf.bottom = hasNavBar
? mRestrictedScreenTop+mRestrictedScreenHeight
- : mUnrestrictedScreenTop+mUnrestrictedScreenHeight;
+ : mUnrestrictedScreenTop + mUnrestrictedScreenHeight;
if (DEBUG_LAYOUT) {
Log.v(TAG, String.format(
"Laying out IN_SCREEN status bar window: (%d,%d - %d,%d)",
@@ -2807,8 +2836,8 @@
// The navigation bar has Real Ultimate Power.
pf.left = df.left = mUnrestrictedScreenLeft;
pf.top = df.top = mUnrestrictedScreenTop;
- pf.right = df.right = mUnrestrictedScreenLeft+mUnrestrictedScreenWidth;
- pf.bottom = df.bottom = mUnrestrictedScreenTop+mUnrestrictedScreenHeight;
+ pf.right = df.right = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth;
+ pf.bottom = df.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight;
if (DEBUG_LAYOUT) {
Log.v(TAG, String.format(
"Laying out navigation bar window: (%d,%d - %d,%d)",
@@ -2818,18 +2847,29 @@
|| attrs.type == TYPE_BOOT_PROGRESS)
&& ((fl & FLAG_FULLSCREEN) != 0)) {
// Fullscreen secure system overlays get what they ask for.
- pf.left = df.left = mUnrestrictedScreenLeft;
- pf.top = df.top = mUnrestrictedScreenTop;
- pf.right = df.right = mUnrestrictedScreenLeft+mUnrestrictedScreenWidth;
- pf.bottom = df.bottom = mUnrestrictedScreenTop+mUnrestrictedScreenHeight;
+ pf.left = df.left = mOverscanScreenLeft;
+ pf.top = df.top = mOverscanScreenTop;
+ pf.right = df.right = mOverscanScreenLeft + mOverscanScreenWidth;
+ pf.bottom = df.bottom = mOverscanScreenTop + mOverscanScreenHeight;
} else if (attrs.type == TYPE_BOOT_PROGRESS
|| attrs.type == TYPE_UNIVERSE_BACKGROUND) {
// Boot progress screen always covers entire display.
- pf.left = df.left = cf.left = mUnrestrictedScreenLeft;
- pf.top = df.top = cf.top = mUnrestrictedScreenTop;
- pf.right = df.right = cf.right = mUnrestrictedScreenLeft+mUnrestrictedScreenWidth;
+ pf.left = df.left = cf.left = mOverscanScreenLeft;
+ pf.top = df.top = cf.top = mOverscanScreenTop;
+ pf.right = df.right = cf.right = mOverscanScreenLeft + mOverscanScreenWidth;
pf.bottom = df.bottom = cf.bottom
- = mUnrestrictedScreenTop+mUnrestrictedScreenHeight;
+ = mOverscanScreenTop + mOverscanScreenHeight;
+ } else if ((attrs.flags & FLAG_LAYOUT_IN_OVERSCAN) != 0
+ && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW
+ && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) {
+ // Asking to layout into the overscan region, so give it that pure
+ // unrestricted area.
+ pf.left = df.left = cf.left = mOverscanScreenLeft;
+ pf.top = df.top = cf.top = mOverscanScreenTop;
+ pf.right = df.right = cf.right
+ = mOverscanScreenLeft + mOverscanScreenWidth;
+ pf.bottom = df.bottom = cf.bottom
+ = mOverscanScreenTop + mOverscanScreenHeight;
} else if (mCanHideNavigationBar
&& (sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0
&& attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW
@@ -2843,9 +2883,9 @@
// what the screen would be if only laying out to hide the nav bar.
pf.left = df.left = cf.left = mUnrestrictedScreenLeft;
pf.top = df.top = cf.top = mUnrestrictedScreenTop;
- pf.right = df.right = cf.right = mUnrestrictedScreenLeft+mUnrestrictedScreenWidth;
+ pf.right = df.right = cf.right = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth;
pf.bottom = df.bottom = cf.bottom
- = mUnrestrictedScreenTop+mUnrestrictedScreenHeight;
+ = mUnrestrictedScreenTop + mUnrestrictedScreenHeight;
} else {
pf.left = df.left = cf.left = mRestrictedScreenLeft;
pf.top = df.top = cf.top = mRestrictedScreenTop;
@@ -4661,6 +4701,17 @@
pw.print(prefix); pw.print("mScreenOnEarly="); pw.print(mScreenOnEarly);
pw.print(" mScreenOnFully="); pw.print(mScreenOnFully);
pw.print(" mOrientationSensorEnabled="); pw.println(mOrientationSensorEnabled);
+ pw.print(prefix); pw.print("mOverscanScreen=("); pw.print(mOverscanScreenLeft);
+ pw.print(","); pw.print(mOverscanScreenTop);
+ pw.print(") "); pw.print(mOverscanScreenWidth);
+ pw.print("x"); pw.println(mOverscanScreenHeight);
+ if (mOverscanLeft != 0 || mOverscanTop != 0
+ || mOverscanRight != 0 || mOverscanBottom != 0) {
+ pw.print(prefix); pw.print("mOverscan left="); pw.print(mOverscanLeft);
+ pw.print(" top="); pw.print(mOverscanTop);
+ pw.print(" right="); pw.print(mOverscanRight);
+ pw.print(" bottom="); pw.println(mOverscanBottom);
+ }
pw.print(prefix); pw.print("mUnrestrictedScreen=("); pw.print(mUnrestrictedScreenLeft);
pw.print(","); pw.print(mUnrestrictedScreenTop);
pw.print(") "); pw.print(mUnrestrictedScreenWidth);
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
index 27d808b..a0a5f5a 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
@@ -136,6 +136,16 @@
mAppWidgetHost = new AppWidgetHost(
context, APPWIDGET_HOST_ID, mOnClickHandler, Looper.myLooper());
mAppWidgetHost.setUserId(mUserId);
+
+ DevicePolicyManager dpm =
+ (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
+ if (dpm != null) {
+ mDisabledFeatures = getDisabledFeatures(dpm);
+ mCameraDisabled = dpm.getCameraDisabled(null);
+ }
+
+ mSafeModeEnabled = LockPatternUtils.isSafeModeEnabled();
+
cleanupAppWidgetIds();
mAppWidgetManager = AppWidgetManager.getInstance(mContext);
@@ -143,14 +153,6 @@
mViewStateManager = new KeyguardViewStateManager(this);
- DevicePolicyManager dpm =
- (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
- if (dpm != null) {
- mDisabledFeatures = getDisabledFeatures(dpm);
- mCameraDisabled = dpm.getCameraDisabled(null);
- }
-
- mSafeModeEnabled = LockPatternUtils.isSafeModeEnabled();
mUserSetupCompleted = Settings.Secure.getIntForUser(mContext.getContentResolver(),
Settings.Secure.USER_SETUP_COMPLETE, 0, UserHandle.USER_CURRENT) != 0;
@@ -172,19 +174,21 @@
mCleanupAppWidgetsOnBootCompleted = true;
return;
}
- // Clean up appWidgetIds that are bound to lockscreen, but not actually used
- // This is only to clean up after another bug: we used to not call
- // deleteAppWidgetId when a user manually deleted a widget in keyguard. This code
- // shouldn't have to run more than once per user. AppWidgetProviders rely on callbacks
- // that are triggered by deleteAppWidgetId, which is why we're doing this
- int[] appWidgetIdsInKeyguardSettings = mLockPatternUtils.getAppWidgets();
- int[] appWidgetIdsBoundToHost = mAppWidgetHost.getAppWidgetIds();
- for (int i = 0; i < appWidgetIdsBoundToHost.length; i++) {
- int appWidgetId = appWidgetIdsBoundToHost[i];
- if (!contains(appWidgetIdsInKeyguardSettings, appWidgetId)) {
- Log.d(TAG, "Found a appWidgetId that's not being used by keyguard, deleting id "
- + appWidgetId);
- mAppWidgetHost.deleteAppWidgetId(appWidgetId);
+ if (!mSafeModeEnabled && !widgetsDisabledByDpm()) {
+ // Clean up appWidgetIds that are bound to lockscreen, but not actually used
+ // This is only to clean up after another bug: we used to not call
+ // deleteAppWidgetId when a user manually deleted a widget in keyguard. This code
+ // shouldn't have to run more than once per user. AppWidgetProviders rely on callbacks
+ // that are triggered by deleteAppWidgetId, which is why we're doing this
+ int[] appWidgetIdsInKeyguardSettings = mLockPatternUtils.getAppWidgets();
+ int[] appWidgetIdsBoundToHost = mAppWidgetHost.getAppWidgetIds();
+ for (int i = 0; i < appWidgetIdsBoundToHost.length; i++) {
+ int appWidgetId = appWidgetIdsBoundToHost[i];
+ if (!contains(appWidgetIdsInKeyguardSettings, appWidgetId)) {
+ Log.d(TAG, "Found a appWidgetId that's not being used by keyguard, deleting id "
+ + appWidgetId);
+ mAppWidgetHost.deleteAppWidgetId(appWidgetId);
+ }
}
}
}
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index c31cde7..6d817a1 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -16,7 +16,6 @@
package com.android.server;
-import static android.Manifest.permission.CONNECTIVITY_INTERNAL;
import static android.Manifest.permission.MANAGE_NETWORK_POLICY;
import static android.Manifest.permission.RECEIVE_DATA_ACTIVITY_CHANGE;
import static android.net.ConnectivityManager.CONNECTIVITY_ACTION;
@@ -32,7 +31,6 @@
import static android.net.NetworkPolicyManager.RULE_ALLOW_ALL;
import static android.net.NetworkPolicyManager.RULE_REJECT_METERED;
-import android.app.Activity;
import android.bluetooth.BluetoothTetheringDataTracker;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
@@ -88,7 +86,6 @@
import android.security.Credentials;
import android.security.KeyStore;
import android.text.TextUtils;
-import android.util.EventLog;
import android.util.Slog;
import android.util.SparseIntArray;
@@ -3336,7 +3333,10 @@
@Override
public boolean updateLockdownVpn() {
- enforceSystemUid();
+ if (Binder.getCallingUid() != Process.SYSTEM_UID) {
+ Slog.w(TAG, "Lockdown VPN only available to AID_SYSTEM");
+ return false;
+ }
// Tear down existing lockdown if profile was removed
mLockdownEnabled = LockdownVpnTracker.isEnabled();
@@ -3387,11 +3387,4 @@
throw new IllegalStateException("Unavailable in lockdown mode");
}
}
-
- private static void enforceSystemUid() {
- final int uid = Binder.getCallingUid();
- if (uid != Process.SYSTEM_UID) {
- throw new SecurityException("Only available to AID_SYSTEM");
- }
- }
}
diff --git a/services/java/com/android/server/DeviceStorageMonitorService.java b/services/java/com/android/server/DeviceStorageMonitorService.java
index 94a087a..016c561 100644
--- a/services/java/com/android/server/DeviceStorageMonitorService.java
+++ b/services/java/com/android/server/DeviceStorageMonitorService.java
@@ -16,9 +16,6 @@
package com.android.server;
-import java.io.FileDescriptor;
-import java.io.PrintWriter;
-
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
@@ -40,12 +37,17 @@
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserHandle;
+import android.os.storage.StorageManager;
import android.provider.Settings;
import android.text.format.Formatter;
import android.util.EventLog;
import android.util.Slog;
import android.util.TimeUtils;
+import java.io.File;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+
/**
* This class implements a service to monitor the amount of disk
* storage space on the device. If the free storage on device is less
@@ -66,17 +68,18 @@
*/
public class DeviceStorageMonitorService extends Binder {
private static final String TAG = "DeviceStorageMonitorService";
+
private static final boolean DEBUG = false;
private static final boolean localLOGV = false;
+
private static final int DEVICE_MEMORY_WHAT = 1;
private static final int MONITOR_INTERVAL = 1; //in minutes
private static final int LOW_MEMORY_NOTIFICATION_ID = 1;
- private static final int DEFAULT_THRESHOLD_PERCENTAGE = 10;
- private static final int DEFAULT_THRESHOLD_MAX_BYTES = 500*1024*1024; // 500MB
+
private static final int DEFAULT_FREE_STORAGE_LOG_INTERVAL_IN_MINUTES = 12*60; //in minutes
private static final long DEFAULT_DISK_FREE_CHANGE_REPORTING_THRESHOLD = 2 * 1024 * 1024; // 2MB
private static final long DEFAULT_CHECK_INTERVAL = MONITOR_INTERVAL*60*1000;
- private static final int DEFAULT_FULL_THRESHOLD_BYTES = 1024*1024; // 1MB
+
private long mFreeMem; // on /data
private long mFreeMemAfterLastCacheClear; // on /data
private long mLastReportedFreeMem;
@@ -84,14 +87,16 @@
private boolean mLowMemFlag=false;
private boolean mMemFullFlag=false;
private Context mContext;
- private ContentResolver mContentResolver;
+ private ContentResolver mResolver;
private long mTotalMemory; // on /data
private StatFs mDataFileStats;
private StatFs mSystemFileStats;
private StatFs mCacheFileStats;
- private static final String DATA_PATH = "/data";
- private static final String SYSTEM_PATH = "/system";
- private static final String CACHE_PATH = "/cache";
+
+ private static final File DATA_PATH = Environment.getDataDirectory();
+ private static final File SYSTEM_PATH = Environment.getRootDirectory();
+ private static final File CACHE_PATH = Environment.getDownloadCacheDirectory();
+
private long mThreadStartTime = -1;
private boolean mClearSucceeded = false;
private boolean mClearingCache;
@@ -116,7 +121,7 @@
// more files than absolutely needed, to reduce the frequency that
// flushing takes place.
private long mMemCacheTrimToThreshold;
- private int mMemFullThreshold;
+ private long mMemFullThreshold;
/**
* This string is used for ServiceManager access to this class.
@@ -151,7 +156,7 @@
private final void restatDataDir() {
try {
- mDataFileStats.restat(DATA_PATH);
+ mDataFileStats.restat(DATA_PATH.getAbsolutePath());
mFreeMem = (long) mDataFileStats.getAvailableBlocks() *
mDataFileStats.getBlockSize();
} catch (IllegalArgumentException e) {
@@ -163,7 +168,7 @@
mFreeMem = Long.parseLong(debugFreeMem);
}
// Read the log interval from secure settings
- long freeMemLogInterval = Settings.Global.getLong(mContentResolver,
+ long freeMemLogInterval = Settings.Global.getLong(mResolver,
Settings.Global.SYS_FREE_STORAGE_LOG_INTERVAL,
DEFAULT_FREE_STORAGE_LOG_INTERVAL_IN_MINUTES)*60*1000;
//log the amount of free memory in event log
@@ -173,14 +178,14 @@
mLastReportedFreeMemTime = currTime;
long mFreeSystem = -1, mFreeCache = -1;
try {
- mSystemFileStats.restat(SYSTEM_PATH);
+ mSystemFileStats.restat(SYSTEM_PATH.getAbsolutePath());
mFreeSystem = (long) mSystemFileStats.getAvailableBlocks() *
mSystemFileStats.getBlockSize();
} catch (IllegalArgumentException e) {
// ignore; report -1
}
try {
- mCacheFileStats.restat(CACHE_PATH);
+ mCacheFileStats.restat(CACHE_PATH.getAbsolutePath());
mFreeCache = (long) mCacheFileStats.getAvailableBlocks() *
mCacheFileStats.getBlockSize();
} catch (IllegalArgumentException e) {
@@ -190,7 +195,7 @@
mFreeMem, mFreeSystem, mFreeCache);
}
// Read the reporting threshold from secure settings
- long threshold = Settings.Global.getLong(mContentResolver,
+ long threshold = Settings.Global.getLong(mResolver,
Settings.Global.DISK_FREE_CHANGE_REPORTING_THRESHOLD,
DEFAULT_DISK_FREE_CHANGE_REPORTING_THRESHOLD);
// If mFree changed significantly log the new value
@@ -303,40 +308,6 @@
delay);
}
- /*
- * just query settings to retrieve the memory threshold.
- * Preferred this over using a ContentObserver since Settings.Secure caches the value
- * any way
- */
- private long getMemThreshold() {
- long value = Settings.Global.getInt(
- mContentResolver,
- Settings.Global.SYS_STORAGE_THRESHOLD_PERCENTAGE,
- DEFAULT_THRESHOLD_PERCENTAGE);
- if(localLOGV) Slog.v(TAG, "Threshold Percentage="+value);
- value = (value*mTotalMemory)/100;
- long maxValue = Settings.Global.getInt(
- mContentResolver,
- Settings.Global.SYS_STORAGE_THRESHOLD_MAX_BYTES,
- DEFAULT_THRESHOLD_MAX_BYTES);
- //evaluate threshold value
- return value < maxValue ? value : maxValue;
- }
-
- /*
- * just query settings to retrieve the memory full threshold.
- * Preferred this over using a ContentObserver since Settings.Secure caches the value
- * any way
- */
- private int getMemFullThreshold() {
- int value = Settings.Global.getInt(
- mContentResolver,
- Settings.Global.SYS_STORAGE_FULL_THRESHOLD_BYTES,
- DEFAULT_FULL_THRESHOLD_BYTES);
- if(localLOGV) Slog.v(TAG, "Full Threshold Bytes="+value);
- return value;
- }
-
/**
* Constructor to run service. initializes the disk space threshold value
* and posts an empty message to kickstart the process.
@@ -344,11 +315,11 @@
public DeviceStorageMonitorService(Context context) {
mLastReportedFreeMemTime = 0;
mContext = context;
- mContentResolver = mContext.getContentResolver();
+ mResolver = mContext.getContentResolver();
//create StatFs object
- mDataFileStats = new StatFs(DATA_PATH);
- mSystemFileStats = new StatFs(SYSTEM_PATH);
- mCacheFileStats = new StatFs(CACHE_PATH);
+ mDataFileStats = new StatFs(DATA_PATH.getAbsolutePath());
+ mSystemFileStats = new StatFs(SYSTEM_PATH.getAbsolutePath());
+ mCacheFileStats = new StatFs(CACHE_PATH.getAbsolutePath());
//initialize total storage on device
mTotalMemory = (long)mDataFileStats.getBlockCount() *
mDataFileStats.getBlockSize();
@@ -360,9 +331,12 @@
mStorageFullIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
mStorageNotFullIntent = new Intent(Intent.ACTION_DEVICE_STORAGE_NOT_FULL);
mStorageNotFullIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
+
// cache storage thresholds
- mMemLowThreshold = getMemThreshold();
- mMemFullThreshold = getMemFullThreshold();
+ final StorageManager sm = StorageManager.from(context);
+ mMemLowThreshold = sm.getStorageLowBytes(DATA_PATH);
+ mMemFullThreshold = sm.getStorageFullBytes(DATA_PATH);
+
mMemCacheStartTrimThreshold = ((mMemLowThreshold*3)+mMemFullThreshold)/4;
mMemCacheTrimToThreshold = mMemLowThreshold
+ ((mMemLowThreshold-mMemCacheStartTrimThreshold)*2);
@@ -373,7 +347,6 @@
mCacheFileDeletedObserver.startWatching();
}
-
/**
* This method sends a notification to NotificationManager to display
* an error dialog indicating low disk space and launch the Installer
diff --git a/services/java/com/android/server/display/DisplayManagerService.java b/services/java/com/android/server/display/DisplayManagerService.java
index 813c9c7..17b0662 100644
--- a/services/java/com/android/server/display/DisplayManagerService.java
+++ b/services/java/com/android/server/display/DisplayManagerService.java
@@ -324,6 +324,18 @@
}
/**
+ * Sets the overscan insets for a particular display.
+ */
+ public void setOverscan(int displayId, int left, int top, int right, int bottom) {
+ synchronized (mSyncRoot) {
+ LogicalDisplay display = mLogicalDisplays.get(displayId);
+ if (display != null) {
+ display.setOverscan(left, top, right, bottom);
+ }
+ }
+ }
+
+ /**
* Called by the window manager to perform traversals while holding a
* surface flinger transaction.
*/
diff --git a/services/java/com/android/server/display/LogicalDisplay.java b/services/java/com/android/server/display/LogicalDisplay.java
index 1583137..424ec36 100644
--- a/services/java/com/android/server/display/LogicalDisplay.java
+++ b/services/java/com/android/server/display/LogicalDisplay.java
@@ -143,6 +143,19 @@
}
}
+ public void setOverscan(int left, int top, int right, int bottom) {
+ mInfo.overscanLeft = left;
+ mInfo.overscanTop = top;
+ mInfo.overscanRight = right;
+ mInfo.overscanBottom = bottom;
+ if (mOverrideDisplayInfo != null) {
+ mOverrideDisplayInfo.overscanLeft = left;
+ mOverrideDisplayInfo.overscanTop = top;
+ mOverrideDisplayInfo.overscanRight = right;
+ mOverrideDisplayInfo.overscanBottom = bottom;
+ }
+ }
+
/**
* Returns true if the logical display is in a valid state.
* This method should be checked after calling {@link #updateLocked} to handle the
diff --git a/services/java/com/android/server/wm/DisplayContent.java b/services/java/com/android/server/wm/DisplayContent.java
index 89e0f17..cc7c8b0 100644
--- a/services/java/com/android/server/wm/DisplayContent.java
+++ b/services/java/com/android/server/wm/DisplayContent.java
@@ -19,6 +19,9 @@
import static com.android.server.wm.WindowManagerService.FORWARD_ITERATOR;
import static com.android.server.wm.WindowManagerService.REVERSE_ITERATOR;
+import android.graphics.Rect;
+import android.os.Debug;
+import android.util.Slog;
import android.util.SparseArray;
import android.view.Display;
import android.view.DisplayInfo;
@@ -316,6 +319,7 @@
pw.print("x"); pw.print(mDisplayInfo.smallestNominalAppHeight);
pw.print("-"); pw.print(mDisplayInfo.largestNominalAppWidth);
pw.print("x"); pw.println(mDisplayInfo.largestNominalAppHeight);
+ pw.print(subPrefix); pw.print("layoutNeeded="); pw.println(layoutNeeded);
AppTokenIterator iterator = getTmpAppIterator(REVERSE_ITERATOR);
int ndx = iterator.size() - 1;
if (ndx >= 0) {
@@ -360,7 +364,6 @@
pw.println();
}
}
- pw.print(subPrefix); pw.print("layoutNeeded="); pw.println(layoutNeeded);
pw.println();
}
}
diff --git a/services/java/com/android/server/wm/DisplaySettings.java b/services/java/com/android/server/wm/DisplaySettings.java
new file mode 100644
index 0000000..34d1a64
--- /dev/null
+++ b/services/java/com/android/server/wm/DisplaySettings.java
@@ -0,0 +1,224 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server.wm;
+
+import android.content.Context;
+import android.graphics.Rect;
+import android.os.Environment;
+import android.util.AtomicFile;
+import android.util.Slog;
+import android.util.Xml;
+import com.android.internal.util.FastXmlSerializer;
+import com.android.internal.util.XmlUtils;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlSerializer;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.HashMap;
+
+/**
+ * Current persistent settings about a display
+ */
+public class DisplaySettings {
+ private static final String TAG = WindowManagerService.TAG;
+
+ private final Context mContext;
+ private final AtomicFile mFile;
+ private final HashMap<String, Entry> mEntries = new HashMap<String, Entry>();
+
+ public static class Entry {
+ public final String name;
+ public int overscanLeft;
+ public int overscanTop;
+ public int overscanRight;
+ public int overscanBottom;
+
+ public Entry(String _name) {
+ name = _name;
+ }
+ }
+
+ public DisplaySettings(Context context) {
+ mContext = context;
+ File dataDir = Environment.getDataDirectory();
+ File systemDir = new File(dataDir, "system");
+ mFile = new AtomicFile(new File(systemDir, "display_settings.xml"));
+ }
+
+ public void getOverscanLocked(String name, Rect outRect) {
+ Entry entry = mEntries.get(name);
+ if (entry != null) {
+ outRect.left = entry.overscanLeft;
+ outRect.top = entry.overscanTop;
+ outRect.right = entry.overscanRight;
+ outRect.bottom = entry.overscanBottom;
+ } else {
+ outRect.set(0, 0, 0, 0);
+ }
+ }
+
+ public void setOverscanLocked(String name, int left, int top, int right, int bottom) {
+ if (left == 0 && top == 0 && right == 0 && bottom == 0) {
+ // Right now all we are storing is overscan; if there is no overscan,
+ // we have no need for the entry.
+ mEntries.remove(name);
+ return;
+ }
+ Entry entry = mEntries.get(name);
+ if (entry == null) {
+ entry = new Entry(name);
+ mEntries.put(name, entry);
+ }
+ entry.overscanLeft = left;
+ entry.overscanTop = top;
+ entry.overscanRight = right;
+ entry.overscanBottom = bottom;
+ }
+
+ public void readSettingsLocked() {
+ FileInputStream stream;
+ try {
+ stream = mFile.openRead();
+ } catch (FileNotFoundException e) {
+ Slog.i(TAG, "No existing display settings " + mFile.getBaseFile()
+ + "; starting empty");
+ return;
+ }
+ boolean success = false;
+ try {
+ XmlPullParser parser = Xml.newPullParser();
+ parser.setInput(stream, null);
+ int type;
+ while ((type = parser.next()) != XmlPullParser.START_TAG
+ && type != XmlPullParser.END_DOCUMENT) {
+ ;
+ }
+
+ if (type != XmlPullParser.START_TAG) {
+ throw new IllegalStateException("no start tag found");
+ }
+
+ int outerDepth = parser.getDepth();
+ while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
+ && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
+ if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
+ continue;
+ }
+
+ String tagName = parser.getName();
+ if (tagName.equals("display")) {
+ readDisplay(parser);
+ } else {
+ Slog.w(TAG, "Unknown element under <display-settings>: "
+ + parser.getName());
+ XmlUtils.skipCurrentTag(parser);
+ }
+ }
+ success = true;
+ } catch (IllegalStateException e) {
+ Slog.w(TAG, "Failed parsing " + e);
+ } catch (NullPointerException e) {
+ Slog.w(TAG, "Failed parsing " + e);
+ } catch (NumberFormatException e) {
+ Slog.w(TAG, "Failed parsing " + e);
+ } catch (XmlPullParserException e) {
+ Slog.w(TAG, "Failed parsing " + e);
+ } catch (IOException e) {
+ Slog.w(TAG, "Failed parsing " + e);
+ } catch (IndexOutOfBoundsException e) {
+ Slog.w(TAG, "Failed parsing " + e);
+ } finally {
+ if (!success) {
+ mEntries.clear();
+ }
+ try {
+ stream.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+
+ private int getIntAttribute(XmlPullParser parser, String name) {
+ try {
+ String str = parser.getAttributeValue(null, name);
+ return str != null ? Integer.parseInt(str) : 0;
+ } catch (NumberFormatException e) {
+ return 0;
+ }
+ }
+
+ private void readDisplay(XmlPullParser parser) throws NumberFormatException,
+ XmlPullParserException, IOException {
+ String name = parser.getAttributeValue(null, "name");
+ if (name != null) {
+ Entry entry = new Entry(name);
+ entry.overscanLeft = getIntAttribute(parser, "overscanLeft");
+ entry.overscanTop = getIntAttribute(parser, "overscanTop");
+ entry.overscanRight = getIntAttribute(parser, "overscanRight");
+ entry.overscanBottom = getIntAttribute(parser, "overscanBottom");
+ mEntries.put(name, entry);
+ }
+ XmlUtils.skipCurrentTag(parser);
+ }
+
+ public void writeSettingsLocked() {
+ FileOutputStream stream;
+ try {
+ stream = mFile.startWrite();
+ } catch (IOException e) {
+ Slog.w(TAG, "Failed to write display settings: " + e);
+ return;
+ }
+
+ try {
+ XmlSerializer out = new FastXmlSerializer();
+ out.setOutput(stream, "utf-8");
+ out.startDocument(null, true);
+ out.startTag(null, "display-settings");
+
+ for (Entry entry : mEntries.values()) {
+ out.startTag(null, "display");
+ out.attribute(null, "name", entry.name);
+ if (entry.overscanLeft != 0) {
+ out.attribute(null, "overscanLeft", Integer.toString(entry.overscanLeft));
+ }
+ if (entry.overscanTop != 0) {
+ out.attribute(null, "overscanTop", Integer.toString(entry.overscanTop));
+ }
+ if (entry.overscanRight != 0) {
+ out.attribute(null, "overscanRight", Integer.toString(entry.overscanRight));
+ }
+ if (entry.overscanBottom != 0) {
+ out.attribute(null, "overscanBottom", Integer.toString(entry.overscanBottom));
+ }
+ out.endTag(null, "display");
+ }
+
+ out.endTag(null, "display-settings");
+ out.endDocument();
+ mFile.finishWrite(stream);
+ } catch (IOException e) {
+ Slog.w(TAG, "Failed to write display settings, restoring backup.", e);
+ mFile.failWrite(stream);
+ }
+ }
+}
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index d38273d..b7637b9 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -320,6 +320,8 @@
final AppOpsManager mAppOps;
+ final DisplaySettings mDisplaySettings;
+
/**
* All currently active sessions with clients.
*/
@@ -731,6 +733,8 @@
com.android.internal.R.bool.config_sf_limitedAlpha);
mDisplayManagerService = displayManager;
mHeadless = displayManager.isHeadless();
+ mDisplaySettings = new DisplaySettings(context);
+ mDisplaySettings.readSettingsLocked();
mDisplayManager = (DisplayManager)context.getSystemService(Context.DISPLAY_SERVICE);
mDisplayManager.registerDisplayListener(this, null);
@@ -7089,6 +7093,15 @@
@Override
public void setForcedDisplaySize(int displayId, int width, int height) {
+ if (mContext.checkCallingOrSelfPermission(
+ android.Manifest.permission.WRITE_SECURE_SETTINGS) !=
+ PackageManager.PERMISSION_GRANTED) {
+ throw new SecurityException("Must hold permission " +
+ android.Manifest.permission.WRITE_SECURE_SETTINGS);
+ }
+ if (displayId != Display.DEFAULT_DISPLAY) {
+ throw new IllegalArgumentException("Can only set the default display");
+ }
synchronized(mWindowMap) {
// Set some sort of reasonable bounds on the size of the display that we
// will try to emulate.
@@ -7160,6 +7173,15 @@
@Override
public void clearForcedDisplaySize(int displayId) {
+ if (mContext.checkCallingOrSelfPermission(
+ android.Manifest.permission.WRITE_SECURE_SETTINGS) !=
+ PackageManager.PERMISSION_GRANTED) {
+ throw new SecurityException("Must hold permission " +
+ android.Manifest.permission.WRITE_SECURE_SETTINGS);
+ }
+ if (displayId != Display.DEFAULT_DISPLAY) {
+ throw new IllegalArgumentException("Can only set the default display");
+ }
synchronized(mWindowMap) {
final DisplayContent displayContent = getDisplayContentLocked(displayId);
if (displayContent != null) {
@@ -7173,6 +7195,15 @@
@Override
public void setForcedDisplayDensity(int displayId, int density) {
+ if (mContext.checkCallingOrSelfPermission(
+ android.Manifest.permission.WRITE_SECURE_SETTINGS) !=
+ PackageManager.PERMISSION_GRANTED) {
+ throw new SecurityException("Must hold permission " +
+ android.Manifest.permission.WRITE_SECURE_SETTINGS);
+ }
+ if (displayId != Display.DEFAULT_DISPLAY) {
+ throw new IllegalArgumentException("Can only set the default display");
+ }
synchronized(mWindowMap) {
final DisplayContent displayContent = getDisplayContentLocked(displayId);
if (displayContent != null) {
@@ -7195,6 +7226,15 @@
@Override
public void clearForcedDisplayDensity(int displayId) {
+ if (mContext.checkCallingOrSelfPermission(
+ android.Manifest.permission.WRITE_SECURE_SETTINGS) !=
+ PackageManager.PERMISSION_GRANTED) {
+ throw new SecurityException("Must hold permission " +
+ android.Manifest.permission.WRITE_SECURE_SETTINGS);
+ }
+ if (displayId != Display.DEFAULT_DISPLAY) {
+ throw new IllegalArgumentException("Can only set the default display");
+ }
synchronized(mWindowMap) {
final DisplayContent displayContent = getDisplayContentLocked(displayId);
if (displayContent != null) {
@@ -7233,6 +7273,33 @@
performLayoutAndPlaceSurfacesLocked();
}
+ public void setOverscan(int displayId, int left, int top, int right, int bottom) {
+ if (mContext.checkCallingOrSelfPermission(
+ android.Manifest.permission.WRITE_SECURE_SETTINGS) !=
+ PackageManager.PERMISSION_GRANTED) {
+ throw new SecurityException("Must hold permission " +
+ android.Manifest.permission.WRITE_SECURE_SETTINGS);
+ }
+ synchronized(mWindowMap) {
+ DisplayContent displayContent = getDisplayContentLocked(displayId);
+ if (displayContent != null) {
+ mDisplayManagerService.setOverscan(displayId, left, top, right, bottom);
+ final DisplayInfo displayInfo = displayContent.getDisplayInfo();
+ synchronized(displayContent.mDisplaySizeLock) {
+ displayInfo.overscanLeft = left;
+ displayInfo.overscanTop = top;
+ displayInfo.overscanRight = right;
+ displayInfo.overscanBottom = bottom;
+ }
+ mPolicy.setDisplayOverscan(displayContent.getDisplay(), left, top, right, bottom);
+ displayContent.layoutNeeded = true;
+ mDisplaySettings.setOverscanLocked(displayInfo.name, left, top, right, bottom);
+ mDisplaySettings.writeSettingsLocked();
+ performLayoutAndPlaceSurfacesLocked();
+ }
+ }
+ }
+
@Override
public boolean hasSystemNavBar() {
return mPolicy.hasSystemNavBar();
@@ -9694,7 +9761,7 @@
if (dumpAll) {
pw.print(" mSystemDecorRect="); pw.print(mSystemDecorRect.toShortString());
pw.print(" mSystemDecorLayer="); pw.print(mSystemDecorLayer);
- pw.print(" mScreenRecr="); pw.println(mScreenRect.toShortString());
+ pw.print(" mScreenRect="); pw.println(mScreenRect.toShortString());
if (mLastStatusBarVisibility != 0) {
pw.print(" mLastStatusBarVisibility=0x");
pw.println(Integer.toHexString(mLastStatusBarVisibility));
@@ -9973,12 +10040,28 @@
}
}
+ private DisplayContent newDisplayContentLocked(final Display display) {
+ DisplayContent displayContent = new DisplayContent(display);
+ mDisplayContents.put(display.getDisplayId(), displayContent);
+ final Rect rect = new Rect();
+ DisplayInfo info = displayContent.getDisplayInfo();
+ mDisplaySettings.getOverscanLocked(info.name, rect);
+ info.overscanLeft = rect.left;
+ info.overscanTop = rect.top;
+ info.overscanRight = rect.right;
+ info.overscanBottom = rect.bottom;
+ mDisplayManagerService.setOverscan(display.getDisplayId(), rect.left, rect.top,
+ rect.right, rect.bottom);
+ mPolicy.setDisplayOverscan(displayContent.getDisplay(), rect.left, rect.top,
+ rect.right, rect.bottom);
+ return displayContent;
+ }
+
public void createDisplayContentLocked(final Display display) {
if (display == null) {
throw new IllegalArgumentException("getDisplayContent: display must not be null");
}
- final DisplayContent displayContent = new DisplayContent(display);
- mDisplayContents.put(display.getDisplayId(), displayContent);
+ newDisplayContentLocked(display);
}
/**
@@ -9992,8 +10075,7 @@
if (displayContent == null) {
final Display display = mDisplayManager.getDisplay(displayId);
if (display != null) {
- displayContent = new DisplayContent(display);
- mDisplayContents.put(displayId, displayContent);
+ displayContent = newDisplayContentLocked(display);
}
}
return displayContent;
diff --git a/services/tests/servicestests/Android.mk b/services/tests/servicestests/Android.mk
index 81a2c14..4ff3899 100644
--- a/services/tests/servicestests/Android.mk
+++ b/services/tests/servicestests/Android.mk
@@ -10,7 +10,7 @@
LOCAL_STATIC_JAVA_LIBRARIES := \
easymocklib \
guava \
- littlemock
+ mockito-target
LOCAL_JAVA_LIBRARIES := android.test.runner services
diff --git a/services/tests/servicestests/src/com/android/server/BroadcastInterceptingContext.java b/services/tests/servicestests/src/com/android/server/BroadcastInterceptingContext.java
index f14569c..ffd1568 100644
--- a/services/tests/servicestests/src/com/android/server/BroadcastInterceptingContext.java
+++ b/services/tests/servicestests/src/com/android/server/BroadcastInterceptingContext.java
@@ -22,6 +22,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Handler;
+import android.os.UserHandle;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.AbstractFuture;
@@ -133,12 +134,28 @@
}
@Override
+ public void sendBroadcast(Intent intent, String receiverPermission) {
+ sendBroadcast(intent);
+ }
+
+ @Override
+ public void sendBroadcastAsUser(Intent intent, UserHandle user) {
+ sendBroadcast(intent);
+ }
+
+ @Override
+ public void sendBroadcastAsUser(Intent intent, UserHandle user,
+ String receiverPermission) {
+ sendBroadcast(intent);
+ }
+
+ @Override
public void sendStickyBroadcast(Intent intent) {
sendBroadcast(intent);
}
@Override
- public void sendBroadcast(Intent intent, String receiverPermission) {
+ public void sendStickyBroadcastAsUser(Intent intent, UserHandle user) {
sendBroadcast(intent);
}
diff --git a/services/tests/servicestests/src/com/android/server/ConnectivityServiceTest.java b/services/tests/servicestests/src/com/android/server/ConnectivityServiceTest.java
index 93ea6a2..4ae013b 100644
--- a/services/tests/servicestests/src/com/android/server/ConnectivityServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/ConnectivityServiceTest.java
@@ -21,16 +21,15 @@
import static android.net.ConnectivityManager.TYPE_WIFI;
import static android.net.ConnectivityManager.getNetworkTypeName;
import static android.net.NetworkStateTracker.EVENT_STATE_CHANGED;
-import static com.google.testing.littlemock.LittleMock.anyInt;
-import static com.google.testing.littlemock.LittleMock.createCaptor;
-import static com.google.testing.littlemock.LittleMock.doNothing;
-import static com.google.testing.littlemock.LittleMock.doReturn;
-import static com.google.testing.littlemock.LittleMock.doThrow;
-import static com.google.testing.littlemock.LittleMock.eq;
-import static com.google.testing.littlemock.LittleMock.isA;
-import static com.google.testing.littlemock.LittleMock.mock;
-import static com.google.testing.littlemock.LittleMock.reset;
-import static com.google.testing.littlemock.LittleMock.verify;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Matchers.isA;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.verify;
import android.content.Context;
import android.net.INetworkPolicyManager;
@@ -48,7 +47,7 @@
import android.util.Log;
import android.util.LogPrinter;
-import com.google.testing.littlemock.ArgumentCaptor;
+import org.mockito.ArgumentCaptor;
import java.net.InetAddress;
import java.util.concurrent.Future;
@@ -128,7 +127,7 @@
doReturn(mWifi.tracker)
.when(mNetFactory).createTracker(eq(TYPE_WIFI), isA(NetworkConfig.class));
- final ArgumentCaptor<Handler> trackerHandler = createCaptor();
+ final ArgumentCaptor<Handler> trackerHandler = ArgumentCaptor.forClass(Handler.class);
doNothing().when(mMobile.tracker)
.startMonitoring(isA(Context.class), trackerHandler.capture());
diff --git a/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java b/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java
index ed44b04..278413e 100644
--- a/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java
+++ b/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java
@@ -110,6 +110,12 @@
}
@Override
+ public void setOverscan(int displayId, int left, int top, int right, int bottom)
+ throws RemoteException {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
public void closeSystemDialogs(String arg0) throws RemoteException {
// TODO Auto-generated method stub